// ExtractHitsPerPage returns the first found HitsPerPageOption from the
// given variadic arguments or nil otherwise.
186254
func ExtractHitsPerPage(opts ...interface{}) *opt.HitsPerPageOption {
	for _, o := range opts {
		if v, ok := o.(*opt.HitsPerPageOption); ok {
			return v
		}
	}
	return nil
}
22950
func extractIDFromPath(url string) (string, error) {
	result := reExtractFileID.FindStringSubmatch(url)
	if len(result) != 2 {
		return "", ErrNotFound
	}
	return result[1], nil
}
842288
func (g Goose) ExtractFromURL(url string) (*Article, error) {
	cc := NewCrawler(g.config, url, "")
	return cc.Crawl()
}
1028421
func ExtractAttributesForFaceting(opts ...interface{}) *opt.AttributesForFacetingOption {
	for _, o := range opts {
		if v, ok := o.(*opt.AttributesForFacetingOption); ok {
			return v
		}
	}
	return nil
}
1037923
func (c *PageCollections) getPageOldVersion(ref ...string) (page.Page, error) {
	var refs []string
	for _, r := range ref {
		// A common construct in the wild is
		// .Site.GetPage "home" "" or
		// .Site.GetPage "home" "/"
		if r != "" && r != "/" {
			refs = append(refs, r)
		}
	}

	var key string

	if len(refs) > 2 {
		// This was allowed in Hugo <= 0.44, but we cannot support this with the
		// new API. This should be the most unusual case.
		return nil, fmt.Errorf(`too many arguments to .Site.GetPage: %v. Use lookups on the form {{ .Site.GetPage "/posts/mypage-md" }}`, ref)
	}

	if len(refs) == 0 || refs[0] == page.KindHome {
		key = "/"
	} else if len(refs) == 1 {
		if len(ref) == 2 && refs[0] == page.KindSection {
			// This is an old style reference to the "Home Page section".
			// Typically fetched via {{ .Site.GetPage "section" .Section }}
			// See https://github.com/gohugoio/hugo/issues/4989
			key = "/"
		} else {
			key = refs[0]
		}
	} else {
		key = refs[1]
	}

	key = filepath.ToSlash(key)
	if !strings.HasPrefix(key, "/") {
		key = "/" + key
	}

	return c.getPageNew(nil, key)
}
1172784
func ExtractQuery(opts ...interface{}) *opt.QueryOption {
	for _, o := range opts {
		if v, ok := o.(*opt.QueryOption); ok {
			return v
		}
	}
	return nil
}
62676
func (p *PageStats) GetTotalPages() int {
	if p == nil || p.TotalPages == nil {
		return 0
	}
	return *p.TotalPages
}
448469
func (c *ZebedeeClient) GetPageTitle(uri string) (data.PageTitle, error) {
	b, err := c.get("/data?uri=" + uri + "&title")
	if err != nil {
		return data.PageTitle{}, err
	}

	var pt data.PageTitle
	if err = json.Unmarshal(b, &pt); err != nil {
		return pt, err
	}

	return pt, nil
}
509302
func ExtractAroundLatLngViaIP(opts ...interface{}) *opt.AroundLatLngViaIPOption {
	for _, o := range opts {
		if v, ok := o.(*opt.AroundLatLngViaIPOption); ok {
			return v
		}
	}
	return nil
}
808657
func ExtractFacets(opts ...interface{}) *opt.FacetsOption {
	for _, o := range opts {
		if v, ok := o.(*opt.FacetsOption); ok {
			return v
		}
	}
	return nil
}
1018290
func ExtractScopes(opts ...interface{}) *opt.ScopesOption {
	for _, o := range opts {
		if v, ok := o.(*opt.ScopesOption); ok {
			return v
		}
	}
	return nil
}
973278
func PagingPage(p Page, totalRecords int, items interface{}) Page {
	return Paging(p.Page, p.Size, totalRecords, items)
}
338641
func ExtractOffset(opts ...interface{}) *opt.OffsetOption {
	for _, o := range opts {
		if v, ok := o.(*opt.OffsetOption); ok {
			return v
		}
	}
	return nil
}
844561
func ExtractExtraURLParams(opts ...interface{}) *opt.ExtraURLParamsOption {
	merged := make(map[string]string)

	for _, o := range opts {
		if v, ok := o.(*opt.ExtraURLParamsOption); ok {
			for key, value := range v.Get() {
				merged[key] = value
			}
		}
	}

	if len(merged) == 0 {
		return nil
	}

	return opt.ExtraURLParams(merged)
}
194522
func (t Tracer) Extract(format interface{}, carrier interface{}) (ctx opentracing.SpanContext, err error) {
	defer func() {
		if r := recover(); r != nil {
			// TODO annotate this error type
			err = ErrContractViolation{r}
		}
	}()

	if format == opentracing.Binary {
		// carrier is guaranteed to be an io.Reader by contract
		r := carrier.(io.Reader)
		packet, err := ioutil.ReadAll(r)
		if err != nil {
			return nil, err
		}

		sample := ssf.SSFSpan{}
		err = proto.Unmarshal(packet, &sample)
		if err != nil {
			return nil, err
		}

		resource := sample.Tags[ResourceKey]

		trace := &Trace{
			TraceID:  sample.TraceId,
			SpanID:   sample.Id,
			Resource: resource,
		}

		return trace.context(), nil
	}

	if tm, ok := carrier.(opentracing.TextMapReader); ok {
		// carrier is guaranteed to be an opentracing.TextMapReader by contract
		// TODO support other TextMapReader implementations
		var traceID int64
		var spanID int64
		for _, headers := range HeaderFormats {

			base := 10
			if headers.numFormat == hexadecimal {
				base = 16
			}

			traceID, _ = strconv.ParseInt(textMapReaderGet(tm, headers.TraceID), base, 64)
			spanID, _ = strconv.ParseInt(textMapReaderGet(tm, headers.SpanID), base, 64)

			if traceID != 0 && spanID != 0 {
				break
			}
		}
		if traceID == 0 && spanID == 0 {
			return nil, errors.New("error parsing fields from TextMapReader")
		}

		trace := &Trace{
			TraceID:  traceID,
			SpanID:   spanID,
			Resource: textMapReaderGet(tm, ResourceKey),
		}

		return trace.context(), nil
	}

	return nil, opentracing.ErrUnsupportedFormat
}
280894
func (s *TemplateService) ExtractTemplate(p *ExtractTemplateParams) (*ExtractTemplateResponse, error) {
	resp, err := s.cs.newRequest("extractTemplate", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r ExtractTemplateResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	// If we have a async client, we need to wait for the async result
	if s.cs.async {
		b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
		if err != nil {
			if err == AsyncTimeoutErr {
				return &r, err
			}
			return nil, err
		}

		b, err = getRawValue(b)
		if err != nil {
			return nil, err
		}

		if err := json.Unmarshal(b, &r); err != nil {
			return nil, err
		}
	}

	return &r, nil
}
426248
func ExtractOptionalFilters(opts ...interface{}) *opt.OptionalFiltersOption {
	for _, o := range opts {
		if v, ok := o.(*opt.OptionalFiltersOption); ok {
			return v
		}
	}
	return nil
}