|
1 this["wp"] = this["wp"] || {}; this["wp"]["i18n"] = |
|
2 /******/ (function(modules) { // webpackBootstrap |
|
3 /******/ // The module cache |
|
4 /******/ var installedModules = {}; |
|
5 /******/ |
|
6 /******/ // The require function |
|
7 /******/ function __webpack_require__(moduleId) { |
|
8 /******/ |
|
9 /******/ // Check if module is in cache |
|
10 /******/ if(installedModules[moduleId]) { |
|
11 /******/ return installedModules[moduleId].exports; |
|
12 /******/ } |
|
13 /******/ // Create a new module (and put it into the cache) |
|
14 /******/ var module = installedModules[moduleId] = { |
|
15 /******/ i: moduleId, |
|
16 /******/ l: false, |
|
17 /******/ exports: {} |
|
18 /******/ }; |
|
19 /******/ |
|
20 /******/ // Execute the module function |
|
21 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
|
22 /******/ |
|
23 /******/ // Flag the module as loaded |
|
24 /******/ module.l = true; |
|
25 /******/ |
|
26 /******/ // Return the exports of the module |
|
27 /******/ return module.exports; |
|
28 /******/ } |
|
29 /******/ |
|
30 /******/ |
|
31 /******/ // expose the modules object (__webpack_modules__) |
|
32 /******/ __webpack_require__.m = modules; |
|
33 /******/ |
|
34 /******/ // expose the module cache |
|
35 /******/ __webpack_require__.c = installedModules; |
|
36 /******/ |
|
37 /******/ // define getter function for harmony exports |
|
38 /******/ __webpack_require__.d = function(exports, name, getter) { |
|
39 /******/ if(!__webpack_require__.o(exports, name)) { |
|
40 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); |
|
41 /******/ } |
|
42 /******/ }; |
|
43 /******/ |
|
44 /******/ // define __esModule on exports |
|
45 /******/ __webpack_require__.r = function(exports) { |
|
46 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
|
47 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
|
48 /******/ } |
|
49 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
|
50 /******/ }; |
|
51 /******/ |
|
52 /******/ // create a fake namespace object |
|
53 /******/ // mode & 1: value is a module id, require it |
|
54 /******/ // mode & 2: merge all properties of value into the ns |
|
55 /******/ // mode & 4: return value when already ns object |
|
56 /******/ // mode & 8|1: behave like require |
|
57 /******/ __webpack_require__.t = function(value, mode) { |
|
58 /******/ if(mode & 1) value = __webpack_require__(value); |
|
59 /******/ if(mode & 8) return value; |
|
60 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; |
|
61 /******/ var ns = Object.create(null); |
|
62 /******/ __webpack_require__.r(ns); |
|
63 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); |
|
64 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); |
|
65 /******/ return ns; |
|
66 /******/ }; |
|
67 /******/ |
|
68 /******/ // getDefaultExport function for compatibility with non-harmony modules |
|
69 /******/ __webpack_require__.n = function(module) { |
|
70 /******/ var getter = module && module.__esModule ? |
|
71 /******/ function getDefault() { return module['default']; } : |
|
72 /******/ function getModuleExports() { return module; }; |
|
73 /******/ __webpack_require__.d(getter, 'a', getter); |
|
74 /******/ return getter; |
|
75 /******/ }; |
|
76 /******/ |
|
77 /******/ // Object.prototype.hasOwnProperty.call |
|
78 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; |
|
79 /******/ |
|
80 /******/ // __webpack_public_path__ |
|
81 /******/ __webpack_require__.p = ""; |
|
82 /******/ |
|
83 /******/ |
|
84 /******/ // Load entry module and return exports |
|
85 /******/ return __webpack_require__(__webpack_require__.s = 376); |
|
86 /******/ }) |
|
87 /************************************************************************/ |
|
88 /******/ ({ |
|
89 |
|
90 /***/ 137: |
|
91 /***/ (function(module, exports, __webpack_require__) { |
|
92 |
|
93 var __WEBPACK_AMD_DEFINE_RESULT__;/* global window, exports, define */ |
|
94 |
|
95 !function() { |
|
96 'use strict' |
|
97 |
|
98 var re = { |
|
99 not_string: /[^s]/, |
|
100 not_bool: /[^t]/, |
|
101 not_type: /[^T]/, |
|
102 not_primitive: /[^v]/, |
|
103 number: /[diefg]/, |
|
104 numeric_arg: /[bcdiefguxX]/, |
|
105 json: /[j]/, |
|
106 not_json: /[^j]/, |
|
107 text: /^[^\x25]+/, |
|
108 modulo: /^\x25{2}/, |
|
109 placeholder: /^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/, |
|
110 key: /^([a-z_][a-z_\d]*)/i, |
|
111 key_access: /^\.([a-z_][a-z_\d]*)/i, |
|
112 index_access: /^\[(\d+)\]/, |
|
113 sign: /^[+-]/ |
|
114 } |
|
115 |
|
116 function sprintf(key) { |
|
117 // `arguments` is not an array, but should be fine for this call |
|
118 return sprintf_format(sprintf_parse(key), arguments) |
|
119 } |
|
120 |
|
121 function vsprintf(fmt, argv) { |
|
122 return sprintf.apply(null, [fmt].concat(argv || [])) |
|
123 } |
|
124 |
|
125 function sprintf_format(parse_tree, argv) { |
|
126 var cursor = 1, tree_length = parse_tree.length, arg, output = '', i, k, ph, pad, pad_character, pad_length, is_positive, sign |
|
127 for (i = 0; i < tree_length; i++) { |
|
128 if (typeof parse_tree[i] === 'string') { |
|
129 output += parse_tree[i] |
|
130 } |
|
131 else if (typeof parse_tree[i] === 'object') { |
|
132 ph = parse_tree[i] // convenience purposes only |
|
133 if (ph.keys) { // keyword argument |
|
134 arg = argv[cursor] |
|
135 for (k = 0; k < ph.keys.length; k++) { |
|
136 if (arg == undefined) { |
|
137 throw new Error(sprintf('[sprintf] Cannot access property "%s" of undefined value "%s"', ph.keys[k], ph.keys[k-1])) |
|
138 } |
|
139 arg = arg[ph.keys[k]] |
|
140 } |
|
141 } |
|
142 else if (ph.param_no) { // positional argument (explicit) |
|
143 arg = argv[ph.param_no] |
|
144 } |
|
145 else { // positional argument (implicit) |
|
146 arg = argv[cursor++] |
|
147 } |
|
148 |
|
149 if (re.not_type.test(ph.type) && re.not_primitive.test(ph.type) && arg instanceof Function) { |
|
150 arg = arg() |
|
151 } |
|
152 |
|
153 if (re.numeric_arg.test(ph.type) && (typeof arg !== 'number' && isNaN(arg))) { |
|
154 throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg)) |
|
155 } |
|
156 |
|
157 if (re.number.test(ph.type)) { |
|
158 is_positive = arg >= 0 |
|
159 } |
|
160 |
|
161 switch (ph.type) { |
|
162 case 'b': |
|
163 arg = parseInt(arg, 10).toString(2) |
|
164 break |
|
165 case 'c': |
|
166 arg = String.fromCharCode(parseInt(arg, 10)) |
|
167 break |
|
168 case 'd': |
|
169 case 'i': |
|
170 arg = parseInt(arg, 10) |
|
171 break |
|
172 case 'j': |
|
173 arg = JSON.stringify(arg, null, ph.width ? parseInt(ph.width) : 0) |
|
174 break |
|
175 case 'e': |
|
176 arg = ph.precision ? parseFloat(arg).toExponential(ph.precision) : parseFloat(arg).toExponential() |
|
177 break |
|
178 case 'f': |
|
179 arg = ph.precision ? parseFloat(arg).toFixed(ph.precision) : parseFloat(arg) |
|
180 break |
|
181 case 'g': |
|
182 arg = ph.precision ? String(Number(arg.toPrecision(ph.precision))) : parseFloat(arg) |
|
183 break |
|
184 case 'o': |
|
185 arg = (parseInt(arg, 10) >>> 0).toString(8) |
|
186 break |
|
187 case 's': |
|
188 arg = String(arg) |
|
189 arg = (ph.precision ? arg.substring(0, ph.precision) : arg) |
|
190 break |
|
191 case 't': |
|
192 arg = String(!!arg) |
|
193 arg = (ph.precision ? arg.substring(0, ph.precision) : arg) |
|
194 break |
|
195 case 'T': |
|
196 arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase() |
|
197 arg = (ph.precision ? arg.substring(0, ph.precision) : arg) |
|
198 break |
|
199 case 'u': |
|
200 arg = parseInt(arg, 10) >>> 0 |
|
201 break |
|
202 case 'v': |
|
203 arg = arg.valueOf() |
|
204 arg = (ph.precision ? arg.substring(0, ph.precision) : arg) |
|
205 break |
|
206 case 'x': |
|
207 arg = (parseInt(arg, 10) >>> 0).toString(16) |
|
208 break |
|
209 case 'X': |
|
210 arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase() |
|
211 break |
|
212 } |
|
213 if (re.json.test(ph.type)) { |
|
214 output += arg |
|
215 } |
|
216 else { |
|
217 if (re.number.test(ph.type) && (!is_positive || ph.sign)) { |
|
218 sign = is_positive ? '+' : '-' |
|
219 arg = arg.toString().replace(re.sign, '') |
|
220 } |
|
221 else { |
|
222 sign = '' |
|
223 } |
|
224 pad_character = ph.pad_char ? ph.pad_char === '0' ? '0' : ph.pad_char.charAt(1) : ' ' |
|
225 pad_length = ph.width - (sign + arg).length |
|
226 pad = ph.width ? (pad_length > 0 ? pad_character.repeat(pad_length) : '') : '' |
|
227 output += ph.align ? sign + arg + pad : (pad_character === '0' ? sign + pad + arg : pad + sign + arg) |
|
228 } |
|
229 } |
|
230 } |
|
231 return output |
|
232 } |
|
233 |
|
234 var sprintf_cache = Object.create(null) |
|
235 |
|
236 function sprintf_parse(fmt) { |
|
237 if (sprintf_cache[fmt]) { |
|
238 return sprintf_cache[fmt] |
|
239 } |
|
240 |
|
241 var _fmt = fmt, match, parse_tree = [], arg_names = 0 |
|
242 while (_fmt) { |
|
243 if ((match = re.text.exec(_fmt)) !== null) { |
|
244 parse_tree.push(match[0]) |
|
245 } |
|
246 else if ((match = re.modulo.exec(_fmt)) !== null) { |
|
247 parse_tree.push('%') |
|
248 } |
|
249 else if ((match = re.placeholder.exec(_fmt)) !== null) { |
|
250 if (match[2]) { |
|
251 arg_names |= 1 |
|
252 var field_list = [], replacement_field = match[2], field_match = [] |
|
253 if ((field_match = re.key.exec(replacement_field)) !== null) { |
|
254 field_list.push(field_match[1]) |
|
255 while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') { |
|
256 if ((field_match = re.key_access.exec(replacement_field)) !== null) { |
|
257 field_list.push(field_match[1]) |
|
258 } |
|
259 else if ((field_match = re.index_access.exec(replacement_field)) !== null) { |
|
260 field_list.push(field_match[1]) |
|
261 } |
|
262 else { |
|
263 throw new SyntaxError('[sprintf] failed to parse named argument key') |
|
264 } |
|
265 } |
|
266 } |
|
267 else { |
|
268 throw new SyntaxError('[sprintf] failed to parse named argument key') |
|
269 } |
|
270 match[2] = field_list |
|
271 } |
|
272 else { |
|
273 arg_names |= 2 |
|
274 } |
|
275 if (arg_names === 3) { |
|
276 throw new Error('[sprintf] mixing positional and named placeholders is not (yet) supported') |
|
277 } |
|
278 |
|
279 parse_tree.push( |
|
280 { |
|
281 placeholder: match[0], |
|
282 param_no: match[1], |
|
283 keys: match[2], |
|
284 sign: match[3], |
|
285 pad_char: match[4], |
|
286 align: match[5], |
|
287 width: match[6], |
|
288 precision: match[7], |
|
289 type: match[8] |
|
290 } |
|
291 ) |
|
292 } |
|
293 else { |
|
294 throw new SyntaxError('[sprintf] unexpected placeholder') |
|
295 } |
|
296 _fmt = _fmt.substring(match[0].length) |
|
297 } |
|
298 return sprintf_cache[fmt] = parse_tree |
|
299 } |
|
300 |
|
301 /** |
|
302 * export to either browser or node.js |
|
303 */ |
|
304 /* eslint-disable quote-props */ |
|
305 if (true) { |
|
306 exports['sprintf'] = sprintf |
|
307 exports['vsprintf'] = vsprintf |
|
308 } |
|
309 if (typeof window !== 'undefined') { |
|
310 window['sprintf'] = sprintf |
|
311 window['vsprintf'] = vsprintf |
|
312 |
|
313 if (true) { |
|
314 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { |
|
315 return { |
|
316 'sprintf': sprintf, |
|
317 'vsprintf': vsprintf |
|
318 } |
|
319 }).call(exports, __webpack_require__, exports, module), |
|
320 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) |
|
321 } |
|
322 } |
|
323 /* eslint-enable quote-props */ |
|
324 }(); // eslint-disable-line |
|
325 |
|
326 |
|
327 /***/ }), |
|
328 |
|
329 /***/ 15: |
|
330 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
331 |
|
332 "use strict"; |
|
333 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; }); |
|
334 function _defineProperty(obj, key, value) { |
|
335 if (key in obj) { |
|
336 Object.defineProperty(obj, key, { |
|
337 value: value, |
|
338 enumerable: true, |
|
339 configurable: true, |
|
340 writable: true |
|
341 }); |
|
342 } else { |
|
343 obj[key] = value; |
|
344 } |
|
345 |
|
346 return obj; |
|
347 } |
|
348 |
|
349 /***/ }), |
|
350 |
|
351 /***/ 376: |
|
352 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
353 |
|
354 "use strict"; |
|
355 __webpack_require__.r(__webpack_exports__); |
|
356 |
|
357 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread.js |
|
358 var objectSpread = __webpack_require__(7); |
|
359 |
|
360 // CONCATENATED MODULE: ./node_modules/@tannin/postfix/index.js |
|
361 var PRECEDENCE, OPENERS, TERMINATORS, PATTERN; |
|
362 |
|
363 /** |
|
364 * Operator precedence mapping. |
|
365 * |
|
366 * @type {Object} |
|
367 */ |
|
368 PRECEDENCE = { |
|
369 '(': 9, |
|
370 '!': 8, |
|
371 '*': 7, |
|
372 '/': 7, |
|
373 '%': 7, |
|
374 '+': 6, |
|
375 '-': 6, |
|
376 '<': 5, |
|
377 '<=': 5, |
|
378 '>': 5, |
|
379 '>=': 5, |
|
380 '==': 4, |
|
381 '!=': 4, |
|
382 '&&': 3, |
|
383 '||': 2, |
|
384 '?': 1, |
|
385 '?:': 1, |
|
386 }; |
|
387 |
|
388 /** |
|
389 * Characters which signal pair opening, to be terminated by terminators. |
|
390 * |
|
391 * @type {string[]} |
|
392 */ |
|
393 OPENERS = [ '(', '?' ]; |
|
394 |
|
395 /** |
|
396 * Characters which signal pair termination, the value an array with the |
|
397 * opener as its first member. The second member is an optional operator |
|
398 * replacement to push to the stack. |
|
399 * |
|
400 * @type {string[]} |
|
401 */ |
|
402 TERMINATORS = { |
|
403 ')': [ '(' ], |
|
404 ':': [ '?', '?:' ], |
|
405 }; |
|
406 |
|
407 /** |
|
408 * Pattern matching operators and openers. |
|
409 * |
|
410 * @type {RegExp} |
|
411 */ |
|
412 PATTERN = /<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/; |
|
413 |
|
414 /** |
|
415 * Given a C expression, returns the equivalent postfix (Reverse Polish) |
|
416 * notation terms as an array. |
|
417 * |
|
418 * If a postfix string is desired, simply `.join( ' ' )` the result. |
|
419 * |
|
420 * @example |
|
421 * |
|
422 * ```js |
|
423 * import postfix from '@tannin/postfix'; |
|
424 * |
|
425 * postfix( 'n > 1' ); |
|
426 * // ⇒ [ 'n', '1', '>' ] |
|
427 * ``` |
|
428 * |
|
429 * @param {string} expression C expression. |
|
430 * |
|
431 * @return {string[]} Postfix terms. |
|
432 */ |
|
433 function postfix( expression ) { |
|
434 var terms = [], |
|
435 stack = [], |
|
436 match, operator, term, element; |
|
437 |
|
438 while ( ( match = expression.match( PATTERN ) ) ) { |
|
439 operator = match[ 0 ]; |
|
440 |
|
441 // Term is the string preceding the operator match. It may contain |
|
442 // whitespace, and may be empty (if operator is at beginning). |
|
443 term = expression.substr( 0, match.index ).trim(); |
|
444 if ( term ) { |
|
445 terms.push( term ); |
|
446 } |
|
447 |
|
448 while ( ( element = stack.pop() ) ) { |
|
449 if ( TERMINATORS[ operator ] ) { |
|
450 if ( TERMINATORS[ operator ][ 0 ] === element ) { |
|
451 // Substitution works here under assumption that because |
|
452 // the assigned operator will no longer be a terminator, it |
|
453 // will be pushed to the stack during the condition below. |
|
454 operator = TERMINATORS[ operator ][ 1 ] || operator; |
|
455 break; |
|
456 } |
|
457 } else if ( OPENERS.indexOf( element ) >= 0 || PRECEDENCE[ element ] < PRECEDENCE[ operator ] ) { |
|
458 // Push to stack if either an opener or when pop reveals an |
|
459 // element of lower precedence. |
|
460 stack.push( element ); |
|
461 break; |
|
462 } |
|
463 |
|
464 // For each popped from stack, push to terms. |
|
465 terms.push( element ); |
|
466 } |
|
467 |
|
468 if ( ! TERMINATORS[ operator ] ) { |
|
469 stack.push( operator ); |
|
470 } |
|
471 |
|
472 // Slice matched fragment from expression to continue match. |
|
473 expression = expression.substr( match.index + operator.length ); |
|
474 } |
|
475 |
|
476 // Push remainder of operand, if exists, to terms. |
|
477 expression = expression.trim(); |
|
478 if ( expression ) { |
|
479 terms.push( expression ); |
|
480 } |
|
481 |
|
482 // Pop remaining items from stack into terms. |
|
483 return terms.concat( stack.reverse() ); |
|
484 } |
|
485 |
|
486 // CONCATENATED MODULE: ./node_modules/@tannin/evaluate/index.js |
|
487 /** |
|
488 * Operator callback functions. |
|
489 * |
|
490 * @type {Object} |
|
491 */ |
|
492 var OPERATORS = { |
|
493 '!': function( a ) { |
|
494 return ! a; |
|
495 }, |
|
496 '*': function( a, b ) { |
|
497 return a * b; |
|
498 }, |
|
499 '/': function( a, b ) { |
|
500 return a / b; |
|
501 }, |
|
502 '%': function( a, b ) { |
|
503 return a % b; |
|
504 }, |
|
505 '+': function( a, b ) { |
|
506 return a + b; |
|
507 }, |
|
508 '-': function( a, b ) { |
|
509 return a - b; |
|
510 }, |
|
511 '<': function( a, b ) { |
|
512 return a < b; |
|
513 }, |
|
514 '<=': function( a, b ) { |
|
515 return a <= b; |
|
516 }, |
|
517 '>': function( a, b ) { |
|
518 return a > b; |
|
519 }, |
|
520 '>=': function( a, b ) { |
|
521 return a >= b; |
|
522 }, |
|
523 '==': function( a, b ) { |
|
524 return a === b; |
|
525 }, |
|
526 '!=': function( a, b ) { |
|
527 return a !== b; |
|
528 }, |
|
529 '&&': function( a, b ) { |
|
530 return a && b; |
|
531 }, |
|
532 '||': function( a, b ) { |
|
533 return a || b; |
|
534 }, |
|
535 '?:': function( a, b, c ) { |
|
536 if ( a ) { |
|
537 throw b; |
|
538 } |
|
539 |
|
540 return c; |
|
541 }, |
|
542 }; |
|
543 |
|
544 /** |
|
545 * Given an array of postfix terms and operand variables, returns the result of |
|
546 * the postfix evaluation. |
|
547 * |
|
548 * @example |
|
549 * |
|
550 * ```js |
|
551 * import evaluate from '@tannin/evaluate'; |
|
552 * |
|
553 * // 3 + 4 * 5 / 6 ⇒ '3 4 5 * 6 / +' |
|
554 * const terms = [ '3', '4', '5', '*', '6', '/', '+' ]; |
|
555 * |
|
556 * evaluate( terms, {} ); |
|
557 * // ⇒ 6.333333333333334 |
|
558 * ``` |
|
559 * |
|
560 * @param {string[]} postfix Postfix terms. |
|
561 * @param {Object} variables Operand variables. |
|
562 * |
|
563 * @return {*} Result of evaluation. |
|
564 */ |
|
565 function evaluate_evaluate( postfix, variables ) { |
|
566 var stack = [], |
|
567 i, j, args, getOperatorResult, term, value; |
|
568 |
|
569 for ( i = 0; i < postfix.length; i++ ) { |
|
570 term = postfix[ i ]; |
|
571 |
|
572 getOperatorResult = OPERATORS[ term ]; |
|
573 if ( getOperatorResult ) { |
|
574 // Pop from stack by number of function arguments. |
|
575 j = getOperatorResult.length; |
|
576 args = Array( j ); |
|
577 while ( j-- ) { |
|
578 args[ j ] = stack.pop(); |
|
579 } |
|
580 |
|
581 try { |
|
582 value = getOperatorResult.apply( null, args ); |
|
583 } catch ( earlyReturn ) { |
|
584 return earlyReturn; |
|
585 } |
|
586 } else if ( variables.hasOwnProperty( term ) ) { |
|
587 value = variables[ term ]; |
|
588 } else { |
|
589 value = +term; |
|
590 } |
|
591 |
|
592 stack.push( value ); |
|
593 } |
|
594 |
|
595 return stack[ 0 ]; |
|
596 } |
|
597 |
|
598 // CONCATENATED MODULE: ./node_modules/@tannin/compile/index.js |
|
599 |
|
600 |
|
601 |
|
602 /** |
|
603 * Given a C expression, returns a function which can be called to evaluate its |
|
604 * result. |
|
605 * |
|
606 * @example |
|
607 * |
|
608 * ```js |
|
609 * import compile from '@tannin/compile'; |
|
610 * |
|
611 * const evaluate = compile( 'n > 1' ); |
|
612 * |
|
613 * evaluate( { n: 2 } ); |
|
614 * // ⇒ true |
|
615 * ``` |
|
616 * |
|
617 * @param {string} expression C expression. |
|
618 * |
|
619 * @return {Function} Compiled evaluator. |
|
620 */ |
|
621 function compile( expression ) { |
|
622 var terms = postfix( expression ); |
|
623 |
|
624 return function( variables ) { |
|
625 return evaluate_evaluate( terms, variables ); |
|
626 }; |
|
627 } |
|
628 |
|
629 // CONCATENATED MODULE: ./node_modules/@tannin/plural-forms/index.js |
|
630 |
|
631 |
|
632 /** |
|
633 * Given a C expression, returns a function which, when called with a value, |
|
634 * evaluates the result with the value assumed to be the "n" variable of the |
|
635 * expression. The result will be coerced to its numeric equivalent. |
|
636 * |
|
637 * @param {string} expression C expression. |
|
638 * |
|
639 * @return {Function} Evaluator function. |
|
640 */ |
|
641 function pluralForms( expression ) { |
|
642 var evaluate = compile( expression ); |
|
643 |
|
644 return function( n ) { |
|
645 return +evaluate( { n: n } ); |
|
646 }; |
|
647 } |
|
648 |
|
649 // CONCATENATED MODULE: ./node_modules/tannin/index.js |
|
650 |
|
651 |
|
652 /** |
|
653 * Tannin constructor options. |
|
654 * |
|
655 * @property {?string} contextDelimiter Joiner in string lookup with context. |
|
656 * @property {?Function} onMissingKey Callback to invoke when key missing. |
|
657 * |
|
658 * @type {Object} |
|
659 * |
|
660 * @typedef {TanninOptions} |
|
661 */ |
|
662 |
|
663 /** |
|
664 * Default Tannin constructor options. |
|
665 * |
|
666 * @type {TanninOptions} |
|
667 */ |
|
668 var DEFAULT_OPTIONS = { |
|
669 contextDelimiter: '\u0004', |
|
670 onMissingKey: null, |
|
671 }; |
|
672 |
|
673 /** |
|
674 * Given a specific locale data's config `plural_forms` value, returns the |
|
675 * expression. |
|
676 * |
|
677 * @example |
|
678 * |
|
679 * ``` |
|
680 * getPluralExpression( 'nplurals=2; plural=(n != 1);' ) === '(n != 1)' |
|
681 * ``` |
|
682 * |
|
683 * @param {string} pf Locale data plural forms. |
|
684 * |
|
685 * @return {string} Plural forms expression. |
|
686 */ |
|
687 function getPluralExpression( pf ) { |
|
688 var parts, i, part; |
|
689 |
|
690 parts = pf.split( ';' ); |
|
691 |
|
692 for ( i = 0; i < parts.length; i++ ) { |
|
693 part = parts[ i ].trim(); |
|
694 if ( part.indexOf( 'plural=' ) === 0 ) { |
|
695 return part.substr( 7 ); |
|
696 } |
|
697 } |
|
698 } |
|
699 |
|
700 /** |
|
701 * Tannin constructor. |
|
702 * |
|
703 * @param {Object} data Jed-formatted locale data. |
|
704 * @param {TanninOptions} options Tannin options. |
|
705 */ |
|
706 function Tannin( data, options ) { |
|
707 var key; |
|
708 |
|
709 this.data = data; |
|
710 this.pluralForms = {}; |
|
711 |
|
712 options = options || {}; |
|
713 this.options = {}; |
|
714 for ( key in DEFAULT_OPTIONS ) { |
|
715 this.options[ key ] = options[ key ] || DEFAULT_OPTIONS[ key ]; |
|
716 } |
|
717 } |
|
718 |
|
719 /** |
|
720 * Returns the plural form index for the given domain and value. |
|
721 * |
|
722 * @param {string} domain Domain on which to calculate plural form. |
|
723 * @param {number} n Value for which plural form is to be calculated. |
|
724 * |
|
725 * @return {number} Plural form index. |
|
726 */ |
|
727 Tannin.prototype.getPluralForm = function( domain, n ) { |
|
728 var getPluralForm = this.pluralForms[ domain ], |
|
729 config, plural, pf; |
|
730 |
|
731 if ( ! getPluralForm ) { |
|
732 config = this.data[ domain ][ '' ]; |
|
733 |
|
734 pf = ( |
|
735 config[ 'Plural-Forms' ] || |
|
736 config[ 'plural-forms' ] || |
|
737 config.plural_forms |
|
738 ); |
|
739 |
|
740 if ( typeof pf !== 'function' ) { |
|
741 plural = getPluralExpression( |
|
742 config[ 'Plural-Forms' ] || |
|
743 config[ 'plural-forms' ] || |
|
744 config.plural_forms |
|
745 ); |
|
746 |
|
747 pf = pluralForms( plural ); |
|
748 } |
|
749 |
|
750 getPluralForm = this.pluralForms[ domain ] = pf; |
|
751 } |
|
752 |
|
753 return getPluralForm( n ); |
|
754 }; |
|
755 |
|
756 /** |
|
757 * Translate a string. |
|
758 * |
|
759 * @param {string} domain Translation domain. |
|
760 * @param {string} context Context distinguishing terms of the same name. |
|
761 * @param {string} singular Primary key for translation lookup. |
|
762 * @param {string} plural Fallback value used for non-zero plural form index. |
|
763 * @param {number} n Value to use in calculating plural form. |
|
764 * |
|
765 * @return {string} Translated string. |
|
766 */ |
|
767 Tannin.prototype.dcnpgettext = function( domain, context, singular, plural, n ) { |
|
768 var index, key, entry; |
|
769 |
|
770 if ( n === undefined ) { |
|
771 // Default to singular. |
|
772 index = 0; |
|
773 } else { |
|
774 // Find index by evaluating plural form for value. |
|
775 index = this.getPluralForm( domain, n ); |
|
776 } |
|
777 |
|
778 key = singular; |
|
779 |
|
780 // If provided, context is prepended to key with delimiter. |
|
781 if ( context ) { |
|
782 key = context + this.options.contextDelimiter + singular; |
|
783 } |
|
784 |
|
785 entry = this.data[ domain ][ key ]; |
|
786 |
|
787 // Verify not only that entry exists, but that the intended index is within |
|
788 // range and non-empty. |
|
789 if ( entry && entry[ index ] ) { |
|
790 return entry[ index ]; |
|
791 } |
|
792 |
|
793 if ( this.options.onMissingKey ) { |
|
794 this.options.onMissingKey( singular, domain ); |
|
795 } |
|
796 |
|
797 // If entry not found, fall back to singular vs. plural with zero index |
|
798 // representing the singular value. |
|
799 return index === 0 ? singular : plural; |
|
800 }; |
|
801 |
|
802 // EXTERNAL MODULE: ./node_modules/memize/index.js |
|
803 var memize = __webpack_require__(41); |
|
804 var memize_default = /*#__PURE__*/__webpack_require__.n(memize); |
|
805 |
|
806 // EXTERNAL MODULE: ./node_modules/@wordpress/i18n/node_modules/sprintf-js/src/sprintf.js |
|
807 var sprintf = __webpack_require__(137); |
|
808 var sprintf_default = /*#__PURE__*/__webpack_require__.n(sprintf); |
|
809 |
|
810 // CONCATENATED MODULE: ./node_modules/@wordpress/i18n/build-module/index.js |
|
811 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setLocaleData", function() { return setLocaleData; }); |
|
812 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__", function() { return __; }); |
|
813 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_x", function() { return _x; }); |
|
814 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_n", function() { return _n; }); |
|
815 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_nx", function() { return _nx; }); |
|
816 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sprintf", function() { return build_module_sprintf; }); |
|
817 |
|
818 |
|
819 /** |
|
820 * External dependencies |
|
821 */ |
|
822 |
|
823 |
|
824 |
|
825 /** |
|
826 * Default locale data to use for Tannin domain when not otherwise provided. |
|
827 * Assumes an English plural forms expression. |
|
828 * |
|
829 * @type {Object} |
|
830 */ |
|
831 |
|
832 var DEFAULT_LOCALE_DATA = { |
|
833 '': { |
|
834 plural_forms: 'plural=(n!=1)' |
|
835 } |
|
836 }; |
|
837 /** |
|
838 * Log to console, once per message; or more precisely, per referentially equal |
|
839 * argument set. Because Jed throws errors, we log these to the console instead |
|
840 * to avoid crashing the application. |
|
841 * |
|
842 * @param {...*} args Arguments to pass to `console.error` |
|
843 */ |
|
844 |
|
845 var logErrorOnce = memize_default()(console.error); // eslint-disable-line no-console |
|
846 |
|
847 /** |
|
848 * The underlying instance of Tannin to which exported functions interface. |
|
849 * |
|
850 * @type {Tannin} |
|
851 */ |
|
852 |
|
853 var i18n = new Tannin({}); |
|
854 /** |
|
855 * Merges locale data into the Tannin instance by domain. Accepts data in a |
|
856 * Jed-formatted JSON object shape. |
|
857 * |
|
858 * @see http://messageformat.github.io/Jed/ |
|
859 * |
|
860 * @param {?Object} data Locale data configuration. |
|
861 * @param {?string} domain Domain for which configuration applies. |
|
862 */ |
|
863 |
|
864 function setLocaleData(data) { |
|
865 var domain = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default'; |
|
866 i18n.data[domain] = Object(objectSpread["a" /* default */])({}, DEFAULT_LOCALE_DATA, i18n.data[domain], data); // Populate default domain configuration (supported locale date which omits |
|
867 // a plural forms expression). |
|
868 |
|
869 i18n.data[domain][''] = Object(objectSpread["a" /* default */])({}, DEFAULT_LOCALE_DATA[''], i18n.data[domain]['']); |
|
870 } |
|
871 /** |
|
872 * Wrapper for Tannin's `dcnpgettext`. Populates default locale data if not |
|
873 * otherwise previously assigned. |
|
874 * |
|
875 * @param {?string} domain Domain to retrieve the translated text. |
|
876 * @param {?string} context Context information for the translators. |
|
877 * @param {string} single Text to translate if non-plural. Used as fallback |
|
878 * return value on a caught error. |
|
879 * @param {?string} plural The text to be used if the number is plural. |
|
880 * @param {?number} number The number to compare against to use either the |
|
881 * singular or plural form. |
|
882 * |
|
883 * @return {string} The translated string. |
|
884 */ |
|
885 |
|
886 function dcnpgettext() { |
|
887 var domain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default'; |
|
888 var context = arguments.length > 1 ? arguments[1] : undefined; |
|
889 var single = arguments.length > 2 ? arguments[2] : undefined; |
|
890 var plural = arguments.length > 3 ? arguments[3] : undefined; |
|
891 var number = arguments.length > 4 ? arguments[4] : undefined; |
|
892 |
|
893 if (!i18n.data[domain]) { |
|
894 setLocaleData(undefined, domain); |
|
895 } |
|
896 |
|
897 return i18n.dcnpgettext(domain, context, single, plural, number); |
|
898 } |
|
899 /** |
|
900 * Retrieve the translation of text. |
|
901 * |
|
902 * @see https://developer.wordpress.org/reference/functions/__/ |
|
903 * |
|
904 * @param {string} text Text to translate. |
|
905 * @param {?string} domain Domain to retrieve the translated text. |
|
906 * |
|
907 * @return {string} Translated text. |
|
908 */ |
|
909 |
|
910 |
|
911 function __(text, domain) { |
|
912 return dcnpgettext(domain, undefined, text); |
|
913 } |
|
914 /** |
|
915 * Retrieve translated string with gettext context. |
|
916 * |
|
917 * @see https://developer.wordpress.org/reference/functions/_x/ |
|
918 * |
|
919 * @param {string} text Text to translate. |
|
920 * @param {string} context Context information for the translators. |
|
921 * @param {?string} domain Domain to retrieve the translated text. |
|
922 * |
|
923 * @return {string} Translated context string without pipe. |
|
924 */ |
|
925 |
|
926 function _x(text, context, domain) { |
|
927 return dcnpgettext(domain, context, text); |
|
928 } |
|
929 /** |
|
930 * Translates and retrieves the singular or plural form based on the supplied |
|
931 * number. |
|
932 * |
|
933 * @see https://developer.wordpress.org/reference/functions/_n/ |
|
934 * |
|
935 * @param {string} single The text to be used if the number is singular. |
|
936 * @param {string} plural The text to be used if the number is plural. |
|
937 * @param {number} number The number to compare against to use either the |
|
938 * singular or plural form. |
|
939 * @param {?string} domain Domain to retrieve the translated text. |
|
940 * |
|
941 * @return {string} The translated singular or plural form. |
|
942 */ |
|
943 |
|
944 function _n(single, plural, number, domain) { |
|
945 return dcnpgettext(domain, undefined, single, plural, number); |
|
946 } |
|
947 /** |
|
948 * Translates and retrieves the singular or plural form based on the supplied |
|
949 * number, with gettext context. |
|
950 * |
|
951 * @see https://developer.wordpress.org/reference/functions/_nx/ |
|
952 * |
|
953 * @param {string} single The text to be used if the number is singular. |
|
954 * @param {string} plural The text to be used if the number is plural. |
|
955 * @param {number} number The number to compare against to use either the |
|
956 * singular or plural form. |
|
957 * @param {string} context Context information for the translators. |
|
958 * @param {?string} domain Domain to retrieve the translated text. |
|
959 * |
|
960 * @return {string} The translated singular or plural form. |
|
961 */ |
|
962 |
|
963 function _nx(single, plural, number, context, domain) { |
|
964 return dcnpgettext(domain, context, single, plural, number); |
|
965 } |
|
966 /** |
|
967 * Returns a formatted string. If an error occurs in applying the format, the |
|
968 * original format string is returned. |
|
969 * |
|
970 * @param {string} format The format of the string to generate. |
|
971 * @param {...string} args Arguments to apply to the format. |
|
972 * |
|
973 * @see http://www.diveintojavascript.com/projects/javascript-sprintf |
|
974 * |
|
975 * @return {string} The formatted string. |
|
976 */ |
|
977 |
|
978 function build_module_sprintf(format) { |
|
979 try { |
|
980 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { |
|
981 args[_key - 1] = arguments[_key]; |
|
982 } |
|
983 |
|
984 return sprintf_default.a.sprintf.apply(sprintf_default.a, [format].concat(args)); |
|
985 } catch (error) { |
|
986 logErrorOnce('sprintf error: \n\n' + error.toString()); |
|
987 return format; |
|
988 } |
|
989 } |
|
990 |
|
991 |
|
992 /***/ }), |
|
993 |
|
994 /***/ 41: |
|
995 /***/ (function(module, exports, __webpack_require__) { |
|
996 |
|
997 module.exports = function memize( fn, options ) { |
|
998 var size = 0, |
|
999 maxSize, head, tail; |
|
1000 |
|
1001 if ( options && options.maxSize ) { |
|
1002 maxSize = options.maxSize; |
|
1003 } |
|
1004 |
|
1005 function memoized( /* ...args */ ) { |
|
1006 var node = head, |
|
1007 len = arguments.length, |
|
1008 args, i; |
|
1009 |
|
1010 searchCache: while ( node ) { |
|
1011 // Perform a shallow equality test to confirm that whether the node |
|
1012 // under test is a candidate for the arguments passed. Two arrays |
|
1013 // are shallowly equal if their length matches and each entry is |
|
1014 // strictly equal between the two sets. Avoid abstracting to a |
|
1015 // function which could incur an arguments leaking deoptimization. |
|
1016 |
|
1017 // Check whether node arguments match arguments length |
|
1018 if ( node.args.length !== arguments.length ) { |
|
1019 node = node.next; |
|
1020 continue; |
|
1021 } |
|
1022 |
|
1023 // Check whether node arguments match arguments values |
|
1024 for ( i = 0; i < len; i++ ) { |
|
1025 if ( node.args[ i ] !== arguments[ i ] ) { |
|
1026 node = node.next; |
|
1027 continue searchCache; |
|
1028 } |
|
1029 } |
|
1030 |
|
1031 // At this point we can assume we've found a match |
|
1032 |
|
1033 // Surface matched node to head if not already |
|
1034 if ( node !== head ) { |
|
1035 // As tail, shift to previous. Must only shift if not also |
|
1036 // head, since if both head and tail, there is no previous. |
|
1037 if ( node === tail ) { |
|
1038 tail = node.prev; |
|
1039 } |
|
1040 |
|
1041 // Adjust siblings to point to each other. If node was tail, |
|
1042 // this also handles new tail's empty `next` assignment. |
|
1043 node.prev.next = node.next; |
|
1044 if ( node.next ) { |
|
1045 node.next.prev = node.prev; |
|
1046 } |
|
1047 |
|
1048 node.next = head; |
|
1049 node.prev = null; |
|
1050 head.prev = node; |
|
1051 head = node; |
|
1052 } |
|
1053 |
|
1054 // Return immediately |
|
1055 return node.val; |
|
1056 } |
|
1057 |
|
1058 // No cached value found. Continue to insertion phase: |
|
1059 |
|
1060 // Create a copy of arguments (avoid leaking deoptimization) |
|
1061 args = new Array( len ); |
|
1062 for ( i = 0; i < len; i++ ) { |
|
1063 args[ i ] = arguments[ i ]; |
|
1064 } |
|
1065 |
|
1066 node = { |
|
1067 args: args, |
|
1068 |
|
1069 // Generate the result from original function |
|
1070 val: fn.apply( null, args ) |
|
1071 }; |
|
1072 |
|
1073 // Don't need to check whether node is already head, since it would |
|
1074 // have been returned above already if it was |
|
1075 |
|
1076 // Shift existing head down list |
|
1077 if ( head ) { |
|
1078 head.prev = node; |
|
1079 node.next = head; |
|
1080 } else { |
|
1081 // If no head, follows that there's no tail (at initial or reset) |
|
1082 tail = node; |
|
1083 } |
|
1084 |
|
1085 // Trim tail if we're reached max size and are pending cache insertion |
|
1086 if ( size === maxSize ) { |
|
1087 tail = tail.prev; |
|
1088 tail.next = null; |
|
1089 } else { |
|
1090 size++; |
|
1091 } |
|
1092 |
|
1093 head = node; |
|
1094 |
|
1095 return node.val; |
|
1096 } |
|
1097 |
|
1098 memoized.clear = function() { |
|
1099 head = null; |
|
1100 tail = null; |
|
1101 size = 0; |
|
1102 }; |
|
1103 |
|
1104 if ( false ) {} |
|
1105 |
|
1106 return memoized; |
|
1107 }; |
|
1108 |
|
1109 |
|
1110 /***/ }), |
|
1111 |
|
1112 /***/ 7: |
|
1113 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1114 |
|
1115 "use strict"; |
|
1116 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectSpread; }); |
|
1117 /* harmony import */ var _defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15); |
|
1118 |
|
1119 function _objectSpread(target) { |
|
1120 for (var i = 1; i < arguments.length; i++) { |
|
1121 var source = arguments[i] != null ? arguments[i] : {}; |
|
1122 var ownKeys = Object.keys(source); |
|
1123 |
|
1124 if (typeof Object.getOwnPropertySymbols === 'function') { |
|
1125 ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { |
|
1126 return Object.getOwnPropertyDescriptor(source, sym).enumerable; |
|
1127 })); |
|
1128 } |
|
1129 |
|
1130 ownKeys.forEach(function (key) { |
|
1131 Object(_defineProperty__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(target, key, source[key]); |
|
1132 }); |
|
1133 } |
|
1134 |
|
1135 return target; |
|
1136 } |
|
1137 |
|
1138 /***/ }) |
|
1139 |
|
1140 /******/ }); |