diff --git a/TODO.md b/TODO.md index 2c294c4..d078b07 100644 --- a/TODO.md +++ b/TODO.md @@ -32,6 +32,15 @@ - [x] Add `hx-target` response divs to the three fieldsets in contenus.php - [x] Update settings.php to return HTML toast on HTMX requests +## JS Refactoring — Extract inline scripts into app/ files + +- [x] Remove overtype-webcomponent.min.js (unused) +- [x] Extract copyLogContent + fallbackCopy + tab-updater → app/admin-logs.js +- [x] Extract copyUrl → app/clipboard.js +- [x] Extract tag-search inline script → app/pill-search.js (generalized for tag + language) +- [x] Extract tfe.php access-request form → app/access-request.js +- [x] Update all templates to use new external JS files + ## Production Error Fixes (2026-05-11 remote logs) - [x] **413 Request Entity Too Large** — bumped `client_max_body_size` to 256M, PHP post/upload to 256M, timeouts to 300s diff --git a/app/public/admin/acces.php b/app/public/admin/acces.php index 2f1c645..8a457bc 100644 --- a/app/public/admin/acces.php +++ b/app/public/admin/acces.php @@ -29,6 +29,7 @@ extract($vars); $pageTitle = 'Accès'; $isAdmin = true; $bodyClass = 'admin-body'; +$extraJs = ['/assets/js/app/clipboard.js']; require_once APP_ROOT . '/templates/head.php'; echo ''; diff --git a/app/public/admin/add.php b/app/public/admin/add.php index 59f86d0..081f565 100644 --- a/app/public/admin/add.php +++ b/app/public/admin/add.php @@ -55,7 +55,7 @@ function wasSelected($key, $value) { $isAdmin = true; $bodyClass = 'admin-body'; $extraCss = ['/assets/css/form.css', '/assets/css/filepond.min.css', '/assets/css/filepond-plugin-image-preview.min.css']; -$extraJs = ['/assets/js/filepond.min.js', '/assets/js/filepond-plugin-file-validate-type.min.js', '/assets/js/filepond-plugin-file-validate-size.min.js', '/assets/js/filepond-plugin-image-preview.min.js', '/assets/js/filepond-plugin-image-exif-orientation.min.js', '/assets/js/file-upload-filepond.js', '/assets/js/beforeunload-guard.js', '/assets/js/upload-progress.js']; +$extraJs = ['/assets/js/vendor/filepond.min.js', '/assets/js/vendor/filepond-plugin-file-validate-type.min.js', '/assets/js/vendor/filepond-plugin-file-validate-size.min.js', '/assets/js/vendor/filepond-plugin-image-preview.min.js', '/assets/js/vendor/filepond-plugin-image-exif-orientation.min.js', '/assets/js/app/file-upload-filepond.js', '/assets/js/app/beforeunload-guard.js', '/assets/js/app/upload-progress.js', '/assets/js/app/pill-search.js']; require_once APP_ROOT . '/templates/head.php'; include APP_ROOT . '/templates/header.php'; include APP_ROOT . '/templates/admin/add.php'; diff --git a/app/public/admin/contenus-edit.php b/app/public/admin/contenus-edit.php index c59635c..f980b2b 100644 --- a/app/public/admin/contenus-edit.php +++ b/app/public/admin/contenus-edit.php @@ -70,7 +70,7 @@ $extraJsInline = ''; if ($editType === 'page' || $editType === 'about_page') { $initialContent = $page["content"] ?? ""; - $extraJs = ["/assets/js/overtype.min.js"]; + $extraJs = ["/assets/js/vendor/overtype.min.js"]; $extraJsInline = <<<'JS' var OT = window.OverType.default || window.OverType; var hidden = document.getElementById('content'); @@ -83,7 +83,7 @@ var editor = new OT(document.getElementById('editor'), { JS; } elseif ($editType === 'form_help') { $initialContent = $formHelpContent; - $extraJs = ["/assets/js/overtype.min.js"]; + $extraJs = ["/assets/js/vendor/overtype.min.js"]; $extraJsInline = <<<'JS' var OT = window.OverType.default || window.OverType; var hidden = document.getElementById('content'); diff --git a/app/public/admin/edit.php b/app/public/admin/edit.php index 52d9313..523ffa6 100644 --- a/app/public/admin/edit.php +++ b/app/public/admin/edit.php @@ -40,7 +40,7 @@ try { $isAdmin = true; $bodyClass = 'admin-body'; $extraCss = ['/assets/css/form.css', '/assets/css/filepond.min.css', '/assets/css/filepond-plugin-image-preview.min.css']; -$extraJs = ['/assets/js/filepond.min.js', '/assets/js/filepond-plugin-file-validate-type.min.js', '/assets/js/filepond-plugin-file-validate-size.min.js', '/assets/js/filepond-plugin-image-preview.min.js', '/assets/js/filepond-plugin-image-exif-orientation.min.js', '/assets/js/file-upload-filepond.js', '/assets/js/beforeunload-guard.js', '/assets/js/upload-progress.js']; +$extraJs = ['/assets/js/vendor/filepond.min.js', '/assets/js/vendor/filepond-plugin-file-validate-type.min.js', '/assets/js/vendor/filepond-plugin-file-validate-size.min.js', '/assets/js/vendor/filepond-plugin-image-preview.min.js', '/assets/js/vendor/filepond-plugin-image-exif-orientation.min.js', '/assets/js/app/file-upload-filepond.js', '/assets/js/app/beforeunload-guard.js', '/assets/js/app/upload-progress.js', '/assets/js/app/pill-search.js']; require_once APP_ROOT . '/templates/head.php'; include APP_ROOT . '/templates/header.php'; include APP_ROOT . '/templates/admin/edit.php'; diff --git a/app/public/assets/js/app/access-request.js b/app/public/assets/js/app/access-request.js new file mode 100644 index 0000000..471f0f3 --- /dev/null +++ b/app/public/assets/js/app/access-request.js @@ -0,0 +1,97 @@ +/** + * access-request.js — handles the "Demander l'accès" form on public thesis pages. + * + * Shows/hides the justification textarea based on email domain (@erg.school / @erg.be). + * Submits via fetch() to /request-access and displays success/error messages. + * Handles the special "recipient_rejected" status to let the user fix their email. + * + * Expects a form with: + * #access-request-form — the form (needs data-thesis-id) + * #access-email — email input + * #justification-container — wrapper div for justification + * #access-justification — justification textarea + * #access-request-message — message display div + */ +(function () { + 'use strict'; + + var form = document.getElementById('access-request-form'); + if (!form) return; + + var emailInput = document.getElementById('access-email'); + var justificationContainer = document.getElementById('justification-container'); + var justificationInput = document.getElementById('access-justification'); + var messageDiv = document.getElementById('access-request-message'); + + if (!emailInput || !messageDiv) return; + + // Show/hide justification based on email domain + emailInput.addEventListener('input', function () { + var email = this.value.trim().toLowerCase(); + var isErg = email.endsWith('@erg.school') || email.endsWith('@erg.be'); + if (justificationContainer) justificationContainer.style.display = isErg ? 'none' : 'block'; + if (justificationInput) justificationInput.required = !isErg; + }); + + function showRetryPrompt(rejectedEmail, serverMessage) { + messageDiv.style.display = 'block'; + messageDiv.className = 'tfe-access-message tfe-access-error'; + messageDiv.innerHTML = + 'Adresse e-mail introuvable sur le serveur de l\'ERG.
' + + '' + serverMessage.replace(/

' + + 'Corrigez votre adresse e-mail et réessayez.'; + emailInput.value = rejectedEmail; + emailInput.classList.add('input-error'); + emailInput.focus(); + emailInput.select(); + emailInput.addEventListener('input', function clearError() { + emailInput.classList.remove('input-error'); + emailInput.removeEventListener('input', clearError); + }); + } + + form.addEventListener('submit', function (e) { + e.preventDefault(); + + var submitBtn = form.querySelector('button[type="submit"]'); + submitBtn.disabled = true; + submitBtn.textContent = 'Envoi en cours...'; + messageDiv.style.display = 'none'; + + var submittedEmail = emailInput.value.trim(); + var formData = new FormData(form); + formData.append('thesis_id', form.getAttribute('data-thesis-id')); + + fetch('/request-access', { + method: 'POST', + body: formData + }) + .then(function (response) { return response.json(); }) + .then(function (data) { + submitBtn.disabled = false; + submitBtn.textContent = 'Demander l\'accès'; + + if (data.status === 'recipient_rejected') { + showRetryPrompt(submittedEmail, data.message); + return; + } + + messageDiv.style.display = 'block'; + if (data.success) { + messageDiv.className = 'tfe-access-message tfe-access-success'; + messageDiv.textContent = data.message; + form.reset(); + } else { + messageDiv.className = 'tfe-access-message tfe-access-error'; + messageDiv.textContent = data.message || 'Une erreur est survenue. Veuillez réessayer.'; + } + }) + .catch(function () { + submitBtn.disabled = false; + submitBtn.textContent = 'Demander l\'accès'; + messageDiv.style.display = 'block'; + messageDiv.className = 'tfe-access-message tfe-access-error'; + messageDiv.textContent = 'Erreur de connexion. Veuillez réessayer.'; + }); + }); +})(); diff --git a/app/public/assets/js/app/admin-logs.js b/app/public/assets/js/app/admin-logs.js new file mode 100644 index 0000000..1c84231 --- /dev/null +++ b/app/public/assets/js/app/admin-logs.js @@ -0,0 +1,64 @@ +/** + * admin-logs.js — log viewer utilities shared by system.php and parametres.php. + * + * Provides: + * - copyLogContent(btn) — copy visible log lines to clipboard + * - HTMX afterSwap handler to update active tab class on #sys-tab-panel + */ +(function () { + 'use strict'; + + window.copyLogContent = function (btn) { + var logOut = document.querySelector('#log-output'); + if (!logOut) return; + var text = Array.from(logOut.querySelectorAll('.log-line')) + .map(function (el) { return el.textContent; }).join('\n'); + if (navigator.clipboard && navigator.clipboard.writeText) { + navigator.clipboard.writeText(text).then(function () { + btn.textContent = '\u2713 Copi\u00e9'; + btn.classList.add('copied'); + setTimeout(function () { btn.textContent = 'Copier'; btn.classList.remove('copied'); }, 2000); + }); + } else { + window._fallbackCopy(text, btn); + } + }; + + window._fallbackCopy = function (text, btn) { + var ta = document.createElement('textarea'); + ta.value = text; + ta.style.cssText = 'position:fixed;opacity:0'; + document.body.appendChild(ta); + ta.select(); + try { + document.execCommand('copy'); + btn.textContent = '\u2713 Copi\u00e9'; + btn.classList.add('copied'); + setTimeout(function () { btn.textContent = 'Copier'; btn.classList.remove('copied'); }, 2000); + } catch (e) {} + document.body.removeChild(ta); + }; + + // Update active tab class after each HTMX swap on #sys-tab-panel + document.body.addEventListener('htmx:afterSwap', function (evt) { + if (!(evt.detail.target && evt.detail.target.id === 'sys-tab-panel')) return; + var rc = evt.detail.requestConfig; + var tab = null; + // Tab clicks carry ?tab=… in the path + var qIdx = rc.path.indexOf('?'); + if (qIdx !== -1) { + tab = new URLSearchParams(rc.path.substring(qIdx + 1)).get('tab'); + } + // Line-count form sends tab via hx-vals in parameters + if (!tab && rc.parameters && rc.parameters.tab) { + tab = rc.parameters.tab; + } + if (!tab) return; + document.querySelectorAll('.sys-tabs .sys-tab').forEach(function (a) { + var isActive = a.getAttribute('data-tab') === tab; + a.classList.toggle('active', isActive); + if (isActive) a.setAttribute('aria-current', 'page'); + else a.removeAttribute('aria-current'); + }); + }); +})(); diff --git a/app/public/assets/js/beforeunload-guard.js b/app/public/assets/js/app/beforeunload-guard.js similarity index 100% rename from app/public/assets/js/beforeunload-guard.js rename to app/public/assets/js/app/beforeunload-guard.js diff --git a/app/public/assets/js/app/clipboard.js b/app/public/assets/js/app/clipboard.js new file mode 100644 index 0000000..27a9101 --- /dev/null +++ b/app/public/assets/js/app/clipboard.js @@ -0,0 +1,38 @@ +/** + * clipboard.js — lightweight URL copy helper. + * + * Usage: + * + * + * + * Or with a custom selector pattern: + * + */ +(function () { + 'use strict'; + + window.copyUrl = function (id) { + var input = document.getElementById('url-' + id); + if (input) { + window.copyUrlFrom(input); + } + }; + + window.copyUrlFrom = function (sourceEl) { + var text = sourceEl.value || sourceEl.textContent || ''; + if (!text) return; + navigator.clipboard.writeText(text).then(function () { + var btn = window.event && window.event.target ? window.event.target.closest('button') : null; + if (btn) { + var origTitle = btn.getAttribute('title') || ''; + var origText = btn.textContent; + btn.setAttribute('title', '\u2713 Copi\u00e9'); + btn.textContent = '\u2713 Copi\u00e9'; + setTimeout(function () { + btn.setAttribute('title', origTitle); + btn.textContent = origText; + }, 1200); + } + }); + }; +})(); diff --git a/app/public/assets/js/file-upload-filepond.js b/app/public/assets/js/app/file-upload-filepond.js similarity index 100% rename from app/public/assets/js/file-upload-filepond.js rename to app/public/assets/js/app/file-upload-filepond.js diff --git a/app/public/assets/js/app/pill-search.js b/app/public/assets/js/app/pill-search.js new file mode 100644 index 0000000..a116487 --- /dev/null +++ b/app/public/assets/js/app/pill-search.js @@ -0,0 +1,171 @@ +/** + * pill-search.js — generalized pill-based search component for tags and languages. + * + * Initialisez avec un conteneur ayant l'attribut data-pill-search : + *
+ * + * DOM attendu à l'intérieur du conteneur : + * - .tag-search-pills → conteneur des pills + * - .tag-search-input → champ de recherche (avec hx-post, hx-trigger, etc.) + * - .tag-search-suggestions → dropdown + * - .tag-search-count → compteur + * - .tag-search-counter → wrapper du compteur + * - .tag-search-input-wrap → wrapper du champ de recherche + * - .tag-search-max-msg → message "maximum atteint" + * + * Options (par attribut data) : + * data-pill-name → nom pour les inputs cachés (ex: "tag", "language_autre") + * data-pill-max → max pills (default 10) + * data-pill-min → min pills requis (default 0) + * data-pill-required → si "1", active l'affichage du minimum + * data-pill-role → "tag" (lowercase) ou "lang" (ucfirst) + */ +(function () { + 'use strict'; + + function initAll() { + document.querySelectorAll('[data-pill-search]:not([data-pill-search-initialized])').forEach(function (container) { + container.setAttribute('data-pill-search-initialized', '1'); + initPillSearch(container); + }); + } + + document.addEventListener('DOMContentLoaded', initAll); + document.body.addEventListener('htmx:afterSwap', initAll); + + function initPillSearch(container) { + var pills = container.querySelector('.tag-search-pills'); + var search = container.querySelector('.tag-search-input'); + var dropdown = container.querySelector('.tag-search-suggestions'); + var countEl = container.querySelector('.tag-search-count'); + var counter = container.querySelector('.tag-search-counter'); + var maxTags = parseInt(container.getAttribute('data-pill-max')) || 10; + var minTags = parseInt(container.getAttribute('data-pill-min')) || 0; + var required = container.getAttribute('data-pill-required') === '1'; + var inputName = container.getAttribute('data-pill-name') || 'tag'; + var role = container.getAttribute('data-pill-role') || 'tag'; + var selectedIdx = -1; + + if (!pills || !search || !dropdown) return; + + function normalize(name) { + return name.trim().replace(/\s+/g, ' ').toLowerCase(); + } + + function pillAlreadyExists(name) { + var norm = normalize(name); + var existing = pills.querySelectorAll('.tag-pill-name'); + for (var i = 0; i < existing.length; i++) { + if (normalize(existing[i].textContent) === norm) return true; + } + return false; + } + + function updateCount() { + var n = pills.querySelectorAll('.tag-pill').length; + var suffix = required ? ' (min ' + minTags + ')' : ''; + if (countEl) countEl.textContent = n + '/' + maxTags + suffix; + if (counter) counter.style.display = (n > 0 || required) ? '' : 'none'; + if (countEl && required) { + countEl.style.color = n < minTags ? 'var(--text-danger)' : 'var(--accent)'; + } + + var wrap = container.querySelector('.tag-search-input-wrap'); + var maxMsg = container.querySelector('.tag-search-max-msg'); + if (n >= maxTags) { + if (wrap) wrap.style.display = 'none'; + if (maxMsg) maxMsg.style.display = ''; + } else { + if (wrap) { wrap.style.display = ''; if (search) search.style.display = ''; } + if (maxMsg) maxMsg.style.display = 'none'; + } + } + + pills.addEventListener('click', function (e) { + var btn = e.target.closest('.tag-pill-remove'); + if (!btn) return; + var pill = btn.closest('.tag-pill'); + pill.remove(); + updateCount(); + var wrap = container.querySelector('.tag-search-input-wrap'); + var inp = container.querySelector('.tag-search-input'); + if (wrap && inp) { wrap.style.display = ''; inp.style.display = ''; } + }); + + function highlight(idx) { + var items = dropdown.querySelectorAll('.tag-search-item'); + for (var i = 0; i < items.length; i++) { + items[i].classList.toggle('tag-search-item--highlight', i === idx); + } + } + + function selectPill(btn) { + var name = normalize(btn.getAttribute('data-tag-name') || ''); + if (!name) return; + if (pillAlreadyExists(name)) return; + if ((pills.querySelectorAll('.tag-pill').length) >= maxTags) return; + + var escaped = htmlEscape(name); + var pill = document.createElement('span'); + pill.className = 'tag-pill'; + pill.innerHTML = '' + + '' + escaped + '' + + ''; + pills.appendChild(pill); + updateCount(); + search.value = ''; + dropdown.innerHTML = ''; + selectedIdx = -1; + search.focus(); + } + + dropdown.addEventListener('click', function (e) { + var btn = e.target.closest('.tag-search-item'); + if (!btn) return; + selectPill(btn); + }); + + search.addEventListener('keydown', function (e) { + var items = dropdown.querySelectorAll('.tag-search-item'); + if (e.key === 'ArrowDown' || e.key === 'ArrowUp') { + e.preventDefault(); + if (items.length === 0) return; + if (e.key === 'ArrowDown') { + selectedIdx = (selectedIdx + 1) % items.length; + } else { + selectedIdx = selectedIdx <= 0 ? items.length - 1 : selectedIdx - 1; + } + highlight(selectedIdx); + } else if (e.key === 'Enter') { + if (items.length > 0) { + e.preventDefault(); + if (selectedIdx >= 0 && selectedIdx < items.length) { + selectPill(items[selectedIdx]); + } else { + selectPill(items[0]); + } + } + } else if (e.key === 'Escape') { + dropdown.innerHTML = ''; + selectedIdx = -1; + } + }); + + search.addEventListener('blur', function () { + setTimeout(function () { + if (!dropdown.contains(document.activeElement)) { + dropdown.innerHTML = ''; + selectedIdx = -1; + } + }, 150); + }); + + function htmlEscape(str) { + var el = document.createElement('span'); + el.textContent = str; + return el.innerHTML; + } + } +})(); diff --git a/app/public/assets/js/upload-progress.js b/app/public/assets/js/app/upload-progress.js similarity index 100% rename from app/public/assets/js/upload-progress.js rename to app/public/assets/js/app/upload-progress.js diff --git a/app/public/assets/js/filepond-plugin-file-validate-size.min.js b/app/public/assets/js/filepond-plugin-file-validate-size.min.js deleted file mode 100644 index 17fcb9d..0000000 --- a/app/public/assets/js/filepond-plugin-file-validate-size.min.js +++ /dev/null @@ -1,9 +0,0 @@ -/*! - * FilePondPluginFileValidateSize 2.2.8 - * Licensed under MIT, https://opensource.org/licenses/MIT/ - * Please visit https://pqina.nl/filepond/ for details. - */ - -/* eslint-disable */ - -!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(e=e||self).FilePondPluginFileValidateSize=i()}(this,function(){"use strict";var e=function(e){var i=e.addFilter,E=e.utils,l=E.Type,_=E.replaceInString,n=E.toNaturalFileSize;return i("ALLOW_HOPPER_ITEM",function(e,i){var E=i.query;if(!E("GET_ALLOW_FILE_SIZE_VALIDATION"))return!0;var l=E("GET_MAX_FILE_SIZE");if(null!==l&&e.size>l)return!1;var _=E("GET_MIN_FILE_SIZE");return!(null!==_&&e.size<_)}),i("LOAD_FILE",function(e,i){var E=i.query;return new Promise(function(i,l){if(!E("GET_ALLOW_FILE_SIZE_VALIDATION"))return i(e);var I=E("GET_FILE_VALIDATE_SIZE_FILTER");if(I&&!I(e))return i(e);var t=E("GET_MAX_FILE_SIZE");if(null!==t&&e.size>t)l({status:{main:E("GET_LABEL_MAX_FILE_SIZE_EXCEEDED"),sub:_(E("GET_LABEL_MAX_FILE_SIZE"),{filesize:n(t,".",E("GET_FILE_SIZE_BASE"),E("GET_FILE_SIZE_LABELS",E))})}});else{var L=E("GET_MIN_FILE_SIZE");if(null!==L&&e.sizea)return void l({status:{main:E("GET_LABEL_MAX_TOTAL_FILE_SIZE_EXCEEDED"),sub:_(E("GET_LABEL_MAX_TOTAL_FILE_SIZE"),{filesize:n(a,".",E("GET_FILE_SIZE_BASE"),E("GET_FILE_SIZE_LABELS",E))})}});i(e)}}})}),{options:{allowFileSizeValidation:[!0,l.BOOLEAN],maxFileSize:[null,l.INT],minFileSize:[null,l.INT],maxTotalFileSize:[null,l.INT],fileValidateSizeFilter:[null,l.FUNCTION],labelMinFileSizeExceeded:["File is too small",l.STRING],labelMinFileSize:["Minimum file size is {filesize}",l.STRING],labelMaxFileSizeExceeded:["File is too large",l.STRING],labelMaxFileSize:["Maximum file size is {filesize}",l.STRING],labelMaxTotalFileSizeExceeded:["Maximum total size exceeded",l.STRING],labelMaxTotalFileSize:["Maximum total file size is {filesize}",l.STRING]}}};return"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:e})),e}); diff --git a/app/public/assets/js/filepond-plugin-file-validate-type.min.js b/app/public/assets/js/filepond-plugin-file-validate-type.min.js deleted file mode 100644 index f2cb360..0000000 --- a/app/public/assets/js/filepond-plugin-file-validate-type.min.js +++ /dev/null @@ -1,9 +0,0 @@ -/*! - * FilePondPluginFileValidateType 1.2.9 - * Licensed under MIT, https://opensource.org/licenses/MIT/ - * Please visit https://pqina.nl/filepond/ for details. - */ - -/* eslint-disable */ - -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).FilePondPluginFileValidateType=t()}(this,function(){"use strict";var e=function(e){var t=e.addFilter,n=e.utils,i=n.Type,T=n.isString,E=n.replaceInString,l=n.guesstimateMimeType,o=n.getExtensionFromFilename,r=n.getFilenameFromURL,u=function(e,t){return e.some(function(e){return/\*$/.test(e)?(n=e,(/^[^/]+/.exec(t)||[]).pop()===n.slice(0,-2)):e===t;var n})},a=function(e,t,n){if(0===t.length)return!0;var i=function(e){var t="";if(T(e)){var n=r(e),i=o(n);i&&(t=l(i))}else t=e.type;return t}(e);return n?new Promise(function(T,E){n(e,i).then(function(e){u(t,e)?T():E()}).catch(E)}):u(t,i)};return t("SET_ATTRIBUTE_TO_OPTION_MAP",function(e){return Object.assign(e,{accept:"acceptedFileTypes"})}),t("ALLOW_HOPPER_ITEM",function(e,t){var n=t.query;return!n("GET_ALLOW_FILE_TYPE_VALIDATION")||a(e,n("GET_ACCEPTED_FILE_TYPES"))}),t("LOAD_FILE",function(e,t){var n=t.query;return new Promise(function(t,i){if(n("GET_ALLOW_FILE_TYPE_VALIDATION")){var T=n("GET_ACCEPTED_FILE_TYPES"),l=n("GET_FILE_VALIDATE_TYPE_DETECT_TYPE"),o=a(e,T,l),r=function(){var e,t=T.map((e=n("GET_FILE_VALIDATE_TYPE_LABEL_EXPECTED_TYPES_MAP"),function(t){return null!==e[t]&&(e[t]||t)})).filter(function(e){return!1!==e}),l=t.filter(function(e,n){return t.indexOf(e)===n});i({status:{main:n("GET_LABEL_FILE_TYPE_NOT_ALLOWED"),sub:E(n("GET_FILE_VALIDATE_TYPE_LABEL_EXPECTED_TYPES"),{allTypes:l.join(", "),allButLastType:l.slice(0,-1).join(", "),lastType:l[l.length-1]})}})};if("boolean"==typeof o)return o?t(e):r();o.then(function(){t(e)}).catch(r)}else t(e)})}),{options:{allowFileTypeValidation:[!0,i.BOOLEAN],acceptedFileTypes:[[],i.ARRAY],labelFileTypeNotAllowed:["File is of invalid type",i.STRING],fileValidateTypeLabelExpectedTypes:["Expects {allButLastType} or {lastType}",i.STRING],fileValidateTypeLabelExpectedTypesMap:[{},i.OBJECT],fileValidateTypeDetectType:[null,i.FUNCTION]}}};return"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:e})),e}); diff --git a/app/public/assets/js/filepond-plugin-image-exif-orientation.min.js b/app/public/assets/js/filepond-plugin-image-exif-orientation.min.js deleted file mode 100644 index 90cc07f..0000000 --- a/app/public/assets/js/filepond-plugin-image-exif-orientation.min.js +++ /dev/null @@ -1,9 +0,0 @@ -/*! - * FilePondPluginImageExifOrientation 1.0.11 - * Licensed under MIT, https://opensource.org/licenses/MIT/ - * Please visit https://pqina.nl/filepond/ for details. - */ - -/* eslint-disable */ - -!function(A,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(A=A||self).FilePondPluginImageExifOrientation=e()}(this,function(){"use strict";var A=65496,e=65505,n=1165519206,t=18761,i=274,r=65280,o=function(A,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return A.getUint16(e,n)},a=function(A,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return A.getUint32(e,n)},u="undefined"!=typeof window&&void 0!==window.document,d=void 0,f=u?new Image:{};f.onload=function(){return d=f.naturalWidth>f.naturalHeight},f.src="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QA6RXhpZgAATU0AKgAAAAgAAwESAAMAAAABAAYAAAEoAAMAAAABAAIAAAITAAMAAAABAAEAAAAAAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wAALCAABAAIBASIA/8QAJgABAAAAAAAAAAAAAAAAAAAAAxABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAAPwBH/9k=";var l=function(u){var f=u.addFilter,l=u.utils,c=l.Type,g=l.isFile;return f("DID_LOAD_ITEM",function(u,f){var l=f.query;return new Promise(function(f,c){var s=u.file;if(!(g(s)&&function(A){return/^image\/jpeg/.test(A.type)}(s)&&l("GET_ALLOW_IMAGE_EXIF_ORIENTATION")&&d))return f(u);(function(u){return new Promise(function(d,f){var l=new FileReader;l.onload=function(u){var f=new DataView(u.target.result);if(o(f,0)===A){for(var l=f.byteLength,c=2;c0&&void 0!==arguments[0]?arguments[0]:0,y:arguments.length>1&&void 0!==arguments[1]?arguments[1]:0}},h=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3?arguments[3]:void 0;return"string"==typeof e?parseFloat(e)*i:"number"==typeof e?e*(r?t[r]:Math.min(t.width,t.height)):void 0},u=function(e){return null!=e},l=function(e,t){return Object.keys(t).forEach(function(i){return e.setAttribute(i,t[i])})},d=function(e,t){var i=document.createElementNS("http://www.w3.org/2000/svg",e);return t&&l(i,t),i},f={contain:"xMidYMid meet",cover:"xMidYMid slice"},p={left:"start",center:"middle",right:"end"},g=function(e){return function(t){return d(e,{id:t.id})}},m={image:function(e){var t=d("image",{id:e.id,"stroke-linecap":"round","stroke-linejoin":"round",opacity:"0"});return t.onload=function(){t.setAttribute("opacity",e.opacity||1)},t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",e.src),t},rect:g("rect"),ellipse:g("ellipse"),text:g("text"),path:g("path"),line:function(e){var t=d("g",{id:e.id,"stroke-linecap":"round","stroke-linejoin":"round"}),i=d("line");t.appendChild(i);var r=d("path");t.appendChild(r);var a=d("path");return t.appendChild(a),t}},y={rect:function(e){return l(e,Object.assign({},e.rect,e.styles))},ellipse:function(e){var t=e.rect.x+.5*e.rect.width,i=e.rect.y+.5*e.rect.height,r=.5*e.rect.width,a=.5*e.rect.height;return l(e,Object.assign({cx:t,cy:i,rx:r,ry:a},e.styles))},image:function(e,t){l(e,Object.assign({},e.rect,e.styles,{preserveAspectRatio:f[t.fit]||"none"}))},text:function(e,t,i,r){var a=h(t.fontSize,i,r),n=t.fontFamily||"sans-serif",o=t.fontWeight||"normal",c=p[t.textAlign]||"start";l(e,Object.assign({},e.rect,e.styles,{"stroke-width":0,"font-weight":o,"font-size":a,"font-family":n,"text-anchor":c})),e.text!==t.text&&(e.text=t.text,e.textContent=t.text.length?t.text:" ")},path:function(e,t,i,r){var a;l(e,Object.assign({},e.styles,{fill:"none",d:(a=t.points.map(function(e){return{x:h(e.x,i,r,"width"),y:h(e.y,i,r,"height")}}),a.map(function(e,t){return"".concat(0===t?"M":"L"," ").concat(e.x," ").concat(e.y)}).join(" "))}))},line:function(e,t,i,r){l(e,Object.assign({},e.rect,e.styles,{fill:"none"}));var a=e.childNodes[0],u=e.childNodes[1],d=e.childNodes[2],f=e.rect,p={x:e.rect.x+e.rect.width,y:e.rect.y+e.rect.height};if(l(a,{x1:f.x,y1:f.y,x2:p.x,y2:p.y}),t.lineDecoration){u.style.display="none",d.style.display="none";var g=function(e){var t=Math.sqrt(e.x*e.x+e.y*e.y);return 0===t?{x:0,y:0}:s(e.x/t,e.y/t)}({x:p.x-f.x,y:p.y-f.y}),m=h(.05,i,r);if(-1!==t.lineDecoration.indexOf("arrow-begin")){var y=n(g,m),E=o(f,y),v=c(f,2,E),w=c(f,-2,E);l(u,{style:"display:block;",d:"M".concat(v.x,",").concat(v.y," L").concat(f.x,",").concat(f.y," L").concat(w.x,",").concat(w.y)})}if(-1!==t.lineDecoration.indexOf("arrow-end")){var _=n(g,-m),I=o(p,_),M=c(p,2,I),x=c(p,-2,I);l(d,{style:"display:block;",d:"M".concat(M.x,",").concat(M.y," L").concat(p.x,",").concat(p.y," L").concat(x.x,",").concat(x.y)})}}}},E=function(e,t,i,r,a){"path"!==t&&(e.rect=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=h(e.x,t,i,"width")||h(e.left,t,i,"width"),a=h(e.y,t,i,"height")||h(e.top,t,i,"height"),n=h(e.width,t,i,"width"),o=h(e.height,t,i,"height"),c=h(e.right,t,i,"width"),s=h(e.bottom,t,i,"height");return u(a)||(a=u(o)&&u(s)?t.height-o-s:s),u(r)||(r=u(n)&&u(c)?t.width-n-c:c),u(n)||(n=u(r)&&u(c)?t.width-r-c:0),u(o)||(o=u(a)&&u(s)?t.height-a-s:0),{x:r||0,y:a||0,width:n||0,height:o||0}}(i,r,a)),e.styles=function(e,t,i){var r=e.borderStyle||e.lineStyle||"solid",a=e.backgroundColor||e.fontColor||"transparent",n=e.borderColor||e.lineColor||"transparent",o=h(e.borderWidth||e.lineWidth,t,i);return{"stroke-linecap":e.lineCap||"round","stroke-linejoin":e.lineJoin||"round","stroke-width":o||0,"stroke-dasharray":"string"==typeof r?"":r.map(function(e){return h(e,t,i)}).join(","),stroke:n,fill:a,opacity:e.opacity||1}}(i,r,a),y[t](e,i,r,a)},v=["x","y","left","top","right","bottom","width","height"],w=function(e){var t=i(e,2),r=t[0],a=t[1],n=a.points?{}:v.reduce(function(e,t){var i;return e[t]="string"==typeof(i=a[t])&&/%/.test(i)?parseFloat(i)/100:i,e},{});return[r,Object.assign({zIndex:0},a,n)]},_=function(e,t){return e[1].zIndex>t[1].zIndex?1:e[1].zIndex.5?1-r.x:r.x,n=r.y>.5?1-r.y:r.y,o=2*a*e.width,c=2*n*e.height,s=function(e,t){var i=e.width,r=e.height,a=A(i,t),n=A(r,t),o=M(e.x+Math.abs(a.x),e.y-Math.abs(a.y)),c=M(e.x+e.width+Math.abs(n.y),e.y+Math.abs(n.x)),s=M(e.x-Math.abs(n.y),e.y+e.height-Math.abs(n.x));return{width:T(o,c),height:T(o,s)}}(t,i);return Math.max(s.width/o,s.height/c)},P=function(e,t){var i=e.width,r=i*t;return r>e.height&&(i=(r=e.height)/t),{x:.5*(e.width-i),y:.5*(e.height-r),width:i,height:r}},C=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.zoom,r=t.rotation,a=t.center,n=t.aspectRatio;n||(n=e.height/e.width);var o=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=e.height/e.width,a=t,n=1,o=r;o>a&&(n=(o=a)/r);var c=Math.max(1/n,a/o),s=e.width/(i*c*n);return{width:s,height:s*t}}(e,n,i),c={x:.5*o.width,y:.5*o.height},s={x:0,y:0,width:o.width,height:o.height,center:c},h=void 0===t.scaleToFit||t.scaleToFit,u=i*R(e,P(s,n),r,h?a:{x:.5,y:.5});return{widthFloat:o.width/u,heightFloat:o.height/u,width:Math.round(o.width/u),height:Math.round(o.height/u)}},k={type:"spring",stiffness:.5,damping:.45,mass:10},D=function(e){return e.utils.createView({name:"image-clip",tag:"div",ignoreRect:!0,mixins:{apis:["crop","markup","resize","width","height","dirty","background"],styles:["width","height","opacity"],animations:{opacity:{type:"tween",duration:250}}},didWriteView:function(e){var t=e.root,i=e.props;i.background&&(t.element.style.backgroundColor=i.background)},create:function(t){var i=t.root,r=t.props;i.ref.image=i.appendChildView(i.createChildView(function(e){return e.utils.createView({name:"image-canvas-wrapper",tag:"div",ignoreRect:!0,mixins:{apis:["crop","width","height"],styles:["originX","originY","translateX","translateY","scaleX","scaleY","rotateZ"],animations:{originX:k,originY:k,scaleX:k,scaleY:k,translateX:k,translateY:k,rotateZ:k}},create:function(t){var i=t.root,r=t.props;r.width=r.image.width,r.height=r.image.height,i.ref.bitmap=i.appendChildView(i.createChildView(function(e){return e.utils.createView({name:"image-bitmap",ignoreRect:!0,mixins:{styles:["scaleX","scaleY"]},create:function(e){var t=e.root,i=e.props;t.appendChild(i.image)}})}(e),{image:r.image}))},write:function(e){var t=e.root,i=e.props.crop.flip,r=t.ref.bitmap;r.scaleX=i.horizontal?-1:1,r.scaleY=i.vertical?-1:1}})}(e),Object.assign({},r))),i.ref.createMarkup=function(){i.ref.markup||(i.ref.markup=i.appendChildView(i.createChildView(I(e),Object.assign({},r))))},i.ref.destroyMarkup=function(){i.ref.markup&&(i.removeChildView(i.ref.markup),i.ref.markup=null)};var a=i.query("GET_IMAGE_PREVIEW_TRANSPARENCY_INDICATOR");null!==a&&(i.element.dataset.transparencyIndicator="grid"===a?a:"color")},write:function(e){var t=e.root,i=e.props,r=e.shouldOptimize,a=i.crop,n=i.markup,o=i.resize,c=i.dirty,s=i.width,h=i.height;t.ref.image.crop=a;var u={x:0,y:0,width:s,height:h,center:{x:.5*s,y:.5*h}},l={width:t.ref.image.width,height:t.ref.image.height},d={x:a.center.x*l.width,y:a.center.y*l.height},f={x:u.center.x-l.width*a.center.x,y:u.center.y-l.height*a.center.y},p=2*Math.PI+a.rotation%(2*Math.PI),g=a.aspectRatio||l.height/l.width,m=void 0===a.scaleToFit||a.scaleToFit,y=R(l,P(u,g),p,m?a.center:{x:.5,y:.5}),E=a.zoom*y;n&&n.length?(t.ref.createMarkup(),t.ref.markup.width=s,t.ref.markup.height=h,t.ref.markup.resize=o,t.ref.markup.dirty=c,t.ref.markup.markup=n,t.ref.markup.crop=C(l,a)):t.ref.markup&&t.ref.destroyMarkup();var v=t.ref.image;if(r)return v.originX=null,v.originY=null,v.translateX=null,v.translateY=null,v.rotateZ=null,v.scaleX=null,void(v.scaleY=null);v.originX=d.x,v.originY=d.y,v.translateX=f.x,v.translateY=f.y,v.rotateZ=p,v.scaleX=E,v.scaleY=E}})},G=0,V=function(){self.onmessage=function(e){createImageBitmap(e.data.message.file).then(function(t){self.postMessage({id:e.data.id,message:t},[t])})}},O=function(){self.onmessage=function(e){for(var t=e.data.message.imageData,i=e.data.message.colorMatrix,r=t.data,a=r.length,n=i[0],o=i[1],c=i[2],s=i[3],h=i[4],u=i[5],l=i[6],d=i[7],f=i[8],p=i[9],g=i[10],m=i[11],y=i[12],E=i[13],v=i[14],w=i[15],_=i[16],I=i[17],M=i[18],x=i[19],T=0,A=0,R=0,P=0,C=0;T=5&&r<=8){var o=[i,t];t=o[0],i=o[1]}return function(e,t,i,r){-1!==r&&e.transform.apply(e,b[r](t,i))}(n,t,i,r),n.drawImage(e,0,0,t,i),a},L=function(e){return/^image/.test(e.type)&&!/svg/.test(e.type)},N=function(e){var t=Math.min(10/e.width,10/e.height),i=document.createElement("canvas"),r=i.getContext("2d"),a=i.width=Math.ceil(e.width*t),n=i.height=Math.ceil(e.height*t);r.drawImage(e,0,0,a,n);var o=null;try{o=r.getImageData(0,0,a,n).data}catch(e){return null}for(var c=o.length,s=0,h=0,u=0,l=0;l\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n';if(document.querySelector("base")){var a=new URL(window.location.href.replace(window.location.hash,"")).href;r=r.replace(/url\(\#/g,"url("+a+"#")}G++,t.element.classList.add("filepond--image-preview-overlay-".concat(i.status)),t.element.innerHTML=r.replace(/__UID__/g,G)},mixins:{styles:["opacity"],animations:{opacity:{type:"spring",mass:25}}}}),i=function(e){return e.utils.createView({name:"image-preview",tag:"div",ignoreRect:!0,mixins:{apis:["image","crop","markup","resize","dirty","background"],styles:["translateY","scaleX","scaleY","opacity"],animations:{scaleX:k,scaleY:k,translateY:k,opacity:{type:"tween",duration:400}}},create:function(t){var i=t.root,r=t.props;i.ref.clip=i.appendChildView(i.createChildView(D(e),{id:r.id,image:r.image,crop:r.crop,markup:r.markup,resize:r.resize,dirty:r.dirty,background:r.background}))},write:function(e){var t=e.root,i=e.props,r=e.shouldOptimize,a=t.ref.clip,n=i.image,o=i.crop,c=i.markup,s=i.resize,h=i.dirty;if(a.crop=o,a.markup=c,a.resize=s,a.dirty=h,a.opacity=r?0:1,!r&&!t.rect.element.hidden){var u=n.height/n.width,l=o.aspectRatio||u,d=t.rect.inner.width,f=t.rect.inner.height,p=t.query("GET_IMAGE_PREVIEW_HEIGHT"),g=t.query("GET_IMAGE_PREVIEW_MIN_HEIGHT"),m=t.query("GET_IMAGE_PREVIEW_MAX_HEIGHT"),y=t.query("GET_PANEL_ASPECT_RATIO"),E=t.query("GET_ALLOW_MULTIPLE");y&&!E&&(p=d*y,l=y);var v=null!==p?p:Math.max(g,Math.min(d*l,m)),w=v/l;w>d&&(v=(w=d)*l),v>f&&(v=f,w=f/l),a.width=w,a.height=v}}})}(e),r=e.utils.createWorker,a=function(e,t,i){return new Promise(function(a){e.ref.imageData||(e.ref.imageData=i.getContext("2d").getImageData(0,0,i.width,i.height));var n=function(e){var t;try{t=new ImageData(e.width,e.height)}catch(i){t=document.createElement("canvas").getContext("2d").createImageData(e.width,e.height)}return t.data.set(new Uint8ClampedArray(e.data)),t}(e.ref.imageData);if(!t||20!==t.length)return i.getContext("2d").putImageData(n,0,0),a();var o=r(O);o.post({imageData:n,colorMatrix:t},function(e){i.getContext("2d").putImageData(e,0,0),o.terminate(),a()},[n.data.buffer])})},n=function(e){var t=e.root,r=e.props,a=e.image,n=r.id,o=t.query("GET_ITEM",{id:n});if(o){var c,s,h=o.getMetadata("crop")||{center:{x:.5,y:.5},flip:{horizontal:!1,vertical:!1},zoom:1,rotation:0,aspectRatio:null},u=t.query("GET_IMAGE_TRANSFORM_CANVAS_BACKGROUND_COLOR"),l=!1;t.query("GET_IMAGE_PREVIEW_MARKUP_SHOW")&&(c=o.getMetadata("markup")||[],s=o.getMetadata("resize"),l=!0);var d=t.appendChildView(t.createChildView(i,{id:n,image:a,crop:h,resize:s,markup:c,dirty:l,background:u,opacity:0,scaleX:1.15,scaleY:1.15,translateY:15}),t.childViews.length);t.ref.images.push(d),d.opacity=1,d.scaleX=1,d.scaleY=1,d.translateY=0,setTimeout(function(){t.dispatch("DID_IMAGE_PREVIEW_SHOW",{id:n})},250)}},o=function(e){var t=e.root;t.ref.overlayShadow.opacity=1,t.ref.overlayError.opacity=0,t.ref.overlaySuccess.opacity=0},c=function(e){var t=e.root;t.ref.overlayShadow.opacity=.25,t.ref.overlayError.opacity=1};return e.utils.createView({name:"image-preview-wrapper",create:function(e){var i=e.root;i.ref.images=[],i.ref.imageData=null,i.ref.imageViewBin=[],i.ref.overlayShadow=i.appendChildView(i.createChildView(t,{opacity:0,status:"idle"})),i.ref.overlaySuccess=i.appendChildView(i.createChildView(t,{opacity:0,status:"success"})),i.ref.overlayError=i.appendChildView(i.createChildView(t,{opacity:0,status:"failure"}))},styles:["height"],apis:["height"],destroy:function(e){e.root.ref.images.forEach(function(e){e.image.width=1,e.image.height=1})},didWriteView:function(e){e.root.ref.images.forEach(function(e){e.dirty=!1})},write:e.utils.createRoute({DID_IMAGE_PREVIEW_DRAW:function(e){var t=e.root,i=t.ref.images[t.ref.images.length-1];i.translateY=0,i.scaleX=1,i.scaleY=1,i.opacity=1},DID_IMAGE_PREVIEW_CONTAINER_CREATE:function(e){var t=e.root,i=e.props.id,r=t.query("GET_ITEM",i);if(r){var a,n,o,c=URL.createObjectURL(r.file);a=c,n=function(e,r){t.dispatch("DID_IMAGE_PREVIEW_CALCULATE_SIZE",{id:i,width:e,height:r})},(o=new Image).onload=function(){var e=o.naturalWidth,t=o.naturalHeight;o=null,n(e,t)},o.src=a}},DID_FINISH_CALCULATE_PREVIEWSIZE:function(e){var t=e.root,i=e.props,o=i.id,c=t.query("GET_ITEM",o);if(c){var s,h,u,l=URL.createObjectURL(c.file),d=function(){var e;(e=l,new Promise(function(t,i){var r=new Image;r.crossOrigin="Anonymous",r.onload=function(){t(r)},r.onerror=function(e){i(e)},r.src=e})).then(f)},f=function(e){URL.revokeObjectURL(l);var r=(c.getMetadata("exif")||{}).orientation||-1,o=e.width,s=e.height;if(o&&s){if(r>=5&&r<=8){var h=[s,o];o=h[0],s=h[1]}var u=Math.max(1,.75*window.devicePixelRatio),d=t.query("GET_IMAGE_PREVIEW_ZOOM_FACTOR")*u,f=s/o,p=t.rect.element.width,g=t.rect.element.height,m=p,y=m*f;f>1?y=(m=Math.min(o,p*d))*f:m=(y=Math.min(s,g*d))/f;var E=S(e,m,y,r),v=function(){var r=t.query("GET_IMAGE_PREVIEW_CALCULATE_AVERAGE_IMAGE_COLOR")?N(data):null;c.setMetadata("color",r,!0),"close"in e&&e.close(),t.ref.overlayShadow.opacity=1,n({root:t,props:i,image:E})},w=c.getMetadata("filter");w?a(t,w,E).then(v):v()}};if(s=c.file,h=window.navigator.userAgent.match(/Firefox\/([0-9]+)\./),!(null!==(u=h?parseInt(h[1]):null)&&u<=58)&&"createImageBitmap"in window&&L(s)){var p=r(V);p.post({file:c.file},function(e){p.terminate(),e?f(e):d()})}else d()}},DID_UPDATE_ITEM_METADATA:function(e){var t=e.root,i=e.props,r=e.action;if(/crop|filter|markup|resize/.test(r.change.key)&&t.ref.images.length){var o=t.query("GET_ITEM",{id:i.id});if(o)if(/filter/.test(r.change.key)){var c=t.ref.images[t.ref.images.length-1];a(t,r.change.value,c.image)}else{if(/crop|markup|resize/.test(r.change.key)){var s=o.getMetadata("crop"),h=t.ref.images[t.ref.images.length-1];if(s&&s.aspectRatio&&h.crop&&h.crop.aspectRatio&&Math.abs(s.aspectRatio-h.crop.aspectRatio)>1e-5){var u=function(e){var t=e.root,i=t.ref.images.shift();return i.opacity=0,i.translateY=-15,t.ref.imageViewBin.push(i),i}({root:t});n({root:t,props:i,image:(l=u.image,(d=d||document.createElement("canvas")).width=l.width,d.height=l.height,d.getContext("2d").drawImage(l,0,0),d)})}else!function(e){var t=e.root,i=e.props,r=t.query("GET_ITEM",{id:i.id});if(r){var a=t.ref.images[t.ref.images.length-1];a.crop=r.getMetadata("crop"),a.background=t.query("GET_IMAGE_TRANSFORM_CANVAS_BACKGROUND_COLOR"),t.query("GET_IMAGE_PREVIEW_MARKUP_SHOW")&&(a.dirty=!0,a.resize=r.getMetadata("resize"),a.markup=r.getMetadata("markup"))}}({root:t,props:i})}var l,d}}},DID_THROW_ITEM_LOAD_ERROR:c,DID_THROW_ITEM_PROCESSING_ERROR:c,DID_THROW_ITEM_INVALID:c,DID_COMPLETE_ITEM_PROCESSING:function(e){var t=e.root;t.ref.overlayShadow.opacity=.25,t.ref.overlaySuccess.opacity=1},DID_START_ITEM_PROCESSING:o,DID_REVERT_ITEM_PROCESSING:o},function(e){var t=e.root,i=t.ref.imageViewBin.filter(function(e){return 0===e.opacity});t.ref.imageViewBin=t.ref.imageViewBin.filter(function(e){return e.opacity>0}),i.forEach(function(e){return function(e,t){e.removeChildView(t),t.image.width=1,t.image.height=1,t._destroy()}(t,e)}),i.length=0})})},H=function(e){var t=e.addFilter,i=e.utils,r=i.Type,a=i.createRoute,n=i.isFile,o=z(e);return t("CREATE_VIEW",function(e){var t=e.is,i=e.view,r=e.query;if(t("file")&&r("GET_ALLOW_IMAGE_PREVIEW")){var c=function(e){e.root.ref.shouldRescale=!0};i.registerWriter(a({DID_RESIZE_ROOT:c,DID_STOP_RESIZE:c,DID_LOAD_ITEM:function(e){var t=e.root,a=e.props.id,c=r("GET_ITEM",a);if(c&&n(c.file)&&!c.archived){var s=c.file;if(function(e){return/^image/.test(e.type)}(s)&&r("GET_IMAGE_PREVIEW_FILTER_ITEM")(c)){var h="createImageBitmap"in(window||{}),u=r("GET_IMAGE_PREVIEW_MAX_FILE_SIZE");if(!(!h&&u&&s.size>u)){t.ref.imagePreview=i.appendChildView(i.createChildView(o,{id:a}));var l=t.query("GET_IMAGE_PREVIEW_HEIGHT");l&&t.dispatch("DID_UPDATE_PANEL_HEIGHT",{id:c.id,height:l});var d=!h&&s.size>r("GET_IMAGE_PREVIEW_MAX_INSTANT_PREVIEW_FILE_SIZE");t.dispatch("DID_IMAGE_PREVIEW_CONTAINER_CREATE",{id:a},d)}}}},DID_IMAGE_PREVIEW_CALCULATE_SIZE:function(e){var t=e.root,i=e.action;t.ref.imageWidth=i.width,t.ref.imageHeight=i.height,t.ref.shouldRescale=!0,t.ref.shouldDrawPreview=!0,t.dispatch("KICK")},DID_UPDATE_ITEM_METADATA:function(e){var t=e.root;"crop"===e.action.change.key&&(t.ref.shouldRescale=!0)}},function(e){var t=e.root,i=e.props;t.ref.imagePreview&&(t.rect.element.hidden||(t.ref.shouldRescale&&(!function(e,t){if(e.ref.imagePreview){var i=t.id,r=e.query("GET_ITEM",{id:i});if(r){var a=e.query("GET_PANEL_ASPECT_RATIO"),n=e.query("GET_ITEM_PANEL_ASPECT_RATIO"),o=e.query("GET_IMAGE_PREVIEW_HEIGHT");if(!(a||n||o)){var c=e.ref,s=c.imageWidth,h=c.imageHeight;if(s&&h){var u=e.query("GET_IMAGE_PREVIEW_MIN_HEIGHT"),l=e.query("GET_IMAGE_PREVIEW_MAX_HEIGHT"),d=(r.getMetadata("exif")||{}).orientation||-1;if(d>=5&&d<=8){var f=[h,s];s=f[0],h=f[1]}if(!L(r.file)||e.query("GET_IMAGE_PREVIEW_UPSCALE")){var p=2048/s;s*=p,h*=p}var g=h/s,m=(r.getMetadata("crop")||{}).aspectRatio||g,y=Math.max(u,Math.min(h,l)),E=e.rect.element.width,v=Math.min(E*m,y);e.dispatch("DID_UPDATE_PANEL_HEIGHT",{id:r.id,height:v})}}}}}(t,i),t.ref.shouldRescale=!1),t.ref.shouldDrawPreview&&(requestAnimationFrame(function(){requestAnimationFrame(function(){t.dispatch("DID_FINISH_CALCULATE_PREVIEWSIZE",{id:i.id})})}),t.ref.shouldDrawPreview=!1)))}))}}),{options:{allowImagePreview:[!0,r.BOOLEAN],imagePreviewFilterItem:[function(){return!0},r.FUNCTION],imagePreviewHeight:[null,r.INT],imagePreviewMinHeight:[44,r.INT],imagePreviewMaxHeight:[256,r.INT],imagePreviewMaxFileSize:[null,r.INT],imagePreviewZoomFactor:[2,r.INT],imagePreviewUpscale:[!1,r.BOOLEAN],imagePreviewMaxInstantPreviewFileSize:[1e6,r.INT],imagePreviewTransparencyIndicator:[null,r.STRING],imagePreviewCalculateAverageImageColor:[!1,r.BOOLEAN],imagePreviewMarkupShow:[!0,r.BOOLEAN],imagePreviewMarkupFilter:[function(){return!0},r.FUNCTION]}}};return"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:H})),H}); diff --git a/app/public/assets/js/filepond.min.js b/app/public/assets/js/filepond.min.js deleted file mode 100644 index 5900a8c..0000000 --- a/app/public/assets/js/filepond.min.js +++ /dev/null @@ -1,9 +0,0 @@ -/*! - * FilePond 4.32.12 - * Licensed under MIT, https://opensource.org/licenses/MIT/ - * Please visit https://pqina.nl/filepond/ for details. - */ - -/* eslint-disable */ - -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).FilePond={})}(this,function(e){"use strict";var t=function(e,t){for(var n in e)e.hasOwnProperty(n)&&t(n,e[n])},n=function(e){var n={};return t(e,function(t){!function(e,t,n){"function"!=typeof n?Object.defineProperty(e,t,Object.assign({},n)):e[t]=n}(n,t,e[t])}),n},r=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(null===n)return e.getAttribute(t)||e.hasAttribute(t);e.setAttribute(t,n)},o=["svg","path"],i=function(e){return o.includes(e)},a=function(e,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};"object"==typeof n&&(o=n,n=null);var a=i(e)?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e);return n&&(i(e)?r(a,"class",n):a.className=n),t(o,function(e,t){r(a,e,t)}),a},s=function(e,t){return function(e,n){return void 0!==n?t.splice(n,0,e):t.push(e),e}},u=function(e,t){return function(n){return t.splice(t.indexOf(n),1),n.element.parentNode&&e.removeChild(n.element),n}},l="undefined"!=typeof window&&void 0!==window.document,c=function(){return l},f="children"in(c()?a("svg"):{})?function(e){return e.children.length}:function(e){return e.childNodes.length},d=function(e,t,n,r){var o=n[0]||e.left,i=n[1]||e.top,a=o+e.width,s=i+e.height*(r[1]||1),u={element:Object.assign({},e),inner:{left:e.left,top:e.top,right:e.right,bottom:e.bottom},outer:{left:o,top:i,right:a,bottom:s}};return t.filter(function(e){return!e.isRectIgnored()}).map(function(e){return e.rect}).forEach(function(e){p(u.inner,Object.assign({},e.inner)),p(u.outer,Object.assign({},e.outer))}),E(u.inner),u.outer.bottom+=u.element.marginBottom,u.outer.right+=u.element.marginRight,E(u.outer),u},p=function(e,t){t.top+=e.top,t.right+=e.left,t.bottom+=e.top,t.left+=e.left,t.bottom>e.bottom&&(e.bottom=t.bottom),t.right>e.right&&(e.right=t.right)},E=function(e){e.width=e.right-e.left,e.height=e.bottom-e.top},_=function(e){return"number"==typeof e},T=function(e){return e<.5?2*e*e:(4-2*e)*e-1},I={spring:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.stiffness,r=void 0===t?.5:t,o=e.damping,i=void 0===o?.75:o,a=e.mass,s=void 0===a?10:a,u=null,l=null,c=0,f=!1,d=n({interpolate:function(e,t){if(!f){if(!_(u)||!_(l))return f=!0,void(c=0);(function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.001;return Math.abs(e-t)0&&void 0!==arguments[0]?arguments[0]:{},o=r.duration,i=void 0===o?500:o,a=r.easing,s=void 0===a?T:a,u=r.delay,l=void 0===u?0:u,c=null,f=!0,d=!1,p=null,E=n({interpolate:function(n,r){f||null===p||(null===c&&(c=n),n-c=i||r?(e=1,t=d?0:1,E.onupdate(t*p),E.oncomplete(t*p),f=!0):(t=e/i,E.onupdate((e>=0?s(d?1-t:t):0)*p))))},target:{get:function(){return d?0:p},set:function(e){if(null===p)return p=e,E.onupdate(e),void E.oncomplete(e);e3&&void 0!==arguments[3]&&arguments[3];(t=Array.isArray(t)?t:[t]).forEach(function(t){e.forEach(function(e){var o=e,i=function(){return n[e]},a=function(t){return n[e]=t};"object"==typeof e&&(o=e.key,i=e.getter||i,a=e.setter||a),t[o]&&!r||(t[o]={get:i,set:a})})})},h=function(e){return null!=e},g={opacity:1,scaleX:1,scaleY:1,translateX:0,translateY:0,rotateX:0,rotateY:0,rotateZ:0,originX:0,originY:0},R=function(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!0;for(var n in t)if(t[n]!==e[n])return!0;return!1},O=function(e,t){var n=t.opacity,r=t.perspective,o=t.translateX,i=t.translateY,a=t.scaleX,s=t.scaleY,u=t.rotateX,l=t.rotateY,c=t.rotateZ,f=t.originX,d=t.originY,p=t.width,E=t.height,_="",T="";(h(f)||h(d))&&(T+="transform-origin: "+(f||0)+"px "+(d||0)+"px;"),h(r)&&(_+="perspective("+r+"px) "),(h(o)||h(i))&&(_+="translate3d("+(o||0)+"px, "+(i||0)+"px, 0) "),(h(a)||h(s))&&(_+="scale3d("+(h(a)?a:1)+", "+(h(s)?s:1)+", 1) "),h(c)&&(_+="rotateZ("+c+"rad) "),h(u)&&(_+="rotateX("+u+"rad) "),h(l)&&(_+="rotateY("+l+"rad) "),_.length&&(T+="transform:"+_+";"),h(n)&&(T+="opacity:"+n+";",0===n&&(T+="visibility:hidden;"),n<1&&(T+="pointer-events:none;")),h(E)&&(T+="height:"+E+"px;"),h(p)&&(T+="width:"+p+"px;");var I=e.elementCurrentStyle||"";T.length===I.length&&T===I||(e.style.cssText=T,e.elementCurrentStyle=T)},y={styles:function(e){var t=e.mixinConfig,n=e.viewProps,r=e.viewInternalAPI,o=e.viewExternalAPI,i=e.view,a=Object.assign({},n),s={};m(t,[r,o],n);var u=function(){return i.rect?d(i.rect,i.childViews,[n.translateX||0,n.translateY||0],[n.scaleX||0,n.scaleY||0]):null};return r.rect={get:u},o.rect={get:u},t.forEach(function(e){n[e]=void 0===a[e]?g[e]:a[e]}),{write:function(){if(R(s,n))return O(i.element,n),Object.assign(s,Object.assign({},n)),!0},destroy:function(){}}},listeners:function(e){e.mixinConfig,e.viewProps,e.viewInternalAPI;var t,n=e.viewExternalAPI,r=(e.viewState,e.view),o=[],i=(t=r.element,function(e,n){t.addEventListener(e,n)}),a=function(e){return function(t,n){e.removeEventListener(t,n)}}(r.element);return n.on=function(e,t){o.push({type:e,fn:t}),i(e,t)},n.off=function(e,t){o.splice(o.findIndex(function(n){return n.type===e&&n.fn===t}),1),a(e,t)},{write:function(){return!0},destroy:function(){o.forEach(function(e){a(e.type,e.fn)})}}},animations:function(e){var n=e.mixinConfig,r=e.viewProps,o=e.viewInternalAPI,i=e.viewExternalAPI,a=Object.assign({},r),s=[];return t(n,function(e,t){var n=v(t);n&&(n.onupdate=function(t){r[e]=t},n.target=a[e],m([{key:e,setter:function(e){n.target!==e&&(n.target=e)},getter:function(){return r[e]}}],[o,i],r,!0),s.push(n))}),{write:function(e){var t=document.hidden,n=!0;return s.forEach(function(r){r.resting||(n=!1),r.interpolate(e,t)}),n},destroy:function(){}}},apis:function(e){var t=e.mixinConfig,n=e.viewProps,r=e.viewExternalAPI;m(t,r,n)}},D=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return t.layoutCalculated||(e.paddingTop=parseInt(n.paddingTop,10)||0,e.marginTop=parseInt(n.marginTop,10)||0,e.marginRight=parseInt(n.marginRight,10)||0,e.marginBottom=parseInt(n.marginBottom,10)||0,e.marginLeft=parseInt(n.marginLeft,10)||0,t.layoutCalculated=!0),e.left=t.offsetLeft||0,e.top=t.offsetTop||0,e.width=t.offsetWidth||0,e.height=t.offsetHeight||0,e.right=e.left+e.width,e.bottom=e.top+e.height,e.scrollTop=t.scrollTop,e.hidden=null===t.offsetParent,e},S=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.tag,r=void 0===t?"div":t,o=e.name,i=void 0===o?null:o,l=e.attributes,c=void 0===l?{}:l,p=e.read,E=void 0===p?function(){}:p,_=e.write,T=void 0===_?function(){}:_,I=e.create,v=void 0===I?function(){}:I,m=e.destroy,h=void 0===m?function(){}:m,g=e.filterFrameActionsForChild,R=void 0===g?function(e,t){return t}:g,O=e.didCreateView,S=void 0===O?function(){}:O,A=e.didWriteView,L=void 0===A?function(){}:A,b=e.ignoreRect,P=void 0!==b&&b,M=e.ignoreRectUpdate,w=void 0!==M&&M,C=e.mixins,N=void 0===C?[]:C;return function(e){var t,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},l=a(r,"filepond--"+i,c),p=window.getComputedStyle(l,null),_=D(),I=null,m=!1,g=[],O=[],A={},b={},M=[T],C=[E],G=[h],U=function(){return l},B=function(){return g.concat()},F=function(){return I||(I=d(_,g,[0,0],[1,1]))},q={element:{get:U},style:{get:function(){return p}},childViews:{get:B}},V=Object.assign({},q,{rect:{get:F},ref:{get:function(){return A}},is:function(e){return i===e},appendChild:(t=l,function(e,n){void 0!==n&&t.children[n]?t.insertBefore(e,t.children[n]):t.appendChild(e)}),createChildView:function(e){return function(t,n){return t(e,n)}}(e),linkView:function(e){return g.push(e),e},unlinkView:function(e){g.splice(g.indexOf(e),1)},appendChildView:s(0,g),removeChildView:u(l,g),registerWriter:function(e){return M.push(e)},registerReader:function(e){return C.push(e)},registerDestroyer:function(e){return G.push(e)},invalidateLayout:function(){return l.layoutCalculated=!1},dispatch:e.dispatch,query:e.query}),x={element:{get:U},childViews:{get:B},rect:{get:F},resting:{get:function(){return m}},isRectIgnored:function(){return P},_read:function(){I=null,g.forEach(function(e){return e._read()}),!(w&&_.width&&_.height)&&D(_,l,p);var e={root:k,props:o,rect:_};C.forEach(function(t){return t(e)})},_write:function(e,t,n){var r=0===t.length;return M.forEach(function(i){!1===i({props:o,root:k,actions:t,timestamp:e,shouldOptimize:n})&&(r=!1)}),O.forEach(function(t){!1===t.write(e)&&(r=!1)}),g.filter(function(e){return!!e.element.parentNode}).forEach(function(o){o._write(e,R(o,t),n)||(r=!1)}),g.forEach(function(o,i){o.element.parentNode||(k.appendChild(o.element,i),o._read(),o._write(e,R(o,t),n),r=!1)}),m=r,L({props:o,root:k,actions:t,timestamp:e}),r},_destroy:function(){O.forEach(function(e){return e.destroy()}),G.forEach(function(e){e({root:k,props:o})}),g.forEach(function(e){return e._destroy()})}},Y=Object.assign({},q,{rect:{get:function(){return _}}});Object.keys(N).sort(function(e,t){return"styles"===e?1:"styles"===t?-1:0}).forEach(function(e){var t=y[e]({mixinConfig:N[e],viewProps:o,viewState:b,viewInternalAPI:V,viewExternalAPI:x,view:n(Y)});t&&O.push(t)});var k=n(V);v({root:k,props:o});var j=f(l);return g.forEach(function(e,t){k.appendChild(e.element,j+t)}),S(k),n(x)}},A=function(e,t){return function(n){var r=n.root,o=n.props,i=n.actions,a=void 0===i?[]:i,s=n.timestamp,u=n.shouldOptimize;a.filter(function(t){return e[t.type]}).forEach(function(t){return e[t.type]({root:r,props:o,action:t.data,timestamp:s,shouldOptimize:u})}),t&&t({root:r,props:o,actions:a,timestamp:s,shouldOptimize:u})}},L=function(e,t){return t.parentNode.insertBefore(e,t)},b=function(e,t){return t.parentNode.insertBefore(e,t.nextSibling)},P=function(e){return Array.isArray(e)},M=function(e){return null==e},w=function(e){return e.trim()},C=function(e){return""+e},N=function(e){return"boolean"==typeof e},G=function(e){return N(e)?e:"true"===e},U=function(e){return"string"==typeof e},B=function(e){return _(e)?e:U(e)?C(e).replace(/[a-z]+/gi,""):0},F=function(e){return parseInt(B(e),10)},q=function(e){return parseFloat(B(e))},V=function(e){return _(e)&&isFinite(e)&&Math.floor(e)===e},x=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;if(V(e))return e;var n=C(e).trim();return/MB$/i.test(n)?(n=n.replace(/MB$i/,"").trim(),F(n)*t*t):/KB/i.test(n)?(n=n.replace(/KB$i/,"").trim(),F(n)*t):F(n)},Y=function(e){return"function"==typeof e},k={process:"POST",patch:"PATCH",revert:"DELETE",fetch:"GET",restore:"GET",load:"GET"},j=function(e,t,n,r,o){if(null===t)return null;if("function"==typeof t)return t;var i={url:"GET"===n||"PATCH"===n?"?"+e+"=":"",method:n,headers:o,withCredentials:!1,timeout:r,onload:null,ondata:null,onerror:null};if(U(t))return i.url=t,i;if(Object.assign(i,t),U(i.headers)){var a=i.headers.split(/:(.+)/);i.headers={header:a[0],value:a[1]}}return i.withCredentials=G(i.withCredentials),i},H=function(e){return"object"==typeof e&&null!==e},X=function(e){return P(e)?"array":function(e){return null===e}(e)?"null":V(e)?"int":/^[0-9]+ ?(?:GB|MB|KB)$/gi.test(e)?"bytes":function(e){return H(e)&&U(e.url)&&H(e.process)&&H(e.revert)&&H(e.restore)&&H(e.fetch)}(e)?"api":typeof e},W={array:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:",";return M(e)?[]:P(e)?e:C(e).split(t).map(w).filter(function(e){return e.length})},boolean:G,int:function(e){return"bytes"===X(e)?x(e):F(e)},number:q,float:q,bytes:x,string:function(e){return Y(e)?e:C(e)},function:function(e){return function(e){for(var t=self,n=e.split("."),r=null;r=n.shift();)if(!(t=t[r]))return null;return t}(e)},serverapi:function(e){return(r={}).url=U(n=e)?n:n.url||"",r.timeout=n.timeout?parseInt(n.timeout,10):0,r.headers=n.headers?n.headers:{},t(k,function(e){r[e]=j(e,n[e],k[e],r.timeout,r.headers)}),r.process=n.process||U(n)||n.url?r.process:null,r.remove=n.remove||null,delete r.headers,r;var n,r},object:function(e){try{return JSON.parse(e.replace(/{\s*'/g,'{"').replace(/'\s*}/g,'"}').replace(/'\s*:/g,'":').replace(/:\s*'/g,':"').replace(/,\s*'/g,',"').replace(/'\s*,/g,'",'))}catch(e){return null}}},z=function(e,t,n){if(e===t)return e;var r,o=X(e);if(o!==n){var i=(r=e,W[n](r));if(o=X(i),null===i)throw'Trying to assign value with incorrect type to "'+option+'", allowed type: "'+n+'"';e=i}return e},Q=function(e){var r={};return t(e,function(t){var n,o,i,a=e[t];r[t]=(n=a[0],o=a[1],i=n,{enumerable:!0,get:function(){return i},set:function(e){i=z(e,n,o)}})}),n(r)},Z=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"-";return e.split(/(?=[A-Z])/).map(function(e){return e.toLowerCase()}).join(t)},K=function(e){return function(n,r,o){var i={};return t(e,function(e){var t=Z(e,"_").toUpperCase();i["SET_"+t]=function(r){try{o.options[e]=r.value}catch(e){}n("DID_SET_"+t,{value:o.options[e]})}}),i}},$=function(e){return function(n){var r={};return t(e,function(e){r["GET_"+Z(e,"_").toUpperCase()]=function(t){return n.options[e]}}),r}},J=1,ee=2,te=3,ne=4,re=5,oe=function(){return Math.random().toString(36).substring(2,11)};function ie(e){this.wrapped=e}function ae(e){var t,n;function r(t,n){try{var i=e[t](n),a=i.value,s=a instanceof ie;Promise.resolve(s?a.wrapped:a).then(function(e){s?r("next",e):o(i.done?"return":"normal",e)},function(e){r("throw",e)})}catch(e){o("throw",e)}}function o(e,o){switch(e){case"return":t.resolve({value:o,done:!0});break;case"throw":t.reject(o);break;default:t.resolve({value:o,done:!1})}(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,o){return new Promise(function(i,a){var s={key:e,arg:o,resolve:i,reject:a,next:null};n?n=n.next=s:(t=n=s,r(e,o))})},"function"!=typeof e.return&&(this.return=void 0)}function se(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}"function"==typeof Symbol&&Symbol.asyncIterator&&(ae.prototype[Symbol.asyncIterator]=function(){return this}),ae.prototype.next=function(e){return this._invoke("next",e)},ae.prototype.throw=function(e){return this._invoke("throw",e)},ae.prototype.return=function(e){return this._invoke("return",e)};function ue(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t1?t-1:0),o=1;o1?t-1:0),o=1;oBrowse',ge.STRING],labelInvalidField:["Field contains invalid files",ge.STRING],labelFileWaitingForSize:["Waiting for size",ge.STRING],labelFileSizeNotAvailable:["Size not available",ge.STRING],labelFileCountSingular:["file in list",ge.STRING],labelFileCountPlural:["files in list",ge.STRING],labelFileLoading:["Loading",ge.STRING],labelFileAdded:["Added",ge.STRING],labelFileLoadError:["Error during load",ge.STRING],labelFileRemoved:["Removed",ge.STRING],labelFileRemoveError:["Error during remove",ge.STRING],labelFileProcessing:["Uploading",ge.STRING],labelFileProcessingComplete:["Upload complete",ge.STRING],labelFileProcessingAborted:["Upload cancelled",ge.STRING],labelFileProcessingError:["Error during upload",ge.STRING],labelFileProcessingRevertError:["Error during revert",ge.STRING],labelTapToCancel:["tap to cancel",ge.STRING],labelTapToRetry:["tap to retry",ge.STRING],labelTapToUndo:["tap to undo",ge.STRING],labelButtonRemoveItem:["Remove",ge.STRING],labelButtonAbortItemLoad:["Abort",ge.STRING],labelButtonRetryItemLoad:["Retry",ge.STRING],labelButtonAbortItemProcessing:["Cancel",ge.STRING],labelButtonUndoItemProcessing:["Undo",ge.STRING],labelButtonRetryItemProcessing:["Retry",ge.STRING],labelButtonProcessItem:["Upload",ge.STRING],iconRemove:['',ge.STRING],iconProcess:['',ge.STRING],iconRetry:['',ge.STRING],iconUndo:['',ge.STRING],iconDone:['',ge.STRING],oninit:[null,ge.FUNCTION],onwarning:[null,ge.FUNCTION],onerror:[null,ge.FUNCTION],onactivatefile:[null,ge.FUNCTION],oninitfile:[null,ge.FUNCTION],onaddfilestart:[null,ge.FUNCTION],onaddfileprogress:[null,ge.FUNCTION],onaddfile:[null,ge.FUNCTION],onprocessfilestart:[null,ge.FUNCTION],onprocessfileprogress:[null,ge.FUNCTION],onprocessfileabort:[null,ge.FUNCTION],onprocessfilerevert:[null,ge.FUNCTION],onprocessfile:[null,ge.FUNCTION],onprocessfiles:[null,ge.FUNCTION],onremovefile:[null,ge.FUNCTION],onpreparefile:[null,ge.FUNCTION],onupdatefiles:[null,ge.FUNCTION],onreorderfiles:[null,ge.FUNCTION],beforeDropFile:[null,ge.FUNCTION],beforeAddFile:[null,ge.FUNCTION],beforeRemoveFile:[null,ge.FUNCTION],beforePrepareFile:[null,ge.FUNCTION],stylePanelLayout:[null,ge.STRING],stylePanelAspectRatio:[null,ge.STRING],styleItemPanelAspectRatio:[null,ge.STRING],styleButtonRemoveItemPosition:["left",ge.STRING],styleButtonProcessItemPosition:["right",ge.STRING],styleLoadIndicatorPosition:["right",ge.STRING],styleProgressIndicatorPosition:["right",ge.STRING],styleButtonRemoveItemAlign:[!1,ge.BOOLEAN],files:[[],ge.ARRAY],credits:[["https://filepond.com","Powered by FilePond"],ge.ARRAY]},Le=function(e,t){return M(t)?e[0]||null:V(t)?e[t]||null:("object"==typeof t&&(t=t.id),e.find(function(e){return e.id===t})||null)},be=function(e){if(M(e))return e;if(/:/.test(e)){var t=e.split(":");return t[1]/t[0]}return parseFloat(e)},Pe=function(e){return e.filter(function(e){return!e.archived})},Me={EMPTY:0,IDLE:1,ERROR:2,BUSY:3,READY:4},we=null,Ce=[Ie.LOAD_ERROR,Ie.PROCESSING_ERROR,Ie.PROCESSING_REVERT_ERROR],Ne=[Ie.LOADING,Ie.PROCESSING,Ie.PROCESSING_QUEUED,Ie.INIT],Ge=[Ie.PROCESSING_COMPLETE],Ue=function(e){return Ce.includes(e.status)},Be=function(e){return Ne.includes(e.status)},Fe=function(e){return Ge.includes(e.status)},qe=function(e){return H(e.options.server)&&(H(e.options.server.process)||Y(e.options.server.process))},Ve=function(e){return{GET_STATUS:function(){var t=Pe(e.items),n=Me.EMPTY,r=Me.ERROR,o=Me.BUSY,i=Me.IDLE,a=Me.READY;return 0===t.length?n:t.some(Ue)?r:t.some(Be)?o:t.some(Fe)?a:i},GET_ITEM:function(t){return Le(e.items,t)},GET_ACTIVE_ITEM:function(t){return Le(Pe(e.items),t)},GET_ACTIVE_ITEMS:function(){return Pe(e.items)},GET_ITEMS:function(){return e.items},GET_ITEM_NAME:function(t){var n=Le(e.items,t);return n?n.filename:null},GET_ITEM_SIZE:function(t){var n=Le(e.items,t);return n?n.fileSize:null},GET_STYLES:function(){return Object.keys(e.options).filter(function(e){return/^style/.test(e)}).map(function(t){return{name:t,value:e.options[t]}})},GET_PANEL_ASPECT_RATIO:function(){return/circle/.test(e.options.stylePanelLayout)?1:be(e.options.stylePanelAspectRatio)},GET_ITEM_PANEL_ASPECT_RATIO:function(){return e.options.styleItemPanelAspectRatio},GET_ITEMS_BY_STATUS:function(t){return Pe(e.items).filter(function(e){return e.status===t})},GET_TOTAL_ITEMS:function(){return Pe(e.items).length},SHOULD_UPDATE_FILE_INPUT:function(){return e.options.storeAsFile&&function(){if(null===we)try{var e=new DataTransfer;e.items.add(new File(["hello world"],"This_Works.txt"));var t=document.createElement("input");t.setAttribute("type","file"),t.files=e.files,we=1===t.files.length}catch(e){we=!1}return we}()&&!qe(e)},IS_ASYNC:function(){return qe(e)},GET_FILE_SIZE_LABELS:function(e){return{labelBytes:e("GET_LABEL_FILE_SIZE_BYTES")||void 0,labelKilobytes:e("GET_LABEL_FILE_SIZE_KILOBYTES")||void 0,labelMegabytes:e("GET_LABEL_FILE_SIZE_MEGABYTES")||void 0,labelGigabytes:e("GET_LABEL_FILE_SIZE_GIGABYTES")||void 0}}}},xe=function(e,t,n){return Math.max(Math.min(n,e),t)},Ye=function(e){return/^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*)\s*$/i.test(e)},ke=function(e){return(""+e).split("/").pop().split("?").shift()},je=function(e){return e.split(".").pop()},He=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return(t+e).slice(-t.length)},Xe=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date;return e.getFullYear()+"-"+He(e.getMonth()+1,"00")+"-"+He(e.getDate(),"00")+"_"+He(e.getHours(),"00")+"-"+He(e.getMinutes(),"00")+"-"+He(e.getSeconds(),"00")},We=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o="string"==typeof n?e.slice(0,e.size,n):e.slice(0,e.size,e.type);return o.lastModifiedDate=new Date,e._relativePath&&(o._relativePath=e._relativePath),U(t)||(t=Xe()),t&&null===r&&je(t)?o.name=t:(r=r||function(e){if("string"!=typeof e)return"";var t=e.split("/").pop();return/svg/.test(t)?"svg":/zip|compressed/.test(t)?"zip":/plain/.test(t)?"txt":/msword/.test(t)?"doc":/[a-z]+/.test(t)?"jpeg"===t?"jpg":t:""}(o.type),o.name=t+(r?"."+r:"")),o},ze=function(e,t){var n=window.BlobBuilder=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;if(n){var r=new n;return r.append(e),r.getBlob(t)}return new Blob([e],{type:t})},Qe=function(e){return(/^data:(.+);/.exec(e)||[])[1]||null},Ze=function(e){var t=Qe(e);return function(e,t){for(var n=new ArrayBuffer(e.length),r=new Uint8Array(n),o=0;o=200&&a.status<300?r.onload(a):r.onerror(a)},a.onerror=function(){return r.onerror(a)},a.onabort=function(){o=!0,r.onabort()},a.ontimeout=function(){return r.ontimeout(a)},a.open(n.method,t,!0),V(n.timeout)&&(a.timeout=n.timeout),Object.keys(n.headers).forEach(function(e){var t=unescape(encodeURIComponent(n.headers[e]));a.setRequestHeader(e,t)}),n.responseType&&(a.responseType=n.responseType),n.withCredentials&&(a.withCredentials=!0),a.send(e),r},ot=function(e,t,n,r){return{type:e,code:t,body:n,headers:r}},it=function(e){return function(t){e(ot("error",0,"Timeout",t.getAllResponseHeaders()))}},at=function(e){return/\?/.test(e)},st=function(){for(var e="",t=arguments.length,n=new Array(t),r=0;r0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;if("function"==typeof t)return t;if(!t||!U(t.url))return null;var n=t.onload||function(e){return e},r=t.onerror||function(e){return null};return function(o,i,a,s,u,l){var c=rt(o,st(e,t.url),Object.assign({},t,{responseType:"blob"}));return c.onload=function(e){var r=e.getAllResponseHeaders(),a=et(r).name||ke(o);i(ot("load",e.status,"HEAD"===t.method?null:We(n(e.response),a),r))},c.onerror=function(e){a(ot("error",e.status,r(e.response)||e.statusText,e.getAllResponseHeaders()))},c.onheaders=function(e){l(ot("headers",e.status,null,e.getAllResponseHeaders()))},c.ontimeout=it(a),c.onprogress=s,c.onabort=u,c}},lt=0,ct=1,ft=2,dt=3,pt=4,Et=function(e,t,n,r,o,i,a,s,u,l,c){for(var f=[],d=c.chunkTransferId,p=c.chunkServer,E=c.chunkSize,_=c.chunkRetryDelays,T={serverId:d,aborted:!1},I=t.ondata||function(e){return e},v=t.onload||function(e,t){return"HEAD"===t?e.getResponseHeader("Upload-Offset"):e.response},m=t.onerror||function(e){return null},h=Math.floor(r.size/E),g=0;g<=h;g++){var R=g*E,O=r.slice(R,R+E,"application/offset+octet-stream");f[g]={index:g,size:O.size,offset:R,data:O,file:r,progress:0,retries:ue(_),status:lt,error:null,request:null,timeout:null}}var y,D,S,A,L=function(e){return e.status===lt||e.status===dt},b=function(t){if(!T.aborted)if(t=t||f.find(L)){t.status=ft,t.progress=null;var n=p.ondata||function(e){return e},o=p.onerror||function(e){return null},s=p.onload||function(){},l=st(e,p.url,T.serverId),c="function"==typeof p.headers?p.headers(t):Object.assign({},p.headers,{"Content-Type":"application/offset+octet-stream","Upload-Offset":t.offset,"Upload-Length":r.size,"Upload-Name":r.name}),d=t.request=rt(n(t.data),l,Object.assign({},p,{headers:c}));d.onload=function(e){s(e,t.index,f.length),t.status=ct,t.request=null,w()},d.onprogress=function(e,n,r){t.progress=e?n:null,M()},d.onerror=function(e){t.status=dt,t.request=null,t.error=o(e.response)||e.statusText,P(t)||a(ot("error",e.status,o(e.response)||e.statusText,e.getAllResponseHeaders()))},d.ontimeout=function(e){t.status=dt,t.request=null,P(t)||it(a)(e)},d.onabort=function(){t.status=lt,t.request=null,u()}}else f.every(function(e){return e.status===ct})&&i(T.serverId)},P=function(e){return 0!==e.retries.length&&(e.status=pt,clearTimeout(e.timeout),e.timeout=setTimeout(function(){b(e)},e.retries.shift()),!0)},M=function(){var e=f.reduce(function(e,t){return null===e||null===t.progress?null:e+t.progress},0);if(null===e)return s(!1,0,0);var t=f.reduce(function(e,t){return e+t.size},0);s(!0,e,t)},w=function(){f.filter(function(e){return e.status===ft}).length>=1||b()};return T.serverId?(y=function(e){T.aborted||(f.filter(function(t){return t.offset0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0;return"function"==typeof t?function(){for(var e=arguments.length,o=new Array(e),i=0;ir.chunkSize,p=f&&(d||r.chunkForce);if(o instanceof Blob&&p)return Et(e,t,n,o,i,a,s,u,l,c,r);var E=t.ondata||function(e){return e},_=t.onload||function(e){return e},T=t.onerror||function(e){return null},I="function"==typeof t.headers?t.headers(o,i)||{}:Object.assign({},t.headers),v=Object.assign({},t,{headers:I}),m=new FormData;H(i)&&m.append(n,JSON.stringify(i)),(o instanceof Blob?[{name:null,file:o}]:o).forEach(function(e){m.append(n,e.file,null===e.name?e.file.name:""+e.name+e.file.name)});var h=rt(E(m),st(e,t.url),v);return h.onload=function(e){a(ot("load",e.status,_(e.response),e.getAllResponseHeaders()))},h.onerror=function(e){s(ot("error",e.status,T(e.response)||e.statusText,e.getAllResponseHeaders()))},h.ontimeout=it(s),h.onprogress=u,h.onabort=l,h}}}(e,t,n,r):null},Tt=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;if("function"==typeof t)return t;if(!t||!U(t.url))return function(e,t){return t()};var n=t.onload||function(e){return e},r=t.onerror||function(e){return null};return function(o,i,a){var s=rt(o,e+t.url,t);return s.onload=function(e){i(ot("load",e.status,n(e.response),e.getAllResponseHeaders()))},s.onerror=function(e){a(ot("error",e.status,r(e.response)||e.statusText,e.getAllResponseHeaders()))},s.ontimeout=it(a),s}},It=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return e+Math.random()*(t-e)},vt=function(e,t){var n={complete:!1,perceivedProgress:0,perceivedPerformanceUpdater:null,progress:null,timestamp:null,perceivedDuration:0,duration:0,request:null,response:null},r=t.allowMinimumUploadDuration,o=function(){n.request&&(n.perceivedPerformanceUpdater.clear(),n.request.abort&&n.request.abort(),n.complete=!0)},i=r?function(){return n.progress?Math.min(n.progress,n.perceivedProgress):null}:function(){return n.progress||null},a=r?function(){return Math.min(n.duration,n.perceivedDuration)}:function(){return n.duration},s=Object.assign({},pe(),{process:function(t,o){var i=function(){0!==n.duration&&null!==n.progress&&s.fire("progress",s.getProgress())},a=function(){n.complete=!0,s.fire("load-perceived",n.response.body)};s.fire("start"),n.timestamp=Date.now(),n.perceivedPerformanceUpdater=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,n=(arguments.length>2&&void 0!==arguments[2]&&arguments[2],arguments.length>3&&void 0!==arguments[3]?arguments[3]:25),r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:250,o=null,i=Date.now();return t>0&&function a(){var s=Date.now()-i,u=It(n,r);s+u>t&&(u=s+u-t);var l=s/t;l>=1||document.hidden?e(1):(e(l),o=setTimeout(a,u))}(),{clear:function(){clearTimeout(o)}}}(function(e){n.perceivedProgress=e,n.perceivedDuration=Date.now()-n.timestamp,i(),n.response&&1===n.perceivedProgress&&!n.complete&&a()},r?It(750,1500):0),n.request=e(t,o,function(e){n.response=H(e)?e:{type:"load",code:200,body:""+e,headers:{}},n.duration=Date.now()-n.timestamp,n.progress=1,s.fire("load",n.response.body),(!r||r&&1===n.perceivedProgress)&&a()},function(e){n.perceivedPerformanceUpdater.clear(),s.fire("error",H(e)?e:{type:"error",code:0,body:""+e})},function(e,t,r){n.duration=Date.now()-n.timestamp,n.progress=e?t/r:null,i()},function(){n.perceivedPerformanceUpdater.clear(),s.fire("abort",n.response?n.response.body:null)},function(e){s.fire("transfer",e)})},abort:o,getProgress:i,getDuration:a,reset:function(){o(),n.complete=!1,n.perceivedProgress=0,n.progress=0,n.timestamp=null,n.perceivedDuration=0,n.duration=0,n.request=null,n.response=null}});return s},mt=function(e){return e.substring(0,e.lastIndexOf("."))||e},ht=function(e){return!!(e instanceof File||e instanceof Blob&&e.name)},gt=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,o=oe(),i={archived:!1,frozen:!1,released:!1,source:null,file:r,serverFileReference:t,transferId:null,processingAborted:!1,status:t?Ie.PROCESSING_COMPLETE:Ie.INIT,activeLoader:null,activeProcessor:null},a=null,s={},u=function(e){return i.status=e},l=function(e){if(!i.released&&!i.frozen){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r1?t-1:0),r=1;r0&&void 0!==arguments[0]?arguments[0]:{},r=n.query,o=n.success,i=void 0===o?function(){}:o,a=n.failure,s=void 0===a?function(){}:a,u=se(n,["query","success","failure"]),l=Le(e.items,r);l?t(l,i,s,u||{}):s({error:ot("error",0,"Item not found"),file:null})}},Pt=function(e,t,n){return{ABORT_ALL:function(){Pe(n.items).forEach(function(e){e.freeze(),e.abortLoad(),e.abortProcessing()})},DID_SET_FILES:function(t){var r=t.value,o=(void 0===r?[]:r).map(function(e){return{source:e.source?e.source:e,options:e.options}}),i=Pe(n.items);i.forEach(function(t){o.find(function(e){return e.source===t.source||e.source===t.file})||e("REMOVE_ITEM",{query:t,remove:!1})}),i=Pe(n.items),o.forEach(function(t,n){i.find(function(e){return e.source===t.source||e.file===t.source})||e("ADD_ITEM",Object.assign({},t,{interactionMethod:re,index:n}))})},DID_UPDATE_ITEM_METADATA:function(r){var o=r.id,i=r.action,a=r.change;a.silent||(clearTimeout(n.itemUpdateTimeout),n.itemUpdateTimeout=setTimeout(function(){var r=Rt(n.items,o);if(t("IS_ASYNC")){r.origin===ve.LOCAL&&e("DID_LOAD_ITEM",{id:r.id,error:null,serverFileReference:r.source});var s,u=function(){setTimeout(function(){e("REQUEST_ITEM_PROCESSING",{query:o})},32)};return r.status===Ie.PROCESSING_COMPLETE?(s=n.options.instantUpload,void r.revert(Tt(n.options.server.url,n.options.server.revert),t("GET_FORCE_REVERT")).then(s?u:function(){}).catch(function(){})):r.status===Ie.PROCESSING?function(e){r.abortProcessing().then(e?u:function(){})}(n.options.instantUpload):void(n.options.instantUpload&&u())}Oe("SHOULD_PREPARE_OUTPUT",!1,{item:r,query:t,action:i,change:a}).then(function(n){var i=t("GET_BEFORE_PREPARE_FILE");i&&(n=i(r,n)),n&&e("REQUEST_PREPARE_OUTPUT",{query:o,item:r,success:function(t){e("DID_PREPARE_OUTPUT",{id:o,file:t})}},!0)})},0))},MOVE_ITEM:function(e){var t=e.query,r=e.index,o=Le(n.items,t);if(o){var i=n.items.indexOf(o);i!==(r=xe(r,0,n.items.length-1))&&n.items.splice(r,0,n.items.splice(i,1)[0])}},SORT:function(r){var o=r.compare;Lt(n,o),e("DID_SORT_ITEMS",{items:t("GET_ACTIVE_ITEMS")})},ADD_ITEMS:function(n){var r=n.items,o=n.index,i=n.interactionMethod,a=n.success,s=void 0===a?function(){}:a,u=n.failure,l=void 0===u?function(){}:u,c=o;if(-1===o||void 0===o){var f=t("GET_ITEM_INSERT_LOCATION"),d=t("GET_TOTAL_ITEMS");c="before"===f?0:d}var p=t("GET_IGNORED_FILES"),E=r.filter(function(e){return ht(e)?!p.includes(e.name.toLowerCase()):!M(e)}).map(function(t){return new Promise(function(n,r){e("ADD_ITEM",{interactionMethod:i,source:t.source||t,success:n,failure:r,index:c++,options:t.options||{}})})});Promise.all(E).then(s).catch(l)},ADD_ITEM:function(r){var o=r.source,i=r.index,a=void 0===i?-1:i,s=r.interactionMethod,u=r.success,l=void 0===u?function(){}:u,c=r.failure,f=void 0===c?function(){}:c,d=r.options,p=void 0===d?{}:d;if(M(o))f({error:ot("error",0,"No source"),file:null});else if(!ht(o)||!n.options.ignoredFiles.includes(o.name.toLowerCase())){if(!function(e){var t=Pe(e.items).length;if(!e.options.allowMultiple)return 0===t;var n=e.options.maxFiles;return null===n||t=400&&t.code<500)return e("DID_THROW_ITEM_INVALID",{id:h,error:t,status:{main:r,sub:t.code+" ("+t.body+")"}}),void f({error:t,file:Te(v)});e("DID_THROW_ITEM_LOAD_ERROR",{id:h,error:t,status:{main:r,sub:n.options.labelTapToRetry}})}),v.on("load-file-error",function(t){e("DID_THROW_ITEM_INVALID",{id:h,error:t.status,status:t.status}),f({error:t.status,file:Te(v)})}),v.on("load-abort",function(){e("REMOVE_ITEM",{query:h})}),v.on("load-skip",function(){v.on("metadata-update",function(t){ht(v.file)&&e("DID_UPDATE_ITEM_METADATA",{id:h,change:t})}),e("COMPLETE_LOAD_ITEM",{query:h,item:v,data:{source:o,success:l}})}),v.on("load",function(){var r=function(r){r?(v.on("metadata-update",function(t){e("DID_UPDATE_ITEM_METADATA",{id:h,change:t})}),Oe("SHOULD_PREPARE_OUTPUT",!1,{item:v,query:t}).then(function(r){var i=t("GET_BEFORE_PREPARE_FILE");i&&(r=i(v,r));var a=function(){e("COMPLETE_LOAD_ITEM",{query:h,item:v,data:{source:o,success:l}}),St(e,n)};r?e("REQUEST_PREPARE_OUTPUT",{query:h,item:v,success:function(t){e("DID_PREPARE_OUTPUT",{id:h,file:t}),a()}},!0):a()})):e("REMOVE_ITEM",{query:h})};Oe("DID_LOAD_ITEM",v,{query:t,dispatch:e}).then(function(){At(t("GET_BEFORE_ADD_FILE"),Te(v)).then(r)}).catch(function(t){if(!t||!t.error||!t.status)return r(!1);e("DID_THROW_ITEM_INVALID",{id:h,error:t.error,status:t.status})})}),v.on("process-start",function(){e("DID_START_ITEM_PROCESSING",{id:h})}),v.on("process-progress",function(t){e("DID_UPDATE_ITEM_PROCESS_PROGRESS",{id:h,progress:t})}),v.on("process-error",function(t){e("DID_THROW_ITEM_PROCESSING_ERROR",{id:h,error:t,status:{main:Dt(n.options.labelFileProcessingError)(t),sub:n.options.labelTapToRetry}})}),v.on("process-revert-error",function(t){e("DID_THROW_ITEM_PROCESSING_REVERT_ERROR",{id:h,error:t,status:{main:Dt(n.options.labelFileProcessingRevertError)(t),sub:n.options.labelTapToRetry}})}),v.on("process-complete",function(t){e("DID_COMPLETE_ITEM_PROCESSING",{id:h,error:null,serverFileReference:t}),e("DID_DEFINE_VALUE",{id:h,value:t})}),v.on("process-abort",function(){e("DID_ABORT_ITEM_PROCESSING",{id:h})}),v.on("process-revert",function(){e("DID_REVERT_ITEM_PROCESSING",{id:h}),e("DID_DEFINE_VALUE",{id:h,value:null})}),e("DID_ADD_ITEM",{id:h,index:a,interactionMethod:s}),St(e,n);var g=n.options.server||{},R=g.url,O=g.load,y=g.restore,D=g.fetch;v.load(o,tt(I===ve.INPUT?U(o)&&function(e){return(e.indexOf(":")>-1||e.indexOf("//")>-1)&&yt(location.href)!==yt(e)}(o)&&D?ut(R,D):Ot:ut(R,I===ve.LIMBO?y:O)),function(e,n,r){Oe("LOAD_FILE",e,{query:t}).then(n).catch(r)})}},REQUEST_PREPARE_OUTPUT:function(e){var n=e.item,r=e.success,o=e.failure,i=void 0===o?function(){}:o,a={error:ot("error",0,"Item not found"),file:null};if(n.archived)return i(a);Oe("PREPARE_OUTPUT",n.file,{query:t,item:n}).then(function(e){Oe("COMPLETE_PREPARE_OUTPUT",e,{query:t,item:n}).then(function(e){if(n.archived)return i(a);r(e)})})},COMPLETE_LOAD_ITEM:function(r){var o=r.item,i=r.data,a=i.success,s=i.source,u=t("GET_ITEM_INSERT_LOCATION");if(Y(u)&&s&&Lt(n,u),e("DID_LOAD_ITEM",{id:o.id,error:null,serverFileReference:o.origin===ve.INPUT?null:s}),a(Te(o)),o.origin!==ve.LOCAL)return o.origin===ve.LIMBO?(e("DID_COMPLETE_ITEM_PROCESSING",{id:o.id,error:null,serverFileReference:s}),void e("DID_DEFINE_VALUE",{id:o.id,value:o.serverId||s})):void(t("IS_ASYNC")&&n.options.instantUpload&&e("REQUEST_ITEM_PROCESSING",{query:o.id}));e("DID_LOAD_LOCAL_ITEM",{id:o.id})},RETRY_ITEM_LOAD:bt(n,function(e){e.retryLoad()}),REQUEST_ITEM_PREPARE:bt(n,function(t,n,r){e("REQUEST_PREPARE_OUTPUT",{query:t.id,item:t,success:function(r){e("DID_PREPARE_OUTPUT",{id:t.id,file:r}),n({file:t,output:r})},failure:r},!0)}),REQUEST_ITEM_PROCESSING:bt(n,function(r,o,i){if(r.status===Ie.IDLE||r.status===Ie.PROCESSING_ERROR)r.status!==Ie.PROCESSING_QUEUED&&(r.requestProcessing(),e("DID_REQUEST_ITEM_PROCESSING",{id:r.id}),e("PROCESS_ITEM",{query:r,success:o,failure:i},!0));else{var a=function(){return e("REQUEST_ITEM_PROCESSING",{query:r,success:o,failure:i})},s=function(){return document.hidden?a():setTimeout(a,32)};r.status===Ie.PROCESSING_COMPLETE||r.status===Ie.PROCESSING_REVERT_ERROR?r.revert(Tt(n.options.server.url,n.options.server.revert),t("GET_FORCE_REVERT")).then(s).catch(function(){}):r.status===Ie.PROCESSING&&r.abortProcessing().then(s)}}),PROCESS_ITEM:bt(n,function(r,o,i){var a=t("GET_MAX_PARALLEL_UPLOADS");if(t("GET_ITEMS_BY_STATUS",Ie.PROCESSING).length!==a){if(r.status!==Ie.PROCESSING){var s=function t(){var r=n.processingQueue.shift();if(r){var o=r.id,i=r.success,a=r.failure,s=Le(n.items,o);s&&!s.archived?e("PROCESS_ITEM",{query:o,success:i,failure:a},!0):t()}};r.onOnce("process-complete",function(){o(Te(r)),s();var i=n.options.server;if(n.options.instantUpload&&r.origin===ve.LOCAL&&Y(i.remove)){var a=function(){};r.origin=ve.LIMBO,n.options.server.remove(r.source,a,a)}t("GET_ITEMS_BY_STATUS",Ie.PROCESSING_COMPLETE).length===n.items.length&&e("DID_COMPLETE_ITEM_PROCESSING_ALL")}),r.onOnce("process-error",function(e){i({error:e,file:Te(r)}),s()}),r.onOnce("process-abort",function(){s()});var u=n.options;r.process(vt(_t(u.server.url,u.server.process,u.name,{chunkTransferId:r.transferId,chunkServer:u.server.patch,chunkUploads:u.chunkUploads,chunkForce:u.chunkForce,chunkSize:u.chunkSize,chunkRetryDelays:u.chunkRetryDelays}),{allowMinimumUploadDuration:t("GET_ALLOW_MINIMUM_UPLOAD_DURATION")}),function(n,o,i){Oe("PREPARE_OUTPUT",n,{query:t,item:r}).then(function(t){e("DID_PREPARE_OUTPUT",{id:r.id,file:t}),o(t)}).catch(i)})}}else n.processingQueue.push({id:r.id,success:o,failure:i})}),RETRY_ITEM_PROCESSING:bt(n,function(t){e("REQUEST_ITEM_PROCESSING",{query:t})}),REQUEST_REMOVE_ITEM:bt(n,function(n){At(t("GET_BEFORE_REMOVE_FILE"),Te(n)).then(function(t){t&&e("REMOVE_ITEM",{query:n})})}),RELEASE_ITEM:bt(n,function(e){e.release()}),REMOVE_ITEM:bt(n,function(r,o,i,a){var s=function(){var t=r.id;Rt(n.items,t).archive(),e("DID_REMOVE_ITEM",{error:null,id:t,item:r}),St(e,n),o(Te(r))},u=n.options.server;r.origin===ve.LOCAL&&u&&Y(u.remove)&&!1!==a.remove?(e("DID_START_ITEM_REMOVE",{id:r.id}),u.remove(r.source,function(){return s()},function(t){e("DID_THROW_ITEM_REMOVE_ERROR",{id:r.id,error:ot("error",0,t,null),status:{main:Dt(n.options.labelFileRemoveError)(t),sub:n.options.labelTapToRetry}})})):((a.revert&&r.origin!==ve.LOCAL&&null!==r.serverId||n.options.chunkUploads&&r.file.size>n.options.chunkSize||n.options.chunkUploads&&n.options.chunkForce)&&r.revert(Tt(n.options.server.url,n.options.server.revert),t("GET_FORCE_REVERT")),s())}),ABORT_ITEM_LOAD:bt(n,function(e){e.abortLoad()}),ABORT_ITEM_PROCESSING:bt(n,function(t){t.serverId?e("REVERT_ITEM_PROCESSING",{id:t.id}):t.abortProcessing().then(function(){n.options.instantUpload&&e("REMOVE_ITEM",{query:t.id})})}),REQUEST_REVERT_ITEM_PROCESSING:bt(n,function(r){if(n.options.instantUpload){var o=function(t){t&&e("REVERT_ITEM_PROCESSING",{query:r})},i=t("GET_BEFORE_REMOVE_FILE");if(!i)return o(!0);var a=i(Te(r));return null==a?o(!0):"boolean"==typeof a?o(a):void("function"==typeof a.then&&a.then(o))}e("REVERT_ITEM_PROCESSING",{query:r})}),REVERT_ITEM_PROCESSING:bt(n,function(r){r.revert(Tt(n.options.server.url,n.options.server.revert),t("GET_FORCE_REVERT")).then(function(){(n.options.instantUpload||function(e){return!ht(e.file)}(r))&&e("REMOVE_ITEM",{query:r.id})}).catch(function(){})}),SET_OPTIONS:function(t){var n=t.options,r=Object.keys(n),o=Mt.filter(function(e){return r.includes(e)});[].concat(ue(o),ue(Object.keys(n).filter(function(e){return!o.includes(e)}))).forEach(function(t){e("SET_"+Z(t,"_").toUpperCase(),{value:n[t]})})}}},Mt=["server"],wt=function(e){return e},Ct=function(e){return document.createElement(e)},Nt=function(e,t){var n=e.childNodes[0];n?t!==n.nodeValue&&(n.nodeValue=t):(n=document.createTextNode(t),e.appendChild(n))},Gt=function(e,t,n,r){var o=(r%360-90)*Math.PI/180;return{x:e+n*Math.cos(o),y:t+n*Math.sin(o)}},Ut=function(e,t,n,r,o){var i=1;return o>r&&o-r<=.5&&(i=0),r>o&&r-o>=.5&&(i=0),function(e,t,n,r,o,i){var a=Gt(e,t,n,o),s=Gt(e,t,n,r);return["M",a.x,a.y,"A",n,n,0,i,0,s.x,s.y].join(" ")}(e,t,n,360*Math.min(.9999,r),360*Math.min(.9999,o),i)},Bt=S({tag:"div",name:"progress-indicator",ignoreRectUpdate:!0,ignoreRect:!0,create:function(e){var t=e.root,n=e.props;n.spin=!1,n.progress=0,n.opacity=0;var r=a("svg");t.ref.path=a("path",{"stroke-width":2,"stroke-linecap":"round"}),r.appendChild(t.ref.path),t.ref.svg=r,t.appendChild(r)},write:function(e){var t=e.root,n=e.props;if(0!==n.opacity){n.align&&(t.element.dataset.align=n.align);var o=parseInt(r(t.ref.path,"stroke-width"),10),i=.5*t.rect.element.width,a=0,s=0;n.spin?(a=0,s=.5):(a=0,s=n.progress);var u=Ut(i,i,i-o,a,s);r(t.ref.path,"d",u),r(t.ref.path,"stroke-opacity",n.spin||n.progress>0?1:0)}},mixins:{apis:["progress","spin","align"],styles:["opacity"],animations:{opacity:{type:"tween",duration:500},progress:{type:"spring",stiffness:.95,damping:.65,mass:10}}}}),Ft=S({tag:"button",attributes:{type:"button"},ignoreRect:!0,ignoreRectUpdate:!0,name:"file-action-button",mixins:{apis:["label"],styles:["translateX","translateY","scaleX","scaleY","opacity"],animations:{scaleX:"spring",scaleY:"spring",translateX:"spring",translateY:"spring",opacity:{type:"tween",duration:250}},listeners:!0},create:function(e){var t=e.root,n=e.props;t.element.innerHTML=(n.icon||"")+""+n.label+"",n.isDisabled=!1},write:function(e){var t=e.root,n=e.props,o=n.isDisabled,i=t.query("GET_DISABLED")||0===n.opacity;i&&!o?(n.isDisabled=!0,r(t.element,"disabled","disabled")):!i&&o&&(n.isDisabled=!1,t.element.removeAttribute("disabled"))}}),qt=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=r.labelBytes,i=void 0===o?"bytes":o,a=r.labelKilobytes,s=void 0===a?"KB":a,u=r.labelMegabytes,l=void 0===u?"MB":u,c=r.labelGigabytes,f=void 0===c?"GB":c,d=n,p=n*n,E=n*n*n;return(e=Math.round(Math.abs(e)))0&&(t.height=t.ref.container.rect.element.height)),o&&(t.ref.panel.height=null),t.ref.panel.height=t.height}),mn=S({create:function(e){var t=e.root,n=e.props;t.ref.handleClick=function(e){return t.dispatch("DID_ACTIVATE_ITEM",{id:n.id})},t.element.id="filepond--item-"+n.id,t.element.addEventListener("click",t.ref.handleClick),t.ref.container=t.appendChildView(t.createChildView(fn,{id:n.id})),t.ref.panel=t.appendChildView(t.createChildView(En,{name:"item-panel"})),t.ref.panel.height=null,n.markedForRemoval=!1,t.query("GET_ALLOW_REORDER")&&(t.element.dataset.dragState="idle",t.element.addEventListener("pointerdown",function(e){if(e.isPrimary){var r=!1,o=e.pageX,i=e.pageY;n.dragOrigin={x:t.translateX,y:t.translateY},n.dragCenter={x:e.offsetX,y:e.offsetY};var a,s,u,l=(a=t.query("GET_ACTIVE_ITEMS"),s=a.map(function(e){return e.id}),u=void 0,{setIndex:function(e){u=e},getIndex:function(){return u},getItemIndex:function(e){return s.indexOf(e.id)}});t.dispatch("DID_GRAB_ITEM",{id:n.id,dragState:l});var c=function(e){e.isPrimary&&(e.stopPropagation(),e.preventDefault(),n.dragOffset={x:e.pageX-o,y:e.pageY-i},n.dragOffset.x*n.dragOffset.x+n.dragOffset.y*n.dragOffset.y>16&&!r&&(r=!0,t.element.removeEventListener("click",t.ref.handleClick)),t.dispatch("DID_DRAG_ITEM",{id:n.id,dragState:l}))},f=function(e){e.isPrimary&&(n.dragOffset={x:e.pageX-o,y:e.pageY-i},p())},d=function(){p()},p=function(){document.removeEventListener("pointercancel",d),document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",f),t.dispatch("DID_DROP_ITEM",{id:n.id,dragState:l}),r&&setTimeout(function(){return t.element.addEventListener("click",t.ref.handleClick)},0)};document.addEventListener("pointercancel",d),document.addEventListener("pointermove",c),document.addEventListener("pointerup",f)}}))},write:vn,destroy:function(e){var t=e.root,n=e.props;t.element.removeEventListener("click",t.ref.handleClick),t.dispatch("RELEASE_ITEM",{query:n.id})},tag:"li",name:"item",mixins:{apis:["id","interactionMethod","markedForRemoval","spawnDate","dragCenter","dragOrigin","dragOffset"],styles:["translateX","translateY","scaleX","scaleY","opacity","height"],animations:{scaleX:"spring",scaleY:"spring",translateX:_n,translateY:_n,opacity:{type:"tween",duration:150}}}}),hn=function(e,t){return Math.max(1,Math.floor((e+1)/t))},gn=function(e,t,n){if(n){var r=e.rect.element.width,o=t.length,i=null;if(0===o||n.topv){if(n.left3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1;e.dragOffset?(e.translateX=null,e.translateY=null,e.translateX=e.dragOrigin.x+e.dragOffset.x,e.translateY=e.dragOrigin.y+e.dragOffset.y,e.scaleX=1.025,e.scaleY=1.025):(e.translateX=t,e.translateY=n,Date.now()>e.spawnDate&&(0===e.opacity&&yn(e,t,n,r,o),e.scaleX=1,e.scaleY=1,e.opacity=1))},yn=function(e,t,n,r,o){e.interactionMethod===re?(e.translateX=null,e.translateX=t,e.translateY=null,e.translateY=n):e.interactionMethod===ee?(e.translateX=null,e.translateX=t-20*r,e.translateY=null,e.translateY=n-10*o,e.scaleX=.8,e.scaleY=.8):e.interactionMethod===te?(e.translateY=null,e.translateY=n-30):e.interactionMethod===J&&(e.translateX=null,e.translateX=t-30,e.translateY=null)},Dn=function(e){return e.rect.element.height+e.rect.element.marginBottom+e.rect.element.marginTop},Sn=A({DID_ADD_ITEM:function(e){var t=e.root,n=e.action,r=n.id,o=n.index,i=n.interactionMethod;t.ref.addIndex=o;var a=Date.now(),s=a,u=1;if(i!==re){u=0;var l=t.query("GET_ITEM_INSERT_INTERVAL"),c=a-t.ref.lastItemSpanwDate;s=cs&&(E=s);var _=Math.floor(s/E+1);Rn.setHeight=d*_,Rn.setWidth=p*E;var T={y:Math.floor(f/d),x:Math.floor(c/p),getGridIndex:function(){return f>Rn.getHeight||f<0||c>Rn.getWidth||c<0?u:this.y*E+this.x},getColIndex:function(){for(var e=t.query("GET_ACTIVE_ITEMS"),n=t.childViews.filter(function(e){return e.rect.element.height}),r=e.map(function(e){return n.find(function(t){return t.id===e.id})}),o=r.findIndex(function(e){return e===a}),i=Dn(a),s=r.length,u=s,l=0,c=0,d=0,p=0;pp){if(f1?T.getGridIndex():T.getColIndex();t.dispatch("MOVE_ITEM",{query:a,index:I});var v=o.getIndex();if(void 0===v||v!==I){if(o.setIndex(I),void 0===v)return;t.dispatch("DID_REORDER_ITEMS",{items:t.query("GET_ACTIVE_ITEMS"),origin:u,target:I})}}}}),An=S({create:function(e){var t=e.root;r(t.element,"role","list"),t.ref.lastItemSpanwDate=Date.now()},write:function(e){var t=e.root,n=e.props,r=e.actions,o=e.shouldOptimize;Sn({root:t,props:n,actions:r});var i=n.dragCoordinates,a=t.rect.element.width,s=t.childViews.filter(function(e){return e.rect.element.height}),u=t.query("GET_ACTIVE_ITEMS").map(function(e){return s.find(function(t){return t.id===e.id})}).filter(function(e){return e}),l=i?gn(t,u,i):null,c=t.ref.addIndex||null;t.ref.addIndex=null;var f=0,d=0,p=0;if(0!==u.length){var E=u[0].rect.element,_=E.marginTop+E.marginBottom,T=E.marginLeft+E.marginRight,I=E.width+T,v=E.height+_,m=hn(a,I);if(1===m){var h=0,g=0;u.forEach(function(e,t){if(l){var n=t-l;g=-2===n?.25*-_:-1===n?.75*-_:0===n?.75*_:1===n?.25*_:0}o&&(e.translateX=null,e.translateY=null),e.markedForRemoval||On(e,0,h+g);var r=(e.rect.element.height+_)*(e.markedForRemoval?e.opacity:1);h+=r})}else{var R=0,O=0;u.forEach(function(e,t){t===l&&(f=1),t===c&&(p+=1),e.markedForRemoval&&e.opacity<.5&&(d-=1);var n=t+p+f+d,r=n%m,i=Math.floor(n/m),a=r*I,s=i*v,u=Math.sign(a-R),E=Math.sign(s-O);R=a,O=s,e.markedForRemoval||(o&&(e.translateX=null,e.translateY=null),On(e,a,s,u,E))})}}},tag:"ul",name:"list",didWriteView:function(e){var t=e.root;t.childViews.filter(function(e){return e.markedForRemoval&&0===e.opacity&&e.resting}).forEach(function(e){e._destroy(),t.removeChildView(e)})},filterFrameActionsForChild:function(e,t){return t.filter(function(t){return!t.data||!t.data.id||e.id===t.data.id})},mixins:{apis:["dragCoordinates"]}}),Ln=A({DID_DRAG:function(e){var t=e.root,n=e.props,r=e.action;t.query("GET_ITEM_INSERT_LOCATION_FREEDOM")&&(n.dragCoordinates={left:r.position.scopeLeft-t.ref.list.rect.element.left,top:r.position.scopeTop-(t.rect.outer.top+t.rect.element.marginTop+t.rect.element.scrollTop)})},DID_END_DRAG:function(e){e.props.dragCoordinates=null}}),bn=S({create:function(e){var t=e.root,n=e.props;t.ref.list=t.appendChildView(t.createChildView(An)),n.dragCoordinates=null,n.overflowing=!1},write:function(e){var t=e.root,n=e.props,r=e.actions;if(Ln({root:t,props:n,actions:r}),t.ref.list.dragCoordinates=n.dragCoordinates,n.overflowing&&!n.overflow&&(n.overflowing=!1,t.element.dataset.state="",t.height=null),n.overflow){var o=Math.round(n.overflow);o!==t.height&&(n.overflowing=!0,t.element.dataset.state="overflow",t.height=o)}},name:"list-scroller",mixins:{apis:["overflow","dragCoordinates"],styles:["height","translateY"],animations:{translateY:"spring"}}}),Pn=function(e,t,n){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";n?r(e,t,o):e.removeAttribute(t)},Mn=function(e){var t=e.root,n=e.action;t.query("GET_ALLOW_SYNC_ACCEPT_ATTRIBUTE")&&Pn(t.element,"accept",!!n.value,n.value?n.value.join(","):"")},wn=function(e){var t=e.root,n=e.action;Pn(t.element,"multiple",n.value)},Cn=function(e){var t=e.root,n=e.action;Pn(t.element,"webkitdirectory",n.value)},Nn=function(e){var t=e.root,n=t.query("GET_DISABLED"),r=t.query("GET_ALLOW_BROWSE"),o=n||!r;Pn(t.element,"disabled",o)},Gn=function(e){var t=e.root;e.action.value?0===t.query("GET_TOTAL_ITEMS")&&Pn(t.element,"required",!0):Pn(t.element,"required",!1)},Un=function(e){var t=e.root,n=e.action;Pn(t.element,"capture",!!n.value,!0===n.value?"":n.value)},Bn=function(e){var t=e.root,n=t.element;if(t.query("GET_TOTAL_ITEMS")>0){Pn(n,"required",!1),Pn(n,"name",!1);for(var r=t.query("GET_ACTIVE_ITEMS"),o=!1,i=0;i0&&void 0!==arguments[0]?arguments[0]:"";return e=e.toLowerCase(),$n.includes(e)?"image/"+("jpg"===e?"jpeg":"svg"===e?"svg+xml":e):Jn.includes(e)?"text/"+e:er[e]||""},nr=function(e){return new Promise(function(t,n){var r=dr(e);if(r.length&&!rr(e))return t(r);or(e).then(t)})},rr=function(e){return!!e.files&&e.files.length>0},or=function(e){return new Promise(function(t,n){var r=(e.items?Array.from(e.items):[]).filter(function(e){return ir(e)}).map(function(e){return ar(e)});r.length?Promise.all(r).then(function(e){var n=[];e.forEach(function(e){n.push.apply(n,e)}),t(n.filter(function(e){return e}).map(function(e){return e._relativePath||(e._relativePath=e.webkitRelativePath),e}))}).catch(console.error):t(e.files?Array.from(e.files):[])})},ir=function(e){if(cr(e)){var t=fr(e);if(t)return t.isFile||t.isDirectory}return"file"===e.kind},ar=function(e){return new Promise(function(t,n){lr(e)?sr(fr(e)).then(t).catch(n):t([e.getAsFile()])})},sr=function(e){return new Promise(function(t,n){var r=[],o=0,i=0,a=function(){0===i&&0===o&&t(r)};!function e(t){o++;var s=t.createReader();!function t(){s.readEntries(function(n){if(0===n.length)return o--,void a();n.forEach(function(t){t.isDirectory?e(t):(i++,t.file(function(e){var n=ur(e);t.fullPath&&(n._relativePath=t.fullPath),r.push(n),i--,a()}))}),t()},n)}()}(e)})},ur=function(e){if(e.type.length)return e;var t=e.lastModifiedDate,n=e.name,r=tr(je(e.name));return r.length?((e=e.slice(0,e.size,r)).name=n,e.lastModifiedDate=t,e):e},lr=function(e){return cr(e)&&(fr(e)||{}).isDirectory},cr=function(e){return"webkitGetAsEntry"in e},fr=function(e){return e.webkitGetAsEntry()},dr=function(e){var t=[];try{if((t=Er(e)).length)return t;t=pr(e)}catch(e){}return t},pr=function(e){var t=e.getData("url");return"string"==typeof t&&t.length?[t]:[]},Er=function(e){var t=e.getData("text/html");if("string"==typeof t&&t.length){var n=t.match(/src\s*=\s*"(.+?)"/);if(n)return[n[1]]}return[]},_r=[],Tr=function(e){return{pageLeft:e.pageX,pageTop:e.pageY,scopeLeft:e.offsetX||e.layerX,scopeTop:e.offsetY||e.layerY}},Ir=function(e){var t=_r.find(function(t){return t.element===e});if(t)return t;var n=vr(e);return _r.push(n),n},vr=function(e){var n=[],r={dragenter:Rr,dragover:Or,dragleave:Dr,drop:yr},o={};t(r,function(t,r){o[t]=r(e,n),e.addEventListener(t,o[t],!1)});var i={element:e,addListener:function(a){return n.push(a),function(){n.splice(n.indexOf(a),1),0===n.length&&(_r.splice(_r.indexOf(i),1),t(r,function(t){e.removeEventListener(t,o[t],!1)}))}}};return i},mr=function(e,t){var n,r=function(e,t){return"elementFromPoint"in e||(e=document),e.elementFromPoint(t.x,t.y)}("getRootNode"in(n=t)?n.getRootNode():document,{x:e.pageX-window.pageXOffset,y:e.pageY-window.pageYOffset});return r===t||t.contains(r)},hr=null,gr=function(e,t){try{e.dropEffect=t}catch(e){}},Rr=function(e,t){return function(e){e.preventDefault(),hr=e.target,t.forEach(function(t){var n=t.element,r=t.onenter;mr(e,n)&&(t.state="enter",r(Tr(e)))})}},Or=function(e,t){return function(e){e.preventDefault();var n=e.dataTransfer;nr(n).then(function(r){var o=!1;t.some(function(t){var i=t.filterElement,a=t.element,s=t.onenter,u=t.onexit,l=t.ondrag,c=t.allowdrop;gr(n,"copy");var f=c(r);if(f)if(mr(e,a)){if(o=!0,null===t.state)return t.state="enter",void s(Tr(e));if(t.state="over",i&&!f)return void gr(n,"none");l(Tr(e))}else i&&!o&&gr(n,"none"),t.state&&(t.state=null,u(Tr(e)));else gr(n,"none")})})}},yr=function(e,t){return function(e){e.preventDefault();var n=e.dataTransfer;nr(n).then(function(n){t.forEach(function(t){var r=t.filterElement,o=t.element,i=t.ondrop,a=t.onexit,s=t.allowdrop;if(t.state=null,!r||mr(e,o))return s(n)?void i(Tr(e),n):a(Tr(e))})})}},Dr=function(e,t){return function(e){hr===e.target&&t.forEach(function(t){var n=t.onexit;t.state=null,n(Tr(e))})}},Sr=function(e,t,n){e.classList.add("filepond--hopper");var r=n.catchesDropsOnPage,o=n.requiresDropOnElement,i=n.filterItems,a=void 0===i?function(e){return e}:i,s=function(e,t,n){var r=Ir(t),o={element:e,filterElement:n,state:null,ondrop:function(){},onenter:function(){},ondrag:function(){},onexit:function(){},onload:function(){},allowdrop:function(){}};return o.destroy=r.addListener(o),o}(e,r?document.documentElement:e,o),u="",l="";s.allowdrop=function(e){return t(a(e))},s.ondrop=function(e,n){var r=a(n);t(r)?(l="drag-drop",c.onload(r,e)):c.ondragend(e)},s.ondrag=function(e){c.ondrag(e)},s.onenter=function(e){l="drag-over",c.ondragstart(e)},s.onexit=function(e){l="drag-exit",c.ondragend(e)};var c={updateHopperState:function(){u!==l&&(e.dataset.hopperState=l,u=l)},onload:function(){},ondragstart:function(){},ondrag:function(){},ondragend:function(){},destroy:function(){s.destroy()}};return c},Ar=!1,Lr=[],br=function(e){var t=document.activeElement;if(t&&(/textarea|input/i.test(t.nodeName)||"true"===t.getAttribute("contenteditable")||""===t.getAttribute("contenteditable"))){for(var n=!1,r=t;r!==document.body;){if(r.classList.contains("filepond--root")){n=!0;break}r=r.parentNode}if(!n)return}nr(e.clipboardData).then(function(e){e.length&&Lr.forEach(function(t){return t(e)})})},Pr=function(){var e=function(e){t.onload(e)},t={destroy:function(){var t;t=e,de(Lr,Lr.indexOf(t)),0===Lr.length&&(document.removeEventListener("paste",br),Ar=!1)},onload:function(){}};return function(e){Lr.includes(e)||(Lr.push(e),Ar||(Ar=!0,document.addEventListener("paste",br)))}(e),t},Mr=null,wr=null,Cr=[],Nr=function(e,t){e.element.textContent=t},Gr=function(e,t,n){var r=e.query("GET_TOTAL_ITEMS");Nr(e,n+" "+t+", "+r+" "+(1===r?e.query("GET_LABEL_FILE_COUNT_SINGULAR"):e.query("GET_LABEL_FILE_COUNT_PLURAL"))),clearTimeout(wr),wr=setTimeout(function(){!function(e){e.element.textContent=""}(e)},1500)},Ur=function(e){return e.element.parentNode.contains(document.activeElement)},Br=function(e){var t=e.root,n=e.action,r=t.query("GET_ITEM",n.id).filename,o=t.query("GET_LABEL_FILE_PROCESSING_ABORTED");Nr(t,r+" "+o)},Fr=function(e){var t=e.root,n=e.action,r=t.query("GET_ITEM",n.id).filename;Nr(t,n.status.main+" "+r+" "+n.status.sub)},qr=S({create:function(e){var t=e.root,n=e.props;t.element.id="filepond--assistant-"+n.id,r(t.element,"role","alert"),r(t.element,"aria-live","polite"),r(t.element,"aria-relevant","additions")},ignoreRect:!0,ignoreRectUpdate:!0,write:A({DID_LOAD_ITEM:function(e){var t=e.root,n=e.action;if(Ur(t)){t.element.textContent="";var r=t.query("GET_ITEM",n.id);Cr.push(r.filename),clearTimeout(Mr),Mr=setTimeout(function(){Gr(t,Cr.join(", "),t.query("GET_LABEL_FILE_ADDED")),Cr.length=0},750)}},DID_REMOVE_ITEM:function(e){var t=e.root,n=e.action;if(Ur(t)){var r=n.item;Gr(t,r.filename,t.query("GET_LABEL_FILE_REMOVED"))}},DID_COMPLETE_ITEM_PROCESSING:function(e){var t=e.root,n=e.action,r=t.query("GET_ITEM",n.id).filename,o=t.query("GET_LABEL_FILE_PROCESSING_COMPLETE");Nr(t,r+" "+o)},DID_ABORT_ITEM_PROCESSING:Br,DID_REVERT_ITEM_PROCESSING:Br,DID_THROW_ITEM_REMOVE_ERROR:Fr,DID_THROW_ITEM_LOAD_ERROR:Fr,DID_THROW_ITEM_INVALID:Fr,DID_THROW_ITEM_PROCESSING_ERROR:Fr}),tag:"span",name:"assistant"}),Vr=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"-";return e.replace(new RegExp(t+".","g"),function(e){return e.charAt(1).toUpperCase()})},xr=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=Date.now(),o=null;return function(){for(var i=arguments.length,a=new Array(i),s=0;s=0?1:0,_=a.find(function(e){return e.markedForRemoval&&e.opacity<.45})?-1:0,T=a.length+E+_,I=hn(s,d);return 1===I?a.forEach(function(e){var r=e.rect.element.height+c;n+=r,t+=r*e.opacity}):(n=Math.ceil(T/I)*p,t=n),{visual:t,bounds:n}},Hr=function(e){var t=e.ref.measureHeight||null;return{cappedHeight:parseInt(e.style.maxHeight,10)||null,fixedHeight:0===t?null:t}},Xr=function(e,t){var n=e.query("GET_ALLOW_REPLACE"),r=e.query("GET_ALLOW_MULTIPLE"),o=e.query("GET_TOTAL_ITEMS"),i=e.query("GET_MAX_FILES"),a=t.length;return!r&&a>1?(e.dispatch("DID_THROW_MAX_FILES",{source:t,error:ot("warning",0,"Max files")}),!0):!(!r&&n)&&(!!(V(i=r?i:1)&&o+a>i)&&(e.dispatch("DID_THROW_MAX_FILES",{source:t,error:ot("warning",0,"Max files")}),!0))},Wr=function(e,t,n){var r=e.childViews[0];return gn(r,t,{left:n.scopeLeft-r.rect.element.left,top:n.scopeTop-(e.rect.outer.top+e.rect.element.marginTop+e.rect.element.scrollTop)})},zr=function(e){var t=e.query("GET_ALLOW_DROP"),n=e.query("GET_DISABLED"),r=t&&!n;if(r&&!e.ref.hopper){var o=Sr(e.element,function(t){var n=e.query("GET_BEFORE_DROP_FILE")||function(){return!0};return!e.query("GET_DROP_VALIDATION")||t.every(function(t){return ye("ALLOW_HOPPER_ITEM",t,{query:e.query}).every(function(e){return!0===e})&&n(t)})},{filterItems:function(t){var n=e.query("GET_IGNORED_FILES");return t.filter(function(e){return!ht(e)||!n.includes(e.name.toLowerCase())})},catchesDropsOnPage:e.query("GET_DROP_ON_PAGE"),requiresDropOnElement:e.query("GET_DROP_ON_ELEMENT")});o.onload=function(t,n){var r=e.ref.list.childViews[0].childViews.filter(function(e){return e.rect.element.height}),o=e.query("GET_ACTIVE_ITEMS").map(function(e){return r.find(function(t){return t.id===e.id})}).filter(function(e){return e});Oe("ADD_ITEMS",t,{dispatch:e.dispatch}).then(function(t){if(Xr(e,t))return!1;e.dispatch("ADD_ITEMS",{items:t,index:Wr(e.ref.list,o,n),interactionMethod:ee})}),e.dispatch("DID_DROP",{position:n}),e.dispatch("DID_END_DRAG",{position:n})},o.ondragstart=function(t){e.dispatch("DID_START_DRAG",{position:t})},o.ondrag=xr(function(t){e.dispatch("DID_DRAG",{position:t})}),o.ondragend=function(t){e.dispatch("DID_END_DRAG",{position:t})},e.ref.hopper=o,e.ref.drip=e.appendChildView(e.createChildView(Hn))}else!r&&e.ref.hopper&&(e.ref.hopper.destroy(),e.ref.hopper=null,e.removeChildView(e.ref.drip))},Qr=function(e,t){var n=e.query("GET_ALLOW_BROWSE"),r=e.query("GET_DISABLED"),o=n&&!r;o&&!e.ref.browser?e.ref.browser=e.appendChildView(e.createChildView(Fn,Object.assign({},t,{onload:function(t){Oe("ADD_ITEMS",t,{dispatch:e.dispatch}).then(function(t){if(Xr(e,t))return!1;e.dispatch("ADD_ITEMS",{items:t,index:-1,interactionMethod:te})})}})),0):!o&&e.ref.browser&&(e.removeChildView(e.ref.browser),e.ref.browser=null)},Zr=function(e){var t=e.query("GET_ALLOW_PASTE"),n=e.query("GET_DISABLED"),r=t&&!n;r&&!e.ref.paster?(e.ref.paster=Pr(),e.ref.paster.onload=function(t){Oe("ADD_ITEMS",t,{dispatch:e.dispatch}).then(function(t){if(Xr(e,t))return!1;e.dispatch("ADD_ITEMS",{items:t,index:-1,interactionMethod:ne})})}):!r&&e.ref.paster&&(e.ref.paster.destroy(),e.ref.paster=null)},Kr=A({DID_SET_ALLOW_BROWSE:function(e){var t=e.root,n=e.props;Qr(t,n)},DID_SET_ALLOW_DROP:function(e){var t=e.root;zr(t)},DID_SET_ALLOW_PASTE:function(e){var t=e.root;Zr(t)},DID_SET_DISABLED:function(e){var t=e.root,n=e.props;zr(t),Zr(t),Qr(t,n),t.query("GET_DISABLED")?t.element.dataset.disabled="disabled":t.element.removeAttribute("data-disabled")}}),$r=S({name:"root",read:function(e){var t=e.root;t.ref.measure&&(t.ref.measureHeight=t.ref.measure.offsetHeight)},create:function(e){var t=e.root,n=e.props,r=t.query("GET_ID");r&&(t.element.id=r);var o=t.query("GET_CLASS_NAME");o&&o.split(" ").filter(function(e){return e.length}).forEach(function(e){t.element.classList.add(e)}),t.ref.label=t.appendChildView(t.createChildView(Yn,Object.assign({},n,{translateY:null,caption:t.query("GET_LABEL_IDLE")}))),t.ref.list=t.appendChildView(t.createChildView(bn,{translateY:null})),t.ref.panel=t.appendChildView(t.createChildView(En,{name:"panel-root"})),t.ref.assistant=t.appendChildView(t.createChildView(qr,Object.assign({},n))),t.ref.data=t.appendChildView(t.createChildView(Kn,Object.assign({},n))),t.ref.measure=Ct("div"),t.ref.measure.style.height="100%",t.element.appendChild(t.ref.measure),t.ref.bounds=null,t.query("GET_STYLES").filter(function(e){return!M(e.value)}).map(function(e){var n=e.name,r=e.value;t.element.dataset[n]=r}),t.ref.widthPrevious=null,t.ref.widthUpdated=xr(function(){t.ref.updateHistory=[],t.dispatch("DID_RESIZE_ROOT")},250),t.ref.previousAspectRatio=null,t.ref.updateHistory=[];var i=window.matchMedia("(pointer: fine) and (hover: hover)").matches,a="PointerEvent"in window;t.query("GET_ALLOW_REORDER")&&a&&!i&&(t.element.addEventListener("touchmove",Yr,{passive:!1}),t.element.addEventListener("gesturestart",Yr));var s=t.query("GET_CREDITS");if(2===s.length){var u=document.createElement("a");u.className="filepond--credits",u.href=s[0],u.tabIndex=-1,u.target="_blank",u.rel="noopener noreferrer nofollow",u.textContent=s[1],t.element.appendChild(u),t.ref.credits=u}},write:function(e){var t=e.root,n=e.props,r=e.actions;if(Kr({root:t,props:n,actions:r}),r.filter(function(e){return/^DID_SET_STYLE_/.test(e.type)}).filter(function(e){return!M(e.data.value)}).map(function(e){var n=e.type,r=e.data,o=Vr(n.substring(8).toLowerCase(),"_");t.element.dataset[o]=r.value,t.invalidateLayout()}),!t.rect.element.hidden){t.rect.element.width!==t.ref.widthPrevious&&(t.ref.widthPrevious=t.rect.element.width,t.ref.widthUpdated());var o=t.ref.bounds;o||(o=t.ref.bounds=Hr(t),t.element.removeChild(t.ref.measure),t.ref.measure=null);var i=t.ref,a=i.hopper,s=i.label,u=i.list,l=i.panel;a&&a.updateHopperState();var c=t.query("GET_PANEL_ASPECT_RATIO"),f=t.query("GET_ALLOW_MULTIPLE"),d=t.query("GET_TOTAL_ITEMS"),p=d===(f?t.query("GET_MAX_FILES")||1e6:1),E=r.find(function(e){return"DID_ADD_ITEM"===e.type});if(p&&E){var _=E.data.interactionMethod;s.opacity=0,f?s.translateY=-40:_===J?s.translateX=40:s.translateY=_===te?40:30}else p||(s.opacity=1,s.translateX=0,s.translateY=0);var T=kr(t),I=jr(t),v=s.rect.element.height,m=!f||p?0:v,h=p?u.rect.element.marginTop:0,g=0===d?0:u.rect.element.marginBottom,R=m+h+I.visual+g,O=m+h+I.bounds+g;if(u.translateY=Math.max(0,m-u.rect.element.marginTop)-T.top,c){var y=t.rect.element.width,D=y*c;c!==t.ref.previousAspectRatio&&(t.ref.previousAspectRatio=c,t.ref.updateHistory=[]);var S=t.ref.updateHistory;if(S.push(y),S.length>4)for(var A=S.length,L=A-10,b=0,P=A;P>=L;P--)if(S[P]===S[P-2]&&b++,b>=2)return;l.scalable=!1,l.height=D;var w=D-m-(g-T.bottom)-(p?h:0);I.visual>w?u.overflow=w:u.overflow=null,t.height=D}else if(o.fixedHeight){l.scalable=!1;var C=o.fixedHeight-m-(g-T.bottom)-(p?h:0);I.visual>C?u.overflow=C:u.overflow=null}else if(o.cappedHeight){var N=R>=o.cappedHeight,G=Math.min(o.cappedHeight,R);l.scalable=!0,l.height=N?G:G-T.top-T.bottom;var U=G-m-(g-T.bottom)-(p?h:0);R>o.cappedHeight&&I.visual>U?u.overflow=U:u.overflow=null,t.height=Math.min(o.cappedHeight,O-T.top-T.bottom)}else{var B=d>0?T.top+T.bottom:0;l.scalable=!0,l.height=Math.max(v,R-B),t.height=Math.max(v,O-B)}t.ref.credits&&l.heightCurrent&&(t.ref.credits.style.transform="translateY("+l.heightCurrent+"px)")}},destroy:function(e){var t=e.root;t.ref.paster&&t.ref.paster.destroy(),t.ref.hopper&&t.ref.hopper.destroy(),t.element.removeEventListener("touchmove",Yr),t.element.removeEventListener("gesturestart",Yr)},mixins:{styles:["height"]}}),Jr=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=null,o=Se(),i=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=Object.assign({},e),o=[],i=[],a=function(e,t,n){!n||document.hidden?(c[e]&&c[e](t),o.push({type:e,data:t})):i.push({type:e,data:t})},s=function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(n,r){y([{source:e,options:t}],{index:t.index}).then(function(e){return n(e&&e[0])}).catch(r)})},addFiles:y,getFile:function(e){return i.query("GET_ACTIVE_ITEM",e)},processFile:S,prepareFile:R,removeFile:O,moveFile:function(e,t){return i.dispatch("MOVE_ITEM",{query:e,index:t})},getFiles:D,processFiles:function(){for(var e=arguments.length,t=new Array(e),n=0;n0&&void 0!==arguments[0]?arguments[0]:{},n={};return t(Se(),function(e,t){n[e]=t[0]}),Jr(Object.assign({},n,{},e))},to=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=[];t(e.attributes,function(t){o.push(e.attributes[t])});var i=o.filter(function(e){return e.name}).reduce(function(t,n){var o,i=r(e,n.name);return t[(o=n.name,Vr(o.replace(/^data-/,"")))]=i===n.name||i,t},{});return function e(n,r){t(r,function(r,o){t(n,function(e,t){var i=new RegExp(r);if(i.test(e)&&(delete n[e],!1!==o))if(U(o))n[o]=t;else{var a,s=o.group;H(o)&&!n[s]&&(n[s]={}),n[s][(a=e.replace(i,""),a.charAt(0).toLowerCase()+a.slice(1))]=t}}),o.mapping&&e(n[o.group],o.mapping)})}(i,n),i},no=function(){return(arguments.length<=0?void 0:arguments[0])instanceof HTMLElement?function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={"^class$":"className","^multiple$":"allowMultiple","^capture$":"captureMethod","^webkitdirectory$":"allowDirectoriesOnly","^server":{group:"server",mapping:{"^process":{group:"process"},"^revert":{group:"revert"},"^fetch":{group:"fetch"},"^restore":{group:"restore"},"^load":{group:"load"}}},"^type$":!1,"^files$":!1};ye("SET_ATTRIBUTE_TO_OPTION_MAP",n);var r=Object.assign({},t),o=to("FIELDSET"===e.nodeName?e.querySelector("input[type=file]"):e,n);Object.keys(o).forEach(function(e){H(o[e])?(H(r[e])||(r[e]={}),Object.assign(r[e],o[e])):r[e]=o[e]}),r.files=(t.files||[]).concat(Array.from(e.querySelectorAll("input:not([type=file])")).map(function(e){return{source:e.value,options:{type:e.dataset.type}}}));var i=eo(r);return e.files&&Array.from(e.files).forEach(function(e){i.addFile(e)}),i.replaceElement(e),i}.apply(void 0,arguments):eo.apply(void 0,arguments)},ro=["fire","_read","_write"],oo=function(e){var t={};return Ee(e,t,ro),t},io=function(e,t){return e.replace(/(?:{([a-zA-Z]+)})/g,function(e,n){return t[n]})},ao=function(e){var t=new Blob(["(",e.toString(),")()"],{type:"application/javascript"}),n=URL.createObjectURL(t),r=new Worker(n);return{transfer:function(e,t){},post:function(e,t,n){var o=oe();r.onmessage=function(e){e.data.id===o&&t(e.data.message)},r.postMessage({id:o,message:e},n)},terminate:function(){r.terminate(),URL.revokeObjectURL(n)}}},so=function(e){return new Promise(function(t,n){var r=new Image;r.onload=function(){t(r)},r.onerror=function(e){n(e)},r.src=e})},uo=function(e,t){var n=e.slice(0,e.size,e.type);return n.lastModifiedDate=e.lastModifiedDate,n.name=t,n},lo=function(e){return uo(e,e.name)},co=[],fo=function(e){if(!co.includes(e)){co.push(e);var n,r=e({addFilter:De,utils:{Type:ge,forin:t,isString:U,isFile:ht,toNaturalFileSize:qt,replaceInString:io,getExtensionFromFilename:je,getFilenameWithoutExtension:mt,guesstimateMimeType:tr,getFileFromBlob:We,getFilenameFromURL:ke,createRoute:A,createWorker:ao,createView:S,createItemAPI:Te,loadImage:so,copyFile:lo,renameFile:uo,createBlob:ze,applyFilterChain:Oe,text:Nt,getNumericAspectRatioFromString:be},views:{fileActionButton:Ft}});n=r.options,Object.assign(Ae,n)}},po=(Kt=c()&&!("[object OperaMini]"===Object.prototype.toString.call(window.operamini))&&"visibilityState"in document&&"Promise"in window&&"slice"in Blob.prototype&&"URL"in window&&"createObjectURL"in window.URL&&"performance"in window&&("supports"in(window.CSS||{})||/MSIE|Trident/.test(window.navigator.userAgent)),function(){return Kt}),Eo={apps:[]},_o=function(){};if(e.Status={},e.FileStatus={},e.FileOrigin={},e.OptionTypes={},e.create=_o,e.destroy=_o,e.parse=_o,e.find=_o,e.registerPlugin=_o,e.getOptions=_o,e.setOptions=_o,po()){!function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:60,r="__framePainter";if(window[r])return window[r].readers.push(e),void window[r].writers.push(t);window[r]={readers:[e],writers:[t]};var o=window[r],i=1e3/n,a=null,s=null,u=null,l=null,c=function(){document.hidden?(u=function(){return window.setTimeout(function(){return f(performance.now())},i)},l=function(){return window.clearTimeout(s)}):(u=function(){return window.requestAnimationFrame(f)},l=function(){return window.cancelAnimationFrame(s)})};document.addEventListener("visibilitychange",function(){l&&l(),c(),f(performance.now())});var f=function e(t){s=u(e),a||(a=t);var n=t-a;n<=i||(a=t-n%i,o.readers.forEach(function(e){return e()}),o.writers.forEach(function(e){return e(t)}))};c(),f(performance.now())}(function(){Eo.apps.forEach(function(e){return e._read()})},function(e){Eo.apps.forEach(function(t){return t._write(e)})});var To=function t(){document.dispatchEvent(new CustomEvent("FilePond:loaded",{detail:{supported:po,create:e.create,destroy:e.destroy,parse:e.parse,find:e.find,registerPlugin:e.registerPlugin,setOptions:e.setOptions}})),document.removeEventListener("DOMContentLoaded",t)};"loading"!==document.readyState?setTimeout(function(){return To()},0):document.addEventListener("DOMContentLoaded",To);var Io=function(){return t(Se(),function(t,n){e.OptionTypes[t]=n[1]})};e.Status=Object.assign({},Me),e.FileOrigin=Object.assign({},ve),e.FileStatus=Object.assign({},Ie),e.OptionTypes={},Io(),e.create=function(){var t=no.apply(void 0,arguments);return t.on("destroy",e.destroy),Eo.apps.push(t),oo(t)},e.destroy=function(e){var t=Eo.apps.findIndex(function(t){return t.isAttachedTo(e)});return t>=0&&(Eo.apps.splice(t,1)[0].restoreElement(),!0)},e.parse=function(t){return Array.from(t.querySelectorAll(".filepond")).filter(function(e){return!Eo.apps.find(function(t){return t.isAttachedTo(e)})}).map(function(t){return e.create(t)})},e.find=function(e){var t=Eo.apps.find(function(t){return t.isAttachedTo(e)});return t?oo(t):null},e.registerPlugin=function(){for(var e=arguments.length,t=new Array(e),n=0;n=0)){return r}else{return null}}if(o&&(o==="*"||o.split(" ").indexOf(n)>=0)){return"unset"}}return r}function ne(t,n){let r=null;q(t,function(e){return!!(r=o(t,ce(e),n))});if(r!=="unset"){return r}}function h(e,t){return e instanceof Element&&e.matches(t)}function A(e){const t=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i;const n=t.exec(e);if(n){return n[1].toLowerCase()}else{return""}}function L(e){if("parseHTMLUnsafe"in Document){return Document.parseHTMLUnsafe(e)}const t=new DOMParser;return t.parseFromString(e,"text/html")}function N(e,t){while(t.childNodes.length>0){e.append(t.childNodes[0])}}function r(e){const t=te().createElement("script");ie(e.attributes,function(e){t.setAttribute(e.name,e.value)});t.textContent=e.textContent;t.async=false;if(Q.config.inlineScriptNonce){t.nonce=Q.config.inlineScriptNonce}return t}function i(e){return e.matches("script")&&(e.type==="text/javascript"||e.type==="module"||e.type==="")}function I(e){Array.from(e.querySelectorAll("script")).forEach(e=>{if(i(e)){const t=r(e);const n=e.parentNode;try{n.insertBefore(t,e)}catch(e){H(e)}finally{e.remove()}}})}function D(e){const t=e.replace(/]*)?>[\s\S]*?<\/head>/i,"");const n=A(t);let r;if(n==="html"){r=new DocumentFragment;const i=L(e);N(r,i.body);r.title=i.title}else if(n==="body"){r=new DocumentFragment;const i=L(t);N(r,i.body);r.title=i.title}else{const i=L('");r=i.querySelector("template").content;r.title=i.title;var o=r.querySelector("title");if(o&&o.parentNode===r){o.remove();r.title=o.innerText}}if(r){if(Q.config.allowScriptTags){I(r)}else{r.querySelectorAll("script").forEach(e=>e.remove())}}return r}function re(e){if(e){e()}}function t(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function P(e){return typeof e==="function"}function k(e){return t(e,"Object")}function oe(e){const t="htmx-internal-data";let n=e[t];if(!n){n=e[t]={}}return n}function M(t){const n=[];if(t){for(let e=0;e=0}function se(e){return e.getRootNode({composed:true})===document}function B(e){return e.trim().split(/\s+/)}function le(e,t){for(const n in t){if(t.hasOwnProperty(n)){e[n]=t[n]}}return e}function v(e){try{return JSON.parse(e)}catch(e){H(e);return null}}function X(){const e="htmx:sessionStorageTest";try{sessionStorage.setItem(e,e);sessionStorage.removeItem(e);return true}catch(e){return false}}function U(e){const t=new URL(e,"http://x");if(t){e=t.pathname+t.search}if(e!="/"){e=e.replace(/\/+$/,"")}return e}function e(e){return On(te().body,function(){return eval(e)})}function V(t){const e=Q.on("htmx:load",function(e){t(e.detail.elt)});return e}function j(){Q.logger=function(e,t,n){if(console){console.log(t,e,n)}}}function $(){Q.logger=null}function f(e,t){if(typeof e!=="string"){return e.querySelector(t)}else{return f(te(),e)}}function x(e,t){if(typeof e!=="string"){return e.querySelectorAll(t)}else{return x(te(),e)}}function b(){return window}function _(e,t){e=w(e);if(t){b().setTimeout(function(){_(e);e=null},t)}else{u(e).removeChild(e)}}function ce(e){return e instanceof Element?e:null}function z(e){return e instanceof HTMLElement?e:null}function J(e){return typeof e==="string"?e:null}function p(e){return e instanceof Element||e instanceof Document||e instanceof DocumentFragment?e:null}function K(e,t,n){e=ce(w(e));if(!e){return}if(n){b().setTimeout(function(){K(e,t);e=null},n)}else{e.classList&&e.classList.add(t)}}function G(e,t,n){let r=ce(w(e));if(!r){return}if(n){b().setTimeout(function(){G(r,t);r=null},n)}else{if(r.classList){r.classList.remove(t);if(r.classList.length===0){r.removeAttribute("class")}}}}function W(e,t){e=w(e);e.classList.toggle(t)}function Z(e,t){e=w(e);ie(e.parentElement.children,function(e){G(e,t)});K(ce(e),t)}function g(e,t){e=ce(w(e));if(e){return e.closest(t)}return null}function l(e,t){return e.substring(0,t.length)===t}function Y(e,t){return e.substring(e.length-t.length)===t}function pe(e){const t=e.trim();if(l(t,"<")&&Y(t,"/>")){return t.substring(1,t.length-2)}else{return t}}function m(t,r,n){if(r.indexOf("global ")===0){return m(t,r.slice(7),true)}t=w(t);const o=[];{let t=0;let n=0;for(let e=0;e"){t--}}if(n0){const r=pe(o.shift());let e;if(r.indexOf("closest ")===0){e=g(ce(t),pe(r.slice(8)))}else if(r.indexOf("find ")===0){e=f(p(t),pe(r.slice(5)))}else if(r==="next"||r==="nextElementSibling"){e=ce(t).nextElementSibling}else if(r.indexOf("next ")===0){e=ge(t,pe(r.slice(5)),!!n)}else if(r==="previous"||r==="previousElementSibling"){e=ce(t).previousElementSibling}else if(r.indexOf("previous ")===0){e=me(t,pe(r.slice(9)),!!n)}else if(r==="document"){e=document}else if(r==="window"){e=window}else if(r==="body"){e=document.body}else if(r==="root"){e=y(t,!!n)}else if(r==="host"){e=t.getRootNode().host}else{s.push(r)}if(e){i.push(e)}}if(s.length>0){const e=s.join(",");const c=p(y(t,!!n));i.push(...M(c.querySelectorAll(e)))}return i}var ge=function(t,e,n){const r=p(y(t,n)).querySelectorAll(e);for(let e=0;e=0;e--){const o=r[e];if(o.compareDocumentPosition(t)===Node.DOCUMENT_POSITION_FOLLOWING){return o}}};function ue(e,t){if(typeof e!=="string"){return m(e,t)[0]}else{return m(te().body,e)[0]}}function w(e,t){if(typeof e==="string"){return f(p(t)||document,e)}else{return e}}function ye(e,t,n,r){if(P(t)){return{target:te().body,event:J(e),listener:t,options:n}}else{return{target:w(e),event:J(t),listener:n,options:r}}}function xe(t,n,r,o){Gn(function(){const e=ye(t,n,r,o);e.target.addEventListener(e.event,e.listener,e.options)});const e=P(n);return e?n:r}function be(t,n,r){Gn(function(){const e=ye(t,n,r);e.target.removeEventListener(e.event,e.listener)});return P(n)?n:r}const ve=te().createElement("output");function we(t,n){const e=ne(t,n);if(e){if(e==="this"){return[Se(t,n)]}else{const r=m(t,e);const o=/(^|,)(\s*)inherit(\s*)($|,)/.test(e);if(o){const i=ce(q(t,function(e){return e!==t&&s(ce(e),n)}));if(i){r.push(...we(i,n))}}if(r.length===0){H('The selector "'+e+'" on '+n+" returned no matches!");return[ve]}else{return r}}}}function Se(e,t){return ce(q(e,function(e){return a(ce(e),t)!=null}))}function Ee(e){const t=ne(e,"hx-target");if(t){if(t==="this"){return Se(e,"hx-target")}else{return ue(e,t)}}else{const n=oe(e);if(n.boosted){return te().body}else{return e}}}function Ce(e){return Q.config.attributesToSettle.includes(e)}function Oe(t,n){ie(Array.from(t.attributes),function(e){if(!n.hasAttribute(e.name)&&Ce(e.name)){t.removeAttribute(e.name)}});ie(n.attributes,function(e){if(Ce(e.name)){t.setAttribute(e.name,e.value)}})}function He(t,e){const n=Jn(e);for(let e=0;e0){s=e.substring(0,e.indexOf(":"));n=e.substring(e.indexOf(":")+1)}else{s=e}o.removeAttribute("hx-swap-oob");o.removeAttribute("data-hx-swap-oob");const r=m(t,n,false);if(r.length){ie(r,function(e){let t;const n=o.cloneNode(true);t=te().createDocumentFragment();t.appendChild(n);if(!He(s,e)){t=p(n)}const r={shouldSwap:true,target:e,fragment:t};if(!ae(e,"htmx:oobBeforeSwap",r))return;e=r.target;if(r.shouldSwap){qe(t);$e(s,e,e,t,i);Re()}ie(i.elts,function(e){ae(e,"htmx:oobAfterSwap",r)})});o.parentNode.removeChild(o)}else{o.parentNode.removeChild(o);fe(te().body,"htmx:oobErrorNoTarget",{content:o})}return e}function Re(){const e=f("#--htmx-preserve-pantry--");if(e){for(const t of[...e.children]){const n=f("#"+t.id);n.parentNode.moveBefore(t,n);n.remove()}e.remove()}}function qe(e){ie(x(e,"[hx-preserve], [data-hx-preserve]"),function(e){const t=a(e,"id");const n=te().getElementById(t);if(n!=null){if(e.moveBefore){let e=f("#--htmx-preserve-pantry--");if(e==null){te().body.insertAdjacentHTML("afterend","
");e=f("#--htmx-preserve-pantry--")}e.moveBefore(n,null)}else{e.parentNode.replaceChild(n,e)}}})}function Ae(l,e,c){ie(e.querySelectorAll("[id]"),function(t){const n=ee(t,"id");if(n&&n.length>0){const r=n.replace("'","\\'");const o=t.tagName.replace(":","\\:");const e=p(l);const i=e&&e.querySelector(o+"[id='"+r+"']");if(i&&i!==e){const s=t.cloneNode();Oe(t,i);c.tasks.push(function(){Oe(t,s)})}}})}function Le(e){return function(){G(e,Q.config.addedClass);Ft(ce(e));Ne(p(e));ae(e,"htmx:load")}}function Ne(e){const t="[autofocus]";const n=z(h(e,t)?e:e.querySelector(t));if(n!=null){n.focus()}}function c(e,t,n,r){Ae(e,n,r);while(n.childNodes.length>0){const o=n.firstChild;K(ce(o),Q.config.addedClass);e.insertBefore(o,t);if(o.nodeType!==Node.TEXT_NODE&&o.nodeType!==Node.COMMENT_NODE){r.tasks.push(Le(o))}}}function Ie(e,t){let n=0;while(n0}function ze(h,d,p,g){if(!g){g={}}let m=null;let n=null;let e=function(){re(g.beforeSwapCallback);h=w(h);const r=g.contextElement?y(g.contextElement,false):te();const e=document.activeElement;let t={};t={elt:e,start:e?e.selectionStart:null,end:e?e.selectionEnd:null};const o=Sn(h);if(p.swapStyle==="textContent"){h.textContent=d}else{let n=D(d);o.title=g.title||n.title;if(g.historyRequest){n=n.querySelector("[hx-history-elt],[data-hx-history-elt]")||n}if(g.selectOOB){const i=g.selectOOB.split(",");for(let t=0;t0){b().setTimeout(n,p.settleDelay)}else{n()}};let t=Q.config.globalViewTransitions;if(p.hasOwnProperty("transition")){t=p.transition}const r=g.contextElement||te();if(t&&ae(r,"htmx:beforeTransition",g.eventInfo)&&typeof Promise!=="undefined"&&document.startViewTransition){const o=new Promise(function(e,t){m=e;n=t});const i=e;e=function(){document.startViewTransition(function(){i();return o})}}try{if(p?.swapDelay&&p.swapDelay>0){b().setTimeout(e,p.swapDelay)}else{e()}}catch(e){fe(r,"htmx:swapError",g.eventInfo);re(n);throw e}}function Je(e,t,n){const r=e.getResponseHeader(t);if(r.indexOf("{")===0){const o=v(r);for(const i in o){if(o.hasOwnProperty(i)){let e=o[i];if(k(e)){n=e.target!==undefined?e.target:n}else{e={value:e}}ae(n,i,e)}}}else{const s=r.split(",");for(let e=0;e0){const s=o[0];if(s==="]"){e--;if(e===0){if(n===null){t=t+"true"}o.shift();t+=")})";try{const l=On(r,function(){return Function(t)()},function(){return true});l.source=t;return l}catch(e){fe(te().body,"htmx:syntax:error",{error:e,source:t});return null}}}else if(s==="["){e++}if(tt(s,n,i)){t+="(("+i+"."+s+") ? ("+i+"."+s+") : (window."+s+"))"}else{t=t+s}n=o.shift()}}}function O(e,t){let n="";while(e.length>0&&!t.test(e[0])){n+=e.shift()}return n}function rt(e){let t;if(e.length>0&&Ye.test(e[0])){e.shift();t=O(e,Qe).trim();e.shift()}else{t=O(e,E)}return t}const ot="input, textarea, select";function it(e,t,n){const r=[];const o=et(t);do{O(o,C);const l=o.length;const c=O(o,/[,\[\s]/);if(c!==""){if(c==="every"){const u={trigger:"every"};O(o,C);u.pollInterval=d(O(o,/[,\[\s]/));O(o,C);var i=nt(e,o,"event");if(i){u.eventFilter=i}r.push(u)}else{const f={trigger:c};var i=nt(e,o,"event");if(i){f.eventFilter=i}O(o,C);while(o.length>0&&o[0]!==","){const a=o.shift();if(a==="changed"){f.changed=true}else if(a==="once"){f.once=true}else if(a==="consume"){f.consume=true}else if(a==="delay"&&o[0]===":"){o.shift();f.delay=d(O(o,E))}else if(a==="from"&&o[0]===":"){o.shift();if(Ye.test(o[0])){var s=rt(o)}else{var s=O(o,E);if(s==="closest"||s==="find"||s==="next"||s==="previous"){o.shift();const h=rt(o);if(h.length>0){s+=" "+h}}}f.from=s}else if(a==="target"&&o[0]===":"){o.shift();f.target=rt(o)}else if(a==="throttle"&&o[0]===":"){o.shift();f.throttle=d(O(o,E))}else if(a==="queue"&&o[0]===":"){o.shift();f.queue=O(o,E)}else if(a==="root"&&o[0]===":"){o.shift();f[a]=rt(o)}else if(a==="threshold"&&o[0]===":"){o.shift();f[a]=O(o,E)}else{fe(e,"htmx:syntax:error",{token:o.shift()})}O(o,C)}r.push(f)}}if(o.length===l){fe(e,"htmx:syntax:error",{token:o.shift()})}O(o,C)}while(o[0]===","&&o.shift());if(n){n[t]=r}return r}function st(e){const t=a(e,"hx-trigger");let n=[];if(t){const r=Q.config.triggerSpecsCache;n=r&&r[t]||it(e,t,r)}if(n.length>0){return n}else if(h(e,"form")){return[{trigger:"submit"}]}else if(h(e,'input[type="button"], input[type="submit"]')){return[{trigger:"click"}]}else if(h(e,ot)){return[{trigger:"change"}]}else{return[{trigger:"click"}]}}function lt(e){oe(e).cancelled=true}function ct(e,t,n){const r=oe(e);r.timeout=b().setTimeout(function(){if(se(e)&&r.cancelled!==true){if(!pt(n,e,Xt("hx:poll:trigger",{triggerSpec:n,target:e}))){t(e)}ct(e,t,n)}},n.pollInterval)}function ut(e){return location.hostname===e.hostname&&ee(e,"href")&&ee(e,"href").indexOf("#")!==0}function ft(e){return g(e,Q.config.disableSelector)}function at(t,n,e){if(t instanceof HTMLAnchorElement&&ut(t)&&(t.target===""||t.target==="_self")||t.tagName==="FORM"&&String(ee(t,"method")).toLowerCase()!=="dialog"){n.boosted=true;let r,o;if(t.tagName==="A"){r="get";o=ee(t,"href")}else{const i=ee(t,"method");r=i?i.toLowerCase():"get";o=ee(t,"action");if(o==null||o===""){o=location.href}if(r==="get"&&o.includes("?")){o=o.replace(/\?[^#]+/,"")}}e.forEach(function(e){gt(t,function(e,t){const n=ce(e);if(ft(n)){S(n);return}he(r,o,n,t)},n,e,true)})}}function ht(e,t){if(e.type==="submit"&&t.tagName==="FORM"){return true}else if(e.type==="click"){const n=t.closest('input[type="submit"], button');if(n&&n.form&&n.type==="submit"){return true}const r=t.closest("a");const o=/^#.+/;if(r&&r.href&&!o.test(r.getAttribute("href"))){return true}}return false}function dt(e,t){return oe(e).boosted&&e instanceof HTMLAnchorElement&&t.type==="click"&&(t.ctrlKey||t.metaKey)}function pt(e,t,n){const r=e.eventFilter;if(r){try{return r.call(t,n)!==true}catch(e){const o=r.source;fe(te().body,"htmx:eventFilter:error",{error:e,source:o});return true}}return false}function gt(l,c,e,u,f){const a=oe(l);let t;if(u.from){t=m(l,u.from)}else{t=[l]}if(u.changed){if(!("lastValue"in a)){a.lastValue=new WeakMap}t.forEach(function(e){if(!a.lastValue.has(u)){a.lastValue.set(u,new WeakMap)}a.lastValue.get(u).set(e,e.value)})}ie(t,function(i){const s=function(e){if(!se(l)){i.removeEventListener(u.trigger,s);return}if(dt(l,e)){return}if(f||ht(e,i)){e.preventDefault()}if(pt(u,l,e)){return}const t=oe(e);t.triggerSpec=u;if(t.handledFor==null){t.handledFor=[]}if(t.handledFor.indexOf(l)<0){t.handledFor.push(l);if(u.consume){e.stopPropagation()}if(u.target&&e.target){if(!h(ce(e.target),u.target)){return}}if(u.once){if(a.triggeredOnce){return}else{a.triggeredOnce=true}}if(u.changed){const n=e.target;const r=n.value;const o=a.lastValue.get(u);if(o.has(n)&&o.get(n)===r){return}o.set(n,r)}if(a.delayed){clearTimeout(a.delayed)}if(a.throttle){return}if(u.throttle>0){if(!a.throttle){ae(l,"htmx:trigger");c(l,e);a.throttle=b().setTimeout(function(){a.throttle=null},u.throttle)}}else if(u.delay>0){a.delayed=b().setTimeout(function(){ae(l,"htmx:trigger");c(l,e)},u.delay)}else{ae(l,"htmx:trigger");c(l,e)}}};if(e.listenerInfos==null){e.listenerInfos=[]}e.listenerInfos.push({trigger:u.trigger,listener:s,on:i});i.addEventListener(u.trigger,s)})}let mt=false;let yt=null;function xt(){if(!yt){yt=function(){mt=true};window.addEventListener("scroll",yt);window.addEventListener("resize",yt);setInterval(function(){if(mt){mt=false;ie(te().querySelectorAll("[hx-trigger*='revealed'],[data-hx-trigger*='revealed']"),function(e){bt(e)})}},200)}}function bt(e){if(!s(e,"data-hx-revealed")&&F(e)){e.setAttribute("data-hx-revealed","true");const t=oe(e);if(t.initHash){ae(e,"revealed")}else{e.addEventListener("htmx:afterProcessNode",function(){ae(e,"revealed")},{once:true})}}}function vt(e,t,n,r){const o=function(){if(!n.loaded){n.loaded=true;ae(e,"htmx:trigger");t(e)}};if(r>0){b().setTimeout(o,r)}else{o()}}function wt(t,n,e){let i=false;ie(de,function(r){if(s(t,"hx-"+r)){const o=a(t,"hx-"+r);i=true;n.path=o;n.verb=r;e.forEach(function(e){St(t,e,n,function(e,t){const n=ce(e);if(ft(n)){S(n);return}he(r,o,n,t)})})}});return i}function St(r,e,t,n){if(e.trigger==="revealed"){xt();gt(r,n,t,e);bt(ce(r))}else if(e.trigger==="intersect"){const o={};if(e.root){o.root=ue(r,e.root)}if(e.threshold){o.threshold=parseFloat(e.threshold)}const i=new IntersectionObserver(function(t){for(let e=0;e0){t.polling=true;ct(ce(r),n,e)}else{gt(r,n,t,e)}}function Et(e){const t=ce(e);if(!t){return false}const n=t.attributes;for(let e=0;e", "+e).join(""));return o}else{return[]}}function Rt(e){const t=At(e.target);const n=Nt(e);if(n){n.lastButtonClicked=t}}function qt(e){const t=Nt(e);if(t){t.lastButtonClicked=null}}function At(e){return g(ce(e),"button, input[type='submit']")}function Lt(e){return e.form||g(e,"form")}function Nt(e){const t=At(e.target);if(!t){return}const n=Lt(t);if(!n){return}return oe(n)}function It(e){e.addEventListener("click",Rt);e.addEventListener("focusin",Rt);e.addEventListener("focusout",qt)}function Dt(t,e,n){const r=oe(t);if(!Array.isArray(r.onHandlers)){r.onHandlers=[]}let o;const i=function(e){On(t,function(){if(ft(t)){return}if(!o){o=new Function("event",n)}o.call(t,e)})};t.addEventListener(e,i);r.onHandlers.push({event:e,listener:i})}function Pt(t){Pe(t);for(let e=0;eQ.config.historyCacheSize){i.shift()}while(i.length>0){try{sessionStorage.setItem("htmx-history-cache",JSON.stringify(i));break}catch(e){fe(te().body,"htmx:historyCacheError",{cause:e,cache:i});i.shift()}}}function Jt(t){if(!X()){return null}t=U(t);const n=v(sessionStorage.getItem("htmx-history-cache"))||[];for(let e=0;e=200&&this.status<400){r.response=this.response;ae(te().body,"htmx:historyCacheMissLoad",r);ze(r.historyElt,r.response,n,{contextElement:r.historyElt,historyRequest:true});$t(r.path);ae(te().body,"htmx:historyRestore",{path:e,cacheMiss:true,serverResponse:r.response})}else{fe(te().body,"htmx:historyCacheMissLoadError",r)}};if(ae(te().body,"htmx:historyCacheMiss",r)){t.send()}}function en(e){Gt();e=e||location.pathname+location.search;const t=Jt(e);if(t){const n={swapStyle:"innerHTML",swapDelay:0,settleDelay:0,scroll:t.scroll};const r={path:e,item:t,historyElt:_t(),swapSpec:n};if(ae(te().body,"htmx:historyCacheHit",r)){ze(r.historyElt,t.content,n,{contextElement:r.historyElt,title:t.title});$t(r.path);ae(te().body,"htmx:historyRestore",r)}}else{if(Q.config.refreshOnHistoryMiss){Q.location.reload(true)}else{Qt(e)}}}function tn(e){let t=we(e,"hx-indicator");if(t==null){t=[e]}ie(t,function(e){const t=oe(e);t.requestCount=(t.requestCount||0)+1;e.classList.add.call(e.classList,Q.config.requestClass)});return t}function nn(e){let t=we(e,"hx-disabled-elt");if(t==null){t=[]}ie(t,function(e){const t=oe(e);t.requestCount=(t.requestCount||0)+1;e.setAttribute("disabled","");e.setAttribute("data-disabled-by-htmx","")});return t}function rn(e,t){ie(e.concat(t),function(e){const t=oe(e);t.requestCount=(t.requestCount||1)-1});ie(e,function(e){const t=oe(e);if(t.requestCount===0){e.classList.remove.call(e.classList,Q.config.requestClass)}});ie(t,function(e){const t=oe(e);if(t.requestCount===0){e.removeAttribute("disabled");e.removeAttribute("data-disabled-by-htmx")}})}function on(t,n){for(let e=0;en.indexOf(e)<0)}else{e=e.filter(e=>e!==n)}r.delete(t);ie(e,e=>r.append(t,e))}}function un(e){if(e instanceof HTMLSelectElement&&e.multiple){return M(e.querySelectorAll("option:checked")).map(function(e){return e.value})}if(e instanceof HTMLInputElement&&e.files){return M(e.files)}return e.value}function fn(t,n,r,e,o){if(e==null||on(t,e)){return}else{t.push(e)}if(sn(e)){const i=ee(e,"name");ln(i,un(e),n);if(o){an(e,r)}}if(e instanceof HTMLFormElement){ie(e.elements,function(e){if(t.indexOf(e)>=0){cn(e.name,un(e),n)}else{t.push(e)}if(o){an(e,r)}});new FormData(e).forEach(function(e,t){if(e instanceof File&&e.name===""){return}ln(t,e,n)})}}function an(e,t){const n=e;if(n.willValidate){ae(n,"htmx:validation:validate");if(!n.checkValidity()){if(ae(n,"htmx:validation:failed",{message:n.validationMessage,validity:n.validity})&&!t.length&&Q.config.reportValidityOfForms){n.reportValidity()}t.push({elt:n,message:n.validationMessage,validity:n.validity})}}}function hn(n,e){for(const t of e.keys()){n.delete(t)}e.forEach(function(e,t){n.append(t,e)});return n}function dn(e,t){const n=[];const r=new FormData;const o=new FormData;const i=[];const s=oe(e);if(s.lastButtonClicked&&!se(s.lastButtonClicked)){s.lastButtonClicked=null}let l=e instanceof HTMLFormElement&&e.noValidate!==true||a(e,"hx-validate")==="true";if(s.lastButtonClicked){l=l&&s.lastButtonClicked.formNoValidate!==true}if(t!=="get"){fn(n,o,i,Lt(e),l)}fn(n,r,i,e,l);if(s.lastButtonClicked||e.tagName==="BUTTON"||e.tagName==="INPUT"&&ee(e,"type")==="submit"){const u=s.lastButtonClicked||e;const f=ee(u,"name");ln(f,u.value,o)}const c=we(e,"hx-include");ie(c,function(e){fn(n,r,i,ce(e),l);if(!h(e,"form")){ie(p(e).querySelectorAll(ot),function(e){fn(n,r,i,e,l)})}});hn(r,o);return{errors:i,formData:r,values:kn(r)}}function pn(e,t,n){if(e!==""){e+="&"}if(String(n)==="[object Object]"){n=JSON.stringify(n)}const r=encodeURIComponent(n);e+=encodeURIComponent(t)+"="+r;return e}function gn(e){e=Dn(e);let n="";e.forEach(function(e,t){n=pn(n,t,e)});return n}function mn(e,t,n){const r={"HX-Request":"true","HX-Trigger":ee(e,"id"),"HX-Trigger-Name":ee(e,"name"),"HX-Target":a(t,"id"),"HX-Current-URL":location.href};Cn(e,"hx-headers",false,r);if(n!==undefined){r["HX-Prompt"]=n}if(oe(e).boosted){r["HX-Boosted"]="true"}return r}function yn(n,e){const t=ne(e,"hx-params");if(t){if(t==="none"){return new FormData}else if(t==="*"){return n}else if(t.indexOf("not ")===0){ie(t.slice(4).split(","),function(e){e=e.trim();n.delete(e)});return n}else{const r=new FormData;ie(t.split(","),function(t){t=t.trim();if(n.has(t)){n.getAll(t).forEach(function(e){r.append(t,e)})}});return r}}else{return n}}function xn(e){return!!ee(e,"href")&&ee(e,"href").indexOf("#")>=0}function bn(e,t){const n=t||ne(e,"hx-swap");const r={swapStyle:oe(e).boosted?"innerHTML":Q.config.defaultSwapStyle,swapDelay:Q.config.defaultSwapDelay,settleDelay:Q.config.defaultSettleDelay};if(Q.config.scrollIntoViewOnBoost&&oe(e).boosted&&!xn(e)){r.show="top"}if(n){const s=B(n);if(s.length>0){for(let e=0;e0?o.join(":"):null;r.scroll=u;r.scrollTarget=i}else if(l.indexOf("show:")===0){const f=l.slice(5);var o=f.split(":");const a=o.pop();var i=o.length>0?o.join(":"):null;r.show=a;r.showTarget=i}else if(l.indexOf("focus-scroll:")===0){const h=l.slice("focus-scroll:".length);r.focusScroll=h=="true"}else if(e==0){r.swapStyle=l}else{H("Unknown modifier in hx-swap: "+l)}}}}return r}function vn(e){return ne(e,"hx-encoding")==="multipart/form-data"||h(e,"form")&&ee(e,"enctype")==="multipart/form-data"}function wn(t,n,r){let o=null;Vt(n,function(e){if(o==null){o=e.encodeParameters(t,r,n)}});if(o!=null){return o}else{if(vn(n)){return hn(new FormData,Dn(r))}else{return gn(r)}}}function Sn(e){return{tasks:[],elts:[e]}}function En(e,t){const n=e[0];const r=e[e.length-1];if(t.scroll){var o=null;if(t.scrollTarget){o=ce(ue(n,t.scrollTarget))}if(t.scroll==="top"&&(n||o)){o=o||n;o.scrollTop=0}if(t.scroll==="bottom"&&(r||o)){o=o||r;o.scrollTop=o.scrollHeight}if(typeof t.scroll==="number"){b().setTimeout(function(){window.scrollTo(0,t.scroll)},0)}}if(t.show){var o=null;if(t.showTarget){let e=t.showTarget;if(t.showTarget==="window"){e="body"}o=ce(ue(n,e))}if(t.show==="top"&&(n||o)){o=o||n;o.scrollIntoView({block:"start",behavior:Q.config.scrollBehavior})}if(t.show==="bottom"&&(r||o)){o=o||r;o.scrollIntoView({block:"end",behavior:Q.config.scrollBehavior})}}}function Cn(r,e,o,i,s){if(i==null){i={}}if(r==null){return i}const l=a(r,e);if(l){let e=l.trim();let t=o;if(e==="unset"){return null}if(e.indexOf("javascript:")===0){e=e.slice(11);t=true}else if(e.indexOf("js:")===0){e=e.slice(3);t=true}if(e.indexOf("{")!==0){e="{"+e+"}"}let n;if(t){n=On(r,function(){if(s){return Function("event","return ("+e+")").call(r,s)}else{return Function("return ("+e+")").call(r)}},{})}else{n=v(e)}for(const c in n){if(n.hasOwnProperty(c)){if(i[c]==null){i[c]=n[c]}}}}return Cn(ce(u(r)),e,o,i,s)}function On(e,t,n){if(Q.config.allowEval){return t()}else{fe(e,"htmx:evalDisallowedError");return n}}function Hn(e,t,n){return Cn(e,"hx-vars",true,n,t)}function Tn(e,t,n){return Cn(e,"hx-vals",false,n,t)}function Rn(e,t){return le(Hn(e,t),Tn(e,t))}function qn(t,n,r){if(r!==null){try{t.setRequestHeader(n,r)}catch(e){t.setRequestHeader(n,encodeURIComponent(r));t.setRequestHeader(n+"-URI-AutoEncoded","true")}}}function An(t){if(t.responseURL){try{const e=new URL(t.responseURL);return e.pathname+e.search}catch(e){fe(te().body,"htmx:badResponseUrl",{url:t.responseURL})}}}function T(e,t){return t.test(e.getAllResponseHeaders())}function Ln(t,n,r){t=t.toLowerCase();if(r){if(r instanceof Element||typeof r==="string"){return he(t,n,null,null,{targetOverride:w(r)||ve,returnPromise:true})}else{let e=w(r.target);if(r.target&&!e||r.source&&!e&&!w(r.source)){e=ve}return he(t,n,w(r.source),r.event,{handler:r.handler,headers:r.headers,values:r.values,targetOverride:e,swapOverride:r.swap,select:r.select,returnPromise:true,push:r.push,replace:r.replace,selectOOB:r.selectOOB})}}else{return he(t,n,null,null,{returnPromise:true})}}function Nn(e){const t=[];while(e){t.push(e);e=e.parentElement}return t}function In(e,t,n){const r=new URL(t,location.protocol!=="about:"?location.href:window.origin);const o=location.protocol!=="about:"?location.origin:window.origin;const i=o===r.origin;if(Q.config.selfRequestsOnly){if(!i){return false}}return ae(e,"htmx:validateUrl",le({url:r,sameHost:i},n))}function Dn(e){if(e instanceof FormData)return e;const t=new FormData;for(const n in e){if(e.hasOwnProperty(n)){if(e[n]&&typeof e[n].forEach==="function"){e[n].forEach(function(e){t.append(n,e)})}else if(typeof e[n]==="object"&&!(e[n]instanceof Blob)){t.append(n,JSON.stringify(e[n]))}else{t.append(n,e[n])}}}return t}function Pn(r,o,e){return new Proxy(e,{get:function(t,e){if(typeof e==="number")return t[e];if(e==="length")return t.length;if(e==="push"){return function(e){t.push(e);r.append(o,e)}}if(typeof t[e]==="function"){return function(){t[e].apply(t,arguments);r.delete(o);t.forEach(function(e){r.append(o,e)})}}if(t[e]&&t[e].length===1){return t[e][0]}else{return t[e]}},set:function(e,t,n){e[t]=n;r.delete(o);e.forEach(function(e){r.append(o,e)});return true}})}function kn(o){return new Proxy(o,{get:function(e,t){if(typeof t==="symbol"){const r=Reflect.get(e,t);if(typeof r==="function"){return function(){return r.apply(o,arguments)}}else{return r}}if(t==="toJSON"){return()=>Object.fromEntries(o)}if(t in e){if(typeof e[t]==="function"){return function(){return o[t].apply(o,arguments)}}}const n=o.getAll(t);if(n.length===0){return undefined}else if(n.length===1){return n[0]}else{return Pn(e,t,n)}},set:function(t,n,e){if(typeof n!=="string"){return false}t.delete(n);if(e&&typeof e.forEach==="function"){e.forEach(function(e){t.append(n,e)})}else if(typeof e==="object"&&!(e instanceof Blob)){t.append(n,JSON.stringify(e))}else{t.append(n,e)}return true},deleteProperty:function(e,t){if(typeof t==="string"){e.delete(t)}return true},ownKeys:function(e){return Reflect.ownKeys(Object.fromEntries(e))},getOwnPropertyDescriptor:function(e,t){return Reflect.getOwnPropertyDescriptor(Object.fromEntries(e),t)}})}function he(t,n,r,o,i,k){let s=null;let l=null;i=i!=null?i:{};if(i.returnPromise&&typeof Promise!=="undefined"){var e=new Promise(function(e,t){s=e;l=t})}if(r==null){r=te().body}const M=i.handler||Vn;const F=i.select||null;if(!se(r)){re(s);return e}const c=i.targetOverride||ce(Ee(r));if(c==null||c==ve){fe(r,"htmx:targetError",{target:ne(r,"hx-target")});re(l);return e}let u=oe(r);const f=u.lastButtonClicked;if(f){const A=ee(f,"formaction");if(A!=null){n=A}const L=ee(f,"formmethod");if(L!=null){if(de.includes(L.toLowerCase())){t=L}else{re(s);return e}}}const a=ne(r,"hx-confirm");if(k===undefined){const K=function(e){return he(t,n,r,o,i,!!e)};const G={target:c,elt:r,path:n,verb:t,triggeringEvent:o,etc:i,issueRequest:K,question:a};if(ae(r,"htmx:confirm",G)===false){re(s);return e}}let h=r;let d=ne(r,"hx-sync");let p=null;let B=false;if(d){const N=d.split(":");const I=N[0].trim();if(I==="this"){h=Se(r,"hx-sync")}else{h=ce(ue(r,I))}d=(N[1]||"drop").trim();u=oe(h);if(d==="drop"&&u.xhr&&u.abortable!==true){re(s);return e}else if(d==="abort"){if(u.xhr){re(s);return e}else{B=true}}else if(d==="replace"){ae(h,"htmx:abort")}else if(d.indexOf("queue")===0){const W=d.split(" ");p=(W[1]||"last").trim()}}if(u.xhr){if(u.abortable){ae(h,"htmx:abort")}else{if(p==null){if(o){const D=oe(o);if(D&&D.triggerSpec&&D.triggerSpec.queue){p=D.triggerSpec.queue}}if(p==null){p="last"}}if(u.queuedRequests==null){u.queuedRequests=[]}if(p==="first"&&u.queuedRequests.length===0){u.queuedRequests.push(function(){he(t,n,r,o,i)})}else if(p==="all"){u.queuedRequests.push(function(){he(t,n,r,o,i)})}else if(p==="last"){u.queuedRequests=[];u.queuedRequests.push(function(){he(t,n,r,o,i)})}re(s);return e}}const g=new XMLHttpRequest;u.xhr=g;u.abortable=B;const m=function(){u.xhr=null;u.abortable=false;if(u.queuedRequests!=null&&u.queuedRequests.length>0){const e=u.queuedRequests.shift();e()}};const X=ne(r,"hx-prompt");if(X){var y=prompt(X);if(y===null||!ae(r,"htmx:prompt",{prompt:y,target:c})){re(s);m();return e}}if(a&&!k){if(!confirm(a)){re(s);m();return e}}let x=mn(r,c,y);if(t!=="get"&&!vn(r)){x["Content-Type"]="application/x-www-form-urlencoded"}if(i.headers){x=le(x,i.headers)}const U=dn(r,t);let b=U.errors;const V=U.formData;if(i.values){hn(V,Dn(i.values))}const j=Dn(Rn(r,o));const v=hn(V,j);let w=yn(v,r);if(Q.config.getCacheBusterParam&&t==="get"){w.set("org.htmx.cache-buster",ee(c,"id")||"true")}if(n==null||n===""){n=location.href}const S=Cn(r,"hx-request");const $=oe(r).boosted;let E=Q.config.methodsThatUseUrlParams.indexOf(t)>=0;const C={boosted:$,useUrlParams:E,formData:w,parameters:kn(w),unfilteredFormData:v,unfilteredParameters:kn(v),headers:x,elt:r,target:c,verb:t,errors:b,withCredentials:i.credentials||S.credentials||Q.config.withCredentials,timeout:i.timeout||S.timeout||Q.config.timeout,path:n,triggeringEvent:o};if(!ae(r,"htmx:configRequest",C)){re(s);m();return e}n=C.path;t=C.verb;x=C.headers;w=Dn(C.parameters);b=C.errors;E=C.useUrlParams;if(b&&b.length>0){ae(r,"htmx:validation:halted",C);re(s);m();return e}const _=n.split("#");const z=_[0];const O=_[1];let H=n;if(E){H=z;const Z=!w.keys().next().done;if(Z){if(H.indexOf("?")<0){H+="?"}else{H+="&"}H+=gn(w);if(O){H+="#"+O}}}if(!In(r,H,C)){fe(r,"htmx:invalidPath",C);re(l);m();return e}g.open(t.toUpperCase(),H,true);g.overrideMimeType("text/html");g.withCredentials=C.withCredentials;g.timeout=C.timeout;if(S.noHeaders){}else{for(const P in x){if(x.hasOwnProperty(P)){const Y=x[P];qn(g,P,Y)}}}const T={xhr:g,target:c,requestConfig:C,etc:i,boosted:$,select:F,pathInfo:{requestPath:n,finalRequestPath:H,responsePath:null,anchor:O}};g.onload=function(){try{const t=Nn(r);T.pathInfo.responsePath=An(g);M(r,T);if(T.keepIndicators!==true){rn(R,q)}ae(r,"htmx:afterRequest",T);ae(r,"htmx:afterOnLoad",T);if(!se(r)){let e=null;while(t.length>0&&e==null){const n=t.shift();if(se(n)){e=n}}if(e){ae(e,"htmx:afterRequest",T);ae(e,"htmx:afterOnLoad",T)}}re(s)}catch(e){fe(r,"htmx:onLoadError",le({error:e},T));throw e}finally{m()}};g.onerror=function(){rn(R,q);fe(r,"htmx:afterRequest",T);fe(r,"htmx:sendError",T);re(l);m()};g.onabort=function(){rn(R,q);fe(r,"htmx:afterRequest",T);fe(r,"htmx:sendAbort",T);re(l);m()};g.ontimeout=function(){rn(R,q);fe(r,"htmx:afterRequest",T);fe(r,"htmx:timeout",T);re(l);m()};if(!ae(r,"htmx:beforeRequest",T)){re(s);m();return e}var R=tn(r);var q=nn(r);ie(["loadstart","loadend","progress","abort"],function(t){ie([g,g.upload],function(e){e.addEventListener(t,function(e){ae(r,"htmx:xhr:"+t,{lengthComputable:e.lengthComputable,loaded:e.loaded,total:e.total})})})});ae(r,"htmx:beforeSend",T);const J=E?null:wn(g,r,w);g.send(J);return e}function Mn(e,t){const n=t.xhr;let r=null;let o=null;if(T(n,/HX-Push:/i)){r=n.getResponseHeader("HX-Push");o="push"}else if(T(n,/HX-Push-Url:/i)){r=n.getResponseHeader("HX-Push-Url");o="push"}else if(T(n,/HX-Replace-Url:/i)){r=n.getResponseHeader("HX-Replace-Url");o="replace"}if(r){if(r==="false"){return{}}else{return{type:o,path:r}}}const i=t.pathInfo.finalRequestPath;const s=t.pathInfo.responsePath;const l=t.etc.push||ne(e,"hx-push-url");const c=t.etc.replace||ne(e,"hx-replace-url");const u=oe(e).boosted;let f=null;let a=null;if(l){f="push";a=l}else if(c){f="replace";a=c}else if(u){f="push";a=s||i}if(a){if(a==="false"){return{}}if(a==="true"){a=s||i}if(t.pathInfo.anchor&&a.indexOf("#")===-1){a=a+"#"+t.pathInfo.anchor}return{type:f,path:a}}else{return{}}}function Fn(e,t){var n=new RegExp(e.code);return n.test(t.toString(10))}function Bn(e){for(var t=0;t`+`.${t}{opacity:0;visibility: hidden} `+`.${n} .${t}, .${n}.${t}{opacity:1;visibility: visible;transition: opacity 200ms ease-in}`+"")}}function Zn(){const e=te().querySelector('meta[name="htmx-config"]');if(e){return v(e.content)}else{return null}}function Yn(){const e=Zn();if(e){Q.config=le(Q.config,e)}}Gn(function(){Yn();Wn();let e=te().body;Ft(e);const t=te().querySelectorAll("[hx-trigger='restored'],[data-hx-trigger='restored']");e.addEventListener("htmx:abort",function(e){const t=e.detail.elt||e.target;const n=oe(t);if(n&&n.xhr){n.xhr.abort()}});const n=window.onpopstate?window.onpopstate.bind(window):null;window.onpopstate=function(e){if(e.state&&e.state.htmx){en();ie(t,function(e){ae(e,"htmx:restored",{document:te(),triggerEvent:ae})})}else{if(n){n(e)}}};b().setTimeout(function(){ae(e,"htmx:load",{});e=null},0)});return Q}(); \ No newline at end of file diff --git a/app/public/assets/js/overtype-webcomponent.min.js b/app/public/assets/js/overtype-webcomponent.min.js deleted file mode 100644 index 334a5c7..0000000 --- a/app/public/assets/js/overtype-webcomponent.min.js +++ /dev/null @@ -1,126 +0,0 @@ -/** - * OverType v2.3.10 - * A lightweight markdown editor library with perfect WYSIWYG alignment - * @license MIT - * @author David Miranda - * https://github.com/panphora/overtype - */ -var OverTypeEditor=(()=>{var ke=Object.defineProperty;var xn=Object.getOwnPropertyDescriptor;var kn=Object.getOwnPropertyNames;var Ln=Object.prototype.hasOwnProperty;var Sn=(n,e,t)=>e in n?ke(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var lt=(n,e)=>{for(var t in e)ke(n,t,{get:e[t],enumerable:!0})},_n=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of kn(e))!Ln.call(n,o)&&o!==t&&ke(n,o,{get:()=>e[o],enumerable:!(i=xn(e,o))||i.enumerable});return n};var En=n=>_n(ke({},"__esModule",{value:!0}),n);var C=(n,e,t)=>(Sn(n,typeof e!="symbol"?e+"":e,t),t);var xi={};lt(xi,{default:()=>bi});var E=class{static resetLinkIndex(){this.linkIndex=0}static setCodeHighlighter(e){this.codeHighlighter=e}static setCustomSyntax(e){this.customSyntax=e}static applyCustomSyntax(e){return this.customSyntax?this.customSyntax(e):e}static escapeHtml(e){let t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,i=>t[i])}static preserveIndentation(e,t){let o=t.match(/^(\s*)/)[1].replace(/ /g," ");return e.replace(/^\s*/,o)}static parseHeader(e){return e.replace(/^(#{1,3})\s(.+)$/,(t,i,o)=>{let r=i.length;return o=this.parseInlineElements(o),`${i} ${o}`})}static parseHorizontalRule(e){return e.match(/^(-{3,}|\*{3,}|_{3,})$/)?`
${e}
`:null}static parseBlockquote(e){return e.replace(/^> (.+)$/,(t,i)=>`> ${i}`)}static parseBulletList(e){return e.replace(/^((?: )*)([-*+])\s(.+)$/,(t,i,o,r)=>(r=this.parseInlineElements(r),`${i}
  • ${o} ${r}
  • `))}static parseTaskList(e,t=!1){return e.replace(/^((?: )*)-(\s+)\[([ xX])\](\s*)(.*)$/,(i,o,r,s,a,l)=>{if(l=this.parseInlineElements(l),t){let p=s.toLowerCase()==="x";return`${o}
  • ${l}
  • `}else return`${o}
  • -${r}[${s}]${a}${l}
  • `})}static parseNumberedList(e){return e.replace(/^((?: )*)(\d+\.)\s(.+)$/,(t,i,o,r)=>(r=this.parseInlineElements(r),`${i}
  • ${o} ${r}
  • `))}static parseCodeBlock(e){return/^`{3}[^`]*$/.test(e)?`
    ${e}
    `:null}static parseBold(e){return e=e.replace(/\*\*(.+?)\*\*/g,'**$1**'),e=e.replace(/__(.+?)__/g,'__$1__'),e}static parseItalic(e){return e=e.replace(new RegExp("(?])\\*(?!\\*)(.+?)(?*$1*'),e=e.replace(new RegExp("(?<=^|\\s)_(?!_)(.+?)(?_$1_'),e}static parseStrikethrough(e){return e=e.replace(new RegExp("(?~~$1~~'),e=e.replace(new RegExp("(?~$1~'),e}static parseInlineCode(e){return e.replace(new RegExp("(?$1$2$3')}static sanitizeUrl(e){let t=e.trim(),i=t.toLowerCase(),r=["http://","https://","mailto:","ftp://","ftps://"].some(a=>i.startsWith(a)),s=t.startsWith("/")||t.startsWith("#")||t.startsWith("?")||t.startsWith(".")||!t.includes(":")&&!t.includes("//");return r||s?e:"#"}static parseLinks(e){return e.replace(/\[(.+?)\]\((.+?)\)/g,(t,i,o)=>{let r=`--link-${this.linkIndex++}`;return`[${i}](${o})`})}static identifyAndProtectSanctuaries(e){let t=new Map,i=0,o=e,r=[],s=/\[([^\]]+)\]\(([^)]+)\)/g,a;for(;(a=s.exec(e))!==null;){let h=a.index+a[0].indexOf("](")+2,u=h+a[2].length;r.push({start:h,end:u})}let l=new RegExp("(?d>=f.start&&h<=f.end)||c.push({match:p[0],index:p.index,openTicks:p[1],content:p[2],closeTicks:p[3]})}return c.sort((d,h)=>h.index-d.index),c.forEach(d=>{let h=`\uE000${i++}\uE001`;t.set(h,{type:"code",original:d.match,openTicks:d.openTicks,content:d.content,closeTicks:d.closeTicks}),o=o.substring(0,d.index)+h+o.substring(d.index+d.match.length)}),o=o.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(d,h,u)=>{let f=`\uE000${i++}\uE001`;return t.set(f,{type:"link",original:d,linkText:h,url:u}),f}),{protectedText:o,sanctuaries:t}}static restoreAndTransformSanctuaries(e,t){return Array.from(t.keys()).sort((o,r)=>{let s=e.indexOf(o),a=e.indexOf(r);return s-a}).forEach(o=>{let r=t.get(o),s;if(r.type==="code")s=`${r.openTicks}${r.content}${r.closeTicks}`;else if(r.type==="link"){let a=r.linkText;t.forEach((c,d)=>{if(a.includes(d)&&c.type==="code"){let h=`${c.openTicks}${c.content}${c.closeTicks}`;a=a.replace(d,h)}}),a=this.parseStrikethrough(a),a=this.parseBold(a),a=this.parseItalic(a);let l=`--link-${this.linkIndex++}`;s=`[${a}](${r.url})`}e=e.replace(o,s)}),e}static parseInlineElements(e){let{protectedText:t,sanctuaries:i}=this.identifyAndProtectSanctuaries(e),o=t;return o=this.parseStrikethrough(o),o=this.parseBold(o),o=this.parseItalic(o),o=this.restoreAndTransformSanctuaries(o,i),o}static parseLine(e,t=!1){let i=this.escapeHtml(e);i=this.preserveIndentation(i,e);let o=this.parseHorizontalRule(i);if(o)return o;let r=this.parseCodeBlock(i);return r||(i=this.parseHeader(i),i=this.parseBlockquote(i),i=this.parseTaskList(i,t),i=this.parseBulletList(i),i=this.parseNumberedList(i),!i.includes(" 
    ":`
    ${i}
    `)}static parse(e,t=-1,i=!1,o,r=!1){this.resetLinkIndex();let s=e.split(` -`),a=!1,p=s.map((c,d)=>{if(i&&d===t)return`
    ${this.escapeHtml(c)||" "}
    `;if(/^```[^`]*$/.test(c))return a=!a,this.applyCustomSyntax(this.parseLine(c,r));if(a){let u=this.escapeHtml(c);return`
    ${this.preserveIndentation(u,c)||" "}
    `}return this.applyCustomSyntax(this.parseLine(c,r))}).join("");return this.postProcessHTML(p,o)}static postProcessHTML(e,t){if(typeof document>"u"||!document)return this.postProcessHTMLManual(e,t);let i=document.createElement("div");i.innerHTML=e;let o=null,r=null,s=null,a=!1,l=Array.from(i.children);for(let p=0;p0&&(s._codeContent+=` -`);let f=c.textContent.replace(/\u00A0/g," ");s._codeContent+=f,u.textContent.length>0&&(u.textContent+=` -`),u.textContent+=f,c.remove();continue}let h=null;if(c.tagName==="DIV"&&(h=c.querySelector("li")),h){let u=h.classList.contains("bullet-list"),f=h.classList.contains("ordered-list");if(!u&&!f){o=null,r=null;continue}let m=u?"ul":"ol";(!o||r!==m)&&(o=document.createElement(m),i.insertBefore(o,c),r=m);let g=[];for(let y of c.childNodes)if(y.nodeType===3&&y.textContent.match(/^\u00A0+$/))g.push(y.cloneNode(!0));else if(y===h)break;g.forEach(y=>{h.insertBefore(y,h.firstChild)}),o.appendChild(h),c.remove()}else o=null,r=null}return i.innerHTML}static postProcessHTMLManual(e,t){let i=e;i=i.replace(/((?:
    (?: )*
  • .*?<\/li><\/div>\s*)+)/gs,r=>{let s=r.match(/
    (?: )*
  • .*?<\/li><\/div>/gs)||[];return s.length>0?"
      "+s.map(l=>{let p=l.match(/
      ((?: )*)
    • .*?<\/li>/);if(p&&c){let d=p[1];return c[0].replace(/
    • /,`
    • ${d}`)}return c?c[0]:""}).filter(Boolean).join("")+"
    ":r}),i=i.replace(/((?:
    (?: )*
  • .*?<\/li><\/div>\s*)+)/gs,r=>{let s=r.match(/
    (?: )*
  • .*?<\/li><\/div>/gs)||[];return s.length>0?"
      "+s.map(l=>{let p=l.match(/
      ((?: )*)
    1. .*?<\/li>/);if(p&&c){let d=p[1];return c[0].replace(/
    2. /,`
    3. ${d}`)}return c?c[0]:""}).filter(Boolean).join("")+"
    ":r});let o=/
    (```[^<]*)<\/span><\/div>(.*?)
    (```)<\/span><\/div>/gs;return i=i.replace(o,(r,s,a,l)=>{let c=(a.match(/
    (.*?)<\/div>/gs)||[]).map(g=>g.replace(/
    (.*?)<\/div>/s,"$1").replace(/ /g," ")).join(` -`),d=s.slice(3).trim(),h=d?` class="language-${d}"`:"",u=c,f=t||this.codeHighlighter;if(f)try{let g=c.replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&"),y=f(g,d);y&&typeof y.then=="function"?console.warn("Async highlighters are not supported in Node.js (non-DOM) context. Use synchronous highlighters for server-side rendering."):y&&typeof y=="string"&&y.trim()&&(u=y)}catch(g){console.warn("Code highlighting failed:",g)}let m=`
    ${s}
    `;return m+=`
    ${u}
    `,m+=`
    ${l}
    `,m}),i}static getListContext(e,t){let i=e.split(` -`),o=0,r=0,s=0;for(let h=0;h=t){r=h,s=o;break}o+=u+1}let a=i[r],l=s+a.length,p=a.match(this.LIST_PATTERNS.checkbox);if(p)return{inList:!0,listType:"checkbox",indent:p[1],marker:"-",checked:p[2]==="x",content:p[3],lineStart:s,lineEnd:l,markerEndPos:s+p[1].length+p[2].length+5};let c=a.match(this.LIST_PATTERNS.bullet);if(c)return{inList:!0,listType:"bullet",indent:c[1],marker:c[2],content:c[3],lineStart:s,lineEnd:l,markerEndPos:s+c[1].length+c[2].length+1};let d=a.match(this.LIST_PATTERNS.numbered);return d?{inList:!0,listType:"numbered",indent:d[1],marker:parseInt(d[2]),content:d[3],lineStart:s,lineEnd:l,markerEndPos:s+d[1].length+d[2].length+2}:{inList:!1,listType:null,indent:"",marker:null,content:a,lineStart:s,lineEnd:l,markerEndPos:s}}static createNewListItem(e){switch(e.listType){case"bullet":return`${e.indent}${e.marker} `;case"numbered":return`${e.indent}${e.marker+1}. `;case"checkbox":return`${e.indent}- [ ] `;default:return""}}static renumberLists(e){let t=e.split(` -`),i=new Map,o=!1;return t.map(s=>{let a=s.match(this.LIST_PATTERNS.numbered);if(a){let l=a[1],p=l.length,c=a[3];o||i.clear();let d=(i.get(p)||0)+1;i.set(p,d);for(let[h]of i)h>p&&i.delete(h);return o=!0,`${l}${d}. ${c}`}else return(s.trim()===""||!s.match(/^\s/))&&(o=!1,i.clear()),s}).join(` -`)}};C(E,"linkIndex",0),C(E,"codeHighlighter",null),C(E,"customSyntax",null),C(E,"LIST_PATTERNS",{bullet:/^(\s*)([-*+])\s+(.*)$/,numbered:/^(\s*)(\d+)\.\s+(.*)$/,checkbox:/^(\s*)-\s+\[([ x])\]\s+(.*)$/});var re=class{constructor(e){this.editor=e}handleKeydown(e){if(!(navigator.platform.toLowerCase().includes("mac")?e.metaKey:e.ctrlKey))return!1;let o=null;switch(e.key.toLowerCase()){case"b":e.shiftKey||(o="toggleBold");break;case"i":e.shiftKey||(o="toggleItalic");break;case"k":e.shiftKey||(o="insertLink");break;case"7":e.shiftKey&&(o="toggleNumberedList");break;case"8":e.shiftKey&&(o="toggleBulletList");break}return o?(e.preventDefault(),this.editor.performAction(o,e),!0):!1}destroy(){}};var z={name:"solar",colors:{bgPrimary:"#faf0ca",bgSecondary:"#ffffff",text:"#0d3b66",textPrimary:"#0d3b66",textSecondary:"#5a7a9b",h1:"#f95738",h2:"#ee964b",h3:"#3d8a51",strong:"#ee964b",em:"#f95738",del:"#ee964b",link:"#0d3b66",code:"#0d3b66",codeBg:"rgba(244, 211, 94, 0.4)",blockquote:"#5a7a9b",hr:"#5a7a9b",syntaxMarker:"rgba(13, 59, 102, 0.52)",syntax:"#999999",cursor:"#f95738",selection:"rgba(244, 211, 94, 0.4)",listMarker:"#ee964b",rawLine:"#5a7a9b",border:"#e0e0e0",hoverBg:"#f0f0f0",primary:"#0d3b66",toolbarBg:"#ffffff",toolbarIcon:"#0d3b66",toolbarHover:"#f5f5f5",toolbarActive:"#faf0ca",placeholder:"#999999"},previewColors:{text:"#0d3b66",h1:"inherit",h2:"inherit",h3:"inherit",strong:"inherit",em:"inherit",link:"#0d3b66",code:"#0d3b66",codeBg:"rgba(244, 211, 94, 0.4)",blockquote:"#5a7a9b",hr:"#5a7a9b",bg:"transparent"}},ct={name:"cave",colors:{bgPrimary:"#141E26",bgSecondary:"#1D2D3E",text:"#c5dde8",textPrimary:"#c5dde8",textSecondary:"#9fcfec",h1:"#d4a5ff",h2:"#f6ae2d",h3:"#9fcfec",strong:"#f6ae2d",em:"#9fcfec",del:"#f6ae2d",link:"#9fcfec",code:"#c5dde8",codeBg:"#1a232b",blockquote:"#9fcfec",hr:"#c5dde8",syntaxMarker:"rgba(159, 207, 236, 0.73)",syntax:"#7a8c98",cursor:"#f26419",selection:"rgba(51, 101, 138, 0.4)",listMarker:"#f6ae2d",rawLine:"#9fcfec",border:"#2a3f52",hoverBg:"#243546",primary:"#9fcfec",toolbarBg:"#1D2D3E",toolbarIcon:"#c5dde8",toolbarHover:"#243546",toolbarActive:"#2a3f52",placeholder:"#6a7a88"},previewColors:{text:"#c5dde8",h1:"inherit",h2:"inherit",h3:"inherit",strong:"inherit",em:"inherit",link:"#9fcfec",code:"#c5dde8",codeBg:"#1a232b",blockquote:"#9fcfec",hr:"#c5dde8",bg:"transparent"}},pt={solar:z,cave:ct,auto:z,light:z,dark:ct};function R(n){return typeof n=="string"?{...pt[n]||pt.solar,name:n}:n}function Ze(n){if(n!=="auto")return n;let e=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)");return e!=null&&e.matches?"cave":"solar"}function Q(n,e){let t=[];for(let[i,o]of Object.entries(n)){let r=i.replace(/([A-Z])/g,"-$1").toLowerCase();t.push(`--${r}: ${o};`)}if(e)for(let[i,o]of Object.entries(e)){let r=i.replace(/([A-Z])/g,"-$1").toLowerCase();t.push(`--preview-${r}-default: ${o};`)}return t.join(` -`)}function dt(n,e={},t={}){return{...n,colors:{...n.colors,...e},previewColors:{...n.previewColors,...t}}}function Le(n={}){let{fontSize:e="14px",lineHeight:t=1.6,fontFamily:i='"SF Mono", SFMono-Regular, Menlo, Monaco, "Cascadia Code", Consolas, "Roboto Mono", "Noto Sans Mono", "Droid Sans Mono", "Ubuntu Mono", "DejaVu Sans Mono", "Liberation Mono", "Courier New", Courier, monospace',padding:o="20px",theme:r=null,mobile:s={}}=n,a=Object.keys(s).length>0?` - @media (max-width: 640px) { - .overtype-wrapper .overtype-input, - .overtype-wrapper .overtype-preview { - ${Object.entries(s).map(([p,c])=>`${p.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${c} !important;`).join(` - `)} - } - } - `:"",l=r&&r.colors?Q(r.colors,r.previewColors):"";return`.overtype-container *{margin: 0 !important;padding: 0 !important;border: 0 !important;float: none !important;clear: none !important;text-decoration: none !important;text-transform: none !important;letter-spacing: normal !important;box-shadow: none !important;text-shadow: none !important;box-sizing: border-box !important}.overtype-container{display: flex !important;flex-direction: column !important;width: 100% !important;height: 100% !important;position: relative !important;overflow: visible !important;font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif !important;text-align: left !important;${l?` - /* Theme Variables */ - ${l}`:""}}.overtype-container .overtype-wrapper *{text-align: left !important}.overtype-container.overtype-auto-resize{height: auto !important}.overtype-container.overtype-auto-resize .overtype-wrapper{flex: 0 0 auto !important;height: auto !important;min-height: 60px !important;overflow: visible !important}.overtype-wrapper{position: relative !important;width: 100% !important;flex: 1 1 0 !important;min-height: 60px !important;overflow: hidden !important;background: var(--bg-secondary,#ffffff) !important;z-index: 1}.overtype-wrapper .overtype-input,.overtype-wrapper .overtype-preview{position: absolute !important;top: 0 !important;left: 0 !important;width: 100% !important;height: 100% !important;font-family: var(--instance-font-family,${i}) !important; - font-variant-ligatures: none !important; /* keep metrics stable for code */ - font-size: var(--instance-font-size, ${e}) !important; - line-height: var(--instance-line-height, ${t}) !important; - font-weight: normal !important; - font-style: normal !important; - font-variant: normal !important; - font-stretch: normal !important; - font-kerning: none !important; - font-feature-settings: normal !important; - - /* Box model - must match exactly */ - padding: var(--instance-padding, ${o}) !important;margin: 0 !important;border: none !important;outline: none !important;box-sizing: border-box !important;white-space: pre-wrap !important;word-wrap: break-word !important;word-break: normal !important;overflow-wrap: break-word !important;tab-size: 2 !important;-moz-tab-size: 2 !important;text-align: left !important;text-indent: 0 !important;letter-spacing: normal !important;word-spacing: normal !important;text-transform: none !important;text-rendering: auto !important;-webkit-font-smoothing: auto !important;-webkit-text-size-adjust: 100% !important;direction: ltr !important;writing-mode: horizontal-tb !important;unicode-bidi: normal !important;text-orientation: mixed !important;text-shadow: none !important;filter: none !important;transform: none !important;zoom: 1 !important;vertical-align: baseline !important;min-width: 0 !important;min-height: 0 !important;max-width: none !important;max-height: none !important;overflow-y: auto !important;overflow-x: auto !important;scrollbar-width: auto !important;scrollbar-gutter: auto !important;animation: none !important;transition: none !important}.overtype-wrapper .overtype-input{z-index: 1 !important;color: transparent !important;caret-color: var(--cursor,#f95738) !important;background-color: transparent !important;resize: none !important;appearance: none !important;-webkit-appearance: none !important;-moz-appearance: none !important;touch-action: manipulation !important;autocomplete: off !important;autocorrect: off !important;autocapitalize: off !important}.overtype-wrapper .overtype-input::selection{background-color: var(--selection,rgba(244,211,94,0.4))}.overtype-wrapper .overtype-placeholder{position: absolute !important;top: 0 !important;left: 0 !important;width: 100% !important;z-index: 0 !important;pointer-events: none !important;user-select: none !important;font-family: var(--instance-font-family,${i}) !important; - font-size: var(--instance-font-size, ${e}) !important; - line-height: var(--instance-line-height, ${t}) !important; - padding: var(--instance-padding, ${o}) !important;box-sizing: border-box !important;color: var(--placeholder,#999) !important}.overtype-wrapper .overtype-preview{z-index: 0 !important;pointer-events: none !important;color: var(--text,#0d3b66) !important;background-color: transparent !important;user-select: none !important;-webkit-user-select: none !important;-moz-user-select: none !important;-ms-user-select: none !important}.overtype-wrapper .overtype-preview *{font-family: inherit !important;font-size: inherit !important;line-height: inherit !important}.overtype-wrapper .overtype-preview div{margin: 0 !important;padding: 0 !important;border: none !important;text-align: left !important;text-indent: 0 !important;display: block !important;position: static !important;transform: none !important;min-height: 0 !important;max-height: none !important;line-height: inherit !important;font-size: inherit !important;font-family: inherit !important}.overtype-wrapper .overtype-preview .header{font-weight: bold !important}.overtype-wrapper .overtype-preview .h1{color: var(--h1,#f95738) !important}.overtype-wrapper .overtype-preview .h2{color: var(--h2,#ee964b) !important}.overtype-wrapper .overtype-preview .h3{color: var(--h3,#3d8a51) !important}.overtype-wrapper .overtype-preview h1,.overtype-wrapper .overtype-preview h2,.overtype-wrapper .overtype-preview h3{font-size: inherit !important;font-weight: bold !important;margin: 0 !important;padding: 0 !important;display: inline !important;line-height: inherit !important}.overtype-wrapper .overtype-preview h1{color: var(--h1,#f95738) !important}.overtype-wrapper .overtype-preview h2{color: var(--h2,#ee964b) !important}.overtype-wrapper .overtype-preview h3{color: var(--h3,#3d8a51) !important}.overtype-wrapper .overtype-preview ul,.overtype-wrapper .overtype-preview ol{list-style: none !important;margin: 0 !important;padding: 0 !important;display: block !important}.overtype-wrapper .overtype-preview li{display: block !important;margin: 0 !important;padding: 0 !important}.overtype-wrapper .overtype-preview strong{color: var(--strong,#ee964b) !important;font-weight: bold !important}.overtype-wrapper .overtype-preview em{color: var(--em,#f95738) !important;text-decoration-color: var(--em,#f95738) !important;text-decoration-thickness: 1px !important;font-style: italic !important}.overtype-wrapper .overtype-preview del{color: var(--del,#ee964b) !important;text-decoration: line-through !important;text-decoration-color: var(--del,#ee964b) !important;text-decoration-thickness: 1px !important}.overtype-wrapper .overtype-preview code{background: var(--code-bg,rgba(244,211,94,0.4)) !important;color: var(--code,#0d3b66) !important;padding: 0 !important;border-radius: 2px !important;font-family: inherit !important;font-size: inherit !important;line-height: inherit !important;font-weight: normal !important}.overtype-wrapper .overtype-preview pre{padding: 0 !important;margin: 0 !important;border-radius: 4px !important;overflow-x: auto !important}.overtype-wrapper .overtype-preview pre.code-block{background: var(--code-bg,rgba(244,211,94,0.4)) !important;white-space: break-spaces !important}.overtype-wrapper .overtype-preview pre code{background: transparent !important;color: var(--code,#0d3b66) !important;font-family: var(--instance-font-family,${i}) !important}.overtype-wrapper .overtype-preview .blockquote{color: var(--blockquote,#5a7a9b) !important;padding: 0 !important;margin: 0 !important;border: none !important}.overtype-wrapper .overtype-preview a{color: var(--link,#0d3b66) !important;text-decoration: underline !important;font-weight: normal !important}.overtype-wrapper .overtype-preview a:hover{text-decoration: underline !important;color: var(--link,#0d3b66) !important}.overtype-wrapper .overtype-preview ul,.overtype-wrapper .overtype-preview ol{list-style: none !important;margin: 0 !important;padding: 0 !important}.overtype-wrapper .overtype-preview hr{border: none !important;color: var(--hr,#5a7a9b) !important;margin: 0 !important;padding: 0 !important}.overtype-wrapper .overtype-preview .hr-marker{color: var(--hr,#5a7a9b) !important;opacity: 0.6 !important}.overtype-wrapper .overtype-preview .code-fence{color: var(--code,#0d3b66) !important;background: var(--code-bg,rgba(244,211,94,0.4)) !important}.overtype-wrapper .overtype-preview .code-block-line{background: var(--code-bg,rgba(244,211,94,0.4)) !important}.overtype-wrapper .overtype-preview .code-block-line .code-fence{background: transparent !important}.overtype-wrapper .overtype-preview .raw-line{color: var(--raw-line,#5a7a9b) !important;font-style: normal !important;font-weight: normal !important}.overtype-wrapper .overtype-preview .syntax-marker{color: var(--syntax-marker,rgba(13,59,102,0.52)) !important;opacity: 0.7 !important}.overtype-wrapper .overtype-preview .list-marker{color: var(--list-marker,#ee964b) !important}.overtype-stats{height: 40px !important;padding: 0 20px !important;background: var(--bg-secondary,#f8f9fa) !important;border-top: 1px solid var(--border,#e0e0e0) !important;display: flex !important;justify-content: space-between !important;align-items: center !important;font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif !important;font-size: 0.85rem !important;color: var(--text-secondary,#666) !important;flex-shrink: 0 !important;z-index: 10001 !important;position: relative !important}.overtype-stats .overtype-stat{display: flex !important;align-items: center !important;gap: 5px !important;white-space: nowrap !important}.overtype-stats .live-dot{width: 8px !important;height: 8px !important;background: #4caf50 !important;border-radius: 50% !important;animation: overtype-pulse 2s infinite !important}@keyframes overtype-pulse{0%,100%{opacity: 1;transform: scale(1)}50%{opacity: 0.6;transform: scale(1.2)}}.overtype-toolbar.overtype-toolbar-hidden{display: none !important}.overtype-toolbar{display: flex !important;align-items: center !important;gap: 4px !important;padding: 8px !important;background: var(--toolbar-bg,var(--bg-primary,#f8f9fa)) !important;border-bottom: 1px solid var(--toolbar-border,transparent) !important;overflow-x: auto !important;overflow-y: hidden !important;-webkit-overflow-scrolling: touch !important;flex-shrink: 0 !important;height: auto !important;position: relative !important;z-index: 100 !important;scrollbar-width: thin}.overtype-toolbar::-webkit-scrollbar{height: 4px}.overtype-toolbar::-webkit-scrollbar-track{background: transparent}.overtype-toolbar::-webkit-scrollbar-thumb{background: rgba(0,0,0,0.2);border-radius: 2px}.overtype-toolbar-button{display: flex;align-items: center;justify-content: center;width: 32px;height: 32px;padding: 0;border: none;border-radius: 6px;background: transparent;color: var(--toolbar-icon,var(--text-secondary,#666));cursor: pointer;transition: all 0.2s ease;flex-shrink: 0}.overtype-toolbar-button svg{width: 20px;height: 20px;fill: currentColor}.overtype-toolbar-button:hover{background: var(--toolbar-hover,var(--bg-secondary,#e9ecef));color: var(--toolbar-icon,var(--text-primary,#333))}.overtype-toolbar-button:active{transform: scale(0.95)}.overtype-toolbar-button.active{background: var(--toolbar-active,var(--primary,#007bff));color: var(--toolbar-icon,var(--text-primary,#333))}.overtype-toolbar-button:disabled{opacity: 0.5;cursor: not-allowed}.overtype-toolbar-separator{width: 1px;height: 24px;background: var(--border,#e0e0e0);margin: 0 4px;flex-shrink: 0}@media (max-width: 640px){.overtype-toolbar{padding: 6px;gap: 2px}.overtype-toolbar-button{width: 36px;height: 36px}.overtype-toolbar-separator{margin: 0 2px}}.overtype-container[data-mode="plain"] .overtype-preview{display: none !important}.overtype-container[data-mode="plain"] .overtype-input{color: var(--text,#0d3b66) !important;font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif !important}.overtype-container:not([data-mode="plain"]) .overtype-input{color: transparent !important}.overtype-toolbar-button{position: relative !important}.overtype-toolbar-button.dropdown-active{background: var(--toolbar-active,var(--hover-bg,#f0f0f0))}.overtype-dropdown-menu{position: fixed !important;background: var(--bg-secondary,white) !important;border: 1px solid var(--border,#e0e0e0) !important;border-radius: 6px;box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;z-index: 10000;min-width: 150px;padding: 4px 0 !important}.overtype-dropdown-item{display: flex;align-items: center;width: 100%;padding: 8px 12px;border: none;background: none;text-align: left;cursor: pointer;font-size: 14px;color: var(--text,#333);font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif}.overtype-dropdown-item:hover{background: var(--hover-bg,#f0f0f0)}.overtype-dropdown-item.active{font-weight: 600}.overtype-dropdown-check{width: 16px;margin-right: 8px;color: var(--h1,#007bff)}.overtype-dropdown-icon{width: 20px;margin-right: 8px;text-align: center}.overtype-container[data-mode="preview"] .overtype-input{display: none !important}.overtype-container[data-mode="preview"] .overtype-preview{pointer-events: auto !important;user-select: text !important;cursor: text !important}.overtype-container.overtype-auto-resize[data-mode="preview"] .overtype-preview{position: static !important;height: auto !important}.overtype-container[data-mode="preview"] .syntax-marker{display: none !important}.overtype-container[data-mode="preview"] .syntax-marker.url-part,.overtype-container[data-mode="preview"] .url-part{display: none !important}.overtype-container[data-mode="preview"] a .syntax-marker{display: none !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h1,.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h2,.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h3{font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif !important;font-weight: 600 !important;margin: 0 !important;display: block !important;line-height: 1 !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h1{font-size: 2em !important;color: var(--preview-h1,var(--preview-h1-default)) !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h2{font-size: 1.5em !important;color: var(--preview-h2,var(--preview-h2-default)) !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h3{font-size: 1.17em !important;color: var(--preview-h3,var(--preview-h3-default)) !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview ul{display: block !important;list-style: disc !important;padding-left: 2em !important;margin: 1em 0 !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview ol{display: block !important;list-style: decimal !important;padding-left: 2em !important;margin: 1em 0 !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview li{display: list-item !important;margin: 0 !important;padding: 0 !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview li.task-list{list-style: none !important;position: relative !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview li.task-list input[type="checkbox"]{margin-right: 0.5em !important;cursor: default !important;vertical-align: middle !important}.overtype-container:not([data-mode="preview"]) .overtype-wrapper .overtype-preview li.task-list{list-style: none !important}.overtype-container:not([data-mode="preview"]) .overtype-wrapper .overtype-preview li.task-list .syntax-marker{color: var(--syntax,#999999) !important;font-weight: normal !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview a{pointer-events: auto !important;cursor: pointer !important;color: var(--preview-link,var(--preview-link-default)) !important;text-decoration: underline !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview pre.code-block{background: var(--preview-code-bg,var(--preview-code-bg-default)) !important;color: var(--preview-code,var(--preview-code-default)) !important;padding: 1.2em !important;border-radius: 3px !important;overflow-x: auto !important;margin: 0 !important;display: block !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview pre.code-block code{background: transparent !important;color: inherit !important;padding: 0 !important;font-family:${i}!important;font-size: 0.9em !important;line-height: 1.4 !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .code-block-line{display: none !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .code-fence{display: none !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .blockquote{display: block !important;border-left: 4px solid var(--preview-blockquote,var(--preview-blockquote-default)) !important;color: var(--preview-blockquote,var(--preview-blockquote-default)) !important;padding-left: 1em !important;margin: 1em 0 !important;font-style: italic !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview{font-family: Georgia,'Times New Roman',serif !important;font-size: 16px !important;line-height: 1.8 !important;color: var(--preview-text,var(--preview-text-default)) !important;background: var(--preview-bg,var(--preview-bg-default)) !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview code{font-family:${i}!important;font-size: 0.9em !important;background: var(--preview-code-bg,var(--preview-code-bg-default)) !important;color: var(--preview-code,var(--preview-code-default)) !important;padding: 0.2em 0.4em !important;border-radius: 3px !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview strong{font-weight: 700 !important;color: var(--preview-strong,var(--preview-strong-default)) !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview em{font-style: italic !important;color: var(--preview-em,var(--preview-em-default)) !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .hr-marker{display: block !important;border-top: 2px solid var(--preview-hr,var(--preview-hr-default)) !important;text-indent: -9999px !important;height: 2px !important}.overtype-link-tooltip{background: #333 !important;color: white !important;padding: 6px 10px !important;border-radius: 16px !important;font-size: 12px !important;font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif !important;display: flex !important;visibility: hidden !important;pointer-events: none !important;z-index: 10000 !important;cursor: pointer !important;box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;max-width: 300px !important;white-space: nowrap !important;overflow: hidden !important;text-overflow: ellipsis !important;position: fixed;top: 0;left: 0}.overtype-link-tooltip.visible{visibility: visible !important;pointer-events: auto !important}${a} - `}var pe={};lt(pe,{applyCustomFormat:()=>Et,default:()=>Fn,expandSelection:()=>_t,getActiveFormats:()=>Ie,getDebugMode:()=>Je,hasFormat:()=>St,insertHeader:()=>ce,insertLink:()=>Te,preserveSelection:()=>xt,setDebugMode:()=>vt,setUndoMethod:()=>wt,toggleBold:()=>Ee,toggleBulletList:()=>He,toggleCode:()=>Ae,toggleH1:()=>Pe,toggleH2:()=>$e,toggleH3:()=>Re,toggleItalic:()=>Ce,toggleNumberedList:()=>Me,toggleQuote:()=>Oe,toggleTaskList:()=>le});var Cn=Object.defineProperty,ht=Object.getOwnPropertySymbols,An=Object.prototype.hasOwnProperty,Tn=Object.prototype.propertyIsEnumerable,ut=(n,e,t)=>e in n?Cn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ft=(n,e)=>{for(var t in e||(e={}))An.call(e,t)&&ut(n,t,e[t]);if(ht)for(var t of ht(e))Tn.call(e,t)&&ut(n,t,e[t]);return n},I={bold:{prefix:"**",suffix:"**",trimFirst:!0},italic:{prefix:"_",suffix:"_",trimFirst:!0},code:{prefix:"`",suffix:"`",blockPrefix:"```",blockSuffix:"```"},link:{prefix:"[",suffix:"](url)",replaceNext:"url",scanFor:"https?://"},bulletList:{prefix:"- ",multiline:!0,unorderedList:!0},numberedList:{prefix:"1. ",multiline:!0,orderedList:!0},quote:{prefix:"> ",multiline:!0,surroundWithNewlines:!0},taskList:{prefix:"- [ ] ",multiline:!0,surroundWithNewlines:!0},header1:{prefix:"# "},header2:{prefix:"## "},header3:{prefix:"### "},header4:{prefix:"#### "},header5:{prefix:"##### "},header6:{prefix:"###### "}};function Hn(){return{prefix:"",suffix:"",blockPrefix:"",blockSuffix:"",multiline:!1,replaceNext:"",prefixSpace:!1,scanFor:"",surroundWithNewlines:!1,orderedList:!1,unorderedList:!1,trimFirst:!1}}function B(n){return ft(ft({},Hn()),n)}var ae=!1;function vt(n){ae=n}function Je(){return ae}function x(n,e,t){ae&&(console.group(`\u{1F50D} ${n}`),console.log(e),t&&console.log("Data:",t),console.groupEnd())}function Se(n,e){if(!ae)return;let t=n.value.slice(n.selectionStart,n.selectionEnd);console.group(`\u{1F4CD} Selection: ${e}`),console.log("Position:",`${n.selectionStart}-${n.selectionEnd}`),console.log("Selected text:",JSON.stringify(t)),console.log("Length:",t.length);let i=n.value.slice(Math.max(0,n.selectionStart-10),n.selectionStart),o=n.value.slice(n.selectionEnd,Math.min(n.value.length,n.selectionEnd+10));console.log("Context:",JSON.stringify(i)+"[SELECTION]"+JSON.stringify(o)),console.groupEnd()}function yt(n){ae&&(console.group("\u{1F4DD} Result"),console.log("Text to insert:",JSON.stringify(n.text)),console.log("New selection:",`${n.selectionStart}-${n.selectionEnd}`),console.groupEnd())}var T=null;function N(n,{text:e,selectionStart:t,selectionEnd:i}){let o=Je();o&&(console.group("\u{1F527} insertText"),console.log("Current selection:",`${n.selectionStart}-${n.selectionEnd}`),console.log("Text to insert:",JSON.stringify(e)),console.log("New selection to set:",t,"-",i)),n.focus();let r=n.selectionStart,s=n.selectionEnd,a=n.value.slice(0,r),l=n.value.slice(s);o&&(console.log("Before text (last 20):",JSON.stringify(a.slice(-20))),console.log("After text (first 20):",JSON.stringify(l.slice(0,20))),console.log("Selected text being replaced:",JSON.stringify(n.value.slice(r,s))));let p=n.value,c=r!==s;if(T===null||T===!0){n.contentEditable="true";try{T=document.execCommand("insertText",!1,e),o&&console.log("execCommand returned:",T,"for text with",e.split(` -`).length,"lines")}catch(d){T=!1,o&&console.log("execCommand threw error:",d)}n.contentEditable="false"}if(o&&(console.log("canInsertText before:",T),console.log("execCommand result:",T)),T){let d=a+e+l,h=n.value;o&&(console.log("Expected length:",d.length),console.log("Actual length:",h.length)),h!==d&&o&&(console.log("execCommand changed the value but not as expected"),console.log("Expected:",JSON.stringify(d.slice(0,100))),console.log("Actual:",JSON.stringify(h.slice(0,100))))}if(!T)if(o&&console.log("Using manual insertion"),n.value===p){o&&console.log("Value unchanged, doing manual replacement");try{document.execCommand("ms-beginUndoUnit")}catch(d){}n.value=a+e+l;try{document.execCommand("ms-endUndoUnit")}catch(d){}n.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0}))}else o&&console.log("Value was changed by execCommand, skipping manual insertion");o&&console.log("Setting selection range:",t,i),t!=null&&i!=null?n.setSelectionRange(t,i):n.setSelectionRange(r,n.selectionEnd),o&&(console.log("Final value length:",n.value.length),console.groupEnd())}function wt(n){switch(n){case"native":T=!0;break;case"manual":T=!1;break;case"auto":T=null;break}}function Qe(n){return n.trim().split(` -`).length>1}function Mn(n,e){let t=e;for(;n[t]&&n[t-1]!=null&&!n[t-1].match(/\s/);)t--;return t}function On(n,e,t){let i=e,o=t?/\n/:/\s/;for(;n[i]&&!n[i].match(o);)i++;return i}function bt(n){let e=n.value.split(` -`),t=0;for(let i=0;i=t&&n.selectionStart=t&&n.selectionEnd0&&s[a-1]!==` -`;)a--;if(r){let p=i;for(;p0?`${s} -`:o,y=Qe(m)&&a&&a.length>0?` -${a}`:r;if(p){let k=n.value[n.selectionStart-1];n.selectionStart!==0&&k!=null&&!k.match(/\s/)&&(g=` ${g}`)}m=Pn(n,g,y,e.multiline);let w=n.selectionStart,b=n.selectionEnd,L=l&&l.length>0&&y.indexOf(l)>-1&&m.length>0;if(d){let k=Xe(n);t=k.newlinesToAppend,i=k.newlinesToPrepend,g=t+o,y+=i}if(m.startsWith(g)&&m.endsWith(y)){let k=m.slice(g.length,m.length-y.length);if(u===f){let _=u-g.length;_=Math.max(_,w),_=Math.min(_,w+k.length),w=b=_}else b=w+k.length;return{text:k,selectionStart:w,selectionEnd:b}}else if(L)if(c&&c.length>0&&m.match(c)){y=y.replace(l,m);let k=g+y;return w=b=w+g.length,{text:k,selectionStart:w,selectionEnd:b}}else{let k=g+m+y;return w=w+g.length+m.length+y.indexOf(l),b=w+l.length,{text:k,selectionStart:w,selectionEnd:b}}else{let k=g+m+y;w=u+g.length,b=f+g.length;let _=m.match(/^\s*|\s*$/g);if(h&&_){let be=_[0]||"",Y=_[1]||"";k=be+g+m.trim()+y+Y,w+=be.length,b-=Y.length}return{text:k,selectionStart:w,selectionEnd:b}}}function Ge(n,e){let{prefix:t,suffix:i,surroundWithNewlines:o}=e,r=n.value.slice(n.selectionStart,n.selectionEnd),s=n.selectionStart,a=n.selectionEnd,l=r.split(` -`);if(l.every(c=>c.startsWith(t)&&(!i||c.endsWith(i))))r=l.map(c=>{let d=c.slice(t.length);return i&&(d=d.slice(0,d.length-i.length)),d}).join(` -`),a=s+r.length;else if(r=l.map(c=>t+c+(i||"")).join(` -`),o){let{newlinesToAppend:c,newlinesToPrepend:d}=Xe(n);s+=c.length,a=s+r.length,r=c+r+d}return{text:r,selectionStart:s,selectionEnd:a}}function mt(n){let e=n.split(` -`),t=/^\d+\.\s+/,i=e.every(r=>t.test(r)),o=e;return i&&(o=e.map(r=>r.replace(t,""))),{text:o.join(` -`),processed:i}}function gt(n){let e=n.split(` -`),t="- ",i=e.every(r=>r.startsWith(t)),o=e;return i&&(o=e.map(r=>r.slice(t.length))),{text:o.join(` -`),processed:i}}function se(n,e){return e?"- ":`${n+1}. `}function $n(n,e){let t,i,o;return n.orderedList?(t=mt(e),i=gt(t.text),o=i.text):(t=gt(e),i=mt(t.text),o=i.text),[t,i,o]}function Rn(n,e){let t=n.selectionStart===n.selectionEnd,i=n.selectionStart,o=n.selectionEnd;bt(n);let r=n.value.slice(n.selectionStart,n.selectionEnd),[s,a,l]=$n(e,r),p=l.split(` -`).map((m,g)=>`${se(g,e.unorderedList)}${m}`),c=p.reduce((m,g,y)=>m+se(y,e.unorderedList).length,0),d=p.reduce((m,g,y)=>m+se(y,!e.unorderedList).length,0);if(s.processed)return t?(i=Math.max(i-se(0,e.unorderedList).length,0),o=i):(i=n.selectionStart,o=n.selectionEnd-c),{text:l,selectionStart:i,selectionEnd:o};let{newlinesToAppend:h,newlinesToPrepend:u}=Xe(n),f=h+p.join(` -`)+u;return t?(i=Math.max(i+se(0,e.unorderedList).length+h.length,0),o=i):a.processed?(i=Math.max(n.selectionStart+h.length,0),o=n.selectionEnd+h.length+c-d):(i=Math.max(n.selectionStart+h.length,0),o=n.selectionEnd+h.length+c),{text:f,selectionStart:i,selectionEnd:o}}function kt(n,e){let t=_e(n,i=>Rn(i,e),{adjustSelection:(i,o,r,s)=>{let a=n.value.slice(s,n.selectionEnd),l=/^\d+\.\s+/,p=/^- /,c=l.test(a),d=p.test(a),h=e.orderedList&&c||e.unorderedList&&d;if(o===r)if(h){let u=a.match(e.orderedList?l:p),f=u?u[0].length:0;return{start:Math.max(o-f,s),end:Math.max(o-f,s)}}else if(c||d){let u=a.match(c?l:p),f=u?u[0].length:0,g=(e.unorderedList?2:3)-f;return{start:o+g,end:o+g}}else{let u=e.unorderedList?2:3;return{start:o+u,end:o+u}}else if(h){let u=a.match(e.orderedList?l:p),f=u?u[0].length:0;return{start:Math.max(o-f,s),end:Math.max(r-f,s)}}else if(c||d){let u=a.match(c?l:p),f=u?u[0].length:0,g=(e.unorderedList?2:3)-f;return{start:o+g,end:r+g}}else{let u=e.unorderedList?2:3;return{start:o+u,end:r+u}}}});N(n,t)}function Lt(n){if(!n)return[];let e=[],{selectionStart:t,selectionEnd:i,value:o}=n,r=o.split(` -`),s=0,a="";for(let d of r){if(t>=s&&t<=s+d.length){a=d;break}s+=d.length+1}a.startsWith("- ")&&(a.startsWith("- [ ] ")||a.startsWith("- [x] ")?e.push("task-list"):e.push("bullet-list")),/^\d+\.\s/.test(a)&&e.push("numbered-list"),a.startsWith("> ")&&e.push("quote"),a.startsWith("# ")&&e.push("header"),a.startsWith("## ")&&e.push("header-2"),a.startsWith("### ")&&e.push("header-3");let l=Math.max(0,t-10),p=Math.min(o.length,i+10),c=o.slice(l,p);if(c.includes("**")){let d=o.slice(Math.max(0,t-100),t),h=o.slice(i,Math.min(o.length,i+100)),u=d.lastIndexOf("**"),f=h.indexOf("**");u!==-1&&f!==-1&&e.push("bold")}if(c.includes("_")){let d=o.slice(Math.max(0,t-100),t),h=o.slice(i,Math.min(o.length,i+100)),u=d.lastIndexOf("_"),f=h.indexOf("_");u!==-1&&f!==-1&&e.push("italic")}if(c.includes("`")){let d=o.slice(Math.max(0,t-100),t),h=o.slice(i,Math.min(o.length,i+100));d.includes("`")&&h.includes("`")&&e.push("code")}if(c.includes("[")&&c.includes("]")){let d=o.slice(Math.max(0,t-100),t),h=o.slice(i,Math.min(o.length,i+100)),u=d.lastIndexOf("["),f=h.indexOf("]");u!==-1&&f!==-1&&o.slice(i+f+1,i+f+10).startsWith("(")&&e.push("link")}return e}function In(n,e){return Lt(n).includes(e)}function Bn(n,e={}){if(!n)return;let{toWord:t,toLine:i,toFormat:o}=e,{selectionStart:r,selectionEnd:s,value:a}=n;if(i){let l=a.split(` -`),p=0,c=0,d=0;for(let h of l){if(r>=d&&r<=d+h.length){p=d,c=d+h.length;break}d+=h.length+1}n.selectionStart=p,n.selectionEnd=c}else if(t&&r===s){let l=r,p=s;for(;l>0&&!/\s/.test(a[l-1]);)l--;for(;pGe(i,e),{prefix:e.prefix});yt(t),N(n,t),Se(n,"Final")}function le(n){if(!n||n.disabled||n.readOnly)return;let e=B(I.taskList),t=_e(n,i=>Ge(i,e),{prefix:e.prefix});N(n,t)}function ce(n,e=1,t=!1){if(!n||n.disabled||n.readOnly)return;(e<1||e>6)&&(e=1),x("insertHeader","============ START ============"),x("insertHeader",`Level: ${e}, Toggle: ${t}`),x("insertHeader",`Initial cursor: ${n.selectionStart}-${n.selectionEnd}`);let i=`header${e===1?"1":e}`,o=B(I[i]||I.header1);x("insertHeader",`Style prefix: "${o.prefix}"`);let r=n.value,s=n.selectionStart,a=n.selectionEnd,l=s;for(;l>0&&r[l-1]!==` -`;)l--;let p=a;for(;p{let y=g.value.slice(g.selectionStart,g.selectionEnd);x("insertHeader",`Line in operation: "${y}"`);let w=y.replace(/^#{1,6}\s*/,"");x("insertHeader",`Cleaned line: "${w}"`);let b;return f?(x("insertHeader","ACTION: Toggling OFF - removing header"),b=w):h>0?(x("insertHeader",`ACTION: Replacing H${h} with H${e}`),b=o.prefix+w):(x("insertHeader","ACTION: Adding new header"),b=o.prefix+w),x("insertHeader",`New line: "${b}"`),{text:b,selectionStart:g.selectionStart,selectionEnd:g.selectionEnd}},{prefix:o.prefix,adjustSelection:(g,y,w,b)=>{if(x("insertHeader","Adjusting selection:"),x("insertHeader",` - isRemoving param: ${g}`),x("insertHeader",` - shouldToggleOff: ${f}`),x("insertHeader",` - selStart: ${y}, selEnd: ${w}`),x("insertHeader",` - lineStartPos: ${b}`),f){let L=Math.max(y-u,b);return x("insertHeader",` - Removing header, adjusting by -${u}`),{start:L,end:y===w?L:Math.max(w-u,b)}}else if(u>0){let L=o.prefix.length-u;return x("insertHeader",` - Replacing header, adjusting by ${L}`),{start:y+L,end:w+L}}else return x("insertHeader",` - Adding header, adjusting by +${o.prefix.length}`),{start:y+o.prefix.length,end:w+o.prefix.length}}});x("insertHeader",`Final result: text="${m.text}", cursor=${m.selectionStart}-${m.selectionEnd}`),x("insertHeader","============ END ============"),N(n,m)}function Pe(n){ce(n,1,!0)}function $e(n){ce(n,2,!0)}function Re(n){ce(n,3,!0)}function Ie(n){return Lt(n)}function St(n,e){return In(n,e)}function _t(n,e={}){Bn(n,e)}function Et(n,e){if(!n||n.disabled||n.readOnly)return;let t=B(e),i;if(t.multiline){let o=n.value.slice(n.selectionStart,n.selectionEnd);Qe(o)?i=Ge(n,t):i=te(n,t)}else i=te(n,t);N(n,i)}var Fn={toggleBold:Ee,toggleItalic:Ce,toggleCode:Ae,insertLink:Te,toggleBulletList:He,toggleNumberedList:Me,toggleQuote:Oe,toggleTaskList:le,insertHeader:ce,toggleH1:Pe,toggleH2:$e,toggleH3:Re,getActiveFormats:Ie,hasFormat:St,expandSelection:_t,applyCustomFormat:Et,preserveSelection:xt,setUndoMethod:wt,setDebugMode:vt,getDebugMode:Je};var Be=class{constructor(e,t={}){this.editor=e,this.container=null,this.buttons={},this.toolbarButtons=t.toolbarButtons||[]}create(){this.container=document.createElement("div"),this.container.className="overtype-toolbar",this.container.setAttribute("role","toolbar"),this.container.setAttribute("aria-label","Formatting toolbar"),this.toolbarButtons.forEach(e=>{if(e.name==="separator"){let t=this.createSeparator();this.container.appendChild(t)}else{let t=this.createButton(e);this.buttons[e.name]=t,this.container.appendChild(t)}}),this.editor.container.insertBefore(this.container,this.editor.wrapper)}createSeparator(){let e=document.createElement("div");return e.className="overtype-toolbar-separator",e.setAttribute("role","separator"),e}createButton(e){let t=document.createElement("button");return t.className="overtype-toolbar-button",t.type="button",t.setAttribute("data-button",e.name),t.title=e.title||"",t.setAttribute("aria-label",e.title||e.name),t.innerHTML=this.sanitizeSVG(e.icon||""),e.name==="viewMode"?(t.classList.add("has-dropdown"),t.dataset.dropdown="true",t.addEventListener("click",i=>{i.preventDefault(),this.toggleViewModeDropdown(t)}),t):(t._clickHandler=i=>{i.preventDefault();let o=e.actionId||e.name;this.editor.performAction(o,i)},t.addEventListener("click",t._clickHandler),t)}async handleAction(e){if(e&&typeof e=="object"&&typeof e.action=="function"){this.editor.textarea.focus();try{return await e.action({editor:this.editor,getValue:()=>this.editor.getValue(),setValue:t=>this.editor.setValue(t),event:null}),!0}catch(t){return console.error(`Action "${e.name}" error:`,t),this.editor.wrapper.dispatchEvent(new CustomEvent("button-error",{detail:{buttonName:e.name,error:t}})),!1}}return typeof e=="string"?this.editor.performAction(e,null):!1}sanitizeSVG(e){return typeof e!="string"?"":e.replace(/)<[^<]*)*<\/script>/gi,"").replace(/\son\w+\s*=\s*["'][^"']*["']/gi,"").replace(/\son\w+\s*=\s*[^\s>]*/gi,"")}toggleViewModeDropdown(e){let t=document.querySelector(".overtype-dropdown-menu");if(t){t.remove(),e.classList.remove("dropdown-active");return}e.classList.add("dropdown-active");let i=this.createViewModeDropdown(e),o=e.getBoundingClientRect();i.style.position="absolute",i.style.top=`${o.bottom+5}px`,i.style.left=`${o.left}px`,document.body.appendChild(i),this.handleDocumentClick=r=>{!i.contains(r.target)&&!e.contains(r.target)&&(i.remove(),e.classList.remove("dropdown-active"),document.removeEventListener("click",this.handleDocumentClick))},setTimeout(()=>{document.addEventListener("click",this.handleDocumentClick)},0)}createViewModeDropdown(e){let t=document.createElement("div");t.className="overtype-dropdown-menu";let i=[{id:"normal",label:"Normal Edit",icon:"\u2713"},{id:"plain",label:"Plain Textarea",icon:"\u2713"},{id:"preview",label:"Preview Mode",icon:"\u2713"}],o=this.editor.container.dataset.mode||"normal";return i.forEach(r=>{let s=document.createElement("button");if(s.className="overtype-dropdown-item",s.type="button",s.textContent=r.label,r.id===o){s.classList.add("active"),s.setAttribute("aria-current","true");let a=document.createElement("span");a.className="overtype-dropdown-icon",a.textContent=r.icon,s.prepend(a)}s.addEventListener("click",a=>{switch(a.preventDefault(),r.id){case"plain":this.editor.showPlainTextarea();break;case"preview":this.editor.showPreviewMode();break;case"normal":default:this.editor.showNormalEditMode();break}t.remove(),e.classList.remove("dropdown-active"),document.removeEventListener("click",this.handleDocumentClick)}),t.appendChild(s)}),t}updateButtonStates(){var e;try{let t=((e=Ie)==null?void 0:e(this.editor.textarea,this.editor.textarea.selectionStart))||[];Object.entries(this.buttons).forEach(([i,o])=>{if(i==="viewMode")return;let r=!1;switch(i){case"bold":r=t.includes("bold");break;case"italic":r=t.includes("italic");break;case"code":r=!1;break;case"bulletList":r=t.includes("bullet-list");break;case"orderedList":r=t.includes("numbered-list");break;case"taskList":r=t.includes("task-list");break;case"quote":r=t.includes("quote");break;case"h1":r=t.includes("header");break;case"h2":r=t.includes("header-2");break;case"h3":r=t.includes("header-3");break}o.classList.toggle("active",r),o.setAttribute("aria-pressed",r.toString())})}catch(t){}}show(){this.container&&this.container.classList.remove("overtype-toolbar-hidden")}hide(){this.container&&this.container.classList.add("overtype-toolbar-hidden")}destroy(){this.container&&(this.handleDocumentClick&&document.removeEventListener("click",this.handleDocumentClick),Object.values(this.buttons).forEach(e=>{e._clickHandler&&(e.removeEventListener("click",e._clickHandler),delete e._clickHandler)}),this.container.remove(),this.container=null,this.buttons={})}};var he=Math.min,U=Math.max,ue=Math.round;var P=n=>({x:n,y:n}),zn={left:"right",right:"left",bottom:"top",top:"bottom"},Nn={start:"end",end:"start"};function Ye(n,e,t){return U(n,he(e,t))}function fe(n,e){return typeof n=="function"?n(e):n}function W(n){return n.split("-")[0]}function me(n){return n.split("-")[1]}function et(n){return n==="x"?"y":"x"}function tt(n){return n==="y"?"height":"width"}var Dn=new Set(["top","bottom"]);function D(n){return Dn.has(W(n))?"y":"x"}function nt(n){return et(D(n))}function Tt(n,e,t){t===void 0&&(t=!1);let i=me(n),o=nt(n),r=tt(o),s=o==="x"?i===(t?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(s=de(s)),[s,de(s)]}function Ht(n){let e=de(n);return[Fe(n),e,Fe(e)]}function Fe(n){return n.replace(/start|end/g,e=>Nn[e])}var Ct=["left","right"],At=["right","left"],jn=["top","bottom"],Vn=["bottom","top"];function Un(n,e,t){switch(n){case"top":case"bottom":return t?e?At:Ct:e?Ct:At;case"left":case"right":return e?jn:Vn;default:return[]}}function Mt(n,e,t,i){let o=me(n),r=Un(W(n),t==="start",i);return o&&(r=r.map(s=>s+"-"+o),e&&(r=r.concat(r.map(Fe)))),r}function de(n){return n.replace(/left|right|bottom|top/g,e=>zn[e])}function Wn(n){return{top:0,right:0,bottom:0,left:0,...n}}function Ot(n){return typeof n!="number"?Wn(n):{top:n,right:n,bottom:n,left:n}}function J(n){let{x:e,y:t,width:i,height:o}=n;return{width:i,height:o,top:t,left:e,right:e+i,bottom:t+o,x:e,y:t}}function Pt(n,e,t){let{reference:i,floating:o}=n,r=D(e),s=nt(e),a=tt(s),l=W(e),p=r==="y",c=i.x+i.width/2-o.width/2,d=i.y+i.height/2-o.height/2,h=i[a]/2-o[a]/2,u;switch(l){case"top":u={x:c,y:i.y-o.height};break;case"bottom":u={x:c,y:i.y+i.height};break;case"right":u={x:i.x+i.width,y:d};break;case"left":u={x:i.x-o.width,y:d};break;default:u={x:i.x,y:i.y}}switch(me(e)){case"start":u[s]-=h*(t&&p?-1:1);break;case"end":u[s]+=h*(t&&p?-1:1);break}return u}async function $t(n,e){var t;e===void 0&&(e={});let{x:i,y:o,platform:r,rects:s,elements:a,strategy:l}=n,{boundary:p="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:h=!1,padding:u=0}=fe(e,n),f=Ot(u),g=a[h?d==="floating"?"reference":"floating":d],y=J(await r.getClippingRect({element:(t=await(r.isElement==null?void 0:r.isElement(g)))==null||t?g:g.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(a.floating)),boundary:p,rootBoundary:c,strategy:l})),w=d==="floating"?{x:i,y:o,width:s.floating.width,height:s.floating.height}:s.reference,b=await(r.getOffsetParent==null?void 0:r.getOffsetParent(a.floating)),L=await(r.isElement==null?void 0:r.isElement(b))?await(r.getScale==null?void 0:r.getScale(b))||{x:1,y:1}:{x:1,y:1},k=J(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:b,strategy:l}):w);return{top:(y.top-k.top+f.top)/L.y,bottom:(k.bottom-y.bottom+f.bottom)/L.y,left:(y.left-k.left+f.left)/L.x,right:(k.right-y.right+f.right)/L.x}}var Rt=async(n,e,t)=>{let{placement:i="bottom",strategy:o="absolute",middleware:r=[],platform:s}=t,a=r.filter(Boolean),l=await(s.isRTL==null?void 0:s.isRTL(e)),p=await s.getElementRects({reference:n,floating:e,strategy:o}),{x:c,y:d}=Pt(p,i,l),h=i,u={},f=0;for(let g=0;gK<=0)){var rt,st;let K=(((rt=r.flip)==null?void 0:rt.index)||0)+1,Ke=be[K];if(Ke&&(!(d==="alignment"?w!==D(Ke):!1)||ee.every(O=>D(O.placement)===w?O.overflows[0]>0:!0)))return{data:{index:K,overflows:ee},reset:{placement:Ke}};let oe=(st=ee.filter(Z=>Z.overflows[0]<=0).sort((Z,O)=>Z.overflows[1]-O.overflows[1])[0])==null?void 0:st.placement;if(!oe)switch(u){case"bestFit":{var at;let Z=(at=ee.filter(O=>{if(_){let V=D(O.placement);return V===w||V==="y"}return!0}).map(O=>[O.placement,O.overflows.filter(V=>V>0).reduce((V,bn)=>V+bn,0)]).sort((O,V)=>O[1]-V[1])[0])==null?void 0:at[0];Z&&(oe=Z);break}case"initialPlacement":oe=a;break}if(o!==oe)return{reset:{placement:oe}}}return{}}}};var qn=new Set(["left","top"]);async function Kn(n,e){let{placement:t,platform:i,elements:o}=n,r=await(i.isRTL==null?void 0:i.isRTL(o.floating)),s=W(t),a=me(t),l=D(t)==="y",p=qn.has(s)?-1:1,c=r&&l?-1:1,d=fe(e,n),{mainAxis:h,crossAxis:u,alignmentAxis:f}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof f=="number"&&(u=a==="end"?f*-1:f),l?{x:u*c,y:h*p}:{x:h*p,y:u*c}}var Bt=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,i;let{x:o,y:r,placement:s,middlewareData:a}=e,l=await Kn(e,n);return s===((t=a.offset)==null?void 0:t.placement)&&(i=a.arrow)!=null&&i.alignmentOffset?{}:{x:o+l.x,y:r+l.y,data:{...l,placement:s}}}}},Ft=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){let{x:t,y:i,placement:o,platform:r}=e,{mainAxis:s=!0,crossAxis:a=!1,limiter:l={fn:y=>{let{x:w,y:b}=y;return{x:w,y:b}}},...p}=fe(n,e),c={x:t,y:i},d=await r.detectOverflow(e,p),h=D(W(o)),u=et(h),f=c[u],m=c[h];if(s){let y=u==="y"?"top":"left",w=u==="y"?"bottom":"right",b=f+d[y],L=f-d[w];f=Ye(b,f,L)}if(a){let y=h==="y"?"top":"left",w=h==="y"?"bottom":"right",b=m+d[y],L=m-d[w];m=Ye(b,m,L)}let g=l.fn({...e,[u]:f,[h]:m});return{...g,data:{x:g.x-t,y:g.y-i,enabled:{[u]:s,[h]:a}}}}}};function Ne(){return typeof window<"u"}function X(n){return Nt(n)?(n.nodeName||"").toLowerCase():"#document"}function A(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function F(n){var e;return(e=(Nt(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function Nt(n){return Ne()?n instanceof Node||n instanceof A(n).Node:!1}function H(n){return Ne()?n instanceof Element||n instanceof A(n).Element:!1}function $(n){return Ne()?n instanceof HTMLElement||n instanceof A(n).HTMLElement:!1}function zt(n){return!Ne()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof A(n).ShadowRoot}var Zn=new Set(["inline","contents"]);function ne(n){let{overflow:e,overflowX:t,overflowY:i,display:o}=M(n);return/auto|scroll|overlay|hidden|clip/.test(e+i+t)&&!Zn.has(o)}var Qn=new Set(["table","td","th"]);function Dt(n){return Qn.has(X(n))}var Jn=[":popover-open",":modal"];function ge(n){return Jn.some(e=>{try{return n.matches(e)}catch(t){return!1}})}var Xn=["transform","translate","scale","rotate","perspective"],Gn=["transform","translate","scale","rotate","perspective","filter"],Yn=["paint","layout","strict","content"];function De(n){let e=je(),t=H(n)?M(n):n;return Xn.some(i=>t[i]?t[i]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||Gn.some(i=>(t.willChange||"").includes(i))||Yn.some(i=>(t.contain||"").includes(i))}function jt(n){let e=j(n);for(;$(e)&&!G(e);){if(De(e))return e;if(ge(e))return null;e=j(e)}return null}function je(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}var ei=new Set(["html","body","#document"]);function G(n){return ei.has(X(n))}function M(n){return A(n).getComputedStyle(n)}function ve(n){return H(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function j(n){if(X(n)==="html")return n;let e=n.assignedSlot||n.parentNode||zt(n)&&n.host||F(n);return zt(e)?e.host:e}function Vt(n){let e=j(n);return G(e)?n.ownerDocument?n.ownerDocument.body:n.body:$(e)&&ne(e)?e:Vt(e)}function ze(n,e,t){var i;e===void 0&&(e=[]),t===void 0&&(t=!0);let o=Vt(n),r=o===((i=n.ownerDocument)==null?void 0:i.body),s=A(o);if(r){let a=Ve(s);return e.concat(s,s.visualViewport||[],ne(o)?o:[],a&&t?ze(a):[])}return e.concat(o,ze(o,[],t))}function Ve(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function Kt(n){let e=M(n),t=parseFloat(e.width)||0,i=parseFloat(e.height)||0,o=$(n),r=o?n.offsetWidth:t,s=o?n.offsetHeight:i,a=ue(t)!==r||ue(i)!==s;return a&&(t=r,i=s),{width:t,height:i,$:a}}function Zt(n){return H(n)?n:n.contextElement}function ie(n){let e=Zt(n);if(!$(e))return P(1);let t=e.getBoundingClientRect(),{width:i,height:o,$:r}=Kt(e),s=(r?ue(t.width):t.width)/i,a=(r?ue(t.height):t.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var ti=P(0);function Qt(n){let e=A(n);return!je()||!e.visualViewport?ti:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function ni(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==A(n)?!1:e}function ye(n,e,t,i){e===void 0&&(e=!1),t===void 0&&(t=!1);let o=n.getBoundingClientRect(),r=Zt(n),s=P(1);e&&(i?H(i)&&(s=ie(i)):s=ie(n));let a=ni(r,t,i)?Qt(r):P(0),l=(o.left+a.x)/s.x,p=(o.top+a.y)/s.y,c=o.width/s.x,d=o.height/s.y;if(r){let h=A(r),u=i&&H(i)?A(i):i,f=h,m=Ve(f);for(;m&&i&&u!==f;){let g=ie(m),y=m.getBoundingClientRect(),w=M(m),b=y.left+(m.clientLeft+parseFloat(w.paddingLeft))*g.x,L=y.top+(m.clientTop+parseFloat(w.paddingTop))*g.y;l*=g.x,p*=g.y,c*=g.x,d*=g.y,l+=b,p+=L,f=A(m),m=Ve(f)}}return J({width:c,height:d,x:l,y:p})}function Ue(n,e){let t=ve(n).scrollLeft;return e?e.left+t:ye(F(n)).left+t}function Jt(n,e){let t=n.getBoundingClientRect(),i=t.left+e.scrollLeft-Ue(n,t),o=t.top+e.scrollTop;return{x:i,y:o}}function ii(n){let{elements:e,rect:t,offsetParent:i,strategy:o}=n,r=o==="fixed",s=F(i),a=e?ge(e.floating):!1;if(i===s||a&&r)return t;let l={scrollLeft:0,scrollTop:0},p=P(1),c=P(0),d=$(i);if((d||!d&&!r)&&((X(i)!=="body"||ne(s))&&(l=ve(i)),$(i))){let u=ye(i);p=ie(i),c.x=u.x+i.clientLeft,c.y=u.y+i.clientTop}let h=s&&!d&&!r?Jt(s,l):P(0);return{width:t.width*p.x,height:t.height*p.y,x:t.x*p.x-l.scrollLeft*p.x+c.x+h.x,y:t.y*p.y-l.scrollTop*p.y+c.y+h.y}}function oi(n){return Array.from(n.getClientRects())}function ri(n){let e=F(n),t=ve(n),i=n.ownerDocument.body,o=U(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),r=U(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight),s=-t.scrollLeft+Ue(n),a=-t.scrollTop;return M(i).direction==="rtl"&&(s+=U(e.clientWidth,i.clientWidth)-o),{width:o,height:r,x:s,y:a}}var Ut=25;function si(n,e){let t=A(n),i=F(n),o=t.visualViewport,r=i.clientWidth,s=i.clientHeight,a=0,l=0;if(o){r=o.width,s=o.height;let c=je();(!c||c&&e==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}let p=Ue(i);if(p<=0){let c=i.ownerDocument,d=c.body,h=getComputedStyle(d),u=c.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,f=Math.abs(i.clientWidth-d.clientWidth-u);f<=Ut&&(r-=f)}else p<=Ut&&(r+=p);return{width:r,height:s,x:a,y:l}}var ai=new Set(["absolute","fixed"]);function li(n,e){let t=ye(n,!0,e==="fixed"),i=t.top+n.clientTop,o=t.left+n.clientLeft,r=$(n)?ie(n):P(1),s=n.clientWidth*r.x,a=n.clientHeight*r.y,l=o*r.x,p=i*r.y;return{width:s,height:a,x:l,y:p}}function Wt(n,e,t){let i;if(e==="viewport")i=si(n,t);else if(e==="document")i=ri(F(n));else if(H(e))i=li(e,t);else{let o=Qt(n);i={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return J(i)}function Xt(n,e){let t=j(n);return t===e||!H(t)||G(t)?!1:M(t).position==="fixed"||Xt(t,e)}function ci(n,e){let t=e.get(n);if(t)return t;let i=ze(n,[],!1).filter(a=>H(a)&&X(a)!=="body"),o=null,r=M(n).position==="fixed",s=r?j(n):n;for(;H(s)&&!G(s);){let a=M(s),l=De(s);!l&&a.position==="fixed"&&(o=null),(r?!l&&!o:!l&&a.position==="static"&&!!o&&ai.has(o.position)||ne(s)&&!l&&Xt(n,s))?i=i.filter(c=>c!==s):o=a,s=j(s)}return e.set(n,i),i}function pi(n){let{element:e,boundary:t,rootBoundary:i,strategy:o}=n,s=[...t==="clippingAncestors"?ge(e)?[]:ci(e,this._c):[].concat(t),i],a=s[0],l=s.reduce((p,c)=>{let d=Wt(e,c,o);return p.top=U(d.top,p.top),p.right=he(d.right,p.right),p.bottom=he(d.bottom,p.bottom),p.left=U(d.left,p.left),p},Wt(e,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function di(n){let{width:e,height:t}=Kt(n);return{width:e,height:t}}function hi(n,e,t){let i=$(e),o=F(e),r=t==="fixed",s=ye(n,!0,r,e),a={scrollLeft:0,scrollTop:0},l=P(0);function p(){l.x=Ue(o)}if(i||!i&&!r)if((X(e)!=="body"||ne(o))&&(a=ve(e)),i){let u=ye(e,!0,r,e);l.x=u.x+e.clientLeft,l.y=u.y+e.clientTop}else o&&p();r&&!i&&o&&p();let c=o&&!i&&!r?Jt(o,a):P(0),d=s.left+a.scrollLeft-l.x-c.x,h=s.top+a.scrollTop-l.y-c.y;return{x:d,y:h,width:s.width,height:s.height}}function it(n){return M(n).position==="static"}function qt(n,e){if(!$(n)||M(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return F(n)===t&&(t=t.ownerDocument.body),t}function Gt(n,e){let t=A(n);if(ge(n))return t;if(!$(n)){let o=j(n);for(;o&&!G(o);){if(H(o)&&!it(o))return o;o=j(o)}return t}let i=qt(n,e);for(;i&&Dt(i)&&it(i);)i=qt(i,e);return i&&G(i)&&it(i)&&!De(i)?t:i||jt(n)||t}var ui=async function(n){let e=this.getOffsetParent||Gt,t=this.getDimensions,i=await t(n.floating);return{reference:hi(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function fi(n){return M(n).direction==="rtl"}var mi={convertOffsetParentRelativeRectToViewportRelativeRect:ii,getDocumentElement:F,getClippingRect:pi,getOffsetParent:Gt,getElementRects:ui,getClientRects:oi,getDimensions:di,getScale:ie,isElement:H,isRTL:fi};var Yt=Bt;var en=Ft,tn=It;var nn=(n,e,t)=>{let i=new Map,o={platform:mi,...t},r={...o.platform,_c:i};return Rt(n,e,{...o,platform:r})};var We=class{constructor(e){this.editor=e,this.tooltip=null,this.currentLink=null,this.hideTimeout=null,this.visibilityChangeHandler=null,this.isTooltipHovered=!1,this.init()}init(){this.createTooltip(),this.editor.textarea.addEventListener("selectionchange",()=>this.checkCursorPosition()),this.editor.textarea.addEventListener("keyup",e=>{(e.key.includes("Arrow")||e.key==="Home"||e.key==="End")&&this.checkCursorPosition()}),this.editor.textarea.addEventListener("input",()=>this.hide()),this.editor.textarea.addEventListener("scroll",()=>{this.currentLink&&this.positionTooltip(this.currentLink)}),this.editor.textarea.addEventListener("blur",()=>{this.isTooltipHovered||this.hide()}),this.visibilityChangeHandler=()=>{document.hidden&&this.hide()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),this.tooltip.addEventListener("mouseenter",()=>{this.isTooltipHovered=!0,this.cancelHide()}),this.tooltip.addEventListener("mouseleave",()=>{this.isTooltipHovered=!1,this.scheduleHide()})}createTooltip(){this.tooltip=document.createElement("div"),this.tooltip.className="overtype-link-tooltip",this.tooltip.innerHTML=` - - - - - - - - `,this.tooltip.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),this.currentLink&&(window.open(this.currentLink.url,"_blank"),this.hide())}),this.editor.container.appendChild(this.tooltip)}checkCursorPosition(){let e=this.editor.textarea.selectionStart,t=this.editor.textarea.value,i=this.findLinkAtPosition(t,e);i?(!this.currentLink||this.currentLink.url!==i.url||this.currentLink.index!==i.index)&&this.show(i):this.scheduleHide()}findLinkAtPosition(e,t){let i=/\[([^\]]+)\]\(([^)]+)\)/g,o,r=0;for(;(o=i.exec(e))!==null;){let s=o.index,a=o.index+o[0].length;if(t>=s&&t<=a)return{text:o[1],url:o[2],index:r,start:s,end:a};r++}return null}async show(e){this.currentLink=e,this.cancelHide();let t=this.tooltip.querySelector(".overtype-link-tooltip-url");t.textContent=e.url,await this.positionTooltip(e),this.currentLink===e&&this.tooltip.classList.add("visible")}async positionTooltip(e){let t=this.findAnchorElement(e.index);if(!t)return;let i=t.getBoundingClientRect();if(!(i.width===0||i.height===0))try{let{x:o,y:r}=await nn(t,this.tooltip,{strategy:"fixed",placement:"bottom",middleware:[Yt(8),en({padding:8}),tn()]});Object.assign(this.tooltip.style,{left:`${o}px`,top:`${r}px`,position:"fixed"})}catch(o){console.warn("Floating UI positioning failed:",o)}}findAnchorElement(e){return this.editor.preview.querySelector(`a[style*="--link-${e}"]`)}hide(){this.tooltip.classList.remove("visible"),this.currentLink=null,this.isTooltipHovered=!1}scheduleHide(){this.cancelHide(),this.hideTimeout=setTimeout(()=>this.hide(),300)}cancelHide(){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null)}destroy(){this.cancelHide(),this.visibilityChangeHandler&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null),this.tooltip&&this.tooltip.parentNode&&this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null,this.currentLink=null,this.isTooltipHovered=!1}};var on='',rn='',sn='',an='',ln='',cn='',pn='',dn='',hn='',un='',fn='',mn='',gn='';var S={bold:{name:"bold",actionId:"toggleBold",icon:on,title:"Bold (Ctrl+B)",action:({editor:n})=>{Ee(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},italic:{name:"italic",actionId:"toggleItalic",icon:rn,title:"Italic (Ctrl+I)",action:({editor:n})=>{Ce(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},code:{name:"code",actionId:"toggleCode",icon:pn,title:"Inline Code",action:({editor:n})=>{Ae(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},separator:{name:"separator"},link:{name:"link",actionId:"insertLink",icon:cn,title:"Insert Link",action:({editor:n})=>{Te(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},h1:{name:"h1",actionId:"toggleH1",icon:sn,title:"Heading 1",action:({editor:n})=>{Pe(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},h2:{name:"h2",actionId:"toggleH2",icon:an,title:"Heading 2",action:({editor:n})=>{$e(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},h3:{name:"h3",actionId:"toggleH3",icon:ln,title:"Heading 3",action:({editor:n})=>{Re(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},bulletList:{name:"bulletList",actionId:"toggleBulletList",icon:dn,title:"Bullet List",action:({editor:n})=>{He(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},orderedList:{name:"orderedList",actionId:"toggleNumberedList",icon:hn,title:"Numbered List",action:({editor:n})=>{Me(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},taskList:{name:"taskList",actionId:"toggleTaskList",icon:fn,title:"Task List",action:({editor:n})=>{le&&(le(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0})))}},quote:{name:"quote",actionId:"toggleQuote",icon:un,title:"Quote",action:({editor:n})=>{Oe(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},upload:{name:"upload",actionId:"uploadFile",icon:mn,title:"Upload File",action:({editor:n})=>{var t,i;if(!((t=n.options.fileUpload)!=null&&t.enabled))return;let e=document.createElement("input");e.type="file",e.multiple=!0,((i=n.options.fileUpload.mimeTypes)==null?void 0:i.length)>0&&(e.accept=n.options.fileUpload.mimeTypes.join(",")),e.onchange=()=>{var r;if(!((r=e.files)!=null&&r.length))return;let o=new DataTransfer;for(let s of e.files)o.items.add(s);n._handleDataTransfer(o)},e.click()}},viewMode:{name:"viewMode",icon:gn,title:"View mode"}},we=[S.bold,S.italic,S.code,S.separator,S.link,S.separator,S.h1,S.h2,S.h3,S.separator,S.bulletList,S.orderedList,S.taskList,S.separator,S.quote,S.separator,S.viewMode];function ot(n){let e={};return(n||[]).forEach(t=>{if(!t||t.name==="separator")return;let i=t.actionId||t.name;t.action&&(e[i]=t.action)}),e}function vn(n){let e=n||we;return Array.isArray(e)?e.map(t=>({name:(t==null?void 0:t.name)||null,actionId:(t==null?void 0:t.actionId)||(t==null?void 0:t.name)||null,icon:(t==null?void 0:t.icon)||null,title:(t==null?void 0:t.title)||null})):null}function vi(n,e){let t=vn(n),i=vn(e);if(t===null||i===null)return t!==i;if(t.length!==i.length)return!0;for(let o=0;o{if(r.overTypeInstance)return r.overTypeInstance.reinit(t),r.overTypeInstance;let s=Object.create(v.prototype);return s._init(r,t),r.overTypeInstance=s,v.instances.set(r,s),s})}_init(e,t={}){this.element=e,this.instanceTheme=t.theme||null,this.options=this._mergeOptions(t),this.instanceId=++v.instanceCount,this.initialized=!1,v.injectStyles(),v.initGlobalListeners();let i=e.querySelector(".overtype-container"),o=e.querySelector(".overtype-wrapper");i||o?this._recoverFromDOM(i,o):this._buildFromScratch(),this.instanceTheme==="auto"&&this.setTheme("auto"),this.shortcuts=new re(this),this._rebuildActionsMap(),this.linkTooltip=new We(this),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.textarea.scrollTop=this.preview.scrollTop,this.textarea.scrollLeft=this.preview.scrollLeft})}),this.initialized=!0,this.options.onChange&&this._notifyChange()}_mergeOptions(e){let t={fontSize:"14px",lineHeight:1.6,fontFamily:'"SF Mono", SFMono-Regular, Menlo, Monaco, "Cascadia Code", Consolas, "Roboto Mono", "Noto Sans Mono", "Droid Sans Mono", "Ubuntu Mono", "DejaVu Sans Mono", "Liberation Mono", "Courier New", Courier, monospace',padding:"16px",mobile:{fontSize:"16px",padding:"12px",lineHeight:1.5},textareaProps:{},autofocus:!1,autoResize:!1,minHeight:"100px",maxHeight:null,placeholder:"Start typing...",value:"",onChange:null,onKeydown:null,onRender:null,onFocus:null,onBlur:null,showActiveLineRaw:!1,showStats:!1,toolbar:!1,toolbarButtons:null,statsFormatter:null,smartLists:!0,codeHighlighter:null,spellcheck:!1},{theme:i,colors:o,...r}=e;return{...t,...r}}_recoverFromDOM(e,t){if(e&&e.classList.contains("overtype-container"))this.container=e,this.wrapper=e.querySelector(".overtype-wrapper");else if(t){this.wrapper=t,this.container=document.createElement("div"),this.container.className="overtype-container";let i=this.instanceTheme||v.currentTheme||z,o=typeof i=="string"?i:i.name;if(o&&this.container.setAttribute("data-theme",o),this.instanceTheme){let r=typeof this.instanceTheme=="string"?R(this.instanceTheme):this.instanceTheme;if(r&&r.colors){let s=Q(r.colors);this.container.style.cssText+=s}}t.parentNode.insertBefore(this.container,t),this.container.appendChild(t)}if(!this.wrapper){e&&e.remove(),t&&t.remove(),this._buildFromScratch();return}if(this.textarea=this.wrapper.querySelector(".overtype-input"),this.preview=this.wrapper.querySelector(".overtype-preview"),!this.textarea||!this.preview){this.container.remove(),this._buildFromScratch();return}this.wrapper._instance=this,this._applyInstanceCSSVars(),this._configureTextarea(),this._applyOptions()}_buildFromScratch(){let e=this._extractContent();this.element.innerHTML="",this._createDOM(),(e||this.options.value)&&this.setValue(e||this.options.value),this._applyOptions()}_extractContent(){let e=this.element.querySelector(".overtype-input");return e?e.value:this.element.textContent||""}_createDOM(){this.container=document.createElement("div"),this.container.className="overtype-container";let e=this.instanceTheme||v.currentTheme||z,t=typeof e=="string"?e:e.name;if(t&&this.container.setAttribute("data-theme",t),this.instanceTheme){let i=typeof this.instanceTheme=="string"?R(this.instanceTheme):this.instanceTheme;if(i&&i.colors){let o=Q(i.colors);this.container.style.cssText+=o}}this.wrapper=document.createElement("div"),this.wrapper.className="overtype-wrapper",this._applyInstanceCSSVars(),this.wrapper._instance=this,this.textarea=document.createElement("textarea"),this.textarea.className="overtype-input",this.textarea.placeholder=this.options.placeholder,this._configureTextarea(),this.options.textareaProps&&Object.entries(this.options.textareaProps).forEach(([i,o])=>{i==="className"||i==="class"?this.textarea.className+=" "+o:i==="style"&&typeof o=="object"?Object.assign(this.textarea.style,o):this.textarea.setAttribute(i,o)}),this.preview=document.createElement("div"),this.preview.className="overtype-preview",this.preview.setAttribute("aria-hidden","true"),this.placeholderEl=document.createElement("div"),this.placeholderEl.className="overtype-placeholder",this.placeholderEl.setAttribute("aria-hidden","true"),this.placeholderEl.textContent=this.options.placeholder,this.wrapper.appendChild(this.textarea),this.wrapper.appendChild(this.preview),this.wrapper.appendChild(this.placeholderEl),this.container.appendChild(this.wrapper),this.options.showStats&&(this.statsBar=document.createElement("div"),this.statsBar.className="overtype-stats",this.container.appendChild(this.statsBar),this._updateStats()),this.element.appendChild(this.container),this.options.autoResize?this._setupAutoResize():this.container.classList.remove("overtype-auto-resize")}_configureTextarea(){this.textarea.setAttribute("autocomplete","off"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck",String(this.options.spellcheck)),this.textarea.setAttribute("data-gramm","false"),this.textarea.setAttribute("data-gramm_editor","false"),this.textarea.setAttribute("data-enable-grammarly","false")}_createToolbar(){var t;let e=this.options.toolbarButtons||we;if((t=this.options.fileUpload)!=null&&t.enabled&&!e.some(i=>(i==null?void 0:i.name)==="upload")){let i=e.findIndex(o=>(o==null?void 0:o.name)==="viewMode");i!==-1?(e=[...e],e.splice(i,0,S.separator,S.upload)):e=[...e,S.separator,S.upload]}this.toolbar=new Be(this,{toolbarButtons:e}),this.toolbar.create(),this._toolbarSelectionListener=()=>{this.toolbar&&this.toolbar.updateButtonStates()},this._toolbarInputListener=()=>{this.toolbar&&this.toolbar.updateButtonStates()},this.textarea.addEventListener("selectionchange",this._toolbarSelectionListener),this.textarea.addEventListener("input",this._toolbarInputListener)}_cleanupToolbarListeners(){this._toolbarSelectionListener&&(this.textarea.removeEventListener("selectionchange",this._toolbarSelectionListener),this._toolbarSelectionListener=null),this._toolbarInputListener&&(this.textarea.removeEventListener("input",this._toolbarInputListener),this._toolbarInputListener=null)}_rebuildActionsMap(){var e;this.actionsById=ot(we),this.options.toolbarButtons&&Object.assign(this.actionsById,ot(this.options.toolbarButtons)),(e=this.options.fileUpload)!=null&&e.enabled&&Object.assign(this.actionsById,ot([S.upload]))}_applyInstanceCSSVars(){this.wrapper&&(this.options.fontSize&&this.wrapper.style.setProperty("--instance-font-size",this.options.fontSize),this.options.lineHeight&&this.wrapper.style.setProperty("--instance-line-height",String(this.options.lineHeight)),this.options.padding&&this.wrapper.style.setProperty("--instance-padding",this.options.padding),this.options.fontFamily&&this.wrapper.style.setProperty("--instance-font-family",this.options.fontFamily))}_applyOptions(){this._applyInstanceCSSVars(),this.options.autofocus&&this.textarea.focus(),this.options.autoResize?this.container.classList.contains("overtype-auto-resize")?this._updateAutoHeight():this._setupAutoResize():this.container.classList.remove("overtype-auto-resize"),this.options.toolbar&&!this.toolbar?this._createToolbar():!this.options.toolbar&&this.toolbar&&(this._cleanupToolbarListeners(),this.toolbar.destroy(),this.toolbar=null),this.placeholderEl&&(this.placeholderEl.textContent=this.options.placeholder),this.options.fileUpload&&!this.fileUploadInitialized?this._initFileUpload():!this.options.fileUpload&&this.fileUploadInitialized&&this._destroyFileUpload(),this.updatePreview()}_initFileUpload(){let e=this.options.fileUpload;if(!(!e||!e.enabled)){if(e.maxSize=e.maxSize||10*1024*1024,e.mimeTypes=e.mimeTypes||[],e.batch=e.batch||!1,!e.onInsertFile||typeof e.onInsertFile!="function"){console.warn("OverType: fileUpload.onInsertFile callback is required for file uploads.");return}this._fileUploadCounter=0,this._uploadedFiles=new Map,this._boundHandleFilePaste=this._handleFilePaste.bind(this),this._boundHandleFileDrop=this._handleFileDrop.bind(this),this._boundHandleDragOver=this._handleDragOver.bind(this),this.textarea.addEventListener("paste",this._boundHandleFilePaste),this.textarea.addEventListener("drop",this._boundHandleFileDrop),this.textarea.addEventListener("dragover",this._boundHandleDragOver),this.fileUploadInitialized=!0}}_extractMarkdownUrls(e){let t=[],i=/!?\[[^\]]*\]\(([^)\s]+)/g,o;for(;(o=i.exec(e))!==null;)t.push(o[1]);return t}_trackInsertedUrls(e,t){if(!(!this._uploadedFiles||!t||!e))for(let i of this._extractMarkdownUrls(e))this._uploadedFiles.set(i,{filename:t.name,file:t})}_checkForRemovedUploads(){var o;if(!this._uploadedFiles||this._uploadedFiles.size===0)return;let e=(o=this.options.fileUpload)==null?void 0:o.onRemoveFile,t=this.textarea.value,i=[];for(let[r,s]of this._uploadedFiles)t.includes(r)||i.push({url:r,info:s});for(let{url:r,info:s}of i)this._uploadedFiles.delete(r),e&&e({url:r,filename:s.filename,file:s.file})}_handleFilePaste(e){var t,i;(i=(t=e==null?void 0:e.clipboardData)==null?void 0:t.files)!=null&&i.length&&(e.preventDefault(),this._handleDataTransfer(e.clipboardData))}_handleFileDrop(e){var t,i;(i=(t=e==null?void 0:e.dataTransfer)==null?void 0:t.files)!=null&&i.length&&(e.preventDefault(),this._handleDataTransfer(e.dataTransfer))}_handleDataTransfer(e){let t=[];for(let i of e.files){if(i.size>this.options.fileUpload.maxSize||this.options.fileUpload.mimeTypes.length>0&&!this.options.fileUpload.mimeTypes.includes(i.type))continue;let o=++this._fileUploadCounter,s=`${i.type.startsWith("image/")?"!":""}[Uploading ${i.name} (#${o})...]()`;if(this.insertAtCursor(`${s} -`),this.options.fileUpload.batch){t.push({file:i,placeholder:s});continue}this.options.fileUpload.onInsertFile(i).then(a=>{this.textarea.value=this.textarea.value.replace(s,a),this._trackInsertedUrls(a,i),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))},a=>{console.error("OverType: File upload failed",a),this.textarea.value=this.textarea.value.replace(s,"[Upload failed]()"),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))})}this.options.fileUpload.batch&&t.length>0&&this.options.fileUpload.onInsertFile(t.map(i=>i.file)).then(i=>{(Array.isArray(i)?i:[i]).forEach((r,s)=>{this.textarea.value=this.textarea.value.replace(t[s].placeholder,r),this._trackInsertedUrls(r,t[s].file)}),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))},i=>{console.error("OverType: File upload failed",i),t.forEach(({placeholder:o})=>{this.textarea.value=this.textarea.value.replace(o,"[Upload failed]()")}),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))})}_handleDragOver(e){e.preventDefault()}_destroyFileUpload(){this.textarea.removeEventListener("paste",this._boundHandleFilePaste),this.textarea.removeEventListener("drop",this._boundHandleFileDrop),this.textarea.removeEventListener("dragover",this._boundHandleDragOver),this._boundHandleFilePaste=null,this._boundHandleFileDrop=null,this._boundHandleDragOver=null,this._uploadedFiles=null,this.fileUploadInitialized=!1}insertAtCursor(e){let t=this.textarea.selectionStart,i=this.textarea.selectionEnd,o=!1;try{o=document.execCommand("insertText",!1,e)}catch(r){}if(!o){let r=this.textarea.value.slice(0,t),s=this.textarea.value.slice(i);this.textarea.value=r+e+s,this.textarea.setSelectionRange(t+e.length,t+e.length)}this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}updatePreview(){let e=this.textarea.value,t=this.textarea.selectionStart,i=this._getCurrentLine(e,t),o=this.container.dataset.mode==="preview",r=E.parse(e,i,this.options.showActiveLineRaw,this.options.codeHighlighter,o);this.preview.innerHTML=r,this.placeholderEl&&(this.placeholderEl.style.display=e?"none":""),this._applyCodeBlockBackgrounds(),this.options.showStats&&this.statsBar&&this._updateStats(),this.options.onRender&&this.options.onRender(this.preview,o?"preview":"normal",this)}_notifyChange(){this.initialized&&(this._checkForRemovedUploads(),this.options.onChange&&this.options.onChange(this.textarea.value,this))}_applyCodeBlockBackgrounds(){let e=this.preview.querySelectorAll(".code-fence");for(let t=0;td.replace(/^ /,"")).join(` -`);document.execCommand?(this.textarea.setSelectionRange(i,o),document.execCommand("insertText",!1,c)):(this.textarea.value=s+c+l,this.textarea.selectionStart=i,this.textarea.selectionEnd=i+c.length)}else if(i!==o){let s=r.substring(0,i),a=r.substring(i,o),l=r.substring(o),c=a.split(` -`).map(d=>" "+d).join(` -`);document.execCommand?(this.textarea.setSelectionRange(i,o),document.execCommand("insertText",!1,c)):(this.textarea.value=s+c+l,this.textarea.selectionStart=i,this.textarea.selectionEnd=i+c.length)}else document.execCommand?document.execCommand("insertText",!1," "):(this.textarea.value=r.substring(0,i)+" "+r.substring(o),this.textarea.selectionStart=this.textarea.selectionEnd=i+2);this.textarea.dispatchEvent(new Event("input",{bubbles:!0}));return}if(e.key==="Enter"&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&this.options.smartLists&&this.handleSmartListContinuation()){e.preventDefault();return}!this.shortcuts.handleKeydown(e)&&this.options.onKeydown&&this.options.onKeydown(e,this)}handleSmartListContinuation(){let e=this.textarea,t=e.selectionStart,i=E.getListContext(e.value,t);return!i||!i.inList?!1:i.content.trim()===""&&t>=i.markerEndPos?(this.deleteListMarker(i),!0):(t>i.markerEndPos&&t{this.updateNumberedLists()},10)}updateNumberedLists(){let e=this.textarea.value,t=this.textarea.selectionStart,i=E.renumberLists(e);if(i!==e){let o=0,r=e.split(` -`),s=i.split(` -`),a=0;for(let p=0;pthis.getValue(),setValue:s=>this.setValue(s),event:t}),!0}catch(s){return console.error(`OverType: Action "${e}" error:`,s),this.wrapper.dispatchEvent(new CustomEvent("button-error",{detail:{actionId:e,error:s}})),!1}}getRenderedHTML(e={}){let t=this.getValue(),i=E.parse(t,-1,!1,this.options.codeHighlighter);return e.cleanHTML&&(i=i.replace(/.*?<\/span>/g,""),i=i.replace(/\sclass="(bullet-list|ordered-list|code-fence|hr-marker|blockquote|url-part)"/g,""),i=i.replace(/\sclass=""/g,"")),i}getPreviewHTML(){return this.preview.innerHTML}getCleanHTML(){return this.getRenderedHTML({cleanHTML:!0})}focus(){this.textarea.focus()}blur(){this.textarea.blur()}isInitialized(){return this.initialized}reinit(e={}){var o;let t=(o=this.options)==null?void 0:o.toolbarButtons;this.options=this._mergeOptions({...this.options,...e});let i=this.toolbar&&this.options.toolbar&&vi(t,this.options.toolbarButtons);this._rebuildActionsMap(),i&&(this._cleanupToolbarListeners(),this.toolbar.destroy(),this.toolbar=null,this._createToolbar()),this.fileUploadInitialized&&this._destroyFileUpload(),this.options.fileUpload&&this._initFileUpload(),this._applyOptions(),this.updatePreview()}showToolbar(){this.toolbar?this.toolbar.show():this._createToolbar()}hideToolbar(){this.toolbar&&this.toolbar.hide()}setTheme(e){if(v._autoInstances.delete(this),this.instanceTheme=e,e==="auto")v._autoInstances.add(this),v._startAutoListener(),this._applyResolvedTheme(Ze("auto"));else{let t=typeof e=="string"?R(e):e,i=typeof t=="string"?t:t.name;if(i&&this.container.setAttribute("data-theme",i),t&&t.colors){let o=Q(t.colors,t.previewColors);this.container.style.cssText+=o}this.updatePreview()}return v._stopAutoListener(),this}_applyResolvedTheme(e){let t=R(e);this.container.setAttribute("data-theme",e),t&&t.colors&&(this.container.style.cssText=Q(t.colors,t.previewColors)),this.updatePreview()}setCodeHighlighter(e){this.options.codeHighlighter=e,this.updatePreview()}_updateStats(){if(!this.statsBar)return;let e=this.textarea.value,t=e.split(` -`),i=e.length,o=e.split(/\s+/).filter(c=>c.length>0).length,r=this.textarea.selectionStart,a=e.substring(0,r).split(` -`),l=a.length,p=a[a.length-1].length+1;this.options.statsFormatter?this.statsBar.innerHTML=this.options.statsFormatter({chars:i,words:o,lines:t.length,line:l,column:p}):this.statsBar.innerHTML=` -
    - - ${i} chars, ${o} words, ${t.length} lines -
    -
    Line ${l}, Col ${p}
    - `}_setupAutoResize(){this.container.classList.add("overtype-auto-resize"),this.previousHeight=null,this._updateAutoHeight(),this.textarea.addEventListener("input",()=>this._updateAutoHeight()),window.addEventListener("resize",()=>this._updateAutoHeight())}_updateAutoHeight(){if(!this.options.autoResize)return;let e=this.textarea,t=this.preview,i=this.wrapper;if(this.container.dataset.mode==="preview"){i.style.removeProperty("height"),t.style.removeProperty("height"),t.style.removeProperty("overflow-y"),e.style.removeProperty("height"),e.style.removeProperty("overflow-y");return}let r=e.scrollTop;i.style.setProperty("height","auto","important"),e.style.setProperty("height","auto","important");let s=e.scrollHeight;if(this.options.minHeight){let p=parseInt(this.options.minHeight);s=Math.max(s,p)}let a="hidden";if(this.options.maxHeight){let p=parseInt(this.options.maxHeight);s>p&&(s=p,a="auto")}let l=s+"px";e.style.setProperty("height",l,"important"),e.style.setProperty("overflow-y",a,"important"),t.style.setProperty("height",l,"important"),t.style.setProperty("overflow-y",a,"important"),i.style.setProperty("height",l,"important"),e.scrollTop=r,t.scrollTop=r,this.previousHeight!==s&&(this.previousHeight=s)}showStats(e){this.options.showStats=e,e&&!this.statsBar?(this.statsBar=document.createElement("div"),this.statsBar.className="overtype-stats",this.container.appendChild(this.statsBar),this._updateStats()):e&&this.statsBar?this._updateStats():!e&&this.statsBar&&(this.statsBar.remove(),this.statsBar=null)}showNormalEditMode(){return this.container.dataset.mode="normal",this.updatePreview(),this._updateAutoHeight(),requestAnimationFrame(()=>{this.textarea.scrollTop=this.preview.scrollTop,this.textarea.scrollLeft=this.preview.scrollLeft}),this}showPlainTextarea(){if(this.container.dataset.mode="plain",this._updateAutoHeight(),this.toolbar){let e=this.container.querySelector('[data-action="toggle-plain"]');e&&(e.classList.remove("active"),e.title="Show markdown preview")}return this}showPreviewMode(){return this.container.dataset.mode="preview",this.updatePreview(),this._updateAutoHeight(),this}destroy(){if(v._autoInstances.delete(this),v._stopAutoListener(),this.fileUploadInitialized&&this._destroyFileUpload(),this.element.overTypeInstance=null,v.instances.delete(this.element),this.shortcuts&&this.shortcuts.destroy(),this.wrapper){let e=this.getValue();this.wrapper.remove(),this.element.textContent=e}this.initialized=!1}static init(e,t={}){return new v(e,t)}static initFromData(e,t={}){return v._resolveTargets(e).map(o=>{let r={...t};for(let s of o.attributes)if(s.name.startsWith("data-ot-")){let l=s.name.slice(8).replace(/-([a-z])/g,(p,c)=>c.toUpperCase());r[l]=v._parseDataValue(s.value)}return new v(o,r)[0]})}static _resolveTargets(e){if(e==null)throw new Error("Invalid target: must be selector string, Element, NodeList, or Array");if(typeof e=="string")return Array.from(document.querySelectorAll(e));if(e instanceof Element)return[e];if(e instanceof NodeList)return Array.from(e);if(Array.isArray(e))return e;if(typeof e.length=="number")return Array.from(e);throw new Error("Invalid target: must be selector string, Element, NodeList, or Array")}static _parseDataValue(e){return e==="true"?!0:e==="false"?!1:e==="null"?null:e!==""&&!isNaN(Number(e))?Number(e):e}static getInstance(e){let t;return e instanceof Element?t=e:t=v._resolveTargets(e)[0],t&&(t.overTypeInstance||v.instances.get(t))||null}static destroyAll(){document.querySelectorAll("[data-overtype-instance]").forEach(t=>{let i=v.getInstance(t);i&&i.destroy()})}static injectStyles(e=!1){if(v.stylesInjected&&!e)return;let t=document.querySelector("style.overtype-styles");t&&t.remove();let i=v.currentTheme||z,o=Le({theme:i}),r=document.createElement("style");r.className="overtype-styles",r.textContent=o,document.head.appendChild(r),v.stylesInjected=!0}static setTheme(e,t=null){if(v._globalAutoTheme=!1,v._globalAutoCustomColors=null,e==="auto"){v._globalAutoTheme=!0,v._globalAutoCustomColors=t,v._startAutoListener(),v._applyGlobalTheme(Ze("auto"),t);return}v._stopAutoListener(),v._applyGlobalTheme(e,t)}static _applyGlobalTheme(e,t=null){let i=typeof e=="string"?R(e):e;t&&(i=dt(i,t)),v.currentTheme=i,v.injectStyles(!0);let o=typeof i=="string"?i:i.name;document.querySelectorAll(".overtype-container").forEach(r=>{o&&r.setAttribute("data-theme",o)}),document.querySelectorAll(".overtype-wrapper").forEach(r=>{r.closest(".overtype-container")||o&&r.setAttribute("data-theme",o);let s=r._instance;s&&s.updatePreview()}),document.querySelectorAll("overtype-editor").forEach(r=>{o&&typeof r.setAttribute=="function"&&r.setAttribute("theme",o),typeof r.refreshTheme=="function"&&r.refreshTheme()})}static _startAutoListener(){v._autoMediaQuery||window.matchMedia&&(v._autoMediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),v._autoMediaListener=e=>{let t=e.matches?"cave":"solar";v._globalAutoTheme&&v._applyGlobalTheme(t,v._globalAutoCustomColors),v._autoInstances.forEach(i=>i._applyResolvedTheme(t))},v._autoMediaQuery.addEventListener("change",v._autoMediaListener))}static _stopAutoListener(){v._autoInstances.size>0||v._globalAutoTheme||v._autoMediaQuery&&(v._autoMediaQuery.removeEventListener("change",v._autoMediaListener),v._autoMediaQuery=null,v._autoMediaListener=null)}static setCodeHighlighter(e){E.setCodeHighlighter(e),document.querySelectorAll(".overtype-wrapper").forEach(t=>{let i=t._instance;i&&i.updatePreview&&i.updatePreview()}),document.querySelectorAll("overtype-editor").forEach(t=>{if(typeof t.getEditor=="function"){let i=t.getEditor();i&&i.updatePreview&&i.updatePreview()}})}static setCustomSyntax(e){E.setCustomSyntax(e),document.querySelectorAll(".overtype-wrapper").forEach(t=>{let i=t._instance;i&&i.updatePreview&&i.updatePreview()}),document.querySelectorAll("overtype-editor").forEach(t=>{if(typeof t.getEditor=="function"){let i=t.getEditor();i&&i.updatePreview&&i.updatePreview()}})}static initGlobalListeners(){v.globalListenersInitialized||(document.addEventListener("input",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let t=e.target.closest(".overtype-wrapper"),i=t==null?void 0:t._instance;i&&i.handleInput(e)}}),document.addEventListener("keydown",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let t=e.target.closest(".overtype-wrapper"),i=t==null?void 0:t._instance;i&&i.handleKeydown(e)}}),document.addEventListener("focus",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let t=e.target.closest(".overtype-wrapper"),i=t==null?void 0:t._instance;i&&i.handleFocus(e)}},!0),document.addEventListener("blur",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let t=e.target.closest(".overtype-wrapper"),i=t==null?void 0:t._instance;i&&i.handleBlur(e)}},!0),document.addEventListener("scroll",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let t=e.target.closest(".overtype-wrapper"),i=t==null?void 0:t._instance;i&&i.handleScroll(e)}},!0),document.addEventListener("selectionchange",e=>{let t=document.activeElement;if(t&&t.classList.contains("overtype-input")){let i=t.closest(".overtype-wrapper"),o=i==null?void 0:i._instance;o&&(o.options.showStats&&o.statsBar&&o._updateStats(),clearTimeout(o._selectionTimeout),o._selectionTimeout=setTimeout(()=>{o.updatePreview()},50))}}),v.globalListenersInitialized=!0)}};C(v,"instances",new WeakMap),C(v,"stylesInjected",!1),C(v,"globalListenersInitialized",!1),C(v,"instanceCount",0),C(v,"_autoMediaQuery",null),C(v,"_autoMediaListener",null),C(v,"_autoInstances",new Set),C(v,"_globalAutoTheme",!1),C(v,"_globalAutoCustomColors",null);var q=v;q.MarkdownParser=E;q.ShortcutsManager=re;q.themes={solar:z,cave:R("cave")};q.getTheme=R;q.currentTheme=z;var yn=q;var wn="overtype-webcomponent-container",yi="Start typing...",wi=["value","theme","toolbar","height","min-height","max-height","placeholder","font-size","line-height","padding","auto-resize","autofocus","show-stats","smart-lists","readonly","spellcheck"],qe=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this._editor=null,this._initialized=!1,this._pendingOptions={},this._styleVersion=0,this._baseStyleElement=null,this._selectionChangeHandler=null,this._isConnected=!1,this._handleChange=this._handleChange.bind(this),this._handleKeydown=this._handleKeydown.bind(this),this._handleRender=this._handleRender.bind(this)}_decodeValue(e){return typeof e!="string"?"":e.replace(/\\r/g,"\r").replace(/\\n/g,` -`).replace(/\\t/g," ")}static get observedAttributes(){return wi}connectedCallback(){this._isConnected=!0,this._initializeEditor()}disconnectedCallback(){this._isConnected=!1,this._cleanup()}attributeChangedCallback(e,t,i){if(t!==i&&!this._silentUpdate){if(!this._initialized){this._pendingOptions[e]=i;return}this._updateOption(e,i)}}_initializeEditor(){if(!(this._initialized||!this._isConnected))try{let e=document.createElement("div");e.className=wn;let t=this.getAttribute("height"),i=this.getAttribute("min-height"),o=this.getAttribute("max-height");t&&(e.style.height=t),i&&(e.style.minHeight=i),o&&(e.style.maxHeight=o),this._injectStyles(),this.shadowRoot.appendChild(e);let r=this._getOptionsFromAttributes(),s=new yn(e,r);this._editor=s[0],this._initialized=!0,this._editor&&this._editor.textarea&&(this._editor.textarea.addEventListener("scroll",()=>{this._editor&&this._editor.preview&&this._editor.textarea&&(this._editor.preview.scrollTop=this._editor.textarea.scrollTop,this._editor.preview.scrollLeft=this._editor.textarea.scrollLeft)}),this._editor.textarea.addEventListener("input",a=>{this._editor&&this._editor.handleInput&&this._editor.handleInput(a)}),this._editor.textarea.addEventListener("keydown",a=>{this._editor&&this._editor.handleKeydown&&this._editor.handleKeydown(a)}),this._selectionChangeHandler=()=>{if(document.activeElement===this){let a=this.shadowRoot.activeElement;a&&a===this._editor.textarea&&(this._editor.options.showStats&&this._editor.statsBar&&this._editor._updateStats(),this._editor.linkTooltip&&this._editor.linkTooltip.checkCursorPosition&&this._editor.linkTooltip.checkCursorPosition())}},document.addEventListener("selectionchange",this._selectionChangeHandler)),this._applyPendingOptions(),this._dispatchEvent("ready",{editor:this._editor})}catch(e){let t=e&&e.message?e.message:String(e);console.warn("OverType Web Component initialization failed:",t),this._dispatchEvent("error",{error:{message:t}})}}_injectStyles(){let e=document.createElement("style"),t=this.getAttribute("theme")||"solar",i=R(t),o=this._getOptionsFromAttributes(),r=Le({...o,theme:i}),s=` - /* Web Component Host Styles */ - :host { - display: block; - position: relative; - width: 100%; - height: 100%; - contain: layout style; - } - - .overtype-webcomponent-container { - width: 100%; - height: 100%; - position: relative; - } - - /* Override container grid layout for web component */ - .overtype-container { - height: 100% !important; - } - `;this._styleVersion+=1;let a=` -/* overtype-webcomponent styles v${this._styleVersion} */ -`;e.textContent=a+r+s,this._baseStyleElement=e,this.shadowRoot.appendChild(e)}_getOptionsFromAttributes(){let e={value:this.getAttribute("value")!==null?this._decodeValue(this.getAttribute("value")):(this.textContent||"").trim(),placeholder:this.getAttribute("placeholder")||yi,toolbar:this.hasAttribute("toolbar"),autofocus:this.hasAttribute("autofocus"),autoResize:this.hasAttribute("auto-resize"),showStats:this.hasAttribute("show-stats"),smartLists:!this.hasAttribute("smart-lists")||this.getAttribute("smart-lists")!=="false",spellcheck:this.hasAttribute("spellcheck")&&this.getAttribute("spellcheck")!=="false",onChange:this._handleChange,onKeydown:this._handleKeydown,onRender:this._handleRender},t=this.getAttribute("font-size");t&&(e.fontSize=t);let i=this.getAttribute("line-height");i&&(e.lineHeight=parseFloat(i)||1.6);let o=this.getAttribute("padding");o&&(e.padding=o);let r=this.getAttribute("min-height");r&&(e.minHeight=r);let s=this.getAttribute("max-height");return s&&(e.maxHeight=s),e}_applyPendingOptions(){for(let[e,t]of Object.entries(this._pendingOptions))this._updateOption(e,t);this._pendingOptions={}}_updateOption(e,t){if(this._editor)switch(e){case"value":{let i=this._decodeValue(t);this._editor.getValue()!==i&&this._editor.setValue(i||"")}break;case"theme":this._reinjectStyles(),this._editor&&this._editor.setTheme&&this._editor.setTheme(t||"solar");break;case"placeholder":this._editor&&(this._editor.options.placeholder=t||"",this._editor.textarea&&(this._editor.textarea.placeholder=t||""),this._editor.placeholderEl&&(this._editor.placeholderEl.textContent=t||""));break;case"readonly":this._editor.textarea&&(this._editor.textarea.readOnly=this.hasAttribute("readonly"));break;case"height":case"min-height":case"max-height":this._updateContainerHeight();break;case"toolbar":if(!!this.hasAttribute("toolbar")==!!this._editor.options.toolbar)return;this._reinitializeEditor();break;case"auto-resize":if(!!this.hasAttribute("auto-resize")==!!this._editor.options.autoResize)return;this._reinitializeEditor();break;case"show-stats":if(!!this.hasAttribute("show-stats")==!!this._editor.options.showStats)return;this._reinitializeEditor();break;case"font-size":{this._updateFontSize(t)&&this._reinjectStyles();break}case"line-height":{this._updateLineHeight(t)&&this._reinjectStyles();break}case"padding":this._reinjectStyles();break;case"smart-lists":{let i=!this.hasAttribute("smart-lists")||this.getAttribute("smart-lists")!=="false";if(!!this._editor.options.smartLists==!!i)return;this._reinitializeEditor();break}case"spellcheck":if(this._editor){let i=this.hasAttribute("spellcheck")&&this.getAttribute("spellcheck")!=="false";this._editor.options.spellcheck=i,this._editor.textarea&&this._editor.textarea.setAttribute("spellcheck",String(i))}break}}_updateContainerHeight(){let e=this.shadowRoot.querySelector(`.${wn}`);if(!e)return;let t=this.getAttribute("height"),i=this.getAttribute("min-height"),o=this.getAttribute("max-height");e.style.height=t||"",e.style.minHeight=i||"",e.style.maxHeight=o||""}_updateFontSize(e){return this._editor&&this._editor.wrapper?(this._editor.options.fontSize=e||"",this._editor.wrapper.style.setProperty("--instance-font-size",this._editor.options.fontSize),this._editor.updatePreview(),!0):!1}_updateLineHeight(e){if(this._editor&&this._editor.wrapper){let t=parseFloat(e),i=Number.isFinite(t)?t:this._editor.options.lineHeight;return this._editor.options.lineHeight=i,this._editor.wrapper.style.setProperty("--instance-line-height",String(i)),this._editor.updatePreview(),!0}return!1}_reinjectStyles(){this._baseStyleElement&&this._baseStyleElement.parentNode&&this._baseStyleElement.remove(),this._injectStyles()}_reinitializeEditor(){let e=this._editor?this._editor.getValue():"";this._cleanup(),this._initialized=!1,this.shadowRoot.innerHTML="",e&&!this.getAttribute("value")&&this.setAttribute("value",e),this._initializeEditor()}_handleChange(e){this._updateValueAttribute(e),!(!this._initialized||!this._editor)&&this._dispatchEvent("change",{value:e,editor:this._editor})}_handleKeydown(e){this._dispatchEvent("keydown",{event:e,editor:this._editor})}_handleRender(e,t){this._dispatchEvent("render",{preview:e,mode:t,editor:this._editor})}_updateValueAttribute(e){this.getAttribute("value")!==e&&(this._silentUpdate=!0,this.setAttribute("value",e),this._silentUpdate=!1)}_dispatchEvent(e,t={}){let i=new CustomEvent(e,{detail:t,bubbles:!0,composed:!0});this.dispatchEvent(i)}_cleanup(){this._selectionChangeHandler&&(document.removeEventListener("selectionchange",this._selectionChangeHandler),this._selectionChangeHandler=null),this._editor&&typeof this._editor.destroy=="function"&&this._editor.destroy(),this._editor=null,this._initialized=!1,this.shadowRoot&&(this.shadowRoot.innerHTML="")}refreshTheme(){this._initialized&&this._reinjectStyles()}getValue(){return this._editor?this._editor.getValue():this.getAttribute("value")||""}setValue(e){this._editor?this._editor.setValue(e):this.setAttribute("value",e)}getHTML(){return this._editor?this._editor.getRenderedHTML(!1):""}insertText(e){!this._editor||typeof e!="string"||this._editor.insertText(e)}focus(){this._editor&&this._editor.textarea&&this._editor.textarea.focus()}blur(){this._editor&&this._editor.textarea&&this._editor.textarea.blur()}getStats(){if(!this._editor||!this._editor.textarea)return null;let e=this._editor.textarea.value,t=e.split(` -`),i=e.length,o=e.split(/\s+/).filter(c=>c.length>0).length,r=this._editor.textarea.selectionStart,a=e.substring(0,r).split(` -`),l=a.length,p=a[a.length-1].length+1;return{characters:i,words:o,lines:t.length,line:l,column:p}}isReady(){return this._initialized&&this._editor!==null}getEditor(){return this._editor}showToolbar(){this._editor&&this._editor.showToolbar()}hideToolbar(){this._editor&&this._editor.hideToolbar()}};customElements.get("overtype-editor")||customElements.define("overtype-editor",qe);var bi=qe;return En(xi);})(); -/** - * OverType - A lightweight markdown editor library with perfect WYSIWYG alignment - * @version 1.0.0 - * @license MIT - */ -/** - * OverType Web Component - * A custom element wrapper for the OverType markdown editor with Shadow DOM isolation - * @version 1.0.0 - * @license MIT - */ diff --git a/app/public/assets/js/overtype.min.js b/app/public/assets/js/overtype.min.js deleted file mode 100644 index 24b76e7..0000000 --- a/app/public/assets/js/overtype.min.js +++ /dev/null @@ -1,1005 +0,0 @@ -/** - * OverType v2.3.5 - * A lightweight markdown editor library with perfect WYSIWYG alignment - * @license MIT - * @author David Miranda - * https://github.com/panphora/overtype - */ -var OverType=(()=>{var ve=Object.defineProperty;var cn=Object.getOwnPropertyDescriptor;var pn=Object.getOwnPropertyNames;var dn=Object.prototype.hasOwnProperty;var un=(t,e,n)=>e in t?ve(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var hn=(t,e)=>{for(var n in e)ve(t,n,{get:e[n],enumerable:!0})},fn=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of pn(e))!dn.call(t,o)&&o!==n&&ve(t,o,{get:()=>e[o],enumerable:!(i=cn(e,o))||i.enumerable});return t};var mn=t=>fn(ve({},"__esModule",{value:!0}),t);var C=(t,e,n)=>(un(t,typeof e!="symbol"?e+"":e,n),n);var ai={};hn(ai,{OverType:()=>z,default:()=>si,defaultToolbarButtons:()=>ie,toolbarButtons:()=>S});var T=class{static resetLinkIndex(){this.linkIndex=0}static setCodeHighlighter(e){this.codeHighlighter=e}static setCustomSyntax(e){this.customSyntax=e}static applyCustomSyntax(e){return this.customSyntax?this.customSyntax(e):e}static escapeHtml(e){let n={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,i=>n[i])}static preserveIndentation(e,n){let o=n.match(/^(\s*)/)[1].replace(/ /g," ");return e.replace(/^\s*/,o)}static parseHeader(e){return e.replace(/^(#{1,3})\s(.+)$/,(n,i,o)=>{let r=i.length;return o=this.parseInlineElements(o),`${i} ${o}`})}static parseHorizontalRule(e){return e.match(/^(-{3,}|\*{3,}|_{3,})$/)?`
    ${e}
    `:null}static parseBlockquote(e){return e.replace(/^> (.+)$/,(n,i)=>`> ${i}`)}static parseBulletList(e){return e.replace(/^((?: )*)([-*+])\s(.+)$/,(n,i,o,r)=>(r=this.parseInlineElements(r),`${i}
  • ${o} ${r}
  • `))}static parseTaskList(e,n=!1){return e.replace(/^((?: )*)-\s+\[([ xX])\]\s+(.+)$/,(i,o,r,s)=>{if(s=this.parseInlineElements(s),n){let a=r.toLowerCase()==="x";return`${o}
  • ${s}
  • `}else return`${o}
  • - [${r}] ${s}
  • `})}static parseNumberedList(e){return e.replace(/^((?: )*)(\d+\.)\s(.+)$/,(n,i,o,r)=>(r=this.parseInlineElements(r),`${i}
  • ${o} ${r}
  • `))}static parseCodeBlock(e){return/^`{3}[^`]*$/.test(e)?`
    ${e}
    `:null}static parseBold(e){return e=e.replace(/\*\*(.+?)\*\*/g,'**$1**'),e=e.replace(/__(.+?)__/g,'__$1__'),e}static parseItalic(e){return e=e.replace(new RegExp("(?])\\*(?!\\*)(.+?)(?*$1*'),e=e.replace(new RegExp("(?<=^|\\s)_(?!_)(.+?)(?_$1_'),e}static parseStrikethrough(e){return e=e.replace(new RegExp("(?~~$1~~'),e=e.replace(new RegExp("(?~$1~'),e}static parseInlineCode(e){return e.replace(new RegExp("(?$1$2$3')}static sanitizeUrl(e){let n=e.trim(),i=n.toLowerCase(),r=["http://","https://","mailto:","ftp://","ftps://"].some(a=>i.startsWith(a)),s=n.startsWith("/")||n.startsWith("#")||n.startsWith("?")||n.startsWith(".")||!n.includes(":")&&!n.includes("//");return r||s?e:"#"}static parseLinks(e){return e.replace(/\[(.+?)\]\((.+?)\)/g,(n,i,o)=>{let r=`--link-${this.linkIndex++}`;return`[${i}](${o})`})}static identifyAndProtectSanctuaries(e){let n=new Map,i=0,o=e,r=[],s=/\[([^\]]+)\]\(([^)]+)\)/g,a;for(;(a=s.exec(e))!==null;){let h=a.index+a[0].indexOf("](")+2,u=h+a[2].length;r.push({start:h,end:u})}let c=new RegExp("(?d>=f.start&&h<=f.end)||l.push({match:p[0],index:p.index,openTicks:p[1],content:p[2],closeTicks:p[3]})}return l.sort((d,h)=>h.index-d.index),l.forEach(d=>{let h=`\uE000${i++}\uE001`;n.set(h,{type:"code",original:d.match,openTicks:d.openTicks,content:d.content,closeTicks:d.closeTicks}),o=o.substring(0,d.index)+h+o.substring(d.index+d.match.length)}),o=o.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(d,h,u)=>{let f=`\uE000${i++}\uE001`;return n.set(f,{type:"link",original:d,linkText:h,url:u}),f}),{protectedText:o,sanctuaries:n}}static restoreAndTransformSanctuaries(e,n){return Array.from(n.keys()).sort((o,r)=>{let s=e.indexOf(o),a=e.indexOf(r);return s-a}).forEach(o=>{let r=n.get(o),s;if(r.type==="code")s=`${r.openTicks}${r.content}${r.closeTicks}`;else if(r.type==="link"){let a=r.linkText;n.forEach((l,d)=>{if(a.includes(d)&&l.type==="code"){let h=`${l.openTicks}${l.content}${l.closeTicks}`;a=a.replace(d,h)}}),a=this.parseStrikethrough(a),a=this.parseBold(a),a=this.parseItalic(a);let c=`--link-${this.linkIndex++}`;s=`[${a}](${r.url})`}e=e.replace(o,s)}),e}static parseInlineElements(e){let{protectedText:n,sanctuaries:i}=this.identifyAndProtectSanctuaries(e),o=n;return o=this.parseStrikethrough(o),o=this.parseBold(o),o=this.parseItalic(o),o=this.restoreAndTransformSanctuaries(o,i),o}static parseLine(e,n=!1){let i=this.escapeHtml(e);i=this.preserveIndentation(i,e);let o=this.parseHorizontalRule(i);if(o)return o;let r=this.parseCodeBlock(i);return r||(i=this.parseHeader(i),i=this.parseBlockquote(i),i=this.parseTaskList(i,n),i=this.parseBulletList(i),i=this.parseNumberedList(i),!i.includes(" 
    ":`
    ${i}
    `)}static parse(e,n=-1,i=!1,o,r=!1){this.resetLinkIndex();let s=e.split(` -`),a=!1,p=s.map((l,d)=>{if(i&&d===n)return`
    ${this.escapeHtml(l)||" "}
    `;if(/^```[^`]*$/.test(l))return a=!a,this.applyCustomSyntax(this.parseLine(l,r));if(a){let u=this.escapeHtml(l);return`
    ${this.preserveIndentation(u,l)||" "}
    `}return this.applyCustomSyntax(this.parseLine(l,r))}).join("");return this.postProcessHTML(p,o)}static postProcessHTML(e,n){if(typeof document>"u"||!document)return this.postProcessHTMLManual(e,n);let i=document.createElement("div");i.innerHTML=e;let o=null,r=null,s=null,a=!1,c=Array.from(i.children);for(let p=0;p0&&(s._codeContent+=` -`);let f=l.textContent.replace(/\u00A0/g," ");s._codeContent+=f,u.textContent.length>0&&(u.textContent+=` -`),u.textContent+=f,l.remove();continue}let h=null;if(l.tagName==="DIV"&&(h=l.querySelector("li")),h){let u=h.classList.contains("bullet-list"),f=h.classList.contains("ordered-list");if(!u&&!f){o=null,r=null;continue}let m=u?"ul":"ol";(!o||r!==m)&&(o=document.createElement(m),i.insertBefore(o,l),r=m);let g=[];for(let y of l.childNodes)if(y.nodeType===3&&y.textContent.match(/^\u00A0+$/))g.push(y.cloneNode(!0));else if(y===h)break;g.forEach(y=>{h.insertBefore(y,h.firstChild)}),o.appendChild(h),l.remove()}else o=null,r=null}return i.innerHTML}static postProcessHTMLManual(e,n){let i=e;i=i.replace(/((?:
    (?: )*
  • .*?<\/li><\/div>\s*)+)/gs,r=>{let s=r.match(/
    (?: )*
  • .*?<\/li><\/div>/gs)||[];return s.length>0?"
      "+s.map(c=>{let p=c.match(/
      ((?: )*)
    • .*?<\/li>/);if(p&&l){let d=p[1];return l[0].replace(/
    • /,`
    • ${d}`)}return l?l[0]:""}).filter(Boolean).join("")+"
    ":r}),i=i.replace(/((?:
    (?: )*
  • .*?<\/li><\/div>\s*)+)/gs,r=>{let s=r.match(/
    (?: )*
  • .*?<\/li><\/div>/gs)||[];return s.length>0?"
      "+s.map(c=>{let p=c.match(/
      ((?: )*)
    1. .*?<\/li>/);if(p&&l){let d=p[1];return l[0].replace(/
    2. /,`
    3. ${d}`)}return l?l[0]:""}).filter(Boolean).join("")+"
    ":r});let o=/
    (```[^<]*)<\/span><\/div>(.*?)
    (```)<\/span><\/div>/gs;return i=i.replace(o,(r,s,a,c)=>{let l=(a.match(/
    (.*?)<\/div>/gs)||[]).map(g=>g.replace(/
    (.*?)<\/div>/s,"$1").replace(/ /g," ")).join(` -`),d=s.slice(3).trim(),h=d?` class="language-${d}"`:"",u=l,f=n||this.codeHighlighter;if(f)try{let g=l.replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&"),y=f(g,d);y&&typeof y.then=="function"?console.warn("Async highlighters are not supported in Node.js (non-DOM) context. Use synchronous highlighters for server-side rendering."):y&&typeof y=="string"&&y.trim()&&(u=y)}catch(g){console.warn("Code highlighting failed:",g)}let m=`
    ${s}
    `;return m+=`
    ${u}
    `,m+=`
    ${c}
    `,m}),i}static getListContext(e,n){let i=e.split(` -`),o=0,r=0,s=0;for(let h=0;h=n){r=h,s=o;break}o+=u+1}let a=i[r],c=s+a.length,p=a.match(this.LIST_PATTERNS.checkbox);if(p)return{inList:!0,listType:"checkbox",indent:p[1],marker:"-",checked:p[2]==="x",content:p[3],lineStart:s,lineEnd:c,markerEndPos:s+p[1].length+p[2].length+5};let l=a.match(this.LIST_PATTERNS.bullet);if(l)return{inList:!0,listType:"bullet",indent:l[1],marker:l[2],content:l[3],lineStart:s,lineEnd:c,markerEndPos:s+l[1].length+l[2].length+1};let d=a.match(this.LIST_PATTERNS.numbered);return d?{inList:!0,listType:"numbered",indent:d[1],marker:parseInt(d[2]),content:d[3],lineStart:s,lineEnd:c,markerEndPos:s+d[1].length+d[2].length+2}:{inList:!1,listType:null,indent:"",marker:null,content:a,lineStart:s,lineEnd:c,markerEndPos:s}}static createNewListItem(e){switch(e.listType){case"bullet":return`${e.indent}${e.marker} `;case"numbered":return`${e.indent}${e.marker+1}. `;case"checkbox":return`${e.indent}- [ ] `;default:return""}}static renumberLists(e){let n=e.split(` -`),i=new Map,o=!1;return n.map(s=>{let a=s.match(this.LIST_PATTERNS.numbered);if(a){let c=a[1],p=c.length,l=a[3];o||i.clear();let d=(i.get(p)||0)+1;i.set(p,d);for(let[h]of i)h>p&&i.delete(h);return o=!0,`${c}${d}. ${l}`}else return(s.trim()===""||!s.match(/^\s/))&&(o=!1,i.clear()),s}).join(` -`)}};C(T,"linkIndex",0),C(T,"codeHighlighter",null),C(T,"customSyntax",null),C(T,"LIST_PATTERNS",{bullet:/^(\s*)([-*+])\s+(.*)$/,numbered:/^(\s*)(\d+)\.\s+(.*)$/,checkbox:/^(\s*)-\s+\[([ x])\]\s+(.*)$/});var re=class{constructor(e){this.editor=e}handleKeydown(e){if(!(navigator.platform.toLowerCase().includes("mac")?e.metaKey:e.ctrlKey))return!1;let o=null;switch(e.key.toLowerCase()){case"b":e.shiftKey||(o="toggleBold");break;case"i":e.shiftKey||(o="toggleItalic");break;case"k":e.shiftKey||(o="insertLink");break;case"7":e.shiftKey&&(o="toggleNumberedList");break;case"8":e.shiftKey&&(o="toggleBulletList");break}return o?(e.preventDefault(),this.editor.performAction(o,e),!0):!1}destroy(){}};var _={name:"solar",colors:{bgPrimary:"#faf0ca",bgSecondary:"#ffffff",text:"#0d3b66",textPrimary:"#0d3b66",textSecondary:"#5a7a9b",h1:"#f95738",h2:"#ee964b",h3:"#3d8a51",strong:"#ee964b",em:"#f95738",del:"#ee964b",link:"#0d3b66",code:"#0d3b66",codeBg:"rgba(244, 211, 94, 0.4)",blockquote:"#5a7a9b",hr:"#5a7a9b",syntaxMarker:"rgba(13, 59, 102, 0.52)",syntax:"#999999",cursor:"#f95738",selection:"rgba(244, 211, 94, 0.4)",listMarker:"#ee964b",rawLine:"#5a7a9b",border:"#e0e0e0",hoverBg:"#f0f0f0",primary:"#0d3b66",toolbarBg:"#ffffff",toolbarIcon:"#0d3b66",toolbarHover:"#f5f5f5",toolbarActive:"#faf0ca",placeholder:"#999999"},previewColors:{text:"#0d3b66",h1:"inherit",h2:"inherit",h3:"inherit",strong:"inherit",em:"inherit",link:"#0d3b66",code:"#0d3b66",codeBg:"rgba(244, 211, 94, 0.4)",blockquote:"#5a7a9b",hr:"#5a7a9b",bg:"transparent"}},qe={name:"cave",colors:{bgPrimary:"#141E26",bgSecondary:"#1D2D3E",text:"#c5dde8",textPrimary:"#c5dde8",textSecondary:"#9fcfec",h1:"#d4a5ff",h2:"#f6ae2d",h3:"#9fcfec",strong:"#f6ae2d",em:"#9fcfec",del:"#f6ae2d",link:"#9fcfec",code:"#c5dde8",codeBg:"#1a232b",blockquote:"#9fcfec",hr:"#c5dde8",syntaxMarker:"rgba(159, 207, 236, 0.73)",syntax:"#7a8c98",cursor:"#f26419",selection:"rgba(51, 101, 138, 0.4)",listMarker:"#f6ae2d",rawLine:"#9fcfec",border:"#2a3f52",hoverBg:"#243546",primary:"#9fcfec",toolbarBg:"#1D2D3E",toolbarIcon:"#c5dde8",toolbarHover:"#243546",toolbarActive:"#2a3f52",placeholder:"#6a7a88"},previewColors:{text:"#c5dde8",h1:"inherit",h2:"inherit",h3:"inherit",strong:"inherit",em:"inherit",link:"#9fcfec",code:"#c5dde8",codeBg:"#1a232b",blockquote:"#9fcfec",hr:"#c5dde8",bg:"transparent"}},We={solar:_,cave:qe,auto:_,light:_,dark:qe};function V(t){return typeof t=="string"?{...We[t]||We.solar,name:t}:t}function Oe(t){if(t!=="auto")return t;let e=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)");return e!=null&&e.matches?"cave":"solar"}function Q(t,e){let n=[];for(let[i,o]of Object.entries(t)){let r=i.replace(/([A-Z])/g,"-$1").toLowerCase();n.push(`--${r}: ${o};`)}if(e)for(let[i,o]of Object.entries(e)){let r=i.replace(/([A-Z])/g,"-$1").toLowerCase();n.push(`--preview-${r}-default: ${o};`)}return n.join(` -`)}function Ke(t,e={},n={}){return{...t,colors:{...t.colors,...e},previewColors:{...t.previewColors,...n}}}function Ze(t={}){let{fontSize:e="14px",lineHeight:n=1.6,fontFamily:i='"SF Mono", SFMono-Regular, Menlo, Monaco, "Cascadia Code", Consolas, "Roboto Mono", "Noto Sans Mono", "Droid Sans Mono", "Ubuntu Mono", "DejaVu Sans Mono", "Liberation Mono", "Courier New", Courier, monospace',padding:o="20px",theme:r=null,mobile:s={}}=t,a=Object.keys(s).length>0?` - @media (max-width: 640px) { - .overtype-wrapper .overtype-input, - .overtype-wrapper .overtype-preview { - ${Object.entries(s).map(([p,l])=>`${p.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${l} !important;`).join(` - `)} - } - } - `:"",c=r&&r.colors?Q(r.colors,r.previewColors):"";return` - /* OverType Editor Styles */ - - /* Middle-ground CSS Reset - Prevent parent styles from leaking in */ - .overtype-container * { - /* Box model - these commonly leak */ - margin: 0 !important; - padding: 0 !important; - border: 0 !important; - - /* Layout - these can break our layout */ - /* Don't reset position - it breaks dropdowns */ - float: none !important; - clear: none !important; - - /* Typography - only reset decorative aspects */ - text-decoration: none !important; - text-transform: none !important; - letter-spacing: normal !important; - - /* Visual effects that can interfere */ - box-shadow: none !important; - text-shadow: none !important; - - /* Ensure box-sizing is consistent */ - box-sizing: border-box !important; - - /* Keep inheritance for these */ - /* font-family, color, line-height, font-size - inherit */ - } - - /* Container base styles after reset */ - .overtype-container { - display: flex !important; - flex-direction: column !important; - width: 100% !important; - height: 100% !important; - position: relative !important; /* Override reset - needed for absolute children */ - overflow: visible !important; /* Allow dropdown to overflow container */ - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important; - text-align: left !important; - ${c?` - /* Theme Variables */ - ${c}`:""} - } - - /* Force left alignment for all elements in the editor */ - .overtype-container .overtype-wrapper * { - text-align: left !important; - } - - /* Auto-resize mode styles */ - .overtype-container.overtype-auto-resize { - height: auto !important; - } - - .overtype-container.overtype-auto-resize .overtype-wrapper { - flex: 0 0 auto !important; /* Don't grow/shrink, use explicit height */ - height: auto !important; - min-height: 60px !important; - overflow: visible !important; - } - - .overtype-wrapper { - position: relative !important; /* Override reset - needed for absolute children */ - width: 100% !important; - flex: 1 1 0 !important; /* Grow to fill remaining space, with flex-basis: 0 */ - min-height: 60px !important; /* Minimum usable height */ - overflow: hidden !important; - background: var(--bg-secondary, #ffffff) !important; - z-index: 1; /* Below toolbar and dropdown */ - } - - /* Critical alignment styles - must be identical for both layers */ - .overtype-wrapper .overtype-input, - .overtype-wrapper .overtype-preview { - /* Positioning - must be identical */ - position: absolute !important; /* Override reset - required for overlay */ - top: 0 !important; - left: 0 !important; - width: 100% !important; - height: 100% !important; - - /* Font properties - any difference breaks alignment */ - font-family: ${i} !important; - font-variant-ligatures: none !important; /* keep metrics stable for code */ - font-size: var(--instance-font-size, ${e}) !important; - line-height: var(--instance-line-height, ${n}) !important; - font-weight: normal !important; - font-style: normal !important; - font-variant: normal !important; - font-stretch: normal !important; - font-kerning: none !important; - font-feature-settings: normal !important; - - /* Box model - must match exactly */ - padding: var(--instance-padding, ${o}) !important; - margin: 0 !important; - border: none !important; - outline: none !important; - box-sizing: border-box !important; - - /* Text layout - critical for character positioning */ - white-space: pre-wrap !important; - word-wrap: break-word !important; - word-break: normal !important; - overflow-wrap: break-word !important; - tab-size: 2 !important; - -moz-tab-size: 2 !important; - text-align: left !important; - text-indent: 0 !important; - letter-spacing: normal !important; - word-spacing: normal !important; - - /* Text rendering */ - text-transform: none !important; - text-rendering: auto !important; - -webkit-font-smoothing: auto !important; - -webkit-text-size-adjust: 100% !important; - - /* Direction and writing */ - direction: ltr !important; - writing-mode: horizontal-tb !important; - unicode-bidi: normal !important; - text-orientation: mixed !important; - - /* Visual effects that could shift perception */ - text-shadow: none !important; - filter: none !important; - transform: none !important; - zoom: 1 !important; - - /* Vertical alignment */ - vertical-align: baseline !important; - - /* Size constraints */ - min-width: 0 !important; - min-height: 0 !important; - max-width: none !important; - max-height: none !important; - - /* Overflow */ - overflow-y: auto !important; - overflow-x: auto !important; - /* overscroll-behavior removed to allow scroll-through to parent */ - scrollbar-width: auto !important; - scrollbar-gutter: auto !important; - - /* Animation/transition - disabled to prevent movement */ - animation: none !important; - transition: none !important; - } - - /* Input layer styles */ - .overtype-wrapper .overtype-input { - /* Layer positioning */ - z-index: 1 !important; - - /* Text visibility */ - color: transparent !important; - caret-color: var(--cursor, #f95738) !important; - background-color: transparent !important; - - /* Textarea-specific */ - resize: none !important; - appearance: none !important; - -webkit-appearance: none !important; - -moz-appearance: none !important; - - /* Prevent mobile zoom on focus */ - touch-action: manipulation !important; - - /* Disable autofill */ - autocomplete: off !important; - autocorrect: off !important; - autocapitalize: off !important; - } - - .overtype-wrapper .overtype-input::selection { - background-color: var(--selection, rgba(244, 211, 94, 0.4)); - } - - /* Placeholder shim - visible when textarea is empty */ - .overtype-wrapper .overtype-placeholder { - position: absolute !important; - top: 0 !important; - left: 0 !important; - width: 100% !important; - z-index: 0 !important; - pointer-events: none !important; - user-select: none !important; - font-family: ${i} !important; - font-size: var(--instance-font-size, ${e}) !important; - line-height: var(--instance-line-height, ${n}) !important; - padding: var(--instance-padding, ${o}) !important; - box-sizing: border-box !important; - color: var(--placeholder, #999) !important; - overflow: hidden !important; - white-space: nowrap !important; - text-overflow: ellipsis !important; - } - - /* Preview layer styles */ - .overtype-wrapper .overtype-preview { - /* Layer positioning */ - z-index: 0 !important; - pointer-events: none !important; - color: var(--text, #0d3b66) !important; - background-color: transparent !important; - - /* Prevent text selection */ - user-select: none !important; - -webkit-user-select: none !important; - -moz-user-select: none !important; - -ms-user-select: none !important; - } - - /* Prevent external resets (Tailwind, Bootstrap, etc.) from breaking alignment. - Any element whose font metrics differ from the textarea causes the CSS "strut" - to inflate line boxes, drifting the overlay. Force inheritance so every element - inside the preview matches the textarea exactly. */ - .overtype-wrapper .overtype-preview * { - font-family: inherit !important; - font-size: inherit !important; - line-height: inherit !important; - } - - /* Defensive styles for preview child divs */ - .overtype-wrapper .overtype-preview div { - /* Reset any inherited styles */ - margin: 0 !important; - padding: 0 !important; - border: none !important; - text-align: left !important; - text-indent: 0 !important; - display: block !important; - position: static !important; - transform: none !important; - min-height: 0 !important; - max-height: none !important; - line-height: inherit !important; - font-size: inherit !important; - font-family: inherit !important; - } - - /* Markdown element styling - NO SIZE CHANGES */ - .overtype-wrapper .overtype-preview .header { - font-weight: bold !important; - } - - /* Header colors */ - .overtype-wrapper .overtype-preview .h1 { - color: var(--h1, #f95738) !important; - } - .overtype-wrapper .overtype-preview .h2 { - color: var(--h2, #ee964b) !important; - } - .overtype-wrapper .overtype-preview .h3 { - color: var(--h3, #3d8a51) !important; - } - - /* Semantic headers - flatten in edit mode */ - .overtype-wrapper .overtype-preview h1, - .overtype-wrapper .overtype-preview h2, - .overtype-wrapper .overtype-preview h3 { - font-size: inherit !important; - font-weight: bold !important; - margin: 0 !important; - padding: 0 !important; - display: inline !important; - line-height: inherit !important; - } - - /* Header colors for semantic headers */ - .overtype-wrapper .overtype-preview h1 { - color: var(--h1, #f95738) !important; - } - .overtype-wrapper .overtype-preview h2 { - color: var(--h2, #ee964b) !important; - } - .overtype-wrapper .overtype-preview h3 { - color: var(--h3, #3d8a51) !important; - } - - /* Lists - remove styling in edit mode */ - .overtype-wrapper .overtype-preview ul, - .overtype-wrapper .overtype-preview ol { - list-style: none !important; - margin: 0 !important; - padding: 0 !important; - display: block !important; /* Lists need to be block for line breaks */ - } - - .overtype-wrapper .overtype-preview li { - display: block !important; /* Each item on its own line */ - margin: 0 !important; - padding: 0 !important; - /* Don't set list-style here - let ul/ol control it */ - } - - /* Bold text */ - .overtype-wrapper .overtype-preview strong { - color: var(--strong, #ee964b) !important; - font-weight: bold !important; - } - - /* Italic text */ - .overtype-wrapper .overtype-preview em { - color: var(--em, #f95738) !important; - text-decoration-color: var(--em, #f95738) !important; - text-decoration-thickness: 1px !important; - font-style: italic !important; - } - - /* Strikethrough text */ - .overtype-wrapper .overtype-preview del { - color: var(--del, #ee964b) !important; - text-decoration: line-through !important; - text-decoration-color: var(--del, #ee964b) !important; - text-decoration-thickness: 1px !important; - } - - /* Inline code */ - .overtype-wrapper .overtype-preview code { - background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important; - color: var(--code, #0d3b66) !important; - padding: 0 !important; - border-radius: 2px !important; - font-family: inherit !important; - font-size: inherit !important; - line-height: inherit !important; - font-weight: normal !important; - } - - /* Code blocks - consolidated pre blocks */ - .overtype-wrapper .overtype-preview pre { - padding: 0 !important; - margin: 0 !important; - border-radius: 4px !important; - overflow-x: auto !important; - } - - /* Code block styling in normal mode - yellow background */ - .overtype-wrapper .overtype-preview pre.code-block { - background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important; - white-space: break-spaces !important; /* Prevent horizontal scrollbar that breaks alignment */ - } - - /* Code inside pre blocks - remove background */ - .overtype-wrapper .overtype-preview pre code { - background: transparent !important; - color: var(--code, #0d3b66) !important; - font-family: ${i} !important; /* Match textarea font exactly for alignment */ - } - - /* Blockquotes */ - .overtype-wrapper .overtype-preview .blockquote { - color: var(--blockquote, #5a7a9b) !important; - padding: 0 !important; - margin: 0 !important; - border: none !important; - } - - /* Links */ - .overtype-wrapper .overtype-preview a { - color: var(--link, #0d3b66) !important; - text-decoration: underline !important; - font-weight: normal !important; - } - - .overtype-wrapper .overtype-preview a:hover { - text-decoration: underline !important; - color: var(--link, #0d3b66) !important; - } - - /* Lists - no list styling */ - .overtype-wrapper .overtype-preview ul, - .overtype-wrapper .overtype-preview ol { - list-style: none !important; - margin: 0 !important; - padding: 0 !important; - } - - - /* Horizontal rules */ - .overtype-wrapper .overtype-preview hr { - border: none !important; - color: var(--hr, #5a7a9b) !important; - margin: 0 !important; - padding: 0 !important; - } - - .overtype-wrapper .overtype-preview .hr-marker { - color: var(--hr, #5a7a9b) !important; - opacity: 0.6 !important; - } - - /* Code fence markers - with background when not in code block */ - .overtype-wrapper .overtype-preview .code-fence { - color: var(--code, #0d3b66) !important; - background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important; - } - - /* Code block lines - background for entire code block */ - .overtype-wrapper .overtype-preview .code-block-line { - background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important; - } - - /* Remove background from code fence when inside code block line */ - .overtype-wrapper .overtype-preview .code-block-line .code-fence { - background: transparent !important; - } - - /* Raw markdown line */ - .overtype-wrapper .overtype-preview .raw-line { - color: var(--raw-line, #5a7a9b) !important; - font-style: normal !important; - font-weight: normal !important; - } - - /* Syntax markers */ - .overtype-wrapper .overtype-preview .syntax-marker { - color: var(--syntax-marker, rgba(13, 59, 102, 0.52)) !important; - opacity: 0.7 !important; - } - - /* List markers */ - .overtype-wrapper .overtype-preview .list-marker { - color: var(--list-marker, #ee964b) !important; - } - - /* Stats bar */ - - /* Stats bar - positioned by flexbox */ - .overtype-stats { - height: 40px !important; - padding: 0 20px !important; - background: #f8f9fa !important; - border-top: 1px solid #e0e0e0 !important; - display: flex !important; - justify-content: space-between !important; - align-items: center !important; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important; - font-size: 0.85rem !important; - color: #666 !important; - flex-shrink: 0 !important; /* Don't shrink */ - z-index: 10001 !important; /* Above link tooltip */ - position: relative !important; /* Enable z-index */ - } - - /* Dark theme stats bar */ - .overtype-container[data-theme="cave"] .overtype-stats { - background: var(--bg-secondary, #1D2D3E) !important; - border-top: 1px solid rgba(197, 221, 232, 0.1) !important; - color: var(--text, #c5dde8) !important; - } - - .overtype-stats .overtype-stat { - display: flex !important; - align-items: center !important; - gap: 5px !important; - white-space: nowrap !important; - } - - .overtype-stats .live-dot { - width: 8px !important; - height: 8px !important; - background: #4caf50 !important; - border-radius: 50% !important; - animation: overtype-pulse 2s infinite !important; - } - - @keyframes overtype-pulse { - 0%, 100% { opacity: 1; transform: scale(1); } - 50% { opacity: 0.6; transform: scale(1.2); } - } - - - /* Toolbar Styles */ - .overtype-toolbar.overtype-toolbar-hidden { - display: none !important; - } - - .overtype-toolbar { - display: flex !important; - align-items: center !important; - gap: 4px !important; - padding: 8px !important; /* Override reset */ - background: var(--toolbar-bg, var(--bg-primary, #f8f9fa)) !important; /* Override reset */ - border-bottom: 1px solid var(--toolbar-border, transparent) !important; /* Override reset */ - overflow-x: auto !important; /* Allow horizontal scrolling */ - overflow-y: hidden !important; /* Hide vertical overflow */ - -webkit-overflow-scrolling: touch !important; - flex-shrink: 0 !important; - height: auto !important; - position: relative !important; /* Override reset */ - z-index: 100 !important; /* Ensure toolbar is above wrapper */ - scrollbar-width: thin; /* Thin scrollbar on Firefox */ - } - - /* Thin scrollbar styling */ - .overtype-toolbar::-webkit-scrollbar { - height: 4px; - } - - .overtype-toolbar::-webkit-scrollbar-track { - background: transparent; - } - - .overtype-toolbar::-webkit-scrollbar-thumb { - background: rgba(0, 0, 0, 0.2); - border-radius: 2px; - } - - .overtype-toolbar-button { - display: flex; - align-items: center; - justify-content: center; - width: 32px; - height: 32px; - padding: 0; - border: none; - border-radius: 6px; - background: transparent; - color: var(--toolbar-icon, var(--text-secondary, #666)); - cursor: pointer; - transition: all 0.2s ease; - flex-shrink: 0; - } - - .overtype-toolbar-button svg { - width: 20px; - height: 20px; - fill: currentColor; - } - - .overtype-toolbar-button:hover { - background: var(--toolbar-hover, var(--bg-secondary, #e9ecef)); - color: var(--toolbar-icon, var(--text-primary, #333)); - } - - .overtype-toolbar-button:active { - transform: scale(0.95); - } - - .overtype-toolbar-button.active { - background: var(--toolbar-active, var(--primary, #007bff)); - color: var(--toolbar-icon, var(--text-primary, #333)); - } - - .overtype-toolbar-button:disabled { - opacity: 0.5; - cursor: not-allowed; - } - - .overtype-toolbar-separator { - width: 1px; - height: 24px; - background: var(--border, #e0e0e0); - margin: 0 4px; - flex-shrink: 0; - } - - /* Adjust wrapper when toolbar is present */ - /* Mobile toolbar adjustments */ - @media (max-width: 640px) { - .overtype-toolbar { - padding: 6px; - gap: 2px; - } - - .overtype-toolbar-button { - width: 36px; - height: 36px; - } - - .overtype-toolbar-separator { - margin: 0 2px; - } - } - - /* Plain mode - hide preview and show textarea text */ - .overtype-container[data-mode="plain"] .overtype-preview { - display: none !important; - } - - .overtype-container[data-mode="plain"] .overtype-input { - color: var(--text, #0d3b66) !important; - /* Use system font stack for better plain text readability */ - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, - "Helvetica Neue", Arial, sans-serif !important; - } - - /* Ensure textarea remains transparent in overlay mode */ - .overtype-container:not([data-mode="plain"]) .overtype-input { - color: transparent !important; - } - - /* Dropdown menu styles */ - .overtype-toolbar-button { - position: relative !important; /* Override reset - needed for dropdown */ - } - - .overtype-toolbar-button.dropdown-active { - background: var(--toolbar-active, var(--hover-bg, #f0f0f0)); - } - - .overtype-dropdown-menu { - position: fixed !important; /* Fixed positioning relative to viewport */ - background: var(--bg-secondary, white) !important; /* Override reset */ - border: 1px solid var(--border, #e0e0e0) !important; /* Override reset */ - border-radius: 6px; - box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important; /* Override reset */ - z-index: 10000; /* Very high z-index to ensure visibility */ - min-width: 150px; - padding: 4px 0 !important; /* Override reset */ - /* Position will be set via JavaScript based on button position */ - } - - .overtype-dropdown-item { - display: flex; - align-items: center; - width: 100%; - padding: 8px 12px; - border: none; - background: none; - text-align: left; - cursor: pointer; - font-size: 14px; - color: var(--text, #333); - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; - } - - .overtype-dropdown-item:hover { - background: var(--hover-bg, #f0f0f0); - } - - .overtype-dropdown-item.active { - font-weight: 600; - } - - .overtype-dropdown-check { - width: 16px; - margin-right: 8px; - color: var(--h1, #007bff); - } - - .overtype-dropdown-icon { - width: 20px; - margin-right: 8px; - text-align: center; - } - - /* Preview mode styles */ - .overtype-container[data-mode="preview"] .overtype-input { - display: none !important; - } - - .overtype-container[data-mode="preview"] .overtype-preview { - pointer-events: auto !important; - user-select: text !important; - cursor: text !important; - } - - .overtype-container.overtype-auto-resize[data-mode="preview"] .overtype-preview { - position: static !important; - height: auto !important; - } - - /* Hide syntax markers in preview mode */ - .overtype-container[data-mode="preview"] .syntax-marker { - display: none !important; - } - - /* Hide URL part of links in preview mode - extra specificity */ - .overtype-container[data-mode="preview"] .syntax-marker.url-part, - .overtype-container[data-mode="preview"] .url-part { - display: none !important; - } - - /* Hide all syntax markers inside links too */ - .overtype-container[data-mode="preview"] a .syntax-marker { - display: none !important; - } - - /* Headers - restore proper sizing in preview mode */ - .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h1, - .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h2, - .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h3 { - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important; - font-weight: 600 !important; - margin: 0 !important; - display: block !important; - line-height: 1 !important; - } - - .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h1 { - font-size: 2em !important; - color: var(--preview-h1, var(--preview-h1-default)) !important; - } - - .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h2 { - font-size: 1.5em !important; - color: var(--preview-h2, var(--preview-h2-default)) !important; - } - - .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h3 { - font-size: 1.17em !important; - color: var(--preview-h3, var(--preview-h3-default)) !important; - } - - /* Lists - restore list styling in preview mode */ - .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview ul { - display: block !important; - list-style: disc !important; - padding-left: 2em !important; - margin: 1em 0 !important; - } - - .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview ol { - display: block !important; - list-style: decimal !important; - padding-left: 2em !important; - margin: 1em 0 !important; - } - - .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview li { - display: list-item !important; - margin: 0 !important; - padding: 0 !important; - } - - /* Task list checkboxes - only in preview mode */ - .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview li.task-list { - list-style: none !important; - position: relative !important; - } - - .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview li.task-list input[type="checkbox"] { - margin-right: 0.5em !important; - cursor: default !important; - vertical-align: middle !important; - } - - /* Task list in normal mode - keep syntax visible */ - .overtype-container:not([data-mode="preview"]) .overtype-wrapper .overtype-preview li.task-list { - list-style: none !important; - } - - .overtype-container:not([data-mode="preview"]) .overtype-wrapper .overtype-preview li.task-list .syntax-marker { - color: var(--syntax, #999999) !important; - font-weight: normal !important; - } - - /* Links - make clickable in preview mode */ - .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview a { - pointer-events: auto !important; - cursor: pointer !important; - color: var(--preview-link, var(--preview-link-default)) !important; - text-decoration: underline !important; - } - - /* Code blocks - proper pre/code styling in preview mode */ - .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview pre.code-block { - background: var(--preview-code-bg, var(--preview-code-bg-default)) !important; - color: var(--preview-code, var(--preview-code-default)) !important; - padding: 1.2em !important; - border-radius: 3px !important; - overflow-x: auto !important; - margin: 0 !important; - display: block !important; - } - - .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview pre.code-block code { - background: transparent !important; - color: inherit !important; - padding: 0 !important; - font-family: ${i} !important; - font-size: 0.9em !important; - line-height: 1.4 !important; - } - - /* Hide old code block lines and fences in preview mode */ - .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .code-block-line { - display: none !important; - } - - .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .code-fence { - display: none !important; - } - - /* Blockquotes - enhanced styling in preview mode */ - .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .blockquote { - display: block !important; - border-left: 4px solid var(--preview-blockquote, var(--preview-blockquote-default)) !important; - color: var(--preview-blockquote, var(--preview-blockquote-default)) !important; - padding-left: 1em !important; - margin: 1em 0 !important; - font-style: italic !important; - } - - /* Typography improvements in preview mode */ - .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview { - font-family: Georgia, 'Times New Roman', serif !important; - font-size: 16px !important; - line-height: 1.8 !important; - color: var(--preview-text, var(--preview-text-default)) !important; - background: var(--preview-bg, var(--preview-bg-default)) !important; - } - - /* Inline code in preview mode - keep monospace */ - .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview code { - font-family: ${i} !important; - font-size: 0.9em !important; - background: var(--preview-code-bg, var(--preview-code-bg-default)) !important; - color: var(--preview-code, var(--preview-code-default)) !important; - padding: 0.2em 0.4em !important; - border-radius: 3px !important; - } - - /* Strong and em elements in preview mode */ - .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview strong { - font-weight: 700 !important; - color: var(--preview-strong, var(--preview-strong-default)) !important; - } - - .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview em { - font-style: italic !important; - color: var(--preview-em, var(--preview-em-default)) !important; - } - - /* HR in preview mode */ - .overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .hr-marker { - display: block !important; - border-top: 2px solid var(--preview-hr, var(--preview-hr-default)) !important; - text-indent: -9999px !important; - height: 2px !important; - } - - /* Link Tooltip */ - .overtype-link-tooltip { - background: #333 !important; - color: white !important; - padding: 6px 10px !important; - border-radius: 16px !important; - font-size: 12px !important; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important; - display: flex !important; - visibility: hidden !important; - pointer-events: none !important; - z-index: 10000 !important; - cursor: pointer !important; - box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important; - max-width: 300px !important; - white-space: nowrap !important; - overflow: hidden !important; - text-overflow: ellipsis !important; - position: fixed; - top: 0; - left: 0; - } - - .overtype-link-tooltip.visible { - visibility: visible !important; - pointer-events: auto !important; - } - - ${a} - `}var gn=Object.defineProperty,Qe=Object.getOwnPropertySymbols,vn=Object.prototype.hasOwnProperty,yn=Object.prototype.propertyIsEnumerable,Ge=(t,e,n)=>e in t?gn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Je=(t,e)=>{for(var n in e||(e={}))vn.call(e,n)&&Ge(t,n,e[n]);if(Qe)for(var n of Qe(e))yn.call(e,n)&&Ge(t,n,e[n]);return t},I={bold:{prefix:"**",suffix:"**",trimFirst:!0},italic:{prefix:"_",suffix:"_",trimFirst:!0},code:{prefix:"`",suffix:"`",blockPrefix:"```",blockSuffix:"```"},link:{prefix:"[",suffix:"](url)",replaceNext:"url",scanFor:"https?://"},bulletList:{prefix:"- ",multiline:!0,unorderedList:!0},numberedList:{prefix:"1. ",multiline:!0,orderedList:!0},quote:{prefix:"> ",multiline:!0,surroundWithNewlines:!0},taskList:{prefix:"- [ ] ",multiline:!0,surroundWithNewlines:!0},header1:{prefix:"# "},header2:{prefix:"## "},header3:{prefix:"### "},header4:{prefix:"#### "},header5:{prefix:"##### "},header6:{prefix:"###### "}};function wn(){return{prefix:"",suffix:"",blockPrefix:"",blockSuffix:"",multiline:!1,replaceNext:"",prefixSpace:!1,scanFor:"",surroundWithNewlines:!1,orderedList:!1,unorderedList:!1,trimFirst:!1}}function F(t){return Je(Je({},wn()),t)}var we=!1;function bn(){return we}function x(t,e,n){we&&(console.group(`\u{1F50D} ${t}`),console.log(e),n&&console.log("Data:",n),console.groupEnd())}function ye(t,e){if(!we)return;let n=t.value.slice(t.selectionStart,t.selectionEnd);console.group(`\u{1F4CD} Selection: ${e}`),console.log("Position:",`${t.selectionStart}-${t.selectionEnd}`),console.log("Selected text:",JSON.stringify(n)),console.log("Length:",n.length);let i=t.value.slice(Math.max(0,t.selectionStart-10),t.selectionStart),o=t.value.slice(t.selectionEnd,Math.min(t.value.length,t.selectionEnd+10));console.log("Context:",JSON.stringify(i)+"[SELECTION]"+JSON.stringify(o)),console.groupEnd()}function tt(t){we&&(console.group("\u{1F4DD} Result"),console.log("Text to insert:",JSON.stringify(t.text)),console.log("New selection:",`${t.selectionStart}-${t.selectionEnd}`),console.groupEnd())}var B=null;function U(t,{text:e,selectionStart:n,selectionEnd:i}){let o=bn();o&&(console.group("\u{1F527} insertText"),console.log("Current selection:",`${t.selectionStart}-${t.selectionEnd}`),console.log("Text to insert:",JSON.stringify(e)),console.log("New selection to set:",n,"-",i)),t.focus();let r=t.selectionStart,s=t.selectionEnd,a=t.value.slice(0,r),c=t.value.slice(s);o&&(console.log("Before text (last 20):",JSON.stringify(a.slice(-20))),console.log("After text (first 20):",JSON.stringify(c.slice(0,20))),console.log("Selected text being replaced:",JSON.stringify(t.value.slice(r,s))));let p=t.value,l=r!==s;if(B===null||B===!0){t.contentEditable="true";try{B=document.execCommand("insertText",!1,e),o&&console.log("execCommand returned:",B,"for text with",e.split(` -`).length,"lines")}catch(d){B=!1,o&&console.log("execCommand threw error:",d)}t.contentEditable="false"}if(o&&(console.log("canInsertText before:",B),console.log("execCommand result:",B)),B){let d=a+e+c,h=t.value;o&&(console.log("Expected length:",d.length),console.log("Actual length:",h.length)),h!==d&&o&&(console.log("execCommand changed the value but not as expected"),console.log("Expected:",JSON.stringify(d.slice(0,100))),console.log("Actual:",JSON.stringify(h.slice(0,100))))}if(!B)if(o&&console.log("Using manual insertion"),t.value===p){o&&console.log("Value unchanged, doing manual replacement");try{document.execCommand("ms-beginUndoUnit")}catch(d){}t.value=a+e+c;try{document.execCommand("ms-endUndoUnit")}catch(d){}t.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0}))}else o&&console.log("Value was changed by execCommand, skipping manual insertion");o&&console.log("Setting selection range:",n,i),n!=null&&i!=null?t.setSelectionRange(n,i):t.setSelectionRange(r,t.selectionEnd),o&&(console.log("Final value length:",t.value.length),console.groupEnd())}function Xe(t){return t.trim().split(` -`).length>1}function xn(t,e){let n=e;for(;t[n]&&t[n-1]!=null&&!t[n-1].match(/\s/);)n--;return n}function kn(t,e,n){let i=e,o=n?/\n/:/\s/;for(;t[i]&&!t[i].match(o);)i++;return i}function nt(t){let e=t.value.split(` -`),n=0;for(let i=0;i=n&&t.selectionStart=n&&t.selectionEnd0&&s[a-1]!==` -`;)a--;if(r){let p=i;for(;p0?`${s} -`:o,y=Xe(m)&&a&&a.length>0?` -${a}`:r;if(p){let k=t.value[t.selectionStart-1];t.selectionStart!==0&&k!=null&&!k.match(/\s/)&&(g=` ${g}`)}m=Ln(t,g,y,e.multiline);let w=t.selectionStart,b=t.selectionEnd,L=c&&c.length>0&&y.indexOf(c)>-1&&m.length>0;if(d){let k=$e(t);n=k.newlinesToAppend,i=k.newlinesToPrepend,g=n+o,y+=i}if(m.startsWith(g)&&m.endsWith(y)){let k=m.slice(g.length,m.length-y.length);if(u===f){let E=u-g.length;E=Math.max(E,w),E=Math.min(E,w+k.length),w=b=E}else b=w+k.length;return{text:k,selectionStart:w,selectionEnd:b}}else if(L)if(l&&l.length>0&&m.match(l)){y=y.replace(c,m);let k=g+y;return w=b=w+g.length,{text:k,selectionStart:w,selectionEnd:b}}else{let k=g+m+y;return w=w+g.length+m.length+y.indexOf(c),b=w+c.length,{text:k,selectionStart:w,selectionEnd:b}}else{let k=g+m+y;w=u+g.length,b=f+g.length;let E=m.match(/^\s*|\s*$/g);if(h&&E){let me=E[0]||"",Y=E[1]||"";k=me+g+m.trim()+y+Y,w+=me.length,b-=Y.length}return{text:k,selectionStart:w,selectionEnd:b}}}function it(t,e){let{prefix:n,suffix:i,surroundWithNewlines:o}=e,r=t.value.slice(t.selectionStart,t.selectionEnd),s=t.selectionStart,a=t.selectionEnd,c=r.split(` -`);if(c.every(l=>l.startsWith(n)&&(!i||l.endsWith(i))))r=c.map(l=>{let d=l.slice(n.length);return i&&(d=d.slice(0,d.length-i.length)),d}).join(` -`),a=s+r.length;else if(r=c.map(l=>n+l+(i||"")).join(` -`),o){let{newlinesToAppend:l,newlinesToPrepend:d}=$e(t);s+=l.length,a=s+r.length,r=l+r+d}return{text:r,selectionStart:s,selectionEnd:a}}function Ye(t){let e=t.split(` -`),n=/^\d+\.\s+/,i=e.every(r=>n.test(r)),o=e;return i&&(o=e.map(r=>r.replace(n,""))),{text:o.join(` -`),processed:i}}function et(t){let e=t.split(` -`),n="- ",i=e.every(r=>r.startsWith(n)),o=e;return i&&(o=e.map(r=>r.slice(n.length))),{text:o.join(` -`),processed:i}}function se(t,e){return e?"- ":`${t+1}. `}function Sn(t,e){let n,i,o;return t.orderedList?(n=Ye(e),i=et(n.text),o=i.text):(n=et(e),i=Ye(n.text),o=i.text),[n,i,o]}function En(t,e){let n=t.selectionStart===t.selectionEnd,i=t.selectionStart,o=t.selectionEnd;nt(t);let r=t.value.slice(t.selectionStart,t.selectionEnd),[s,a,c]=Sn(e,r),p=c.split(` -`).map((m,g)=>`${se(g,e.unorderedList)}${m}`),l=p.reduce((m,g,y)=>m+se(y,e.unorderedList).length,0),d=p.reduce((m,g,y)=>m+se(y,!e.unorderedList).length,0);if(s.processed)return n?(i=Math.max(i-se(0,e.unorderedList).length,0),o=i):(i=t.selectionStart,o=t.selectionEnd-l),{text:c,selectionStart:i,selectionEnd:o};let{newlinesToAppend:h,newlinesToPrepend:u}=$e(t),f=h+p.join(` -`)+u;return n?(i=Math.max(i+se(0,e.unorderedList).length+h.length,0),o=i):a.processed?(i=Math.max(t.selectionStart+h.length,0),o=t.selectionEnd+h.length+l-d):(i=Math.max(t.selectionStart+h.length,0),o=t.selectionEnd+h.length+l),{text:f,selectionStart:i,selectionEnd:o}}function ot(t,e){let n=be(t,i=>En(i,e),{adjustSelection:(i,o,r,s)=>{let a=t.value.slice(s,t.selectionEnd),c=/^\d+\.\s+/,p=/^- /,l=c.test(a),d=p.test(a),h=e.orderedList&&l||e.unorderedList&&d;if(o===r)if(h){let u=a.match(e.orderedList?c:p),f=u?u[0].length:0;return{start:Math.max(o-f,s),end:Math.max(o-f,s)}}else if(l||d){let u=a.match(l?c:p),f=u?u[0].length:0,g=(e.unorderedList?2:3)-f;return{start:o+g,end:o+g}}else{let u=e.unorderedList?2:3;return{start:o+u,end:o+u}}else if(h){let u=a.match(e.orderedList?c:p),f=u?u[0].length:0;return{start:Math.max(o-f,s),end:Math.max(r-f,s)}}else if(l||d){let u=a.match(l?c:p),f=u?u[0].length:0,g=(e.unorderedList?2:3)-f;return{start:o+g,end:r+g}}else{let u=e.unorderedList?2:3;return{start:o+u,end:r+u}}}});U(t,n)}function Tn(t){if(!t)return[];let e=[],{selectionStart:n,selectionEnd:i,value:o}=t,r=o.split(` -`),s=0,a="";for(let d of r){if(n>=s&&n<=s+d.length){a=d;break}s+=d.length+1}a.startsWith("- ")&&(a.startsWith("- [ ] ")||a.startsWith("- [x] ")?e.push("task-list"):e.push("bullet-list")),/^\d+\.\s/.test(a)&&e.push("numbered-list"),a.startsWith("> ")&&e.push("quote"),a.startsWith("# ")&&e.push("header"),a.startsWith("## ")&&e.push("header-2"),a.startsWith("### ")&&e.push("header-3");let c=Math.max(0,n-10),p=Math.min(o.length,i+10),l=o.slice(c,p);if(l.includes("**")){let d=o.slice(Math.max(0,n-100),n),h=o.slice(i,Math.min(o.length,i+100)),u=d.lastIndexOf("**"),f=h.indexOf("**");u!==-1&&f!==-1&&e.push("bold")}if(l.includes("_")){let d=o.slice(Math.max(0,n-100),n),h=o.slice(i,Math.min(o.length,i+100)),u=d.lastIndexOf("_"),f=h.indexOf("_");u!==-1&&f!==-1&&e.push("italic")}if(l.includes("`")){let d=o.slice(Math.max(0,n-100),n),h=o.slice(i,Math.min(o.length,i+100));d.includes("`")&&h.includes("`")&&e.push("code")}if(l.includes("[")&&l.includes("]")){let d=o.slice(Math.max(0,n-100),n),h=o.slice(i,Math.min(o.length,i+100)),u=d.lastIndexOf("["),f=h.indexOf("]");u!==-1&&f!==-1&&o.slice(i+f+1,i+f+10).startsWith("(")&&e.push("link")}return e}function rt(t){if(!t||t.disabled||t.readOnly)return;x("toggleBold","Starting"),ye(t,"Before");let e=F(I.bold),n=xe(t,e);tt(n),U(t,n),ye(t,"After")}function st(t){if(!t||t.disabled||t.readOnly)return;let e=F(I.italic),n=xe(t,e);U(t,n)}function at(t){if(!t||t.disabled||t.readOnly)return;let e=F(I.code),n=xe(t,e);U(t,n)}function lt(t,e={}){if(!t||t.disabled||t.readOnly)return;let n=t.value.slice(t.selectionStart,t.selectionEnd),i=F(I.link);if(n&&n.match(/^https?:\/\//)&&!e.url?(i.suffix=`](${n})`,i.replaceNext=""):e.url&&(i.suffix=`](${e.url})`,i.replaceNext=""),e.text&&!n){let s=t.selectionStart;t.value=t.value.slice(0,s)+e.text+t.value.slice(s),t.selectionStart=s,t.selectionEnd=s+e.text.length}let r=xe(t,i);U(t,r)}function ct(t){if(!t||t.disabled||t.readOnly)return;let e=F(I.bulletList);ot(t,e)}function pt(t){if(!t||t.disabled||t.readOnly)return;let e=F(I.numberedList);ot(t,e)}function dt(t){if(!t||t.disabled||t.readOnly)return;x("toggleQuote","Starting"),ye(t,"Initial");let e=F(I.quote),n=be(t,i=>it(i,e),{prefix:e.prefix});tt(n),U(t,n),ye(t,"Final")}function Ie(t){if(!t||t.disabled||t.readOnly)return;let e=F(I.taskList),n=be(t,i=>it(i,e),{prefix:e.prefix});U(t,n)}function Re(t,e=1,n=!1){if(!t||t.disabled||t.readOnly)return;(e<1||e>6)&&(e=1),x("insertHeader","============ START ============"),x("insertHeader",`Level: ${e}, Toggle: ${n}`),x("insertHeader",`Initial cursor: ${t.selectionStart}-${t.selectionEnd}`);let i=`header${e===1?"1":e}`,o=F(I[i]||I.header1);x("insertHeader",`Style prefix: "${o.prefix}"`);let r=t.value,s=t.selectionStart,a=t.selectionEnd,c=s;for(;c>0&&r[c-1]!==` -`;)c--;let p=a;for(;p{let y=g.value.slice(g.selectionStart,g.selectionEnd);x("insertHeader",`Line in operation: "${y}"`);let w=y.replace(/^#{1,6}\s*/,"");x("insertHeader",`Cleaned line: "${w}"`);let b;return f?(x("insertHeader","ACTION: Toggling OFF - removing header"),b=w):h>0?(x("insertHeader",`ACTION: Replacing H${h} with H${e}`),b=o.prefix+w):(x("insertHeader","ACTION: Adding new header"),b=o.prefix+w),x("insertHeader",`New line: "${b}"`),{text:b,selectionStart:g.selectionStart,selectionEnd:g.selectionEnd}},{prefix:o.prefix,adjustSelection:(g,y,w,b)=>{if(x("insertHeader","Adjusting selection:"),x("insertHeader",` - isRemoving param: ${g}`),x("insertHeader",` - shouldToggleOff: ${f}`),x("insertHeader",` - selStart: ${y}, selEnd: ${w}`),x("insertHeader",` - lineStartPos: ${b}`),f){let L=Math.max(y-u,b);return x("insertHeader",` - Removing header, adjusting by -${u}`),{start:L,end:y===w?L:Math.max(w-u,b)}}else if(u>0){let L=o.prefix.length-u;return x("insertHeader",` - Replacing header, adjusting by ${L}`),{start:y+L,end:w+L}}else return x("insertHeader",` - Adding header, adjusting by +${o.prefix.length}`),{start:y+o.prefix.length,end:w+o.prefix.length}}});x("insertHeader",`Final result: text="${m.text}", cursor=${m.selectionStart}-${m.selectionEnd}`),x("insertHeader","============ END ============"),U(t,m)}function ut(t){Re(t,1,!0)}function ht(t){Re(t,2,!0)}function ft(t){Re(t,3,!0)}function mt(t){return Tn(t)}var ke=class{constructor(e,n={}){this.editor=e,this.container=null,this.buttons={},this.toolbarButtons=n.toolbarButtons||[]}create(){this.container=document.createElement("div"),this.container.className="overtype-toolbar",this.container.setAttribute("role","toolbar"),this.container.setAttribute("aria-label","Formatting toolbar"),this.toolbarButtons.forEach(e=>{if(e.name==="separator"){let n=this.createSeparator();this.container.appendChild(n)}else{let n=this.createButton(e);this.buttons[e.name]=n,this.container.appendChild(n)}}),this.editor.container.insertBefore(this.container,this.editor.wrapper)}createSeparator(){let e=document.createElement("div");return e.className="overtype-toolbar-separator",e.setAttribute("role","separator"),e}createButton(e){let n=document.createElement("button");return n.className="overtype-toolbar-button",n.type="button",n.setAttribute("data-button",e.name),n.title=e.title||"",n.setAttribute("aria-label",e.title||e.name),n.innerHTML=this.sanitizeSVG(e.icon||""),e.name==="viewMode"?(n.classList.add("has-dropdown"),n.dataset.dropdown="true",n.addEventListener("click",i=>{i.preventDefault(),this.toggleViewModeDropdown(n)}),n):(n._clickHandler=i=>{i.preventDefault();let o=e.actionId||e.name;this.editor.performAction(o,i)},n.addEventListener("click",n._clickHandler),n)}async handleAction(e){if(e&&typeof e=="object"&&typeof e.action=="function"){this.editor.textarea.focus();try{return await e.action({editor:this.editor,getValue:()=>this.editor.getValue(),setValue:n=>this.editor.setValue(n),event:null}),!0}catch(n){return console.error(`Action "${e.name}" error:`,n),this.editor.wrapper.dispatchEvent(new CustomEvent("button-error",{detail:{buttonName:e.name,error:n}})),!1}}return typeof e=="string"?this.editor.performAction(e,null):!1}sanitizeSVG(e){return typeof e!="string"?"":e.replace(/)<[^<]*)*<\/script>/gi,"").replace(/\son\w+\s*=\s*["'][^"']*["']/gi,"").replace(/\son\w+\s*=\s*[^\s>]*/gi,"")}toggleViewModeDropdown(e){let n=document.querySelector(".overtype-dropdown-menu");if(n){n.remove(),e.classList.remove("dropdown-active");return}e.classList.add("dropdown-active");let i=this.createViewModeDropdown(e),o=e.getBoundingClientRect();i.style.position="absolute",i.style.top=`${o.bottom+5}px`,i.style.left=`${o.left}px`,document.body.appendChild(i),this.handleDocumentClick=r=>{!i.contains(r.target)&&!e.contains(r.target)&&(i.remove(),e.classList.remove("dropdown-active"),document.removeEventListener("click",this.handleDocumentClick))},setTimeout(()=>{document.addEventListener("click",this.handleDocumentClick)},0)}createViewModeDropdown(e){let n=document.createElement("div");n.className="overtype-dropdown-menu";let i=[{id:"normal",label:"Normal Edit",icon:"\u2713"},{id:"plain",label:"Plain Textarea",icon:"\u2713"},{id:"preview",label:"Preview Mode",icon:"\u2713"}],o=this.editor.container.dataset.mode||"normal";return i.forEach(r=>{let s=document.createElement("button");if(s.className="overtype-dropdown-item",s.type="button",s.textContent=r.label,r.id===o){s.classList.add("active"),s.setAttribute("aria-current","true");let a=document.createElement("span");a.className="overtype-dropdown-icon",a.textContent=r.icon,s.prepend(a)}s.addEventListener("click",a=>{switch(a.preventDefault(),r.id){case"plain":this.editor.showPlainTextarea();break;case"preview":this.editor.showPreviewMode();break;case"normal":default:this.editor.showNormalEditMode();break}n.remove(),e.classList.remove("dropdown-active"),document.removeEventListener("click",this.handleDocumentClick)}),n.appendChild(s)}),n}updateButtonStates(){var e;try{let n=((e=mt)==null?void 0:e(this.editor.textarea,this.editor.textarea.selectionStart))||[];Object.entries(this.buttons).forEach(([i,o])=>{if(i==="viewMode")return;let r=!1;switch(i){case"bold":r=n.includes("bold");break;case"italic":r=n.includes("italic");break;case"code":r=!1;break;case"bulletList":r=n.includes("bullet-list");break;case"orderedList":r=n.includes("numbered-list");break;case"taskList":r=n.includes("task-list");break;case"quote":r=n.includes("quote");break;case"h1":r=n.includes("header");break;case"h2":r=n.includes("header-2");break;case"h3":r=n.includes("header-3");break}o.classList.toggle("active",r),o.setAttribute("aria-pressed",r.toString())})}catch(n){}}show(){this.container&&this.container.classList.remove("overtype-toolbar-hidden")}hide(){this.container&&this.container.classList.add("overtype-toolbar-hidden")}destroy(){this.container&&(this.handleDocumentClick&&document.removeEventListener("click",this.handleDocumentClick),Object.values(this.buttons).forEach(e=>{e._clickHandler&&(e.removeEventListener("click",e._clickHandler),delete e._clickHandler)}),this.container.remove(),this.container=null,this.buttons={})}};var le=Math.min,q=Math.max,ce=Math.round;var O=t=>({x:t,y:t}),Cn={left:"right",right:"left",bottom:"top",top:"bottom"},An={start:"end",end:"start"};function _e(t,e,n){return q(t,le(e,n))}function pe(t,e){return typeof t=="function"?t(e):t}function W(t){return t.split("-")[0]}function de(t){return t.split("-")[1]}function Be(t){return t==="x"?"y":"x"}function Fe(t){return t==="y"?"height":"width"}var Mn=new Set(["top","bottom"]);function N(t){return Mn.has(W(t))?"y":"x"}function Ne(t){return Be(N(t))}function wt(t,e,n){n===void 0&&(n=!1);let i=de(t),o=Ne(t),r=Fe(o),s=o==="x"?i===(n?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(s=ae(s)),[s,ae(s)]}function bt(t){let e=ae(t);return[Le(t),e,Le(e)]}function Le(t){return t.replace(/start|end/g,e=>An[e])}var vt=["left","right"],yt=["right","left"],Hn=["top","bottom"],Pn=["bottom","top"];function On(t,e,n){switch(t){case"top":case"bottom":return n?e?yt:vt:e?vt:yt;case"left":case"right":return e?Hn:Pn;default:return[]}}function xt(t,e,n,i){let o=de(t),r=On(W(t),n==="start",i);return o&&(r=r.map(s=>s+"-"+o),e&&(r=r.concat(r.map(Le)))),r}function ae(t){return t.replace(/left|right|bottom|top/g,e=>Cn[e])}function $n(t){return{top:0,right:0,bottom:0,left:0,...t}}function kt(t){return typeof t!="number"?$n(t):{top:t,right:t,bottom:t,left:t}}function G(t){let{x:e,y:n,width:i,height:o}=t;return{width:i,height:o,top:n,left:e,right:e+i,bottom:n+o,x:e,y:n}}function Lt(t,e,n){let{reference:i,floating:o}=t,r=N(e),s=Ne(e),a=Fe(s),c=W(e),p=r==="y",l=i.x+i.width/2-o.width/2,d=i.y+i.height/2-o.height/2,h=i[a]/2-o[a]/2,u;switch(c){case"top":u={x:l,y:i.y-o.height};break;case"bottom":u={x:l,y:i.y+i.height};break;case"right":u={x:i.x+i.width,y:d};break;case"left":u={x:i.x-o.width,y:d};break;default:u={x:i.x,y:i.y}}switch(de(e)){case"start":u[s]-=h*(n&&p?-1:1);break;case"end":u[s]+=h*(n&&p?-1:1);break}return u}async function St(t,e){var n;e===void 0&&(e={});let{x:i,y:o,platform:r,rects:s,elements:a,strategy:c}=t,{boundary:p="clippingAncestors",rootBoundary:l="viewport",elementContext:d="floating",altBoundary:h=!1,padding:u=0}=pe(e,t),f=kt(u),g=a[h?d==="floating"?"reference":"floating":d],y=G(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(g)))==null||n?g:g.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(a.floating)),boundary:p,rootBoundary:l,strategy:c})),w=d==="floating"?{x:i,y:o,width:s.floating.width,height:s.floating.height}:s.reference,b=await(r.getOffsetParent==null?void 0:r.getOffsetParent(a.floating)),L=await(r.isElement==null?void 0:r.isElement(b))?await(r.getScale==null?void 0:r.getScale(b))||{x:1,y:1}:{x:1,y:1},k=G(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:b,strategy:c}):w);return{top:(y.top-k.top+f.top)/L.y,bottom:(k.bottom-y.bottom+f.bottom)/L.y,left:(y.left-k.left+f.left)/L.x,right:(k.right-y.right+f.right)/L.x}}var Et=async(t,e,n)=>{let{placement:i="bottom",strategy:o="absolute",middleware:r=[],platform:s}=n,a=r.filter(Boolean),c=await(s.isRTL==null?void 0:s.isRTL(e)),p=await s.getElementRects({reference:t,floating:e,strategy:o}),{x:l,y:d}=Lt(p,i,c),h=i,u={},f=0;for(let g=0;gK<=0)){var je,Ve;let K=(((je=r.flip)==null?void 0:je.index)||0)+1,Pe=me[K];if(Pe&&(!(d==="alignment"?w!==N(Pe):!1)||ee.every(P=>N(P.placement)===w?P.overflows[0]>0:!0)))return{data:{index:K,overflows:ee},reset:{placement:Pe}};let oe=(Ve=ee.filter(Z=>Z.overflows[0]<=0).sort((Z,P)=>Z.overflows[1]-P.overflows[1])[0])==null?void 0:Ve.placement;if(!oe)switch(u){case"bestFit":{var Ue;let Z=(Ue=ee.filter(P=>{if(E){let j=N(P.placement);return j===w||j==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(j=>j>0).reduce((j,ln)=>j+ln,0)]).sort((P,j)=>P[1]-j[1])[0])==null?void 0:Ue[0];Z&&(oe=Z);break}case"initialPlacement":oe=a;break}if(o!==oe)return{reset:{placement:oe}}}return{}}}};var In=new Set(["left","top"]);async function Rn(t,e){let{placement:n,platform:i,elements:o}=t,r=await(i.isRTL==null?void 0:i.isRTL(o.floating)),s=W(n),a=de(n),c=N(n)==="y",p=In.has(s)?-1:1,l=r&&c?-1:1,d=pe(e,t),{mainAxis:h,crossAxis:u,alignmentAxis:f}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof f=="number"&&(u=a==="end"?f*-1:f),c?{x:u*l,y:h*p}:{x:h*p,y:u*l}}var Ct=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,i;let{x:o,y:r,placement:s,middlewareData:a}=e,c=await Rn(e,t);return s===((n=a.offset)==null?void 0:n.placement)&&(i=a.arrow)!=null&&i.alignmentOffset?{}:{x:o+c.x,y:r+c.y,data:{...c,placement:s}}}}},At=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:n,y:i,placement:o,platform:r}=e,{mainAxis:s=!0,crossAxis:a=!1,limiter:c={fn:y=>{let{x:w,y:b}=y;return{x:w,y:b}}},...p}=pe(t,e),l={x:n,y:i},d=await r.detectOverflow(e,p),h=N(W(o)),u=Be(h),f=l[u],m=l[h];if(s){let y=u==="y"?"top":"left",w=u==="y"?"bottom":"right",b=f+d[y],L=f-d[w];f=_e(b,f,L)}if(a){let y=h==="y"?"top":"left",w=h==="y"?"bottom":"right",b=m+d[y],L=m-d[w];m=_e(b,m,L)}let g=c.fn({...e,[u]:f,[h]:m});return{...g,data:{x:g.x-n,y:g.y-i,enabled:{[u]:s,[h]:a}}}}}};function Ee(){return typeof window<"u"}function J(t){return Ht(t)?(t.nodeName||"").toLowerCase():"#document"}function A(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function R(t){var e;return(e=(Ht(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Ht(t){return Ee()?t instanceof Node||t instanceof A(t).Node:!1}function M(t){return Ee()?t instanceof Element||t instanceof A(t).Element:!1}function $(t){return Ee()?t instanceof HTMLElement||t instanceof A(t).HTMLElement:!1}function Mt(t){return!Ee()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof A(t).ShadowRoot}var _n=new Set(["inline","contents"]);function te(t){let{overflow:e,overflowX:n,overflowY:i,display:o}=H(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+n)&&!_n.has(o)}var Bn=new Set(["table","td","th"]);function Pt(t){return Bn.has(J(t))}var Fn=[":popover-open",":modal"];function ue(t){return Fn.some(e=>{try{return t.matches(e)}catch(n){return!1}})}var Nn=["transform","translate","scale","rotate","perspective"],Dn=["transform","translate","scale","rotate","perspective","filter"],zn=["paint","layout","strict","content"];function Te(t){let e=Ce(),n=M(t)?H(t):t;return Nn.some(i=>n[i]?n[i]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||Dn.some(i=>(n.willChange||"").includes(i))||zn.some(i=>(n.contain||"").includes(i))}function Ot(t){let e=D(t);for(;$(e)&&!X(e);){if(Te(e))return e;if(ue(e))return null;e=D(e)}return null}function Ce(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}var jn=new Set(["html","body","#document"]);function X(t){return jn.has(J(t))}function H(t){return A(t).getComputedStyle(t)}function he(t){return M(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function D(t){if(J(t)==="html")return t;let e=t.assignedSlot||t.parentNode||Mt(t)&&t.host||R(t);return Mt(e)?e.host:e}function $t(t){let e=D(t);return X(e)?t.ownerDocument?t.ownerDocument.body:t.body:$(e)&&te(e)?e:$t(e)}function Se(t,e,n){var i;e===void 0&&(e=[]),n===void 0&&(n=!0);let o=$t(t),r=o===((i=t.ownerDocument)==null?void 0:i.body),s=A(o);if(r){let a=Ae(s);return e.concat(s,s.visualViewport||[],te(o)?o:[],a&&n?Se(a):[])}return e.concat(o,Se(o,[],n))}function Ae(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Bt(t){let e=H(t),n=parseFloat(e.width)||0,i=parseFloat(e.height)||0,o=$(t),r=o?t.offsetWidth:n,s=o?t.offsetHeight:i,a=ce(n)!==r||ce(i)!==s;return a&&(n=r,i=s),{width:n,height:i,$:a}}function Ft(t){return M(t)?t:t.contextElement}function ne(t){let e=Ft(t);if(!$(e))return O(1);let n=e.getBoundingClientRect(),{width:i,height:o,$:r}=Bt(e),s=(r?ce(n.width):n.width)/i,a=(r?ce(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var Vn=O(0);function Nt(t){let e=A(t);return!Ce()||!e.visualViewport?Vn:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Un(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==A(t)?!1:e}function fe(t,e,n,i){e===void 0&&(e=!1),n===void 0&&(n=!1);let o=t.getBoundingClientRect(),r=Ft(t),s=O(1);e&&(i?M(i)&&(s=ne(i)):s=ne(t));let a=Un(r,n,i)?Nt(r):O(0),c=(o.left+a.x)/s.x,p=(o.top+a.y)/s.y,l=o.width/s.x,d=o.height/s.y;if(r){let h=A(r),u=i&&M(i)?A(i):i,f=h,m=Ae(f);for(;m&&i&&u!==f;){let g=ne(m),y=m.getBoundingClientRect(),w=H(m),b=y.left+(m.clientLeft+parseFloat(w.paddingLeft))*g.x,L=y.top+(m.clientTop+parseFloat(w.paddingTop))*g.y;c*=g.x,p*=g.y,l*=g.x,d*=g.y,c+=b,p+=L,f=A(m),m=Ae(f)}}return G({width:l,height:d,x:c,y:p})}function Me(t,e){let n=he(t).scrollLeft;return e?e.left+n:fe(R(t)).left+n}function Dt(t,e){let n=t.getBoundingClientRect(),i=n.left+e.scrollLeft-Me(t,n),o=n.top+e.scrollTop;return{x:i,y:o}}function qn(t){let{elements:e,rect:n,offsetParent:i,strategy:o}=t,r=o==="fixed",s=R(i),a=e?ue(e.floating):!1;if(i===s||a&&r)return n;let c={scrollLeft:0,scrollTop:0},p=O(1),l=O(0),d=$(i);if((d||!d&&!r)&&((J(i)!=="body"||te(s))&&(c=he(i)),$(i))){let u=fe(i);p=ne(i),l.x=u.x+i.clientLeft,l.y=u.y+i.clientTop}let h=s&&!d&&!r?Dt(s,c):O(0);return{width:n.width*p.x,height:n.height*p.y,x:n.x*p.x-c.scrollLeft*p.x+l.x+h.x,y:n.y*p.y-c.scrollTop*p.y+l.y+h.y}}function Wn(t){return Array.from(t.getClientRects())}function Kn(t){let e=R(t),n=he(t),i=t.ownerDocument.body,o=q(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),r=q(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight),s=-n.scrollLeft+Me(t),a=-n.scrollTop;return H(i).direction==="rtl"&&(s+=q(e.clientWidth,i.clientWidth)-o),{width:o,height:r,x:s,y:a}}var It=25;function Zn(t,e){let n=A(t),i=R(t),o=n.visualViewport,r=i.clientWidth,s=i.clientHeight,a=0,c=0;if(o){r=o.width,s=o.height;let l=Ce();(!l||l&&e==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}let p=Me(i);if(p<=0){let l=i.ownerDocument,d=l.body,h=getComputedStyle(d),u=l.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,f=Math.abs(i.clientWidth-d.clientWidth-u);f<=It&&(r-=f)}else p<=It&&(r+=p);return{width:r,height:s,x:a,y:c}}var Qn=new Set(["absolute","fixed"]);function Gn(t,e){let n=fe(t,!0,e==="fixed"),i=n.top+t.clientTop,o=n.left+t.clientLeft,r=$(t)?ne(t):O(1),s=t.clientWidth*r.x,a=t.clientHeight*r.y,c=o*r.x,p=i*r.y;return{width:s,height:a,x:c,y:p}}function Rt(t,e,n){let i;if(e==="viewport")i=Zn(t,n);else if(e==="document")i=Kn(R(t));else if(M(e))i=Gn(e,n);else{let o=Nt(t);i={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return G(i)}function zt(t,e){let n=D(t);return n===e||!M(n)||X(n)?!1:H(n).position==="fixed"||zt(n,e)}function Jn(t,e){let n=e.get(t);if(n)return n;let i=Se(t,[],!1).filter(a=>M(a)&&J(a)!=="body"),o=null,r=H(t).position==="fixed",s=r?D(t):t;for(;M(s)&&!X(s);){let a=H(s),c=Te(s);!c&&a.position==="fixed"&&(o=null),(r?!c&&!o:!c&&a.position==="static"&&!!o&&Qn.has(o.position)||te(s)&&!c&&zt(t,s))?i=i.filter(l=>l!==s):o=a,s=D(s)}return e.set(t,i),i}function Xn(t){let{element:e,boundary:n,rootBoundary:i,strategy:o}=t,s=[...n==="clippingAncestors"?ue(e)?[]:Jn(e,this._c):[].concat(n),i],a=s[0],c=s.reduce((p,l)=>{let d=Rt(e,l,o);return p.top=q(d.top,p.top),p.right=le(d.right,p.right),p.bottom=le(d.bottom,p.bottom),p.left=q(d.left,p.left),p},Rt(e,a,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Yn(t){let{width:e,height:n}=Bt(t);return{width:e,height:n}}function ei(t,e,n){let i=$(e),o=R(e),r=n==="fixed",s=fe(t,!0,r,e),a={scrollLeft:0,scrollTop:0},c=O(0);function p(){c.x=Me(o)}if(i||!i&&!r)if((J(e)!=="body"||te(o))&&(a=he(e)),i){let u=fe(e,!0,r,e);c.x=u.x+e.clientLeft,c.y=u.y+e.clientTop}else o&&p();r&&!i&&o&&p();let l=o&&!i&&!r?Dt(o,a):O(0),d=s.left+a.scrollLeft-c.x-l.x,h=s.top+a.scrollTop-c.y-l.y;return{x:d,y:h,width:s.width,height:s.height}}function De(t){return H(t).position==="static"}function _t(t,e){if(!$(t)||H(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return R(t)===n&&(n=n.ownerDocument.body),n}function jt(t,e){let n=A(t);if(ue(t))return n;if(!$(t)){let o=D(t);for(;o&&!X(o);){if(M(o)&&!De(o))return o;o=D(o)}return n}let i=_t(t,e);for(;i&&Pt(i)&&De(i);)i=_t(i,e);return i&&X(i)&&De(i)&&!Te(i)?n:i||Ot(t)||n}var ti=async function(t){let e=this.getOffsetParent||jt,n=this.getDimensions,i=await n(t.floating);return{reference:ei(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function ni(t){return H(t).direction==="rtl"}var ii={convertOffsetParentRelativeRectToViewportRelativeRect:qn,getDocumentElement:R,getClippingRect:Xn,getOffsetParent:jt,getElementRects:ti,getClientRects:Wn,getDimensions:Yn,getScale:ne,isElement:M,isRTL:ni};var Vt=Ct;var Ut=At,qt=Tt;var Wt=(t,e,n)=>{let i=new Map,o={platform:ii,...n},r={...o.platform,_c:i};return Et(t,e,{...o,platform:r})};var He=class{constructor(e){this.editor=e,this.tooltip=null,this.currentLink=null,this.hideTimeout=null,this.visibilityChangeHandler=null,this.isTooltipHovered=!1,this.init()}init(){this.createTooltip(),this.editor.textarea.addEventListener("selectionchange",()=>this.checkCursorPosition()),this.editor.textarea.addEventListener("keyup",e=>{(e.key.includes("Arrow")||e.key==="Home"||e.key==="End")&&this.checkCursorPosition()}),this.editor.textarea.addEventListener("input",()=>this.hide()),this.editor.textarea.addEventListener("scroll",()=>{this.currentLink&&this.positionTooltip(this.currentLink)}),this.editor.textarea.addEventListener("blur",()=>{this.isTooltipHovered||this.hide()}),this.visibilityChangeHandler=()=>{document.hidden&&this.hide()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),this.tooltip.addEventListener("mouseenter",()=>{this.isTooltipHovered=!0,this.cancelHide()}),this.tooltip.addEventListener("mouseleave",()=>{this.isTooltipHovered=!1,this.scheduleHide()})}createTooltip(){this.tooltip=document.createElement("div"),this.tooltip.className="overtype-link-tooltip",this.tooltip.innerHTML=` - - - - - - - - `,this.tooltip.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),this.currentLink&&(window.open(this.currentLink.url,"_blank"),this.hide())}),this.editor.container.appendChild(this.tooltip)}checkCursorPosition(){let e=this.editor.textarea.selectionStart,n=this.editor.textarea.value,i=this.findLinkAtPosition(n,e);i?(!this.currentLink||this.currentLink.url!==i.url||this.currentLink.index!==i.index)&&this.show(i):this.scheduleHide()}findLinkAtPosition(e,n){let i=/\[([^\]]+)\]\(([^)]+)\)/g,o,r=0;for(;(o=i.exec(e))!==null;){let s=o.index,a=o.index+o[0].length;if(n>=s&&n<=a)return{text:o[1],url:o[2],index:r,start:s,end:a};r++}return null}async show(e){this.currentLink=e,this.cancelHide();let n=this.tooltip.querySelector(".overtype-link-tooltip-url");n.textContent=e.url,await this.positionTooltip(e),this.currentLink===e&&this.tooltip.classList.add("visible")}async positionTooltip(e){let n=this.findAnchorElement(e.index);if(!n)return;let i=n.getBoundingClientRect();if(!(i.width===0||i.height===0))try{let{x:o,y:r}=await Wt(n,this.tooltip,{strategy:"fixed",placement:"bottom",middleware:[Vt(8),Ut({padding:8}),qt()]});Object.assign(this.tooltip.style,{left:`${o}px`,top:`${r}px`,position:"fixed"})}catch(o){console.warn("Floating UI positioning failed:",o)}}findAnchorElement(e){return this.editor.preview.querySelector(`a[style*="--link-${e}"]`)}hide(){this.tooltip.classList.remove("visible"),this.currentLink=null,this.isTooltipHovered=!1}scheduleHide(){this.cancelHide(),this.hideTimeout=setTimeout(()=>this.hide(),300)}cancelHide(){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null)}destroy(){this.cancelHide(),this.visibilityChangeHandler&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null),this.tooltip&&this.tooltip.parentNode&&this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null,this.currentLink=null,this.isTooltipHovered=!1}};var Kt=` - - -`,Zt=` - - - -`,Qt=` - -`,Gt=` - -`,Jt=` - -`,Xt=` - - - -`,Yt=` - - - -`,en=` - - - - - - -`,tn=` - - - - - - - -`,nn=` - - -`,on=` - - - - - - -`,rn=` - - - -`,sn=` - - -`;var S={bold:{name:"bold",actionId:"toggleBold",icon:Kt,title:"Bold (Ctrl+B)",action:({editor:t})=>{rt(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},italic:{name:"italic",actionId:"toggleItalic",icon:Zt,title:"Italic (Ctrl+I)",action:({editor:t})=>{st(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},code:{name:"code",actionId:"toggleCode",icon:Yt,title:"Inline Code",action:({editor:t})=>{at(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},separator:{name:"separator"},link:{name:"link",actionId:"insertLink",icon:Xt,title:"Insert Link",action:({editor:t})=>{lt(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},h1:{name:"h1",actionId:"toggleH1",icon:Qt,title:"Heading 1",action:({editor:t})=>{ut(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},h2:{name:"h2",actionId:"toggleH2",icon:Gt,title:"Heading 2",action:({editor:t})=>{ht(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},h3:{name:"h3",actionId:"toggleH3",icon:Jt,title:"Heading 3",action:({editor:t})=>{ft(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},bulletList:{name:"bulletList",actionId:"toggleBulletList",icon:en,title:"Bullet List",action:({editor:t})=>{ct(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},orderedList:{name:"orderedList",actionId:"toggleNumberedList",icon:tn,title:"Numbered List",action:({editor:t})=>{pt(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},taskList:{name:"taskList",actionId:"toggleTaskList",icon:on,title:"Task List",action:({editor:t})=>{Ie&&(Ie(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0})))}},quote:{name:"quote",actionId:"toggleQuote",icon:nn,title:"Quote",action:({editor:t})=>{dt(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},upload:{name:"upload",actionId:"uploadFile",icon:rn,title:"Upload File",action:({editor:t})=>{var n,i;if(!((n=t.options.fileUpload)!=null&&n.enabled))return;let e=document.createElement("input");e.type="file",e.multiple=!0,((i=t.options.fileUpload.mimeTypes)==null?void 0:i.length)>0&&(e.accept=t.options.fileUpload.mimeTypes.join(",")),e.onchange=()=>{var r;if(!((r=e.files)!=null&&r.length))return;let o=new DataTransfer;for(let s of e.files)o.items.add(s);t._handleDataTransfer(o)},e.click()}},viewMode:{name:"viewMode",icon:sn,title:"View mode"}},ie=[S.bold,S.italic,S.code,S.separator,S.link,S.separator,S.h1,S.h2,S.h3,S.separator,S.bulletList,S.orderedList,S.taskList,S.separator,S.quote,S.separator,S.viewMode];function ze(t){let e={};return(t||[]).forEach(n=>{if(!n||n.name==="separator")return;let i=n.actionId||n.name;n.action&&(e[i]=n.action)}),e}function an(t){let e=t||ie;return Array.isArray(e)?e.map(n=>({name:(n==null?void 0:n.name)||null,actionId:(n==null?void 0:n.actionId)||(n==null?void 0:n.name)||null,icon:(n==null?void 0:n.icon)||null,title:(n==null?void 0:n.title)||null})):null}function ri(t,e){let n=an(t),i=an(e);if(n===null||i===null)return n!==i;if(n.length!==i.length)return!0;for(let o=0;o{if(r.overTypeInstance)return r.overTypeInstance.reinit(n),r.overTypeInstance;let s=Object.create(v.prototype);return s._init(r,n),r.overTypeInstance=s,v.instances.set(r,s),s})}_init(e,n={}){this.element=e,this.instanceTheme=n.theme||null,this.options=this._mergeOptions(n),this.instanceId=++v.instanceCount,this.initialized=!1,v.injectStyles(),v.initGlobalListeners();let i=e.querySelector(".overtype-container"),o=e.querySelector(".overtype-wrapper");i||o?this._recoverFromDOM(i,o):this._buildFromScratch(),this.instanceTheme==="auto"&&this.setTheme("auto"),this.shortcuts=new re(this),this._rebuildActionsMap(),this.linkTooltip=new He(this),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.textarea.scrollTop=this.preview.scrollTop,this.textarea.scrollLeft=this.preview.scrollLeft})}),this.initialized=!0,this.options.onChange&&this.options.onChange(this.getValue(),this)}_mergeOptions(e){let n={fontSize:"14px",lineHeight:1.6,fontFamily:'"SF Mono", SFMono-Regular, Menlo, Monaco, "Cascadia Code", Consolas, "Roboto Mono", "Noto Sans Mono", "Droid Sans Mono", "Ubuntu Mono", "DejaVu Sans Mono", "Liberation Mono", "Courier New", Courier, monospace',padding:"16px",mobile:{fontSize:"16px",padding:"12px",lineHeight:1.5},textareaProps:{},autofocus:!1,autoResize:!1,minHeight:"100px",maxHeight:null,placeholder:"Start typing...",value:"",onChange:null,onKeydown:null,onRender:null,showActiveLineRaw:!1,showStats:!1,toolbar:!1,toolbarButtons:null,statsFormatter:null,smartLists:!0,codeHighlighter:null,spellcheck:!1},{theme:i,colors:o,...r}=e;return{...n,...r}}_recoverFromDOM(e,n){if(e&&e.classList.contains("overtype-container"))this.container=e,this.wrapper=e.querySelector(".overtype-wrapper");else if(n){this.wrapper=n,this.container=document.createElement("div"),this.container.className="overtype-container";let i=this.instanceTheme||v.currentTheme||_,o=typeof i=="string"?i:i.name;if(o&&this.container.setAttribute("data-theme",o),this.instanceTheme){let r=typeof this.instanceTheme=="string"?V(this.instanceTheme):this.instanceTheme;if(r&&r.colors){let s=Q(r.colors);this.container.style.cssText+=s}}n.parentNode.insertBefore(this.container,n),this.container.appendChild(n)}if(!this.wrapper){e&&e.remove(),n&&n.remove(),this._buildFromScratch();return}if(this.textarea=this.wrapper.querySelector(".overtype-input"),this.preview=this.wrapper.querySelector(".overtype-preview"),!this.textarea||!this.preview){this.container.remove(),this._buildFromScratch();return}this.wrapper._instance=this,this.options.fontSize&&this.wrapper.style.setProperty("--instance-font-size",this.options.fontSize),this.options.lineHeight&&this.wrapper.style.setProperty("--instance-line-height",String(this.options.lineHeight)),this.options.padding&&this.wrapper.style.setProperty("--instance-padding",this.options.padding),this._configureTextarea(),this._applyOptions()}_buildFromScratch(){let e=this._extractContent();this.element.innerHTML="",this._createDOM(),(e||this.options.value)&&this.setValue(e||this.options.value),this._applyOptions()}_extractContent(){let e=this.element.querySelector(".overtype-input");return e?e.value:this.element.textContent||""}_createDOM(){this.container=document.createElement("div"),this.container.className="overtype-container";let e=this.instanceTheme||v.currentTheme||_,n=typeof e=="string"?e:e.name;if(n&&this.container.setAttribute("data-theme",n),this.instanceTheme){let i=typeof this.instanceTheme=="string"?V(this.instanceTheme):this.instanceTheme;if(i&&i.colors){let o=Q(i.colors);this.container.style.cssText+=o}}this.wrapper=document.createElement("div"),this.wrapper.className="overtype-wrapper",this.options.fontSize&&this.wrapper.style.setProperty("--instance-font-size",this.options.fontSize),this.options.lineHeight&&this.wrapper.style.setProperty("--instance-line-height",String(this.options.lineHeight)),this.options.padding&&this.wrapper.style.setProperty("--instance-padding",this.options.padding),this.wrapper._instance=this,this.textarea=document.createElement("textarea"),this.textarea.className="overtype-input",this.textarea.placeholder=this.options.placeholder,this._configureTextarea(),this.options.textareaProps&&Object.entries(this.options.textareaProps).forEach(([i,o])=>{i==="className"||i==="class"?this.textarea.className+=" "+o:i==="style"&&typeof o=="object"?Object.assign(this.textarea.style,o):this.textarea.setAttribute(i,o)}),this.preview=document.createElement("div"),this.preview.className="overtype-preview",this.preview.setAttribute("aria-hidden","true"),this.placeholderEl=document.createElement("div"),this.placeholderEl.className="overtype-placeholder",this.placeholderEl.setAttribute("aria-hidden","true"),this.placeholderEl.textContent=this.options.placeholder,this.wrapper.appendChild(this.textarea),this.wrapper.appendChild(this.preview),this.wrapper.appendChild(this.placeholderEl),this.container.appendChild(this.wrapper),this.options.showStats&&(this.statsBar=document.createElement("div"),this.statsBar.className="overtype-stats",this.container.appendChild(this.statsBar),this._updateStats()),this.element.appendChild(this.container),this.options.autoResize?this._setupAutoResize():this.container.classList.remove("overtype-auto-resize")}_configureTextarea(){this.textarea.setAttribute("autocomplete","off"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck",String(this.options.spellcheck)),this.textarea.setAttribute("data-gramm","false"),this.textarea.setAttribute("data-gramm_editor","false"),this.textarea.setAttribute("data-enable-grammarly","false")}_createToolbar(){var n;let e=this.options.toolbarButtons||ie;if((n=this.options.fileUpload)!=null&&n.enabled&&!e.some(i=>(i==null?void 0:i.name)==="upload")){let i=e.findIndex(o=>(o==null?void 0:o.name)==="viewMode");i!==-1?(e=[...e],e.splice(i,0,S.separator,S.upload)):e=[...e,S.separator,S.upload]}this.toolbar=new ke(this,{toolbarButtons:e}),this.toolbar.create(),this._toolbarSelectionListener=()=>{this.toolbar&&this.toolbar.updateButtonStates()},this._toolbarInputListener=()=>{this.toolbar&&this.toolbar.updateButtonStates()},this.textarea.addEventListener("selectionchange",this._toolbarSelectionListener),this.textarea.addEventListener("input",this._toolbarInputListener)}_cleanupToolbarListeners(){this._toolbarSelectionListener&&(this.textarea.removeEventListener("selectionchange",this._toolbarSelectionListener),this._toolbarSelectionListener=null),this._toolbarInputListener&&(this.textarea.removeEventListener("input",this._toolbarInputListener),this._toolbarInputListener=null)}_rebuildActionsMap(){var e;this.actionsById=ze(ie),this.options.toolbarButtons&&Object.assign(this.actionsById,ze(this.options.toolbarButtons)),(e=this.options.fileUpload)!=null&&e.enabled&&Object.assign(this.actionsById,ze([S.upload]))}_applyOptions(){this.options.autofocus&&this.textarea.focus(),this.options.autoResize?this.container.classList.contains("overtype-auto-resize")?this._updateAutoHeight():this._setupAutoResize():this.container.classList.remove("overtype-auto-resize"),this.options.toolbar&&!this.toolbar?this._createToolbar():!this.options.toolbar&&this.toolbar&&(this._cleanupToolbarListeners(),this.toolbar.destroy(),this.toolbar=null),this.placeholderEl&&(this.placeholderEl.textContent=this.options.placeholder),this.options.fileUpload&&!this.fileUploadInitialized?this._initFileUpload():!this.options.fileUpload&&this.fileUploadInitialized&&this._destroyFileUpload(),this.updatePreview()}_initFileUpload(){let e=this.options.fileUpload;if(!(!e||!e.enabled)){if(e.maxSize=e.maxSize||10*1024*1024,e.mimeTypes=e.mimeTypes||[],e.batch=e.batch||!1,!e.onInsertFile||typeof e.onInsertFile!="function"){console.warn("OverType: fileUpload.onInsertFile callback is required for file uploads.");return}this._fileUploadCounter=0,this._boundHandleFilePaste=this._handleFilePaste.bind(this),this._boundHandleFileDrop=this._handleFileDrop.bind(this),this._boundHandleDragOver=this._handleDragOver.bind(this),this.textarea.addEventListener("paste",this._boundHandleFilePaste),this.textarea.addEventListener("drop",this._boundHandleFileDrop),this.textarea.addEventListener("dragover",this._boundHandleDragOver),this.fileUploadInitialized=!0}}_handleFilePaste(e){var n,i;(i=(n=e==null?void 0:e.clipboardData)==null?void 0:n.files)!=null&&i.length&&(e.preventDefault(),this._handleDataTransfer(e.clipboardData))}_handleFileDrop(e){var n,i;(i=(n=e==null?void 0:e.dataTransfer)==null?void 0:n.files)!=null&&i.length&&(e.preventDefault(),this._handleDataTransfer(e.dataTransfer))}_handleDataTransfer(e){let n=[];for(let i of e.files){if(i.size>this.options.fileUpload.maxSize||this.options.fileUpload.mimeTypes.length>0&&!this.options.fileUpload.mimeTypes.includes(i.type))continue;let o=++this._fileUploadCounter,s=`${i.type.startsWith("image/")?"!":""}[Uploading ${i.name} (#${o})...]()`;if(this.insertAtCursor(`${s} -`),this.options.fileUpload.batch){n.push({file:i,placeholder:s});continue}this.options.fileUpload.onInsertFile(i).then(a=>{this.textarea.value=this.textarea.value.replace(s,a),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))},a=>{console.error("OverType: File upload failed",a),this.textarea.value=this.textarea.value.replace(s,"[Upload failed]()"),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))})}this.options.fileUpload.batch&&n.length>0&&this.options.fileUpload.onInsertFile(n.map(i=>i.file)).then(i=>{(Array.isArray(i)?i:[i]).forEach((r,s)=>{this.textarea.value=this.textarea.value.replace(n[s].placeholder,r)}),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))},i=>{console.error("OverType: File upload failed",i),n.forEach(({placeholder:o})=>{this.textarea.value=this.textarea.value.replace(o,"[Upload failed]()")}),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))})}_handleDragOver(e){e.preventDefault()}_destroyFileUpload(){this.textarea.removeEventListener("paste",this._boundHandleFilePaste),this.textarea.removeEventListener("drop",this._boundHandleFileDrop),this.textarea.removeEventListener("dragover",this._boundHandleDragOver),this._boundHandleFilePaste=null,this._boundHandleFileDrop=null,this._boundHandleDragOver=null,this.fileUploadInitialized=!1}insertAtCursor(e){let n=this.textarea.selectionStart,i=this.textarea.selectionEnd,o=!1;try{o=document.execCommand("insertText",!1,e)}catch(r){}if(!o){let r=this.textarea.value.slice(0,n),s=this.textarea.value.slice(i);this.textarea.value=r+e+s,this.textarea.setSelectionRange(n+e.length,n+e.length)}this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}updatePreview(){let e=this.textarea.value,n=this.textarea.selectionStart,i=this._getCurrentLine(e,n),o=this.container.dataset.mode==="preview",r=T.parse(e,i,this.options.showActiveLineRaw,this.options.codeHighlighter,o);this.preview.innerHTML=r,this.placeholderEl&&(this.placeholderEl.style.display=e?"none":""),this._applyCodeBlockBackgrounds(),this.options.showStats&&this.statsBar&&this._updateStats(),this.options.onChange&&this.initialized&&this.options.onChange(e,this),this.options.onRender&&this.options.onRender(this.preview,o?"preview":"normal",this)}_applyCodeBlockBackgrounds(){let e=this.preview.querySelectorAll(".code-fence");for(let n=0;nd.replace(/^ /,"")).join(` -`);document.execCommand?(this.textarea.setSelectionRange(i,o),document.execCommand("insertText",!1,l)):(this.textarea.value=s+l+c,this.textarea.selectionStart=i,this.textarea.selectionEnd=i+l.length)}else if(i!==o){let s=r.substring(0,i),a=r.substring(i,o),c=r.substring(o),l=a.split(` -`).map(d=>" "+d).join(` -`);document.execCommand?(this.textarea.setSelectionRange(i,o),document.execCommand("insertText",!1,l)):(this.textarea.value=s+l+c,this.textarea.selectionStart=i,this.textarea.selectionEnd=i+l.length)}else document.execCommand?document.execCommand("insertText",!1," "):(this.textarea.value=r.substring(0,i)+" "+r.substring(o),this.textarea.selectionStart=this.textarea.selectionEnd=i+2);this.textarea.dispatchEvent(new Event("input",{bubbles:!0}));return}if(e.key==="Enter"&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&this.options.smartLists&&this.handleSmartListContinuation()){e.preventDefault();return}!this.shortcuts.handleKeydown(e)&&this.options.onKeydown&&this.options.onKeydown(e,this)}handleSmartListContinuation(){let e=this.textarea,n=e.selectionStart,i=T.getListContext(e.value,n);return!i||!i.inList?!1:i.content.trim()===""&&n>=i.markerEndPos?(this.deleteListMarker(i),!0):(n>i.markerEndPos&&n{this.updateNumberedLists()},10)}updateNumberedLists(){let e=this.textarea.value,n=this.textarea.selectionStart,i=T.renumberLists(e);if(i!==e){let o=0,r=e.split(` -`),s=i.split(` -`),a=0;for(let p=0;pthis.getValue(),setValue:s=>this.setValue(s),event:n}),!0}catch(s){return console.error(`OverType: Action "${e}" error:`,s),this.wrapper.dispatchEvent(new CustomEvent("button-error",{detail:{actionId:e,error:s}})),!1}}getRenderedHTML(e={}){let n=this.getValue(),i=T.parse(n,-1,!1,this.options.codeHighlighter);return e.cleanHTML&&(i=i.replace(/.*?<\/span>/g,""),i=i.replace(/\sclass="(bullet-list|ordered-list|code-fence|hr-marker|blockquote|url-part)"/g,""),i=i.replace(/\sclass=""/g,"")),i}getPreviewHTML(){return this.preview.innerHTML}getCleanHTML(){return this.getRenderedHTML({cleanHTML:!0})}focus(){this.textarea.focus()}blur(){this.textarea.blur()}isInitialized(){return this.initialized}reinit(e={}){var o;let n=(o=this.options)==null?void 0:o.toolbarButtons;this.options=this._mergeOptions({...this.options,...e});let i=this.toolbar&&this.options.toolbar&&ri(n,this.options.toolbarButtons);this._rebuildActionsMap(),i&&(this._cleanupToolbarListeners(),this.toolbar.destroy(),this.toolbar=null,this._createToolbar()),this.fileUploadInitialized&&this._destroyFileUpload(),this.options.fileUpload&&this._initFileUpload(),this._applyOptions(),this.updatePreview()}showToolbar(){this.toolbar?this.toolbar.show():this._createToolbar()}hideToolbar(){this.toolbar&&this.toolbar.hide()}setTheme(e){if(v._autoInstances.delete(this),this.instanceTheme=e,e==="auto")v._autoInstances.add(this),v._startAutoListener(),this._applyResolvedTheme(Oe("auto"));else{let n=typeof e=="string"?V(e):e,i=typeof n=="string"?n:n.name;if(i&&this.container.setAttribute("data-theme",i),n&&n.colors){let o=Q(n.colors,n.previewColors);this.container.style.cssText+=o}this.updatePreview()}return v._stopAutoListener(),this}_applyResolvedTheme(e){let n=V(e);this.container.setAttribute("data-theme",e),n&&n.colors&&(this.container.style.cssText=Q(n.colors,n.previewColors)),this.updatePreview()}setCodeHighlighter(e){this.options.codeHighlighter=e,this.updatePreview()}_updateStats(){if(!this.statsBar)return;let e=this.textarea.value,n=e.split(` -`),i=e.length,o=e.split(/\s+/).filter(l=>l.length>0).length,r=this.textarea.selectionStart,a=e.substring(0,r).split(` -`),c=a.length,p=a[a.length-1].length+1;this.options.statsFormatter?this.statsBar.innerHTML=this.options.statsFormatter({chars:i,words:o,lines:n.length,line:c,column:p}):this.statsBar.innerHTML=` -
    - - ${i} chars, ${o} words, ${n.length} lines -
    -
    Line ${c}, Col ${p}
    - `}_setupAutoResize(){this.container.classList.add("overtype-auto-resize"),this.previousHeight=null,this._updateAutoHeight(),this.textarea.addEventListener("input",()=>this._updateAutoHeight()),window.addEventListener("resize",()=>this._updateAutoHeight())}_updateAutoHeight(){if(!this.options.autoResize)return;let e=this.textarea,n=this.preview,i=this.wrapper;if(this.container.dataset.mode==="preview"){i.style.removeProperty("height"),n.style.removeProperty("height"),n.style.removeProperty("overflow-y"),e.style.removeProperty("height"),e.style.removeProperty("overflow-y");return}let r=e.scrollTop;i.style.setProperty("height","auto","important"),e.style.setProperty("height","auto","important");let s=e.scrollHeight;if(this.options.minHeight){let p=parseInt(this.options.minHeight);s=Math.max(s,p)}let a="hidden";if(this.options.maxHeight){let p=parseInt(this.options.maxHeight);s>p&&(s=p,a="auto")}let c=s+"px";e.style.setProperty("height",c,"important"),e.style.setProperty("overflow-y",a,"important"),n.style.setProperty("height",c,"important"),n.style.setProperty("overflow-y",a,"important"),i.style.setProperty("height",c,"important"),e.scrollTop=r,n.scrollTop=r,this.previousHeight!==s&&(this.previousHeight=s)}showStats(e){this.options.showStats=e,e&&!this.statsBar?(this.statsBar=document.createElement("div"),this.statsBar.className="overtype-stats",this.container.appendChild(this.statsBar),this._updateStats()):e&&this.statsBar?this._updateStats():!e&&this.statsBar&&(this.statsBar.remove(),this.statsBar=null)}showNormalEditMode(){return this.container.dataset.mode="normal",this.updatePreview(),this._updateAutoHeight(),requestAnimationFrame(()=>{this.textarea.scrollTop=this.preview.scrollTop,this.textarea.scrollLeft=this.preview.scrollLeft}),this}showPlainTextarea(){if(this.container.dataset.mode="plain",this._updateAutoHeight(),this.toolbar){let e=this.container.querySelector('[data-action="toggle-plain"]');e&&(e.classList.remove("active"),e.title="Show markdown preview")}return this}showPreviewMode(){return this.container.dataset.mode="preview",this.updatePreview(),this._updateAutoHeight(),this}destroy(){if(v._autoInstances.delete(this),v._stopAutoListener(),this.fileUploadInitialized&&this._destroyFileUpload(),this.element.overTypeInstance=null,v.instances.delete(this.element),this.shortcuts&&this.shortcuts.destroy(),this.wrapper){let e=this.getValue();this.wrapper.remove(),this.element.textContent=e}this.initialized=!1}static init(e,n={}){return new v(e,n)}static initFromData(e,n={}){let i=document.querySelectorAll(e);return Array.from(i).map(o=>{let r={...n};for(let s of o.attributes)if(s.name.startsWith("data-ot-")){let c=s.name.slice(8).replace(/-([a-z])/g,(p,l)=>l.toUpperCase());r[c]=v._parseDataValue(s.value)}return new v(o,r)[0]})}static _parseDataValue(e){return e==="true"?!0:e==="false"?!1:e==="null"?null:e!==""&&!isNaN(Number(e))?Number(e):e}static getInstance(e){return e.overTypeInstance||v.instances.get(e)||null}static destroyAll(){document.querySelectorAll("[data-overtype-instance]").forEach(n=>{let i=v.getInstance(n);i&&i.destroy()})}static injectStyles(e=!1){if(v.stylesInjected&&!e)return;let n=document.querySelector("style.overtype-styles");n&&n.remove();let i=v.currentTheme||_,o=Ze({theme:i}),r=document.createElement("style");r.className="overtype-styles",r.textContent=o,document.head.appendChild(r),v.stylesInjected=!0}static setTheme(e,n=null){if(v._globalAutoTheme=!1,v._globalAutoCustomColors=null,e==="auto"){v._globalAutoTheme=!0,v._globalAutoCustomColors=n,v._startAutoListener(),v._applyGlobalTheme(Oe("auto"),n);return}v._stopAutoListener(),v._applyGlobalTheme(e,n)}static _applyGlobalTheme(e,n=null){let i=typeof e=="string"?V(e):e;n&&(i=Ke(i,n)),v.currentTheme=i,v.injectStyles(!0);let o=typeof i=="string"?i:i.name;document.querySelectorAll(".overtype-container").forEach(r=>{o&&r.setAttribute("data-theme",o)}),document.querySelectorAll(".overtype-wrapper").forEach(r=>{r.closest(".overtype-container")||o&&r.setAttribute("data-theme",o);let s=r._instance;s&&s.updatePreview()}),document.querySelectorAll("overtype-editor").forEach(r=>{o&&typeof r.setAttribute=="function"&&r.setAttribute("theme",o),typeof r.refreshTheme=="function"&&r.refreshTheme()})}static _startAutoListener(){v._autoMediaQuery||window.matchMedia&&(v._autoMediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),v._autoMediaListener=e=>{let n=e.matches?"cave":"solar";v._globalAutoTheme&&v._applyGlobalTheme(n,v._globalAutoCustomColors),v._autoInstances.forEach(i=>i._applyResolvedTheme(n))},v._autoMediaQuery.addEventListener("change",v._autoMediaListener))}static _stopAutoListener(){v._autoInstances.size>0||v._globalAutoTheme||v._autoMediaQuery&&(v._autoMediaQuery.removeEventListener("change",v._autoMediaListener),v._autoMediaQuery=null,v._autoMediaListener=null)}static setCodeHighlighter(e){T.setCodeHighlighter(e),document.querySelectorAll(".overtype-wrapper").forEach(n=>{let i=n._instance;i&&i.updatePreview&&i.updatePreview()}),document.querySelectorAll("overtype-editor").forEach(n=>{if(typeof n.getEditor=="function"){let i=n.getEditor();i&&i.updatePreview&&i.updatePreview()}})}static setCustomSyntax(e){T.setCustomSyntax(e),document.querySelectorAll(".overtype-wrapper").forEach(n=>{let i=n._instance;i&&i.updatePreview&&i.updatePreview()}),document.querySelectorAll("overtype-editor").forEach(n=>{if(typeof n.getEditor=="function"){let i=n.getEditor();i&&i.updatePreview&&i.updatePreview()}})}static initGlobalListeners(){v.globalListenersInitialized||(document.addEventListener("input",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let n=e.target.closest(".overtype-wrapper"),i=n==null?void 0:n._instance;i&&i.handleInput(e)}}),document.addEventListener("keydown",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let n=e.target.closest(".overtype-wrapper"),i=n==null?void 0:n._instance;i&&i.handleKeydown(e)}}),document.addEventListener("scroll",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let n=e.target.closest(".overtype-wrapper"),i=n==null?void 0:n._instance;i&&i.handleScroll(e)}},!0),document.addEventListener("selectionchange",e=>{let n=document.activeElement;if(n&&n.classList.contains("overtype-input")){let i=n.closest(".overtype-wrapper"),o=i==null?void 0:i._instance;o&&(o.options.showStats&&o.statsBar&&o._updateStats(),clearTimeout(o._selectionTimeout),o._selectionTimeout=setTimeout(()=>{o.updatePreview()},50))}}),v.globalListenersInitialized=!0)}};C(v,"instances",new WeakMap),C(v,"stylesInjected",!1),C(v,"globalListenersInitialized",!1),C(v,"instanceCount",0),C(v,"_autoMediaQuery",null),C(v,"_autoMediaListener",null),C(v,"_autoInstances",new Set),C(v,"_globalAutoTheme",!1),C(v,"_globalAutoCustomColors",null);var z=v;z.MarkdownParser=T;z.ShortcutsManager=re;z.themes={solar:_,cave:V("cave")};z.getTheme=V;z.currentTheme=_;var si=z;return mn(ai);})(); -/** - * OverType - A lightweight markdown editor library with perfect WYSIWYG alignment - * @version 1.0.0 - * @license MIT - */ - -if (typeof window !== "undefined" && typeof window.document !== "undefined") { - // Extract exports BEFORE reassigning OverType (var OverType is window.OverType) - window.toolbarButtons = OverType.toolbarButtons; - window.defaultToolbarButtons = OverType.defaultToolbarButtons; - window.OverType = OverType.default ? OverType.default : OverType; -} - diff --git a/app/public/partage/index.php b/app/public/partage/index.php index c0ef328..9c8a095 100644 --- a/app/public/partage/index.php +++ b/app/public/partage/index.php @@ -396,15 +396,16 @@ function renderShareLinkForm(string $slug, array $link): void - - - - - - - - - + + + + + + + + + +
    diff --git a/app/src/Controllers/TfeController.php b/app/src/Controllers/TfeController.php index 36ddd33..492da33 100644 --- a/app/src/Controllers/TfeController.php +++ b/app/src/Controllers/TfeController.php @@ -133,6 +133,7 @@ class TfeController // Layout 'currentNav' => '', 'extraCss' => ['/assets/css/tfe.css'], + 'extraJs' => ['/assets/js/app/access-request.js'], 'bodyClass' => 'tfe-body', ]; } diff --git a/app/templates/admin/acces.php b/app/templates/admin/acces.php index bb306b6..27fe7ef 100644 --- a/app/templates/admin/acces.php +++ b/app/templates/admin/acces.php @@ -1455,6 +1455,19 @@ +%%%%%%% diff from: somsyvxz 249f7943 "Bulk bar anti-shift, tags icons, AP no-wrap, credits reorder" (rebased revision) +\\\\\\\ to: npqqxmut d463ff53 "fix: harden security based on pentest scan findings" (rebased revision) ++ $linkName = $link['name'] ?? ''; +++ $linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : ''; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff from: npqqxmut d463ff53 "fix: harden security based on pentest scan findings" (rebased revision) +\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ to: somsyvxz 249f7943 "Bulk bar anti-shift, tags icons, AP no-wrap, credits reorder" (rebased revision) +- $linkName = $link['name'] ?? ''; +- $linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : ''; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff from: somsyvxz 14a3cd10 "Bulk bar anti-shift, tags icons, AP no-wrap, credits reorder" (rebase destination) +\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ to: okvqnxxl ce3e339b "refactor: extract inline JS into app/ modules, remove dead overtype-webcomponent" (rebased revision) + $linkName = $link['name'] ?? ''; + $linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : ''; + $linkLockedYear = $link['locked_year'] ?? null; ++%%%%%%% diff from: somsyvxz 249f7943 "Bulk bar anti-shift, tags icons, AP no-wrap, credits reorder" (rebased revision) ++\\\\\\\ to: okvqnxxl 4c0538fc "refactor: extract inline JS into app/ modules, remove dead overtype-webcomponent" (rebased revision) +++ $linkName = $link['name'] ?? ''; ++ $linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : ''; ?> @@ -1904,14 +1917,6 @@ document.getElementById('open-create-dialog').addEventListener('click', () => { document.getElementById('create-dialog').showModal(); }); -function copyUrl(id) { - const input = document.getElementById('url-' + id); - navigator.clipboard.writeText(input.value).then(() => { - const btn = event.target.closest('button'); - if (btn) { const orig = btn.getAttribute('title') || ''; btn.setAttribute('title', '✓ Copié'); setTimeout(() => btn.setAttribute('title', orig), 1200); } - }); -} - function openEditDialog(id, name, hasPassword, expiresVal) { document.getElementById('edit-link-id').value = id; document.getElementById('edit-name').value = name || ''; diff --git a/app/templates/admin/contenus.php b/app/templates/admin/contenus.php index af9a969..4b64efd 100644 --- a/app/templates/admin/contenus.php +++ b/app/templates/admin/contenus.php @@ -390,7 +390,7 @@ document.addEventListener('htmx:afterSwap', function(evt) { diff --git a/app/templates/admin/footer.php b/app/templates/admin/footer.php index 925d2cc..f19f5f0 100644 --- a/app/templates/admin/footer.php +++ b/app/templates/admin/footer.php @@ -13,7 +13,7 @@ - + + diff --git a/app/templates/admin/system.php b/app/templates/admin/system.php index 4d627d6..c54df8f 100644 --- a/app/templates/admin/system.php +++ b/app/templates/admin/system.php @@ -111,55 +111,4 @@
    - - + diff --git a/app/templates/partials/form/language-search.php b/app/templates/partials/form/language-search.php index 6e3054e..f84526a 100644 --- a/app/templates/partials/form/language-search.php +++ b/app/templates/partials/form/language-search.php @@ -31,7 +31,7 @@ $maxLanguages = $maxLanguages ?? 10; $required = $required ?? false; $langCount = count($selectedLanguages); ?> -
    +
    *' : '' ?>
    @@ -79,183 +79,24 @@ $langCount = count($selectedLanguages);
    - - -
    +
    *' : '' ?>
    @@ -81,171 +81,5 @@ $belowMin = $required && $tagCount < $minTags;
    - - - - - +