UNPKG

json-ts

Version:

Automatically generate Typescript Definition files or Flow types from JSON input

2 lines 1.86 MB
!function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var c="function"==typeof require&&require;if(!s&&c)return c(o,!0);if(a)return a(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var l=r[o]={exports:{}};t[o][0].call(l.exports,function(e){var r=t[o][1][e];return i(r||e)},l,l.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;o<n.length;o++)i(n[o]);return i}({1:[function(e,t,r){(function(e){(function(){function n(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}function i(e,t,r,n){var i=-1,a=null==e?0:e.length;for(n&&a&&(r=e[++i]);++i<a;)r=t(r,e[i],i,e);return r}function a(e){return e.split("")}function o(e){return e.match(N)||[]}function s(e){return Z.test(e)}function c(e){return $.test(e)}function u(e){return s(e)?l(e):a(e)}function l(e){return e.match(Q)||[]}function d(e){return e.match(Y)||[]}function f(){}function _(e){return null==e?e===S?w:A:de&&de in Object(e)?h(e):y(e)}function p(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),r=r>i?i:r,r<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var a=Array(i);++n<i;)a[n]=e[n+t];return a}function m(e){if("string"==typeof e)return e;if(pe(e))return n(e,m)+"";if(b(e))return _e?_e.call(e):"";var t=e+"";return"0"==t&&1/e==-E?"-0":t}function g(e,t,r){var n=e.length;return r=r===S?n:r,!t&&r>=n?e:p(e,t,r)}function h(e){var t=ce.call(e,de),r=e[de];try{e[de]=S;var n=!0}catch(e){}var i=ue.call(e);return n&&(t?e[de]=r:delete e[de]),i}function y(e){return ue.call(e)}function v(e){return null!=e&&"object"==typeof e}function b(e){return"symbol"==typeof e||v(e)&&_(e)==T}function x(e){return null==e?"":m(e)}function k(e){return(e=x(e))&&e.replace(F,oe).replace(X,"")}function D(e){return x(e).toLowerCase()}function C(e,t,r){return e=x(e),t=r?S:t,t===S?c(e)?d(e):o(e):e.match(t)||[]}var S,E=1/0,A="[object Null]",T="[object Symbol]",w="[object Undefined]",N=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,F=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,P="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",M="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",I="["+M+"]",O="["+P+"]",R="[a-z\\xdf-\\xf6\\xf8-\\xff]",B="[^\\ud800-\\udfff"+M+"\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",L="\\ud83c[\\udffb-\\udfff]",j="(?:\\ud83c[\\udde6-\\uddff]){2}",z="[\\ud800-\\udbff][\\udc00-\\udfff]",K="[A-Z\\xc0-\\xd6\\xd8-\\xde]",J="(?:"+R+"|"+B+")",q="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]|\\ud83c[\\udffb-\\udfff])?",U="(?:\\u200d(?:"+["[^\\ud800-\\udfff]",j,z].join("|")+")[\\ufe0e\\ufe0f]?"+q+")*",V="[\\ufe0e\\ufe0f]?"+q+U,W="(?:"+["[\\u2700-\\u27bf]",j,z].join("|")+")"+V,H="(?:"+["[^\\ud800-\\udfff]"+O+"?",O,j,z,"[\\ud800-\\udfff]"].join("|")+")",G=RegExp("['’]","g"),X=RegExp(O,"g"),Q=RegExp(L+"(?="+L+")|"+H+V,"g"),Y=RegExp([K+"?"+R+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[I,K,"$"].join("|")+")","(?:[A-Z\\xc0-\\xd6\\xd8-\\xde]|[^\\ud800-\\udfff\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[I,K+J,"$"].join("|")+")",K+"?"+J+"+(?:['’](?:d|ll|m|re|s|t|ve))?",K+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)","\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)","\\d+",W].join("|"),"g"),Z=RegExp("[\\u200d\\ud800-\\udfff"+P+"\\ufe0e\\ufe0f]"),$=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,ee={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"},te="object"==typeof e&&e&&e.Object===Object&&e,re="object"==typeof self&&self&&self.Object===Object&&self,ne=te||re||Function("return this")(),ie="object"==typeof r&&r&&!r.nodeType&&r,ae=ie&&"object"==typeof t&&t&&!t.nodeType&&t,oe=function(e){return function(t){return null==e?S:e[t]}}(ee),se=Object.prototype,ce=se.hasOwnProperty,ue=se.toString,le=ne.Symbol,de=le?le.toStringTag:S,fe=le?le.prototype:S,_e=fe?fe.toString:S,pe=Array.isArray,me=function(e){return function(t){return i(C(k(t).replace(G,"")),e,"")}}(function(e,t,r){return e+(r?" ":"")+ge(t)}),ge=function(e){return function(t){t=x(t);var r=s(t)?u(t):S,n=r?r[0]:t.charAt(0),i=r?g(r,1).join(""):t.slice(1);return n[e]()+i}}("toUpperCase");f.words=C,f.deburr=k,f.isArray=pe,f.isObjectLike=v,f.isSymbol=b,f.startCase=me,f.toLower=D,f.toString=x,f.upperFirst=ge,f.VERSION="4.17.4","function"==typeof define&&"object"==typeof define.amd&&define.amd?(ne._=f,define(function(){return f})):ae?((ae.exports=f)._=f,ie._=f):ne._=f}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,r){"use strict";function n(e){var t=e.reduce(function(e,t){var r=e[t.name.text];return r?(r.count+=1,t.members.forEach(function(e){r.names.add(e.name.text)})):e[t.name.text]={count:1,names:new Set([])},e},{});return e.forEach(function(e){var r=e.name.text,n=t[r];1!==n.count&&e.members.forEach(function(e){var t=e.name.text;n.names.has(t)||(e.questionToken=a.createNode(a.SyntaxKind.QuestionToken))})}),e.reduce(function(e,t){var r=t.name.text,n=new Set(t.members.map(function(e){return(e.name||e.label).text})),o=e.findIndex(function(e){return(e.name||e.label).text===r});return-1===o?e.concat(t):(e.forEach(function(e,r){if(r!==o)return e;var s=new Set(e.members.map(function(e){return(e.name||e.label).text}));n.size<s.size&&e.members.forEach(function(e){n.has(e.name.text)||(e.questionToken=a.createNode(a.SyntaxKind.QuestionToken))}),i(e.members,t.members)}),e)},[])}function i(e,t){t.forEach(function(t){var r=e.findIndex(function(e){return e.name.text===t.name.text}),n=e[r];if(n){if(s.membersMatch(n,t))return;var i=o.namedProp({name:n.name.text});if(n.type.kind===a.SyntaxKind.UnionType){new Set(n.type.types.map(function(e){return e.kind})).has(t.type.kind)||(n.type.types.push(t.type),e[r]=n)}else if(s.isEmptyArrayType(n)&&!s.isEmptyArrayType(t))i.type=a.createNode(a.SyntaxKind.ArrayType),i.type.elementType=t.type.elementType,e[r]=i;else{if(s.isEmptyArrayType(t)&&n.type.kind===a.SyntaxKind.ArrayType&&!s.isEmptyArrayType(n))return;var c=[n.type,t.type];i.type=a.createUnionOrIntersectionTypeNode(a.SyntaxKind.UnionType,c),e[r]=i}}else t.questionToken=a.createNode(a.SyntaxKind.QuestionToken),e.push(t)})}Object.defineProperty(r,"__esModule",{value:!0});var a=e("typescript"),o=e("./transformer"),s=e("./util");r.collapseInterfaces=n},{"./transformer":6,"./util":7,typescript:167}],3:[function(e,t,r){"use strict";function n(e,t){void 0===t&&(t={});var n=a({},r.defaults,t),i=s.parse(e,n),d=i.stack,f=i.inputKind;switch(f){case o.SyntaxKind.ArrayLiteralExpression:case o.SyntaxKind.ObjectLiteralExpression:var _=u.transform(d,n),p=l.collapseInterfaces(_),m=c.print(p,f,n);return m;default:var m=c.printLiteral(d[0],f,n);return m}}function i(e,t){void 0===t&&(t={});var n=new Set([]),i=a({},r.defaults,t),o=e.reduce(function(e,t){var r=s.parse(t,i),a=r.stack,o=r.inputKind;n.add(o);var c=u.transform(a,i);return e.concat(c)},[]);n.size;var d=l.collapseInterfaces(o);return c.print(d,Array.from(n)[0],i)}var a=this&&this.__assign||Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e};Object.defineProperty(r,"__esModule",{value:!0});var o=e("typescript"),s=e("./parser");r.parse=s.parse;var c=e("./printer");r.print=c.print;var u=e("./transformer");r.transform=u.transform;var l=e("./collapse-interfaces");r.defaults={prefix:"I",rootName:"RootObject"},r.json2ts=n,r.json2tsMulti=i,"undefined"!=typeof window&&void 0===window.json2ts&&(window.json2ts=n,window.json2ts.parse=s.parse,window.json2ts.transform=u.transform,window.json2ts.print=c.print)},{"./collapse-interfaces":2,"./parser":4,"./printer":5,"./transformer":6,typescript:167}],4:[function(e,t,r){"use strict";function n(e,t){function r(e){var t=l[l.length-1];(t&&t.body?t.body:u).push(e)}function n(e){switch(e.kind){case a.SyntaxKind.NullKeyword:case a.SyntaxKind.TrueKeyword:case a.SyntaxKind.FalseKeyword:case a.SyntaxKind.NumericLiteral:case a.SyntaxKind.StringLiteral:r(c(e,e.kind));break;case a.SyntaxKind.PrefixUnaryExpression:r(c(e,a.SyntaxKind.NumericLiteral));break;case a.SyntaxKind.ObjectLiteralExpression:var t={kind:a.SyntaxKind.ObjectLiteralExpression,_kind:"ObjectLiteralExpression",interfaceCandidate:!0,body:[]};r(t),l.push(t),i(e.properties),l.pop();break;case a.SyntaxKind.ArrayLiteralExpression:var t={kind:a.SyntaxKind.ArrayLiteralExpression,_kind:"ArrayLiteralExpression",body:[]};r(t),l.push(t),i(e.elements),l.pop()}}function i(e){e.forEach(function(e){if(!e.initializer)return n(e);switch(e.initializer.kind){case a.SyntaxKind.TrueKeyword:case a.SyntaxKind.FalseKeyword:case a.SyntaxKind.NullKeyword:case a.SyntaxKind.StringLiteral:case a.SyntaxKind.NumericLiteral:r(s(e,e.initializer.kind));break;case a.SyntaxKind.PrefixUnaryExpression:r(s(e,a.SyntaxKind.NumericLiteral));break;case a.SyntaxKind.ObjectLiteralExpression:var t=o(e.name.text).needsQuotes,c=!1===t,u={name:e.name.text,body:[],interfaceCandidate:c,kind:a.SyntaxKind.ObjectLiteralExpression,_kind:"ObjectLiteralExpression"};r(u),l.push(u),i(e.initializer.properties),l.pop();break;case a.SyntaxKind.ArrayLiteralExpression:var u={name:e.name.text,body:[],kind:a.SyntaxKind.ArrayLiteralExpression,_kind:"ArrayLiteralExpression"};r(u),l.push(u),i(e.initializer.elements),l.pop()}})}function s(e,t){return{name:e.name.text,value:e.initializer.text,kind:t}}function c(e,t){return{kind:t,name:e.text,value:e.text}}void 0===t&&(t=[]);var u=t.slice(),l=t.slice();return i(e),u}function i(e,t){var r,i="const ROOTOBJ = "+e,o=a.createSourceFile("json.ts",i,a.ScriptTarget.ES2015,!0),s=o.statements[0],c=s.declarationList.declarations[0].initializer;switch(c.kind){case a.SyntaxKind.TrueKeyword:case a.SyntaxKind.FalseKeyword:case a.SyntaxKind.NullKeyword:case a.SyntaxKind.StringLiteral:case a.SyntaxKind.NumericLiteral:r=[{kind:c.kind}];break;case a.SyntaxKind.ArrayLiteralExpression:r=n(c.elements,[{kind:a.SyntaxKind.ArrayLiteralExpression,_kind:"ArrayLiteralExpression",name:t.rootName,body:[]}]);break;default:r=n(c.properties)}return{stack:r,inputKind:c.kind}}Object.defineProperty(r,"__esModule",{value:!0});var a=e("typescript"),o=e("needsquotes");r.parse=i},{needsquotes:109,typescript:167}],5:[function(e,t,r){"use strict";function n(e,t,r){var n=a.createSourceFile("module",""),i=a.createPrinter({newLine:a.NewLineKind.LineFeed});if(t===a.SyntaxKind.ArrayLiteralExpression){var o=e[0],s=a.createNode(a.SyntaxKind.TypeAliasDeclaration);s.type=o.members[0].type,s.name=a.createIdentifier(""+r.prefix+r.rootName),e[0]=s}if(r.flow){return["// @flow",e.map(function(e){var t=a.createNode(a.SyntaxKind.TypeAliasDeclaration);return t.modifiers=[a.createToken(a.SyntaxKind.ExportKeyword)],t.type=a.createTypeLiteralNode(e.members),t.name=e.name,t}).map(function(e){return i.printNode(a.EmitHint.Unspecified,e,n)}).join("\n")+"\n"].join("\n")}if(r.namespace){e.forEach(function(e){e.modifiers=[a.createToken(a.SyntaxKind.ExportKeyword)]});var c=a.createModuleDeclaration(void 0,[a.createToken(a.SyntaxKind.DeclareKeyword)],a.createIdentifier(r.namespace),a.createModuleBlock(e),a.NodeFlags.Namespace);return i.printNode(a.EmitHint.Unspecified,c,n)+"\n"}return e.map(function(e){return i.printNode(a.EmitHint.Unspecified,e,n)}).join("\n")+"\n"}function i(e,t,r){var n=a.createSourceFile("module",""),i=a.createPrinter({newLine:a.NewLineKind.LineFeed}),s=a.createNode(a.SyntaxKind.TypeAliasDeclaration);return s.type=a.createNode(o.kindMap[t]),s.name=a.createIdentifier(""+r.prefix+r.rootName),i.printNode(a.EmitHint.Unspecified,s,n)}Object.defineProperty(r,"__esModule",{value:!0});var a=e("typescript"),o=e("./transformer");r.print=n,r.printLiteral=i},{"./transformer":6,typescript:167}],6:[function(e,t,r){"use strict";function n(e){var t=s(e.name),r=t.needsQuotes?t.quotedValue:e.name,n=a.createNode(a.SyntaxKind.PropertySignature);return n.name=a.createIdentifier(r),e.optional&&(n.questionToken=a.createNode(a.SyntaxKind.QuestionToken)),n}function i(e,t){function i(e){var t=f(e.body),r=a.createNode(a.SyntaxKind.InterfaceDeclaration);return r.name=a.createIdentifier(p(e)),r.members=a.createNodeArray(t,!1),r}function u(e){return e.reduce(function(e,t){if(t.kind===a.SyntaxKind.ObjectLiteralExpression){var r=i(t);return t.interfaceCandidate?e.concat([r],u(t.body)):e.concat(u(t.body))}if(t.kind===a.SyntaxKind.ArrayLiteralExpression){var n=t.body.map(function(e){return e.name=h(t.name),e}),o=u(n);return e.concat(o)}return e},[])}function f(e){return e.map(function(e){switch(e.kind){case a.SyntaxKind.FalseKeyword:case a.SyntaxKind.TrueKeyword:var t=n({name:e.name});return t.type=a.createNode(a.SyntaxKind.BooleanKeyword),t;case a.SyntaxKind.StringLiteral:var t=n({name:e.name});return t.type=a.createNode(a.SyntaxKind.StringKeyword),t;case a.SyntaxKind.NullKeyword:var t=n({name:e.name});return t.type=a.createNode(a.SyntaxKind.NullKeyword),t;case a.SyntaxKind.NumericLiteral:var t=n({name:e.name});return t.type=a.createNode(a.SyntaxKind.NumberKeyword),t;case a.SyntaxKind.ObjectLiteralExpression:if(e.interfaceCandidate){var t=n({name:e.name});return t.type=a.createTypeReferenceNode(p(e),void 0),t}var t=n({name:e.name});return t.type=a.createTypeLiteralNode(f(e.body)),t;case a.SyntaxKind.ArrayLiteralExpression:if(e.body.length){var t=n({name:e.name}),r=_(e);return t.type=a.createArrayTypeNode(r),t}var t=n({name:e.name}),i=a.createNode(a.SyntaxKind.AnyKeyword);return t.type=a.createArrayTypeNode(i),t}})}function _(e){var t=o.Set(e.body.map(function(e){return e.kind}));if(1===t.size){var n=t.first();switch(n){case a.SyntaxKind.NullKeyword:case a.SyntaxKind.StringLiteral:case a.SyntaxKind.TrueKeyword:case a.SyntaxKind.FalseKeyword:case a.SyntaxKind.NumericLiteral:return a.createNode(r.kindMap[n]);case a.SyntaxKind.ObjectLiteralExpression:var i=a.createTypeReferenceNode(g(e.name),void 0);return i;default:return a.createNode(a.SyntaxKind.AnyKeyword)}}else if(2===t.size&&t.has(a.SyntaxKind.TrueKeyword)&&t.has(a.SyntaxKind.FalseKeyword))return a.createNode(a.SyntaxKind.BooleanKeyword);if(t.every(function(e){return d.has(e)})){var s=t.map(function(e){return a.createNode(r.kindMap[e])}).toJS(),i=a.createNode(a.SyntaxKind.ParenthesizedType);return i.type=a.createUnionOrIntersectionTypeNode(a.SyntaxKind.UnionType,s),i}return a.createNode(a.SyntaxKind.AnyKeyword)}function p(e){var r=e.name[0].toUpperCase()+e.name.slice(1);return t.prefix?t.prefix+r:s(r).needsQuotes?"_"+r:r}function m(e){return l(e).replace(/ /g,"")}function g(e){return t.prefix?m(t.prefix+"_"+e+"_Item"):s(e).needsQuotes?"_"+m(e+"_Item"):m(e+"_Item")}function h(e){return m(e+"_Item")}var y=[{kind:a.SyntaxKind.ObjectLiteralExpression,_kind:"ObjectLiteralExpression",name:t.rootName,interfaceCandidate:!0,body:e}],v=u(y);return c.collapseInterfaces(v)}Object.defineProperty(r,"__esModule",{value:!0});var a=e("typescript"),o=e("immutable"),s=e("needsquotes"),c=e("./collapse-interfaces"),u=e("../_"),l=u.startCase;u.toLower;r.log=function(e){return console.log("--\n",JSON.stringify(e,null,2))},r.kindMap=(f={},f[a.SyntaxKind.NullKeyword]=a.SyntaxKind.NullKeyword,f[a.SyntaxKind.StringLiteral]=a.SyntaxKind.StringKeyword,f[a.SyntaxKind.FirstLiteralToken]=a.SyntaxKind.NumberKeyword,f[a.SyntaxKind.TrueKeyword]=a.SyntaxKind.BooleanKeyword,f[a.SyntaxKind.FalseKeyword]=a.SyntaxKind.BooleanKeyword,f[a.SyntaxKind.NumericLiteral]=a.SyntaxKind.NumberKeyword,f),r.namedProp=n;var d=o.Set([a.SyntaxKind.TrueKeyword,a.SyntaxKind.FalseKeyword,a.SyntaxKind.StringLiteral,a.SyntaxKind.NumericLiteral,a.SyntaxKind.PrefixUnaryExpression,a.SyntaxKind.NullKeyword]);r.transform=i;var f},{"../_":1,"./collapse-interfaces":2,immutable:101,needsquotes:109,typescript:167}],7:[function(e,t,r){"use strict";function n(e,t){return e.kind===t.kind&&(e.name.text===t.name.text&&(e.type.kind===t.type.kind&&(e.type.kind!==a.SyntaxKind.ArrayType||t.type.kind!==a.SyntaxKind.ArrayType||e.type.elementType.kind===t.type.elementType.kind)))}function i(e){return e.type.kind===a.SyntaxKind.ArrayType&&e.type.elementType.kind===a.SyntaxKind.AnyKeyword}Object.defineProperty(r,"__esModule",{value:!0});var a=e("typescript");r.membersMatch=n,r.isEmptyArrayType=i},{typescript:167}],8:[function(e,t,r){var n=r;n.bignum=e("bn.js"),n.define=e("./asn1/api").define,n.base=e("./asn1/base"),n.constants=e("./asn1/constants"),n.decoders=e("./asn1/decoders"),n.encoders=e("./asn1/encoders")},{"./asn1/api":9,"./asn1/base":11,"./asn1/constants":15,"./asn1/decoders":17,"./asn1/encoders":20,"bn.js":23}],9:[function(e,t,r){function n(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}var i=e("../asn1"),a=e("inherits");r.define=function(e,t){return new n(e,t)},n.prototype._createNamed=function(t){var r;try{r=e("vm").runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(e){r=function(e){this._initNamed(e)}}return a(r,t),r.prototype._initNamed=function(e){t.call(this,e)},new r(this)},n.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(i.decoders[e])),this.decoders[e]},n.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},n.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(i.encoders[e])),this.encoders[e]},n.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}},{"../asn1":8,inherits:103,vm:169}],10:[function(e,t,r){function n(e,t){if(o.call(this,t),!s.isBuffer(e))return void this.error("Input not Buffer");this.base=e,this.offset=0,this.length=e.length}function i(e,t){if(Array.isArray(e))this.length=0,this.value=e.map(function(e){return e instanceof i||(e=new i(e,t)),this.length+=e.length,e},this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=s.byteLength(e);else{if(!s.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}var a=e("inherits"),o=e("../base").Reporter,s=e("buffer").Buffer;a(n,o),r.DecoderBuffer=n,n.prototype.save=function(){return{offset:this.offset,reporter:o.prototype.save.call(this)}},n.prototype.restore=function(e){var t=new n(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,o.prototype.restore.call(this,e.reporter),t},n.prototype.isEmpty=function(){return this.offset===this.length},n.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},n.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");var r=new n(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},n.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},r.EncoderBuffer=i,i.prototype.join=function(e,t){return e||(e=new s(this.length)),t||(t=0),0===this.length?e:(Array.isArray(this.value)?this.value.forEach(function(r){r.join(e,t),t+=r.length}):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):s.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length),e)}},{"../base":11,buffer:54,inherits:103}],11:[function(e,t,r){var n=r;n.Reporter=e("./reporter").Reporter,n.DecoderBuffer=e("./buffer").DecoderBuffer,n.EncoderBuffer=e("./buffer").EncoderBuffer,n.Node=e("./node")},{"./buffer":10,"./node":12,"./reporter":13}],12:[function(e,t,r){function n(e,t){var r={};this._baseState=r,r.enc=e,r.parent=t||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}var i=e("../base").Reporter,a=e("../base").EncoderBuffer,o=e("../base").DecoderBuffer,s=e("minimalistic-assert"),c=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],u=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(c),l=["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"];t.exports=n;var d=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];n.prototype.clone=function(){var e=this._baseState,t={};d.forEach(function(r){t[r]=e[r]});var r=new this.constructor(t.parent);return r._baseState=t,r},n.prototype._wrap=function(){var e=this._baseState;u.forEach(function(t){this[t]=function(){var r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}},this)},n.prototype._init=function(e){var t=this._baseState;s(null===t.parent),e.call(this),t.children=t.children.filter(function(e){return e._baseState.parent===this},this),s.equal(t.children.length,1,"Root node can have only one child")},n.prototype._useArgs=function(e){var t=this._baseState,r=e.filter(function(e){return e instanceof this.constructor},this);e=e.filter(function(e){return!(e instanceof this.constructor)},this),0!==r.length&&(s(null===t.children),t.children=r,r.forEach(function(e){e._baseState.parent=this},this)),0!==e.length&&(s(null===t.args),t.args=e,t.reverseArgs=e.map(function(e){if("object"!=typeof e||e.constructor!==Object)return e;var t={};return Object.keys(e).forEach(function(r){r==(0|r)&&(r|=0);var n=e[r];t[n]=r}),t}))},l.forEach(function(e){n.prototype[e]=function(){var t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}}),c.forEach(function(e){n.prototype[e]=function(){var t=this._baseState,r=Array.prototype.slice.call(arguments);return s(null===t.tag),t.tag=e,this._useArgs(r),this}}),n.prototype.use=function(e){s(e);var t=this._baseState;return s(null===t.use),t.use=e,this},n.prototype.optional=function(){return this._baseState.optional=!0,this},n.prototype.def=function(e){var t=this._baseState;return s(null===t.default),t.default=e,t.optional=!0,this},n.prototype.explicit=function(e){var t=this._baseState;return s(null===t.explicit&&null===t.implicit),t.explicit=e,this},n.prototype.implicit=function(e){var t=this._baseState;return s(null===t.explicit&&null===t.implicit),t.implicit=e,this},n.prototype.obj=function(){var e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},n.prototype.key=function(e){var t=this._baseState;return s(null===t.key),t.key=e,this},n.prototype.any=function(){return this._baseState.any=!0,this},n.prototype.choice=function(e){var t=this._baseState;return s(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map(function(t){return e[t]})),this},n.prototype.contains=function(e){var t=this._baseState;return s(null===t.use),t.contains=e,this},n.prototype._decode=function(e,t){var r=this._baseState;if(null===r.parent)return e.wrapResult(r.children[0]._decode(e,t));var n=r.default,i=!0,a=null;if(null!==r.key&&(a=e.enterKey(r.key)),r.optional){var s=null;if(null!==r.explicit?s=r.explicit:null!==r.implicit?s=r.implicit:null!==r.tag&&(s=r.tag),null!==s||r.any){if(i=this._peekTag(e,s,r.any),e.isError(i))return i}else{var c=e.save();try{null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),i=!0}catch(e){i=!1}e.restore(c)}}var u;if(r.obj&&i&&(u=e.enterObject()),i){if(null!==r.explicit){var l=this._decodeTag(e,r.explicit);if(e.isError(l))return l;e=l}var d=e.offset;if(null===r.use&&null===r.choice){if(r.any)var c=e.save();var f=this._decodeTag(e,null!==r.implicit?r.implicit:r.tag,r.any);if(e.isError(f))return f;r.any?n=e.raw(c):e=f}if(t&&t.track&&null!==r.tag&&t.track(e.path(),d,e.length,"tagged"),t&&t.track&&null!==r.tag&&t.track(e.path(),e.offset,e.length,"content"),n=r.any?n:null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),e.isError(n))return n;if(r.any||null!==r.choice||null===r.children||r.children.forEach(function(r){r._decode(e,t)}),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){var _=new o(n);n=this._getUse(r.contains,e._reporterState.obj)._decode(_,t)}}return r.obj&&i&&(n=e.leaveObject(u)),null===r.key||null===n&&!0!==i?null!==a&&e.exitKey(a):e.leaveKey(a,r.key,n),n},n.prototype._decodeGeneric=function(e,t,r){var n=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,n.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&n.args?this._decodeObjid(t,n.args[0],n.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},n.prototype._getUse=function(e,t){var r=this._baseState;return r.useDecoder=this._use(e,t),s(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},n.prototype._decodeChoice=function(e,t){var r=this._baseState,n=null,i=!1;return Object.keys(r.choice).some(function(a){var o=e.save(),s=r.choice[a];try{var c=s._decode(e,t);if(e.isError(c))return!1;n={type:a,value:c},i=!0}catch(t){return e.restore(o),!1}return!0},this),i?n:e.error("Choice not matched")},n.prototype._createEncoderBuffer=function(e){return new a(e,this.reporter)},n.prototype._encode=function(e,t,r){var n=this._baseState;if(null===n.default||n.default!==e){var i=this._encodeValue(e,t,r);if(void 0!==i&&!this._skipDefault(i,t,r))return i}},n.prototype._encodeValue=function(e,t,r){var n=this._baseState;if(null===n.parent)return n.children[0]._encode(e,t||new i);var a=null;if(this.reporter=t,n.optional&&void 0===e){if(null===n.default)return;e=n.default}var o=null,s=!1;if(n.any)a=this._createEncoderBuffer(e);else if(n.choice)a=this._encodeChoice(e,t);else if(n.contains)o=this._getUse(n.contains,r)._encode(e,t),s=!0;else if(n.children)o=n.children.map(function(r){if("null_"===r._baseState.tag)return r._encode(null,t,e);if(null===r._baseState.key)return t.error("Child should have a key");var n=t.enterKey(r._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");var i=r._encode(e[r._baseState.key],t,e);return t.leaveKey(n),i},this).filter(function(e){return e}),o=this._createEncoderBuffer(o);else if("seqof"===n.tag||"setof"===n.tag){if(!n.args||1!==n.args.length)return t.error("Too many args for : "+n.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");var c=this.clone();c._baseState.implicit=null,o=this._createEncoderBuffer(e.map(function(r){var n=this._baseState;return this._getUse(n.args[0],e)._encode(r,t)},c))}else null!==n.use?a=this._getUse(n.use,r)._encode(e,t):(o=this._encodePrimitive(n.tag,e),s=!0);var a;if(!n.any&&null===n.choice){var u=null!==n.implicit?n.implicit:n.tag,l=null===n.implicit?"universal":"context";null===u?null===n.use&&t.error("Tag could be ommited only for .use()"):null===n.use&&(a=this._encodeComposite(u,s,l,o))}return null!==n.explicit&&(a=this._encodeComposite(n.explicit,!1,"context",a)),a},n.prototype._encodeChoice=function(e,t){var r=this._baseState,n=r.choice[e.type];return n||s(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),n._encode(e.value,t)},n.prototype._encodePrimitive=function(e,t){var r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},n.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},n.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(e)}},{"../base":11,"minimalistic-assert":107}],13:[function(e,t,r){function n(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function i(e,t){this.path=e,this.rethrow(t)}var a=e("inherits");r.Reporter=n,n.prototype.isError=function(e){return e instanceof i},n.prototype.save=function(){var e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},n.prototype.restore=function(e){var t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},n.prototype.enterKey=function(e){return this._reporterState.path.push(e)},n.prototype.exitKey=function(e){var t=this._reporterState;t.path=t.path.slice(0,e-1)},n.prototype.leaveKey=function(e,t,r){var n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},n.prototype.path=function(){return this._reporterState.path.join("/")},n.prototype.enterObject=function(){var e=this._reporterState,t=e.obj;return e.obj={},t},n.prototype.leaveObject=function(e){var t=this._reporterState,r=t.obj;return t.obj=e,r},n.prototype.error=function(e){var t,r=this._reporterState,n=e instanceof i;if(t=n?e:new i(r.path.map(function(e){return"["+JSON.stringify(e)+"]"}).join(""),e.message||e,e.stack),!r.options.partial)throw t;return n||r.errors.push(t),t},n.prototype.wrapResult=function(e){var t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},a(i,Error),i.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,i),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},{ inherits:103}],14:[function(e,t,r){var n=e("../constants");r.tagClass={0:"universal",1:"application",2:"context",3:"private"},r.tagClassByName=n._reverse(r.tagClass),r.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},r.tagByName=n._reverse(r.tag)},{"../constants":15}],15:[function(e,t,r){var n=r;n._reverse=function(e){var t={};return Object.keys(e).forEach(function(r){(0|r)==r&&(r|=0);var n=e[r];t[n]=r}),t},n.der=e("./der")},{"./der":14}],16:[function(e,t,r){function n(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new i,this.tree._init(e.body)}function i(e){u.Node.call(this,"der",e)}function a(e,t){var r=e.readUInt8(t);if(e.isError(r))return r;var n=d.tagClass[r>>6],i=0==(32&r);if(31==(31&r)){var a=r;for(r=0;128==(128&a);){if(a=e.readUInt8(t),e.isError(a))return a;r<<=7,r|=127&a}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:d.tag[r]}}function o(e,t,r){var n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(0==(128&n))return n;var i=127&n;if(i>4)return e.error("length octect is too long");n=0;for(var a=0;a<i;a++){n<<=8;var o=e.readUInt8(r);if(e.isError(o))return o;n|=o}return n}var s=e("inherits"),c=e("../../asn1"),u=c.base,l=c.bignum,d=c.constants.der;t.exports=n,n.prototype.decode=function(e,t){return e instanceof u.DecoderBuffer||(e=new u.DecoderBuffer(e,t)),this.tree._decode(e,t)},s(i,u.Node),i.prototype._peekTag=function(e,t,r){if(e.isEmpty())return!1;var n=e.save(),i=a(e,'Failed to peek tag: "'+t+'"');return e.isError(i)?i:(e.restore(n),i.tag===t||i.tagStr===t||i.tagStr+"of"===t||r)},i.prototype._decodeTag=function(e,t,r){var n=a(e,'Failed to decode tag of "'+t+'"');if(e.isError(n))return n;var i=o(e,n.primitive,'Failed to get length of "'+t+'"');if(e.isError(i))return i;if(!r&&n.tag!==t&&n.tagStr!==t&&n.tagStr+"of"!==t)return e.error('Failed to match tag: "'+t+'"');if(n.primitive||null!==i)return e.skip(i,'Failed to match body of: "'+t+'"');var s=e.save(),c=this._skipUntilEnd(e,'Failed to skip indefinite length body: "'+this.tag+'"');return e.isError(c)?c:(i=e.offset-s.offset,e.restore(s),e.skip(i,'Failed to match body of: "'+t+'"'))},i.prototype._skipUntilEnd=function(e,t){for(;;){var r=a(e,t);if(e.isError(r))return r;var n=o(e,r.primitive,t);if(e.isError(n))return n;var i;if(i=r.primitive||null!==n?e.skip(n):this._skipUntilEnd(e,t),e.isError(i))return i;if("end"===r.tagStr)break}},i.prototype._decodeList=function(e,t,r,n){for(var i=[];!e.isEmpty();){var a=this._peekTag(e,"end");if(e.isError(a))return a;var o=r.decode(e,"der",n);if(e.isError(o)&&a)break;i.push(o)}return i},i.prototype._decodeStr=function(e,t){if("bitstr"===t){var r=e.readUInt8();return e.isError(r)?r:{unused:r,data:e.raw()}}if("bmpstr"===t){var n=e.raw();if(n.length%2==1)return e.error("Decoding of string type: bmpstr length mismatch");for(var i="",a=0;a<n.length/2;a++)i+=String.fromCharCode(n.readUInt16BE(2*a));return i}if("numstr"===t){var o=e.raw().toString("ascii");return this._isNumstr(o)?o:e.error("Decoding of string type: numstr unsupported characters")}if("octstr"===t)return e.raw();if("objDesc"===t)return e.raw();if("printstr"===t){var s=e.raw().toString("ascii");return this._isPrintstr(s)?s:e.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(t)?e.raw().toString():e.error("Decoding of string type: "+t+" unsupported")},i.prototype._decodeObjid=function(e,t,r){for(var n,i=[],a=0;!e.isEmpty();){var o=e.readUInt8();a<<=7,a|=127&o,0==(128&o)&&(i.push(a),a=0)}128&o&&i.push(a);var s=i[0]/40|0,c=i[0]%40;if(n=r?i:[s,c].concat(i.slice(1)),t){var u=t[n.join(" ")];void 0===u&&(u=t[n.join(".")]),void 0!==u&&(n=u)}return n},i.prototype._decodeTime=function(e,t){var r=e.raw().toString();if("gentime"===t)var n=0|r.slice(0,4),i=0|r.slice(4,6),a=0|r.slice(6,8),o=0|r.slice(8,10),s=0|r.slice(10,12),c=0|r.slice(12,14);else{if("utctime"!==t)return e.error("Decoding "+t+" time is not supported yet");var n=0|r.slice(0,2),i=0|r.slice(2,4),a=0|r.slice(4,6),o=0|r.slice(6,8),s=0|r.slice(8,10),c=0|r.slice(10,12);n=n<70?2e3+n:1900+n}return Date.UTC(n,i-1,a,o,s,c,0)},i.prototype._decodeNull=function(e){return null},i.prototype._decodeBool=function(e){var t=e.readUInt8();return e.isError(t)?t:0!==t},i.prototype._decodeInt=function(e,t){var r=e.raw(),n=new l(r);return t&&(n=t[n.toString(10)]||n),n},i.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getDecoder("der").tree}},{"../../asn1":8,inherits:103}],17:[function(e,t,r){var n=r;n.der=e("./der"),n.pem=e("./pem")},{"./der":16,"./pem":18}],18:[function(e,t,r){function n(e){o.call(this,e),this.enc="pem"}var i=e("inherits"),a=e("buffer").Buffer,o=e("./der");i(n,o),t.exports=n,n.prototype.decode=function(e,t){for(var r=e.toString().split(/[\r\n]+/g),n=t.label.toUpperCase(),i=-1,s=-1,c=0;c<r.length;c++){var u=r[c].match(/^-----(BEGIN|END) ([^-]+)-----$/);if(null!==u&&u[2]===n){if(-1!==i){if("END"!==u[1])break;s=c;break}if("BEGIN"!==u[1])break;i=c}}if(-1===i||-1===s)throw new Error("PEM section not found for: "+n);var l=r.slice(i+1,s).join("");l.replace(/[^a-z0-9\+\/=]+/gi,"");var d=new a(l,"base64");return o.prototype.decode.call(this,d,t)}},{"./der":16,buffer:54,inherits:103}],19:[function(e,t,r){function n(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new i,this.tree._init(e.body)}function i(e){l.Node.call(this,"der",e)}function a(e){return e<10?"0"+e:e}function o(e,t,r,n){var i;if("seqof"===e?e="seq":"setof"===e&&(e="set"),d.tagByName.hasOwnProperty(e))i=d.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return n.error("Unknown tag: "+e);i=e}return i>=31?n.error("Multi-octet tag encoding unsupported"):(t||(i|=32),i|=d.tagClassByName[r||"universal"]<<6)}var s=e("inherits"),c=e("buffer").Buffer,u=e("../../asn1"),l=u.base,d=u.constants.der;t.exports=n,n.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},s(i,l.Node),i.prototype._encodeComposite=function(e,t,r,n){var i=o(e,t,r,this.reporter);if(n.length<128){var a=new c(2);return a[0]=i,a[1]=n.length,this._createEncoderBuffer([a,n])}for(var s=1,u=n.length;u>=256;u>>=8)s++;var a=new c(2+s);a[0]=i,a[1]=128|s;for(var u=1+s,l=n.length;l>0;u--,l>>=8)a[u]=255&l;return this._createEncoderBuffer([a,n])},i.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var r=new c(2*e.length),n=0;n<e.length;n++)r.writeUInt16BE(e.charCodeAt(n),2*n);return this._createEncoderBuffer(r)}return"numstr"===t?this._isNumstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===t?this._isPrintstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(t)?this._createEncoderBuffer(e):"objDesc"===t?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: "+t+" unsupported")},i.prototype._encodeObjid=function(e,t,r){if("string"==typeof e){if(!t)return this.reporter.error("string objid given, but no values map found");if(!t.hasOwnProperty(e))return this.reporter.error("objid not found in values map");e=t[e].split(/[\s\.]+/g);for(var n=0;n<e.length;n++)e[n]|=0}else if(Array.isArray(e)){e=e.slice();for(var n=0;n<e.length;n++)e[n]|=0}if(!Array.isArray(e))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(e));if(!r){if(e[1]>=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}for(var i=0,n=0;n<e.length;n++){var a=e[n];for(i++;a>=128;a>>=7)i++}for(var o=new c(i),s=o.length-1,n=e.length-1;n>=0;n--){var a=e[n];for(o[s--]=127&a;(a>>=7)>0;)o[s--]=128|127&a}return this._createEncoderBuffer(o)},i.prototype._encodeTime=function(e,t){var r,n=new Date(e);return"gentime"===t?r=[a(n.getFullYear()),a(n.getUTCMonth()+1),a(n.getUTCDate()),a(n.getUTCHours()),a(n.getUTCMinutes()),a(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[a(n.getFullYear()%100),a(n.getUTCMonth()+1),a(n.getUTCDate()),a(n.getUTCHours()),a(n.getUTCMinutes()),a(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},i.prototype._encodeNull=function(){return this._createEncoderBuffer("")},i.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!c.isBuffer(e)){var r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=new c(r)}if(c.isBuffer(e)){var n=e.length;0===e.length&&n++;var i=new c(n);return e.copy(i),0===e.length&&(i[0]=0),this._createEncoderBuffer(i)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);for(var n=1,a=e;a>=256;a>>=8)n++;for(var i=new Array(n),a=i.length-1;a>=0;a--)i[a]=255&e,e>>=8;return 128&i[0]&&i.unshift(0),this._createEncoderBuffer(new c(i))},i.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},i.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},i.prototype._skipDefault=function(e,t,r){var n,i=this._baseState;if(null===i.default)return!1;var a=e.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i.default,t,r).join()),a.length!==i.defaultBuffer.length)return!1;for(n=0;n<a.length;n++)if(a[n]!==i.defaultBuffer[n])return!1;return!0}},{"../../asn1":8,buffer:54,inherits:103}],20:[function(e,t,r){var n=r;n.der=e("./der"),n.pem=e("./pem")},{"./der":19,"./pem":21}],21:[function(e,t,r){function n(e){a.call(this,e),this.enc="pem"}var i=e("inherits"),a=e("./der");i(n,a),t.exports=n,n.prototype.encode=function(e,t){for(var r=a.prototype.encode.call(this,e),n=r.toString("base64"),i=["-----BEGIN "+t.label+"-----"],o=0;o<n.length;o+=64)i.push(n.slice(o,o+64));return i.push("-----END "+t.label+"-----"),i.join("\n")}},{"./der":19,inherits:103}],22:[function(e,t,r){"use strict";function n(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function i(e){return 3*e.length/4-n(e)}function a(e){var t,r,i,a,o,s,c=e.length;o=n(e),s=new d(3*c/4-o),i=o>0?c-4:c;var u=0;for(t=0,r=0;t<i;t+=4,r+=3)a=l[e.charCodeAt(t)]<<18|l[e.charCodeAt(t+1)]<<12|l[e.charCodeAt(t+2)]<<6|l[e.charCodeAt(t+3)],s[u++]=a>>16&255,s[u++]=a>>8&255,s[u++]=255&a;return 2===o?(a=l[e.charCodeAt(t)]<<2|l[e.charCodeAt(t+1)]>>4,s[u++]=255&a):1===o&&(a=l[e.charCodeAt(t)]<<10|l[e.charCodeAt(t+1)]<<4|l[e.charCodeAt(t+2)]>>2,s[u++]=a>>8&255,s[u++]=255&a),s}function o(e){return u[e>>18&63]+u[e>>12&63]+u[e>>6&63]+u[63&e]}function s(e,t,r){for(var n,i=[],a=t;a<r;a+=3)n=(e[a]<<16)+(e[a+1]<<8)+e[a+2],i.push(o(n));return i.join("")}function c(e){for(var t,r=e.length,n=r%3,i="",a=[],o=0,c=r-n;o<c;o+=16383)a.push(s(e,o,o+16383>c?c:o+16383));return 1===n?(t=e[r-1],i+=u[t>>2],i+=u[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=u[t>>10],i+=u[t>>4&63],i+=u[t<<2&63],i+="="),a.push(i),a.join("")}r.byteLength=i,r.toByteArray=a,r.fromByteArray=c;for(var u=[],l=[],d="undefined"!=typeof Uint8Array?Uint8Array:Array,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_=0,p=f.length;_<p;++_)u[_]=f[_],l[f.charCodeAt(_)]=_;l["-".charCodeAt(0)]=62,l["_".charCodeAt(0)]=63},{}],23:[function(e,t,r){!function(t,r){"use strict";function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function a(e,t,r){if(a.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}function o(e,t,r){for(var n=0,i=Math.min(e.length,r),a=t;a<i;a++){var o=e.charCodeAt(a)-48;n<<=4,n|=o>=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return n}function s(e,t,r,n){for(var i=0,a=Math.min(e.length,r),o=t;o<a;o++){var s=e.charCodeAt(o)-48;i*=n,i+=s>=49?s-49+10:s>=17?s-17+10:s}return i}function c(e){for(var t=new Array(e.bitLength()),r=0;r<t.length;r++){var n=r/26|0,i=r%26;t[r]=(e.words[n]&1<<i)>>>i}return t}function u(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],a=0|t.words[0],o=i*a,s=67108863&o,c=o/67108864|0;r.words[0]=s;for(var u=1;u<n;u++){for(var l=c>>>26,d=67108863&c,f=Math.min(u,t.length-1),_=Math.max(0,u-e.length+1);_<=f;_++){var p=u-_|0;i=0|e.words[p],a=0|t.words[_],o=i*a+d,l+=o/67108864|0,d=67108863&o}r.words[u]=0|d,c=0|l}return 0!==c?r.words[u]=0|c:r.length--,r.strip()}function l(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,a=0;a<r.length-1;a++){var o=i;i=0;for(var s=67108863&n,c=Math.min(a,t.length-1),u=Math.max(0,a-e.length+1);u<=c;u++){var l=a-u,d=0|e.words[l],f=0|t.words[u],_=d*f,p=67108863&_;o=o+(_/67108864|0)|0,p=p+s|0,s=67108863&p,o=o+(p>>>26)|0,i+=o>>>26,o&=67108863}r.words[a]=s,n=o,o=i}return 0!==n?r.words[a]=n:r.length--,r.strip()}function d(e,t,r){return(new f).mulp(e,t,r)}function f(e,t){this.x=e,this.y=t}function _(e,t){this.name=e,this.p=new a(t,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function p(){_.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function m(){_.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function g(){_.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function h(){_.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function y(e){if("string"==typeof e){var t=a._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function v(e){y.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new a(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}"object"==typeof t?t.exports=a:r.BN=a,a.BN=a,a.wordSize=26;var b;try{b=e("buffer").Buffer}catch(e){}a.isBN=function(e){return e instanceof a||null!==e&&"object"==typeof e&&e.constructor.wordSize===a.wordSize&&Array.isArray(e.words)},a.max=function(e,t){return e.cmp(t)>0?e:t},a.min=function(e,t){return e.cmp(t)<0?e:t},a.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36),e=e.toString().replace(/\s+/g,"");var i=0;"-"===e[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},a.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},a.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var a,o,s=0;if("be"===r)for(i=e.length-1,a=0;i>=0;i-=3)o=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[a]|=o<<s&67108863,this.words[a+1]=o>>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);else if("le"===r)for(i=0,a=0;i<e.length;i+=3)o=e[i]|e[i+1]<<8|e[i+2]<<16,this.words[a]|=o<<s&67108863,this.words[a+1]=o>>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);return this.strip()},a.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var n,i,a=0;for(r=e.length-6,n=0;r>=t;r-=6)i=o(e,r,r+6),this.words[n]|=i<<a&67108863,this.words[n+1]|=i>>>26-a&4194303,(a+=24)>=26&&(a-=26,n++);r+6!==t&&(i=o(e,t,r+6),this.words[n]|=i<<a&67108863,this.words[n+1]|=i>>>26-a&4194303),this.strip()},a.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var a=e.length-r,o=a%n,c=Math.min(a,a-o)+r,u=0,l=r;l<c;l+=n)u=s(e,l,l+n,t),this.imuln(i),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==o){var d=1;for(u=s(e,l,e.length,t),l=0;l<o;l++)d*=t;this.imuln(d),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}},a.prototype.copy=function(e){e.words=new Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red},a.prototype.clone=function(){var e=new a(null);return this.copy(e),e},a.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},a.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},a.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},a.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var x=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","000000000000000000000000