/*---------------------------------------------------------
 * Copyright (C) Microsoft Corporation. All rights reserved.
 *--------------------------------------------------------*/
"use strict";define("vs/languages/typescript/common/js/defineRewriter",["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.define"},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._checkArguments(s.parent,t)}},e._checkArguments=function(t,r){var i,s,o=t.arguments[0]&&8===t.arguments[0].kind?1:0;if(t.arguments[o]&&156===t.arguments[o].kind&&t.arguments[o].elements.forEach(function(e){8===e.kind&&(i?i.push(e):i=[e])}),o+=1,i&&t.arguments[o]&&165===t.arguments[o].kind&&(s=t.arguments[o].parameters),i&&s&&s.length)for(var a=0;a<s.length;a++){var c=s[a];if(!e._specialModules[c.name.getText()]){var l=i[a];if(!l)break;var u=n.encodeVariableName(c);r.newDerive(l,e._importPattern,u,l.getText()),r.newInsert(c.name.getEnd(),e._typeOfPattern,u)}}},e._pattern=/\bdefine\b/g,e._specialModules={require:!0,exports:!0,module:!0},e._importPattern="import * as {0} from {1};\n",e._typeOfPattern=": typeof {0}",e}();return i});