Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

magic-string

Package Overview
Dependencies
Maintainers
1
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

magic-string - npm Package Compare versions

Comparing version
0.11.1
to
0.11.2
+4
-0
CHANGELOG.md
# changelog
## 0.11.2
* Support sourcemaps with moved content
## 0.11.1

@@ -4,0 +8,0 @@

+42
-25

@@ -48,3 +48,3 @@ 'use strict';

if ( this.edited ) {
if ( this.content.length ) throw new Error( "Cannot split a chunk that has already been edited (\"" + (this.original) + "\")" );
if ( this.content.length ) throw new Error( ("Cannot split a chunk that has already been edited (\"" + (this.original) + "\")") );

@@ -121,2 +121,21 @@ // zero-length edited chunks are a special case (overlapping replacements)

function getLocator ( source ) {
var originalLines = source.split( '\n' );
return function locate ( index ) {
var len = originalLines.length;
var lineStart = 0;
for ( var i = 0; i < len; i += 1 ) {
var line = originalLines[i];
var lineEnd = lineStart + line.length + 1; // +1 for newline
if ( lineEnd > index ) return { line: i, column: index - lineStart };
lineStart = lineEnd;
}
};
}
function encodeMappings ( original, intro, chunks, hires, sourcemapLocations, sourceIndex, offsets, names ) {

@@ -128,12 +147,13 @@ var rawLines = [];

var originalCharIndex = 0;
var generatedCodeColumn = 0;
var sourceCodeLine = 0;
var sourceCodeColumn = 0;
function addSegmentsUntil ( end ) {
var locate = getLocator( original );
function addUneditedChunk ( chunk ) {
var originalCharIndex = chunk.start;
var first = true;
while ( originalCharIndex < end ) {
var ref = locate( originalCharIndex ), line = ref.line, column = ref.column;
while ( originalCharIndex < chunk.end ) {
if ( hires || first || sourcemapLocations[ originalCharIndex ] ) {

@@ -143,4 +163,4 @@ rawSegments.push({

generatedCodeColumn: generatedCodeColumn,
sourceCodeLine: sourceCodeLine,
sourceCodeColumn: sourceCodeColumn,
sourceCodeLine: line,
sourceCodeColumn: column,
sourceCodeName: -1,

@@ -152,4 +172,4 @@ sourceIndex: sourceIndex

if ( original[ originalCharIndex ] === '\n' ) {
sourceCodeLine += 1;
sourceCodeColumn = 0;
line += 1;
column = 0;
generatedCodeLine += 1;

@@ -159,3 +179,3 @@ rawLines[ generatedCodeLine ] = rawSegments = [];

} else {
sourceCodeColumn += 1;
column += 1;
generatedCodeColumn += 1;

@@ -171,2 +191,3 @@ }

var chunk = chunks[i];
var ref = locate( chunk.start ), line = ref.line, column = ref.column;

@@ -178,4 +199,4 @@ if ( chunk.edited ) {

generatedCodeColumn: generatedCodeColumn,
sourceCodeLine: sourceCodeLine,
sourceCodeColumn: sourceCodeColumn,
sourceCodeLine: line,
sourceCodeColumn: column,
sourceCodeName: chunk.storeName ? names.indexOf( chunk.original ) : -1,

@@ -201,16 +222,12 @@ sourceIndex: sourceIndex

if ( lines.length ) {
sourceCodeLine += lines.length;
sourceCodeColumn = lastLine.length;
line += lines.length;
column = lastLine.length;
} else {
sourceCodeColumn += lastLine.length;
column += lastLine.length;
}
} else {
addSegmentsUntil( chunk.end );
addUneditedChunk( chunk );
}
originalCharIndex = chunk.end;
}
addSegmentsUntil( original.length );
offsets.sourceIndex = offsets.sourceIndex || 0;

@@ -383,3 +400,3 @@ offsets.sourceCodeLine = offsets.sourceCodeLine || 0;

var replacer = function ( match ) {
if ( shouldIndentNextCharacter ) return "" + indentStr + "" + match + "";
if ( shouldIndentNextCharacter ) return ("" + indentStr + "" + match);
shouldIndentNextCharacter = true;

@@ -578,3 +595,3 @@ return match;

if ( chunk.start < start || chunk.end > end ) {
if ( chunk.edited ) throw new Error( "Cannot use replaced characters (" + start + ", " + end + ") as slice anchors" );
if ( chunk.edited ) throw new Error( ("Cannot use replaced characters (" + start + ", " + end + ") as slice anchors") );

@@ -716,3 +733,3 @@ var sliceStart = Math.max( start - chunk.start, 0 );

if ( source.content.original !== uniqueSource.content ) {
throw new Error( "Illegal source: same filename (" + (source.filename) + "), different contents" );
throw new Error( ("Illegal source: same filename (" + (source.filename) + "), different contents") );
}

@@ -719,0 +736,0 @@ }

@@ -1,1 +0,1 @@

{"version":3,"file":"magic-string.cjs.js","sources":["../src/Chunk.js","../src/utils/btoa.js","../src/utils/SourceMap.js","../src/utils/guessIndent.js","../src/utils/encodeMappings.js","../src/utils/getRelativePath.js","../src/utils/isObject.js","../src/utils/findIndex.js","../src/MagicString.js","../src/utils/hasOwnProp.js","../src/Bundle.js","../src/index.js"],"sourcesContent":["export default function Chunk ( start, end, content ) {\n\tthis.start = start;\n\tthis.end = end;\n\tthis.original = content;\n\n\tthis.content = content;\n\tthis.storeName = false;\n\tthis.edited = false;\n}\n\nChunk.prototype = {\n\tclone () {\n\t\tconst chunk = new Chunk( this.start, this.end, this.original );\n\t\tchunk.content = this.content;\n\t\tchunk.storeName = this.storeName;\n\t\tchunk.edited = this.edited;\n\n\t\treturn chunk;\n\t},\n\n\tedit ( content, storeName ) {\n\t\tthis.content = content;\n\t\tthis.storeName = storeName;\n\n\t\tthis.edited = true;\n\n\t\treturn this;\n\t},\n\n\tsplit ( index ) {\n\t\tif ( index === this.start ) return this;\n\n\t\tconst sliceIndex = index - this.start;\n\n\t\tconst originalBefore = this.original.slice( 0, sliceIndex );\n\t\tconst originalAfter = this.original.slice( sliceIndex );\n\n\t\tthis.original = originalBefore;\n\n\t\tconst newChunk = new Chunk( index, this.end, originalAfter );\n\t\tthis.end = index;\n\n\t\tif ( this.edited ) {\n\t\t\tif ( this.content.length ) throw new Error( `Cannot split a chunk that has already been edited (\"${this.original}\")` );\n\n\t\t\t// zero-length edited chunks are a special case (overlapping replacements)\n\t\t\tnewChunk.edit( '', false );\n\t\t\tthis.content = '';\n\t\t} else {\n\t\t\tthis.content = originalBefore;\n\t\t}\n\n\t\treturn newChunk;\n\t}\n};\n","let _btoa;\n\nif ( typeof window !== 'undefined' && typeof window.btoa === 'function' ) {\n\t_btoa = window.btoa;\n} else if ( typeof Buffer === 'function' ) {\n\t/* global Buffer */\n\t_btoa = str => new Buffer( str ).toString( 'base64' );\n} else {\n\tthrow new Error( 'Unsupported environment: `window.btoa` or `Buffer` should be supported.' );\n}\n\nexport default _btoa;\n","import btoa from './btoa.js';\n\nexport default function SourceMap ( properties ) {\n\tthis.version = 3;\n\n\tthis.file = properties.file;\n\tthis.sources = properties.sources;\n\tthis.sourcesContent = properties.sourcesContent;\n\tthis.names = properties.names;\n\tthis.mappings = properties.mappings;\n}\n\nSourceMap.prototype = {\n\ttoString () {\n\t\treturn JSON.stringify( this );\n\t},\n\n\ttoUrl () {\n\t\treturn 'data:application/json;charset=utf-8;base64,' + btoa( this.toString() );\n\t}\n};\n","export default function guessIndent ( code ) {\n\tconst lines = code.split( '\\n' );\n\n\tconst tabbed = lines.filter( line => /^\\t+/.test( line ) );\n\tconst spaced = lines.filter( line => /^ {2,}/.test( line ) );\n\n\tif ( tabbed.length === 0 && spaced.length === 0 ) {\n\t\treturn null;\n\t}\n\n\t// More lines tabbed than spaced? Assume tabs, and\n\t// default to tabs in the case of a tie (or nothing\n\t// to go on)\n\tif ( tabbed.length >= spaced.length ) {\n\t\treturn '\\t';\n\t}\n\n\t// Otherwise, we need to guess the multiple\n\tconst min = spaced.reduce( ( previous, current ) => {\n\t\tconst numSpaces = /^ +/.exec( current )[0].length;\n\t\treturn Math.min( numSpaces, previous );\n\t}, Infinity );\n\n\treturn new Array( min + 1 ).join( ' ' );\n}\n","import { encode } from 'vlq';\n\nexport default function encodeMappings ( original, intro, chunks, hires, sourcemapLocations, sourceIndex, offsets, names ) {\n\tlet rawLines = [];\n\n\tlet generatedCodeLine = intro.split( '\\n' ).length - 1;\n\tlet rawSegments = rawLines[ generatedCodeLine ] = [];\n\n\tlet originalCharIndex = 0;\n\n\tlet generatedCodeColumn = 0;\n\tlet sourceCodeLine = 0;\n\tlet sourceCodeColumn = 0;\n\n\tfunction addSegmentsUntil ( end ) {\n\t\tlet first = true;\n\n\t\twhile ( originalCharIndex < end ) {\n\t\t\tif ( hires || first || sourcemapLocations[ originalCharIndex ] ) {\n\t\t\t\trawSegments.push({\n\t\t\t\t\tgeneratedCodeLine,\n\t\t\t\t\tgeneratedCodeColumn,\n\t\t\t\t\tsourceCodeLine,\n\t\t\t\t\tsourceCodeColumn,\n\t\t\t\t\tsourceCodeName: -1,\n\t\t\t\t\tsourceIndex\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif ( original[ originalCharIndex ] === '\\n' ) {\n\t\t\t\tsourceCodeLine += 1;\n\t\t\t\tsourceCodeColumn = 0;\n\t\t\t\tgeneratedCodeLine += 1;\n\t\t\t\trawLines[ generatedCodeLine ] = rawSegments = [];\n\t\t\t\tgeneratedCodeColumn = 0;\n\t\t\t} else {\n\t\t\t\tsourceCodeColumn += 1;\n\t\t\t\tgeneratedCodeColumn += 1;\n\t\t\t}\n\n\t\t\toriginalCharIndex += 1;\n\t\t\tfirst = false;\n\t\t}\n\t}\n\n\tfor ( let i = 0; i < chunks.length; i += 1 ) {\n\t\tconst chunk = chunks[i];\n\n\t\tif ( chunk.edited ) {\n\t\t\tif ( i > 0 || chunk.content.length ) {\n\t\t\t\trawSegments.push({\n\t\t\t\t\tgeneratedCodeLine,\n\t\t\t\t\tgeneratedCodeColumn,\n\t\t\t\t\tsourceCodeLine,\n\t\t\t\t\tsourceCodeColumn,\n\t\t\t\t\tsourceCodeName: chunk.storeName ? names.indexOf( chunk.original ) : -1,\n\t\t\t\t\tsourceIndex\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tlet lines = chunk.content.split( '\\n' );\n\t\t\tlet lastLine = lines.pop();\n\n\t\t\tif ( lines.length ) {\n\t\t\t\tgeneratedCodeLine += lines.length;\n\t\t\t\trawLines[ generatedCodeLine ] = rawSegments = [];\n\t\t\t\tgeneratedCodeColumn = lastLine.length;\n\t\t\t} else {\n\t\t\t\tgeneratedCodeColumn += lastLine.length;\n\t\t\t}\n\n\t\t\tlines = chunk.original.split( '\\n' );\n\t\t\tlastLine = lines.pop();\n\n\t\t\tif ( lines.length ) {\n\t\t\t\tsourceCodeLine += lines.length;\n\t\t\t\tsourceCodeColumn = lastLine.length;\n\t\t\t} else {\n\t\t\t\tsourceCodeColumn += lastLine.length;\n\t\t\t}\n\t\t} else {\n\t\t\taddSegmentsUntil( chunk.end );\n\t\t}\n\n\t\toriginalCharIndex = chunk.end;\n\t}\n\n\taddSegmentsUntil( original.length );\n\n\toffsets.sourceIndex = offsets.sourceIndex || 0;\n\toffsets.sourceCodeLine = offsets.sourceCodeLine || 0;\n\toffsets.sourceCodeColumn = offsets.sourceCodeColumn || 0;\n\toffsets.sourceCodeName = offsets.sourceCodeName || 0;\n\n\tconst encoded = rawLines.map( segments => {\n\t\tlet generatedCodeColumn = 0;\n\n\t\treturn segments.map( segment => {\n\t\t\tlet arr = [\n\t\t\t\tsegment.generatedCodeColumn - generatedCodeColumn,\n\t\t\t\tsegment.sourceIndex - offsets.sourceIndex,\n\t\t\t\tsegment.sourceCodeLine - offsets.sourceCodeLine,\n\t\t\t\tsegment.sourceCodeColumn - offsets.sourceCodeColumn\n\t\t\t];\n\n\t\t\tgeneratedCodeColumn = segment.generatedCodeColumn;\n\t\t\toffsets.sourceIndex = segment.sourceIndex;\n\t\t\toffsets.sourceCodeLine = segment.sourceCodeLine;\n\t\t\toffsets.sourceCodeColumn = segment.sourceCodeColumn;\n\n\t\t\tif ( ~segment.sourceCodeName ) {\n\t\t\t\tarr.push( segment.sourceCodeName - offsets.sourceCodeName );\n\t\t\t\toffsets.sourceCodeName = segment.sourceCodeName;\n\t\t\t}\n\n\t\t\treturn encode( arr );\n\t\t}).join( ',' );\n\t}).join( ';' );\n\n\treturn encoded;\n}\n","export default function getRelativePath ( from, to ) {\n\tlet fromParts = from.split( /[\\/\\\\]/ );\n\tlet toParts = to.split( /[\\/\\\\]/ );\n\n\tfromParts.pop(); // get dirname\n\n\twhile ( fromParts[0] === toParts[0] ) {\n\t\tfromParts.shift();\n\t\ttoParts.shift();\n\t}\n\n\tif ( fromParts.length ) {\n\t\tlet i = fromParts.length;\n\t\twhile ( i-- ) fromParts[i] = '..';\n\t}\n\n\treturn fromParts.concat( toParts ).join( '/' );\n}\n","const toString = Object.prototype.toString;\n\nexport default function isObject ( thing ) {\n\treturn toString.call( thing ) === '[object Object]';\n}\n","export default function findIndex ( array, fn ) {\n\tfor ( let i = 0; i < array.length; i += 1 ) {\n\t\tif ( fn( array[i], i ) ) return i;\n\t}\n\n\treturn -1;\n}\n","import Chunk from './Chunk.js';\nimport SourceMap from './utils/SourceMap.js';\nimport guessIndent from './utils/guessIndent.js';\nimport encodeMappings from './utils/encodeMappings.js';\nimport getRelativePath from './utils/getRelativePath.js';\nimport isObject from './utils/isObject.js';\nimport findIndex from './utils/findIndex.js';\n\nlet warned = false;\n\nexport default function MagicString ( string, options = {} ) {\n\tconst chunk = new Chunk( 0, string.length, string );\n\n\tObject.defineProperties( this, {\n\t\toriginal: { writable: true, value: string },\n\t\toutro: { writable: true, value: '' },\n\t\tintro: { writable: true, value: '' },\n\t\tchunks: { writable: true, value: [ chunk ] },\n\t\tmoves: { writable: true, value: [] },\n\t\tfilename: { writable: true, value: options.filename },\n\t\tindentExclusionRanges: { writable: true, value: options.indentExclusionRanges },\n\t\tsourcemapLocations: { writable: true, value: {} },\n\t\tstoredNames: { writable: true, value: {} },\n\t\tindentStr: { writable: true, value: guessIndent( string ) }\n\t});\n}\n\nMagicString.prototype = {\n\taddSourcemapLocation ( char ) {\n\t\tthis.sourcemapLocations[ char ] = true;\n\t},\n\n\tappend ( content ) {\n\t\tif ( typeof content !== 'string' ) throw new TypeError( 'outro content must be a string' );\n\n\t\tthis.outro += content;\n\t\treturn this;\n\t},\n\n\tclone () {\n\t\tlet cloned = new MagicString( this.original, { filename: this.filename });\n\n\t\tcloned.chunks = this.chunks.map( chunk => chunk.clone() );\n\n\t\tif ( this.indentExclusionRanges ) {\n\t\t\tcloned.indentExclusionRanges = typeof this.indentExclusionRanges[0] === 'number' ?\n\t\t\t\t[ this.indentExclusionRanges[0], this.indentExclusionRanges[1] ] :\n\t\t\t\tthis.indentExclusionRanges.map( range => [ range.start, range.end ] );\n\t\t}\n\n\t\tObject.keys( this.sourcemapLocations ).forEach( loc => {\n\t\t\tcloned.sourcemapLocations[ loc ] = true;\n\t\t});\n\n\t\treturn cloned;\n\t},\n\n\tgenerateMap ( options ) {\n\t\toptions = options || {};\n\n\t\tconst names = Object.keys( this.storedNames );\n\n\t\treturn new SourceMap({\n\t\t\tfile: ( options.file ? options.file.split( /[\\/\\\\]/ ).pop() : null ),\n\t\t\tsources: [ options.source ? getRelativePath( options.file || '', options.source ) : null ],\n\t\t\tsourcesContent: options.includeContent ? [ this.original ] : [ null ],\n\t\t\tnames,\n\t\t\tmappings: this.getMappings( options.hires, 0, {}, names )\n\t\t});\n\t},\n\n\tgetIndentString () {\n\t\treturn this.indentStr === null ? '\\t' : this.indentStr;\n\t},\n\n\tgetMappings ( hires, sourceIndex, offsets, names ) {\n\t\treturn encodeMappings( this.original, this.intro, this.chunks, hires, this.sourcemapLocations, sourceIndex, offsets, names );\n\t},\n\n\tindent ( indentStr, options ) {\n\t\tconst pattern = /^[^\\r\\n]/gm;\n\n\t\tif ( isObject( indentStr ) ) {\n\t\t\toptions = indentStr;\n\t\t\tindentStr = undefined;\n\t\t}\n\n\t\tindentStr = indentStr !== undefined ? indentStr : ( this.indentStr || '\\t' );\n\n\t\tif ( indentStr === '' ) return this; // noop\n\n\t\toptions = options || {};\n\n\t\t// Process exclusion ranges\n\t\tlet isExcluded = {};\n\n\t\tif ( options.exclude ) {\n\t\t\tlet exclusions = typeof options.exclude[0] === 'number' ? [ options.exclude ] : options.exclude;\n\t\t\texclusions.forEach( exclusion => {\n\t\t\t\tfor ( let i = exclusion[0]; i < exclusion[1]; i += 1 ) {\n\t\t\t\t\tisExcluded[i] = true;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tlet shouldIndentNextCharacter = options.indentStart !== false;\n\t\tconst replacer = match => {\n\t\t\tif ( shouldIndentNextCharacter ) return `${indentStr}${match}`;\n\t\t\tshouldIndentNextCharacter = true;\n\t\t\treturn match;\n\t\t};\n\n\t\tthis.intro = this.intro.replace( pattern, replacer );\n\n\t\tlet chunkIndex;\n\t\tlet charIndex = 0;\n\n\t\tfor ( chunkIndex = 0; chunkIndex < this.chunks.length; chunkIndex += 1 ) { // can't cache this.chunks.length, it may change\n\t\t\tlet chunk = this.chunks[ chunkIndex ];\n\t\t\tconst end = chunk.end;\n\n\t\t\tif ( chunk.edited ) {\n\t\t\t\tif ( !isExcluded[ charIndex ] ) {\n\t\t\t\t\tchunk.content = chunk.content.replace( pattern, replacer );\n\n\t\t\t\t\tif ( chunk.content.length ) {\n\t\t\t\t\t\tshouldIndentNextCharacter = chunk.content[ chunk.content.length - 1 ] === '\\n';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcharIndex = chunk.start;\n\n\t\t\t\twhile ( charIndex < end ) {\n\t\t\t\t\tif ( !isExcluded[ charIndex ] ) {\n\t\t\t\t\t\tconst char = this.original[ charIndex ];\n\n\t\t\t\t\t\tif ( char === '\\n' ) {\n\t\t\t\t\t\t\tshouldIndentNextCharacter = true;\n\t\t\t\t\t\t} else if ( char !== '\\r' && shouldIndentNextCharacter ) {\n\t\t\t\t\t\t\tshouldIndentNextCharacter = false;\n\n\t\t\t\t\t\t\tconst indentation = new Chunk( charIndex, charIndex, '' ).edit( indentStr, false );\n\t\t\t\t\t\t\tconst remainder = chunk.split( charIndex );\n\n\t\t\t\t\t\t\tif ( charIndex === chunk.start ) {\n\t\t\t\t\t\t\t\tthis.chunks.splice( chunkIndex, 0, indentation );\n\t\t\t\t\t\t\t\tchunkIndex += 1;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthis.chunks.splice( chunkIndex + 1, 0, indentation, remainder );\n\t\t\t\t\t\t\t\tchunkIndex += 2;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tchunk = remainder;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tcharIndex += 1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcharIndex = chunk.end;\n\t\t}\n\n\t\tthis.outro = this.outro.replace( pattern, replacer );\n\n\t\treturn this;\n\t},\n\n\tinsert ( index, content ) {\n\t\tif ( typeof content !== 'string' ) throw new TypeError( 'inserted content must be a string' );\n\n\t\tthis._split( index );\n\n\t\tlet next = findIndex( this.chunks, chunk => chunk.original.length && chunk.start === index );\n\t\tif ( !~next ) next = this.chunks.length;\n\n\t\tconst newChunk = new Chunk( index, index, '' ).edit( content, false );\n\n\t\tthis.chunks.splice( next, 0, newChunk );\n\t\treturn this;\n\t},\n\n\t// get current location of character in original string\n\tlocate () {\n\t\tthrow new Error( 'magicString.locate is deprecated' );\n\t},\n\n\tlocateOrigin () {\n\t\tthrow new Error( 'magicString.locateOrigin is deprecated' );\n\t},\n\n\tmove ( start, end, index ) {\n\t\tif ( index >= start && index <= end ) throw new Error( 'Cannot move a selection inside itself' );\n\n\t\tthis._split( start );\n\t\tthis._split( end );\n\t\tthis._split( index );\n\n\t\tconst firstIndex = findIndex( this.chunks, chunk => chunk.start === start );\n\t\tlet lastIndex = findIndex( this.chunks, chunk => chunk.end === end );\n\n\t\tconst toMove = this.chunks.splice( firstIndex, lastIndex + 1 - firstIndex );\n\n\t\tlet insertionIndex = findIndex( this.chunks, chunk => chunk.original.length && chunk.start === index );\n\t\tif ( !~insertionIndex ) insertionIndex = this.chunks.length;\n\n\t\tthis.chunks.splice.apply( this.chunks, [ insertionIndex, 0 ].concat( toMove ) );\n\n\t\treturn this;\n\t},\n\n\toverwrite ( start, end, content, storeName ) {\n\t\tif ( typeof content !== 'string' ) {\n\t\t\tthrow new TypeError( 'replacement content must be a string' );\n\t\t}\n\n\t\tthis._split( start );\n\t\tthis._split( end );\n\n\t\tif ( storeName ) {\n\t\t\tconst original = this.original.slice( start, end );\n\t\t\tthis.storedNames[ original ] = true;\n\t\t}\n\n\t\tlet firstIndex = findIndex( this.chunks, chunk => chunk.start === start && chunk.original.length );\n\t\tif ( !~firstIndex ) firstIndex = this.chunks.length;\n\t\tlet lastIndex = findIndex( this.chunks, chunk => chunk.end === end );\n\n\t\tconst newChunk = new Chunk( start, end, this.original.slice( start, end ) ).edit( content, storeName );\n\n\t\tthis.chunks.splice( firstIndex, lastIndex + 1 - firstIndex, newChunk );\n\t\treturn this;\n\t},\n\n\tprepend ( content ) {\n\t\tif ( typeof content !== 'string' ) throw new TypeError( 'outro content must be a string' );\n\n\t\tthis.intro = content + this.intro;\n\t\treturn this;\n\t},\n\n\tremove ( start, end ) {\n\t\twhile ( start < 0 ) start += this.original.length;\n\t\twhile ( end < 0 ) end += this.original.length;\n\n\t\tif ( start === end ) return this;\n\n\t\tif ( start < 0 || end > this.original.length ) throw new Error( 'Character is out of bounds' );\n\t\tif ( start > end ) throw new Error( 'end must be greater than start' );\n\n\t\tlet firstIndex = findIndex( this.chunks, chunk => chunk.start <= start && chunk.end > start );\n\t\tlet chunk = this.chunks[ firstIndex ];\n\n\t\t// if the chunk contains `start`, split\n\t\tif ( chunk.start < start ) {\n\t\t\tif ( chunk.edited && chunk.content.length ) throw new Error( 'nope' );\n\t\t\tthis._split( start );\n\t\t\tfirstIndex += 1;\n\t\t}\n\n\t\tlet lastIndex = findIndex( this.chunks, chunk => chunk.start < end && chunk.end >= end );\n\t\tchunk = this.chunks[ lastIndex ];\n\n\t\t// if the chunk contains `end`, split\n\t\tif ( chunk.start < end ) {\n\t\t\tif ( chunk.edited && chunk.content.length ) throw new Error( 'nope' );\n\t\t\tthis._split( end );\n\t\t}\n\n\t\tlastIndex += 1;\n\n\t\tconst newChunk = new Chunk( start, end, this.original.slice( start, end ) ).edit( '', false );\n\t\tthis.chunks.splice( firstIndex, lastIndex - firstIndex, newChunk );\n\n\t\treturn this;\n\t},\n\n\treplace ( start, end, content ) {\n\t\tif ( !warned ) {\n\t\t\tconsole.warn( 'magicString.replace(...) is deprecated. Use magicString.overwrite(...) instead' );\n\t\t\twarned = true;\n\t\t}\n\n\t\treturn this.overwrite( start, end, content );\n\t},\n\n\tslice ( start, end = this.original.length ) {\n\t\twhile ( start < 0 ) start += this.original.length;\n\t\twhile ( end < 0 ) end += this.original.length;\n\n\t\tlet result = '';\n\n\t\tfor ( let i = 0; i < this.chunks.length; i += 1 ) {\n\t\t\tconst chunk = this.chunks[i];\n\n\t\t\tif ( chunk.end <= start ) continue;\n\t\t\tif ( chunk.start >= end ) break;\n\n\t\t\tif ( chunk.start < start || chunk.end > end ) {\n\t\t\t\tif ( chunk.edited ) throw new Error( `Cannot use replaced characters (${start}, ${end}) as slice anchors` );\n\n\t\t\t\tconst sliceStart = Math.max( start - chunk.start, 0 );\n\t\t\t\tconst sliceEnd = Math.min( chunk.content.length - ( chunk.end - end ), chunk.content.length );\n\n\t\t\t\tresult += chunk.content.slice( sliceStart, sliceEnd );\n\t\t\t} else {\n\t\t\t\tresult += chunk.content;\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t},\n\n\tsnip ( start, end ) {\n\t\tconst clone = this.clone();\n\t\tclone.remove( 0, start );\n\t\tclone.remove( end, clone.original.length );\n\n\t\treturn clone;\n\t},\n\n\t_split ( index ) {\n\t\t// TODO bisect\n\t\tfor ( let i = 0; i < this.chunks.length; i += 1 ) {\n\t\t\tconst chunk = this.chunks[i];\n\t\t\tif ( chunk.start === index || chunk.end === index ) return;\n\n\t\t\tif ( chunk.start < index && chunk.end > index ) {\n\t\t\t\tconst newChunk = chunk.split( index );\n\t\t\t\tthis.chunks.splice( i + 1, 0, newChunk );\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t},\n\n\ttoString () {\n\t\treturn this.intro + this.chunks.map( chunk => chunk.content ).join( '' ) + this.outro;\n\t},\n\n\ttrimLines () {\n\t\treturn this.trim('[\\\\r\\\\n]');\n\t},\n\n\t// TODO rewrite these methods, post-refactor\n\ttrim ( charType ) {\n\t\treturn this.trimStart( charType ).trimEnd( charType );\n\t},\n\n\ttrimEnd ( charType ) {\n\t\tconst rx = new RegExp( ( charType || '\\\\s' ) + '+$' );\n\n\t\tthis.outro = this.outro.replace( rx, '' );\n\t\tif ( this.outro.length ) return this;\n\n\t\tdo {\n\t\t\tlet lastChunk = this.chunks[ this.chunks.length - 1 ];\n\t\t\tif ( rx.test( lastChunk.content ) ) {\n\t\t\t\tlastChunk.edit( lastChunk.content.replace( rx, '' ) );\n\t\t\t}\n\n\t\t\tif ( lastChunk.content.length || this.chunks.length === 1 ) {\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tthis.chunks.pop();\n\t\t\t}\n\t\t} while ( true );\n\n\t\treturn this;\n\t},\n\n\ttrimStart ( charType ) {\n\t\tconst rx = new RegExp( '^' + ( charType || '\\\\s' ) + '+' );\n\n\t\tthis.intro = this.intro.replace( rx, '' );\n\t\tif ( this.intro.length ) return this;\n\n\t\tdo {\n\t\t\tlet firstChunk = this.chunks[0];\n\t\t\tif ( rx.test( firstChunk.content ) ) {\n\t\t\t\tfirstChunk.edit( firstChunk.content.replace( rx, '' ) );\n\t\t\t}\n\n\t\t\tif ( firstChunk.content.length || this.chunks.length === 1 ) {\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tthis.chunks.shift();\n\t\t\t}\n\t\t} while ( true );\n\n\t\treturn this;\n\t}\n};\n","export default Object.prototype.hasOwnProperty;","import MagicString from './MagicString.js';\nimport SourceMap from './utils/SourceMap.js';\nimport getRelativePath from './utils/getRelativePath.js';\nimport hasOwnProp from './utils/hasOwnProp.js';\nimport isObject from './utils/isObject.js';\n\nexport default function Bundle ( options = {} ) {\n\tthis.intro = options.intro || '';\n\tthis.separator = options.separator !== undefined ? options.separator : '\\n';\n\n\tthis.sources = [];\n\n\tthis.uniqueSources = [];\n\tthis.uniqueSourceIndexByFilename = {};\n}\n\nBundle.prototype = {\n\taddSource ( source ) {\n\t\tif ( source instanceof MagicString ) {\n\t\t\treturn this.addSource({\n\t\t\t\tcontent: source,\n\t\t\t\tfilename: source.filename,\n\t\t\t\tseparator: this.separator\n\t\t\t});\n\t\t}\n\n\t\tif ( !isObject( source ) || !source.content ) {\n\t\t\tthrow new Error( 'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`' );\n\t\t}\n\n\t\t[ 'filename', 'indentExclusionRanges', 'separator' ].forEach( option => {\n\t\t\tif ( !hasOwnProp.call( source, option ) ) source[ option ] = source.content[ option ];\n\t\t});\n\n\t\tif ( source.separator === undefined ) { // TODO there's a bunch of this sort of thing, needs cleaning up\n\t\t\tsource.separator = this.separator;\n\t\t}\n\n\t\tif ( source.filename ) {\n\t\t\tif ( !hasOwnProp.call( this.uniqueSourceIndexByFilename, source.filename ) ) {\n\t\t\t\tthis.uniqueSourceIndexByFilename[ source.filename ] = this.uniqueSources.length;\n\t\t\t\tthis.uniqueSources.push({ filename: source.filename, content: source.content.original });\n\t\t\t} else {\n\t\t\t\tconst uniqueSource = this.uniqueSources[ this.uniqueSourceIndexByFilename[ source.filename ] ];\n\t\t\t\tif ( source.content.original !== uniqueSource.content ) {\n\t\t\t\t\tthrow new Error( `Illegal source: same filename (${source.filename}), different contents` );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.sources.push( source );\n\t\treturn this;\n\t},\n\n\tappend ( str, options ) {\n\t\tthis.addSource({\n\t\t\tcontent: new MagicString( str ),\n\t\t\tseparator: ( options && options.separator ) || ''\n\t\t});\n\n\t\treturn this;\n\t},\n\n\tclone () {\n\t\tconst bundle = new Bundle({\n\t\t\tintro: this.intro,\n\t\t\tseparator: this.separator\n\t\t});\n\n\t\tthis.sources.forEach( source => {\n\t\t\tbundle.addSource({\n\t\t\t\tfilename: source.filename,\n\t\t\t\tcontent: source.content.clone(),\n\t\t\t\tseparator: source.separator\n\t\t\t});\n\t\t});\n\n\t\treturn bundle;\n\t},\n\n\tgenerateMap ( options ) {\n\t\tlet offsets = {};\n\n\t\tlet names = [];\n\t\tthis.sources.forEach( source => {\n\t\t\tObject.keys( source.content.storedNames ).forEach( name => {\n\t\t\t\tif ( !~names.indexOf( name ) ) names.push( name );\n\t\t\t});\n\t\t});\n\n\t\tconst encoded = (\n\t\t\tgetSemis( this.intro ) +\n\t\t\tthis.sources.map( ( source, i ) => {\n\t\t\t\tconst prefix = ( i > 0 ) ? ( getSemis( source.separator ) || ',' ) : '';\n\t\t\t\tlet mappings;\n\n\t\t\t\t// we don't bother encoding sources without a filename\n\t\t\t\tif ( !source.filename ) {\n\t\t\t\t\tmappings = getSemis( source.content.toString() );\n\t\t\t\t} else {\n\t\t\t\t\tconst sourceIndex = this.uniqueSourceIndexByFilename[ source.filename ];\n\t\t\t\t\tmappings = source.content.getMappings( options.hires, sourceIndex, offsets, names );\n\t\t\t\t}\n\n\t\t\t\treturn prefix + mappings;\n\t\t\t}).join( '' )\n\t\t);\n\n\t\treturn new SourceMap({\n\t\t\tfile: ( options.file ? options.file.split( /[\\/\\\\]/ ).pop() : null ),\n\t\t\tsources: this.uniqueSources.map( source => {\n\t\t\t\treturn options.file ? getRelativePath( options.file, source.filename ) : source.filename;\n\t\t\t}),\n\t\t\tsourcesContent: this.uniqueSources.map( source => {\n\t\t\t\treturn options.includeContent ? source.content : null;\n\t\t\t}),\n\t\t\tnames,\n\t\t\tmappings: encoded\n\t\t});\n\t},\n\n\tgetIndentString () {\n\t\tlet indentStringCounts = {};\n\n\t\tthis.sources.forEach( source => {\n\t\t\tconst indentStr = source.content.indentStr;\n\n\t\t\tif ( indentStr === null ) return;\n\n\t\t\tif ( !indentStringCounts[ indentStr ] ) indentStringCounts[ indentStr ] = 0;\n\t\t\tindentStringCounts[ indentStr ] += 1;\n\t\t});\n\n\t\treturn ( Object.keys( indentStringCounts ).sort( ( a, b ) => {\n\t\t\treturn indentStringCounts[a] - indentStringCounts[b];\n\t\t})[0] ) || '\\t';\n\t},\n\n\tindent ( indentStr ) {\n\t\tif ( !arguments.length ) {\n\t\t\tindentStr = this.getIndentString();\n\t\t}\n\n\t\tif ( indentStr === '' ) return this; // noop\n\n\t\tlet trailingNewline = !this.intro || this.intro.slice( -1 ) === '\\n';\n\n\t\tthis.sources.forEach( ( source, i ) => {\n\t\t\tconst separator = source.separator !== undefined ? source.separator : this.separator;\n\t\t\tconst indentStart = trailingNewline || ( i > 0 && /\\r?\\n$/.test( separator ) );\n\n\t\t\tsource.content.indent( indentStr, {\n\t\t\t\texclude: source.indentExclusionRanges,\n\t\t\t\tindentStart//: trailingNewline || /\\r?\\n$/.test( separator ) //true///\\r?\\n/.test( separator )\n\t\t\t});\n\n\t\t\t// TODO this is a very slow way to determine this\n\t\t\ttrailingNewline = source.content.toString().slice( 0, -1 ) === '\\n';\n\t\t});\n\n\t\tif ( this.intro ) {\n\t\t\tthis.intro = indentStr + this.intro.replace( /^[^\\n]/gm, ( match, index ) => {\n\t\t\t\treturn index > 0 ? indentStr + match : match;\n\t\t\t});\n\t\t}\n\n\t\treturn this;\n\t},\n\n\tprepend ( str ) {\n\t\tthis.intro = str + this.intro;\n\t\treturn this;\n\t},\n\n\ttoString () {\n\t\tconst body = this.sources.map( ( source, i ) => {\n\t\t\tconst separator = source.separator !== undefined ? source.separator : this.separator;\n\t\t\tlet str = ( i > 0 ? separator : '' ) + source.content.toString();\n\n\t\t\treturn str;\n\t\t}).join( '' );\n\n\t\treturn this.intro + body;\n\t},\n\n\ttrimLines () {\n\t\treturn this.trim('[\\\\r\\\\n]');\n\t},\n\n\ttrim ( charType ) {\n\t\treturn this.trimStart( charType ).trimEnd( charType );\n\t},\n\n\ttrimStart ( charType ) {\n\t\tconst rx = new RegExp( '^' + ( charType || '\\\\s' ) + '+' );\n\t\tthis.intro = this.intro.replace( rx, '' );\n\n\t\tif ( !this.intro ) {\n\t\t\tlet source;\n\t\t\tlet i = 0;\n\n\t\t\tdo {\n\t\t\t\tsource = this.sources[i];\n\n\t\t\t\tif ( !source ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tsource.content.trimStart( charType );\n\t\t\t\ti += 1;\n\t\t\t} while ( source.content.toString() === '' ); // TODO faster way to determine non-empty source?\n\t\t}\n\n\t\treturn this;\n\t},\n\n\ttrimEnd ( charType ) {\n\t\tconst rx = new RegExp( ( charType || '\\\\s' ) + '+$' );\n\n\t\tlet source;\n\t\tlet i = this.sources.length - 1;\n\n\t\tdo {\n\t\t\tsource = this.sources[i];\n\n\t\t\tif ( !source ) {\n\t\t\t\tthis.intro = this.intro.replace( rx, '' );\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tsource.content.trimEnd( charType );\n\t\t\ti -= 1;\n\t\t} while ( source.content.toString() === '' ); // TODO faster way to determine non-empty source?\n\n\t\treturn this;\n\t}\n};\n\nfunction getSemis ( str ) {\n\treturn new Array( str.split( '\\n' ).length ).join( ';' );\n}\n","import MagicString from './MagicString.js';\nimport Bundle from './Bundle.js';\n\nMagicString.Bundle = Bundle;\n\nexport default MagicString;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;MAWM;EACJ;;;;;;;;KAQG;;;;;;;;;MASC;;;EAGJ;;EAEA;EACA;;;;EAIA;;;;+CAI6C,uDAAqD,IAAE,aAAa,CAAC,GAAA,KAAE;;;;;;;;;;;;;AC3CtH;;;;;;SAMS,WAAA,GAAG,GAAI,SAAA,sCAAsC,GAAA;;;;;;;;;;;;;;;;;;SCO7C;;;;MAIH;;;;;;CChBL;;CAEA,2BAA6B,WAAA,IAAI,GAAI,SAAA,mBAAmB,GAAA;CACxD,2BAA6B,WAAA,IAAI,GAAI,SAAA,qBAAqB,GAAA;;;;;;;;;;;;;;CAc1D,yBAA2B,WAAE,iBAAiB,GAAM;EACnD;;;;;;;;CChBD;;CAEA;CACA;;CAEA;;CAEA;CACA;CACA;;;EAGC;;;;;KAKG,mBAAA;KACA,qBAAA;KACA,gBAAA;KACA,kBAAA;;KAEA,aAAA;;;;;;;;;;;;;;;;;;;;OAoBE;EACL;;;;;KAKG,mBAAA;KACA,qBAAA;KACA,gBAAA;KACA,kBAAA;;KAEA,aAAA;;;;GAIF;GACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCF,4BAA8B,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6BAA+B,WAAE,SAAS,GAAM;GAC/C,oEAAsE,MAAI;GAC1E;;;;;;;;UAQO;;;;KAIL;;;;UAIK;EACR;;;;GAIC;GACA;;;;;;;;;;;;;;;;;QAiBK;EACN;;EAEA;EACA;;;;;;;;;;;;;;;;;;;;;;;;"}
{"version":3,"file":"magic-string.cjs.js","sources":["../src/Chunk.js","../src/utils/btoa.js","../src/utils/SourceMap.js","../src/utils/guessIndent.js","../src/utils/encodeMappings.js","../src/utils/getRelativePath.js","../src/utils/isObject.js","../src/utils/findIndex.js","../src/MagicString.js","../src/utils/hasOwnProp.js","../src/Bundle.js","../src/index.js"],"sourcesContent":["export default function Chunk ( start, end, content ) {\n\tthis.start = start;\n\tthis.end = end;\n\tthis.original = content;\n\n\tthis.content = content;\n\tthis.storeName = false;\n\tthis.edited = false;\n}\n\nChunk.prototype = {\n\tclone () {\n\t\tconst chunk = new Chunk( this.start, this.end, this.original );\n\t\tchunk.content = this.content;\n\t\tchunk.storeName = this.storeName;\n\t\tchunk.edited = this.edited;\n\n\t\treturn chunk;\n\t},\n\n\tedit ( content, storeName ) {\n\t\tthis.content = content;\n\t\tthis.storeName = storeName;\n\n\t\tthis.edited = true;\n\n\t\treturn this;\n\t},\n\n\tsplit ( index ) {\n\t\tif ( index === this.start ) return this;\n\n\t\tconst sliceIndex = index - this.start;\n\n\t\tconst originalBefore = this.original.slice( 0, sliceIndex );\n\t\tconst originalAfter = this.original.slice( sliceIndex );\n\n\t\tthis.original = originalBefore;\n\n\t\tconst newChunk = new Chunk( index, this.end, originalAfter );\n\t\tthis.end = index;\n\n\t\tif ( this.edited ) {\n\t\t\tif ( this.content.length ) throw new Error( `Cannot split a chunk that has already been edited (\"${this.original}\")` );\n\n\t\t\t// zero-length edited chunks are a special case (overlapping replacements)\n\t\t\tnewChunk.edit( '', false );\n\t\t\tthis.content = '';\n\t\t} else {\n\t\t\tthis.content = originalBefore;\n\t\t}\n\n\t\treturn newChunk;\n\t}\n};\n","let _btoa;\n\nif ( typeof window !== 'undefined' && typeof window.btoa === 'function' ) {\n\t_btoa = window.btoa;\n} else if ( typeof Buffer === 'function' ) {\n\t/* global Buffer */\n\t_btoa = str => new Buffer( str ).toString( 'base64' );\n} else {\n\tthrow new Error( 'Unsupported environment: `window.btoa` or `Buffer` should be supported.' );\n}\n\nexport default _btoa;\n","import btoa from './btoa.js';\n\nexport default function SourceMap ( properties ) {\n\tthis.version = 3;\n\n\tthis.file = properties.file;\n\tthis.sources = properties.sources;\n\tthis.sourcesContent = properties.sourcesContent;\n\tthis.names = properties.names;\n\tthis.mappings = properties.mappings;\n}\n\nSourceMap.prototype = {\n\ttoString () {\n\t\treturn JSON.stringify( this );\n\t},\n\n\ttoUrl () {\n\t\treturn 'data:application/json;charset=utf-8;base64,' + btoa( this.toString() );\n\t}\n};\n","export default function guessIndent ( code ) {\n\tconst lines = code.split( '\\n' );\n\n\tconst tabbed = lines.filter( line => /^\\t+/.test( line ) );\n\tconst spaced = lines.filter( line => /^ {2,}/.test( line ) );\n\n\tif ( tabbed.length === 0 && spaced.length === 0 ) {\n\t\treturn null;\n\t}\n\n\t// More lines tabbed than spaced? Assume tabs, and\n\t// default to tabs in the case of a tie (or nothing\n\t// to go on)\n\tif ( tabbed.length >= spaced.length ) {\n\t\treturn '\\t';\n\t}\n\n\t// Otherwise, we need to guess the multiple\n\tconst min = spaced.reduce( ( previous, current ) => {\n\t\tconst numSpaces = /^ +/.exec( current )[0].length;\n\t\treturn Math.min( numSpaces, previous );\n\t}, Infinity );\n\n\treturn new Array( min + 1 ).join( ' ' );\n}\n","import { encode } from 'vlq';\n\nfunction getLocator ( source ) {\n\tlet originalLines = source.split( '\\n' );\n\n\treturn function locate ( index ) {\n\t\tconst len = originalLines.length;\n\n\t\tlet lineStart = 0;\n\n\t\tfor ( let i = 0; i < len; i += 1 ) {\n\t\t\tconst line = originalLines[i];\n\t\t\tconst lineEnd = lineStart + line.length + 1; // +1 for newline\n\n\t\t\tif ( lineEnd > index ) return { line: i, column: index - lineStart };\n\n\t\t\tlineStart = lineEnd;\n\t\t}\n\t};\n}\n\nexport default function encodeMappings ( original, intro, chunks, hires, sourcemapLocations, sourceIndex, offsets, names ) {\n\tlet rawLines = [];\n\n\tlet generatedCodeLine = intro.split( '\\n' ).length - 1;\n\tlet rawSegments = rawLines[ generatedCodeLine ] = [];\n\n\tlet generatedCodeColumn = 0;\n\n\tconst locate = getLocator( original );\n\n\tfunction addUneditedChunk ( chunk ) {\n\t\tlet originalCharIndex = chunk.start;\n\t\tlet first = true;\n\n\t\tlet { line, column } = locate( originalCharIndex );\n\n\t\twhile ( originalCharIndex < chunk.end ) {\n\t\t\tif ( hires || first || sourcemapLocations[ originalCharIndex ] ) {\n\t\t\t\trawSegments.push({\n\t\t\t\t\tgeneratedCodeLine,\n\t\t\t\t\tgeneratedCodeColumn,\n\t\t\t\t\tsourceCodeLine: line,\n\t\t\t\t\tsourceCodeColumn: column,\n\t\t\t\t\tsourceCodeName: -1,\n\t\t\t\t\tsourceIndex\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif ( original[ originalCharIndex ] === '\\n' ) {\n\t\t\t\tline += 1;\n\t\t\t\tcolumn = 0;\n\t\t\t\tgeneratedCodeLine += 1;\n\t\t\t\trawLines[ generatedCodeLine ] = rawSegments = [];\n\t\t\t\tgeneratedCodeColumn = 0;\n\t\t\t} else {\n\t\t\t\tcolumn += 1;\n\t\t\t\tgeneratedCodeColumn += 1;\n\t\t\t}\n\n\t\t\toriginalCharIndex += 1;\n\t\t\tfirst = false;\n\t\t}\n\t}\n\n\tfor ( let i = 0; i < chunks.length; i += 1 ) {\n\t\tconst chunk = chunks[i];\n\t\tlet { line, column } = locate( chunk.start );\n\n\t\tif ( chunk.edited ) {\n\t\t\tif ( i > 0 || chunk.content.length ) {\n\t\t\t\trawSegments.push({\n\t\t\t\t\tgeneratedCodeLine,\n\t\t\t\t\tgeneratedCodeColumn,\n\t\t\t\t\tsourceCodeLine: line,\n\t\t\t\t\tsourceCodeColumn: column,\n\t\t\t\t\tsourceCodeName: chunk.storeName ? names.indexOf( chunk.original ) : -1,\n\t\t\t\t\tsourceIndex\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tlet lines = chunk.content.split( '\\n' );\n\t\t\tlet lastLine = lines.pop();\n\n\t\t\tif ( lines.length ) {\n\t\t\t\tgeneratedCodeLine += lines.length;\n\t\t\t\trawLines[ generatedCodeLine ] = rawSegments = [];\n\t\t\t\tgeneratedCodeColumn = lastLine.length;\n\t\t\t} else {\n\t\t\t\tgeneratedCodeColumn += lastLine.length;\n\t\t\t}\n\n\t\t\tlines = chunk.original.split( '\\n' );\n\t\t\tlastLine = lines.pop();\n\n\t\t\tif ( lines.length ) {\n\t\t\t\tline += lines.length;\n\t\t\t\tcolumn = lastLine.length;\n\t\t\t} else {\n\t\t\t\tcolumn += lastLine.length;\n\t\t\t}\n\t\t} else {\n\t\t\taddUneditedChunk( chunk );\n\t\t}\n\t}\n\n\toffsets.sourceIndex = offsets.sourceIndex || 0;\n\toffsets.sourceCodeLine = offsets.sourceCodeLine || 0;\n\toffsets.sourceCodeColumn = offsets.sourceCodeColumn || 0;\n\toffsets.sourceCodeName = offsets.sourceCodeName || 0;\n\n\tconst encoded = rawLines.map( segments => {\n\t\tlet generatedCodeColumn = 0;\n\n\t\treturn segments.map( segment => {\n\t\t\tlet arr = [\n\t\t\t\tsegment.generatedCodeColumn - generatedCodeColumn,\n\t\t\t\tsegment.sourceIndex - offsets.sourceIndex,\n\t\t\t\tsegment.sourceCodeLine - offsets.sourceCodeLine,\n\t\t\t\tsegment.sourceCodeColumn - offsets.sourceCodeColumn\n\t\t\t];\n\n\t\t\tgeneratedCodeColumn = segment.generatedCodeColumn;\n\t\t\toffsets.sourceIndex = segment.sourceIndex;\n\t\t\toffsets.sourceCodeLine = segment.sourceCodeLine;\n\t\t\toffsets.sourceCodeColumn = segment.sourceCodeColumn;\n\n\t\t\tif ( ~segment.sourceCodeName ) {\n\t\t\t\tarr.push( segment.sourceCodeName - offsets.sourceCodeName );\n\t\t\t\toffsets.sourceCodeName = segment.sourceCodeName;\n\t\t\t}\n\n\t\t\treturn encode( arr );\n\t\t}).join( ',' );\n\t}).join( ';' );\n\n\treturn encoded;\n}\n","export default function getRelativePath ( from, to ) {\n\tlet fromParts = from.split( /[\\/\\\\]/ );\n\tlet toParts = to.split( /[\\/\\\\]/ );\n\n\tfromParts.pop(); // get dirname\n\n\twhile ( fromParts[0] === toParts[0] ) {\n\t\tfromParts.shift();\n\t\ttoParts.shift();\n\t}\n\n\tif ( fromParts.length ) {\n\t\tlet i = fromParts.length;\n\t\twhile ( i-- ) fromParts[i] = '..';\n\t}\n\n\treturn fromParts.concat( toParts ).join( '/' );\n}\n","const toString = Object.prototype.toString;\n\nexport default function isObject ( thing ) {\n\treturn toString.call( thing ) === '[object Object]';\n}\n","export default function findIndex ( array, fn ) {\n\tfor ( let i = 0; i < array.length; i += 1 ) {\n\t\tif ( fn( array[i], i ) ) return i;\n\t}\n\n\treturn -1;\n}\n","import Chunk from './Chunk.js';\nimport SourceMap from './utils/SourceMap.js';\nimport guessIndent from './utils/guessIndent.js';\nimport encodeMappings from './utils/encodeMappings.js';\nimport getRelativePath from './utils/getRelativePath.js';\nimport isObject from './utils/isObject.js';\nimport findIndex from './utils/findIndex.js';\n\nlet warned = false;\n\nexport default function MagicString ( string, options = {} ) {\n\tconst chunk = new Chunk( 0, string.length, string );\n\n\tObject.defineProperties( this, {\n\t\toriginal: { writable: true, value: string },\n\t\toutro: { writable: true, value: '' },\n\t\tintro: { writable: true, value: '' },\n\t\tchunks: { writable: true, value: [ chunk ] },\n\t\tmoves: { writable: true, value: [] },\n\t\tfilename: { writable: true, value: options.filename },\n\t\tindentExclusionRanges: { writable: true, value: options.indentExclusionRanges },\n\t\tsourcemapLocations: { writable: true, value: {} },\n\t\tstoredNames: { writable: true, value: {} },\n\t\tindentStr: { writable: true, value: guessIndent( string ) }\n\t});\n}\n\nMagicString.prototype = {\n\taddSourcemapLocation ( char ) {\n\t\tthis.sourcemapLocations[ char ] = true;\n\t},\n\n\tappend ( content ) {\n\t\tif ( typeof content !== 'string' ) throw new TypeError( 'outro content must be a string' );\n\n\t\tthis.outro += content;\n\t\treturn this;\n\t},\n\n\tclone () {\n\t\tlet cloned = new MagicString( this.original, { filename: this.filename });\n\n\t\tcloned.chunks = this.chunks.map( chunk => chunk.clone() );\n\n\t\tif ( this.indentExclusionRanges ) {\n\t\t\tcloned.indentExclusionRanges = typeof this.indentExclusionRanges[0] === 'number' ?\n\t\t\t\t[ this.indentExclusionRanges[0], this.indentExclusionRanges[1] ] :\n\t\t\t\tthis.indentExclusionRanges.map( range => [ range.start, range.end ] );\n\t\t}\n\n\t\tObject.keys( this.sourcemapLocations ).forEach( loc => {\n\t\t\tcloned.sourcemapLocations[ loc ] = true;\n\t\t});\n\n\t\treturn cloned;\n\t},\n\n\tgenerateMap ( options ) {\n\t\toptions = options || {};\n\n\t\tconst names = Object.keys( this.storedNames );\n\n\t\treturn new SourceMap({\n\t\t\tfile: ( options.file ? options.file.split( /[\\/\\\\]/ ).pop() : null ),\n\t\t\tsources: [ options.source ? getRelativePath( options.file || '', options.source ) : null ],\n\t\t\tsourcesContent: options.includeContent ? [ this.original ] : [ null ],\n\t\t\tnames,\n\t\t\tmappings: this.getMappings( options.hires, 0, {}, names )\n\t\t});\n\t},\n\n\tgetIndentString () {\n\t\treturn this.indentStr === null ? '\\t' : this.indentStr;\n\t},\n\n\tgetMappings ( hires, sourceIndex, offsets, names ) {\n\t\treturn encodeMappings( this.original, this.intro, this.chunks, hires, this.sourcemapLocations, sourceIndex, offsets, names );\n\t},\n\n\tindent ( indentStr, options ) {\n\t\tconst pattern = /^[^\\r\\n]/gm;\n\n\t\tif ( isObject( indentStr ) ) {\n\t\t\toptions = indentStr;\n\t\t\tindentStr = undefined;\n\t\t}\n\n\t\tindentStr = indentStr !== undefined ? indentStr : ( this.indentStr || '\\t' );\n\n\t\tif ( indentStr === '' ) return this; // noop\n\n\t\toptions = options || {};\n\n\t\t// Process exclusion ranges\n\t\tlet isExcluded = {};\n\n\t\tif ( options.exclude ) {\n\t\t\tlet exclusions = typeof options.exclude[0] === 'number' ? [ options.exclude ] : options.exclude;\n\t\t\texclusions.forEach( exclusion => {\n\t\t\t\tfor ( let i = exclusion[0]; i < exclusion[1]; i += 1 ) {\n\t\t\t\t\tisExcluded[i] = true;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tlet shouldIndentNextCharacter = options.indentStart !== false;\n\t\tconst replacer = match => {\n\t\t\tif ( shouldIndentNextCharacter ) return `${indentStr}${match}`;\n\t\t\tshouldIndentNextCharacter = true;\n\t\t\treturn match;\n\t\t};\n\n\t\tthis.intro = this.intro.replace( pattern, replacer );\n\n\t\tlet chunkIndex;\n\t\tlet charIndex = 0;\n\n\t\tfor ( chunkIndex = 0; chunkIndex < this.chunks.length; chunkIndex += 1 ) { // can't cache this.chunks.length, it may change\n\t\t\tlet chunk = this.chunks[ chunkIndex ];\n\t\t\tconst end = chunk.end;\n\n\t\t\tif ( chunk.edited ) {\n\t\t\t\tif ( !isExcluded[ charIndex ] ) {\n\t\t\t\t\tchunk.content = chunk.content.replace( pattern, replacer );\n\n\t\t\t\t\tif ( chunk.content.length ) {\n\t\t\t\t\t\tshouldIndentNextCharacter = chunk.content[ chunk.content.length - 1 ] === '\\n';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcharIndex = chunk.start;\n\n\t\t\t\twhile ( charIndex < end ) {\n\t\t\t\t\tif ( !isExcluded[ charIndex ] ) {\n\t\t\t\t\t\tconst char = this.original[ charIndex ];\n\n\t\t\t\t\t\tif ( char === '\\n' ) {\n\t\t\t\t\t\t\tshouldIndentNextCharacter = true;\n\t\t\t\t\t\t} else if ( char !== '\\r' && shouldIndentNextCharacter ) {\n\t\t\t\t\t\t\tshouldIndentNextCharacter = false;\n\n\t\t\t\t\t\t\tconst indentation = new Chunk( charIndex, charIndex, '' ).edit( indentStr, false );\n\t\t\t\t\t\t\tconst remainder = chunk.split( charIndex );\n\n\t\t\t\t\t\t\tif ( charIndex === chunk.start ) {\n\t\t\t\t\t\t\t\tthis.chunks.splice( chunkIndex, 0, indentation );\n\t\t\t\t\t\t\t\tchunkIndex += 1;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthis.chunks.splice( chunkIndex + 1, 0, indentation, remainder );\n\t\t\t\t\t\t\t\tchunkIndex += 2;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tchunk = remainder;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tcharIndex += 1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcharIndex = chunk.end;\n\t\t}\n\n\t\tthis.outro = this.outro.replace( pattern, replacer );\n\n\t\treturn this;\n\t},\n\n\tinsert ( index, content ) {\n\t\tif ( typeof content !== 'string' ) throw new TypeError( 'inserted content must be a string' );\n\n\t\tthis._split( index );\n\n\t\tlet next = findIndex( this.chunks, chunk => chunk.original.length && chunk.start === index );\n\t\tif ( !~next ) next = this.chunks.length;\n\n\t\tconst newChunk = new Chunk( index, index, '' ).edit( content, false );\n\n\t\tthis.chunks.splice( next, 0, newChunk );\n\t\treturn this;\n\t},\n\n\t// get current location of character in original string\n\tlocate () {\n\t\tthrow new Error( 'magicString.locate is deprecated' );\n\t},\n\n\tlocateOrigin () {\n\t\tthrow new Error( 'magicString.locateOrigin is deprecated' );\n\t},\n\n\tmove ( start, end, index ) {\n\t\tif ( index >= start && index <= end ) throw new Error( 'Cannot move a selection inside itself' );\n\n\t\tthis._split( start );\n\t\tthis._split( end );\n\t\tthis._split( index );\n\n\t\tconst firstIndex = findIndex( this.chunks, chunk => chunk.start === start );\n\t\tlet lastIndex = findIndex( this.chunks, chunk => chunk.end === end );\n\n\t\tconst toMove = this.chunks.splice( firstIndex, lastIndex + 1 - firstIndex );\n\n\t\tlet insertionIndex = findIndex( this.chunks, chunk => chunk.original.length && chunk.start === index );\n\t\tif ( !~insertionIndex ) insertionIndex = this.chunks.length;\n\n\t\tthis.chunks.splice.apply( this.chunks, [ insertionIndex, 0 ].concat( toMove ) );\n\n\t\treturn this;\n\t},\n\n\toverwrite ( start, end, content, storeName ) {\n\t\tif ( typeof content !== 'string' ) {\n\t\t\tthrow new TypeError( 'replacement content must be a string' );\n\t\t}\n\n\t\tthis._split( start );\n\t\tthis._split( end );\n\n\t\tif ( storeName ) {\n\t\t\tconst original = this.original.slice( start, end );\n\t\t\tthis.storedNames[ original ] = true;\n\t\t}\n\n\t\tlet firstIndex = findIndex( this.chunks, chunk => chunk.start === start && chunk.original.length );\n\t\tif ( !~firstIndex ) firstIndex = this.chunks.length;\n\t\tlet lastIndex = findIndex( this.chunks, chunk => chunk.end === end );\n\n\t\tconst newChunk = new Chunk( start, end, this.original.slice( start, end ) ).edit( content, storeName );\n\n\t\tthis.chunks.splice( firstIndex, lastIndex + 1 - firstIndex, newChunk );\n\t\treturn this;\n\t},\n\n\tprepend ( content ) {\n\t\tif ( typeof content !== 'string' ) throw new TypeError( 'outro content must be a string' );\n\n\t\tthis.intro = content + this.intro;\n\t\treturn this;\n\t},\n\n\tremove ( start, end ) {\n\t\twhile ( start < 0 ) start += this.original.length;\n\t\twhile ( end < 0 ) end += this.original.length;\n\n\t\tif ( start === end ) return this;\n\n\t\tif ( start < 0 || end > this.original.length ) throw new Error( 'Character is out of bounds' );\n\t\tif ( start > end ) throw new Error( 'end must be greater than start' );\n\n\t\tlet firstIndex = findIndex( this.chunks, chunk => chunk.start <= start && chunk.end > start );\n\t\tlet chunk = this.chunks[ firstIndex ];\n\n\t\t// if the chunk contains `start`, split\n\t\tif ( chunk.start < start ) {\n\t\t\tif ( chunk.edited && chunk.content.length ) throw new Error( 'nope' );\n\t\t\tthis._split( start );\n\t\t\tfirstIndex += 1;\n\t\t}\n\n\t\tlet lastIndex = findIndex( this.chunks, chunk => chunk.start < end && chunk.end >= end );\n\t\tchunk = this.chunks[ lastIndex ];\n\n\t\t// if the chunk contains `end`, split\n\t\tif ( chunk.start < end ) {\n\t\t\tif ( chunk.edited && chunk.content.length ) throw new Error( 'nope' );\n\t\t\tthis._split( end );\n\t\t}\n\n\t\tlastIndex += 1;\n\n\t\tconst newChunk = new Chunk( start, end, this.original.slice( start, end ) ).edit( '', false );\n\t\tthis.chunks.splice( firstIndex, lastIndex - firstIndex, newChunk );\n\n\t\treturn this;\n\t},\n\n\treplace ( start, end, content ) {\n\t\tif ( !warned ) {\n\t\t\tconsole.warn( 'magicString.replace(...) is deprecated. Use magicString.overwrite(...) instead' );\n\t\t\twarned = true;\n\t\t}\n\n\t\treturn this.overwrite( start, end, content );\n\t},\n\n\tslice ( start, end = this.original.length ) {\n\t\twhile ( start < 0 ) start += this.original.length;\n\t\twhile ( end < 0 ) end += this.original.length;\n\n\t\tlet result = '';\n\n\t\tfor ( let i = 0; i < this.chunks.length; i += 1 ) {\n\t\t\tconst chunk = this.chunks[i];\n\n\t\t\tif ( chunk.end <= start ) continue;\n\t\t\tif ( chunk.start >= end ) break;\n\n\t\t\tif ( chunk.start < start || chunk.end > end ) {\n\t\t\t\tif ( chunk.edited ) throw new Error( `Cannot use replaced characters (${start}, ${end}) as slice anchors` );\n\n\t\t\t\tconst sliceStart = Math.max( start - chunk.start, 0 );\n\t\t\t\tconst sliceEnd = Math.min( chunk.content.length - ( chunk.end - end ), chunk.content.length );\n\n\t\t\t\tresult += chunk.content.slice( sliceStart, sliceEnd );\n\t\t\t} else {\n\t\t\t\tresult += chunk.content;\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t},\n\n\tsnip ( start, end ) {\n\t\tconst clone = this.clone();\n\t\tclone.remove( 0, start );\n\t\tclone.remove( end, clone.original.length );\n\n\t\treturn clone;\n\t},\n\n\t_split ( index ) {\n\t\t// TODO bisect\n\t\tfor ( let i = 0; i < this.chunks.length; i += 1 ) {\n\t\t\tconst chunk = this.chunks[i];\n\t\t\tif ( chunk.start === index || chunk.end === index ) return;\n\n\t\t\tif ( chunk.start < index && chunk.end > index ) {\n\t\t\t\tconst newChunk = chunk.split( index );\n\t\t\t\tthis.chunks.splice( i + 1, 0, newChunk );\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t},\n\n\ttoString () {\n\t\treturn this.intro + this.chunks.map( chunk => chunk.content ).join( '' ) + this.outro;\n\t},\n\n\ttrimLines () {\n\t\treturn this.trim('[\\\\r\\\\n]');\n\t},\n\n\t// TODO rewrite these methods, post-refactor\n\ttrim ( charType ) {\n\t\treturn this.trimStart( charType ).trimEnd( charType );\n\t},\n\n\ttrimEnd ( charType ) {\n\t\tconst rx = new RegExp( ( charType || '\\\\s' ) + '+$' );\n\n\t\tthis.outro = this.outro.replace( rx, '' );\n\t\tif ( this.outro.length ) return this;\n\n\t\tdo {\n\t\t\tlet lastChunk = this.chunks[ this.chunks.length - 1 ];\n\t\t\tif ( rx.test( lastChunk.content ) ) {\n\t\t\t\tlastChunk.edit( lastChunk.content.replace( rx, '' ) );\n\t\t\t}\n\n\t\t\tif ( lastChunk.content.length || this.chunks.length === 1 ) {\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tthis.chunks.pop();\n\t\t\t}\n\t\t} while ( true );\n\n\t\treturn this;\n\t},\n\n\ttrimStart ( charType ) {\n\t\tconst rx = new RegExp( '^' + ( charType || '\\\\s' ) + '+' );\n\n\t\tthis.intro = this.intro.replace( rx, '' );\n\t\tif ( this.intro.length ) return this;\n\n\t\tdo {\n\t\t\tlet firstChunk = this.chunks[0];\n\t\t\tif ( rx.test( firstChunk.content ) ) {\n\t\t\t\tfirstChunk.edit( firstChunk.content.replace( rx, '' ) );\n\t\t\t}\n\n\t\t\tif ( firstChunk.content.length || this.chunks.length === 1 ) {\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tthis.chunks.shift();\n\t\t\t}\n\t\t} while ( true );\n\n\t\treturn this;\n\t}\n};\n","export default Object.prototype.hasOwnProperty;","import MagicString from './MagicString.js';\nimport SourceMap from './utils/SourceMap.js';\nimport getRelativePath from './utils/getRelativePath.js';\nimport hasOwnProp from './utils/hasOwnProp.js';\nimport isObject from './utils/isObject.js';\n\nexport default function Bundle ( options = {} ) {\n\tthis.intro = options.intro || '';\n\tthis.separator = options.separator !== undefined ? options.separator : '\\n';\n\n\tthis.sources = [];\n\n\tthis.uniqueSources = [];\n\tthis.uniqueSourceIndexByFilename = {};\n}\n\nBundle.prototype = {\n\taddSource ( source ) {\n\t\tif ( source instanceof MagicString ) {\n\t\t\treturn this.addSource({\n\t\t\t\tcontent: source,\n\t\t\t\tfilename: source.filename,\n\t\t\t\tseparator: this.separator\n\t\t\t});\n\t\t}\n\n\t\tif ( !isObject( source ) || !source.content ) {\n\t\t\tthrow new Error( 'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`' );\n\t\t}\n\n\t\t[ 'filename', 'indentExclusionRanges', 'separator' ].forEach( option => {\n\t\t\tif ( !hasOwnProp.call( source, option ) ) source[ option ] = source.content[ option ];\n\t\t});\n\n\t\tif ( source.separator === undefined ) { // TODO there's a bunch of this sort of thing, needs cleaning up\n\t\t\tsource.separator = this.separator;\n\t\t}\n\n\t\tif ( source.filename ) {\n\t\t\tif ( !hasOwnProp.call( this.uniqueSourceIndexByFilename, source.filename ) ) {\n\t\t\t\tthis.uniqueSourceIndexByFilename[ source.filename ] = this.uniqueSources.length;\n\t\t\t\tthis.uniqueSources.push({ filename: source.filename, content: source.content.original });\n\t\t\t} else {\n\t\t\t\tconst uniqueSource = this.uniqueSources[ this.uniqueSourceIndexByFilename[ source.filename ] ];\n\t\t\t\tif ( source.content.original !== uniqueSource.content ) {\n\t\t\t\t\tthrow new Error( `Illegal source: same filename (${source.filename}), different contents` );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.sources.push( source );\n\t\treturn this;\n\t},\n\n\tappend ( str, options ) {\n\t\tthis.addSource({\n\t\t\tcontent: new MagicString( str ),\n\t\t\tseparator: ( options && options.separator ) || ''\n\t\t});\n\n\t\treturn this;\n\t},\n\n\tclone () {\n\t\tconst bundle = new Bundle({\n\t\t\tintro: this.intro,\n\t\t\tseparator: this.separator\n\t\t});\n\n\t\tthis.sources.forEach( source => {\n\t\t\tbundle.addSource({\n\t\t\t\tfilename: source.filename,\n\t\t\t\tcontent: source.content.clone(),\n\t\t\t\tseparator: source.separator\n\t\t\t});\n\t\t});\n\n\t\treturn bundle;\n\t},\n\n\tgenerateMap ( options ) {\n\t\tlet offsets = {};\n\n\t\tlet names = [];\n\t\tthis.sources.forEach( source => {\n\t\t\tObject.keys( source.content.storedNames ).forEach( name => {\n\t\t\t\tif ( !~names.indexOf( name ) ) names.push( name );\n\t\t\t});\n\t\t});\n\n\t\tconst encoded = (\n\t\t\tgetSemis( this.intro ) +\n\t\t\tthis.sources.map( ( source, i ) => {\n\t\t\t\tconst prefix = ( i > 0 ) ? ( getSemis( source.separator ) || ',' ) : '';\n\t\t\t\tlet mappings;\n\n\t\t\t\t// we don't bother encoding sources without a filename\n\t\t\t\tif ( !source.filename ) {\n\t\t\t\t\tmappings = getSemis( source.content.toString() );\n\t\t\t\t} else {\n\t\t\t\t\tconst sourceIndex = this.uniqueSourceIndexByFilename[ source.filename ];\n\t\t\t\t\tmappings = source.content.getMappings( options.hires, sourceIndex, offsets, names );\n\t\t\t\t}\n\n\t\t\t\treturn prefix + mappings;\n\t\t\t}).join( '' )\n\t\t);\n\n\t\treturn new SourceMap({\n\t\t\tfile: ( options.file ? options.file.split( /[\\/\\\\]/ ).pop() : null ),\n\t\t\tsources: this.uniqueSources.map( source => {\n\t\t\t\treturn options.file ? getRelativePath( options.file, source.filename ) : source.filename;\n\t\t\t}),\n\t\t\tsourcesContent: this.uniqueSources.map( source => {\n\t\t\t\treturn options.includeContent ? source.content : null;\n\t\t\t}),\n\t\t\tnames,\n\t\t\tmappings: encoded\n\t\t});\n\t},\n\n\tgetIndentString () {\n\t\tlet indentStringCounts = {};\n\n\t\tthis.sources.forEach( source => {\n\t\t\tconst indentStr = source.content.indentStr;\n\n\t\t\tif ( indentStr === null ) return;\n\n\t\t\tif ( !indentStringCounts[ indentStr ] ) indentStringCounts[ indentStr ] = 0;\n\t\t\tindentStringCounts[ indentStr ] += 1;\n\t\t});\n\n\t\treturn ( Object.keys( indentStringCounts ).sort( ( a, b ) => {\n\t\t\treturn indentStringCounts[a] - indentStringCounts[b];\n\t\t})[0] ) || '\\t';\n\t},\n\n\tindent ( indentStr ) {\n\t\tif ( !arguments.length ) {\n\t\t\tindentStr = this.getIndentString();\n\t\t}\n\n\t\tif ( indentStr === '' ) return this; // noop\n\n\t\tlet trailingNewline = !this.intro || this.intro.slice( -1 ) === '\\n';\n\n\t\tthis.sources.forEach( ( source, i ) => {\n\t\t\tconst separator = source.separator !== undefined ? source.separator : this.separator;\n\t\t\tconst indentStart = trailingNewline || ( i > 0 && /\\r?\\n$/.test( separator ) );\n\n\t\t\tsource.content.indent( indentStr, {\n\t\t\t\texclude: source.indentExclusionRanges,\n\t\t\t\tindentStart//: trailingNewline || /\\r?\\n$/.test( separator ) //true///\\r?\\n/.test( separator )\n\t\t\t});\n\n\t\t\t// TODO this is a very slow way to determine this\n\t\t\ttrailingNewline = source.content.toString().slice( 0, -1 ) === '\\n';\n\t\t});\n\n\t\tif ( this.intro ) {\n\t\t\tthis.intro = indentStr + this.intro.replace( /^[^\\n]/gm, ( match, index ) => {\n\t\t\t\treturn index > 0 ? indentStr + match : match;\n\t\t\t});\n\t\t}\n\n\t\treturn this;\n\t},\n\n\tprepend ( str ) {\n\t\tthis.intro = str + this.intro;\n\t\treturn this;\n\t},\n\n\ttoString () {\n\t\tconst body = this.sources.map( ( source, i ) => {\n\t\t\tconst separator = source.separator !== undefined ? source.separator : this.separator;\n\t\t\tlet str = ( i > 0 ? separator : '' ) + source.content.toString();\n\n\t\t\treturn str;\n\t\t}).join( '' );\n\n\t\treturn this.intro + body;\n\t},\n\n\ttrimLines () {\n\t\treturn this.trim('[\\\\r\\\\n]');\n\t},\n\n\ttrim ( charType ) {\n\t\treturn this.trimStart( charType ).trimEnd( charType );\n\t},\n\n\ttrimStart ( charType ) {\n\t\tconst rx = new RegExp( '^' + ( charType || '\\\\s' ) + '+' );\n\t\tthis.intro = this.intro.replace( rx, '' );\n\n\t\tif ( !this.intro ) {\n\t\t\tlet source;\n\t\t\tlet i = 0;\n\n\t\t\tdo {\n\t\t\t\tsource = this.sources[i];\n\n\t\t\t\tif ( !source ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tsource.content.trimStart( charType );\n\t\t\t\ti += 1;\n\t\t\t} while ( source.content.toString() === '' ); // TODO faster way to determine non-empty source?\n\t\t}\n\n\t\treturn this;\n\t},\n\n\ttrimEnd ( charType ) {\n\t\tconst rx = new RegExp( ( charType || '\\\\s' ) + '+$' );\n\n\t\tlet source;\n\t\tlet i = this.sources.length - 1;\n\n\t\tdo {\n\t\t\tsource = this.sources[i];\n\n\t\t\tif ( !source ) {\n\t\t\t\tthis.intro = this.intro.replace( rx, '' );\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tsource.content.trimEnd( charType );\n\t\t\ti -= 1;\n\t\t} while ( source.content.toString() === '' ); // TODO faster way to determine non-empty source?\n\n\t\treturn this;\n\t}\n};\n\nfunction getSemis ( str ) {\n\treturn new Array( str.split( '\\n' ).length ).join( ';' );\n}\n","import MagicString from './MagicString.js';\nimport Bundle from './Bundle.js';\n\nMagicString.Bundle = Bundle;\n\nexport default MagicString;\n"],"names":["this"],"mappings":";;;;;;;;;;;;;;;MAWM;EACJ;;;;;;;;KAQG;;;;;;;;;MASC;;;EAGJ;;EAEA;EACA;;;;EAIA;;;;+CAI6C,CAAA,uDAAqD,IAAE,aAAa,SAAG,CAAC;;;;;;;;;;;;;AC3CvH;;;;;;SAMS,WAAA,GAAG,GAAI,SAAA,sCAAsC,GAAA;;;;;;;;;;;;;;;;;;SCO7C;;;;MAIH;;;;;;CChBL;;CAEA,2BAA6B,WAAA,IAAI,GAAI,SAA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BACsB,WAAA,MAAM,GAAI;sDACoB,WAAA,IAAI,GAAI;;;;;EAK5D;;qBAEmB,WAAE,SAAS,GAAM;IAClC;IACA;;;;;;KAMC,kBAAoBA,MAAI;;;;;;;;;;oCAUO,WAAA,MAAM,GAAI;;;2CAGH,WAAA,MAAM,GAAI;;;GAGlD,OAAA;;;;;gBAKa;EACd;;wBAEsB,WAAA,MAAM,GAAI;GAC/B;;;;;;;;mDAQgD,WAAE,IAAI,GAAM;;;;;OAKxD;EACL,kBAAA;;EAAA;;;;;;EAMA;;wBAEsB,WAAE,SAAS,GAAM;GACtC,oEAAsEA,MAAI;GAC1E;;;;IAIC,aAAA;;;;;;;;4DAQwD,WAAE,YAAY,GAAM;;;;;;;;QAQxE;;;;;SAKC;EACP,kBAAA;;EAAA,6BAA+B,WAAE,SAAS,GAAM;GAC/C,oEAAsEA,MAAI;GAC1E;;;;;;;;UAQO;;;;KAIL;;;;UAIK;EACR;;;;GAIC;GACA;;;;;;;;;;;;;;;;;QAiBK;EACN;;EAEA;EACA;;;;;;;;;;;;;;;;;;;;;;;;"}

@@ -46,3 +46,3 @@ import { encode } from 'vlq';

if ( this.edited ) {
if ( this.content.length ) throw new Error( "Cannot split a chunk that has already been edited (\"" + (this.original) + "\")" );
if ( this.content.length ) throw new Error( ("Cannot split a chunk that has already been edited (\"" + (this.original) + "\")") );

@@ -119,2 +119,21 @@ // zero-length edited chunks are a special case (overlapping replacements)

function getLocator ( source ) {
var originalLines = source.split( '\n' );
return function locate ( index ) {
var len = originalLines.length;
var lineStart = 0;
for ( var i = 0; i < len; i += 1 ) {
var line = originalLines[i];
var lineEnd = lineStart + line.length + 1; // +1 for newline
if ( lineEnd > index ) return { line: i, column: index - lineStart };
lineStart = lineEnd;
}
};
}
function encodeMappings ( original, intro, chunks, hires, sourcemapLocations, sourceIndex, offsets, names ) {

@@ -126,12 +145,13 @@ var rawLines = [];

var originalCharIndex = 0;
var generatedCodeColumn = 0;
var sourceCodeLine = 0;
var sourceCodeColumn = 0;
function addSegmentsUntil ( end ) {
var locate = getLocator( original );
function addUneditedChunk ( chunk ) {
var originalCharIndex = chunk.start;
var first = true;
while ( originalCharIndex < end ) {
var ref = locate( originalCharIndex ), line = ref.line, column = ref.column;
while ( originalCharIndex < chunk.end ) {
if ( hires || first || sourcemapLocations[ originalCharIndex ] ) {

@@ -141,4 +161,4 @@ rawSegments.push({

generatedCodeColumn: generatedCodeColumn,
sourceCodeLine: sourceCodeLine,
sourceCodeColumn: sourceCodeColumn,
sourceCodeLine: line,
sourceCodeColumn: column,
sourceCodeName: -1,

@@ -150,4 +170,4 @@ sourceIndex: sourceIndex

if ( original[ originalCharIndex ] === '\n' ) {
sourceCodeLine += 1;
sourceCodeColumn = 0;
line += 1;
column = 0;
generatedCodeLine += 1;

@@ -157,3 +177,3 @@ rawLines[ generatedCodeLine ] = rawSegments = [];

} else {
sourceCodeColumn += 1;
column += 1;
generatedCodeColumn += 1;

@@ -169,2 +189,3 @@ }

var chunk = chunks[i];
var ref = locate( chunk.start ), line = ref.line, column = ref.column;

@@ -176,4 +197,4 @@ if ( chunk.edited ) {

generatedCodeColumn: generatedCodeColumn,
sourceCodeLine: sourceCodeLine,
sourceCodeColumn: sourceCodeColumn,
sourceCodeLine: line,
sourceCodeColumn: column,
sourceCodeName: chunk.storeName ? names.indexOf( chunk.original ) : -1,

@@ -199,16 +220,12 @@ sourceIndex: sourceIndex

if ( lines.length ) {
sourceCodeLine += lines.length;
sourceCodeColumn = lastLine.length;
line += lines.length;
column = lastLine.length;
} else {
sourceCodeColumn += lastLine.length;
column += lastLine.length;
}
} else {
addSegmentsUntil( chunk.end );
addUneditedChunk( chunk );
}
originalCharIndex = chunk.end;
}
addSegmentsUntil( original.length );
offsets.sourceIndex = offsets.sourceIndex || 0;

@@ -381,3 +398,3 @@ offsets.sourceCodeLine = offsets.sourceCodeLine || 0;

var replacer = function ( match ) {
if ( shouldIndentNextCharacter ) return "" + indentStr + "" + match + "";
if ( shouldIndentNextCharacter ) return ("" + indentStr + "" + match);
shouldIndentNextCharacter = true;

@@ -576,3 +593,3 @@ return match;

if ( chunk.start < start || chunk.end > end ) {
if ( chunk.edited ) throw new Error( "Cannot use replaced characters (" + start + ", " + end + ") as slice anchors" );
if ( chunk.edited ) throw new Error( ("Cannot use replaced characters (" + start + ", " + end + ") as slice anchors") );

@@ -714,3 +731,3 @@ var sliceStart = Math.max( start - chunk.start, 0 );

if ( source.content.original !== uniqueSource.content ) {
throw new Error( "Illegal source: same filename (" + (source.filename) + "), different contents" );
throw new Error( ("Illegal source: same filename (" + (source.filename) + "), different contents") );
}

@@ -717,0 +734,0 @@ }

@@ -1,1 +0,1 @@

{"version":3,"file":"magic-string.es6.js","sources":["../src/Chunk.js","../src/utils/btoa.js","../src/utils/SourceMap.js","../src/utils/guessIndent.js","../src/utils/encodeMappings.js","../src/utils/getRelativePath.js","../src/utils/isObject.js","../src/utils/findIndex.js","../src/MagicString.js","../src/utils/hasOwnProp.js","../src/Bundle.js","../src/index.js"],"sourcesContent":["export default function Chunk ( start, end, content ) {\n\tthis.start = start;\n\tthis.end = end;\n\tthis.original = content;\n\n\tthis.content = content;\n\tthis.storeName = false;\n\tthis.edited = false;\n}\n\nChunk.prototype = {\n\tclone () {\n\t\tconst chunk = new Chunk( this.start, this.end, this.original );\n\t\tchunk.content = this.content;\n\t\tchunk.storeName = this.storeName;\n\t\tchunk.edited = this.edited;\n\n\t\treturn chunk;\n\t},\n\n\tedit ( content, storeName ) {\n\t\tthis.content = content;\n\t\tthis.storeName = storeName;\n\n\t\tthis.edited = true;\n\n\t\treturn this;\n\t},\n\n\tsplit ( index ) {\n\t\tif ( index === this.start ) return this;\n\n\t\tconst sliceIndex = index - this.start;\n\n\t\tconst originalBefore = this.original.slice( 0, sliceIndex );\n\t\tconst originalAfter = this.original.slice( sliceIndex );\n\n\t\tthis.original = originalBefore;\n\n\t\tconst newChunk = new Chunk( index, this.end, originalAfter );\n\t\tthis.end = index;\n\n\t\tif ( this.edited ) {\n\t\t\tif ( this.content.length ) throw new Error( `Cannot split a chunk that has already been edited (\"${this.original}\")` );\n\n\t\t\t// zero-length edited chunks are a special case (overlapping replacements)\n\t\t\tnewChunk.edit( '', false );\n\t\t\tthis.content = '';\n\t\t} else {\n\t\t\tthis.content = originalBefore;\n\t\t}\n\n\t\treturn newChunk;\n\t}\n};\n","let _btoa;\n\nif ( typeof window !== 'undefined' && typeof window.btoa === 'function' ) {\n\t_btoa = window.btoa;\n} else if ( typeof Buffer === 'function' ) {\n\t/* global Buffer */\n\t_btoa = str => new Buffer( str ).toString( 'base64' );\n} else {\n\tthrow new Error( 'Unsupported environment: `window.btoa` or `Buffer` should be supported.' );\n}\n\nexport default _btoa;\n","import btoa from './btoa.js';\n\nexport default function SourceMap ( properties ) {\n\tthis.version = 3;\n\n\tthis.file = properties.file;\n\tthis.sources = properties.sources;\n\tthis.sourcesContent = properties.sourcesContent;\n\tthis.names = properties.names;\n\tthis.mappings = properties.mappings;\n}\n\nSourceMap.prototype = {\n\ttoString () {\n\t\treturn JSON.stringify( this );\n\t},\n\n\ttoUrl () {\n\t\treturn 'data:application/json;charset=utf-8;base64,' + btoa( this.toString() );\n\t}\n};\n","export default function guessIndent ( code ) {\n\tconst lines = code.split( '\\n' );\n\n\tconst tabbed = lines.filter( line => /^\\t+/.test( line ) );\n\tconst spaced = lines.filter( line => /^ {2,}/.test( line ) );\n\n\tif ( tabbed.length === 0 && spaced.length === 0 ) {\n\t\treturn null;\n\t}\n\n\t// More lines tabbed than spaced? Assume tabs, and\n\t// default to tabs in the case of a tie (or nothing\n\t// to go on)\n\tif ( tabbed.length >= spaced.length ) {\n\t\treturn '\\t';\n\t}\n\n\t// Otherwise, we need to guess the multiple\n\tconst min = spaced.reduce( ( previous, current ) => {\n\t\tconst numSpaces = /^ +/.exec( current )[0].length;\n\t\treturn Math.min( numSpaces, previous );\n\t}, Infinity );\n\n\treturn new Array( min + 1 ).join( ' ' );\n}\n","import { encode } from 'vlq';\n\nexport default function encodeMappings ( original, intro, chunks, hires, sourcemapLocations, sourceIndex, offsets, names ) {\n\tlet rawLines = [];\n\n\tlet generatedCodeLine = intro.split( '\\n' ).length - 1;\n\tlet rawSegments = rawLines[ generatedCodeLine ] = [];\n\n\tlet originalCharIndex = 0;\n\n\tlet generatedCodeColumn = 0;\n\tlet sourceCodeLine = 0;\n\tlet sourceCodeColumn = 0;\n\n\tfunction addSegmentsUntil ( end ) {\n\t\tlet first = true;\n\n\t\twhile ( originalCharIndex < end ) {\n\t\t\tif ( hires || first || sourcemapLocations[ originalCharIndex ] ) {\n\t\t\t\trawSegments.push({\n\t\t\t\t\tgeneratedCodeLine,\n\t\t\t\t\tgeneratedCodeColumn,\n\t\t\t\t\tsourceCodeLine,\n\t\t\t\t\tsourceCodeColumn,\n\t\t\t\t\tsourceCodeName: -1,\n\t\t\t\t\tsourceIndex\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif ( original[ originalCharIndex ] === '\\n' ) {\n\t\t\t\tsourceCodeLine += 1;\n\t\t\t\tsourceCodeColumn = 0;\n\t\t\t\tgeneratedCodeLine += 1;\n\t\t\t\trawLines[ generatedCodeLine ] = rawSegments = [];\n\t\t\t\tgeneratedCodeColumn = 0;\n\t\t\t} else {\n\t\t\t\tsourceCodeColumn += 1;\n\t\t\t\tgeneratedCodeColumn += 1;\n\t\t\t}\n\n\t\t\toriginalCharIndex += 1;\n\t\t\tfirst = false;\n\t\t}\n\t}\n\n\tfor ( let i = 0; i < chunks.length; i += 1 ) {\n\t\tconst chunk = chunks[i];\n\n\t\tif ( chunk.edited ) {\n\t\t\tif ( i > 0 || chunk.content.length ) {\n\t\t\t\trawSegments.push({\n\t\t\t\t\tgeneratedCodeLine,\n\t\t\t\t\tgeneratedCodeColumn,\n\t\t\t\t\tsourceCodeLine,\n\t\t\t\t\tsourceCodeColumn,\n\t\t\t\t\tsourceCodeName: chunk.storeName ? names.indexOf( chunk.original ) : -1,\n\t\t\t\t\tsourceIndex\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tlet lines = chunk.content.split( '\\n' );\n\t\t\tlet lastLine = lines.pop();\n\n\t\t\tif ( lines.length ) {\n\t\t\t\tgeneratedCodeLine += lines.length;\n\t\t\t\trawLines[ generatedCodeLine ] = rawSegments = [];\n\t\t\t\tgeneratedCodeColumn = lastLine.length;\n\t\t\t} else {\n\t\t\t\tgeneratedCodeColumn += lastLine.length;\n\t\t\t}\n\n\t\t\tlines = chunk.original.split( '\\n' );\n\t\t\tlastLine = lines.pop();\n\n\t\t\tif ( lines.length ) {\n\t\t\t\tsourceCodeLine += lines.length;\n\t\t\t\tsourceCodeColumn = lastLine.length;\n\t\t\t} else {\n\t\t\t\tsourceCodeColumn += lastLine.length;\n\t\t\t}\n\t\t} else {\n\t\t\taddSegmentsUntil( chunk.end );\n\t\t}\n\n\t\toriginalCharIndex = chunk.end;\n\t}\n\n\taddSegmentsUntil( original.length );\n\n\toffsets.sourceIndex = offsets.sourceIndex || 0;\n\toffsets.sourceCodeLine = offsets.sourceCodeLine || 0;\n\toffsets.sourceCodeColumn = offsets.sourceCodeColumn || 0;\n\toffsets.sourceCodeName = offsets.sourceCodeName || 0;\n\n\tconst encoded = rawLines.map( segments => {\n\t\tlet generatedCodeColumn = 0;\n\n\t\treturn segments.map( segment => {\n\t\t\tlet arr = [\n\t\t\t\tsegment.generatedCodeColumn - generatedCodeColumn,\n\t\t\t\tsegment.sourceIndex - offsets.sourceIndex,\n\t\t\t\tsegment.sourceCodeLine - offsets.sourceCodeLine,\n\t\t\t\tsegment.sourceCodeColumn - offsets.sourceCodeColumn\n\t\t\t];\n\n\t\t\tgeneratedCodeColumn = segment.generatedCodeColumn;\n\t\t\toffsets.sourceIndex = segment.sourceIndex;\n\t\t\toffsets.sourceCodeLine = segment.sourceCodeLine;\n\t\t\toffsets.sourceCodeColumn = segment.sourceCodeColumn;\n\n\t\t\tif ( ~segment.sourceCodeName ) {\n\t\t\t\tarr.push( segment.sourceCodeName - offsets.sourceCodeName );\n\t\t\t\toffsets.sourceCodeName = segment.sourceCodeName;\n\t\t\t}\n\n\t\t\treturn encode( arr );\n\t\t}).join( ',' );\n\t}).join( ';' );\n\n\treturn encoded;\n}\n","export default function getRelativePath ( from, to ) {\n\tlet fromParts = from.split( /[\\/\\\\]/ );\n\tlet toParts = to.split( /[\\/\\\\]/ );\n\n\tfromParts.pop(); // get dirname\n\n\twhile ( fromParts[0] === toParts[0] ) {\n\t\tfromParts.shift();\n\t\ttoParts.shift();\n\t}\n\n\tif ( fromParts.length ) {\n\t\tlet i = fromParts.length;\n\t\twhile ( i-- ) fromParts[i] = '..';\n\t}\n\n\treturn fromParts.concat( toParts ).join( '/' );\n}\n","const toString = Object.prototype.toString;\n\nexport default function isObject ( thing ) {\n\treturn toString.call( thing ) === '[object Object]';\n}\n","export default function findIndex ( array, fn ) {\n\tfor ( let i = 0; i < array.length; i += 1 ) {\n\t\tif ( fn( array[i], i ) ) return i;\n\t}\n\n\treturn -1;\n}\n","import Chunk from './Chunk.js';\nimport SourceMap from './utils/SourceMap.js';\nimport guessIndent from './utils/guessIndent.js';\nimport encodeMappings from './utils/encodeMappings.js';\nimport getRelativePath from './utils/getRelativePath.js';\nimport isObject from './utils/isObject.js';\nimport findIndex from './utils/findIndex.js';\n\nlet warned = false;\n\nexport default function MagicString ( string, options = {} ) {\n\tconst chunk = new Chunk( 0, string.length, string );\n\n\tObject.defineProperties( this, {\n\t\toriginal: { writable: true, value: string },\n\t\toutro: { writable: true, value: '' },\n\t\tintro: { writable: true, value: '' },\n\t\tchunks: { writable: true, value: [ chunk ] },\n\t\tmoves: { writable: true, value: [] },\n\t\tfilename: { writable: true, value: options.filename },\n\t\tindentExclusionRanges: { writable: true, value: options.indentExclusionRanges },\n\t\tsourcemapLocations: { writable: true, value: {} },\n\t\tstoredNames: { writable: true, value: {} },\n\t\tindentStr: { writable: true, value: guessIndent( string ) }\n\t});\n}\n\nMagicString.prototype = {\n\taddSourcemapLocation ( char ) {\n\t\tthis.sourcemapLocations[ char ] = true;\n\t},\n\n\tappend ( content ) {\n\t\tif ( typeof content !== 'string' ) throw new TypeError( 'outro content must be a string' );\n\n\t\tthis.outro += content;\n\t\treturn this;\n\t},\n\n\tclone () {\n\t\tlet cloned = new MagicString( this.original, { filename: this.filename });\n\n\t\tcloned.chunks = this.chunks.map( chunk => chunk.clone() );\n\n\t\tif ( this.indentExclusionRanges ) {\n\t\t\tcloned.indentExclusionRanges = typeof this.indentExclusionRanges[0] === 'number' ?\n\t\t\t\t[ this.indentExclusionRanges[0], this.indentExclusionRanges[1] ] :\n\t\t\t\tthis.indentExclusionRanges.map( range => [ range.start, range.end ] );\n\t\t}\n\n\t\tObject.keys( this.sourcemapLocations ).forEach( loc => {\n\t\t\tcloned.sourcemapLocations[ loc ] = true;\n\t\t});\n\n\t\treturn cloned;\n\t},\n\n\tgenerateMap ( options ) {\n\t\toptions = options || {};\n\n\t\tconst names = Object.keys( this.storedNames );\n\n\t\treturn new SourceMap({\n\t\t\tfile: ( options.file ? options.file.split( /[\\/\\\\]/ ).pop() : null ),\n\t\t\tsources: [ options.source ? getRelativePath( options.file || '', options.source ) : null ],\n\t\t\tsourcesContent: options.includeContent ? [ this.original ] : [ null ],\n\t\t\tnames,\n\t\t\tmappings: this.getMappings( options.hires, 0, {}, names )\n\t\t});\n\t},\n\n\tgetIndentString () {\n\t\treturn this.indentStr === null ? '\\t' : this.indentStr;\n\t},\n\n\tgetMappings ( hires, sourceIndex, offsets, names ) {\n\t\treturn encodeMappings( this.original, this.intro, this.chunks, hires, this.sourcemapLocations, sourceIndex, offsets, names );\n\t},\n\n\tindent ( indentStr, options ) {\n\t\tconst pattern = /^[^\\r\\n]/gm;\n\n\t\tif ( isObject( indentStr ) ) {\n\t\t\toptions = indentStr;\n\t\t\tindentStr = undefined;\n\t\t}\n\n\t\tindentStr = indentStr !== undefined ? indentStr : ( this.indentStr || '\\t' );\n\n\t\tif ( indentStr === '' ) return this; // noop\n\n\t\toptions = options || {};\n\n\t\t// Process exclusion ranges\n\t\tlet isExcluded = {};\n\n\t\tif ( options.exclude ) {\n\t\t\tlet exclusions = typeof options.exclude[0] === 'number' ? [ options.exclude ] : options.exclude;\n\t\t\texclusions.forEach( exclusion => {\n\t\t\t\tfor ( let i = exclusion[0]; i < exclusion[1]; i += 1 ) {\n\t\t\t\t\tisExcluded[i] = true;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tlet shouldIndentNextCharacter = options.indentStart !== false;\n\t\tconst replacer = match => {\n\t\t\tif ( shouldIndentNextCharacter ) return `${indentStr}${match}`;\n\t\t\tshouldIndentNextCharacter = true;\n\t\t\treturn match;\n\t\t};\n\n\t\tthis.intro = this.intro.replace( pattern, replacer );\n\n\t\tlet chunkIndex;\n\t\tlet charIndex = 0;\n\n\t\tfor ( chunkIndex = 0; chunkIndex < this.chunks.length; chunkIndex += 1 ) { // can't cache this.chunks.length, it may change\n\t\t\tlet chunk = this.chunks[ chunkIndex ];\n\t\t\tconst end = chunk.end;\n\n\t\t\tif ( chunk.edited ) {\n\t\t\t\tif ( !isExcluded[ charIndex ] ) {\n\t\t\t\t\tchunk.content = chunk.content.replace( pattern, replacer );\n\n\t\t\t\t\tif ( chunk.content.length ) {\n\t\t\t\t\t\tshouldIndentNextCharacter = chunk.content[ chunk.content.length - 1 ] === '\\n';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcharIndex = chunk.start;\n\n\t\t\t\twhile ( charIndex < end ) {\n\t\t\t\t\tif ( !isExcluded[ charIndex ] ) {\n\t\t\t\t\t\tconst char = this.original[ charIndex ];\n\n\t\t\t\t\t\tif ( char === '\\n' ) {\n\t\t\t\t\t\t\tshouldIndentNextCharacter = true;\n\t\t\t\t\t\t} else if ( char !== '\\r' && shouldIndentNextCharacter ) {\n\t\t\t\t\t\t\tshouldIndentNextCharacter = false;\n\n\t\t\t\t\t\t\tconst indentation = new Chunk( charIndex, charIndex, '' ).edit( indentStr, false );\n\t\t\t\t\t\t\tconst remainder = chunk.split( charIndex );\n\n\t\t\t\t\t\t\tif ( charIndex === chunk.start ) {\n\t\t\t\t\t\t\t\tthis.chunks.splice( chunkIndex, 0, indentation );\n\t\t\t\t\t\t\t\tchunkIndex += 1;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthis.chunks.splice( chunkIndex + 1, 0, indentation, remainder );\n\t\t\t\t\t\t\t\tchunkIndex += 2;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tchunk = remainder;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tcharIndex += 1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcharIndex = chunk.end;\n\t\t}\n\n\t\tthis.outro = this.outro.replace( pattern, replacer );\n\n\t\treturn this;\n\t},\n\n\tinsert ( index, content ) {\n\t\tif ( typeof content !== 'string' ) throw new TypeError( 'inserted content must be a string' );\n\n\t\tthis._split( index );\n\n\t\tlet next = findIndex( this.chunks, chunk => chunk.original.length && chunk.start === index );\n\t\tif ( !~next ) next = this.chunks.length;\n\n\t\tconst newChunk = new Chunk( index, index, '' ).edit( content, false );\n\n\t\tthis.chunks.splice( next, 0, newChunk );\n\t\treturn this;\n\t},\n\n\t// get current location of character in original string\n\tlocate () {\n\t\tthrow new Error( 'magicString.locate is deprecated' );\n\t},\n\n\tlocateOrigin () {\n\t\tthrow new Error( 'magicString.locateOrigin is deprecated' );\n\t},\n\n\tmove ( start, end, index ) {\n\t\tif ( index >= start && index <= end ) throw new Error( 'Cannot move a selection inside itself' );\n\n\t\tthis._split( start );\n\t\tthis._split( end );\n\t\tthis._split( index );\n\n\t\tconst firstIndex = findIndex( this.chunks, chunk => chunk.start === start );\n\t\tlet lastIndex = findIndex( this.chunks, chunk => chunk.end === end );\n\n\t\tconst toMove = this.chunks.splice( firstIndex, lastIndex + 1 - firstIndex );\n\n\t\tlet insertionIndex = findIndex( this.chunks, chunk => chunk.original.length && chunk.start === index );\n\t\tif ( !~insertionIndex ) insertionIndex = this.chunks.length;\n\n\t\tthis.chunks.splice.apply( this.chunks, [ insertionIndex, 0 ].concat( toMove ) );\n\n\t\treturn this;\n\t},\n\n\toverwrite ( start, end, content, storeName ) {\n\t\tif ( typeof content !== 'string' ) {\n\t\t\tthrow new TypeError( 'replacement content must be a string' );\n\t\t}\n\n\t\tthis._split( start );\n\t\tthis._split( end );\n\n\t\tif ( storeName ) {\n\t\t\tconst original = this.original.slice( start, end );\n\t\t\tthis.storedNames[ original ] = true;\n\t\t}\n\n\t\tlet firstIndex = findIndex( this.chunks, chunk => chunk.start === start && chunk.original.length );\n\t\tif ( !~firstIndex ) firstIndex = this.chunks.length;\n\t\tlet lastIndex = findIndex( this.chunks, chunk => chunk.end === end );\n\n\t\tconst newChunk = new Chunk( start, end, this.original.slice( start, end ) ).edit( content, storeName );\n\n\t\tthis.chunks.splice( firstIndex, lastIndex + 1 - firstIndex, newChunk );\n\t\treturn this;\n\t},\n\n\tprepend ( content ) {\n\t\tif ( typeof content !== 'string' ) throw new TypeError( 'outro content must be a string' );\n\n\t\tthis.intro = content + this.intro;\n\t\treturn this;\n\t},\n\n\tremove ( start, end ) {\n\t\twhile ( start < 0 ) start += this.original.length;\n\t\twhile ( end < 0 ) end += this.original.length;\n\n\t\tif ( start === end ) return this;\n\n\t\tif ( start < 0 || end > this.original.length ) throw new Error( 'Character is out of bounds' );\n\t\tif ( start > end ) throw new Error( 'end must be greater than start' );\n\n\t\tlet firstIndex = findIndex( this.chunks, chunk => chunk.start <= start && chunk.end > start );\n\t\tlet chunk = this.chunks[ firstIndex ];\n\n\t\t// if the chunk contains `start`, split\n\t\tif ( chunk.start < start ) {\n\t\t\tif ( chunk.edited && chunk.content.length ) throw new Error( 'nope' );\n\t\t\tthis._split( start );\n\t\t\tfirstIndex += 1;\n\t\t}\n\n\t\tlet lastIndex = findIndex( this.chunks, chunk => chunk.start < end && chunk.end >= end );\n\t\tchunk = this.chunks[ lastIndex ];\n\n\t\t// if the chunk contains `end`, split\n\t\tif ( chunk.start < end ) {\n\t\t\tif ( chunk.edited && chunk.content.length ) throw new Error( 'nope' );\n\t\t\tthis._split( end );\n\t\t}\n\n\t\tlastIndex += 1;\n\n\t\tconst newChunk = new Chunk( start, end, this.original.slice( start, end ) ).edit( '', false );\n\t\tthis.chunks.splice( firstIndex, lastIndex - firstIndex, newChunk );\n\n\t\treturn this;\n\t},\n\n\treplace ( start, end, content ) {\n\t\tif ( !warned ) {\n\t\t\tconsole.warn( 'magicString.replace(...) is deprecated. Use magicString.overwrite(...) instead' );\n\t\t\twarned = true;\n\t\t}\n\n\t\treturn this.overwrite( start, end, content );\n\t},\n\n\tslice ( start, end = this.original.length ) {\n\t\twhile ( start < 0 ) start += this.original.length;\n\t\twhile ( end < 0 ) end += this.original.length;\n\n\t\tlet result = '';\n\n\t\tfor ( let i = 0; i < this.chunks.length; i += 1 ) {\n\t\t\tconst chunk = this.chunks[i];\n\n\t\t\tif ( chunk.end <= start ) continue;\n\t\t\tif ( chunk.start >= end ) break;\n\n\t\t\tif ( chunk.start < start || chunk.end > end ) {\n\t\t\t\tif ( chunk.edited ) throw new Error( `Cannot use replaced characters (${start}, ${end}) as slice anchors` );\n\n\t\t\t\tconst sliceStart = Math.max( start - chunk.start, 0 );\n\t\t\t\tconst sliceEnd = Math.min( chunk.content.length - ( chunk.end - end ), chunk.content.length );\n\n\t\t\t\tresult += chunk.content.slice( sliceStart, sliceEnd );\n\t\t\t} else {\n\t\t\t\tresult += chunk.content;\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t},\n\n\tsnip ( start, end ) {\n\t\tconst clone = this.clone();\n\t\tclone.remove( 0, start );\n\t\tclone.remove( end, clone.original.length );\n\n\t\treturn clone;\n\t},\n\n\t_split ( index ) {\n\t\t// TODO bisect\n\t\tfor ( let i = 0; i < this.chunks.length; i += 1 ) {\n\t\t\tconst chunk = this.chunks[i];\n\t\t\tif ( chunk.start === index || chunk.end === index ) return;\n\n\t\t\tif ( chunk.start < index && chunk.end > index ) {\n\t\t\t\tconst newChunk = chunk.split( index );\n\t\t\t\tthis.chunks.splice( i + 1, 0, newChunk );\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t},\n\n\ttoString () {\n\t\treturn this.intro + this.chunks.map( chunk => chunk.content ).join( '' ) + this.outro;\n\t},\n\n\ttrimLines () {\n\t\treturn this.trim('[\\\\r\\\\n]');\n\t},\n\n\t// TODO rewrite these methods, post-refactor\n\ttrim ( charType ) {\n\t\treturn this.trimStart( charType ).trimEnd( charType );\n\t},\n\n\ttrimEnd ( charType ) {\n\t\tconst rx = new RegExp( ( charType || '\\\\s' ) + '+$' );\n\n\t\tthis.outro = this.outro.replace( rx, '' );\n\t\tif ( this.outro.length ) return this;\n\n\t\tdo {\n\t\t\tlet lastChunk = this.chunks[ this.chunks.length - 1 ];\n\t\t\tif ( rx.test( lastChunk.content ) ) {\n\t\t\t\tlastChunk.edit( lastChunk.content.replace( rx, '' ) );\n\t\t\t}\n\n\t\t\tif ( lastChunk.content.length || this.chunks.length === 1 ) {\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tthis.chunks.pop();\n\t\t\t}\n\t\t} while ( true );\n\n\t\treturn this;\n\t},\n\n\ttrimStart ( charType ) {\n\t\tconst rx = new RegExp( '^' + ( charType || '\\\\s' ) + '+' );\n\n\t\tthis.intro = this.intro.replace( rx, '' );\n\t\tif ( this.intro.length ) return this;\n\n\t\tdo {\n\t\t\tlet firstChunk = this.chunks[0];\n\t\t\tif ( rx.test( firstChunk.content ) ) {\n\t\t\t\tfirstChunk.edit( firstChunk.content.replace( rx, '' ) );\n\t\t\t}\n\n\t\t\tif ( firstChunk.content.length || this.chunks.length === 1 ) {\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tthis.chunks.shift();\n\t\t\t}\n\t\t} while ( true );\n\n\t\treturn this;\n\t}\n};\n","export default Object.prototype.hasOwnProperty;","import MagicString from './MagicString.js';\nimport SourceMap from './utils/SourceMap.js';\nimport getRelativePath from './utils/getRelativePath.js';\nimport hasOwnProp from './utils/hasOwnProp.js';\nimport isObject from './utils/isObject.js';\n\nexport default function Bundle ( options = {} ) {\n\tthis.intro = options.intro || '';\n\tthis.separator = options.separator !== undefined ? options.separator : '\\n';\n\n\tthis.sources = [];\n\n\tthis.uniqueSources = [];\n\tthis.uniqueSourceIndexByFilename = {};\n}\n\nBundle.prototype = {\n\taddSource ( source ) {\n\t\tif ( source instanceof MagicString ) {\n\t\t\treturn this.addSource({\n\t\t\t\tcontent: source,\n\t\t\t\tfilename: source.filename,\n\t\t\t\tseparator: this.separator\n\t\t\t});\n\t\t}\n\n\t\tif ( !isObject( source ) || !source.content ) {\n\t\t\tthrow new Error( 'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`' );\n\t\t}\n\n\t\t[ 'filename', 'indentExclusionRanges', 'separator' ].forEach( option => {\n\t\t\tif ( !hasOwnProp.call( source, option ) ) source[ option ] = source.content[ option ];\n\t\t});\n\n\t\tif ( source.separator === undefined ) { // TODO there's a bunch of this sort of thing, needs cleaning up\n\t\t\tsource.separator = this.separator;\n\t\t}\n\n\t\tif ( source.filename ) {\n\t\t\tif ( !hasOwnProp.call( this.uniqueSourceIndexByFilename, source.filename ) ) {\n\t\t\t\tthis.uniqueSourceIndexByFilename[ source.filename ] = this.uniqueSources.length;\n\t\t\t\tthis.uniqueSources.push({ filename: source.filename, content: source.content.original });\n\t\t\t} else {\n\t\t\t\tconst uniqueSource = this.uniqueSources[ this.uniqueSourceIndexByFilename[ source.filename ] ];\n\t\t\t\tif ( source.content.original !== uniqueSource.content ) {\n\t\t\t\t\tthrow new Error( `Illegal source: same filename (${source.filename}), different contents` );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.sources.push( source );\n\t\treturn this;\n\t},\n\n\tappend ( str, options ) {\n\t\tthis.addSource({\n\t\t\tcontent: new MagicString( str ),\n\t\t\tseparator: ( options && options.separator ) || ''\n\t\t});\n\n\t\treturn this;\n\t},\n\n\tclone () {\n\t\tconst bundle = new Bundle({\n\t\t\tintro: this.intro,\n\t\t\tseparator: this.separator\n\t\t});\n\n\t\tthis.sources.forEach( source => {\n\t\t\tbundle.addSource({\n\t\t\t\tfilename: source.filename,\n\t\t\t\tcontent: source.content.clone(),\n\t\t\t\tseparator: source.separator\n\t\t\t});\n\t\t});\n\n\t\treturn bundle;\n\t},\n\n\tgenerateMap ( options ) {\n\t\tlet offsets = {};\n\n\t\tlet names = [];\n\t\tthis.sources.forEach( source => {\n\t\t\tObject.keys( source.content.storedNames ).forEach( name => {\n\t\t\t\tif ( !~names.indexOf( name ) ) names.push( name );\n\t\t\t});\n\t\t});\n\n\t\tconst encoded = (\n\t\t\tgetSemis( this.intro ) +\n\t\t\tthis.sources.map( ( source, i ) => {\n\t\t\t\tconst prefix = ( i > 0 ) ? ( getSemis( source.separator ) || ',' ) : '';\n\t\t\t\tlet mappings;\n\n\t\t\t\t// we don't bother encoding sources without a filename\n\t\t\t\tif ( !source.filename ) {\n\t\t\t\t\tmappings = getSemis( source.content.toString() );\n\t\t\t\t} else {\n\t\t\t\t\tconst sourceIndex = this.uniqueSourceIndexByFilename[ source.filename ];\n\t\t\t\t\tmappings = source.content.getMappings( options.hires, sourceIndex, offsets, names );\n\t\t\t\t}\n\n\t\t\t\treturn prefix + mappings;\n\t\t\t}).join( '' )\n\t\t);\n\n\t\treturn new SourceMap({\n\t\t\tfile: ( options.file ? options.file.split( /[\\/\\\\]/ ).pop() : null ),\n\t\t\tsources: this.uniqueSources.map( source => {\n\t\t\t\treturn options.file ? getRelativePath( options.file, source.filename ) : source.filename;\n\t\t\t}),\n\t\t\tsourcesContent: this.uniqueSources.map( source => {\n\t\t\t\treturn options.includeContent ? source.content : null;\n\t\t\t}),\n\t\t\tnames,\n\t\t\tmappings: encoded\n\t\t});\n\t},\n\n\tgetIndentString () {\n\t\tlet indentStringCounts = {};\n\n\t\tthis.sources.forEach( source => {\n\t\t\tconst indentStr = source.content.indentStr;\n\n\t\t\tif ( indentStr === null ) return;\n\n\t\t\tif ( !indentStringCounts[ indentStr ] ) indentStringCounts[ indentStr ] = 0;\n\t\t\tindentStringCounts[ indentStr ] += 1;\n\t\t});\n\n\t\treturn ( Object.keys( indentStringCounts ).sort( ( a, b ) => {\n\t\t\treturn indentStringCounts[a] - indentStringCounts[b];\n\t\t})[0] ) || '\\t';\n\t},\n\n\tindent ( indentStr ) {\n\t\tif ( !arguments.length ) {\n\t\t\tindentStr = this.getIndentString();\n\t\t}\n\n\t\tif ( indentStr === '' ) return this; // noop\n\n\t\tlet trailingNewline = !this.intro || this.intro.slice( -1 ) === '\\n';\n\n\t\tthis.sources.forEach( ( source, i ) => {\n\t\t\tconst separator = source.separator !== undefined ? source.separator : this.separator;\n\t\t\tconst indentStart = trailingNewline || ( i > 0 && /\\r?\\n$/.test( separator ) );\n\n\t\t\tsource.content.indent( indentStr, {\n\t\t\t\texclude: source.indentExclusionRanges,\n\t\t\t\tindentStart//: trailingNewline || /\\r?\\n$/.test( separator ) //true///\\r?\\n/.test( separator )\n\t\t\t});\n\n\t\t\t// TODO this is a very slow way to determine this\n\t\t\ttrailingNewline = source.content.toString().slice( 0, -1 ) === '\\n';\n\t\t});\n\n\t\tif ( this.intro ) {\n\t\t\tthis.intro = indentStr + this.intro.replace( /^[^\\n]/gm, ( match, index ) => {\n\t\t\t\treturn index > 0 ? indentStr + match : match;\n\t\t\t});\n\t\t}\n\n\t\treturn this;\n\t},\n\n\tprepend ( str ) {\n\t\tthis.intro = str + this.intro;\n\t\treturn this;\n\t},\n\n\ttoString () {\n\t\tconst body = this.sources.map( ( source, i ) => {\n\t\t\tconst separator = source.separator !== undefined ? source.separator : this.separator;\n\t\t\tlet str = ( i > 0 ? separator : '' ) + source.content.toString();\n\n\t\t\treturn str;\n\t\t}).join( '' );\n\n\t\treturn this.intro + body;\n\t},\n\n\ttrimLines () {\n\t\treturn this.trim('[\\\\r\\\\n]');\n\t},\n\n\ttrim ( charType ) {\n\t\treturn this.trimStart( charType ).trimEnd( charType );\n\t},\n\n\ttrimStart ( charType ) {\n\t\tconst rx = new RegExp( '^' + ( charType || '\\\\s' ) + '+' );\n\t\tthis.intro = this.intro.replace( rx, '' );\n\n\t\tif ( !this.intro ) {\n\t\t\tlet source;\n\t\t\tlet i = 0;\n\n\t\t\tdo {\n\t\t\t\tsource = this.sources[i];\n\n\t\t\t\tif ( !source ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tsource.content.trimStart( charType );\n\t\t\t\ti += 1;\n\t\t\t} while ( source.content.toString() === '' ); // TODO faster way to determine non-empty source?\n\t\t}\n\n\t\treturn this;\n\t},\n\n\ttrimEnd ( charType ) {\n\t\tconst rx = new RegExp( ( charType || '\\\\s' ) + '+$' );\n\n\t\tlet source;\n\t\tlet i = this.sources.length - 1;\n\n\t\tdo {\n\t\t\tsource = this.sources[i];\n\n\t\t\tif ( !source ) {\n\t\t\t\tthis.intro = this.intro.replace( rx, '' );\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tsource.content.trimEnd( charType );\n\t\t\ti -= 1;\n\t\t} while ( source.content.toString() === '' ); // TODO faster way to determine non-empty source?\n\n\t\treturn this;\n\t}\n};\n\nfunction getSemis ( str ) {\n\treturn new Array( str.split( '\\n' ).length ).join( ';' );\n}\n","import MagicString from './MagicString.js';\nimport Bundle from './Bundle.js';\n\nMagicString.Bundle = Bundle;\n\nexport default MagicString;\n"],"names":[],"mappings":";;;;;;;;;;;;;MAWM;EACJ;;;;;;;;KAQG;;;;;;;;;MASC;;;EAGJ;;EAEA;EACA;;;;EAIA;;;;+CAI6C,uDAAqD,IAAE,aAAa,CAAC,GAAA,KAAE;;;;;;;;;;;;;AC3CtH;;;;;;SAMS,WAAA,GAAG,GAAI,SAAA,sCAAsC,GAAA;;;;;;;;;;;;;;;;;;SCO7C;;;;MAIH;;;;;;CChBL;;CAEA,2BAA6B,WAAA,IAAI,GAAI,SAAA,mBAAmB,GAAA;CACxD,2BAA6B,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;IACA;;;;;;KAMC,kBAAoB,MAAI;;;;;;;;;;oCAUO,WAAA,MAAM,GAAI;;;2CAGH,WAAA,MAAM,GAAI;;;GAGlD,OAAA;;;;;gBAKa;EACd;;wBAEsB,WAAA,MAAM,GAAI;GAC/B;;;;;;;;mDAQgD,WAAE,IAAI,GAAM;;;;;OAKxD;EACL,kBAAA;;EAAA;;;;;;EAMA;;wBAEsB,WAAE,SAAS,GAAM;GACtC,oEAAsE,MAAI;GAC1E;;;;IAIC,aAAA;;;;;;;;4DAQwD,WAAE,YAAY,GAAM;;;;;;;;QAQxE;;;;;SAKC;EACP,kBAAA;;EAAA,6BAA+B,WAAE,SAAS,GAAM;GAC/C,oEAAsE,MAAI;GAC1E;;;;;;;;UAQO;;;;KAIL;;;;UAIK;EACR;;;;GAIC;GACA;;;;;;;;;;;;;;;;;QAiBK;EACN;;EAEA;EACA;;;;;;;;;;;;;;;;;;;;;;;;"}
{"version":3,"file":"magic-string.es6.js","sources":["../src/Chunk.js","../src/utils/btoa.js","../src/utils/SourceMap.js","../src/utils/guessIndent.js","../src/utils/encodeMappings.js","../src/utils/getRelativePath.js","../src/utils/isObject.js","../src/utils/findIndex.js","../src/MagicString.js","../src/utils/hasOwnProp.js","../src/Bundle.js","../src/index.js"],"sourcesContent":["export default function Chunk ( start, end, content ) {\n\tthis.start = start;\n\tthis.end = end;\n\tthis.original = content;\n\n\tthis.content = content;\n\tthis.storeName = false;\n\tthis.edited = false;\n}\n\nChunk.prototype = {\n\tclone () {\n\t\tconst chunk = new Chunk( this.start, this.end, this.original );\n\t\tchunk.content = this.content;\n\t\tchunk.storeName = this.storeName;\n\t\tchunk.edited = this.edited;\n\n\t\treturn chunk;\n\t},\n\n\tedit ( content, storeName ) {\n\t\tthis.content = content;\n\t\tthis.storeName = storeName;\n\n\t\tthis.edited = true;\n\n\t\treturn this;\n\t},\n\n\tsplit ( index ) {\n\t\tif ( index === this.start ) return this;\n\n\t\tconst sliceIndex = index - this.start;\n\n\t\tconst originalBefore = this.original.slice( 0, sliceIndex );\n\t\tconst originalAfter = this.original.slice( sliceIndex );\n\n\t\tthis.original = originalBefore;\n\n\t\tconst newChunk = new Chunk( index, this.end, originalAfter );\n\t\tthis.end = index;\n\n\t\tif ( this.edited ) {\n\t\t\tif ( this.content.length ) throw new Error( `Cannot split a chunk that has already been edited (\"${this.original}\")` );\n\n\t\t\t// zero-length edited chunks are a special case (overlapping replacements)\n\t\t\tnewChunk.edit( '', false );\n\t\t\tthis.content = '';\n\t\t} else {\n\t\t\tthis.content = originalBefore;\n\t\t}\n\n\t\treturn newChunk;\n\t}\n};\n","let _btoa;\n\nif ( typeof window !== 'undefined' && typeof window.btoa === 'function' ) {\n\t_btoa = window.btoa;\n} else if ( typeof Buffer === 'function' ) {\n\t/* global Buffer */\n\t_btoa = str => new Buffer( str ).toString( 'base64' );\n} else {\n\tthrow new Error( 'Unsupported environment: `window.btoa` or `Buffer` should be supported.' );\n}\n\nexport default _btoa;\n","import btoa from './btoa.js';\n\nexport default function SourceMap ( properties ) {\n\tthis.version = 3;\n\n\tthis.file = properties.file;\n\tthis.sources = properties.sources;\n\tthis.sourcesContent = properties.sourcesContent;\n\tthis.names = properties.names;\n\tthis.mappings = properties.mappings;\n}\n\nSourceMap.prototype = {\n\ttoString () {\n\t\treturn JSON.stringify( this );\n\t},\n\n\ttoUrl () {\n\t\treturn 'data:application/json;charset=utf-8;base64,' + btoa( this.toString() );\n\t}\n};\n","export default function guessIndent ( code ) {\n\tconst lines = code.split( '\\n' );\n\n\tconst tabbed = lines.filter( line => /^\\t+/.test( line ) );\n\tconst spaced = lines.filter( line => /^ {2,}/.test( line ) );\n\n\tif ( tabbed.length === 0 && spaced.length === 0 ) {\n\t\treturn null;\n\t}\n\n\t// More lines tabbed than spaced? Assume tabs, and\n\t// default to tabs in the case of a tie (or nothing\n\t// to go on)\n\tif ( tabbed.length >= spaced.length ) {\n\t\treturn '\\t';\n\t}\n\n\t// Otherwise, we need to guess the multiple\n\tconst min = spaced.reduce( ( previous, current ) => {\n\t\tconst numSpaces = /^ +/.exec( current )[0].length;\n\t\treturn Math.min( numSpaces, previous );\n\t}, Infinity );\n\n\treturn new Array( min + 1 ).join( ' ' );\n}\n","import { encode } from 'vlq';\n\nfunction getLocator ( source ) {\n\tlet originalLines = source.split( '\\n' );\n\n\treturn function locate ( index ) {\n\t\tconst len = originalLines.length;\n\n\t\tlet lineStart = 0;\n\n\t\tfor ( let i = 0; i < len; i += 1 ) {\n\t\t\tconst line = originalLines[i];\n\t\t\tconst lineEnd = lineStart + line.length + 1; // +1 for newline\n\n\t\t\tif ( lineEnd > index ) return { line: i, column: index - lineStart };\n\n\t\t\tlineStart = lineEnd;\n\t\t}\n\t};\n}\n\nexport default function encodeMappings ( original, intro, chunks, hires, sourcemapLocations, sourceIndex, offsets, names ) {\n\tlet rawLines = [];\n\n\tlet generatedCodeLine = intro.split( '\\n' ).length - 1;\n\tlet rawSegments = rawLines[ generatedCodeLine ] = [];\n\n\tlet generatedCodeColumn = 0;\n\n\tconst locate = getLocator( original );\n\n\tfunction addUneditedChunk ( chunk ) {\n\t\tlet originalCharIndex = chunk.start;\n\t\tlet first = true;\n\n\t\tlet { line, column } = locate( originalCharIndex );\n\n\t\twhile ( originalCharIndex < chunk.end ) {\n\t\t\tif ( hires || first || sourcemapLocations[ originalCharIndex ] ) {\n\t\t\t\trawSegments.push({\n\t\t\t\t\tgeneratedCodeLine,\n\t\t\t\t\tgeneratedCodeColumn,\n\t\t\t\t\tsourceCodeLine: line,\n\t\t\t\t\tsourceCodeColumn: column,\n\t\t\t\t\tsourceCodeName: -1,\n\t\t\t\t\tsourceIndex\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif ( original[ originalCharIndex ] === '\\n' ) {\n\t\t\t\tline += 1;\n\t\t\t\tcolumn = 0;\n\t\t\t\tgeneratedCodeLine += 1;\n\t\t\t\trawLines[ generatedCodeLine ] = rawSegments = [];\n\t\t\t\tgeneratedCodeColumn = 0;\n\t\t\t} else {\n\t\t\t\tcolumn += 1;\n\t\t\t\tgeneratedCodeColumn += 1;\n\t\t\t}\n\n\t\t\toriginalCharIndex += 1;\n\t\t\tfirst = false;\n\t\t}\n\t}\n\n\tfor ( let i = 0; i < chunks.length; i += 1 ) {\n\t\tconst chunk = chunks[i];\n\t\tlet { line, column } = locate( chunk.start );\n\n\t\tif ( chunk.edited ) {\n\t\t\tif ( i > 0 || chunk.content.length ) {\n\t\t\t\trawSegments.push({\n\t\t\t\t\tgeneratedCodeLine,\n\t\t\t\t\tgeneratedCodeColumn,\n\t\t\t\t\tsourceCodeLine: line,\n\t\t\t\t\tsourceCodeColumn: column,\n\t\t\t\t\tsourceCodeName: chunk.storeName ? names.indexOf( chunk.original ) : -1,\n\t\t\t\t\tsourceIndex\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tlet lines = chunk.content.split( '\\n' );\n\t\t\tlet lastLine = lines.pop();\n\n\t\t\tif ( lines.length ) {\n\t\t\t\tgeneratedCodeLine += lines.length;\n\t\t\t\trawLines[ generatedCodeLine ] = rawSegments = [];\n\t\t\t\tgeneratedCodeColumn = lastLine.length;\n\t\t\t} else {\n\t\t\t\tgeneratedCodeColumn += lastLine.length;\n\t\t\t}\n\n\t\t\tlines = chunk.original.split( '\\n' );\n\t\t\tlastLine = lines.pop();\n\n\t\t\tif ( lines.length ) {\n\t\t\t\tline += lines.length;\n\t\t\t\tcolumn = lastLine.length;\n\t\t\t} else {\n\t\t\t\tcolumn += lastLine.length;\n\t\t\t}\n\t\t} else {\n\t\t\taddUneditedChunk( chunk );\n\t\t}\n\t}\n\n\toffsets.sourceIndex = offsets.sourceIndex || 0;\n\toffsets.sourceCodeLine = offsets.sourceCodeLine || 0;\n\toffsets.sourceCodeColumn = offsets.sourceCodeColumn || 0;\n\toffsets.sourceCodeName = offsets.sourceCodeName || 0;\n\n\tconst encoded = rawLines.map( segments => {\n\t\tlet generatedCodeColumn = 0;\n\n\t\treturn segments.map( segment => {\n\t\t\tlet arr = [\n\t\t\t\tsegment.generatedCodeColumn - generatedCodeColumn,\n\t\t\t\tsegment.sourceIndex - offsets.sourceIndex,\n\t\t\t\tsegment.sourceCodeLine - offsets.sourceCodeLine,\n\t\t\t\tsegment.sourceCodeColumn - offsets.sourceCodeColumn\n\t\t\t];\n\n\t\t\tgeneratedCodeColumn = segment.generatedCodeColumn;\n\t\t\toffsets.sourceIndex = segment.sourceIndex;\n\t\t\toffsets.sourceCodeLine = segment.sourceCodeLine;\n\t\t\toffsets.sourceCodeColumn = segment.sourceCodeColumn;\n\n\t\t\tif ( ~segment.sourceCodeName ) {\n\t\t\t\tarr.push( segment.sourceCodeName - offsets.sourceCodeName );\n\t\t\t\toffsets.sourceCodeName = segment.sourceCodeName;\n\t\t\t}\n\n\t\t\treturn encode( arr );\n\t\t}).join( ',' );\n\t}).join( ';' );\n\n\treturn encoded;\n}\n","export default function getRelativePath ( from, to ) {\n\tlet fromParts = from.split( /[\\/\\\\]/ );\n\tlet toParts = to.split( /[\\/\\\\]/ );\n\n\tfromParts.pop(); // get dirname\n\n\twhile ( fromParts[0] === toParts[0] ) {\n\t\tfromParts.shift();\n\t\ttoParts.shift();\n\t}\n\n\tif ( fromParts.length ) {\n\t\tlet i = fromParts.length;\n\t\twhile ( i-- ) fromParts[i] = '..';\n\t}\n\n\treturn fromParts.concat( toParts ).join( '/' );\n}\n","const toString = Object.prototype.toString;\n\nexport default function isObject ( thing ) {\n\treturn toString.call( thing ) === '[object Object]';\n}\n","export default function findIndex ( array, fn ) {\n\tfor ( let i = 0; i < array.length; i += 1 ) {\n\t\tif ( fn( array[i], i ) ) return i;\n\t}\n\n\treturn -1;\n}\n","import Chunk from './Chunk.js';\nimport SourceMap from './utils/SourceMap.js';\nimport guessIndent from './utils/guessIndent.js';\nimport encodeMappings from './utils/encodeMappings.js';\nimport getRelativePath from './utils/getRelativePath.js';\nimport isObject from './utils/isObject.js';\nimport findIndex from './utils/findIndex.js';\n\nlet warned = false;\n\nexport default function MagicString ( string, options = {} ) {\n\tconst chunk = new Chunk( 0, string.length, string );\n\n\tObject.defineProperties( this, {\n\t\toriginal: { writable: true, value: string },\n\t\toutro: { writable: true, value: '' },\n\t\tintro: { writable: true, value: '' },\n\t\tchunks: { writable: true, value: [ chunk ] },\n\t\tmoves: { writable: true, value: [] },\n\t\tfilename: { writable: true, value: options.filename },\n\t\tindentExclusionRanges: { writable: true, value: options.indentExclusionRanges },\n\t\tsourcemapLocations: { writable: true, value: {} },\n\t\tstoredNames: { writable: true, value: {} },\n\t\tindentStr: { writable: true, value: guessIndent( string ) }\n\t});\n}\n\nMagicString.prototype = {\n\taddSourcemapLocation ( char ) {\n\t\tthis.sourcemapLocations[ char ] = true;\n\t},\n\n\tappend ( content ) {\n\t\tif ( typeof content !== 'string' ) throw new TypeError( 'outro content must be a string' );\n\n\t\tthis.outro += content;\n\t\treturn this;\n\t},\n\n\tclone () {\n\t\tlet cloned = new MagicString( this.original, { filename: this.filename });\n\n\t\tcloned.chunks = this.chunks.map( chunk => chunk.clone() );\n\n\t\tif ( this.indentExclusionRanges ) {\n\t\t\tcloned.indentExclusionRanges = typeof this.indentExclusionRanges[0] === 'number' ?\n\t\t\t\t[ this.indentExclusionRanges[0], this.indentExclusionRanges[1] ] :\n\t\t\t\tthis.indentExclusionRanges.map( range => [ range.start, range.end ] );\n\t\t}\n\n\t\tObject.keys( this.sourcemapLocations ).forEach( loc => {\n\t\t\tcloned.sourcemapLocations[ loc ] = true;\n\t\t});\n\n\t\treturn cloned;\n\t},\n\n\tgenerateMap ( options ) {\n\t\toptions = options || {};\n\n\t\tconst names = Object.keys( this.storedNames );\n\n\t\treturn new SourceMap({\n\t\t\tfile: ( options.file ? options.file.split( /[\\/\\\\]/ ).pop() : null ),\n\t\t\tsources: [ options.source ? getRelativePath( options.file || '', options.source ) : null ],\n\t\t\tsourcesContent: options.includeContent ? [ this.original ] : [ null ],\n\t\t\tnames,\n\t\t\tmappings: this.getMappings( options.hires, 0, {}, names )\n\t\t});\n\t},\n\n\tgetIndentString () {\n\t\treturn this.indentStr === null ? '\\t' : this.indentStr;\n\t},\n\n\tgetMappings ( hires, sourceIndex, offsets, names ) {\n\t\treturn encodeMappings( this.original, this.intro, this.chunks, hires, this.sourcemapLocations, sourceIndex, offsets, names );\n\t},\n\n\tindent ( indentStr, options ) {\n\t\tconst pattern = /^[^\\r\\n]/gm;\n\n\t\tif ( isObject( indentStr ) ) {\n\t\t\toptions = indentStr;\n\t\t\tindentStr = undefined;\n\t\t}\n\n\t\tindentStr = indentStr !== undefined ? indentStr : ( this.indentStr || '\\t' );\n\n\t\tif ( indentStr === '' ) return this; // noop\n\n\t\toptions = options || {};\n\n\t\t// Process exclusion ranges\n\t\tlet isExcluded = {};\n\n\t\tif ( options.exclude ) {\n\t\t\tlet exclusions = typeof options.exclude[0] === 'number' ? [ options.exclude ] : options.exclude;\n\t\t\texclusions.forEach( exclusion => {\n\t\t\t\tfor ( let i = exclusion[0]; i < exclusion[1]; i += 1 ) {\n\t\t\t\t\tisExcluded[i] = true;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tlet shouldIndentNextCharacter = options.indentStart !== false;\n\t\tconst replacer = match => {\n\t\t\tif ( shouldIndentNextCharacter ) return `${indentStr}${match}`;\n\t\t\tshouldIndentNextCharacter = true;\n\t\t\treturn match;\n\t\t};\n\n\t\tthis.intro = this.intro.replace( pattern, replacer );\n\n\t\tlet chunkIndex;\n\t\tlet charIndex = 0;\n\n\t\tfor ( chunkIndex = 0; chunkIndex < this.chunks.length; chunkIndex += 1 ) { // can't cache this.chunks.length, it may change\n\t\t\tlet chunk = this.chunks[ chunkIndex ];\n\t\t\tconst end = chunk.end;\n\n\t\t\tif ( chunk.edited ) {\n\t\t\t\tif ( !isExcluded[ charIndex ] ) {\n\t\t\t\t\tchunk.content = chunk.content.replace( pattern, replacer );\n\n\t\t\t\t\tif ( chunk.content.length ) {\n\t\t\t\t\t\tshouldIndentNextCharacter = chunk.content[ chunk.content.length - 1 ] === '\\n';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcharIndex = chunk.start;\n\n\t\t\t\twhile ( charIndex < end ) {\n\t\t\t\t\tif ( !isExcluded[ charIndex ] ) {\n\t\t\t\t\t\tconst char = this.original[ charIndex ];\n\n\t\t\t\t\t\tif ( char === '\\n' ) {\n\t\t\t\t\t\t\tshouldIndentNextCharacter = true;\n\t\t\t\t\t\t} else if ( char !== '\\r' && shouldIndentNextCharacter ) {\n\t\t\t\t\t\t\tshouldIndentNextCharacter = false;\n\n\t\t\t\t\t\t\tconst indentation = new Chunk( charIndex, charIndex, '' ).edit( indentStr, false );\n\t\t\t\t\t\t\tconst remainder = chunk.split( charIndex );\n\n\t\t\t\t\t\t\tif ( charIndex === chunk.start ) {\n\t\t\t\t\t\t\t\tthis.chunks.splice( chunkIndex, 0, indentation );\n\t\t\t\t\t\t\t\tchunkIndex += 1;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthis.chunks.splice( chunkIndex + 1, 0, indentation, remainder );\n\t\t\t\t\t\t\t\tchunkIndex += 2;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tchunk = remainder;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tcharIndex += 1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcharIndex = chunk.end;\n\t\t}\n\n\t\tthis.outro = this.outro.replace( pattern, replacer );\n\n\t\treturn this;\n\t},\n\n\tinsert ( index, content ) {\n\t\tif ( typeof content !== 'string' ) throw new TypeError( 'inserted content must be a string' );\n\n\t\tthis._split( index );\n\n\t\tlet next = findIndex( this.chunks, chunk => chunk.original.length && chunk.start === index );\n\t\tif ( !~next ) next = this.chunks.length;\n\n\t\tconst newChunk = new Chunk( index, index, '' ).edit( content, false );\n\n\t\tthis.chunks.splice( next, 0, newChunk );\n\t\treturn this;\n\t},\n\n\t// get current location of character in original string\n\tlocate () {\n\t\tthrow new Error( 'magicString.locate is deprecated' );\n\t},\n\n\tlocateOrigin () {\n\t\tthrow new Error( 'magicString.locateOrigin is deprecated' );\n\t},\n\n\tmove ( start, end, index ) {\n\t\tif ( index >= start && index <= end ) throw new Error( 'Cannot move a selection inside itself' );\n\n\t\tthis._split( start );\n\t\tthis._split( end );\n\t\tthis._split( index );\n\n\t\tconst firstIndex = findIndex( this.chunks, chunk => chunk.start === start );\n\t\tlet lastIndex = findIndex( this.chunks, chunk => chunk.end === end );\n\n\t\tconst toMove = this.chunks.splice( firstIndex, lastIndex + 1 - firstIndex );\n\n\t\tlet insertionIndex = findIndex( this.chunks, chunk => chunk.original.length && chunk.start === index );\n\t\tif ( !~insertionIndex ) insertionIndex = this.chunks.length;\n\n\t\tthis.chunks.splice.apply( this.chunks, [ insertionIndex, 0 ].concat( toMove ) );\n\n\t\treturn this;\n\t},\n\n\toverwrite ( start, end, content, storeName ) {\n\t\tif ( typeof content !== 'string' ) {\n\t\t\tthrow new TypeError( 'replacement content must be a string' );\n\t\t}\n\n\t\tthis._split( start );\n\t\tthis._split( end );\n\n\t\tif ( storeName ) {\n\t\t\tconst original = this.original.slice( start, end );\n\t\t\tthis.storedNames[ original ] = true;\n\t\t}\n\n\t\tlet firstIndex = findIndex( this.chunks, chunk => chunk.start === start && chunk.original.length );\n\t\tif ( !~firstIndex ) firstIndex = this.chunks.length;\n\t\tlet lastIndex = findIndex( this.chunks, chunk => chunk.end === end );\n\n\t\tconst newChunk = new Chunk( start, end, this.original.slice( start, end ) ).edit( content, storeName );\n\n\t\tthis.chunks.splice( firstIndex, lastIndex + 1 - firstIndex, newChunk );\n\t\treturn this;\n\t},\n\n\tprepend ( content ) {\n\t\tif ( typeof content !== 'string' ) throw new TypeError( 'outro content must be a string' );\n\n\t\tthis.intro = content + this.intro;\n\t\treturn this;\n\t},\n\n\tremove ( start, end ) {\n\t\twhile ( start < 0 ) start += this.original.length;\n\t\twhile ( end < 0 ) end += this.original.length;\n\n\t\tif ( start === end ) return this;\n\n\t\tif ( start < 0 || end > this.original.length ) throw new Error( 'Character is out of bounds' );\n\t\tif ( start > end ) throw new Error( 'end must be greater than start' );\n\n\t\tlet firstIndex = findIndex( this.chunks, chunk => chunk.start <= start && chunk.end > start );\n\t\tlet chunk = this.chunks[ firstIndex ];\n\n\t\t// if the chunk contains `start`, split\n\t\tif ( chunk.start < start ) {\n\t\t\tif ( chunk.edited && chunk.content.length ) throw new Error( 'nope' );\n\t\t\tthis._split( start );\n\t\t\tfirstIndex += 1;\n\t\t}\n\n\t\tlet lastIndex = findIndex( this.chunks, chunk => chunk.start < end && chunk.end >= end );\n\t\tchunk = this.chunks[ lastIndex ];\n\n\t\t// if the chunk contains `end`, split\n\t\tif ( chunk.start < end ) {\n\t\t\tif ( chunk.edited && chunk.content.length ) throw new Error( 'nope' );\n\t\t\tthis._split( end );\n\t\t}\n\n\t\tlastIndex += 1;\n\n\t\tconst newChunk = new Chunk( start, end, this.original.slice( start, end ) ).edit( '', false );\n\t\tthis.chunks.splice( firstIndex, lastIndex - firstIndex, newChunk );\n\n\t\treturn this;\n\t},\n\n\treplace ( start, end, content ) {\n\t\tif ( !warned ) {\n\t\t\tconsole.warn( 'magicString.replace(...) is deprecated. Use magicString.overwrite(...) instead' );\n\t\t\twarned = true;\n\t\t}\n\n\t\treturn this.overwrite( start, end, content );\n\t},\n\n\tslice ( start, end = this.original.length ) {\n\t\twhile ( start < 0 ) start += this.original.length;\n\t\twhile ( end < 0 ) end += this.original.length;\n\n\t\tlet result = '';\n\n\t\tfor ( let i = 0; i < this.chunks.length; i += 1 ) {\n\t\t\tconst chunk = this.chunks[i];\n\n\t\t\tif ( chunk.end <= start ) continue;\n\t\t\tif ( chunk.start >= end ) break;\n\n\t\t\tif ( chunk.start < start || chunk.end > end ) {\n\t\t\t\tif ( chunk.edited ) throw new Error( `Cannot use replaced characters (${start}, ${end}) as slice anchors` );\n\n\t\t\t\tconst sliceStart = Math.max( start - chunk.start, 0 );\n\t\t\t\tconst sliceEnd = Math.min( chunk.content.length - ( chunk.end - end ), chunk.content.length );\n\n\t\t\t\tresult += chunk.content.slice( sliceStart, sliceEnd );\n\t\t\t} else {\n\t\t\t\tresult += chunk.content;\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t},\n\n\tsnip ( start, end ) {\n\t\tconst clone = this.clone();\n\t\tclone.remove( 0, start );\n\t\tclone.remove( end, clone.original.length );\n\n\t\treturn clone;\n\t},\n\n\t_split ( index ) {\n\t\t// TODO bisect\n\t\tfor ( let i = 0; i < this.chunks.length; i += 1 ) {\n\t\t\tconst chunk = this.chunks[i];\n\t\t\tif ( chunk.start === index || chunk.end === index ) return;\n\n\t\t\tif ( chunk.start < index && chunk.end > index ) {\n\t\t\t\tconst newChunk = chunk.split( index );\n\t\t\t\tthis.chunks.splice( i + 1, 0, newChunk );\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t},\n\n\ttoString () {\n\t\treturn this.intro + this.chunks.map( chunk => chunk.content ).join( '' ) + this.outro;\n\t},\n\n\ttrimLines () {\n\t\treturn this.trim('[\\\\r\\\\n]');\n\t},\n\n\t// TODO rewrite these methods, post-refactor\n\ttrim ( charType ) {\n\t\treturn this.trimStart( charType ).trimEnd( charType );\n\t},\n\n\ttrimEnd ( charType ) {\n\t\tconst rx = new RegExp( ( charType || '\\\\s' ) + '+$' );\n\n\t\tthis.outro = this.outro.replace( rx, '' );\n\t\tif ( this.outro.length ) return this;\n\n\t\tdo {\n\t\t\tlet lastChunk = this.chunks[ this.chunks.length - 1 ];\n\t\t\tif ( rx.test( lastChunk.content ) ) {\n\t\t\t\tlastChunk.edit( lastChunk.content.replace( rx, '' ) );\n\t\t\t}\n\n\t\t\tif ( lastChunk.content.length || this.chunks.length === 1 ) {\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tthis.chunks.pop();\n\t\t\t}\n\t\t} while ( true );\n\n\t\treturn this;\n\t},\n\n\ttrimStart ( charType ) {\n\t\tconst rx = new RegExp( '^' + ( charType || '\\\\s' ) + '+' );\n\n\t\tthis.intro = this.intro.replace( rx, '' );\n\t\tif ( this.intro.length ) return this;\n\n\t\tdo {\n\t\t\tlet firstChunk = this.chunks[0];\n\t\t\tif ( rx.test( firstChunk.content ) ) {\n\t\t\t\tfirstChunk.edit( firstChunk.content.replace( rx, '' ) );\n\t\t\t}\n\n\t\t\tif ( firstChunk.content.length || this.chunks.length === 1 ) {\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tthis.chunks.shift();\n\t\t\t}\n\t\t} while ( true );\n\n\t\treturn this;\n\t}\n};\n","export default Object.prototype.hasOwnProperty;","import MagicString from './MagicString.js';\nimport SourceMap from './utils/SourceMap.js';\nimport getRelativePath from './utils/getRelativePath.js';\nimport hasOwnProp from './utils/hasOwnProp.js';\nimport isObject from './utils/isObject.js';\n\nexport default function Bundle ( options = {} ) {\n\tthis.intro = options.intro || '';\n\tthis.separator = options.separator !== undefined ? options.separator : '\\n';\n\n\tthis.sources = [];\n\n\tthis.uniqueSources = [];\n\tthis.uniqueSourceIndexByFilename = {};\n}\n\nBundle.prototype = {\n\taddSource ( source ) {\n\t\tif ( source instanceof MagicString ) {\n\t\t\treturn this.addSource({\n\t\t\t\tcontent: source,\n\t\t\t\tfilename: source.filename,\n\t\t\t\tseparator: this.separator\n\t\t\t});\n\t\t}\n\n\t\tif ( !isObject( source ) || !source.content ) {\n\t\t\tthrow new Error( 'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`' );\n\t\t}\n\n\t\t[ 'filename', 'indentExclusionRanges', 'separator' ].forEach( option => {\n\t\t\tif ( !hasOwnProp.call( source, option ) ) source[ option ] = source.content[ option ];\n\t\t});\n\n\t\tif ( source.separator === undefined ) { // TODO there's a bunch of this sort of thing, needs cleaning up\n\t\t\tsource.separator = this.separator;\n\t\t}\n\n\t\tif ( source.filename ) {\n\t\t\tif ( !hasOwnProp.call( this.uniqueSourceIndexByFilename, source.filename ) ) {\n\t\t\t\tthis.uniqueSourceIndexByFilename[ source.filename ] = this.uniqueSources.length;\n\t\t\t\tthis.uniqueSources.push({ filename: source.filename, content: source.content.original });\n\t\t\t} else {\n\t\t\t\tconst uniqueSource = this.uniqueSources[ this.uniqueSourceIndexByFilename[ source.filename ] ];\n\t\t\t\tif ( source.content.original !== uniqueSource.content ) {\n\t\t\t\t\tthrow new Error( `Illegal source: same filename (${source.filename}), different contents` );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.sources.push( source );\n\t\treturn this;\n\t},\n\n\tappend ( str, options ) {\n\t\tthis.addSource({\n\t\t\tcontent: new MagicString( str ),\n\t\t\tseparator: ( options && options.separator ) || ''\n\t\t});\n\n\t\treturn this;\n\t},\n\n\tclone () {\n\t\tconst bundle = new Bundle({\n\t\t\tintro: this.intro,\n\t\t\tseparator: this.separator\n\t\t});\n\n\t\tthis.sources.forEach( source => {\n\t\t\tbundle.addSource({\n\t\t\t\tfilename: source.filename,\n\t\t\t\tcontent: source.content.clone(),\n\t\t\t\tseparator: source.separator\n\t\t\t});\n\t\t});\n\n\t\treturn bundle;\n\t},\n\n\tgenerateMap ( options ) {\n\t\tlet offsets = {};\n\n\t\tlet names = [];\n\t\tthis.sources.forEach( source => {\n\t\t\tObject.keys( source.content.storedNames ).forEach( name => {\n\t\t\t\tif ( !~names.indexOf( name ) ) names.push( name );\n\t\t\t});\n\t\t});\n\n\t\tconst encoded = (\n\t\t\tgetSemis( this.intro ) +\n\t\t\tthis.sources.map( ( source, i ) => {\n\t\t\t\tconst prefix = ( i > 0 ) ? ( getSemis( source.separator ) || ',' ) : '';\n\t\t\t\tlet mappings;\n\n\t\t\t\t// we don't bother encoding sources without a filename\n\t\t\t\tif ( !source.filename ) {\n\t\t\t\t\tmappings = getSemis( source.content.toString() );\n\t\t\t\t} else {\n\t\t\t\t\tconst sourceIndex = this.uniqueSourceIndexByFilename[ source.filename ];\n\t\t\t\t\tmappings = source.content.getMappings( options.hires, sourceIndex, offsets, names );\n\t\t\t\t}\n\n\t\t\t\treturn prefix + mappings;\n\t\t\t}).join( '' )\n\t\t);\n\n\t\treturn new SourceMap({\n\t\t\tfile: ( options.file ? options.file.split( /[\\/\\\\]/ ).pop() : null ),\n\t\t\tsources: this.uniqueSources.map( source => {\n\t\t\t\treturn options.file ? getRelativePath( options.file, source.filename ) : source.filename;\n\t\t\t}),\n\t\t\tsourcesContent: this.uniqueSources.map( source => {\n\t\t\t\treturn options.includeContent ? source.content : null;\n\t\t\t}),\n\t\t\tnames,\n\t\t\tmappings: encoded\n\t\t});\n\t},\n\n\tgetIndentString () {\n\t\tlet indentStringCounts = {};\n\n\t\tthis.sources.forEach( source => {\n\t\t\tconst indentStr = source.content.indentStr;\n\n\t\t\tif ( indentStr === null ) return;\n\n\t\t\tif ( !indentStringCounts[ indentStr ] ) indentStringCounts[ indentStr ] = 0;\n\t\t\tindentStringCounts[ indentStr ] += 1;\n\t\t});\n\n\t\treturn ( Object.keys( indentStringCounts ).sort( ( a, b ) => {\n\t\t\treturn indentStringCounts[a] - indentStringCounts[b];\n\t\t})[0] ) || '\\t';\n\t},\n\n\tindent ( indentStr ) {\n\t\tif ( !arguments.length ) {\n\t\t\tindentStr = this.getIndentString();\n\t\t}\n\n\t\tif ( indentStr === '' ) return this; // noop\n\n\t\tlet trailingNewline = !this.intro || this.intro.slice( -1 ) === '\\n';\n\n\t\tthis.sources.forEach( ( source, i ) => {\n\t\t\tconst separator = source.separator !== undefined ? source.separator : this.separator;\n\t\t\tconst indentStart = trailingNewline || ( i > 0 && /\\r?\\n$/.test( separator ) );\n\n\t\t\tsource.content.indent( indentStr, {\n\t\t\t\texclude: source.indentExclusionRanges,\n\t\t\t\tindentStart//: trailingNewline || /\\r?\\n$/.test( separator ) //true///\\r?\\n/.test( separator )\n\t\t\t});\n\n\t\t\t// TODO this is a very slow way to determine this\n\t\t\ttrailingNewline = source.content.toString().slice( 0, -1 ) === '\\n';\n\t\t});\n\n\t\tif ( this.intro ) {\n\t\t\tthis.intro = indentStr + this.intro.replace( /^[^\\n]/gm, ( match, index ) => {\n\t\t\t\treturn index > 0 ? indentStr + match : match;\n\t\t\t});\n\t\t}\n\n\t\treturn this;\n\t},\n\n\tprepend ( str ) {\n\t\tthis.intro = str + this.intro;\n\t\treturn this;\n\t},\n\n\ttoString () {\n\t\tconst body = this.sources.map( ( source, i ) => {\n\t\t\tconst separator = source.separator !== undefined ? source.separator : this.separator;\n\t\t\tlet str = ( i > 0 ? separator : '' ) + source.content.toString();\n\n\t\t\treturn str;\n\t\t}).join( '' );\n\n\t\treturn this.intro + body;\n\t},\n\n\ttrimLines () {\n\t\treturn this.trim('[\\\\r\\\\n]');\n\t},\n\n\ttrim ( charType ) {\n\t\treturn this.trimStart( charType ).trimEnd( charType );\n\t},\n\n\ttrimStart ( charType ) {\n\t\tconst rx = new RegExp( '^' + ( charType || '\\\\s' ) + '+' );\n\t\tthis.intro = this.intro.replace( rx, '' );\n\n\t\tif ( !this.intro ) {\n\t\t\tlet source;\n\t\t\tlet i = 0;\n\n\t\t\tdo {\n\t\t\t\tsource = this.sources[i];\n\n\t\t\t\tif ( !source ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tsource.content.trimStart( charType );\n\t\t\t\ti += 1;\n\t\t\t} while ( source.content.toString() === '' ); // TODO faster way to determine non-empty source?\n\t\t}\n\n\t\treturn this;\n\t},\n\n\ttrimEnd ( charType ) {\n\t\tconst rx = new RegExp( ( charType || '\\\\s' ) + '+$' );\n\n\t\tlet source;\n\t\tlet i = this.sources.length - 1;\n\n\t\tdo {\n\t\t\tsource = this.sources[i];\n\n\t\t\tif ( !source ) {\n\t\t\t\tthis.intro = this.intro.replace( rx, '' );\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tsource.content.trimEnd( charType );\n\t\t\ti -= 1;\n\t\t} while ( source.content.toString() === '' ); // TODO faster way to determine non-empty source?\n\n\t\treturn this;\n\t}\n};\n\nfunction getSemis ( str ) {\n\treturn new Array( str.split( '\\n' ).length ).join( ';' );\n}\n","import MagicString from './MagicString.js';\nimport Bundle from './Bundle.js';\n\nMagicString.Bundle = Bundle;\n\nexport default MagicString;\n"],"names":["this"],"mappings":";;;;;;;;;;;;;MAWM;EACJ;;;;;;;;KAQG;;;;;;;;;MASC;;;EAGJ;;EAEA;EACA;;;;EAIA;;;;+CAI6C,CAAA,uDAAqD,IAAE,aAAa,SAAG,CAAC;;;;;;;;;;;;;AC3CvH;;;;;;SAMS,WAAA,GAAG,GAAI,SAAA,sCAAsC,GAAA;;;;;;;;;;;;;;;;;;SCO7C;;;;MAIH;;;;;;CChBL;;CAEA,2BAA6B,WAAA,IAAI,GAAI,SAAA,mBAAmB,GAAA;CACxD,2BAA6B,WAAA,IAAI,GAAI,SAAA,qBAAqB,GAAA;;;;;;;;;;;;;;CAc1D,yBAA2B,WAAE,iBAAiB,GAAM;EACnD;;;;;;;;CChBD;;;EAGC;;EAEA;;QAEM;GACL;GACA;;;;;;;;;;CAUF;;CAEA;CACA;;CAEA;;CAEA;;;EAGC;EACA;;EAEA,IAAI,MAAA,8CAA8C,mBAAQ;;;;;KAKvD,mBAAA;KACA,qBAAA;;;;KAIA,aAAA;;;;;;;;;;;;;;;;;;;;OAoBE;EACL;EACA,IAAI,MAAA,wCAAwC,mBAAQ;;;;;KAKjD,mBAAA;KACA,qBAAA;;;;KAIA,aAAA;;;;GAIF;GACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BF,4BAA8B,WAAA,QAAQ,GAAI;EACzC;;uBAEqB,WAAA,OAAO,GAAI;GAC/B;;;;;;;;;;;;;;;;;;;;;;;;;CClHF;CACA;;;;;;;;;;EAUC;;;;;;;ACZF;;;;;;;OCCO;;;;;;;ACOP;;sCAEqD;CACpD,iCAAA;;CAAA;;;;;;;;;;;;;;;;;qBAiBoB;;;;OAId;;;;;;;MAOD;EACJ;;mCAEiC,WAAA,KAAK,GAAI,SAAA,aAAa,GAAA;;;;;oCAKrB,WAAA,KAAK,GAAI,SAAA,0BAA0B,GAAA;;;kDAGr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AAa,GAAA;;;UAGnD;;;;;KAKL;;;;QAIG;EACN;;;;;;GAMC;;;;;;;;;;;;;;;UAeO;EACR;;;;;;GAMC;;;;;;;;;;;;;;;;;;yBEnXqC;CACvC,iCAAA;;CAAA;;;;;;;;;;UAUS;;;;;;;;;;;;;gEAasD,WAAA,MAAM,GAAI;;;;;;;;;;;;;IAatE;;sBAEkB,CAAA,iCAAgC,IAAE,eAAe,2BAAsB,CAAC;;;;;;;;;OASvF;;;;;;;;;MASD;EACJ;;;;;wBAKsB,WAAA,MAAM,GAAI;;;;;;;;;;;YAWtB;EACV,kBAAA;;EAAA;;EAEA;wBACsB,WAAA,MAAM,GAAI;sDACoB,WAAA,IAAI,GAAI;;;;;EAK5D;;qBAEmB,WAAE,SAAS,GAAM;IAClC;IACA;;;;;;KAMC,kBAAoBA,MAAI;;;;;;;;;;oCAUO,WAAA,MAAM,GAAI;;;2CAGH,WAAA,MAAM,GAAI;;;GAGlD,OAAA;;;;;gBAKa;EACd;;wBAEsB,WAAA,MAAM,GAAI;GAC/B;;;;;;;;mDAQgD,WAAE,IAAI,GAAM;;;;;OAKxD;EACL,kBAAA;;EAAA;;;;;;EAMA;;wBAEsB,WAAE,SAAS,GAAM;GACtC,oEAAsEA,MAAI;GAC1E;;;;IAIC,aAAA;;;;;;;;4DAQwD,WAAE,YAAY,GAAM;;;;;;;;QAQxE;;;;;SAKC;EACP,kBAAA;;EAAA,6BAA+B,WAAE,SAAS,GAAM;GAC/C,oEAAsEA,MAAI;GAC1E;;;;;;;;UAQO;;;;KAIL;;;;UAIK;EACR;;;;GAIC;GACA;;;;;;;;;;;;;;;;;QAiBK;EACN;;EAEA;EACA;;;;;;;;;;;;;;;;;;;;;;;;"}

@@ -50,3 +50,3 @@ (function (global, factory) {

if ( this.edited ) {
if ( this.content.length ) throw new Error( "Cannot split a chunk that has already been edited (\"" + (this.original) + "\")" );
if ( this.content.length ) throw new Error( ("Cannot split a chunk that has already been edited (\"" + (this.original) + "\")") );

@@ -169,2 +169,21 @@ // zero-length edited chunks are a special case (overlapping replacements)

function getLocator ( source ) {
var originalLines = source.split( '\n' );
return function locate ( index ) {
var len = originalLines.length;
var lineStart = 0;
for ( var i = 0; i < len; i += 1 ) {
var line = originalLines[i];
var lineEnd = lineStart + line.length + 1; // +1 for newline
if ( lineEnd > index ) return { line: i, column: index - lineStart };
lineStart = lineEnd;
}
};
}
function encodeMappings ( original, intro, chunks, hires, sourcemapLocations, sourceIndex, offsets, names ) {

@@ -176,12 +195,13 @@ var rawLines = [];

var originalCharIndex = 0;
var generatedCodeColumn = 0;
var sourceCodeLine = 0;
var sourceCodeColumn = 0;
function addSegmentsUntil ( end ) {
var locate = getLocator( original );
function addUneditedChunk ( chunk ) {
var originalCharIndex = chunk.start;
var first = true;
while ( originalCharIndex < end ) {
var ref = locate( originalCharIndex ), line = ref.line, column = ref.column;
while ( originalCharIndex < chunk.end ) {
if ( hires || first || sourcemapLocations[ originalCharIndex ] ) {

@@ -191,4 +211,4 @@ rawSegments.push({

generatedCodeColumn: generatedCodeColumn,
sourceCodeLine: sourceCodeLine,
sourceCodeColumn: sourceCodeColumn,
sourceCodeLine: line,
sourceCodeColumn: column,
sourceCodeName: -1,

@@ -200,4 +220,4 @@ sourceIndex: sourceIndex

if ( original[ originalCharIndex ] === '\n' ) {
sourceCodeLine += 1;
sourceCodeColumn = 0;
line += 1;
column = 0;
generatedCodeLine += 1;

@@ -207,3 +227,3 @@ rawLines[ generatedCodeLine ] = rawSegments = [];

} else {
sourceCodeColumn += 1;
column += 1;
generatedCodeColumn += 1;

@@ -219,2 +239,3 @@ }

var chunk = chunks[i];
var ref = locate( chunk.start ), line = ref.line, column = ref.column;

@@ -226,4 +247,4 @@ if ( chunk.edited ) {

generatedCodeColumn: generatedCodeColumn,
sourceCodeLine: sourceCodeLine,
sourceCodeColumn: sourceCodeColumn,
sourceCodeLine: line,
sourceCodeColumn: column,
sourceCodeName: chunk.storeName ? names.indexOf( chunk.original ) : -1,

@@ -249,16 +270,12 @@ sourceIndex: sourceIndex

if ( lines.length ) {
sourceCodeLine += lines.length;
sourceCodeColumn = lastLine.length;
line += lines.length;
column = lastLine.length;
} else {
sourceCodeColumn += lastLine.length;
column += lastLine.length;
}
} else {
addSegmentsUntil( chunk.end );
addUneditedChunk( chunk );
}
originalCharIndex = chunk.end;
}
addSegmentsUntil( original.length );
offsets.sourceIndex = offsets.sourceIndex || 0;

@@ -431,3 +448,3 @@ offsets.sourceCodeLine = offsets.sourceCodeLine || 0;

var replacer = function ( match ) {
if ( shouldIndentNextCharacter ) return "" + indentStr + "" + match + "";
if ( shouldIndentNextCharacter ) return ("" + indentStr + "" + match);
shouldIndentNextCharacter = true;

@@ -626,3 +643,3 @@ return match;

if ( chunk.start < start || chunk.end > end ) {
if ( chunk.edited ) throw new Error( "Cannot use replaced characters (" + start + ", " + end + ") as slice anchors" );
if ( chunk.edited ) throw new Error( ("Cannot use replaced characters (" + start + ", " + end + ") as slice anchors") );

@@ -764,3 +781,3 @@ var sliceStart = Math.max( start - chunk.start, 0 );

if ( source.content.original !== uniqueSource.content ) {
throw new Error( "Illegal source: same filename (" + (source.filename) + "), different contents" );
throw new Error( ("Illegal source: same filename (" + (source.filename) + "), different contents") );
}

@@ -767,0 +784,0 @@ }

@@ -1,1 +0,1 @@

{"version":3,"file":"magic-string.umd.js","sources":["../src/Chunk.js","../src/utils/btoa.js","../src/utils/SourceMap.js","../src/utils/guessIndent.js","../node_modules/vlq/src/vlq.js","../src/utils/encodeMappings.js","../src/utils/getRelativePath.js","../src/utils/isObject.js","../src/utils/findIndex.js","../src/MagicString.js","../src/utils/hasOwnProp.js","../src/Bundle.js","../src/index.js"],"sourcesContent":["export default function Chunk ( start, end, content ) {\n\tthis.start = start;\n\tthis.end = end;\n\tthis.original = content;\n\n\tthis.content = content;\n\tthis.storeName = false;\n\tthis.edited = false;\n}\n\nChunk.prototype = {\n\tclone () {\n\t\tconst chunk = new Chunk( this.start, this.end, this.original );\n\t\tchunk.content = this.content;\n\t\tchunk.storeName = this.storeName;\n\t\tchunk.edited = this.edited;\n\n\t\treturn chunk;\n\t},\n\n\tedit ( content, storeName ) {\n\t\tthis.content = content;\n\t\tthis.storeName = storeName;\n\n\t\tthis.edited = true;\n\n\t\treturn this;\n\t},\n\n\tsplit ( index ) {\n\t\tif ( index === this.start ) return this;\n\n\t\tconst sliceIndex = index - this.start;\n\n\t\tconst originalBefore = this.original.slice( 0, sliceIndex );\n\t\tconst originalAfter = this.original.slice( sliceIndex );\n\n\t\tthis.original = originalBefore;\n\n\t\tconst newChunk = new Chunk( index, this.end, originalAfter );\n\t\tthis.end = index;\n\n\t\tif ( this.edited ) {\n\t\t\tif ( this.content.length ) throw new Error( `Cannot split a chunk that has already been edited (\"${this.original}\")` );\n\n\t\t\t// zero-length edited chunks are a special case (overlapping replacements)\n\t\t\tnewChunk.edit( '', false );\n\t\t\tthis.content = '';\n\t\t} else {\n\t\t\tthis.content = originalBefore;\n\t\t}\n\n\t\treturn newChunk;\n\t}\n};\n","let _btoa;\n\nif ( typeof window !== 'undefined' && typeof window.btoa === 'function' ) {\n\t_btoa = window.btoa;\n} else if ( typeof Buffer === 'function' ) {\n\t/* global Buffer */\n\t_btoa = str => new Buffer( str ).toString( 'base64' );\n} else {\n\tthrow new Error( 'Unsupported environment: `window.btoa` or `Buffer` should be supported.' );\n}\n\nexport default _btoa;\n","import btoa from './btoa.js';\n\nexport default function SourceMap ( properties ) {\n\tthis.version = 3;\n\n\tthis.file = properties.file;\n\tthis.sources = properties.sources;\n\tthis.sourcesContent = properties.sourcesContent;\n\tthis.names = properties.names;\n\tthis.mappings = properties.mappings;\n}\n\nSourceMap.prototype = {\n\ttoString () {\n\t\treturn JSON.stringify( this );\n\t},\n\n\ttoUrl () {\n\t\treturn 'data:application/json;charset=utf-8;base64,' + btoa( this.toString() );\n\t}\n};\n","export default function guessIndent ( code ) {\n\tconst lines = code.split( '\\n' );\n\n\tconst tabbed = lines.filter( line => /^\\t+/.test( line ) );\n\tconst spaced = lines.filter( line => /^ {2,}/.test( line ) );\n\n\tif ( tabbed.length === 0 && spaced.length === 0 ) {\n\t\treturn null;\n\t}\n\n\t// More lines tabbed than spaced? Assume tabs, and\n\t// default to tabs in the case of a tie (or nothing\n\t// to go on)\n\tif ( tabbed.length >= spaced.length ) {\n\t\treturn '\\t';\n\t}\n\n\t// Otherwise, we need to guess the multiple\n\tconst min = spaced.reduce( ( previous, current ) => {\n\t\tconst numSpaces = /^ +/.exec( current )[0].length;\n\t\treturn Math.min( numSpaces, previous );\n\t}, Infinity );\n\n\treturn new Array( min + 1 ).join( ' ' );\n}\n","var charToInteger = {};\nvar integerToChar = {};\n\n'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split( '' ).forEach( function ( char, i ) {\n\tcharToInteger[ char ] = i;\n\tintegerToChar[ i ] = char;\n});\n\nexport function decode ( string ) {\n\tvar result = [],\n\t\tlen = string.length,\n\t\ti,\n\t\thasContinuationBit,\n\t\tshift = 0,\n\t\tvalue = 0,\n\t\tinteger,\n\t\tshouldNegate;\n\n\tfor ( i = 0; i < len; i += 1 ) {\n\t\tinteger = charToInteger[ string[i] ];\n\n\t\tif ( integer === undefined ) {\n\t\t\tthrow new Error( 'Invalid character (' + string[i] + ')' );\n\t\t}\n\n\t\thasContinuationBit = integer & 32;\n\n\t\tinteger &= 31;\n\t\tvalue += integer << shift;\n\n\t\tif ( hasContinuationBit ) {\n\t\t\tshift += 5;\n\t\t} else {\n\t\t\tshouldNegate = value & 1;\n\t\t\tvalue >>= 1;\n\n\t\t\tresult.push( shouldNegate ? -value : value );\n\n\t\t\t// reset\n\t\t\tvalue = shift = 0;\n\t\t}\n\t}\n\n\treturn result;\n}\n\nexport function encode ( value ) {\n\tvar result, i;\n\n\tif ( typeof value === 'number' ) {\n\t\tresult = encodeInteger( value );\n\t} else {\n\t\tresult = '';\n\t\tfor ( i = 0; i < value.length; i += 1 ) {\n\t\t\tresult += encodeInteger( value[i] );\n\t\t}\n\t}\n\n\treturn result;\n}\n\nfunction encodeInteger ( num ) {\n\tvar result = '', clamped;\n\n\tif ( num < 0 ) {\n\t\tnum = ( -num << 1 ) | 1;\n\t} else {\n\t\tnum <<= 1;\n\t}\n\n\tdo {\n\t\tclamped = num & 31;\n\t\tnum >>= 5;\n\n\t\tif ( num > 0 ) {\n\t\t\tclamped |= 32;\n\t\t}\n\n\t\tresult += integerToChar[ clamped ];\n\t} while ( num > 0 );\n\n\treturn result;\n}\n","import { encode } from 'vlq';\n\nexport default function encodeMappings ( original, intro, chunks, hires, sourcemapLocations, sourceIndex, offsets, names ) {\n\tlet rawLines = [];\n\n\tlet generatedCodeLine = intro.split( '\\n' ).length - 1;\n\tlet rawSegments = rawLines[ generatedCodeLine ] = [];\n\n\tlet originalCharIndex = 0;\n\n\tlet generatedCodeColumn = 0;\n\tlet sourceCodeLine = 0;\n\tlet sourceCodeColumn = 0;\n\n\tfunction addSegmentsUntil ( end ) {\n\t\tlet first = true;\n\n\t\twhile ( originalCharIndex < end ) {\n\t\t\tif ( hires || first || sourcemapLocations[ originalCharIndex ] ) {\n\t\t\t\trawSegments.push({\n\t\t\t\t\tgeneratedCodeLine,\n\t\t\t\t\tgeneratedCodeColumn,\n\t\t\t\t\tsourceCodeLine,\n\t\t\t\t\tsourceCodeColumn,\n\t\t\t\t\tsourceCodeName: -1,\n\t\t\t\t\tsourceIndex\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif ( original[ originalCharIndex ] === '\\n' ) {\n\t\t\t\tsourceCodeLine += 1;\n\t\t\t\tsourceCodeColumn = 0;\n\t\t\t\tgeneratedCodeLine += 1;\n\t\t\t\trawLines[ generatedCodeLine ] = rawSegments = [];\n\t\t\t\tgeneratedCodeColumn = 0;\n\t\t\t} else {\n\t\t\t\tsourceCodeColumn += 1;\n\t\t\t\tgeneratedCodeColumn += 1;\n\t\t\t}\n\n\t\t\toriginalCharIndex += 1;\n\t\t\tfirst = false;\n\t\t}\n\t}\n\n\tfor ( let i = 0; i < chunks.length; i += 1 ) {\n\t\tconst chunk = chunks[i];\n\n\t\tif ( chunk.edited ) {\n\t\t\tif ( i > 0 || chunk.content.length ) {\n\t\t\t\trawSegments.push({\n\t\t\t\t\tgeneratedCodeLine,\n\t\t\t\t\tgeneratedCodeColumn,\n\t\t\t\t\tsourceCodeLine,\n\t\t\t\t\tsourceCodeColumn,\n\t\t\t\t\tsourceCodeName: chunk.storeName ? names.indexOf( chunk.original ) : -1,\n\t\t\t\t\tsourceIndex\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tlet lines = chunk.content.split( '\\n' );\n\t\t\tlet lastLine = lines.pop();\n\n\t\t\tif ( lines.length ) {\n\t\t\t\tgeneratedCodeLine += lines.length;\n\t\t\t\trawLines[ generatedCodeLine ] = rawSegments = [];\n\t\t\t\tgeneratedCodeColumn = lastLine.length;\n\t\t\t} else {\n\t\t\t\tgeneratedCodeColumn += lastLine.length;\n\t\t\t}\n\n\t\t\tlines = chunk.original.split( '\\n' );\n\t\t\tlastLine = lines.pop();\n\n\t\t\tif ( lines.length ) {\n\t\t\t\tsourceCodeLine += lines.length;\n\t\t\t\tsourceCodeColumn = lastLine.length;\n\t\t\t} else {\n\t\t\t\tsourceCodeColumn += lastLine.length;\n\t\t\t}\n\t\t} else {\n\t\t\taddSegmentsUntil( chunk.end );\n\t\t}\n\n\t\toriginalCharIndex = chunk.end;\n\t}\n\n\taddSegmentsUntil( original.length );\n\n\toffsets.sourceIndex = offsets.sourceIndex || 0;\n\toffsets.sourceCodeLine = offsets.sourceCodeLine || 0;\n\toffsets.sourceCodeColumn = offsets.sourceCodeColumn || 0;\n\toffsets.sourceCodeName = offsets.sourceCodeName || 0;\n\n\tconst encoded = rawLines.map( segments => {\n\t\tlet generatedCodeColumn = 0;\n\n\t\treturn segments.map( segment => {\n\t\t\tlet arr = [\n\t\t\t\tsegment.generatedCodeColumn - generatedCodeColumn,\n\t\t\t\tsegment.sourceIndex - offsets.sourceIndex,\n\t\t\t\tsegment.sourceCodeLine - offsets.sourceCodeLine,\n\t\t\t\tsegment.sourceCodeColumn - offsets.sourceCodeColumn\n\t\t\t];\n\n\t\t\tgeneratedCodeColumn = segment.generatedCodeColumn;\n\t\t\toffsets.sourceIndex = segment.sourceIndex;\n\t\t\toffsets.sourceCodeLine = segment.sourceCodeLine;\n\t\t\toffsets.sourceCodeColumn = segment.sourceCodeColumn;\n\n\t\t\tif ( ~segment.sourceCodeName ) {\n\t\t\t\tarr.push( segment.sourceCodeName - offsets.sourceCodeName );\n\t\t\t\toffsets.sourceCodeName = segment.sourceCodeName;\n\t\t\t}\n\n\t\t\treturn encode( arr );\n\t\t}).join( ',' );\n\t}).join( ';' );\n\n\treturn encoded;\n}\n","export default function getRelativePath ( from, to ) {\n\tlet fromParts = from.split( /[\\/\\\\]/ );\n\tlet toParts = to.split( /[\\/\\\\]/ );\n\n\tfromParts.pop(); // get dirname\n\n\twhile ( fromParts[0] === toParts[0] ) {\n\t\tfromParts.shift();\n\t\ttoParts.shift();\n\t}\n\n\tif ( fromParts.length ) {\n\t\tlet i = fromParts.length;\n\t\twhile ( i-- ) fromParts[i] = '..';\n\t}\n\n\treturn fromParts.concat( toParts ).join( '/' );\n}\n","const toString = Object.prototype.toString;\n\nexport default function isObject ( thing ) {\n\treturn toString.call( thing ) === '[object Object]';\n}\n","export default function findIndex ( array, fn ) {\n\tfor ( let i = 0; i < array.length; i += 1 ) {\n\t\tif ( fn( array[i], i ) ) return i;\n\t}\n\n\treturn -1;\n}\n","import Chunk from './Chunk.js';\nimport SourceMap from './utils/SourceMap.js';\nimport guessIndent from './utils/guessIndent.js';\nimport encodeMappings from './utils/encodeMappings.js';\nimport getRelativePath from './utils/getRelativePath.js';\nimport isObject from './utils/isObject.js';\nimport findIndex from './utils/findIndex.js';\n\nlet warned = false;\n\nexport default function MagicString ( string, options = {} ) {\n\tconst chunk = new Chunk( 0, string.length, string );\n\n\tObject.defineProperties( this, {\n\t\toriginal: { writable: true, value: string },\n\t\toutro: { writable: true, value: '' },\n\t\tintro: { writable: true, value: '' },\n\t\tchunks: { writable: true, value: [ chunk ] },\n\t\tmoves: { writable: true, value: [] },\n\t\tfilename: { writable: true, value: options.filename },\n\t\tindentExclusionRanges: { writable: true, value: options.indentExclusionRanges },\n\t\tsourcemapLocations: { writable: true, value: {} },\n\t\tstoredNames: { writable: true, value: {} },\n\t\tindentStr: { writable: true, value: guessIndent( string ) }\n\t});\n}\n\nMagicString.prototype = {\n\taddSourcemapLocation ( char ) {\n\t\tthis.sourcemapLocations[ char ] = true;\n\t},\n\n\tappend ( content ) {\n\t\tif ( typeof content !== 'string' ) throw new TypeError( 'outro content must be a string' );\n\n\t\tthis.outro += content;\n\t\treturn this;\n\t},\n\n\tclone () {\n\t\tlet cloned = new MagicString( this.original, { filename: this.filename });\n\n\t\tcloned.chunks = this.chunks.map( chunk => chunk.clone() );\n\n\t\tif ( this.indentExclusionRanges ) {\n\t\t\tcloned.indentExclusionRanges = typeof this.indentExclusionRanges[0] === 'number' ?\n\t\t\t\t[ this.indentExclusionRanges[0], this.indentExclusionRanges[1] ] :\n\t\t\t\tthis.indentExclusionRanges.map( range => [ range.start, range.end ] );\n\t\t}\n\n\t\tObject.keys( this.sourcemapLocations ).forEach( loc => {\n\t\t\tcloned.sourcemapLocations[ loc ] = true;\n\t\t});\n\n\t\treturn cloned;\n\t},\n\n\tgenerateMap ( options ) {\n\t\toptions = options || {};\n\n\t\tconst names = Object.keys( this.storedNames );\n\n\t\treturn new SourceMap({\n\t\t\tfile: ( options.file ? options.file.split( /[\\/\\\\]/ ).pop() : null ),\n\t\t\tsources: [ options.source ? getRelativePath( options.file || '', options.source ) : null ],\n\t\t\tsourcesContent: options.includeContent ? [ this.original ] : [ null ],\n\t\t\tnames,\n\t\t\tmappings: this.getMappings( options.hires, 0, {}, names )\n\t\t});\n\t},\n\n\tgetIndentString () {\n\t\treturn this.indentStr === null ? '\\t' : this.indentStr;\n\t},\n\n\tgetMappings ( hires, sourceIndex, offsets, names ) {\n\t\treturn encodeMappings( this.original, this.intro, this.chunks, hires, this.sourcemapLocations, sourceIndex, offsets, names );\n\t},\n\n\tindent ( indentStr, options ) {\n\t\tconst pattern = /^[^\\r\\n]/gm;\n\n\t\tif ( isObject( indentStr ) ) {\n\t\t\toptions = indentStr;\n\t\t\tindentStr = undefined;\n\t\t}\n\n\t\tindentStr = indentStr !== undefined ? indentStr : ( this.indentStr || '\\t' );\n\n\t\tif ( indentStr === '' ) return this; // noop\n\n\t\toptions = options || {};\n\n\t\t// Process exclusion ranges\n\t\tlet isExcluded = {};\n\n\t\tif ( options.exclude ) {\n\t\t\tlet exclusions = typeof options.exclude[0] === 'number' ? [ options.exclude ] : options.exclude;\n\t\t\texclusions.forEach( exclusion => {\n\t\t\t\tfor ( let i = exclusion[0]; i < exclusion[1]; i += 1 ) {\n\t\t\t\t\tisExcluded[i] = true;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tlet shouldIndentNextCharacter = options.indentStart !== false;\n\t\tconst replacer = match => {\n\t\t\tif ( shouldIndentNextCharacter ) return `${indentStr}${match}`;\n\t\t\tshouldIndentNextCharacter = true;\n\t\t\treturn match;\n\t\t};\n\n\t\tthis.intro = this.intro.replace( pattern, replacer );\n\n\t\tlet chunkIndex;\n\t\tlet charIndex = 0;\n\n\t\tfor ( chunkIndex = 0; chunkIndex < this.chunks.length; chunkIndex += 1 ) { // can't cache this.chunks.length, it may change\n\t\t\tlet chunk = this.chunks[ chunkIndex ];\n\t\t\tconst end = chunk.end;\n\n\t\t\tif ( chunk.edited ) {\n\t\t\t\tif ( !isExcluded[ charIndex ] ) {\n\t\t\t\t\tchunk.content = chunk.content.replace( pattern, replacer );\n\n\t\t\t\t\tif ( chunk.content.length ) {\n\t\t\t\t\t\tshouldIndentNextCharacter = chunk.content[ chunk.content.length - 1 ] === '\\n';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcharIndex = chunk.start;\n\n\t\t\t\twhile ( charIndex < end ) {\n\t\t\t\t\tif ( !isExcluded[ charIndex ] ) {\n\t\t\t\t\t\tconst char = this.original[ charIndex ];\n\n\t\t\t\t\t\tif ( char === '\\n' ) {\n\t\t\t\t\t\t\tshouldIndentNextCharacter = true;\n\t\t\t\t\t\t} else if ( char !== '\\r' && shouldIndentNextCharacter ) {\n\t\t\t\t\t\t\tshouldIndentNextCharacter = false;\n\n\t\t\t\t\t\t\tconst indentation = new Chunk( charIndex, charIndex, '' ).edit( indentStr, false );\n\t\t\t\t\t\t\tconst remainder = chunk.split( charIndex );\n\n\t\t\t\t\t\t\tif ( charIndex === chunk.start ) {\n\t\t\t\t\t\t\t\tthis.chunks.splice( chunkIndex, 0, indentation );\n\t\t\t\t\t\t\t\tchunkIndex += 1;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthis.chunks.splice( chunkIndex + 1, 0, indentation, remainder );\n\t\t\t\t\t\t\t\tchunkIndex += 2;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tchunk = remainder;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tcharIndex += 1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcharIndex = chunk.end;\n\t\t}\n\n\t\tthis.outro = this.outro.replace( pattern, replacer );\n\n\t\treturn this;\n\t},\n\n\tinsert ( index, content ) {\n\t\tif ( typeof content !== 'string' ) throw new TypeError( 'inserted content must be a string' );\n\n\t\tthis._split( index );\n\n\t\tlet next = findIndex( this.chunks, chunk => chunk.original.length && chunk.start === index );\n\t\tif ( !~next ) next = this.chunks.length;\n\n\t\tconst newChunk = new Chunk( index, index, '' ).edit( content, false );\n\n\t\tthis.chunks.splice( next, 0, newChunk );\n\t\treturn this;\n\t},\n\n\t// get current location of character in original string\n\tlocate () {\n\t\tthrow new Error( 'magicString.locate is deprecated' );\n\t},\n\n\tlocateOrigin () {\n\t\tthrow new Error( 'magicString.locateOrigin is deprecated' );\n\t},\n\n\tmove ( start, end, index ) {\n\t\tif ( index >= start && index <= end ) throw new Error( 'Cannot move a selection inside itself' );\n\n\t\tthis._split( start );\n\t\tthis._split( end );\n\t\tthis._split( index );\n\n\t\tconst firstIndex = findIndex( this.chunks, chunk => chunk.start === start );\n\t\tlet lastIndex = findIndex( this.chunks, chunk => chunk.end === end );\n\n\t\tconst toMove = this.chunks.splice( firstIndex, lastIndex + 1 - firstIndex );\n\n\t\tlet insertionIndex = findIndex( this.chunks, chunk => chunk.original.length && chunk.start === index );\n\t\tif ( !~insertionIndex ) insertionIndex = this.chunks.length;\n\n\t\tthis.chunks.splice.apply( this.chunks, [ insertionIndex, 0 ].concat( toMove ) );\n\n\t\treturn this;\n\t},\n\n\toverwrite ( start, end, content, storeName ) {\n\t\tif ( typeof content !== 'string' ) {\n\t\t\tthrow new TypeError( 'replacement content must be a string' );\n\t\t}\n\n\t\tthis._split( start );\n\t\tthis._split( end );\n\n\t\tif ( storeName ) {\n\t\t\tconst original = this.original.slice( start, end );\n\t\t\tthis.storedNames[ original ] = true;\n\t\t}\n\n\t\tlet firstIndex = findIndex( this.chunks, chunk => chunk.start === start && chunk.original.length );\n\t\tif ( !~firstIndex ) firstIndex = this.chunks.length;\n\t\tlet lastIndex = findIndex( this.chunks, chunk => chunk.end === end );\n\n\t\tconst newChunk = new Chunk( start, end, this.original.slice( start, end ) ).edit( content, storeName );\n\n\t\tthis.chunks.splice( firstIndex, lastIndex + 1 - firstIndex, newChunk );\n\t\treturn this;\n\t},\n\n\tprepend ( content ) {\n\t\tif ( typeof content !== 'string' ) throw new TypeError( 'outro content must be a string' );\n\n\t\tthis.intro = content + this.intro;\n\t\treturn this;\n\t},\n\n\tremove ( start, end ) {\n\t\twhile ( start < 0 ) start += this.original.length;\n\t\twhile ( end < 0 ) end += this.original.length;\n\n\t\tif ( start === end ) return this;\n\n\t\tif ( start < 0 || end > this.original.length ) throw new Error( 'Character is out of bounds' );\n\t\tif ( start > end ) throw new Error( 'end must be greater than start' );\n\n\t\tlet firstIndex = findIndex( this.chunks, chunk => chunk.start <= start && chunk.end > start );\n\t\tlet chunk = this.chunks[ firstIndex ];\n\n\t\t// if the chunk contains `start`, split\n\t\tif ( chunk.start < start ) {\n\t\t\tif ( chunk.edited && chunk.content.length ) throw new Error( 'nope' );\n\t\t\tthis._split( start );\n\t\t\tfirstIndex += 1;\n\t\t}\n\n\t\tlet lastIndex = findIndex( this.chunks, chunk => chunk.start < end && chunk.end >= end );\n\t\tchunk = this.chunks[ lastIndex ];\n\n\t\t// if the chunk contains `end`, split\n\t\tif ( chunk.start < end ) {\n\t\t\tif ( chunk.edited && chunk.content.length ) throw new Error( 'nope' );\n\t\t\tthis._split( end );\n\t\t}\n\n\t\tlastIndex += 1;\n\n\t\tconst newChunk = new Chunk( start, end, this.original.slice( start, end ) ).edit( '', false );\n\t\tthis.chunks.splice( firstIndex, lastIndex - firstIndex, newChunk );\n\n\t\treturn this;\n\t},\n\n\treplace ( start, end, content ) {\n\t\tif ( !warned ) {\n\t\t\tconsole.warn( 'magicString.replace(...) is deprecated. Use magicString.overwrite(...) instead' );\n\t\t\twarned = true;\n\t\t}\n\n\t\treturn this.overwrite( start, end, content );\n\t},\n\n\tslice ( start, end = this.original.length ) {\n\t\twhile ( start < 0 ) start += this.original.length;\n\t\twhile ( end < 0 ) end += this.original.length;\n\n\t\tlet result = '';\n\n\t\tfor ( let i = 0; i < this.chunks.length; i += 1 ) {\n\t\t\tconst chunk = this.chunks[i];\n\n\t\t\tif ( chunk.end <= start ) continue;\n\t\t\tif ( chunk.start >= end ) break;\n\n\t\t\tif ( chunk.start < start || chunk.end > end ) {\n\t\t\t\tif ( chunk.edited ) throw new Error( `Cannot use replaced characters (${start}, ${end}) as slice anchors` );\n\n\t\t\t\tconst sliceStart = Math.max( start - chunk.start, 0 );\n\t\t\t\tconst sliceEnd = Math.min( chunk.content.length - ( chunk.end - end ), chunk.content.length );\n\n\t\t\t\tresult += chunk.content.slice( sliceStart, sliceEnd );\n\t\t\t} else {\n\t\t\t\tresult += chunk.content;\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t},\n\n\tsnip ( start, end ) {\n\t\tconst clone = this.clone();\n\t\tclone.remove( 0, start );\n\t\tclone.remove( end, clone.original.length );\n\n\t\treturn clone;\n\t},\n\n\t_split ( index ) {\n\t\t// TODO bisect\n\t\tfor ( let i = 0; i < this.chunks.length; i += 1 ) {\n\t\t\tconst chunk = this.chunks[i];\n\t\t\tif ( chunk.start === index || chunk.end === index ) return;\n\n\t\t\tif ( chunk.start < index && chunk.end > index ) {\n\t\t\t\tconst newChunk = chunk.split( index );\n\t\t\t\tthis.chunks.splice( i + 1, 0, newChunk );\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t},\n\n\ttoString () {\n\t\treturn this.intro + this.chunks.map( chunk => chunk.content ).join( '' ) + this.outro;\n\t},\n\n\ttrimLines () {\n\t\treturn this.trim('[\\\\r\\\\n]');\n\t},\n\n\t// TODO rewrite these methods, post-refactor\n\ttrim ( charType ) {\n\t\treturn this.trimStart( charType ).trimEnd( charType );\n\t},\n\n\ttrimEnd ( charType ) {\n\t\tconst rx = new RegExp( ( charType || '\\\\s' ) + '+$' );\n\n\t\tthis.outro = this.outro.replace( rx, '' );\n\t\tif ( this.outro.length ) return this;\n\n\t\tdo {\n\t\t\tlet lastChunk = this.chunks[ this.chunks.length - 1 ];\n\t\t\tif ( rx.test( lastChunk.content ) ) {\n\t\t\t\tlastChunk.edit( lastChunk.content.replace( rx, '' ) );\n\t\t\t}\n\n\t\t\tif ( lastChunk.content.length || this.chunks.length === 1 ) {\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tthis.chunks.pop();\n\t\t\t}\n\t\t} while ( true );\n\n\t\treturn this;\n\t},\n\n\ttrimStart ( charType ) {\n\t\tconst rx = new RegExp( '^' + ( charType || '\\\\s' ) + '+' );\n\n\t\tthis.intro = this.intro.replace( rx, '' );\n\t\tif ( this.intro.length ) return this;\n\n\t\tdo {\n\t\t\tlet firstChunk = this.chunks[0];\n\t\t\tif ( rx.test( firstChunk.content ) ) {\n\t\t\t\tfirstChunk.edit( firstChunk.content.replace( rx, '' ) );\n\t\t\t}\n\n\t\t\tif ( firstChunk.content.length || this.chunks.length === 1 ) {\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tthis.chunks.shift();\n\t\t\t}\n\t\t} while ( true );\n\n\t\treturn this;\n\t}\n};\n","export default Object.prototype.hasOwnProperty;","import MagicString from './MagicString.js';\nimport SourceMap from './utils/SourceMap.js';\nimport getRelativePath from './utils/getRelativePath.js';\nimport hasOwnProp from './utils/hasOwnProp.js';\nimport isObject from './utils/isObject.js';\n\nexport default function Bundle ( options = {} ) {\n\tthis.intro = options.intro || '';\n\tthis.separator = options.separator !== undefined ? options.separator : '\\n';\n\n\tthis.sources = [];\n\n\tthis.uniqueSources = [];\n\tthis.uniqueSourceIndexByFilename = {};\n}\n\nBundle.prototype = {\n\taddSource ( source ) {\n\t\tif ( source instanceof MagicString ) {\n\t\t\treturn this.addSource({\n\t\t\t\tcontent: source,\n\t\t\t\tfilename: source.filename,\n\t\t\t\tseparator: this.separator\n\t\t\t});\n\t\t}\n\n\t\tif ( !isObject( source ) || !source.content ) {\n\t\t\tthrow new Error( 'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`' );\n\t\t}\n\n\t\t[ 'filename', 'indentExclusionRanges', 'separator' ].forEach( option => {\n\t\t\tif ( !hasOwnProp.call( source, option ) ) source[ option ] = source.content[ option ];\n\t\t});\n\n\t\tif ( source.separator === undefined ) { // TODO there's a bunch of this sort of thing, needs cleaning up\n\t\t\tsource.separator = this.separator;\n\t\t}\n\n\t\tif ( source.filename ) {\n\t\t\tif ( !hasOwnProp.call( this.uniqueSourceIndexByFilename, source.filename ) ) {\n\t\t\t\tthis.uniqueSourceIndexByFilename[ source.filename ] = this.uniqueSources.length;\n\t\t\t\tthis.uniqueSources.push({ filename: source.filename, content: source.content.original });\n\t\t\t} else {\n\t\t\t\tconst uniqueSource = this.uniqueSources[ this.uniqueSourceIndexByFilename[ source.filename ] ];\n\t\t\t\tif ( source.content.original !== uniqueSource.content ) {\n\t\t\t\t\tthrow new Error( `Illegal source: same filename (${source.filename}), different contents` );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.sources.push( source );\n\t\treturn this;\n\t},\n\n\tappend ( str, options ) {\n\t\tthis.addSource({\n\t\t\tcontent: new MagicString( str ),\n\t\t\tseparator: ( options && options.separator ) || ''\n\t\t});\n\n\t\treturn this;\n\t},\n\n\tclone () {\n\t\tconst bundle = new Bundle({\n\t\t\tintro: this.intro,\n\t\t\tseparator: this.separator\n\t\t});\n\n\t\tthis.sources.forEach( source => {\n\t\t\tbundle.addSource({\n\t\t\t\tfilename: source.filename,\n\t\t\t\tcontent: source.content.clone(),\n\t\t\t\tseparator: source.separator\n\t\t\t});\n\t\t});\n\n\t\treturn bundle;\n\t},\n\n\tgenerateMap ( options ) {\n\t\tlet offsets = {};\n\n\t\tlet names = [];\n\t\tthis.sources.forEach( source => {\n\t\t\tObject.keys( source.content.storedNames ).forEach( name => {\n\t\t\t\tif ( !~names.indexOf( name ) ) names.push( name );\n\t\t\t});\n\t\t});\n\n\t\tconst encoded = (\n\t\t\tgetSemis( this.intro ) +\n\t\t\tthis.sources.map( ( source, i ) => {\n\t\t\t\tconst prefix = ( i > 0 ) ? ( getSemis( source.separator ) || ',' ) : '';\n\t\t\t\tlet mappings;\n\n\t\t\t\t// we don't bother encoding sources without a filename\n\t\t\t\tif ( !source.filename ) {\n\t\t\t\t\tmappings = getSemis( source.content.toString() );\n\t\t\t\t} else {\n\t\t\t\t\tconst sourceIndex = this.uniqueSourceIndexByFilename[ source.filename ];\n\t\t\t\t\tmappings = source.content.getMappings( options.hires, sourceIndex, offsets, names );\n\t\t\t\t}\n\n\t\t\t\treturn prefix + mappings;\n\t\t\t}).join( '' )\n\t\t);\n\n\t\treturn new SourceMap({\n\t\t\tfile: ( options.file ? options.file.split( /[\\/\\\\]/ ).pop() : null ),\n\t\t\tsources: this.uniqueSources.map( source => {\n\t\t\t\treturn options.file ? getRelativePath( options.file, source.filename ) : source.filename;\n\t\t\t}),\n\t\t\tsourcesContent: this.uniqueSources.map( source => {\n\t\t\t\treturn options.includeContent ? source.content : null;\n\t\t\t}),\n\t\t\tnames,\n\t\t\tmappings: encoded\n\t\t});\n\t},\n\n\tgetIndentString () {\n\t\tlet indentStringCounts = {};\n\n\t\tthis.sources.forEach( source => {\n\t\t\tconst indentStr = source.content.indentStr;\n\n\t\t\tif ( indentStr === null ) return;\n\n\t\t\tif ( !indentStringCounts[ indentStr ] ) indentStringCounts[ indentStr ] = 0;\n\t\t\tindentStringCounts[ indentStr ] += 1;\n\t\t});\n\n\t\treturn ( Object.keys( indentStringCounts ).sort( ( a, b ) => {\n\t\t\treturn indentStringCounts[a] - indentStringCounts[b];\n\t\t})[0] ) || '\\t';\n\t},\n\n\tindent ( indentStr ) {\n\t\tif ( !arguments.length ) {\n\t\t\tindentStr = this.getIndentString();\n\t\t}\n\n\t\tif ( indentStr === '' ) return this; // noop\n\n\t\tlet trailingNewline = !this.intro || this.intro.slice( -1 ) === '\\n';\n\n\t\tthis.sources.forEach( ( source, i ) => {\n\t\t\tconst separator = source.separator !== undefined ? source.separator : this.separator;\n\t\t\tconst indentStart = trailingNewline || ( i > 0 && /\\r?\\n$/.test( separator ) );\n\n\t\t\tsource.content.indent( indentStr, {\n\t\t\t\texclude: source.indentExclusionRanges,\n\t\t\t\tindentStart//: trailingNewline || /\\r?\\n$/.test( separator ) //true///\\r?\\n/.test( separator )\n\t\t\t});\n\n\t\t\t// TODO this is a very slow way to determine this\n\t\t\ttrailingNewline = source.content.toString().slice( 0, -1 ) === '\\n';\n\t\t});\n\n\t\tif ( this.intro ) {\n\t\t\tthis.intro = indentStr + this.intro.replace( /^[^\\n]/gm, ( match, index ) => {\n\t\t\t\treturn index > 0 ? indentStr + match : match;\n\t\t\t});\n\t\t}\n\n\t\treturn this;\n\t},\n\n\tprepend ( str ) {\n\t\tthis.intro = str + this.intro;\n\t\treturn this;\n\t},\n\n\ttoString () {\n\t\tconst body = this.sources.map( ( source, i ) => {\n\t\t\tconst separator = source.separator !== undefined ? source.separator : this.separator;\n\t\t\tlet str = ( i > 0 ? separator : '' ) + source.content.toString();\n\n\t\t\treturn str;\n\t\t}).join( '' );\n\n\t\treturn this.intro + body;\n\t},\n\n\ttrimLines () {\n\t\treturn this.trim('[\\\\r\\\\n]');\n\t},\n\n\ttrim ( charType ) {\n\t\treturn this.trimStart( charType ).trimEnd( charType );\n\t},\n\n\ttrimStart ( charType ) {\n\t\tconst rx = new RegExp( '^' + ( charType || '\\\\s' ) + '+' );\n\t\tthis.intro = this.intro.replace( rx, '' );\n\n\t\tif ( !this.intro ) {\n\t\t\tlet source;\n\t\t\tlet i = 0;\n\n\t\t\tdo {\n\t\t\t\tsource = this.sources[i];\n\n\t\t\t\tif ( !source ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tsource.content.trimStart( charType );\n\t\t\t\ti += 1;\n\t\t\t} while ( source.content.toString() === '' ); // TODO faster way to determine non-empty source?\n\t\t}\n\n\t\treturn this;\n\t},\n\n\ttrimEnd ( charType ) {\n\t\tconst rx = new RegExp( ( charType || '\\\\s' ) + '+$' );\n\n\t\tlet source;\n\t\tlet i = this.sources.length - 1;\n\n\t\tdo {\n\t\t\tsource = this.sources[i];\n\n\t\t\tif ( !source ) {\n\t\t\t\tthis.intro = this.intro.replace( rx, '' );\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tsource.content.trimEnd( charType );\n\t\t\ti -= 1;\n\t\t} while ( source.content.toString() === '' ); // TODO faster way to determine non-empty source?\n\n\t\treturn this;\n\t}\n};\n\nfunction getSemis ( str ) {\n\treturn new Array( str.split( '\\n' ).length ).join( ';' );\n}\n","import MagicString from './MagicString.js';\nimport Bundle from './Bundle.js';\n\nMagicString.Bundle = Bundle;\n\nexport default MagicString;\n"],"names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;;;;;SAiBK;GACN;;GAEA;GACA;;;;;;;;;;;;;;;;;;;;;;;;;;"}
{"version":3,"file":"magic-string.umd.js","sources":["../src/Chunk.js","../src/utils/btoa.js","../src/utils/SourceMap.js","../src/utils/guessIndent.js","../node_modules/vlq/src/vlq.js","../src/utils/encodeMappings.js","../src/utils/getRelativePath.js","../src/utils/isObject.js","../src/utils/findIndex.js","../src/MagicString.js","../src/utils/hasOwnProp.js","../src/Bundle.js","../src/index.js"],"sourcesContent":["export default function Chunk ( start, end, content ) {\n\tthis.start = start;\n\tthis.end = end;\n\tthis.original = content;\n\n\tthis.content = content;\n\tthis.storeName = false;\n\tthis.edited = false;\n}\n\nChunk.prototype = {\n\tclone () {\n\t\tconst chunk = new Chunk( this.start, this.end, this.original );\n\t\tchunk.content = this.content;\n\t\tchunk.storeName = this.storeName;\n\t\tchunk.edited = this.edited;\n\n\t\treturn chunk;\n\t},\n\n\tedit ( content, storeName ) {\n\t\tthis.content = content;\n\t\tthis.storeName = storeName;\n\n\t\tthis.edited = true;\n\n\t\treturn this;\n\t},\n\n\tsplit ( index ) {\n\t\tif ( index === this.start ) return this;\n\n\t\tconst sliceIndex = index - this.start;\n\n\t\tconst originalBefore = this.original.slice( 0, sliceIndex );\n\t\tconst originalAfter = this.original.slice( sliceIndex );\n\n\t\tthis.original = originalBefore;\n\n\t\tconst newChunk = new Chunk( index, this.end, originalAfter );\n\t\tthis.end = index;\n\n\t\tif ( this.edited ) {\n\t\t\tif ( this.content.length ) throw new Error( `Cannot split a chunk that has already been edited (\"${this.original}\")` );\n\n\t\t\t// zero-length edited chunks are a special case (overlapping replacements)\n\t\t\tnewChunk.edit( '', false );\n\t\t\tthis.content = '';\n\t\t} else {\n\t\t\tthis.content = originalBefore;\n\t\t}\n\n\t\treturn newChunk;\n\t}\n};\n","let _btoa;\n\nif ( typeof window !== 'undefined' && typeof window.btoa === 'function' ) {\n\t_btoa = window.btoa;\n} else if ( typeof Buffer === 'function' ) {\n\t/* global Buffer */\n\t_btoa = str => new Buffer( str ).toString( 'base64' );\n} else {\n\tthrow new Error( 'Unsupported environment: `window.btoa` or `Buffer` should be supported.' );\n}\n\nexport default _btoa;\n","import btoa from './btoa.js';\n\nexport default function SourceMap ( properties ) {\n\tthis.version = 3;\n\n\tthis.file = properties.file;\n\tthis.sources = properties.sources;\n\tthis.sourcesContent = properties.sourcesContent;\n\tthis.names = properties.names;\n\tthis.mappings = properties.mappings;\n}\n\nSourceMap.prototype = {\n\ttoString () {\n\t\treturn JSON.stringify( this );\n\t},\n\n\ttoUrl () {\n\t\treturn 'data:application/json;charset=utf-8;base64,' + btoa( this.toString() );\n\t}\n};\n","export default function guessIndent ( code ) {\n\tconst lines = code.split( '\\n' );\n\n\tconst tabbed = lines.filter( line => /^\\t+/.test( line ) );\n\tconst spaced = lines.filter( line => /^ {2,}/.test( line ) );\n\n\tif ( tabbed.length === 0 && spaced.length === 0 ) {\n\t\treturn null;\n\t}\n\n\t// More lines tabbed than spaced? Assume tabs, and\n\t// default to tabs in the case of a tie (or nothing\n\t// to go on)\n\tif ( tabbed.length >= spaced.length ) {\n\t\treturn '\\t';\n\t}\n\n\t// Otherwise, we need to guess the multiple\n\tconst min = spaced.reduce( ( previous, current ) => {\n\t\tconst numSpaces = /^ +/.exec( current )[0].length;\n\t\treturn Math.min( numSpaces, previous );\n\t}, Infinity );\n\n\treturn new Array( min + 1 ).join( ' ' );\n}\n","var charToInteger = {};\nvar integerToChar = {};\n\n'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split( '' ).forEach( function ( char, i ) {\n\tcharToInteger[ char ] = i;\n\tintegerToChar[ i ] = char;\n});\n\nexport function decode ( string ) {\n\tvar result = [],\n\t\tlen = string.length,\n\t\ti,\n\t\thasContinuationBit,\n\t\tshift = 0,\n\t\tvalue = 0,\n\t\tinteger,\n\t\tshouldNegate;\n\n\tfor ( i = 0; i < len; i += 1 ) {\n\t\tinteger = charToInteger[ string[i] ];\n\n\t\tif ( integer === undefined ) {\n\t\t\tthrow new Error( 'Invalid character (' + string[i] + ')' );\n\t\t}\n\n\t\thasContinuationBit = integer & 32;\n\n\t\tinteger &= 31;\n\t\tvalue += integer << shift;\n\n\t\tif ( hasContinuationBit ) {\n\t\t\tshift += 5;\n\t\t} else {\n\t\t\tshouldNegate = value & 1;\n\t\t\tvalue >>= 1;\n\n\t\t\tresult.push( shouldNegate ? -value : value );\n\n\t\t\t// reset\n\t\t\tvalue = shift = 0;\n\t\t}\n\t}\n\n\treturn result;\n}\n\nexport function encode ( value ) {\n\tvar result, i;\n\n\tif ( typeof value === 'number' ) {\n\t\tresult = encodeInteger( value );\n\t} else {\n\t\tresult = '';\n\t\tfor ( i = 0; i < value.length; i += 1 ) {\n\t\t\tresult += encodeInteger( value[i] );\n\t\t}\n\t}\n\n\treturn result;\n}\n\nfunction encodeInteger ( num ) {\n\tvar result = '', clamped;\n\n\tif ( num < 0 ) {\n\t\tnum = ( -num << 1 ) | 1;\n\t} else {\n\t\tnum <<= 1;\n\t}\n\n\tdo {\n\t\tclamped = num & 31;\n\t\tnum >>= 5;\n\n\t\tif ( num > 0 ) {\n\t\t\tclamped |= 32;\n\t\t}\n\n\t\tresult += integerToChar[ clamped ];\n\t} while ( num > 0 );\n\n\treturn result;\n}\n","import { encode } from 'vlq';\n\nfunction getLocator ( source ) {\n\tlet originalLines = source.split( '\\n' );\n\n\treturn function locate ( index ) {\n\t\tconst len = originalLines.length;\n\n\t\tlet lineStart = 0;\n\n\t\tfor ( let i = 0; i < len; i += 1 ) {\n\t\t\tconst line = originalLines[i];\n\t\t\tconst lineEnd = lineStart + line.length + 1; // +1 for newline\n\n\t\t\tif ( lineEnd > index ) return { line: i, column: index - lineStart };\n\n\t\t\tlineStart = lineEnd;\n\t\t}\n\t};\n}\n\nexport default function encodeMappings ( original, intro, chunks, hires, sourcemapLocations, sourceIndex, offsets, names ) {\n\tlet rawLines = [];\n\n\tlet generatedCodeLine = intro.split( '\\n' ).length - 1;\n\tlet rawSegments = rawLines[ generatedCodeLine ] = [];\n\n\tlet generatedCodeColumn = 0;\n\n\tconst locate = getLocator( original );\n\n\tfunction addUneditedChunk ( chunk ) {\n\t\tlet originalCharIndex = chunk.start;\n\t\tlet first = true;\n\n\t\tlet { line, column } = locate( originalCharIndex );\n\n\t\twhile ( originalCharIndex < chunk.end ) {\n\t\t\tif ( hires || first || sourcemapLocations[ originalCharIndex ] ) {\n\t\t\t\trawSegments.push({\n\t\t\t\t\tgeneratedCodeLine,\n\t\t\t\t\tgeneratedCodeColumn,\n\t\t\t\t\tsourceCodeLine: line,\n\t\t\t\t\tsourceCodeColumn: column,\n\t\t\t\t\tsourceCodeName: -1,\n\t\t\t\t\tsourceIndex\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif ( original[ originalCharIndex ] === '\\n' ) {\n\t\t\t\tline += 1;\n\t\t\t\tcolumn = 0;\n\t\t\t\tgeneratedCodeLine += 1;\n\t\t\t\trawLines[ generatedCodeLine ] = rawSegments = [];\n\t\t\t\tgeneratedCodeColumn = 0;\n\t\t\t} else {\n\t\t\t\tcolumn += 1;\n\t\t\t\tgeneratedCodeColumn += 1;\n\t\t\t}\n\n\t\t\toriginalCharIndex += 1;\n\t\t\tfirst = false;\n\t\t}\n\t}\n\n\tfor ( let i = 0; i < chunks.length; i += 1 ) {\n\t\tconst chunk = chunks[i];\n\t\tlet { line, column } = locate( chunk.start );\n\n\t\tif ( chunk.edited ) {\n\t\t\tif ( i > 0 || chunk.content.length ) {\n\t\t\t\trawSegments.push({\n\t\t\t\t\tgeneratedCodeLine,\n\t\t\t\t\tgeneratedCodeColumn,\n\t\t\t\t\tsourceCodeLine: line,\n\t\t\t\t\tsourceCodeColumn: column,\n\t\t\t\t\tsourceCodeName: chunk.storeName ? names.indexOf( chunk.original ) : -1,\n\t\t\t\t\tsourceIndex\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tlet lines = chunk.content.split( '\\n' );\n\t\t\tlet lastLine = lines.pop();\n\n\t\t\tif ( lines.length ) {\n\t\t\t\tgeneratedCodeLine += lines.length;\n\t\t\t\trawLines[ generatedCodeLine ] = rawSegments = [];\n\t\t\t\tgeneratedCodeColumn = lastLine.length;\n\t\t\t} else {\n\t\t\t\tgeneratedCodeColumn += lastLine.length;\n\t\t\t}\n\n\t\t\tlines = chunk.original.split( '\\n' );\n\t\t\tlastLine = lines.pop();\n\n\t\t\tif ( lines.length ) {\n\t\t\t\tline += lines.length;\n\t\t\t\tcolumn = lastLine.length;\n\t\t\t} else {\n\t\t\t\tcolumn += lastLine.length;\n\t\t\t}\n\t\t} else {\n\t\t\taddUneditedChunk( chunk );\n\t\t}\n\t}\n\n\toffsets.sourceIndex = offsets.sourceIndex || 0;\n\toffsets.sourceCodeLine = offsets.sourceCodeLine || 0;\n\toffsets.sourceCodeColumn = offsets.sourceCodeColumn || 0;\n\toffsets.sourceCodeName = offsets.sourceCodeName || 0;\n\n\tconst encoded = rawLines.map( segments => {\n\t\tlet generatedCodeColumn = 0;\n\n\t\treturn segments.map( segment => {\n\t\t\tlet arr = [\n\t\t\t\tsegment.generatedCodeColumn - generatedCodeColumn,\n\t\t\t\tsegment.sourceIndex - offsets.sourceIndex,\n\t\t\t\tsegment.sourceCodeLine - offsets.sourceCodeLine,\n\t\t\t\tsegment.sourceCodeColumn - offsets.sourceCodeColumn\n\t\t\t];\n\n\t\t\tgeneratedCodeColumn = segment.generatedCodeColumn;\n\t\t\toffsets.sourceIndex = segment.sourceIndex;\n\t\t\toffsets.sourceCodeLine = segment.sourceCodeLine;\n\t\t\toffsets.sourceCodeColumn = segment.sourceCodeColumn;\n\n\t\t\tif ( ~segment.sourceCodeName ) {\n\t\t\t\tarr.push( segment.sourceCodeName - offsets.sourceCodeName );\n\t\t\t\toffsets.sourceCodeName = segment.sourceCodeName;\n\t\t\t}\n\n\t\t\treturn encode( arr );\n\t\t}).join( ',' );\n\t}).join( ';' );\n\n\treturn encoded;\n}\n","export default function getRelativePath ( from, to ) {\n\tlet fromParts = from.split( /[\\/\\\\]/ );\n\tlet toParts = to.split( /[\\/\\\\]/ );\n\n\tfromParts.pop(); // get dirname\n\n\twhile ( fromParts[0] === toParts[0] ) {\n\t\tfromParts.shift();\n\t\ttoParts.shift();\n\t}\n\n\tif ( fromParts.length ) {\n\t\tlet i = fromParts.length;\n\t\twhile ( i-- ) fromParts[i] = '..';\n\t}\n\n\treturn fromParts.concat( toParts ).join( '/' );\n}\n","const toString = Object.prototype.toString;\n\nexport default function isObject ( thing ) {\n\treturn toString.call( thing ) === '[object Object]';\n}\n","export default function findIndex ( array, fn ) {\n\tfor ( let i = 0; i < array.length; i += 1 ) {\n\t\tif ( fn( array[i], i ) ) return i;\n\t}\n\n\treturn -1;\n}\n","import Chunk from './Chunk.js';\nimport SourceMap from './utils/SourceMap.js';\nimport guessIndent from './utils/guessIndent.js';\nimport encodeMappings from './utils/encodeMappings.js';\nimport getRelativePath from './utils/getRelativePath.js';\nimport isObject from './utils/isObject.js';\nimport findIndex from './utils/findIndex.js';\n\nlet warned = false;\n\nexport default function MagicString ( string, options = {} ) {\n\tconst chunk = new Chunk( 0, string.length, string );\n\n\tObject.defineProperties( this, {\n\t\toriginal: { writable: true, value: string },\n\t\toutro: { writable: true, value: '' },\n\t\tintro: { writable: true, value: '' },\n\t\tchunks: { writable: true, value: [ chunk ] },\n\t\tmoves: { writable: true, value: [] },\n\t\tfilename: { writable: true, value: options.filename },\n\t\tindentExclusionRanges: { writable: true, value: options.indentExclusionRanges },\n\t\tsourcemapLocations: { writable: true, value: {} },\n\t\tstoredNames: { writable: true, value: {} },\n\t\tindentStr: { writable: true, value: guessIndent( string ) }\n\t});\n}\n\nMagicString.prototype = {\n\taddSourcemapLocation ( char ) {\n\t\tthis.sourcemapLocations[ char ] = true;\n\t},\n\n\tappend ( content ) {\n\t\tif ( typeof content !== 'string' ) throw new TypeError( 'outro content must be a string' );\n\n\t\tthis.outro += content;\n\t\treturn this;\n\t},\n\n\tclone () {\n\t\tlet cloned = new MagicString( this.original, { filename: this.filename });\n\n\t\tcloned.chunks = this.chunks.map( chunk => chunk.clone() );\n\n\t\tif ( this.indentExclusionRanges ) {\n\t\t\tcloned.indentExclusionRanges = typeof this.indentExclusionRanges[0] === 'number' ?\n\t\t\t\t[ this.indentExclusionRanges[0], this.indentExclusionRanges[1] ] :\n\t\t\t\tthis.indentExclusionRanges.map( range => [ range.start, range.end ] );\n\t\t}\n\n\t\tObject.keys( this.sourcemapLocations ).forEach( loc => {\n\t\t\tcloned.sourcemapLocations[ loc ] = true;\n\t\t});\n\n\t\treturn cloned;\n\t},\n\n\tgenerateMap ( options ) {\n\t\toptions = options || {};\n\n\t\tconst names = Object.keys( this.storedNames );\n\n\t\treturn new SourceMap({\n\t\t\tfile: ( options.file ? options.file.split( /[\\/\\\\]/ ).pop() : null ),\n\t\t\tsources: [ options.source ? getRelativePath( options.file || '', options.source ) : null ],\n\t\t\tsourcesContent: options.includeContent ? [ this.original ] : [ null ],\n\t\t\tnames,\n\t\t\tmappings: this.getMappings( options.hires, 0, {}, names )\n\t\t});\n\t},\n\n\tgetIndentString () {\n\t\treturn this.indentStr === null ? '\\t' : this.indentStr;\n\t},\n\n\tgetMappings ( hires, sourceIndex, offsets, names ) {\n\t\treturn encodeMappings( this.original, this.intro, this.chunks, hires, this.sourcemapLocations, sourceIndex, offsets, names );\n\t},\n\n\tindent ( indentStr, options ) {\n\t\tconst pattern = /^[^\\r\\n]/gm;\n\n\t\tif ( isObject( indentStr ) ) {\n\t\t\toptions = indentStr;\n\t\t\tindentStr = undefined;\n\t\t}\n\n\t\tindentStr = indentStr !== undefined ? indentStr : ( this.indentStr || '\\t' );\n\n\t\tif ( indentStr === '' ) return this; // noop\n\n\t\toptions = options || {};\n\n\t\t// Process exclusion ranges\n\t\tlet isExcluded = {};\n\n\t\tif ( options.exclude ) {\n\t\t\tlet exclusions = typeof options.exclude[0] === 'number' ? [ options.exclude ] : options.exclude;\n\t\t\texclusions.forEach( exclusion => {\n\t\t\t\tfor ( let i = exclusion[0]; i < exclusion[1]; i += 1 ) {\n\t\t\t\t\tisExcluded[i] = true;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tlet shouldIndentNextCharacter = options.indentStart !== false;\n\t\tconst replacer = match => {\n\t\t\tif ( shouldIndentNextCharacter ) return `${indentStr}${match}`;\n\t\t\tshouldIndentNextCharacter = true;\n\t\t\treturn match;\n\t\t};\n\n\t\tthis.intro = this.intro.replace( pattern, replacer );\n\n\t\tlet chunkIndex;\n\t\tlet charIndex = 0;\n\n\t\tfor ( chunkIndex = 0; chunkIndex < this.chunks.length; chunkIndex += 1 ) { // can't cache this.chunks.length, it may change\n\t\t\tlet chunk = this.chunks[ chunkIndex ];\n\t\t\tconst end = chunk.end;\n\n\t\t\tif ( chunk.edited ) {\n\t\t\t\tif ( !isExcluded[ charIndex ] ) {\n\t\t\t\t\tchunk.content = chunk.content.replace( pattern, replacer );\n\n\t\t\t\t\tif ( chunk.content.length ) {\n\t\t\t\t\t\tshouldIndentNextCharacter = chunk.content[ chunk.content.length - 1 ] === '\\n';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcharIndex = chunk.start;\n\n\t\t\t\twhile ( charIndex < end ) {\n\t\t\t\t\tif ( !isExcluded[ charIndex ] ) {\n\t\t\t\t\t\tconst char = this.original[ charIndex ];\n\n\t\t\t\t\t\tif ( char === '\\n' ) {\n\t\t\t\t\t\t\tshouldIndentNextCharacter = true;\n\t\t\t\t\t\t} else if ( char !== '\\r' && shouldIndentNextCharacter ) {\n\t\t\t\t\t\t\tshouldIndentNextCharacter = false;\n\n\t\t\t\t\t\t\tconst indentation = new Chunk( charIndex, charIndex, '' ).edit( indentStr, false );\n\t\t\t\t\t\t\tconst remainder = chunk.split( charIndex );\n\n\t\t\t\t\t\t\tif ( charIndex === chunk.start ) {\n\t\t\t\t\t\t\t\tthis.chunks.splice( chunkIndex, 0, indentation );\n\t\t\t\t\t\t\t\tchunkIndex += 1;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthis.chunks.splice( chunkIndex + 1, 0, indentation, remainder );\n\t\t\t\t\t\t\t\tchunkIndex += 2;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tchunk = remainder;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tcharIndex += 1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcharIndex = chunk.end;\n\t\t}\n\n\t\tthis.outro = this.outro.replace( pattern, replacer );\n\n\t\treturn this;\n\t},\n\n\tinsert ( index, content ) {\n\t\tif ( typeof content !== 'string' ) throw new TypeError( 'inserted content must be a string' );\n\n\t\tthis._split( index );\n\n\t\tlet next = findIndex( this.chunks, chunk => chunk.original.length && chunk.start === index );\n\t\tif ( !~next ) next = this.chunks.length;\n\n\t\tconst newChunk = new Chunk( index, index, '' ).edit( content, false );\n\n\t\tthis.chunks.splice( next, 0, newChunk );\n\t\treturn this;\n\t},\n\n\t// get current location of character in original string\n\tlocate () {\n\t\tthrow new Error( 'magicString.locate is deprecated' );\n\t},\n\n\tlocateOrigin () {\n\t\tthrow new Error( 'magicString.locateOrigin is deprecated' );\n\t},\n\n\tmove ( start, end, index ) {\n\t\tif ( index >= start && index <= end ) throw new Error( 'Cannot move a selection inside itself' );\n\n\t\tthis._split( start );\n\t\tthis._split( end );\n\t\tthis._split( index );\n\n\t\tconst firstIndex = findIndex( this.chunks, chunk => chunk.start === start );\n\t\tlet lastIndex = findIndex( this.chunks, chunk => chunk.end === end );\n\n\t\tconst toMove = this.chunks.splice( firstIndex, lastIndex + 1 - firstIndex );\n\n\t\tlet insertionIndex = findIndex( this.chunks, chunk => chunk.original.length && chunk.start === index );\n\t\tif ( !~insertionIndex ) insertionIndex = this.chunks.length;\n\n\t\tthis.chunks.splice.apply( this.chunks, [ insertionIndex, 0 ].concat( toMove ) );\n\n\t\treturn this;\n\t},\n\n\toverwrite ( start, end, content, storeName ) {\n\t\tif ( typeof content !== 'string' ) {\n\t\t\tthrow new TypeError( 'replacement content must be a string' );\n\t\t}\n\n\t\tthis._split( start );\n\t\tthis._split( end );\n\n\t\tif ( storeName ) {\n\t\t\tconst original = this.original.slice( start, end );\n\t\t\tthis.storedNames[ original ] = true;\n\t\t}\n\n\t\tlet firstIndex = findIndex( this.chunks, chunk => chunk.start === start && chunk.original.length );\n\t\tif ( !~firstIndex ) firstIndex = this.chunks.length;\n\t\tlet lastIndex = findIndex( this.chunks, chunk => chunk.end === end );\n\n\t\tconst newChunk = new Chunk( start, end, this.original.slice( start, end ) ).edit( content, storeName );\n\n\t\tthis.chunks.splice( firstIndex, lastIndex + 1 - firstIndex, newChunk );\n\t\treturn this;\n\t},\n\n\tprepend ( content ) {\n\t\tif ( typeof content !== 'string' ) throw new TypeError( 'outro content must be a string' );\n\n\t\tthis.intro = content + this.intro;\n\t\treturn this;\n\t},\n\n\tremove ( start, end ) {\n\t\twhile ( start < 0 ) start += this.original.length;\n\t\twhile ( end < 0 ) end += this.original.length;\n\n\t\tif ( start === end ) return this;\n\n\t\tif ( start < 0 || end > this.original.length ) throw new Error( 'Character is out of bounds' );\n\t\tif ( start > end ) throw new Error( 'end must be greater than start' );\n\n\t\tlet firstIndex = findIndex( this.chunks, chunk => chunk.start <= start && chunk.end > start );\n\t\tlet chunk = this.chunks[ firstIndex ];\n\n\t\t// if the chunk contains `start`, split\n\t\tif ( chunk.start < start ) {\n\t\t\tif ( chunk.edited && chunk.content.length ) throw new Error( 'nope' );\n\t\t\tthis._split( start );\n\t\t\tfirstIndex += 1;\n\t\t}\n\n\t\tlet lastIndex = findIndex( this.chunks, chunk => chunk.start < end && chunk.end >= end );\n\t\tchunk = this.chunks[ lastIndex ];\n\n\t\t// if the chunk contains `end`, split\n\t\tif ( chunk.start < end ) {\n\t\t\tif ( chunk.edited && chunk.content.length ) throw new Error( 'nope' );\n\t\t\tthis._split( end );\n\t\t}\n\n\t\tlastIndex += 1;\n\n\t\tconst newChunk = new Chunk( start, end, this.original.slice( start, end ) ).edit( '', false );\n\t\tthis.chunks.splice( firstIndex, lastIndex - firstIndex, newChunk );\n\n\t\treturn this;\n\t},\n\n\treplace ( start, end, content ) {\n\t\tif ( !warned ) {\n\t\t\tconsole.warn( 'magicString.replace(...) is deprecated. Use magicString.overwrite(...) instead' );\n\t\t\twarned = true;\n\t\t}\n\n\t\treturn this.overwrite( start, end, content );\n\t},\n\n\tslice ( start, end = this.original.length ) {\n\t\twhile ( start < 0 ) start += this.original.length;\n\t\twhile ( end < 0 ) end += this.original.length;\n\n\t\tlet result = '';\n\n\t\tfor ( let i = 0; i < this.chunks.length; i += 1 ) {\n\t\t\tconst chunk = this.chunks[i];\n\n\t\t\tif ( chunk.end <= start ) continue;\n\t\t\tif ( chunk.start >= end ) break;\n\n\t\t\tif ( chunk.start < start || chunk.end > end ) {\n\t\t\t\tif ( chunk.edited ) throw new Error( `Cannot use replaced characters (${start}, ${end}) as slice anchors` );\n\n\t\t\t\tconst sliceStart = Math.max( start - chunk.start, 0 );\n\t\t\t\tconst sliceEnd = Math.min( chunk.content.length - ( chunk.end - end ), chunk.content.length );\n\n\t\t\t\tresult += chunk.content.slice( sliceStart, sliceEnd );\n\t\t\t} else {\n\t\t\t\tresult += chunk.content;\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t},\n\n\tsnip ( start, end ) {\n\t\tconst clone = this.clone();\n\t\tclone.remove( 0, start );\n\t\tclone.remove( end, clone.original.length );\n\n\t\treturn clone;\n\t},\n\n\t_split ( index ) {\n\t\t// TODO bisect\n\t\tfor ( let i = 0; i < this.chunks.length; i += 1 ) {\n\t\t\tconst chunk = this.chunks[i];\n\t\t\tif ( chunk.start === index || chunk.end === index ) return;\n\n\t\t\tif ( chunk.start < index && chunk.end > index ) {\n\t\t\t\tconst newChunk = chunk.split( index );\n\t\t\t\tthis.chunks.splice( i + 1, 0, newChunk );\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t},\n\n\ttoString () {\n\t\treturn this.intro + this.chunks.map( chunk => chunk.content ).join( '' ) + this.outro;\n\t},\n\n\ttrimLines () {\n\t\treturn this.trim('[\\\\r\\\\n]');\n\t},\n\n\t// TODO rewrite these methods, post-refactor\n\ttrim ( charType ) {\n\t\treturn this.trimStart( charType ).trimEnd( charType );\n\t},\n\n\ttrimEnd ( charType ) {\n\t\tconst rx = new RegExp( ( charType || '\\\\s' ) + '+$' );\n\n\t\tthis.outro = this.outro.replace( rx, '' );\n\t\tif ( this.outro.length ) return this;\n\n\t\tdo {\n\t\t\tlet lastChunk = this.chunks[ this.chunks.length - 1 ];\n\t\t\tif ( rx.test( lastChunk.content ) ) {\n\t\t\t\tlastChunk.edit( lastChunk.content.replace( rx, '' ) );\n\t\t\t}\n\n\t\t\tif ( lastChunk.content.length || this.chunks.length === 1 ) {\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tthis.chunks.pop();\n\t\t\t}\n\t\t} while ( true );\n\n\t\treturn this;\n\t},\n\n\ttrimStart ( charType ) {\n\t\tconst rx = new RegExp( '^' + ( charType || '\\\\s' ) + '+' );\n\n\t\tthis.intro = this.intro.replace( rx, '' );\n\t\tif ( this.intro.length ) return this;\n\n\t\tdo {\n\t\t\tlet firstChunk = this.chunks[0];\n\t\t\tif ( rx.test( firstChunk.content ) ) {\n\t\t\t\tfirstChunk.edit( firstChunk.content.replace( rx, '' ) );\n\t\t\t}\n\n\t\t\tif ( firstChunk.content.length || this.chunks.length === 1 ) {\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tthis.chunks.shift();\n\t\t\t}\n\t\t} while ( true );\n\n\t\treturn this;\n\t}\n};\n","export default Object.prototype.hasOwnProperty;","import MagicString from './MagicString.js';\nimport SourceMap from './utils/SourceMap.js';\nimport getRelativePath from './utils/getRelativePath.js';\nimport hasOwnProp from './utils/hasOwnProp.js';\nimport isObject from './utils/isObject.js';\n\nexport default function Bundle ( options = {} ) {\n\tthis.intro = options.intro || '';\n\tthis.separator = options.separator !== undefined ? options.separator : '\\n';\n\n\tthis.sources = [];\n\n\tthis.uniqueSources = [];\n\tthis.uniqueSourceIndexByFilename = {};\n}\n\nBundle.prototype = {\n\taddSource ( source ) {\n\t\tif ( source instanceof MagicString ) {\n\t\t\treturn this.addSource({\n\t\t\t\tcontent: source,\n\t\t\t\tfilename: source.filename,\n\t\t\t\tseparator: this.separator\n\t\t\t});\n\t\t}\n\n\t\tif ( !isObject( source ) || !source.content ) {\n\t\t\tthrow new Error( 'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`' );\n\t\t}\n\n\t\t[ 'filename', 'indentExclusionRanges', 'separator' ].forEach( option => {\n\t\t\tif ( !hasOwnProp.call( source, option ) ) source[ option ] = source.content[ option ];\n\t\t});\n\n\t\tif ( source.separator === undefined ) { // TODO there's a bunch of this sort of thing, needs cleaning up\n\t\t\tsource.separator = this.separator;\n\t\t}\n\n\t\tif ( source.filename ) {\n\t\t\tif ( !hasOwnProp.call( this.uniqueSourceIndexByFilename, source.filename ) ) {\n\t\t\t\tthis.uniqueSourceIndexByFilename[ source.filename ] = this.uniqueSources.length;\n\t\t\t\tthis.uniqueSources.push({ filename: source.filename, content: source.content.original });\n\t\t\t} else {\n\t\t\t\tconst uniqueSource = this.uniqueSources[ this.uniqueSourceIndexByFilename[ source.filename ] ];\n\t\t\t\tif ( source.content.original !== uniqueSource.content ) {\n\t\t\t\t\tthrow new Error( `Illegal source: same filename (${source.filename}), different contents` );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.sources.push( source );\n\t\treturn this;\n\t},\n\n\tappend ( str, options ) {\n\t\tthis.addSource({\n\t\t\tcontent: new MagicString( str ),\n\t\t\tseparator: ( options && options.separator ) || ''\n\t\t});\n\n\t\treturn this;\n\t},\n\n\tclone () {\n\t\tconst bundle = new Bundle({\n\t\t\tintro: this.intro,\n\t\t\tseparator: this.separator\n\t\t});\n\n\t\tthis.sources.forEach( source => {\n\t\t\tbundle.addSource({\n\t\t\t\tfilename: source.filename,\n\t\t\t\tcontent: source.content.clone(),\n\t\t\t\tseparator: source.separator\n\t\t\t});\n\t\t});\n\n\t\treturn bundle;\n\t},\n\n\tgenerateMap ( options ) {\n\t\tlet offsets = {};\n\n\t\tlet names = [];\n\t\tthis.sources.forEach( source => {\n\t\t\tObject.keys( source.content.storedNames ).forEach( name => {\n\t\t\t\tif ( !~names.indexOf( name ) ) names.push( name );\n\t\t\t});\n\t\t});\n\n\t\tconst encoded = (\n\t\t\tgetSemis( this.intro ) +\n\t\t\tthis.sources.map( ( source, i ) => {\n\t\t\t\tconst prefix = ( i > 0 ) ? ( getSemis( source.separator ) || ',' ) : '';\n\t\t\t\tlet mappings;\n\n\t\t\t\t// we don't bother encoding sources without a filename\n\t\t\t\tif ( !source.filename ) {\n\t\t\t\t\tmappings = getSemis( source.content.toString() );\n\t\t\t\t} else {\n\t\t\t\t\tconst sourceIndex = this.uniqueSourceIndexByFilename[ source.filename ];\n\t\t\t\t\tmappings = source.content.getMappings( options.hires, sourceIndex, offsets, names );\n\t\t\t\t}\n\n\t\t\t\treturn prefix + mappings;\n\t\t\t}).join( '' )\n\t\t);\n\n\t\treturn new SourceMap({\n\t\t\tfile: ( options.file ? options.file.split( /[\\/\\\\]/ ).pop() : null ),\n\t\t\tsources: this.uniqueSources.map( source => {\n\t\t\t\treturn options.file ? getRelativePath( options.file, source.filename ) : source.filename;\n\t\t\t}),\n\t\t\tsourcesContent: this.uniqueSources.map( source => {\n\t\t\t\treturn options.includeContent ? source.content : null;\n\t\t\t}),\n\t\t\tnames,\n\t\t\tmappings: encoded\n\t\t});\n\t},\n\n\tgetIndentString () {\n\t\tlet indentStringCounts = {};\n\n\t\tthis.sources.forEach( source => {\n\t\t\tconst indentStr = source.content.indentStr;\n\n\t\t\tif ( indentStr === null ) return;\n\n\t\t\tif ( !indentStringCounts[ indentStr ] ) indentStringCounts[ indentStr ] = 0;\n\t\t\tindentStringCounts[ indentStr ] += 1;\n\t\t});\n\n\t\treturn ( Object.keys( indentStringCounts ).sort( ( a, b ) => {\n\t\t\treturn indentStringCounts[a] - indentStringCounts[b];\n\t\t})[0] ) || '\\t';\n\t},\n\n\tindent ( indentStr ) {\n\t\tif ( !arguments.length ) {\n\t\t\tindentStr = this.getIndentString();\n\t\t}\n\n\t\tif ( indentStr === '' ) return this; // noop\n\n\t\tlet trailingNewline = !this.intro || this.intro.slice( -1 ) === '\\n';\n\n\t\tthis.sources.forEach( ( source, i ) => {\n\t\t\tconst separator = source.separator !== undefined ? source.separator : this.separator;\n\t\t\tconst indentStart = trailingNewline || ( i > 0 && /\\r?\\n$/.test( separator ) );\n\n\t\t\tsource.content.indent( indentStr, {\n\t\t\t\texclude: source.indentExclusionRanges,\n\t\t\t\tindentStart//: trailingNewline || /\\r?\\n$/.test( separator ) //true///\\r?\\n/.test( separator )\n\t\t\t});\n\n\t\t\t// TODO this is a very slow way to determine this\n\t\t\ttrailingNewline = source.content.toString().slice( 0, -1 ) === '\\n';\n\t\t});\n\n\t\tif ( this.intro ) {\n\t\t\tthis.intro = indentStr + this.intro.replace( /^[^\\n]/gm, ( match, index ) => {\n\t\t\t\treturn index > 0 ? indentStr + match : match;\n\t\t\t});\n\t\t}\n\n\t\treturn this;\n\t},\n\n\tprepend ( str ) {\n\t\tthis.intro = str + this.intro;\n\t\treturn this;\n\t},\n\n\ttoString () {\n\t\tconst body = this.sources.map( ( source, i ) => {\n\t\t\tconst separator = source.separator !== undefined ? source.separator : this.separator;\n\t\t\tlet str = ( i > 0 ? separator : '' ) + source.content.toString();\n\n\t\t\treturn str;\n\t\t}).join( '' );\n\n\t\treturn this.intro + body;\n\t},\n\n\ttrimLines () {\n\t\treturn this.trim('[\\\\r\\\\n]');\n\t},\n\n\ttrim ( charType ) {\n\t\treturn this.trimStart( charType ).trimEnd( charType );\n\t},\n\n\ttrimStart ( charType ) {\n\t\tconst rx = new RegExp( '^' + ( charType || '\\\\s' ) + '+' );\n\t\tthis.intro = this.intro.replace( rx, '' );\n\n\t\tif ( !this.intro ) {\n\t\t\tlet source;\n\t\t\tlet i = 0;\n\n\t\t\tdo {\n\t\t\t\tsource = this.sources[i];\n\n\t\t\t\tif ( !source ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tsource.content.trimStart( charType );\n\t\t\t\ti += 1;\n\t\t\t} while ( source.content.toString() === '' ); // TODO faster way to determine non-empty source?\n\t\t}\n\n\t\treturn this;\n\t},\n\n\ttrimEnd ( charType ) {\n\t\tconst rx = new RegExp( ( charType || '\\\\s' ) + '+$' );\n\n\t\tlet source;\n\t\tlet i = this.sources.length - 1;\n\n\t\tdo {\n\t\t\tsource = this.sources[i];\n\n\t\t\tif ( !source ) {\n\t\t\t\tthis.intro = this.intro.replace( rx, '' );\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tsource.content.trimEnd( charType );\n\t\t\ti -= 1;\n\t\t} while ( source.content.toString() === '' ); // TODO faster way to determine non-empty source?\n\n\t\treturn this;\n\t}\n};\n\nfunction getSemis ( str ) {\n\treturn new Array( str.split( '\\n' ).length ).join( ';' );\n}\n","import MagicString from './MagicString.js';\nimport Bundle from './Bundle.js';\n\nMagicString.Bundle = Bundle;\n\nexport default MagicString;\n"],"names":["this"],"mappings":";;;;;;;;;;;;;;;;;OAWM;GACJ;;;;;;;;MAQG;;;;;;;;;OASC;;;GAGJ;;GAEA;GACA;;;;GAIA;;;;gDAI6C,CAAA,uDAAqD,IAAE,aAAa,SAAG,CAAC;;;;;;;;;;;;;CC3CvH;;;;;;UAMS,WAAA,GAAG,GAAI,SAAA,sCAAsC,GAAA;;;;;;;;;;;;;;;;;;UCO7C;;;;OAIH;;;;;;EChBL;;EAEA,2BAA6B,WAAA,IAAI,GAAI,SAAA,mBAAmB,GAAA;EACxD,2BAA6B,WAAA,IAAI,GAAI,SAAA,qBAAqB,GAAA;;;;;;;;;;;;;;EAc1D,yBAA2B,WAAE,iBAAiB,GAAM;GACnD;;;;;;;CCnBF,IAAI,aAAa,GAAG,EAAE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AasD,WAAA,MAAM,GAAI;;;;;;;;;;;;;KAatE;;uBAEkB,CAAA,iCAAgC,IAAE,eAAe,2BAAsB,CAAC;;;;;;;;;QASvF;;;;;;;;;OASD;GACJ;;;;;yBAKsB,WAAA,MAAM,GAAI;;;;;;;;;;;aAWtB;GACV,kBAAA;;GAAA;;GAEA;yBACsB,WAAA,MAAM,GAAI;uDACoB,WAAA,IAAI,GAAI;;;;;GAK5D;;sBAEmB,WAAE,SAAS,GAAM;KAClC;KACA;;;;;;MAMC,kBAAoBA,MAAI;;;;;;;;;;qCAUO,WAAA,MAAM,GAAI;;;4CAGH,WAAA,MAAM,GAAI;;;IAGlD,OAAA;;;;;iBAKa;GACd;;yBAEsB,WAAA,MAAM,GAAI;IAC/B;;;;;;;;oDAQgD,WAAE,IAAI,GAAM;;;;;QAKxD;GACL,kBAAA;;GAAA;;;;;;GAMA;;yBAEsB,WAAE,SAAS,GAAM;IACtC,oEAAsEA,MAAI;IAC1E;;;;KAIC,aAAA;;;;;;;;6DAQwD,WAAE,YAAY,GAAM;;;;;;;;SAQxE;;;;;UAKC;GACP,kBAAA;;GAAA,6BAA+B,WAAE,SAAS,GAAM;IAC/C,oEAAsEA,MAAI;IAC1E;;;;;;;;WAQO;;;;MAIL;;;;WAIK;GACR;;;;IAIC;IACA;;;;;;;;;;;;;;;;;SAiBK;GACN;;GAEA;GACA;;;;;;;;;;;;;;;;;;;;;;;;;;"}

@@ -5,3 +5,3 @@ {

"author": "Rich Harris",
"version": "0.11.1",
"version": "0.11.2",
"repository": "https://github.com/rich-harris/magic-string",

@@ -8,0 +8,0 @@ "main": "dist/magic-string.cjs.js",

import { encode } from 'vlq';
function getLocator ( source ) {
let originalLines = source.split( '\n' );
return function locate ( index ) {
const len = originalLines.length;
let lineStart = 0;
for ( let i = 0; i < len; i += 1 ) {
const line = originalLines[i];
const lineEnd = lineStart + line.length + 1; // +1 for newline
if ( lineEnd > index ) return { line: i, column: index - lineStart };
lineStart = lineEnd;
}
};
}
export default function encodeMappings ( original, intro, chunks, hires, sourcemapLocations, sourceIndex, offsets, names ) {

@@ -9,12 +28,13 @@ let rawLines = [];

let originalCharIndex = 0;
let generatedCodeColumn = 0;
let sourceCodeLine = 0;
let sourceCodeColumn = 0;
function addSegmentsUntil ( end ) {
const locate = getLocator( original );
function addUneditedChunk ( chunk ) {
let originalCharIndex = chunk.start;
let first = true;
while ( originalCharIndex < end ) {
let { line, column } = locate( originalCharIndex );
while ( originalCharIndex < chunk.end ) {
if ( hires || first || sourcemapLocations[ originalCharIndex ] ) {

@@ -24,4 +44,4 @@ rawSegments.push({

generatedCodeColumn,
sourceCodeLine,
sourceCodeColumn,
sourceCodeLine: line,
sourceCodeColumn: column,
sourceCodeName: -1,

@@ -33,4 +53,4 @@ sourceIndex

if ( original[ originalCharIndex ] === '\n' ) {
sourceCodeLine += 1;
sourceCodeColumn = 0;
line += 1;
column = 0;
generatedCodeLine += 1;

@@ -40,3 +60,3 @@ rawLines[ generatedCodeLine ] = rawSegments = [];

} else {
sourceCodeColumn += 1;
column += 1;
generatedCodeColumn += 1;

@@ -52,2 +72,3 @@ }

const chunk = chunks[i];
let { line, column } = locate( chunk.start );

@@ -59,4 +80,4 @@ if ( chunk.edited ) {

generatedCodeColumn,
sourceCodeLine,
sourceCodeColumn,
sourceCodeLine: line,
sourceCodeColumn: column,
sourceCodeName: chunk.storeName ? names.indexOf( chunk.original ) : -1,

@@ -82,16 +103,12 @@ sourceIndex

if ( lines.length ) {
sourceCodeLine += lines.length;
sourceCodeColumn = lastLine.length;
line += lines.length;
column = lastLine.length;
} else {
sourceCodeColumn += lastLine.length;
column += lastLine.length;
}
} else {
addSegmentsUntil( chunk.end );
addUneditedChunk( chunk );
}
originalCharIndex = chunk.end;
}
addSegmentsUntil( original.length );
offsets.sourceIndex = offsets.sourceIndex || 0;

@@ -98,0 +115,0 @@ offsets.sourceCodeLine = offsets.sourceCodeLine || 0;