{"version":3,"sources":["webpack:///./node_modules/cocoon-js-vanilla/index.js","webpack:///./app/javascript/packs/public.jsx","webpack:///./app/javascript/mastodon/load_keyboard_extensions.js"],"names":["document","addEventListener","cocoonElementCounter","createNewID","Date","getTime","newcontentBraced","id","newcontentUnderscored","cocoonAddFields","e","target","preventDefault","stopPropagation","thisNode","assoc","getAttribute","assocs","content","insertionMethod","insertionNode","insertionTraversal","count","parseInt","regexpBraced","RegExp","regexpUnderscored","newId","newContent","replace","newContents","originalEvent","isNaN","Math","max","push","insertionNodeElem","console","warn","querySelector","parentNode","getInsertionNodeElem","length","forEach","node","i","contentNode","beforeInsert","CustomEvent","bubbles","cancelable","detail","dispatchEvent","defaultPrevented","htmlMapping","before","prepend","append","after","htmlMethod","addedContent","insertAdjacentHTML","previousElementSibling","firstElementChild","lastElementChild","nextElementSibling","afterInsert","cocoonRemoveFields","wrapperClass","nodeToDelete","closest","triggerNode","beforeRemove","timeout","setTimeout","classList","contains","parentElement","removeChild","elem","selector","sibling","matches","cocoonGetPreviousSibling","value","style","display","afterRemove","this","start","messages","defineMessages","usernameTaken","defaultMessage","passwordExceedsLength","passwordDoesNotMatch","loaded","localeData","getLocale","locale","documentElement","lang","dateTimeFormat","Intl","DateTimeFormat","year","month","day","hour","minute","dateFormat","timeFormat","timeStyle","hour12","formatMessage","_ref","values","IntlMessageFormat","format","call","querySelectorAll","innerHTML","emojify","datetime","formattedDate","title","textContent","todayFormat","formattedContent","date","today","getDate","getMonth","getFullYear","isToday","formattedTime","time","now","timeGiven","includes","timeAgoString","formatDate","options","reactComponents","then","_ref2","default","MediaContainer","component","children","child","createElement","createRoot","render","_jsx","components","body","appendChild","catch","error","delegate","_throttle","_ref3","axios","get","params","acct","setCustomValidity","leading","trailing","password","getElementById","confirmation","maxLength","statusEl","dataset","spoiler","spoilerLink","message","window","data","parent","type","ready","postMessage","height","getElementsByTagName","scrollHeight","_ref4","avatar","file","files","url","URL","createObjectURL","originalSrc","src","_ref5","focus","select","setSelectionRange","_ref6","input","oldReadOnly","readonly","execCommand","blur","add","remove","err","toggleSidebar","sidebar","toggleButton","overflow","setAttribute","toggle","key","_ref7","_ref8","field","loadPolyfills","loadLocale","test","navigator","userAgent","arrowKeyNav","register","Promise","resolve"],"mappings":"8EAAAA,SAASC,iBAAiB,oBAAoB,WAC5C,IAAIC,EAAuB,EACvBC,EAAc,WAChB,OAAO,IAAIC,MAAOC,UAAYH,GAChC,EACII,EAAmB,SAAUC,GAC/B,MAAO,IAAMA,EAAK,KACpB,EACIC,EAAwB,SAAUD,GACpC,MAAO,IAAMA,EAAK,KACpB,EA+BIE,EAAkB,SAAUC,EAAGC,GACjCD,EAAEE,iBACFF,EAAEG,kBACF,IAAIC,EAAWH,EACXI,EAAQD,EAASE,aAAa,oBAC9BC,EAASH,EAASE,aAAa,qBAC/BE,EAAUJ,EAASE,aAAa,uCAChCG,EAAkBL,EAASE,aAAa,sCAAwCF,EAASE,aAAa,wCAA0C,SAChJI,EAAgBN,EAASE,aAAa,mCACtCK,EAAqBP,EAASE,aAAa,wCAC3CM,EAAQC,SAAST,EAASE,aAAa,cAAe,IACtDQ,EAAe,IAAIC,OAAO,UAAYV,EAAQ,cAAe,KAC7DW,EAAoB,IAAID,OAAO,QAAUV,EAAQ,UAAW,KAC5DY,EAAQxB,IACRyB,EAAaV,EAAQW,QAAQL,EAAclB,EAAiBqB,IAC5DG,EAAc,GACdC,EAAgBrB,EAUpB,IATIkB,IAAeV,IACjBM,EAAe,IAAIC,OAAO,UAAYR,EAAS,cAAe,KAC9DS,EAAoB,IAAID,OAAO,QAAUR,EAAS,UAAW,KAC7DW,EAAaV,EAAQW,QAAQL,EAAclB,EAAiBqB,KAG9DG,EAAc,CADdF,EAAaA,EAAWC,QAAQH,EAAmBlB,EAAsBmB,KAEzEL,EAAQU,MAAMV,GAAS,EAAIW,KAAKC,IAAIZ,EAAO,GAC3CA,GAAS,EACFA,GACLK,EAAQxB,IAERyB,GADAA,EAAaV,EAAQW,QAAQL,E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VA,EAAE8M,KAAyB,UAAV9M,EAAE8M,MACrB9M,EAAEE,iBACFsM,IACF,IAGFlD,mBAAShK,SAAU,gBAAiB,aAAayN,IAAA,IAAC,OAAE9M,GAAQ8M,EAAA,OAAK9M,EAAOyL,IAAMzL,EAAOK,aAAa,gBAAgB,IAClHgJ,mBAAShK,SAAU,gBAAiB,YAAY0N,IAAA,IAAC,OAAE/M,GAAQ+M,EAAA,OAAK/M,EAAOyL,IAAMzL,EAAOK,aAAa,cAAc,IAI/GgJ,mBAAShK,SAAU,mCAAoC,UAAU,KAC/D,CAAC,eAAgB,wBAAyB,4BAA6B,sCAAsC2C,SAAQpC,IACnH,MAAMoN,EAAQ3N,SAAS2K,eAAepK,GAClCoN,IACFA,EAAMvI,MAAQ,GAChB,GACA,IAOJwI,cACG5E,KAAK6E,KACL7E,MANH,WACEuC,YAAMvF,EACR,IAKGgD,MClRY,WACb,MAAI,QAAQ8E,KAAKC,UAAUC,WAJpB,iCAK6BhF,MAAKiF,IACrCA,EAAYC,UAAU,IAGnBC,QAAQC,SACjB,ID4QGtE,OAAMC,IACL1H,QAAQ0H,MAAMA,EAAM,G","file":"js/public-17088b5107d0a16215d0.chunk.js","sourcesContent":["document.addEventListener('DOMContentLoaded', function () {\n var cocoonElementCounter = 0;\n var createNewID = function () {\n return new Date().getTime() + cocoonElementCounter++;\n };\n var newcontentBraced = function (id) {\n return '[' + id + ']$1';\n };\n var newcontentUnderscored = function (id) {\n return '_' + id + '_$1';\n };\n var getInsertionNodeElem = function (insertionNode, insertionTraversal, thisNode) {\n if (!insertionNode) {\n return thisNode.parentNode;\n }\n if (typeof insertionNode === 'function') {\n if (insertionTraversal) {\n console.warn('association-insertion-traversal is ignored, because association-insertion-node is given as a function.');\n }\n return insertionNode(thisNode);\n }\n if (typeof insertionNode === 'string') {\n if (insertionTraversal) {\n return thisNode[insertionTraversal](insertionNode);\n } else {\n return insertionNode === 'this' ? thisNode : document.querySelector(insertionNode);\n }\n }\n };\n var cocoonDetach = function (node) {\n return node.parentElement.removeChild(node);\n };\n var cocoonGetPreviousSibling = function (elem, selector) {\n var sibling = elem.previousElementSibling;\n if (!selector) return sibling;\n while (sibling) {\n var match = sibling.matches(selector);\n if (match) return sibling;\n sibling = sibling.previousElementSibling;\n }\n };\n var cocoonAddFields = function (e, target) {\n e.preventDefault();\n e.stopPropagation();\n var thisNode = target;\n var assoc = thisNode.getAttribute('data-association');\n var assocs = thisNode.getAttribute('data-associations');\n var content = thisNode.getAttribute('data-association-insertion-template');\n var insertionMethod = thisNode.getAttribute('data-association-insertion-method') || thisNode.getAttribute('data-association-insertion-position') || 'before';\n var insertionNode = thisNode.getAttribute('data-association-insertion-node');\n var insertionTraversal = thisNode.getAttribute('data-association-insertion-traversal');\n var count = parseInt(thisNode.getAttribute('data-count'), 10);\n var regexpBraced = new RegExp('\\\\[new_' + assoc + '\\\\](.*?\\\\s)', 'g');\n var regexpUnderscored = new RegExp('_new_' + assoc + '_(\\\\w*)', 'g');\n var newId = createNewID();\n var newContent = content.replace(regexpBraced, newcontentBraced(newId));\n var newContents = [];\n var originalEvent = e;\n if (newContent === content) {\n regexpBraced = new RegExp('\\\\[new_' + assocs + '\\\\](.*?\\\\s)', 'g');\n regexpUnderscored = new RegExp('_new_' + assocs + '_(\\\\w*)', 'g');\n newContent = content.replace(regexpBraced, newcontentBraced(newId));\n }\n newContent = newContent.replace(regexpUnderscored, newcontentUnderscored(newId));\n newContents = [newContent];\n count = isNaN(count) ? 1 : Math.max(count, 1);\n count -= 1;\n while (count) {\n newId = createNewID();\n newContent = content.replace(regexpBraced, newcontentBraced(newId));\n newContent = newContent.replace(regexpUnderscored, newcontentUnderscored(newId));\n newContents.push(newContent);\n count -= 1;\n }\n var insertionNodeElem = getInsertionNodeElem(insertionNode, insertionTraversal, thisNode);\n if (!insertionNodeElem || insertionNodeElem.length === 0) {\n console.warn(\"Couldn't find the element to insert the template. Make sure your `data-association-insertion-*` on `link_to_add_association` is correct.\");\n }\n newContents.forEach(function (node, i) {\n var contentNode = node;\n var beforeInsert = new CustomEvent('cocoon:before-insert', {\n bubbles: true,\n cancelable: true,\n detail: [contentNode, originalEvent]\n });\n insertionNodeElem.dispatchEvent(beforeInsert);\n if (!beforeInsert.defaultPrevented) {\n // allow any of the jquery dom manipulation methods (after, before, append, prepend, etc)\n // to be called on the node. allows the insertion node to be the parent of the inserted\n // code and doesn't force it to be a sibling like after/before does. default: 'before'\n var htmlMapping = {\n before: 'beforebegin',\n prepend: 'afterbegin',\n append: 'beforeend',\n after: 'afterend'\n };\n var htmlMethod = htmlMapping[insertionMethod];\n var addedContent = insertionNodeElem.insertAdjacentHTML(htmlMethod, contentNode);\n if (htmlMethod === htmlMapping.before) {\n addedContent = insertionNodeElem.previousElementSibling;\n } else if (htmlMethod === htmlMapping.prepend) {\n addedContent = insertionNodeElem.firstElementChild;\n } else if (htmlMethod === htmlMapping.append) {\n addedContent = insertionNodeElem.lastElementChild;\n } else if (htmlMethod === htmlMapping.after) {\n addedContent = insertionNodeElem.nextElementSibling;\n }\n var afterInsert = new CustomEvent('cocoon:after-insert', {\n bubbles: true,\n detail: [contentNode, originalEvent, addedContent]\n });\n insertionNodeElem.dispatchEvent(afterInsert);\n }\n });\n };\n var cocoonRemoveFields = function (e, target) {\n var thisNode = target;\n var wrapperClass = thisNode.getAttribute('data-wrapper-class') || 'nested-fields';\n var nodeToDelete = thisNode.closest('.' + wrapperClass);\n var triggerNode = nodeToDelete.parentNode;\n var originalEvent = e;\n e.preventDefault();\n e.stopPropagation();\n var beforeRemove = new CustomEvent('cocoon:before-remove', {\n bubbles: true,\n cancelable: true,\n detail: [nodeToDelete, originalEvent]\n });\n triggerNode.dispatchEvent(beforeRemove);\n if (!beforeRemove.defaultPrevented) {\n var timeout = triggerNode.getAttribute('data-remove-timeout') || 0;\n setTimeout(function () {\n if (thisNode.classList.contains('dynamic')) {\n cocoonDetach(nodeToDelete);\n } else {\n var hiddenInput = cocoonGetPreviousSibling(thisNode, 'input[type=hidden]');\n hiddenInput.value = '1';\n nodeToDelete.style.display = 'none';\n }\n var afterRemove = new CustomEvent('cocoon:after-remove', {\n bubbles: true,\n detail: [nodeToDelete, originalEvent]\n });\n triggerNode.dispatchEvent(afterRemove);\n }, timeout);\n }\n };\n document.addEventListener('click', function (e) {\n for (var target = e.target; target && target !== this; target = target.parentNode) {\n if (target.matches('.add_fields')) {\n cocoonAddFields(e, target);\n return;\n }\n if (target.matches('.remove_fields')) {\n cocoonRemoveFields(e, target);\n return;\n }\n }\n }, false);\n});\n\n// TODO - Test this\n// document.addEventListener(\"DOMContentLoaded page:load turbolinks:load\", function () {\n// var destroyedFields = document.querySelectorAll(\".remove_fields.existing.destroyed\");\n// Array.prototype.forEach.call(destroyedFields, function (el) {\n// var wrapperClass = el.getAttribute(\"data-wrapper-class\") || \"nested-fields\";\n// el.closest(\".\" + wrapperClass).style.display = \"none\";\n// });\n// });","import { createRoot } from 'react-dom/client';\n\nimport './public-path';\n\nimport { IntlMessageFormat } from 'intl-messageformat';\nimport { defineMessages } from 'react-intl';\n\nimport { delegate } from '@rails/ujs';\nimport axios from 'axios';\nimport { throttle } from 'lodash';\n\nimport { start } from '../mastodon/common';\nimport { timeAgoString } from '../mastodon/components/relative_timestamp';\nimport emojify from '../mastodon/features/emoji/emoji';\nimport loadKeyboardExtensions from '../mastodon/load_keyboard_extensions';\nimport { loadLocale, getLocale } from '../mastodon/locales';\nimport { loadPolyfills } from '../mastodon/polyfills';\nimport ready from '../mastodon/ready';\n\nimport 'cocoon-js-vanilla';\n\nstart();\n\nconst messages = defineMessages({\n usernameTaken: { id: 'username.taken', defaultMessage: 'That username is taken. Try another' },\n passwordExceedsLength: { id: 'password_confirmation.exceeds_maxlength', defaultMessage: 'Password confirmation exceeds the maximum password length' },\n passwordDoesNotMatch: { id: 'password_confirmation.mismatching', defaultMessage: 'Password confirmation does not match' },\n});\n\nwindow.addEventListener('message', e => {\n const data = e.data || {};\n\n if (!window.parent || data.type !== 'setHeight') {\n return;\n }\n\n ready(() => {\n window.parent.postMessage({\n type: 'setHeight',\n id: data.id,\n height: document.getElementsByTagName('html')[0].scrollHeight,\n }, '*');\n });\n});\n\nfunction loaded() {\n const { messages: localeData } = getLocale();\n\n const locale = document.documentElement.lang;\n\n const dateTimeFormat = new Intl.DateTimeFormat(locale, {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n });\n\n const dateFormat = new Intl.DateTimeFormat(locale, {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n timeFormat: false,\n });\n\n const timeFormat = new Intl.DateTimeFormat(locale, {\n timeStyle: 'short',\n hour12: false,\n });\n\n const formatMessage = ({ id, defaultMessage }, values) => {\n const messageFormat = new IntlMessageFormat(localeData[id] || defaultMessage, locale);\n return messageFormat.format(values);\n };\n\n [].forEach.call(document.querySelectorAll('.emojify'), (content) => {\n content.innerHTML = emojify(content.innerHTML);\n });\n\n [].forEach.call(document.querySelectorAll('time.formatted'), (content) => {\n const datetime = new Date(content.getAttribute('datetime'));\n const formattedDate = dateTimeFormat.format(datetime);\n\n content.title = formattedDate;\n content.textContent = formattedDate;\n });\n\n const isToday = date => {\n const today = new Date();\n\n return date.getDate() === today.getDate() &&\n date.getMonth() === today.getMonth() &&\n date.getFullYear() === today.getFullYear();\n };\n const todayFormat = new IntlMessageFormat(localeData['relative_format.today'] || 'Today at {time}', locale);\n\n [].forEach.call(document.querySelectorAll('time.relative-formatted'), (content) => {\n const datetime = new Date(content.getAttribute('datetime'));\n\n let formattedContent;\n\n if (isToday(datetime)) {\n const formattedTime = timeFormat.format(datetime);\n\n formattedContent = todayFormat.format({ time: formattedTime });\n } else {\n formattedContent = dateFormat.format(datetime);\n }\n\n content.title = formattedContent;\n content.textContent = formattedContent;\n });\n\n [].forEach.call(document.querySelectorAll('time.time-ago'), (content) => {\n const datetime = new Date(content.getAttribute('datetime'));\n const now = new Date();\n\n const timeGiven = content.getAttribute('datetime').includes('T');\n content.title = timeGiven ? dateTimeFormat.format(datetime) : dateFormat.format(datetime);\n content.textContent = timeAgoString({\n formatMessage,\n formatDate: (date, options) => (new Intl.DateTimeFormat(locale, options)).format(date),\n }, datetime, now, now.getFullYear(), timeGiven);\n });\n\n const reactComponents = document.querySelectorAll('[data-component]');\n\n if (reactComponents.length > 0) {\n import(/* webpackChunkName: \"containers/media_container\" */ '../mastodon/containers/media_container')\n .then(({ default: MediaContainer }) => {\n [].forEach.call(reactComponents, (component) => {\n [].forEach.call(component.children, (child) => {\n component.removeChild(child);\n });\n });\n\n const content = document.createElement('div');\n\n const root = createRoot(content);\n root.render();\n document.body.appendChild(content);\n })\n .catch(error => {\n console.error(error);\n });\n }\n\n delegate(document, '#user_account_attributes_username', 'input', throttle(({ target }) => {\n if (target.value && target.value.length > 0) {\n axios.get('/api/v1/accounts/lookup', { params: { acct: target.value } }).then(() => {\n target.setCustomValidity(formatMessage(messages.usernameTaken));\n }).catch(() => {\n target.setCustomValidity('');\n });\n } else {\n target.setCustomValidity('');\n }\n }, 500, { leading: false, trailing: true }));\n\n delegate(document, '#user_password,#user_password_confirmation', 'input', () => {\n const password = document.getElementById('user_password');\n const confirmation = document.getElementById('user_password_confirmation');\n if (!confirmation) return;\n\n if (confirmation.value && confirmation.value.length > password.maxLength) {\n confirmation.setCustomValidity(formatMessage(messages.passwordExceedsLength));\n } else if (password.value && password.value !== confirmation.value) {\n confirmation.setCustomValidity(formatMessage(messages.passwordDoesNotMatch));\n } else {\n confirmation.setCustomValidity('');\n }\n });\n\n delegate(document, '.status__content__spoiler-link', 'click', function() {\n const statusEl = this.parentNode.parentNode;\n\n if (statusEl.dataset.spoiler === 'expanded') {\n statusEl.dataset.spoiler = 'folded';\n this.textContent = (new IntlMessageFormat(localeData['status.show_more'] || 'Show more', locale)).format();\n } else {\n statusEl.dataset.spoiler = 'expanded';\n this.textContent = (new IntlMessageFormat(localeData['status.show_less'] || 'Show less', locale)).format();\n }\n\n return false;\n });\n\n [].forEach.call(document.querySelectorAll('.status__content__spoiler-link'), (spoilerLink) => {\n const statusEl = spoilerLink.parentNode.parentNode;\n const message = (statusEl.dataset.spoiler === 'expanded') ? (localeData['status.show_less'] || 'Show less') : (localeData['status.show_more'] || 'Show more');\n spoilerLink.textContent = (new IntlMessageFormat(message, locale)).format();\n });\n}\n\ndelegate(document, '#edit_profile input[type=file]', 'change', ({ target }) => {\n const avatar = document.getElementById(target.id + '-preview');\n const [file] = target.files || [];\n const url = file ? URL.createObjectURL(file) : avatar.dataset.originalSrc;\n\n avatar.src = url;\n});\n\ndelegate(document, '.input-copy input', 'click', ({ target }) => {\n target.focus();\n target.select();\n target.setSelectionRange(0, target.value.length);\n});\n\ndelegate(document, '.input-copy button', 'click', ({ target }) => {\n const input = target.parentNode.querySelector('.input-copy__wrapper input');\n\n const oldReadOnly = input.readonly;\n\n input.readonly = false;\n input.focus();\n input.select();\n input.setSelectionRange(0, input.value.length);\n\n try {\n if (document.execCommand('copy')) {\n input.blur();\n target.parentNode.classList.add('copied');\n\n setTimeout(() => {\n target.parentNode.classList.remove('copied');\n }, 700);\n }\n } catch (err) {\n console.error(err);\n }\n\n input.readonly = oldReadOnly;\n});\n\nconst toggleSidebar = () => {\n const sidebar = document.querySelector('.sidebar ul');\n const toggleButton = document.querySelector('.sidebar__toggle__icon');\n\n if (sidebar.classList.contains('visible')) {\n document.body.style.overflow = null;\n toggleButton.setAttribute('aria-expanded', 'false');\n } else {\n document.body.style.overflow = 'hidden';\n toggleButton.setAttribute('aria-expanded', 'true');\n }\n\n toggleButton.classList.toggle('active');\n sidebar.classList.toggle('visible');\n};\n\ndelegate(document, '.sidebar__toggle__icon', 'click', () => {\n toggleSidebar();\n});\n\ndelegate(document, '.sidebar__toggle__icon', 'keydown', e => {\n if (e.key === ' ' || e.key === 'Enter') {\n e.preventDefault();\n toggleSidebar();\n }\n});\n\ndelegate(document, '.custom-emoji', 'mouseover', ({ target }) => target.src = target.getAttribute('data-original'));\ndelegate(document, '.custom-emoji', 'mouseout', ({ target }) => target.src = target.getAttribute('data-static'));\n\n// Empty the honeypot fields in JS in case something like an extension\n// automatically filled them.\ndelegate(document, '#registration_new_user,#new_user', 'submit', () => {\n ['user_website', 'user_confirm_password', 'registration_user_website', 'registration_user_confirm_password'].forEach(id => {\n const field = document.getElementById(id);\n if (field) {\n field.value = '';\n }\n });\n});\n\nfunction main() {\n ready(loaded);\n}\n\nloadPolyfills()\n .then(loadLocale)\n .then(main)\n .then(loadKeyboardExtensions)\n .catch(error => {\n console.error(error);\n });\n","// On KaiOS, we may not be able to use a mouse cursor or navigate using Tab-based focus, so we install\n// special left/right focus navigation keyboard listeners, at least on public pages (i.e. so folks\n// can at least log in using KaiOS devices).\n\nfunction importArrowKeyNavigation() {\n return import(/* webpackChunkName: \"arrow-key-navigation\" */ 'arrow-key-navigation');\n}\n\nexport default function loadKeyboardExtensions() {\n if (/KAIOS/.test(navigator.userAgent)) {\n return importArrowKeyNavigation().then(arrowKeyNav => {\n arrowKeyNav.register();\n });\n }\n return Promise.resolve();\n}\n"],"sourceRoot":""}