(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 1 && arguments[1] !== undefined ? arguments[1] : 'en'; return (0, _moment2.default)(day).locale(locale).format('ddd ll'); } /* eslint-disable import/no-extraneous-dependencies, no-underscore-dangle */ function formatMonthTitle(date) { var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en'; return (0, _moment2.default)(date).locale(locale).format('MMMM YYYY'); } function formatWeekdayShort(day) { var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en'; return (0, _moment2.default)().locale(locale)._locale.weekdaysMin()[day]; } function formatWeekdayLong(day) { var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en'; return (0, _moment2.default)().locale(locale)._locale.weekdays()[day]; } function getFirstDayOfWeek() { var locale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'en'; var localeData = _moment2.default.localeData(locale); return localeData.firstDayOfWeek(); } function getMonths() { var locale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'en'; var months = []; var i = 0; while (i < 12) { months.push((0, _moment2.default)().locale(locale).month(i).format('MMMM')); i += 1; } return months; } exports.default = { formatDay: formatDay, formatMonthTitle: formatMonthTitle, formatWeekdayShort: formatWeekdayShort, formatWeekdayLong: formatWeekdayLong, getFirstDayOfWeek: getFirstDayOfWeek, getMonths: getMonths }; },{"moment":"moment"}],2:[function(require,module,exports){ /* eslint-env node */ module.exports = require('./lib/src/addons/MomentLocaleUtils'); module.exports.localeUtils = require('./lib/src/addons/MomentLocaleUtils'); },{"./lib/src/addons/MomentLocaleUtils":1}],3:[function(require,module,exports){ module.exports={ "name": "wiki-fountain", "version": "0.1.0", "private": true, "devDependencies": { "babel-plugin-transform-async-to-generator": "^6.24.1", "babel-plugin-transform-object-rest-spread": "^6.26.0", "babel-preset-es2015": "^6.24.1", "babel-preset-react": "^6.24.1", "babel-runtime": "^6.26.0", "babelify": "^7.3.0", "browser-sync": "^2.26.3", "browserify": "^13.0.1", "envify": "^3.4.0", "exorcist": "^0.4.0", "gulp": "^4.0.2", "gulp-if": "^2.0.1", "gulp-less": "^3.1.0", "gulp-minify-css": "^1.2.4", "gulp-notify": "^2.2.0", "gulp-rename": "^1.4.0", "gulp-sourcemaps": "^1.12.1", "gulp-uglify": "^1.5.3", "gulp-watch": "^4.3.6", "natives": "^1.1.6", "vinyl-buffer": "^1.0.1", "vinyl-source-stream": "^2.0.0", "watchify": "^3.11.0", "yargs": "^4.7.1" }, "dependencies": { "babel-polyfill": "^6.26.0", "classnames": "^2.2.6", "clone-deep": "^0.2.4", "dom-scroll-into-view": "^1.2.0", "file-saver": "^2.0.2", "moment": "^2.22.2", "range": "0.0.3", "react": "^15.6.2", "react-autocomplete": "^1.8.1", "react-day-picker": "^5.5.3", "react-dom": "^15.6.2", "react-router": "^2.6.1", "resolve-pathname": "^2.2.0", "shallow-equals": "0.0.0", "stable": "^0.1.8", "url-search-params": "^0.5.0", "whatwg-fetch": "^2.0.4" }, "scripts": { "start": "gulp watch", "build": "gulp" } } },{}],4:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var query = function () { var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(method, url, params) { var init, _ref2, response, log, body; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: init = { method: method, credentials: 'same-origin', headers: new Headers() }; if (method === 'POST' && params) { init.headers.append('Content-Type', 'application/json'), init.body = JSON.stringify(params); } else if (params) { if (method === 'GET') { url += '?' + getParams(params, true).toString(); } else { init.body = getParams(params, false); } } _context.next = 4; return (0, _telemetry.logFetch)(apiUrl + url, init); case 4: _ref2 = _context.sent; response = _ref2.response; log = _ref2.log; if (!(response.status === 401)) { _context.next = 11; break; } throw new UnauthorizedHttpError(); case 11: if (response.ok) { _context.next = 21; break; } _context.t0 = Error; _context.t1 = response.status + ' ' + response.statusText + '\n'; _context.next = 16; return response.text(); case 16: _context.t2 = _context.sent; _context.t3 = _context.t1 + _context.t2; throw new _context.t0(_context.t3); case 21: if (!(response.status === 204 || response.headers.get('Content-Length') == 0)) { _context.next = 23; break; } return _context.abrupt('return'); case 23: _context.next = 25; return response.json(); case 25: body = _context.sent; (0, _telemetry.logResponseBody)(log, body); return _context.abrupt('return', postProcess(body)); case 28: case 'end': return _context.stop(); } } }, _callee, this); })); return function query(_x, _x2, _x3) { return _ref.apply(this, arguments); }; }(); exports.UnauthorizedHttpError = UnauthorizedHttpError; var _moment = require('moment'); var _moment2 = _interopRequireDefault(_moment); var _telemetry = require('./telemetry'); var _url = require('./url'); var _url2 = _interopRequireDefault(_url); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } var apiUrl = (0, _url2.default)('/api/'); function getParams(params, isUrl) { var data = true ? new URLSearchParams() : new FormData(); for (var k in params) { data.append(k, params[k]); }return data; } var dateRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d*)?Z$/; function postProcess(result) { if (!result) return result; if (typeof result === 'string') { if (dateRegex.test(result)) return _moment2.default.parseZone(result).toDate(); } else if (Array.isArray(result)) { return result.map(postProcess); } else if (result && (typeof result === 'undefined' ? 'undefined' : _typeof(result)) === 'object') { for (var prop in result) { result[prop] = postProcess(result[prop]); } } return result; } function get(url, params) { return query('GET', url, params); } function post(url, params) { return query('POST', url, params); } function del(url, params) { return query('DELETE', url, params); } var enc = encodeURIComponent; exports.default = { getEditathons: function getEditathons() { return get('editathons'); }, getEditathon: function getEditathon(code) { return get('editathons/' + enc(code)); }, getEditathonConfig: function getEditathonConfig(code) { return get('editathons/' + enc(code) + '/config'); }, setEditathonConfig: function setEditathonConfig(code, editathon) { return post('editathons/' + enc(code) + '/config', editathon); }, createEditathon: function createEditathon(editathon) { return post('editathons/new', editathon); }, addArticle: function addArticle(code, title, user) { return post('editathons/' + enc(code) + '/article', { title: title, user: user }); }, removeArticles: function removeArticles(code, ids) { return post('editathons/' + enc(code) + '/removeArticles', ids); }, setMark: function setMark(code, _ref3) { var title = _ref3.title, marks = _ref3.marks, comment = _ref3.comment; return post('editathons/' + enc(code) + '/mark', { title: title, comment: comment || '', marks: JSON.stringify(marks) }); }, getResults: function getResults(code, limit) { return get('editathons/' + enc(code) + '/results', { limit: limit }); }, publishEditathon: function publishEditathon(code) { return post('editathons/' + enc(code) + '/publish'); }, removeEditathon: function removeEditathon(code) { return del('editathons/' + enc(code)); }, getMyCurrentEditathons: function getMyCurrentEditathons() { return get('personal/current-editathons'); }, getJuryEditathons: function getJuryEditathons() { return get('personal/jury-editathons'); }, getCreatedEditathons: function getCreatedEditathons() { return get('personal/created-editathons'); }, getDraft: function getDraft() { return get('personal/get-draft'); }, getUnapprovedEditathons: function getUnapprovedEditathons() { return get('personal/unapproved-editathons'); }, parse: function parse(wiki, text) { var title = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; return post('wiki/parse', { wiki: wiki, text: text, title: title }); }, award: function award(code, awards) { return post('editathons/' + enc(code) + '/award', awards); }, exists: function exists(what, value, existingCode) { return get('editathons/exists', { what: what, value: value, existingCode: existingCode }); } }; function UnauthorizedHttpError() {} },{"./telemetry":71,"./url":96,"moment":"moment"}],5:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _Api = require('./../Api'); var _Api2 = _interopRequireDefault(_Api); var _getArticleData = require('./../getArticleData'); var _getArticleData2 = _interopRequireDefault(_getArticleData); var _MwApi = require('./../MwApi'); var _rules = require('./../rules'); var _rules2 = _interopRequireDefault(_rules); var _translate = require('./../translate'); var _url = require('./../url'); var _url2 = _interopRequireDefault(_url); var _Loader = require('./Loader'); var _Loader2 = _interopRequireDefault(_Loader); var _PageLookup = require('./PageLookup'); var _PageLookup2 = _interopRequireDefault(_PageLookup); var _UserLookup = require('./UserLookup'); var _UserLookup2 = _interopRequireDefault(_UserLookup); var _Warnings = require('./Warnings'); var _Warnings2 = _interopRequireDefault(_Warnings); var _WikiButton = require('./WikiButton'); var _WikiButton2 = _interopRequireDefault(_WikiButton); var _WikiLink = require('./WikiLink'); var _WikiLink2 = _interopRequireDefault(_WikiLink); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } var AddArticle = _react2.default.createClass({ displayName: 'AddArticle', contextTypes: { router: _react2.default.PropTypes.object.isRequired }, getInitialState: function getInitialState() { return { title: '', user: Global.user && Global.user.name, regDate: Global.user && Global.user.registered, updating: false, stage: null, card: null, adding: false, error: false }; }, componentWillMount: function componentWillMount() { if (!Global.user) { return this.returnToList(); } var isJury = !!this.props.editathon.jury.filter(function (j) { return j === Global.user.name; })[0]; this.setState({ isJury: isJury, stage: isJury ? 'user' : 'pick' }); }, update: function update() { var _this = this; return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { var _state, title, stats, what; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _state = _this.state, title = _state.title, stats = _state.stats; _context.prev = 1; if (!(!stats || title !== stats.title)) { _context.next = 8; break; } what = (0, _rules.getRulesReqs)(_this.getRules()); _context.next = 6; return (0, _getArticleData2.default)(_this.props.editathon.wiki, title, ['title', 'card'].concat(_toConsumableArray(what))); case 6: stats = _context.sent; if (stats) title = stats.title; case 8: _context.next = 14; break; case 10: _context.prev = 10; _context.t0 = _context['catch'](1); console.log('error retrieving article info', _context.t0); stats = null; case 14: _this.setState({ updating: false, title: title, stats: stats }); case 15: case 'end': return _context.stop(); } } }, _callee, _this, [[1, 10]]); }))(); }, add: function add() { var _this2 = this; return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { var _state2, stats, user; return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _state2 = _this2.state, stats = _state2.stats, user = _state2.user; if (!(!stats || !stats.title)) { _context2.next = 3; break; } return _context2.abrupt('return'); case 3: _this2.setState({ adding: true }); _context2.prev = 4; _context2.next = 7; return _Api2.default.addArticle(_this2.props.editathon.code, stats.title, user); case 7: _context2.next = 9; return _this2.returnToList(true); case 9: _context2.next = 15; break; case 11: _context2.prev = 11; _context2.t0 = _context2['catch'](4); _this2.setState({ adding: false }); if (_context2.t0 instanceof _Api.UnauthorizedHttpError) { alert(_this2.tr('unauthorized')); } else { alert(_this2.tr('networkError', _context2.t0.message)); } case 15: case 'end': return _context2.stop(); } } }, _callee2, _this2, [[4, 11]]); }))(); }, returnToList: function returnToList() { var _this3 = this; var reload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() { return regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: _this3.context.router.replace({ pathname: (0, _url2.default)('/editathons/' + _this3.props.editathon.code) }); if (!(reload && _this3.props.onReloadEditathon)) { _context3.next = 4; break; } _context3.next = 4; return _this3.props.onReloadEditathon(); case 4: case 'end': return _context3.stop(); } } }, _callee3, _this3); }))(); }, getRules: function getRules() { return (0, _rules2.default)(this.props.editathon.rules); }, render: function render() { return _react2.default.createElement( 'form', { className: 'AddArticle', onSubmit: function onSubmit(e) { return e.preventDefault(); } }, this.renderStage() ); }, renderStage: function renderStage() { var renderer = { user: this.renderUserStage, pick: this.renderPickStage, approve: this.renderApproveStage }[this.state.stage]; return renderer ? renderer().props.children : null; }, tr: function tr() { var _props$translation; return (_props$translation = this.props.translation).tr.apply(_props$translation, arguments); }, backButton: function backButton() { var _this4 = this; var _state3 = this.state, isJury = _state3.isJury, stage = _state3.stage; var name = void 0, action = void 0; if (stage === 'user') { name = 'cancel'; action = function action() { return _this4.returnToList(); }; } else if (stage === 'pick') { if (isJury) { name = 'back'; action = function action() { return _this4.setState({ stage: 'user' }); }; } else { name = 'cancel'; action = function action() { return _this4.returnToList(); }; } } else if (stage === 'approve') { name = 'back'; action = function action() { return _this4.setState({ stage: 'pick' }); }; } return _react2.default.createElement( _WikiButton2.default, { onClick: action }, this.tr(name) ); }, pickUser: function pickUser() { var _this5 = this; return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() { var user, regDate, mwApi, error, stage; return regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: user = _this5.state.user.trim(); _this5.setState({ updating: true, error: false, user: user }); regDate = void 0; _context4.prev = 3; mwApi = (0, _MwApi.getMwApi)(_this5.props.editathon.wiki); _context4.next = 7; return mwApi.getUserRegDate(user); case 7: regDate = _context4.sent; _context4.next = 13; break; case 10: _context4.prev = 10; _context4.t0 = _context4['catch'](3); console.error(_context4.t0); case 13: error = regDate === undefined ? user : false; stage = regDate === undefined ? 'user' : 'pick'; _this5.setState({ stage: stage, updating: false, regDate: regDate, error: error }); case 16: case 'end': return _context4.stop(); } } }, _callee4, _this5, [[3, 10]]); }))(); }, renderUserStage: function renderUserStage() { var _this6 = this; var _props = this.props, tr = _props.translation.tr, wiki = _props.editathon.wiki; var _state4 = this.state, user = _state4.user, updating = _state4.updating, error = _state4.error; return _react2.default.createElement( 'div', null, _react2.default.createElement( 'label', { htmlFor: 'user' }, this.tr('user') ), _react2.default.createElement(_UserLookup2.default, { wiki: wiki, inputProps: { id: 'user' }, autoFocus: true, value: user, onChange: function onChange(user) { return _this6.setState({ user: user }); } }), error && _react2.default.createElement( 'div', { className: 'Warnings' }, _react2.default.createElement( 'div', { className: 'stat error' }, this.tr('userNotFound', error) ) ), _react2.default.createElement( 'div', { id: 'buttons' }, this.backButton(), _react2.default.createElement( _WikiButton2.default, { loading: updating, disabled: !user.trim(), type: 'progressive', submit: true, onClick: this.pickUser }, this.tr('next') ) ) ); }, getCtx: function getCtx() { return { user: { name: this.state.user, registered: this.state.regDate } }; }, renderPickStage: function renderPickStage() { var _this7 = this; var _props2 = this.props, tr = _props2.translation.tr, wiki = _props2.editathon.wiki; var ctx = this.getCtx(); var rules = this.getRules().filter(function (rule) { return rule.userOnly; }); var error = rules.filter(function (rule) { return !(rule.flags & _rules.RuleFlags.optional); }).some(function (rule) { return !rule.check(null, ctx); }); if (error) { return _react2.default.createElement( 'div', null, _react2.default.createElement(_Warnings2.default, { ctx: ctx, rules: rules, stats: null, wiki: wiki }), _react2.default.createElement( 'div', { id: 'buttons' }, this.backButton() ) ); } return _react2.default.createElement( 'div', null, _react2.default.createElement( 'label', { htmlFor: 'title' }, this.tr('articleTitle') ), _react2.default.createElement(_Warnings2.default, { ctx: ctx, rules: rules, stats: null, wiki: wiki }), _react2.default.createElement(_PageLookup2.default, { wiki: wiki, autoFocus: true, inputProps: { id: 'title' }, value: this.state.title, onChange: function onChange(title) { return _this7.setState({ title: title }); } }), _react2.default.createElement( 'div', { id: 'buttons' }, this.backButton(), _react2.default.createElement( _WikiButton2.default, { disabled: !this.state.title.trim(), type: 'progressive', submit: true, onClick: function onClick() { _this7.setState({ stage: 'approve', updating: true }); _this7.update(); } }, this.tr('next') ) ) ); }, renderApproveStage: function renderApproveStage() { var editathon = this.props.editathon; var stats = this.state.stats; var missing = !stats; var title = stats && stats.title || this.state.title; var header = _react2.default.createElement( 'header', null, _react2.default.createElement(_WikiLink2.default, { to: title, wiki: editathon.wiki, red: missing }) ); var addedBy = stats && editathon.articles.find(function (a) { return a.name.toLowerCase() === stats.title.toLowerCase(); }); var rules = this.getRules().filter(function (rule) { return !rule.userOnly; }); var ctx = this.getCtx(); var ok = stats && rules.every(function (rule) { return rule.flags & _rules.RuleFlags.optional || rule.check(stats, ctx); }); return _react2.default.createElement( 'div', null, this.state.updating ? _react2.default.createElement(_Loader2.default, null) : _react2.default.createElement( 'div', null, missing ? _react2.default.createElement( 'div', null, header, _react2.default.createElement( 'div', null, this.tr('notFound') ) ) : _react2.default.createElement( 'div', { className: 'info' }, _react2.default.createElement( 'div', { className: 'Warnings' }, header, addedBy && _react2.default.createElement( 'div', { className: 'stat error' }, addedBy.user === ctx.user.name ? this.tr('youAlreadyAdded') : this.tr('someoneAlreadyAdded') ), _react2.default.createElement(_Warnings2.default, { ctx: ctx, rules: rules, stats: stats, title: stats.title, wiki: editathon.wiki }) ), this.renderCard() ) ).props.children, _react2.default.createElement( 'div', { id: 'buttons' }, this.backButton(), _react2.default.createElement( _WikiButton2.default, { loading: this.state.adding, disabled: this.state.updating || !ok || addedBy, type: 'constructive', submit: true, onClick: this.add }, this.tr('add') ) ) ); }, renderCard: function renderCard() { if (!this.state.stats) return null; var _state$stats$card = this.state.stats.card, extract = _state$stats$card.extract, thumbnail = _state$stats$card.thumbnail; return _react2.default.createElement( 'div', { className: 'card' }, _react2.default.createElement( 'div', { className: 'content' }, _react2.default.createElement( 'div', { className: 'thumbnail' }, thumbnail && _react2.default.createElement('img', { src: thumbnail.source }) ), _react2.default.createElement( 'div', { className: 'extract' }, extract ) ) ); } }); exports.default = (0, _translate.withTranslation)(AddArticle, 'AddArticle'); },{"./../Api":4,"./../MwApi":61,"./../getArticleData":64,"./../rules":69,"./../translate":73,"./../url":96,"./Loader":36,"./PageLookup":43,"./UserLookup":54,"./Warnings":55,"./WikiButton":56,"./WikiLink":57,"react":"react"}],6:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _Footer = require('./Footer'); var _Footer2 = _interopRequireDefault(_Footer); var _Header = require('./Header'); var _Header2 = _interopRequireDefault(_Header); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.default = function (_ref) { var children = _ref.children; return _react2.default.createElement( 'div', null, _react2.default.createElement(_Header2.default, null), children, _react2.default.createElement(_Footer2.default, null) ); }; },{"./Footer":23,"./Header":24,"react":"react"}],7:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _moment = require('moment'); var _moment2 = _interopRequireDefault(_moment); var _stable = require('stable'); var _stable2 = _interopRequireDefault(_stable); var _sortBy2 = require('./../sortBy'); var _sortBy3 = _interopRequireDefault(_sortBy2); var _utils = require('./../utils'); var _jury = require('./../jury'); var _translate = require('./../translate'); var _Dashboard = require('./Dashboard'); var _Dashboard2 = _interopRequireDefault(_Dashboard); var _DropDownButton = require('./DropDownButton'); var _DropDownButton2 = _interopRequireDefault(_DropDownButton); var _Link = require('./Link'); var _Link2 = _interopRequireDefault(_Link); var _Loader = require('./Loader'); var _Loader2 = _interopRequireDefault(_Loader); var _MarkDetails = require('./MarkDetails'); var _MarkDetails2 = _interopRequireDefault(_MarkDetails); var _RequiresLogin = require('./RequiresLogin'); var _RequiresLogin2 = _interopRequireDefault(_RequiresLogin); var _WikiButton = require('./WikiButton'); var _WikiButton2 = _interopRequireDefault(_WikiButton); var _WikiLink = require('./WikiLink'); var _WikiLink2 = _interopRequireDefault(_WikiLink); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } function sort(items, by, asc) { if (by === null) { return items; } var sort = (0, _sortBy3.default)(by); if (!asc) { sort = sort.desc; } return (0, _stable2.default)(items, sort); } var ArticlesList = _react2.default.createClass({ displayName: 'ArticlesList', propTypes: { editathon: _react2.default.PropTypes.object }, getInitialState: function getInitialState() { return { sortBy: 'total', sortAsc: false, data: [] }; }, componentWillMount: function componentWillMount() { this.componentWillReceiveProps(this.props); }, componentWillReceiveProps: function componentWillReceiveProps(_ref) { var editathon = _ref.editathon; if (editathon && editathon.articles && editathon.jury) { this.setState({ data: sort(this.getData(editathon.articles, editathon), this.state.sortBy, this.state.sortAsc) }); } }, getData: function getData(articles, editathon) { var getTotal = function getTotal(articles) { var marks = articles.map(function (article) { return (0, _jury.getTotalMark)(editathon, article.marks); }).filter(function (x) { return x !== null; }); if (!marks.length) return null; return marks.reduce(function (s, m) { return s + m; }, 0); }; if (editathon.flags & _jury.EditathonFlags.hiddenMarks) getTotal = function getTotal() { return null; }; return [].concat(_toConsumableArray((0, _utils.groupBy)(articles, function (a) { return a.user; }))).map(function (_ref2) { var _ref3 = _slicedToArray(_ref2, 2), k = _ref3[0], v = _ref3[1]; return { name: k, articles: v, total: getTotal(v), count: v.length }; }); }, tr: function tr() { var _props$translation; return (_props$translation = this.props.translation).tr.apply(_props$translation, arguments); }, formatNumber: function formatNumber() { var _props$translation2; for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return (_props$translation2 = this.props.translation).translate.apply(_props$translation2, ['formatNumber'].concat(args)); }, formatMark: function formatMark(mark) { var consensualVote = this.props.editathon.flags & _jury.EditathonFlags.consensualVote; return mark === null ? '' : this.formatNumber(mark, { places: consensualVote ? 0 : 2 }); }, renderHeader: function renderHeader(editathon) { var _this = this; var now = _moment2.default.utc(); if (now.isBefore(editathon.start, 'day')) { return _react2.default.createElement( 'div', { className: 'header' }, this.tr('editathonWillStartIn', editathon.start) ); } var isJury = Global.user && editathon.jury.filter(function (j) { return j === Global.user.name; })[0]; var juryButton = function juryButton(def) { return isJury && _react2.default.createElement( _WikiButton2.default, { type: def ? 'progressive' : '', disabled: editathon.articles.length === 0 }, _react2.default.createElement( _Link2.default, { to: '/jury/' + _this.props.editathon.code }, _this.tr('juryTool') ) ); }; if (now.isAfter(editathon.finish, 'day')) { var showAward = isJury && this.showMarks() && editathon.articles.filter(function (a) { return (0, _jury.getTotalMark)(editathon, a.marks) === null; }).length === 0; return _react2.default.createElement( 'div', { className: 'header' }, _react2.default.createElement( 'span', null, this.tr('editathonIsOver') ), juryButton(!showAward), showAward && _react2.default.createElement( _WikiButton2.default, { className: 'award', type: 'progressive' }, _react2.default.createElement( _Link2.default, { to: '/editathons/' + this.props.editathon.code + '/award' }, this.tr('award') ) ) ); } else { return _react2.default.createElement( 'div', { className: 'header' }, _react2.default.createElement( 'span', null, this.tr('editathonWillEndIn', editathon.finish) ), juryButton(true), _react2.default.createElement( _RequiresLogin2.default, { redirectTo: '/editathons/' + this.props.editathon.code + '/add' }, _react2.default.createElement( _WikiButton2.default, { type: isJury ? '' : 'progressive', className: (0, _classnames2.default)('addArticle', isJury && 'combine') }, _react2.default.createElement( _Link2.default, { to: '/editathons/' + this.props.editathon.code + '/add' }, this.tr('addArticle') ) ), isJury && _react2.default.createElement(_DropDownButton2.default, { className: 'manageArticles', collapse: true, items: [_react2.default.createElement( _Link2.default, { to: '/editathons/' + this.props.editathon.code + '/manage' }, this.tr('manageArticles') )] }) ) ); } }, render: function render() { var _this2 = this; var editathon = this.props.editathon; if (!editathon || !editathon.jury) return _react2.default.createElement(_Loader2.default, null); var data = this.state.data; return _react2.default.createElement( 'div', { className: 'ArticlesList' }, this.renderHeader(editathon), _react2.default.createElement(_Dashboard2.default, { editathon: editathon }), _react2.default.createElement( 'div', { className: 'jury' }, this.tr('jury') + ' ', editathon.jury.slice().sort().map(function (j) { return _react2.default.createElement( 'span', { key: j }, _react2.default.createElement(_WikiLink2.default, { to: 'User_talk:' + j, wiki: editathon.wiki }) ); }) ), _react2.default.createElement( 'table', null, _react2.default.createElement( 'thead', null, _react2.default.createElement( 'tr', null, _react2.default.createElement('th', { className: 'expander' }), _react2.default.createElement( 'th', { className: 'user' }, this.renderSorter('name', this.tr('user')) ), _react2.default.createElement( 'th', { className: 'count' }, this.renderSorter('count', this.tr('acticlesCount')) ), this.showMarks() && _react2.default.createElement( 'th', { className: 'total' }, this.renderSorter('total', this.tr('totalScore')) ) ) ), _react2.default.createElement( 'tbody', null, _react2.default.createElement('tr', { className: 'spacer' }) ), data.map(function (user) { return _react2.default.createElement( ExpandableRow, { key: user.name, user: user, wiki: editathon.wiki, formatMark: _this2.formatMark, formatNumber: _this2.formatNumber, showMarks: _this2.showMarks() }, _this2.renderArticles(editathon, user) ); }) ) ); }, renderArticles: function renderArticles(editathon, user) { var _this3 = this; var wiki = editathon.wiki, jury = editathon.jury, marksConfig = editathon.marks; return _react2.default.createElement( 'table', { className: 'articles' }, _react2.default.createElement( 'thead', null, _react2.default.createElement( 'tr', null, _react2.default.createElement( 'th', { className: 'article' }, this.tr('acticle') ), _react2.default.createElement( 'th', { className: 'dateAdded' }, this.tr('addedOn') ), this.showMarks() && _react2.default.createElement( 'th', { className: 'mark' }, this.tr('score') ) ) ), _react2.default.createElement( 'tbody', null, user.articles.slice().sort((0, _sortBy3.default)('dateAdded').desc).map(function (a) { return [_react2.default.createElement( 'tr', { className: 'summary' }, _react2.default.createElement( 'td', { className: 'article' }, _react2.default.createElement(_WikiLink2.default, { to: a.name, wiki: wiki }) ), _react2.default.createElement( 'td', { className: 'dateAdded' }, _this3.tr('dateAdded', (0, _moment2.default)(a.dateAdded).utc()) ), _this3.showMarks() && _react2.default.createElement( 'td', { className: 'mark' }, _this3.formatMark((0, _jury.getTotalMark)(editathon, a.marks)) ) ), _this3.showMarks() && a.marks.length >= editathon.minMarks && _react2.default.createElement( 'tr', { className: 'details' }, _react2.default.createElement( 'td', { colSpan: 3 }, _react2.default.createElement( 'ul', null, jury.map(function (jury) { return (0, _jury.findMarkOf)(a.marks, jury); }).filter(function (x) { return x; }).map(function (m, i) { return _react2.default.createElement( 'li', { key: i }, _react2.default.createElement(_MarkDetails2.default, { mark: m, config: marksConfig }) ); }) ) ) )]; }) ) ); }, showMarks: function showMarks() { return !(this.props.editathon.flags & _jury.EditathonFlags.hiddenMarks); }, sortBy: function sortBy(_sortBy) { var sortAsc = _sortBy === this.state.sortBy ? !this.state.sortAsc : true; this.setState({ sortBy: _sortBy, sortAsc: sortAsc, data: sort(this.state.data, _sortBy, sortAsc) }); }, renderSorter: function renderSorter(by, title) { var _this4 = this; var _state = this.state, sortBy = _state.sortBy, sortAsc = _state.sortAsc; return _react2.default.createElement( 'button', { className: (0, _classnames2.default)({ sorter: true, asc: sortBy === by && sortAsc, desc: sortBy === by && !sortAsc }), onClick: function onClick() { return _this4.sortBy(by); } }, title ); } }); var ExpandableRow = _react2.default.createClass({ displayName: 'ExpandableRow', getInitialState: function getInitialState() { return { expanded: false }; }, componentWillMount: function componentWillMount() { this.setState({ expanded: Global.user && Global.user.name === this.props.user.name }); }, expand: function expand() { this.setState({ expanded: !this.state.expanded }); }, render: function render() { var _props = this.props, user = _props.user, wiki = _props.wiki, formatNumber = _props.formatNumber, formatMark = _props.formatMark, children = _props.children; var expanded = this.state.expanded; return _react2.default.createElement( 'tbody', null, _react2.default.createElement( 'tr', { onClick: this.expand }, _react2.default.createElement( 'td', { className: (0, _classnames2.default)({ expander: true, expanded: expanded }) }, _react2.default.createElement('button', { onClick: this.expand }) ), _react2.default.createElement( 'td', { className: 'user' }, _react2.default.createElement(_WikiLink2.default, { to: 'User_talk:' + user.name, wiki: wiki }) ), _react2.default.createElement( 'td', { className: 'count' }, formatNumber(user.count) ), this.props.showMarks && _react2.default.createElement( 'td', { className: 'total' }, formatMark(user.total) ) ), expanded && _react2.default.createElement( 'tr', { className: 'expanded' }, _react2.default.createElement( 'td', { colSpan: this.props.showMarks ? 4 : 3 }, children ) ) ); } }); exports.default = (0, _translate.withTranslation)(ArticlesList, 'ArticlesList'); },{"./../jury":65,"./../sortBy":70,"./../translate":73,"./../utils":97,"./Dashboard":8,"./DropDownButton":11,"./Link":35,"./Loader":36,"./MarkDetails":39,"./RequiresLogin":50,"./WikiButton":56,"./WikiLink":57,"classnames":"classnames","moment":"moment","react":"react","stable":"stable"}],8:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _translate = require('./../translate'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Dashboard = function (_React$Component) { _inherits(Dashboard, _React$Component); function Dashboard(props) { _classCallCheck(this, Dashboard); return _possibleConstructorReturn(this, (Dashboard.__proto__ || Object.getPrototypeOf(Dashboard)).call(this, props)); } _createClass(Dashboard, [{ key: 'render', value: function render() { var _props = this.props, e = _props.editathon, _props$translation = _props.translation, tr = _props$translation.tr, translate = _props$translation.translate; var items = [{ name: tr('users'), value: new Set(e.articles.map(function (a) { return a.user; })).size }, { name: tr('articles'), value: e.articles.length }, { name: tr('marks'), value: e.articles.reduce(function (m, a) { return [].concat(_toConsumableArray(m), _toConsumableArray(a.marks)); }, []).length }, { name: tr('withoutMarks'), value: e.articles.filter(function (a) { return a.marks.length < e.minMarks; }).length, isGood: function isGood(x) { return x === 0; } }, e.minMarks > 1 && Global.user && e.jury.indexOf(Global.user.name) !== -1 && { name: tr('needsYourMark'), value: e.articles.filter(function (a) { return a.marks.length < e.minMarks && !a.marks.some(function (m) { return m.user === Global.user.name; }); }).length, isGood: function isGood(x) { return x === 0; } }]; return _react2.default.createElement( 'div', { className: 'Dashboard' }, items.filter(function (x) { return x; }).map(function (x, i) { return _react2.default.createElement( 'div', { className: 'itemWrapper', key: i }, _react2.default.createElement( 'div', { className: (0, _classnames2.default)({ item: true, good: x.isGood && x.isGood(x.value), bad: x.isGood && !x.isGood(x.value) }) }, _react2.default.createElement( 'div', { className: 'name' }, x.name ), _react2.default.createElement( 'div', { className: 'value' }, translate('formatNumber', x.value) ) ) ); }) ); } }]); return Dashboard; }(_react2.default.Component); exports.default = (0, _translate.withTranslation)(Dashboard, 'Dashboard'); },{"./../translate":73,"classnames":"classnames","react":"react"}],9:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactDom = require('react-dom'); var _reactDayPicker = require('react-day-picker'); var _reactDayPicker2 = _interopRequireDefault(_reactDayPicker); var _moment = require('react-day-picker/moment'); var _moment2 = _interopRequireDefault(_moment); var _moment3 = require('moment'); var _moment4 = _interopRequireDefault(_moment3); var _translate = require('../translate'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } function dateEqual(date1, date2) { if (!date1) { return !date2; } else if (!date2) { return false; } else { return date1.valueOf() === date2.valueOf(); } } function getUtcDate(date) { return _moment4.default.utc({ y: date.getFullYear(), M: date.getMonth(), d: date.getDate() }); } var DateTimePicker = function (_React$Component) { _inherits(DateTimePicker, _React$Component); function DateTimePicker(props) { _classCallCheck(this, DateTimePicker); var _this = _possibleConstructorReturn(this, (DateTimePicker.__proto__ || Object.getPrototypeOf(DateTimePicker)).call(this, props)); _this.state = _this.getState(props.value, props); return _this; } _createClass(DateTimePicker, [{ key: 'componentWillReceiveProps', value: function componentWillReceiveProps(newProps) { var state = {}; if (!dateEqual(newProps.value, this.props.value) || this.getCurLang() !== this.getCurLang(newProps)) { state = this.getState(newProps.value, newProps); } this.setState(state); } }, { key: 'formatDate', value: function formatDate(date) { var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props; return props.translation.translate('formatDate', (0, _moment4.default)(date).utc(), this.getFormat(props)); } }, { key: 'parseDate', value: function parseDate(text) { return _moment4.default.utc(text, this.getFormat(), this.getCurLang(), true); } }, { key: 'getFormat', value: function getFormat() { var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.props; return props.translation.translate('dateTimePicker'); } }, { key: 'getCurLang', value: function getCurLang() { var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.props; return props.translation.curLang; } }, { key: 'onDayClick', value: function onDayClick(date) { var _this2 = this; date = getUtcDate(date); var prev = this.props.value; if (prev) { var time = _moment4.default.utc(prev); date.add(time.diff((0, _moment4.default)(time).startOf('d'))); } date = date.toDate(); this.setState(this.getState(date)); this.props.onChange && this.props.onChange(date); setTimeout(function () { return _this2.setState({ isOpen: false }); }, 100); } }, { key: 'getState', value: function getState(date, props) { return { text: date && this.formatDate(date, props) || '', month: date || new Date() }; } }, { key: 'onInputChange', value: function onInputChange(text) { var date = this.parseDate(text); var value = date.isValid() ? date.toDate() : null; this.setState({ text: text, month: date.isValid() ? date.toDate() : this.state.month }); if (this.props.onChange) { if (value || text == '' && this.props.allowEmpty) { this.props.onChange(value); } } } }, { key: 'onInputFocus', value: function onInputFocus() { if (this.timeout) { clearTimeout(this.timeout); this.timeout = null; } this.setState(function (state) { return state.isOpen ? {} : { isOpen: true }; }); } }, { key: 'onInputBlur', value: function onInputBlur() { var _this3 = this; this.timeout = setTimeout(function () { return _this3.setState(function () { return _extends({}, _this3.getState(_this3.props.value), { isOpen: false }); }); }, 150); } }, { key: 'onPopupClick', value: function onPopupClick() { var input = (0, _reactDom.findDOMNode)(this.refs.input); if (input) { input.focus(); } } }, { key: 'render', value: function render() { var _this4 = this; var locale = _moment4.default.localeData(this.getCurLang()); var placeholder = this.getFormat().split(' ').map(function (x) { return x.toLowerCase().startsWith('l') ? locale.longDateFormat(x).toLowerCase() : x; }).join(' '); var value = this.props.value && _moment4.default.utc(this.props.value); return _react2.default.createElement( 'div', { className: 'DateTimePicker' }, _react2.default.createElement('input', { id: this.props.id, value: this.state.text, ref: 'input', placeholder: placeholder, onClick: function onClick() { return _this4.setState({ isOpen: true }); }, onChange: function onChange(e) { return _this4.onInputChange(e.target.value); }, onFocus: function onFocus() { return _this4.onInputFocus(); }, onBlur: function onBlur() { return _this4.onInputBlur(); } }), _react2.default.createElement( 'div', { className: 'popup-container', onClick: function onClick() { return _this4.onPopupClick(); } }, this.state.isOpen && _react2.default.createElement( 'div', { className: 'popup' }, _react2.default.createElement(_reactDayPicker2.default, { tabIndex: null, locale: this.getCurLang(), localeUtils: _moment2.default, modifiers: { weekend: function weekend(date) { var wd = date.getDay(); return wd === 0 || wd === 6; } }, month: this.state.month, selectedDays: function selectedDays(date) { return value && value.isSame(getUtcDate(date), 'day'); }, disabledDays: function disabledDays(date) { return (0, _moment4.default)().isAfter(date, 'day'); }, onDayClick: function onDayClick(date, mods) { return _this4.onDayClick(date, mods); }, onMonthChange: function onMonthChange(month) { return _this4.setState({ month: month }); } }) ) ) ); } }]); return DateTimePicker; }(_react2.default.Component); exports.default = (0, _translate.withTranslation)(DateTimePicker); },{"../translate":73,"moment":"moment","react":"react","react-day-picker":"react-day-picker","react-day-picker/moment":2,"react-dom":"react-dom"}],10:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _reactAutocomplete = require('react-autocomplete'); var _reactAutocomplete2 = _interopRequireDefault(_reactAutocomplete); var _WikiButton = require('./WikiButton'); var _WikiButton2 = _interopRequireDefault(_WikiButton); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var DropDown = function (_React$Component) { _inherits(DropDown, _React$Component); function DropDown(props) { _classCallCheck(this, DropDown); var _this = _possibleConstructorReturn(this, (DropDown.__proto__ || Object.getPrototypeOf(DropDown)).call(this, props)); _this.state = { open: false }; _this._ignoreBlur = true; _this._highlightPending = true; return _this; } _createClass(DropDown, [{ key: 'componentWillReceiveProps', value: function componentWillReceiveProps(props) { var value = props.value; if (value !== this.props.value) { this._highlightPending = true; } } }, { key: 'onButtonFocus', value: function onButtonFocus() { if (!this.state.open) { this._highlightPending = true; this.setState({ open: true }); } else { this.focusInput(); } } }, { key: 'onBlur', value: function onBlur() { var _this2 = this; if (this._ignoreBlur) return; setTimeout(function () { return _this2.setState({ value: '', open: false }); }, 1); } }, { key: 'renderButton', value: function renderButton() { var _this3 = this; var _props = this.props, renderButton = _props.renderButton, value = _props.value, _props$renderItem = _props.renderItem, renderItem = _props$renderItem === undefined ? function (x) { return x; } : _props$renderItem, getValue = _props.getValue, items = _props.items; var item = void 0, text = void 0; if (!getValue) { text = value; } else { var _iteratorNormalCompletion = true; var _didIteratorError = false; var _iteratorError = undefined; try { for (var _iterator = items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { var it = _step.value; if (getValue(it) === value) { item = it; text = renderItem(it); break; } } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally { try { if (!_iteratorNormalCompletion && _iterator.return) { _iterator.return(); } } finally { if (_didIteratorError) { throw _iteratorError; } } } } var button = renderButton ? renderButton(value, text, item) : _react2.default.createElement( _WikiButton2.default, null, text ); return _react2.default.cloneElement(button, { tabIndex: this.state.open ? -1 : 0, onFocus: function onFocus() { return _this3.onButtonFocus(); }, onMouseDown: function onMouseDown() { return _this3._ignoreBlur = true; } }); } }, { key: 'renderItem', value: function renderItem(item, selected) { var _props2 = this.props, renderItem = _props2.renderItem, getValue = _props2.getValue; return _react2.default.createElement( 'div', { key: getValue ? getValue(item) : item, className: (0, _classnames2.default)({ item: true, selected: selected }) }, renderItem ? renderItem(item) : item ); } }, { key: 'renderMenu', value: function renderMenu(items, value, style) { return _react2.default.createElement( 'div', { className: 'menu', tabIndex: '-1' }, items ); } }, { key: 'focusInput', value: function focusInput() { this._autocomplete && this._autocomplete.refs.input.focus(); } }, { key: 'onChange', value: function onChange(event, value) { var _props3 = this.props, matchItem = _props3.matchItem, filter = _props3.filter; if (!matchItem) return; this.setState({ value: value }); if (this._autocomplete) { if (filter) { this.highlightIndex(this._autocomplete.getFilteredItems(this._autocomplete.props).length ? 0 : null); } else { this.highlightFirst(function (item) { return matchItem(item, value); }); } } } }, { key: 'highlightValue', value: function highlightValue(value) { var getValue = this.props.getValue; if (getValue) { this.highlightFirst(function (item) { return getValue(item) === value; }); } } }, { key: 'highlightFirst', value: function highlightFirst(pred) { if (!this._autocomplete) return; var items = this._autocomplete.getFilteredItems(this._autocomplete.props); for (var i = 0; i < items.length; i++) { if (pred(items[i])) { this.highlightIndex(i); return; } } this.highlightIndex(null); } }, { key: 'highlightIndex', value: function highlightIndex(index) { this._autocomplete.setState({ highlightedIndex: index }); } }, { key: 'onAutocompleteRef', value: function onAutocompleteRef(ac) { this._autocomplete = ac; this.focusInput(); if (this._highlightPending) { this.highlightValue(this.props.value); this._highlightPending = false; } } }, { key: 'onKeyDown', value: function onKeyDown(e) { if (e.key === 'Escape') { e.target.blur(); } } }, { key: 'renderPopup', value: function renderPopup() { var _this4 = this; var _state = this.state, open = _state.open, value = _state.value; if (!open) return; var _props4 = this.props, _props4$onChange = _props4.onChange, onChange = _props4$onChange === undefined ? function () {} : _props4$onChange, items = _props4.items, _props4$getValue = _props4.getValue, getValue = _props4$getValue === undefined ? function (x) { return x; } : _props4$getValue, _props4$filter = _props4.filter, filter = _props4$filter === undefined ? false : _props4$filter, matchItem = _props4.matchItem; return _react2.default.createElement( 'div', { className: 'popup-container' }, _react2.default.createElement( 'div', { className: 'popup' }, _react2.default.createElement(_reactAutocomplete2.default, { autoHighlight: false, ref: function ref(ac) { return _this4.onAutocompleteRef(ac); }, wrapperStyle: {}, wrapperProps: { className: 'Autocomplete', onMouseDown: function onMouseDown() { return _this4._ignoreBlur = true; }, onMouseUp: function onMouseUp() { return _this4._ignoreBlur = false; } }, inputProps: { className: (0, _classnames2.default)('input', { hidden: !matchItem }), onFocus: function onFocus(e) { _this4._ignoreBlur = false; e.target.select(); }, onBlur: function onBlur() { return _this4.onBlur(); }, onKeyDown: function onKeyDown(e) { return _this4.onKeyDown(e); } }, open: true, value: value, items: items, getItemValue: function getItemValue(x) { return x; }, shouldItemRender: filter && matchItem ? matchItem : undefined, renderItem: function renderItem(item, selected) { return _this4.renderItem(item, selected); }, renderMenu: function renderMenu() { return _this4.renderMenu.apply(_this4, arguments); }, onSelect: function onSelect(value, item) { onChange(getValue(value)); _this4.setState({ value: '', open: false }); }, onChange: function onChange(e, v) { return _this4.onChange(e, v); } }) ) ); } }, { key: 'render', value: function render() { return _react2.default.createElement( 'div', { className: (0, _classnames2.default)('DropDown', this.props.collapse && 'collapse', this.props.className) }, this.renderButton(), this.renderPopup() ); } }]); return DropDown; }(_react2.default.Component); exports.default = DropDown; },{"./WikiButton":56,"classnames":"classnames","react":"react","react-autocomplete":"react-autocomplete"}],11:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = DropDownButton; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _DropDown = require('./DropDown'); var _DropDown2 = _interopRequireDefault(_DropDown); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function DropDownButton(_ref) { var className = _ref.className, collapse = _ref.collapse, items = _ref.items, renderItem = _ref.renderItem, onClick = _ref.onClick, children = _ref.children; return _react2.default.createElement(_DropDown2.default, { className: className, collapse: collapse, items: items, renderItem: renderItem, value: children, onChange: function onChange(x) { return onClick(x); } }); } },{"./DropDown":10,"react":"react"}],12:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _Loader = require('./Loader'); var _Loader2 = _interopRequireDefault(_Loader); var _WikiButton = require('./WikiButton'); var _WikiButton2 = _interopRequireDefault(_WikiButton); var _wikiPreview = require('./wikiPreview'); var _Api = require('../Api'); var _Api2 = _interopRequireDefault(_Api); var _translate = require('../translate'); var _utils = require('../utils'); var _url = require('../url'); var _url2 = _interopRequireDefault(_url); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var EditathonAward = function (_React$Component) { _inherits(EditathonAward, _React$Component); _createClass(EditathonAward, null, [{ key: 'contextTypes', get: function get() { return { router: _react2.default.PropTypes.object.isRequired }; } }]); function EditathonAward(props) { _classCallCheck(this, EditathonAward); var _this = _possibleConstructorReturn(this, (EditathonAward.__proto__ || Object.getPrototypeOf(EditathonAward)).call(this, props)); _this.state = { loading: false, processing: false, data: [], texts: [] }; _this.renderAward = _this.renderAward.bind(_this); return _this; } _createClass(EditathonAward, [{ key: 'componentWillMount', value: function () { var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { var data; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: this.setState({ loading: true }); _context.next = 3; return _Api2.default.getResults(this.props.editathon.code, 3); case 3: data = _context.sent; this.setState({ data: data, loading: false }); case 5: case 'end': return _context.stop(); } } }, _callee, this); })); function componentWillMount() { return _ref.apply(this, arguments); } return componentWillMount; }() }, { key: 'editText', value: function editText(rank, text) { var texts = this.state.texts; texts[rank] = text; this.setState({ texts: texts }); } }, { key: 'hasSignature', value: function hasSignature(rank) { return (/(^|[^~])~~~~(?!~)/.exec(this.state.texts[rank]) ); } }, { key: 'addSignature', value: function addSignature(rank) { var text = this.state.texts[rank] || ''; this.editText(rank, text.replace(/\s+$/, '') + ' ~~~~'); } }, { key: 'renderAward', value: function renderAward(_ref2) { var _this2 = this; var _ref3 = _slicedToArray(_ref2, 2), rank = _ref3[0], users = _ref3[1]; var text = this.state.texts[rank] || ''; return _react2.default.createElement( 'div', { key: rank, className: 'award' }, _react2.default.createElement( 'h3', null, this.tr('rank', rank) ), _react2.default.createElement( 'div', { className: 'users' }, users.map(function (u, i) { return _react2.default.createElement( 'span', { key: i, className: 'user' }, u ); }) ), _react2.default.createElement('textarea', { rows: 4, value: text, onChange: function onChange(ev) { return _this2.editText(rank, ev.target.value); } }), text && !this.hasSignature(rank) && _react2.default.createElement( 'div', { className: 'warning' }, _react2.default.createElement( 'span', null, this.tr('noSignature', _react2.default.createElement( 'button', { key: 'sig', className: 'sig', onClick: function onClick() { return _this2.addSignature(rank); } }, '~~~~' )) ) ), _react2.default.createElement(_wikiPreview.WikiText, { className: 'preview', padding: false, autoSize: true, text: text, wiki: this.props.editathon.wiki, title: 'User talk:' + users[0] }) ); } }, { key: 'goBack', value: function goBack() { this.context.router.replace({ pathname: (0, _url2.default)('/editathons/' + this.props.editathon.code) }); } }, { key: 'process', value: function () { var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { var awards, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step$value, rank, users, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, user; return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: this.setState({ processing: true }); _context2.prev = 1; awards = {}; _iteratorNormalCompletion = true; _didIteratorError = false; _iteratorError = undefined; _context2.prev = 6; _iterator = this.getPlaces()[Symbol.iterator](); case 8: if (_iteratorNormalCompletion = (_step = _iterator.next()).done) { _context2.next = 32; break; } _step$value = _slicedToArray(_step.value, 2), rank = _step$value[0], users = _step$value[1]; _iteratorNormalCompletion2 = true; _didIteratorError2 = false; _iteratorError2 = undefined; _context2.prev = 13; for (_iterator2 = users[Symbol.iterator](); !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { user = _step2.value; awards[user] = this.state.texts[rank]; } _context2.next = 21; break; case 17: _context2.prev = 17; _context2.t0 = _context2['catch'](13); _didIteratorError2 = true; _iteratorError2 = _context2.t0; case 21: _context2.prev = 21; _context2.prev = 22; if (!_iteratorNormalCompletion2 && _iterator2.return) { _iterator2.return(); } case 24: _context2.prev = 24; if (!_didIteratorError2) { _context2.next = 27; break; } throw _iteratorError2; case 27: return _context2.finish(24); case 28: return _context2.finish(21); case 29: _iteratorNormalCompletion = true; _context2.next = 8; break; case 32: _context2.next = 38; break; case 34: _context2.prev = 34; _context2.t1 = _context2['catch'](6); _didIteratorError = true; _iteratorError = _context2.t1; case 38: _context2.prev = 38; _context2.prev = 39; if (!_iteratorNormalCompletion && _iterator.return) { _iterator.return(); } case 41: _context2.prev = 41; if (!_didIteratorError) { _context2.next = 44; break; } throw _iteratorError; case 44: return _context2.finish(41); case 45: return _context2.finish(38); case 46: _context2.next = 48; return _Api2.default.award(this.props.editathon.code, awards); case 48: this.goBack(); _context2.next = 55; break; case 51: _context2.prev = 51; _context2.t2 = _context2['catch'](1); alert(_context2.t2); this.setState({ processing: false }); case 55: case 'end': return _context2.stop(); } } }, _callee2, this, [[1, 51], [6, 34, 38, 46], [13, 17, 21, 29], [22,, 24, 28], [39,, 41, 45]]); })); function process() { return _ref4.apply(this, arguments); } return process; }() }, { key: 'tr', value: function tr() { var tr = this.props.translation.tr; return tr.apply(undefined, arguments); } }, { key: 'isValid', value: function isValid() { var texts = this.state.texts; return texts.filter(function (x) { return x; }).length === this.getPlaces().length; } }, { key: 'getPlaces', value: function getPlaces() { return [].concat(_toConsumableArray((0, _utils.groupBy)(this.state.data, function (r) { return r.rank; }, function (r) { return r.name; }))); } }, { key: 'render', value: function render() { var _this3 = this; var _state = this.state, loading = _state.loading, processing = _state.processing; return _react2.default.createElement( 'div', { className: 'EditathonAward' }, _react2.default.createElement( 'h2', null, this.tr('title') ), _react2.default.createElement( _Loader2.default, { className: 'entries', loading: loading }, this.getPlaces().map(this.renderAward) ), !loading && _react2.default.createElement( 'div', { className: 'buttons' }, _react2.default.createElement( _WikiButton2.default, { type: 'constructive', onClick: function onClick() { return _this3.process(); }, loading: processing, disabled: !this.isValid() }, this.tr('award') ), _react2.default.createElement( _WikiButton2.default, { onClick: function onClick() { return _this3.goBack(); }, disabled: processing }, this.tr('cancel') ) ) ); } }]); return EditathonAward; }(_react2.default.Component); exports.default = (0, _translate.withTranslation)(EditathonAward, 'EditathonAward'); },{"../Api":4,"../translate":73,"../url":96,"../utils":97,"./Loader":36,"./WikiButton":56,"./wikiPreview":60,"react":"react"}],13:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _moment = require('moment'); var _moment2 = _interopRequireDefault(_moment); var _Tooltip = require('./Tooltip'); var _Tooltip2 = _interopRequireDefault(_Tooltip); var _translate = require('./../translate'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } function overlap(e1, e2) { return e1.start.isSameOrBefore(e2.start) && e2.start.isSameOrBefore(e1.finish) || e2.start.isSameOrBefore(e1.start) && e1.start.isSameOrBefore(e2.finish); } function getLayers(editathons) { var layers = []; var first = true; var _iteratorNormalCompletion = true; var _didIteratorError = false; var _iteratorError = undefined; try { var _loop = function _loop() { var editathon = _step.value; var layer = layers.filter(function (lr) { return lr.every(function (e) { return !overlap(e, editathon); }); })[0]; if (!layer) { layer = []; layers.push(layer); } layer.push(editathon); }; for (var _iterator = editathons[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { _loop(); } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally { try { if (!_iteratorNormalCompletion && _iterator.return) { _iterator.return(); } } finally { if (_didIteratorError) { throw _iteratorError; } } } return layers; } function totalMonths(m) { return m.year() * 12 + m.month(); } var EditathonCalendar = function (_React$PureComponent) { _inherits(EditathonCalendar, _React$PureComponent); function EditathonCalendar() { _classCallCheck(this, EditathonCalendar); return _possibleConstructorReturn(this, (EditathonCalendar.__proto__ || Object.getPrototypeOf(EditathonCalendar)).apply(this, arguments)); } _createClass(EditathonCalendar, [{ key: 'onWheel', value: function onWheel(e) { e.preventDefault(); var k = 1; if (e.deltaMode === 1) { k = parseFloat(getComputedStyle(this._element).lineHeight); } this._element.scrollLeft += e.deltaY * k; } }, { key: 'formatDate', value: function formatDate() { var _props$translation; for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return (_props$translation = this.props.translation).translate.apply(_props$translation, ['formatDate'].concat(args)); } }, { key: 'renderSection', value: function renderSection(d, isFirst) { var format = isFirst || d.month() === 0 ? 'MMM YYYY' : 'MMM'; return _react2.default.createElement( 'div', { className: 'section', key: d.toDate().getTime() }, _react2.default.createElement( 'span', { className: 'label' }, this.formatDate(d, format) ) ); } }, { key: 'renderAxis', value: function renderAxis(min, max) { var sections = []; for (var d = min.clone(); d.isSameOrBefore(max); d.add(1, 'month')) { sections.push(this.renderSection(d, d.isSame(min))); } return _react2.default.createElement( 'div', { id: 'axis' }, sections ); } }, { key: 'dateToOffset', value: function dateToOffset(date, min) { var months = totalMonths(date) - totalMonths(min); return months * 100 + (date.date() - 1) * 100.0 / (date.daysInMonth() - 1); } }, { key: 'renderStrip', value: function renderStrip(e, min, isFirstLayer, key) { var left = this.dateToOffset(e.start, min); var right = this.dateToOffset(e.finish, min); return _react2.default.createElement( 'div', { className: 'strip', key: key, style: { left: left, width: right - left } }, _react2.default.createElement( 'div', { className: 'tooltip' }, _react2.default.createElement( _Tooltip2.default, { onTop: isFirstLayer }, e.name + '\n' + this.formatDate(e.start, 'L') + ' \u2013 ' + this.formatDate(e.finish, 'L') ) ), _react2.default.createElement('div', { className: 'inner' }) ); } }, { key: 'renderLayers', value: function renderLayers(editathons, min) { var _this2 = this; var layers = getLayers(editathons); return layers.map(function (layer, i) { return _react2.default.createElement( 'div', { className: 'layer', key: i }, layer.map(function (editathon, j) { return _this2.renderStrip(editathon, min, i === 0, j); }) ); }); } }, { key: 'render', value: function render() { var _this3 = this; var editathons = this.props.editathons.map(function (e) { return _extends({}, e, { start: (0, _moment2.default)(e.start).startOf('day'), finish: (0, _moment2.default)(e.finish).startOf('day') }); }).filter(function (e) { return !e.start.isSame(e.finish); }); var min = (0, _moment2.default)(_moment2.default.min(editathons.map(function (e) { return e.start; }))).startOf('month'); var max = (0, _moment2.default)(_moment2.default.max(editathons.map(function (e) { return e.finish; }))).startOf('month').add(1, 'month'); if (max.diff(min, 'months') < 7) { min = (0, _moment2.default)(max).add(-7, 'months'); } return _react2.default.createElement( 'div', { className: 'EditathonCalendar', onWheel: function onWheel(e) { return _this3.onWheel(e); }, ref: function ref(x) { return _this3._element = x; } }, _react2.default.createElement( 'div', { className: 'content' }, this.renderAxis(min, max), this.renderLayers(editathons, min) ) ); } }]); return EditathonCalendar; }(_react2.default.PureComponent); exports.default = (0, _translate.withTranslation)(EditathonCalendar); },{"./../translate":73,"./Tooltip":53,"moment":"moment","react":"react"}],14:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _GeneralPage = require('./GeneralPage'); var _GeneralPage2 = _interopRequireDefault(_GeneralPage); var _RulesPage = require('./RulesPage'); var _RulesPage2 = _interopRequireDefault(_RulesPage); var _MarksPage = require('./MarksPage'); var _MarksPage2 = _interopRequireDefault(_MarksPage); var _TemplatePage = require('./TemplatePage'); var _TemplatePage2 = _interopRequireDefault(_TemplatePage); var _JuryPage = require('./JuryPage'); var _JuryPage2 = _interopRequireDefault(_JuryPage); var _validation = require('./validation'); var _Loader = require('../Loader'); var _Loader2 = _interopRequireDefault(_Loader); var _WikiButton = require('../WikiButton'); var _WikiButton2 = _interopRequireDefault(_WikiButton); var _Api = require('../../Api'); var _Api2 = _interopRequireDefault(_Api); var _translate = require('../../translate'); var _url = require('../../url'); var _url2 = _interopRequireDefault(_url); var _ModalDialog = require('../ModalDialog'); var _ModalDialog2 = _interopRequireDefault(_ModalDialog); var _Link = require('../Link'); var _Link2 = _interopRequireDefault(_Link); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } function Headers(_ref) { var items = _ref.items, selected = _ref.selected, _onClick = _ref.onClick; return _react2.default.createElement( 'div', { className: 'Headers' }, items.map(function (item, i) { return _react2.default.createElement( 'button', { key: i, className: (0, _classnames2.default)({ item: true, selected: i === selected }), onClick: function onClick() { return _onClick(i); } }, item ); }) ); } var Pages = { general: _GeneralPage2.default, rules: _RulesPage2.default, marks: _MarksPage2.default, template: _TemplatePage2.default, jury: _JuryPage2.default }; var EditathonConfig = function (_React$Component) { _inherits(EditathonConfig, _React$Component); _createClass(EditathonConfig, null, [{ key: 'contextTypes', get: function get() { return { router: _react2.default.PropTypes.object.isRequired }; } }]); function EditathonConfig(props) { _classCallCheck(this, EditathonConfig); var _this = _possibleConstructorReturn(this, (EditathonConfig.__proto__ || Object.getPrototypeOf(EditathonConfig)).call(this, props)); _this.state = { selected: 'general', sending: false, loading: false, editathon: {}, validating: false, existingDraft: null }; _this._maxPageIndex = 0; return _this; } _createClass(EditathonConfig, [{ key: 'getCode', value: function getCode() { var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.props; return props.params.id; } }, { key: 'isNew', value: function isNew() { return this.getCode() === 'new'; } }, { key: 'componentWillMount', value: function () { var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { var draft, editathon; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: this.setState({ loading: true }); _context.next = 3; return _Api2.default.getDraft(); case 3: draft = _context.sent; this.setState({ loading: false, draft: draft }); if (!(!draft && !this.isNew() && Global.user)) { _context.next = 11; break; } this.setState({ loading: true }); _context.next = 9; return _Api2.default.getEditathonConfig(this.getCode()); case 9: editathon = _context.sent; this.setState({ loading: false, editathon: editathon }); case 11: case 'end': return _context.stop(); } } }, _callee, this); })); function componentWillMount() { return _ref2.apply(this, arguments); } return componentWillMount; }() }, { key: 'componentDidUpdate', value: function () { var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(prevProps) { var draft, editathon; return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: draft = this.state.draft; if (draft && this.getCode() === draft.code) { this.setState({ draft: null }); } if (!(this.getCode(prevProps) !== this.getCode())) { _context2.next = 8; break; } this.setState({ loading: true }); _context2.next = 6; return _Api2.default.getEditathonConfig(this.getCode()); case 6: editathon = _context2.sent; this.setState({ loading: false, editathon: editathon }); case 8: case 'end': return _context2.stop(); } } }, _callee2, this); })); function componentDidUpdate(_x2) { return _ref3.apply(this, arguments); } return componentDidUpdate; }() }, { key: 'goBack', value: function goBack() { var returnTo = this.props.location.query.returnTo; if (returnTo) { this.context.router.push((0, _url2.default)(returnTo)); } else { this.context.router.replace((0, _url2.default)(this.isNew() || !this.state.editathon.isPublished ? '/editathons/' : '/editathons/' + this.state.editathon.code)); } } }, { key: 'moveBack', value: function moveBack() { if (this.getSelectedIndex() === 0) { this.goBack(); } else { this.moveTo(Object.keys(Pages)[this.getSelectedIndex() - 1], 'back'); } } }, { key: 'moveNext', value: function moveNext() { this.moveTo(Object.keys(Pages)[this.getSelectedIndex() + 1], 'next'); } }, { key: 'moveTo', value: function () { var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(key) { var validating = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; return regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: if (!this.state.validating) { _context3.next = 2; break; } return _context3.abrupt('return'); case 2: this.setState({ validating: validating }); _context3.t0 = key; if (!_context3.t0) { _context3.next = 8; break; } _context3.next = 7; return this._form.validate(); case 7: _context3.t0 = _context3.sent; case 8: if (!_context3.t0) { _context3.next = 11; break; } this.setState({ selected: key }); this._maxPageIndex = Math.max(this._maxPageIndex, Object.keys(Pages).indexOf(key)); case 11: this.setState({ validating: false }); case 12: case 'end': return _context3.stop(); } } }, _callee3, this); })); function moveTo(_x3) { return _ref4.apply(this, arguments); } return moveTo; }() }, { key: 'getSelectedIndex', value: function getSelectedIndex() { return Object.keys(Pages).indexOf(this.state.selected); } }, { key: 'shouldShowPage', value: function shouldShowPage(key) { if (!this.isNew()) return true; return Object.keys(Pages).indexOf(key) <= this._maxPageIndex; } }, { key: 'submit', value: function () { var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() { var editathon; return regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: _context4.next = 2; return this._form.validate(); case 2: if (_context4.sent) { _context4.next = 4; break; } return _context4.abrupt('return'); case 4: this.setState({ sending: true }); editathon = this.state.editathon; _context4.prev = 6; if (!this.isNew()) { _context4.next = 12; break; } _context4.next = 10; return _Api2.default.createEditathon(editathon); case 10: _context4.next = 14; break; case 12: _context4.next = 14; return _Api2.default.setEditathonConfig(this.getCode(), editathon); case 14: this.goBack(); _context4.next = 21; break; case 17: _context4.prev = 17; _context4.t0 = _context4['catch'](6); alert(_context4.t0.message); this.setState({ sending: false }); case 21: case 'end': return _context4.stop(); } } }, _callee4, this, [[6, 17]]); })); function submit() { return _ref5.apply(this, arguments); } return submit; }() }, { key: 'render', value: function render() { var _this2 = this; var tr = this.props.translation.tr; var _state = this.state, editathon = _state.editathon, selected = _state.selected, sending = _state.sending, loading = _state.loading, validating = _state.validating, draft = _state.draft; if (!Global.user) { this.goBack(); return null; } if (loading) { return _react2.default.createElement(_Loader2.default, null); } var isLast = this.getSelectedIndex() === Object.keys(Pages).length - 1; if (draft) { return _react2.default.createElement( 'div', { className: 'EditathonConfig' }, _react2.default.createElement( _ModalDialog2.default, { isOpen: true, className: 'draftExists' }, _react2.default.createElement( 'div', { className: 'message' }, tr('draftExists', draft.name) ), _react2.default.createElement( 'div', { className: 'buttons' }, _react2.default.createElement( _WikiButton2.default, { type: 'progressive' }, _react2.default.createElement( _Link2.default, { replace: true, to: '/editathons/' + draft.code + '/config' }, tr('editDraft') ) ), _react2.default.createElement( _WikiButton2.default, { onClick: function onClick() { return _this2.goBack(); } }, tr('cancel') ) ) ) ); } return _react2.default.createElement( _validation.ValidationForm, { className: (0, _classnames2.default)('EditathonConfig', 'mainContentPane', validating && 'validating'), ref: function ref(r) { return _this2._form = r; } }, _react2.default.createElement( 'h1', null, this.isNew() ? tr('newEditathon') : editathon.name ), _react2.default.createElement(Headers, { items: Object.keys(Pages).filter(function (k) { return _this2.shouldShowPage(k); }).map(function (k) { return tr(k); }), selected: this.getSelectedIndex(), onClick: function onClick(k) { return _this2.moveTo(Object.keys(Pages)[k]); } }), _react2.default.createElement(Pages[selected], { value: editathon, onChange: function onChange(v) { return _this2.setState({ editathon: v }); }, isNew: this.isNew() }), this.isNew() ? _react2.default.createElement( 'div', { className: 'buttons' }, _react2.default.createElement( _WikiButton2.default, { disabled: validating, loading: validating === 'back', onClick: function onClick() { return _this2.moveBack(); } }, tr('back') ), !isLast && _react2.default.createElement( _WikiButton2.default, { disabled: validating, loading: validating === 'next', type: 'progressive', onClick: function onClick() { return _this2.moveNext(); } }, tr('next') ), isLast && _react2.default.createElement( _WikiButton2.default, { disabled: validating, loading: sending || validating === 'next', type: 'progressive', onClick: function onClick() { return _this2.submit(); } }, tr('create') ) ) : _react2.default.createElement( 'div', { className: 'buttons' }, _react2.default.createElement( _WikiButton2.default, { disabled: validating, loading: sending, type: 'progressive', onClick: function onClick() { return _this2.submit(); } }, tr('save') ), _react2.default.createElement( _WikiButton2.default, { disabled: validating, onClick: function onClick() { return _this2.goBack(); } }, tr('cancel') ) ) ); } }]); return EditathonConfig; }(_react2.default.Component); exports.default = (0, _translate.withTranslation)(EditathonConfig, 'EditathonConfig'); },{"../../Api":4,"../../translate":73,"../../url":96,"../Link":35,"../Loader":36,"../ModalDialog":42,"../WikiButton":56,"./GeneralPage":15,"./JuryPage":16,"./MarksPage":17,"./RulesPage":18,"./TemplatePage":19,"./validation":20,"classnames":"classnames","react":"react"}],15:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _moment = require('moment'); var _moment2 = _interopRequireDefault(_moment); var _DateTimePicker = require('../DateTimePicker'); var _DateTimePicker2 = _interopRequireDefault(_DateTimePicker); var _WikiLookup = require('../WikiLookup'); var _WikiLookup2 = _interopRequireDefault(_WikiLookup); var _jury = require('../../jury'); var _translate = require('../../translate'); var _validation = require('./validation'); var _utils = require('../utils'); var _Api = require('../../Api'); var _Api2 = _interopRequireDefault(_Api); var _throttle = require('../../throttle'); var _throttle2 = _interopRequireDefault(_throttle); var _url = require('../../url'); var _url2 = _interopRequireDefault(_url); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } function getDefaultData() { var date = _moment2.default.utc().add('d', 1); return { start: (0, _moment2.default)(date).startOf('d'), finish: (0, _moment2.default)(date).endOf('d') }; } var GeneralPage = function (_React$Component) { _inherits(GeneralPage, _React$Component); function GeneralPage(props) { _classCallCheck(this, GeneralPage); var _this = _possibleConstructorReturn(this, (GeneralPage.__proto__ || Object.getPrototypeOf(GeneralPage)).call(this, props)); _this.state = { code: '' }; _this.set = (0, _utils.createSetter)(); _this.bind = (0, _utils.createBinder)(); _this.codeChecker = existanceChecker('code'); _this.nameChecker = existanceChecker('name', props.isNew ? null : props.value.code); return _this; } _createClass(GeneralPage, [{ key: 'componentWillMount', value: function componentWillMount() { (0, _utils.setDefault)(this.props, getDefaultData); if (!this.state.code && this.props.value.code) { this.setState({ code: this.props.value.code }); } } }, { key: 'setCode', value: function setCode(code) { this.setState({ code: code }); code = code.trim().replace(/[ _]/g, '-').toLowerCase(); this.set('code', code); this.codeChecker.onChange(code); } }, { key: 'setName', value: function setName(name) { this.set('name', name); this.nameChecker.onChange(name); } }, { key: 'changeFlag', value: function changeFlag(flag, isSet) { var value = this.props.value; var flags = isSet ? value.flags | flag : value.flags & ~flag; this.set('flags', flags); } }, { key: 'validateCodeOrName', value: function () { var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(what) { var _props, value, tr, isNew, exists; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _props = this.props, value = _props.value[what], tr = _props.translation.tr, isNew = _props.isNew; if (!(what === 'code' && !isNew)) { _context.next = 3; break; } return _context.abrupt('return'); case 3: if (!(value.length < 3)) { _context.next = 5; break; } return _context.abrupt('return', tr('tooShort')); case 5: if (!(what === 'code')) { _context.next = 8; break; } if (/^[a-z0-9\- ]+$/i.test(value)) { _context.next = 8; break; } return _context.abrupt('return', tr('codeSymbols')); case 8: _context.next = 10; return (what === 'code' ? this.codeChecker : this.nameChecker).check(value); case 10: exists = _context.sent; if (!exists) { _context.next = 13; break; } return _context.abrupt('return', tr('exists')); case 13: case 'end': return _context.stop(); } } }, _callee, this); })); function validateCodeOrName(_x) { return _ref.apply(this, arguments); } return validateCodeOrName; }() }, { key: 'render', value: function render() { var _this2 = this; var _props2 = this.props, value = _props2.value, tr = _props2.translation.tr, isNew = _props2.isNew; return _react2.default.createElement( 'div', { className: 'page GeneralPage' }, _react2.default.createElement( 'label', { id: 'name' }, _react2.default.createElement( 'span', null, tr('title') ), _react2.default.createElement( _validation.Validation, { isEmpty: function isEmpty() { return !value.name; }, validate: function validate() { return _this2.validateCodeOrName('name'); } }, _react2.default.createElement('input', { type: 'text', value: value.name, onChange: function onChange(e) { return _this2.setName(e.target.value); } }) ) ), _react2.default.createElement( 'label', { id: 'code' }, _react2.default.createElement( 'span', null, tr('code') ), _react2.default.createElement( _validation.Validation, { isEmpty: function isEmpty() { return !value.code; }, validate: function validate() { return _this2.validateCodeOrName('code'); } }, _react2.default.createElement('input', { disabled: !isNew, type: 'text', value: this.state.code, onChange: function onChange(e) { return _this2.setCode(e.target.value); } }) ), _react2.default.createElement( 'span', { id: 'url' }, window.location.origin + (0, _url2.default)('/editathons/') + encodeURIComponent(value.code || '') ) ), _react2.default.createElement( 'div', { className: 'field', id: 'project' }, _react2.default.createElement( 'label', { htmlFor: 'wiki' }, tr('project') ), _react2.default.createElement( _validation.Validation, { isEmpty: function isEmpty() { return !value.wiki; } }, this.bind('wiki', _react2.default.createElement(_WikiLookup2.default, { inputProps: { id: 'wiki' } })) ) ), _react2.default.createElement( 'label', { id: 'description', className: 'optional' }, _react2.default.createElement( 'span', null, tr('description'), _react2.default.createElement( 'span', { className: 'optional' }, tr('optional') ) ), this.bind('description', _react2.default.createElement('textarea', null)) ), _react2.default.createElement( 'div', { id: 'dates', className: 'field' }, _react2.default.createElement( 'div', { className: 'field' }, _react2.default.createElement( 'label', { htmlFor: 'startDate' }, tr('startDate') ), _react2.default.createElement( _validation.Validation, { isEmpty: function isEmpty() { return !value.start; } }, this.bind('start', _react2.default.createElement(_DateTimePicker2.default, { id: 'startDate', vertical: true })) ) ), _react2.default.createElement( 'div', { className: 'field' }, _react2.default.createElement( 'label', { htmlFor: 'finishDate' }, tr('finishDate') ), _react2.default.createElement( _validation.Validation, { isEmpty: function isEmpty() { return !value.finish; }, validate: function validate() { return value.start && value.start >= value.finish && tr('negativeDates'); } }, this.bind('finish', _react2.default.createElement(_DateTimePicker2.default, { id: 'finishDate', vertical: true })) ) ) ), _react2.default.createElement( 'div', { id: 'flags', className: 'field' }, _react2.default.createElement( 'label', null, _react2.default.createElement('input', { type: 'checkbox', checked: value.flags & _jury.EditathonFlags.consensualVote, onChange: function onChange(e) { return _this2.changeFlag(_jury.EditathonFlags.consensualVote, e.target.checked); } }), tr('consensualVote'), _react2.default.createElement( 'span', { className: 'note' }, tr('consensualVoteNote') ) ), _react2.default.createElement( 'label', null, _react2.default.createElement('input', { type: 'checkbox', checked: value.flags & _jury.EditathonFlags.hiddenMarks, onChange: function onChange(e) { return _this2.changeFlag(_jury.EditathonFlags.hiddenMarks, e.target.checked); } }), tr('hiddenMarks'), _react2.default.createElement( 'span', { className: 'note' }, tr('hiddenMarksNote') ) ) ) ); } }]); return GeneralPage; }(_react2.default.Component); function existanceChecker(what, existingCode) { var value = ''; var result = false; function check(val) { val = val.trim(); if (!val) { return false; } if (val === value) { return result; } value = val; return result = _Api2.default.exists(what, val, existingCode); } return { check: check, onChange: (0, _throttle2.default)(check, 500) }; } exports.default = (0, _translate.withTranslation)(GeneralPage, 'EditathonConfig.GeneralPage'); },{"../../Api":4,"../../jury":65,"../../throttle":72,"../../translate":73,"../../url":96,"../DateTimePicker":9,"../WikiLookup":58,"../utils":59,"./validation":20,"moment":"moment","react":"react"}],16:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _translate = require('../../translate'); var _IntegerInput = require('../IntegerInput'); var _IntegerInput2 = _interopRequireDefault(_IntegerInput); var _UserLookup = require('../UserLookup'); var _UserLookup2 = _interopRequireDefault(_UserLookup); var _utils = require('../utils'); var _WikiButton = require('../WikiButton'); var _WikiButton2 = _interopRequireDefault(_WikiButton); var _validation = require('./validation'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } function getDefaultData() { return [Global.user.name]; } var JuryPage = function (_React$Component) { _inherits(JuryPage, _React$Component); function JuryPage(props) { _classCallCheck(this, JuryPage); var _this = _possibleConstructorReturn(this, (JuryPage.__proto__ || Object.getPrototypeOf(JuryPage)).call(this, props)); _this.bind = (0, _utils.createBinder)(); return _this; } _createClass(JuryPage, [{ key: 'componentDidMount', value: function componentDidMount() { (0, _utils.setDefault)(this.props, 'jury', getDefaultData); } }, { key: 'add', value: function add() { var _props = this.props, value = _props.value, onChange = _props.onChange; value.jury.push(''); onChange(value); } }, { key: 'replace', value: function replace(index, v) { var _props2 = this.props, value = _props2.value, onChange = _props2.onChange; if (v === undefined) { value.jury.splice(index, 1); } else { value.jury.splice(index, 1, v); } onChange(value); } }, { key: 'renderItem', value: function renderItem(jury, index) { var _this2 = this; return _react2.default.createElement( 'div', { className: 'item', key: index }, _react2.default.createElement( _validation.Validation, { isEmpty: function isEmpty() { return !jury; } }, _react2.default.createElement(_UserLookup2.default, { wiki: this.props.value.wiki, value: jury, onChange: function onChange(text) { return _this2.replace(index, text); } }) ), _react2.default.createElement(_WikiButton2.default, { className: 'delete', onClick: function onClick(e) { _this2.replace(index); e.target.blur(); } }) ); } }, { key: 'render', value: function render() { var _this3 = this; var _props3 = this.props, tr = _props3.translation.tr, value = _props3.value; var _value$jury = value.jury, jury = _value$jury === undefined ? [] : _value$jury, _value$minMarks = value.minMarks, minMarks = _value$minMarks === undefined ? 0 : _value$minMarks; return _react2.default.createElement( 'div', { className: 'page JuryPage' }, jury.map(function (j, i) { return _this3.renderItem(j, i); }), _react2.default.createElement( _validation.Validation, { isEmpty: function isEmpty() { return jury.length === 0; } }, _react2.default.createElement( _WikiButton2.default, { className: 'add', onClick: function onClick() { return _this3.add(); } }, tr('add') ) ), _react2.default.createElement( 'label', null, _react2.default.createElement( 'span', null, tr('minMarks') ), _react2.default.createElement(_IntegerInput2.default, { value: minMarks, min: 1, max: Math.max(1, jury.length), onChange: function onChange(v) { _this3.props.onChange(_extends({}, value, { minMarks: v })); } }) ) ); } }]); return JuryPage; }(_react2.default.Component); exports.default = (0, _translate.withTranslation)(JuryPage, 'EditathonConfig.JuryPage'); },{"../../translate":73,"../IntegerInput":25,"../UserLookup":54,"../WikiButton":56,"../utils":59,"./validation":20,"react":"react"}],17:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _DropDownButton = require('../DropDownButton'); var _DropDownButton2 = _interopRequireDefault(_DropDownButton); var _IntegerInput = require('../IntegerInput'); var _IntegerInput2 = _interopRequireDefault(_IntegerInput); var _MarksPreview = require('../MarksPreview'); var _MarksPreview2 = _interopRequireDefault(_MarksPreview); var _WikiButton = require('../WikiButton'); var _WikiButton2 = _interopRequireDefault(_WikiButton); var _translate = require('../../translate'); var _validation = require('./validation'); var _utils = require('../utils'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var MarksPage = function (_React$Component) { _inherits(MarksPage, _React$Component); function MarksPage(props) { _classCallCheck(this, MarksPage); var _this = _possibleConstructorReturn(this, (MarksPage.__proto__ || Object.getPrototypeOf(MarksPage)).call(this, props)); _this._markPrototypes = { check: function check() { return { title: '', value: 0, children: {} }; }, int: function int() { return { title: '', min: 1, max: 5 }; }, radio: function radio() { return { title: '', values: [_this._markPrototypes.option(), _this._markPrototypes.option()] }; }, option: function option() { return { title: '', children: {}, value: 0 }; } }; _this._markRenderers = { check: _this.renderCheck, radio: _this.renderRadio, int: _this.renderInt }; for (var key in _this._markRenderers) { _this._markRenderers[key] = _this._markRenderers[key].bind(_this); } _this.onNewProps(props); return _this; } _createClass(MarksPage, [{ key: 'componentWillMount', value: function componentWillMount() { (0, _utils.setDefault)(this.props, 'marks', function () { return { 0: { type: 'radio', title: 'Accept the article?', values: [{ value: 1, title: 'Yes', description: 'accepted', children: {} }, { value: 0, title: 'No', description: 'not accepted', children: {} }] } }; }); } }, { key: 'componentWillReceiveProps', value: function componentWillReceiveProps(nextProps) { this.onNewProps(nextProps, this.props); } }, { key: 'onNewProps', value: function onNewProps(newProps) { var oldProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; if (newProps.value === oldProps.value) { return; } this._marks = JSON.parse(JSON.stringify({ x: newProps.value.marks })).x; this.calcId(newProps); } }, { key: 'calcId', value: function calcId() { var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.props; function getChildIds(mark) { return mark.children ? getIds(mark.children) : []; } function getIds(marks) { var _ref; return [].concat(_toConsumableArray(Object.keys(marks)), _toConsumableArray((_ref = []).concat.apply(_ref, _toConsumableArray(Object.values(marks).map(function (m) { var _ref2; return m.type === 'radio' ? (_ref2 = []).concat.apply(_ref2, _toConsumableArray(m.values.map(getChildIds))) : getChildIds(m); }))))); } var marks = props.value.marks; if (!marks) return; this._id = Math.max.apply(Math, _toConsumableArray(getIds(marks).concat(-1))) + 1; } }, { key: 'tr', value: function tr() { var _props$translation; return (_props$translation = this.props.translation).tr.apply(_props$translation, arguments); } }, { key: 'renderGenericMark', value: function renderGenericMark(id, mark, header, onDelete, value, showDesc, children) { var _this2 = this; return _react2.default.createElement( 'div', { key: id, className: 'mark' }, _react2.default.createElement( 'div', { className: 'settings' }, _react2.default.createElement( 'header', null, _react2.default.createElement( 'span', null, header ), onDelete && _react2.default.createElement(_WikiButton2.default, { className: 'delete', onClick: onDelete }) ), _react2.default.createElement( 'div', { className: 'row' }, _react2.default.createElement( 'label', { className: 'title' }, _react2.default.createElement( 'span', null, this.tr('title') ), _react2.default.createElement( _validation.Validation, { isEmpty: function isEmpty() { return !mark.title; } }, _react2.default.createElement('input', { value: mark.title, onChange: function onChange(e) { mark.title = e.target.value; _this2.onChange(); } }) ) ), value ), showDesc && _react2.default.createElement( 'div', { className: 'row' }, _react2.default.createElement( 'label', { className: 'description' }, _react2.default.createElement( 'span', null, this.tr('description') ), _react2.default.createElement('input', { value: mark.description || '', onChange: function onChange(e) { mark.description = e.target.value; _this2.onChange(); }, placeholder: this.tr('optional') }) ) ) ), children ); } }, { key: 'renderIntegerValue', value: function renderIntegerValue(mark) { var _this3 = this; var title = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'value'; var prop = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : title; return _react2.default.createElement( 'label', { key: prop }, _react2.default.createElement( 'span', null, this.tr(title) ), _react2.default.createElement( _validation.Validation, { isEmpty: function isEmpty() { return !mark[prop] && mark[prop] !== 0; } }, _react2.default.createElement(_IntegerInput2.default, { value: mark[prop], onChange: function onChange(v) { mark[prop] = v; _this3.onChange(); } }) ) ); } }, { key: 'renderRadio', value: function renderRadio(id, mark, onDelete) { var _this4 = this; return this.renderGenericMark(id, mark, this.tr(mark.type), onDelete, null, false, [_react2.default.createElement( 'div', { className: 'options', key: 'options' }, mark.values.map(function (option, index) { return _this4.renderGenericMark(index, option, _this4.tr('option'), mark.values.length <= 2 ? null : function () { mark.values.splice(index, 1); _this4.onChange(); }, _this4.renderIntegerValue(option), true, [_this4.renderMarks(option.children), _this4.renderAdd(option.children)]); }) ), _react2.default.createElement( _WikiButton2.default, { className: 'add', key: 'add', onClick: function onClick() { mark.values.push(_this4._markPrototypes['option']()); _this4.onChange(); } }, this.tr('addOption') )]); } }, { key: 'renderCheck', value: function renderCheck(id, mark, onDelete) { return this.renderGenericMark(id, mark, this.tr(mark.type), onDelete, this.renderIntegerValue(mark), true, [this.renderMarks(mark.children), this.renderAdd(mark.children)]); } }, { key: 'renderInt', value: function renderInt(id, mark, onDelete) { return this.renderGenericMark(id, mark, this.tr(mark.type), onDelete, [this.renderIntegerValue(mark, 'min'), this.renderIntegerValue(mark, 'max')]); } }, { key: 'renderAdd', value: function renderAdd(marks) { var _this5 = this; return _react2.default.createElement(_DropDownButton2.default, { key: 'add', className: 'add', items: Object.keys(this._markRenderers), renderItem: function renderItem(t) { return _this5.tr(t); }, onClick: function onClick(t) { return _this5.add(t, marks); }, children: this.tr('add') }); } }, { key: 'add', value: function add(type, marks) { marks[this._id++] = _extends({ type: type }, this._markPrototypes[type]()); this.onChange(); } }, { key: 'del', value: function del(id, marks) { delete marks[id]; this.onChange(); } }, { key: 'onChange', value: function onChange() { var _props = this.props, value = _props.value, onChange = _props.onChange; onChange(_extends({}, value, { marks: this._marks })); } }, { key: 'renderMarks', value: function renderMarks(marks) { var _this6 = this; return Object.keys(marks).map(function (id) { var mark = marks[id]; return _this6._markRenderers[mark.type](id, mark, function () { return _this6.del(id, marks); }); }); } }, { key: 'render', value: function render() { var marks = this._marks; if (!marks) return null; return _react2.default.createElement( 'div', { className: 'page MarksPage' }, this.renderMarks(marks), this.renderAdd(marks), _react2.default.createElement( 'div', { className: 'preview' }, _react2.default.createElement( 'header', null, this.tr('preview') ), _react2.default.createElement(_MarksPreview2.default, { config: marks }) ) ); } }]); return MarksPage; }(_react2.default.Component); exports.default = (0, _translate.withTranslation)(MarksPage, 'EditathonConfig.MarksPage'); },{"../../translate":73,"../DropDownButton":11,"../IntegerInput":25,"../MarksPreview":41,"../WikiButton":56,"../utils":59,"./validation":20,"react":"react"}],18:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _getArticleData = require('../../getArticleData'); var _getArticleData2 = _interopRequireDefault(_getArticleData); var _MwApi = require('../../MwApi'); var _rules = require('../../rules'); var _rules2 = _interopRequireDefault(_rules); var _translate = require('../../translate'); var _DateTimePicker = require('../DateTimePicker'); var _DateTimePicker2 = _interopRequireDefault(_DateTimePicker); var _DropDown = require('../DropDown'); var _DropDown2 = _interopRequireDefault(_DropDown); var _DropDownButton = require('../DropDownButton'); var _DropDownButton2 = _interopRequireDefault(_DropDownButton); var _Warnings = require('../Jury/Warnings'); var _Warnings2 = _interopRequireDefault(_Warnings); var _Loader = require('../Loader'); var _Loader2 = _interopRequireDefault(_Loader); var _PageLookup = require('../PageLookup'); var _PageLookup2 = _interopRequireDefault(_PageLookup); var _UserLookup = require('../UserLookup'); var _UserLookup2 = _interopRequireDefault(_UserLookup); var _utils = require('../utils'); var _Warnings3 = require('../Warnings'); var _Warnings4 = _interopRequireDefault(_Warnings3); var _WikiButton = require('../WikiButton'); var _WikiButton2 = _interopRequireDefault(_WikiButton); var _WikiLink = require('../WikiLink'); var _WikiLink2 = _interopRequireDefault(_WikiLink); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } function setDefaultParams(component, params) { var cwm = component.componentWillMount; component.componentWillMount = function componentWillMount() { if (cwm) { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } cwm.apply(component, args); } if (Object.keys(component.props.params).length === 0 && component.props.onChange) { component.props.onChange(_extends({}, params)); } }; } var ArticleSizeRule = function (_React$Component) { _inherits(ArticleSizeRule, _React$Component); function ArticleSizeRule(props) { _classCallCheck(this, ArticleSizeRule); var _this = _possibleConstructorReturn(this, (ArticleSizeRule.__proto__ || Object.getPrototypeOf(ArticleSizeRule)).call(this, props)); setDefaultParams(_this, { bytes: { atLeast: '' } }); return _this; } _createClass(ArticleSizeRule, [{ key: 'add', value: function add(type) { var params = _extends({}, this.props.params); params[type] = { atLeast: '' }; this.props.onChange(params); } }, { key: 'changeType', value: function changeType(oldType, newType) { var params = this.props.params; var newParams = {}; for (var type in params) { newParams[type === oldType ? newType : type] = params[type]; } this.props.onChange(newParams); } }, { key: 'changeOp', value: function changeOp(type, op) { var params = _extends({}, this.props.params); var param = params[type]; var value = Object.values(param)[0]; params[type] = _defineProperty({}, op, value); this.props.onChange(params); } }, { key: 'changeValue', value: function changeValue(type, value) { var params = _extends({}, this.props.params); var param = params[type]; var op = Object.keys(param)[0]; params[type] = _defineProperty({}, op, value); this.props.onChange(params); } }, { key: 'remove', value: function remove(type) { var params = _extends({}, this.props.params); delete params[type]; this.props.onChange(params); } }, { key: 'renderParam', value: function renderParam(params, type) { var _this2 = this; var tr = this.props.translation.tr; var param = params[type]; var op = Object.keys(param)[0]; return _react2.default.createElement( 'div', { className: 'item', key: type }, _react2.default.createElement(_DropDown2.default, { items: ['atLeast' /* , 'atMost' */], renderItem: function renderItem(i) { return tr(i); }, value: op, getValue: function getValue(x) { return x; }, onChange: function onChange(o) { return _this2.changeOp(type, o); } }), _react2.default.createElement('input', { className: 'value', value: param[op], onChange: function onChange(e) { return _this2.changeValue(type, e.target.value); } }), _react2.default.createElement(_DropDown2.default, { items: ['bytes', 'words', 'chars'], renderItem: function renderItem(i) { return tr(i); }, value: type, getValue: function getValue(x) { return x; }, onChange: function onChange(t) { return _this2.changeType(type, t); } }), Object.keys(params).length > 1 && _react2.default.createElement(_WikiButton2.default, { className: 'delete', onClick: function onClick() { return _this2.remove(type); } }) ); } }, { key: 'render', value: function render() { var _this3 = this; var params = this.props.params; var tr = this.props.translation.tr; var available = ['bytes', 'chars', 'words'].filter(function (t) { return Object.keys(params).indexOf(t) === -1; }); return _react2.default.createElement( 'div', { className: 'ArticleSizeRule' }, Object.keys(params).map(function (type, i) { return [i === 0 ? null : _react2.default.createElement( 'span', { className: 'or' }, tr('or') ), _this3.renderParam(params, type)]; }), available.length > 0 && _react2.default.createElement( _DropDownButton2.default, { className: 'add', items: available, renderItem: function renderItem(t) { return tr(t); }, onClick: function onClick(t) { return _this3.add(t); } }, tr('add') ) ); } }]); return ArticleSizeRule; }(_react2.default.Component); ArticleSizeRule = (0, _translate.withTranslation)(ArticleSizeRule, 'EditathonConfig.RulesPage.articleSize'); function createSimple(defaultParams) { return function (_React$Component2) { _inherits(SimpleRule, _React$Component2); function SimpleRule(props) { _classCallCheck(this, SimpleRule); var _this4 = _possibleConstructorReturn(this, (SimpleRule.__proto__ || Object.getPrototypeOf(SimpleRule)).call(this, props)); defaultParams && setDefaultParams(_this4, defaultParams); return _this4; } _createClass(SimpleRule, [{ key: 'render', value: function render() { var tr = this.props.translation.tr; return _react2.default.createElement( 'div', { className: 'SimpleRule' }, tr('description') ); } }]); return SimpleRule; }(_react2.default.Component); } var SubmitterIsCreatorRule = (0, _translate.withTranslation)(createSimple(), 'EditathonConfig.RulesPage.submitterIsCreator'); var NamespaceRule = (0, _translate.withTranslation)(createSimple({ isIn: [0] }), 'EditathonConfig.RulesPage.namespace'); var ArticleCreatedRule = function (_React$Component3) { _inherits(ArticleCreatedRule, _React$Component3); function ArticleCreatedRule() { _classCallCheck(this, ArticleCreatedRule); return _possibleConstructorReturn(this, (ArticleCreatedRule.__proto__ || Object.getPrototypeOf(ArticleCreatedRule)).apply(this, arguments)); } _createClass(ArticleCreatedRule, [{ key: 'update', value: function update(prop, value) { var params = _extends({}, this.props.params); if (value) { params[prop] = value; } else { delete params[prop]; } this.props.onChange(params); } }, { key: 'render', value: function render() { var _this6 = this; var _props$params = this.props.params, before = _props$params.before, after = _props$params.after; var tr = this.props.translation.tr; return _react2.default.createElement( 'div', { className: 'ArticleCreatedRule' }, _react2.default.createElement( 'div', { className: 'item' }, _react2.default.createElement( 'label', { htmlFor: 'notBefore' }, tr('notBefore') ), _react2.default.createElement(_DateTimePicker2.default, { id: 'notBefore', value: after, allowEmpty: true, onChange: function onChange(v) { return _this6.update('after', v); } }) ), _react2.default.createElement( 'div', { className: 'item' }, _react2.default.createElement( 'label', { htmlFor: 'notAfter' }, tr('notAfter') ), _react2.default.createElement(_DateTimePicker2.default, { id: 'notAfter', value: before, allowEmpty: true, onChange: function onChange(v) { return _this6.update('before', v); } }) ) ); } }]); return ArticleCreatedRule; }(_react2.default.Component); function getArticleCreatedRuleDefauls(editathon) { return { after: editathon.start, before: editathon.finish }; } ArticleCreatedRule = (0, _translate.withTranslation)(ArticleCreatedRule, 'EditathonConfig.RulesPage.articleCreated'); var SubmitterRegisteredRule = function (_React$Component4) { _inherits(SubmitterRegisteredRule, _React$Component4); function SubmitterRegisteredRule() { _classCallCheck(this, SubmitterRegisteredRule); return _possibleConstructorReturn(this, (SubmitterRegisteredRule.__proto__ || Object.getPrototypeOf(SubmitterRegisteredRule)).apply(this, arguments)); } _createClass(SubmitterRegisteredRule, [{ key: 'changeNotBefore', value: function changeNotBefore(value) { var params = _extends({}, this.props.params); if (value) { params.after = value; } else { delete params.after; } this.props.onChange(params); } }, { key: 'render', value: function render() { var _this8 = this; var after = this.props.params.after; var tr = this.props.translation.tr; return _react2.default.createElement( 'div', { className: 'SubmitterRegisteredRule' }, _react2.default.createElement( 'div', { className: 'item' }, _react2.default.createElement( 'label', { htmlFor: 'notBefore' }, tr('notBefore') ), _react2.default.createElement(_DateTimePicker2.default, { id: 'notBefore', value: after, allowEmpty: true, onChange: function onChange(v) { return _this8.changeNotBefore(v); } }) ) ); } }]); return SubmitterRegisteredRule; }(_react2.default.Component); SubmitterRegisteredRule = (0, _translate.withTranslation)(SubmitterRegisteredRule, 'EditathonConfig.RulesPage.submitterRegistered'); function editor(component) { var extras = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; return _extends({ component: component }, extras); } var Editors = { namespace: editor(NamespaceRule, { noJury: true }), articleSize: editor(ArticleSizeRule, { allowMulti: true }), articleCreated: editor(ArticleCreatedRule, { getDefaults: getArticleCreatedRuleDefauls }), submitterIsCreator: editor(SubmitterIsCreatorRule), submitterRegistered: editor(SubmitterRegisteredRule, { noJury: true }) }; var RulesDemo = function (_React$Component5) { _inherits(RulesDemo, _React$Component5); function RulesDemo(props) { _classCallCheck(this, RulesDemo); var _this9 = _possibleConstructorReturn(this, (RulesDemo.__proto__ || Object.getPrototypeOf(RulesDemo)).call(this, props)); _this9.state = { title: '', titleText: '', user: Global.user.name, userText: Global.user.name, stats: null, ctx: null, updating: false }; return _this9; } _createClass(RulesDemo, [{ key: 'componentWillReceiveProps', value: function componentWillReceiveProps(_ref) { var rules = _ref.rules; var title = this.state.title; if (!title) return; this.update(title, rules); } }, { key: 'getReqs', value: function getReqs(rules) { return (0, _rules.getRulesReqs)((0, _rules2.default)(rules)); } }, { key: 'update', value: function () { var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(title, rules) { var newReqs, oldReqs, stats; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: // check if update is required newReqs = this.getReqs(rules); if (!(this.state.stats && title.trim() === this.state.title.trim())) { _context.next = 5; break; } oldReqs = this.getReqs(this.props.rules); if (!newReqs.every(function (r) { return oldReqs.indexOf(r) !== -1; })) { _context.next = 5; break; } return _context.abrupt('return'); case 5: // update stats = void 0; this.setState({ updating: true, stats: null, title: title }); _context.prev = 7; this._title = title; _context.next = 11; return (0, _getArticleData2.default)(this.props.wiki, title, ['title'].concat(_toConsumableArray(newReqs))); case 11: stats = _context.sent; if (!(this._title !== title)) { _context.next = 14; break; } return _context.abrupt('return'); case 14: _context.next = 20; break; case 16: _context.prev = 16; _context.t0 = _context['catch'](7); console.log('error retrieving article info', _context.t0); stats = null; case 20: this.setState({ updating: false, stats: stats }); case 21: case 'end': return _context.stop(); } } }, _callee, this, [[7, 16]]); })); function update(_x2, _x3) { return _ref2.apply(this, arguments); } return update; }() }, { key: 'updateCtx', value: function () { var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(user) { var ctx, mwApi, regDate; return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: if (!(this.state.ctx && user.trim() === this.state.user.trim())) { _context2.next = 2; break; } return _context2.abrupt('return'); case 2: ctx = void 0; this.setState({ updatingCtx: true, ctx: null, user: user }); _context2.prev = 4; mwApi = (0, _MwApi.getMwApi)(this.props.wiki); this._user = user; _context2.next = 9; return mwApi.getUserRegDate(user); case 9: regDate = _context2.sent; ctx = { user: { name: user, registered: regDate } }; if (!(this._user !== user)) { _context2.next = 13; break; } return _context2.abrupt('return'); case 13: _context2.next = 19; break; case 15: _context2.prev = 15; _context2.t0 = _context2['catch'](4); console.log('error retrieving ctx info', _context2.t0); ctx = null; case 19: this.setState({ updatingCtx: false, ctx: ctx }); case 20: case 'end': return _context2.stop(); } } }, _callee2, this, [[4, 15]]); })); function updateCtx(_x4) { return _ref3.apply(this, arguments); } return updateCtx; }() }, { key: 'refresh', value: function refresh() { var _state = this.state, titleText = _state.titleText, userText = _state.userText; if (!titleText) { this.setState({ title: '' }); return; } else if (!userText) { this.setState({ user: '' }); return; } var rules = this.props.rules; this.update(titleText, rules); this.updateCtx(userText); } }, { key: 'render', value: function render() { var _this10 = this; var _props = this.props, wiki = _props.wiki, tr = _props.translation.tr; var _state2 = this.state, userText = _state2.userText, titleText = _state2.titleText, title = _state2.title, user = _state2.user, updating = _state2.updating, updatingCtx = _state2.updatingCtx, stats = _state2.stats, ctx = _state2.ctx; var rules = (0, _rules2.default)(this.props.rules); var inner = null; if (title && user) { if (updating || updatingCtx) { inner = _react2.default.createElement(_Loader2.default, null); } else { var realTitle = stats ? stats.title : title; inner = _react2.default.createElement( 'div', null, _react2.default.createElement( 'header', null, tr('forUser') ), _react2.default.createElement(_WikiLink2.default, { to: realTitle, wiki: wiki, red: !stats }), stats && ctx && _react2.default.createElement(_Warnings4.default, { ctx: ctx, rules: rules, stats: stats, title: title, wiki: wiki }), stats && ctx && _react2.default.createElement( 'header', null, tr('forJury') ), stats && ctx && _react2.default.createElement( 'div', { className: 'Jury' }, _react2.default.createElement(_Warnings2.default, { info: stats, rules: rules.filter(function (r) { return r.flags & _rules.RuleFlags.informational; }), article: { user: ctx.user.name, name: realTitle }, wiki: wiki }) ) ).props.children; } } return _react2.default.createElement( 'form', { className: 'RulesDemo', onSubmit: function onSubmit(e) { return e.preventDefault(); } }, _react2.default.createElement( 'header', null, tr('preview') ), _react2.default.createElement( 'table', { className: 'lookup' }, _react2.default.createElement( 'tbody', null, _react2.default.createElement( 'tr', null, _react2.default.createElement( 'td', null, _react2.default.createElement( 'label', { htmlFor: 'title' }, tr('user') ) ), _react2.default.createElement( 'td', null, _react2.default.createElement(_UserLookup2.default, { inputProps: { id: 'title' }, wiki: wiki, value: userText, onChange: function onChange(userText) { return _this10.setState({ userText: userText }); } }) ) ), _react2.default.createElement( 'tr', null, _react2.default.createElement( 'td', null, _react2.default.createElement( 'label', { htmlFor: 'title' }, tr('article') ) ), _react2.default.createElement( 'td', null, _react2.default.createElement(_PageLookup2.default, { inputProps: { id: 'title' }, wiki: wiki, value: titleText, onChange: function onChange(titleText) { return _this10.setState({ titleText: titleText }); } }) ) ) ) ), _react2.default.createElement( _WikiButton2.default, { className: 'show', submit: true, onClick: function onClick() { return _this10.refresh(); } }, tr('show') ), inner ); } }]); return RulesDemo; }(_react2.default.Component); RulesDemo = (0, _translate.withTranslation)(RulesDemo, 'EditathonConfig.RulesPage.RulesDemo'); function getDefaultData() { return [{ type: 'namespace', params: {}, flags: 0 }]; } var RulesPage = function (_React$Component6) { _inherits(RulesPage, _React$Component6); function RulesPage() { _classCallCheck(this, RulesPage); return _possibleConstructorReturn(this, (RulesPage.__proto__ || Object.getPrototypeOf(RulesPage)).apply(this, arguments)); } _createClass(RulesPage, [{ key: 'componentWillMount', value: function componentWillMount() { (0, _utils.setDefault)(this.props, 'rules', getDefaultData); } }, { key: 'addRule', value: function addRule(type) { var _props2 = this.props, value = _props2.value, onChange = _props2.onChange; var rules = [].concat(_toConsumableArray(value.rules)); var getDefaults = Editors[type].getDefaults; rules.push({ type: type, params: getDefaults && getDefaults(value) || {}, flags: Editors[type].noJury ? 0 : _rules.RuleFlags.informational }); value.rules = rules; onChange(value); } }, { key: 'deleteRule', value: function deleteRule(rule) { this.replaceRule(rule); } }, { key: 'changeFlag', value: function changeFlag(rule, flag, value) { var flags = value ? rule.flags | flag : rule.flags & ~flag; this.replaceRule(rule, _extends({}, rule, { flags: flags })); } }, { key: 'onParamsChanged', value: function onParamsChanged(rule, params) { this.replaceRule(rule, _extends({}, rule, { params: params })); } }, { key: 'replaceRule', value: function replaceRule(rule, newRule) { var _props3 = this.props, value = _props3.value, onChange = _props3.onChange; var rules = [].concat(_toConsumableArray(value.rules)); var index = rules.indexOf(rule); if (index !== -1) { if (newRule === undefined) { rules.splice(index, 1); } else { rules.splice(index, 1, newRule); } } value.rules = rules; onChange(value); } }, { key: 'render', value: function render() { var _this12 = this; var tr = this.props.translation.tr; var _props$value$rules = this.props.value.rules, rules = _props$value$rules === undefined ? [] : _props$value$rules; var available = Object.keys(Editors).filter(function (t) { return Editors[t].allowMulti || rules.every(function (r) { return r.type !== t; }); }); return _react2.default.createElement( 'div', { className: 'page RulesPage' }, rules.filter(function (r) { return Editors[r.type]; }).map(function (r, i) { return _react2.default.createElement( 'div', { className: 'rule', key: i }, _react2.default.createElement( 'header', null, _react2.default.createElement( 'span', null, tr(r.type + '.title') ), _react2.default.createElement( 'label', null, _react2.default.createElement('input', { type: 'checkbox', checked: r.flags & _rules.RuleFlags.optional, onChange: function onChange(e) { return _this12.changeFlag(r, _rules.RuleFlags.optional, e.target.checked); } }), tr('optional') ), !Editors[r.type].noJury && _react2.default.createElement( 'label', null, _react2.default.createElement('input', { type: 'checkbox', checked: r.flags & _rules.RuleFlags.informational, onChange: function onChange(e) { return _this12.changeFlag(r, _rules.RuleFlags.informational, e.target.checked); } }), tr('informational') ), _react2.default.createElement(_WikiButton2.default, { className: 'delete', onClick: function onClick() { return _this12.deleteRule(r); } }) ), _react2.default.createElement(Editors[r.type].component, { params: r.params, onChange: function onChange(params) { return _this12.onParamsChanged(r, params); } }) ); }), _react2.default.createElement( _DropDownButton2.default, { className: 'add', items: available, renderItem: function renderItem(t) { return tr(t + '.title'); }, onClick: function onClick(t) { return _this12.addRule(t); } }, tr('add') ), _react2.default.createElement(RulesDemo, { wiki: this.props.value.wiki, rules: rules }) ); } }]); return RulesPage; }(_react2.default.Component); exports.default = (0, _translate.withTranslation)(RulesPage, 'EditathonConfig.RulesPage'); },{"../../MwApi":61,"../../getArticleData":64,"../../rules":69,"../../translate":73,"../DateTimePicker":9,"../DropDown":10,"../DropDownButton":11,"../Jury/Warnings":33,"../Loader":36,"../PageLookup":43,"../UserLookup":54,"../Warnings":55,"../WikiButton":56,"../WikiLink":57,"../utils":59,"react":"react"}],19:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _validation = require('./validation'); var _utils = require('../utils'); var _PageLookup = require('../PageLookup'); var _PageLookup2 = _interopRequireDefault(_PageLookup); var _WikiButton = require('../WikiButton'); var _WikiButton2 = _interopRequireDefault(_WikiButton); var _translate = require('../../translate'); var _TemplatePreview = require('../TemplatePreview'); var _TemplatePreview2 = _interopRequireDefault(_TemplatePreview); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var TemplatePage = function (_React$Component) { _inherits(TemplatePage, _React$Component); function TemplatePage(props) { _classCallCheck(this, TemplatePage); var _this = _possibleConstructorReturn(this, (TemplatePage.__proto__ || Object.getPrototypeOf(TemplatePage)).call(this, props)); _this.set = (0, _utils.createSetter)(); _this.template = (0, _utils.createSubSection)(_this, 'template'); return _this; } _createClass(TemplatePage, [{ key: 'addArg', value: function addArg() { var _template$props = this.template.props, value = _template$props.value, onChange = _template$props.onChange; value.args.push({}); onChange(_extends({}, value)); } }, { key: 'deleteArg', value: function deleteArg(arg) { var _template$props2 = this.template.props, value = _template$props2.value, onChange = _template$props2.onChange; var index = value.args.indexOf(arg); if (index !== -1) { value.args.splice(index, 1); } onChange(_extends({}, value)); } }, { key: 'onEnable', value: function onEnable(enabled) { if (enabled) { this.set('template', this._value || { name: '', talkPage: true, args: [] }); } else { this._value = _extends({}, this.props.value.template); this.set('template', null); } } }, { key: 'render', value: function render() { var _this2 = this; var _props = this.props, tr = _props.translation.tr, template = _props.value.template; var enabled = !!template; return _react2.default.createElement( 'div', { className: 'page TemplatePage' }, _react2.default.createElement( 'label', { id: 'add' }, _react2.default.createElement('input', { type: 'checkbox', checked: enabled, onChange: function onChange(e) { return _this2.onEnable(e.target.checked); } }), _react2.default.createElement( 'span', null, tr('autoAdd') ) ), enabled && this.renderRest() ); } }, { key: 'renderArg', value: function renderArg(arg, id) { var _this3 = this; var _onChange = function onChange(e, p) { var _template$props3 = _this3.template.props, value = _template$props3.value, onChange = _template$props3.onChange; var val = e.target.value; arg[p] = val ? val : null; onChange(_extends({}, value)); }; return _react2.default.createElement( 'div', { className: 'arg', key: id }, _react2.default.createElement('input', { id: id + '-name', value: arg.name || '', onChange: function onChange(e) { return _onChange(e, 'name'); } }), _react2.default.createElement( 'span', null, '=' ), _react2.default.createElement( _validation.Validation, { isEmpty: function isEmpty() { return !arg.value; } }, _react2.default.createElement('input', { id: id + '-value', value: arg.value || '', onChange: function onChange(e) { return _onChange(e, 'value'); } }) ), _react2.default.createElement(_WikiButton2.default, { className: 'delete', onClick: function onClick() { return _this3.deleteArg(arg); } }) ); } }, { key: 'renderRest', value: function renderRest() { var _this4 = this; var _props2 = this.props, tr = _props2.translation.tr, _props2$value = _props2.value, _props2$value$templat = _props2$value.template, name = _props2$value$templat.name, args = _props2$value$templat.args, wiki = _props2$value.wiki; return _react2.default.createElement( 'div', null, _react2.default.createElement( 'div', { className: 'field', id: 'template' }, _react2.default.createElement( 'label', { htmlFor: 'name' }, tr('name') ), _react2.default.createElement( _validation.Validation, { isEmpty: function isEmpty() { return !name; } }, this.template.bind('name', _react2.default.createElement(_PageLookup2.default, { inputProps: { id: 'name' }, ns: 10, wiki: wiki })) ) ), _react2.default.createElement( 'div', { id: 'placement', className: 'field' }, _react2.default.createElement( 'header', null, tr('placement') ), _react2.default.createElement( 'label', null, this.template.bind('talkPage', _react2.default.createElement('input', { type: 'radio', name: 'talkPage', value: false })), _react2.default.createElement( 'span', null, tr('inArticle') ) ), _react2.default.createElement( 'label', null, this.template.bind('talkPage', _react2.default.createElement('input', { type: 'radio', name: 'talkPage', value: true })), _react2.default.createElement( 'span', null, tr('onTalkPage') ) ) ), _react2.default.createElement( 'div', { id: 'args' }, _react2.default.createElement( 'header', null, tr('args') ), _react2.default.createElement( 'div', { className: 'args' }, args.map(function (arg, id) { return _this4.renderArg(arg, id); }) ), _react2.default.createElement( _WikiButton2.default, { onClick: function onClick() { return _this4.addArg(); } }, tr('add') ) ), _react2.default.createElement( 'div', { id: 'preview' }, _react2.default.createElement( 'header', null, tr('preview') ), _react2.default.createElement(_TemplatePreview2.default, { name: name, args: args, labelFor: function labelFor(id, isName) { return id === null ? 'name' : id + '-' + (isName ? 'name' : 'value'); } }) ) ).props.children; } }]); return TemplatePage; }(_react2.default.Component); exports.default = (0, _translate.withTranslation)(TemplatePage, 'EditathonConfig.TemplatePage'); },{"../../translate":73,"../PageLookup":43,"../TemplatePreview":52,"../WikiButton":56,"../utils":59,"./validation":20,"react":"react"}],20:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.Validation = exports.ValidationForm = undefined; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _Tooltip = require('../Tooltip'); var _Tooltip2 = _interopRequireDefault(_Tooltip); var _translate = require('../../translate'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var ValidationForm = exports.ValidationForm = function (_React$Component) { _inherits(ValidationForm, _React$Component); _createClass(ValidationForm, null, [{ key: 'childContextTypes', get: function get() { return { 'ValidationContext': _react2.default.PropTypes.object }; } }, { key: 'propTypes', get: function get() { return { className: _react2.default.PropTypes.string }; } }]); function ValidationForm(props) { _classCallCheck(this, ValidationForm); var _this = _possibleConstructorReturn(this, (ValidationForm.__proto__ || Object.getPrototypeOf(ValidationForm)).call(this, props)); _this._validations = new Set(); return _this; } _createClass(ValidationForm, [{ key: 'validate', value: function () { var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { var valid, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, v, result; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: valid = true; _iteratorNormalCompletion = true; _didIteratorError = false; _iteratorError = undefined; _context.prev = 4; _iterator = this._validations[Symbol.iterator](); case 6: if (_iteratorNormalCompletion = (_step = _iterator.next()).done) { _context.next = 15; break; } v = _step.value; _context.next = 10; return v.validate(true); case 10: result = _context.sent; valid = valid && result; case 12: _iteratorNormalCompletion = true; _context.next = 6; break; case 15: _context.next = 21; break; case 17: _context.prev = 17; _context.t0 = _context['catch'](4); _didIteratorError = true; _iteratorError = _context.t0; case 21: _context.prev = 21; _context.prev = 22; if (!_iteratorNormalCompletion && _iterator.return) { _iterator.return(); } case 24: _context.prev = 24; if (!_didIteratorError) { _context.next = 27; break; } throw _iteratorError; case 27: return _context.finish(24); case 28: return _context.finish(21); case 29: return _context.abrupt('return', valid); case 30: case 'end': return _context.stop(); } } }, _callee, this, [[4, 17, 21, 29], [22,, 24, 28]]); })); function validate() { return _ref.apply(this, arguments); } return validate; }() }, { key: 'add', value: function add(validation) { this._validations.add(validation); } }, { key: 'remove', value: function remove(validation) { this._validations.delete(validation); } }, { key: 'getChildContext', value: function getChildContext() { return { 'ValidationContext': { add: this.add.bind(this), remove: this.remove.bind(this) } }; } }, { key: 'render', value: function render() { return _react2.default.createElement( 'div', { className: (0, _classnames2.default)('ValidationForm', this.props.className) }, this.props.children ); } }]); return ValidationForm; }(_react2.default.Component); var Validation = function (_React$Component2) { _inherits(Validation, _React$Component2); _createClass(Validation, null, [{ key: 'contextTypes', get: function get() { return { 'ValidationContext': _react2.default.PropTypes.object }; } }, { key: 'propTypes', get: function get() { return { isEmpty: _react2.default.PropTypes.func, validate: _react2.default.PropTypes.func }; } }]); function Validation(props) { _classCallCheck(this, Validation); var _this2 = _possibleConstructorReturn(this, (Validation.__proto__ || Object.getPrototypeOf(Validation)).call(this, props)); _this2.state = { message: null }; _this2._isEmpty = false; return _this2; } _createClass(Validation, [{ key: 'componentDidMount', value: function componentDidMount() { this.context.ValidationContext.add(this); } }, { key: 'componentWillUnmount', value: function componentWillUnmount() { this.context.ValidationContext.remove(this); } }, { key: 'validate', value: function () { var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(checkEmpty) { var message, props, isEmpty; return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: message = null; props = this.props; isEmpty = !props.isEmpty || props.isEmpty(); if ((checkEmpty || this._isEmpty) && isEmpty) { message = this.props.translation.tr('required'); this._isEmpty = true; } else { this._isEmpty = false; } if (isEmpty) { _context2.next = 11; break; } _context2.t0 = props.validate; if (!_context2.t0) { _context2.next = 10; break; } _context2.next = 9; return props.validate(); case 9: _context2.t0 = _context2.sent; case 10: message = _context2.t0; case 11: this.setState({ message: message }); return _context2.abrupt('return', !message); case 13: case 'end': return _context2.stop(); } } }, _callee2, this); })); function validate(_x) { return _ref2.apply(this, arguments); } return validate; }() }, { key: 'render', value: function render() { var _this3 = this; var message = this.state.message; return _react2.default.createElement( 'div', { className: (0, _classnames2.default)('Validation', message && 'invalid'), onBlur: function onBlur() { _this3.validate(false); } }, this.props.children, message && _react2.default.createElement( _Tooltip2.default, null, message ) ); } }]); return Validation; }(_react2.default.Component); exports.Validation = Validation = (0, _translate.withTranslation)(Validation, 'Validation'); exports.Validation = Validation; },{"../../translate":73,"../Tooltip":53,"classnames":"classnames","react":"react"}],21:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); exports.renderEditathonDates = renderEditathonDates; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _moment = require('moment'); var _moment2 = _interopRequireDefault(_moment); var _Link = require('./Link'); var _Link2 = _interopRequireDefault(_Link); var _Loader = require('./Loader'); var _Loader2 = _interopRequireDefault(_Loader); var _RequiresLogin = require('./RequiresLogin'); var _RequiresLogin2 = _interopRequireDefault(_RequiresLogin); var _DropDown = require('./DropDown'); var _DropDown2 = _interopRequireDefault(_DropDown); var _EditathonCalendar = require('./EditathonCalendar'); var _EditathonCalendar2 = _interopRequireDefault(_EditathonCalendar); var _WikiButton = require('./WikiButton'); var _WikiButton2 = _interopRequireDefault(_WikiButton); var _utils = require('./utils'); var _utils2 = require('./../utils'); var _Api = require('./../Api'); var _Api2 = _interopRequireDefault(_Api); var _MwApi = require('./../MwApi'); var _translate = require('../translate'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var ProjectTypes = { 'Wikipedia': '', 'Wikiquote': 'q', 'Wikisource': 's', 'Wikibooks': 'b', 'Wikinews': 'n', 'Wikiversity': 'v', 'Wikivoyage': 'voy', 'Wiktionary': 'wikt' }; var EditathonFilter = function (_React$PureComponent) { _inherits(EditathonFilter, _React$PureComponent); function EditathonFilter(props) { _classCallCheck(this, EditathonFilter); var _this = _possibleConstructorReturn(this, (EditathonFilter.__proto__ || Object.getPrototypeOf(EditathonFilter)).call(this, props)); _this.state = { matrix: [] }; _this.bind = (0, _utils.createBinder)(); _this.setLang = (0, _utils.createSetter)().bind(_this, 'lang'); return _this; } _createClass(EditathonFilter, [{ key: 'componentWillMount', value: function () { var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { var _this2 = this; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: (0, _utils.setDefault)(this.props, function () { return { type: null, lang: _this2.getDefaultLang() }; }); _context.t0 = this; _context.next = 4; return (0, _MwApi.getSiteMatrix)(); case 4: _context.t1 = _context.sent; _context.t2 = { matrix: _context.t1 }; _context.t0.setState.call(_context.t0, _context.t2); case 7: case 'end': return _context.stop(); } } }, _callee, this); })); function componentWillMount() { return _ref.apply(this, arguments); } return componentWillMount; }() }, { key: 'renderButton', value: function renderButton(placeholder, value, text) { if (value === null) { return _react2.default.createElement( _WikiButton2.default, null, _react2.default.createElement( 'button', null, _react2.default.createElement( 'span', { className: 'placeholder' }, placeholder ) ) ); } else { return _react2.default.createElement( _WikiButton2.default, null, text ); } } }, { key: 'renderLangButton', value: function renderLangButton(placeholder) { var lang = this.props.value.lang; var name = this.state.matrix.filter(function (m) { return m.code === lang; }).map(function (m) { return m.name; })[0]; return this.renderButton(placeholder, lang, this.renderLang(lang, name)); } }, { key: 'renderLang', value: function renderLang(code, name) { if (name === undefined) { return code; } else if (code === null) { return name; } else { return code + ': ' + name; } } }, { key: 'matchItem', value: function matchItem(item, value) { if (value === null) { return item.code === null; } value = value.toLowerCase(); return (item.code || '').startsWith(value) || (item.name || '').toLowerCase().startsWith(value); } }, { key: 'getDefaultLang', value: function getDefaultLang() { var lang = localStorage.getItem('fountainFilterLang'); if (lang === 'null') { return null; } return lang || (0, _utils2.getNavitagorLang)(); } }, { key: 'onLangChanged', value: function onLangChanged(lang) { this.setLang(lang); localStorage.setItem('fountainFilterLang', lang); } }, { key: 'render', value: function render() { var _this3 = this; var tr = this.props.translation.tr; return _react2.default.createElement( 'div', { className: 'EditathonFilter' }, this.bind('text', _react2.default.createElement('input', { type: 'text', placeholder: tr('search') })), this.bind('type', _react2.default.createElement(_DropDown2.default, { items: [{ name: tr('all'), value: null }].concat(_toConsumableArray(Object.keys(ProjectTypes).map(function (x) { return { name: x, value: ProjectTypes[x] }; }))), getValue: function getValue(x) { return x.value; }, renderItem: function renderItem(x) { return x.name; }, renderButton: this.renderButton.bind(this, tr('project')) })), _react2.default.createElement(_DropDown2.default, { showInput: true, filter: true, matchItem: function matchItem(item, value) { return _this3.matchItem(item, value); }, items: [{ code: null, name: tr('all') }].concat(_toConsumableArray(this.state.matrix)), getValue: function getValue(x) { return x.code; }, renderButton: function renderButton() { return _this3.renderLangButton(tr('language')); }, renderItem: function renderItem(x) { return _this3.renderLang(x.code, x.name); }, onChange: function onChange(lg) { return _this3.onLangChanged(lg); } }) ); } }]); return EditathonFilter; }(_react2.default.PureComponent); EditathonFilter = (0, _translate.withTranslation)(EditathonFilter, 'EditathonFilter'); var EditathonList = _react2.default.createClass({ displayName: 'EditathonList', getInitialState: function getInitialState() { return { loading: true }; }, componentWillMount: function componentWillMount() { var _this4 = this; return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _context2.t0 = _this4; _context2.next = 3; return _Api2.default.getEditathons(); case 3: _context2.t1 = _context2.sent; _context2.t2 = { list: _context2.t1, loading: false }; _context2.t0.setState.call(_context2.t0, _context2.t2); case 6: case 'end': return _context2.stop(); } } }, _callee2, _this4); }))(); }, filter: function filter(e) { var _$exec = /^(?:(.+):)?(.+)$/.exec(e.wiki), _$exec2 = _slicedToArray(_$exec, 3), type = _$exec2[1], lang = _$exec2[2]; var _state$filter = this.state.filter, filter = _state$filter === undefined ? {} : _state$filter; return (filter.type ? filter.type === type : true) && (filter.lang ? filter.lang === lang : true) && (filter.text ? (0, _utils2.checkTokenMatch)(filter.text, e.name) : true); }, render: function render() { var _this5 = this; var tr = this.props.translation.tr; var _state = this.state, _state$filter2 = _state.filter, filter = _state$filter2 === undefined ? {} : _state$filter2, list = _state.list, loading = _state.loading; var editathons = list && list.filter(function (e) { return _this5.filter(e); }) || []; if (loading) { return _react2.default.createElement(_Loader2.default, null); } return _react2.default.createElement( 'div', { className: 'EditathonList mainContentPane' }, _react2.default.createElement( 'h1', null, tr('title') ), _react2.default.createElement(EditathonFilter, { value: filter, onChange: function onChange(filter) { return _this5.setState({ filter: filter }); } }), filter.lang && _react2.default.createElement(_EditathonCalendar2.default, { editathons: editathons }), _react2.default.createElement( _RequiresLogin2.default, { className: 'create', redirectTo: '/editathons/new/config' }, _react2.default.createElement( _WikiButton2.default, { type: 'progressive' }, _react2.default.createElement( _Link2.default, { to: '/editathons/new/config' }, tr('create') ) ) ), _react2.default.createElement( 'ul', null, editathons.filter(function (item) { return !isPast(item); }).map(this.renderItem) ), _react2.default.createElement( 'h2', null, tr('finished') ), _react2.default.createElement( 'ul', { className: 'past' }, editathons.filter(isPast).map(this.renderItem) ) ); }, renderItem: function renderItem(item) { var today = (0, _moment2.default)().utc(); var isCurrent = (0, _moment2.default)(item.start).isBefore(today) && (0, _moment2.default)(item.finish).isAfter(today); var url = '/editathons/' + encodeURIComponent(item.code); return _react2.default.createElement( 'li', { key: item.code, title: item.description }, _react2.default.createElement( _Link2.default, { to: { pathname: url, state: { editathon: item } } }, _react2.default.createElement( 'div', { className: 'summary' }, _react2.default.createElement( 'div', { className: 'name' }, item.name ), _react2.default.createElement( 'div', { className: 'dates' }, renderEditathonDates(item.start, item.finish, this.props.translation.translate) ) ), isCurrent && _react2.default.createElement( 'div', { className: 'description' }, item.description ) ) ); } }); function renderEditathonDates(start, finish, translate) { start = _moment2.default.utc(start); finish = _moment2.default.utc(finish); var format = 'MMM'; var startFormat = format; if (start.date() !== 1 || _moment2.default.utc(finish).endOf('month').date() !== finish.date()) startFormat = format = 'D ' + format;else if (start.isSame(finish, 'month')) startFormat = ''; format = format + ' YYYY'; if (start.year() !== finish.year()) startFormat = format; if (!startFormat) return translate('formatDate', finish, format); return translate('formatDate', start, startFormat) + ' \u2014 ' + translate('formatDate', finish, format); } function isPast(editathon) { return (0, _moment2.default)(editathon.finish).isBefore((0, _moment2.default)().utc()); } exports.default = (0, _translate.withTranslation)(EditathonList, 'EditathonList'); },{"../translate":73,"./../Api":4,"./../MwApi":61,"./../utils":97,"./DropDown":10,"./EditathonCalendar":13,"./Link":35,"./Loader":36,"./RequiresLogin":50,"./WikiButton":56,"./utils":59,"moment":"moment","react":"react"}],22:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _Api = require('./../Api'); var _Api2 = _interopRequireDefault(_Api); var _Loader = require('./Loader'); var _Loader2 = _interopRequireDefault(_Loader); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } exports.default = _react2.default.createClass({ displayName: 'EditathonPage', getInitialState: function getInitialState() { return {}; }, getCode: function getCode() { return this.props.params.id; }, componentWillMount: function componentWillMount() { var _this = this; return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { var loc, ed; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: loc = _this.props.location.state; ed = loc && loc.editathon || null; _this.setState({ editathon: ed }); if (!(!ed || !ed.articles)) { _context.next = 6; break; } _context.next = 6; return _this.reload(); case 6: case 'end': return _context.stop(); } } }, _callee, _this); }))(); }, reload: function reload() { var _this2 = this; return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _context2.t0 = _this2; _context2.next = 3; return _Api2.default.getEditathon(_this2.getCode()); case 3: _context2.t1 = _context2.sent; _context2.t2 = { editathon: _context2.t1 }; _context2.t0.setState.call(_context2.t0, _context2.t2); case 6: case 'end': return _context2.stop(); } } }, _callee2, _this2); }))(); }, render: function render() { if (!this.state.editathon) return _react2.default.createElement( 'div', { className: 'EditathonPage' }, _react2.default.createElement(_Loader2.default, null) ); return _react2.default.createElement( 'div', { className: 'EditathonPage mainContentPane' }, _react2.default.createElement( 'h1', null, this.state.editathon.name ), _react2.default.cloneElement(this.props.children, { editathon: this.state.editathon, onReloadEditathon: this.reload }) ); } }); },{"./../Api":4,"./Loader":36,"react":"react"}],23:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _translate = require('./../translate'); var _utils = require('./../utils'); var _SendReportButton = require('./SendReportButton'); var _SendReportButton2 = _interopRequireDefault(_SendReportButton); var _WikiLink = require('./WikiLink'); var _WikiLink2 = _interopRequireDefault(_WikiLink); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Footer = function Footer(_ref) { var tr = _ref.translation.tr; return _react2.default.createElement( 'div', { className: 'Footer mainContentPane' }, _react2.default.createElement( 'span', null, tr('preLink') ), _react2.default.createElement( _WikiLink2.default, { to: 'User_talk:\u041B\u0435 \u041B\u043E\u0439' }, tr('link') ), _react2.default.createElement( 'span', null, tr('postLink') ), ' ', _react2.default.createElement( 'a', { className: 'WikiLink', rel: 'noopener noreferrer', target: '_blank', href: 'https://meta.wikimedia.org/w/index.php?title=Special:Translate&group=page-Wikipedia+Asian+Month%2FTool+Interface&language=' + ((0, _utils.getNavitagorLang)() || 'en') + '&filter=%21translated&action=translate' }, 'Translate this page.' ), _react2.default.createElement(_SendReportButton2.default, null) ); }; exports.default = (0, _translate.withTranslation)(Footer, 'Footer'); },{"./../translate":73,"./../utils":97,"./SendReportButton":51,"./WikiLink":57,"react":"react"}],24:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _Link = require('./Link'); var _Link2 = _interopRequireDefault(_Link); var _LangSwitcher = require('./LangSwitcher'); var _LangSwitcher2 = _interopRequireDefault(_LangSwitcher); var _url = require('../url'); var _url2 = _interopRequireDefault(_url); var _translate = require('../translate'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Header = function Header(_ref) { var children = _ref.children, tr = _ref.translation.tr; return _react2.default.createElement( 'div', { className: 'Header' }, _react2.default.createElement( 'div', { className: 'mainContentPane' }, _react2.default.createElement( _Link2.default, { to: '/' }, _react2.default.createElement('img', { className: 'logo', src: (0, _url2.default)('/Content/logo.png') }) ), _react2.default.createElement(_LangSwitcher2.default, null), Global.user && _react2.default.createElement( 'div', { className: 'login' }, _react2.default.createElement( 'span', { className: 'userName' }, _react2.default.createElement( _Link2.default, { className: 'WikiLink', to: '/personal' }, Global.user.name ) ), _react2.default.createElement( 'a', { className: 'action', href: (0, _url2.default)('/logout?redirectTo=' + window.location.pathname) }, tr('signOut') ) ) || _react2.default.createElement( 'div', { className: 'login' }, _react2.default.createElement( 'a', { className: 'action', href: (0, _url2.default)('/login?redirectTo=' + window.location.pathname) }, tr('signIn') ) ) ) ); }; exports.default = (0, _translate.withTranslation)(Header, 'Header'); },{"../translate":73,"../url":96,"./LangSwitcher":34,"./Link":35,"react":"react"}],25:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactDom = require('react-dom'); var _reactDom2 = _interopRequireDefault(_reactDom); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var IntegerInput = function (_React$Component) { _inherits(IntegerInput, _React$Component); function IntegerInput(props) { _classCallCheck(this, IntegerInput); var _this = _possibleConstructorReturn(this, (IntegerInput.__proto__ || Object.getPrototypeOf(IntegerInput)).call(this, props)); _this.componentWillReceiveProps(props); return _this; } _createClass(IntegerInput, [{ key: 'componentWillReceiveProps', value: function componentWillReceiveProps(_ref) { var value = _ref.value, max = _ref.max, min = _ref.min, onChange = _ref.onChange; if (this.isEmpty(value)) { this.state = { value: '' }; return; } value = parseInt(value) || 0; var changed = false; if (value > max) { value = max; changed = true; } if (value < min) { value = min; changed = true; } this.state = { value: value }; if (changed && onChange) { onChange(value); } } }, { key: 'isEmpty', value: function isEmpty(value) { return !value && value !== 0; } }, { key: 'dec', value: function dec() { var _props = this.props, min = _props.min, onChange = _props.onChange; var value = parseInt(this.state.value) || 0; if (onChange && !(value <= min)) { onChange(value - 1); } } }, { key: 'inc', value: function inc() { var _props2 = this.props, max = _props2.max, onChange = _props2.onChange; var value = parseInt(this.state.value) || 0; if (onChange && !(value >= max)) { onChange(value + 1); } } }, { key: 'onChange', value: function onChange(value) { this.setState({ value: value }); value = parseInt(value); if (isNaN(value)) return; var _props3 = this.props, min = _props3.min, max = _props3.max, onChange = _props3.onChange; if (onChange && !(value < min) && !(value > max)) { onChange(value); } } }, { key: 'onBlur', value: function onBlur() { var value = this.state.value; var _props4 = this.props, min = _props4.min, max = _props4.max, onChange = _props4.onChange; if (this.isEmpty(value)) { onChange && onChange(undefined); return; } value = parseInt(value); if (isNaN(value)) { value = this.props.value; } value = value || 0; if (value > max) { value = max; } if (value < min) { value = min; } this.setState({ value: value }); if (onChange && value != this.props.value) { onChange(value); } } }, { key: 'onKeyDown', value: function onKeyDown(e) { switch (e.keyCode) { case 38: this.inc(); break; case 40: this.dec(); break; default: return; } e.preventDefault(); } }, { key: 'render', value: function render() { var _this2 = this; var value = this.state.value; var className = this.props.className; if (this.isEmpty(value)) { value = ''; } return _react2.default.createElement( 'div', { className: (0, _classnames2.default)(['IntegerInput', className]) }, _react2.default.createElement( 'div', { className: 'minus', onClick: function onClick() { return _this2.dec(); } }, _react2.default.createElement( 'span', null, '\u2212' ) ), _react2.default.createElement('input', { type: 'number', value: value, onChange: function onChange(e) { return _this2.onChange(e.target.value); }, onBlur: function onBlur() { return _this2.onBlur(); }, onKeyDown: function onKeyDown(e) { return _this2.onKeyDown(e); } }), _react2.default.createElement( 'div', { className: 'plus', onClick: function onClick() { return _this2.inc(); } }, _react2.default.createElement( 'span', null, '+' ) ) ); } }]); return IntegerInput; }(_react2.default.Component); exports.default = IntegerInput; },{"classnames":"classnames","react":"react","react-dom":"react-dom"}],26:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _jury = require('./../../jury'); var _translate = require('./../../translate'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var ArticlesList = _react2.default.createClass({ displayName: 'ArticlesList', onItemClick: function onItemClick(e, article) { e.preventDefault(); this.props.onArticleSelected(article.name); }, hasMark: function hasMark(article) { return (0, _jury.findMarkOf)(article.marks) !== undefined; }, getJuryWithMarks: function getJuryWithMarks(article) { var jury = this.props.editathon.jury; return jury.filter(function (j) { return (0, _jury.findMarkOf)(article.marks, j); }); }, renderArticle: function renderArticle(article) { var _this = this; var _props = this.props, editathon = _props.editathon, translation = _props.translation; var juryWithMarks = this.getJuryWithMarks(article); return _react2.default.createElement( 'li', { className: (0, _classnames2.default)({ selected: article.name === this.props.selected, hasMark: this.hasMark(article), invalid: article.stats && this.props.validators.map(function (v) { return v.validate(article.stats); }).some(function (x) { return !x.valid; }), conflict: this.hasMark(article) && (0, _jury.isConflict)(editathon, article) }), key: article.name }, _react2.default.createElement( 'div', { className: 'marks', title: juryWithMarks.join(translation.translate('delimiter')) }, editathon.jury.map(function (j, i) { return _react2.default.createElement('div', { key: i, className: (0, _classnames2.default)({ hasMark: juryWithMarks.indexOf(j) !== -1 }) }); }) ), _react2.default.createElement( 'a', { href: '#', title: article.name, onClick: function onClick(e) { return _this.onItemClick(e, article); } }, article.name ) ); }, render: function render() { var _this2 = this; return _react2.default.createElement( 'ul', { className: 'ArticlesList' }, this.props.editathon.articles.map(function (article) { return _this2.renderArticle(article); }) ); } }); exports.default = (0, _translate.withTranslation)(ArticlesList); },{"./../../jury":65,"./../../translate":73,"classnames":"classnames","react":"react"}],27:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _ModalDialog = require('../ModalDialog'); var _ModalDialog2 = _interopRequireDefault(_ModalDialog); var _MarkDetails = require('../MarkDetails'); var _MarkDetails2 = _interopRequireDefault(_MarkDetails); var _WikiLink = require('../WikiLink'); var _WikiLink2 = _interopRequireDefault(_WikiLink); var _jury = require('./../../jury'); var _translate = require('./../../translate'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var ConflictButton = function (_React$Component) { _inherits(ConflictButton, _React$Component); function ConflictButton(props) { _classCallCheck(this, ConflictButton); var _this = _possibleConstructorReturn(this, (ConflictButton.__proto__ || Object.getPrototypeOf(ConflictButton)).call(this, props)); _this.state = { firstTime: localStorage.getItem('fountainFirstConflict') === null, showDialog: false }; return _this; } _createClass(ConflictButton, [{ key: 'onClick', value: function onClick() { if (this.state.firstTime) { localStorage.setItem('fountainFirstConflict', 'false'); } this.setState({ firstTime: false, showDialog: true }); } }, { key: 'isConflict', value: function isConflict() { var article = this.props.article; return (0, _jury.findMarkOf)(article.marks) !== undefined && (0, _jury.isConflict)(this.props.editathon, article); } }, { key: 'formatNumber', value: function formatNumber() { var _props$translation; for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return (_props$translation = this.props.translation).translate.apply(_props$translation, ['formatNumber'].concat(args)); } }, { key: 'renderMark', value: function renderMark(parts) { var details = []; for (var p in parts) { var v = parts[p]; details.push(_react2.default.createElement( 'dt', { key: 'dt' + p }, v && this.formatNumber(v, { forcePlus: true }) + ' ' || '' )); details.push(_react2.default.createElement( 'dd', { key: 'dd' + p }, p )); } return details; } }, { key: 'render', value: function render() { var _this2 = this; if (!this.isConflict()) return null; var _props = this.props, _props$editathon = _props.editathon, jury = _props$editathon.jury, marksConfig = _props$editathon.marks, wiki = _props$editathon.wiki, marks = _props.article.marks; return _react2.default.createElement( 'div', { className: 'ConflictButton' }, _react2.default.createElement('button', { className: (0, _classnames2.default)({ firstTime: this.state.firstTime }), onClick: function onClick() { return _this2.onClick(); } }), _react2.default.createElement( _ModalDialog2.default, { isOpen: this.state.showDialog, tryClose: function tryClose() { return _this2.setState({ showDialog: false }); } }, _react2.default.createElement( 'table', null, _react2.default.createElement( 'tbody', null, jury.map(function (j) { return (0, _jury.findMarkOf)(marks, j); }).filter(function (m) { return m; }).map(function (m, i) { return _react2.default.createElement( 'tr', { key: i }, _react2.default.createElement( 'td', { className: 'jury' }, _react2.default.createElement(_WikiLink2.default, { to: 'User_talk:' + m.user, wiki: wiki, target: '_blank' }) ), _react2.default.createElement( 'td', { className: 'mark' }, _react2.default.createElement(_MarkDetails2.default, { config: marksConfig, mark: { marks: m.marks } }) ), _react2.default.createElement( 'td', { className: 'comment' }, m.comment ) ); }) ) ) ) ); } }]); return ConflictButton; }(_react2.default.Component); exports.default = (0, _translate.withTranslation)(ConflictButton); },{"../MarkDetails":39,"../ModalDialog":42,"../WikiLink":57,"./../../jury":65,"./../../translate":73,"classnames":"classnames","react":"react"}],28:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _MarkInput = require('../MarkInput'); var _MarkInput2 = _interopRequireDefault(_MarkInput); var _ModalDialog = require('../ModalDialog'); var _ModalDialog2 = _interopRequireDefault(_ModalDialog); var _WikiButton = require('../WikiButton'); var _WikiButton2 = _interopRequireDefault(_WikiButton); var _translate = require('../../translate'); var _jury = require('../../jury'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Evaluation = _react2.default.createClass({ displayName: 'Evaluation', getInitialState: function getInitialState() { return { marks: {}, comment: null, isCommentOpen: false, editingComment: '' }; }, componentWillMount: function componentWillMount() { this.readMarks(this.props); }, componentWillReceiveProps: function componentWillReceiveProps(props) { if (props.article !== this.props.article) { this.readMarks(props); } }, readMarks: function readMarks(_ref) { var _ref$mark = _ref.mark; _ref$mark = _ref$mark === undefined ? {} : _ref$mark; var _ref$mark$marks = _ref$mark.marks, marks = _ref$mark$marks === undefined ? {} : _ref$mark$marks, _ref$mark$comment = _ref$mark.comment, comment = _ref$mark$comment === undefined ? null : _ref$mark$comment; this.setState({ marks: _extends({}, marks), comment: comment }); }, openComment: function openComment() { this.setState({ isCommentOpen: true, editingComment: this.state.comment || '' }); }, saveComment: function saveComment() { this.onChanged({ isCommentOpen: false, comment: this.state.editingComment }); }, hasChanges: function hasChanges() { var _ref2 = this.props.mark || {}, _ref2$marks = _ref2.marks, oldMark = _ref2$marks === undefined ? {} : _ref2$marks, oldComment = _ref2.oldComment; var _state = this.state, newMark = _state.marks, newComment = _state.comment; if ((newComment || '') !== (oldComment || '')) { return true; } for (var key in newMark) { if (oldMark[key] !== newMark[key]) { return true; } } return false; }, canSave: function canSave() { return this.hasChanges() && (0, _jury.isMarkValid)(this.state.marks, this.props.marks); }, onSave: function onSave() { this.props.onSaveMarks({ marks: _extends({}, this.state.marks), comment: this.state.comment }); }, onMarksChange: function onMarksChange(marks) { this.onChanged({ marks: marks }); }, onChanged: function onChanged(newState) { var _this = this; this.setState(newState, function () { return _this.props.onChanged(_this.hasChanges()); }); }, render: function render() { var _this2 = this; if (!this.props.article) return null; var _props = this.props, config = _props.marks, tr = _props.translation.tr; var _state2 = this.state, marks = _state2.marks, comment = _state2.comment, isCommentOpen = _state2.isCommentOpen, editingComment = _state2.editingComment; var total = ((0, _jury.calcMark)(marks, config) || { sum: null }).sum; return _react2.default.createElement( 'div', { className: 'Evaluation' }, _react2.default.createElement(_MarkInput2.default, { config: config, value: marks, onChange: this.onMarksChange }), _react2.default.createElement( 'button', { onClick: this.openComment, className: (0, _classnames2.default)({ 'comment-button': true, selected: comment }), title: comment }, tr('comment') ), _react2.default.createElement( 'div', { className: 'controls' }, _react2.default.createElement( 'div', { className: 'total' }, tr('total', total === null ? '--' : total) ), _react2.default.createElement( _WikiButton2.default, { disabled: !this.canSave(), type: 'constructive', onClick: this.onSave }, tr('save') ), _react2.default.createElement( _WikiButton2.default, { onClick: this.props.onNext }, tr('skip') ) ), _react2.default.createElement( _ModalDialog2.default, { isOpen: isCommentOpen, className: 'comment-dialog' }, _react2.default.createElement('textarea', { maxLength: 255, autoFocus: true, ref: 'commentTextarea', value: editingComment, onChange: function onChange(event) { return _this2.setState({ editingComment: event.target.value }); } }), _react2.default.createElement( 'div', { className: 'commentLength' }, editingComment.length, ' / 255' ), _react2.default.createElement( 'div', { className: 'buttons' }, _react2.default.createElement( _WikiButton2.default, { type: 'progressive', onClick: this.saveComment }, tr('Comment.save') ), _react2.default.createElement( _WikiButton2.default, { onClick: function onClick() { return _this2.setState({ isCommentOpen: false }); } }, tr('Comment.cancel') ) ) ) ); } }); exports.default = (0, _translate.withTranslation)(Evaluation, 'Jury.Evaluation'); },{"../../jury":65,"../../translate":73,"../MarkInput":40,"../ModalDialog":42,"../WikiButton":56,"classnames":"classnames","react":"react"}],29:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; exports.default = Expander; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } function Expander(_ref) { var expanded = _ref.expanded, className = _ref.className, children = _ref.children, props = _objectWithoutProperties(_ref, ['expanded', 'className', 'children']); return _react2.default.createElement( 'div', _extends({ className: (0, _classnames2.default)(['Expander', className, expanded && 'expanded']) }, props), children ); } },{"classnames":"classnames","react":"react"}],30:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Header; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _WikiLink = require('../WikiLink'); var _WikiLink2 = _interopRequireDefault(_WikiLink); var _ConflictButton = require('./ConflictButton'); var _ConflictButton2 = _interopRequireDefault(_ConflictButton); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function Header(_ref) { var article = _ref.article, editathon = _ref.editathon, menuOpen = _ref.menuOpen, toggleMenu = _ref.toggleMenu, children = _ref.children, onClose = _ref.onClose; return _react2.default.createElement( 'div', { className: 'Header' }, _react2.default.createElement('button', { className: (0, _classnames2.default)({ 'menu-button': true, 'open': menuOpen }), onClick: function onClick() { return toggleMenu(); } }), _react2.default.createElement(_ConflictButton2.default, { editathon: editathon, article: article }), _react2.default.createElement(_WikiLink2.default, { className: 'title', title: article.name, to: article.name, wiki: editathon.wiki, target: '_blank' }), _react2.default.createElement( 'div', { className: 'children' }, children ), _react2.default.createElement('button', { className: 'close-button', onClick: onClose }) ); } },{"../WikiLink":57,"./ConflictButton":27,"classnames":"classnames","react":"react"}],31:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _ModalDialog = require('../ModalDialog'); var _ModalDialog2 = _interopRequireDefault(_ModalDialog); var _WikiButton = require('../WikiButton'); var _WikiButton2 = _interopRequireDefault(_WikiButton); var _Api = require('./../../Api'); var _Api2 = _interopRequireDefault(_Api); var _getArticleData = require('./../../getArticleData'); var _getArticleData2 = _interopRequireDefault(_getArticleData); var _jury = require('./../../jury'); var _MwApi = require('./../../MwApi'); var _rules = require('./../../rules'); var _rules2 = _interopRequireDefault(_rules); var _sortBy = require('./../../sortBy'); var _sortBy2 = _interopRequireDefault(_sortBy); var _translate = require('./../../translate'); var _url = require('./../../url'); var _url2 = _interopRequireDefault(_url); var _Loader = require('./../Loader'); var _Loader2 = _interopRequireDefault(_Loader); var _ArticlesList = require('./ArticlesList'); var _ArticlesList2 = _interopRequireDefault(_ArticlesList); var _Evaluation = require('./Evaluation'); var _Evaluation2 = _interopRequireDefault(_Evaluation); var _Expander = require('./Expander'); var _Expander2 = _interopRequireDefault(_Expander); var _Header = require('./Header'); var _Header2 = _interopRequireDefault(_Header); var _Preview = require('./Preview'); var _Preview2 = _interopRequireDefault(_Preview); var _Warnings = require('./Warnings'); var _Warnings2 = _interopRequireDefault(_Warnings); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } var Jury = _react2.default.createClass({ displayName: 'Jury', contextTypes: { router: _react2.default.PropTypes.object.isRequired }, getInitialState: function getInitialState() { return { editathon: null, changed: false, unsavedWarning: null, menuOpen: false }; }, getCode: function getCode() { return this.props.params && this.props.params.id; }, componentWillMount: function componentWillMount() { var _this = this; return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { var editathon, marksCount, article; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: if (!(!_this.getCode() || !Global.user)) { _context.next = 3; break; } _this.close(); return _context.abrupt('return'); case 3: _context.next = 5; return _Api2.default.getEditathon(_this.getCode()); case 5: editathon = _context.sent; if (editathon.jury.filter(function (j) { return j === Global.user.name; })[0]) { _context.next = 9; break; } _this.close(); return _context.abrupt('return'); case 9: if (editathon.articles.length) { _context.next = 12; break; } _this.close(); return _context.abrupt('return'); case 12: marksCount = new Map(editathon.articles.map(function (article) { return [article, editathon.jury.filter(function (j) { return (0, _jury.findMarkOf)(article.marks, j); }).length]; })); editathon.articles.sort((0, _sortBy2.default)(function (a) { return marksCount.get(a); }, 'dateAdded')); article = editathon.articles[0]; _this.setState({ editathon: editathon, selected: editathon.articles[0] && editathon.articles[0].name, info: article ? undefined : false }); if (article) { if ((0, _jury.findMarkOf)(article.marks)) { article = _this.getNextArticle(article) || article; } _this.selectArticle(article.name); } case 17: case 'end': return _context.stop(); } } }, _callee, _this); }))(); }, getArticle: function getArticle(title) { return this.state.editathon.articles.filter(function (article) { return article.name === title; })[0]; }, getSelectedArticle: function getSelectedArticle() { return this.getArticle(this.state.selected); }, selectArticle: function selectArticle(title) { var _this2 = this; return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { var article, info, userGender, what, mwApi, _ref, _ref2; return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: if (!_this2.state.changed) { _context2.next = 5; break; } _context2.next = 3; return _this2.unsavedWarning(); case 3: if (_context2.sent) { _context2.next = 5; break; } return _context2.abrupt('return'); case 5: article = _this2.getArticle(title); _this2.setState({ selected: title, info: article.info, menuOpen: false, changed: false }); if (article.info) { _context2.next = 34; break; } info = void 0, userGender = void 0; _context2.prev = 9; what = (0, _rules.getRulesReqs)(_this2.getRules()); mwApi = (0, _MwApi.getMwApi)(_this2.state.editathon.wiki); // files _context2.next = 14; return mwApi.getNamespace(title); case 14: _context2.t0 = _context2.sent; if (!(_context2.t0 === 6)) { _context2.next = 19; break; } what.push('fileUrl'); _context2.next = 20; break; case 19: what.push('title'); case 20: _context2.next = 22; return Promise.all([(0, _getArticleData2.default)(_this2.state.editathon.wiki, title, [].concat(_toConsumableArray(what), ['html', 'indicators'])), mwApi.getUserGender(article.user)]); case 22: _ref = _context2.sent; _ref2 = _slicedToArray(_ref, 2); info = _ref2[0]; userGender = _ref2[1]; if (info === null) info = false;else info.userGender = userGender; article.info = info; _context2.next = 33; break; case 30: _context2.prev = 30; _context2.t1 = _context2['catch'](9); info = { error: _context2.t1 }; case 33: if (title === _this2.state.selected) { _this2.setState({ info: info }); } case 34: case 'end': return _context2.stop(); } } }, _callee2, _this2, [[9, 30]]); }))(); }, getRules: function getRules() { return (0, _rules2.default)(this.state.editathon.rules).filter(function (r) { return r.flags & (_rules.RuleFlags.optional | _rules.RuleFlags.informational); }); }, onChanged: function onChanged(changed) { this.setState({ changed: changed }); }, unsavedWarning: function unsavedWarning() { var _this3 = this; return new Promise(function (resolve) { _this3.setState({ unsavedWarning: function unsavedWarning(result) { _this3.setState({ unsavedWarning: null }); resolve(result); } }); }); }, setMark: function setMark(article, mark) { var m = (0, _jury.findMarkOf)(article.marks); if (!m) { m = { user: Global.user.name }; article.marks.push(m); } m.marks = mark.marks; m.comment = mark.comment; }, moveNext: function moveNext() { var next = this.getNextArticle(this.getSelectedArticle()); if (next) { this.selectArticle(next.name); } }, getNextArticle: function getNextArticle(article) { var articles = this.state.editathon.articles; var curentIndex = articles.indexOf(article); for (var index = curentIndex;;) { index = (index + 1) % articles.length; if (index === curentIndex) break; if (!(0, _jury.findMarkOf)(articles[index].marks)) { return articles[index]; } } }, onSaveMark: function onSaveMark(_ref3) { var _this4 = this; var comment = _ref3.comment, marks = _ref3.marks; return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() { var mark, article; return regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: mark = { marks: marks, comment: comment }; article = _this4.getSelectedArticle(); _context3.prev = 2; _context3.next = 5; return _Api2.default.setMark(_this4.getCode(), { title: article.name, marks: mark.marks, comment: mark.comment }); case 5: _this4.setMark(article, mark); _this4.setState({ editathon: _this4.state.editathon, changed: false }); _this4.moveNext(); _context3.next = 14; break; case 10: _context3.prev = 10; _context3.t0 = _context3['catch'](2); console.error(_context3.t0); alert('Error \'' + _context3.t0 + '\' while saving the mark for \'' + article.name + '\'.'); case 14: case 'end': return _context3.stop(); } } }, _callee3, _this4, [[2, 10]]); }))(); }, toggleMenu: function toggleMenu() { this.setState({ menuOpen: !this.state.menuOpen }); }, tryClose: function tryClose() { var _this5 = this; return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() { return regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: _context4.t0 = _this5.state.changed; if (!_context4.t0) { _context4.next = 5; break; } _context4.next = 4; return _this5.unsavedWarning(); case 4: _context4.t0 = !_context4.sent; case 5: if (!_context4.t0) { _context4.next = 7; break; } return _context4.abrupt('return'); case 7: _this5.close(); case 8: case 'end': return _context4.stop(); } } }, _callee4, _this5); }))(); }, close: function close() { this.context.router.replace({ pathname: (0, _url2.default)('/editathons/' + (this.getCode() || '')) }); }, render: function render() { var _this6 = this; var translate = this.props.translation.translate; var _state = this.state, editathon = _state.editathon, info = _state.info; if (!editathon) return _react2.default.createElement(_Loader2.default, null); var article = this.getSelectedArticle(); return _react2.default.createElement( 'div', { className: 'Jury' }, _react2.default.createElement( _Header2.default, { article: article, editathon: editathon, menuOpen: this.state.menuOpen, toggleMenu: this.toggleMenu, onClose: this.tryClose }, _react2.default.createElement(_Warnings2.default, { info: info, rules: this.getRules(), article: article, wiki: editathon.wiki }) ), _react2.default.createElement( 'main', null, _react2.default.createElement( _Expander2.default, { expanded: this.state.menuOpen }, _react2.default.createElement(_ArticlesList2.default, { editathon: editathon, selected: this.state.selected, onArticleSelected: this.selectArticle }) ), _react2.default.createElement(_Preview2.default, { title: this.state.selected, wiki: editathon.wiki, info: info }), _react2.default.createElement(_Evaluation2.default, { onNext: this.moveNext, onSaveMarks: this.onSaveMark, article: article, marks: editathon.marks, mark: (0, _jury.findMarkOf)(article.marks), onChanged: this.onChanged }) ), _react2.default.createElement( _ModalDialog2.default, { isOpen: this.state.unsavedWarning, className: 'unsavedWarning' }, _react2.default.createElement( 'div', { className: 'message' }, translate('UnsavedWarning.message') ), _react2.default.createElement( 'div', { className: 'buttons' }, _react2.default.createElement( _WikiButton2.default, { type: 'destructive', onClick: function onClick() { return _this6.state.unsavedWarning(true); } }, translate('UnsavedWarning.ok') ), _react2.default.createElement( _WikiButton2.default, { onClick: function onClick() { return _this6.state.unsavedWarning(false); } }, translate('UnsavedWarning.cancel') ) ) ) ); } }); exports.default = (0, _translate.withTranslation)(Jury, 'Jury'); },{"../ModalDialog":42,"../WikiButton":56,"./../../Api":4,"./../../MwApi":61,"./../../getArticleData":64,"./../../jury":65,"./../../rules":69,"./../../sortBy":70,"./../../translate":73,"./../../url":96,"./../Loader":36,"./ArticlesList":26,"./Evaluation":28,"./Expander":29,"./Header":30,"./Preview":32,"./Warnings":33,"react":"react"}],32:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _translate = require('../../translate'); var _Loader = require('../Loader'); var _Loader2 = _interopRequireDefault(_Loader); var _wikiPreview = require('../wikiPreview'); var _MwApi = require('./../../MwApi'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Preview = _react2.default.createClass({ displayName: 'Preview', shouldComponentUpdate: function shouldComponentUpdate(_ref) { var title = _ref.title, info = _ref.info; return title !== this.props.title || info !== this.props.info; }, render: function render() { return _react2.default.createElement( 'div', { className: 'Preview' }, this.renderContent() ); }, renderContent: function renderContent() { var _props = this.props, info = _props.info, title = _props.title, wiki = _props.wiki, tr = _props.translation.tr; if (info === undefined) return _react2.default.createElement( 'div', { key: 'loader', className: 'content' }, _react2.default.createElement(_Loader2.default, null) ); if (info === false) return _react2.default.createElement( 'div', { key: 'not-found', className: 'content not-found' }, tr('notFound') ); if (info && info.error) { console.error(info.error); var error = info.error.stack ? info.error.message + '\n' + info.error.stack : JSON.stringify(info.error, null, 4); return _react2.default.createElement( 'div', { key: 'error', className: 'content error' }, tr('loadingError') + ' ', _react2.default.createElement( 'pre', null, error ) ); } return _react2.default.createElement(_wikiPreview.WikiHtml, { className: 'content', wiki: wiki, title: info.title, preHtml: '\n
\n ' + Object.keys(info.indicators).map(function (k) { return '
' + info.indicators[k] + '
'; }) + '\n
\n' + (info.title !== title ? '

\n ' + info.title + '\n

' : '') + '\n', html: '\n' + (info.fileUrl && '\n
\n \n \n \n
' || '') + '\n' + info.html + '\n' }); } }); exports.default = (0, _translate.withTranslation)(Preview, 'Jury.Preview'); },{"../../translate":73,"../Loader":36,"../wikiPreview":60,"./../../MwApi":61,"react":"react"}],33:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _Loader = require('./../Loader'); var _Loader2 = _interopRequireDefault(_Loader); var _WikiLink = require('./../WikiLink'); var _WikiLink2 = _interopRequireDefault(_WikiLink); var _translate = require('../../translate'); var _Header = require('./Header'); var _Header2 = _interopRequireDefault(_Header); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var RuleMessages = { submitterIsCreator: function submitterIsCreator(rule, ok, stats, ctx, tr, wiki) { return [tr('author'), _react2.default.createElement(_WikiLink2.default, { to: 'User_talk:' + stats.creator, wiki: wiki, target: '_blank' })]; }, articleCreated: function articleCreated(rule, ok, stats, ctx, tr) { return [tr('createdOn'), tr('createdDate', stats.created)]; }, articleSize: function articleSize(rule, ok, stats, ctx, tr) { return [rule.params.bytes && tr('bytes', stats.bytes), rule.params.chars && tr('chars', stats.chars), rule.params.words && tr('words', stats.words)].filter(function (x) { return x; }); }, addedForCleanupRu: function addedForCleanupRu(rule, ok, stats, ctx, tr, wiki, title) { var _tr = tr('addedForCleanupRu', stats.addedForCleanupRu.date), _tr2 = _slicedToArray(_tr, 2), header = _tr2[0], link = _tr2[1]; return [header, _react2.default.createElement( _WikiLink2.default, { key: 'link', wiki: wiki, target: '_blank', to: stats.addedForCleanupRu.date ? '?oldid=' + stats.addedForCleanupRu.revId + '&diff=cur' : title + '?action=history' }, link )]; } }; var Warnings = _react2.default.createClass({ displayName: 'Warnings', render: function render() { return _react2.default.createElement( 'div', { className: 'Warnings' }, this.renderWarnings() ); }, renderWarnings: function renderWarnings() { var _this = this; var _props = this.props, article = _props.article, rules = _props.rules, info = _props.info, tr = _props.translation.tr, wiki = _props.wiki; if (!article || !rules || info === undefined) { return _react2.default.createElement(_Loader2.default, null); } var author = this.renderStat('_author', [tr('submittedBy', info.userGender), _react2.default.createElement(_WikiLink2.default, { key: 'a', to: 'User_talk:' + article.user, wiki: wiki, className: 'value nowrap', target: '_blank' })], true); if (!info || info.error) { return author; } var ctx = { user: { name: article.user } }; return _react2.default.createElement( 'div', null, author, rules.map(function (rule, i) { var result = rule.check(info, ctx); return _this.renderStat(i, RuleMessages[rule.type](rule, result, info, ctx, tr, wiki, article.name), result); }) ).props.children; }, renderStat: function renderStat(key, rows, isOk) { return _react2.default.createElement( 'div', { key: key, className: (0, _classnames2.default)({ item: true, nasty: !isOk }) }, rows.map(function (row, i) { return _react2.default.createElement( 'div', { className: 'row', key: i }, row ); }) ); } }); exports.default = (0, _translate.withTranslation)(Warnings, 'Jury.Warnings'); },{"../../translate":73,"./../Loader":36,"./../WikiLink":57,"./Header":30,"classnames":"classnames","react":"react"}],34:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _DropDown = require('./DropDown'); var _DropDown2 = _interopRequireDefault(_DropDown); var _translate = require('../translate'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function getItems(_ref) { var allLangs = _ref.allLangs, trF = _ref.translateFrom; return allLangs().map(function (x) { return { code: x, name: trF(x, '_name') }; }); } function matchItem(item, value) { value = value.toLowerCase(); return item.code.toLowerCase().startsWith(value) || item.name.toLowerCase().startsWith(value); } function LangSwitcher(_ref2) { var translation = _ref2.translation; return _react2.default.createElement(_DropDown2.default, { className: 'LangSwitcher', renderButton: function renderButton() { return _react2.default.createElement( 'button', null, '\xA0' ); }, items: getItems(translation), renderItem: function renderItem(x) { return x.code + ': ' + x.name; }, getValue: function getValue(x) { return x.code; }, filter: true, value: translation.curLang, onChange: function onChange(lg) { return translation.setLang(lg); }, matchItem: matchItem }); } exports.default = (0, _translate.withTranslation)(LangSwitcher); },{"../translate":73,"./DropDown":10,"react":"react"}],35:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactRouter = require('react-router'); var _url = require('../url'); var _url2 = _interopRequireDefault(_url); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Link = function (_React$Component) { _inherits(Link, _React$Component); function Link(props, _ref) { var router = _ref.router; _classCallCheck(this, Link); var _this = _possibleConstructorReturn(this, (Link.__proto__ || Object.getPrototypeOf(Link)).call(this, props)); _this._replacingRouter = _extends({}, router, { push: router.replace }); return _this; } _createClass(Link, [{ key: 'fixLink', value: function fixLink(to) { if (to === null) { return null; } else if (to.pathname) { return Object.assign({}, to, { pathname: (0, _url2.default)(to.pathname) }); } else if (typeof to === 'string') { return (0, _url2.default)(to); } else { return to; } } }, { key: 'getChildContext', value: function getChildContext() { return { router: this.props.replace ? this._replacingRouter : this.context.router }; } }, { key: 'render', value: function render() { var _props = this.props, to = _props.to, replace = _props.replace, props = _objectWithoutProperties(_props, ['to', 'replace']); return _react2.default.createElement(_reactRouter.Link, _extends({}, props, { to: this.fixLink(to) })); } }], [{ key: 'contextTypes', get: function get() { return { router: _react2.default.PropTypes.object.isRequired }; } }, { key: 'childContextTypes', get: function get() { return { router: _react2.default.PropTypes.object }; } }]); return Link; }(_react2.default.Component); exports.default = Link; },{"../url":96,"react":"react","react-router":"react-router"}],36:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } exports.default = function (_ref) { var className = _ref.className, _ref$loading = _ref.loading, loading = _ref$loading === undefined ? true : _ref$loading, children = _ref.children, props = _objectWithoutProperties(_ref, ['className', 'loading', 'children']); return _react2.default.createElement('div', _extends({ className: (0, _classnames2.default)([loading && 'Loader', className]), children: loading ? null : children }, props)); }; },{"classnames":"classnames","react":"react"}],37:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.createLookup = undefined; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _reactAutocomplete = require('react-autocomplete'); var _reactAutocomplete2 = _interopRequireDefault(_reactAutocomplete); var _throttle = require('./../throttle'); var _throttle2 = _interopRequireDefault(_throttle); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var LookupWithThrottle = function (_React$Component) { _inherits(LookupWithThrottle, _React$Component); function LookupWithThrottle(props) { _classCallCheck(this, LookupWithThrottle); var _this = _possibleConstructorReturn(this, (LookupWithThrottle.__proto__ || Object.getPrototypeOf(LookupWithThrottle)).call(this, props)); _this.state = { items: [] }; return _this; } _createClass(LookupWithThrottle, [{ key: 'componentWillMount', value: function componentWillMount() { var _this2 = this; this.callLookup = (0, _throttle2.default)(function () { var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(value) { var items; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _this2.lookupValue = value; _context.next = 3; return _this2.props.lookup(value); case 3: items = _context.sent; // make sure older request's response // didn't return after newer request's response if (_this2.lookupValue === value) { _this2.setState({ items: items }); } case 5: case 'end': return _context.stop(); } } }, _callee, _this2); })); return function (_x) { return _ref.apply(this, arguments); }; }(), 500); } }, { key: 'componentDidMount', value: function componentDidMount() { if (this._autocomplete && this.props.autoFocus) { this._autocomplete.refs.input.select(); } } }, { key: 'componentWillUnmount', value: function componentWillUnmount() { this.callLookup && this.callLookup.cancel(); } }, { key: 'onChange', value: function () { var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(value) { var onChange; return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: onChange = this.props.onChange; onChange && onChange(value); case 2: case 'end': return _context2.stop(); } } }, _callee2, this); })); function onChange(_x2) { return _ref2.apply(this, arguments); } return onChange; }() }, { key: 'render', value: function render() { var _this3 = this; var _props = this.props, inputProps = _props.inputProps, className = _props.className, value = _props.value; return _react2.default.createElement(_reactAutocomplete2.default, { ref: function ref(x) { return _this3._autocomplete = x; }, inputProps: inputProps, wrapperProps: { className: (0, _classnames2.default)(['LookupWithThrottle', className]) }, wrapperStyle: {}, value: value, items: this.state.items, getItemValue: function getItemValue(x) { return x; }, renderItem: this.renderItem, renderMenu: this.renderMenu, onSelect: function onSelect(value, item) { _this3.onChange(value); _this3.setState({ items: [] }); }, onChange: function onChange(event, value) { _this3.onChange(value); _this3.callLookup(value); } }); } }, { key: 'renderItem', value: function renderItem(item, selected) { return _react2.default.createElement( 'div', { key: item, className: (0, _classnames2.default)({ item: true, selected: selected }) }, item ); } }, { key: 'renderMenu', value: function renderMenu(items, value, style) { if (!items.length) return _react2.default.createElement('div', null); return _react2.default.createElement( 'div', { className: 'popup-container' }, _react2.default.createElement( 'div', { className: 'popup', style: { minWidth: style.minWidth } }, items ) ); } }]); return LookupWithThrottle; }(_react2.default.Component); exports.default = LookupWithThrottle; function createLookup(baseClassName, _lookup) { return function Lookup(_ref3) { var className = _ref3.className, props = _objectWithoutProperties(_ref3, ['className']); return _react2.default.createElement(LookupWithThrottle, _extends({ className: (0, _classnames2.default)([baseClassName, className]), lookup: function lookup(v) { return _lookup(v, props); } }, props)); }; } exports.createLookup = createLookup; },{"./../throttle":72,"classnames":"classnames","react":"react","react-autocomplete":"react-autocomplete"}],38:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _translate = require('./../translate'); var _sortBy = require('./../sortBy'); var _sortBy2 = _interopRequireDefault(_sortBy); var _WikiButton = require('./WikiButton'); var _WikiButton2 = _interopRequireDefault(_WikiButton); var _Api = require('./../Api'); var _Api2 = _interopRequireDefault(_Api); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var ManageArticles = function (_React$Component) { _inherits(ManageArticles, _React$Component); function ManageArticles(props) { _classCallCheck(this, ManageArticles); var _this = _possibleConstructorReturn(this, (ManageArticles.__proto__ || Object.getPrototypeOf(ManageArticles)).call(this, props)); _this.state = { checked: new Set(), loading: false }; return _this; } _createClass(ManageArticles, [{ key: 'toggle', value: function toggle(id) { var checked = this.state.checked; if (checked.has(id)) { checked.delete(id); } else { checked.add(id); } this.setState({}); } }, { key: 'remove', value: function () { var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { var _state, checked, loading; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: this.setState({ loading: true }); _state = this.state, checked = _state.checked, loading = _state.loading; _context.prev = 2; _context.next = 5; return _Api2.default.removeArticles(this.props.editathon.code, [].concat(_toConsumableArray(checked))); case 5: checked.clear(); _context.next = 8; return this.props.onReloadEditathon(); case 8: _context.prev = 8; this.setState({ loading: false }); return _context.finish(8); case 11: case 'end': return _context.stop(); } } }, _callee, this, [[2,, 8, 11]]); })); function remove() { return _ref.apply(this, arguments); } return remove; }() }, { key: 'render', value: function render() { var _this2 = this; var _props = this.props, editathon = _props.editathon, _props$translation = _props.translation, translate = _props$translation.translate, tr = _props$translation.tr; var _state2 = this.state, checked = _state2.checked, loading = _state2.loading; return _react2.default.createElement( 'div', { className: 'ManageArticles' }, _react2.default.createElement( 'div', { className: 'buttons' }, _react2.default.createElement( _WikiButton2.default, { type: 'destructive', disabled: checked.size === 0, onClick: function onClick() { return _this2.remove(); }, loading: loading }, tr('removeSelected') ) ), _react2.default.createElement( 'table', null, _react2.default.createElement( 'thead', null, _react2.default.createElement( 'tr', null, _react2.default.createElement('th', { className: 'check' }), _react2.default.createElement( 'th', { className: 'user' }, '\u0423\u0447\u0430\u0441\u0442\u043D\u0438\u043A' ), _react2.default.createElement( 'th', { className: 'article' }, '\u0421\u0442\u0430\u0442\u044C\u044F' ), _react2.default.createElement( 'th', { className: 'date' }, '\u0414\u0430\u0442\u0430 \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u0438\u044F' ) ) ), _react2.default.createElement( 'tbody', null, editathon.articles.sort((0, _sortBy2.default)((0, _sortBy2.default)(function (a) { return a.dateAdded; }).desc, function (a) { return a.name; }, function (a) { return a.id; })).map(function (a) { return _react2.default.createElement( 'tr', { key: a.id, tabIndex: 0, onClick: function onClick() { return _this2.toggle(a.id); }, onKeyDown: function onKeyDown(e) { if (e.key === 'Enter') { _this2.toggle(a.id); } else if (e.key === ' ') { _this2.toggle(a.id); } else { return; } e.preventDefault(); } }, _react2.default.createElement('td', { className: (0, _classnames2.default)('check', checked.has(a.id) && 'checked') }), _react2.default.createElement( 'td', { className: 'user' }, a.user ), _react2.default.createElement( 'td', { className: 'article' }, a.name ), _react2.default.createElement( 'td', { className: 'date' }, translate('formatDate', a.dateAdded, 'L LT') ) ); }) ) ) ); } }]); return ManageArticles; }(_react2.default.Component); exports.default = (0, _translate.withTranslation)(ManageArticles, 'ManageArticles'); },{"./../Api":4,"./../sortBy":70,"./../translate":73,"./WikiButton":56,"classnames":"classnames","react":"react"}],39:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _translate = require('../translate'); var _jury = require('../jury'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function MarkDetails(_ref) { var mark = _ref.mark, config = _ref.config, translation = _ref.translation; var _calcMark = (0, _jury.calcMark)(mark.marks, config), sum = _calcMark.sum, parts = _calcMark.parts; var formatNumber = function formatNumber() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return translation.translate.apply(translation, ['formatNumber'].concat(args)); }; var details = []; for (var id in parts) { var p = parts[id]; details.push(_react2.default.createElement( 'dt', { key: 'dt-' + id }, p.value && formatNumber(p.value, { forcePlus: true }) + ' ' || '' )); details.push(_react2.default.createElement( 'dd', { key: 'dd-' + id }, p.title )); } var user = mark.user ? [_react2.default.createElement( 'span', { key: 'jury', className: 'jury' }, mark.user ), ': '] : null; return _react2.default.createElement( 'div', { className: 'MarkDetails' }, user, _react2.default.createElement( 'span', { className: 'sum' }, formatNumber(sum) ), _react2.default.createElement( 'dl', { className: 'details' }, details ), mark.comment && _react2.default.createElement( 'div', { className: 'comment' }, mark.comment ) ); } exports.default = (0, _translate.withTranslation)(MarkDetails); },{"../jury":65,"../translate":73,"react":"react"}],40:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _IntegerInput = require('./IntegerInput'); var _IntegerInput2 = _interopRequireDefault(_IntegerInput); var _WikiButton = require('./WikiButton'); var _WikiButton2 = _interopRequireDefault(_WikiButton); var _jury = require('../jury'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var MarkInput = function (_React$Component) { _inherits(MarkInput, _React$Component); function MarkInput(props) { _classCallCheck(this, MarkInput); var _this = _possibleConstructorReturn(this, (MarkInput.__proto__ || Object.getPrototypeOf(MarkInput)).call(this, props)); _this._markRenderers = { check: _this.renderCheck, radio: _this.renderRadio, int: _this.renderInt }; for (var key in _this._markRenderers) { _this._markRenderers[key] = _this._markRenderers[key].bind(_this); } return _this; } _createClass(MarkInput, [{ key: 'setMark', value: function setMark(id, value) { var marks = _extends({}, this.props.value); if (value === undefined) { value = !marks[id]; } marks[id] = value; this.onChange(marks); } }, { key: 'clearMark', value: function clearMark(id) { var marks = _extends({}, this.props.value); delete marks[id]; this.onChange(marks); } }, { key: 'onChange', value: function onChange(marks) { this.props.onChange(marks); } }, { key: 'renderCheck', value: function renderCheck(id, mark) { var _this2 = this; return _react2.default.createElement( 'div', { className: 'check' }, _react2.default.createElement( 'button', { className: (0, _classnames2.default)({ selected: !!mark.cur }), title: mark.description, onClick: function onClick() { return _this2.setMark(id); } }, mark.title || '\xa0' ), this.renderMarkControls(mark.children) ); } }, { key: 'renderRadio', value: function renderRadio(id, mark) { var _this3 = this; return _react2.default.createElement( 'div', { className: 'radio' }, _react2.default.createElement( 'span', { className: 'title' }, mark.title + ': ' ), _react2.default.createElement( 'div', { className: 'buttons' }, mark.values.map(function (v, i) { return _react2.default.createElement( 'button', { key: i, title: v.description, className: (0, _classnames2.default)({ selected: mark.cur && mark.cur.val === i }), onClick: function onClick() { return _this3.setMark(id, i); } }, v.title || '\xa0' ); }) ), this.renderMarkControls(mark.children) ); } }, { key: 'renderInt', value: function renderInt(id, mark) { var _this4 = this; return _react2.default.createElement( 'div', { className: 'int' }, _react2.default.createElement( 'span', { className: 'title' }, mark.title + ': ' ), _react2.default.createElement(_IntegerInput2.default, { value: mark.cur ? mark.cur.val : undefined, min: mark.min, max: mark.max, onChange: function onChange(v) { return v === undefined ? _this4.clearMark(id) : _this4.setMark(id, v); } }) ); } }, { key: 'renderMarkControl', value: function renderMarkControl(id, mark) { return this._markRenderers[mark.type](id, mark); } }, { key: 'renderMarkControls', value: function renderMarkControls(config) { var _this5 = this; var marks = (0, _jury.getActiveMarks)(this.props.value, config); return _react2.default.createElement( 'ul', null, Object.keys(marks).map(function (id) { return _react2.default.createElement( 'li', { key: id }, _this5.renderMarkControl(id, marks[id]) ); }) ); } }, { key: 'render', value: function render() { var config = this.props.config; return _react2.default.createElement( 'div', { className: 'MarkInput' }, config && this.renderMarkControls(config) ); } }]); return MarkInput; }(_react2.default.Component); exports.default = MarkInput; },{"../jury":65,"./IntegerInput":25,"./WikiButton":56,"classnames":"classnames","react":"react"}],41:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _translate = require('../translate'); var _jury = require('../jury'); var _MarkDetails = require('./MarkDetails'); var _MarkDetails2 = _interopRequireDefault(_MarkDetails); var _MarkInput = require('./MarkInput'); var _MarkInput2 = _interopRequireDefault(_MarkInput); var _WikiButton = require('./WikiButton'); var _WikiButton2 = _interopRequireDefault(_WikiButton); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var MarksPreview = function (_React$Component) { _inherits(MarksPreview, _React$Component); function MarksPreview(props) { _classCallCheck(this, MarksPreview); var _this = _possibleConstructorReturn(this, (MarksPreview.__proto__ || Object.getPrototypeOf(MarksPreview)).call(this, props)); _this.state = { marks: {} }; return _this; } _createClass(MarksPreview, [{ key: 'render', value: function render() { var _this2 = this; var _props = this.props, config = _props.config, tr = _props.translation.tr; var marks = this.state.marks; var isValid = (0, _jury.isMarkValid)(marks, config); var isEmpty = !Object.keys(config).length; return _react2.default.createElement( 'div', { className: 'MarksPreview' }, isValid && !isEmpty ? _react2.default.createElement(_MarkDetails2.default, { mark: { marks: marks }, config: config }) : tr('incomplete'), _react2.default.createElement(_MarkInput2.default, { config: config, value: marks, onChange: function onChange(marks) { return _this2.setState({ marks: marks }); } }), Object.keys(marks).length !== 0 && _react2.default.createElement(_WikiButton2.default, { className: 'reset', onClick: function onClick() { return _this2.setState({ marks: {} }); }, children: tr('resetPreview') }) ); } }]); return MarksPreview; }(_react2.default.Component); exports.default = (0, _translate.withTranslation)(MarksPreview, 'MarksPreview'); },{"../jury":65,"../translate":73,"./MarkDetails":39,"./MarkInput":40,"./WikiButton":56,"react":"react"}],42:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } exports.default = function (_ref) { var isOpen = _ref.isOpen, children = _ref.children, tryClose = _ref.tryClose, props = _objectWithoutProperties(_ref, ['isOpen', 'children', 'tryClose']); return isOpen && _react2.default.createElement( 'div', _extends({}, props, { className: 'ModalDialog' }), _react2.default.createElement( 'div', { className: (0, _classnames2.default)(['content', props.className]) }, children ), _react2.default.createElement('div', { className: 'wrapper', onClick: tryClose }) ) || null; }; },{"classnames":"classnames","react":"react"}],43:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _MwApi = require('./../MwApi'); var _LookupWithThrottle = require('./LookupWithThrottle'); function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } exports.default = (0, _LookupWithThrottle.createLookup)('PageLookup', function () { var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(value, _ref2) { var wiki = _ref2.wiki, ns = _ref2.ns; var mw, restrictNs, allNs, id, results, prefixLength; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: value = (value || '').trim(); if (value) { _context.next = 3; break; } return _context.abrupt('return', []); case 3: mw = (0, _MwApi.getMwApi)(wiki); restrictNs = ns !== undefined; if (!restrictNs) { _context.next = 11; break; } _context.next = 8; return mw.getNamespaces(); case 8: _context.t0 = _context.sent; _context.next = 12; break; case 11: _context.t0 = null; case 12: allNs = _context.t0; if (!restrictNs) { _context.next = 19; break; } _context.next = 16; return mw.getNamespace(value); case 16: id = _context.sent; if (!(id !== undefined && id !== null && id != ns)) { _context.next = 19; break; } return _context.abrupt('return', []); case 19: _context.next = 21; return mw.lookup(value, ns); case 21: results = _context.sent; if (restrictNs && ns !== 0) { prefixLength = allNs[ns][0].length + 1; results = results.map(function (r) { return r.slice(prefixLength); }); } return _context.abrupt('return', results); case 24: case 'end': return _context.stop(); } } }, _callee, this); })); function lookup(_x, _x2) { return _ref.apply(this, arguments); } return lookup; }()); },{"./../MwApi":61,"./LookupWithThrottle":37}],44:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _moment = require('moment'); var _moment2 = _interopRequireDefault(_moment); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _Api = require('../../Api'); var _Api2 = _interopRequireDefault(_Api); var _jury = require('../../jury'); var _MwApi = require('../../MwApi'); var _rules = require('../../rules'); var _translate = require('../../translate'); var _EditathonList = require('../EditathonList'); var _Link = require('../Link'); var _Link2 = _interopRequireDefault(_Link); var _Loader = require('../Loader'); var _Loader2 = _interopRequireDefault(_Loader); var _MarksPreview = require('../MarksPreview'); var _MarksPreview2 = _interopRequireDefault(_MarksPreview); var _TemplatePreview = require('../TemplatePreview'); var _TemplatePreview2 = _interopRequireDefault(_TemplatePreview); var _WikiButton = require('../WikiButton'); var _WikiButton2 = _interopRequireDefault(_WikiButton); var _WikiLink = require('../WikiLink'); var _WikiLink2 = _interopRequireDefault(_WikiLink); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var Rules = function () { function Rules() { _classCallCheck(this, Rules); } _createClass(Rules, null, [{ key: 'articleSize', value: function articleSize(rule, tr) { return Object.keys(rule.params).map(function (k) { return Object.keys(rule.params[k]).map(function (op) { return tr(op) + ' ' + rule.params[k][op] + ' ' + tr(k); }).join(', '); }).join(' OR '); } }, { key: 'submitterIsCreator', value: function submitterIsCreator(rule) { return null; } }, { key: 'articleCreated', value: function articleCreated(rule, tr, translate) { return Object.keys(rule.params).map(function (k) { return tr(k === 'after' ? 'notBefore' : 'notAfter') + ' ' + translate('formatDate', (0, _moment2.default)(rule.params[k]).utc(), 'L LT'); }).join(', '); } }, { key: 'submitterRegistered', value: function submitterRegistered(rule, tr, translate) { return this.articleCreated(rule, tr, translate); } }, { key: 'namespace', value: function namespace(rule) { return 'MAIN'; } }, { key: 'addedForCleanupRu', value: function addedForCleanupRu(rule) { return null; } }, { key: 'render', value: function render(rule, translate) { // TODO: better i18n support var tr = function tr(x) { for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } return translate.apply(undefined, ['EditathonConfig.RulesPage.' + rule.type + '.' + x].concat(args)); }; return _react2.default.createElement( 'div', { className: 'Rule', key: rule.id }, _react2.default.createElement( 'div', { className: 'type' }, tr('title'), ':' ), _react2.default.createElement( 'div', { className: 'descr' }, Rules[rule.type](rule, tr, translate) ), _react2.default.createElement( 'div', { className: 'flags' }, (rule.flags & _rules.RuleFlags.optional) !== 0 && _react2.default.createElement( 'div', { className: 'flag optional' }, 'optional' ) || _react2.default.createElement( 'div', { className: 'flag required' }, 'required' ), (rule.flags & _rules.RuleFlags.informational) !== 0 && _react2.default.createElement( 'div', { className: 'flag jury' }, 'jury' ) ) ); } }]); return Rules; }(); var Approval = function (_React$Component) { _inherits(Approval, _React$Component); function Approval(props) { _classCallCheck(this, Approval); var _this = _possibleConstructorReturn(this, (Approval.__proto__ || Object.getPrototypeOf(Approval)).call(this, props)); _this.state = { sending: false, data: null }; return _this; } _createClass(Approval, [{ key: 'componentDidMount', value: function componentDidMount() { this.update(); } }, { key: 'update', value: function () { var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: this.setState({ data: null }); _context.t0 = this; _context.next = 4; return _Api2.default.getUnapprovedEditathons(); case 4: _context.t1 = _context.sent; _context.t2 = { data: _context.t1 }; _context.t0.setState.call(_context.t0, _context.t2); case 7: case 'end': return _context.stop(); } } }, _callee, this); })); function update() { return _ref.apply(this, arguments); } return update; }() }, { key: 'render', value: function render() { var _this2 = this; var _props$translation = this.props.translation, translate = _props$translation.translate, tr = _props$translation.tr; var _state = this.state, data = _state.data, sending = _state.sending; if (!data) { return _react2.default.createElement(_Loader2.default, null); } return _react2.default.createElement( 'div', { className: 'Approval' }, _react2.default.createElement( 'h2', null, tr('title') ), _react2.default.createElement( 'div', { className: 'list' }, data.map(function (ed) { return _react2.default.createElement( 'div', { className: 'row', key: ed.code }, _react2.default.createElement( 'header', { title: ed.name }, ed.name ), _react2.default.createElement( 'div', null, ed.description ), _react2.default.createElement( 'dl', null, _react2.default.createElement( 'div', null, _react2.default.createElement( 'dt', null, tr('creator') ), _react2.default.createElement( 'dd', null, _react2.default.createElement(_WikiLink2.default, { to: 'User_talk:' + ed.creator }) ) ), _react2.default.createElement( 'div', null, _react2.default.createElement( 'dt', null, tr('code') ), _react2.default.createElement( 'dd', null, ed.code ) ), _react2.default.createElement( 'div', null, _react2.default.createElement( 'dt', null, tr('project') ), _react2.default.createElement( 'dd', null, (0, _MwApi.getWikiHost)(ed.wiki) ) ), _react2.default.createElement( 'div', null, _react2.default.createElement( 'dt', null, tr('dates') ), _react2.default.createElement( 'dd', null, (0, _EditathonList.renderEditathonDates)(ed.start, ed.finish, translate) ) ), _react2.default.createElement( 'div', null, _react2.default.createElement( 'dt', null, tr('flags') ), _react2.default.createElement( 'dd', { className: 'flags' }, ed.flags === 0 && tr('noFlags'), (ed.flags & _jury.EditathonFlags.consensualVote) !== 0 && _react2.default.createElement( 'div', { className: 'flag consensualVote' }, translate('EditathonConfig.GeneralPage.consensualVote') ), (ed.flags & _jury.EditathonFlags.hiddenMarks) !== 0 && _react2.default.createElement( 'div', { className: 'flag hiddenMarks' }, translate('EditathonConfig.GeneralPage.hiddenMarks') ) ) ), _react2.default.createElement( 'div', null, _react2.default.createElement( 'dt', null, tr('jury') ), _react2.default.createElement( 'dd', null, ed.jury.map(function (j) { return _react2.default.createElement( 'span', { className: 'jury', key: j }, _react2.default.createElement(_WikiLink2.default, { to: 'User_talk:' + j }) ); }) ) ), _react2.default.createElement( 'div', null, _react2.default.createElement( 'dt', null, tr('rules') ), _react2.default.createElement( 'dd', null, ed.rules.map(function (rule) { return Rules.render(rule, translate); }) ) ), _react2.default.createElement( 'div', null, _react2.default.createElement( 'dt', null, tr('marks') ), _react2.default.createElement( 'dd', null, _react2.default.createElement(_MarksPreview2.default, { config: ed.marks }) ) ), _react2.default.createElement( 'div', null, _react2.default.createElement( 'dt', null, tr('template') ), _react2.default.createElement( 'dd', null, ed.template && _react2.default.createElement(_TemplatePreview2.default, { name: ed.template.name, args: ed.template.args }) || tr('noTemplate') ) ) ), _react2.default.createElement( 'div', { className: 'buttons' }, _react2.default.createElement( _WikiButton2.default, { disabled: sending, loading: sending === 'approve', type: 'constructive', onClick: function onClick() { return _this2.onApprove(ed.code); } }, tr('approve') ), _react2.default.createElement( _WikiButton2.default, { disabled: sending }, _react2.default.createElement( _Link2.default, { to: '/editathons/' + ed.code + '/config?returnTo=/personal/approval' }, tr('edit') ) ), _react2.default.createElement( _WikiButton2.default, { disabled: sending, loading: sending === 'delete', type: 'destructive', onClick: function onClick() { return _this2.onDelete(ed.code); } }, tr('delete') ) ) ); }) ) ); } }, { key: 'onApprove', value: function () { var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(code) { return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return this.exec('approve', function () { return _Api2.default.publishEditathon(code); }); case 2: case 'end': return _context2.stop(); } } }, _callee2, this); })); function onApprove(_x) { return _ref2.apply(this, arguments); } return onApprove; }() }, { key: 'onDelete', value: function () { var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(code) { return regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return this.exec('delete', function () { return _Api2.default.removeEditathon(code); }); case 2: case 'end': return _context3.stop(); } } }, _callee3, this); })); function onDelete(_x2) { return _ref3.apply(this, arguments); } return onDelete; }() }, { key: 'exec', value: function () { var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(sending, api) { return regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: this.setState({ sending: sending }); _context4.prev = 1; _context4.next = 4; return api(); case 4: this.update(); _context4.next = 10; break; case 7: _context4.prev = 7; _context4.t0 = _context4['catch'](1); alert(_context4.t0); case 10: this.setState({ sending: false }); case 11: case 'end': return _context4.stop(); } } }, _callee4, this, [[1, 7]]); })); function exec(_x3, _x4) { return _ref4.apply(this, arguments); } return exec; }() }]); return Approval; }(_react2.default.Component); exports.default = (0, _translate.withTranslation)(Approval, 'Personal.Approval'); },{"../../Api":4,"../../MwApi":61,"../../jury":65,"../../rules":69,"../../translate":73,"../EditathonList":21,"../Link":35,"../Loader":36,"../MarksPreview":41,"../TemplatePreview":52,"../WikiButton":56,"../WikiLink":57,"moment":"moment","react":"react"}],45:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _Link = require('../Link'); var _Link2 = _interopRequireDefault(_Link); var _Remote = require('../Remote'); var _Remote2 = _interopRequireDefault(_Remote); var _Api = require('../../Api'); var _Api2 = _interopRequireDefault(_Api); var _translate = require('../../translate'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Created = function Created(_ref) { var _ref$translation = _ref.translation, translate = _ref$translation.translate, tr = _ref$translation.tr; return _react2.default.createElement(_Remote2.default, { getData: _Api2.default.getCreatedEditathons, render: function render(data) { return _react2.default.createElement( 'div', { className: 'Created' }, _react2.default.createElement( 'h2', null, tr('title') ), _react2.default.createElement( 'div', { className: 'list' }, data.map(function (ed) { return _react2.default.createElement( _Link2.default, { key: ed.code, className: (0, _classnames2.default)('row', !ed.isPublished && 'draft'), to: '/editathons/' + ed.code + (ed.isPublished ? '' : '/config') }, _react2.default.createElement( 'div', { className: 'name', title: ed.name }, ed.name ), !ed.isPublished && _react2.default.createElement( 'div', { className: 'description' }, tr('draft') ) ); }) ) ); } }); }; exports.default = (0, _translate.withTranslation)(Created, 'Personal.Created'); },{"../../Api":4,"../../translate":73,"../Link":35,"../Remote":49,"classnames":"classnames","react":"react"}],46:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _moment = require('moment'); var _moment2 = _interopRequireDefault(_moment); var _Link = require('../Link'); var _Link2 = _interopRequireDefault(_Link); var _Remote = require('../Remote'); var _Remote2 = _interopRequireDefault(_Remote); var _WikiButton = require('../WikiButton'); var _WikiButton2 = _interopRequireDefault(_WikiButton); var _Api = require('../../Api'); var _Api2 = _interopRequireDefault(_Api); var _translate = require('../../translate'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Editathons = function Editathons(_ref) { var _ref$translation = _ref.translation, translate = _ref$translation.translate, tr = _ref$translation.tr; return _react2.default.createElement(_Remote2.default, { getData: _Api2.default.getMyCurrentEditathons, render: function render(data) { return _react2.default.createElement( 'div', { className: 'Editathons' }, _react2.default.createElement( 'h2', null, tr('title') ), _react2.default.createElement( 'div', { className: 'list' }, data.map(function (ed) { return _extends({}, ed, { finished: (0, _moment2.default)(ed.finish).isBefore(), hasRows: ed.rows.length !== 0 }); }).map(function (ed) { return _react2.default.createElement( 'div', { className: 'row', key: ed.code }, _react2.default.createElement( 'div', { className: 'name', title: ed.name }, _react2.default.createElement( _Link2.default, { className: 'WikiLink', to: '/editathons/' + ed.code }, ed.name ) ), _react2.default.createElement( 'div', { className: 'finish', title: translate('formatDate', ed.finish, 'LL LT') }, ed.finished ? tr('hasEnded', ed.finish) : tr('willEndIn', ed.finish) ), _react2.default.createElement( _Link2.default, { to: '/editathons/' + ed.code, className: 'details' }, ed.hasRows && _react2.default.createElement( 'div', { className: 'row header' }, _react2.default.createElement('span', { className: 'rank' }), _react2.default.createElement('span', { className: 'name' }), _react2.default.createElement('span', { className: 'total' }) ), ed.rows.map(function (r, i) { return _react2.default.createElement( 'div', { className: (0, _classnames2.default)('row', r.name === Global.user.name && 'me'), key: ed.code + '*' + i }, _react2.default.createElement( 'span', { className: 'rank' }, translate('formatNumber', r.rank) ), _react2.default.createElement( 'span', { className: 'name' }, r.name ), _react2.default.createElement( 'span', { className: 'total' }, translate('formatNumber', r.total, { places: 2 }) ) ); }), !ed.hasRows && _react2.default.createElement( 'span', { className: 'no-marks' }, ed.hiddenMarks ? tr('hiddenMarks') : tr('noMarks') ) ), !ed.finished && _react2.default.createElement( _WikiButton2.default, null, _react2.default.createElement( _Link2.default, { to: '/editathons/' + ed.code + '/add' }, translate('ArticlesList.addArticle') ) ) ); }) ) ); } }); }; exports.default = (0, _translate.withTranslation)(Editathons, 'Personal.Editathons'); },{"../../Api":4,"../../translate":73,"../Link":35,"../Remote":49,"../WikiButton":56,"classnames":"classnames","moment":"moment","react":"react"}],47:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _moment = require('moment'); var _moment2 = _interopRequireDefault(_moment); var _Link = require('../Link'); var _Link2 = _interopRequireDefault(_Link); var _Remote = require('../Remote'); var _Remote2 = _interopRequireDefault(_Remote); var _WikiButton = require('../WikiButton'); var _WikiButton2 = _interopRequireDefault(_WikiButton); var _Api = require('../../Api'); var _Api2 = _interopRequireDefault(_Api); var _translate = require('../../translate'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Jury = function Jury(_ref) { var _ref$translation = _ref.translation, translate = _ref$translation.translate, tr = _ref$translation.tr; return _react2.default.createElement(_Remote2.default, { getData: _Api2.default.getJuryEditathons, render: function render(data) { return _react2.default.createElement( 'div', { className: 'Jury' }, _react2.default.createElement( 'h2', null, tr('title') ), _react2.default.createElement( 'div', { className: 'list' }, data.map(function (ed) { return _react2.default.createElement( _Link2.default, { className: 'row', key: ed.code, to: '/jury/' + ed.code }, _react2.default.createElement( 'div', { className: 'details' }, _react2.default.createElement( 'div', { className: 'name', title: ed.name }, ed.name ), _react2.default.createElement( 'div', { className: 'finish', title: translate('formatDate', ed.finish, 'LL LT') }, (0, _moment2.default)(ed.finish).isBefore() ? tr('hasEnded', ed.finish) : tr('willEndIn', ed.finish) ) ), _react2.default.createElement( 'div', { className: (0, _classnames2.default)('marks', !ed.missing && 'marks-zero') }, _react2.default.createElement( 'span', null, ed.missing ) ) ); }) ) ); } }); }; exports.default = (0, _translate.withTranslation)(Jury, 'Personal.Jury'); },{"../../Api":4,"../../translate":73,"../Link":35,"../Remote":49,"../WikiButton":56,"classnames":"classnames","moment":"moment","react":"react"}],48:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.routes = undefined; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _resolvePathname = require('resolve-pathname'); var _resolvePathname2 = _interopRequireDefault(_resolvePathname); var _routerUtils = require('../../routerUtils'); var _translate = require('../../translate'); var _url = require('../../url'); var _url2 = _interopRequireDefault(_url); var _Link = require('../Link'); var _Link2 = _interopRequireDefault(_Link); var _Editathons = require('./Editathons'); var _Editathons2 = _interopRequireDefault(_Editathons); var _Jury = require('./Jury'); var _Jury2 = _interopRequireDefault(_Jury); var _Created = require('./Created'); var _Created2 = _interopRequireDefault(_Created); var _Approval = require('./Approval'); var _Approval2 = _interopRequireDefault(_Approval); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Tabs = { editathons: _Editathons2.default, jury: _Jury2.default, created: _Created2.default, approval: _Approval2.default }; var Personal = function (_React$Component) { _inherits(Personal, _React$Component); function Personal() { _classCallCheck(this, Personal); return _possibleConstructorReturn(this, (Personal.__proto__ || Object.getPrototypeOf(Personal)).apply(this, arguments)); } _createClass(Personal, [{ key: 'componentWillMount', value: function componentWillMount() { if (!Global.user) { this.context.router.replace({ pathname: (0, _url2.default)('/') }); } } }, { key: 'render', value: function render() { var _props = this.props, children = _props.children, location = _props.location, tr = _props.translation.tr; return _react2.default.createElement( 'div', { className: 'Personal mainContentPane' }, _react2.default.createElement( 'h1', null, tr('title') ), _react2.default.createElement( 'div', { className: 'content' }, _react2.default.createElement( 'nav', { className: 'tabs' }, Object.keys(Tabs).map(function (path) { return { path: path, active: location.pathname.endsWith(path) }; }).map(function (_ref) { var path = _ref.path, active = _ref.active; return _react2.default.createElement( 'div', { key: path, className: (0, _classnames2.default)({ tab: true, active: active }) }, _react2.default.createElement( _Link2.default, { replace: true, to: active ? null : (0, _resolvePathname2.default)('./' + path, (0, _url.unUrl)(location.pathname)) }, tr(path) ) ); }) ), _react2.default.createElement( 'div', { className: 'content' }, children ) ) ); } }], [{ key: 'contextTypes', get: function get() { return { router: _react2.default.PropTypes.object.isRequired }; } }]); return Personal; }(_react2.default.Component); Personal = (0, _translate.withTranslation)(Personal, 'Personal'); var routes = exports.routes = (0, _routerUtils.getRoutes)('personal', Personal, Tabs); },{"../../routerUtils":68,"../../translate":73,"../../url":96,"../Link":35,"./Approval":44,"./Created":45,"./Editathons":46,"./Jury":47,"classnames":"classnames","react":"react","resolve-pathname":"resolve-pathname"}],49:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _Loader = require('./Loader'); var _Loader2 = _interopRequireDefault(_Loader); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Remote = function (_React$Component) { _inherits(Remote, _React$Component); function Remote(props) { _classCallCheck(this, Remote); var _this = _possibleConstructorReturn(this, (Remote.__proto__ || Object.getPrototypeOf(Remote)).call(this, props)); _this.state = { data: null }; return _this; } _createClass(Remote, [{ key: 'componentDidMount', value: function () { var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: this.update(this.props.getData); case 1: case 'end': return _context.stop(); } } }, _callee, this); })); function componentDidMount() { return _ref.apply(this, arguments); } return componentDidMount; }() }, { key: 'update', value: function update() { return this._update(this.props.getData); } }, { key: '_update', value: function () { var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(getData) { return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: if (getData) { _context2.next = 2; break; } return _context2.abrupt('return', false); case 2: _context2.t0 = this; _context2.next = 5; return getData(); case 5: _context2.t1 = _context2.sent; _context2.t2 = { data: _context2.t1 }; _context2.t0.setState.call(_context2.t0, _context2.t2); return _context2.abrupt('return', true); case 9: case 'end': return _context2.stop(); } } }, _callee2, this); })); function _update(_x) { return _ref2.apply(this, arguments); } return _update; }() }, { key: 'componentWillReceiveProps', value: function componentWillReceiveProps(_ref3) { var getData = _ref3.getData; this.update(getData); } }, { key: 'render', value: function render() { var _props = this.props, children = _props.children, render = _props.render, _props$propName = _props.propName, propName = _props$propName === undefined ? 'data' : _props$propName; var data = this.state.data; if (!children && !render) return null; if (!data) return _react2.default.createElement(_Loader2.default, null); if (render) { return render(data); } else { return _react2.default.cloneElement(children, _defineProperty({}, propName, data)); } } }]); return Remote; }(_react2.default.Component); exports.default = Remote; },{"./Loader":36,"react":"react"}],50:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _ModalDialog = require('./ModalDialog'); var _ModalDialog2 = _interopRequireDefault(_ModalDialog); var _WikiButton = require('./WikiButton'); var _WikiButton2 = _interopRequireDefault(_WikiButton); var _translate = require('./../translate'); var _url = require('./../url'); var _url2 = _interopRequireDefault(_url); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var RequiresLogin = function (_React$Component) { _inherits(RequiresLogin, _React$Component); function RequiresLogin(props) { _classCallCheck(this, RequiresLogin); var _this = _possibleConstructorReturn(this, (RequiresLogin.__proto__ || Object.getPrototypeOf(RequiresLogin)).call(this, props)); _this.state = { needLogin: false }; return _this; } _createClass(RequiresLogin, [{ key: 'onClickCapture', value: function onClickCapture(e) { if (!Global.user && !this.state.needLogin) { this.setState({ needLogin: true }); e.preventDefault(); e.stopPropagation(); } } }, { key: 'render', value: function render() { var _this2 = this; var _props = this.props, className = _props.className, children = _props.children, redirectTo = _props.redirectTo, tr = _props.translation.tr; return _react2.default.createElement( 'div', { onClickCapture: function onClickCapture(e) { return _this2.onClickCapture(e); }, className: (0, _classnames2.default)(['RequiresLogin', className]) }, _react2.default.createElement( _ModalDialog2.default, { isOpen: this.state.needLogin, className: 'needLogin' }, _react2.default.createElement( 'div', { className: 'message' }, tr('title') ), _react2.default.createElement( 'div', { className: 'buttons' }, _react2.default.createElement( _WikiButton2.default, { type: 'progressive' }, _react2.default.createElement( 'a', { href: (0, _url2.default)('/login?redirectTo=' + ((0, _url2.default)(redirectTo) || window.location.pathname)) }, tr('ok') ) ), _react2.default.createElement( _WikiButton2.default, { onClick: function onClick() { return _this2.setState({ needLogin: false }); } }, tr('cancel') ) ) ), children ); } }]); return RequiresLogin; }(_react2.default.Component); exports.default = (0, _translate.withTranslation)(RequiresLogin, 'SignInWarning'); },{"./../translate":73,"./../url":96,"./ModalDialog":42,"./WikiButton":56,"classnames":"classnames","react":"react"}],51:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = SendReportButton; var _fileSaver = require('file-saver'); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _telemetry = require('../telemetry'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function SendReportButton() { return _react2.default.createElement( 'button', { className: 'SendReportButton', onClick: onClick }, 'Technical Information.' ); } function onClick() { var blob = new Blob([JSON.stringify((0, _telemetry.getTelemetry)())], { type: 'application/octet-stream;charset=utf-8' }); (0, _fileSaver.saveAs)(blob, 'report'); } },{"../telemetry":71,"file-saver":"file-saver","react":"react"}],52:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = TemplatePreview; var _react = require('react'); var _react2 = _interopRequireDefault(_react); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function TemplatePreview(_ref) { var name = _ref.name, args = _ref.args, labelFor = _ref.labelFor; return _react2.default.createElement( 'div', { className: 'TemplatePreview' }, renderTemplate(name, args, labelFor) ); } function renderTemplate(name, args, labelFor) { var parts = []; var add = function add(text, id, isName) { var props = { key: parts.length - 1 }; if (id !== undefined) { props.className = 'label'; if (labelFor) { props.htmlFor = labelFor(id, isName); props.className += ' clickable'; } } parts.push(_react2.default.createElement(id !== undefined ? 'label' : 'span', props, text)); }; add('{{'); add(name, null); for (var id in args) { var arg = args[id]; add('|'); if (arg.name) { add(arg.name, id, true); add('='); } add(arg.value, id, false); } add('}}'); return parts; } },{"react":"react"}],53:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Tooltip; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function Tooltip(_ref) { var children = _ref.children, className = _ref.className, _ref$onTop = _ref.onTop, onTop = _ref$onTop === undefined ? false : _ref$onTop; return _react2.default.createElement( 'div', { className: (0, _classnames2.default)('Tooltip', className) }, _react2.default.createElement( 'div', { className: (0, _classnames2.default)('content', onTop ? 'top' : 'bottom') }, children ) ); } },{"classnames":"classnames","react":"react"}],54:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _MwApi = require('./../MwApi'); var _LookupWithThrottle = require('./LookupWithThrottle'); function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } exports.default = (0, _LookupWithThrottle.createLookup)('UserLookup', function () { var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(value, _ref2) { var wiki = _ref2.wiki; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: value = (value || '').trim(); if (value) { _context.next = 3; break; } return _context.abrupt('return', []); case 3: _context.next = 5; return (0, _MwApi.getMwApi)(wiki).lookupUser(value); case 5: return _context.abrupt('return', _context.sent); case 6: case 'end': return _context.stop(); } } }, _callee, this); })); function lookup(_x, _x2) { return _ref.apply(this, arguments); } return lookup; }()); },{"./../MwApi":61,"./LookupWithThrottle":37}],55:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _moment = require('moment'); var _moment2 = _interopRequireDefault(_moment); var _WikiLink = require('./WikiLink'); var _WikiLink2 = _interopRequireDefault(_WikiLink); var _sortBy = require('./../sortBy'); var _sortBy2 = _interopRequireDefault(_sortBy); var _rules = require('./../rules'); var _translate = require('./../translate'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var log = function log(a) { console.log(a);return a; }; var RuleMessages = { submitterRegistered: function submitterRegistered(_ref) { var tr = _ref.tr, rule = _ref.rule, ok = _ref.ok; return !ok && tr('submitterRegistered', rule.params.after) || null; }, namespace: function namespace(_ref2) { var tr = _ref2.tr, rule = _ref2.rule, ok = _ref2.ok; return tr('namespace', ok); }, submitterIsCreator: function submitterIsCreator(_ref3) { var tr = _ref3.tr, rule = _ref3.rule, ok = _ref3.ok, stats = _ref3.stats, wiki = _ref3.wiki; return [tr('author'), _react2.default.createElement(_WikiLink2.default, { key: 'link', to: 'User:' + stats.creator, wiki: wiki })]; }, articleCreated: function articleCreated(_ref4) { var tr = _ref4.tr, rule = _ref4.rule, ok = _ref4.ok, stats = _ref4.stats; return tr('articleCreated', (0, _moment2.default)(stats.created).utc()); }, articleSize: function articleSize(_ref5) { var tr = _ref5.tr, translate = _ref5.translate, rule = _ref5.rule, ok = _ref5.ok, stats = _ref5.stats; return [rule.params.bytes && tr('bytes', stats.bytes), rule.params.chars && tr('chars', stats.chars), rule.params.words && tr('words', stats.words)].filter(function (x) { return x; }).join(translate('delimiter')); }, addedForCleanupRu: function addedForCleanupRu(_ref6) { var tr = _ref6.tr, rule = _ref6.rule, ok = _ref6.ok, stats = _ref6.stats, wiki = _ref6.wiki; var _tr = tr('addedForCleanupRu', stats.addedForCleanupRu.date), _tr2 = _slicedToArray(_tr, 3), prefix = _tr2[0], link = _tr2[1], suffix = _tr2[2]; return [prefix, _react2.default.createElement( _WikiLink2.default, { key: 'link', wiki: wiki, to: stats.addedForCleanupRu.date ? '?oldid=' + stats.addedForCleanupRu.revId + '&diff=cur' : stats.title + '?action=history' }, link ), suffix]; } }; function renderStat(key, name, isOk, isCritical) { return !name ? undefined : _react2.default.createElement( 'div', { key: key, className: (0, _classnames2.default)({ stat: true, error: !isOk && isCritical, warning: !isOk && !isCritical }) }, name ); } function Warnings(_ref7) { var rules = _ref7.rules, ctx = _ref7.ctx, stats = _ref7.stats, wiki = _ref7.wiki, translation = _ref7.translation; return _react2.default.createElement( 'div', { className: 'Warnings' }, rules.map(function (rule) { return [rule, rule.check(stats, ctx)]; }).sort((0, _sortBy2.default)( // sorting by result (error, warning, ok), then by type function (_ref8) { var _ref9 = _slicedToArray(_ref8, 2), rule = _ref9[0], result = _ref9[1]; return result; }, function (_ref10) { var _ref11 = _slicedToArray(_ref10, 2), rule = _ref11[0], result = _ref11[1]; return result || rule.flags & _rules.RuleFlags.optional; }, function (_ref12) { var _ref13 = _slicedToArray(_ref12, 2), rule = _ref13[0], result = _ref13[1]; return rule.type; })).map(function (_ref14, i) { var _ref15 = _slicedToArray(_ref14, 2), rule = _ref15[0], result = _ref15[1]; return renderStat(i, RuleMessages[rule.type]({ rule: rule, stats: stats, wiki: wiki, ok: result, tr: translation.tr, translate: translation.translate }), result, !(rule.flags & _rules.RuleFlags.optional)); }) ); } exports.default = (0, _translate.withTranslation)(Warnings, 'AddArticle.Warnings'); },{"./../rules":69,"./../sortBy":70,"./../translate":73,"./WikiLink":57,"classnames":"classnames","moment":"moment","react":"react"}],56:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } function WikiButton(_ref) { var type = _ref.type, children = _ref.children, className = _ref.className, submit = _ref.submit, loading = _ref.loading, props = _objectWithoutProperties(_ref, ['type', 'children', 'className', 'submit', 'loading']); var element = _react2.default.createElement('button', { type: submit ? 'submit' : 'button' }); if (!props.disabled && _react2.default.isValidElement(children)) { element = children; children = element.props.children; } return _react2.default.cloneElement(element, Object.assign({ children: children }, props, { className: (0, _classnames2.default)(['WikiButton', type, className, loading && 'loading']), disabled: loading || props.disabled || false }), children); } WikiButton.propTypes = { children: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.string, _react2.default.PropTypes.element]), type: _react2.default.PropTypes.string, submit: _react2.default.PropTypes.bool }; exports.default = WikiButton; },{"classnames":"classnames","react":"react"}],57:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; exports.default = function (_ref) { var _classNames; var to = _ref.to, _ref$wiki = _ref.wiki, wiki = _ref$wiki === undefined ? 'meta' : _ref$wiki, children = _ref.children, className = _ref.className, red = _ref.red, props = _objectWithoutProperties(_ref, ['to', 'wiki', 'children', 'className', 'red']); return _react2.default.createElement( 'a', _extends({}, props, { className: (0, _classnames2.default)((_classNames = { 'WikiLink': true }, _defineProperty(_classNames, className, className), _defineProperty(_classNames, 'red', red), _classNames)), href: (0, _MwApi.getArticleUrl)(wiki, to) }), children || withoutNS(to) ); }; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _MwApi = require('./../MwApi'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } function withoutNS(to) { return to.replace(/(.*:)?(.*)/, '$2'); } },{"./../MwApi":61,"classnames":"classnames","react":"react"}],58:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactAutocomplete = require('react-autocomplete'); var _reactAutocomplete2 = _interopRequireDefault(_reactAutocomplete); var _MwApi = require('./../MwApi'); var _sortBy = require('./../sortBy'); var _sortBy2 = _interopRequireDefault(_sortBy); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var MaxItems = 10; var WikiLookup = function (_React$Component) { _inherits(WikiLookup, _React$Component); function WikiLookup(props) { _classCallCheck(this, WikiLookup); var _this = _possibleConstructorReturn(this, (WikiLookup.__proto__ || Object.getPrototypeOf(WikiLookup)).call(this, props)); _this.state = { text: props.value || '', items: [], filteredItems: [] }; _this.init(); _this.value = props.value; return _this; } _createClass(WikiLookup, [{ key: 'init', value: function () { var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { var _this2 = this; var matrix, items; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _context.next = 2; return (0, _MwApi.getSiteMatrix)(); case 2: matrix = _context.sent; items = matrix.map(function (lang) { return lang.sites.map(function (s) { return { code: s.code, name: s.name, lang: { code: lang.code, name: lang.name || '' } }; }); }).reduce(function (a1, a2) { return a1.concat(a2); }, [{ code: null, name: '', lang: { code: 'commons', name: 'commons' } }]); this.setState(function (state) { return { items: items, filteredItems: _this2.filter(state.text, items) }; }); case 5: case 'end': return _context.stop(); } } }, _callee, this); })); function init() { return _ref.apply(this, arguments); } return init; }() }, { key: 'componentWillReceiveProps', value: function componentWillReceiveProps(newProps) { var _this3 = this; console.log(newProps, this.props); if (newProps.value != this.value) { this.value = newProps.value; var text = newProps.value || ''; this.setState(function (state) { return { text: text, filteredItems: _this3.filter(text, state.items) }; }); } } }, { key: 'renderItem', value: function renderItem(item, selected, styles) { return _react2.default.createElement( 'tr', { className: (0, _classnames2.default)({ item: true, selected: selected }), key: this.getItemCode(item) }, _react2.default.createElement( 'td', null, this.getItemCode(item) ), _react2.default.createElement( 'td', null, item.name ), _react2.default.createElement( 'td', null, item.lang.name ) ); } }, { key: 'getItemCode', value: function getItemCode(item) { return item.code === null ? item.lang.code : item.code + ':' + item.lang.code; } }, { key: 'renderMenu', value: function renderMenu(items, value, style) { if (!items.length) { return _react2.default.createElement('div', null); } var more = this.state.filteredItems.length > MaxItems; return _react2.default.createElement( 'div', { className: 'popup-container' }, _react2.default.createElement( 'div', { className: 'popup', style: { minWidth: style.minWidth } }, _react2.default.createElement( 'table', null, _react2.default.createElement( 'thead', null, _react2.default.createElement( 'tr', null, _react2.default.createElement( 'th', null, '\u043A\u043E\u0434' ), _react2.default.createElement( 'th', null, '\u043D\u0430\u0437\u0432\u0430\u043D\u0438\u0435' ), _react2.default.createElement( 'th', null, '\u044F\u0437\u044B\u043A' ) ) ), _react2.default.createElement( 'tbody', null, items ), more && _react2.default.createElement( 'tbody', null, _react2.default.createElement( 'tr', { className: 'item' }, _react2.default.createElement( 'td', { colSpan: 3 }, '...' ) ) ) ) ) ); } }, { key: 'matchItem', value: function matchItem(item, text) { if (text.length < 1) return false; return this.getItemCode(item).indexOf(text) !== -1 || item.name.toLowerCase().indexOf(text) === 0 || item.lang.name.toLowerCase().indexOf(text) === 0; } }, { key: 'sortItems', value: function sortItems(a, b, text) { return (0, _sortBy2.default)(function (x) { return x.code === text ? 0 : 1; }, function (x) { return x.lang.code === text ? 0 : 1; }, function (x) { return x.lang.code; }, function (x) { return x.code; })(a, b); } }, { key: 'filter', value: function filter(text, items) { var _this4 = this; text = text.toLowerCase(); return items.filter(function (i) { return _this4.matchItem(i, text); }).sort(function (a, b) { return _this4.sortItems(a, b, text); }); } }, { key: 'onChange', value: function onChange(text, item) { var _this5 = this; this.setState(function (state) { return { text: text, filteredItems: _this5.filter(text, state.items) }; }); if (item && this.props.onChange) { this.props.onChange(item && this.getItemCode(item) || null); } } }, { key: 'onBlur', value: function onBlur(e) { this.setState({ text: this.props.value || '' }); this.props.inputProps && this.props.inputProps.onBlur && this.props.inputProps.onBlur(e); } }, { key: 'render', value: function render() { var _this6 = this; return _react2.default.createElement(_reactAutocomplete2.default, { wrapperProps: { className: 'WikiLookup' }, inputProps: _extends({}, this.props.inputProps, { onBlur: function onBlur(e) { return _this6.onBlur(e); } }), value: this.state.text, items: [].concat(_toConsumableArray(this.state.filteredItems)).slice(0, MaxItems), getItemValue: this.getItemCode, renderItem: this.renderItem.bind(this), renderMenu: this.renderMenu.bind(this), onSelect: function onSelect(text, item) { return _this6.onChange(text, item); }, onChange: function onChange(event, text) { return _this6.onChange(text); } }); } }]); return WikiLookup; }(_react2.default.Component); exports.default = WikiLookup; },{"./../MwApi":61,"./../sortBy":70,"classnames":"classnames","react":"react","react-autocomplete":"react-autocomplete"}],59:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; exports.bind = bind; exports.createSetter = createSetter; exports.createBinder = createBinder; exports.setDefault = setDefault; exports.createSubSection = createSubSection; var _react = require('react'); var _react2 = _interopRequireDefault(_react); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function bind(comp, get, set) { var _React$cloneElement; var value = get(); var prop = 'value'; var onChange = void 0; if (comp.type === 'input' && comp.props.type === 'checkbox') { onChange = function onChange(e) { return set(e.target.checked); }; prop = 'checked'; value = value || false; } else if (comp.type === 'input' && comp.props.type === 'radio') { onChange = function onChange(e) { return set(comp.props.value); }; prop = 'checked'; value = value === comp.props.value; } else if (comp.type === 'input' || comp.type === 'textarea') { onChange = function onChange(e) { return set(e.target.value); }; value = value || ''; } else { onChange = function onChange(v) { return set(v); }; } return _react2.default.cloneElement(comp, (_React$cloneElement = {}, _defineProperty(_React$cloneElement, prop, value), _defineProperty(_React$cloneElement, 'onChange', onChange), _React$cloneElement)); } function setProp(me, prop, value, valueProp) { me.props.onChange(_extends({}, me.props[valueProp] || {}, _defineProperty({}, prop, value))); } function isObjectEmpty(obj) { return obj.constructor === Object && Object.keys(obj).length === 0; } function createSetter() { var valueProp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'value'; return function set(prop, value) { return setProp(this, prop, value, valueProp); }; } function createBinder() { var valueProp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'value'; var bindProp = bind; return function bind(prop, component, onChange) { var _this = this; return bindProp(component, function () { var value = _this.props[valueProp]; return value && value[prop]; }, function (v) { onChange && onChange(v); setProp(_this, prop, v, valueProp); }); }; } function setDefault(props, prop, getDefault) { var valueProp = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'value'; if (getDefault === undefined) { getDefault = prop; prop = null; } var onChange = props.onChange; var _props$valueProp = props[valueProp], value = _props$valueProp === undefined ? {} : _props$valueProp; if (prop !== null) { value = value[prop] || {}; } if (onChange && isObjectEmpty(value)) { value = getDefault(); if (prop !== null) { onChange(_extends({}, props[valueProp], _defineProperty({}, prop, value))); } else { onChange(value); } } } function createSubSection(parent, prop) { var valueProp = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'value'; var childValueProp = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'value'; function onChange(v) { var value = _extends({}, parent.props[valueProp]); value[prop] = v; parent.props.onChange(value); } return { get props() { var _ref; return _ref = {}, _defineProperty(_ref, childValueProp, parent.props[valueProp][prop]), _defineProperty(_ref, 'onChange', onChange), _ref; }, bind: createBinder(childValueProp), set: createSetter(childValueProp) }; } },{"react":"react"}],60:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.WikiText = exports.WikiHtml = undefined; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _Api = require('../Api'); var _Api2 = _interopRequireDefault(_Api); var _MwApi = require('../MwApi'); var _throttle = require('../throttle'); var _throttle2 = _interopRequireDefault(_throttle); var _translate = require('../translate'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var BrowserSupportsSrcDoc = document && !!("srcdoc" in document.createElement("iframe")); var IFrame = function (_React$Component) { _inherits(IFrame, _React$Component); function IFrame(props) { _classCallCheck(this, IFrame); var _this = _possibleConstructorReturn(this, (IFrame.__proto__ || Object.getPrototypeOf(IFrame)).call(this, props)); _this.onMessage = _this.onMessage.bind(_this); _this._id = Math.random().toString(); return _this; } _createClass(IFrame, [{ key: 'componentDidMount', value: function componentDidMount() { window.addEventListener('message', this.onMessage, false); if (!BrowserSupportsSrcDoc && this._iframe) { var doc = this._iframe.contentWindow.document; doc.open(); doc.write(this.getHtml()); doc.close(); } } }, { key: 'componentWillUnmount', value: function componentWillUnmount() { window.removeEventListener('message', this.onMessage, false); } }, { key: 'onMessage', value: function onMessage(_ref) { var _ref$data = _ref.data, id = _ref$data.id, height = _ref$data.height; if (id === this._id && this._iframe) { this._iframe.style.height = height + 'px'; } } }, { key: 'getScript', value: function getScript() { return '\n\n'; } }, { key: 'getHtml', value: function getHtml() { var _props = this.props, html = _props.html, _props$autoSize = _props.autoSize, autoSize = _props$autoSize === undefined ? false : _props$autoSize; if (typeof html !== 'function') { return html; } return html(autoSize ? this.getScript() : ''); } }, { key: 'render', value: function render() { var _this2 = this; var _props2 = this.props, className = _props2.className, _props2$sandbox = _props2.sandbox, sandbox = _props2$sandbox === undefined ? 'allow-popups allow-scripts' : _props2$sandbox, autoSize = _props2.autoSize; return _react2.default.createElement('iframe', { ref: function ref(x) { return _this2._iframe = x; }, className: (0, _classnames2.default)('IFrame', autoSize && 'autoSize', className), scrolling: autoSize ? 'no' : undefined, sandbox: BrowserSupportsSrcDoc ? sandbox : undefined, srcDoc: BrowserSupportsSrcDoc ? this.getHtml() || '' : undefined }); } }]); return IFrame; }(_react2.default.Component); function WikiHtml(_ref2) { var _html = _ref2.html, preHtml = _ref2.preHtml, wiki = _ref2.wiki, title = _ref2.title, className = _ref2.className, translation = _ref2.translation, _ref2$padding = _ref2.padding, padding = _ref2$padding === undefined ? true : _ref2$padding, _ref2$autoSize = _ref2.autoSize, autoSize = _ref2$autoSize === undefined ? false : _ref2$autoSize; return _react2.default.createElement(IFrame, { className: (0, _classnames2.default)('WikiHtml', className), autoSize: autoSize, html: function html(script) { return '\n\n\n\n \n \n \n \n\n ' + (preHtml || '') + '\n
\n ' + _html + '\n
\n ' + script + '\n \n\n\n'; } }); } exports.WikiHtml = WikiHtml = (0, _translate.withTranslation)(WikiHtml); exports.WikiHtml = WikiHtml; var WikiText = exports.WikiText = function (_React$Component2) { _inherits(WikiText, _React$Component2); function WikiText(props) { _classCallCheck(this, WikiText); var _this3 = _possibleConstructorReturn(this, (WikiText.__proto__ || Object.getPrototypeOf(WikiText)).call(this, props)); _this3.preview = (0, _throttle2.default)(_this3.preview.bind(_this3), 1000); _this3.state = { html: '', loading: false }; _this3._seq = 0; return _this3; } _createClass(WikiText, [{ key: 'componentWillReceiveProps', value: function componentWillReceiveProps(_ref3) { var text = _ref3.text; if (text !== this.props.text) { this.update(); } } }, { key: 'componentWillMount', value: function componentWillMount() { this.update(); } }, { key: 'componentWillUnmount', value: function componentWillUnmount() { this.preview.cancel(); } }, { key: 'update', value: function update() { this.setState({ loading: true }); this.preview(); } }, { key: 'preview', value: function () { var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { var _props3, wiki, text, title, id, html; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _props3 = this.props, wiki = _props3.wiki, text = _props3.text, title = _props3.title; if (!(!wiki || !text)) { _context.next = 4; break; } this.setState({ html: '', loading: false }); return _context.abrupt('return'); case 4: id = ++this._seq; _context.next = 7; return _Api2.default.parse(wiki, text, title); case 7: html = _context.sent; if (id === this._seq) { this.setState({ html: html, loading: false }); } case 9: case 'end': return _context.stop(); } } }, _callee, this); })); function preview() { return _ref4.apply(this, arguments); } return preview; }() }, { key: 'render', value: function render() { var _props4 = this.props, className = _props4.className, text = _props4.text, props = _objectWithoutProperties(_props4, ['className', 'text']); var _state = this.state, loading = _state.loading, html = _state.html; return _react2.default.createElement( 'div', { className: (0, _classnames2.default)('WikiText', loading && 'loading', className) }, html && _react2.default.createElement(WikiHtml, _extends({ html: html }, props)) ); } }]); return WikiText; }(_react2.default.Component); },{"../Api":4,"../MwApi":61,"../throttle":72,"../translate":73,"classnames":"classnames","react":"react"}],61:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.getSiteMatrix = undefined; var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); var getSiteMatrix = exports.getSiteMatrix = function () { var _ref15 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9() { var matrix, map, results, i, lang, result; return regeneratorRuntime.wrap(function _callee9$(_context9) { while (1) { switch (_context9.prev = _context9.next) { case 0: _context9.next = 2; return getMwApi('meta').exec({ action: 'sitematrix', smsiteprop: 'code|sitename', maxage: 30 * 24 * 60 * 60 }); case 2: matrix = _context9.sent; delete matrix.sitematrix.count; delete matrix.sitematrix.specials; map = { 'wiki': null, 'wikiquote': 'q', 'wikisource': 's', 'wikibooks': 'b', 'wikinews': 'n', 'wikiversity': 'v', 'wikivoyage': 'voy', 'wiktionary': 'wikt' }; results = []; _context9.t0 = regeneratorRuntime.keys(matrix.sitematrix); case 8: if ((_context9.t1 = _context9.t0()).done) { _context9.next = 18; break; } i = _context9.t1.value; lang = matrix.sitematrix[i]; if (!(lang.site === undefined)) { _context9.next = 14; break; } console.log(lang); return _context9.abrupt('continue', 8); case 14: result = { code: lang.code, name: lang.name, sites: lang.site.filter(function (s) { return s.private === undefined && s.closed === undefined && s.fishbowl === undefined && s.code in map; }).map(function (s) { return { code: map[s.code], name: s.sitename }; }) }; if (result.sites.length) { results.push(result); } _context9.next = 8; break; case 18: return _context9.abrupt('return', results); case 19: case 'end': return _context9.stop(); } } }, _callee9, this); })); return function getSiteMatrix() { return _ref15.apply(this, arguments); }; }(); exports.getWikiHost = getWikiHost; exports.getArticleUrl = getArticleUrl; exports.default = MwApi; exports.getMwApi = getMwApi; var _package = require('./../package.json'); var _package2 = _interopRequireDefault(_package); var _telemetry = require('./telemetry.js'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } var wikisMap = [['meta', 'meta.wikimedia.org'], ['commons', 'commons.wikimedia.org'], [/^([a-z0-9\-]+)$/, '$1.wikipedia.org'], [/^q:([a-z0-9\-]+)$/, '$1.wikiquote.org'], [/^s:([a-z0-9\-]+)$/, '$1.wikisource.org'], [/^b:([a-z0-9\-]+)$/, '$1.wikibooks.org'], [/^n:([a-z0-9\-]+)$/, '$1.wikinews.org'], [/^v:([a-z0-9\-]+)$/, '$1.wikiversity.org'], [/^voy:([a-z0-9\-]+)$/, '$1.wikivoyage.org'], [/^wikt:([a-z0-9\-]+)$/, '$1.wiktionary.org']]; function getWikiHost(wiki) { var _iteratorNormalCompletion = true; var _didIteratorError = false; var _iteratorError = undefined; try { for (var _iterator = wikisMap[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { var _step$value = _slicedToArray(_step.value, 2), key = _step$value[0], value = _step$value[1]; if (key === wiki) { return value; } else if (key instanceof RegExp && key.test(wiki)) { return wiki.replace(key, value); } } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally { try { if (!_iteratorNormalCompletion && _iterator.return) { _iterator.return(); } } finally { if (_didIteratorError) { throw _iteratorError; } } } throw new Error('Unknown wiki \'' + wiki + '\'.'); } function getArticleUrl(wiki) { var to = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; wiki = getWikiHost(wiki); return 'https://' + wiki + '/wiki/' + to; } function MwApi(url) { var exec = function () { var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(params) { var data, k, headers, _ref2, response, log, body; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: params = Object.assign({}, { format: 'json', formatversion: 2, origin: '*' }, params); data = new URLSearchParams(); for (k in params) { data.append(k, params[k]); }headers = new Headers({ // causes OPTIONS request, making it twice as slow // 'Api-User-Agent': `${pkg.name}/${pkg.version}`, }); _context.next = 6; return (0, _telemetry.logFetch)(url + '?' + data, { method: 'GET', headers: headers }); case 6: _ref2 = _context.sent; response = _ref2.response; log = _ref2.log; _context.next = 11; return response.json(); case 11: body = _context.sent; (0, _telemetry.logResponseBody)(log, body); return _context.abrupt('return', body); case 14: case 'end': return _context.stop(); } } }, _callee, this); })); return function exec(_x2) { return _ref.apply(this, arguments); }; }(); this.exec = exec; this.lookup = function () { var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(title) { var ns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; var response; return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return exec({ action: 'opensearch', search: title, namespace: ns, limit: 10, redirects: 'resolve' }); case 2: response = _context2.sent; return _context2.abrupt('return', response[1]); case 4: case 'end': return _context2.stop(); } } }, _callee2, this); })); function lookup(_x3) { return _ref3.apply(this, arguments); } return lookup; }(); this.lookupUser = function () { var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(text) { var _ref5, allusers; return regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return exec({ action: 'query', list: 'allusers', auprefix: text.slice(0, 1).toUpperCase() + text.slice(1), auwitheditsonly: true }); case 2: _ref5 = _context3.sent; allusers = _ref5.query.allusers; return _context3.abrupt('return', allusers.map(function (u) { return u.name; })); case 5: case 'end': return _context3.stop(); } } }, _callee3, this); })); function lookupUser(_x5) { return _ref4.apply(this, arguments); } return lookupUser; }(); this.getPageHtml = function () { var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(title) { var response; return regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: _context4.next = 2; return exec({ action: 'parse', page: title, prop: 'text' }); case 2: response = _context4.sent; return _context4.abrupt('return', response.parse.text); case 4: case 'end': return _context4.stop(); } } }, _callee4, this); })); function getPageHtml(_x6) { return _ref6.apply(this, arguments); } return getPageHtml; }(); this.getUserGender = function () { var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(name) { var _ref8, _ref8$query$users, _ref8$query$users$0$g, gender; return regeneratorRuntime.wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: _context5.next = 2; return exec({ action: 'query', list: 'users', ususers: name, usprop: 'gender' }); case 2: _ref8 = _context5.sent; _ref8$query$users = _slicedToArray(_ref8.query.users, 1); _ref8$query$users$0$g = _ref8$query$users[0].gender; gender = _ref8$query$users$0$g === undefined ? 'unknown' : _ref8$query$users$0$g; return _context5.abrupt('return', gender); case 7: case 'end': return _context5.stop(); } } }, _callee5, this); })); function getUserGender(_x7) { return _ref7.apply(this, arguments); } return getUserGender; }(); // returns undefined if user is not found // returns null if reg date is unknown this.getUserRegDate = function () { var _ref9 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(name) { var _ref10, _ref10$query$users, registration; return regeneratorRuntime.wrap(function _callee6$(_context6) { while (1) { switch (_context6.prev = _context6.next) { case 0: _context6.next = 2; return exec({ action: 'query', list: 'users', ususers: name, usprop: 'registration' }); case 2: _ref10 = _context6.sent; _ref10$query$users = _slicedToArray(_ref10.query.users, 1); registration = _ref10$query$users[0].registration; return _context6.abrupt('return', registration); case 6: case 'end': return _context6.stop(); } } }, _callee6, this); })); function getUserRegDate(_x8) { return _ref9.apply(this, arguments); } return getUserRegDate; }(); this.getNamespaces = function () { var _ref11 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() { var result, all, ns, id, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _ref13, _id2, alias, _id; return regeneratorRuntime.wrap(function _callee7$(_context7) { while (1) { switch (_context7.prev = _context7.next) { case 0: _context7.next = 2; return exec({ action: 'query', meta: 'siteinfo', siprop: 'namespaces|namespacealiases', maxage: 30 * 24 * 60 * 60 }); case 2: result = _context7.sent; all = {}; ns = result.query.namespaces; for (id in ns) { all[id] = new Set([ns[id].name, ns[id].canonical].filter(function (x) { return x !== undefined; })); } _iteratorNormalCompletion2 = true; _didIteratorError2 = false; _iteratorError2 = undefined; _context7.prev = 9; for (_iterator2 = result.query.namespacealiases[Symbol.iterator](); !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { _ref13 = _step2.value; _id2 = _ref13.id, alias = _ref13.alias; all[_id2].add(alias); } _context7.next = 17; break; case 13: _context7.prev = 13; _context7.t0 = _context7['catch'](9); _didIteratorError2 = true; _iteratorError2 = _context7.t0; case 17: _context7.prev = 17; _context7.prev = 18; if (!_iteratorNormalCompletion2 && _iterator2.return) { _iterator2.return(); } case 20: _context7.prev = 20; if (!_didIteratorError2) { _context7.next = 23; break; } throw _iteratorError2; case 23: return _context7.finish(20); case 24: return _context7.finish(17); case 25: for (_id in all) { all[_id] = [].concat(_toConsumableArray(all[_id])); } return _context7.abrupt('return', all); case 27: case 'end': return _context7.stop(); } } }, _callee7, this, [[9, 13, 17, 25], [18,, 20, 24]]); })); function getNamespaces() { return _ref11.apply(this, arguments); } return getNamespaces; }(); // returns numberic id of the namespace, or null if there is no // prefix, or undefined if prefix is unknown this.getNamespace = function () { var _ref14 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8(title) { var allNs, index, prefix; return regeneratorRuntime.wrap(function _callee8$(_context8) { while (1) { switch (_context8.prev = _context8.next) { case 0: _context8.next = 2; return this.getNamespaces(); case 2: allNs = _context8.sent; if (title[0] === ':') { title = title.slice(1); } index = title.indexOf(':'); if (!(index === -1)) { _context8.next = 7; break; } return _context8.abrupt('return', null); case 7: prefix = title.slice(0, index).toLowerCase(); return _context8.abrupt('return', Object.keys(allNs).filter(function (n) { return allNs[n].some(function (x) { return x.toLowerCase() === prefix; }); }).map(function (n) { return parseInt(n); })[0]); case 9: case 'end': return _context8.stop(); } } }, _callee8, this); })); function getNamespace(_x9) { return _ref14.apply(this, arguments); } return getNamespace; }(); } function getMwApi(wiki) { return new MwApi('https://' + getWikiHost(wiki) + '/w/api.php'); } },{"./../package.json":3,"./telemetry.js":71}],62:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactRouter = require('react-router'); var _url = require('./url'); var _url2 = _interopRequireDefault(_url); var _App = require('./Components/App'); var _App2 = _interopRequireDefault(_App); var _AddArticle = require('./Components/AddArticle'); var _AddArticle2 = _interopRequireDefault(_AddArticle); var _ArticlesList = require('./Components/ArticlesList'); var _ArticlesList2 = _interopRequireDefault(_ArticlesList); var _EditathonList = require('./Components/EditathonList'); var _EditathonList2 = _interopRequireDefault(_EditathonList); var _EditathonPage = require('./Components/EditathonPage'); var _EditathonPage2 = _interopRequireDefault(_EditathonPage); var _EditathonConfig = require('./Components/EditathonConfig/EditathonConfig'); var _EditathonConfig2 = _interopRequireDefault(_EditathonConfig); var _ManageArticles = require('./Components/ManageArticles'); var _ManageArticles2 = _interopRequireDefault(_ManageArticles); var _EditathonAward = require('./Components/EditathonAward'); var _EditathonAward2 = _interopRequireDefault(_EditathonAward); var _Personal = require('./Components/Personal/Personal'); var _Jury = require('./Components/Jury/Jury'); var _Jury2 = _interopRequireDefault(_Jury); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.default = _react2.default.createElement( _reactRouter.Router, { history: _reactRouter.browserHistory }, _react2.default.createElement( _reactRouter.Route, { path: (0, _url2.default)('/jury') }, _react2.default.createElement(_reactRouter.Route, { path: ':id', component: _Jury2.default }) ), _react2.default.createElement( _reactRouter.Route, { path: (0, _url2.default)('/'), component: _App2.default }, _react2.default.createElement(_reactRouter.IndexRedirect, { to: 'editathons/' }), _react2.default.createElement( _reactRouter.Route, { path: 'editathons/' }, _react2.default.createElement(_reactRouter.IndexRoute, { component: _EditathonList2.default }), _react2.default.createElement( _reactRouter.Route, { path: ':id', component: _EditathonPage2.default }, _react2.default.createElement(_reactRouter.IndexRoute, { component: _ArticlesList2.default }), _react2.default.createElement(_reactRouter.Route, { path: 'add', component: _AddArticle2.default }), _react2.default.createElement(_reactRouter.Route, { path: 'manage', component: _ManageArticles2.default }), _react2.default.createElement(_reactRouter.Route, { path: 'award', component: _EditathonAward2.default }) ), _react2.default.createElement(_reactRouter.Route, { path: ':id/config', component: _EditathonConfig2.default }) ), _react2.default.createElement(_reactRouter.Redirect, { from: 'editathons', to: 'editathons/' }), _Personal.routes ) ); },{"./Components/AddArticle":5,"./Components/App":6,"./Components/ArticlesList":7,"./Components/EditathonAward":12,"./Components/EditathonConfig/EditathonConfig":14,"./Components/EditathonList":21,"./Components/EditathonPage":22,"./Components/Jury/Jury":31,"./Components/ManageArticles":38,"./Components/Personal/Personal":48,"./url":96,"react":"react","react-router":"react-router"}],63:[function(require,module,exports){ 'use strict'; var _urlSearchParams = require('url-search-params'); var _urlSearchParams2 = _interopRequireDefault(_urlSearchParams); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } window.URLSearchParams = _urlSearchParams2.default; // URLSearchParams should be in global scope, otherwise fetch polyfill think it's not supported // and url-search-params doesn't polyfill the global scope by default },{"url-search-params":"url-search-params"}],64:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _moment = require('moment'); var _moment2 = _interopRequireDefault(_moment); var _MwApi = require('./MwApi'); var _parsing = require('./parsing'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var Request = function () { function Request() { _classCallCheck(this, Request); this.items = new Map(); this.callbacks = []; this.lastCustomTypeId = 0; } _createClass(Request, [{ key: 'add', value: function add(type, params, cb) { var item = this.items.get(type); if (item === undefined) { if (type === 'firstRev' || type === 'lastRev') { item = { _title: 'titles', action: 'query', redirects: true, rvdir: type === 'firstRev' ? 'newer' : 'older' }; } else if (type === 'html') { item = { _title: 'page', action: 'parse', redirects: true, prop: ['text', 'indicators'], wrapoutputclass: '' }; } else if (type === 'custom') { type = 'custom-' + ++this.lastCustomTypeId; item = {}; } else { throw new Error('Unknown type \'' + type + '\''); } this.items.set(type, item); } // merging params for (var key in params) { var value = params[key]; if (Array.isArray(value)) { var arr = item[key]; if (arr === undefined) arr = [];else if (!Array.isArray(arr)) throw new Error('\'' + key + '\' is already defined as non-array \'' + arr + '\' for ' + type); var _iteratorNormalCompletion = true; var _didIteratorError = false; var _iteratorError = undefined; try { for (var _iterator = value[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { var it = _step.value; if (arr.indexOf(it) === -1) arr.push(it); } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally { try { if (!_iteratorNormalCompletion && _iterator.return) { _iterator.return(); } } finally { if (_didIteratorError) { throw _iteratorError; } } } item[key] = arr; } else { if (key in item && item[key] !== value) throw new Error('\'' + key + '\' is already defined for ' + type + ', existing \'' + item[key] + '\' !== new \'' + value + '\''); item[key] = value; } } this.callbacks.push(function (results) { return cb(results.get(type)); }); return this; } }, { key: 'runFor', value: function () { var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(wiki, title) { var items, promises, results, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _step2$value, type, result, _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, cb; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: items = [].concat(_toConsumableArray(this.items.entries())); promises = items.map(function (_ref2) { var _ref3 = _slicedToArray(_ref2, 2), type = _ref3[0], item = _ref3[1]; var params = {}; if (item._title) { params[item._title] = title; } for (var key in item) { if (key[0] == '_') continue; var value = item[key]; if (Array.isArray(value)) value = value.join('|'); params[key] = value; } return wiki.exec(params); }); _context.t0 = Map; _context.next = 5; return Promise.all(promises); case 5: _context.t1 = function (result, i) { return [items[i][0], result]; }; _context.t2 = _context.sent.map(_context.t1); results = new _context.t0(_context.t2); _iteratorNormalCompletion2 = true; _didIteratorError2 = false; _iteratorError2 = undefined; _context.prev = 11; _iterator2 = results[Symbol.iterator](); case 13: if (_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done) { _context.next = 20; break; } _step2$value = _slicedToArray(_step2.value, 2), type = _step2$value[0], result = _step2$value[1]; if (!(result.query && result.query.pages[0].missing)) { _context.next = 17; break; } return _context.abrupt('return', false); case 17: _iteratorNormalCompletion2 = true; _context.next = 13; break; case 20: _context.next = 26; break; case 22: _context.prev = 22; _context.t3 = _context['catch'](11); _didIteratorError2 = true; _iteratorError2 = _context.t3; case 26: _context.prev = 26; _context.prev = 27; if (!_iteratorNormalCompletion2 && _iterator2.return) { _iterator2.return(); } case 29: _context.prev = 29; if (!_didIteratorError2) { _context.next = 32; break; } throw _iteratorError2; case 32: return _context.finish(29); case 33: return _context.finish(26); case 34: _iteratorNormalCompletion3 = true; _didIteratorError3 = false; _iteratorError3 = undefined; _context.prev = 37; for (_iterator3 = this.callbacks[Symbol.iterator](); !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { cb = _step3.value; cb(results); } _context.next = 45; break; case 41: _context.prev = 41; _context.t4 = _context['catch'](37); _didIteratorError3 = true; _iteratorError3 = _context.t4; case 45: _context.prev = 45; _context.prev = 46; if (!_iteratorNormalCompletion3 && _iterator3.return) { _iterator3.return(); } case 48: _context.prev = 48; if (!_didIteratorError3) { _context.next = 51; break; } throw _iteratorError3; case 51: return _context.finish(48); case 52: return _context.finish(45); case 53: return _context.abrupt('return', true); case 54: case 'end': return _context.stop(); } } }, _callee, this, [[11, 22, 26, 34], [27,, 29, 33], [37, 41, 45, 53], [46,, 48, 52]]); })); function runFor(_x, _x2) { return _ref.apply(this, arguments); } return runFor; }() }]); return Request; }(); var ItalianWikiVoyageTags = ["sup", "sub", "table", "div", "#comment", "h1", "h2", "h3", "h4", "h5", "h6"]; var Types = { title: ['lastRev', { prop: ['revisions'], rvlimit: 1 }, function (_ref4) { var _ref4$query$pages = _slicedToArray(_ref4.query.pages, 1), title = _ref4$query$pages[0].title; return title; }], ns: ['lastRev', { prop: ['revisions'], rvlimit: 1 }, function (_ref5) { var _ref5$query$pages = _slicedToArray(_ref5.query.pages, 1), ns = _ref5$query$pages[0].ns; return ns; }], html: ['html', {}, function (_ref6) { var text = _ref6.parse.text; return text; }], indicators: ['html', {}, function (_ref7) { var indicators = _ref7.parse.indicators; return indicators; }], chars: ['html', {}, function (_ref8) { var text = _ref8.parse.text; return (0, _parsing.getPlainText)(text).length; }], charsItalianWikiVoyage: ['html', {}, function (_ref9) { var text = _ref9.parse.text; return (0, _parsing.getPlainText)(text, ItalianWikiVoyageTags).length; }], words: ['html', {}, function (_ref10) { var text = _ref10.parse.text; return (0, _parsing.getWordCount)(text); }], wordsItalianWikiVoyage: ['html', {}, function (_ref11) { var text = _ref11.parse.text; return (0, _parsing.getWordCount)(text, ItalianWikiVoyageTags); }], bytes: ['lastRev', { prop: ['revisions'], rvprop: ['size'], rvlimit: 1 }, function (_ref12) { var _ref12$query$pages = _slicedToArray(_ref12.query.pages, 1), _ref12$query$pages$0$ = _slicedToArray(_ref12$query$pages[0].revisions, 1), size = _ref12$query$pages$0$[0].size; return size; }], card: ['lastRev', { prop: ['extracts', 'pageimages'], exintro: true, // only content before first section exsentences: 5, // max sentences to return explaintext: true, piprop: 'thumbnail', pithumbsize: 300 }, function (_ref13) { var _ref13$query$pages = _slicedToArray(_ref13.query.pages, 1), _ref13$query$pages$ = _ref13$query$pages[0], extract = _ref13$query$pages$.extract, thumbnail = _ref13$query$pages$.thumbnail; return { extract: extract, thumbnail: thumbnail }; }], creator: ['firstRev', { prop: ['revisions'], rvprop: ['user'], rvlimit: 1 }, function (_ref14) { var _ref14$query$pages = _slicedToArray(_ref14.query.pages, 1), _ref14$query$pages$0$ = _slicedToArray(_ref14$query$pages[0].revisions, 1), user = _ref14$query$pages$0$[0].user; return user; }], created: ['firstRev', { prop: ['revisions'], rvprop: ['timestamp'], rvlimit: 1 }, function (_ref15) { var _ref15$query$pages = _slicedToArray(_ref15.query.pages, 1), _ref15$query$pages$0$ = _slicedToArray(_ref15$query$pages[0].revisions, 1), timestamp = _ref15$query$pages$0$[0].timestamp; return timestamp; }], addedForCleanupRu: function addedForCleanupRu(_ref16) { var at = _ref16.at; return ['custom', { _title: 'titles', action: 'query', redirects: true, rvdir: 'older', rvstart: (0, _moment2.default)(at).toISOString(), prop: ['revisions'], rvprop: ['ids', 'content'], rvlimit: 1 }, function (_ref17) { var _ref17$query$pages = _slicedToArray(_ref17.query.pages, 1), _ref17$query$pages$0$ = _slicedToArray(_ref17$query$pages[0].revisions, 1), _ref17$query$pages$0$2 = _ref17$query$pages$0$[0], revid = _ref17$query$pages$0$2.revid, content = _ref17$query$pages$0$2.content; var template = (0, _parsing.findTemplate)(content, 'К улучшению'); var arg = template && template.args[0]; return { date: arg && arg.value && _moment2.default.utc(arg.value, 'YYYY-M-D', true), revId: revid }; }]; }, fileUrl: ['lastRev', { prop: ['imageinfo'], iiprop: 'url', iiurlwidth: 800 }, function (_ref18) { var _ref18$query$pages = _slicedToArray(_ref18.query.pages, 1), _ref18$query$pages$ = _ref18$query$pages[0], title = _ref18$query$pages$.title, _ref18$query$pages$$i = _slicedToArray(_ref18$query$pages$.imageinfo, 1), _ref18$query$pages$$i2 = _ref18$query$pages$$i[0], url = _ref18$query$pages$$i2.url, thumburl = _ref18$query$pages$$i2.thumburl; return { title: title, fileUrl: { url: url, thumburl: thumburl } }; }, 'merge'] }; // what: title, ns, html, chars, bytes, creator, created, card, { type: addedForCleanupRu, arg: { at: 'date' } } exports.default = function () { var _ref19 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(wiki, title, what) { var req, result, mwApi, _iteratorNormalCompletion4, _didIteratorError4, _iteratorError4, _loop, _iterator4, _step4; return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: req = new Request(); result = {}; mwApi = (0, _MwApi.getMwApi)(wiki); _iteratorNormalCompletion4 = true; _didIteratorError4 = false; _iteratorError4 = undefined; _context2.prev = 6; _loop = function _loop() { var item = _step4.value; var type = void 0, arg = void 0; if (typeof item === 'string') { type = item; arg = null; } else { type = item.type; arg = item.arg; } var realType = type; if (wiki === 'voy:it') { if (type === 'chars') { realType = 'charsItalianWikiVoyage'; } else if (type === 'words') { realType = 'wordsItalianWikiVoyage'; } } if (!(type in Types)) throw new Error('Unknown type \'' + type + '\''); var config = Types[realType]; if (typeof config === 'function') { config = config(arg); } var _config = config, _config2 = _slicedToArray(_config, 4), reqType = _config2[0], params = _config2[1], cb = _config2[2], mode = _config2[3]; req.add(reqType, params, function (data) { var res = cb(data); if (mode === 'merge') { Object.assign(result, res); } else { result[type] = res; } }); }; for (_iterator4 = new Set(what)[Symbol.iterator](); !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { _loop(); } _context2.next = 15; break; case 11: _context2.prev = 11; _context2.t0 = _context2['catch'](6); _didIteratorError4 = true; _iteratorError4 = _context2.t0; case 15: _context2.prev = 15; _context2.prev = 16; if (!_iteratorNormalCompletion4 && _iterator4.return) { _iterator4.return(); } case 18: _context2.prev = 18; if (!_didIteratorError4) { _context2.next = 21; break; } throw _iteratorError4; case 21: return _context2.finish(18); case 22: return _context2.finish(15); case 23: _context2.next = 25; return req.runFor(mwApi, title); case 25: if (_context2.sent) { _context2.next = 27; break; } return _context2.abrupt('return', null); case 27: return _context2.abrupt('return', result); case 28: case 'end': return _context2.stop(); } } }, _callee2, this, [[6, 11, 15, 23], [16,, 18, 22]]); })); function getArticleData(_x3, _x4, _x5) { return _ref19.apply(this, arguments); } return getArticleData; }(); },{"./MwApi":61,"./parsing":67,"moment":"moment"}],65:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.EditathonFlags = undefined; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; exports.findMarkOf = findMarkOf; exports.getActiveMarks = getActiveMarks; exports.calcMark = calcMark; exports.isMarkValid = isMarkValid; exports.getTotalMark = getTotalMark; exports.isConflict = isConflict; var _shallowEquals = require('shallow-equals'); var _shallowEquals2 = _interopRequireDefault(_shallowEquals); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var EditathonFlags = exports.EditathonFlags = Object.freeze({ consensualVote: 1, hiddenMarks: 2 }); function findMarkOf(marks) { var user = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Global.user.name; return marks.filter(function (m) { return m.user === user; })[0]; } var Calc = { radio: function radio(mark, val) { // backwards compatibily if (val === false) val = 0;else if (val === true) val = 1; var cur = mark.values[val]; return cur && _extends({}, cur, { val: val }); }, check: function check(mark, val) { return val && _extends({}, mark); }, int: function int(mark, val) { return val !== undefined ? _extends({}, mark, { val: val, value: val }) : undefined; } }; function getActiveMarks() { var mark = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var marks = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var res = {}; for (var id in marks) { var m = marks[id]; var cur = Calc[m.type](m, mark[id]); res[id] = _extends({}, m, { cur: cur, children: cur && cur.children ? getActiveMarks(mark, cur.children) : undefined }); if (cur) delete cur.children; } return res; } function calcMark(mark, marks) { if (!mark) return; return function calcMark(marks) { var res = { parts: {}, sum: null }; for (var id in marks) { var m = marks[id]; if (!m.cur) continue; res.sum += m.cur.value; var title = void 0, value = void 0; if (m.type === 'radio') { title = m.cur.description || m.cur.title; value = m.cur.value; } else if (m.type === 'check') { title = m.title || m.description; value = m.value; } else if (m.type === 'int') { title = m.title || m.description; value = m.cur.value; } else { throw new Error('Unknown type: ' + m.type); } res.parts[id] = { title: title || '', value: value }; if (m.children) { var _calcMark = calcMark(m.children), parts = _calcMark.parts, sum = _calcMark.sum; Object.assign(res.parts, parts); res.sum += sum; } } return res; }(getActiveMarks(mark, marks)); } function isSameMark(m1, m2, marksConfig) { function get(m) { for (var id in m) { m[id] = m[id].value; } return m; } m1 = calcMark(m1, marksConfig); m2 = calcMark(m2, marksConfig); if (!m1 || !m2) return m1 === m2; return (0, _shallowEquals2.default)(get(m1.parts), get(m2.parts)); } function getConsensualMark(marks, marksConfig) { if (marks.length > 1) { if (!marks.reduce(function (a, b) { return isSameMark(a, b, marksConfig) && a; })) { return null; } } return calcMark(marks[0], marksConfig).sum; } function isMarkValid(marks, marksConfig) { // tests if all radios & ints have values function isValid(marks) { if (!marks) return true; var _iteratorNormalCompletion = true; var _didIteratorError = false; var _iteratorError = undefined; try { for (var _iterator = Object.values(marks)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { var m = _step.value; if (m.type === 'radio' && m.cur === undefined) return false; if (m.type === 'int' && m.cur === undefined) return false; if (!isValid(m.children)) return false; } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally { try { if (!_iteratorNormalCompletion && _iterator.return) { _iterator.return(); } } finally { if (_didIteratorError) { throw _iteratorError; } } } return true; } return isValid(getActiveMarks(marks, marksConfig)); } function calcTotalMark(jury, marks, marksConfig, minMarks) { var all = jury.map(function (j) { return findMarkOf(marks, j); }).filter(function (m) { return m; }).map(function (m) { return m.marks; }); if (all.length == 0) return null; if (all.length < minMarks) return null; return { average: all.map(function (m) { return calcMark(m, marksConfig).sum; }).reduce(function (a, b) { return a + b; }, 0) / all.length, consensual: getConsensualMark(all, marksConfig) }; } function getTotalMark(_ref, marks) { var jury = _ref.jury, marksConfig = _ref.marks, flags = _ref.flags, minMarks = _ref.minMarks; var consensualVote = !!(flags & EditathonFlags.consensualVote); var mark = calcTotalMark(jury, marks, marksConfig, minMarks); return mark && (consensualVote ? mark.consensual : mark.average); } function isConflict(editathon, article) { var jury = editathon.jury, marks = editathon.marks, flags = editathon.flags, minMarks = editathon.minMarks; if (flags & EditathonFlags.hiddenMarks) return false; if (!(flags & EditathonFlags.consensualVote)) return false; var mark = calcTotalMark(jury, article.marks, marks, minMarks); return mark && mark.consensual === null; } },{"shallow-equals":"shallow-equals"}],66:[function(require,module,exports){ 'use strict'; require('babel-polyfill'); require('./URLSearchParams'); require('whatwg-fetch'); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactDom = require('react-dom'); var _Router = require('./Router'); var _Router2 = _interopRequireDefault(_Router); var _translate = require('./translate'); var _utils = require('./utils'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } // TODO: do on the server side when lighttpd is updated to version 1.4.40 on labs server if (location.hostname === 'tools.wmflabs.org' && location.protocol === 'http:') { location.href = 'https' + location.href.slice(4); } var lang = localStorage.getItem('fountainLang') || (0, _utils.getNavitagorLang)(); (0, _reactDom.render)(_react2.default.createElement( _translate.TranslationContext, { defaultLang: lang || 'en', onSetLang: function onSetLang(x) { return localStorage.setItem('fountainLang', x); } }, _Router2.default ), document.getElementById('body')); },{"./Router":62,"./URLSearchParams":63,"./translate":73,"./utils":97,"babel-polyfill":"babel-polyfill","react":"react","react-dom":"react-dom","whatwg-fetch":"whatwg-fetch"}],67:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getPlainText = getPlainText; exports.getWordCount = getWordCount; exports.getIgnoredRegions = getIgnoredRegions; exports.ignoredRegionsContain = ignoredRegionsContain; exports.findTemplate = findTemplate; var _utils = require("./utils"); var _marked = /*#__PURE__*/regeneratorRuntime.mark(getIgnoredRegions); function _toArray(arr) { return Array.isArray(arr) ? arr : Array.from(arr); } function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } function eraseTags(tag, tags) { if (!tag.childNodes.length) return tag.textContent.trim(); return [].concat(_toConsumableArray(tag.childNodes)).filter(function (tag) { return tags.indexOf(tag.nodeName.toLowerCase()) === -1; }).map(function (tag) { return eraseTags(tag, tags).trim(); }).filter(function (tag) { return tag; }).join(" "); } function getPlainText(text) { var tags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ["sup", "sub", "table", "div", "ul", "ol", "li", "dl", "dd", "dt", "#comment", "h1", "h2", "h3", "h4", "h5", "h6"]; var parser = new DOMParser(); var html = parser.parseFromString(text, "text/html"); return eraseTags(html.body, tags); } function getWordCount(text, tags) { return (getPlainText(text, tags).match(/[^\s]*[^\s\u2000-\u206f!"$%'()*,\-.:;?\\\[\]|~¡«°·»¿՚՛՜՝՞՟։־׀׆׳״،؟।၊။♪⟨⟩、。《》「」『』【】〜〽・﬩️﹁﹂!(),:?[]{}]+[^\s]*(\s|$)+/g) || []).length; } function parseTemplateAt(text, index, strict) { text = text.substr(index).trim(); if (!text.startsWith('{{') || strict && !text.EndsWith('}}')) { throw new Error('Template should be surrounded by {{}}.'); } var level = 0; var str = ''; var template = { name: null, args: [] }; var _text$split$filter = text.split(/({{|\||}}|\[\[|\]\])/).filter(function (x) { return x; }), _text$split$filter2 = _toArray(_text$split$filter), parts = _text$split$filter2.slice(1); var _iteratorNormalCompletion = true; var _didIteratorError = false; var _iteratorError = undefined; try { for (var _iterator = parts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { var part = _step.value; if (level < 0) { if (strict) { throw new Error('Unexpected text after template end.'); } else { break; } } if ((part === '|' || part === '}}') && level === 0) { if (template.name === null) { template.name = str; } else { var arg = /^([\s\w]+)=(.*)$/.exec(str); if (arg) { template.args.push({ name: arg[1], value: arg[2] }); } else { template.args.push({ value: str }); } } str = ''; } else { str += part; } if (part == '{{' || part == '[[') { level++; } else if (part == '}}' || part == ']]') { level--; } } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally { try { if (!_iteratorNormalCompletion && _iterator.return) { _iterator.return(); } } finally { if (_didIteratorError) { throw _iteratorError; } } } if (level >= 0) { throw new Error('Template end not found.'); } return template; } function getIgnoredRegions(text) { var tokens, prevToken, start, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, match, token; return regeneratorRuntime.wrap(function getIgnoredRegions$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: tokens = new RegExp(['', '(]', ''].join('|'), 'g'); prevToken = null; start = 0; _iteratorNormalCompletion2 = true; _didIteratorError2 = false; _iteratorError2 = undefined; _context.prev = 6; _iterator2 = (0, _utils.matchAll)(tokens, text)[Symbol.iterator](); case 8: if (_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done) { _context.next = 23; break; } match = _step2.value; token = match[1] || match[0]; if (!((token === '' && prevToken === '