/*---------------------------------------------------------
 * Copyright (C) Microsoft Corporation. All rights reserved.
 *--------------------------------------------------------*/
"use strict";define("vs/languages/typescript/common/js/requireRewriter",["require","exports","vs/languages/typescript/common/js/rewriting","vs/languages/typescript/common/lib/typescriptServices"],function(e,t,n,r){var i=function(){function e(){}return Object.defineProperty(e.prototype,"name",{get:function(){return"rewriter.modules.require"},enumerable:!0,configurable:!0}),e.prototype.computeEdits=function(t){var n=t.sourceFile.getFullText();for(e._pattern.lastIndex=0;e._pattern.test(n);){var i=e._pattern.lastIndex-1,s=r.getTokenAtPosition(t.sourceFile,i);s&&65===s.kind&&s.parent&&160===s.parent.kind&&e._checkCallExpression(s.parent,t)}},e._checkCallExpression=function(e,t){if(1===e.arguments.length&&8===e.arguments[0].kind){var r=e.arguments[0],i=r.getText().replace(/\.js("|')$/,function(e,t){return t}),s=n.encodeVariableName(r);t.newDerive(r,"import * as "+s+" from "+i+";\n"),t.newReplace(e.getStart(),e.getWidth(),"(<typeof "+s+">"+e.getText()+")")}},e._pattern=/\brequire\b/g,e}();return i});