{"version":3,"sources":["webpack:///./app/javascript/packs/public.jsx","webpack:///./app/javascript/mastodon/load_keyboard_extensions.js","webpack:///./node_modules/cocoon-js-vanilla/index.js"],"names":["start","messages","defineMessages","usernameTaken","id","defaultMessage","passwordExceedsLength","passwordDoesNotMatch","loaded","localeData","getLocale","locale","document","documentElement","lang","dateTimeFormat","Intl","DateTimeFormat","year","month","day","hour","minute","dateFormat","timeFormat","timeStyle","hour12","formatMessage","_ref","values","IntlMessageFormat","format","forEach","call","querySelectorAll","content","innerHTML","emojify","datetime","Date","getAttribute","formattedDate","title","textContent","todayFormat","formattedContent","date","today","getDate","getMonth","getFullYear","isToday","formattedTime","time","now","timeGiven","includes","timeAgoString","formatDate","options","reactComponents","length","then","_ref2","default","MediaContainer","component","children","child","removeChild","createElement","createRoot","render","_jsx","components","body","appendChild","catch","error","console","delegate","_throttle","_ref3","target","value","axios","get","params","acct","setCustomValidity","leading","trailing","password","getElementById","confirmation","maxLength","statusEl","this","parentNode","dataset","spoiler","spoilerLink","message","window","addEventListener","e","data","parent","type","ready","postMessage","height","getElementsByTagName","scrollHeight","_ref4","avatar","file","files","url","URL","createObjectURL","originalSrc","src","_ref5","focus","select","setSelectionRange","_ref6","input","querySelector","oldReadOnly","readonly","execCommand","blur","classList","add","setTimeout","remove","err","toggleSidebar","sidebar","toggleButton","contains","style","overflow","setAttribute","toggle","key","preventDefault","_ref7","_ref8","field","loadPolyfills","loadLocale","test","navigator","userAgent","arrowKeyNav","register","Promise","resolve","cocoonElementCounter","createNewID","getTime","newcontentBraced","newcontentUnderscored","cocoonAddFields","stopPropagation","thisNode","assoc","assocs","insertionMethod","insertionNode","insertionTraversal","count","parseInt","regexpBraced","RegExp","regexpUnderscored","newId","newContent","replace","newContents","originalEvent","isNaN","Math","max","push","insertionNodeElem","warn","getInsertionNodeElem","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","parentElement","elem","selector","sibling","matches","cocoonGetPreviousSibling","display","afterRemove"],"mappings":"gPAqBAA,cAEA,MAAMC,EAAWC,YAAe,CAC9BC,cAAe,CAAEC,GAAG,iBAAmBC,eAAe,uCACtDC,sBAAuB,CAAEF,GAAG,0CAA4CC,eAAe,6DACvFE,qBAAsB,CAAEH,GAAG,oCAAsCC,eAAe,0CAmBlF,SAASG,IACP,MAAQP,SAAUQ,GAAeC,cAE3BC,EAASC,SAASC,gBAAgBC,KAElCC,EAAiB,IAAIC,KAAKC,eAAeN,EAAQ,CACrDO,KAAM,UACNC,MAAO,OACPC,IAAK,UACLC,KAAM,UACNC,OAAQ,YAGJC,EAAa,IAAIP,KAAKC,eAAeN,EAAQ,CACjDO,KAAM,UACNC,MAAO,QACPC,IAAK,UACLI,YAAY,IAGRA,EAAa,IAAIR,KAAKC,eAAeN,EAAQ,CACjDc,UAAW,QACXC,QAAQ,IAGJC,EAAgBA,CAAAC,EAAyBC,KAAY,IAApC,GAAEzB,EAAE,eAAEC,GAAgBuB,EAE3C,OADsB,IAAIE,IAAkBrB,EAAWL,IAAOC,EAAgBM,GACzDoB,OAAOF,EAAO,EAGrC,GAAGG,QAAQC,KAAKrB,SAASsB,iBAAiB,aAAcC,IACtDA,EAAQC,UAAYC,YAAQF,EAAQC,UAAU,IAGhD,GAAGJ,QAAQC,KAAKrB,SAASsB,iBAAiB,mBAAoBC,IAC5D,MAAMG,EAAW,IAAIC,KAAKJ,EAAQK,aAAa,aACzCC,EAAgB1B,EAAegB,OAAOO,GAE5CH,EAAQO,MAAQD,EAChBN,EAAQQ,YAAcF,CAAa,IAGrC,MAOMG,EAAc,IAAId,IAAkBrB,EAAW,0BAA4B,kBAAmBE,GAEpG,GAAGqB,QAAQC,KAAKrB,SAASsB,iBAAiB,4BAA6BC,IACrE,MA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H,KAET,SAAU+B,EAAMC,GAC7C,IAAIC,EAAUF,EAAKb,uBACnB,IAAKc,EAAU,OAAOC,EACtB,KAAOA,GAAS,CAEd,GADYA,EAAQC,QAAQF,GACjB,OAAOC,EAClBA,EAAUA,EAAQf,sBACpB,CACF,CA+F0BiB,CAAyB1D,EAAU,uBACzCpF,MAAQ,IACpBoI,EAAazE,MAAMoF,QAAU,QAE/B,IAAIC,EAAc,IAAIjC,YAAY,sBAAuB,CACvDC,SAAS,EACTE,OAAQ,CAACkB,EAAcjC,KAEzBmC,EAAYnB,cAAc6B,EAC5B,GAAGR,EACL,CACF,EACAhN,SAAS4F,iBAAiB,SAAS,SAAUC,GAC3C,IAAK,IAAItB,EAASsB,EAAEtB,OAAQA,GAAUA,IAAWc,KAAMd,EAASA,EAAOe,WAAY,CACjF,GAAIf,EAAO8I,QAAQ,eAEjB,YADA3D,EAAgB7D,EAAGtB,GAGrB,GAAIA,EAAO8I,QAAQ,kBAEjB,YADAX,EAAmB7G,EAAGtB,EAG1B,CACF,IAAG,EACL,G","file":"js/public-5c54ec06fd84f516426a.chunk.js","sourcesContent":["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","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// });"],"sourceRoot":""}