No Description

index.js 84KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147
  1. import { c as createCommonjsModule, g as getCjsExportFromNamespace, a as commonjsGlobal, u as unwrapExports } from './style-inject.es-b888177c.js';
  2. import 'react';
  3. import './index-29b5a955.js';
  4. import './test-89de59f6.js';
  5. export { C as ConsumeListView, P as PayPlatformOptions, a as PriceOptions, W as WaitPayInfoView } from './index-6e59934c.js';
  6. /*
  7. Copyright (c) 2014, Yahoo! Inc. All rights reserved.
  8. Copyrights licensed under the New BSD License.
  9. See the accompanying LICENSE file for terms.
  10. */
  11. var extend_1 = extend;
  12. var hop = Object.prototype.hasOwnProperty;
  13. function extend(obj) {
  14. var sources = Array.prototype.slice.call(arguments, 1),
  15. i, len, source, key;
  16. for (i = 0, len = sources.length; i < len; i += 1) {
  17. source = sources[i];
  18. if (!source) { continue; }
  19. for (key in source) {
  20. if (hop.call(source, key)) {
  21. obj[key] = source[key];
  22. }
  23. }
  24. }
  25. return obj;
  26. }
  27. var hop_1 = hop;
  28. var utils = {
  29. extend: extend_1,
  30. hop: hop_1
  31. };
  32. var es5 = createCommonjsModule(function (module, exports) {
  33. // Purposely using the same implementation as the Intl.js `Intl` polyfill.
  34. // Copyright 2013 Andy Earnshaw, MIT License
  35. var realDefineProp = (function () {
  36. try { return !!Object.defineProperty({}, 'a', {}); }
  37. catch (e) { return false; }
  38. })();
  39. var defineProperty = realDefineProp ? Object.defineProperty :
  40. function (obj, name, desc) {
  41. if ('get' in desc && obj.__defineGetter__) {
  42. obj.__defineGetter__(name, desc.get);
  43. } else if (!utils.hop.call(obj, name) || 'value' in desc) {
  44. obj[name] = desc.value;
  45. }
  46. };
  47. var objCreate = Object.create || function (proto, props) {
  48. var obj, k;
  49. function F() {}
  50. F.prototype = proto;
  51. obj = new F();
  52. for (k in props) {
  53. if (utils.hop.call(props, k)) {
  54. defineProperty(obj, k, props[k]);
  55. }
  56. }
  57. return obj;
  58. };
  59. exports.defineProperty = defineProperty, exports.objCreate = objCreate;
  60. });
  61. var es5_1 = es5.defineProperty;
  62. var es5_2 = es5.objCreate;
  63. var compiler = createCommonjsModule(function (module, exports) {
  64. exports["default"] = Compiler;
  65. function Compiler(locales, formats, pluralFn) {
  66. this.locales = locales;
  67. this.formats = formats;
  68. this.pluralFn = pluralFn;
  69. }
  70. Compiler.prototype.compile = function (ast) {
  71. this.pluralStack = [];
  72. this.currentPlural = null;
  73. this.pluralNumberFormat = null;
  74. return this.compileMessage(ast);
  75. };
  76. Compiler.prototype.compileMessage = function (ast) {
  77. if (!(ast && ast.type === 'messageFormatPattern')) {
  78. throw new Error('Message AST is not of type: "messageFormatPattern"');
  79. }
  80. var elements = ast.elements,
  81. pattern = [];
  82. var i, len, element;
  83. for (i = 0, len = elements.length; i < len; i += 1) {
  84. element = elements[i];
  85. switch (element.type) {
  86. case 'messageTextElement':
  87. pattern.push(this.compileMessageText(element));
  88. break;
  89. case 'argumentElement':
  90. pattern.push(this.compileArgument(element));
  91. break;
  92. default:
  93. throw new Error('Message element does not have a valid type');
  94. }
  95. }
  96. return pattern;
  97. };
  98. Compiler.prototype.compileMessageText = function (element) {
  99. // When this `element` is part of plural sub-pattern and its value contains
  100. // an unescaped '#', use a `PluralOffsetString` helper to properly output
  101. // the number with the correct offset in the string.
  102. if (this.currentPlural && /(^|[^\\])#/g.test(element.value)) {
  103. // Create a cache a NumberFormat instance that can be reused for any
  104. // PluralOffsetString instance in this message.
  105. if (!this.pluralNumberFormat) {
  106. this.pluralNumberFormat = new Intl.NumberFormat(this.locales);
  107. }
  108. return new PluralOffsetString(
  109. this.currentPlural.id,
  110. this.currentPlural.format.offset,
  111. this.pluralNumberFormat,
  112. element.value);
  113. }
  114. // Unescape the escaped '#'s in the message text.
  115. return element.value.replace(/\\#/g, '#');
  116. };
  117. Compiler.prototype.compileArgument = function (element) {
  118. var format = element.format;
  119. if (!format) {
  120. return new StringFormat(element.id);
  121. }
  122. var formats = this.formats,
  123. locales = this.locales,
  124. pluralFn = this.pluralFn,
  125. options;
  126. switch (format.type) {
  127. case 'numberFormat':
  128. options = formats.number[format.style];
  129. return {
  130. id : element.id,
  131. format: new Intl.NumberFormat(locales, options).format
  132. };
  133. case 'dateFormat':
  134. options = formats.date[format.style];
  135. return {
  136. id : element.id,
  137. format: new Intl.DateTimeFormat(locales, options).format
  138. };
  139. case 'timeFormat':
  140. options = formats.time[format.style];
  141. return {
  142. id : element.id,
  143. format: new Intl.DateTimeFormat(locales, options).format
  144. };
  145. case 'pluralFormat':
  146. options = this.compileOptions(element);
  147. return new PluralFormat(
  148. element.id, format.ordinal, format.offset, options, pluralFn
  149. );
  150. case 'selectFormat':
  151. options = this.compileOptions(element);
  152. return new SelectFormat(element.id, options);
  153. default:
  154. throw new Error('Message element does not have a valid format type');
  155. }
  156. };
  157. Compiler.prototype.compileOptions = function (element) {
  158. var format = element.format,
  159. options = format.options,
  160. optionsHash = {};
  161. // Save the current plural element, if any, then set it to a new value when
  162. // compiling the options sub-patterns. This conforms the spec's algorithm
  163. // for handling `"#"` syntax in message text.
  164. this.pluralStack.push(this.currentPlural);
  165. this.currentPlural = format.type === 'pluralFormat' ? element : null;
  166. var i, len, option;
  167. for (i = 0, len = options.length; i < len; i += 1) {
  168. option = options[i];
  169. // Compile the sub-pattern and save it under the options's selector.
  170. optionsHash[option.selector] = this.compileMessage(option.value);
  171. }
  172. // Pop the plural stack to put back the original current plural value.
  173. this.currentPlural = this.pluralStack.pop();
  174. return optionsHash;
  175. };
  176. // -- Compiler Helper Classes --------------------------------------------------
  177. function StringFormat(id) {
  178. this.id = id;
  179. }
  180. StringFormat.prototype.format = function (value) {
  181. if (!value && typeof value !== 'number') {
  182. return '';
  183. }
  184. return typeof value === 'string' ? value : String(value);
  185. };
  186. function PluralFormat(id, useOrdinal, offset, options, pluralFn) {
  187. this.id = id;
  188. this.useOrdinal = useOrdinal;
  189. this.offset = offset;
  190. this.options = options;
  191. this.pluralFn = pluralFn;
  192. }
  193. PluralFormat.prototype.getOption = function (value) {
  194. var options = this.options;
  195. var option = options['=' + value] ||
  196. options[this.pluralFn(value - this.offset, this.useOrdinal)];
  197. return option || options.other;
  198. };
  199. function PluralOffsetString(id, offset, numberFormat, string) {
  200. this.id = id;
  201. this.offset = offset;
  202. this.numberFormat = numberFormat;
  203. this.string = string;
  204. }
  205. PluralOffsetString.prototype.format = function (value) {
  206. var number = this.numberFormat.format(value - this.offset);
  207. return this.string
  208. .replace(/(^|[^\\])#/g, '$1' + number)
  209. .replace(/\\#/g, '#');
  210. };
  211. function SelectFormat(id, options) {
  212. this.id = id;
  213. this.options = options;
  214. }
  215. SelectFormat.prototype.getOption = function (value) {
  216. var options = this.options;
  217. return options[value] || options.other;
  218. };
  219. });
  220. var parser = createCommonjsModule(function (module, exports) {
  221. exports["default"] = (function() {
  222. /*
  223. * Generated by PEG.js 0.9.0.
  224. *
  225. * http://pegjs.org/
  226. */
  227. function peg$subclass(child, parent) {
  228. function ctor() { this.constructor = child; }
  229. ctor.prototype = parent.prototype;
  230. child.prototype = new ctor();
  231. }
  232. function peg$SyntaxError(message, expected, found, location) {
  233. this.message = message;
  234. this.expected = expected;
  235. this.found = found;
  236. this.location = location;
  237. this.name = "SyntaxError";
  238. if (typeof Error.captureStackTrace === "function") {
  239. Error.captureStackTrace(this, peg$SyntaxError);
  240. }
  241. }
  242. peg$subclass(peg$SyntaxError, Error);
  243. function peg$parse(input) {
  244. var options = arguments.length > 1 ? arguments[1] : {},
  245. peg$FAILED = {},
  246. peg$startRuleFunctions = { start: peg$parsestart },
  247. peg$startRuleFunction = peg$parsestart,
  248. peg$c0 = function(elements) {
  249. return {
  250. type : 'messageFormatPattern',
  251. elements: elements,
  252. location: location()
  253. };
  254. },
  255. peg$c1 = function(text) {
  256. var string = '',
  257. i, j, outerLen, inner, innerLen;
  258. for (i = 0, outerLen = text.length; i < outerLen; i += 1) {
  259. inner = text[i];
  260. for (j = 0, innerLen = inner.length; j < innerLen; j += 1) {
  261. string += inner[j];
  262. }
  263. }
  264. return string;
  265. },
  266. peg$c2 = function(messageText) {
  267. return {
  268. type : 'messageTextElement',
  269. value: messageText,
  270. location: location()
  271. };
  272. },
  273. peg$c3 = /^[^ \t\n\r,.+={}#]/,
  274. peg$c4 = { type: "class", value: "[^ \\t\\n\\r,.+={}#]", description: "[^ \\t\\n\\r,.+={}#]" },
  275. peg$c5 = "{",
  276. peg$c6 = { type: "literal", value: "{", description: "\"{\"" },
  277. peg$c7 = ",",
  278. peg$c8 = { type: "literal", value: ",", description: "\",\"" },
  279. peg$c9 = "}",
  280. peg$c10 = { type: "literal", value: "}", description: "\"}\"" },
  281. peg$c11 = function(id, format) {
  282. return {
  283. type : 'argumentElement',
  284. id : id,
  285. format: format && format[2],
  286. location: location()
  287. };
  288. },
  289. peg$c12 = "number",
  290. peg$c13 = { type: "literal", value: "number", description: "\"number\"" },
  291. peg$c14 = "date",
  292. peg$c15 = { type: "literal", value: "date", description: "\"date\"" },
  293. peg$c16 = "time",
  294. peg$c17 = { type: "literal", value: "time", description: "\"time\"" },
  295. peg$c18 = function(type, style) {
  296. return {
  297. type : type + 'Format',
  298. style: style && style[2],
  299. location: location()
  300. };
  301. },
  302. peg$c19 = "plural",
  303. peg$c20 = { type: "literal", value: "plural", description: "\"plural\"" },
  304. peg$c21 = function(pluralStyle) {
  305. return {
  306. type : pluralStyle.type,
  307. ordinal: false,
  308. offset : pluralStyle.offset || 0,
  309. options: pluralStyle.options,
  310. location: location()
  311. };
  312. },
  313. peg$c22 = "selectordinal",
  314. peg$c23 = { type: "literal", value: "selectordinal", description: "\"selectordinal\"" },
  315. peg$c24 = function(pluralStyle) {
  316. return {
  317. type : pluralStyle.type,
  318. ordinal: true,
  319. offset : pluralStyle.offset || 0,
  320. options: pluralStyle.options,
  321. location: location()
  322. }
  323. },
  324. peg$c25 = "select",
  325. peg$c26 = { type: "literal", value: "select", description: "\"select\"" },
  326. peg$c27 = function(options) {
  327. return {
  328. type : 'selectFormat',
  329. options: options,
  330. location: location()
  331. };
  332. },
  333. peg$c28 = "=",
  334. peg$c29 = { type: "literal", value: "=", description: "\"=\"" },
  335. peg$c30 = function(selector, pattern) {
  336. return {
  337. type : 'optionalFormatPattern',
  338. selector: selector,
  339. value : pattern,
  340. location: location()
  341. };
  342. },
  343. peg$c31 = "offset:",
  344. peg$c32 = { type: "literal", value: "offset:", description: "\"offset:\"" },
  345. peg$c33 = function(number) {
  346. return number;
  347. },
  348. peg$c34 = function(offset, options) {
  349. return {
  350. type : 'pluralFormat',
  351. offset : offset,
  352. options: options,
  353. location: location()
  354. };
  355. },
  356. peg$c35 = { type: "other", description: "whitespace" },
  357. peg$c36 = /^[ \t\n\r]/,
  358. peg$c37 = { type: "class", value: "[ \\t\\n\\r]", description: "[ \\t\\n\\r]" },
  359. peg$c38 = { type: "other", description: "optionalWhitespace" },
  360. peg$c39 = /^[0-9]/,
  361. peg$c40 = { type: "class", value: "[0-9]", description: "[0-9]" },
  362. peg$c41 = /^[0-9a-f]/i,
  363. peg$c42 = { type: "class", value: "[0-9a-f]i", description: "[0-9a-f]i" },
  364. peg$c43 = "0",
  365. peg$c44 = { type: "literal", value: "0", description: "\"0\"" },
  366. peg$c45 = /^[1-9]/,
  367. peg$c46 = { type: "class", value: "[1-9]", description: "[1-9]" },
  368. peg$c47 = function(digits) {
  369. return parseInt(digits, 10);
  370. },
  371. peg$c48 = /^[^{}\\\0-\x1F \t\n\r]/,
  372. peg$c49 = { type: "class", value: "[^{}\\\\\\0-\\x1F\\x7f \\t\\n\\r]", description: "[^{}\\\\\\0-\\x1F\\x7f \\t\\n\\r]" },
  373. peg$c50 = "\\\\",
  374. peg$c51 = { type: "literal", value: "\\\\", description: "\"\\\\\\\\\"" },
  375. peg$c52 = function() { return '\\'; },
  376. peg$c53 = "\\#",
  377. peg$c54 = { type: "literal", value: "\\#", description: "\"\\\\#\"" },
  378. peg$c55 = function() { return '\\#'; },
  379. peg$c56 = "\\{",
  380. peg$c57 = { type: "literal", value: "\\{", description: "\"\\\\{\"" },
  381. peg$c58 = function() { return '\u007B'; },
  382. peg$c59 = "\\}",
  383. peg$c60 = { type: "literal", value: "\\}", description: "\"\\\\}\"" },
  384. peg$c61 = function() { return '\u007D'; },
  385. peg$c62 = "\\u",
  386. peg$c63 = { type: "literal", value: "\\u", description: "\"\\\\u\"" },
  387. peg$c64 = function(digits) {
  388. return String.fromCharCode(parseInt(digits, 16));
  389. },
  390. peg$c65 = function(chars) { return chars.join(''); },
  391. peg$currPos = 0,
  392. peg$savedPos = 0,
  393. peg$posDetailsCache = [{ line: 1, column: 1, seenCR: false }],
  394. peg$maxFailPos = 0,
  395. peg$maxFailExpected = [],
  396. peg$silentFails = 0,
  397. peg$result;
  398. if ("startRule" in options) {
  399. if (!(options.startRule in peg$startRuleFunctions)) {
  400. throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
  401. }
  402. peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
  403. }
  404. function location() {
  405. return peg$computeLocation(peg$savedPos, peg$currPos);
  406. }
  407. function peg$computePosDetails(pos) {
  408. var details = peg$posDetailsCache[pos],
  409. p, ch;
  410. if (details) {
  411. return details;
  412. } else {
  413. p = pos - 1;
  414. while (!peg$posDetailsCache[p]) {
  415. p--;
  416. }
  417. details = peg$posDetailsCache[p];
  418. details = {
  419. line: details.line,
  420. column: details.column,
  421. seenCR: details.seenCR
  422. };
  423. while (p < pos) {
  424. ch = input.charAt(p);
  425. if (ch === "\n") {
  426. if (!details.seenCR) { details.line++; }
  427. details.column = 1;
  428. details.seenCR = false;
  429. } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") {
  430. details.line++;
  431. details.column = 1;
  432. details.seenCR = true;
  433. } else {
  434. details.column++;
  435. details.seenCR = false;
  436. }
  437. p++;
  438. }
  439. peg$posDetailsCache[pos] = details;
  440. return details;
  441. }
  442. }
  443. function peg$computeLocation(startPos, endPos) {
  444. var startPosDetails = peg$computePosDetails(startPos),
  445. endPosDetails = peg$computePosDetails(endPos);
  446. return {
  447. start: {
  448. offset: startPos,
  449. line: startPosDetails.line,
  450. column: startPosDetails.column
  451. },
  452. end: {
  453. offset: endPos,
  454. line: endPosDetails.line,
  455. column: endPosDetails.column
  456. }
  457. };
  458. }
  459. function peg$fail(expected) {
  460. if (peg$currPos < peg$maxFailPos) { return; }
  461. if (peg$currPos > peg$maxFailPos) {
  462. peg$maxFailPos = peg$currPos;
  463. peg$maxFailExpected = [];
  464. }
  465. peg$maxFailExpected.push(expected);
  466. }
  467. function peg$buildException(message, expected, found, location) {
  468. function cleanupExpected(expected) {
  469. var i = 1;
  470. expected.sort(function(a, b) {
  471. if (a.description < b.description) {
  472. return -1;
  473. } else if (a.description > b.description) {
  474. return 1;
  475. } else {
  476. return 0;
  477. }
  478. });
  479. while (i < expected.length) {
  480. if (expected[i - 1] === expected[i]) {
  481. expected.splice(i, 1);
  482. } else {
  483. i++;
  484. }
  485. }
  486. }
  487. function buildMessage(expected, found) {
  488. function stringEscape(s) {
  489. function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); }
  490. return s
  491. .replace(/\\/g, '\\\\')
  492. .replace(/"/g, '\\"')
  493. .replace(/\x08/g, '\\b')
  494. .replace(/\t/g, '\\t')
  495. .replace(/\n/g, '\\n')
  496. .replace(/\f/g, '\\f')
  497. .replace(/\r/g, '\\r')
  498. .replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
  499. .replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); })
  500. .replace(/[\u0100-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); })
  501. .replace(/[\u1000-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); });
  502. }
  503. var expectedDescs = new Array(expected.length),
  504. expectedDesc, foundDesc, i;
  505. for (i = 0; i < expected.length; i++) {
  506. expectedDescs[i] = expected[i].description;
  507. }
  508. expectedDesc = expected.length > 1
  509. ? expectedDescs.slice(0, -1).join(", ")
  510. + " or "
  511. + expectedDescs[expected.length - 1]
  512. : expectedDescs[0];
  513. foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input";
  514. return "Expected " + expectedDesc + " but " + foundDesc + " found.";
  515. }
  516. if (expected !== null) {
  517. cleanupExpected(expected);
  518. }
  519. return new peg$SyntaxError(
  520. message !== null ? message : buildMessage(expected, found),
  521. expected,
  522. found,
  523. location
  524. );
  525. }
  526. function peg$parsestart() {
  527. var s0;
  528. s0 = peg$parsemessageFormatPattern();
  529. return s0;
  530. }
  531. function peg$parsemessageFormatPattern() {
  532. var s0, s1, s2;
  533. s0 = peg$currPos;
  534. s1 = [];
  535. s2 = peg$parsemessageFormatElement();
  536. while (s2 !== peg$FAILED) {
  537. s1.push(s2);
  538. s2 = peg$parsemessageFormatElement();
  539. }
  540. if (s1 !== peg$FAILED) {
  541. peg$savedPos = s0;
  542. s1 = peg$c0(s1);
  543. }
  544. s0 = s1;
  545. return s0;
  546. }
  547. function peg$parsemessageFormatElement() {
  548. var s0;
  549. s0 = peg$parsemessageTextElement();
  550. if (s0 === peg$FAILED) {
  551. s0 = peg$parseargumentElement();
  552. }
  553. return s0;
  554. }
  555. function peg$parsemessageText() {
  556. var s0, s1, s2, s3, s4, s5;
  557. s0 = peg$currPos;
  558. s1 = [];
  559. s2 = peg$currPos;
  560. s3 = peg$parse_();
  561. if (s3 !== peg$FAILED) {
  562. s4 = peg$parsechars();
  563. if (s4 !== peg$FAILED) {
  564. s5 = peg$parse_();
  565. if (s5 !== peg$FAILED) {
  566. s3 = [s3, s4, s5];
  567. s2 = s3;
  568. } else {
  569. peg$currPos = s2;
  570. s2 = peg$FAILED;
  571. }
  572. } else {
  573. peg$currPos = s2;
  574. s2 = peg$FAILED;
  575. }
  576. } else {
  577. peg$currPos = s2;
  578. s2 = peg$FAILED;
  579. }
  580. if (s2 !== peg$FAILED) {
  581. while (s2 !== peg$FAILED) {
  582. s1.push(s2);
  583. s2 = peg$currPos;
  584. s3 = peg$parse_();
  585. if (s3 !== peg$FAILED) {
  586. s4 = peg$parsechars();
  587. if (s4 !== peg$FAILED) {
  588. s5 = peg$parse_();
  589. if (s5 !== peg$FAILED) {
  590. s3 = [s3, s4, s5];
  591. s2 = s3;
  592. } else {
  593. peg$currPos = s2;
  594. s2 = peg$FAILED;
  595. }
  596. } else {
  597. peg$currPos = s2;
  598. s2 = peg$FAILED;
  599. }
  600. } else {
  601. peg$currPos = s2;
  602. s2 = peg$FAILED;
  603. }
  604. }
  605. } else {
  606. s1 = peg$FAILED;
  607. }
  608. if (s1 !== peg$FAILED) {
  609. peg$savedPos = s0;
  610. s1 = peg$c1(s1);
  611. }
  612. s0 = s1;
  613. if (s0 === peg$FAILED) {
  614. s0 = peg$currPos;
  615. s1 = peg$parsews();
  616. if (s1 !== peg$FAILED) {
  617. s0 = input.substring(s0, peg$currPos);
  618. } else {
  619. s0 = s1;
  620. }
  621. }
  622. return s0;
  623. }
  624. function peg$parsemessageTextElement() {
  625. var s0, s1;
  626. s0 = peg$currPos;
  627. s1 = peg$parsemessageText();
  628. if (s1 !== peg$FAILED) {
  629. peg$savedPos = s0;
  630. s1 = peg$c2(s1);
  631. }
  632. s0 = s1;
  633. return s0;
  634. }
  635. function peg$parseargument() {
  636. var s0, s1, s2;
  637. s0 = peg$parsenumber();
  638. if (s0 === peg$FAILED) {
  639. s0 = peg$currPos;
  640. s1 = [];
  641. if (peg$c3.test(input.charAt(peg$currPos))) {
  642. s2 = input.charAt(peg$currPos);
  643. peg$currPos++;
  644. } else {
  645. s2 = peg$FAILED;
  646. if (peg$silentFails === 0) { peg$fail(peg$c4); }
  647. }
  648. if (s2 !== peg$FAILED) {
  649. while (s2 !== peg$FAILED) {
  650. s1.push(s2);
  651. if (peg$c3.test(input.charAt(peg$currPos))) {
  652. s2 = input.charAt(peg$currPos);
  653. peg$currPos++;
  654. } else {
  655. s2 = peg$FAILED;
  656. if (peg$silentFails === 0) { peg$fail(peg$c4); }
  657. }
  658. }
  659. } else {
  660. s1 = peg$FAILED;
  661. }
  662. if (s1 !== peg$FAILED) {
  663. s0 = input.substring(s0, peg$currPos);
  664. } else {
  665. s0 = s1;
  666. }
  667. }
  668. return s0;
  669. }
  670. function peg$parseargumentElement() {
  671. var s0, s1, s2, s3, s4, s5, s6, s7, s8;
  672. s0 = peg$currPos;
  673. if (input.charCodeAt(peg$currPos) === 123) {
  674. s1 = peg$c5;
  675. peg$currPos++;
  676. } else {
  677. s1 = peg$FAILED;
  678. if (peg$silentFails === 0) { peg$fail(peg$c6); }
  679. }
  680. if (s1 !== peg$FAILED) {
  681. s2 = peg$parse_();
  682. if (s2 !== peg$FAILED) {
  683. s3 = peg$parseargument();
  684. if (s3 !== peg$FAILED) {
  685. s4 = peg$parse_();
  686. if (s4 !== peg$FAILED) {
  687. s5 = peg$currPos;
  688. if (input.charCodeAt(peg$currPos) === 44) {
  689. s6 = peg$c7;
  690. peg$currPos++;
  691. } else {
  692. s6 = peg$FAILED;
  693. if (peg$silentFails === 0) { peg$fail(peg$c8); }
  694. }
  695. if (s6 !== peg$FAILED) {
  696. s7 = peg$parse_();
  697. if (s7 !== peg$FAILED) {
  698. s8 = peg$parseelementFormat();
  699. if (s8 !== peg$FAILED) {
  700. s6 = [s6, s7, s8];
  701. s5 = s6;
  702. } else {
  703. peg$currPos = s5;
  704. s5 = peg$FAILED;
  705. }
  706. } else {
  707. peg$currPos = s5;
  708. s5 = peg$FAILED;
  709. }
  710. } else {
  711. peg$currPos = s5;
  712. s5 = peg$FAILED;
  713. }
  714. if (s5 === peg$FAILED) {
  715. s5 = null;
  716. }
  717. if (s5 !== peg$FAILED) {
  718. s6 = peg$parse_();
  719. if (s6 !== peg$FAILED) {
  720. if (input.charCodeAt(peg$currPos) === 125) {
  721. s7 = peg$c9;
  722. peg$currPos++;
  723. } else {
  724. s7 = peg$FAILED;
  725. if (peg$silentFails === 0) { peg$fail(peg$c10); }
  726. }
  727. if (s7 !== peg$FAILED) {
  728. peg$savedPos = s0;
  729. s1 = peg$c11(s3, s5);
  730. s0 = s1;
  731. } else {
  732. peg$currPos = s0;
  733. s0 = peg$FAILED;
  734. }
  735. } else {
  736. peg$currPos = s0;
  737. s0 = peg$FAILED;
  738. }
  739. } else {
  740. peg$currPos = s0;
  741. s0 = peg$FAILED;
  742. }
  743. } else {
  744. peg$currPos = s0;
  745. s0 = peg$FAILED;
  746. }
  747. } else {
  748. peg$currPos = s0;
  749. s0 = peg$FAILED;
  750. }
  751. } else {
  752. peg$currPos = s0;
  753. s0 = peg$FAILED;
  754. }
  755. } else {
  756. peg$currPos = s0;
  757. s0 = peg$FAILED;
  758. }
  759. return s0;
  760. }
  761. function peg$parseelementFormat() {
  762. var s0;
  763. s0 = peg$parsesimpleFormat();
  764. if (s0 === peg$FAILED) {
  765. s0 = peg$parsepluralFormat();
  766. if (s0 === peg$FAILED) {
  767. s0 = peg$parseselectOrdinalFormat();
  768. if (s0 === peg$FAILED) {
  769. s0 = peg$parseselectFormat();
  770. }
  771. }
  772. }
  773. return s0;
  774. }
  775. function peg$parsesimpleFormat() {
  776. var s0, s1, s2, s3, s4, s5, s6;
  777. s0 = peg$currPos;
  778. if (input.substr(peg$currPos, 6) === peg$c12) {
  779. s1 = peg$c12;
  780. peg$currPos += 6;
  781. } else {
  782. s1 = peg$FAILED;
  783. if (peg$silentFails === 0) { peg$fail(peg$c13); }
  784. }
  785. if (s1 === peg$FAILED) {
  786. if (input.substr(peg$currPos, 4) === peg$c14) {
  787. s1 = peg$c14;
  788. peg$currPos += 4;
  789. } else {
  790. s1 = peg$FAILED;
  791. if (peg$silentFails === 0) { peg$fail(peg$c15); }
  792. }
  793. if (s1 === peg$FAILED) {
  794. if (input.substr(peg$currPos, 4) === peg$c16) {
  795. s1 = peg$c16;
  796. peg$currPos += 4;
  797. } else {
  798. s1 = peg$FAILED;
  799. if (peg$silentFails === 0) { peg$fail(peg$c17); }
  800. }
  801. }
  802. }
  803. if (s1 !== peg$FAILED) {
  804. s2 = peg$parse_();
  805. if (s2 !== peg$FAILED) {
  806. s3 = peg$currPos;
  807. if (input.charCodeAt(peg$currPos) === 44) {
  808. s4 = peg$c7;
  809. peg$currPos++;
  810. } else {
  811. s4 = peg$FAILED;
  812. if (peg$silentFails === 0) { peg$fail(peg$c8); }
  813. }
  814. if (s4 !== peg$FAILED) {
  815. s5 = peg$parse_();
  816. if (s5 !== peg$FAILED) {
  817. s6 = peg$parsechars();
  818. if (s6 !== peg$FAILED) {
  819. s4 = [s4, s5, s6];
  820. s3 = s4;
  821. } else {
  822. peg$currPos = s3;
  823. s3 = peg$FAILED;
  824. }
  825. } else {
  826. peg$currPos = s3;
  827. s3 = peg$FAILED;
  828. }
  829. } else {
  830. peg$currPos = s3;
  831. s3 = peg$FAILED;
  832. }
  833. if (s3 === peg$FAILED) {
  834. s3 = null;
  835. }
  836. if (s3 !== peg$FAILED) {
  837. peg$savedPos = s0;
  838. s1 = peg$c18(s1, s3);
  839. s0 = s1;
  840. } else {
  841. peg$currPos = s0;
  842. s0 = peg$FAILED;
  843. }
  844. } else {
  845. peg$currPos = s0;
  846. s0 = peg$FAILED;
  847. }
  848. } else {
  849. peg$currPos = s0;
  850. s0 = peg$FAILED;
  851. }
  852. return s0;
  853. }
  854. function peg$parsepluralFormat() {
  855. var s0, s1, s2, s3, s4, s5;
  856. s0 = peg$currPos;
  857. if (input.substr(peg$currPos, 6) === peg$c19) {
  858. s1 = peg$c19;
  859. peg$currPos += 6;
  860. } else {
  861. s1 = peg$FAILED;
  862. if (peg$silentFails === 0) { peg$fail(peg$c20); }
  863. }
  864. if (s1 !== peg$FAILED) {
  865. s2 = peg$parse_();
  866. if (s2 !== peg$FAILED) {
  867. if (input.charCodeAt(peg$currPos) === 44) {
  868. s3 = peg$c7;
  869. peg$currPos++;
  870. } else {
  871. s3 = peg$FAILED;
  872. if (peg$silentFails === 0) { peg$fail(peg$c8); }
  873. }
  874. if (s3 !== peg$FAILED) {
  875. s4 = peg$parse_();
  876. if (s4 !== peg$FAILED) {
  877. s5 = peg$parsepluralStyle();
  878. if (s5 !== peg$FAILED) {
  879. peg$savedPos = s0;
  880. s1 = peg$c21(s5);
  881. s0 = s1;
  882. } else {
  883. peg$currPos = s0;
  884. s0 = peg$FAILED;
  885. }
  886. } else {
  887. peg$currPos = s0;
  888. s0 = peg$FAILED;
  889. }
  890. } else {
  891. peg$currPos = s0;
  892. s0 = peg$FAILED;
  893. }
  894. } else {
  895. peg$currPos = s0;
  896. s0 = peg$FAILED;
  897. }
  898. } else {
  899. peg$currPos = s0;
  900. s0 = peg$FAILED;
  901. }
  902. return s0;
  903. }
  904. function peg$parseselectOrdinalFormat() {
  905. var s0, s1, s2, s3, s4, s5;
  906. s0 = peg$currPos;
  907. if (input.substr(peg$currPos, 13) === peg$c22) {
  908. s1 = peg$c22;
  909. peg$currPos += 13;
  910. } else {
  911. s1 = peg$FAILED;
  912. if (peg$silentFails === 0) { peg$fail(peg$c23); }
  913. }
  914. if (s1 !== peg$FAILED) {
  915. s2 = peg$parse_();
  916. if (s2 !== peg$FAILED) {
  917. if (input.charCodeAt(peg$currPos) === 44) {
  918. s3 = peg$c7;
  919. peg$currPos++;
  920. } else {
  921. s3 = peg$FAILED;
  922. if (peg$silentFails === 0) { peg$fail(peg$c8); }
  923. }
  924. if (s3 !== peg$FAILED) {
  925. s4 = peg$parse_();
  926. if (s4 !== peg$FAILED) {
  927. s5 = peg$parsepluralStyle();
  928. if (s5 !== peg$FAILED) {
  929. peg$savedPos = s0;
  930. s1 = peg$c24(s5);
  931. s0 = s1;
  932. } else {
  933. peg$currPos = s0;
  934. s0 = peg$FAILED;
  935. }
  936. } else {
  937. peg$currPos = s0;
  938. s0 = peg$FAILED;
  939. }
  940. } else {
  941. peg$currPos = s0;
  942. s0 = peg$FAILED;
  943. }
  944. } else {
  945. peg$currPos = s0;
  946. s0 = peg$FAILED;
  947. }
  948. } else {
  949. peg$currPos = s0;
  950. s0 = peg$FAILED;
  951. }
  952. return s0;
  953. }
  954. function peg$parseselectFormat() {
  955. var s0, s1, s2, s3, s4, s5, s6;
  956. s0 = peg$currPos;
  957. if (input.substr(peg$currPos, 6) === peg$c25) {
  958. s1 = peg$c25;
  959. peg$currPos += 6;
  960. } else {
  961. s1 = peg$FAILED;
  962. if (peg$silentFails === 0) { peg$fail(peg$c26); }
  963. }
  964. if (s1 !== peg$FAILED) {
  965. s2 = peg$parse_();
  966. if (s2 !== peg$FAILED) {
  967. if (input.charCodeAt(peg$currPos) === 44) {
  968. s3 = peg$c7;
  969. peg$currPos++;
  970. } else {
  971. s3 = peg$FAILED;
  972. if (peg$silentFails === 0) { peg$fail(peg$c8); }
  973. }
  974. if (s3 !== peg$FAILED) {
  975. s4 = peg$parse_();
  976. if (s4 !== peg$FAILED) {
  977. s5 = [];
  978. s6 = peg$parseoptionalFormatPattern();
  979. if (s6 !== peg$FAILED) {
  980. while (s6 !== peg$FAILED) {
  981. s5.push(s6);
  982. s6 = peg$parseoptionalFormatPattern();
  983. }
  984. } else {
  985. s5 = peg$FAILED;
  986. }
  987. if (s5 !== peg$FAILED) {
  988. peg$savedPos = s0;
  989. s1 = peg$c27(s5);
  990. s0 = s1;
  991. } else {
  992. peg$currPos = s0;
  993. s0 = peg$FAILED;
  994. }
  995. } else {
  996. peg$currPos = s0;
  997. s0 = peg$FAILED;
  998. }
  999. } else {
  1000. peg$currPos = s0;
  1001. s0 = peg$FAILED;
  1002. }
  1003. } else {
  1004. peg$currPos = s0;
  1005. s0 = peg$FAILED;
  1006. }
  1007. } else {
  1008. peg$currPos = s0;
  1009. s0 = peg$FAILED;
  1010. }
  1011. return s0;
  1012. }
  1013. function peg$parseselector() {
  1014. var s0, s1, s2, s3;
  1015. s0 = peg$currPos;
  1016. s1 = peg$currPos;
  1017. if (input.charCodeAt(peg$currPos) === 61) {
  1018. s2 = peg$c28;
  1019. peg$currPos++;
  1020. } else {
  1021. s2 = peg$FAILED;
  1022. if (peg$silentFails === 0) { peg$fail(peg$c29); }
  1023. }
  1024. if (s2 !== peg$FAILED) {
  1025. s3 = peg$parsenumber();
  1026. if (s3 !== peg$FAILED) {
  1027. s2 = [s2, s3];
  1028. s1 = s2;
  1029. } else {
  1030. peg$currPos = s1;
  1031. s1 = peg$FAILED;
  1032. }
  1033. } else {
  1034. peg$currPos = s1;
  1035. s1 = peg$FAILED;
  1036. }
  1037. if (s1 !== peg$FAILED) {
  1038. s0 = input.substring(s0, peg$currPos);
  1039. } else {
  1040. s0 = s1;
  1041. }
  1042. if (s0 === peg$FAILED) {
  1043. s0 = peg$parsechars();
  1044. }
  1045. return s0;
  1046. }
  1047. function peg$parseoptionalFormatPattern() {
  1048. var s0, s1, s2, s3, s4, s5, s6, s7, s8;
  1049. s0 = peg$currPos;
  1050. s1 = peg$parse_();
  1051. if (s1 !== peg$FAILED) {
  1052. s2 = peg$parseselector();
  1053. if (s2 !== peg$FAILED) {
  1054. s3 = peg$parse_();
  1055. if (s3 !== peg$FAILED) {
  1056. if (input.charCodeAt(peg$currPos) === 123) {
  1057. s4 = peg$c5;
  1058. peg$currPos++;
  1059. } else {
  1060. s4 = peg$FAILED;
  1061. if (peg$silentFails === 0) { peg$fail(peg$c6); }
  1062. }
  1063. if (s4 !== peg$FAILED) {
  1064. s5 = peg$parse_();
  1065. if (s5 !== peg$FAILED) {
  1066. s6 = peg$parsemessageFormatPattern();
  1067. if (s6 !== peg$FAILED) {
  1068. s7 = peg$parse_();
  1069. if (s7 !== peg$FAILED) {
  1070. if (input.charCodeAt(peg$currPos) === 125) {
  1071. s8 = peg$c9;
  1072. peg$currPos++;
  1073. } else {
  1074. s8 = peg$FAILED;
  1075. if (peg$silentFails === 0) { peg$fail(peg$c10); }
  1076. }
  1077. if (s8 !== peg$FAILED) {
  1078. peg$savedPos = s0;
  1079. s1 = peg$c30(s2, s6);
  1080. s0 = s1;
  1081. } else {
  1082. peg$currPos = s0;
  1083. s0 = peg$FAILED;
  1084. }
  1085. } else {
  1086. peg$currPos = s0;
  1087. s0 = peg$FAILED;
  1088. }
  1089. } else {
  1090. peg$currPos = s0;
  1091. s0 = peg$FAILED;
  1092. }
  1093. } else {
  1094. peg$currPos = s0;
  1095. s0 = peg$FAILED;
  1096. }
  1097. } else {
  1098. peg$currPos = s0;
  1099. s0 = peg$FAILED;
  1100. }
  1101. } else {
  1102. peg$currPos = s0;
  1103. s0 = peg$FAILED;
  1104. }
  1105. } else {
  1106. peg$currPos = s0;
  1107. s0 = peg$FAILED;
  1108. }
  1109. } else {
  1110. peg$currPos = s0;
  1111. s0 = peg$FAILED;
  1112. }
  1113. return s0;
  1114. }
  1115. function peg$parseoffset() {
  1116. var s0, s1, s2, s3;
  1117. s0 = peg$currPos;
  1118. if (input.substr(peg$currPos, 7) === peg$c31) {
  1119. s1 = peg$c31;
  1120. peg$currPos += 7;
  1121. } else {
  1122. s1 = peg$FAILED;
  1123. if (peg$silentFails === 0) { peg$fail(peg$c32); }
  1124. }
  1125. if (s1 !== peg$FAILED) {
  1126. s2 = peg$parse_();
  1127. if (s2 !== peg$FAILED) {
  1128. s3 = peg$parsenumber();
  1129. if (s3 !== peg$FAILED) {
  1130. peg$savedPos = s0;
  1131. s1 = peg$c33(s3);
  1132. s0 = s1;
  1133. } else {
  1134. peg$currPos = s0;
  1135. s0 = peg$FAILED;
  1136. }
  1137. } else {
  1138. peg$currPos = s0;
  1139. s0 = peg$FAILED;
  1140. }
  1141. } else {
  1142. peg$currPos = s0;
  1143. s0 = peg$FAILED;
  1144. }
  1145. return s0;
  1146. }
  1147. function peg$parsepluralStyle() {
  1148. var s0, s1, s2, s3, s4;
  1149. s0 = peg$currPos;
  1150. s1 = peg$parseoffset();
  1151. if (s1 === peg$FAILED) {
  1152. s1 = null;
  1153. }
  1154. if (s1 !== peg$FAILED) {
  1155. s2 = peg$parse_();
  1156. if (s2 !== peg$FAILED) {
  1157. s3 = [];
  1158. s4 = peg$parseoptionalFormatPattern();
  1159. if (s4 !== peg$FAILED) {
  1160. while (s4 !== peg$FAILED) {
  1161. s3.push(s4);
  1162. s4 = peg$parseoptionalFormatPattern();
  1163. }
  1164. } else {
  1165. s3 = peg$FAILED;
  1166. }
  1167. if (s3 !== peg$FAILED) {
  1168. peg$savedPos = s0;
  1169. s1 = peg$c34(s1, s3);
  1170. s0 = s1;
  1171. } else {
  1172. peg$currPos = s0;
  1173. s0 = peg$FAILED;
  1174. }
  1175. } else {
  1176. peg$currPos = s0;
  1177. s0 = peg$FAILED;
  1178. }
  1179. } else {
  1180. peg$currPos = s0;
  1181. s0 = peg$FAILED;
  1182. }
  1183. return s0;
  1184. }
  1185. function peg$parsews() {
  1186. var s0, s1;
  1187. peg$silentFails++;
  1188. s0 = [];
  1189. if (peg$c36.test(input.charAt(peg$currPos))) {
  1190. s1 = input.charAt(peg$currPos);
  1191. peg$currPos++;
  1192. } else {
  1193. s1 = peg$FAILED;
  1194. if (peg$silentFails === 0) { peg$fail(peg$c37); }
  1195. }
  1196. if (s1 !== peg$FAILED) {
  1197. while (s1 !== peg$FAILED) {
  1198. s0.push(s1);
  1199. if (peg$c36.test(input.charAt(peg$currPos))) {
  1200. s1 = input.charAt(peg$currPos);
  1201. peg$currPos++;
  1202. } else {
  1203. s1 = peg$FAILED;
  1204. if (peg$silentFails === 0) { peg$fail(peg$c37); }
  1205. }
  1206. }
  1207. } else {
  1208. s0 = peg$FAILED;
  1209. }
  1210. peg$silentFails--;
  1211. if (s0 === peg$FAILED) {
  1212. s1 = peg$FAILED;
  1213. if (peg$silentFails === 0) { peg$fail(peg$c35); }
  1214. }
  1215. return s0;
  1216. }
  1217. function peg$parse_() {
  1218. var s0, s1, s2;
  1219. peg$silentFails++;
  1220. s0 = peg$currPos;
  1221. s1 = [];
  1222. s2 = peg$parsews();
  1223. while (s2 !== peg$FAILED) {
  1224. s1.push(s2);
  1225. s2 = peg$parsews();
  1226. }
  1227. if (s1 !== peg$FAILED) {
  1228. s0 = input.substring(s0, peg$currPos);
  1229. } else {
  1230. s0 = s1;
  1231. }
  1232. peg$silentFails--;
  1233. if (s0 === peg$FAILED) {
  1234. s1 = peg$FAILED;
  1235. if (peg$silentFails === 0) { peg$fail(peg$c38); }
  1236. }
  1237. return s0;
  1238. }
  1239. function peg$parsedigit() {
  1240. var s0;
  1241. if (peg$c39.test(input.charAt(peg$currPos))) {
  1242. s0 = input.charAt(peg$currPos);
  1243. peg$currPos++;
  1244. } else {
  1245. s0 = peg$FAILED;
  1246. if (peg$silentFails === 0) { peg$fail(peg$c40); }
  1247. }
  1248. return s0;
  1249. }
  1250. function peg$parsehexDigit() {
  1251. var s0;
  1252. if (peg$c41.test(input.charAt(peg$currPos))) {
  1253. s0 = input.charAt(peg$currPos);
  1254. peg$currPos++;
  1255. } else {
  1256. s0 = peg$FAILED;
  1257. if (peg$silentFails === 0) { peg$fail(peg$c42); }
  1258. }
  1259. return s0;
  1260. }
  1261. function peg$parsenumber() {
  1262. var s0, s1, s2, s3, s4, s5;
  1263. s0 = peg$currPos;
  1264. if (input.charCodeAt(peg$currPos) === 48) {
  1265. s1 = peg$c43;
  1266. peg$currPos++;
  1267. } else {
  1268. s1 = peg$FAILED;
  1269. if (peg$silentFails === 0) { peg$fail(peg$c44); }
  1270. }
  1271. if (s1 === peg$FAILED) {
  1272. s1 = peg$currPos;
  1273. s2 = peg$currPos;
  1274. if (peg$c45.test(input.charAt(peg$currPos))) {
  1275. s3 = input.charAt(peg$currPos);
  1276. peg$currPos++;
  1277. } else {
  1278. s3 = peg$FAILED;
  1279. if (peg$silentFails === 0) { peg$fail(peg$c46); }
  1280. }
  1281. if (s3 !== peg$FAILED) {
  1282. s4 = [];
  1283. s5 = peg$parsedigit();
  1284. while (s5 !== peg$FAILED) {
  1285. s4.push(s5);
  1286. s5 = peg$parsedigit();
  1287. }
  1288. if (s4 !== peg$FAILED) {
  1289. s3 = [s3, s4];
  1290. s2 = s3;
  1291. } else {
  1292. peg$currPos = s2;
  1293. s2 = peg$FAILED;
  1294. }
  1295. } else {
  1296. peg$currPos = s2;
  1297. s2 = peg$FAILED;
  1298. }
  1299. if (s2 !== peg$FAILED) {
  1300. s1 = input.substring(s1, peg$currPos);
  1301. } else {
  1302. s1 = s2;
  1303. }
  1304. }
  1305. if (s1 !== peg$FAILED) {
  1306. peg$savedPos = s0;
  1307. s1 = peg$c47(s1);
  1308. }
  1309. s0 = s1;
  1310. return s0;
  1311. }
  1312. function peg$parsechar() {
  1313. var s0, s1, s2, s3, s4, s5, s6, s7;
  1314. if (peg$c48.test(input.charAt(peg$currPos))) {
  1315. s0 = input.charAt(peg$currPos);
  1316. peg$currPos++;
  1317. } else {
  1318. s0 = peg$FAILED;
  1319. if (peg$silentFails === 0) { peg$fail(peg$c49); }
  1320. }
  1321. if (s0 === peg$FAILED) {
  1322. s0 = peg$currPos;
  1323. if (input.substr(peg$currPos, 2) === peg$c50) {
  1324. s1 = peg$c50;
  1325. peg$currPos += 2;
  1326. } else {
  1327. s1 = peg$FAILED;
  1328. if (peg$silentFails === 0) { peg$fail(peg$c51); }
  1329. }
  1330. if (s1 !== peg$FAILED) {
  1331. peg$savedPos = s0;
  1332. s1 = peg$c52();
  1333. }
  1334. s0 = s1;
  1335. if (s0 === peg$FAILED) {
  1336. s0 = peg$currPos;
  1337. if (input.substr(peg$currPos, 2) === peg$c53) {
  1338. s1 = peg$c53;
  1339. peg$currPos += 2;
  1340. } else {
  1341. s1 = peg$FAILED;
  1342. if (peg$silentFails === 0) { peg$fail(peg$c54); }
  1343. }
  1344. if (s1 !== peg$FAILED) {
  1345. peg$savedPos = s0;
  1346. s1 = peg$c55();
  1347. }
  1348. s0 = s1;
  1349. if (s0 === peg$FAILED) {
  1350. s0 = peg$currPos;
  1351. if (input.substr(peg$currPos, 2) === peg$c56) {
  1352. s1 = peg$c56;
  1353. peg$currPos += 2;
  1354. } else {
  1355. s1 = peg$FAILED;
  1356. if (peg$silentFails === 0) { peg$fail(peg$c57); }
  1357. }
  1358. if (s1 !== peg$FAILED) {
  1359. peg$savedPos = s0;
  1360. s1 = peg$c58();
  1361. }
  1362. s0 = s1;
  1363. if (s0 === peg$FAILED) {
  1364. s0 = peg$currPos;
  1365. if (input.substr(peg$currPos, 2) === peg$c59) {
  1366. s1 = peg$c59;
  1367. peg$currPos += 2;
  1368. } else {
  1369. s1 = peg$FAILED;
  1370. if (peg$silentFails === 0) { peg$fail(peg$c60); }
  1371. }
  1372. if (s1 !== peg$FAILED) {
  1373. peg$savedPos = s0;
  1374. s1 = peg$c61();
  1375. }
  1376. s0 = s1;
  1377. if (s0 === peg$FAILED) {
  1378. s0 = peg$currPos;
  1379. if (input.substr(peg$currPos, 2) === peg$c62) {
  1380. s1 = peg$c62;
  1381. peg$currPos += 2;
  1382. } else {
  1383. s1 = peg$FAILED;
  1384. if (peg$silentFails === 0) { peg$fail(peg$c63); }
  1385. }
  1386. if (s1 !== peg$FAILED) {
  1387. s2 = peg$currPos;
  1388. s3 = peg$currPos;
  1389. s4 = peg$parsehexDigit();
  1390. if (s4 !== peg$FAILED) {
  1391. s5 = peg$parsehexDigit();
  1392. if (s5 !== peg$FAILED) {
  1393. s6 = peg$parsehexDigit();
  1394. if (s6 !== peg$FAILED) {
  1395. s7 = peg$parsehexDigit();
  1396. if (s7 !== peg$FAILED) {
  1397. s4 = [s4, s5, s6, s7];
  1398. s3 = s4;
  1399. } else {
  1400. peg$currPos = s3;
  1401. s3 = peg$FAILED;
  1402. }
  1403. } else {
  1404. peg$currPos = s3;
  1405. s3 = peg$FAILED;
  1406. }
  1407. } else {
  1408. peg$currPos = s3;
  1409. s3 = peg$FAILED;
  1410. }
  1411. } else {
  1412. peg$currPos = s3;
  1413. s3 = peg$FAILED;
  1414. }
  1415. if (s3 !== peg$FAILED) {
  1416. s2 = input.substring(s2, peg$currPos);
  1417. } else {
  1418. s2 = s3;
  1419. }
  1420. if (s2 !== peg$FAILED) {
  1421. peg$savedPos = s0;
  1422. s1 = peg$c64(s2);
  1423. s0 = s1;
  1424. } else {
  1425. peg$currPos = s0;
  1426. s0 = peg$FAILED;
  1427. }
  1428. } else {
  1429. peg$currPos = s0;
  1430. s0 = peg$FAILED;
  1431. }
  1432. }
  1433. }
  1434. }
  1435. }
  1436. }
  1437. return s0;
  1438. }
  1439. function peg$parsechars() {
  1440. var s0, s1, s2;
  1441. s0 = peg$currPos;
  1442. s1 = [];
  1443. s2 = peg$parsechar();
  1444. if (s2 !== peg$FAILED) {
  1445. while (s2 !== peg$FAILED) {
  1446. s1.push(s2);
  1447. s2 = peg$parsechar();
  1448. }
  1449. } else {
  1450. s1 = peg$FAILED;
  1451. }
  1452. if (s1 !== peg$FAILED) {
  1453. peg$savedPos = s0;
  1454. s1 = peg$c65(s1);
  1455. }
  1456. s0 = s1;
  1457. return s0;
  1458. }
  1459. peg$result = peg$startRuleFunction();
  1460. if (peg$result !== peg$FAILED && peg$currPos === input.length) {
  1461. return peg$result;
  1462. } else {
  1463. if (peg$result !== peg$FAILED && peg$currPos < input.length) {
  1464. peg$fail({ type: "end", description: "end of input" });
  1465. }
  1466. throw peg$buildException(
  1467. null,
  1468. peg$maxFailExpected,
  1469. peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
  1470. peg$maxFailPos < input.length
  1471. ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
  1472. : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
  1473. );
  1474. }
  1475. }
  1476. return {
  1477. SyntaxError: peg$SyntaxError,
  1478. parse: peg$parse
  1479. };
  1480. })();
  1481. });
  1482. var intlMessageformatParser = createCommonjsModule(function (module, exports) {
  1483. exports = module.exports = parser['default'];
  1484. exports['default'] = exports;
  1485. });
  1486. var core = createCommonjsModule(function (module, exports) {
  1487. exports["default"] = MessageFormat;
  1488. // -- MessageFormat --------------------------------------------------------
  1489. function MessageFormat(message, locales, formats) {
  1490. // Parse string messages into an AST.
  1491. var ast = typeof message === 'string' ?
  1492. MessageFormat.__parse(message) : message;
  1493. if (!(ast && ast.type === 'messageFormatPattern')) {
  1494. throw new TypeError('A message must be provided as a String or AST.');
  1495. }
  1496. // Creates a new object with the specified `formats` merged with the default
  1497. // formats.
  1498. formats = this._mergeFormats(MessageFormat.formats, formats);
  1499. // Defined first because it's used to build the format pattern.
  1500. es5.defineProperty(this, '_locale', {value: this._resolveLocale(locales)});
  1501. // Compile the `ast` to a pattern that is highly optimized for repeated
  1502. // `format()` invocations. **Note:** This passes the `locales` set provided
  1503. // to the constructor instead of just the resolved locale.
  1504. var pluralFn = this._findPluralRuleFunction(this._locale);
  1505. var pattern = this._compilePattern(ast, locales, formats, pluralFn);
  1506. // "Bind" `format()` method to `this` so it can be passed by reference like
  1507. // the other `Intl` APIs.
  1508. var messageFormat = this;
  1509. this.format = function (values) {
  1510. try {
  1511. return messageFormat._format(pattern, values);
  1512. } catch (e) {
  1513. if (e.variableId) {
  1514. throw new Error(
  1515. 'The intl string context variable \'' + e.variableId + '\'' +
  1516. ' was not provided to the string \'' + message + '\''
  1517. );
  1518. } else {
  1519. throw e;
  1520. }
  1521. }
  1522. };
  1523. }
  1524. // Default format options used as the prototype of the `formats` provided to the
  1525. // constructor. These are used when constructing the internal Intl.NumberFormat
  1526. // and Intl.DateTimeFormat instances.
  1527. es5.defineProperty(MessageFormat, 'formats', {
  1528. enumerable: true,
  1529. value: {
  1530. number: {
  1531. 'currency': {
  1532. style: 'currency'
  1533. },
  1534. 'percent': {
  1535. style: 'percent'
  1536. }
  1537. },
  1538. date: {
  1539. 'short': {
  1540. month: 'numeric',
  1541. day : 'numeric',
  1542. year : '2-digit'
  1543. },
  1544. 'medium': {
  1545. month: 'short',
  1546. day : 'numeric',
  1547. year : 'numeric'
  1548. },
  1549. 'long': {
  1550. month: 'long',
  1551. day : 'numeric',
  1552. year : 'numeric'
  1553. },
  1554. 'full': {
  1555. weekday: 'long',
  1556. month : 'long',
  1557. day : 'numeric',
  1558. year : 'numeric'
  1559. }
  1560. },
  1561. time: {
  1562. 'short': {
  1563. hour : 'numeric',
  1564. minute: 'numeric'
  1565. },
  1566. 'medium': {
  1567. hour : 'numeric',
  1568. minute: 'numeric',
  1569. second: 'numeric'
  1570. },
  1571. 'long': {
  1572. hour : 'numeric',
  1573. minute : 'numeric',
  1574. second : 'numeric',
  1575. timeZoneName: 'short'
  1576. },
  1577. 'full': {
  1578. hour : 'numeric',
  1579. minute : 'numeric',
  1580. second : 'numeric',
  1581. timeZoneName: 'short'
  1582. }
  1583. }
  1584. }
  1585. });
  1586. // Define internal private properties for dealing with locale data.
  1587. es5.defineProperty(MessageFormat, '__localeData__', {value: es5.objCreate(null)});
  1588. es5.defineProperty(MessageFormat, '__addLocaleData', {value: function (data) {
  1589. if (!(data && data.locale)) {
  1590. throw new Error(
  1591. 'Locale data provided to IntlMessageFormat is missing a ' +
  1592. '`locale` property'
  1593. );
  1594. }
  1595. MessageFormat.__localeData__[data.locale.toLowerCase()] = data;
  1596. }});
  1597. // Defines `__parse()` static method as an exposed private.
  1598. es5.defineProperty(MessageFormat, '__parse', {value: intlMessageformatParser["default"].parse});
  1599. // Define public `defaultLocale` property which defaults to English, but can be
  1600. // set by the developer.
  1601. es5.defineProperty(MessageFormat, 'defaultLocale', {
  1602. enumerable: true,
  1603. writable : true,
  1604. value : undefined
  1605. });
  1606. MessageFormat.prototype.resolvedOptions = function () {
  1607. // TODO: Provide anything else?
  1608. return {
  1609. locale: this._locale
  1610. };
  1611. };
  1612. MessageFormat.prototype._compilePattern = function (ast, locales, formats, pluralFn) {
  1613. var compiler$1 = new compiler["default"](locales, formats, pluralFn);
  1614. return compiler$1.compile(ast);
  1615. };
  1616. MessageFormat.prototype._findPluralRuleFunction = function (locale) {
  1617. var localeData = MessageFormat.__localeData__;
  1618. var data = localeData[locale.toLowerCase()];
  1619. // The locale data is de-duplicated, so we have to traverse the locale's
  1620. // hierarchy until we find a `pluralRuleFunction` to return.
  1621. while (data) {
  1622. if (data.pluralRuleFunction) {
  1623. return data.pluralRuleFunction;
  1624. }
  1625. data = data.parentLocale && localeData[data.parentLocale.toLowerCase()];
  1626. }
  1627. throw new Error(
  1628. 'Locale data added to IntlMessageFormat is missing a ' +
  1629. '`pluralRuleFunction` for :' + locale
  1630. );
  1631. };
  1632. MessageFormat.prototype._format = function (pattern, values) {
  1633. var result = '',
  1634. i, len, part, id, value, err;
  1635. for (i = 0, len = pattern.length; i < len; i += 1) {
  1636. part = pattern[i];
  1637. // Exist early for string parts.
  1638. if (typeof part === 'string') {
  1639. result += part;
  1640. continue;
  1641. }
  1642. id = part.id;
  1643. // Enforce that all required values are provided by the caller.
  1644. if (!(values && utils.hop.call(values, id))) {
  1645. err = new Error('A value must be provided for: ' + id);
  1646. err.variableId = id;
  1647. throw err;
  1648. }
  1649. value = values[id];
  1650. // Recursively format plural and select parts' option — which can be a
  1651. // nested pattern structure. The choosing of the option to use is
  1652. // abstracted-by and delegated-to the part helper object.
  1653. if (part.options) {
  1654. result += this._format(part.getOption(value), values);
  1655. } else {
  1656. result += part.format(value);
  1657. }
  1658. }
  1659. return result;
  1660. };
  1661. MessageFormat.prototype._mergeFormats = function (defaults, formats) {
  1662. var mergedFormats = {},
  1663. type, mergedType;
  1664. for (type in defaults) {
  1665. if (!utils.hop.call(defaults, type)) { continue; }
  1666. mergedFormats[type] = mergedType = es5.objCreate(defaults[type]);
  1667. if (formats && utils.hop.call(formats, type)) {
  1668. utils.extend(mergedType, formats[type]);
  1669. }
  1670. }
  1671. return mergedFormats;
  1672. };
  1673. MessageFormat.prototype._resolveLocale = function (locales) {
  1674. if (typeof locales === 'string') {
  1675. locales = [locales];
  1676. }
  1677. // Create a copy of the array so we can push on the default locale.
  1678. locales = (locales || []).concat(MessageFormat.defaultLocale);
  1679. var localeData = MessageFormat.__localeData__;
  1680. var i, len, localeParts, data;
  1681. // Using the set of locales + the default locale, we look for the first one
  1682. // which that has been registered. When data does not exist for a locale, we
  1683. // traverse its ancestors to find something that's been registered within
  1684. // its hierarchy of locales. Since we lack the proper `parentLocale` data
  1685. // here, we must take a naive approach to traversal.
  1686. for (i = 0, len = locales.length; i < len; i += 1) {
  1687. localeParts = locales[i].toLowerCase().split('-');
  1688. while (localeParts.length) {
  1689. data = localeData[localeParts.join('-')];
  1690. if (data) {
  1691. // Return the normalized locale string; e.g., we return "en-US",
  1692. // instead of "en-us".
  1693. return data.locale;
  1694. }
  1695. localeParts.pop();
  1696. }
  1697. }
  1698. var defaultLocale = locales.pop();
  1699. throw new Error(
  1700. 'No locale data has been added to IntlMessageFormat for: ' +
  1701. locales.join(', ') + ', or the default locale: ' + defaultLocale
  1702. );
  1703. };
  1704. });
  1705. var en = createCommonjsModule(function (module, exports) {
  1706. exports["default"] = {"locale":"en","pluralRuleFunction":function (n,ord){var s=String(n).split("."),v0=!s[1],t0=Number(s[0])==n,n10=t0&&s[0].slice(-1),n100=t0&&s[0].slice(-2);if(ord)return n10==1&&n100!=11?"one":n10==2&&n100!=12?"two":n10==3&&n100!=13?"few":"other";return n==1&&v0?"one":"other"}};
  1707. });
  1708. var main = createCommonjsModule(function (module, exports) {
  1709. core["default"].__addLocaleData(en["default"]);
  1710. core["default"].defaultLocale = 'en';
  1711. exports["default"] = core["default"];
  1712. });
  1713. var _nodeResolve_empty = {};
  1714. var _nodeResolve_empty$1 = /*#__PURE__*/Object.freeze({
  1715. __proto__: null,
  1716. 'default': _nodeResolve_empty
  1717. });
  1718. getCjsExportFromNamespace(_nodeResolve_empty$1);
  1719. var intlMessageformat = createCommonjsModule(function (module, exports) {
  1720. var IntlMessageFormat = main['default'];
  1721. // Add all locale data to `IntlMessageFormat`. This module will be ignored when
  1722. // bundling for the browser with Browserify/Webpack.
  1723. // Re-export `IntlMessageFormat` as the CommonJS default exports with all the
  1724. // locale data registered, and with English set as the default locale. Define
  1725. // the `default` prop for use with other compiled ES6 Modules.
  1726. exports = module.exports = IntlMessageFormat;
  1727. exports['default'] = exports;
  1728. });
  1729. /**
  1730. * lodash (Custom Build) <https://lodash.com/>
  1731. * Build: `lodash modularize exports="npm" -o ./`
  1732. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  1733. * Released under MIT license <https://lodash.com/license>
  1734. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  1735. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  1736. */
  1737. /** Used as the `TypeError` message for "Functions" methods. */
  1738. var FUNC_ERROR_TEXT = 'Expected a function';
  1739. /** Used to stand-in for `undefined` hash values. */
  1740. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  1741. /** Used as references for various `Number` constants. */
  1742. var INFINITY = 1 / 0;
  1743. /** `Object#toString` result references. */
  1744. var funcTag = '[object Function]',
  1745. genTag = '[object GeneratorFunction]',
  1746. symbolTag = '[object Symbol]';
  1747. /** Used to match property names within property paths. */
  1748. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  1749. reIsPlainProp = /^\w*$/,
  1750. reLeadingDot = /^\./,
  1751. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  1752. /**
  1753. * Used to match `RegExp`
  1754. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  1755. */
  1756. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  1757. /** Used to match backslashes in property paths. */
  1758. var reEscapeChar = /\\(\\)?/g;
  1759. /** Used to detect host constructors (Safari). */
  1760. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  1761. /** Detect free variable `global` from Node.js. */
  1762. var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
  1763. /** Detect free variable `self`. */
  1764. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  1765. /** Used as a reference to the global object. */
  1766. var root = freeGlobal || freeSelf || Function('return this')();
  1767. /**
  1768. * Gets the value at `key` of `object`.
  1769. *
  1770. * @private
  1771. * @param {Object} [object] The object to query.
  1772. * @param {string} key The key of the property to get.
  1773. * @returns {*} Returns the property value.
  1774. */
  1775. function getValue(object, key) {
  1776. return object == null ? undefined : object[key];
  1777. }
  1778. /**
  1779. * Checks if `value` is a host object in IE < 9.
  1780. *
  1781. * @private
  1782. * @param {*} value The value to check.
  1783. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  1784. */
  1785. function isHostObject(value) {
  1786. // Many host objects are `Object` objects that can coerce to strings
  1787. // despite having improperly defined `toString` methods.
  1788. var result = false;
  1789. if (value != null && typeof value.toString != 'function') {
  1790. try {
  1791. result = !!(value + '');
  1792. } catch (e) {}
  1793. }
  1794. return result;
  1795. }
  1796. /** Used for built-in method references. */
  1797. var arrayProto = Array.prototype,
  1798. funcProto = Function.prototype,
  1799. objectProto = Object.prototype;
  1800. /** Used to detect overreaching core-js shims. */
  1801. var coreJsData = root['__core-js_shared__'];
  1802. /** Used to detect methods masquerading as native. */
  1803. var maskSrcKey = (function() {
  1804. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  1805. return uid ? ('Symbol(src)_1.' + uid) : '';
  1806. }());
  1807. /** Used to resolve the decompiled source of functions. */
  1808. var funcToString = funcProto.toString;
  1809. /** Used to check objects for own properties. */
  1810. var hasOwnProperty = objectProto.hasOwnProperty;
  1811. /**
  1812. * Used to resolve the
  1813. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  1814. * of values.
  1815. */
  1816. var objectToString = objectProto.toString;
  1817. /** Used to detect if a method is native. */
  1818. var reIsNative = RegExp('^' +
  1819. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  1820. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  1821. );
  1822. /** Built-in value references. */
  1823. var Symbol = root.Symbol,
  1824. splice = arrayProto.splice;
  1825. /* Built-in method references that are verified to be native. */
  1826. var Map = getNative(root, 'Map'),
  1827. nativeCreate = getNative(Object, 'create');
  1828. /** Used to convert symbols to primitives and strings. */
  1829. var symbolProto = Symbol ? Symbol.prototype : undefined,
  1830. symbolToString = symbolProto ? symbolProto.toString : undefined;
  1831. /**
  1832. * Creates a hash object.
  1833. *
  1834. * @private
  1835. * @constructor
  1836. * @param {Array} [entries] The key-value pairs to cache.
  1837. */
  1838. function Hash(entries) {
  1839. var index = -1,
  1840. length = entries ? entries.length : 0;
  1841. this.clear();
  1842. while (++index < length) {
  1843. var entry = entries[index];
  1844. this.set(entry[0], entry[1]);
  1845. }
  1846. }
  1847. /**
  1848. * Removes all key-value entries from the hash.
  1849. *
  1850. * @private
  1851. * @name clear
  1852. * @memberOf Hash
  1853. */
  1854. function hashClear() {
  1855. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  1856. }
  1857. /**
  1858. * Removes `key` and its value from the hash.
  1859. *
  1860. * @private
  1861. * @name delete
  1862. * @memberOf Hash
  1863. * @param {Object} hash The hash to modify.
  1864. * @param {string} key The key of the value to remove.
  1865. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  1866. */
  1867. function hashDelete(key) {
  1868. return this.has(key) && delete this.__data__[key];
  1869. }
  1870. /**
  1871. * Gets the hash value for `key`.
  1872. *
  1873. * @private
  1874. * @name get
  1875. * @memberOf Hash
  1876. * @param {string} key The key of the value to get.
  1877. * @returns {*} Returns the entry value.
  1878. */
  1879. function hashGet(key) {
  1880. var data = this.__data__;
  1881. if (nativeCreate) {
  1882. var result = data[key];
  1883. return result === HASH_UNDEFINED ? undefined : result;
  1884. }
  1885. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  1886. }
  1887. /**
  1888. * Checks if a hash value for `key` exists.
  1889. *
  1890. * @private
  1891. * @name has
  1892. * @memberOf Hash
  1893. * @param {string} key The key of the entry to check.
  1894. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  1895. */
  1896. function hashHas(key) {
  1897. var data = this.__data__;
  1898. return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
  1899. }
  1900. /**
  1901. * Sets the hash `key` to `value`.
  1902. *
  1903. * @private
  1904. * @name set
  1905. * @memberOf Hash
  1906. * @param {string} key The key of the value to set.
  1907. * @param {*} value The value to set.
  1908. * @returns {Object} Returns the hash instance.
  1909. */
  1910. function hashSet(key, value) {
  1911. var data = this.__data__;
  1912. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  1913. return this;
  1914. }
  1915. // Add methods to `Hash`.
  1916. Hash.prototype.clear = hashClear;
  1917. Hash.prototype['delete'] = hashDelete;
  1918. Hash.prototype.get = hashGet;
  1919. Hash.prototype.has = hashHas;
  1920. Hash.prototype.set = hashSet;
  1921. /**
  1922. * Creates an list cache object.
  1923. *
  1924. * @private
  1925. * @constructor
  1926. * @param {Array} [entries] The key-value pairs to cache.
  1927. */
  1928. function ListCache(entries) {
  1929. var index = -1,
  1930. length = entries ? entries.length : 0;
  1931. this.clear();
  1932. while (++index < length) {
  1933. var entry = entries[index];
  1934. this.set(entry[0], entry[1]);
  1935. }
  1936. }
  1937. /**
  1938. * Removes all key-value entries from the list cache.
  1939. *
  1940. * @private
  1941. * @name clear
  1942. * @memberOf ListCache
  1943. */
  1944. function listCacheClear() {
  1945. this.__data__ = [];
  1946. }
  1947. /**
  1948. * Removes `key` and its value from the list cache.
  1949. *
  1950. * @private
  1951. * @name delete
  1952. * @memberOf ListCache
  1953. * @param {string} key The key of the value to remove.
  1954. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  1955. */
  1956. function listCacheDelete(key) {
  1957. var data = this.__data__,
  1958. index = assocIndexOf(data, key);
  1959. if (index < 0) {
  1960. return false;
  1961. }
  1962. var lastIndex = data.length - 1;
  1963. if (index == lastIndex) {
  1964. data.pop();
  1965. } else {
  1966. splice.call(data, index, 1);
  1967. }
  1968. return true;
  1969. }
  1970. /**
  1971. * Gets the list cache value for `key`.
  1972. *
  1973. * @private
  1974. * @name get
  1975. * @memberOf ListCache
  1976. * @param {string} key The key of the value to get.
  1977. * @returns {*} Returns the entry value.
  1978. */
  1979. function listCacheGet(key) {
  1980. var data = this.__data__,
  1981. index = assocIndexOf(data, key);
  1982. return index < 0 ? undefined : data[index][1];
  1983. }
  1984. /**
  1985. * Checks if a list cache value for `key` exists.
  1986. *
  1987. * @private
  1988. * @name has
  1989. * @memberOf ListCache
  1990. * @param {string} key The key of the entry to check.
  1991. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  1992. */
  1993. function listCacheHas(key) {
  1994. return assocIndexOf(this.__data__, key) > -1;
  1995. }
  1996. /**
  1997. * Sets the list cache `key` to `value`.
  1998. *
  1999. * @private
  2000. * @name set
  2001. * @memberOf ListCache
  2002. * @param {string} key The key of the value to set.
  2003. * @param {*} value The value to set.
  2004. * @returns {Object} Returns the list cache instance.
  2005. */
  2006. function listCacheSet(key, value) {
  2007. var data = this.__data__,
  2008. index = assocIndexOf(data, key);
  2009. if (index < 0) {
  2010. data.push([key, value]);
  2011. } else {
  2012. data[index][1] = value;
  2013. }
  2014. return this;
  2015. }
  2016. // Add methods to `ListCache`.
  2017. ListCache.prototype.clear = listCacheClear;
  2018. ListCache.prototype['delete'] = listCacheDelete;
  2019. ListCache.prototype.get = listCacheGet;
  2020. ListCache.prototype.has = listCacheHas;
  2021. ListCache.prototype.set = listCacheSet;
  2022. /**
  2023. * Creates a map cache object to store key-value pairs.
  2024. *
  2025. * @private
  2026. * @constructor
  2027. * @param {Array} [entries] The key-value pairs to cache.
  2028. */
  2029. function MapCache(entries) {
  2030. var index = -1,
  2031. length = entries ? entries.length : 0;
  2032. this.clear();
  2033. while (++index < length) {
  2034. var entry = entries[index];
  2035. this.set(entry[0], entry[1]);
  2036. }
  2037. }
  2038. /**
  2039. * Removes all key-value entries from the map.
  2040. *
  2041. * @private
  2042. * @name clear
  2043. * @memberOf MapCache
  2044. */
  2045. function mapCacheClear() {
  2046. this.__data__ = {
  2047. 'hash': new Hash,
  2048. 'map': new (Map || ListCache),
  2049. 'string': new Hash
  2050. };
  2051. }
  2052. /**
  2053. * Removes `key` and its value from the map.
  2054. *
  2055. * @private
  2056. * @name delete
  2057. * @memberOf MapCache
  2058. * @param {string} key The key of the value to remove.
  2059. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2060. */
  2061. function mapCacheDelete(key) {
  2062. return getMapData(this, key)['delete'](key);
  2063. }
  2064. /**
  2065. * Gets the map value for `key`.
  2066. *
  2067. * @private
  2068. * @name get
  2069. * @memberOf MapCache
  2070. * @param {string} key The key of the value to get.
  2071. * @returns {*} Returns the entry value.
  2072. */
  2073. function mapCacheGet(key) {
  2074. return getMapData(this, key).get(key);
  2075. }
  2076. /**
  2077. * Checks if a map value for `key` exists.
  2078. *
  2079. * @private
  2080. * @name has
  2081. * @memberOf MapCache
  2082. * @param {string} key The key of the entry to check.
  2083. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2084. */
  2085. function mapCacheHas(key) {
  2086. return getMapData(this, key).has(key);
  2087. }
  2088. /**
  2089. * Sets the map `key` to `value`.
  2090. *
  2091. * @private
  2092. * @name set
  2093. * @memberOf MapCache
  2094. * @param {string} key The key of the value to set.
  2095. * @param {*} value The value to set.
  2096. * @returns {Object} Returns the map cache instance.
  2097. */
  2098. function mapCacheSet(key, value) {
  2099. getMapData(this, key).set(key, value);
  2100. return this;
  2101. }
  2102. // Add methods to `MapCache`.
  2103. MapCache.prototype.clear = mapCacheClear;
  2104. MapCache.prototype['delete'] = mapCacheDelete;
  2105. MapCache.prototype.get = mapCacheGet;
  2106. MapCache.prototype.has = mapCacheHas;
  2107. MapCache.prototype.set = mapCacheSet;
  2108. /**
  2109. * Gets the index at which the `key` is found in `array` of key-value pairs.
  2110. *
  2111. * @private
  2112. * @param {Array} array The array to inspect.
  2113. * @param {*} key The key to search for.
  2114. * @returns {number} Returns the index of the matched value, else `-1`.
  2115. */
  2116. function assocIndexOf(array, key) {
  2117. var length = array.length;
  2118. while (length--) {
  2119. if (eq(array[length][0], key)) {
  2120. return length;
  2121. }
  2122. }
  2123. return -1;
  2124. }
  2125. /**
  2126. * The base implementation of `_.get` without support for default values.
  2127. *
  2128. * @private
  2129. * @param {Object} object The object to query.
  2130. * @param {Array|string} path The path of the property to get.
  2131. * @returns {*} Returns the resolved value.
  2132. */
  2133. function baseGet(object, path) {
  2134. path = isKey(path, object) ? [path] : castPath(path);
  2135. var index = 0,
  2136. length = path.length;
  2137. while (object != null && index < length) {
  2138. object = object[toKey(path[index++])];
  2139. }
  2140. return (index && index == length) ? object : undefined;
  2141. }
  2142. /**
  2143. * The base implementation of `_.isNative` without bad shim checks.
  2144. *
  2145. * @private
  2146. * @param {*} value The value to check.
  2147. * @returns {boolean} Returns `true` if `value` is a native function,
  2148. * else `false`.
  2149. */
  2150. function baseIsNative(value) {
  2151. if (!isObject(value) || isMasked(value)) {
  2152. return false;
  2153. }
  2154. var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
  2155. return pattern.test(toSource(value));
  2156. }
  2157. /**
  2158. * The base implementation of `_.toString` which doesn't convert nullish
  2159. * values to empty strings.
  2160. *
  2161. * @private
  2162. * @param {*} value The value to process.
  2163. * @returns {string} Returns the string.
  2164. */
  2165. function baseToString(value) {
  2166. // Exit early for strings to avoid a performance hit in some environments.
  2167. if (typeof value == 'string') {
  2168. return value;
  2169. }
  2170. if (isSymbol(value)) {
  2171. return symbolToString ? symbolToString.call(value) : '';
  2172. }
  2173. var result = (value + '');
  2174. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  2175. }
  2176. /**
  2177. * Casts `value` to a path array if it's not one.
  2178. *
  2179. * @private
  2180. * @param {*} value The value to inspect.
  2181. * @returns {Array} Returns the cast property path array.
  2182. */
  2183. function castPath(value) {
  2184. return isArray(value) ? value : stringToPath(value);
  2185. }
  2186. /**
  2187. * Gets the data for `map`.
  2188. *
  2189. * @private
  2190. * @param {Object} map The map to query.
  2191. * @param {string} key The reference key.
  2192. * @returns {*} Returns the map data.
  2193. */
  2194. function getMapData(map, key) {
  2195. var data = map.__data__;
  2196. return isKeyable(key)
  2197. ? data[typeof key == 'string' ? 'string' : 'hash']
  2198. : data.map;
  2199. }
  2200. /**
  2201. * Gets the native function at `key` of `object`.
  2202. *
  2203. * @private
  2204. * @param {Object} object The object to query.
  2205. * @param {string} key The key of the method to get.
  2206. * @returns {*} Returns the function if it's native, else `undefined`.
  2207. */
  2208. function getNative(object, key) {
  2209. var value = getValue(object, key);
  2210. return baseIsNative(value) ? value : undefined;
  2211. }
  2212. /**
  2213. * Checks if `value` is a property name and not a property path.
  2214. *
  2215. * @private
  2216. * @param {*} value The value to check.
  2217. * @param {Object} [object] The object to query keys on.
  2218. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  2219. */
  2220. function isKey(value, object) {
  2221. if (isArray(value)) {
  2222. return false;
  2223. }
  2224. var type = typeof value;
  2225. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  2226. value == null || isSymbol(value)) {
  2227. return true;
  2228. }
  2229. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  2230. (object != null && value in Object(object));
  2231. }
  2232. /**
  2233. * Checks if `value` is suitable for use as unique object key.
  2234. *
  2235. * @private
  2236. * @param {*} value The value to check.
  2237. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  2238. */
  2239. function isKeyable(value) {
  2240. var type = typeof value;
  2241. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  2242. ? (value !== '__proto__')
  2243. : (value === null);
  2244. }
  2245. /**
  2246. * Checks if `func` has its source masked.
  2247. *
  2248. * @private
  2249. * @param {Function} func The function to check.
  2250. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  2251. */
  2252. function isMasked(func) {
  2253. return !!maskSrcKey && (maskSrcKey in func);
  2254. }
  2255. /**
  2256. * Converts `string` to a property path array.
  2257. *
  2258. * @private
  2259. * @param {string} string The string to convert.
  2260. * @returns {Array} Returns the property path array.
  2261. */
  2262. var stringToPath = memoize(function(string) {
  2263. string = toString(string);
  2264. var result = [];
  2265. if (reLeadingDot.test(string)) {
  2266. result.push('');
  2267. }
  2268. string.replace(rePropName, function(match, number, quote, string) {
  2269. result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
  2270. });
  2271. return result;
  2272. });
  2273. /**
  2274. * Converts `value` to a string key if it's not a string or symbol.
  2275. *
  2276. * @private
  2277. * @param {*} value The value to inspect.
  2278. * @returns {string|symbol} Returns the key.
  2279. */
  2280. function toKey(value) {
  2281. if (typeof value == 'string' || isSymbol(value)) {
  2282. return value;
  2283. }
  2284. var result = (value + '');
  2285. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  2286. }
  2287. /**
  2288. * Converts `func` to its source code.
  2289. *
  2290. * @private
  2291. * @param {Function} func The function to process.
  2292. * @returns {string} Returns the source code.
  2293. */
  2294. function toSource(func) {
  2295. if (func != null) {
  2296. try {
  2297. return funcToString.call(func);
  2298. } catch (e) {}
  2299. try {
  2300. return (func + '');
  2301. } catch (e) {}
  2302. }
  2303. return '';
  2304. }
  2305. /**
  2306. * Creates a function that memoizes the result of `func`. If `resolver` is
  2307. * provided, it determines the cache key for storing the result based on the
  2308. * arguments provided to the memoized function. By default, the first argument
  2309. * provided to the memoized function is used as the map cache key. The `func`
  2310. * is invoked with the `this` binding of the memoized function.
  2311. *
  2312. * **Note:** The cache is exposed as the `cache` property on the memoized
  2313. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  2314. * constructor with one whose instances implement the
  2315. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  2316. * method interface of `delete`, `get`, `has`, and `set`.
  2317. *
  2318. * @static
  2319. * @memberOf _
  2320. * @since 0.1.0
  2321. * @category Function
  2322. * @param {Function} func The function to have its output memoized.
  2323. * @param {Function} [resolver] The function to resolve the cache key.
  2324. * @returns {Function} Returns the new memoized function.
  2325. * @example
  2326. *
  2327. * var object = { 'a': 1, 'b': 2 };
  2328. * var other = { 'c': 3, 'd': 4 };
  2329. *
  2330. * var values = _.memoize(_.values);
  2331. * values(object);
  2332. * // => [1, 2]
  2333. *
  2334. * values(other);
  2335. * // => [3, 4]
  2336. *
  2337. * object.a = 2;
  2338. * values(object);
  2339. * // => [1, 2]
  2340. *
  2341. * // Modify the result cache.
  2342. * values.cache.set(object, ['a', 'b']);
  2343. * values(object);
  2344. * // => ['a', 'b']
  2345. *
  2346. * // Replace `_.memoize.Cache`.
  2347. * _.memoize.Cache = WeakMap;
  2348. */
  2349. function memoize(func, resolver) {
  2350. if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
  2351. throw new TypeError(FUNC_ERROR_TEXT);
  2352. }
  2353. var memoized = function() {
  2354. var args = arguments,
  2355. key = resolver ? resolver.apply(this, args) : args[0],
  2356. cache = memoized.cache;
  2357. if (cache.has(key)) {
  2358. return cache.get(key);
  2359. }
  2360. var result = func.apply(this, args);
  2361. memoized.cache = cache.set(key, result);
  2362. return result;
  2363. };
  2364. memoized.cache = new (memoize.Cache || MapCache);
  2365. return memoized;
  2366. }
  2367. // Assign cache to `_.memoize`.
  2368. memoize.Cache = MapCache;
  2369. /**
  2370. * Performs a
  2371. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  2372. * comparison between two values to determine if they are equivalent.
  2373. *
  2374. * @static
  2375. * @memberOf _
  2376. * @since 4.0.0
  2377. * @category Lang
  2378. * @param {*} value The value to compare.
  2379. * @param {*} other The other value to compare.
  2380. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  2381. * @example
  2382. *
  2383. * var object = { 'a': 1 };
  2384. * var other = { 'a': 1 };
  2385. *
  2386. * _.eq(object, object);
  2387. * // => true
  2388. *
  2389. * _.eq(object, other);
  2390. * // => false
  2391. *
  2392. * _.eq('a', 'a');
  2393. * // => true
  2394. *
  2395. * _.eq('a', Object('a'));
  2396. * // => false
  2397. *
  2398. * _.eq(NaN, NaN);
  2399. * // => true
  2400. */
  2401. function eq(value, other) {
  2402. return value === other || (value !== value && other !== other);
  2403. }
  2404. /**
  2405. * Checks if `value` is classified as an `Array` object.
  2406. *
  2407. * @static
  2408. * @memberOf _
  2409. * @since 0.1.0
  2410. * @category Lang
  2411. * @param {*} value The value to check.
  2412. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  2413. * @example
  2414. *
  2415. * _.isArray([1, 2, 3]);
  2416. * // => true
  2417. *
  2418. * _.isArray(document.body.children);
  2419. * // => false
  2420. *
  2421. * _.isArray('abc');
  2422. * // => false
  2423. *
  2424. * _.isArray(_.noop);
  2425. * // => false
  2426. */
  2427. var isArray = Array.isArray;
  2428. /**
  2429. * Checks if `value` is classified as a `Function` object.
  2430. *
  2431. * @static
  2432. * @memberOf _
  2433. * @since 0.1.0
  2434. * @category Lang
  2435. * @param {*} value The value to check.
  2436. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  2437. * @example
  2438. *
  2439. * _.isFunction(_);
  2440. * // => true
  2441. *
  2442. * _.isFunction(/abc/);
  2443. * // => false
  2444. */
  2445. function isFunction(value) {
  2446. // The use of `Object#toString` avoids issues with the `typeof` operator
  2447. // in Safari 8-9 which returns 'object' for typed array and other constructors.
  2448. var tag = isObject(value) ? objectToString.call(value) : '';
  2449. return tag == funcTag || tag == genTag;
  2450. }
  2451. /**
  2452. * Checks if `value` is the
  2453. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  2454. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  2455. *
  2456. * @static
  2457. * @memberOf _
  2458. * @since 0.1.0
  2459. * @category Lang
  2460. * @param {*} value The value to check.
  2461. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  2462. * @example
  2463. *
  2464. * _.isObject({});
  2465. * // => true
  2466. *
  2467. * _.isObject([1, 2, 3]);
  2468. * // => true
  2469. *
  2470. * _.isObject(_.noop);
  2471. * // => true
  2472. *
  2473. * _.isObject(null);
  2474. * // => false
  2475. */
  2476. function isObject(value) {
  2477. var type = typeof value;
  2478. return !!value && (type == 'object' || type == 'function');
  2479. }
  2480. /**
  2481. * Checks if `value` is object-like. A value is object-like if it's not `null`
  2482. * and has a `typeof` result of "object".
  2483. *
  2484. * @static
  2485. * @memberOf _
  2486. * @since 4.0.0
  2487. * @category Lang
  2488. * @param {*} value The value to check.
  2489. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  2490. * @example
  2491. *
  2492. * _.isObjectLike({});
  2493. * // => true
  2494. *
  2495. * _.isObjectLike([1, 2, 3]);
  2496. * // => true
  2497. *
  2498. * _.isObjectLike(_.noop);
  2499. * // => false
  2500. *
  2501. * _.isObjectLike(null);
  2502. * // => false
  2503. */
  2504. function isObjectLike(value) {
  2505. return !!value && typeof value == 'object';
  2506. }
  2507. /**
  2508. * Checks if `value` is classified as a `Symbol` primitive or object.
  2509. *
  2510. * @static
  2511. * @memberOf _
  2512. * @since 4.0.0
  2513. * @category Lang
  2514. * @param {*} value The value to check.
  2515. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  2516. * @example
  2517. *
  2518. * _.isSymbol(Symbol.iterator);
  2519. * // => true
  2520. *
  2521. * _.isSymbol('abc');
  2522. * // => false
  2523. */
  2524. function isSymbol(value) {
  2525. return typeof value == 'symbol' ||
  2526. (isObjectLike(value) && objectToString.call(value) == symbolTag);
  2527. }
  2528. /**
  2529. * Converts `value` to a string. An empty string is returned for `null`
  2530. * and `undefined` values. The sign of `-0` is preserved.
  2531. *
  2532. * @static
  2533. * @memberOf _
  2534. * @since 4.0.0
  2535. * @category Lang
  2536. * @param {*} value The value to process.
  2537. * @returns {string} Returns the string.
  2538. * @example
  2539. *
  2540. * _.toString(null);
  2541. * // => ''
  2542. *
  2543. * _.toString(-0);
  2544. * // => '-0'
  2545. *
  2546. * _.toString([1, 2, 3]);
  2547. * // => '1,2,3'
  2548. */
  2549. function toString(value) {
  2550. return value == null ? '' : baseToString(value);
  2551. }
  2552. /**
  2553. * Gets the value at `path` of `object`. If the resolved value is
  2554. * `undefined`, the `defaultValue` is returned in its place.
  2555. *
  2556. * @static
  2557. * @memberOf _
  2558. * @since 3.7.0
  2559. * @category Object
  2560. * @param {Object} object The object to query.
  2561. * @param {Array|string} path The path of the property to get.
  2562. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  2563. * @returns {*} Returns the resolved value.
  2564. * @example
  2565. *
  2566. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  2567. *
  2568. * _.get(object, 'a[0].b.c');
  2569. * // => 3
  2570. *
  2571. * _.get(object, ['a', '0', 'b', 'c']);
  2572. * // => 3
  2573. *
  2574. * _.get(object, 'a.b.c', 'default');
  2575. * // => 'default'
  2576. */
  2577. function get(object, path, defaultValue) {
  2578. var result = object == null ? undefined : baseGet(object, path);
  2579. return result === undefined ? defaultValue : result;
  2580. }
  2581. var lodash_get = get;
  2582. var Observer_1 = createCommonjsModule(function (module, exports) {
  2583. Object.defineProperty(exports, "__esModule", { value: true });
  2584. var Observer = function (obj) {
  2585. Object.keys(obj.__data__ || obj).forEach(function (key) {
  2586. defineReactive(obj, key);
  2587. });
  2588. return obj;
  2589. };
  2590. var observe = function (value) {
  2591. if (!value || typeof value !== 'object') {
  2592. return;
  2593. }
  2594. Observer(value);
  2595. };
  2596. var defineReactive = function (obj, key) {
  2597. var childObj = observe(obj[key]);
  2598. Object.defineProperty(obj, key, {
  2599. get: function () {
  2600. if (obj.__data__[key]) {
  2601. return obj.__data__[key];
  2602. }
  2603. else if (obj.__metas__['zh-CN'][key]) {
  2604. return obj.__metas__['zh-CN'][key];
  2605. }
  2606. },
  2607. set: function (newVal) {
  2608. if (obj[key] === newVal) {
  2609. return;
  2610. }
  2611. obj[key] = newVal;
  2612. var cb = obj.callback[key];
  2613. cb.call(obj);
  2614. childObj = observe(newVal);
  2615. }
  2616. });
  2617. };
  2618. exports.default = Observer;
  2619. });
  2620. unwrapExports(Observer_1);
  2621. var src = createCommonjsModule(function (module, exports) {
  2622. var __assign = (commonjsGlobal && commonjsGlobal.__assign) || Object.assign || function(t) {
  2623. for (var s, i = 1, n = arguments.length; i < n; i++) {
  2624. s = arguments[i];
  2625. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  2626. t[p] = s[p];
  2627. }
  2628. return t;
  2629. };
  2630. Object.defineProperty(exports, "__esModule", { value: true });
  2631. var I18N = (function () {
  2632. function I18N(lang, metas) {
  2633. this.__lang__ = lang;
  2634. this.__metas__ = metas;
  2635. this.__data__ = metas[lang];
  2636. }
  2637. I18N.prototype.setLang = function (lang) {
  2638. this.__lang__ = lang;
  2639. this.__data__ = this.__metas__[lang];
  2640. };
  2641. I18N.prototype.getProp = function (obj, is, value) {
  2642. if (typeof is === 'string') {
  2643. is = is.split('.');
  2644. }
  2645. if (is.length === 1 && value !== undefined) {
  2646. return (obj[is[0]] = value);
  2647. }
  2648. else if (is.length === 0) {
  2649. return obj;
  2650. }
  2651. else {
  2652. var prop = is.shift();
  2653. if (value !== undefined && obj[prop] === undefined) {
  2654. obj[prop] = {};
  2655. }
  2656. return this.getProp(obj[prop], is, value);
  2657. }
  2658. };
  2659. I18N.prototype.template = function (str, args) {
  2660. var _this = this;
  2661. if (!str) {
  2662. return '';
  2663. }
  2664. return str.replace(/\{(.+?)\}/g, function (match, p1) {
  2665. return _this.getProp(__assign({}, _this.__data__, args), p1);
  2666. });
  2667. };
  2668. I18N.prototype.get = function (str, args) {
  2669. var msg = lodash_get(this.__data__, str);
  2670. if (!msg) {
  2671. msg = lodash_get(this.__metas__['zh-CN'], str, str);
  2672. }
  2673. if (args) {
  2674. try {
  2675. msg = new intlMessageformat.default(msg, this.__lang__);
  2676. msg = msg.format(args);
  2677. return msg;
  2678. }
  2679. catch (err) {
  2680. console.warn("kiwi-intl format message failed for key='" + str + "'", err);
  2681. return '';
  2682. }
  2683. }
  2684. else {
  2685. return msg;
  2686. }
  2687. };
  2688. return I18N;
  2689. }());
  2690. var IntlFormat = {
  2691. init: function (lang, metas) {
  2692. var i18n = new I18N(lang, metas);
  2693. return Observer_1.default(i18n);
  2694. }
  2695. };
  2696. exports.IntlFormat = IntlFormat;
  2697. exports.default = IntlFormat;
  2698. });
  2699. var KiwiIntl = unwrapExports(src);
  2700. var src_1 = src.IntlFormat;
  2701. var priceOptions = {
  2702. "index": {
  2703. "others": "Others"
  2704. }
  2705. };
  2706. var payplatformoption = {
  2707. "platform": "支付平台"
  2708. };
  2709. var enUsLangs = Object.assign({}, {
  2710. priceOptions: priceOptions,
  2711. payplatformoption: payplatformoption
  2712. });
  2713. var priceOptions$1 = {
  2714. index: {
  2715. others: '其他金额'
  2716. }
  2717. };
  2718. var payplatformoption$1 = {
  2719. platform: '支付平台'
  2720. };
  2721. var zhCNLangs = Object.assign({}, {
  2722. priceOptions: priceOptions$1,
  2723. payplatformoption: payplatformoption$1
  2724. });
  2725. // type TransmitImgTxtData = {
  2726. // user_id?: string|number;
  2727. // anonymity?: boolean;
  2728. // avatar?: string;
  2729. // nickname?: string;
  2730. // is_long?: boolean;
  2731. // }
  2732. // interface TransmitCardProps {
  2733. // type: TransmitType;
  2734. // data: TransmitImgTxtData;
  2735. // }
  2736. // export class TransmitCard extends React.PureComponent<TransmitCardProps, {}> {
  2737. // renderVideo() {
  2738. // return <div className={styles.transmitVideoCard}>Video</div>;
  2739. // }
  2740. // renderImgTxt() {
  2741. // const { data } = this.props;
  2742. // const {
  2743. // user_id,
  2744. // anonymity,
  2745. // avatar,
  2746. // nickname,
  2747. // is_long,
  2748. // } = data;
  2749. // return (
  2750. // <div className={styles.transmitImgTxtCard}>
  2751. // <div className={styles.header}>
  2752. // <UserLink user_id={user_id} anonymity={anonymity}>
  2753. // <Avatar
  2754. // id={user_id}
  2755. // image={avatar}
  2756. // follow={false}
  2757. // size="cover"
  2758. // className={styles.ava}
  2759. // anonymity={anonymity}
  2760. // />
  2761. // </UserLink>
  2762. // <div className={styles.nickname}>
  2763. // <UserLink user_id={user_id} anonymity={anonymity}>
  2764. // {nickname}
  2765. // </UserLink>
  2766. // </div>
  2767. // <div className={styles.type}>
  2768. // {is_long
  2769. // ? intl.get('bilingually.imgtxt.article')
  2770. // : intl.get('bilingually.imgtxt')}
  2771. // </div>
  2772. // </div>
  2773. // </div>
  2774. // );
  2775. // }
  2776. // render() {
  2777. // const { type } = this.props;
  2778. // if (type === 'imgTxt') {
  2779. // this.renderImgTxt();
  2780. // }
  2781. // if (type === 'shortVideo' || type === 'microVideo') {
  2782. // this.renderVideo();
  2783. // }
  2784. // return null;
  2785. // }
  2786. // }
  2787. var Test = "TestComponent";
  2788. var langs = {
  2789. 'en_US': enUsLangs,
  2790. 'zh_CN': zhCNLangs
  2791. };
  2792. var kiwiIntl = KiwiIntl.init('en_US', langs);
  2793. export { Test, kiwiIntl };
  2794. //# sourceMappingURL=index.js.map