PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / 1.6.2
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster v1.6.2
2.6.0 trunk 1.1.0 1.1.4 1.2.1 1.2.2 1.2.3 1.2.5 1.2.9 1.3.1 1.3.2 1.5.0 1.5.1 1.5.4 1.5.7 1.5.8 1.5.9 1.6.2 1.6.5 1.6.8 1.7.2 1.7.4 1.7.5 1.7.9 1.8.1 All 42 releases
sellkit / assets / dist / js / admin.js

admin.js in SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster 1.6.2, at assets/dist/js/admin.js

1,652 lines 47.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2 "use strict";
3
4 var _i18n = require("@wordpress/i18n");
5
6 var adminNotice = function adminNotice() {
7 var $ = jQuery;
8 $('.sellkit-notice.notice .notice-dismiss, .sellkit-rating-notice-i-already-did').on('click', function () {
9 var noticeKey = $(this).parents('.sellkit-notice').attr('data-key');
10 $(this).parents('.sellkit-notice').remove();
11 wp.ajax.post('sellkit_admin_notice_dismiss', {
12 key: noticeKey,
13 nonce: window.sellkitAdmin.nonce
14 });
15 });
16 $('.sellkit-rating-notice-maybe-later').on('click', function () {
17 $(this).parents('.sellkit-notice').remove();
18 wp.ajax.post('sellkit_admin_notice_maybe_later', {
19 nonce: window.sellkitAdmin.nonce
20 });
21 });
22 var text = (0, _i18n.__)('Installing WooCommerce', 'sellkit');
23 $('.sellkit-notice').find('a[href="#install-woo"]').off().on('click', function () {
24 $(this).html('<span class="sellkit-notice-loading-icon">' + text + ' </span>').attr('disabled', 'disabled');
25 wp.ajax.post({
26 action: 'sellkit_install_woocommerce_plugin_by_notice',
27 nonce: window.sellkitAdmin.nonce
28 }).done(function () {
29 location.reload();
30 }).fail(function (result) {
31 if (result.includes('{"success":true}')) {
32 location.reload();
33 return;
34 }
35
36 $('.sellkit-notice').find('a[href="#install-woo"]').text((0, _i18n.__)('Failed, Try again.', 'sellkit'));
37 });
38 });
39 };
40
41 document.addEventListener('DOMContentLoaded', function () {
42 adminNotice();
43 });
44
45 },{"@wordpress/i18n":10}],2:[function(require,module,exports){
46 function _defineProperty(obj, key, value) {
47 if (key in obj) {
48 Object.defineProperty(obj, key, {
49 value: value,
50 enumerable: true,
51 configurable: true,
52 writable: true
53 });
54 } else {
55 obj[key] = value;
56 }
57
58 return obj;
59 }
60
61 module.exports = _defineProperty;
62 },{}],3:[function(require,module,exports){
63 function _interopRequireDefault(obj) {
64 return obj && obj.__esModule ? obj : {
65 "default": obj
66 };
67 }
68
69 module.exports = _interopRequireDefault;
70 },{}],4:[function(require,module,exports){
71 'use strict';
72
73 function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
74
75 var postfix = _interopDefault(require('@tannin/postfix'));
76 var evaluate = _interopDefault(require('@tannin/evaluate'));
77
78 /**
79 * Given a C expression, returns a function which can be called to evaluate its
80 * result.
81 *
82 * @example
83 *
84 * ```js
85 * import compile from '@tannin/compile';
86 *
87 * const evaluate = compile( 'n > 1' );
88 *
89 * evaluate( { n: 2 } );
90 * // ⇒ true
91 * ```
92 *
93 * @param {string} expression C expression.
94 *
95 * @return {(variables?:{[variable:string]:*})=>*} Compiled evaluator.
96 */
97 function compile( expression ) {
98 var terms = postfix( expression );
99
100 return function( variables ) {
101 return evaluate( terms, variables );
102 };
103 }
104
105 module.exports = compile;
106
107 },{"@tannin/evaluate":5,"@tannin/postfix":7}],5:[function(require,module,exports){
108 'use strict';
109
110 /**
111 * Operator callback functions.
112 *
113 * @type {Object}
114 */
115 var OPERATORS = {
116 '!': function( a ) {
117 return ! a;
118 },
119 '*': function( a, b ) {
120 return a * b;
121 },
122 '/': function( a, b ) {
123 return a / b;
124 },
125 '%': function( a, b ) {
126 return a % b;
127 },
128 '+': function( a, b ) {
129 return a + b;
130 },
131 '-': function( a, b ) {
132 return a - b;
133 },
134 '<': function( a, b ) {
135 return a < b;
136 },
137 '<=': function( a, b ) {
138 return a <= b;
139 },
140 '>': function( a, b ) {
141 return a > b;
142 },
143 '>=': function( a, b ) {
144 return a >= b;
145 },
146 '==': function( a, b ) {
147 return a === b;
148 },
149 '!=': function( a, b ) {
150 return a !== b;
151 },
152 '&&': function( a, b ) {
153 return a && b;
154 },
155 '||': function( a, b ) {
156 return a || b;
157 },
158 '?:': function( a, b, c ) {
159 if ( a ) {
160 throw b;
161 }
162
163 return c;
164 },
165 };
166
167 /**
168 * Given an array of postfix terms and operand variables, returns the result of
169 * the postfix evaluation.
170 *
171 * @example
172 *
173 * ```js
174 * import evaluate from '@tannin/evaluate';
175 *
176 * // 3 + 4 * 5 / 6 ⇒ '3 4 5 * 6 / +'
177 * const terms = [ '3', '4', '5', '*', '6', '/', '+' ];
178 *
179 * evaluate( terms, {} );
180 * // ⇒ 6.333333333333334
181 * ```
182 *
183 * @param {string[]} postfix Postfix terms.
184 * @param {Object} variables Operand variables.
185 *
186 * @return {*} Result of evaluation.
187 */
188 function evaluate( postfix, variables ) {
189 var stack = [],
190 i, j, args, getOperatorResult, term, value;
191
192 for ( i = 0; i < postfix.length; i++ ) {
193 term = postfix[ i ];
194
195 getOperatorResult = OPERATORS[ term ];
196 if ( getOperatorResult ) {
197 // Pop from stack by number of function arguments.
198 j = getOperatorResult.length;
199 args = Array( j );
200 while ( j-- ) {
201 args[ j ] = stack.pop();
202 }
203
204 try {
205 value = getOperatorResult.apply( null, args );
206 } catch ( earlyReturn ) {
207 return earlyReturn;
208 }
209 } else if ( variables.hasOwnProperty( term ) ) {
210 value = variables[ term ];
211 } else {
212 value = +term;
213 }
214
215 stack.push( value );
216 }
217
218 return stack[ 0 ];
219 }
220
221 module.exports = evaluate;
222
223 },{}],6:[function(require,module,exports){
224 'use strict';
225
226 function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
227
228 var compile = _interopDefault(require('@tannin/compile'));
229
230 /**
231 * Given a C expression, returns a function which, when called with a value,
232 * evaluates the result with the value assumed to be the "n" variable of the
233 * expression. The result will be coerced to its numeric equivalent.
234 *
235 * @param {string} expression C expression.
236 *
237 * @return {Function} Evaluator function.
238 */
239 function pluralForms( expression ) {
240 var evaluate = compile( expression );
241
242 return function( n ) {
243 return +evaluate( { n: n } );
244 };
245 }
246
247 module.exports = pluralForms;
248
249 },{"@tannin/compile":4}],7:[function(require,module,exports){
250 'use strict';
251
252 var PRECEDENCE, OPENERS, TERMINATORS, PATTERN;
253
254 /**
255 * Operator precedence mapping.
256 *
257 * @type {Object}
258 */
259 PRECEDENCE = {
260 '(': 9,
261 '!': 8,
262 '*': 7,
263 '/': 7,
264 '%': 7,
265 '+': 6,
266 '-': 6,
267 '<': 5,
268 '<=': 5,
269 '>': 5,
270 '>=': 5,
271 '==': 4,
272 '!=': 4,
273 '&&': 3,
274 '||': 2,
275 '?': 1,
276 '?:': 1,
277 };
278
279 /**
280 * Characters which signal pair opening, to be terminated by terminators.
281 *
282 * @type {string[]}
283 */
284 OPENERS = [ '(', '?' ];
285
286 /**
287 * Characters which signal pair termination, the value an array with the
288 * opener as its first member. The second member is an optional operator
289 * replacement to push to the stack.
290 *
291 * @type {string[]}
292 */
293 TERMINATORS = {
294 ')': [ '(' ],
295 ':': [ '?', '?:' ],
296 };
297
298 /**
299 * Pattern matching operators and openers.
300 *
301 * @type {RegExp}
302 */
303 PATTERN = /<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/;
304
305 /**
306 * Given a C expression, returns the equivalent postfix (Reverse Polish)
307 * notation terms as an array.
308 *
309 * If a postfix string is desired, simply `.join( ' ' )` the result.
310 *
311 * @example
312 *
313 * ```js
314 * import postfix from '@tannin/postfix';
315 *
316 * postfix( 'n > 1' );
317 * // ⇒ [ 'n', '1', '>' ]
318 * ```
319 *
320 * @param {string} expression C expression.
321 *
322 * @return {string[]} Postfix terms.
323 */
324 function postfix( expression ) {
325 var terms = [],
326 stack = [],
327 match, operator, term, element;
328
329 while ( ( match = expression.match( PATTERN ) ) ) {
330 operator = match[ 0 ];
331
332 // Term is the string preceding the operator match. It may contain
333 // whitespace, and may be empty (if operator is at beginning).
334 term = expression.substr( 0, match.index ).trim();
335 if ( term ) {
336 terms.push( term );
337 }
338
339 while ( ( element = stack.pop() ) ) {
340 if ( TERMINATORS[ operator ] ) {
341 if ( TERMINATORS[ operator ][ 0 ] === element ) {
342 // Substitution works here under assumption that because
343 // the assigned operator will no longer be a terminator, it
344 // will be pushed to the stack during the condition below.
345 operator = TERMINATORS[ operator ][ 1 ] || operator;
346 break;
347 }
348 } else if ( OPENERS.indexOf( element ) >= 0 || PRECEDENCE[ element ] < PRECEDENCE[ operator ] ) {
349 // Push to stack if either an opener or when pop reveals an
350 // element of lower precedence.
351 stack.push( element );
352 break;
353 }
354
355 // For each popped from stack, push to terms.
356 terms.push( element );
357 }
358
359 if ( ! TERMINATORS[ operator ] ) {
360 stack.push( operator );
361 }
362
363 // Slice matched fragment from expression to continue match.
364 expression = expression.substr( match.index + operator.length );
365 }
366
367 // Push remainder of operand, if exists, to terms.
368 expression = expression.trim();
369 if ( expression ) {
370 terms.push( expression );
371 }
372
373 // Pop remaining items from stack into terms.
374 return terms.concat( stack.reverse() );
375 }
376
377 module.exports = postfix;
378
379 },{}],8:[function(require,module,exports){
380 "use strict";
381
382 var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
383
384 Object.defineProperty(exports, "__esModule", {
385 value: true
386 });
387 exports.createI18n = void 0;
388
389 var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
390
391 var _tannin = _interopRequireDefault(require("tannin"));
392
393 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
394
395 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
396
397 /**
398 * @typedef {Record<string,any>} LocaleData
399 */
400
401 /**
402 * Default locale data to use for Tannin domain when not otherwise provided.
403 * Assumes an English plural forms expression.
404 *
405 * @type {LocaleData}
406 */
407 var DEFAULT_LOCALE_DATA = {
408 '': {
409 /** @param {number} n */
410 plural_forms: function plural_forms(n) {
411 return n === 1 ? 0 : 1;
412 }
413 }
414 };
415 /**
416 * An i18n instance
417 *
418 * @typedef {Object} I18n
419 * @property {Function} setLocaleData Merges locale data into the Tannin instance by domain. Accepts data in a
420 * Jed-formatted JSON object shape.
421 * @property {Function} __ Retrieve the translation of text.
422 * @property {Function} _x Retrieve translated string with gettext context.
423 * @property {Function} _n Translates and retrieves the singular or plural form based on the supplied
424 * number.
425 * @property {Function} _nx Translates and retrieves the singular or plural form based on the supplied
426 * number, with gettext context.
427 * @property {Function} isRTL Check if current locale is RTL.
428 */
429
430 /**
431 * Create an i18n instance
432 *
433 * @param {LocaleData} [initialData] Locale data configuration.
434 * @param {string} [initialDomain] Domain for which configuration applies.
435 * @return {I18n} I18n instance
436 */
437
438 var createI18n = function createI18n(initialData, initialDomain) {
439 /**
440 * The underlying instance of Tannin to which exported functions interface.
441 *
442 * @type {Tannin}
443 */
444 var tannin = new _tannin.default({});
445 /**
446 * Merges locale data into the Tannin instance by domain. Accepts data in a
447 * Jed-formatted JSON object shape.
448 *
449 * @see http://messageformat.github.io/Jed/
450 *
451 * @param {LocaleData} [data] Locale data configuration.
452 * @param {string} [domain] Domain for which configuration applies.
453 */
454
455 var setLocaleData = function setLocaleData(data) {
456 var domain = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
457 tannin.data[domain] = _objectSpread({}, DEFAULT_LOCALE_DATA, {}, tannin.data[domain], {}, data); // Populate default domain configuration (supported locale date which omits
458 // a plural forms expression).
459
460 tannin.data[domain][''] = _objectSpread({}, DEFAULT_LOCALE_DATA[''], {}, tannin.data[domain]['']);
461 };
462 /**
463 * Wrapper for Tannin's `dcnpgettext`. Populates default locale data if not
464 * otherwise previously assigned.
465 *
466 * @param {string|undefined} domain Domain to retrieve the translated text.
467 * @param {string|undefined} context Context information for the translators.
468 * @param {string} single Text to translate if non-plural. Used as
469 * fallback return value on a caught error.
470 * @param {string} [plural] The text to be used if the number is
471 * plural.
472 * @param {number} [number] The number to compare against to use
473 * either the singular or plural form.
474 *
475 * @return {string} The translated string.
476 */
477
478
479 var dcnpgettext = function dcnpgettext() {
480 var domain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
481 var context = arguments.length > 1 ? arguments[1] : undefined;
482 var single = arguments.length > 2 ? arguments[2] : undefined;
483 var plural = arguments.length > 3 ? arguments[3] : undefined;
484 var number = arguments.length > 4 ? arguments[4] : undefined;
485
486 if (!tannin.data[domain]) {
487 setLocaleData(undefined, domain);
488 }
489
490 return tannin.dcnpgettext(domain, context, single, plural, number);
491 };
492 /**
493 * Retrieve the translation of text.
494 *
495 * @see https://developer.wordpress.org/reference/functions/__/
496 *
497 * @param {string} text Text to translate.
498 * @param {string} [domain] Domain to retrieve the translated text.
499 *
500 * @return {string} Translated text.
501 */
502
503
504 var __ = function __(text, domain) {
505 return dcnpgettext(domain, undefined, text);
506 };
507 /**
508 * Retrieve translated string with gettext context.
509 *
510 * @see https://developer.wordpress.org/reference/functions/_x/
511 *
512 * @param {string} text Text to translate.
513 * @param {string} context Context information for the translators.
514 * @param {string} [domain] Domain to retrieve the translated text.
515 *
516 * @return {string} Translated context string without pipe.
517 */
518
519
520 var _x = function _x(text, context, domain) {
521 return dcnpgettext(domain, context, text);
522 };
523 /**
524 * Translates and retrieves the singular or plural form based on the supplied
525 * number.
526 *
527 * @see https://developer.wordpress.org/reference/functions/_n/
528 *
529 * @param {string} single The text to be used if the number is singular.
530 * @param {string} plural The text to be used if the number is plural.
531 * @param {number} number The number to compare against to use either the
532 * singular or plural form.
533 * @param {string} [domain] Domain to retrieve the translated text.
534 *
535 * @return {string} The translated singular or plural form.
536 */
537
538
539 var _n = function _n(single, plural, number, domain) {
540 return dcnpgettext(domain, undefined, single, plural, number);
541 };
542 /**
543 * Translates and retrieves the singular or plural form based on the supplied
544 * number, with gettext context.
545 *
546 * @see https://developer.wordpress.org/reference/functions/_nx/
547 *
548 * @param {string} single The text to be used if the number is singular.
549 * @param {string} plural The text to be used if the number is plural.
550 * @param {number} number The number to compare against to use either the
551 * singular or plural form.
552 * @param {string} context Context information for the translators.
553 * @param {string} [domain] Domain to retrieve the translated text.
554 *
555 * @return {string} The translated singular or plural form.
556 */
557
558
559 var _nx = function _nx(single, plural, number, context, domain) {
560 return dcnpgettext(domain, context, single, plural, number);
561 };
562 /**
563 * Check if current locale is RTL.
564 *
565 * **RTL (Right To Left)** is a locale property indicating that text is written from right to left.
566 * For example, the `he` locale (for Hebrew) specifies right-to-left. Arabic (ar) is another common
567 * language written RTL. The opposite of RTL, LTR (Left To Right) is used in other languages,
568 * including English (`en`, `en-US`, `en-GB`, etc.), Spanish (`es`), and French (`fr`).
569 *
570 * @return {boolean} Whether locale is RTL.
571 */
572
573
574 var isRTL = function isRTL() {
575 return 'rtl' === _x('ltr', 'text direction');
576 };
577
578 if (initialData) {
579 setLocaleData(initialData, initialDomain);
580 }
581
582 return {
583 setLocaleData: setLocaleData,
584 __: __,
585 _x: _x,
586 _n: _n,
587 _nx: _nx,
588 isRTL: isRTL
589 };
590 };
591
592 exports.createI18n = createI18n;
593
594 },{"@babel/runtime/helpers/defineProperty":2,"@babel/runtime/helpers/interopRequireDefault":3,"tannin":15}],9:[function(require,module,exports){
595 "use strict";
596
597 Object.defineProperty(exports, "__esModule", {
598 value: true
599 });
600 exports.isRTL = exports._nx = exports._n = exports._x = exports.__ = exports.setLocaleData = void 0;
601
602 var _createI18n = require("./create-i18n");
603
604 /**
605 * Internal dependencies
606 */
607 var i18n = (0, _createI18n.createI18n)();
608 /*
609 * Comments in this file are duplicated from ./i18n due to
610 * https://github.com/WordPress/gutenberg/pull/20318#issuecomment-590837722
611 */
612
613 /**
614 * @typedef {import('./create-i18n').LocaleData} LocaleData
615 */
616
617 /**
618 * Merges locale data into the Tannin instance by domain. Accepts data in a
619 * Jed-formatted JSON object shape.
620 *
621 * @see http://messageformat.github.io/Jed/
622 *
623 * @param {LocaleData} [data] Locale data configuration.
624 * @param {string} [domain] Domain for which configuration applies.
625 */
626
627 var setLocaleData = i18n.setLocaleData.bind(i18n);
628 /**
629 * Retrieve the translation of text.
630 *
631 * @see https://developer.wordpress.org/reference/functions/__/
632 *
633 * @param {string} text Text to translate.
634 * @param {string} [domain] Domain to retrieve the translated text.
635 *
636 * @return {string} Translated text.
637 */
638
639 exports.setLocaleData = setLocaleData;
640
641 var __ = i18n.__.bind(i18n);
642 /**
643 * Retrieve translated string with gettext context.
644 *
645 * @see https://developer.wordpress.org/reference/functions/_x/
646 *
647 * @param {string} text Text to translate.
648 * @param {string} context Context information for the translators.
649 * @param {string} [domain] Domain to retrieve the translated text.
650 *
651 * @return {string} Translated context string without pipe.
652 */
653
654
655 exports.__ = __;
656
657 var _x = i18n._x.bind(i18n);
658 /**
659 * Translates and retrieves the singular or plural form based on the supplied
660 * number.
661 *
662 * @see https://developer.wordpress.org/reference/functions/_n/
663 *
664 * @param {string} single The text to be used if the number is singular.
665 * @param {string} plural The text to be used if the number is plural.
666 * @param {number} number The number to compare against to use either the
667 * singular or plural form.
668 * @param {string} [domain] Domain to retrieve the translated text.
669 *
670 * @return {string} The translated singular or plural form.
671 */
672
673
674 exports._x = _x;
675
676 var _n = i18n._n.bind(i18n);
677 /**
678 * Translates and retrieves the singular or plural form based on the supplied
679 * number, with gettext context.
680 *
681 * @see https://developer.wordpress.org/reference/functions/_nx/
682 *
683 * @param {string} single The text to be used if the number is singular.
684 * @param {string} plural The text to be used if the number is plural.
685 * @param {number} number The number to compare against to use either the
686 * singular or plural form.
687 * @param {string} context Context information for the translators.
688 * @param {string} [domain] Domain to retrieve the translated text.
689 *
690 * @return {string} The translated singular or plural form.
691 */
692
693
694 exports._n = _n;
695
696 var _nx = i18n._nx.bind(i18n);
697 /**
698 * Check if current locale is RTL.
699 *
700 * **RTL (Right To Left)** is a locale property indicating that text is written from right to left.
701 * For example, the `he` locale (for Hebrew) specifies right-to-left. Arabic (ar) is another common
702 * language written RTL. The opposite of RTL, LTR (Left To Right) is used in other languages,
703 * including English (`en`, `en-US`, `en-GB`, etc.), Spanish (`es`), and French (`fr`).
704 *
705 * @return {boolean} Whether locale is RTL.
706 */
707
708
709 exports._nx = _nx;
710 var isRTL = i18n.isRTL.bind(i18n);
711 exports.isRTL = isRTL;
712
713 },{"./create-i18n":8}],10:[function(require,module,exports){
714 "use strict";
715
716 Object.defineProperty(exports, "__esModule", {
717 value: true
718 });
719 var _exportNames = {
720 sprintf: true,
721 setLocaleData: true,
722 __: true,
723 _x: true,
724 _n: true,
725 _nx: true,
726 isRTL: true
727 };
728 Object.defineProperty(exports, "sprintf", {
729 enumerable: true,
730 get: function get() {
731 return _sprintf.sprintf;
732 }
733 });
734 Object.defineProperty(exports, "setLocaleData", {
735 enumerable: true,
736 get: function get() {
737 return _defaultI18n.setLocaleData;
738 }
739 });
740 Object.defineProperty(exports, "__", {
741 enumerable: true,
742 get: function get() {
743 return _defaultI18n.__;
744 }
745 });
746 Object.defineProperty(exports, "_x", {
747 enumerable: true,
748 get: function get() {
749 return _defaultI18n._x;
750 }
751 });
752 Object.defineProperty(exports, "_n", {
753 enumerable: true,
754 get: function get() {
755 return _defaultI18n._n;
756 }
757 });
758 Object.defineProperty(exports, "_nx", {
759 enumerable: true,
760 get: function get() {
761 return _defaultI18n._nx;
762 }
763 });
764 Object.defineProperty(exports, "isRTL", {
765 enumerable: true,
766 get: function get() {
767 return _defaultI18n.isRTL;
768 }
769 });
770
771 var _sprintf = require("./sprintf");
772
773 var _createI18n = require("./create-i18n");
774
775 Object.keys(_createI18n).forEach(function (key) {
776 if (key === "default" || key === "__esModule") return;
777 if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
778 Object.defineProperty(exports, key, {
779 enumerable: true,
780 get: function get() {
781 return _createI18n[key];
782 }
783 });
784 });
785
786 var _defaultI18n = require("./default-i18n");
787
788 },{"./create-i18n":8,"./default-i18n":9,"./sprintf":11}],11:[function(require,module,exports){
789 "use strict";
790
791 var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
792
793 Object.defineProperty(exports, "__esModule", {
794 value: true
795 });
796 exports.sprintf = sprintf;
797
798 var _memize = _interopRequireDefault(require("memize"));
799
800 var _sprintfJs = _interopRequireDefault(require("sprintf-js"));
801
802 /**
803 * External dependencies
804 */
805
806 /**
807 * Log to console, once per message; or more precisely, per referentially equal
808 * argument set. Because Jed throws errors, we log these to the console instead
809 * to avoid crashing the application.
810 *
811 * @param {...*} args Arguments to pass to `console.error`
812 */
813 var logErrorOnce = (0, _memize.default)(console.error); // eslint-disable-line no-console
814
815 /**
816 * Returns a formatted string. If an error occurs in applying the format, the
817 * original format string is returned.
818 *
819 * @param {string} format The format of the string to generate.
820 * @param {...*} args Arguments to apply to the format.
821 *
822 * @see http://www.diveintojavascript.com/projects/javascript-sprintf
823 *
824 * @return {string} The formatted string.
825 */
826
827 function sprintf(format) {
828 try {
829 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
830 args[_key - 1] = arguments[_key];
831 }
832
833 return _sprintfJs.default.sprintf.apply(_sprintfJs.default, [format].concat(args));
834 } catch (error) {
835 logErrorOnce('sprintf error: \n\n' + error.toString());
836 return format;
837 }
838 }
839
840 },{"@babel/runtime/helpers/interopRequireDefault":3,"memize":13,"sprintf-js":12}],12:[function(require,module,exports){
841 /* global window, exports, define */
842
843 !function() {
844 'use strict'
845
846 var re = {
847 not_string: /[^s]/,
848 not_bool: /[^t]/,
849 not_type: /[^T]/,
850 not_primitive: /[^v]/,
851 number: /[diefg]/,
852 numeric_arg: /[bcdiefguxX]/,
853 json: /[j]/,
854 not_json: /[^j]/,
855 text: /^[^\x25]+/,
856 modulo: /^\x25{2}/,
857 placeholder: /^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,
858 key: /^([a-z_][a-z_\d]*)/i,
859 key_access: /^\.([a-z_][a-z_\d]*)/i,
860 index_access: /^\[(\d+)\]/,
861 sign: /^[+-]/
862 }
863
864 function sprintf(key) {
865 // `arguments` is not an array, but should be fine for this call
866 return sprintf_format(sprintf_parse(key), arguments)
867 }
868
869 function vsprintf(fmt, argv) {
870 return sprintf.apply(null, [fmt].concat(argv || []))
871 }
872
873 function sprintf_format(parse_tree, argv) {
874 var cursor = 1, tree_length = parse_tree.length, arg, output = '', i, k, ph, pad, pad_character, pad_length, is_positive, sign
875 for (i = 0; i < tree_length; i++) {
876 if (typeof parse_tree[i] === 'string') {
877 output += parse_tree[i]
878 }
879 else if (typeof parse_tree[i] === 'object') {
880 ph = parse_tree[i] // convenience purposes only
881 if (ph.keys) { // keyword argument
882 arg = argv[cursor]
883 for (k = 0; k < ph.keys.length; k++) {
884 if (arg == undefined) {
885 throw new Error(sprintf('[sprintf] Cannot access property "%s" of undefined value "%s"', ph.keys[k], ph.keys[k-1]))
886 }
887 arg = arg[ph.keys[k]]
888 }
889 }
890 else if (ph.param_no) { // positional argument (explicit)
891 arg = argv[ph.param_no]
892 }
893 else { // positional argument (implicit)
894 arg = argv[cursor++]
895 }
896
897 if (re.not_type.test(ph.type) && re.not_primitive.test(ph.type) && arg instanceof Function) {
898 arg = arg()
899 }
900
901 if (re.numeric_arg.test(ph.type) && (typeof arg !== 'number' && isNaN(arg))) {
902 throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg))
903 }
904
905 if (re.number.test(ph.type)) {
906 is_positive = arg >= 0
907 }
908
909 switch (ph.type) {
910 case 'b':
911 arg = parseInt(arg, 10).toString(2)
912 break
913 case 'c':
914 arg = String.fromCharCode(parseInt(arg, 10))
915 break
916 case 'd':
917 case 'i':
918 arg = parseInt(arg, 10)
919 break
920 case 'j':
921 arg = JSON.stringify(arg, null, ph.width ? parseInt(ph.width) : 0)
922 break
923 case 'e':
924 arg = ph.precision ? parseFloat(arg).toExponential(ph.precision) : parseFloat(arg).toExponential()
925 break
926 case 'f':
927 arg = ph.precision ? parseFloat(arg).toFixed(ph.precision) : parseFloat(arg)
928 break
929 case 'g':
930 arg = ph.precision ? String(Number(arg.toPrecision(ph.precision))) : parseFloat(arg)
931 break
932 case 'o':
933 arg = (parseInt(arg, 10) >>> 0).toString(8)
934 break
935 case 's':
936 arg = String(arg)
937 arg = (ph.precision ? arg.substring(0, ph.precision) : arg)
938 break
939 case 't':
940 arg = String(!!arg)
941 arg = (ph.precision ? arg.substring(0, ph.precision) : arg)
942 break
943 case 'T':
944 arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase()
945 arg = (ph.precision ? arg.substring(0, ph.precision) : arg)
946 break
947 case 'u':
948 arg = parseInt(arg, 10) >>> 0
949 break
950 case 'v':
951 arg = arg.valueOf()
952 arg = (ph.precision ? arg.substring(0, ph.precision) : arg)
953 break
954 case 'x':
955 arg = (parseInt(arg, 10) >>> 0).toString(16)
956 break
957 case 'X':
958 arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase()
959 break
960 }
961 if (re.json.test(ph.type)) {
962 output += arg
963 }
964 else {
965 if (re.number.test(ph.type) && (!is_positive || ph.sign)) {
966 sign = is_positive ? '+' : '-'
967 arg = arg.toString().replace(re.sign, '')
968 }
969 else {
970 sign = ''
971 }
972 pad_character = ph.pad_char ? ph.pad_char === '0' ? '0' : ph.pad_char.charAt(1) : ' '
973 pad_length = ph.width - (sign + arg).length
974 pad = ph.width ? (pad_length > 0 ? pad_character.repeat(pad_length) : '') : ''
975 output += ph.align ? sign + arg + pad : (pad_character === '0' ? sign + pad + arg : pad + sign + arg)
976 }
977 }
978 }
979 return output
980 }
981
982 var sprintf_cache = Object.create(null)
983
984 function sprintf_parse(fmt) {
985 if (sprintf_cache[fmt]) {
986 return sprintf_cache[fmt]
987 }
988
989 var _fmt = fmt, match, parse_tree = [], arg_names = 0
990 while (_fmt) {
991 if ((match = re.text.exec(_fmt)) !== null) {
992 parse_tree.push(match[0])
993 }
994 else if ((match = re.modulo.exec(_fmt)) !== null) {
995 parse_tree.push('%')
996 }
997 else if ((match = re.placeholder.exec(_fmt)) !== null) {
998 if (match[2]) {
999 arg_names |= 1
1000 var field_list = [], replacement_field = match[2], field_match = []
1001 if ((field_match = re.key.exec(replacement_field)) !== null) {
1002 field_list.push(field_match[1])
1003 while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
1004 if ((field_match = re.key_access.exec(replacement_field)) !== null) {
1005 field_list.push(field_match[1])
1006 }
1007 else if ((field_match = re.index_access.exec(replacement_field)) !== null) {
1008 field_list.push(field_match[1])
1009 }
1010 else {
1011 throw new SyntaxError('[sprintf] failed to parse named argument key')
1012 }
1013 }
1014 }
1015 else {
1016 throw new SyntaxError('[sprintf] failed to parse named argument key')
1017 }
1018 match[2] = field_list
1019 }
1020 else {
1021 arg_names |= 2
1022 }
1023 if (arg_names === 3) {
1024 throw new Error('[sprintf] mixing positional and named placeholders is not (yet) supported')
1025 }
1026
1027 parse_tree.push(
1028 {
1029 placeholder: match[0],
1030 param_no: match[1],
1031 keys: match[2],
1032 sign: match[3],
1033 pad_char: match[4],
1034 align: match[5],
1035 width: match[6],
1036 precision: match[7],
1037 type: match[8]
1038 }
1039 )
1040 }
1041 else {
1042 throw new SyntaxError('[sprintf] unexpected placeholder')
1043 }
1044 _fmt = _fmt.substring(match[0].length)
1045 }
1046 return sprintf_cache[fmt] = parse_tree
1047 }
1048
1049 /**
1050 * export to either browser or node.js
1051 */
1052 /* eslint-disable quote-props */
1053 if (typeof exports !== 'undefined') {
1054 exports['sprintf'] = sprintf
1055 exports['vsprintf'] = vsprintf
1056 }
1057 if (typeof window !== 'undefined') {
1058 window['sprintf'] = sprintf
1059 window['vsprintf'] = vsprintf
1060
1061 if (typeof define === 'function' && define['amd']) {
1062 define(function() {
1063 return {
1064 'sprintf': sprintf,
1065 'vsprintf': vsprintf
1066 }
1067 })
1068 }
1069 }
1070 /* eslint-enable quote-props */
1071 }(); // eslint-disable-line
1072
1073 },{}],13:[function(require,module,exports){
1074 (function (process){
1075 /**
1076 * Memize options object.
1077 *
1078 * @typedef MemizeOptions
1079 *
1080 * @property {number} [maxSize] Maximum size of the cache.
1081 */
1082
1083 /**
1084 * Internal cache entry.
1085 *
1086 * @typedef MemizeCacheNode
1087 *
1088 * @property {?MemizeCacheNode|undefined} [prev] Previous node.
1089 * @property {?MemizeCacheNode|undefined} [next] Next node.
1090 * @property {Array<*>} args Function arguments for cache
1091 * entry.
1092 * @property {*} val Function result.
1093 */
1094
1095 /**
1096 * Properties of the enhanced function for controlling cache.
1097 *
1098 * @typedef MemizeMemoizedFunction
1099 *
1100 * @property {()=>void} clear Clear the cache.
1101 */
1102
1103 /**
1104 * Accepts a function to be memoized, and returns a new memoized function, with
1105 * optional options.
1106 *
1107 * @template {Function} F
1108 *
1109 * @param {F} fn Function to memoize.
1110 * @param {MemizeOptions} [options] Options object.
1111 *
1112 * @return {F & MemizeMemoizedFunction} Memoized function.
1113 */
1114 function memize( fn, options ) {
1115 var size = 0;
1116
1117 /** @type {?MemizeCacheNode|undefined} */
1118 var head;
1119
1120 /** @type {?MemizeCacheNode|undefined} */
1121 var tail;
1122
1123 options = options || {};
1124
1125 function memoized( /* ...args */ ) {
1126 var node = head,
1127 len = arguments.length,
1128 args, i;
1129
1130 searchCache: while ( node ) {
1131 // Perform a shallow equality test to confirm that whether the node
1132 // under test is a candidate for the arguments passed. Two arrays
1133 // are shallowly equal if their length matches and each entry is
1134 // strictly equal between the two sets. Avoid abstracting to a
1135 // function which could incur an arguments leaking deoptimization.
1136
1137 // Check whether node arguments match arguments length
1138 if ( node.args.length !== arguments.length ) {
1139 node = node.next;
1140 continue;
1141 }
1142
1143 // Check whether node arguments match arguments values
1144 for ( i = 0; i < len; i++ ) {
1145 if ( node.args[ i ] !== arguments[ i ] ) {
1146 node = node.next;
1147 continue searchCache;
1148 }
1149 }
1150
1151 // At this point we can assume we've found a match
1152
1153 // Surface matched node to head if not already
1154 if ( node !== head ) {
1155 // As tail, shift to previous. Must only shift if not also
1156 // head, since if both head and tail, there is no previous.
1157 if ( node === tail ) {
1158 tail = node.prev;
1159 }
1160
1161 // Adjust siblings to point to each other. If node was tail,
1162 // this also handles new tail's empty `next` assignment.
1163 /** @type {MemizeCacheNode} */ ( node.prev ).next = node.next;
1164 if ( node.next ) {
1165 node.next.prev = node.prev;
1166 }
1167
1168 node.next = head;
1169 node.prev = null;
1170 /** @type {MemizeCacheNode} */ ( head ).prev = node;
1171 head = node;
1172 }
1173
1174 // Return immediately
1175 return node.val;
1176 }
1177
1178 // No cached value found. Continue to insertion phase:
1179
1180 // Create a copy of arguments (avoid leaking deoptimization)
1181 args = new Array( len );
1182 for ( i = 0; i < len; i++ ) {
1183 args[ i ] = arguments[ i ];
1184 }
1185
1186 node = {
1187 args: args,
1188
1189 // Generate the result from original function
1190 val: fn.apply( null, args ),
1191 };
1192
1193 // Don't need to check whether node is already head, since it would
1194 // have been returned above already if it was
1195
1196 // Shift existing head down list
1197 if ( head ) {
1198 head.prev = node;
1199 node.next = head;
1200 } else {
1201 // If no head, follows that there's no tail (at initial or reset)
1202 tail = node;
1203 }
1204
1205 // Trim tail if we're reached max size and are pending cache insertion
1206 if ( size === /** @type {MemizeOptions} */ ( options ).maxSize ) {
1207 tail = /** @type {MemizeCacheNode} */ ( tail ).prev;
1208 /** @type {MemizeCacheNode} */ ( tail ).next = null;
1209 } else {
1210 size++;
1211 }
1212
1213 head = node;
1214
1215 return node.val;
1216 }
1217
1218 memoized.clear = function() {
1219 head = null;
1220 tail = null;
1221 size = 0;
1222 };
1223
1224 if ( process.env.NODE_ENV === 'test' ) {
1225 // Cache is not exposed in the public API, but used in tests to ensure
1226 // expected list progression
1227 memoized.getCache = function() {
1228 return [ head, tail, size ];
1229 };
1230 }
1231
1232 // Ignore reason: There's not a clear solution to create an intersection of
1233 // the function with additional properties, where the goal is to retain the
1234 // function signature of the incoming argument and add control properties
1235 // on the return value.
1236
1237 // @ts-ignore
1238 return memoized;
1239 }
1240
1241 module.exports = memize;
1242
1243 }).call(this,require('_process'))
1244 },{"_process":14}],14:[function(require,module,exports){
1245 // shim for using process in browser
1246 var process = module.exports = {};
1247
1248 // cached from whatever global is present so that test runners that stub it
1249 // don't break things. But we need to wrap it in a try catch in case it is
1250 // wrapped in strict mode code which doesn't define any globals. It's inside a
1251 // function because try/catches deoptimize in certain engines.
1252
1253 var cachedSetTimeout;
1254 var cachedClearTimeout;
1255
1256 function defaultSetTimout() {
1257 throw new Error('setTimeout has not been defined');
1258 }
1259 function defaultClearTimeout () {
1260 throw new Error('clearTimeout has not been defined');
1261 }
1262 (function () {
1263 try {
1264 if (typeof setTimeout === 'function') {
1265 cachedSetTimeout = setTimeout;
1266 } else {
1267 cachedSetTimeout = defaultSetTimout;
1268 }
1269 } catch (e) {
1270 cachedSetTimeout = defaultSetTimout;
1271 }
1272 try {
1273 if (typeof clearTimeout === 'function') {
1274 cachedClearTimeout = clearTimeout;
1275 } else {
1276 cachedClearTimeout = defaultClearTimeout;
1277 }
1278 } catch (e) {
1279 cachedClearTimeout = defaultClearTimeout;
1280 }
1281 } ())
1282 function runTimeout(fun) {
1283 if (cachedSetTimeout === setTimeout) {
1284 //normal enviroments in sane situations
1285 return setTimeout(fun, 0);
1286 }
1287 // if setTimeout wasn't available but was latter defined
1288 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
1289 cachedSetTimeout = setTimeout;
1290 return setTimeout(fun, 0);
1291 }
1292 try {
1293 // when when somebody has screwed with setTimeout but no I.E. maddness
1294 return cachedSetTimeout(fun, 0);
1295 } catch(e){
1296 try {
1297 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
1298 return cachedSetTimeout.call(null, fun, 0);
1299 } catch(e){
1300 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
1301 return cachedSetTimeout.call(this, fun, 0);
1302 }
1303 }
1304
1305
1306 }
1307 function runClearTimeout(marker) {
1308 if (cachedClearTimeout === clearTimeout) {
1309 //normal enviroments in sane situations
1310 return clearTimeout(marker);
1311 }
1312 // if clearTimeout wasn't available but was latter defined
1313 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
1314 cachedClearTimeout = clearTimeout;
1315 return clearTimeout(marker);
1316 }
1317 try {
1318 // when when somebody has screwed with setTimeout but no I.E. maddness
1319 return cachedClearTimeout(marker);
1320 } catch (e){
1321 try {
1322 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
1323 return cachedClearTimeout.call(null, marker);
1324 } catch (e){
1325 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
1326 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
1327 return cachedClearTimeout.call(this, marker);
1328 }
1329 }
1330
1331
1332
1333 }
1334 var queue = [];
1335 var draining = false;
1336 var currentQueue;
1337 var queueIndex = -1;
1338
1339 function cleanUpNextTick() {
1340 if (!draining || !currentQueue) {
1341 return;
1342 }
1343 draining = false;
1344 if (currentQueue.length) {
1345 queue = currentQueue.concat(queue);
1346 } else {
1347 queueIndex = -1;
1348 }
1349 if (queue.length) {
1350 drainQueue();
1351 }
1352 }
1353
1354 function drainQueue() {
1355 if (draining) {
1356 return;
1357 }
1358 var timeout = runTimeout(cleanUpNextTick);
1359 draining = true;
1360
1361 var len = queue.length;
1362 while(len) {
1363 currentQueue = queue;
1364 queue = [];
1365 while (++queueIndex < len) {
1366 if (currentQueue) {
1367 currentQueue[queueIndex].run();
1368 }
1369 }
1370 queueIndex = -1;
1371 len = queue.length;
1372 }
1373 currentQueue = null;
1374 draining = false;
1375 runClearTimeout(timeout);
1376 }
1377
1378 process.nextTick = function (fun) {
1379 var args = new Array(arguments.length - 1);
1380 if (arguments.length > 1) {
1381 for (var i = 1; i < arguments.length; i++) {
1382 args[i - 1] = arguments[i];
1383 }
1384 }
1385 queue.push(new Item(fun, args));
1386 if (queue.length === 1 && !draining) {
1387 runTimeout(drainQueue);
1388 }
1389 };
1390
1391 // v8 likes predictible objects
1392 function Item(fun, array) {
1393 this.fun = fun;
1394 this.array = array;
1395 }
1396 Item.prototype.run = function () {
1397 this.fun.apply(null, this.array);
1398 };
1399 process.title = 'browser';
1400 process.browser = true;
1401 process.env = {};
1402 process.argv = [];
1403 process.version = ''; // empty string to avoid regexp issues
1404 process.versions = {};
1405
1406 function noop() {}
1407
1408 process.on = noop;
1409 process.addListener = noop;
1410 process.once = noop;
1411 process.off = noop;
1412 process.removeListener = noop;
1413 process.removeAllListeners = noop;
1414 process.emit = noop;
1415 process.prependListener = noop;
1416 process.prependOnceListener = noop;
1417
1418 process.listeners = function (name) { return [] }
1419
1420 process.binding = function (name) {
1421 throw new Error('process.binding is not supported');
1422 };
1423
1424 process.cwd = function () { return '/' };
1425 process.chdir = function (dir) {
1426 throw new Error('process.chdir is not supported');
1427 };
1428 process.umask = function() { return 0; };
1429
1430 },{}],15:[function(require,module,exports){
1431 'use strict';
1432
1433 function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
1434
1435 var pluralForms = _interopDefault(require('@tannin/plural-forms'));
1436
1437 /**
1438 * Tannin constructor options.
1439 *
1440 * @typedef {Object} TanninOptions
1441 *
1442 * @property {string} [contextDelimiter] Joiner in string lookup with context.
1443 * @property {Function} [onMissingKey] Callback to invoke when key missing.
1444 */
1445
1446 /**
1447 * Domain metadata.
1448 *
1449 * @typedef {Object} TanninDomainMetadata
1450 *
1451 * @property {string} [domain] Domain name.
1452 * @property {string} [lang] Language code.
1453 * @property {(string|Function)} [plural_forms] Plural forms expression or
1454 * function evaluator.
1455 */
1456
1457 /**
1458 * Domain translation pair respectively representing the singular and plural
1459 * translation.
1460 *
1461 * @typedef {[string,string]} TanninTranslation
1462 */
1463
1464 /**
1465 * Locale data domain. The key is used as reference for lookup, the value an
1466 * array of two string entries respectively representing the singular and plural
1467 * translation.
1468 *
1469 * @typedef {{[key:string]:TanninDomainMetadata|TanninTranslation,'':TanninDomainMetadata|TanninTranslation}} TanninLocaleDomain
1470 */
1471
1472 /**
1473 * Jed-formatted locale data.
1474 *
1475 * @see http://messageformat.github.io/Jed/
1476 *
1477 * @typedef {{[domain:string]:TanninLocaleDomain}} TanninLocaleData
1478 */
1479
1480 /**
1481 * Default Tannin constructor options.
1482 *
1483 * @type {TanninOptions}
1484 */
1485 var DEFAULT_OPTIONS = {
1486 contextDelimiter: '\u0004',
1487 onMissingKey: null,
1488 };
1489
1490 /**
1491 * Given a specific locale data's config `plural_forms` value, returns the
1492 * expression.
1493 *
1494 * @example
1495 *
1496 * ```
1497 * getPluralExpression( 'nplurals=2; plural=(n != 1);' ) === '(n != 1)'
1498 * ```
1499 *
1500 * @param {string} pf Locale data plural forms.
1501 *
1502 * @return {string} Plural forms expression.
1503 */
1504 function getPluralExpression( pf ) {
1505 var parts, i, part;
1506
1507 parts = pf.split( ';' );
1508
1509 for ( i = 0; i < parts.length; i++ ) {
1510 part = parts[ i ].trim();
1511 if ( part.indexOf( 'plural=' ) === 0 ) {
1512 return part.substr( 7 );
1513 }
1514 }
1515 }
1516
1517 /**
1518 * Tannin constructor.
1519 *
1520 * @class
1521 *
1522 * @param {TanninLocaleData} data Jed-formatted locale data.
1523 * @param {TanninOptions} [options] Tannin options.
1524 */
1525 function Tannin( data, options ) {
1526 var key;
1527
1528 /**
1529 * Jed-formatted locale data.
1530 *
1531 * @name Tannin#data
1532 * @type {TanninLocaleData}
1533 */
1534 this.data = data;
1535
1536 /**
1537 * Plural forms function cache, keyed by plural forms string.
1538 *
1539 * @name Tannin#pluralForms
1540 * @type {Object<string,Function>}
1541 */
1542 this.pluralForms = {};
1543
1544 /**
1545 * Effective options for instance, including defaults.
1546 *
1547 * @name Tannin#options
1548 * @type {TanninOptions}
1549 */
1550 this.options = {};
1551
1552 for ( key in DEFAULT_OPTIONS ) {
1553 this.options[ key ] = options !== undefined && key in options
1554 ? options[ key ]
1555 : DEFAULT_OPTIONS[ key ];
1556 }
1557 }
1558
1559 /**
1560 * Returns the plural form index for the given domain and value.
1561 *
1562 * @param {string} domain Domain on which to calculate plural form.
1563 * @param {number} n Value for which plural form is to be calculated.
1564 *
1565 * @return {number} Plural form index.
1566 */
1567 Tannin.prototype.getPluralForm = function( domain, n ) {
1568 var getPluralForm = this.pluralForms[ domain ],
1569 config, plural, pf;
1570
1571 if ( ! getPluralForm ) {
1572 config = this.data[ domain ][ '' ];
1573
1574 pf = (
1575 config[ 'Plural-Forms' ] ||
1576 config[ 'plural-forms' ] ||
1577 // Ignore reason: As known, there's no way to document the empty
1578 // string property on a key to guarantee this as metadata.
1579 // @ts-ignore
1580 config.plural_forms
1581 );
1582
1583 if ( typeof pf !== 'function' ) {
1584 plural = getPluralExpression(
1585 config[ 'Plural-Forms' ] ||
1586 config[ 'plural-forms' ] ||
1587 // Ignore reason: As known, there's no way to document the empty
1588 // string property on a key to guarantee this as metadata.
1589 // @ts-ignore
1590 config.plural_forms
1591 );
1592
1593 pf = pluralForms( plural );
1594 }
1595
1596 getPluralForm = this.pluralForms[ domain ] = pf;
1597 }
1598
1599 return getPluralForm( n );
1600 };
1601
1602 /**
1603 * Translate a string.
1604 *
1605 * @param {string} domain Translation domain.
1606 * @param {string|void} context Context distinguishing terms of the same name.
1607 * @param {string} singular Primary key for translation lookup.
1608 * @param {string=} plural Fallback value used for non-zero plural
1609 * form index.
1610 * @param {number=} n Value to use in calculating plural form.
1611 *
1612 * @return {string} Translated string.
1613 */
1614 Tannin.prototype.dcnpgettext = function( domain, context, singular, plural, n ) {
1615 var index, key, entry;
1616
1617 if ( n === undefined ) {
1618 // Default to singular.
1619 index = 0;
1620 } else {
1621 // Find index by evaluating plural form for value.
1622 index = this.getPluralForm( domain, n );
1623 }
1624
1625 key = singular;
1626
1627 // If provided, context is prepended to key with delimiter.
1628 if ( context ) {
1629 key = context + this.options.contextDelimiter + singular;
1630 }
1631
1632 entry = this.data[ domain ][ key ];
1633
1634 // Verify not only that entry exists, but that the intended index is within
1635 // range and non-empty.
1636 if ( entry && entry[ index ] ) {
1637 return entry[ index ];
1638 }
1639
1640 if ( this.options.onMissingKey ) {
1641 this.options.onMissingKey( singular, domain );
1642 }
1643
1644 // If entry not found, fall back to singular vs. plural with zero index
1645 // representing the singular value.
1646 return index === 0 ? singular : plural;
1647 };
1648
1649 module.exports = Tannin;
1650
1651 },{"@tannin/plural-forms":6}]},{},[1]);
1652