function simpleMode(t){ensureState(t,"start");var n={},e=t.languageData||{},a=!1;for(var r in t)if(r!=e&&t.hasOwnProperty(r))for(var i=n[r]=[],o=t[r],u=0;u<o.length;u++){var s=o[u];i.push(new Rule(s,t)),(s.indent||s.dedent)&&(a=!0);}return {startState:function(){return {state:"start",pending:null,indent:a?[]:null}},copyState:function(t){var n={state:t.state,pending:t.pending,indent:t.indent&&t.indent.slice(0)};return t.stack&&(n.stack=t.stack.slice(0)),n},token:tokenFunction(n),indent:indentFunction(n,e),languageData:e}}function ensureState(t,n){if(!t.hasOwnProperty(n))throw new Error("Undefined state "+n+" in simple mode")}function toRegex(t,n){if(!t)return /(?:)/;var e="";return t instanceof RegExp?(t.ignoreCase&&(e="i"),t=t.source):t=String(t),new RegExp((!1===n?"":"^")+"(?:"+t+")",e)}function asToken(t){if(!t)return null;if(t.apply)return t;if("string"==typeof t)return t.replace(/\./g," ");for(var n=[],e=0;e<t.length;e++)n.push(t[e]&&t[e].replace(/\./g," "));return n}function Rule(t,n){(t.next||t.push)&&ensureState(n,t.next||t.push),this.regex=toRegex(t.regex),this.token=asToken(t.token),this.data=t;}function tokenFunction(t){return function(n,e){if(e.pending){var a=e.pending.shift();return 0==e.pending.length&&(e.pending=null),n.pos+=a.text.length,a.token}for(var r=t[e.state],i=0;i<r.length;i++){var o=r[i],u=(!o.data.sol||n.sol())&&n.match(o.regex);if(u){o.data.next?e.state=o.data.next:o.data.push?((e.stack||(e.stack=[])).push(e.state),e.state=o.data.push):o.data.pop&&e.stack&&e.stack.length&&(e.state=e.stack.pop()),o.data.indent&&e.indent.push(n.indentation()+n.indentUnit),o.data.dedent&&e.indent.pop();var s=o.token;if(s&&s.apply&&(s=s(u)),u.length>2&&o.token&&"string"!=typeof o.token){e.pending=[];for(var d=2;d<u.length;d++)u[d]&&e.pending.push({text:u[d],token:o.token[d-1]});return n.backUp(u[0].length-(u[1]?u[1].length:0)),s[0]}return s&&s.join?s[0]:s}}return n.next(),null}}function indentFunction(t,n){return function(e,a){if(null==e.indent||n.dontIndentStates&&n.doneIndentState.indexOf(e.state)>-1)return null;var r=e.indent.length-1,i=t[e.state];t:for(;;){for(var o=0;o<i.length;o++){var u=i[o];if(u.data.dedent&&!1!==u.data.dedentIfLineStart){var s=u.regex.exec(a);if(s&&s[0]){r--,(u.next||u.push)&&(i=t[u.next||u.push]),a=a.slice(s[0].length);continue t}}}break}return r<0?0:e.indent[r]}}

export { simpleMode as s };
