package com.google.javascript.jscomp;

import com.google.debugging.sourcemap.proto.Mapping;

import javax.annotation.Nullable;
import java.io.PrintStream;

public class ShadowCompiler extends Compiler {

    public ShadowCompiler() {
        super();
    }

    public ShadowCompiler(PrintStream outStream) {
        super(outStream);
    }

    public ShadowCompiler(ErrorManager errorManager) {
        super(errorManager);
    }

    public void justSetOptions(CompilerOptions opts) {
        this.options = opts;
    }

    @Nullable
    @Override
    public Mapping.OriginalMapping getSourceMapping(String sourceName, int lineNumber, int columnNumber) {
        try {
            return super.getSourceMapping(sourceName, lineNumber, columnNumber);
        } catch (Exception e) {
            // sometimes fails on windows trying to resolve [synthetic:1] sources
            return null;
        }
    }
}

@@ -74,133 +74,422 @@
 map.
-proto.Mapping;%0A%0Aimport javax.annotation.Nullable;%0Aimport java.io.PrintStream;%0A%0Apublic class ShadowCompiler extends Compiler %7B
+SourceMapConsumerV3;%0Aimport com.google.debugging.sourcemap.proto.Mapping;%0Aimport com.google.debugging.sourcemap.proto.Mapping.OriginalMapping;%0A%0Aimport javax.annotation.Nullable;%0Aimport java.io.PrintStream;%0Aimport java.nio.file.Paths;%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Apublic class ShadowCompiler extends Compiler %7B%0A%0A    private final Map%3CString, SourceMapConsumerV3%3E consumerCache = new HashMap%3C%3E();
 %0A%0A  
@@ -802,24 +802,301 @@
 pts;%0A    %7D%0A%0A
+    /**%0A     * fixing https://github.com/google/closure-compiler/issues/3825 by removing relative path logic%0A     * the inputs provided by shadow-cljs always use the full name and as such don't need that logic%0A     *%0A     * this makes source maps work again on windows%0A     */%0A
     @Nullabl
@@ -1122,24 +1122,16 @@
  public 
-Mapping.
 Original
@@ -1240,33 +1240,301 @@
     
-return super
+if (sourceName == null) %7B%0A                return null;%0A            %7D%0A%0A            SourceMapInput sourceMap = inputSourceMaps.get(sourceName);%0A            if (sourceMap == null) %7B%0A                return null;%0A            %7D%0A%0A            SourceMapConsumerV3 consumer = consumerCache
 .get
-S
+(s
 ourceMap
 ping
@@ -1533,49 +1533,680 @@
 eMap
-ping(sourceName, lineNumber, columnNumber
+.getOriginalPath());%0A%0A            if (consumer == null) %7B%0A                consumer = sourceMap.getSourceMap(this.getErrorManager());%0A                if (consumer == null) %7B%0A                    return null;%0A                %7D%0A%0A                consumerCache.put(sourceMap.getOriginalPath(), consumer);%0A            %7D%0A%0A            OriginalMapping result = consumer.getMappingForLine(lineNumber, columnNumber + 1);%0A            if (result == null) %7B%0A                return null;%0A            %7D%0A%0A            return result.toBuilder()%0A                    .setOriginalFile(sourceName)%0A                    .setColumnPosition(result.getColumnPosition() - 1)%0A                    .build(
 );%0A 

add workarround fix for google/closure-compiler#3825