// BeeFuncMap returns a FuncMap of functions used in different templates.
3290
func BeeFuncMap() template.FuncMap {
	return template.FuncMap{
		"trim":       strings.TrimSpace,
		"bold":       colors.Bold,
		"headline":   colors.MagentaBold,
		"foldername": colors.RedBold,
		"endline":    EndLine,
		"tmpltostr":  TmplToString,
	}
}
592342
func sliceBinOp(f func(a, b byte) byte, a, b []byte) []byte {
	maxl := len(a)
	if len(b) > maxl {
		maxl = len(b)
	}
	lA := make([]byte, maxl)
	copy(lA, a)
	lB := make([]byte, maxl)
	copy(lB, b)
	res := make([]byte, maxl)
	for i := range res {
		res[i] = f(lA[i], lB[i])
	}
	return res
}
212025
func deriveFmap(f func(string) <-chan int, in <-chan string) <-chan (<-chan int) {
	out := make(chan (<-chan int), cap(in))
	go func() {
		for a := range in {
			b := f(a)
			out <- b
		}
		close(out)
	}()
	return out
}
424975
func valuesToMap(values map[string][]string) map[string]interface{} {
	ret := make(map[string]interface{})

	for key, value := range values {
		if len(value) > 0 {
			ret[key] = value[0]
		}
	}

	return ret
}
755444
func NewRegexpMap() *RegexpMap {
	return &RegexpMap{
		lookupValues:  make(map[string]*RegexpList),
		rules:         make(map[string]*regexp.Regexp),
		rulesRelation: make(map[string]refCount),
	}
}
27091
func (f booleanFunc) toMap() map[Key]ValueSet {
	if !f.k.IsValid() {
		return nil
	}

	return map[Key]ValueSet{
		f.k: NewValueSet(NewStringValue(f.value)),
	}
}
173613
func rowToMap(qr *sqltypes.Result, rownum int) (map[string]string, error) {
	row := qr.Rows[rownum]
	m := make(map[string]string, len(row))
	for i, fld := range qr.Fields {
		if row[i].IsNull() {
			continue
		}
		m[fld.Name] = row[i].ToString()
	}
	return m, nil
}
987788
func (s *Application) FuncMapCopyTo(m map[string]interface{}) *Application {
	for k, v := range s.FuncMap {
		m[k] = v
	}
	return s
}
127781
func UnwrapActDependWrap(a ActionInterface) *ActDepend {
	w, ok := a.(*ActionWrap)

	if !ok {
		return UnwrapActDepend(a)
	}

	ax, ok := w.action.(*ActDepend)

	if !ok {
		return UnwrapActDependWrap(ax)
	}

	return ax

}
1208891
func (g *Generator) funcMap() template.FuncMap {
	return template.FuncMap{
		"EscapeMD":       escapeMD,
		"Symbol":         g.symbol,
		"LinkifySymbols": g.linkifySymbols,
	}
}
998649
func getCmpTp4MinMax(args []Expression) (argTp types.EvalType) {
	datetimeFound, isAllStr := false, true
	cmpEvalType, isStr, isTemporalWithDate := temporalWithDateAsNumEvalType(args[0].GetType())
	if !isStr {
		isAllStr = false
	}
	if isTemporalWithDate {
		datetimeFound = true
	}
	lft := args[0].GetType()
	for i := range args {
		rft := args[i].GetType()
		var tp types.EvalType
		tp, isStr, isTemporalWithDate = temporalWithDateAsNumEvalType(rft)
		if isTemporalWithDate {
			datetimeFound = true
		}
		if !isStr {
			isAllStr = false
		}
		cmpEvalType = getBaseCmpType(cmpEvalType, tp, lft, rft)
		lft = rft
	}
	argTp = cmpEvalType
	if cmpEvalType.IsStringKind() {
		argTp = types.ETString
	}
	if isAllStr && datetimeFound {
		argTp = types.ETDatetime
	}
	return argTp
}
994703
func TupleToMap(args []interface{}) (map[interface{}]interface{}, error) {
	if len(args)%2 != 0 {
		return nil, errors.New("Odd number of elements in args for TupleToMap")
	}
	m := make(map[interface{}]interface{})
	var key interface{}
	for i, o := range args {
		if i%2 == 1 {
			m[key] = o
		} else {
			key = o
		}
	}
	return m, nil
}
381025
func (s *Application) DefaultFuncMap() (r map[string]interface{}) {
	r = tplfunc.New()
	r["RootURL"] = func(p ...string) string {
		if len(p) > 0 {
			return s.URL + p[0]
		}
		return s.URL
	}
	r["RootModuleURL"] = func(ctl string, act string, params ...interface{}) string {
		return s.URLBuilder.Build(s.RootModuleName, ctl, act, params...)
	}
	r["ModuleRootURL"] = func(module string) string {
		return s.Module(module).URL
	}
	r["URLFor"] = s.URLBuilder.Build
	return
}
278902
func zzUnpackCMap(packed []int) []rune {
	m := make([]rune, 0x110000)
	j := 0 // index in unpacked array
	var count int
	assert(len(packed) == 2836)
	for i, value := range packed {
		if i%2 == 0 {
			count = value
		} else {
			m[j] = rune(value)
			j++
			count--
			for count > 0 {
				m[j] = rune(value)
				j++
				count--
			}
		}
	}
	return m
}
1059489
func fileAsConfigMap(file string) ([]byte, map[string]interface{}, error) {
	raw, err := ioutil.ReadFile(file)
	if err != nil {
		return nil, nil, errors.Annotatef(err, "reading config from %q", file)
	}
	if len(raw) == 0 {
		return nil, nil, nil
	}

	cfg, err := bytesAsConfigMap(raw)
	if err != nil {
		return raw, cfg, errors.NotValidf("converting %q contents to map: %s", file, err.Error())
	}
	return raw, cfg, nil
}
756163
func PgTsConfigMapByMapcfgMaptokentypeMapseqno(db XODB, mapcfg pgtypes.Oid, maptokentype int, mapseqno int) (*PgTsConfigMap, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`tableoid, cmax, xmax, cmin, xmin, ctid, mapcfg, maptokentype, mapseqno, mapdict ` +
		`FROM pg_catalog.pg_ts_config_map ` +
		`WHERE mapcfg = $1 AND maptokentype = $2 AND mapseqno = $3`

	// run query
	XOLog(sqlstr, mapcfg, maptokentype, mapseqno)
	ptcm := PgTsConfigMap{}

	err = db.QueryRow(sqlstr, mapcfg, maptokentype, mapseqno).Scan(&ptcm.Tableoid, &ptcm.Cmax, &ptcm.Xmax, &ptcm.Cmin, &ptcm.Xmin, &ptcm.Ctid, &ptcm.Mapcfg, &ptcm.Maptokentype, &ptcm.Mapseqno, &ptcm.Mapdict)
	if err != nil {
		return nil, err
	}

	return &ptcm, nil
}
318135
func Packages(pkgs ...Pkg) FuncMap {
	l := 0
	for _, p := range pkgs {
		l += len(p.Funcs)
	}
	m := make(FuncMap, l)
	for _, p := range pkgs {
		for nm, f := range p.Funcs {
			if p.MapName != nil {
				nm = p.MapName(nm)
			}
			name := p.Prefix + nm
			if f2, ok := m[name]; ok {
				log.Printf("use: name clash for '%s', %T, %T", name, f, f2)
			}
			m[name] = f
		}
	}
	return m
}