// Code generated by ent, DO NOT EDIT.

package ent

import (
	"context"
	"errors"
	"fmt"
	"sync"
	"time"

	"entgo.io/ent"
	"entgo.io/ent/dialect/sql"
	"github.com/AvengeMedia/dankcalendar/core/ent/account"
	"github.com/AvengeMedia/dankcalendar/core/ent/calendar"
	"github.com/AvengeMedia/dankcalendar/core/ent/event"
	"github.com/AvengeMedia/dankcalendar/core/ent/invitationstate"
	"github.com/AvengeMedia/dankcalendar/core/ent/predicate"
	"github.com/AvengeMedia/dankcalendar/core/ent/reminderstate"
	"github.com/AvengeMedia/dankcalendar/core/ent/secret"
	"github.com/AvengeMedia/dankcalendar/core/ent/task"
	"github.com/AvengeMedia/dankcalendar/core/internal/settings"
)

const (
	// Operation types.
	OpCreate    = ent.OpCreate
	OpDelete    = ent.OpDelete
	OpDeleteOne = ent.OpDeleteOne
	OpUpdate    = ent.OpUpdate
	OpUpdateOne = ent.OpUpdateOne

	// Node types.
	TypeAccount         = "Account"
	TypeCalendar        = "Calendar"
	TypeEvent           = "Event"
	TypeInvitationState = "InvitationState"
	TypeReminderState   = "ReminderState"
	TypeSecret          = "Secret"
	TypeTask            = "Task"
)

// AccountMutation represents an operation that mutates the Account nodes in the graph.
type AccountMutation struct {
	config
	op               Op
	typ              string
	id               *string
	kind             *account.Kind
	display_name     *string
	settings         *map[string]interface{}
	needs_reauth     *bool
	auth_error       *string
	sync_notice      *string
	created_at       *time.Time
	updated_at       *time.Time
	clearedFields    map[string]struct{}
	calendars        map[string]struct{}
	removedcalendars map[string]struct{}
	clearedcalendars bool
	secrets          map[string]struct{}
	removedsecrets   map[string]struct{}
	clearedsecrets   bool
	done             bool
	oldValue         func(context.Context) (*Account, error)
	predicates       []predicate.Account
}

var _ ent.Mutation = (*AccountMutation)(nil)

// accountOption allows management of the mutation configuration using functional options.
type accountOption func(*AccountMutation)

// newAccountMutation creates new mutation for the Account entity.
func newAccountMutation(c config, op Op, opts ...accountOption) *AccountMutation {
	m := &AccountMutation{
		config:        c,
		op:            op,
		typ:           TypeAccount,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}

// withAccountID sets the ID field of the mutation.
func withAccountID(id string) accountOption {
	return func(m *AccountMutation) {
		var (
			err   error
			once  sync.Once
			value *Account
		)
		m.oldValue = func(ctx context.Context) (*Account, error) {
			once.Do(func() {
				if m.done {
					err = errors.New("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().Account.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}

// withAccount sets the old Account of the mutation.
func withAccount(node *Account) accountOption {
	return func(m *AccountMutation) {
		m.oldValue = func(context.Context) (*Account, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}

// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
func (m AccountMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}

// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
func (m AccountMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, errors.New("ent: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}

// SetID sets the value of the id field. Note that this
// operation is only accepted on creation of Account entities.
func (m *AccountMutation) SetID(id string) {
	m.id = &id
}

// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *AccountMutation) ID() (id string, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}

// IDs queries the database and returns the entity ids that match the mutation's predicate.
// That means, if the mutation is applied within a transaction with an isolation level such
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
// or updated by the mutation.
func (m *AccountMutation) IDs(ctx context.Context) ([]string, error) {
	switch {
	case m.op.Is(OpUpdateOne | OpDeleteOne):
		id, exists := m.ID()
		if exists {
			return []string{id}, nil
		}
		fallthrough
	case m.op.Is(OpUpdate | OpDelete):
		return m.Client().Account.Query().Where(m.predicates...).IDs(ctx)
	default:
		return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
	}
}

// SetKind sets the "kind" field.
func (m *AccountMutation) SetKind(a account.Kind) {
	m.kind = &a
}

// Kind returns the value of the "kind" field in the mutation.
func (m *AccountMutation) Kind() (r account.Kind, exists bool) {
	v := m.kind
	if v == nil {
		return
	}
	return *v, true
}

// OldKind returns the old "kind" field's value of the Account entity.
// If the Account object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *AccountMutation) OldKind(ctx context.Context) (v account.Kind, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldKind is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldKind requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldKind: %w", err)
	}
	return oldValue.Kind, nil
}

// ResetKind resets all changes to the "kind" field.
func (m *AccountMutation) ResetKind() {
	m.kind = nil
}

// SetDisplayName sets the "display_name" field.
func (m *AccountMutation) SetDisplayName(s string) {
	m.display_name = &s
}

// DisplayName returns the value of the "display_name" field in the mutation.
func (m *AccountMutation) DisplayName() (r string, exists bool) {
	v := m.display_name
	if v == nil {
		return
	}
	return *v, true
}

// OldDisplayName returns the old "display_name" field's value of the Account entity.
// If the Account object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *AccountMutation) OldDisplayName(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldDisplayName is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldDisplayName requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldDisplayName: %w", err)
	}
	return oldValue.DisplayName, nil
}

// ResetDisplayName resets all changes to the "display_name" field.
func (m *AccountMutation) ResetDisplayName() {
	m.display_name = nil
}

// SetSettings sets the "settings" field.
func (m *AccountMutation) SetSettings(value map[string]interface{}) {
	m.settings = &value
}

// Settings returns the value of the "settings" field in the mutation.
func (m *AccountMutation) Settings() (r map[string]interface{}, exists bool) {
	v := m.settings
	if v == nil {
		return
	}
	return *v, true
}

// OldSettings returns the old "settings" field's value of the Account entity.
// If the Account object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *AccountMutation) OldSettings(ctx context.Context) (v map[string]interface{}, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldSettings is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldSettings requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldSettings: %w", err)
	}
	return oldValue.Settings, nil
}

// ClearSettings clears the value of the "settings" field.
func (m *AccountMutation) ClearSettings() {
	m.settings = nil
	m.clearedFields[account.FieldSettings] = struct{}{}
}

// SettingsCleared returns if the "settings" field was cleared in this mutation.
func (m *AccountMutation) SettingsCleared() bool {
	_, ok := m.clearedFields[account.FieldSettings]
	return ok
}

// ResetSettings resets all changes to the "settings" field.
func (m *AccountMutation) ResetSettings() {
	m.settings = nil
	delete(m.clearedFields, account.FieldSettings)
}

// SetNeedsReauth sets the "needs_reauth" field.
func (m *AccountMutation) SetNeedsReauth(b bool) {
	m.needs_reauth = &b
}

// NeedsReauth returns the value of the "needs_reauth" field in the mutation.
func (m *AccountMutation) NeedsReauth() (r bool, exists bool) {
	v := m.needs_reauth
	if v == nil {
		return
	}
	return *v, true
}

// OldNeedsReauth returns the old "needs_reauth" field's value of the Account entity.
// If the Account object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *AccountMutation) OldNeedsReauth(ctx context.Context) (v bool, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldNeedsReauth is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldNeedsReauth requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldNeedsReauth: %w", err)
	}
	return oldValue.NeedsReauth, nil
}

// ResetNeedsReauth resets all changes to the "needs_reauth" field.
func (m *AccountMutation) ResetNeedsReauth() {
	m.needs_reauth = nil
}

// SetAuthError sets the "auth_error" field.
func (m *AccountMutation) SetAuthError(s string) {
	m.auth_error = &s
}

// AuthError returns the value of the "auth_error" field in the mutation.
func (m *AccountMutation) AuthError() (r string, exists bool) {
	v := m.auth_error
	if v == nil {
		return
	}
	return *v, true
}

// OldAuthError returns the old "auth_error" field's value of the Account entity.
// If the Account object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *AccountMutation) OldAuthError(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldAuthError is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldAuthError requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldAuthError: %w", err)
	}
	return oldValue.AuthError, nil
}

// ClearAuthError clears the value of the "auth_error" field.
func (m *AccountMutation) ClearAuthError() {
	m.auth_error = nil
	m.clearedFields[account.FieldAuthError] = struct{}{}
}

// AuthErrorCleared returns if the "auth_error" field was cleared in this mutation.
func (m *AccountMutation) AuthErrorCleared() bool {
	_, ok := m.clearedFields[account.FieldAuthError]
	return ok
}

// ResetAuthError resets all changes to the "auth_error" field.
func (m *AccountMutation) ResetAuthError() {
	m.auth_error = nil
	delete(m.clearedFields, account.FieldAuthError)
}

// SetSyncNotice sets the "sync_notice" field.
func (m *AccountMutation) SetSyncNotice(s string) {
	m.sync_notice = &s
}

// SyncNotice returns the value of the "sync_notice" field in the mutation.
func (m *AccountMutation) SyncNotice() (r string, exists bool) {
	v := m.sync_notice
	if v == nil {
		return
	}
	return *v, true
}

// OldSyncNotice returns the old "sync_notice" field's value of the Account entity.
// If the Account object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *AccountMutation) OldSyncNotice(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldSyncNotice is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldSyncNotice requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldSyncNotice: %w", err)
	}
	return oldValue.SyncNotice, nil
}

// ClearSyncNotice clears the value of the "sync_notice" field.
func (m *AccountMutation) ClearSyncNotice() {
	m.sync_notice = nil
	m.clearedFields[account.FieldSyncNotice] = struct{}{}
}

// SyncNoticeCleared returns if the "sync_notice" field was cleared in this mutation.
func (m *AccountMutation) SyncNoticeCleared() bool {
	_, ok := m.clearedFields[account.FieldSyncNotice]
	return ok
}

// ResetSyncNotice resets all changes to the "sync_notice" field.
func (m *AccountMutation) ResetSyncNotice() {
	m.sync_notice = nil
	delete(m.clearedFields, account.FieldSyncNotice)
}

// SetCreatedAt sets the "created_at" field.
func (m *AccountMutation) SetCreatedAt(t time.Time) {
	m.created_at = &t
}

// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *AccountMutation) CreatedAt() (r time.Time, exists bool) {
	v := m.created_at
	if v == nil {
		return
	}
	return *v, true
}

// OldCreatedAt returns the old "created_at" field's value of the Account entity.
// If the Account object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *AccountMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldCreatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
	}
	return oldValue.CreatedAt, nil
}

// ResetCreatedAt resets all changes to the "created_at" field.
func (m *AccountMutation) ResetCreatedAt() {
	m.created_at = nil
}

// SetUpdatedAt sets the "updated_at" field.
func (m *AccountMutation) SetUpdatedAt(t time.Time) {
	m.updated_at = &t
}

// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *AccountMutation) UpdatedAt() (r time.Time, exists bool) {
	v := m.updated_at
	if v == nil {
		return
	}
	return *v, true
}

// OldUpdatedAt returns the old "updated_at" field's value of the Account entity.
// If the Account object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *AccountMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
	}
	return oldValue.UpdatedAt, nil
}

// ResetUpdatedAt resets all changes to the "updated_at" field.
func (m *AccountMutation) ResetUpdatedAt() {
	m.updated_at = nil
}

// AddCalendarIDs adds the "calendars" edge to the Calendar entity by ids.
func (m *AccountMutation) AddCalendarIDs(ids ...string) {
	if m.calendars == nil {
		m.calendars = make(map[string]struct{})
	}
	for i := range ids {
		m.calendars[ids[i]] = struct{}{}
	}
}

// ClearCalendars clears the "calendars" edge to the Calendar entity.
func (m *AccountMutation) ClearCalendars() {
	m.clearedcalendars = true
}

// CalendarsCleared reports if the "calendars" edge to the Calendar entity was cleared.
func (m *AccountMutation) CalendarsCleared() bool {
	return m.clearedcalendars
}

// RemoveCalendarIDs removes the "calendars" edge to the Calendar entity by IDs.
func (m *AccountMutation) RemoveCalendarIDs(ids ...string) {
	if m.removedcalendars == nil {
		m.removedcalendars = make(map[string]struct{})
	}
	for i := range ids {
		delete(m.calendars, ids[i])
		m.removedcalendars[ids[i]] = struct{}{}
	}
}

// RemovedCalendars returns the removed IDs of the "calendars" edge to the Calendar entity.
func (m *AccountMutation) RemovedCalendarsIDs() (ids []string) {
	for id := range m.removedcalendars {
		ids = append(ids, id)
	}
	return
}

// CalendarsIDs returns the "calendars" edge IDs in the mutation.
func (m *AccountMutation) CalendarsIDs() (ids []string) {
	for id := range m.calendars {
		ids = append(ids, id)
	}
	return
}

// ResetCalendars resets all changes to the "calendars" edge.
func (m *AccountMutation) ResetCalendars() {
	m.calendars = nil
	m.clearedcalendars = false
	m.removedcalendars = nil
}

// AddSecretIDs adds the "secrets" edge to the Secret entity by ids.
func (m *AccountMutation) AddSecretIDs(ids ...string) {
	if m.secrets == nil {
		m.secrets = make(map[string]struct{})
	}
	for i := range ids {
		m.secrets[ids[i]] = struct{}{}
	}
}

// ClearSecrets clears the "secrets" edge to the Secret entity.
func (m *AccountMutation) ClearSecrets() {
	m.clearedsecrets = true
}

// SecretsCleared reports if the "secrets" edge to the Secret entity was cleared.
func (m *AccountMutation) SecretsCleared() bool {
	return m.clearedsecrets
}

// RemoveSecretIDs removes the "secrets" edge to the Secret entity by IDs.
func (m *AccountMutation) RemoveSecretIDs(ids ...string) {
	if m.removedsecrets == nil {
		m.removedsecrets = make(map[string]struct{})
	}
	for i := range ids {
		delete(m.secrets, ids[i])
		m.removedsecrets[ids[i]] = struct{}{}
	}
}

// RemovedSecrets returns the removed IDs of the "secrets" edge to the Secret entity.
func (m *AccountMutation) RemovedSecretsIDs() (ids []string) {
	for id := range m.removedsecrets {
		ids = append(ids, id)
	}
	return
}

// SecretsIDs returns the "secrets" edge IDs in the mutation.
func (m *AccountMutation) SecretsIDs() (ids []string) {
	for id := range m.secrets {
		ids = append(ids, id)
	}
	return
}

// ResetSecrets resets all changes to the "secrets" edge.
func (m *AccountMutation) ResetSecrets() {
	m.secrets = nil
	m.clearedsecrets = false
	m.removedsecrets = nil
}

// Where appends a list predicates to the AccountMutation builder.
func (m *AccountMutation) Where(ps ...predicate.Account) {
	m.predicates = append(m.predicates, ps...)
}

// WhereP appends storage-level predicates to the AccountMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *AccountMutation) WhereP(ps ...func(*sql.Selector)) {
	p := make([]predicate.Account, len(ps))
	for i := range ps {
		p[i] = ps[i]
	}
	m.Where(p...)
}

// Op returns the operation name.
func (m *AccountMutation) Op() Op {
	return m.op
}

// SetOp allows setting the mutation operation.
func (m *AccountMutation) SetOp(op Op) {
	m.op = op
}

// Type returns the node type of this mutation (Account).
func (m *AccountMutation) Type() string {
	return m.typ
}

// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *AccountMutation) Fields() []string {
	fields := make([]string, 0, 8)
	if m.kind != nil {
		fields = append(fields, account.FieldKind)
	}
	if m.display_name != nil {
		fields = append(fields, account.FieldDisplayName)
	}
	if m.settings != nil {
		fields = append(fields, account.FieldSettings)
	}
	if m.needs_reauth != nil {
		fields = append(fields, account.FieldNeedsReauth)
	}
	if m.auth_error != nil {
		fields = append(fields, account.FieldAuthError)
	}
	if m.sync_notice != nil {
		fields = append(fields, account.FieldSyncNotice)
	}
	if m.created_at != nil {
		fields = append(fields, account.FieldCreatedAt)
	}
	if m.updated_at != nil {
		fields = append(fields, account.FieldUpdatedAt)
	}
	return fields
}

// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *AccountMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case account.FieldKind:
		return m.Kind()
	case account.FieldDisplayName:
		return m.DisplayName()
	case account.FieldSettings:
		return m.Settings()
	case account.FieldNeedsReauth:
		return m.NeedsReauth()
	case account.FieldAuthError:
		return m.AuthError()
	case account.FieldSyncNotice:
		return m.SyncNotice()
	case account.FieldCreatedAt:
		return m.CreatedAt()
	case account.FieldUpdatedAt:
		return m.UpdatedAt()
	}
	return nil, false
}

// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *AccountMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case account.FieldKind:
		return m.OldKind(ctx)
	case account.FieldDisplayName:
		return m.OldDisplayName(ctx)
	case account.FieldSettings:
		return m.OldSettings(ctx)
	case account.FieldNeedsReauth:
		return m.OldNeedsReauth(ctx)
	case account.FieldAuthError:
		return m.OldAuthError(ctx)
	case account.FieldSyncNotice:
		return m.OldSyncNotice(ctx)
	case account.FieldCreatedAt:
		return m.OldCreatedAt(ctx)
	case account.FieldUpdatedAt:
		return m.OldUpdatedAt(ctx)
	}
	return nil, fmt.Errorf("unknown Account field %s", name)
}

// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *AccountMutation) SetField(name string, value ent.Value) error {
	switch name {
	case account.FieldKind:
		v, ok := value.(account.Kind)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetKind(v)
		return nil
	case account.FieldDisplayName:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetDisplayName(v)
		return nil
	case account.FieldSettings:
		v, ok := value.(map[string]interface{})
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetSettings(v)
		return nil
	case account.FieldNeedsReauth:
		v, ok := value.(bool)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetNeedsReauth(v)
		return nil
	case account.FieldAuthError:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetAuthError(v)
		return nil
	case account.FieldSyncNotice:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetSyncNotice(v)
		return nil
	case account.FieldCreatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCreatedAt(v)
		return nil
	case account.FieldUpdatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUpdatedAt(v)
		return nil
	}
	return fmt.Errorf("unknown Account field %s", name)
}

// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *AccountMutation) AddedFields() []string {
	return nil
}

// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
func (m *AccountMutation) AddedField(name string) (ent.Value, bool) {
	return nil, false
}

// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *AccountMutation) AddField(name string, value ent.Value) error {
	switch name {
	}
	return fmt.Errorf("unknown Account numeric field %s", name)
}

// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *AccountMutation) ClearedFields() []string {
	var fields []string
	if m.FieldCleared(account.FieldSettings) {
		fields = append(fields, account.FieldSettings)
	}
	if m.FieldCleared(account.FieldAuthError) {
		fields = append(fields, account.FieldAuthError)
	}
	if m.FieldCleared(account.FieldSyncNotice) {
		fields = append(fields, account.FieldSyncNotice)
	}
	return fields
}

// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *AccountMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}

// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
func (m *AccountMutation) ClearField(name string) error {
	switch name {
	case account.FieldSettings:
		m.ClearSettings()
		return nil
	case account.FieldAuthError:
		m.ClearAuthError()
		return nil
	case account.FieldSyncNotice:
		m.ClearSyncNotice()
		return nil
	}
	return fmt.Errorf("unknown Account nullable field %s", name)
}

// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
func (m *AccountMutation) ResetField(name string) error {
	switch name {
	case account.FieldKind:
		m.ResetKind()
		return nil
	case account.FieldDisplayName:
		m.ResetDisplayName()
		return nil
	case account.FieldSettings:
		m.ResetSettings()
		return nil
	case account.FieldNeedsReauth:
		m.ResetNeedsReauth()
		return nil
	case account.FieldAuthError:
		m.ResetAuthError()
		return nil
	case account.FieldSyncNotice:
		m.ResetSyncNotice()
		return nil
	case account.FieldCreatedAt:
		m.ResetCreatedAt()
		return nil
	case account.FieldUpdatedAt:
		m.ResetUpdatedAt()
		return nil
	}
	return fmt.Errorf("unknown Account field %s", name)
}

// AddedEdges returns all edge names that were set/added in this mutation.
func (m *AccountMutation) AddedEdges() []string {
	edges := make([]string, 0, 2)
	if m.calendars != nil {
		edges = append(edges, account.EdgeCalendars)
	}
	if m.secrets != nil {
		edges = append(edges, account.EdgeSecrets)
	}
	return edges
}

// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *AccountMutation) AddedIDs(name string) []ent.Value {
	switch name {
	case account.EdgeCalendars:
		ids := make([]ent.Value, 0, len(m.calendars))
		for id := range m.calendars {
			ids = append(ids, id)
		}
		return ids
	case account.EdgeSecrets:
		ids := make([]ent.Value, 0, len(m.secrets))
		for id := range m.secrets {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}

// RemovedEdges returns all edge names that were removed in this mutation.
func (m *AccountMutation) RemovedEdges() []string {
	edges := make([]string, 0, 2)
	if m.removedcalendars != nil {
		edges = append(edges, account.EdgeCalendars)
	}
	if m.removedsecrets != nil {
		edges = append(edges, account.EdgeSecrets)
	}
	return edges
}

// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *AccountMutation) RemovedIDs(name string) []ent.Value {
	switch name {
	case account.EdgeCalendars:
		ids := make([]ent.Value, 0, len(m.removedcalendars))
		for id := range m.removedcalendars {
			ids = append(ids, id)
		}
		return ids
	case account.EdgeSecrets:
		ids := make([]ent.Value, 0, len(m.removedsecrets))
		for id := range m.removedsecrets {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}

// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *AccountMutation) ClearedEdges() []string {
	edges := make([]string, 0, 2)
	if m.clearedcalendars {
		edges = append(edges, account.EdgeCalendars)
	}
	if m.clearedsecrets {
		edges = append(edges, account.EdgeSecrets)
	}
	return edges
}

// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *AccountMutation) EdgeCleared(name string) bool {
	switch name {
	case account.EdgeCalendars:
		return m.clearedcalendars
	case account.EdgeSecrets:
		return m.clearedsecrets
	}
	return false
}

// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *AccountMutation) ClearEdge(name string) error {
	switch name {
	}
	return fmt.Errorf("unknown Account unique edge %s", name)
}

// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *AccountMutation) ResetEdge(name string) error {
	switch name {
	case account.EdgeCalendars:
		m.ResetCalendars()
		return nil
	case account.EdgeSecrets:
		m.ResetSecrets()
		return nil
	}
	return fmt.Errorf("unknown Account edge %s", name)
}

// CalendarMutation represents an operation that mutates the Calendar nodes in the graph.
type CalendarMutation struct {
	config
	op                         Op
	typ                        string
	id                         *string
	remote_id                  *string
	name                       *string
	name_override              *string
	description                *string
	color                      *string
	time_zone                  *string
	read_only                  *bool
	hidden                     *bool
	sync_disabled              *bool
	reminder_overrides         **settings.ReminderOverride
	sync_token                 *string
	supported_components       *[]string
	appendsupported_components []string
	created_at                 *time.Time
	updated_at                 *time.Time
	clearedFields              map[string]struct{}
	account                    *string
	clearedaccount             bool
	events                     map[string]struct{}
	removedevents              map[string]struct{}
	clearedevents              bool
	tasks                      map[string]struct{}
	removedtasks               map[string]struct{}
	clearedtasks               bool
	done                       bool
	oldValue                   func(context.Context) (*Calendar, error)
	predicates                 []predicate.Calendar
}

var _ ent.Mutation = (*CalendarMutation)(nil)

// calendarOption allows management of the mutation configuration using functional options.
type calendarOption func(*CalendarMutation)

// newCalendarMutation creates new mutation for the Calendar entity.
func newCalendarMutation(c config, op Op, opts ...calendarOption) *CalendarMutation {
	m := &CalendarMutation{
		config:        c,
		op:            op,
		typ:           TypeCalendar,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}

// withCalendarID sets the ID field of the mutation.
func withCalendarID(id string) calendarOption {
	return func(m *CalendarMutation) {
		var (
			err   error
			once  sync.Once
			value *Calendar
		)
		m.oldValue = func(ctx context.Context) (*Calendar, error) {
			once.Do(func() {
				if m.done {
					err = errors.New("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().Calendar.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}

// withCalendar sets the old Calendar of the mutation.
func withCalendar(node *Calendar) calendarOption {
	return func(m *CalendarMutation) {
		m.oldValue = func(context.Context) (*Calendar, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}

// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
func (m CalendarMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}

// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
func (m CalendarMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, errors.New("ent: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}

// SetID sets the value of the id field. Note that this
// operation is only accepted on creation of Calendar entities.
func (m *CalendarMutation) SetID(id string) {
	m.id = &id
}

// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *CalendarMutation) ID() (id string, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}

// IDs queries the database and returns the entity ids that match the mutation's predicate.
// That means, if the mutation is applied within a transaction with an isolation level such
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
// or updated by the mutation.
func (m *CalendarMutation) IDs(ctx context.Context) ([]string, error) {
	switch {
	case m.op.Is(OpUpdateOne | OpDeleteOne):
		id, exists := m.ID()
		if exists {
			return []string{id}, nil
		}
		fallthrough
	case m.op.Is(OpUpdate | OpDelete):
		return m.Client().Calendar.Query().Where(m.predicates...).IDs(ctx)
	default:
		return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
	}
}

// SetRemoteID sets the "remote_id" field.
func (m *CalendarMutation) SetRemoteID(s string) {
	m.remote_id = &s
}

// RemoteID returns the value of the "remote_id" field in the mutation.
func (m *CalendarMutation) RemoteID() (r string, exists bool) {
	v := m.remote_id
	if v == nil {
		return
	}
	return *v, true
}

// OldRemoteID returns the old "remote_id" field's value of the Calendar entity.
// If the Calendar object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CalendarMutation) OldRemoteID(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldRemoteID is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldRemoteID requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldRemoteID: %w", err)
	}
	return oldValue.RemoteID, nil
}

// ResetRemoteID resets all changes to the "remote_id" field.
func (m *CalendarMutation) ResetRemoteID() {
	m.remote_id = nil
}

// SetName sets the "name" field.
func (m *CalendarMutation) SetName(s string) {
	m.name = &s
}

// Name returns the value of the "name" field in the mutation.
func (m *CalendarMutation) Name() (r string, exists bool) {
	v := m.name
	if v == nil {
		return
	}
	return *v, true
}

// OldName returns the old "name" field's value of the Calendar entity.
// If the Calendar object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CalendarMutation) OldName(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldName is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldName requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldName: %w", err)
	}
	return oldValue.Name, nil
}

// ResetName resets all changes to the "name" field.
func (m *CalendarMutation) ResetName() {
	m.name = nil
}

// SetNameOverride sets the "name_override" field.
func (m *CalendarMutation) SetNameOverride(s string) {
	m.name_override = &s
}

// NameOverride returns the value of the "name_override" field in the mutation.
func (m *CalendarMutation) NameOverride() (r string, exists bool) {
	v := m.name_override
	if v == nil {
		return
	}
	return *v, true
}

// OldNameOverride returns the old "name_override" field's value of the Calendar entity.
// If the Calendar object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CalendarMutation) OldNameOverride(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldNameOverride is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldNameOverride requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldNameOverride: %w", err)
	}
	return oldValue.NameOverride, nil
}

// ClearNameOverride clears the value of the "name_override" field.
func (m *CalendarMutation) ClearNameOverride() {
	m.name_override = nil
	m.clearedFields[calendar.FieldNameOverride] = struct{}{}
}

// NameOverrideCleared returns if the "name_override" field was cleared in this mutation.
func (m *CalendarMutation) NameOverrideCleared() bool {
	_, ok := m.clearedFields[calendar.FieldNameOverride]
	return ok
}

// ResetNameOverride resets all changes to the "name_override" field.
func (m *CalendarMutation) ResetNameOverride() {
	m.name_override = nil
	delete(m.clearedFields, calendar.FieldNameOverride)
}

// SetDescription sets the "description" field.
func (m *CalendarMutation) SetDescription(s string) {
	m.description = &s
}

// Description returns the value of the "description" field in the mutation.
func (m *CalendarMutation) Description() (r string, exists bool) {
	v := m.description
	if v == nil {
		return
	}
	return *v, true
}

// OldDescription returns the old "description" field's value of the Calendar entity.
// If the Calendar object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CalendarMutation) OldDescription(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldDescription is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldDescription requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldDescription: %w", err)
	}
	return oldValue.Description, nil
}

// ClearDescription clears the value of the "description" field.
func (m *CalendarMutation) ClearDescription() {
	m.description = nil
	m.clearedFields[calendar.FieldDescription] = struct{}{}
}

// DescriptionCleared returns if the "description" field was cleared in this mutation.
func (m *CalendarMutation) DescriptionCleared() bool {
	_, ok := m.clearedFields[calendar.FieldDescription]
	return ok
}

// ResetDescription resets all changes to the "description" field.
func (m *CalendarMutation) ResetDescription() {
	m.description = nil
	delete(m.clearedFields, calendar.FieldDescription)
}

// SetColor sets the "color" field.
func (m *CalendarMutation) SetColor(s string) {
	m.color = &s
}

// Color returns the value of the "color" field in the mutation.
func (m *CalendarMutation) Color() (r string, exists bool) {
	v := m.color
	if v == nil {
		return
	}
	return *v, true
}

// OldColor returns the old "color" field's value of the Calendar entity.
// If the Calendar object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CalendarMutation) OldColor(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldColor is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldColor requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldColor: %w", err)
	}
	return oldValue.Color, nil
}

// ClearColor clears the value of the "color" field.
func (m *CalendarMutation) ClearColor() {
	m.color = nil
	m.clearedFields[calendar.FieldColor] = struct{}{}
}

// ColorCleared returns if the "color" field was cleared in this mutation.
func (m *CalendarMutation) ColorCleared() bool {
	_, ok := m.clearedFields[calendar.FieldColor]
	return ok
}

// ResetColor resets all changes to the "color" field.
func (m *CalendarMutation) ResetColor() {
	m.color = nil
	delete(m.clearedFields, calendar.FieldColor)
}

// SetTimeZone sets the "time_zone" field.
func (m *CalendarMutation) SetTimeZone(s string) {
	m.time_zone = &s
}

// TimeZone returns the value of the "time_zone" field in the mutation.
func (m *CalendarMutation) TimeZone() (r string, exists bool) {
	v := m.time_zone
	if v == nil {
		return
	}
	return *v, true
}

// OldTimeZone returns the old "time_zone" field's value of the Calendar entity.
// If the Calendar object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CalendarMutation) OldTimeZone(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldTimeZone is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldTimeZone requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldTimeZone: %w", err)
	}
	return oldValue.TimeZone, nil
}

// ClearTimeZone clears the value of the "time_zone" field.
func (m *CalendarMutation) ClearTimeZone() {
	m.time_zone = nil
	m.clearedFields[calendar.FieldTimeZone] = struct{}{}
}

// TimeZoneCleared returns if the "time_zone" field was cleared in this mutation.
func (m *CalendarMutation) TimeZoneCleared() bool {
	_, ok := m.clearedFields[calendar.FieldTimeZone]
	return ok
}

// ResetTimeZone resets all changes to the "time_zone" field.
func (m *CalendarMutation) ResetTimeZone() {
	m.time_zone = nil
	delete(m.clearedFields, calendar.FieldTimeZone)
}

// SetReadOnly sets the "read_only" field.
func (m *CalendarMutation) SetReadOnly(b bool) {
	m.read_only = &b
}

// ReadOnly returns the value of the "read_only" field in the mutation.
func (m *CalendarMutation) ReadOnly() (r bool, exists bool) {
	v := m.read_only
	if v == nil {
		return
	}
	return *v, true
}

// OldReadOnly returns the old "read_only" field's value of the Calendar entity.
// If the Calendar object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CalendarMutation) OldReadOnly(ctx context.Context) (v bool, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldReadOnly is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldReadOnly requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldReadOnly: %w", err)
	}
	return oldValue.ReadOnly, nil
}

// ResetReadOnly resets all changes to the "read_only" field.
func (m *CalendarMutation) ResetReadOnly() {
	m.read_only = nil
}

// SetHidden sets the "hidden" field.
func (m *CalendarMutation) SetHidden(b bool) {
	m.hidden = &b
}

// Hidden returns the value of the "hidden" field in the mutation.
func (m *CalendarMutation) Hidden() (r bool, exists bool) {
	v := m.hidden
	if v == nil {
		return
	}
	return *v, true
}

// OldHidden returns the old "hidden" field's value of the Calendar entity.
// If the Calendar object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CalendarMutation) OldHidden(ctx context.Context) (v bool, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldHidden is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldHidden requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldHidden: %w", err)
	}
	return oldValue.Hidden, nil
}

// ResetHidden resets all changes to the "hidden" field.
func (m *CalendarMutation) ResetHidden() {
	m.hidden = nil
}

// SetSyncDisabled sets the "sync_disabled" field.
func (m *CalendarMutation) SetSyncDisabled(b bool) {
	m.sync_disabled = &b
}

// SyncDisabled returns the value of the "sync_disabled" field in the mutation.
func (m *CalendarMutation) SyncDisabled() (r bool, exists bool) {
	v := m.sync_disabled
	if v == nil {
		return
	}
	return *v, true
}

// OldSyncDisabled returns the old "sync_disabled" field's value of the Calendar entity.
// If the Calendar object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CalendarMutation) OldSyncDisabled(ctx context.Context) (v bool, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldSyncDisabled is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldSyncDisabled requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldSyncDisabled: %w", err)
	}
	return oldValue.SyncDisabled, nil
}

// ResetSyncDisabled resets all changes to the "sync_disabled" field.
func (m *CalendarMutation) ResetSyncDisabled() {
	m.sync_disabled = nil
}

// SetReminderOverrides sets the "reminder_overrides" field.
func (m *CalendarMutation) SetReminderOverrides(so *settings.ReminderOverride) {
	m.reminder_overrides = &so
}

// ReminderOverrides returns the value of the "reminder_overrides" field in the mutation.
func (m *CalendarMutation) ReminderOverrides() (r *settings.ReminderOverride, exists bool) {
	v := m.reminder_overrides
	if v == nil {
		return
	}
	return *v, true
}

// OldReminderOverrides returns the old "reminder_overrides" field's value of the Calendar entity.
// If the Calendar object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CalendarMutation) OldReminderOverrides(ctx context.Context) (v *settings.ReminderOverride, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldReminderOverrides is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldReminderOverrides requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldReminderOverrides: %w", err)
	}
	return oldValue.ReminderOverrides, nil
}

// ClearReminderOverrides clears the value of the "reminder_overrides" field.
func (m *CalendarMutation) ClearReminderOverrides() {
	m.reminder_overrides = nil
	m.clearedFields[calendar.FieldReminderOverrides] = struct{}{}
}

// ReminderOverridesCleared returns if the "reminder_overrides" field was cleared in this mutation.
func (m *CalendarMutation) ReminderOverridesCleared() bool {
	_, ok := m.clearedFields[calendar.FieldReminderOverrides]
	return ok
}

// ResetReminderOverrides resets all changes to the "reminder_overrides" field.
func (m *CalendarMutation) ResetReminderOverrides() {
	m.reminder_overrides = nil
	delete(m.clearedFields, calendar.FieldReminderOverrides)
}

// SetSyncToken sets the "sync_token" field.
func (m *CalendarMutation) SetSyncToken(s string) {
	m.sync_token = &s
}

// SyncToken returns the value of the "sync_token" field in the mutation.
func (m *CalendarMutation) SyncToken() (r string, exists bool) {
	v := m.sync_token
	if v == nil {
		return
	}
	return *v, true
}

// OldSyncToken returns the old "sync_token" field's value of the Calendar entity.
// If the Calendar object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CalendarMutation) OldSyncToken(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldSyncToken is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldSyncToken requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldSyncToken: %w", err)
	}
	return oldValue.SyncToken, nil
}

// ClearSyncToken clears the value of the "sync_token" field.
func (m *CalendarMutation) ClearSyncToken() {
	m.sync_token = nil
	m.clearedFields[calendar.FieldSyncToken] = struct{}{}
}

// SyncTokenCleared returns if the "sync_token" field was cleared in this mutation.
func (m *CalendarMutation) SyncTokenCleared() bool {
	_, ok := m.clearedFields[calendar.FieldSyncToken]
	return ok
}

// ResetSyncToken resets all changes to the "sync_token" field.
func (m *CalendarMutation) ResetSyncToken() {
	m.sync_token = nil
	delete(m.clearedFields, calendar.FieldSyncToken)
}

// SetSupportedComponents sets the "supported_components" field.
func (m *CalendarMutation) SetSupportedComponents(s []string) {
	m.supported_components = &s
	m.appendsupported_components = nil
}

// SupportedComponents returns the value of the "supported_components" field in the mutation.
func (m *CalendarMutation) SupportedComponents() (r []string, exists bool) {
	v := m.supported_components
	if v == nil {
		return
	}
	return *v, true
}

// OldSupportedComponents returns the old "supported_components" field's value of the Calendar entity.
// If the Calendar object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CalendarMutation) OldSupportedComponents(ctx context.Context) (v []string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldSupportedComponents is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldSupportedComponents requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldSupportedComponents: %w", err)
	}
	return oldValue.SupportedComponents, nil
}

// AppendSupportedComponents adds s to the "supported_components" field.
func (m *CalendarMutation) AppendSupportedComponents(s []string) {
	m.appendsupported_components = append(m.appendsupported_components, s...)
}

// AppendedSupportedComponents returns the list of values that were appended to the "supported_components" field in this mutation.
func (m *CalendarMutation) AppendedSupportedComponents() ([]string, bool) {
	if len(m.appendsupported_components) == 0 {
		return nil, false
	}
	return m.appendsupported_components, true
}

// ClearSupportedComponents clears the value of the "supported_components" field.
func (m *CalendarMutation) ClearSupportedComponents() {
	m.supported_components = nil
	m.appendsupported_components = nil
	m.clearedFields[calendar.FieldSupportedComponents] = struct{}{}
}

// SupportedComponentsCleared returns if the "supported_components" field was cleared in this mutation.
func (m *CalendarMutation) SupportedComponentsCleared() bool {
	_, ok := m.clearedFields[calendar.FieldSupportedComponents]
	return ok
}

// ResetSupportedComponents resets all changes to the "supported_components" field.
func (m *CalendarMutation) ResetSupportedComponents() {
	m.supported_components = nil
	m.appendsupported_components = nil
	delete(m.clearedFields, calendar.FieldSupportedComponents)
}

// SetCreatedAt sets the "created_at" field.
func (m *CalendarMutation) SetCreatedAt(t time.Time) {
	m.created_at = &t
}

// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *CalendarMutation) CreatedAt() (r time.Time, exists bool) {
	v := m.created_at
	if v == nil {
		return
	}
	return *v, true
}

// OldCreatedAt returns the old "created_at" field's value of the Calendar entity.
// If the Calendar object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CalendarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldCreatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
	}
	return oldValue.CreatedAt, nil
}

// ResetCreatedAt resets all changes to the "created_at" field.
func (m *CalendarMutation) ResetCreatedAt() {
	m.created_at = nil
}

// SetUpdatedAt sets the "updated_at" field.
func (m *CalendarMutation) SetUpdatedAt(t time.Time) {
	m.updated_at = &t
}

// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *CalendarMutation) UpdatedAt() (r time.Time, exists bool) {
	v := m.updated_at
	if v == nil {
		return
	}
	return *v, true
}

// OldUpdatedAt returns the old "updated_at" field's value of the Calendar entity.
// If the Calendar object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CalendarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
	}
	return oldValue.UpdatedAt, nil
}

// ResetUpdatedAt resets all changes to the "updated_at" field.
func (m *CalendarMutation) ResetUpdatedAt() {
	m.updated_at = nil
}

// SetAccountID sets the "account" edge to the Account entity by id.
func (m *CalendarMutation) SetAccountID(id string) {
	m.account = &id
}

// ClearAccount clears the "account" edge to the Account entity.
func (m *CalendarMutation) ClearAccount() {
	m.clearedaccount = true
}

// AccountCleared reports if the "account" edge to the Account entity was cleared.
func (m *CalendarMutation) AccountCleared() bool {
	return m.clearedaccount
}

// AccountID returns the "account" edge ID in the mutation.
func (m *CalendarMutation) AccountID() (id string, exists bool) {
	if m.account != nil {
		return *m.account, true
	}
	return
}

// AccountIDs returns the "account" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// AccountID instead. It exists only for internal usage by the builders.
func (m *CalendarMutation) AccountIDs() (ids []string) {
	if id := m.account; id != nil {
		ids = append(ids, *id)
	}
	return
}

// ResetAccount resets all changes to the "account" edge.
func (m *CalendarMutation) ResetAccount() {
	m.account = nil
	m.clearedaccount = false
}

// AddEventIDs adds the "events" edge to the Event entity by ids.
func (m *CalendarMutation) AddEventIDs(ids ...string) {
	if m.events == nil {
		m.events = make(map[string]struct{})
	}
	for i := range ids {
		m.events[ids[i]] = struct{}{}
	}
}

// ClearEvents clears the "events" edge to the Event entity.
func (m *CalendarMutation) ClearEvents() {
	m.clearedevents = true
}

// EventsCleared reports if the "events" edge to the Event entity was cleared.
func (m *CalendarMutation) EventsCleared() bool {
	return m.clearedevents
}

// RemoveEventIDs removes the "events" edge to the Event entity by IDs.
func (m *CalendarMutation) RemoveEventIDs(ids ...string) {
	if m.removedevents == nil {
		m.removedevents = make(map[string]struct{})
	}
	for i := range ids {
		delete(m.events, ids[i])
		m.removedevents[ids[i]] = struct{}{}
	}
}

// RemovedEvents returns the removed IDs of the "events" edge to the Event entity.
func (m *CalendarMutation) RemovedEventsIDs() (ids []string) {
	for id := range m.removedevents {
		ids = append(ids, id)
	}
	return
}

// EventsIDs returns the "events" edge IDs in the mutation.
func (m *CalendarMutation) EventsIDs() (ids []string) {
	for id := range m.events {
		ids = append(ids, id)
	}
	return
}

// ResetEvents resets all changes to the "events" edge.
func (m *CalendarMutation) ResetEvents() {
	m.events = nil
	m.clearedevents = false
	m.removedevents = nil
}

// AddTaskIDs adds the "tasks" edge to the Task entity by ids.
func (m *CalendarMutation) AddTaskIDs(ids ...string) {
	if m.tasks == nil {
		m.tasks = make(map[string]struct{})
	}
	for i := range ids {
		m.tasks[ids[i]] = struct{}{}
	}
}

// ClearTasks clears the "tasks" edge to the Task entity.
func (m *CalendarMutation) ClearTasks() {
	m.clearedtasks = true
}

// TasksCleared reports if the "tasks" edge to the Task entity was cleared.
func (m *CalendarMutation) TasksCleared() bool {
	return m.clearedtasks
}

// RemoveTaskIDs removes the "tasks" edge to the Task entity by IDs.
func (m *CalendarMutation) RemoveTaskIDs(ids ...string) {
	if m.removedtasks == nil {
		m.removedtasks = make(map[string]struct{})
	}
	for i := range ids {
		delete(m.tasks, ids[i])
		m.removedtasks[ids[i]] = struct{}{}
	}
}

// RemovedTasks returns the removed IDs of the "tasks" edge to the Task entity.
func (m *CalendarMutation) RemovedTasksIDs() (ids []string) {
	for id := range m.removedtasks {
		ids = append(ids, id)
	}
	return
}

// TasksIDs returns the "tasks" edge IDs in the mutation.
func (m *CalendarMutation) TasksIDs() (ids []string) {
	for id := range m.tasks {
		ids = append(ids, id)
	}
	return
}

// ResetTasks resets all changes to the "tasks" edge.
func (m *CalendarMutation) ResetTasks() {
	m.tasks = nil
	m.clearedtasks = false
	m.removedtasks = nil
}

// Where appends a list predicates to the CalendarMutation builder.
func (m *CalendarMutation) Where(ps ...predicate.Calendar) {
	m.predicates = append(m.predicates, ps...)
}

// WhereP appends storage-level predicates to the CalendarMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *CalendarMutation) WhereP(ps ...func(*sql.Selector)) {
	p := make([]predicate.Calendar, len(ps))
	for i := range ps {
		p[i] = ps[i]
	}
	m.Where(p...)
}

// Op returns the operation name.
func (m *CalendarMutation) Op() Op {
	return m.op
}

// SetOp allows setting the mutation operation.
func (m *CalendarMutation) SetOp(op Op) {
	m.op = op
}

// Type returns the node type of this mutation (Calendar).
func (m *CalendarMutation) Type() string {
	return m.typ
}

// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *CalendarMutation) Fields() []string {
	fields := make([]string, 0, 14)
	if m.remote_id != nil {
		fields = append(fields, calendar.FieldRemoteID)
	}
	if m.name != nil {
		fields = append(fields, calendar.FieldName)
	}
	if m.name_override != nil {
		fields = append(fields, calendar.FieldNameOverride)
	}
	if m.description != nil {
		fields = append(fields, calendar.FieldDescription)
	}
	if m.color != nil {
		fields = append(fields, calendar.FieldColor)
	}
	if m.time_zone != nil {
		fields = append(fields, calendar.FieldTimeZone)
	}
	if m.read_only != nil {
		fields = append(fields, calendar.FieldReadOnly)
	}
	if m.hidden != nil {
		fields = append(fields, calendar.FieldHidden)
	}
	if m.sync_disabled != nil {
		fields = append(fields, calendar.FieldSyncDisabled)
	}
	if m.reminder_overrides != nil {
		fields = append(fields, calendar.FieldReminderOverrides)
	}
	if m.sync_token != nil {
		fields = append(fields, calendar.FieldSyncToken)
	}
	if m.supported_components != nil {
		fields = append(fields, calendar.FieldSupportedComponents)
	}
	if m.created_at != nil {
		fields = append(fields, calendar.FieldCreatedAt)
	}
	if m.updated_at != nil {
		fields = append(fields, calendar.FieldUpdatedAt)
	}
	return fields
}

// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *CalendarMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case calendar.FieldRemoteID:
		return m.RemoteID()
	case calendar.FieldName:
		return m.Name()
	case calendar.FieldNameOverride:
		return m.NameOverride()
	case calendar.FieldDescription:
		return m.Description()
	case calendar.FieldColor:
		return m.Color()
	case calendar.FieldTimeZone:
		return m.TimeZone()
	case calendar.FieldReadOnly:
		return m.ReadOnly()
	case calendar.FieldHidden:
		return m.Hidden()
	case calendar.FieldSyncDisabled:
		return m.SyncDisabled()
	case calendar.FieldReminderOverrides:
		return m.ReminderOverrides()
	case calendar.FieldSyncToken:
		return m.SyncToken()
	case calendar.FieldSupportedComponents:
		return m.SupportedComponents()
	case calendar.FieldCreatedAt:
		return m.CreatedAt()
	case calendar.FieldUpdatedAt:
		return m.UpdatedAt()
	}
	return nil, false
}

// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *CalendarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case calendar.FieldRemoteID:
		return m.OldRemoteID(ctx)
	case calendar.FieldName:
		return m.OldName(ctx)
	case calendar.FieldNameOverride:
		return m.OldNameOverride(ctx)
	case calendar.FieldDescription:
		return m.OldDescription(ctx)
	case calendar.FieldColor:
		return m.OldColor(ctx)
	case calendar.FieldTimeZone:
		return m.OldTimeZone(ctx)
	case calendar.FieldReadOnly:
		return m.OldReadOnly(ctx)
	case calendar.FieldHidden:
		return m.OldHidden(ctx)
	case calendar.FieldSyncDisabled:
		return m.OldSyncDisabled(ctx)
	case calendar.FieldReminderOverrides:
		return m.OldReminderOverrides(ctx)
	case calendar.FieldSyncToken:
		return m.OldSyncToken(ctx)
	case calendar.FieldSupportedComponents:
		return m.OldSupportedComponents(ctx)
	case calendar.FieldCreatedAt:
		return m.OldCreatedAt(ctx)
	case calendar.FieldUpdatedAt:
		return m.OldUpdatedAt(ctx)
	}
	return nil, fmt.Errorf("unknown Calendar field %s", name)
}

// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *CalendarMutation) SetField(name string, value ent.Value) error {
	switch name {
	case calendar.FieldRemoteID:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetRemoteID(v)
		return nil
	case calendar.FieldName:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetName(v)
		return nil
	case calendar.FieldNameOverride:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetNameOverride(v)
		return nil
	case calendar.FieldDescription:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetDescription(v)
		return nil
	case calendar.FieldColor:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetColor(v)
		return nil
	case calendar.FieldTimeZone:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetTimeZone(v)
		return nil
	case calendar.FieldReadOnly:
		v, ok := value.(bool)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetReadOnly(v)
		return nil
	case calendar.FieldHidden:
		v, ok := value.(bool)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetHidden(v)
		return nil
	case calendar.FieldSyncDisabled:
		v, ok := value.(bool)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetSyncDisabled(v)
		return nil
	case calendar.FieldReminderOverrides:
		v, ok := value.(*settings.ReminderOverride)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetReminderOverrides(v)
		return nil
	case calendar.FieldSyncToken:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetSyncToken(v)
		return nil
	case calendar.FieldSupportedComponents:
		v, ok := value.([]string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetSupportedComponents(v)
		return nil
	case calendar.FieldCreatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCreatedAt(v)
		return nil
	case calendar.FieldUpdatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUpdatedAt(v)
		return nil
	}
	return fmt.Errorf("unknown Calendar field %s", name)
}

// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *CalendarMutation) AddedFields() []string {
	return nil
}

// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
func (m *CalendarMutation) AddedField(name string) (ent.Value, bool) {
	return nil, false
}

// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *CalendarMutation) AddField(name string, value ent.Value) error {
	switch name {
	}
	return fmt.Errorf("unknown Calendar numeric field %s", name)
}

// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *CalendarMutation) ClearedFields() []string {
	var fields []string
	if m.FieldCleared(calendar.FieldNameOverride) {
		fields = append(fields, calendar.FieldNameOverride)
	}
	if m.FieldCleared(calendar.FieldDescription) {
		fields = append(fields, calendar.FieldDescription)
	}
	if m.FieldCleared(calendar.FieldColor) {
		fields = append(fields, calendar.FieldColor)
	}
	if m.FieldCleared(calendar.FieldTimeZone) {
		fields = append(fields, calendar.FieldTimeZone)
	}
	if m.FieldCleared(calendar.FieldReminderOverrides) {
		fields = append(fields, calendar.FieldReminderOverrides)
	}
	if m.FieldCleared(calendar.FieldSyncToken) {
		fields = append(fields, calendar.FieldSyncToken)
	}
	if m.FieldCleared(calendar.FieldSupportedComponents) {
		fields = append(fields, calendar.FieldSupportedComponents)
	}
	return fields
}

// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *CalendarMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}

// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
func (m *CalendarMutation) ClearField(name string) error {
	switch name {
	case calendar.FieldNameOverride:
		m.ClearNameOverride()
		return nil
	case calendar.FieldDescription:
		m.ClearDescription()
		return nil
	case calendar.FieldColor:
		m.ClearColor()
		return nil
	case calendar.FieldTimeZone:
		m.ClearTimeZone()
		return nil
	case calendar.FieldReminderOverrides:
		m.ClearReminderOverrides()
		return nil
	case calendar.FieldSyncToken:
		m.ClearSyncToken()
		return nil
	case calendar.FieldSupportedComponents:
		m.ClearSupportedComponents()
		return nil
	}
	return fmt.Errorf("unknown Calendar nullable field %s", name)
}

// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
func (m *CalendarMutation) ResetField(name string) error {
	switch name {
	case calendar.FieldRemoteID:
		m.ResetRemoteID()
		return nil
	case calendar.FieldName:
		m.ResetName()
		return nil
	case calendar.FieldNameOverride:
		m.ResetNameOverride()
		return nil
	case calendar.FieldDescription:
		m.ResetDescription()
		return nil
	case calendar.FieldColor:
		m.ResetColor()
		return nil
	case calendar.FieldTimeZone:
		m.ResetTimeZone()
		return nil
	case calendar.FieldReadOnly:
		m.ResetReadOnly()
		return nil
	case calendar.FieldHidden:
		m.ResetHidden()
		return nil
	case calendar.FieldSyncDisabled:
		m.ResetSyncDisabled()
		return nil
	case calendar.FieldReminderOverrides:
		m.ResetReminderOverrides()
		return nil
	case calendar.FieldSyncToken:
		m.ResetSyncToken()
		return nil
	case calendar.FieldSupportedComponents:
		m.ResetSupportedComponents()
		return nil
	case calendar.FieldCreatedAt:
		m.ResetCreatedAt()
		return nil
	case calendar.FieldUpdatedAt:
		m.ResetUpdatedAt()
		return nil
	}
	return fmt.Errorf("unknown Calendar field %s", name)
}

// AddedEdges returns all edge names that were set/added in this mutation.
func (m *CalendarMutation) AddedEdges() []string {
	edges := make([]string, 0, 3)
	if m.account != nil {
		edges = append(edges, calendar.EdgeAccount)
	}
	if m.events != nil {
		edges = append(edges, calendar.EdgeEvents)
	}
	if m.tasks != nil {
		edges = append(edges, calendar.EdgeTasks)
	}
	return edges
}

// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *CalendarMutation) AddedIDs(name string) []ent.Value {
	switch name {
	case calendar.EdgeAccount:
		if id := m.account; id != nil {
			return []ent.Value{*id}
		}
	case calendar.EdgeEvents:
		ids := make([]ent.Value, 0, len(m.events))
		for id := range m.events {
			ids = append(ids, id)
		}
		return ids
	case calendar.EdgeTasks:
		ids := make([]ent.Value, 0, len(m.tasks))
		for id := range m.tasks {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}

// RemovedEdges returns all edge names that were removed in this mutation.
func (m *CalendarMutation) RemovedEdges() []string {
	edges := make([]string, 0, 3)
	if m.removedevents != nil {
		edges = append(edges, calendar.EdgeEvents)
	}
	if m.removedtasks != nil {
		edges = append(edges, calendar.EdgeTasks)
	}
	return edges
}

// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *CalendarMutation) RemovedIDs(name string) []ent.Value {
	switch name {
	case calendar.EdgeEvents:
		ids := make([]ent.Value, 0, len(m.removedevents))
		for id := range m.removedevents {
			ids = append(ids, id)
		}
		return ids
	case calendar.EdgeTasks:
		ids := make([]ent.Value, 0, len(m.removedtasks))
		for id := range m.removedtasks {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}

// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *CalendarMutation) ClearedEdges() []string {
	edges := make([]string, 0, 3)
	if m.clearedaccount {
		edges = append(edges, calendar.EdgeAccount)
	}
	if m.clearedevents {
		edges = append(edges, calendar.EdgeEvents)
	}
	if m.clearedtasks {
		edges = append(edges, calendar.EdgeTasks)
	}
	return edges
}

// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *CalendarMutation) EdgeCleared(name string) bool {
	switch name {
	case calendar.EdgeAccount:
		return m.clearedaccount
	case calendar.EdgeEvents:
		return m.clearedevents
	case calendar.EdgeTasks:
		return m.clearedtasks
	}
	return false
}

// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *CalendarMutation) ClearEdge(name string) error {
	switch name {
	case calendar.EdgeAccount:
		m.ClearAccount()
		return nil
	}
	return fmt.Errorf("unknown Calendar unique edge %s", name)
}

// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *CalendarMutation) ResetEdge(name string) error {
	switch name {
	case calendar.EdgeAccount:
		m.ResetAccount()
		return nil
	case calendar.EdgeEvents:
		m.ResetEvents()
		return nil
	case calendar.EdgeTasks:
		m.ResetTasks()
		return nil
	}
	return fmt.Errorf("unknown Calendar edge %s", name)
}

// EventMutation represents an operation that mutates the Event nodes in the graph.
type EventMutation struct {
	config
	op               Op
	typ              string
	id               *string
	uid              *string
	remote_id        *string
	etag             *string
	summary          *string
	description      *string
	location         *string
	url              *string
	meeting_url      *string
	status           *event.Status
	start            *time.Time
	end              *time.Time
	all_day          *bool
	start_tz         *string
	end_tz           *string
	recurrence       *map[string]interface{}
	recurring_id     *string
	original_start   *time.Time
	organizer        *map[string]interface{}
	attendees        *[]map[string]interface{}
	appendattendees  []map[string]interface{}
	reminders        *[]map[string]interface{}
	appendreminders  []map[string]interface{}
	categories       *[]string
	appendcategories []string
	transparency     *string
	visibility       *string
	raw_ics          *string
	created          *time.Time
	updated          *time.Time
	clearedFields    map[string]struct{}
	calendar         *string
	clearedcalendar  bool
	done             bool
	oldValue         func(context.Context) (*Event, error)
	predicates       []predicate.Event
}

var _ ent.Mutation = (*EventMutation)(nil)

// eventOption allows management of the mutation configuration using functional options.
type eventOption func(*EventMutation)

// newEventMutation creates new mutation for the Event entity.
func newEventMutation(c config, op Op, opts ...eventOption) *EventMutation {
	m := &EventMutation{
		config:        c,
		op:            op,
		typ:           TypeEvent,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}

// withEventID sets the ID field of the mutation.
func withEventID(id string) eventOption {
	return func(m *EventMutation) {
		var (
			err   error
			once  sync.Once
			value *Event
		)
		m.oldValue = func(ctx context.Context) (*Event, error) {
			once.Do(func() {
				if m.done {
					err = errors.New("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().Event.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}

// withEvent sets the old Event of the mutation.
func withEvent(node *Event) eventOption {
	return func(m *EventMutation) {
		m.oldValue = func(context.Context) (*Event, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}

// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
func (m EventMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}

// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
func (m EventMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, errors.New("ent: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}

// SetID sets the value of the id field. Note that this
// operation is only accepted on creation of Event entities.
func (m *EventMutation) SetID(id string) {
	m.id = &id
}

// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *EventMutation) ID() (id string, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}

// IDs queries the database and returns the entity ids that match the mutation's predicate.
// That means, if the mutation is applied within a transaction with an isolation level such
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
// or updated by the mutation.
func (m *EventMutation) IDs(ctx context.Context) ([]string, error) {
	switch {
	case m.op.Is(OpUpdateOne | OpDeleteOne):
		id, exists := m.ID()
		if exists {
			return []string{id}, nil
		}
		fallthrough
	case m.op.Is(OpUpdate | OpDelete):
		return m.Client().Event.Query().Where(m.predicates...).IDs(ctx)
	default:
		return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
	}
}

// SetUID sets the "uid" field.
func (m *EventMutation) SetUID(s string) {
	m.uid = &s
}

// UID returns the value of the "uid" field in the mutation.
func (m *EventMutation) UID() (r string, exists bool) {
	v := m.uid
	if v == nil {
		return
	}
	return *v, true
}

// OldUID returns the old "uid" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldUID(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldUID is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldUID requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUID: %w", err)
	}
	return oldValue.UID, nil
}

// ResetUID resets all changes to the "uid" field.
func (m *EventMutation) ResetUID() {
	m.uid = nil
}

// SetRemoteID sets the "remote_id" field.
func (m *EventMutation) SetRemoteID(s string) {
	m.remote_id = &s
}

// RemoteID returns the value of the "remote_id" field in the mutation.
func (m *EventMutation) RemoteID() (r string, exists bool) {
	v := m.remote_id
	if v == nil {
		return
	}
	return *v, true
}

// OldRemoteID returns the old "remote_id" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldRemoteID(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldRemoteID is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldRemoteID requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldRemoteID: %w", err)
	}
	return oldValue.RemoteID, nil
}

// ClearRemoteID clears the value of the "remote_id" field.
func (m *EventMutation) ClearRemoteID() {
	m.remote_id = nil
	m.clearedFields[event.FieldRemoteID] = struct{}{}
}

// RemoteIDCleared returns if the "remote_id" field was cleared in this mutation.
func (m *EventMutation) RemoteIDCleared() bool {
	_, ok := m.clearedFields[event.FieldRemoteID]
	return ok
}

// ResetRemoteID resets all changes to the "remote_id" field.
func (m *EventMutation) ResetRemoteID() {
	m.remote_id = nil
	delete(m.clearedFields, event.FieldRemoteID)
}

// SetEtag sets the "etag" field.
func (m *EventMutation) SetEtag(s string) {
	m.etag = &s
}

// Etag returns the value of the "etag" field in the mutation.
func (m *EventMutation) Etag() (r string, exists bool) {
	v := m.etag
	if v == nil {
		return
	}
	return *v, true
}

// OldEtag returns the old "etag" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldEtag(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldEtag is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldEtag requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldEtag: %w", err)
	}
	return oldValue.Etag, nil
}

// ClearEtag clears the value of the "etag" field.
func (m *EventMutation) ClearEtag() {
	m.etag = nil
	m.clearedFields[event.FieldEtag] = struct{}{}
}

// EtagCleared returns if the "etag" field was cleared in this mutation.
func (m *EventMutation) EtagCleared() bool {
	_, ok := m.clearedFields[event.FieldEtag]
	return ok
}

// ResetEtag resets all changes to the "etag" field.
func (m *EventMutation) ResetEtag() {
	m.etag = nil
	delete(m.clearedFields, event.FieldEtag)
}

// SetSummary sets the "summary" field.
func (m *EventMutation) SetSummary(s string) {
	m.summary = &s
}

// Summary returns the value of the "summary" field in the mutation.
func (m *EventMutation) Summary() (r string, exists bool) {
	v := m.summary
	if v == nil {
		return
	}
	return *v, true
}

// OldSummary returns the old "summary" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldSummary(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldSummary is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldSummary requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldSummary: %w", err)
	}
	return oldValue.Summary, nil
}

// ResetSummary resets all changes to the "summary" field.
func (m *EventMutation) ResetSummary() {
	m.summary = nil
}

// SetDescription sets the "description" field.
func (m *EventMutation) SetDescription(s string) {
	m.description = &s
}

// Description returns the value of the "description" field in the mutation.
func (m *EventMutation) Description() (r string, exists bool) {
	v := m.description
	if v == nil {
		return
	}
	return *v, true
}

// OldDescription returns the old "description" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldDescription(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldDescription is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldDescription requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldDescription: %w", err)
	}
	return oldValue.Description, nil
}

// ClearDescription clears the value of the "description" field.
func (m *EventMutation) ClearDescription() {
	m.description = nil
	m.clearedFields[event.FieldDescription] = struct{}{}
}

// DescriptionCleared returns if the "description" field was cleared in this mutation.
func (m *EventMutation) DescriptionCleared() bool {
	_, ok := m.clearedFields[event.FieldDescription]
	return ok
}

// ResetDescription resets all changes to the "description" field.
func (m *EventMutation) ResetDescription() {
	m.description = nil
	delete(m.clearedFields, event.FieldDescription)
}

// SetLocation sets the "location" field.
func (m *EventMutation) SetLocation(s string) {
	m.location = &s
}

// Location returns the value of the "location" field in the mutation.
func (m *EventMutation) Location() (r string, exists bool) {
	v := m.location
	if v == nil {
		return
	}
	return *v, true
}

// OldLocation returns the old "location" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldLocation(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldLocation is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldLocation requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldLocation: %w", err)
	}
	return oldValue.Location, nil
}

// ClearLocation clears the value of the "location" field.
func (m *EventMutation) ClearLocation() {
	m.location = nil
	m.clearedFields[event.FieldLocation] = struct{}{}
}

// LocationCleared returns if the "location" field was cleared in this mutation.
func (m *EventMutation) LocationCleared() bool {
	_, ok := m.clearedFields[event.FieldLocation]
	return ok
}

// ResetLocation resets all changes to the "location" field.
func (m *EventMutation) ResetLocation() {
	m.location = nil
	delete(m.clearedFields, event.FieldLocation)
}

// SetURL sets the "url" field.
func (m *EventMutation) SetURL(s string) {
	m.url = &s
}

// URL returns the value of the "url" field in the mutation.
func (m *EventMutation) URL() (r string, exists bool) {
	v := m.url
	if v == nil {
		return
	}
	return *v, true
}

// OldURL returns the old "url" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldURL(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldURL is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldURL requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldURL: %w", err)
	}
	return oldValue.URL, nil
}

// ClearURL clears the value of the "url" field.
func (m *EventMutation) ClearURL() {
	m.url = nil
	m.clearedFields[event.FieldURL] = struct{}{}
}

// URLCleared returns if the "url" field was cleared in this mutation.
func (m *EventMutation) URLCleared() bool {
	_, ok := m.clearedFields[event.FieldURL]
	return ok
}

// ResetURL resets all changes to the "url" field.
func (m *EventMutation) ResetURL() {
	m.url = nil
	delete(m.clearedFields, event.FieldURL)
}

// SetMeetingURL sets the "meeting_url" field.
func (m *EventMutation) SetMeetingURL(s string) {
	m.meeting_url = &s
}

// MeetingURL returns the value of the "meeting_url" field in the mutation.
func (m *EventMutation) MeetingURL() (r string, exists bool) {
	v := m.meeting_url
	if v == nil {
		return
	}
	return *v, true
}

// OldMeetingURL returns the old "meeting_url" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldMeetingURL(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldMeetingURL is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldMeetingURL requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldMeetingURL: %w", err)
	}
	return oldValue.MeetingURL, nil
}

// ClearMeetingURL clears the value of the "meeting_url" field.
func (m *EventMutation) ClearMeetingURL() {
	m.meeting_url = nil
	m.clearedFields[event.FieldMeetingURL] = struct{}{}
}

// MeetingURLCleared returns if the "meeting_url" field was cleared in this mutation.
func (m *EventMutation) MeetingURLCleared() bool {
	_, ok := m.clearedFields[event.FieldMeetingURL]
	return ok
}

// ResetMeetingURL resets all changes to the "meeting_url" field.
func (m *EventMutation) ResetMeetingURL() {
	m.meeting_url = nil
	delete(m.clearedFields, event.FieldMeetingURL)
}

// SetStatus sets the "status" field.
func (m *EventMutation) SetStatus(e event.Status) {
	m.status = &e
}

// Status returns the value of the "status" field in the mutation.
func (m *EventMutation) Status() (r event.Status, exists bool) {
	v := m.status
	if v == nil {
		return
	}
	return *v, true
}

// OldStatus returns the old "status" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldStatus(ctx context.Context) (v event.Status, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldStatus is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldStatus requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldStatus: %w", err)
	}
	return oldValue.Status, nil
}

// ResetStatus resets all changes to the "status" field.
func (m *EventMutation) ResetStatus() {
	m.status = nil
}

// SetStart sets the "start" field.
func (m *EventMutation) SetStart(t time.Time) {
	m.start = &t
}

// Start returns the value of the "start" field in the mutation.
func (m *EventMutation) Start() (r time.Time, exists bool) {
	v := m.start
	if v == nil {
		return
	}
	return *v, true
}

// OldStart returns the old "start" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldStart(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldStart is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldStart requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldStart: %w", err)
	}
	return oldValue.Start, nil
}

// ResetStart resets all changes to the "start" field.
func (m *EventMutation) ResetStart() {
	m.start = nil
}

// SetEnd sets the "end" field.
func (m *EventMutation) SetEnd(t time.Time) {
	m.end = &t
}

// End returns the value of the "end" field in the mutation.
func (m *EventMutation) End() (r time.Time, exists bool) {
	v := m.end
	if v == nil {
		return
	}
	return *v, true
}

// OldEnd returns the old "end" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldEnd(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldEnd is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldEnd requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldEnd: %w", err)
	}
	return oldValue.End, nil
}

// ResetEnd resets all changes to the "end" field.
func (m *EventMutation) ResetEnd() {
	m.end = nil
}

// SetAllDay sets the "all_day" field.
func (m *EventMutation) SetAllDay(b bool) {
	m.all_day = &b
}

// AllDay returns the value of the "all_day" field in the mutation.
func (m *EventMutation) AllDay() (r bool, exists bool) {
	v := m.all_day
	if v == nil {
		return
	}
	return *v, true
}

// OldAllDay returns the old "all_day" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldAllDay(ctx context.Context) (v bool, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldAllDay is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldAllDay requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldAllDay: %w", err)
	}
	return oldValue.AllDay, nil
}

// ResetAllDay resets all changes to the "all_day" field.
func (m *EventMutation) ResetAllDay() {
	m.all_day = nil
}

// SetStartTz sets the "start_tz" field.
func (m *EventMutation) SetStartTz(s string) {
	m.start_tz = &s
}

// StartTz returns the value of the "start_tz" field in the mutation.
func (m *EventMutation) StartTz() (r string, exists bool) {
	v := m.start_tz
	if v == nil {
		return
	}
	return *v, true
}

// OldStartTz returns the old "start_tz" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldStartTz(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldStartTz is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldStartTz requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldStartTz: %w", err)
	}
	return oldValue.StartTz, nil
}

// ClearStartTz clears the value of the "start_tz" field.
func (m *EventMutation) ClearStartTz() {
	m.start_tz = nil
	m.clearedFields[event.FieldStartTz] = struct{}{}
}

// StartTzCleared returns if the "start_tz" field was cleared in this mutation.
func (m *EventMutation) StartTzCleared() bool {
	_, ok := m.clearedFields[event.FieldStartTz]
	return ok
}

// ResetStartTz resets all changes to the "start_tz" field.
func (m *EventMutation) ResetStartTz() {
	m.start_tz = nil
	delete(m.clearedFields, event.FieldStartTz)
}

// SetEndTz sets the "end_tz" field.
func (m *EventMutation) SetEndTz(s string) {
	m.end_tz = &s
}

// EndTz returns the value of the "end_tz" field in the mutation.
func (m *EventMutation) EndTz() (r string, exists bool) {
	v := m.end_tz
	if v == nil {
		return
	}
	return *v, true
}

// OldEndTz returns the old "end_tz" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldEndTz(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldEndTz is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldEndTz requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldEndTz: %w", err)
	}
	return oldValue.EndTz, nil
}

// ClearEndTz clears the value of the "end_tz" field.
func (m *EventMutation) ClearEndTz() {
	m.end_tz = nil
	m.clearedFields[event.FieldEndTz] = struct{}{}
}

// EndTzCleared returns if the "end_tz" field was cleared in this mutation.
func (m *EventMutation) EndTzCleared() bool {
	_, ok := m.clearedFields[event.FieldEndTz]
	return ok
}

// ResetEndTz resets all changes to the "end_tz" field.
func (m *EventMutation) ResetEndTz() {
	m.end_tz = nil
	delete(m.clearedFields, event.FieldEndTz)
}

// SetRecurrence sets the "recurrence" field.
func (m *EventMutation) SetRecurrence(value map[string]interface{}) {
	m.recurrence = &value
}

// Recurrence returns the value of the "recurrence" field in the mutation.
func (m *EventMutation) Recurrence() (r map[string]interface{}, exists bool) {
	v := m.recurrence
	if v == nil {
		return
	}
	return *v, true
}

// OldRecurrence returns the old "recurrence" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldRecurrence(ctx context.Context) (v map[string]interface{}, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldRecurrence is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldRecurrence requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldRecurrence: %w", err)
	}
	return oldValue.Recurrence, nil
}

// ClearRecurrence clears the value of the "recurrence" field.
func (m *EventMutation) ClearRecurrence() {
	m.recurrence = nil
	m.clearedFields[event.FieldRecurrence] = struct{}{}
}

// RecurrenceCleared returns if the "recurrence" field was cleared in this mutation.
func (m *EventMutation) RecurrenceCleared() bool {
	_, ok := m.clearedFields[event.FieldRecurrence]
	return ok
}

// ResetRecurrence resets all changes to the "recurrence" field.
func (m *EventMutation) ResetRecurrence() {
	m.recurrence = nil
	delete(m.clearedFields, event.FieldRecurrence)
}

// SetRecurringID sets the "recurring_id" field.
func (m *EventMutation) SetRecurringID(s string) {
	m.recurring_id = &s
}

// RecurringID returns the value of the "recurring_id" field in the mutation.
func (m *EventMutation) RecurringID() (r string, exists bool) {
	v := m.recurring_id
	if v == nil {
		return
	}
	return *v, true
}

// OldRecurringID returns the old "recurring_id" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldRecurringID(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldRecurringID is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldRecurringID requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldRecurringID: %w", err)
	}
	return oldValue.RecurringID, nil
}

// ClearRecurringID clears the value of the "recurring_id" field.
func (m *EventMutation) ClearRecurringID() {
	m.recurring_id = nil
	m.clearedFields[event.FieldRecurringID] = struct{}{}
}

// RecurringIDCleared returns if the "recurring_id" field was cleared in this mutation.
func (m *EventMutation) RecurringIDCleared() bool {
	_, ok := m.clearedFields[event.FieldRecurringID]
	return ok
}

// ResetRecurringID resets all changes to the "recurring_id" field.
func (m *EventMutation) ResetRecurringID() {
	m.recurring_id = nil
	delete(m.clearedFields, event.FieldRecurringID)
}

// SetOriginalStart sets the "original_start" field.
func (m *EventMutation) SetOriginalStart(t time.Time) {
	m.original_start = &t
}

// OriginalStart returns the value of the "original_start" field in the mutation.
func (m *EventMutation) OriginalStart() (r time.Time, exists bool) {
	v := m.original_start
	if v == nil {
		return
	}
	return *v, true
}

// OldOriginalStart returns the old "original_start" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldOriginalStart(ctx context.Context) (v *time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldOriginalStart is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldOriginalStart requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldOriginalStart: %w", err)
	}
	return oldValue.OriginalStart, nil
}

// ClearOriginalStart clears the value of the "original_start" field.
func (m *EventMutation) ClearOriginalStart() {
	m.original_start = nil
	m.clearedFields[event.FieldOriginalStart] = struct{}{}
}

// OriginalStartCleared returns if the "original_start" field was cleared in this mutation.
func (m *EventMutation) OriginalStartCleared() bool {
	_, ok := m.clearedFields[event.FieldOriginalStart]
	return ok
}

// ResetOriginalStart resets all changes to the "original_start" field.
func (m *EventMutation) ResetOriginalStart() {
	m.original_start = nil
	delete(m.clearedFields, event.FieldOriginalStart)
}

// SetOrganizer sets the "organizer" field.
func (m *EventMutation) SetOrganizer(value map[string]interface{}) {
	m.organizer = &value
}

// Organizer returns the value of the "organizer" field in the mutation.
func (m *EventMutation) Organizer() (r map[string]interface{}, exists bool) {
	v := m.organizer
	if v == nil {
		return
	}
	return *v, true
}

// OldOrganizer returns the old "organizer" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldOrganizer(ctx context.Context) (v map[string]interface{}, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldOrganizer is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldOrganizer requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldOrganizer: %w", err)
	}
	return oldValue.Organizer, nil
}

// ClearOrganizer clears the value of the "organizer" field.
func (m *EventMutation) ClearOrganizer() {
	m.organizer = nil
	m.clearedFields[event.FieldOrganizer] = struct{}{}
}

// OrganizerCleared returns if the "organizer" field was cleared in this mutation.
func (m *EventMutation) OrganizerCleared() bool {
	_, ok := m.clearedFields[event.FieldOrganizer]
	return ok
}

// ResetOrganizer resets all changes to the "organizer" field.
func (m *EventMutation) ResetOrganizer() {
	m.organizer = nil
	delete(m.clearedFields, event.FieldOrganizer)
}

// SetAttendees sets the "attendees" field.
func (m *EventMutation) SetAttendees(value []map[string]interface{}) {
	m.attendees = &value
	m.appendattendees = nil
}

// Attendees returns the value of the "attendees" field in the mutation.
func (m *EventMutation) Attendees() (r []map[string]interface{}, exists bool) {
	v := m.attendees
	if v == nil {
		return
	}
	return *v, true
}

// OldAttendees returns the old "attendees" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldAttendees(ctx context.Context) (v []map[string]interface{}, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldAttendees is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldAttendees requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldAttendees: %w", err)
	}
	return oldValue.Attendees, nil
}

// AppendAttendees adds value to the "attendees" field.
func (m *EventMutation) AppendAttendees(value []map[string]interface{}) {
	m.appendattendees = append(m.appendattendees, value...)
}

// AppendedAttendees returns the list of values that were appended to the "attendees" field in this mutation.
func (m *EventMutation) AppendedAttendees() ([]map[string]interface{}, bool) {
	if len(m.appendattendees) == 0 {
		return nil, false
	}
	return m.appendattendees, true
}

// ClearAttendees clears the value of the "attendees" field.
func (m *EventMutation) ClearAttendees() {
	m.attendees = nil
	m.appendattendees = nil
	m.clearedFields[event.FieldAttendees] = struct{}{}
}

// AttendeesCleared returns if the "attendees" field was cleared in this mutation.
func (m *EventMutation) AttendeesCleared() bool {
	_, ok := m.clearedFields[event.FieldAttendees]
	return ok
}

// ResetAttendees resets all changes to the "attendees" field.
func (m *EventMutation) ResetAttendees() {
	m.attendees = nil
	m.appendattendees = nil
	delete(m.clearedFields, event.FieldAttendees)
}

// SetReminders sets the "reminders" field.
func (m *EventMutation) SetReminders(value []map[string]interface{}) {
	m.reminders = &value
	m.appendreminders = nil
}

// Reminders returns the value of the "reminders" field in the mutation.
func (m *EventMutation) Reminders() (r []map[string]interface{}, exists bool) {
	v := m.reminders
	if v == nil {
		return
	}
	return *v, true
}

// OldReminders returns the old "reminders" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldReminders(ctx context.Context) (v []map[string]interface{}, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldReminders is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldReminders requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldReminders: %w", err)
	}
	return oldValue.Reminders, nil
}

// AppendReminders adds value to the "reminders" field.
func (m *EventMutation) AppendReminders(value []map[string]interface{}) {
	m.appendreminders = append(m.appendreminders, value...)
}

// AppendedReminders returns the list of values that were appended to the "reminders" field in this mutation.
func (m *EventMutation) AppendedReminders() ([]map[string]interface{}, bool) {
	if len(m.appendreminders) == 0 {
		return nil, false
	}
	return m.appendreminders, true
}

// ClearReminders clears the value of the "reminders" field.
func (m *EventMutation) ClearReminders() {
	m.reminders = nil
	m.appendreminders = nil
	m.clearedFields[event.FieldReminders] = struct{}{}
}

// RemindersCleared returns if the "reminders" field was cleared in this mutation.
func (m *EventMutation) RemindersCleared() bool {
	_, ok := m.clearedFields[event.FieldReminders]
	return ok
}

// ResetReminders resets all changes to the "reminders" field.
func (m *EventMutation) ResetReminders() {
	m.reminders = nil
	m.appendreminders = nil
	delete(m.clearedFields, event.FieldReminders)
}

// SetCategories sets the "categories" field.
func (m *EventMutation) SetCategories(s []string) {
	m.categories = &s
	m.appendcategories = nil
}

// Categories returns the value of the "categories" field in the mutation.
func (m *EventMutation) Categories() (r []string, exists bool) {
	v := m.categories
	if v == nil {
		return
	}
	return *v, true
}

// OldCategories returns the old "categories" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldCategories(ctx context.Context) (v []string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldCategories is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldCategories requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCategories: %w", err)
	}
	return oldValue.Categories, nil
}

// AppendCategories adds s to the "categories" field.
func (m *EventMutation) AppendCategories(s []string) {
	m.appendcategories = append(m.appendcategories, s...)
}

// AppendedCategories returns the list of values that were appended to the "categories" field in this mutation.
func (m *EventMutation) AppendedCategories() ([]string, bool) {
	if len(m.appendcategories) == 0 {
		return nil, false
	}
	return m.appendcategories, true
}

// ClearCategories clears the value of the "categories" field.
func (m *EventMutation) ClearCategories() {
	m.categories = nil
	m.appendcategories = nil
	m.clearedFields[event.FieldCategories] = struct{}{}
}

// CategoriesCleared returns if the "categories" field was cleared in this mutation.
func (m *EventMutation) CategoriesCleared() bool {
	_, ok := m.clearedFields[event.FieldCategories]
	return ok
}

// ResetCategories resets all changes to the "categories" field.
func (m *EventMutation) ResetCategories() {
	m.categories = nil
	m.appendcategories = nil
	delete(m.clearedFields, event.FieldCategories)
}

// SetTransparency sets the "transparency" field.
func (m *EventMutation) SetTransparency(s string) {
	m.transparency = &s
}

// Transparency returns the value of the "transparency" field in the mutation.
func (m *EventMutation) Transparency() (r string, exists bool) {
	v := m.transparency
	if v == nil {
		return
	}
	return *v, true
}

// OldTransparency returns the old "transparency" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldTransparency(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldTransparency is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldTransparency requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldTransparency: %w", err)
	}
	return oldValue.Transparency, nil
}

// ClearTransparency clears the value of the "transparency" field.
func (m *EventMutation) ClearTransparency() {
	m.transparency = nil
	m.clearedFields[event.FieldTransparency] = struct{}{}
}

// TransparencyCleared returns if the "transparency" field was cleared in this mutation.
func (m *EventMutation) TransparencyCleared() bool {
	_, ok := m.clearedFields[event.FieldTransparency]
	return ok
}

// ResetTransparency resets all changes to the "transparency" field.
func (m *EventMutation) ResetTransparency() {
	m.transparency = nil
	delete(m.clearedFields, event.FieldTransparency)
}

// SetVisibility sets the "visibility" field.
func (m *EventMutation) SetVisibility(s string) {
	m.visibility = &s
}

// Visibility returns the value of the "visibility" field in the mutation.
func (m *EventMutation) Visibility() (r string, exists bool) {
	v := m.visibility
	if v == nil {
		return
	}
	return *v, true
}

// OldVisibility returns the old "visibility" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldVisibility(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldVisibility is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldVisibility requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldVisibility: %w", err)
	}
	return oldValue.Visibility, nil
}

// ClearVisibility clears the value of the "visibility" field.
func (m *EventMutation) ClearVisibility() {
	m.visibility = nil
	m.clearedFields[event.FieldVisibility] = struct{}{}
}

// VisibilityCleared returns if the "visibility" field was cleared in this mutation.
func (m *EventMutation) VisibilityCleared() bool {
	_, ok := m.clearedFields[event.FieldVisibility]
	return ok
}

// ResetVisibility resets all changes to the "visibility" field.
func (m *EventMutation) ResetVisibility() {
	m.visibility = nil
	delete(m.clearedFields, event.FieldVisibility)
}

// SetRawIcs sets the "raw_ics" field.
func (m *EventMutation) SetRawIcs(s string) {
	m.raw_ics = &s
}

// RawIcs returns the value of the "raw_ics" field in the mutation.
func (m *EventMutation) RawIcs() (r string, exists bool) {
	v := m.raw_ics
	if v == nil {
		return
	}
	return *v, true
}

// OldRawIcs returns the old "raw_ics" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldRawIcs(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldRawIcs is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldRawIcs requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldRawIcs: %w", err)
	}
	return oldValue.RawIcs, nil
}

// ClearRawIcs clears the value of the "raw_ics" field.
func (m *EventMutation) ClearRawIcs() {
	m.raw_ics = nil
	m.clearedFields[event.FieldRawIcs] = struct{}{}
}

// RawIcsCleared returns if the "raw_ics" field was cleared in this mutation.
func (m *EventMutation) RawIcsCleared() bool {
	_, ok := m.clearedFields[event.FieldRawIcs]
	return ok
}

// ResetRawIcs resets all changes to the "raw_ics" field.
func (m *EventMutation) ResetRawIcs() {
	m.raw_ics = nil
	delete(m.clearedFields, event.FieldRawIcs)
}

// SetCreated sets the "created" field.
func (m *EventMutation) SetCreated(t time.Time) {
	m.created = &t
}

// Created returns the value of the "created" field in the mutation.
func (m *EventMutation) Created() (r time.Time, exists bool) {
	v := m.created
	if v == nil {
		return
	}
	return *v, true
}

// OldCreated returns the old "created" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldCreated(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldCreated is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldCreated requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCreated: %w", err)
	}
	return oldValue.Created, nil
}

// ResetCreated resets all changes to the "created" field.
func (m *EventMutation) ResetCreated() {
	m.created = nil
}

// SetUpdated sets the "updated" field.
func (m *EventMutation) SetUpdated(t time.Time) {
	m.updated = &t
}

// Updated returns the value of the "updated" field in the mutation.
func (m *EventMutation) Updated() (r time.Time, exists bool) {
	v := m.updated
	if v == nil {
		return
	}
	return *v, true
}

// OldUpdated returns the old "updated" field's value of the Event entity.
// If the Event object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *EventMutation) OldUpdated(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldUpdated is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldUpdated requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUpdated: %w", err)
	}
	return oldValue.Updated, nil
}

// ResetUpdated resets all changes to the "updated" field.
func (m *EventMutation) ResetUpdated() {
	m.updated = nil
}

// SetCalendarID sets the "calendar" edge to the Calendar entity by id.
func (m *EventMutation) SetCalendarID(id string) {
	m.calendar = &id
}

// ClearCalendar clears the "calendar" edge to the Calendar entity.
func (m *EventMutation) ClearCalendar() {
	m.clearedcalendar = true
}

// CalendarCleared reports if the "calendar" edge to the Calendar entity was cleared.
func (m *EventMutation) CalendarCleared() bool {
	return m.clearedcalendar
}

// CalendarID returns the "calendar" edge ID in the mutation.
func (m *EventMutation) CalendarID() (id string, exists bool) {
	if m.calendar != nil {
		return *m.calendar, true
	}
	return
}

// CalendarIDs returns the "calendar" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// CalendarID instead. It exists only for internal usage by the builders.
func (m *EventMutation) CalendarIDs() (ids []string) {
	if id := m.calendar; id != nil {
		ids = append(ids, *id)
	}
	return
}

// ResetCalendar resets all changes to the "calendar" edge.
func (m *EventMutation) ResetCalendar() {
	m.calendar = nil
	m.clearedcalendar = false
}

// Where appends a list predicates to the EventMutation builder.
func (m *EventMutation) Where(ps ...predicate.Event) {
	m.predicates = append(m.predicates, ps...)
}

// WhereP appends storage-level predicates to the EventMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *EventMutation) WhereP(ps ...func(*sql.Selector)) {
	p := make([]predicate.Event, len(ps))
	for i := range ps {
		p[i] = ps[i]
	}
	m.Where(p...)
}

// Op returns the operation name.
func (m *EventMutation) Op() Op {
	return m.op
}

// SetOp allows setting the mutation operation.
func (m *EventMutation) SetOp(op Op) {
	m.op = op
}

// Type returns the node type of this mutation (Event).
func (m *EventMutation) Type() string {
	return m.typ
}

// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *EventMutation) Fields() []string {
	fields := make([]string, 0, 26)
	if m.uid != nil {
		fields = append(fields, event.FieldUID)
	}
	if m.remote_id != nil {
		fields = append(fields, event.FieldRemoteID)
	}
	if m.etag != nil {
		fields = append(fields, event.FieldEtag)
	}
	if m.summary != nil {
		fields = append(fields, event.FieldSummary)
	}
	if m.description != nil {
		fields = append(fields, event.FieldDescription)
	}
	if m.location != nil {
		fields = append(fields, event.FieldLocation)
	}
	if m.url != nil {
		fields = append(fields, event.FieldURL)
	}
	if m.meeting_url != nil {
		fields = append(fields, event.FieldMeetingURL)
	}
	if m.status != nil {
		fields = append(fields, event.FieldStatus)
	}
	if m.start != nil {
		fields = append(fields, event.FieldStart)
	}
	if m.end != nil {
		fields = append(fields, event.FieldEnd)
	}
	if m.all_day != nil {
		fields = append(fields, event.FieldAllDay)
	}
	if m.start_tz != nil {
		fields = append(fields, event.FieldStartTz)
	}
	if m.end_tz != nil {
		fields = append(fields, event.FieldEndTz)
	}
	if m.recurrence != nil {
		fields = append(fields, event.FieldRecurrence)
	}
	if m.recurring_id != nil {
		fields = append(fields, event.FieldRecurringID)
	}
	if m.original_start != nil {
		fields = append(fields, event.FieldOriginalStart)
	}
	if m.organizer != nil {
		fields = append(fields, event.FieldOrganizer)
	}
	if m.attendees != nil {
		fields = append(fields, event.FieldAttendees)
	}
	if m.reminders != nil {
		fields = append(fields, event.FieldReminders)
	}
	if m.categories != nil {
		fields = append(fields, event.FieldCategories)
	}
	if m.transparency != nil {
		fields = append(fields, event.FieldTransparency)
	}
	if m.visibility != nil {
		fields = append(fields, event.FieldVisibility)
	}
	if m.raw_ics != nil {
		fields = append(fields, event.FieldRawIcs)
	}
	if m.created != nil {
		fields = append(fields, event.FieldCreated)
	}
	if m.updated != nil {
		fields = append(fields, event.FieldUpdated)
	}
	return fields
}

// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *EventMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case event.FieldUID:
		return m.UID()
	case event.FieldRemoteID:
		return m.RemoteID()
	case event.FieldEtag:
		return m.Etag()
	case event.FieldSummary:
		return m.Summary()
	case event.FieldDescription:
		return m.Description()
	case event.FieldLocation:
		return m.Location()
	case event.FieldURL:
		return m.URL()
	case event.FieldMeetingURL:
		return m.MeetingURL()
	case event.FieldStatus:
		return m.Status()
	case event.FieldStart:
		return m.Start()
	case event.FieldEnd:
		return m.End()
	case event.FieldAllDay:
		return m.AllDay()
	case event.FieldStartTz:
		return m.StartTz()
	case event.FieldEndTz:
		return m.EndTz()
	case event.FieldRecurrence:
		return m.Recurrence()
	case event.FieldRecurringID:
		return m.RecurringID()
	case event.FieldOriginalStart:
		return m.OriginalStart()
	case event.FieldOrganizer:
		return m.Organizer()
	case event.FieldAttendees:
		return m.Attendees()
	case event.FieldReminders:
		return m.Reminders()
	case event.FieldCategories:
		return m.Categories()
	case event.FieldTransparency:
		return m.Transparency()
	case event.FieldVisibility:
		return m.Visibility()
	case event.FieldRawIcs:
		return m.RawIcs()
	case event.FieldCreated:
		return m.Created()
	case event.FieldUpdated:
		return m.Updated()
	}
	return nil, false
}

// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *EventMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case event.FieldUID:
		return m.OldUID(ctx)
	case event.FieldRemoteID:
		return m.OldRemoteID(ctx)
	case event.FieldEtag:
		return m.OldEtag(ctx)
	case event.FieldSummary:
		return m.OldSummary(ctx)
	case event.FieldDescription:
		return m.OldDescription(ctx)
	case event.FieldLocation:
		return m.OldLocation(ctx)
	case event.FieldURL:
		return m.OldURL(ctx)
	case event.FieldMeetingURL:
		return m.OldMeetingURL(ctx)
	case event.FieldStatus:
		return m.OldStatus(ctx)
	case event.FieldStart:
		return m.OldStart(ctx)
	case event.FieldEnd:
		return m.OldEnd(ctx)
	case event.FieldAllDay:
		return m.OldAllDay(ctx)
	case event.FieldStartTz:
		return m.OldStartTz(ctx)
	case event.FieldEndTz:
		return m.OldEndTz(ctx)
	case event.FieldRecurrence:
		return m.OldRecurrence(ctx)
	case event.FieldRecurringID:
		return m.OldRecurringID(ctx)
	case event.FieldOriginalStart:
		return m.OldOriginalStart(ctx)
	case event.FieldOrganizer:
		return m.OldOrganizer(ctx)
	case event.FieldAttendees:
		return m.OldAttendees(ctx)
	case event.FieldReminders:
		return m.OldReminders(ctx)
	case event.FieldCategories:
		return m.OldCategories(ctx)
	case event.FieldTransparency:
		return m.OldTransparency(ctx)
	case event.FieldVisibility:
		return m.OldVisibility(ctx)
	case event.FieldRawIcs:
		return m.OldRawIcs(ctx)
	case event.FieldCreated:
		return m.OldCreated(ctx)
	case event.FieldUpdated:
		return m.OldUpdated(ctx)
	}
	return nil, fmt.Errorf("unknown Event field %s", name)
}

// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *EventMutation) SetField(name string, value ent.Value) error {
	switch name {
	case event.FieldUID:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUID(v)
		return nil
	case event.FieldRemoteID:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetRemoteID(v)
		return nil
	case event.FieldEtag:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetEtag(v)
		return nil
	case event.FieldSummary:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetSummary(v)
		return nil
	case event.FieldDescription:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetDescription(v)
		return nil
	case event.FieldLocation:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetLocation(v)
		return nil
	case event.FieldURL:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetURL(v)
		return nil
	case event.FieldMeetingURL:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetMeetingURL(v)
		return nil
	case event.FieldStatus:
		v, ok := value.(event.Status)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetStatus(v)
		return nil
	case event.FieldStart:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetStart(v)
		return nil
	case event.FieldEnd:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetEnd(v)
		return nil
	case event.FieldAllDay:
		v, ok := value.(bool)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetAllDay(v)
		return nil
	case event.FieldStartTz:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetStartTz(v)
		return nil
	case event.FieldEndTz:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetEndTz(v)
		return nil
	case event.FieldRecurrence:
		v, ok := value.(map[string]interface{})
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetRecurrence(v)
		return nil
	case event.FieldRecurringID:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetRecurringID(v)
		return nil
	case event.FieldOriginalStart:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetOriginalStart(v)
		return nil
	case event.FieldOrganizer:
		v, ok := value.(map[string]interface{})
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetOrganizer(v)
		return nil
	case event.FieldAttendees:
		v, ok := value.([]map[string]interface{})
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetAttendees(v)
		return nil
	case event.FieldReminders:
		v, ok := value.([]map[string]interface{})
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetReminders(v)
		return nil
	case event.FieldCategories:
		v, ok := value.([]string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCategories(v)
		return nil
	case event.FieldTransparency:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetTransparency(v)
		return nil
	case event.FieldVisibility:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetVisibility(v)
		return nil
	case event.FieldRawIcs:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetRawIcs(v)
		return nil
	case event.FieldCreated:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCreated(v)
		return nil
	case event.FieldUpdated:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUpdated(v)
		return nil
	}
	return fmt.Errorf("unknown Event field %s", name)
}

// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *EventMutation) AddedFields() []string {
	return nil
}

// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
func (m *EventMutation) AddedField(name string) (ent.Value, bool) {
	return nil, false
}

// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *EventMutation) AddField(name string, value ent.Value) error {
	switch name {
	}
	return fmt.Errorf("unknown Event numeric field %s", name)
}

// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *EventMutation) ClearedFields() []string {
	var fields []string
	if m.FieldCleared(event.FieldRemoteID) {
		fields = append(fields, event.FieldRemoteID)
	}
	if m.FieldCleared(event.FieldEtag) {
		fields = append(fields, event.FieldEtag)
	}
	if m.FieldCleared(event.FieldDescription) {
		fields = append(fields, event.FieldDescription)
	}
	if m.FieldCleared(event.FieldLocation) {
		fields = append(fields, event.FieldLocation)
	}
	if m.FieldCleared(event.FieldURL) {
		fields = append(fields, event.FieldURL)
	}
	if m.FieldCleared(event.FieldMeetingURL) {
		fields = append(fields, event.FieldMeetingURL)
	}
	if m.FieldCleared(event.FieldStartTz) {
		fields = append(fields, event.FieldStartTz)
	}
	if m.FieldCleared(event.FieldEndTz) {
		fields = append(fields, event.FieldEndTz)
	}
	if m.FieldCleared(event.FieldRecurrence) {
		fields = append(fields, event.FieldRecurrence)
	}
	if m.FieldCleared(event.FieldRecurringID) {
		fields = append(fields, event.FieldRecurringID)
	}
	if m.FieldCleared(event.FieldOriginalStart) {
		fields = append(fields, event.FieldOriginalStart)
	}
	if m.FieldCleared(event.FieldOrganizer) {
		fields = append(fields, event.FieldOrganizer)
	}
	if m.FieldCleared(event.FieldAttendees) {
		fields = append(fields, event.FieldAttendees)
	}
	if m.FieldCleared(event.FieldReminders) {
		fields = append(fields, event.FieldReminders)
	}
	if m.FieldCleared(event.FieldCategories) {
		fields = append(fields, event.FieldCategories)
	}
	if m.FieldCleared(event.FieldTransparency) {
		fields = append(fields, event.FieldTransparency)
	}
	if m.FieldCleared(event.FieldVisibility) {
		fields = append(fields, event.FieldVisibility)
	}
	if m.FieldCleared(event.FieldRawIcs) {
		fields = append(fields, event.FieldRawIcs)
	}
	return fields
}

// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *EventMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}

// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
func (m *EventMutation) ClearField(name string) error {
	switch name {
	case event.FieldRemoteID:
		m.ClearRemoteID()
		return nil
	case event.FieldEtag:
		m.ClearEtag()
		return nil
	case event.FieldDescription:
		m.ClearDescription()
		return nil
	case event.FieldLocation:
		m.ClearLocation()
		return nil
	case event.FieldURL:
		m.ClearURL()
		return nil
	case event.FieldMeetingURL:
		m.ClearMeetingURL()
		return nil
	case event.FieldStartTz:
		m.ClearStartTz()
		return nil
	case event.FieldEndTz:
		m.ClearEndTz()
		return nil
	case event.FieldRecurrence:
		m.ClearRecurrence()
		return nil
	case event.FieldRecurringID:
		m.ClearRecurringID()
		return nil
	case event.FieldOriginalStart:
		m.ClearOriginalStart()
		return nil
	case event.FieldOrganizer:
		m.ClearOrganizer()
		return nil
	case event.FieldAttendees:
		m.ClearAttendees()
		return nil
	case event.FieldReminders:
		m.ClearReminders()
		return nil
	case event.FieldCategories:
		m.ClearCategories()
		return nil
	case event.FieldTransparency:
		m.ClearTransparency()
		return nil
	case event.FieldVisibility:
		m.ClearVisibility()
		return nil
	case event.FieldRawIcs:
		m.ClearRawIcs()
		return nil
	}
	return fmt.Errorf("unknown Event nullable field %s", name)
}

// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
func (m *EventMutation) ResetField(name string) error {
	switch name {
	case event.FieldUID:
		m.ResetUID()
		return nil
	case event.FieldRemoteID:
		m.ResetRemoteID()
		return nil
	case event.FieldEtag:
		m.ResetEtag()
		return nil
	case event.FieldSummary:
		m.ResetSummary()
		return nil
	case event.FieldDescription:
		m.ResetDescription()
		return nil
	case event.FieldLocation:
		m.ResetLocation()
		return nil
	case event.FieldURL:
		m.ResetURL()
		return nil
	case event.FieldMeetingURL:
		m.ResetMeetingURL()
		return nil
	case event.FieldStatus:
		m.ResetStatus()
		return nil
	case event.FieldStart:
		m.ResetStart()
		return nil
	case event.FieldEnd:
		m.ResetEnd()
		return nil
	case event.FieldAllDay:
		m.ResetAllDay()
		return nil
	case event.FieldStartTz:
		m.ResetStartTz()
		return nil
	case event.FieldEndTz:
		m.ResetEndTz()
		return nil
	case event.FieldRecurrence:
		m.ResetRecurrence()
		return nil
	case event.FieldRecurringID:
		m.ResetRecurringID()
		return nil
	case event.FieldOriginalStart:
		m.ResetOriginalStart()
		return nil
	case event.FieldOrganizer:
		m.ResetOrganizer()
		return nil
	case event.FieldAttendees:
		m.ResetAttendees()
		return nil
	case event.FieldReminders:
		m.ResetReminders()
		return nil
	case event.FieldCategories:
		m.ResetCategories()
		return nil
	case event.FieldTransparency:
		m.ResetTransparency()
		return nil
	case event.FieldVisibility:
		m.ResetVisibility()
		return nil
	case event.FieldRawIcs:
		m.ResetRawIcs()
		return nil
	case event.FieldCreated:
		m.ResetCreated()
		return nil
	case event.FieldUpdated:
		m.ResetUpdated()
		return nil
	}
	return fmt.Errorf("unknown Event field %s", name)
}

// AddedEdges returns all edge names that were set/added in this mutation.
func (m *EventMutation) AddedEdges() []string {
	edges := make([]string, 0, 1)
	if m.calendar != nil {
		edges = append(edges, event.EdgeCalendar)
	}
	return edges
}

// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *EventMutation) AddedIDs(name string) []ent.Value {
	switch name {
	case event.EdgeCalendar:
		if id := m.calendar; id != nil {
			return []ent.Value{*id}
		}
	}
	return nil
}

// RemovedEdges returns all edge names that were removed in this mutation.
func (m *EventMutation) RemovedEdges() []string {
	edges := make([]string, 0, 1)
	return edges
}

// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *EventMutation) RemovedIDs(name string) []ent.Value {
	return nil
}

// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *EventMutation) ClearedEdges() []string {
	edges := make([]string, 0, 1)
	if m.clearedcalendar {
		edges = append(edges, event.EdgeCalendar)
	}
	return edges
}

// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *EventMutation) EdgeCleared(name string) bool {
	switch name {
	case event.EdgeCalendar:
		return m.clearedcalendar
	}
	return false
}

// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *EventMutation) ClearEdge(name string) error {
	switch name {
	case event.EdgeCalendar:
		m.ClearCalendar()
		return nil
	}
	return fmt.Errorf("unknown Event unique edge %s", name)
}

// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *EventMutation) ResetEdge(name string) error {
	switch name {
	case event.EdgeCalendar:
		m.ResetCalendar()
		return nil
	}
	return fmt.Errorf("unknown Event edge %s", name)
}

// InvitationStateMutation represents an operation that mutates the InvitationState nodes in the graph.
type InvitationStateMutation struct {
	config
	op            Op
	typ           string
	id            *int
	calendar_id   *string
	uid           *string
	event_start   *time.Time
	notified_at   *time.Time
	clearedFields map[string]struct{}
	done          bool
	oldValue      func(context.Context) (*InvitationState, error)
	predicates    []predicate.InvitationState
}

var _ ent.Mutation = (*InvitationStateMutation)(nil)

// invitationstateOption allows management of the mutation configuration using functional options.
type invitationstateOption func(*InvitationStateMutation)

// newInvitationStateMutation creates new mutation for the InvitationState entity.
func newInvitationStateMutation(c config, op Op, opts ...invitationstateOption) *InvitationStateMutation {
	m := &InvitationStateMutation{
		config:        c,
		op:            op,
		typ:           TypeInvitationState,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}

// withInvitationStateID sets the ID field of the mutation.
func withInvitationStateID(id int) invitationstateOption {
	return func(m *InvitationStateMutation) {
		var (
			err   error
			once  sync.Once
			value *InvitationState
		)
		m.oldValue = func(ctx context.Context) (*InvitationState, error) {
			once.Do(func() {
				if m.done {
					err = errors.New("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().InvitationState.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}

// withInvitationState sets the old InvitationState of the mutation.
func withInvitationState(node *InvitationState) invitationstateOption {
	return func(m *InvitationStateMutation) {
		m.oldValue = func(context.Context) (*InvitationState, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}

// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
func (m InvitationStateMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}

// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
func (m InvitationStateMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, errors.New("ent: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}

// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *InvitationStateMutation) ID() (id int, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}

// IDs queries the database and returns the entity ids that match the mutation's predicate.
// That means, if the mutation is applied within a transaction with an isolation level such
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
// or updated by the mutation.
func (m *InvitationStateMutation) IDs(ctx context.Context) ([]int, error) {
	switch {
	case m.op.Is(OpUpdateOne | OpDeleteOne):
		id, exists := m.ID()
		if exists {
			return []int{id}, nil
		}
		fallthrough
	case m.op.Is(OpUpdate | OpDelete):
		return m.Client().InvitationState.Query().Where(m.predicates...).IDs(ctx)
	default:
		return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
	}
}

// SetCalendarID sets the "calendar_id" field.
func (m *InvitationStateMutation) SetCalendarID(s string) {
	m.calendar_id = &s
}

// CalendarID returns the value of the "calendar_id" field in the mutation.
func (m *InvitationStateMutation) CalendarID() (r string, exists bool) {
	v := m.calendar_id
	if v == nil {
		return
	}
	return *v, true
}

// OldCalendarID returns the old "calendar_id" field's value of the InvitationState entity.
// If the InvitationState object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *InvitationStateMutation) OldCalendarID(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldCalendarID is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldCalendarID requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCalendarID: %w", err)
	}
	return oldValue.CalendarID, nil
}

// ResetCalendarID resets all changes to the "calendar_id" field.
func (m *InvitationStateMutation) ResetCalendarID() {
	m.calendar_id = nil
}

// SetUID sets the "uid" field.
func (m *InvitationStateMutation) SetUID(s string) {
	m.uid = &s
}

// UID returns the value of the "uid" field in the mutation.
func (m *InvitationStateMutation) UID() (r string, exists bool) {
	v := m.uid
	if v == nil {
		return
	}
	return *v, true
}

// OldUID returns the old "uid" field's value of the InvitationState entity.
// If the InvitationState object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *InvitationStateMutation) OldUID(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldUID is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldUID requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUID: %w", err)
	}
	return oldValue.UID, nil
}

// ResetUID resets all changes to the "uid" field.
func (m *InvitationStateMutation) ResetUID() {
	m.uid = nil
}

// SetEventStart sets the "event_start" field.
func (m *InvitationStateMutation) SetEventStart(t time.Time) {
	m.event_start = &t
}

// EventStart returns the value of the "event_start" field in the mutation.
func (m *InvitationStateMutation) EventStart() (r time.Time, exists bool) {
	v := m.event_start
	if v == nil {
		return
	}
	return *v, true
}

// OldEventStart returns the old "event_start" field's value of the InvitationState entity.
// If the InvitationState object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *InvitationStateMutation) OldEventStart(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldEventStart is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldEventStart requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldEventStart: %w", err)
	}
	return oldValue.EventStart, nil
}

// ResetEventStart resets all changes to the "event_start" field.
func (m *InvitationStateMutation) ResetEventStart() {
	m.event_start = nil
}

// SetNotifiedAt sets the "notified_at" field.
func (m *InvitationStateMutation) SetNotifiedAt(t time.Time) {
	m.notified_at = &t
}

// NotifiedAt returns the value of the "notified_at" field in the mutation.
func (m *InvitationStateMutation) NotifiedAt() (r time.Time, exists bool) {
	v := m.notified_at
	if v == nil {
		return
	}
	return *v, true
}

// OldNotifiedAt returns the old "notified_at" field's value of the InvitationState entity.
// If the InvitationState object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *InvitationStateMutation) OldNotifiedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldNotifiedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldNotifiedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldNotifiedAt: %w", err)
	}
	return oldValue.NotifiedAt, nil
}

// ResetNotifiedAt resets all changes to the "notified_at" field.
func (m *InvitationStateMutation) ResetNotifiedAt() {
	m.notified_at = nil
}

// Where appends a list predicates to the InvitationStateMutation builder.
func (m *InvitationStateMutation) Where(ps ...predicate.InvitationState) {
	m.predicates = append(m.predicates, ps...)
}

// WhereP appends storage-level predicates to the InvitationStateMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *InvitationStateMutation) WhereP(ps ...func(*sql.Selector)) {
	p := make([]predicate.InvitationState, len(ps))
	for i := range ps {
		p[i] = ps[i]
	}
	m.Where(p...)
}

// Op returns the operation name.
func (m *InvitationStateMutation) Op() Op {
	return m.op
}

// SetOp allows setting the mutation operation.
func (m *InvitationStateMutation) SetOp(op Op) {
	m.op = op
}

// Type returns the node type of this mutation (InvitationState).
func (m *InvitationStateMutation) Type() string {
	return m.typ
}

// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *InvitationStateMutation) Fields() []string {
	fields := make([]string, 0, 4)
	if m.calendar_id != nil {
		fields = append(fields, invitationstate.FieldCalendarID)
	}
	if m.uid != nil {
		fields = append(fields, invitationstate.FieldUID)
	}
	if m.event_start != nil {
		fields = append(fields, invitationstate.FieldEventStart)
	}
	if m.notified_at != nil {
		fields = append(fields, invitationstate.FieldNotifiedAt)
	}
	return fields
}

// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *InvitationStateMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case invitationstate.FieldCalendarID:
		return m.CalendarID()
	case invitationstate.FieldUID:
		return m.UID()
	case invitationstate.FieldEventStart:
		return m.EventStart()
	case invitationstate.FieldNotifiedAt:
		return m.NotifiedAt()
	}
	return nil, false
}

// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *InvitationStateMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case invitationstate.FieldCalendarID:
		return m.OldCalendarID(ctx)
	case invitationstate.FieldUID:
		return m.OldUID(ctx)
	case invitationstate.FieldEventStart:
		return m.OldEventStart(ctx)
	case invitationstate.FieldNotifiedAt:
		return m.OldNotifiedAt(ctx)
	}
	return nil, fmt.Errorf("unknown InvitationState field %s", name)
}

// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *InvitationStateMutation) SetField(name string, value ent.Value) error {
	switch name {
	case invitationstate.FieldCalendarID:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCalendarID(v)
		return nil
	case invitationstate.FieldUID:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUID(v)
		return nil
	case invitationstate.FieldEventStart:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetEventStart(v)
		return nil
	case invitationstate.FieldNotifiedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetNotifiedAt(v)
		return nil
	}
	return fmt.Errorf("unknown InvitationState field %s", name)
}

// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *InvitationStateMutation) AddedFields() []string {
	return nil
}

// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
func (m *InvitationStateMutation) AddedField(name string) (ent.Value, bool) {
	return nil, false
}

// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *InvitationStateMutation) AddField(name string, value ent.Value) error {
	switch name {
	}
	return fmt.Errorf("unknown InvitationState numeric field %s", name)
}

// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *InvitationStateMutation) ClearedFields() []string {
	return nil
}

// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *InvitationStateMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}

// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
func (m *InvitationStateMutation) ClearField(name string) error {
	return fmt.Errorf("unknown InvitationState nullable field %s", name)
}

// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
func (m *InvitationStateMutation) ResetField(name string) error {
	switch name {
	case invitationstate.FieldCalendarID:
		m.ResetCalendarID()
		return nil
	case invitationstate.FieldUID:
		m.ResetUID()
		return nil
	case invitationstate.FieldEventStart:
		m.ResetEventStart()
		return nil
	case invitationstate.FieldNotifiedAt:
		m.ResetNotifiedAt()
		return nil
	}
	return fmt.Errorf("unknown InvitationState field %s", name)
}

// AddedEdges returns all edge names that were set/added in this mutation.
func (m *InvitationStateMutation) AddedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}

// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *InvitationStateMutation) AddedIDs(name string) []ent.Value {
	return nil
}

// RemovedEdges returns all edge names that were removed in this mutation.
func (m *InvitationStateMutation) RemovedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}

// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *InvitationStateMutation) RemovedIDs(name string) []ent.Value {
	return nil
}

// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *InvitationStateMutation) ClearedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}

// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *InvitationStateMutation) EdgeCleared(name string) bool {
	return false
}

// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *InvitationStateMutation) ClearEdge(name string) error {
	return fmt.Errorf("unknown InvitationState unique edge %s", name)
}

// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *InvitationStateMutation) ResetEdge(name string) error {
	return fmt.Errorf("unknown InvitationState edge %s", name)
}

// ReminderStateMutation represents an operation that mutates the ReminderState nodes in the graph.
type ReminderStateMutation struct {
	config
	op               Op
	typ              string
	id               *int
	calendar_id      *string
	uid              *string
	occurrence_start *time.Time
	minutes          *int
	addminutes       *int
	fired_at         *time.Time
	snoozed_until    *time.Time
	clearedFields    map[string]struct{}
	done             bool
	oldValue         func(context.Context) (*ReminderState, error)
	predicates       []predicate.ReminderState
}

var _ ent.Mutation = (*ReminderStateMutation)(nil)

// reminderstateOption allows management of the mutation configuration using functional options.
type reminderstateOption func(*ReminderStateMutation)

// newReminderStateMutation creates new mutation for the ReminderState entity.
func newReminderStateMutation(c config, op Op, opts ...reminderstateOption) *ReminderStateMutation {
	m := &ReminderStateMutation{
		config:        c,
		op:            op,
		typ:           TypeReminderState,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}

// withReminderStateID sets the ID field of the mutation.
func withReminderStateID(id int) reminderstateOption {
	return func(m *ReminderStateMutation) {
		var (
			err   error
			once  sync.Once
			value *ReminderState
		)
		m.oldValue = func(ctx context.Context) (*ReminderState, error) {
			once.Do(func() {
				if m.done {
					err = errors.New("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().ReminderState.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}

// withReminderState sets the old ReminderState of the mutation.
func withReminderState(node *ReminderState) reminderstateOption {
	return func(m *ReminderStateMutation) {
		m.oldValue = func(context.Context) (*ReminderState, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}

// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
func (m ReminderStateMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}

// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
func (m ReminderStateMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, errors.New("ent: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}

// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *ReminderStateMutation) ID() (id int, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}

// IDs queries the database and returns the entity ids that match the mutation's predicate.
// That means, if the mutation is applied within a transaction with an isolation level such
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
// or updated by the mutation.
func (m *ReminderStateMutation) IDs(ctx context.Context) ([]int, error) {
	switch {
	case m.op.Is(OpUpdateOne | OpDeleteOne):
		id, exists := m.ID()
		if exists {
			return []int{id}, nil
		}
		fallthrough
	case m.op.Is(OpUpdate | OpDelete):
		return m.Client().ReminderState.Query().Where(m.predicates...).IDs(ctx)
	default:
		return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
	}
}

// SetCalendarID sets the "calendar_id" field.
func (m *ReminderStateMutation) SetCalendarID(s string) {
	m.calendar_id = &s
}

// CalendarID returns the value of the "calendar_id" field in the mutation.
func (m *ReminderStateMutation) CalendarID() (r string, exists bool) {
	v := m.calendar_id
	if v == nil {
		return
	}
	return *v, true
}

// OldCalendarID returns the old "calendar_id" field's value of the ReminderState entity.
// If the ReminderState object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *ReminderStateMutation) OldCalendarID(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldCalendarID is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldCalendarID requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCalendarID: %w", err)
	}
	return oldValue.CalendarID, nil
}

// ResetCalendarID resets all changes to the "calendar_id" field.
func (m *ReminderStateMutation) ResetCalendarID() {
	m.calendar_id = nil
}

// SetUID sets the "uid" field.
func (m *ReminderStateMutation) SetUID(s string) {
	m.uid = &s
}

// UID returns the value of the "uid" field in the mutation.
func (m *ReminderStateMutation) UID() (r string, exists bool) {
	v := m.uid
	if v == nil {
		return
	}
	return *v, true
}

// OldUID returns the old "uid" field's value of the ReminderState entity.
// If the ReminderState object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *ReminderStateMutation) OldUID(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldUID is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldUID requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUID: %w", err)
	}
	return oldValue.UID, nil
}

// ResetUID resets all changes to the "uid" field.
func (m *ReminderStateMutation) ResetUID() {
	m.uid = nil
}

// SetOccurrenceStart sets the "occurrence_start" field.
func (m *ReminderStateMutation) SetOccurrenceStart(t time.Time) {
	m.occurrence_start = &t
}

// OccurrenceStart returns the value of the "occurrence_start" field in the mutation.
func (m *ReminderStateMutation) OccurrenceStart() (r time.Time, exists bool) {
	v := m.occurrence_start
	if v == nil {
		return
	}
	return *v, true
}

// OldOccurrenceStart returns the old "occurrence_start" field's value of the ReminderState entity.
// If the ReminderState object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *ReminderStateMutation) OldOccurrenceStart(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldOccurrenceStart is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldOccurrenceStart requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldOccurrenceStart: %w", err)
	}
	return oldValue.OccurrenceStart, nil
}

// ResetOccurrenceStart resets all changes to the "occurrence_start" field.
func (m *ReminderStateMutation) ResetOccurrenceStart() {
	m.occurrence_start = nil
}

// SetMinutes sets the "minutes" field.
func (m *ReminderStateMutation) SetMinutes(i int) {
	m.minutes = &i
	m.addminutes = nil
}

// Minutes returns the value of the "minutes" field in the mutation.
func (m *ReminderStateMutation) Minutes() (r int, exists bool) {
	v := m.minutes
	if v == nil {
		return
	}
	return *v, true
}

// OldMinutes returns the old "minutes" field's value of the ReminderState entity.
// If the ReminderState object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *ReminderStateMutation) OldMinutes(ctx context.Context) (v int, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldMinutes is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldMinutes requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldMinutes: %w", err)
	}
	return oldValue.Minutes, nil
}

// AddMinutes adds i to the "minutes" field.
func (m *ReminderStateMutation) AddMinutes(i int) {
	if m.addminutes != nil {
		*m.addminutes += i
	} else {
		m.addminutes = &i
	}
}

// AddedMinutes returns the value that was added to the "minutes" field in this mutation.
func (m *ReminderStateMutation) AddedMinutes() (r int, exists bool) {
	v := m.addminutes
	if v == nil {
		return
	}
	return *v, true
}

// ResetMinutes resets all changes to the "minutes" field.
func (m *ReminderStateMutation) ResetMinutes() {
	m.minutes = nil
	m.addminutes = nil
}

// SetFiredAt sets the "fired_at" field.
func (m *ReminderStateMutation) SetFiredAt(t time.Time) {
	m.fired_at = &t
}

// FiredAt returns the value of the "fired_at" field in the mutation.
func (m *ReminderStateMutation) FiredAt() (r time.Time, exists bool) {
	v := m.fired_at
	if v == nil {
		return
	}
	return *v, true
}

// OldFiredAt returns the old "fired_at" field's value of the ReminderState entity.
// If the ReminderState object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *ReminderStateMutation) OldFiredAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldFiredAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldFiredAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldFiredAt: %w", err)
	}
	return oldValue.FiredAt, nil
}

// ResetFiredAt resets all changes to the "fired_at" field.
func (m *ReminderStateMutation) ResetFiredAt() {
	m.fired_at = nil
}

// SetSnoozedUntil sets the "snoozed_until" field.
func (m *ReminderStateMutation) SetSnoozedUntil(t time.Time) {
	m.snoozed_until = &t
}

// SnoozedUntil returns the value of the "snoozed_until" field in the mutation.
func (m *ReminderStateMutation) SnoozedUntil() (r time.Time, exists bool) {
	v := m.snoozed_until
	if v == nil {
		return
	}
	return *v, true
}

// OldSnoozedUntil returns the old "snoozed_until" field's value of the ReminderState entity.
// If the ReminderState object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *ReminderStateMutation) OldSnoozedUntil(ctx context.Context) (v *time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldSnoozedUntil is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldSnoozedUntil requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldSnoozedUntil: %w", err)
	}
	return oldValue.SnoozedUntil, nil
}

// ClearSnoozedUntil clears the value of the "snoozed_until" field.
func (m *ReminderStateMutation) ClearSnoozedUntil() {
	m.snoozed_until = nil
	m.clearedFields[reminderstate.FieldSnoozedUntil] = struct{}{}
}

// SnoozedUntilCleared returns if the "snoozed_until" field was cleared in this mutation.
func (m *ReminderStateMutation) SnoozedUntilCleared() bool {
	_, ok := m.clearedFields[reminderstate.FieldSnoozedUntil]
	return ok
}

// ResetSnoozedUntil resets all changes to the "snoozed_until" field.
func (m *ReminderStateMutation) ResetSnoozedUntil() {
	m.snoozed_until = nil
	delete(m.clearedFields, reminderstate.FieldSnoozedUntil)
}

// Where appends a list predicates to the ReminderStateMutation builder.
func (m *ReminderStateMutation) Where(ps ...predicate.ReminderState) {
	m.predicates = append(m.predicates, ps...)
}

// WhereP appends storage-level predicates to the ReminderStateMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *ReminderStateMutation) WhereP(ps ...func(*sql.Selector)) {
	p := make([]predicate.ReminderState, len(ps))
	for i := range ps {
		p[i] = ps[i]
	}
	m.Where(p...)
}

// Op returns the operation name.
func (m *ReminderStateMutation) Op() Op {
	return m.op
}

// SetOp allows setting the mutation operation.
func (m *ReminderStateMutation) SetOp(op Op) {
	m.op = op
}

// Type returns the node type of this mutation (ReminderState).
func (m *ReminderStateMutation) Type() string {
	return m.typ
}

// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *ReminderStateMutation) Fields() []string {
	fields := make([]string, 0, 6)
	if m.calendar_id != nil {
		fields = append(fields, reminderstate.FieldCalendarID)
	}
	if m.uid != nil {
		fields = append(fields, reminderstate.FieldUID)
	}
	if m.occurrence_start != nil {
		fields = append(fields, reminderstate.FieldOccurrenceStart)
	}
	if m.minutes != nil {
		fields = append(fields, reminderstate.FieldMinutes)
	}
	if m.fired_at != nil {
		fields = append(fields, reminderstate.FieldFiredAt)
	}
	if m.snoozed_until != nil {
		fields = append(fields, reminderstate.FieldSnoozedUntil)
	}
	return fields
}

// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *ReminderStateMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case reminderstate.FieldCalendarID:
		return m.CalendarID()
	case reminderstate.FieldUID:
		return m.UID()
	case reminderstate.FieldOccurrenceStart:
		return m.OccurrenceStart()
	case reminderstate.FieldMinutes:
		return m.Minutes()
	case reminderstate.FieldFiredAt:
		return m.FiredAt()
	case reminderstate.FieldSnoozedUntil:
		return m.SnoozedUntil()
	}
	return nil, false
}

// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *ReminderStateMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case reminderstate.FieldCalendarID:
		return m.OldCalendarID(ctx)
	case reminderstate.FieldUID:
		return m.OldUID(ctx)
	case reminderstate.FieldOccurrenceStart:
		return m.OldOccurrenceStart(ctx)
	case reminderstate.FieldMinutes:
		return m.OldMinutes(ctx)
	case reminderstate.FieldFiredAt:
		return m.OldFiredAt(ctx)
	case reminderstate.FieldSnoozedUntil:
		return m.OldSnoozedUntil(ctx)
	}
	return nil, fmt.Errorf("unknown ReminderState field %s", name)
}

// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *ReminderStateMutation) SetField(name string, value ent.Value) error {
	switch name {
	case reminderstate.FieldCalendarID:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCalendarID(v)
		return nil
	case reminderstate.FieldUID:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUID(v)
		return nil
	case reminderstate.FieldOccurrenceStart:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetOccurrenceStart(v)
		return nil
	case reminderstate.FieldMinutes:
		v, ok := value.(int)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetMinutes(v)
		return nil
	case reminderstate.FieldFiredAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetFiredAt(v)
		return nil
	case reminderstate.FieldSnoozedUntil:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetSnoozedUntil(v)
		return nil
	}
	return fmt.Errorf("unknown ReminderState field %s", name)
}

// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *ReminderStateMutation) AddedFields() []string {
	var fields []string
	if m.addminutes != nil {
		fields = append(fields, reminderstate.FieldMinutes)
	}
	return fields
}

// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
func (m *ReminderStateMutation) AddedField(name string) (ent.Value, bool) {
	switch name {
	case reminderstate.FieldMinutes:
		return m.AddedMinutes()
	}
	return nil, false
}

// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *ReminderStateMutation) AddField(name string, value ent.Value) error {
	switch name {
	case reminderstate.FieldMinutes:
		v, ok := value.(int)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.AddMinutes(v)
		return nil
	}
	return fmt.Errorf("unknown ReminderState numeric field %s", name)
}

// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *ReminderStateMutation) ClearedFields() []string {
	var fields []string
	if m.FieldCleared(reminderstate.FieldSnoozedUntil) {
		fields = append(fields, reminderstate.FieldSnoozedUntil)
	}
	return fields
}

// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *ReminderStateMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}

// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
func (m *ReminderStateMutation) ClearField(name string) error {
	switch name {
	case reminderstate.FieldSnoozedUntil:
		m.ClearSnoozedUntil()
		return nil
	}
	return fmt.Errorf("unknown ReminderState nullable field %s", name)
}

// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
func (m *ReminderStateMutation) ResetField(name string) error {
	switch name {
	case reminderstate.FieldCalendarID:
		m.ResetCalendarID()
		return nil
	case reminderstate.FieldUID:
		m.ResetUID()
		return nil
	case reminderstate.FieldOccurrenceStart:
		m.ResetOccurrenceStart()
		return nil
	case reminderstate.FieldMinutes:
		m.ResetMinutes()
		return nil
	case reminderstate.FieldFiredAt:
		m.ResetFiredAt()
		return nil
	case reminderstate.FieldSnoozedUntil:
		m.ResetSnoozedUntil()
		return nil
	}
	return fmt.Errorf("unknown ReminderState field %s", name)
}

// AddedEdges returns all edge names that were set/added in this mutation.
func (m *ReminderStateMutation) AddedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}

// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *ReminderStateMutation) AddedIDs(name string) []ent.Value {
	return nil
}

// RemovedEdges returns all edge names that were removed in this mutation.
func (m *ReminderStateMutation) RemovedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}

// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *ReminderStateMutation) RemovedIDs(name string) []ent.Value {
	return nil
}

// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *ReminderStateMutation) ClearedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}

// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *ReminderStateMutation) EdgeCleared(name string) bool {
	return false
}

// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *ReminderStateMutation) ClearEdge(name string) error {
	return fmt.Errorf("unknown ReminderState unique edge %s", name)
}

// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *ReminderStateMutation) ResetEdge(name string) error {
	return fmt.Errorf("unknown ReminderState edge %s", name)
}

// SecretMutation represents an operation that mutates the Secret nodes in the graph.
type SecretMutation struct {
	config
	op             Op
	typ            string
	id             *string
	key            *string
	value          *[]byte
	created_at     *time.Time
	updated_at     *time.Time
	clearedFields  map[string]struct{}
	account        *string
	clearedaccount bool
	done           bool
	oldValue       func(context.Context) (*Secret, error)
	predicates     []predicate.Secret
}

var _ ent.Mutation = (*SecretMutation)(nil)

// secretOption allows management of the mutation configuration using functional options.
type secretOption func(*SecretMutation)

// newSecretMutation creates new mutation for the Secret entity.
func newSecretMutation(c config, op Op, opts ...secretOption) *SecretMutation {
	m := &SecretMutation{
		config:        c,
		op:            op,
		typ:           TypeSecret,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}

// withSecretID sets the ID field of the mutation.
func withSecretID(id string) secretOption {
	return func(m *SecretMutation) {
		var (
			err   error
			once  sync.Once
			value *Secret
		)
		m.oldValue = func(ctx context.Context) (*Secret, error) {
			once.Do(func() {
				if m.done {
					err = errors.New("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().Secret.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}

// withSecret sets the old Secret of the mutation.
func withSecret(node *Secret) secretOption {
	return func(m *SecretMutation) {
		m.oldValue = func(context.Context) (*Secret, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}

// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
func (m SecretMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}

// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
func (m SecretMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, errors.New("ent: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}

// SetID sets the value of the id field. Note that this
// operation is only accepted on creation of Secret entities.
func (m *SecretMutation) SetID(id string) {
	m.id = &id
}

// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *SecretMutation) ID() (id string, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}

// IDs queries the database and returns the entity ids that match the mutation's predicate.
// That means, if the mutation is applied within a transaction with an isolation level such
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
// or updated by the mutation.
func (m *SecretMutation) IDs(ctx context.Context) ([]string, error) {
	switch {
	case m.op.Is(OpUpdateOne | OpDeleteOne):
		id, exists := m.ID()
		if exists {
			return []string{id}, nil
		}
		fallthrough
	case m.op.Is(OpUpdate | OpDelete):
		return m.Client().Secret.Query().Where(m.predicates...).IDs(ctx)
	default:
		return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
	}
}

// SetKey sets the "key" field.
func (m *SecretMutation) SetKey(s string) {
	m.key = &s
}

// Key returns the value of the "key" field in the mutation.
func (m *SecretMutation) Key() (r string, exists bool) {
	v := m.key
	if v == nil {
		return
	}
	return *v, true
}

// OldKey returns the old "key" field's value of the Secret entity.
// If the Secret object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *SecretMutation) OldKey(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldKey is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldKey requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldKey: %w", err)
	}
	return oldValue.Key, nil
}

// ResetKey resets all changes to the "key" field.
func (m *SecretMutation) ResetKey() {
	m.key = nil
}

// SetValue sets the "value" field.
func (m *SecretMutation) SetValue(b []byte) {
	m.value = &b
}

// Value returns the value of the "value" field in the mutation.
func (m *SecretMutation) Value() (r []byte, exists bool) {
	v := m.value
	if v == nil {
		return
	}
	return *v, true
}

// OldValue returns the old "value" field's value of the Secret entity.
// If the Secret object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *SecretMutation) OldValue(ctx context.Context) (v []byte, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldValue is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldValue requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldValue: %w", err)
	}
	return oldValue.Value, nil
}

// ResetValue resets all changes to the "value" field.
func (m *SecretMutation) ResetValue() {
	m.value = nil
}

// SetCreatedAt sets the "created_at" field.
func (m *SecretMutation) SetCreatedAt(t time.Time) {
	m.created_at = &t
}

// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *SecretMutation) CreatedAt() (r time.Time, exists bool) {
	v := m.created_at
	if v == nil {
		return
	}
	return *v, true
}

// OldCreatedAt returns the old "created_at" field's value of the Secret entity.
// If the Secret object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *SecretMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldCreatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
	}
	return oldValue.CreatedAt, nil
}

// ResetCreatedAt resets all changes to the "created_at" field.
func (m *SecretMutation) ResetCreatedAt() {
	m.created_at = nil
}

// SetUpdatedAt sets the "updated_at" field.
func (m *SecretMutation) SetUpdatedAt(t time.Time) {
	m.updated_at = &t
}

// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *SecretMutation) UpdatedAt() (r time.Time, exists bool) {
	v := m.updated_at
	if v == nil {
		return
	}
	return *v, true
}

// OldUpdatedAt returns the old "updated_at" field's value of the Secret entity.
// If the Secret object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *SecretMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
	}
	return oldValue.UpdatedAt, nil
}

// ResetUpdatedAt resets all changes to the "updated_at" field.
func (m *SecretMutation) ResetUpdatedAt() {
	m.updated_at = nil
}

// SetAccountID sets the "account" edge to the Account entity by id.
func (m *SecretMutation) SetAccountID(id string) {
	m.account = &id
}

// ClearAccount clears the "account" edge to the Account entity.
func (m *SecretMutation) ClearAccount() {
	m.clearedaccount = true
}

// AccountCleared reports if the "account" edge to the Account entity was cleared.
func (m *SecretMutation) AccountCleared() bool {
	return m.clearedaccount
}

// AccountID returns the "account" edge ID in the mutation.
func (m *SecretMutation) AccountID() (id string, exists bool) {
	if m.account != nil {
		return *m.account, true
	}
	return
}

// AccountIDs returns the "account" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// AccountID instead. It exists only for internal usage by the builders.
func (m *SecretMutation) AccountIDs() (ids []string) {
	if id := m.account; id != nil {
		ids = append(ids, *id)
	}
	return
}

// ResetAccount resets all changes to the "account" edge.
func (m *SecretMutation) ResetAccount() {
	m.account = nil
	m.clearedaccount = false
}

// Where appends a list predicates to the SecretMutation builder.
func (m *SecretMutation) Where(ps ...predicate.Secret) {
	m.predicates = append(m.predicates, ps...)
}

// WhereP appends storage-level predicates to the SecretMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *SecretMutation) WhereP(ps ...func(*sql.Selector)) {
	p := make([]predicate.Secret, len(ps))
	for i := range ps {
		p[i] = ps[i]
	}
	m.Where(p...)
}

// Op returns the operation name.
func (m *SecretMutation) Op() Op {
	return m.op
}

// SetOp allows setting the mutation operation.
func (m *SecretMutation) SetOp(op Op) {
	m.op = op
}

// Type returns the node type of this mutation (Secret).
func (m *SecretMutation) Type() string {
	return m.typ
}

// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *SecretMutation) Fields() []string {
	fields := make([]string, 0, 4)
	if m.key != nil {
		fields = append(fields, secret.FieldKey)
	}
	if m.value != nil {
		fields = append(fields, secret.FieldValue)
	}
	if m.created_at != nil {
		fields = append(fields, secret.FieldCreatedAt)
	}
	if m.updated_at != nil {
		fields = append(fields, secret.FieldUpdatedAt)
	}
	return fields
}

// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *SecretMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case secret.FieldKey:
		return m.Key()
	case secret.FieldValue:
		return m.Value()
	case secret.FieldCreatedAt:
		return m.CreatedAt()
	case secret.FieldUpdatedAt:
		return m.UpdatedAt()
	}
	return nil, false
}

// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *SecretMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case secret.FieldKey:
		return m.OldKey(ctx)
	case secret.FieldValue:
		return m.OldValue(ctx)
	case secret.FieldCreatedAt:
		return m.OldCreatedAt(ctx)
	case secret.FieldUpdatedAt:
		return m.OldUpdatedAt(ctx)
	}
	return nil, fmt.Errorf("unknown Secret field %s", name)
}

// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *SecretMutation) SetField(name string, value ent.Value) error {
	switch name {
	case secret.FieldKey:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetKey(v)
		return nil
	case secret.FieldValue:
		v, ok := value.([]byte)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetValue(v)
		return nil
	case secret.FieldCreatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCreatedAt(v)
		return nil
	case secret.FieldUpdatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUpdatedAt(v)
		return nil
	}
	return fmt.Errorf("unknown Secret field %s", name)
}

// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *SecretMutation) AddedFields() []string {
	return nil
}

// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
func (m *SecretMutation) AddedField(name string) (ent.Value, bool) {
	return nil, false
}

// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *SecretMutation) AddField(name string, value ent.Value) error {
	switch name {
	}
	return fmt.Errorf("unknown Secret numeric field %s", name)
}

// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *SecretMutation) ClearedFields() []string {
	return nil
}

// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *SecretMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}

// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
func (m *SecretMutation) ClearField(name string) error {
	return fmt.Errorf("unknown Secret nullable field %s", name)
}

// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
func (m *SecretMutation) ResetField(name string) error {
	switch name {
	case secret.FieldKey:
		m.ResetKey()
		return nil
	case secret.FieldValue:
		m.ResetValue()
		return nil
	case secret.FieldCreatedAt:
		m.ResetCreatedAt()
		return nil
	case secret.FieldUpdatedAt:
		m.ResetUpdatedAt()
		return nil
	}
	return fmt.Errorf("unknown Secret field %s", name)
}

// AddedEdges returns all edge names that were set/added in this mutation.
func (m *SecretMutation) AddedEdges() []string {
	edges := make([]string, 0, 1)
	if m.account != nil {
		edges = append(edges, secret.EdgeAccount)
	}
	return edges
}

// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *SecretMutation) AddedIDs(name string) []ent.Value {
	switch name {
	case secret.EdgeAccount:
		if id := m.account; id != nil {
			return []ent.Value{*id}
		}
	}
	return nil
}

// RemovedEdges returns all edge names that were removed in this mutation.
func (m *SecretMutation) RemovedEdges() []string {
	edges := make([]string, 0, 1)
	return edges
}

// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *SecretMutation) RemovedIDs(name string) []ent.Value {
	return nil
}

// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *SecretMutation) ClearedEdges() []string {
	edges := make([]string, 0, 1)
	if m.clearedaccount {
		edges = append(edges, secret.EdgeAccount)
	}
	return edges
}

// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *SecretMutation) EdgeCleared(name string) bool {
	switch name {
	case secret.EdgeAccount:
		return m.clearedaccount
	}
	return false
}

// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *SecretMutation) ClearEdge(name string) error {
	switch name {
	case secret.EdgeAccount:
		m.ClearAccount()
		return nil
	}
	return fmt.Errorf("unknown Secret unique edge %s", name)
}

// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *SecretMutation) ResetEdge(name string) error {
	switch name {
	case secret.EdgeAccount:
		m.ResetAccount()
		return nil
	}
	return fmt.Errorf("unknown Secret edge %s", name)
}

// TaskMutation represents an operation that mutates the Task nodes in the graph.
type TaskMutation struct {
	config
	op                  Op
	typ                 string
	id                  *string
	uid                 *string
	remote_id           *string
	etag                *string
	summary             *string
	description         *string
	location            *string
	status              *task.Status
	priority            *int
	addpriority         *int
	percent_complete    *int
	addpercent_complete *int
	due                 *time.Time
	start               *time.Time
	completed           *time.Time
	all_day             *bool
	due_tz              *string
	start_tz            *string
	parent_uid          *string
	recurrence          *map[string]interface{}
	reminders           *[]map[string]interface{}
	appendreminders     []map[string]interface{}
	categories          *[]string
	appendcategories    []string
	raw_ics             *string
	created             *time.Time
	updated             *time.Time
	clearedFields       map[string]struct{}
	calendar            *string
	clearedcalendar     bool
	done                bool
	oldValue            func(context.Context) (*Task, error)
	predicates          []predicate.Task
}

var _ ent.Mutation = (*TaskMutation)(nil)

// taskOption allows management of the mutation configuration using functional options.
type taskOption func(*TaskMutation)

// newTaskMutation creates new mutation for the Task entity.
func newTaskMutation(c config, op Op, opts ...taskOption) *TaskMutation {
	m := &TaskMutation{
		config:        c,
		op:            op,
		typ:           TypeTask,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}

// withTaskID sets the ID field of the mutation.
func withTaskID(id string) taskOption {
	return func(m *TaskMutation) {
		var (
			err   error
			once  sync.Once
			value *Task
		)
		m.oldValue = func(ctx context.Context) (*Task, error) {
			once.Do(func() {
				if m.done {
					err = errors.New("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().Task.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}

// withTask sets the old Task of the mutation.
func withTask(node *Task) taskOption {
	return func(m *TaskMutation) {
		m.oldValue = func(context.Context) (*Task, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}

// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
func (m TaskMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}

// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
func (m TaskMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, errors.New("ent: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}

// SetID sets the value of the id field. Note that this
// operation is only accepted on creation of Task entities.
func (m *TaskMutation) SetID(id string) {
	m.id = &id
}

// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *TaskMutation) ID() (id string, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}

// IDs queries the database and returns the entity ids that match the mutation's predicate.
// That means, if the mutation is applied within a transaction with an isolation level such
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
// or updated by the mutation.
func (m *TaskMutation) IDs(ctx context.Context) ([]string, error) {
	switch {
	case m.op.Is(OpUpdateOne | OpDeleteOne):
		id, exists := m.ID()
		if exists {
			return []string{id}, nil
		}
		fallthrough
	case m.op.Is(OpUpdate | OpDelete):
		return m.Client().Task.Query().Where(m.predicates...).IDs(ctx)
	default:
		return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
	}
}

// SetUID sets the "uid" field.
func (m *TaskMutation) SetUID(s string) {
	m.uid = &s
}

// UID returns the value of the "uid" field in the mutation.
func (m *TaskMutation) UID() (r string, exists bool) {
	v := m.uid
	if v == nil {
		return
	}
	return *v, true
}

// OldUID returns the old "uid" field's value of the Task entity.
// If the Task object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *TaskMutation) OldUID(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldUID is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldUID requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUID: %w", err)
	}
	return oldValue.UID, nil
}

// ResetUID resets all changes to the "uid" field.
func (m *TaskMutation) ResetUID() {
	m.uid = nil
}

// SetRemoteID sets the "remote_id" field.
func (m *TaskMutation) SetRemoteID(s string) {
	m.remote_id = &s
}

// RemoteID returns the value of the "remote_id" field in the mutation.
func (m *TaskMutation) RemoteID() (r string, exists bool) {
	v := m.remote_id
	if v == nil {
		return
	}
	return *v, true
}

// OldRemoteID returns the old "remote_id" field's value of the Task entity.
// If the Task object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *TaskMutation) OldRemoteID(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldRemoteID is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldRemoteID requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldRemoteID: %w", err)
	}
	return oldValue.RemoteID, nil
}

// ClearRemoteID clears the value of the "remote_id" field.
func (m *TaskMutation) ClearRemoteID() {
	m.remote_id = nil
	m.clearedFields[task.FieldRemoteID] = struct{}{}
}

// RemoteIDCleared returns if the "remote_id" field was cleared in this mutation.
func (m *TaskMutation) RemoteIDCleared() bool {
	_, ok := m.clearedFields[task.FieldRemoteID]
	return ok
}

// ResetRemoteID resets all changes to the "remote_id" field.
func (m *TaskMutation) ResetRemoteID() {
	m.remote_id = nil
	delete(m.clearedFields, task.FieldRemoteID)
}

// SetEtag sets the "etag" field.
func (m *TaskMutation) SetEtag(s string) {
	m.etag = &s
}

// Etag returns the value of the "etag" field in the mutation.
func (m *TaskMutation) Etag() (r string, exists bool) {
	v := m.etag
	if v == nil {
		return
	}
	return *v, true
}

// OldEtag returns the old "etag" field's value of the Task entity.
// If the Task object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *TaskMutation) OldEtag(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldEtag is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldEtag requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldEtag: %w", err)
	}
	return oldValue.Etag, nil
}

// ClearEtag clears the value of the "etag" field.
func (m *TaskMutation) ClearEtag() {
	m.etag = nil
	m.clearedFields[task.FieldEtag] = struct{}{}
}

// EtagCleared returns if the "etag" field was cleared in this mutation.
func (m *TaskMutation) EtagCleared() bool {
	_, ok := m.clearedFields[task.FieldEtag]
	return ok
}

// ResetEtag resets all changes to the "etag" field.
func (m *TaskMutation) ResetEtag() {
	m.etag = nil
	delete(m.clearedFields, task.FieldEtag)
}

// SetSummary sets the "summary" field.
func (m *TaskMutation) SetSummary(s string) {
	m.summary = &s
}

// Summary returns the value of the "summary" field in the mutation.
func (m *TaskMutation) Summary() (r string, exists bool) {
	v := m.summary
	if v == nil {
		return
	}
	return *v, true
}

// OldSummary returns the old "summary" field's value of the Task entity.
// If the Task object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *TaskMutation) OldSummary(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldSummary is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldSummary requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldSummary: %w", err)
	}
	return oldValue.Summary, nil
}

// ResetSummary resets all changes to the "summary" field.
func (m *TaskMutation) ResetSummary() {
	m.summary = nil
}

// SetDescription sets the "description" field.
func (m *TaskMutation) SetDescription(s string) {
	m.description = &s
}

// Description returns the value of the "description" field in the mutation.
func (m *TaskMutation) Description() (r string, exists bool) {
	v := m.description
	if v == nil {
		return
	}
	return *v, true
}

// OldDescription returns the old "description" field's value of the Task entity.
// If the Task object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *TaskMutation) OldDescription(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldDescription is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldDescription requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldDescription: %w", err)
	}
	return oldValue.Description, nil
}

// ClearDescription clears the value of the "description" field.
func (m *TaskMutation) ClearDescription() {
	m.description = nil
	m.clearedFields[task.FieldDescription] = struct{}{}
}

// DescriptionCleared returns if the "description" field was cleared in this mutation.
func (m *TaskMutation) DescriptionCleared() bool {
	_, ok := m.clearedFields[task.FieldDescription]
	return ok
}

// ResetDescription resets all changes to the "description" field.
func (m *TaskMutation) ResetDescription() {
	m.description = nil
	delete(m.clearedFields, task.FieldDescription)
}

// SetLocation sets the "location" field.
func (m *TaskMutation) SetLocation(s string) {
	m.location = &s
}

// Location returns the value of the "location" field in the mutation.
func (m *TaskMutation) Location() (r string, exists bool) {
	v := m.location
	if v == nil {
		return
	}
	return *v, true
}

// OldLocation returns the old "location" field's value of the Task entity.
// If the Task object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *TaskMutation) OldLocation(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldLocation is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldLocation requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldLocation: %w", err)
	}
	return oldValue.Location, nil
}

// ClearLocation clears the value of the "location" field.
func (m *TaskMutation) ClearLocation() {
	m.location = nil
	m.clearedFields[task.FieldLocation] = struct{}{}
}

// LocationCleared returns if the "location" field was cleared in this mutation.
func (m *TaskMutation) LocationCleared() bool {
	_, ok := m.clearedFields[task.FieldLocation]
	return ok
}

// ResetLocation resets all changes to the "location" field.
func (m *TaskMutation) ResetLocation() {
	m.location = nil
	delete(m.clearedFields, task.FieldLocation)
}

// SetStatus sets the "status" field.
func (m *TaskMutation) SetStatus(t task.Status) {
	m.status = &t
}

// Status returns the value of the "status" field in the mutation.
func (m *TaskMutation) Status() (r task.Status, exists bool) {
	v := m.status
	if v == nil {
		return
	}
	return *v, true
}

// OldStatus returns the old "status" field's value of the Task entity.
// If the Task object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *TaskMutation) OldStatus(ctx context.Context) (v task.Status, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldStatus is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldStatus requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldStatus: %w", err)
	}
	return oldValue.Status, nil
}

// ResetStatus resets all changes to the "status" field.
func (m *TaskMutation) ResetStatus() {
	m.status = nil
}

// SetPriority sets the "priority" field.
func (m *TaskMutation) SetPriority(i int) {
	m.priority = &i
	m.addpriority = nil
}

// Priority returns the value of the "priority" field in the mutation.
func (m *TaskMutation) Priority() (r int, exists bool) {
	v := m.priority
	if v == nil {
		return
	}
	return *v, true
}

// OldPriority returns the old "priority" field's value of the Task entity.
// If the Task object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *TaskMutation) OldPriority(ctx context.Context) (v int, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldPriority is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldPriority requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldPriority: %w", err)
	}
	return oldValue.Priority, nil
}

// AddPriority adds i to the "priority" field.
func (m *TaskMutation) AddPriority(i int) {
	if m.addpriority != nil {
		*m.addpriority += i
	} else {
		m.addpriority = &i
	}
}

// AddedPriority returns the value that was added to the "priority" field in this mutation.
func (m *TaskMutation) AddedPriority() (r int, exists bool) {
	v := m.addpriority
	if v == nil {
		return
	}
	return *v, true
}

// ResetPriority resets all changes to the "priority" field.
func (m *TaskMutation) ResetPriority() {
	m.priority = nil
	m.addpriority = nil
}

// SetPercentComplete sets the "percent_complete" field.
func (m *TaskMutation) SetPercentComplete(i int) {
	m.percent_complete = &i
	m.addpercent_complete = nil
}

// PercentComplete returns the value of the "percent_complete" field in the mutation.
func (m *TaskMutation) PercentComplete() (r int, exists bool) {
	v := m.percent_complete
	if v == nil {
		return
	}
	return *v, true
}

// OldPercentComplete returns the old "percent_complete" field's value of the Task entity.
// If the Task object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *TaskMutation) OldPercentComplete(ctx context.Context) (v int, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldPercentComplete is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldPercentComplete requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldPercentComplete: %w", err)
	}
	return oldValue.PercentComplete, nil
}

// AddPercentComplete adds i to the "percent_complete" field.
func (m *TaskMutation) AddPercentComplete(i int) {
	if m.addpercent_complete != nil {
		*m.addpercent_complete += i
	} else {
		m.addpercent_complete = &i
	}
}

// AddedPercentComplete returns the value that was added to the "percent_complete" field in this mutation.
func (m *TaskMutation) AddedPercentComplete() (r int, exists bool) {
	v := m.addpercent_complete
	if v == nil {
		return
	}
	return *v, true
}

// ResetPercentComplete resets all changes to the "percent_complete" field.
func (m *TaskMutation) ResetPercentComplete() {
	m.percent_complete = nil
	m.addpercent_complete = nil
}

// SetDue sets the "due" field.
func (m *TaskMutation) SetDue(t time.Time) {
	m.due = &t
}

// Due returns the value of the "due" field in the mutation.
func (m *TaskMutation) Due() (r time.Time, exists bool) {
	v := m.due
	if v == nil {
		return
	}
	return *v, true
}

// OldDue returns the old "due" field's value of the Task entity.
// If the Task object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *TaskMutation) OldDue(ctx context.Context) (v *time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldDue is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldDue requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldDue: %w", err)
	}
	return oldValue.Due, nil
}

// ClearDue clears the value of the "due" field.
func (m *TaskMutation) ClearDue() {
	m.due = nil
	m.clearedFields[task.FieldDue] = struct{}{}
}

// DueCleared returns if the "due" field was cleared in this mutation.
func (m *TaskMutation) DueCleared() bool {
	_, ok := m.clearedFields[task.FieldDue]
	return ok
}

// ResetDue resets all changes to the "due" field.
func (m *TaskMutation) ResetDue() {
	m.due = nil
	delete(m.clearedFields, task.FieldDue)
}

// SetStart sets the "start" field.
func (m *TaskMutation) SetStart(t time.Time) {
	m.start = &t
}

// Start returns the value of the "start" field in the mutation.
func (m *TaskMutation) Start() (r time.Time, exists bool) {
	v := m.start
	if v == nil {
		return
	}
	return *v, true
}

// OldStart returns the old "start" field's value of the Task entity.
// If the Task object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *TaskMutation) OldStart(ctx context.Context) (v *time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldStart is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldStart requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldStart: %w", err)
	}
	return oldValue.Start, nil
}

// ClearStart clears the value of the "start" field.
func (m *TaskMutation) ClearStart() {
	m.start = nil
	m.clearedFields[task.FieldStart] = struct{}{}
}

// StartCleared returns if the "start" field was cleared in this mutation.
func (m *TaskMutation) StartCleared() bool {
	_, ok := m.clearedFields[task.FieldStart]
	return ok
}

// ResetStart resets all changes to the "start" field.
func (m *TaskMutation) ResetStart() {
	m.start = nil
	delete(m.clearedFields, task.FieldStart)
}

// SetCompleted sets the "completed" field.
func (m *TaskMutation) SetCompleted(t time.Time) {
	m.completed = &t
}

// Completed returns the value of the "completed" field in the mutation.
func (m *TaskMutation) Completed() (r time.Time, exists bool) {
	v := m.completed
	if v == nil {
		return
	}
	return *v, true
}

// OldCompleted returns the old "completed" field's value of the Task entity.
// If the Task object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *TaskMutation) OldCompleted(ctx context.Context) (v *time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldCompleted is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldCompleted requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCompleted: %w", err)
	}
	return oldValue.Completed, nil
}

// ClearCompleted clears the value of the "completed" field.
func (m *TaskMutation) ClearCompleted() {
	m.completed = nil
	m.clearedFields[task.FieldCompleted] = struct{}{}
}

// CompletedCleared returns if the "completed" field was cleared in this mutation.
func (m *TaskMutation) CompletedCleared() bool {
	_, ok := m.clearedFields[task.FieldCompleted]
	return ok
}

// ResetCompleted resets all changes to the "completed" field.
func (m *TaskMutation) ResetCompleted() {
	m.completed = nil
	delete(m.clearedFields, task.FieldCompleted)
}

// SetAllDay sets the "all_day" field.
func (m *TaskMutation) SetAllDay(b bool) {
	m.all_day = &b
}

// AllDay returns the value of the "all_day" field in the mutation.
func (m *TaskMutation) AllDay() (r bool, exists bool) {
	v := m.all_day
	if v == nil {
		return
	}
	return *v, true
}

// OldAllDay returns the old "all_day" field's value of the Task entity.
// If the Task object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *TaskMutation) OldAllDay(ctx context.Context) (v bool, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldAllDay is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldAllDay requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldAllDay: %w", err)
	}
	return oldValue.AllDay, nil
}

// ResetAllDay resets all changes to the "all_day" field.
func (m *TaskMutation) ResetAllDay() {
	m.all_day = nil
}

// SetDueTz sets the "due_tz" field.
func (m *TaskMutation) SetDueTz(s string) {
	m.due_tz = &s
}

// DueTz returns the value of the "due_tz" field in the mutation.
func (m *TaskMutation) DueTz() (r string, exists bool) {
	v := m.due_tz
	if v == nil {
		return
	}
	return *v, true
}

// OldDueTz returns the old "due_tz" field's value of the Task entity.
// If the Task object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *TaskMutation) OldDueTz(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldDueTz is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldDueTz requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldDueTz: %w", err)
	}
	return oldValue.DueTz, nil
}

// ClearDueTz clears the value of the "due_tz" field.
func (m *TaskMutation) ClearDueTz() {
	m.due_tz = nil
	m.clearedFields[task.FieldDueTz] = struct{}{}
}

// DueTzCleared returns if the "due_tz" field was cleared in this mutation.
func (m *TaskMutation) DueTzCleared() bool {
	_, ok := m.clearedFields[task.FieldDueTz]
	return ok
}

// ResetDueTz resets all changes to the "due_tz" field.
func (m *TaskMutation) ResetDueTz() {
	m.due_tz = nil
	delete(m.clearedFields, task.FieldDueTz)
}

// SetStartTz sets the "start_tz" field.
func (m *TaskMutation) SetStartTz(s string) {
	m.start_tz = &s
}

// StartTz returns the value of the "start_tz" field in the mutation.
func (m *TaskMutation) StartTz() (r string, exists bool) {
	v := m.start_tz
	if v == nil {
		return
	}
	return *v, true
}

// OldStartTz returns the old "start_tz" field's value of the Task entity.
// If the Task object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *TaskMutation) OldStartTz(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldStartTz is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldStartTz requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldStartTz: %w", err)
	}
	return oldValue.StartTz, nil
}

// ClearStartTz clears the value of the "start_tz" field.
func (m *TaskMutation) ClearStartTz() {
	m.start_tz = nil
	m.clearedFields[task.FieldStartTz] = struct{}{}
}

// StartTzCleared returns if the "start_tz" field was cleared in this mutation.
func (m *TaskMutation) StartTzCleared() bool {
	_, ok := m.clearedFields[task.FieldStartTz]
	return ok
}

// ResetStartTz resets all changes to the "start_tz" field.
func (m *TaskMutation) ResetStartTz() {
	m.start_tz = nil
	delete(m.clearedFields, task.FieldStartTz)
}

// SetParentUID sets the "parent_uid" field.
func (m *TaskMutation) SetParentUID(s string) {
	m.parent_uid = &s
}

// ParentUID returns the value of the "parent_uid" field in the mutation.
func (m *TaskMutation) ParentUID() (r string, exists bool) {
	v := m.parent_uid
	if v == nil {
		return
	}
	return *v, true
}

// OldParentUID returns the old "parent_uid" field's value of the Task entity.
// If the Task object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *TaskMutation) OldParentUID(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldParentUID is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldParentUID requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldParentUID: %w", err)
	}
	return oldValue.ParentUID, nil
}

// ClearParentUID clears the value of the "parent_uid" field.
func (m *TaskMutation) ClearParentUID() {
	m.parent_uid = nil
	m.clearedFields[task.FieldParentUID] = struct{}{}
}

// ParentUIDCleared returns if the "parent_uid" field was cleared in this mutation.
func (m *TaskMutation) ParentUIDCleared() bool {
	_, ok := m.clearedFields[task.FieldParentUID]
	return ok
}

// ResetParentUID resets all changes to the "parent_uid" field.
func (m *TaskMutation) ResetParentUID() {
	m.parent_uid = nil
	delete(m.clearedFields, task.FieldParentUID)
}

// SetRecurrence sets the "recurrence" field.
func (m *TaskMutation) SetRecurrence(value map[string]interface{}) {
	m.recurrence = &value
}

// Recurrence returns the value of the "recurrence" field in the mutation.
func (m *TaskMutation) Recurrence() (r map[string]interface{}, exists bool) {
	v := m.recurrence
	if v == nil {
		return
	}
	return *v, true
}

// OldRecurrence returns the old "recurrence" field's value of the Task entity.
// If the Task object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *TaskMutation) OldRecurrence(ctx context.Context) (v map[string]interface{}, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldRecurrence is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldRecurrence requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldRecurrence: %w", err)
	}
	return oldValue.Recurrence, nil
}

// ClearRecurrence clears the value of the "recurrence" field.
func (m *TaskMutation) ClearRecurrence() {
	m.recurrence = nil
	m.clearedFields[task.FieldRecurrence] = struct{}{}
}

// RecurrenceCleared returns if the "recurrence" field was cleared in this mutation.
func (m *TaskMutation) RecurrenceCleared() bool {
	_, ok := m.clearedFields[task.FieldRecurrence]
	return ok
}

// ResetRecurrence resets all changes to the "recurrence" field.
func (m *TaskMutation) ResetRecurrence() {
	m.recurrence = nil
	delete(m.clearedFields, task.FieldRecurrence)
}

// SetReminders sets the "reminders" field.
func (m *TaskMutation) SetReminders(value []map[string]interface{}) {
	m.reminders = &value
	m.appendreminders = nil
}

// Reminders returns the value of the "reminders" field in the mutation.
func (m *TaskMutation) Reminders() (r []map[string]interface{}, exists bool) {
	v := m.reminders
	if v == nil {
		return
	}
	return *v, true
}

// OldReminders returns the old "reminders" field's value of the Task entity.
// If the Task object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *TaskMutation) OldReminders(ctx context.Context) (v []map[string]interface{}, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldReminders is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldReminders requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldReminders: %w", err)
	}
	return oldValue.Reminders, nil
}

// AppendReminders adds value to the "reminders" field.
func (m *TaskMutation) AppendReminders(value []map[string]interface{}) {
	m.appendreminders = append(m.appendreminders, value...)
}

// AppendedReminders returns the list of values that were appended to the "reminders" field in this mutation.
func (m *TaskMutation) AppendedReminders() ([]map[string]interface{}, bool) {
	if len(m.appendreminders) == 0 {
		return nil, false
	}
	return m.appendreminders, true
}

// ClearReminders clears the value of the "reminders" field.
func (m *TaskMutation) ClearReminders() {
	m.reminders = nil
	m.appendreminders = nil
	m.clearedFields[task.FieldReminders] = struct{}{}
}

// RemindersCleared returns if the "reminders" field was cleared in this mutation.
func (m *TaskMutation) RemindersCleared() bool {
	_, ok := m.clearedFields[task.FieldReminders]
	return ok
}

// ResetReminders resets all changes to the "reminders" field.
func (m *TaskMutation) ResetReminders() {
	m.reminders = nil
	m.appendreminders = nil
	delete(m.clearedFields, task.FieldReminders)
}

// SetCategories sets the "categories" field.
func (m *TaskMutation) SetCategories(s []string) {
	m.categories = &s
	m.appendcategories = nil
}

// Categories returns the value of the "categories" field in the mutation.
func (m *TaskMutation) Categories() (r []string, exists bool) {
	v := m.categories
	if v == nil {
		return
	}
	return *v, true
}

// OldCategories returns the old "categories" field's value of the Task entity.
// If the Task object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *TaskMutation) OldCategories(ctx context.Context) (v []string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldCategories is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldCategories requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCategories: %w", err)
	}
	return oldValue.Categories, nil
}

// AppendCategories adds s to the "categories" field.
func (m *TaskMutation) AppendCategories(s []string) {
	m.appendcategories = append(m.appendcategories, s...)
}

// AppendedCategories returns the list of values that were appended to the "categories" field in this mutation.
func (m *TaskMutation) AppendedCategories() ([]string, bool) {
	if len(m.appendcategories) == 0 {
		return nil, false
	}
	return m.appendcategories, true
}

// ClearCategories clears the value of the "categories" field.
func (m *TaskMutation) ClearCategories() {
	m.categories = nil
	m.appendcategories = nil
	m.clearedFields[task.FieldCategories] = struct{}{}
}

// CategoriesCleared returns if the "categories" field was cleared in this mutation.
func (m *TaskMutation) CategoriesCleared() bool {
	_, ok := m.clearedFields[task.FieldCategories]
	return ok
}

// ResetCategories resets all changes to the "categories" field.
func (m *TaskMutation) ResetCategories() {
	m.categories = nil
	m.appendcategories = nil
	delete(m.clearedFields, task.FieldCategories)
}

// SetRawIcs sets the "raw_ics" field.
func (m *TaskMutation) SetRawIcs(s string) {
	m.raw_ics = &s
}

// RawIcs returns the value of the "raw_ics" field in the mutation.
func (m *TaskMutation) RawIcs() (r string, exists bool) {
	v := m.raw_ics
	if v == nil {
		return
	}
	return *v, true
}

// OldRawIcs returns the old "raw_ics" field's value of the Task entity.
// If the Task object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *TaskMutation) OldRawIcs(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldRawIcs is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldRawIcs requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldRawIcs: %w", err)
	}
	return oldValue.RawIcs, nil
}

// ClearRawIcs clears the value of the "raw_ics" field.
func (m *TaskMutation) ClearRawIcs() {
	m.raw_ics = nil
	m.clearedFields[task.FieldRawIcs] = struct{}{}
}

// RawIcsCleared returns if the "raw_ics" field was cleared in this mutation.
func (m *TaskMutation) RawIcsCleared() bool {
	_, ok := m.clearedFields[task.FieldRawIcs]
	return ok
}

// ResetRawIcs resets all changes to the "raw_ics" field.
func (m *TaskMutation) ResetRawIcs() {
	m.raw_ics = nil
	delete(m.clearedFields, task.FieldRawIcs)
}

// SetCreated sets the "created" field.
func (m *TaskMutation) SetCreated(t time.Time) {
	m.created = &t
}

// Created returns the value of the "created" field in the mutation.
func (m *TaskMutation) Created() (r time.Time, exists bool) {
	v := m.created
	if v == nil {
		return
	}
	return *v, true
}

// OldCreated returns the old "created" field's value of the Task entity.
// If the Task object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *TaskMutation) OldCreated(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldCreated is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldCreated requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCreated: %w", err)
	}
	return oldValue.Created, nil
}

// ResetCreated resets all changes to the "created" field.
func (m *TaskMutation) ResetCreated() {
	m.created = nil
}

// SetUpdated sets the "updated" field.
func (m *TaskMutation) SetUpdated(t time.Time) {
	m.updated = &t
}

// Updated returns the value of the "updated" field in the mutation.
func (m *TaskMutation) Updated() (r time.Time, exists bool) {
	v := m.updated
	if v == nil {
		return
	}
	return *v, true
}

// OldUpdated returns the old "updated" field's value of the Task entity.
// If the Task object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *TaskMutation) OldUpdated(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldUpdated is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldUpdated requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUpdated: %w", err)
	}
	return oldValue.Updated, nil
}

// ResetUpdated resets all changes to the "updated" field.
func (m *TaskMutation) ResetUpdated() {
	m.updated = nil
}

// SetCalendarID sets the "calendar" edge to the Calendar entity by id.
func (m *TaskMutation) SetCalendarID(id string) {
	m.calendar = &id
}

// ClearCalendar clears the "calendar" edge to the Calendar entity.
func (m *TaskMutation) ClearCalendar() {
	m.clearedcalendar = true
}

// CalendarCleared reports if the "calendar" edge to the Calendar entity was cleared.
func (m *TaskMutation) CalendarCleared() bool {
	return m.clearedcalendar
}

// CalendarID returns the "calendar" edge ID in the mutation.
func (m *TaskMutation) CalendarID() (id string, exists bool) {
	if m.calendar != nil {
		return *m.calendar, true
	}
	return
}

// CalendarIDs returns the "calendar" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// CalendarID instead. It exists only for internal usage by the builders.
func (m *TaskMutation) CalendarIDs() (ids []string) {
	if id := m.calendar; id != nil {
		ids = append(ids, *id)
	}
	return
}

// ResetCalendar resets all changes to the "calendar" edge.
func (m *TaskMutation) ResetCalendar() {
	m.calendar = nil
	m.clearedcalendar = false
}

// Where appends a list predicates to the TaskMutation builder.
func (m *TaskMutation) Where(ps ...predicate.Task) {
	m.predicates = append(m.predicates, ps...)
}

// WhereP appends storage-level predicates to the TaskMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *TaskMutation) WhereP(ps ...func(*sql.Selector)) {
	p := make([]predicate.Task, len(ps))
	for i := range ps {
		p[i] = ps[i]
	}
	m.Where(p...)
}

// Op returns the operation name.
func (m *TaskMutation) Op() Op {
	return m.op
}

// SetOp allows setting the mutation operation.
func (m *TaskMutation) SetOp(op Op) {
	m.op = op
}

// Type returns the node type of this mutation (Task).
func (m *TaskMutation) Type() string {
	return m.typ
}

// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *TaskMutation) Fields() []string {
	fields := make([]string, 0, 22)
	if m.uid != nil {
		fields = append(fields, task.FieldUID)
	}
	if m.remote_id != nil {
		fields = append(fields, task.FieldRemoteID)
	}
	if m.etag != nil {
		fields = append(fields, task.FieldEtag)
	}
	if m.summary != nil {
		fields = append(fields, task.FieldSummary)
	}
	if m.description != nil {
		fields = append(fields, task.FieldDescription)
	}
	if m.location != nil {
		fields = append(fields, task.FieldLocation)
	}
	if m.status != nil {
		fields = append(fields, task.FieldStatus)
	}
	if m.priority != nil {
		fields = append(fields, task.FieldPriority)
	}
	if m.percent_complete != nil {
		fields = append(fields, task.FieldPercentComplete)
	}
	if m.due != nil {
		fields = append(fields, task.FieldDue)
	}
	if m.start != nil {
		fields = append(fields, task.FieldStart)
	}
	if m.completed != nil {
		fields = append(fields, task.FieldCompleted)
	}
	if m.all_day != nil {
		fields = append(fields, task.FieldAllDay)
	}
	if m.due_tz != nil {
		fields = append(fields, task.FieldDueTz)
	}
	if m.start_tz != nil {
		fields = append(fields, task.FieldStartTz)
	}
	if m.parent_uid != nil {
		fields = append(fields, task.FieldParentUID)
	}
	if m.recurrence != nil {
		fields = append(fields, task.FieldRecurrence)
	}
	if m.reminders != nil {
		fields = append(fields, task.FieldReminders)
	}
	if m.categories != nil {
		fields = append(fields, task.FieldCategories)
	}
	if m.raw_ics != nil {
		fields = append(fields, task.FieldRawIcs)
	}
	if m.created != nil {
		fields = append(fields, task.FieldCreated)
	}
	if m.updated != nil {
		fields = append(fields, task.FieldUpdated)
	}
	return fields
}

// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *TaskMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case task.FieldUID:
		return m.UID()
	case task.FieldRemoteID:
		return m.RemoteID()
	case task.FieldEtag:
		return m.Etag()
	case task.FieldSummary:
		return m.Summary()
	case task.FieldDescription:
		return m.Description()
	case task.FieldLocation:
		return m.Location()
	case task.FieldStatus:
		return m.Status()
	case task.FieldPriority:
		return m.Priority()
	case task.FieldPercentComplete:
		return m.PercentComplete()
	case task.FieldDue:
		return m.Due()
	case task.FieldStart:
		return m.Start()
	case task.FieldCompleted:
		return m.Completed()
	case task.FieldAllDay:
		return m.AllDay()
	case task.FieldDueTz:
		return m.DueTz()
	case task.FieldStartTz:
		return m.StartTz()
	case task.FieldParentUID:
		return m.ParentUID()
	case task.FieldRecurrence:
		return m.Recurrence()
	case task.FieldReminders:
		return m.Reminders()
	case task.FieldCategories:
		return m.Categories()
	case task.FieldRawIcs:
		return m.RawIcs()
	case task.FieldCreated:
		return m.Created()
	case task.FieldUpdated:
		return m.Updated()
	}
	return nil, false
}

// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *TaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case task.FieldUID:
		return m.OldUID(ctx)
	case task.FieldRemoteID:
		return m.OldRemoteID(ctx)
	case task.FieldEtag:
		return m.OldEtag(ctx)
	case task.FieldSummary:
		return m.OldSummary(ctx)
	case task.FieldDescription:
		return m.OldDescription(ctx)
	case task.FieldLocation:
		return m.OldLocation(ctx)
	case task.FieldStatus:
		return m.OldStatus(ctx)
	case task.FieldPriority:
		return m.OldPriority(ctx)
	case task.FieldPercentComplete:
		return m.OldPercentComplete(ctx)
	case task.FieldDue:
		return m.OldDue(ctx)
	case task.FieldStart:
		return m.OldStart(ctx)
	case task.FieldCompleted:
		return m.OldCompleted(ctx)
	case task.FieldAllDay:
		return m.OldAllDay(ctx)
	case task.FieldDueTz:
		return m.OldDueTz(ctx)
	case task.FieldStartTz:
		return m.OldStartTz(ctx)
	case task.FieldParentUID:
		return m.OldParentUID(ctx)
	case task.FieldRecurrence:
		return m.OldRecurrence(ctx)
	case task.FieldReminders:
		return m.OldReminders(ctx)
	case task.FieldCategories:
		return m.OldCategories(ctx)
	case task.FieldRawIcs:
		return m.OldRawIcs(ctx)
	case task.FieldCreated:
		return m.OldCreated(ctx)
	case task.FieldUpdated:
		return m.OldUpdated(ctx)
	}
	return nil, fmt.Errorf("unknown Task field %s", name)
}

// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *TaskMutation) SetField(name string, value ent.Value) error {
	switch name {
	case task.FieldUID:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUID(v)
		return nil
	case task.FieldRemoteID:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetRemoteID(v)
		return nil
	case task.FieldEtag:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetEtag(v)
		return nil
	case task.FieldSummary:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetSummary(v)
		return nil
	case task.FieldDescription:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetDescription(v)
		return nil
	case task.FieldLocation:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetLocation(v)
		return nil
	case task.FieldStatus:
		v, ok := value.(task.Status)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetStatus(v)
		return nil
	case task.FieldPriority:
		v, ok := value.(int)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetPriority(v)
		return nil
	case task.FieldPercentComplete:
		v, ok := value.(int)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetPercentComplete(v)
		return nil
	case task.FieldDue:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetDue(v)
		return nil
	case task.FieldStart:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetStart(v)
		return nil
	case task.FieldCompleted:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCompleted(v)
		return nil
	case task.FieldAllDay:
		v, ok := value.(bool)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetAllDay(v)
		return nil
	case task.FieldDueTz:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetDueTz(v)
		return nil
	case task.FieldStartTz:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetStartTz(v)
		return nil
	case task.FieldParentUID:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetParentUID(v)
		return nil
	case task.FieldRecurrence:
		v, ok := value.(map[string]interface{})
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetRecurrence(v)
		return nil
	case task.FieldReminders:
		v, ok := value.([]map[string]interface{})
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetReminders(v)
		return nil
	case task.FieldCategories:
		v, ok := value.([]string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCategories(v)
		return nil
	case task.FieldRawIcs:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetRawIcs(v)
		return nil
	case task.FieldCreated:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCreated(v)
		return nil
	case task.FieldUpdated:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUpdated(v)
		return nil
	}
	return fmt.Errorf("unknown Task field %s", name)
}

// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *TaskMutation) AddedFields() []string {
	var fields []string
	if m.addpriority != nil {
		fields = append(fields, task.FieldPriority)
	}
	if m.addpercent_complete != nil {
		fields = append(fields, task.FieldPercentComplete)
	}
	return fields
}

// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
func (m *TaskMutation) AddedField(name string) (ent.Value, bool) {
	switch name {
	case task.FieldPriority:
		return m.AddedPriority()
	case task.FieldPercentComplete:
		return m.AddedPercentComplete()
	}
	return nil, false
}

// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *TaskMutation) AddField(name string, value ent.Value) error {
	switch name {
	case task.FieldPriority:
		v, ok := value.(int)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.AddPriority(v)
		return nil
	case task.FieldPercentComplete:
		v, ok := value.(int)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.AddPercentComplete(v)
		return nil
	}
	return fmt.Errorf("unknown Task numeric field %s", name)
}

// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *TaskMutation) ClearedFields() []string {
	var fields []string
	if m.FieldCleared(task.FieldRemoteID) {
		fields = append(fields, task.FieldRemoteID)
	}
	if m.FieldCleared(task.FieldEtag) {
		fields = append(fields, task.FieldEtag)
	}
	if m.FieldCleared(task.FieldDescription) {
		fields = append(fields, task.FieldDescription)
	}
	if m.FieldCleared(task.FieldLocation) {
		fields = append(fields, task.FieldLocation)
	}
	if m.FieldCleared(task.FieldDue) {
		fields = append(fields, task.FieldDue)
	}
	if m.FieldCleared(task.FieldStart) {
		fields = append(fields, task.FieldStart)
	}
	if m.FieldCleared(task.FieldCompleted) {
		fields = append(fields, task.FieldCompleted)
	}
	if m.FieldCleared(task.FieldDueTz) {
		fields = append(fields, task.FieldDueTz)
	}
	if m.FieldCleared(task.FieldStartTz) {
		fields = append(fields, task.FieldStartTz)
	}
	if m.FieldCleared(task.FieldParentUID) {
		fields = append(fields, task.FieldParentUID)
	}
	if m.FieldCleared(task.FieldRecurrence) {
		fields = append(fields, task.FieldRecurrence)
	}
	if m.FieldCleared(task.FieldReminders) {
		fields = append(fields, task.FieldReminders)
	}
	if m.FieldCleared(task.FieldCategories) {
		fields = append(fields, task.FieldCategories)
	}
	if m.FieldCleared(task.FieldRawIcs) {
		fields = append(fields, task.FieldRawIcs)
	}
	return fields
}

// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *TaskMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}

// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
func (m *TaskMutation) ClearField(name string) error {
	switch name {
	case task.FieldRemoteID:
		m.ClearRemoteID()
		return nil
	case task.FieldEtag:
		m.ClearEtag()
		return nil
	case task.FieldDescription:
		m.ClearDescription()
		return nil
	case task.FieldLocation:
		m.ClearLocation()
		return nil
	case task.FieldDue:
		m.ClearDue()
		return nil
	case task.FieldStart:
		m.ClearStart()
		return nil
	case task.FieldCompleted:
		m.ClearCompleted()
		return nil
	case task.FieldDueTz:
		m.ClearDueTz()
		return nil
	case task.FieldStartTz:
		m.ClearStartTz()
		return nil
	case task.FieldParentUID:
		m.ClearParentUID()
		return nil
	case task.FieldRecurrence:
		m.ClearRecurrence()
		return nil
	case task.FieldReminders:
		m.ClearReminders()
		return nil
	case task.FieldCategories:
		m.ClearCategories()
		return nil
	case task.FieldRawIcs:
		m.ClearRawIcs()
		return nil
	}
	return fmt.Errorf("unknown Task nullable field %s", name)
}

// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
func (m *TaskMutation) ResetField(name string) error {
	switch name {
	case task.FieldUID:
		m.ResetUID()
		return nil
	case task.FieldRemoteID:
		m.ResetRemoteID()
		return nil
	case task.FieldEtag:
		m.ResetEtag()
		return nil
	case task.FieldSummary:
		m.ResetSummary()
		return nil
	case task.FieldDescription:
		m.ResetDescription()
		return nil
	case task.FieldLocation:
		m.ResetLocation()
		return nil
	case task.FieldStatus:
		m.ResetStatus()
		return nil
	case task.FieldPriority:
		m.ResetPriority()
		return nil
	case task.FieldPercentComplete:
		m.ResetPercentComplete()
		return nil
	case task.FieldDue:
		m.ResetDue()
		return nil
	case task.FieldStart:
		m.ResetStart()
		return nil
	case task.FieldCompleted:
		m.ResetCompleted()
		return nil
	case task.FieldAllDay:
		m.ResetAllDay()
		return nil
	case task.FieldDueTz:
		m.ResetDueTz()
		return nil
	case task.FieldStartTz:
		m.ResetStartTz()
		return nil
	case task.FieldParentUID:
		m.ResetParentUID()
		return nil
	case task.FieldRecurrence:
		m.ResetRecurrence()
		return nil
	case task.FieldReminders:
		m.ResetReminders()
		return nil
	case task.FieldCategories:
		m.ResetCategories()
		return nil
	case task.FieldRawIcs:
		m.ResetRawIcs()
		return nil
	case task.FieldCreated:
		m.ResetCreated()
		return nil
	case task.FieldUpdated:
		m.ResetUpdated()
		return nil
	}
	return fmt.Errorf("unknown Task field %s", name)
}

// AddedEdges returns all edge names that were set/added in this mutation.
func (m *TaskMutation) AddedEdges() []string {
	edges := make([]string, 0, 1)
	if m.calendar != nil {
		edges = append(edges, task.EdgeCalendar)
	}
	return edges
}

// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *TaskMutation) AddedIDs(name string) []ent.Value {
	switch name {
	case task.EdgeCalendar:
		if id := m.calendar; id != nil {
			return []ent.Value{*id}
		}
	}
	return nil
}

// RemovedEdges returns all edge names that were removed in this mutation.
func (m *TaskMutation) RemovedEdges() []string {
	edges := make([]string, 0, 1)
	return edges
}

// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *TaskMutation) RemovedIDs(name string) []ent.Value {
	return nil
}

// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *TaskMutation) ClearedEdges() []string {
	edges := make([]string, 0, 1)
	if m.clearedcalendar {
		edges = append(edges, task.EdgeCalendar)
	}
	return edges
}

// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *TaskMutation) EdgeCleared(name string) bool {
	switch name {
	case task.EdgeCalendar:
		return m.clearedcalendar
	}
	return false
}

// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *TaskMutation) ClearEdge(name string) error {
	switch name {
	case task.EdgeCalendar:
		m.ClearCalendar()
		return nil
	}
	return fmt.Errorf("unknown Task unique edge %s", name)
}

// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *TaskMutation) ResetEdge(name string) error {
	switch name {
	case task.EdgeCalendar:
		m.ResetCalendar()
		return nil
	}
	return fmt.Errorf("unknown Task edge %s", name)
}
