package config

import (
	
	
	
	

	
	
	
	
)

type LanguageTarget int8

type JSXOptions struct {
	Parse    bool
	Factory  []string
	Fragment []string
}

type TSOptions struct {
	Parse bool
}

type Platform uint8

const (
	PlatformBrowser Platform = iota
	PlatformNode
	PlatformNeutral
)

Loose: "class Foo { foo = 1 }" => "class Foo { constructor() { this.foo = 1; } }" Strict: "class Foo { foo = 1 }" => "class Foo { constructor() { __publicField(this, 'foo', 1); } }" The disadvantage of strictness here is code bloat and performance. The advantage is following the class field specification accurately. For example, loose mode will incorrectly trigger setter methods while strict mode won't.
This is used when not bundling. It means to preserve whatever form the import or export was originally in. ES6 syntax stays ES6 syntax and CommonJS syntax stays CommonJS syntax.
IIFE stands for immediately-invoked function expression. That looks like this: (() => { ... bundled code ... })(); If the optional GlobalName is configured, then we'll write out this: let globalName = (() => { ... bundled code ... return exports; })();
The CommonJS format looks like this: ... bundled code ... module.exports = exports;
The ES module format looks like this: ... bundled code ... export {...};
Setting this to true disables warnings about code that is very likely to be a bug. This is used to ignore issues inside "node_modules" directories. This has caught real issues in the past. However, it's not esbuild's job to find bugs in other libraries, and these warnings are problematic for people using these libraries with esbuild. The only fix is to either disable all esbuild warnings and not get warnings about your own code, or to try to get the warning fixed in the affected library. This is especially annoying if the warning is a false positive as was the case in https://github.com/firebase/firebase-js-sdk/issues/3814. So these warnings are now disabled for code inside "node_modules" directories.
If present, metadata about the bundle is written as JSON here
The original name of the file, or the manual chunk name, or the name of the type of output file ("entry" or "chunk" or "asset")
A hash of the contents of this file, and the contents and output paths of all dependencies (except for their hash placeholders)
	HashPlaceholder
)

type PathTemplate struct {
	Data        string
	Placeholder PathPlaceholder
}

type PathPlaceholders struct {
	Name *string
	Hash *string
}

func ( PathPlaceholders) ( PathPlaceholder) *string {
	switch  {
	case NamePlaceholder:
		return .Name
	case HashPlaceholder:
		return .Hash
	}
	return nil
}

func ( []PathTemplate) string {
Avoid allocations in this case
		return [0].Data
	}
	 := strings.Builder{}
	for ,  := range  {
		.WriteString(.Data)
		switch .Placeholder {
		case NamePlaceholder:
			.WriteString("[name]")
		case HashPlaceholder:
			.WriteString("[hash]")
		}
	}
	return .String()
}

func ( []PathTemplate,  PathPlaceholder) bool {
	for ,  := range  {
		if .Placeholder ==  {
			return true
		}
	}
	return false
}

Don't allocate if no substitution is possible and the template is already minimal
	 := false
	for ,  := range  {
		if .Get(.Placeholder) != nil || (.Placeholder == NoPlaceholder && +1 < len()) {
			 = true
			break
		}
	}
	if ! {
		return 
	}
Otherwise, substitute and merge as appropriate
	 := make([]PathTemplate, 0, len())
	for ,  := range  {
		if  := .Get(.Placeholder);  != nil {
			.Data += *
			.Placeholder = NoPlaceholder
		}
		if  := len() - 1;  >= 0 && [].Placeholder == NoPlaceholder {
			 := &[]
			.Data += .Data
			.Placeholder = .Placeholder
		} else {
			 = append(, )
		}
	}
	return 
}

func ( Mode,  Format) bool {
	return  == ModeBundle || ( == ModeConvertFormat &&  == FormatIIFE)
}

type InjectedDefine struct {
	Source logger.Source
	Data   js_ast.E
	Name   string
}

type InjectedFile struct {
	Path        string
	SourceIndex uint32
	Exports     []string
	IsDefine    bool
}

var filterMutex sync.Mutex
var filterCache map[string]*regexp.Regexp

func ( string) ( *regexp.Regexp) {
Must provide a filter
		return nil
	}
	 := false
Cache hit?
	(func() {
		filterMutex.Lock()
		defer filterMutex.Unlock()
		if filterCache != nil {
			,  = filterCache[]
		}
	})()
	if  {
		return
	}
Cache miss
	,  := regexp.Compile()
	if  != nil {
		return nil
	}
Cache for next time
	filterMutex.Lock()
	defer filterMutex.Unlock()
	if filterCache == nil {
		filterCache = make(map[string]*regexp.Regexp)
	}
	filterCache[] = 
	return
}

func ( string,  string,  string) (*regexp.Regexp, error) {
	if  == "" {
		return nil, fmt.Errorf("[%s] %q is missing a filter", , )
	}

	 := compileFilter()
	if  == nil {
		return nil, fmt.Errorf("[%s] %q filter is not a valid Go regular expression: %q", , , )
	}

	return , nil
}

func ( logger.Path,  *regexp.Regexp,  string) bool {
	return ( == "" || .Namespace == ) && .MatchString(.Text)
}