diff --git a/CHANGELOG.md b/CHANGELOG.md
index f7a372e11..1266d2dfe 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,8 +9,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Renamed `:await_up_timeout` in `:connections_pool` namespace to `:connect_timeout`, old name is deprecated.
- Renamed `:timeout` in `pools` namespace to `:recv_timeout`, old name is deprecated.
+- The `discoverable` field in the `User` struct will now add a NOINDEX metatag to profile pages when false.
+- Users with the `discoverable` field set to false will not show up in searches.
- Minimum lifetime for ephmeral activities changed to 10 minutes and made configurable (`:min_lifetime` option).
-
### Removed
- **Breaking:** `Pleroma.Workers.Cron.StatsWorker` setting from Oban `:crontab` (moved to a simpler implementation).
@@ -19,12 +20,27 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Removed `:managed_config` option. In practice, it was accidentally removed with 2.0.0 release when frontends were
switched to a new configuration mechanism, however it was not officially removed until now.
-## unreleased-patch - ???
+## [2.1.2] - 2020-09-17
+
+### Security
+
+- Fix most MRF rules either crashing or not being applied to objects passed into the Common Pipeline (ChatMessage, Question, Answer, Audio, Event).
### Fixed
-- Welcome Chat messages preventing user registration with MRF Simple Policy applied to the local instance
-- Mastodon API: the public timeline returning an error when the `reply_visibility` parameter is set to `self` for an unauthenticated user
+- Welcome Chat messages preventing user registration with MRF Simple Policy applied to the local instance.
+- Mastodon API: the public timeline returning an error when the `reply_visibility` parameter is set to `self` for an unauthenticated user.
+- Mastodon Streaming API: Handler crashes on authentication failures, resulting in error logs.
+- Mastodon Streaming API: Error logs on client pings.
+- Rich media: Log spam on failures. Now the error is only logged once per attempt.
+
+### Changed
+
+- Rich Media: A HEAD request is now done to the url, to ensure it has the appropriate content type and size before proceeding with a GET.
+
+### Upgrade notes
+
+1. Restart Pleroma
## [2.1.1] - 2020-09-08
@@ -41,6 +57,12 @@ switched to a new configuration mechanism, however it was not officially removed
### Added
- Rich media failure tracking (along with `:failure_backoff` option).
+Admin API Changes
+
+- Add `PATCH /api/pleroma/admin/instance_document/:document_name` to modify the Terms of Service and Instance Panel HTML pages via Admin API
+
\n {{ importFailedText }}\n
\n\n {{ importFailedText }}\n
\n for paragraphs, GS uses
between them)\n // as well as approximate line count by counting characters and approximating ~80\n // per line.\n //\n // Using max-height + overflow: auto for status components resulted in false positives\n // very often with japanese characters, and it was very annoying.\n tallStatus () {\n const lengthScore = this.status.statusnet_html.split(/
20\n },\n longSubject () {\n return this.status.summary.length > 240\n },\n // When a status has a subject and is also tall, we should only have one show more/less button. If the default is to collapse statuses with subjects, we just treat it like a status with a subject; otherwise, we just treat it like a tall status.\n mightHideBecauseSubject () {\n return !!this.status.summary && this.localCollapseSubjectDefault\n },\n mightHideBecauseTall () {\n return this.tallStatus && !(this.status.summary && this.localCollapseSubjectDefault)\n },\n hideSubjectStatus () {\n return this.mightHideBecauseSubject && !this.expandingSubject\n },\n hideTallStatus () {\n return this.mightHideBecauseTall && !this.showingTall\n },\n showingMore () {\n return (this.mightHideBecauseTall && this.showingTall) || (this.mightHideBecauseSubject && this.expandingSubject)\n },\n nsfwClickthrough () {\n if (!this.status.nsfw) {\n return false\n }\n if (this.status.summary && this.localCollapseSubjectDefault) {\n return false\n }\n return true\n },\n attachmentSize () {\n if ((this.mergedConfig.hideAttachments && !this.inConversation) ||\n (this.mergedConfig.hideAttachmentsInConv && this.inConversation) ||\n (this.status.attachments.length > this.maxThumbnails)) {\n return 'hide'\n } else if (this.compact) {\n return 'small'\n }\n return 'normal'\n },\n galleryTypes () {\n if (this.attachmentSize === 'hide') {\n return []\n }\n return this.mergedConfig.playVideosInModal\n ? ['image', 'video']\n : ['image']\n },\n galleryAttachments () {\n return this.status.attachments.filter(\n file => fileType.fileMatchesSomeType(this.galleryTypes, file)\n )\n },\n nonGalleryAttachments () {\n return this.status.attachments.filter(\n file => !fileType.fileMatchesSomeType(this.galleryTypes, file)\n )\n },\n attachmentTypes () {\n return this.status.attachments.map(file => fileType.fileType(file.mimetype))\n },\n maxThumbnails () {\n return this.mergedConfig.maxThumbnails\n },\n postBodyHtml () {\n const html = this.status.statusnet_html\n\n if (this.mergedConfig.greentext) {\n try {\n if (html.includes('>')) {\n // This checks if post has '>' at the beginning, excluding mentions so that @mention >impying works\n return processHtml(html, (string) => {\n if (string.includes('>') &&\n string\n .replace(/<[^>]+?>/gi, '') // remove all tags\n .replace(/@\\w+/gi, '') // remove mentions (even failed ones)\n .trim()\n .startsWith('>')) {\n return `${string}`\n } else {\n return string\n }\n })\n } else {\n return html\n }\n } catch (e) {\n console.err('Failed to process status html', e)\n return html\n }\n } else {\n return html\n }\n },\n ...mapGetters(['mergedConfig']),\n ...mapState({\n betterShadow: state => state.interface.browserSupport.cssFilter,\n currentUser: state => state.users.currentUser\n })\n },\n components: {\n Attachment,\n Poll,\n Gallery,\n LinkPreview\n },\n methods: {\n linkClicked (event) {\n const target = event.target.closest('.status-content a')\n if (target) {\n if (target.className.match(/mention/)) {\n const href = target.href\n const attn = this.status.attentions.find(attn => mentionMatchesUrl(attn, href))\n if (attn) {\n event.stopPropagation()\n event.preventDefault()\n const link = this.generateUserProfileLink(attn.id, attn.screen_name)\n this.$router.push(link)\n return\n }\n }\n if (target.rel.match(/(?:^|\\s)tag(?:$|\\s)/) || target.className.match(/hashtag/)) {\n // Extract tag name from dataset or link url\n const tag = target.dataset.tag || extractTagFromUrl(target.href)\n if (tag) {\n const link = this.generateTagLink(tag)\n this.$router.push(link)\n return\n }\n }\n window.open(target.href, '_blank')\n }\n },\n toggleShowMore () {\n if (this.mightHideBecauseTall) {\n this.showingTall = !this.showingTall\n } else if (this.mightHideBecauseSubject) {\n this.expandingSubject = !this.expandingSubject\n }\n },\n generateUserProfileLink (id, name) {\n return generateProfileLink(id, name, this.$store.state.instance.restrictedNicknames)\n },\n generateTagLink (tag) {\n return `/tag/${tag}`\n },\n setMedia () {\n const attachments = this.attachmentSize === 'hide' ? this.status.attachments : this.galleryAttachments\n return () => this.$store.dispatch('setMedia', attachments)\n }\n }\n}\n\nexport default StatusContent\n","/**\n * This is a tiny purpose-built HTML parser/processor. This basically detects any type of visual newline and\n * allows it to be processed, useful for greentexting, mostly\n *\n * known issue: doesn't handle CDATA so nested CDATA might not work well\n *\n * @param {Object} input - input data\n * @param {(string) => string} processor - function that will be called on every line\n * @return {string} processed html\n */\nexport const processHtml = (html, processor) => {\n const handledTags = new Set(['p', 'br', 'div'])\n const openCloseTags = new Set(['p', 'div'])\n\n let buffer = '' // Current output buffer\n const level = [] // How deep we are in tags and which tags were there\n let textBuffer = '' // Current line content\n let tagBuffer = null // Current tag buffer, if null = we are not currently reading a tag\n\n // Extracts tag name from tag, i.e. => span\n const getTagName = (tag) => {\n const result = /(?:<\\/(\\w+)>|<(\\w+)\\s?[^/]*?\\/?>)/gi.exec(tag)\n return result && (result[1] || result[2])\n }\n\n const flush = () => { // Processes current line buffer, adds it to output buffer and clears line buffer\n if (textBuffer.trim().length > 0) {\n buffer += processor(textBuffer)\n } else {\n buffer += textBuffer\n }\n textBuffer = ''\n }\n\n const handleBr = (tag) => { // handles single newlines/linebreaks/selfclosing\n flush()\n buffer += tag\n }\n\n const handleOpen = (tag) => { // handles opening tags\n flush()\n buffer += tag\n level.push(tag)\n }\n\n const handleClose = (tag) => { // handles closing tags\n flush()\n buffer += tag\n if (level[level.length - 1] === tag) {\n level.pop()\n }\n }\n\n for (let i = 0; i < html.length; i++) {\n const char = html[i]\n if (char === '<' && tagBuffer === null) {\n tagBuffer = char\n } else if (char !== '>' && tagBuffer !== null) {\n tagBuffer += char\n } else if (char === '>' && tagBuffer !== null) {\n tagBuffer += char\n const tagFull = tagBuffer\n tagBuffer = null\n const tagName = getTagName(tagFull)\n if (handledTags.has(tagName)) {\n if (tagName === 'br') {\n handleBr(tagFull)\n } else if (openCloseTags.has(tagName)) {\n if (tagFull[1] === '/') {\n handleClose(tagFull)\n } else if (tagFull[tagFull.length - 2] === '/') {\n // self-closing\n handleBr(tagFull)\n } else {\n handleOpen(tagFull)\n }\n }\n } else {\n textBuffer += tagFull\n }\n } else if (char === '\\n') {\n handleBr(char)\n } else {\n textBuffer += char\n }\n }\n if (tagBuffer) {\n textBuffer += tagBuffer\n }\n\n flush()\n\n return buffer\n}\n","export const mentionMatchesUrl = (attention, url) => {\n if (url === attention.statusnet_profile_url) {\n return true\n }\n const [namepart, instancepart] = attention.screen_name.split('@')\n const matchstring = new RegExp('://' + instancepart + '/.*' + namepart + '$', 'g')\n\n return !!url.match(matchstring)\n}\n\n/**\n * Extract tag name from pleroma or mastodon url.\n * i.e https://bikeshed.party/tag/photo or https://quey.org/tags/sky\n * @param {string} url\n */\nexport const extractTagFromUrl = (url) => {\n const regex = /tag[s]*\\/(\\w+)$/g\n const result = regex.exec(url)\n if (!result) {\n return false\n }\n return result[1]\n}\n","function injectStyle (context) {\n require(\"!!vue-style-loader!css-loader?minimize!../../../node_modules/vue-loader/lib/style-compiler/index?{\\\"optionsId\\\":\\\"0\\\",\\\"vue\\\":true,\\\"scoped\\\":false,\\\"sourceMap\\\":false}!sass-loader!../../../node_modules/vue-loader/lib/selector?type=styles&index=0!./status_content.vue\")\n}\n/* script */\nexport * from \"!!babel-loader!./status_content.js\"\nimport __vue_script__ from \"!!babel-loader!./status_content.js\"/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-2a51d4c2\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./status_content.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = injectStyle\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"StatusContent\"},[_vm._t(\"header\"),_vm._v(\" \"),(_vm.status.summary_html)?_c('div',{staticClass:\"summary-wrapper\",class:{ 'tall-subject': (_vm.longSubject && !_vm.showingLongSubject) }},[_c('div',{staticClass:\"media-body summary\",domProps:{\"innerHTML\":_vm._s(_vm.status.summary_html)},on:{\"click\":function($event){$event.preventDefault();return _vm.linkClicked($event)}}}),_vm._v(\" \"),(_vm.longSubject && _vm.showingLongSubject)?_c('a',{staticClass:\"tall-subject-hider\",attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();_vm.showingLongSubject=false}}},[_vm._v(_vm._s(_vm.$t(\"status.hide_full_subject\")))]):(_vm.longSubject)?_c('a',{staticClass:\"tall-subject-hider\",class:{ 'tall-subject-hider_focused': _vm.focused },attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();_vm.showingLongSubject=true}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"status.show_full_subject\"))+\"\\n \")]):_vm._e()]):_vm._e(),_vm._v(\" \"),_c('div',{staticClass:\"status-content-wrapper\",class:{'tall-status': _vm.hideTallStatus}},[(_vm.hideTallStatus)?_c('a',{staticClass:\"tall-status-hider\",class:{ 'tall-status-hider_focused': _vm.focused },attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();return _vm.toggleShowMore($event)}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"general.show_more\"))+\"\\n \")]):_vm._e(),_vm._v(\" \"),(!_vm.hideSubjectStatus)?_c('div',{staticClass:\"status-content media-body\",class:{ 'single-line': _vm.singleLine },domProps:{\"innerHTML\":_vm._s(_vm.postBodyHtml)},on:{\"click\":function($event){$event.preventDefault();return _vm.linkClicked($event)}}}):_vm._e(),_vm._v(\" \"),(_vm.hideSubjectStatus)?_c('a',{staticClass:\"cw-status-hider\",attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();return _vm.toggleShowMore($event)}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(\"status.show_content\"))+\"\\n \"),(_vm.attachmentTypes.includes('image'))?_c('span',{staticClass:\"icon-picture\"}):_vm._e(),_vm._v(\" \"),(_vm.attachmentTypes.includes('video'))?_c('span',{staticClass:\"icon-video\"}):_vm._e(),_vm._v(\" \"),(_vm.attachmentTypes.includes('audio'))?_c('span',{staticClass:\"icon-music\"}):_vm._e(),_vm._v(\" \"),(_vm.attachmentTypes.includes('unknown'))?_c('span',{staticClass:\"icon-doc\"}):_vm._e(),_vm._v(\" \"),(_vm.status.poll && _vm.status.poll.options)?_c('span',{staticClass:\"icon-chart-bar\"}):_vm._e(),_vm._v(\" \"),(_vm.status.card)?_c('span',{staticClass:\"icon-link\"}):_vm._e()]):_vm._e(),_vm._v(\" \"),(_vm.showingMore && !_vm.fullContent)?_c('a',{staticClass:\"status-unhider\",attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();return _vm.toggleShowMore($event)}}},[_vm._v(\"\\n \"+_vm._s(_vm.tallStatus ? _vm.$t(\"general.show_less\") : _vm.$t(\"status.hide_content\"))+\"\\n \")]):_vm._e()]),_vm._v(\" \"),(_vm.status.poll && _vm.status.poll.options && !_vm.hideSubjectStatus)?_c('div',[_c('poll',{attrs:{\"base-poll\":_vm.status.poll}})],1):_vm._e(),_vm._v(\" \"),(_vm.status.attachments.length !== 0 && (!_vm.hideSubjectStatus || _vm.showingLongSubject))?_c('div',{staticClass:\"attachments media-body\"},[_vm._l((_vm.nonGalleryAttachments),function(attachment){return _c('attachment',{key:attachment.id,staticClass:\"non-gallery\",attrs:{\"size\":_vm.attachmentSize,\"nsfw\":_vm.nsfwClickthrough,\"attachment\":attachment,\"allow-play\":true,\"set-media\":_vm.setMedia()}})}),_vm._v(\" \"),(_vm.galleryAttachments.length > 0)?_c('gallery',{attrs:{\"nsfw\":_vm.nsfwClickthrough,\"attachments\":_vm.galleryAttachments,\"set-media\":_vm.setMedia()}}):_vm._e()],2):_vm._e(),_vm._v(\" \"),(_vm.status.card && !_vm.hideSubjectStatus && !_vm.noHeading)?_c('div',{staticClass:\"link-preview media-body\"},[_c('link-preview',{attrs:{\"card\":_vm.status.card,\"size\":_vm.attachmentSize,\"nsfw\":_vm.nsfwClickthrough}})],1):_vm._e(),_vm._v(\" \"),_vm._t(\"footer\")],2)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","export const SECOND = 1000\nexport const MINUTE = 60 * SECOND\nexport const HOUR = 60 * MINUTE\nexport const DAY = 24 * HOUR\nexport const WEEK = 7 * DAY\nexport const MONTH = 30 * DAY\nexport const YEAR = 365.25 * DAY\n\nexport const relativeTime = (date, nowThreshold = 1) => {\n if (typeof date === 'string') date = Date.parse(date)\n const round = Date.now() > date ? Math.floor : Math.ceil\n const d = Math.abs(Date.now() - date)\n let r = { num: round(d / YEAR), key: 'time.years' }\n if (d < nowThreshold * SECOND) {\n r.num = 0\n r.key = 'time.now'\n } else if (d < MINUTE) {\n r.num = round(d / SECOND)\n r.key = 'time.seconds'\n } else if (d < HOUR) {\n r.num = round(d / MINUTE)\n r.key = 'time.minutes'\n } else if (d < DAY) {\n r.num = round(d / HOUR)\n r.key = 'time.hours'\n } else if (d < WEEK) {\n r.num = round(d / DAY)\n r.key = 'time.days'\n } else if (d < MONTH) {\n r.num = round(d / WEEK)\n r.key = 'time.weeks'\n } else if (d < YEAR) {\n r.num = round(d / MONTH)\n r.key = 'time.months'\n }\n // Remove plural form when singular\n if (r.num === 1) r.key = r.key.slice(0, -1)\n return r\n}\n\nexport const relativeTimeShort = (date, nowThreshold = 1) => {\n const r = relativeTime(date, nowThreshold)\n r.key += '_short'\n return r\n}\n","import UserCard from '../user_card/user_card.vue'\nimport UserAvatar from '../user_avatar/user_avatar.vue'\nimport generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'\n\nconst BasicUserCard = {\n props: [\n 'user'\n ],\n data () {\n return {\n userExpanded: false\n }\n },\n components: {\n UserCard,\n UserAvatar\n },\n methods: {\n toggleUserExpanded () {\n this.userExpanded = !this.userExpanded\n },\n userProfileLink (user) {\n return generateProfileLink(user.id, user.screen_name, this.$store.state.instance.restrictedNicknames)\n }\n }\n}\n\nexport default BasicUserCard\n","function injectStyle (context) {\n require(\"!!vue-style-loader!css-loader?minimize!../../../node_modules/vue-loader/lib/style-compiler/index?{\\\"optionsId\\\":\\\"0\\\",\\\"vue\\\":true,\\\"scoped\\\":false,\\\"sourceMap\\\":false}!sass-loader!../../../node_modules/vue-loader/lib/selector?type=styles&index=0!./basic_user_card.vue\")\n}\n/* script */\nexport * from \"!!babel-loader!./basic_user_card.js\"\nimport __vue_script__ from \"!!babel-loader!./basic_user_card.js\"/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-4d2bc0bb\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./basic_user_card.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = injectStyle\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"basic-user-card\"},[_c('router-link',{attrs:{\"to\":_vm.userProfileLink(_vm.user)}},[_c('UserAvatar',{staticClass:\"avatar\",attrs:{\"user\":_vm.user},nativeOn:{\"click\":function($event){$event.preventDefault();return _vm.toggleUserExpanded($event)}}})],1),_vm._v(\" \"),(_vm.userExpanded)?_c('div',{staticClass:\"basic-user-card-expanded-content\"},[_c('UserCard',{attrs:{\"user-id\":_vm.user.id,\"rounded\":true,\"bordered\":true}})],1):_c('div',{staticClass:\"basic-user-card-collapsed-content\"},[_c('div',{staticClass:\"basic-user-card-user-name\",attrs:{\"title\":_vm.user.name}},[(_vm.user.name_html)?_c('span',{staticClass:\"basic-user-card-user-name-value\",domProps:{\"innerHTML\":_vm._s(_vm.user.name_html)}}):_c('span',{staticClass:\"basic-user-card-user-name-value\"},[_vm._v(_vm._s(_vm.user.name))])]),_vm._v(\" \"),_c('div',[_c('router-link',{staticClass:\"basic-user-card-screen-name\",attrs:{\"to\":_vm.userProfileLink(_vm.user)}},[_vm._v(\"\\n @\"+_vm._s(_vm.user.screen_name)+\"\\n \")])],1),_vm._v(\" \"),_vm._t(\"default\")],2)],1)}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","import { convert, brightness, contrastRatio } from 'chromatism'\nimport { alphaBlendLayers, getTextColor, relativeLuminance } from '../color_convert/color_convert.js'\nimport { LAYERS, DEFAULT_OPACITY, SLOT_INHERITANCE } from './pleromafe.js'\n\n/*\n * # What's all this?\n * Here be theme engine for pleromafe. All of this supposed to ease look\n * and feel customization, making widget styles and make developer's life\n * easier when it comes to supporting themes. Like many other theme systems\n * it operates on color definitions, or \"slots\" - for example you define\n * \"button\" color slot and then in UI component Button's CSS you refer to\n * it as a CSS3 Variable.\n *\n * Some applications allow you to customize colors for certain things.\n * Some UI toolkits allow you to define colors for each type of widget.\n * Most of them are pretty barebones and have no assistance for common\n * problems and cases, and in general themes themselves are very hard to\n * maintain in all aspects. This theme engine tries to solve all of the\n * common problems with themes.\n *\n * You don't have redefine several similar colors if you just want to\n * change one color - all color slots are derived from other ones, so you\n * can have at least one or two \"basic\" colors defined and have all other\n * components inherit and modify basic ones.\n *\n * You don't have to test contrast ratio for colors or pick text color for\n * each element even if you have light-on-dark elements in dark-on-light\n * theme.\n *\n * You don't have to maintain order of code for inheriting slots from othet\n * slots - dependency graph resolving does it for you.\n */\n\n/* This indicates that this version of code outputs similar theme data and\n * should be incremented if output changes - for instance if getTextColor\n * function changes and older themes no longer render text colors as\n * author intended previously.\n */\nexport const CURRENT_VERSION = 3\n\nexport const getLayersArray = (layer, data = LAYERS) => {\n let array = [layer]\n let parent = data[layer]\n while (parent) {\n array.unshift(parent)\n parent = data[parent]\n }\n return array\n}\n\nexport const getLayers = (layer, variant = layer, opacitySlot, colors, opacity) => {\n return getLayersArray(layer).map((currentLayer) => ([\n currentLayer === layer\n ? colors[variant]\n : colors[currentLayer],\n currentLayer === layer\n ? opacity[opacitySlot] || 1\n : opacity[currentLayer]\n ]))\n}\n\nconst getDependencies = (key, inheritance) => {\n const data = inheritance[key]\n if (typeof data === 'string' && data.startsWith('--')) {\n return [data.substring(2)]\n } else {\n if (data === null) return []\n const { depends, layer, variant } = data\n const layerDeps = layer\n ? getLayersArray(layer).map(currentLayer => {\n return currentLayer === layer\n ? variant || layer\n : currentLayer\n })\n : []\n if (Array.isArray(depends)) {\n return [...depends, ...layerDeps]\n } else {\n return [...layerDeps]\n }\n }\n}\n\n/**\n * Sorts inheritance object topologically - dependant slots come after\n * dependencies\n *\n * @property {Object} inheritance - object defining the nodes\n * @property {Function} getDeps - function that returns dependencies for\n * given value and inheritance object.\n * @returns {String[]} keys of inheritance object, sorted in topological\n * order. Additionally, dependency-less nodes will always be first in line\n */\nexport const topoSort = (\n inheritance = SLOT_INHERITANCE,\n getDeps = getDependencies\n) => {\n // This is an implementation of https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm\n\n const allKeys = Object.keys(inheritance)\n const whites = new Set(allKeys)\n const grays = new Set()\n const blacks = new Set()\n const unprocessed = [...allKeys]\n const output = []\n\n const step = (node) => {\n if (whites.has(node)) {\n // Make node \"gray\"\n whites.delete(node)\n grays.add(node)\n // Do step for each node connected to it (one way)\n getDeps(node, inheritance).forEach(step)\n // Make node \"black\"\n grays.delete(node)\n blacks.add(node)\n // Put it into the output list\n output.push(node)\n } else if (grays.has(node)) {\n console.debug('Cyclic depenency in topoSort, ignoring')\n output.push(node)\n } else if (blacks.has(node)) {\n // do nothing\n } else {\n throw new Error('Unintended condition in topoSort!')\n }\n }\n while (unprocessed.length > 0) {\n step(unprocessed.pop())\n }\n\n // The index thing is to make sorting stable on browsers\n // where Array.sort() isn't stable\n return output.map((data, index) => ({ data, index })).sort(({ data: a, index: ai }, { data: b, index: bi }) => {\n const depsA = getDeps(a, inheritance).length\n const depsB = getDeps(b, inheritance).length\n\n if (depsA === depsB || (depsB !== 0 && depsA !== 0)) return ai - bi\n if (depsA === 0 && depsB !== 0) return -1\n if (depsB === 0 && depsA !== 0) return 1\n }).map(({ data }) => data)\n}\n\nconst expandSlotValue = (value) => {\n if (typeof value === 'object') return value\n return {\n depends: value.startsWith('--') ? [value.substring(2)] : [],\n default: value.startsWith('#') ? value : undefined\n }\n}\n/**\n * retrieves opacity slot for given slot. This goes up the depenency graph\n * to find which parent has opacity slot defined for it.\n * TODO refactor this\n */\nexport const getOpacitySlot = (\n k,\n inheritance = SLOT_INHERITANCE,\n getDeps = getDependencies\n) => {\n const value = expandSlotValue(inheritance[k])\n if (value.opacity === null) return\n if (value.opacity) return value.opacity\n const findInheritedOpacity = (key, visited = [k]) => {\n const depSlot = getDeps(key, inheritance)[0]\n if (depSlot === undefined) return\n const dependency = inheritance[depSlot]\n if (dependency === undefined) return\n if (dependency.opacity || dependency === null) {\n return dependency.opacity\n } else if (dependency.depends && visited.includes(depSlot)) {\n return findInheritedOpacity(depSlot, [...visited, depSlot])\n } else {\n return null\n }\n }\n if (value.depends) {\n return findInheritedOpacity(k)\n }\n}\n\n/**\n * retrieves layer slot for given slot. This goes up the depenency graph\n * to find which parent has opacity slot defined for it.\n * this is basically copypaste of getOpacitySlot except it checks if key is\n * in LAYERS\n * TODO refactor this\n */\nexport const getLayerSlot = (\n k,\n inheritance = SLOT_INHERITANCE,\n getDeps = getDependencies\n) => {\n const value = expandSlotValue(inheritance[k])\n if (LAYERS[k]) return k\n if (value.layer === null) return\n if (value.layer) return value.layer\n const findInheritedLayer = (key, visited = [k]) => {\n const depSlot = getDeps(key, inheritance)[0]\n if (depSlot === undefined) return\n const dependency = inheritance[depSlot]\n if (dependency === undefined) return\n if (dependency.layer || dependency === null) {\n return dependency.layer\n } else if (dependency.depends) {\n return findInheritedLayer(dependency, [...visited, depSlot])\n } else {\n return null\n }\n }\n if (value.depends) {\n return findInheritedLayer(k)\n }\n}\n\n/**\n * topologically sorted SLOT_INHERITANCE\n */\nexport const SLOT_ORDERED = topoSort(\n Object.entries(SLOT_INHERITANCE)\n .sort(([aK, aV], [bK, bV]) => ((aV && aV.priority) || 0) - ((bV && bV.priority) || 0))\n .reduce((acc, [k, v]) => ({ ...acc, [k]: v }), {})\n)\n\n/**\n * All opacity slots used in color slots, their default values and affected\n * color slots.\n */\nexport const OPACITIES = Object.entries(SLOT_INHERITANCE).reduce((acc, [k, v]) => {\n const opacity = getOpacitySlot(k, SLOT_INHERITANCE, getDependencies)\n if (opacity) {\n return {\n ...acc,\n [opacity]: {\n defaultValue: DEFAULT_OPACITY[opacity] || 1,\n affectedSlots: [...((acc[opacity] && acc[opacity].affectedSlots) || []), k]\n }\n }\n } else {\n return acc\n }\n}, {})\n\n/**\n * Handle dynamic color\n */\nexport const computeDynamicColor = (sourceColor, getColor, mod) => {\n if (typeof sourceColor !== 'string' || !sourceColor.startsWith('--')) return sourceColor\n let targetColor = null\n // Color references other color\n const [variable, modifier] = sourceColor.split(/,/g).map(str => str.trim())\n const variableSlot = variable.substring(2)\n targetColor = getColor(variableSlot)\n if (modifier) {\n targetColor = brightness(Number.parseFloat(modifier) * mod, targetColor).rgb\n }\n return targetColor\n}\n\n/**\n * THE function you want to use. Takes provided colors and opacities\n * value and uses inheritance data to figure out color needed for the slot.\n */\nexport const getColors = (sourceColors, sourceOpacity) => SLOT_ORDERED.reduce(({ colors, opacity }, key) => {\n const sourceColor = sourceColors[key]\n const value = expandSlotValue(SLOT_INHERITANCE[key])\n const deps = getDependencies(key, SLOT_INHERITANCE)\n const isTextColor = !!value.textColor\n const variant = value.variant || value.layer\n\n let backgroundColor = null\n\n if (isTextColor) {\n backgroundColor = alphaBlendLayers(\n { ...(colors[deps[0]] || convert(sourceColors[key] || '#FF00FF').rgb) },\n getLayers(\n getLayerSlot(key) || 'bg',\n variant || 'bg',\n getOpacitySlot(variant),\n colors,\n opacity\n )\n )\n } else if (variant && variant !== key) {\n backgroundColor = colors[variant] || convert(sourceColors[variant]).rgb\n } else {\n backgroundColor = colors.bg || convert(sourceColors.bg)\n }\n\n const isLightOnDark = relativeLuminance(backgroundColor) < 0.5\n const mod = isLightOnDark ? 1 : -1\n\n let outputColor = null\n if (sourceColor) {\n // Color is defined in source color\n let targetColor = sourceColor\n if (targetColor === 'transparent') {\n // We take only layers below current one\n const layers = getLayers(\n getLayerSlot(key),\n key,\n getOpacitySlot(key) || key,\n colors,\n opacity\n ).slice(0, -1)\n targetColor = {\n ...alphaBlendLayers(\n convert('#FF00FF').rgb,\n layers\n ),\n a: 0\n }\n } else if (typeof sourceColor === 'string' && sourceColor.startsWith('--')) {\n targetColor = computeDynamicColor(\n sourceColor,\n variableSlot => colors[variableSlot] || sourceColors[variableSlot],\n mod\n )\n } else if (typeof sourceColor === 'string' && sourceColor.startsWith('#')) {\n targetColor = convert(targetColor).rgb\n }\n outputColor = { ...targetColor }\n } else if (value.default) {\n // same as above except in object form\n outputColor = convert(value.default).rgb\n } else {\n // calculate color\n const defaultColorFunc = (mod, dep) => ({ ...dep })\n const colorFunc = value.color || defaultColorFunc\n\n if (value.textColor) {\n if (value.textColor === 'bw') {\n outputColor = contrastRatio(backgroundColor).rgb\n } else {\n let color = { ...colors[deps[0]] }\n if (value.color) {\n color = colorFunc(mod, ...deps.map((dep) => ({ ...colors[dep] })))\n }\n outputColor = getTextColor(\n backgroundColor,\n { ...color },\n value.textColor === 'preserve'\n )\n }\n } else {\n // background color case\n outputColor = colorFunc(\n mod,\n ...deps.map((dep) => ({ ...colors[dep] }))\n )\n }\n }\n if (!outputColor) {\n throw new Error('Couldn\\'t generate color for ' + key)\n }\n\n const opacitySlot = value.opacity || getOpacitySlot(key)\n const ownOpacitySlot = value.opacity\n\n if (ownOpacitySlot === null) {\n outputColor.a = 1\n } else if (sourceColor === 'transparent') {\n outputColor.a = 0\n } else {\n const opacityOverriden = ownOpacitySlot && sourceOpacity[opacitySlot] !== undefined\n\n const dependencySlot = deps[0]\n const dependencyColor = dependencySlot && colors[dependencySlot]\n\n if (!ownOpacitySlot && dependencyColor && !value.textColor && ownOpacitySlot !== null) {\n // Inheriting color from dependency (weird, i know)\n // except if it's a text color or opacity slot is set to 'null'\n outputColor.a = dependencyColor.a\n } else if (!dependencyColor && !opacitySlot) {\n // Remove any alpha channel if no dependency and no opacitySlot found\n delete outputColor.a\n } else {\n // Otherwise try to assign opacity\n if (dependencyColor && dependencyColor.a === 0) {\n // transparent dependency shall make dependents transparent too\n outputColor.a = 0\n } else {\n // Otherwise check if opacity is overriden and use that or default value instead\n outputColor.a = Number(\n opacityOverriden\n ? sourceOpacity[opacitySlot]\n : (OPACITIES[opacitySlot] || {}).defaultValue\n )\n }\n }\n }\n\n if (Number.isNaN(outputColor.a) || outputColor.a === undefined) {\n outputColor.a = 1\n }\n\n if (opacitySlot) {\n return {\n colors: { ...colors, [key]: outputColor },\n opacity: { ...opacity, [opacitySlot]: outputColor.a }\n }\n } else {\n return {\n colors: { ...colors, [key]: outputColor },\n opacity\n }\n }\n}, { colors: {}, opacity: {} })\n","/* eslint-env browser */\nimport statusPosterService from '../../services/status_poster/status_poster.service.js'\nimport fileSizeFormatService from '../../services/file_size_format/file_size_format.js'\n\nconst mediaUpload = {\n data () {\n return {\n uploadCount: 0,\n uploadReady: true\n }\n },\n computed: {\n uploading () {\n return this.uploadCount > 0\n }\n },\n methods: {\n uploadFile (file) {\n const self = this\n const store = this.$store\n if (file.size > store.state.instance.uploadlimit) {\n const filesize = fileSizeFormatService.fileSizeFormat(file.size)\n const allowedsize = fileSizeFormatService.fileSizeFormat(store.state.instance.uploadlimit)\n self.$emit('upload-failed', 'file_too_big', { filesize: filesize.num, filesizeunit: filesize.unit, allowedsize: allowedsize.num, allowedsizeunit: allowedsize.unit })\n return\n }\n const formData = new FormData()\n formData.append('file', file)\n\n self.$emit('uploading')\n self.uploadCount++\n\n statusPosterService.uploadMedia({ store, formData })\n .then((fileData) => {\n self.$emit('uploaded', fileData)\n self.decreaseUploadCount()\n }, (error) => { // eslint-disable-line handle-callback-err\n self.$emit('upload-failed', 'default')\n self.decreaseUploadCount()\n })\n },\n decreaseUploadCount () {\n this.uploadCount--\n if (this.uploadCount === 0) {\n this.$emit('all-uploaded')\n }\n },\n clearFile () {\n this.uploadReady = false\n this.$nextTick(() => {\n this.uploadReady = true\n })\n },\n multiUpload (files) {\n for (const file of files) {\n this.uploadFile(file)\n }\n },\n change ({ target }) {\n this.multiUpload(target.files)\n }\n },\n props: [\n 'dropFiles',\n 'disabled'\n ],\n watch: {\n 'dropFiles': function (fileInfos) {\n if (!this.uploading) {\n this.multiUpload(fileInfos)\n }\n }\n }\n}\n\nexport default mediaUpload\n","function injectStyle (context) {\n require(\"!!vue-style-loader!css-loader?minimize!../../../node_modules/vue-loader/lib/style-compiler/index?{\\\"optionsId\\\":\\\"0\\\",\\\"vue\\\":true,\\\"scoped\\\":false,\\\"sourceMap\\\":false}!sass-loader!../../../node_modules/vue-loader/lib/selector?type=styles&index=0!./media_upload.vue\")\n}\n/* script */\nexport * from \"!!babel-loader!./media_upload.js\"\nimport __vue_script__ from \"!!babel-loader!./media_upload.js\"/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-6bb295a4\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./media_upload.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = injectStyle\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:\"media-upload\",class:{ disabled: _vm.disabled }},[_c('label',{staticClass:\"label\",attrs:{\"title\":_vm.$t('tool_tip.media_upload')}},[(_vm.uploading)?_c('i',{staticClass:\"progress-icon icon-spin4 animate-spin\"}):_vm._e(),_vm._v(\" \"),(!_vm.uploading)?_c('i',{staticClass:\"new-icon icon-upload\"}):_vm._e(),_vm._v(\" \"),(_vm.uploadReady)?_c('input',{staticStyle:{\"position\":\"fixed\",\"top\":\"-100em\"},attrs:{\"disabled\":_vm.disabled,\"type\":\"file\",\"multiple\":\"true\"},on:{\"change\":_vm.change}}):_vm._e()])])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","import * as DateUtils from 'src/services/date_utils/date_utils.js'\nimport { uniq } from 'lodash'\n\nexport default {\n name: 'PollForm',\n props: ['visible'],\n data: () => ({\n pollType: 'single',\n options: ['', ''],\n expiryAmount: 10,\n expiryUnit: 'minutes'\n }),\n computed: {\n pollLimits () {\n return this.$store.state.instance.pollLimits\n },\n maxOptions () {\n return this.pollLimits.max_options\n },\n maxLength () {\n return this.pollLimits.max_option_chars\n },\n expiryUnits () {\n const allUnits = ['minutes', 'hours', 'days']\n const expiry = this.convertExpiryFromUnit\n return allUnits.filter(\n unit => this.pollLimits.max_expiration >= expiry(unit, 1)\n )\n },\n minExpirationInCurrentUnit () {\n return Math.ceil(\n this.convertExpiryToUnit(\n this.expiryUnit,\n this.pollLimits.min_expiration\n )\n )\n },\n maxExpirationInCurrentUnit () {\n return Math.floor(\n this.convertExpiryToUnit(\n this.expiryUnit,\n this.pollLimits.max_expiration\n )\n )\n }\n },\n methods: {\n clear () {\n this.pollType = 'single'\n this.options = ['', '']\n this.expiryAmount = 10\n this.expiryUnit = 'minutes'\n },\n nextOption (index) {\n const element = this.$el.querySelector(`#poll-${index + 1}`)\n if (element) {\n element.focus()\n } else {\n // Try adding an option and try focusing on it\n const addedOption = this.addOption()\n if (addedOption) {\n this.$nextTick(function () {\n this.nextOption(index)\n })\n }\n }\n },\n addOption () {\n if (this.options.length < this.maxOptions) {\n this.options.push('')\n return true\n }\n return false\n },\n deleteOption (index, event) {\n if (this.options.length > 2) {\n this.options.splice(index, 1)\n this.updatePollToParent()\n }\n },\n convertExpiryToUnit (unit, amount) {\n // Note: we want seconds and not milliseconds\n switch (unit) {\n case 'minutes': return (1000 * amount) / DateUtils.MINUTE\n case 'hours': return (1000 * amount) / DateUtils.HOUR\n case 'days': return (1000 * amount) / DateUtils.DAY\n }\n },\n convertExpiryFromUnit (unit, amount) {\n // Note: we want seconds and not milliseconds\n switch (unit) {\n case 'minutes': return 0.001 * amount * DateUtils.MINUTE\n case 'hours': return 0.001 * amount * DateUtils.HOUR\n case 'days': return 0.001 * amount * DateUtils.DAY\n }\n },\n expiryAmountChange () {\n this.expiryAmount =\n Math.max(this.minExpirationInCurrentUnit, this.expiryAmount)\n this.expiryAmount =\n Math.min(this.maxExpirationInCurrentUnit, this.expiryAmount)\n this.updatePollToParent()\n },\n updatePollToParent () {\n const expiresIn = this.convertExpiryFromUnit(\n this.expiryUnit,\n this.expiryAmount\n )\n\n const options = uniq(this.options.filter(option => option !== ''))\n if (options.length < 2) {\n this.$emit('update-poll', { error: this.$t('polls.not_enough_options') })\n return\n }\n this.$emit('update-poll', {\n options,\n multiple: this.pollType === 'multiple',\n expiresIn\n })\n }\n }\n}\n","function injectStyle (context) {\n require(\"!!vue-style-loader!css-loader?minimize!../../../node_modules/vue-loader/lib/style-compiler/index?{\\\"optionsId\\\":\\\"0\\\",\\\"vue\\\":true,\\\"scoped\\\":false,\\\"sourceMap\\\":false}!sass-loader!../../../node_modules/vue-loader/lib/selector?type=styles&index=0!./poll_form.vue\")\n}\n/* script */\nexport * from \"!!babel-loader!./poll_form.js\"\nimport __vue_script__ from \"!!babel-loader!./poll_form.js\"/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-1f896331\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./poll_form.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = injectStyle\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.visible)?_c('div',{staticClass:\"poll-form\"},[_vm._l((_vm.options),function(option,index){return _c('div',{key:index,staticClass:\"poll-option\"},[_c('div',{staticClass:\"input-container\"},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.options[index]),expression:\"options[index]\"}],staticClass:\"poll-option-input\",attrs:{\"id\":(\"poll-\" + index),\"type\":\"text\",\"placeholder\":_vm.$t('polls.option'),\"maxlength\":_vm.maxLength},domProps:{\"value\":(_vm.options[index])},on:{\"change\":_vm.updatePollToParent,\"keydown\":function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,\"enter\",13,$event.key,\"Enter\")){ return null; }$event.stopPropagation();$event.preventDefault();return _vm.nextOption(index)},\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.options, index, $event.target.value)}}})]),_vm._v(\" \"),(_vm.options.length > 2)?_c('div',{staticClass:\"icon-container\"},[_c('i',{staticClass:\"icon-cancel\",on:{\"click\":function($event){return _vm.deleteOption(index)}}})]):_vm._e()])}),_vm._v(\" \"),(_vm.options.length < _vm.maxOptions)?_c('a',{staticClass:\"add-option faint\",on:{\"click\":_vm.addOption}},[_c('i',{staticClass:\"icon-plus\"}),_vm._v(\"\\n \"+_vm._s(_vm.$t(\"polls.add_option\"))+\"\\n \")]):_vm._e(),_vm._v(\" \"),_c('div',{staticClass:\"poll-type-expiry\"},[_c('div',{staticClass:\"poll-type\",attrs:{\"title\":_vm.$t('polls.type')}},[_c('label',{staticClass:\"select\",attrs:{\"for\":\"poll-type-selector\"}},[_c('select',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.pollType),expression:\"pollType\"}],staticClass:\"select\",on:{\"change\":[function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = \"_value\" in o ? o._value : o.value;return val}); _vm.pollType=$event.target.multiple ? $$selectedVal : $$selectedVal[0]},_vm.updatePollToParent]}},[_c('option',{attrs:{\"value\":\"single\"}},[_vm._v(_vm._s(_vm.$t('polls.single_choice')))]),_vm._v(\" \"),_c('option',{attrs:{\"value\":\"multiple\"}},[_vm._v(_vm._s(_vm.$t('polls.multiple_choices')))])]),_vm._v(\" \"),_c('i',{staticClass:\"icon-down-open\"})])]),_vm._v(\" \"),_c('div',{staticClass:\"poll-expiry\",attrs:{\"title\":_vm.$t('polls.expiry')}},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.expiryAmount),expression:\"expiryAmount\"}],staticClass:\"expiry-amount hide-number-spinner\",attrs:{\"type\":\"number\",\"min\":_vm.minExpirationInCurrentUnit,\"max\":_vm.maxExpirationInCurrentUnit},domProps:{\"value\":(_vm.expiryAmount)},on:{\"change\":_vm.expiryAmountChange,\"input\":function($event){if($event.target.composing){ return; }_vm.expiryAmount=$event.target.value}}}),_vm._v(\" \"),_c('label',{staticClass:\"expiry-unit select\"},[_c('select',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.expiryUnit),expression:\"expiryUnit\"}],on:{\"change\":[function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = \"_value\" in o ? o._value : o.value;return val}); _vm.expiryUnit=$event.target.multiple ? $$selectedVal : $$selectedVal[0]},_vm.expiryAmountChange]}},_vm._l((_vm.expiryUnits),function(unit){return _c('option',{key:unit,domProps:{\"value\":unit}},[_vm._v(\"\\n \"+_vm._s(_vm.$t((\"time.\" + unit + \"_short\"), ['']))+\"\\n \")])}),0),_vm._v(\" \"),_c('i',{staticClass:\"icon-down-open\"})])])])],2):_vm._e()}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","import statusPoster from '../../services/status_poster/status_poster.service.js'\nimport MediaUpload from '../media_upload/media_upload.vue'\nimport ScopeSelector from '../scope_selector/scope_selector.vue'\nimport EmojiInput from '../emoji_input/emoji_input.vue'\nimport PollForm from '../poll/poll_form.vue'\nimport Attachment from '../attachment/attachment.vue'\nimport StatusContent from '../status_content/status_content.vue'\nimport fileTypeService from '../../services/file_type/file_type.service.js'\nimport { findOffset } from '../../services/offset_finder/offset_finder.service.js'\nimport { reject, map, uniqBy, debounce } from 'lodash'\nimport suggestor from '../emoji_input/suggestor.js'\nimport { mapGetters, mapState } from 'vuex'\nimport Checkbox from '../checkbox/checkbox.vue'\n\nconst buildMentionsString = ({ user, attentions = [] }, currentUser) => {\n let allAttentions = [...attentions]\n\n allAttentions.unshift(user)\n\n allAttentions = uniqBy(allAttentions, 'id')\n allAttentions = reject(allAttentions, { id: currentUser.id })\n\n let mentions = map(allAttentions, (attention) => {\n return `@${attention.screen_name}`\n })\n\n return mentions.length > 0 ? mentions.join(' ') + ' ' : ''\n}\n\n// Converts a string with px to a number like '2px' -> 2\nconst pxStringToNumber = (str) => {\n return Number(str.substring(0, str.length - 2))\n}\n\nconst PostStatusForm = {\n props: [\n 'replyTo',\n 'repliedUser',\n 'attentions',\n 'copyMessageScope',\n 'subject',\n 'disableSubject',\n 'disableScopeSelector',\n 'disableNotice',\n 'disableLockWarning',\n 'disablePolls',\n 'disableSensitivityCheckbox',\n 'disableSubmit',\n 'disablePreview',\n 'placeholder',\n 'maxHeight',\n 'postHandler',\n 'preserveFocus',\n 'autoFocus',\n 'fileLimit',\n 'submitOnEnter',\n 'emojiPickerPlacement'\n ],\n components: {\n MediaUpload,\n EmojiInput,\n PollForm,\n ScopeSelector,\n Checkbox,\n Attachment,\n StatusContent\n },\n mounted () {\n this.updateIdempotencyKey()\n this.resize(this.$refs.textarea)\n\n if (this.replyTo) {\n const textLength = this.$refs.textarea.value.length\n this.$refs.textarea.setSelectionRange(textLength, textLength)\n }\n\n if (this.replyTo || this.autoFocus) {\n this.$refs.textarea.focus()\n }\n },\n data () {\n const preset = this.$route.query.message\n let statusText = preset || ''\n\n const { scopeCopy } = this.$store.getters.mergedConfig\n\n if (this.replyTo) {\n const currentUser = this.$store.state.users.currentUser\n statusText = buildMentionsString({ user: this.repliedUser, attentions: this.attentions }, currentUser)\n }\n\n const scope = ((this.copyMessageScope && scopeCopy) || this.copyMessageScope === 'direct')\n ? this.copyMessageScope\n : this.$store.state.users.currentUser.default_scope\n\n const { postContentType: contentType } = this.$store.getters.mergedConfig\n\n return {\n dropFiles: [],\n uploadingFiles: false,\n error: null,\n posting: false,\n highlighted: 0,\n newStatus: {\n spoilerText: this.subject || '',\n status: statusText,\n nsfw: false,\n files: [],\n poll: {},\n mediaDescriptions: {},\n visibility: scope,\n contentType\n },\n caret: 0,\n pollFormVisible: false,\n showDropIcon: 'hide',\n dropStopTimeout: null,\n preview: null,\n previewLoading: false,\n emojiInputShown: false,\n idempotencyKey: ''\n }\n },\n computed: {\n users () {\n return this.$store.state.users.users\n },\n userDefaultScope () {\n return this.$store.state.users.currentUser.default_scope\n },\n showAllScopes () {\n return !this.mergedConfig.minimalScopesMode\n },\n emojiUserSuggestor () {\n return suggestor({\n emoji: [\n ...this.$store.state.instance.emoji,\n ...this.$store.state.instance.customEmoji\n ],\n users: this.$store.state.users.users,\n updateUsersList: (query) => this.$store.dispatch('searchUsers', { query })\n })\n },\n emojiSuggestor () {\n return suggestor({\n emoji: [\n ...this.$store.state.instance.emoji,\n ...this.$store.state.instance.customEmoji\n ]\n })\n },\n emoji () {\n return this.$store.state.instance.emoji || []\n },\n customEmoji () {\n return this.$store.state.instance.customEmoji || []\n },\n statusLength () {\n return this.newStatus.status.length\n },\n spoilerTextLength () {\n return this.newStatus.spoilerText.length\n },\n statusLengthLimit () {\n return this.$store.state.instance.textlimit\n },\n hasStatusLengthLimit () {\n return this.statusLengthLimit > 0\n },\n charactersLeft () {\n return this.statusLengthLimit - (this.statusLength + this.spoilerTextLength)\n },\n isOverLengthLimit () {\n return this.hasStatusLengthLimit && (this.charactersLeft < 0)\n },\n minimalScopesMode () {\n return this.$store.state.instance.minimalScopesMode\n },\n alwaysShowSubject () {\n return this.mergedConfig.alwaysShowSubjectInput\n },\n postFormats () {\n return this.$store.state.instance.postFormats || []\n },\n safeDMEnabled () {\n return this.$store.state.instance.safeDM\n },\n pollsAvailable () {\n return this.$store.state.instance.pollsAvailable &&\n this.$store.state.instance.pollLimits.max_options >= 2 &&\n this.disablePolls !== true\n },\n hideScopeNotice () {\n return this.disableNotice || this.$store.getters.mergedConfig.hideScopeNotice\n },\n pollContentError () {\n return this.pollFormVisible &&\n this.newStatus.poll &&\n this.newStatus.poll.error\n },\n showPreview () {\n return !this.disablePreview && (!!this.preview || this.previewLoading)\n },\n emptyStatus () {\n return this.newStatus.status.trim() === '' && this.newStatus.files.length === 0\n },\n uploadFileLimitReached () {\n return this.newStatus.files.length >= this.fileLimit\n },\n ...mapGetters(['mergedConfig']),\n ...mapState({\n mobileLayout: state => state.interface.mobileLayout\n })\n },\n watch: {\n 'newStatus': {\n deep: true,\n handler () {\n this.statusChanged()\n }\n }\n },\n methods: {\n statusChanged () {\n this.autoPreview()\n this.updateIdempotencyKey()\n },\n clearStatus () {\n const newStatus = this.newStatus\n this.newStatus = {\n status: '',\n spoilerText: '',\n files: [],\n visibility: newStatus.visibility,\n contentType: newStatus.contentType,\n poll: {},\n mediaDescriptions: {}\n }\n this.pollFormVisible = false\n this.$refs.mediaUpload && this.$refs.mediaUpload.clearFile()\n this.clearPollForm()\n if (this.preserveFocus) {\n this.$nextTick(() => {\n this.$refs.textarea.focus()\n })\n }\n let el = this.$el.querySelector('textarea')\n el.style.height = 'auto'\n el.style.height = undefined\n this.error = null\n if (this.preview) this.previewStatus()\n },\n async postStatus (event, newStatus, opts = {}) {\n if (this.posting) { return }\n if (this.disableSubmit) { return }\n if (this.emojiInputShown) { return }\n if (this.submitOnEnter) {\n event.stopPropagation()\n event.preventDefault()\n }\n\n if (this.emptyStatus) {\n this.error = this.$t('post_status.empty_status_error')\n return\n }\n\n const poll = this.pollFormVisible ? this.newStatus.poll : {}\n if (this.pollContentError) {\n this.error = this.pollContentError\n return\n }\n\n this.posting = true\n\n try {\n await this.setAllMediaDescriptions()\n } catch (e) {\n this.error = this.$t('post_status.media_description_error')\n this.posting = false\n return\n }\n\n const postingOptions = {\n status: newStatus.status,\n spoilerText: newStatus.spoilerText || null,\n visibility: newStatus.visibility,\n sensitive: newStatus.nsfw,\n media: newStatus.files,\n store: this.$store,\n inReplyToStatusId: this.replyTo,\n contentType: newStatus.contentType,\n poll,\n idempotencyKey: this.idempotencyKey\n }\n\n const postHandler = this.postHandler ? this.postHandler : statusPoster.postStatus\n\n postHandler(postingOptions).then((data) => {\n if (!data.error) {\n this.clearStatus()\n this.$emit('posted', data)\n } else {\n this.error = data.error\n }\n this.posting = false\n })\n },\n previewStatus () {\n if (this.emptyStatus && this.newStatus.spoilerText.trim() === '') {\n this.preview = { error: this.$t('post_status.preview_empty') }\n this.previewLoading = false\n return\n }\n const newStatus = this.newStatus\n this.previewLoading = true\n statusPoster.postStatus({\n status: newStatus.status,\n spoilerText: newStatus.spoilerText || null,\n visibility: newStatus.visibility,\n sensitive: newStatus.nsfw,\n media: [],\n store: this.$store,\n inReplyToStatusId: this.replyTo,\n contentType: newStatus.contentType,\n poll: {},\n preview: true\n }).then((data) => {\n // Don't apply preview if not loading, because it means\n // user has closed the preview manually.\n if (!this.previewLoading) return\n if (!data.error) {\n this.preview = data\n } else {\n this.preview = { error: data.error }\n }\n }).catch((error) => {\n this.preview = { error }\n }).finally(() => {\n this.previewLoading = false\n })\n },\n debouncePreviewStatus: debounce(function () { this.previewStatus() }, 500),\n autoPreview () {\n if (!this.preview) return\n this.previewLoading = true\n this.debouncePreviewStatus()\n },\n closePreview () {\n this.preview = null\n this.previewLoading = false\n },\n togglePreview () {\n if (this.showPreview) {\n this.closePreview()\n } else {\n this.previewStatus()\n }\n },\n addMediaFile (fileInfo) {\n this.newStatus.files.push(fileInfo)\n this.$emit('resize', { delayed: true })\n },\n removeMediaFile (fileInfo) {\n let index = this.newStatus.files.indexOf(fileInfo)\n this.newStatus.files.splice(index, 1)\n this.$emit('resize')\n },\n uploadFailed (errString, templateArgs) {\n templateArgs = templateArgs || {}\n this.error = this.$t('upload.error.base') + ' ' + this.$t('upload.error.' + errString, templateArgs)\n },\n startedUploadingFiles () {\n this.uploadingFiles = true\n },\n finishedUploadingFiles () {\n this.$emit('resize')\n this.uploadingFiles = false\n },\n type (fileInfo) {\n return fileTypeService.fileType(fileInfo.mimetype)\n },\n paste (e) {\n this.autoPreview()\n this.resize(e)\n if (e.clipboardData.files.length > 0) {\n // prevent pasting of file as text\n e.preventDefault()\n // Strangely, files property gets emptied after event propagation\n // Trying to wrap it in array doesn't work. Plus I doubt it's possible\n // to hold more than one file in clipboard.\n this.dropFiles = [e.clipboardData.files[0]]\n }\n },\n fileDrop (e) {\n if (e.dataTransfer && e.dataTransfer.types.includes('Files')) {\n e.preventDefault() // allow dropping text like before\n this.dropFiles = e.dataTransfer.files\n clearTimeout(this.dropStopTimeout)\n this.showDropIcon = 'hide'\n }\n },\n fileDragStop (e) {\n // The false-setting is done with delay because just using leave-events\n // directly caused unwanted flickering, this is not perfect either but\n // much less noticable.\n clearTimeout(this.dropStopTimeout)\n this.showDropIcon = 'fade'\n this.dropStopTimeout = setTimeout(() => (this.showDropIcon = 'hide'), 500)\n },\n fileDrag (e) {\n e.dataTransfer.dropEffect = this.uploadFileLimitReached ? 'none' : 'copy'\n if (e.dataTransfer && e.dataTransfer.types.includes('Files')) {\n clearTimeout(this.dropStopTimeout)\n this.showDropIcon = 'show'\n }\n },\n onEmojiInputInput (e) {\n this.$nextTick(() => {\n this.resize(this.$refs['textarea'])\n })\n },\n resize (e) {\n const target = e.target || e\n if (!(target instanceof window.Element)) { return }\n\n // Reset to default height for empty form, nothing else to do here.\n if (target.value === '') {\n target.style.height = null\n this.$emit('resize')\n this.$refs['emoji-input'].resize()\n return\n }\n\n const formRef = this.$refs['form']\n const bottomRef = this.$refs['bottom']\n /* Scroller is either `window` (replies in TL), sidebar (main post form,\n * replies in notifs) or mobile post form. Note that getting and setting\n * scroll is different for `Window` and `Element`s\n */\n const bottomBottomPaddingStr = window.getComputedStyle(bottomRef)['padding-bottom']\n const bottomBottomPadding = pxStringToNumber(bottomBottomPaddingStr)\n\n const scrollerRef = this.$el.closest('.sidebar-scroller') ||\n this.$el.closest('.post-form-modal-view') ||\n window\n\n // Getting info about padding we have to account for, removing 'px' part\n const topPaddingStr = window.getComputedStyle(target)['padding-top']\n const bottomPaddingStr = window.getComputedStyle(target)['padding-bottom']\n const topPadding = pxStringToNumber(topPaddingStr)\n const bottomPadding = pxStringToNumber(bottomPaddingStr)\n const vertPadding = topPadding + bottomPadding\n\n const oldHeight = pxStringToNumber(target.style.height)\n\n /* Explanation:\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight\n * scrollHeight returns element's scrollable content height, i.e. visible\n * element + overscrolled parts of it. We use it to determine when text\n * inside the textarea exceeded its height, so we can set height to prevent\n * overscroll, i.e. make textarea grow with the text. HOWEVER, since we\n * explicitly set new height, scrollHeight won't go below that, so we can't\n * SHRINK the textarea when there's extra space. To workaround that we set\n * height to 'auto' which makes textarea tiny again, so that scrollHeight\n * will match text height again. HOWEVER, shrinking textarea can screw with\n * the scroll since there might be not enough padding around form-bottom to even\n * warrant a scroll, so it will jump to 0 and refuse to move anywhere,\n * so we check current scroll position before shrinking and then restore it\n * with needed delta.\n */\n\n // this part has to be BEFORE the content size update\n const currentScroll = scrollerRef === window\n ? scrollerRef.scrollY\n : scrollerRef.scrollTop\n const scrollerHeight = scrollerRef === window\n ? scrollerRef.innerHeight\n : scrollerRef.offsetHeight\n const scrollerBottomBorder = currentScroll + scrollerHeight\n\n // BEGIN content size update\n target.style.height = 'auto'\n const heightWithoutPadding = Math.floor(target.scrollHeight - vertPadding)\n let newHeight = this.maxHeight ? Math.min(heightWithoutPadding, this.maxHeight) : heightWithoutPadding\n // This is a bit of a hack to combat target.scrollHeight being different on every other input\n // on some browsers for whatever reason. Don't change the height if difference is 1px or less.\n if (Math.abs(newHeight - oldHeight) <= 1) {\n newHeight = oldHeight\n }\n target.style.height = `${newHeight}px`\n this.$emit('resize', newHeight)\n // END content size update\n\n // We check where the bottom border of form-bottom element is, this uses findOffset\n // to find offset relative to scrollable container (scroller)\n const bottomBottomBorder = bottomRef.offsetHeight + findOffset(bottomRef, scrollerRef).top + bottomBottomPadding\n\n const isBottomObstructed = scrollerBottomBorder < bottomBottomBorder\n const isFormBiggerThanScroller = scrollerHeight < formRef.offsetHeight\n const bottomChangeDelta = bottomBottomBorder - scrollerBottomBorder\n // The intention is basically this;\n // Keep form-bottom always visible so that submit button is in view EXCEPT\n // if form element bigger than scroller and caret isn't at the end, so that\n // if you scroll up and edit middle of text you won't get scrolled back to bottom\n const shouldScrollToBottom = isBottomObstructed &&\n !(isFormBiggerThanScroller &&\n this.$refs.textarea.selectionStart !== this.$refs.textarea.value.length)\n const totalDelta = shouldScrollToBottom ? bottomChangeDelta : 0\n const targetScroll = currentScroll + totalDelta\n\n if (scrollerRef === window) {\n scrollerRef.scroll(0, targetScroll)\n } else {\n scrollerRef.scrollTop = targetScroll\n }\n\n this.$refs['emoji-input'].resize()\n },\n showEmojiPicker () {\n this.$refs['textarea'].focus()\n this.$refs['emoji-input'].triggerShowPicker()\n },\n clearError () {\n this.error = null\n },\n changeVis (visibility) {\n this.newStatus.visibility = visibility\n },\n togglePollForm () {\n this.pollFormVisible = !this.pollFormVisible\n },\n setPoll (poll) {\n this.newStatus.poll = poll\n },\n clearPollForm () {\n if (this.$refs.pollForm) {\n this.$refs.pollForm.clear()\n }\n },\n dismissScopeNotice () {\n this.$store.dispatch('setOption', { name: 'hideScopeNotice', value: true })\n },\n setMediaDescription (id) {\n const description = this.newStatus.mediaDescriptions[id]\n if (!description || description.trim() === '') return\n return statusPoster.setMediaDescription({ store: this.$store, id, description })\n },\n setAllMediaDescriptions () {\n const ids = this.newStatus.files.map(file => file.id)\n return Promise.all(ids.map(id => this.setMediaDescription(id)))\n },\n handleEmojiInputShow (value) {\n this.emojiInputShown = value\n },\n updateIdempotencyKey () {\n this.idempotencyKey = Date.now().toString()\n },\n openProfileTab () {\n this.$store.dispatch('openSettingsModalTab', 'profile')\n }\n }\n}\n\nexport default PostStatusForm\n","function injectStyle (context) {\n require(\"!!vue-style-loader!css-loader?minimize!../../../node_modules/vue-loader/lib/style-compiler/index?{\\\"optionsId\\\":\\\"0\\\",\\\"vue\\\":true,\\\"scoped\\\":false,\\\"sourceMap\\\":false}!sass-loader!../../../node_modules/vue-loader/lib/selector?type=styles&index=0!./post_status_form.vue\")\n}\n/* script */\nexport * from \"!!babel-loader!./post_status_form.js\"\nimport __vue_script__ from \"!!babel-loader!./post_status_form.js\"/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-c3d07a7c\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./post_status_form.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = injectStyle\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{ref:\"form\",staticClass:\"post-status-form\"},[_c('form',{attrs:{\"autocomplete\":\"off\"},on:{\"submit\":function($event){$event.preventDefault();},\"dragover\":function($event){$event.preventDefault();return _vm.fileDrag($event)}}},[_c('div',{directives:[{name:\"show\",rawName:\"v-show\",value:(_vm.showDropIcon !== 'hide'),expression:\"showDropIcon !== 'hide'\"}],staticClass:\"drop-indicator\",class:[_vm.uploadFileLimitReached ? 'icon-block' : 'icon-upload'],style:({ animation: _vm.showDropIcon === 'show' ? 'fade-in 0.25s' : 'fade-out 0.5s' }),on:{\"dragleave\":_vm.fileDragStop,\"drop\":function($event){$event.stopPropagation();return _vm.fileDrop($event)}}}),_vm._v(\" \"),_c('div',{staticClass:\"form-group\"},[(!_vm.$store.state.users.currentUser.locked && _vm.newStatus.visibility == 'private' && !_vm.disableLockWarning)?_c('i18n',{staticClass:\"visibility-notice\",attrs:{\"path\":\"post_status.account_not_locked_warning\",\"tag\":\"p\"}},[_c('a',{attrs:{\"href\":\"#\"},on:{\"click\":_vm.openProfileTab}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('post_status.account_not_locked_warning_link'))+\"\\n \")])]):_vm._e(),_vm._v(\" \"),(!_vm.hideScopeNotice && _vm.newStatus.visibility === 'public')?_c('p',{staticClass:\"visibility-notice notice-dismissible\"},[_c('span',[_vm._v(_vm._s(_vm.$t('post_status.scope_notice.public')))]),_vm._v(\" \"),_c('a',{staticClass:\"button-icon dismiss\",on:{\"click\":function($event){$event.preventDefault();return _vm.dismissScopeNotice()}}},[_c('i',{staticClass:\"icon-cancel\"})])]):(!_vm.hideScopeNotice && _vm.newStatus.visibility === 'unlisted')?_c('p',{staticClass:\"visibility-notice notice-dismissible\"},[_c('span',[_vm._v(_vm._s(_vm.$t('post_status.scope_notice.unlisted')))]),_vm._v(\" \"),_c('a',{staticClass:\"button-icon dismiss\",on:{\"click\":function($event){$event.preventDefault();return _vm.dismissScopeNotice()}}},[_c('i',{staticClass:\"icon-cancel\"})])]):(!_vm.hideScopeNotice && _vm.newStatus.visibility === 'private' && _vm.$store.state.users.currentUser.locked)?_c('p',{staticClass:\"visibility-notice notice-dismissible\"},[_c('span',[_vm._v(_vm._s(_vm.$t('post_status.scope_notice.private')))]),_vm._v(\" \"),_c('a',{staticClass:\"button-icon dismiss\",on:{\"click\":function($event){$event.preventDefault();return _vm.dismissScopeNotice()}}},[_c('i',{staticClass:\"icon-cancel\"})])]):(_vm.newStatus.visibility === 'direct')?_c('p',{staticClass:\"visibility-notice\"},[(_vm.safeDMEnabled)?_c('span',[_vm._v(_vm._s(_vm.$t('post_status.direct_warning_to_first_only')))]):_c('span',[_vm._v(_vm._s(_vm.$t('post_status.direct_warning_to_all')))])]):_vm._e(),_vm._v(\" \"),(!_vm.disablePreview)?_c('div',{staticClass:\"preview-heading faint\"},[_c('a',{staticClass:\"preview-toggle faint\",on:{\"click\":function($event){$event.stopPropagation();$event.preventDefault();return _vm.togglePreview($event)}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('post_status.preview'))+\"\\n \"),_c('i',{class:_vm.showPreview ? 'icon-left-open' : 'icon-right-open'})]),_vm._v(\" \"),_c('i',{directives:[{name:\"show\",rawName:\"v-show\",value:(_vm.previewLoading),expression:\"previewLoading\"}],staticClass:\"icon-spin3 animate-spin\"})]):_vm._e(),_vm._v(\" \"),(_vm.showPreview)?_c('div',{staticClass:\"preview-container\"},[(!_vm.preview)?_c('div',{staticClass:\"preview-status\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.loading'))+\"\\n \")]):(_vm.preview.error)?_c('div',{staticClass:\"preview-status preview-error\"},[_vm._v(\"\\n \"+_vm._s(_vm.preview.error)+\"\\n \")]):_c('StatusContent',{staticClass:\"preview-status\",attrs:{\"status\":_vm.preview}})],1):_vm._e(),_vm._v(\" \"),(!_vm.disableSubject && (_vm.newStatus.spoilerText || _vm.alwaysShowSubject))?_c('EmojiInput',{staticClass:\"form-control\",attrs:{\"enable-emoji-picker\":\"\",\"suggest\":_vm.emojiSuggestor},model:{value:(_vm.newStatus.spoilerText),callback:function ($$v) {_vm.$set(_vm.newStatus, \"spoilerText\", $$v)},expression:\"newStatus.spoilerText\"}},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.newStatus.spoilerText),expression:\"newStatus.spoilerText\"}],staticClass:\"form-post-subject\",attrs:{\"type\":\"text\",\"placeholder\":_vm.$t('post_status.content_warning'),\"disabled\":_vm.posting},domProps:{\"value\":(_vm.newStatus.spoilerText)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.newStatus, \"spoilerText\", $event.target.value)}}})]):_vm._e(),_vm._v(\" \"),_c('EmojiInput',{ref:\"emoji-input\",staticClass:\"form-control main-input\",attrs:{\"suggest\":_vm.emojiUserSuggestor,\"placement\":_vm.emojiPickerPlacement,\"enable-emoji-picker\":\"\",\"hide-emoji-button\":\"\",\"newline-on-ctrl-enter\":_vm.submitOnEnter,\"enable-sticker-picker\":\"\"},on:{\"input\":_vm.onEmojiInputInput,\"sticker-uploaded\":_vm.addMediaFile,\"sticker-upload-failed\":_vm.uploadFailed,\"shown\":_vm.handleEmojiInputShow},model:{value:(_vm.newStatus.status),callback:function ($$v) {_vm.$set(_vm.newStatus, \"status\", $$v)},expression:\"newStatus.status\"}},[_c('textarea',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.newStatus.status),expression:\"newStatus.status\"}],ref:\"textarea\",staticClass:\"form-post-body\",class:{ 'scrollable-form': !!_vm.maxHeight },attrs:{\"placeholder\":_vm.placeholder || _vm.$t('post_status.default'),\"rows\":\"1\",\"cols\":\"1\",\"disabled\":_vm.posting},domProps:{\"value\":(_vm.newStatus.status)},on:{\"keydown\":[function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,\"enter\",13,$event.key,\"Enter\")){ return null; }if($event.ctrlKey||$event.shiftKey||$event.altKey||$event.metaKey){ return null; }_vm.submitOnEnter && _vm.postStatus($event, _vm.newStatus)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,\"enter\",13,$event.key,\"Enter\")){ return null; }if(!$event.metaKey){ return null; }return _vm.postStatus($event, _vm.newStatus)},function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,\"enter\",13,$event.key,\"Enter\")){ return null; }if(!$event.ctrlKey){ return null; }!_vm.submitOnEnter && _vm.postStatus($event, _vm.newStatus)}],\"input\":[function($event){if($event.target.composing){ return; }_vm.$set(_vm.newStatus, \"status\", $event.target.value)},_vm.resize],\"compositionupdate\":_vm.resize,\"paste\":_vm.paste}}),_vm._v(\" \"),(_vm.hasStatusLengthLimit)?_c('p',{staticClass:\"character-counter faint\",class:{ error: _vm.isOverLengthLimit }},[_vm._v(\"\\n \"+_vm._s(_vm.charactersLeft)+\"\\n \")]):_vm._e()]),_vm._v(\" \"),(!_vm.disableScopeSelector)?_c('div',{staticClass:\"visibility-tray\"},[_c('scope-selector',{attrs:{\"show-all\":_vm.showAllScopes,\"user-default\":_vm.userDefaultScope,\"original-scope\":_vm.copyMessageScope,\"initial-scope\":_vm.newStatus.visibility,\"on-scope-change\":_vm.changeVis}}),_vm._v(\" \"),(_vm.postFormats.length > 1)?_c('div',{staticClass:\"text-format\"},[_c('label',{staticClass:\"select\",attrs:{\"for\":\"post-content-type\"}},[_c('select',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.newStatus.contentType),expression:\"newStatus.contentType\"}],staticClass:\"form-control\",attrs:{\"id\":\"post-content-type\"},on:{\"change\":function($event){var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = \"_value\" in o ? o._value : o.value;return val}); _vm.$set(_vm.newStatus, \"contentType\", $event.target.multiple ? $$selectedVal : $$selectedVal[0])}}},_vm._l((_vm.postFormats),function(postFormat){return _c('option',{key:postFormat,domProps:{\"value\":postFormat}},[_vm._v(\"\\n \"+_vm._s(_vm.$t((\"post_status.content_type[\\\"\" + postFormat + \"\\\"]\")))+\"\\n \")])}),0),_vm._v(\" \"),_c('i',{staticClass:\"icon-down-open\"})])]):_vm._e(),_vm._v(\" \"),(_vm.postFormats.length === 1 && _vm.postFormats[0] !== 'text/plain')?_c('div',{staticClass:\"text-format\"},[_c('span',{staticClass:\"only-format\"},[_vm._v(\"\\n \"+_vm._s(_vm.$t((\"post_status.content_type[\\\"\" + (_vm.postFormats[0]) + \"\\\"]\")))+\"\\n \")])]):_vm._e()],1):_vm._e()],1),_vm._v(\" \"),(_vm.pollsAvailable)?_c('poll-form',{ref:\"pollForm\",attrs:{\"visible\":_vm.pollFormVisible},on:{\"update-poll\":_vm.setPoll}}):_vm._e(),_vm._v(\" \"),_c('div',{ref:\"bottom\",staticClass:\"form-bottom\"},[_c('div',{staticClass:\"form-bottom-left\"},[_c('media-upload',{ref:\"mediaUpload\",staticClass:\"media-upload-icon\",attrs:{\"drop-files\":_vm.dropFiles,\"disabled\":_vm.uploadFileLimitReached},on:{\"uploading\":_vm.startedUploadingFiles,\"uploaded\":_vm.addMediaFile,\"upload-failed\":_vm.uploadFailed,\"all-uploaded\":_vm.finishedUploadingFiles}}),_vm._v(\" \"),_c('div',{staticClass:\"emoji-icon\"},[_c('i',{staticClass:\"icon-smile btn btn-default\",attrs:{\"title\":_vm.$t('emoji.add_emoji')},on:{\"click\":_vm.showEmojiPicker}})]),_vm._v(\" \"),(_vm.pollsAvailable)?_c('div',{staticClass:\"poll-icon\",class:{ selected: _vm.pollFormVisible }},[_c('i',{staticClass:\"icon-chart-bar btn btn-default\",attrs:{\"title\":_vm.$t('polls.add_poll')},on:{\"click\":_vm.togglePollForm}})]):_vm._e()],1),_vm._v(\" \"),(_vm.posting)?_c('button',{staticClass:\"btn btn-default\",attrs:{\"disabled\":\"\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('post_status.posting'))+\"\\n \")]):(_vm.isOverLengthLimit)?_c('button',{staticClass:\"btn btn-default\",attrs:{\"disabled\":\"\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.submit'))+\"\\n \")]):_c('button',{staticClass:\"btn btn-default\",attrs:{\"disabled\":_vm.uploadingFiles || _vm.disableSubmit},on:{\"touchstart\":function($event){$event.stopPropagation();$event.preventDefault();return _vm.postStatus($event, _vm.newStatus)},\"click\":function($event){$event.stopPropagation();$event.preventDefault();return _vm.postStatus($event, _vm.newStatus)}}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('general.submit'))+\"\\n \")])]),_vm._v(\" \"),(_vm.error)?_c('div',{staticClass:\"alert error\"},[_vm._v(\"\\n Error: \"+_vm._s(_vm.error)+\"\\n \"),_c('i',{staticClass:\"button-icon icon-cancel\",on:{\"click\":_vm.clearError}})]):_vm._e(),_vm._v(\" \"),_c('div',{staticClass:\"attachments\"},_vm._l((_vm.newStatus.files),function(file){return _c('div',{key:file.url,staticClass:\"media-upload-wrapper\"},[_c('i',{staticClass:\"fa button-icon icon-cancel\",on:{\"click\":function($event){return _vm.removeMediaFile(file)}}}),_vm._v(\" \"),_c('attachment',{attrs:{\"attachment\":file,\"set-media\":function () { return _vm.$store.dispatch('setMedia', _vm.newStatus.files); },\"size\":\"small\",\"allow-play\":\"false\"}}),_vm._v(\" \"),_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.newStatus.mediaDescriptions[file.id]),expression:\"newStatus.mediaDescriptions[file.id]\"}],attrs:{\"type\":\"text\",\"placeholder\":_vm.$t('post_status.media_description')},domProps:{\"value\":(_vm.newStatus.mediaDescriptions[file.id])},on:{\"keydown\":function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,\"enter\",13,$event.key,\"Enter\")){ return null; }$event.preventDefault();},\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.newStatus.mediaDescriptions, file.id, $event.target.value)}}})],1)}),0),_vm._v(\" \"),(_vm.newStatus.files.length > 0 && !_vm.disableSensitivityCheckbox)?_c('div',{staticClass:\"upload_settings\"},[_c('Checkbox',{model:{value:(_vm.newStatus.nsfw),callback:function ($$v) {_vm.$set(_vm.newStatus, \"nsfw\", $$v)},expression:\"newStatus.nsfw\"}},[_vm._v(\"\\n \"+_vm._s(_vm.$t('post_status.attachments_sensitive'))+\"\\n \")])],1):_vm._e()],1)])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","import StillImage from '../still-image/still-image.vue'\nimport VideoAttachment from '../video_attachment/video_attachment.vue'\nimport nsfwImage from '../../assets/nsfw.png'\nimport fileTypeService from '../../services/file_type/file_type.service.js'\nimport { mapGetters } from 'vuex'\n\nconst Attachment = {\n props: [\n 'attachment',\n 'nsfw',\n 'size',\n 'allowPlay',\n 'setMedia',\n 'naturalSizeLoad'\n ],\n data () {\n return {\n nsfwImage: this.$store.state.instance.nsfwCensorImage || nsfwImage,\n hideNsfwLocal: this.$store.getters.mergedConfig.hideNsfw,\n preloadImage: this.$store.getters.mergedConfig.preloadImage,\n loading: false,\n img: fileTypeService.fileType(this.attachment.mimetype) === 'image' && document.createElement('img'),\n modalOpen: false,\n showHidden: false\n }\n },\n components: {\n StillImage,\n VideoAttachment\n },\n computed: {\n usePlaceholder () {\n return this.size === 'hide' || this.type === 'unknown'\n },\n placeholderName () {\n if (this.attachment.description === '' || !this.attachment.description) {\n return this.type.toUpperCase()\n }\n return this.attachment.description\n },\n placeholderIconClass () {\n if (this.type === 'image') return 'icon-picture'\n if (this.type === 'video') return 'icon-video'\n if (this.type === 'audio') return 'icon-music'\n return 'icon-doc'\n },\n referrerpolicy () {\n return this.$store.state.instance.mediaProxyAvailable ? '' : 'no-referrer'\n },\n type () {\n return fileTypeService.fileType(this.attachment.mimetype)\n },\n hidden () {\n return this.nsfw && this.hideNsfwLocal && !this.showHidden\n },\n isEmpty () {\n return (this.type === 'html' && !this.attachment.oembed) || this.type === 'unknown'\n },\n isSmall () {\n return this.size === 'small'\n },\n fullwidth () {\n if (this.size === 'hide') return false\n return this.type === 'html' || this.type === 'audio' || this.type === 'unknown'\n },\n useModal () {\n const modalTypes = this.size === 'hide' ? ['image', 'video', 'audio']\n : this.mergedConfig.playVideosInModal\n ? ['image', 'video']\n : ['image']\n return modalTypes.includes(this.type)\n },\n ...mapGetters(['mergedConfig'])\n },\n methods: {\n linkClicked ({ target }) {\n if (target.tagName === 'A') {\n window.open(target.href, '_blank')\n }\n },\n openModal (event) {\n if (this.useModal) {\n event.stopPropagation()\n event.preventDefault()\n this.setMedia()\n this.$store.dispatch('setCurrent', this.attachment)\n }\n },\n toggleHidden (event) {\n if (\n (this.mergedConfig.useOneClickNsfw && !this.showHidden) &&\n (this.type !== 'video' || this.mergedConfig.playVideosInModal)\n ) {\n this.openModal(event)\n return\n }\n if (this.img && !this.preloadImage) {\n if (this.img.onload) {\n this.img.onload()\n } else {\n this.loading = true\n this.img.src = this.attachment.url\n this.img.onload = () => {\n this.loading = false\n this.showHidden = !this.showHidden\n }\n }\n } else {\n this.showHidden = !this.showHidden\n }\n },\n onImageLoad (image) {\n const width = image.naturalWidth\n const height = image.naturalHeight\n this.naturalSizeLoad && this.naturalSizeLoad({ width, height })\n }\n }\n}\n\nexport default Attachment\n","function injectStyle (context) {\n require(\"!!vue-style-loader!css-loader?minimize!../../../node_modules/vue-loader/lib/style-compiler/index?{\\\"optionsId\\\":\\\"0\\\",\\\"vue\\\":true,\\\"scoped\\\":false,\\\"sourceMap\\\":false}!sass-loader!../../../node_modules/vue-loader/lib/selector?type=styles&index=0!./attachment.vue\")\n}\n/* script */\nexport * from \"!!babel-loader!./attachment.js\"\nimport __vue_script__ from \"!!babel-loader!./attachment.js\"/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-6c00fc80\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./attachment.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = injectStyle\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","var render = function () {\nvar _obj;\nvar _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.usePlaceholder)?_c('div',{class:{ 'fullwidth': _vm.fullwidth },on:{\"click\":_vm.openModal}},[(_vm.type !== 'html')?_c('a',{staticClass:\"placeholder\",attrs:{\"target\":\"_blank\",\"href\":_vm.attachment.url,\"alt\":_vm.attachment.description,\"title\":_vm.attachment.description}},[_c('span',{class:_vm.placeholderIconClass}),_vm._v(\" \"),_c('b',[_vm._v(_vm._s(_vm.nsfw ? \"NSFW / \" : \"\"))]),_vm._v(_vm._s(_vm.placeholderName)+\"\\n \")]):_vm._e()]):_c('div',{directives:[{name:\"show\",rawName:\"v-show\",value:(!_vm.isEmpty),expression:\"!isEmpty\"}],staticClass:\"attachment\",class:( _obj = {}, _obj[_vm.type] = true, _obj.loading = _vm.loading, _obj['fullwidth'] = _vm.fullwidth, _obj['nsfw-placeholder'] = _vm.hidden, _obj )},[(_vm.hidden)?_c('a',{staticClass:\"image-attachment\",attrs:{\"href\":_vm.attachment.url,\"alt\":_vm.attachment.description,\"title\":_vm.attachment.description},on:{\"click\":function($event){$event.preventDefault();return _vm.toggleHidden($event)}}},[_c('img',{key:_vm.nsfwImage,staticClass:\"nsfw\",class:{'small': _vm.isSmall},attrs:{\"src\":_vm.nsfwImage}}),_vm._v(\" \"),(_vm.type === 'video')?_c('i',{staticClass:\"play-icon icon-play-circled\"}):_vm._e()]):_vm._e(),_vm._v(\" \"),(_vm.nsfw && _vm.hideNsfwLocal && !_vm.hidden)?_c('div',{staticClass:\"hider\"},[_c('a',{attrs:{\"href\":\"#\"},on:{\"click\":function($event){$event.preventDefault();return _vm.toggleHidden($event)}}},[_vm._v(\"Hide\")])]):_vm._e(),_vm._v(\" \"),(_vm.type === 'image' && (!_vm.hidden || _vm.preloadImage))?_c('a',{staticClass:\"image-attachment\",class:{'hidden': _vm.hidden && _vm.preloadImage },attrs:{\"href\":_vm.attachment.url,\"target\":\"_blank\"},on:{\"click\":_vm.openModal}},[_c('StillImage',{staticClass:\"image\",attrs:{\"referrerpolicy\":_vm.referrerpolicy,\"mimetype\":_vm.attachment.mimetype,\"src\":_vm.attachment.large_thumb_url || _vm.attachment.url,\"image-load-handler\":_vm.onImageLoad,\"alt\":_vm.attachment.description}})],1):_vm._e(),_vm._v(\" \"),(_vm.type === 'video' && !_vm.hidden)?_c('a',{staticClass:\"video-container\",class:{'small': _vm.isSmall},attrs:{\"href\":_vm.allowPlay ? undefined : _vm.attachment.url},on:{\"click\":_vm.openModal}},[_c('VideoAttachment',{staticClass:\"video\",attrs:{\"attachment\":_vm.attachment,\"controls\":_vm.allowPlay}}),_vm._v(\" \"),(!_vm.allowPlay)?_c('i',{staticClass:\"play-icon icon-play-circled\"}):_vm._e()],1):_vm._e(),_vm._v(\" \"),(_vm.type === 'audio')?_c('audio',{attrs:{\"src\":_vm.attachment.url,\"alt\":_vm.attachment.description,\"title\":_vm.attachment.description,\"controls\":\"\"}}):_vm._e(),_vm._v(\" \"),(_vm.type === 'html' && _vm.attachment.oembed)?_c('div',{staticClass:\"oembed\",on:{\"click\":function($event){$event.preventDefault();return _vm.linkClicked($event)}}},[(_vm.attachment.thumb_url)?_c('div',{staticClass:\"image\"},[_c('img',{attrs:{\"src\":_vm.attachment.thumb_url}})]):_vm._e(),_vm._v(\" \"),_c('div',{staticClass:\"text\"},[_c('h1',[_c('a',{attrs:{\"href\":_vm.attachment.url}},[_vm._v(_vm._s(_vm.attachment.oembed.title))])]),_vm._v(\" \"),_c('div',{domProps:{\"innerHTML\":_vm._s(_vm.attachment.oembed.oembedHTML)}})])]):_vm._e()])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","\n \n\n\n\n","/* script */\nexport * from \"!!babel-loader!../../../node_modules/vue-loader/lib/selector?type=script&index=0!./timeago.vue\"\nimport __vue_script__ from \"!!babel-loader!../../../node_modules/vue-loader/lib/selector?type=script&index=0!./timeago.vue\"\n/* template */\nimport {render as __vue_render__, staticRenderFns as __vue_static_render_fns__} from \"!!../../../node_modules/vue-loader/lib/template-compiler/index?{\\\"id\\\":\\\"data-v-ac499830\\\",\\\"hasScoped\\\":false,\\\"optionsId\\\":\\\"0\\\",\\\"buble\\\":{\\\"transforms\\\":{}}}!../../../node_modules/vue-loader/lib/selector?type=template&index=0!./timeago.vue\"\n/* template functional */\nvar __vue_template_functional__ = false\n/* styles */\nvar __vue_styles__ = null\n/* scopeId */\nvar __vue_scopeId__ = null\n/* moduleIdentifier (server only) */\nvar __vue_module_identifier__ = null\nimport normalizeComponent from \"!../../../node_modules/vue-loader/lib/runtime/component-normalizer\"\nvar Component = normalizeComponent(\n __vue_script__,\n __vue_render__,\n __vue_static_render_fns__,\n __vue_template_functional__,\n __vue_styles__,\n __vue_scopeId__,\n __vue_module_identifier__\n)\n\nexport default Component.exports\n","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('time',{attrs:{\"datetime\":_vm.time,\"title\":_vm.localeDateString}},[_vm._v(\"\\n \"+_vm._s(_vm.$t(_vm.relativeTime.key, [_vm.relativeTime.num]))+\"\\n\")])}\nvar staticRenderFns = []\nexport { render, staticRenderFns }","import { hex2rgb } from '../color_convert/color_convert.js'\nconst highlightStyle = (prefs) => {\n if (prefs === undefined) return\n const { color, type } = prefs\n if (typeof color !== 'string') return\n const rgb = hex2rgb(color)\n if (rgb == null) return\n const solidColor = `rgb(${Math.floor(rgb.r)}, ${Math.floor(rgb.g)}, ${Math.floor(rgb.b)})`\n const tintColor = `rgba(${Math.floor(rgb.r)}, ${Math.floor(rgb.g)}, ${Math.floor(rgb.b)}, .1)`\n const tintColor2 = `rgba(${Math.floor(rgb.r)}, ${Math.floor(rgb.g)}, ${Math.floor(rgb.b)}, .2)`\n if (type === 'striped') {\n return {\n backgroundImage: [\n 'repeating-linear-gradient(135deg,',\n `${tintColor} ,`,\n `${tintColor} 20px,`,\n `${tintColor2} 20px,`,\n `${tintColor2} 40px`\n ].join(' '),\n backgroundPosition: '0 0'\n }\n } else if (type === 'solid') {\n return {\n backgroundColor: tintColor2\n }\n } else if (type === 'side') {\n return {\n backgroundImage: [\n 'linear-gradient(to right,',\n `${solidColor} ,`,\n `${solidColor} 2px,`,\n `transparent 6px`\n ].join(' '),\n backgroundPosition: '0 0'\n }\n }\n}\n\nconst highlightClass = (user) => {\n return 'USER____' + user.screen_name\n .replace(/\\./g, '_')\n .replace(/@/g, '_AT_')\n}\n\nexport {\n highlightClass,\n highlightStyle\n}\n","\n {slot.data.attrs.label}
\n : ''\n }\n {renderSlot}\n