function hasKey(e,t){var s=e;t.slice(0,-1).forEach(function(e){s=s[e]||{}});var n=t[t.length-1];return n in s}function setKey(e,t,s){var n=e;t.slice(0,-1).forEach(function(e){void 0===n[e]&&(n[e]={});n=n[e]});var i=t[t.length-1];void 0===n[i]||"boolean"==typeof n[i]?n[i]=s:Array.isArray(n[i])?n[i].push(s):n[i]=[n[i],s]}function isNumber(e){return"number"==typeof e?!0:/^0x[0-9a-f]+$/i.test(e)?!0:/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function longest(e){return Math.max.apply(null,e.map(function(e){return e.length}))}module.exports=function(e,t){function s(e,t){var s=!n.strings[e]&&isNumber(t)?Number(t):t;setKey(o,e.split("."),s);(i[e]||[]).forEach(function(e){setKey(o,e.split("."),s)})}t||(t={});var n={bools:{},strings:{}};[].concat(t["boolean"]).filter(Boolean).forEach(function(e){n.bools[e]=!0});[].concat(t.string).filter(Boolean).forEach(function(e){n.strings[e]=!0});var i={};Object.keys(t.alias||{}).forEach(function(e){i[e]=[].concat(t.alias[e]);i[e].forEach(function(t){i[t]=[e].concat(i[e].filter(function(e){return t!==e}))})});var r=t["default"]||{},o={_:[]};Object.keys(n.bools).forEach(function(e){s(e,void 0===r[e]?!1:r[e])});var a=[];if(-1!==e.indexOf("--")){a=e.slice(e.indexOf("--")+1);e=e.slice(0,e.indexOf("--"))}for(var f=0;f<e.length;f++){var c=e[f];if(/^--.+=/.test(c)){var l=c.match(/^--([^=]+)=([\s\S]*)$/);s(l[1],l[2])}else if(/^--no-.+/.test(c)){var u=c.match(/^--no-(.+)/)[1];s(u,!1)}else if(/^--.+/.test(c)){var u=c.match(/^--(.+)/)[1],h=e[f+1];if(void 0===h||/^-/.test(h)||n.bools[u]||(i[u]?n.bools[i[u]]:0))if(/^(true|false)$/.test(h)){s(u,"true"===h);f++}else s(u,n.strings[u]?"":!0);else{s(u,h);f++}}else if(/^-[^-]+/.test(c)){for(var v=c.slice(1,-1).split(""),b=!1,d=0;d<v.length;d++){var h=c.slice(d+2);if("-"!==h){if(/[A-Za-z]/.test(v[d])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(h)){s(v[d],h);b=!0;break}if(v[d+1]&&v[d+1].match(/\W/)){s(v[d],c.slice(d+2));b=!0;break}s(v[d],n.strings[v[d]]?"":!0)}else s(v[d],h)}var u=c.slice(-1)[0];if(!b&&"-"!==u)if(!e[f+1]||/^(-|--)[^-]/.test(e[f+1])||n.bools[u]||(i[u]?n.bools[i[u]]:0))if(e[f+1]&&/true|false/.test(e[f+1])){s(u,"true"===e[f+1]);f++}else s(u,n.strings[u]?"":!0);else{s(u,e[f+1]);f++}}else o._.push(n.strings._||!isNumber(c)?c:Number(c))}Object.keys(r).forEach(function(e){if(!hasKey(o,e.split("."))){setKey(o,e.split("."),r[e]);(i[e]||[]).forEach(function(t){setKey(o,t.split("."),r[e])})}});a.forEach(function(e){o._.push(e)});return o};