{"version":3,"sources":["sprintf.js"],"names":["sprintf","key","sprintf_format","sprintf_parse","arguments","vsprintf","fmt","argv","apply","concat","parse_tree","arg","i","k","match","pad","pad_character","pad_length","is_positive","sign","cursor","tree_length","length","output","Array","isArray","hasOwnProperty","Error","re","not_type","test","not_primitive","Function","numeric_arg","isNaN","TypeError","number","parseInt","toString","String","fromCharCode","JSON","stringify","parseFloat","toExponential","toFixed","Number","toPrecision","substring","Object","prototype","call","slice","toLowerCase","valueOf","toUpperCase","json","replace","charAt","repeat","sprintf_cache","_fmt","arg_names","text","exec","push","modulo","placeholder","SyntaxError","field_list","replacement_field","field_match","key_access","index_access","not_string","not_bool","not_json","create","exports","window","define"],"mappings":";CAEC,WACG,aAoBA,SAASA,EAAQC,GAEb,OAAOC,EAAeC,EAAcF,GAAMG,WAG9C,SAASC,EAASC,EAAKC,GACnB,OAAOP,EAAQQ,MAAM,MAAOF,GAAKG,OAAOF,QAG5C,SAASL,EAAeQ,EAAYH,GAChC,IAAiDI,EAAkBC,EAAGC,EAAGC,EAAOC,EAAKC,EAAeC,EAAYC,EAAaC,EAAzHC,EAAS,EAAGC,EAAcX,EAAWY,OAAaC,EAAS,GAC/D,IAAKX,EAAI,EAAGA,EAAIS,EAAaT,IACzB,GAA6B,iBAAlBF,EAAWE,GAClBW,GAAUb,EAAWE,QAEpB,GAAIY,MAAMC,QAAQf,EAAWE,IAAK,CAEnC,IADAE,EAAQJ,EAAWE,IACT,GAEN,IADAD,EAAMJ,EAAKa,GACNP,EAAI,EAAGA,EAAIC,EAAM,GAAGQ,OAAQT,IAAK,CAClC,IAAKF,EAAIe,eAAeZ,EAAM,GAAGD,IAC7B,MAAM,IAAIc,MAAM3B,EAAQ,yCAA0Cc,EAAM,GAAGD,KAE/EF,EAAMA,EAAIG,EAAM,GAAGD,SAIvBF,EADKG,EAAM,GACLP,EAAKO,EAAM,IAGXP,EAAKa,KAOf,GAJIQ,EAAGC,SAASC,KAAKhB,EAAM,KAAOc,EAAGG,cAA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A/BtB,GAAItD,EAAM,GAAI,CACVgD,GAAa,EACb,IAAIO,KAAiBC,EAAoBxD,EAAM,GAAIyD,KACnD,GAAuD,QAAlDA,EAAc3C,EAAG3B,IAAI+D,KAAKM,IAe3B,MAAM,IAAIF,YAAY,gDAbtB,IADAC,EAAWJ,KAAKM,EAAY,IACwD,MAA5ED,EAAoBA,EAAkBtB,UAAUuB,EAAY,GAAGjD,UACnE,GAA8D,QAAzDiD,EAAc3C,EAAG4C,WAAWR,KAAKM,IAClCD,EAAWJ,KAAKM,EAAY,QAE3B,CAAA,GAAgE,QAA3DA,EAAc3C,EAAG6C,aAAaT,KAAKM,IAIzC,MAAM,IAAIF,YAAY,gDAHtBC,EAAWJ,KAAKM,EAAY,IAUxCzD,EAAM,GAAKuD,OAGXP,GAAa,EAEjB,GAAkB,IAAdA,EACA,MAAM,IAAInC,MAAM,6EAEpBjB,EAAWuD,KAAKnD,GAKpB+C,EAAOA,EAAKb,UAAUlC,EAAM,GAAGQ,QAEnC,OAAOsC,EAActD,GAAOI,EA3LhC,IAAIkB,GACA8C,WAAY,OACZC,SAAU,OACV9C,SAAU,OACVE,cAAe,OACfK,OAAQ,UACRH,YAAa,eACbuB,KAAM,MACNoB,SAAU,OACVb,KAAM,YACNG,OAAQ,WACRC,YAAa,4FACblE,IAAK,sBACLuE,WAAY,wBACZC,aAAc,aACdtD,KAAM,WAyHNyC,EAAgBX,OAAO4B,OAAO,MA0DX,oBAAZC,UACPA,QAAiB,QAAI9E,EACrB8E,QAAkB,SAAIzE,GAEJ,oBAAX0E,SACPA,OAAgB,QAAI/E,EACpB+E,OAAiB,SAAI1E,EAEC,mBAAX2E,QAAyBA,OAAY,KAC5CA,OAAO,WACH,OACIhF,QAAWA,EACXK,SAAYA","file":"sprintf.min.js","sourcesContent":["/* global window, exports, define */\n\n!function() {\n    'use strict'\n\n    var re = {\n        not_string: /[^s]/,\n        not_bool: /[^t]/,\n        not_type: /[^T]/,\n        not_primitive: /[^v]/,\n        number: /[diefg]/,\n        numeric_arg: /[bcdiefguxX]/,\n        json: /[j]/,\n        not_json: /[^j]/,\n        text: /^[^\\x25]+/,\n        modulo: /^\\x25{2}/,\n        placeholder: /^\\x25(?:([1-9]\\d*)\\$|\\(([^\\)]+)\\))?(\\+)?(0|'[^$])?(-)?(\\d+)?(?:\\.(\\d+))?([b-gijostTuvxX])/,\n        key: /^([a-z_][a-z_\\d]*)/i,\n        key_access: /^\\.([a-z_][a-z_\\d]*)/i,\n        index_access: /^\\[(\\d+)\\]/,\n        sign: /^[\\+\\-]/\n    }\n\n    function sprintf(key) {\n        // `arguments` is not an array, but should be fine for this call\n        return sprintf_format(sprintf_parse(key), arguments)\n    }\n\n    function vsprintf(fmt, argv) {\n        return sprintf.apply(null, [fmt].concat(argv || []))\n    }\n\n    function sprintf_format(parse_tree, argv) {\n        var cursor = 1, tree_length = parse_tree.length, arg, output = '', i, k, match, pad, pad_character, pad_length, is_positive, sign\n        for (i = 0; i < tree_length; i++) {\n            if (typeof parse_tree[i] === 'string') {\n                output += parse_tree[i]\n            }\n            else if (Array.isArray(parse_tree[i])) {\n                match = parse_tree[i] // convenience purposes only\n                if (match[2]) { // keyword argument\n                    arg = argv[cursor]\n                    for (k = 0; k < match[2].length; k++) {\n                        if (!arg.hasOwnProperty(match[2][k])) {\n                            throw new Error(sprintf('[sprintf] property \"%s\" does not exist', match[2][k]))\n                        }\n                        arg = arg[match[2][k]]\n                    }\n                }\n                else if (match[1]) { // positional argument (explicit)\n                    arg = argv[match[1]]\n                }\n                else { // positional argument (implicit)\n                    arg = argv[cursor++]\n                }\n\n                if (re.not_type.test(match[8]) && re.not_primitive.test(match[8]) && arg instanceof Function) {\n                    arg = arg()\n                }\n\n                if (re.numeric_arg.test(match[8]) && (typeof arg !== 'number' && isNaN(arg))) {\n                    throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg))\n                }\n\n                if (re.number.test(match[8])) {\n                    is_positive = arg >= 0\n                }\n\n                switch (match[8]) {\n                    case 'b':\n                        arg = parseInt(arg, 10).toString(2)\n                        break\n                    case 'c':\n                        arg = String.fromCharCode(parseInt(arg, 10))\n                        break\n                    case 'd':\n                    case 'i':\n                        arg = parseInt(arg, 10)\n                        break\n                    case 'j':\n                        arg = JSON.stringify(arg, null, match[6] ? parseInt(match[6]) : 0)\n                        break\n                    case 'e':\n                        arg = match[7] ? parseFloat(arg).toExponential(match[7]) : parseFloat(arg).toExponential()\n                        break\n                    case 'f':\n                        arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg)\n                        break\n                    case 'g':\n                        arg = match[7] ? String(Number(arg.toPrecision(match[7]))) : parseFloat(arg)\n                        break\n                    case 'o':\n                        arg = (parseInt(arg, 10) >>> 0).toString(8)\n                        break\n                    case 's':\n                        arg = String(arg)\n                        arg = (match[7] ? arg.substring(0, match[7]) : arg)\n                        break\n                    case 't':\n                        arg = String(!!arg)\n                        arg = (match[7] ? arg.substring(0, match[7]) : arg)\n                        break\n                    case 'T':\n                        arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase()\n                        arg = (match[7] ? arg.substring(0, match[7]) : arg)\n                        break\n                    case 'u':\n                        arg = parseInt(arg, 10) >>> 0\n                        break\n                    case 'v':\n                        arg = arg.valueOf()\n                        arg = (match[7] ? arg.substring(0, match[7]) : arg)\n                        break\n                    case 'x':\n                        arg = (parseInt(arg, 10) >>> 0).toString(16)\n                        break\n                    case 'X':\n                        arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase()\n                        break\n                }\n                if (re.json.test(match[8])) {\n                    output += arg\n                }\n                else {\n                    if (re.number.test(match[8]) && (!is_positive || match[3])) {\n                        sign = is_positive ? '+' : '-'\n                        arg = arg.toString().replace(re.sign, '')\n                    }\n                    else {\n                        sign = ''\n                    }\n                    pad_character = match[4] ? match[4] === '0' ? '0' : match[4].charAt(1) : ' '\n                    pad_length = match[6] - (sign + arg).length\n                    pad = match[6] ? (pad_length > 0 ? pad_character.repeat(pad_length) : '') : ''\n                    output += match[5] ? sign + arg + pad : (pad_character === '0' ? sign + pad + arg : pad + sign + arg)\n                }\n            }\n        }\n        return output\n    }\n\n    var sprintf_cache = Object.create(null)\n\n    function sprintf_parse(fmt) {\n        if (sprintf_cache[fmt]) {\n            return sprintf_cache[fmt]\n        }\n\n        var _fmt = fmt, match, parse_tree = [], arg_names = 0\n        while (_fmt) {\n            if ((match = re.text.exec(_fmt)) !== null) {\n                parse_tree.push(match[0])\n            }\n            else if ((match = re.modulo.exec(_fmt)) !== null) {\n                parse_tree.push('%')\n            }\n            else if ((match = re.placeholder.exec(_fmt)) !== null) {\n                if (match[2]) {\n                    arg_names |= 1\n                    var field_list = [], replacement_field = match[2], field_match = []\n                    if ((field_match = re.key.exec(replacement_field)) !== null) {\n                        field_list.push(field_match[1])\n                        while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {\n                            if ((field_match = re.key_access.exec(replacement_field)) !== null) {\n                                field_list.push(field_match[1])\n                            }\n                            else if ((field_match = re.index_access.exec(replacement_field)) !== null) {\n                                field_list.push(field_match[1])\n                            }\n                            else {\n                                throw new SyntaxError('[sprintf] failed to parse named argument key')\n                            }\n                        }\n                    }\n                    else {\n                        throw new SyntaxError('[sprintf] failed to parse named argument key')\n                    }\n                    match[2] = field_list\n                }\n                else {\n                    arg_names |= 2\n                }\n                if (arg_names === 3) {\n                    throw new Error('[sprintf] mixing positional and named placeholders is not (yet) supported')\n                }\n                parse_tree.push(match)\n            }\n            else {\n                throw new SyntaxError('[sprintf] unexpected placeholder')\n            }\n            _fmt = _fmt.substring(match[0].length)\n        }\n        return sprintf_cache[fmt] = parse_tree\n    }\n\n    /**\n     * export to either browser or node.js\n     */\n    /* eslint-disable quote-props */\n    if (typeof exports !== 'undefined') {\n        exports['sprintf'] = sprintf\n        exports['vsprintf'] = vsprintf\n    }\n    if (typeof window !== 'undefined') {\n        window['sprintf'] = sprintf\n        window['vsprintf'] = vsprintf\n\n        if (typeof define === 'function' && define['amd']) {\n            define(function() {\n                return {\n                    'sprintf': sprintf,\n                    'vsprintf': vsprintf\n                }\n            })\n        }\n    }\n    /* eslint-enable quote-props */\n}()\n"]}