//go:build !no_gotd_slices
// +build !no_gotd_slices

// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	"context"
	"errors"
	"fmt"
	"sort"
	"strings"

	"go.uber.org/multierr"

	"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// InputStorePaymentPurposeClassArray is adapter for slice of InputStorePaymentPurposeClass.
type InputStorePaymentPurposeClassArray []InputStorePaymentPurposeClass

// Sort sorts slice of InputStorePaymentPurposeClass.
func (s InputStorePaymentPurposeClassArray) Sort(less func(a, b InputStorePaymentPurposeClass) bool) InputStorePaymentPurposeClassArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputStorePaymentPurposeClass.
func (s InputStorePaymentPurposeClassArray) SortStable(less func(a, b InputStorePaymentPurposeClass) bool) InputStorePaymentPurposeClassArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputStorePaymentPurposeClass.
func (s InputStorePaymentPurposeClassArray) Retain(keep func(x InputStorePaymentPurposeClass) bool) InputStorePaymentPurposeClassArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputStorePaymentPurposeClassArray) First() (v InputStorePaymentPurposeClass, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputStorePaymentPurposeClassArray) Last() (v InputStorePaymentPurposeClass, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputStorePaymentPurposeClassArray) PopFirst() (v InputStorePaymentPurposeClass, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputStorePaymentPurposeClass
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputStorePaymentPurposeClassArray) Pop() (v InputStorePaymentPurposeClass, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// AsInputStorePaymentPremiumSubscription returns copy with only InputStorePaymentPremiumSubscription constructors.
func (s InputStorePaymentPurposeClassArray) AsInputStorePaymentPremiumSubscription() (to InputStorePaymentPremiumSubscriptionArray) {
	for _, elem := range s {
		value, ok := elem.(*InputStorePaymentPremiumSubscription)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputStorePaymentGiftPremium returns copy with only InputStorePaymentGiftPremium constructors.
func (s InputStorePaymentPurposeClassArray) AsInputStorePaymentGiftPremium() (to InputStorePaymentGiftPremiumArray) {
	for _, elem := range s {
		value, ok := elem.(*InputStorePaymentGiftPremium)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputStorePaymentPremiumGiftCode returns copy with only InputStorePaymentPremiumGiftCode constructors.
func (s InputStorePaymentPurposeClassArray) AsInputStorePaymentPremiumGiftCode() (to InputStorePaymentPremiumGiftCodeArray) {
	for _, elem := range s {
		value, ok := elem.(*InputStorePaymentPremiumGiftCode)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputStorePaymentPremiumGiveaway returns copy with only InputStorePaymentPremiumGiveaway constructors.
func (s InputStorePaymentPurposeClassArray) AsInputStorePaymentPremiumGiveaway() (to InputStorePaymentPremiumGiveawayArray) {
	for _, elem := range s {
		value, ok := elem.(*InputStorePaymentPremiumGiveaway)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputStorePaymentStarsTopup returns copy with only InputStorePaymentStarsTopup constructors.
func (s InputStorePaymentPurposeClassArray) AsInputStorePaymentStarsTopup() (to InputStorePaymentStarsTopupArray) {
	for _, elem := range s {
		value, ok := elem.(*InputStorePaymentStarsTopup)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputStorePaymentStarsGift returns copy with only InputStorePaymentStarsGift constructors.
func (s InputStorePaymentPurposeClassArray) AsInputStorePaymentStarsGift() (to InputStorePaymentStarsGiftArray) {
	for _, elem := range s {
		value, ok := elem.(*InputStorePaymentStarsGift)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputStorePaymentStarsGiveaway returns copy with only InputStorePaymentStarsGiveaway constructors.
func (s InputStorePaymentPurposeClassArray) AsInputStorePaymentStarsGiveaway() (to InputStorePaymentStarsGiveawayArray) {
	for _, elem := range s {
		value, ok := elem.(*InputStorePaymentStarsGiveaway)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// AsInputStorePaymentAuthCode returns copy with only InputStorePaymentAuthCode constructors.
func (s InputStorePaymentPurposeClassArray) AsInputStorePaymentAuthCode() (to InputStorePaymentAuthCodeArray) {
	for _, elem := range s {
		value, ok := elem.(*InputStorePaymentAuthCode)
		if !ok {
			continue
		}
		to = append(to, *value)
	}

	return to
}

// InputStorePaymentPremiumSubscriptionArray is adapter for slice of InputStorePaymentPremiumSubscription.
type InputStorePaymentPremiumSubscriptionArray []InputStorePaymentPremiumSubscription

// Sort sorts slice of InputStorePaymentPremiumSubscription.
func (s InputStorePaymentPremiumSubscriptionArray) Sort(less func(a, b InputStorePaymentPremiumSubscription) bool) InputStorePaymentPremiumSubscriptionArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputStorePaymentPremiumSubscription.
func (s InputStorePaymentPremiumSubscriptionArray) SortStable(less func(a, b InputStorePaymentPremiumSubscription) bool) InputStorePaymentPremiumSubscriptionArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputStorePaymentPremiumSubscription.
func (s InputStorePaymentPremiumSubscriptionArray) Retain(keep func(x InputStorePaymentPremiumSubscription) bool) InputStorePaymentPremiumSubscriptionArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputStorePaymentPremiumSubscriptionArray) First() (v InputStorePaymentPremiumSubscription, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputStorePaymentPremiumSubscriptionArray) Last() (v InputStorePaymentPremiumSubscription, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputStorePaymentPremiumSubscriptionArray) PopFirst() (v InputStorePaymentPremiumSubscription, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputStorePaymentPremiumSubscription
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputStorePaymentPremiumSubscriptionArray) Pop() (v InputStorePaymentPremiumSubscription, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// InputStorePaymentGiftPremiumArray is adapter for slice of InputStorePaymentGiftPremium.
type InputStorePaymentGiftPremiumArray []InputStorePaymentGiftPremium

// Sort sorts slice of InputStorePaymentGiftPremium.
func (s InputStorePaymentGiftPremiumArray) Sort(less func(a, b InputStorePaymentGiftPremium) bool) InputStorePaymentGiftPremiumArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputStorePaymentGiftPremium.
func (s InputStorePaymentGiftPremiumArray) SortStable(less func(a, b InputStorePaymentGiftPremium) bool) InputStorePaymentGiftPremiumArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputStorePaymentGiftPremium.
func (s InputStorePaymentGiftPremiumArray) Retain(keep func(x InputStorePaymentGiftPremium) bool) InputStorePaymentGiftPremiumArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputStorePaymentGiftPremiumArray) First() (v InputStorePaymentGiftPremium, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputStorePaymentGiftPremiumArray) Last() (v InputStorePaymentGiftPremium, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputStorePaymentGiftPremiumArray) PopFirst() (v InputStorePaymentGiftPremium, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputStorePaymentGiftPremium
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputStorePaymentGiftPremiumArray) Pop() (v InputStorePaymentGiftPremium, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// InputStorePaymentPremiumGiftCodeArray is adapter for slice of InputStorePaymentPremiumGiftCode.
type InputStorePaymentPremiumGiftCodeArray []InputStorePaymentPremiumGiftCode

// Sort sorts slice of InputStorePaymentPremiumGiftCode.
func (s InputStorePaymentPremiumGiftCodeArray) Sort(less func(a, b InputStorePaymentPremiumGiftCode) bool) InputStorePaymentPremiumGiftCodeArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputStorePaymentPremiumGiftCode.
func (s InputStorePaymentPremiumGiftCodeArray) SortStable(less func(a, b InputStorePaymentPremiumGiftCode) bool) InputStorePaymentPremiumGiftCodeArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputStorePaymentPremiumGiftCode.
func (s InputStorePaymentPremiumGiftCodeArray) Retain(keep func(x InputStorePaymentPremiumGiftCode) bool) InputStorePaymentPremiumGiftCodeArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputStorePaymentPremiumGiftCodeArray) First() (v InputStorePaymentPremiumGiftCode, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputStorePaymentPremiumGiftCodeArray) Last() (v InputStorePaymentPremiumGiftCode, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputStorePaymentPremiumGiftCodeArray) PopFirst() (v InputStorePaymentPremiumGiftCode, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputStorePaymentPremiumGiftCode
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputStorePaymentPremiumGiftCodeArray) Pop() (v InputStorePaymentPremiumGiftCode, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// InputStorePaymentPremiumGiveawayArray is adapter for slice of InputStorePaymentPremiumGiveaway.
type InputStorePaymentPremiumGiveawayArray []InputStorePaymentPremiumGiveaway

// Sort sorts slice of InputStorePaymentPremiumGiveaway.
func (s InputStorePaymentPremiumGiveawayArray) Sort(less func(a, b InputStorePaymentPremiumGiveaway) bool) InputStorePaymentPremiumGiveawayArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputStorePaymentPremiumGiveaway.
func (s InputStorePaymentPremiumGiveawayArray) SortStable(less func(a, b InputStorePaymentPremiumGiveaway) bool) InputStorePaymentPremiumGiveawayArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputStorePaymentPremiumGiveaway.
func (s InputStorePaymentPremiumGiveawayArray) Retain(keep func(x InputStorePaymentPremiumGiveaway) bool) InputStorePaymentPremiumGiveawayArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputStorePaymentPremiumGiveawayArray) First() (v InputStorePaymentPremiumGiveaway, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputStorePaymentPremiumGiveawayArray) Last() (v InputStorePaymentPremiumGiveaway, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputStorePaymentPremiumGiveawayArray) PopFirst() (v InputStorePaymentPremiumGiveaway, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputStorePaymentPremiumGiveaway
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputStorePaymentPremiumGiveawayArray) Pop() (v InputStorePaymentPremiumGiveaway, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// InputStorePaymentStarsTopupArray is adapter for slice of InputStorePaymentStarsTopup.
type InputStorePaymentStarsTopupArray []InputStorePaymentStarsTopup

// Sort sorts slice of InputStorePaymentStarsTopup.
func (s InputStorePaymentStarsTopupArray) Sort(less func(a, b InputStorePaymentStarsTopup) bool) InputStorePaymentStarsTopupArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputStorePaymentStarsTopup.
func (s InputStorePaymentStarsTopupArray) SortStable(less func(a, b InputStorePaymentStarsTopup) bool) InputStorePaymentStarsTopupArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputStorePaymentStarsTopup.
func (s InputStorePaymentStarsTopupArray) Retain(keep func(x InputStorePaymentStarsTopup) bool) InputStorePaymentStarsTopupArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputStorePaymentStarsTopupArray) First() (v InputStorePaymentStarsTopup, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputStorePaymentStarsTopupArray) Last() (v InputStorePaymentStarsTopup, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputStorePaymentStarsTopupArray) PopFirst() (v InputStorePaymentStarsTopup, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputStorePaymentStarsTopup
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputStorePaymentStarsTopupArray) Pop() (v InputStorePaymentStarsTopup, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// InputStorePaymentStarsGiftArray is adapter for slice of InputStorePaymentStarsGift.
type InputStorePaymentStarsGiftArray []InputStorePaymentStarsGift

// Sort sorts slice of InputStorePaymentStarsGift.
func (s InputStorePaymentStarsGiftArray) Sort(less func(a, b InputStorePaymentStarsGift) bool) InputStorePaymentStarsGiftArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputStorePaymentStarsGift.
func (s InputStorePaymentStarsGiftArray) SortStable(less func(a, b InputStorePaymentStarsGift) bool) InputStorePaymentStarsGiftArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputStorePaymentStarsGift.
func (s InputStorePaymentStarsGiftArray) Retain(keep func(x InputStorePaymentStarsGift) bool) InputStorePaymentStarsGiftArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputStorePaymentStarsGiftArray) First() (v InputStorePaymentStarsGift, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputStorePaymentStarsGiftArray) Last() (v InputStorePaymentStarsGift, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputStorePaymentStarsGiftArray) PopFirst() (v InputStorePaymentStarsGift, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputStorePaymentStarsGift
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputStorePaymentStarsGiftArray) Pop() (v InputStorePaymentStarsGift, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// InputStorePaymentStarsGiveawayArray is adapter for slice of InputStorePaymentStarsGiveaway.
type InputStorePaymentStarsGiveawayArray []InputStorePaymentStarsGiveaway

// Sort sorts slice of InputStorePaymentStarsGiveaway.
func (s InputStorePaymentStarsGiveawayArray) Sort(less func(a, b InputStorePaymentStarsGiveaway) bool) InputStorePaymentStarsGiveawayArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputStorePaymentStarsGiveaway.
func (s InputStorePaymentStarsGiveawayArray) SortStable(less func(a, b InputStorePaymentStarsGiveaway) bool) InputStorePaymentStarsGiveawayArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputStorePaymentStarsGiveaway.
func (s InputStorePaymentStarsGiveawayArray) Retain(keep func(x InputStorePaymentStarsGiveaway) bool) InputStorePaymentStarsGiveawayArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputStorePaymentStarsGiveawayArray) First() (v InputStorePaymentStarsGiveaway, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputStorePaymentStarsGiveawayArray) Last() (v InputStorePaymentStarsGiveaway, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputStorePaymentStarsGiveawayArray) PopFirst() (v InputStorePaymentStarsGiveaway, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputStorePaymentStarsGiveaway
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputStorePaymentStarsGiveawayArray) Pop() (v InputStorePaymentStarsGiveaway, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// InputStorePaymentAuthCodeArray is adapter for slice of InputStorePaymentAuthCode.
type InputStorePaymentAuthCodeArray []InputStorePaymentAuthCode

// Sort sorts slice of InputStorePaymentAuthCode.
func (s InputStorePaymentAuthCodeArray) Sort(less func(a, b InputStorePaymentAuthCode) bool) InputStorePaymentAuthCodeArray {
	sort.Slice(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// SortStable sorts slice of InputStorePaymentAuthCode.
func (s InputStorePaymentAuthCodeArray) SortStable(less func(a, b InputStorePaymentAuthCode) bool) InputStorePaymentAuthCodeArray {
	sort.SliceStable(s, func(i, j int) bool {
		return less(s[i], s[j])
	})
	return s
}

// Retain filters in-place slice of InputStorePaymentAuthCode.
func (s InputStorePaymentAuthCodeArray) Retain(keep func(x InputStorePaymentAuthCode) bool) InputStorePaymentAuthCodeArray {
	n := 0
	for _, x := range s {
		if keep(x) {
			s[n] = x
			n++
		}
	}
	s = s[:n]

	return s
}

// First returns first element of slice (if exists).
func (s InputStorePaymentAuthCodeArray) First() (v InputStorePaymentAuthCode, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[0], true
}

// Last returns last element of slice (if exists).
func (s InputStorePaymentAuthCodeArray) Last() (v InputStorePaymentAuthCode, ok bool) {
	if len(s) < 1 {
		return
	}
	return s[len(s)-1], true
}

// PopFirst returns first element of slice (if exists) and deletes it.
func (s *InputStorePaymentAuthCodeArray) PopFirst() (v InputStorePaymentAuthCode, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[0]

	// Delete by index from SliceTricks.
	copy(a[0:], a[1:])
	var zero InputStorePaymentAuthCode
	a[len(a)-1] = zero
	a = a[:len(a)-1]
	*s = a

	return v, true
}

// Pop returns last element of slice (if exists) and deletes it.
func (s *InputStorePaymentAuthCodeArray) Pop() (v InputStorePaymentAuthCode, ok bool) {
	if s == nil || len(*s) < 1 {
		return
	}

	a := *s
	v = a[len(a)-1]
	a = a[:len(a)-1]
	*s = a

	return v, true
}
