var words={};function define(e,t){for(var n=0;n<t.length;n++)words[t[n]]=e;}var commonAtoms=["true","false"],commonKeywords=["if","then","do","else","elif","while","until","for","in","esac","fi","fin","fil","done","exit","set","unset","export","function"],commonCommands=["ab","awk","bash","beep","cat","cc","cd","chown","chmod","chroot","clear","cp","curl","cut","diff","echo","find","gawk","gcc","get","git","grep","hg","kill","killall","ln","ls","make","mkdir","openssl","mv","nc","nl","node","npm","ping","ps","restart","rm","rmdir","sed","service","sh","shopt","shred","source","sort","sleep","ssh","start","stop","su","sudo","svn","tee","telnet","top","touch","vi","vim","wall","wc","wget","who","write","yes","zsh"];function tokenBase(e,t){if(e.eatSpace())return null;var n=e.sol(),o=e.next();if("\\"===o)return e.next(),null;if("'"===o||'"'===o||"`"===o)return t.tokens.unshift(tokenString(o,"`"===o?"quote":"string")),tokenize(e,t);if("#"===o)return n&&e.eat("!")?(e.skipToEnd(),"meta"):(e.skipToEnd(),"comment");if("$"===o)return t.tokens.unshift(tokenDollar),tokenize(e,t);if("+"===o||"="===o)return "operator";if("-"===o)return e.eat("-"),e.eatWhile(/\w/),"attribute";if("<"==o){if(e.match("<<"))return "operator";var r=e.match(/^<-?\s*['"]?([^'"]*)['"]?/);if(r)return t.tokens.unshift(tokenHeredoc(r[1])),"string.special"}if(/\d/.test(o)&&(e.eatWhile(/\d/),e.eol()||!/\w/.test(e.peek())))return "number";e.eatWhile(/[\w-]/);var i=e.current();return "="===e.peek()&&/\w+/.test(i)?"def":words.hasOwnProperty(i)?words[i]:null}function tokenString(e,t){var n="("==e?")":"{"==e?"}":e;return function(o,r){for(var i,s=!1;null!=(i=o.next());){if(i===n&&!s){r.tokens.shift();break}if("$"===i&&!s&&"'"!==e&&o.peek()!=n){s=!0,o.backUp(1),r.tokens.unshift(tokenDollar);break}if(!s&&e!==n&&i===e)return r.tokens.unshift(tokenString(e,t)),tokenize(o,r);if(!s&&/['"]/.test(i)&&!/['"]/.test(e)){r.tokens.unshift(tokenStringStart(i,"string")),o.backUp(1);break}s=!s&&"\\"===i;}return t}}function tokenStringStart(e,t){return function(n,o){return o.tokens[0]=tokenString(e,t),n.next(),tokenize(n,o)}}define("atom",commonAtoms),define("keyword",commonKeywords),define("builtin",commonCommands);var tokenDollar=function(e,t){t.tokens.length>1&&e.eat("$");var n=e.next();return /['"({]/.test(n)?(t.tokens[0]=tokenString(n,"("==n?"quote":"{"==n?"def":"string"),tokenize(e,t)):(/\d/.test(n)||e.eatWhile(/\w/),t.tokens.shift(),"def")};function tokenHeredoc(e){return function(t,n){return t.sol()&&t.string==e&&n.tokens.shift(),t.skipToEnd(),"string.special"}}function tokenize(e,t){return (t.tokens[0]||tokenBase)(e,t)}const shell={startState:function(){return {tokens:[]}},token:function(e,t){return tokenize(e,t)},languageData:{autocomplete:commonAtoms.concat(commonKeywords,commonCommands),closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"#"}}};

export { shell };
