import {
  init_cjs_shims
} from "./chunk-7GH3YGSC.js";

// src/queries/standard-queries.ts
init_cjs_shims();
var standardQueries = `
mutation StoreSchema($schema: SchemaInput!) {
  storeSchema(schema: $schema) {
    __typename
    ... on StoreSchemaResult {
      schema {
        key
        name
        version {
          created
          version
        }
      }
    }
    ... on BadRequestError {
      code
      message
      retryable
    }
    ... on InternalError {
      code
      message
      retryable
    }
  }
}

mutation DeleteSchema(
  $schema: SchemaMatchInput!
) {
  deleteSchema(schema: $schema) {
    __typename
    ... on DeleteSchemaResult {
      success
    }
    ... on BadRequestError {
      code
      message
      retryable
    }
    ... on InternalError {
      code
      message
      retryable
    }
  }
}

mutation CreateLedger(
  $ik: SafeString!
  $ledger: CreateLedgerInput!
  $schemaKey: SafeString!
) {
  createLedger(ik: $ik, ledger: $ledger, schema: { key: $schemaKey }) {
    __typename
    ... on CreateLedgerResult {
      ledger {
        id
        ik
        name
        created
        schema {
          key
        }
      }
      isIkReplay
    }
    ... on BadRequestError {
      code
      message
      retryable
    }
    ... on InternalError {
      code
      message
      retryable
    }
  }
}

mutation DeleteLedger(
  $ledger: LedgerMatchInput!
) {
  deleteLedger(ledger: $ledger) {
    __typename
    ... on DeleteLedgerResult {
      success
    }
    ... on BadRequestError {
      code
      message
      retryable
    }
    ... on InternalError {
      code
      message
      retryable
    }
  }
}

mutation AddLedgerEntry(
  $ik: SafeString!
  $ledgerIk: SafeString!
  $type: String!
  $typeVersion: Int
  $posted: DateTime
  $parameters: JSON!
  $tags: [LedgerEntryTagInput!]
  $groups: [LedgerEntryGroupInput!]
) {
  addLedgerEntry(
    ik: $ik
    entry: {
      ledger: { ik: $ledgerIk }
      type: $type
      typeVersion: $typeVersion
      posted: $posted
      parameters: $parameters
      tags: $tags
      groups: $groups
    }
  ) {
    __typename
    ... on AddLedgerEntryResult {
      isIkReplay
      entry {
        type
        typeVersion
        id
        ik
        posted
        created
      }
      lines {
        id
        amount
        account {
          path
        }
      }
    }
    ... on BadRequestError {
      code
      message
      retryable
    }
    ... on InternalError {
      code
      message
      retryable
    }
  }
}


mutation ReverseLedgerEntry(
  $id: ID!
) {
  reverseLedgerEntry(id: $id) {
    __typename
    ... on ReverseLedgerEntryResult {
      reversingLedgerEntry {
        ik
        id
        created
        posted
        type
        typeVersion
        description
        hidden
        lines {
          nodes {
            id
            amount
            account {
              path
            }
          }
        }
      }
      reversedLedgerEntry {
        ik
        id
        created
        posted
        type
        typeVersion
        description
        hidden
        lines {
          nodes {
            id
            amount
            account {
              path
            }
          }
        }
      }
      isIkReplay
    }
    ... on BadRequestError {
      code
      message
      retryable
    }
    ... on InternalError {
      code
      message
      retryable
    }
  }
}

mutation MigrateLedgerEntry(
  $id: ID!
  $newLedgerEntry: LedgerEntryInput!
) {
  migrateLedgerEntry(input: {
    id: $id
    newLedgerEntry: $newLedgerEntry
  }) {
    __typename
    ... on MigrateLedgerEntryResult {
      reversingLedgerEntry {
        ik
        id
        created
        posted
        type
        description
        reversedAt
        hidden
        lines {
          nodes {
            id
            amount
            account {
              path
            }
          }
        }
      }
      reversedLedgerEntry {
        ik
        id
        created
        posted
        type
        description
        reversedAt
        hidden
        lines {
          nodes {
            id
            amount
            account {
              path
            }
          }
        }
      }
      newLedgerEntry {
        ik
        id
        created
        posted
        type
        description
        reversedAt
        hidden
        lines {
          nodes {
            id
            amount
            account {
              path
            }
          }
        }
      }
      isIkReplay
    }
    ... on BadRequestError {
      code
      message
      retryable
    }
    ... on InternalError {
      code
      message
      retryable
    }
  }
}

mutation AddLedgerEntryRuntime(
  $ik: SafeString!
  $type: String!
  $typeVersion: Int
  $ledgerIk: SafeString!
  $posted: DateTime
  $lines: [LedgerLineInput!]!
  $tags: [LedgerEntryTagInput!]
  $groups: [LedgerEntryGroupInput!]
) {
  addLedgerEntry(
    ik: $ik
    entry: {
      type: $type
      typeVersion: $typeVersion
      ledger: { ik: $ledgerIk }
      posted: $posted
      lines: $lines
      tags: $tags
      groups: $groups
    }
  ) {
    __typename
    ... on AddLedgerEntryResult {
      isIkReplay
      entry {
        type
        typeVersion
        id
        ik
        posted
        created
      }
      lines {
        id
        amount
        account {
          path
        }
      }
    }
    ... on BadRequestError {
      code
      message
      retryable
    }
    ... on InternalError {
      code
      message
      retryable
    }
  }
}

mutation ReconcileTx(
  $ledgerIk: SafeString!
  $type: String!
  $typeVersion: Int
  $parameters: JSON!
  $tags: [LedgerEntryTagInput!]
  $groups: [LedgerEntryGroupInput!]
) {
  reconcileTx(
    entry: {
      ledger: { ik: $ledgerIk }
      type: $type
      typeVersion: $typeVersion
      parameters: $parameters
      tags: $tags
      groups: $groups
    }
  ) {
    __typename
    ... on ReconcileTxResult {
      entry {
        id
        ik
        date
        posted
        created
        description
        type
        typeVersion
      }
      lines {
        id
        amount
        account {
          path
        }
        externalTxId
      }
    }
    ... on BadRequestError {
      code
      message
      retryable
    }
    ... on InternalError {
      code
      message
      retryable
    }
  }
}

mutation ReconcileTxRuntime(
  $ledgerIk: SafeString!
  $type: String!
  $typeVersion: Int
  $lines: [LedgerLineInput!]!
  $tags: [LedgerEntryTagInput!]
  $groups: [LedgerEntryGroupInput!]
) {
  reconcileTx(
    entry: {
      ledger: { ik: $ledgerIk }
      type: $type
      typeVersion: $typeVersion
      lines: $lines
      tags: $tags
      groups: $groups
    }
  ) {
    __typename
    ... on ReconcileTxResult {
      entry {
        id
        ik
        date
        posted
        created
        description
        type
        typeVersion
      }
      lines {
        id
        amount
        account {
          path
        }
        externalTxId
      }
    }
    ... on BadRequestError {
      code
      message
      retryable
    }
    ... on InternalError {
      code
      message
      retryable
    }
  }
}

mutation UpdateLedgerEntry(
  $entryIk: SafeString!
  $ledgerIk: SafeString!
  $update: UpdateLedgerEntryInput!
) {
  updateLedgerEntry(
    ledgerEntry: { ik: $entryIk, ledger: { ik: $ledgerIk } }
    update: $update
  ) {
    __typename
    ... on UpdateLedgerEntryResult {
      entry {
        id
        ik
        posted
        created
        description
        lines {
          nodes {
            id
            amount
            account {
              path
            }
          }
        }
        groups {
          key
          value
        }
        tags {
          key
          value
        }
      }
    }
    ... on BadRequestError {
      code
      message
      retryable
    }
    ... on InternalError {
      code
      message
      retryable
    }
  }
}

mutation UpdateLedger($ledgerIk: SafeString!, $update: UpdateLedgerInput!) {
  updateLedger(ledger: { ik: $ledgerIk }, update: $update) {
    __typename
    ... on UpdateLedgerResult {
      ledger {
        id
        ik
        name
      }
    }
    ... on BadRequestError {
      code
      message
      retryable
    }
    ... on InternalError {
      code
      message
      retryable
    }
  }
}
mutation CreateCustomLink($name: String!, $ik: SafeString!) {
  createCustomLink(name: $name, ik: $ik) {
    __typename
    ... on CreateCustomLinkResult {
      link {
        id
        name
        created
      }
      isIkReplay
    }
    ... on BadRequestError {
      code
      message
      retryable
    }
    ... on InternalError {
      code
      message
      retryable
    }
  }
}

mutation SyncCustomAccounts($linkId: ID!, $accounts: [CustomAccountInput!]!) {
  syncCustomAccounts(link: { id: $linkId }, accounts: $accounts) {
    __typename
    ... on SyncCustomAccountsResult {
      accounts {
        id
        externalId
        name
        currency {
          code
          customCurrencyId
        }
      }
    }
    ... on BadRequestError {
      code
      message
      retryable
    }
    ... on InternalError {
      code
      message
      retryable
    }
  }
}

mutation SyncCustomTxs($linkId: ID!, $txs: [CustomTxInput!]!) {
  syncCustomTxs(link: { id: $linkId }, txs: $txs) {
    __typename
    ... on SyncCustomTxsResult {
      txs {
        __typename
        linkId
        id
        externalId
        externalAccountId
        amount
        description
        posted
      }
    }
    ... on BadRequestError {
      code
      message
      retryable
    }
    ... on InternalError {
      code
      message
      retryable
    }
  }
}

mutation DeleteCustomTxs($txs: [ID!]!) {
  deleteCustomTxs(txs: $txs) {
    __typename
    ... on DeleteCustomTxsResult {
      txs {
        tx {
          linkId
          id
          externalId
          externalAccountId
          amount
          description
          posted
          deletedAt
        }
      }
    }
    ... on BadRequestError {
      code
      message
      retryable
    }
    ... on InternalError {
      code
      message
      retryable
    }
  }
}

query GetLedger($ik: SafeString!) {
  ledger(ledger: { ik: $ik }) {
    id
    ik
    name
    created
    balanceUTCOffset
  }
}

query GetLedgerEntry($ik: SafeString!, $ledgerIk: SafeString!) {
  ledgerEntry(ledgerEntry: { ik: $ik, ledger: { ik: $ledgerIk } }) {
    id
    ik
    posted
    created
    description
    lines {
      nodes {
        id
        amount
        account {
          path
        }
      }
    }
  }
}

query ListLedgerAccounts(
  $ledgerIk: SafeString!
  $after: String
  $first: Int
  $before: String
) {
  ledger(ledger: { ik: $ledgerIk }) {
    id
    ik
    name
    created
    ledgerAccounts(after: $after, first: $first, before: $before) {
      nodes {
        id
        path
        name
        type
        created
      }
      pageInfo {
        hasNextPage
        endCursor
        hasPreviousPage
        startCursor
      }
    }
  }
}

query ListLedgerAccountBalances(
  $ledgerIk: SafeString!
  $after: String
  $first: Int
  $before: String
  $balanceCurrency: CurrencyMatchInput
  $balanceAt: LastMoment
  $ownBalanceConsistencyMode: ReadBalanceConsistencyMode
  $childBalanceConsistencyMode: ReadBalanceConsistencyMode
  $balanceConsistencyMode: ReadBalanceConsistencyMode
) {
  ledger(ledger: { ik: $ledgerIk }) {
    id
    ik
    name
    created
    ledgerAccounts(after: $after, first: $first, before: $before) {
      nodes {
        id
        path
        name
        type
        created
        ownBalance(
          currency: $balanceCurrency
          at: $balanceAt
          consistencyMode: $ownBalanceConsistencyMode
        )
        childBalance(
          currency: $balanceCurrency
          at: $balanceAt
          consistencyMode: $childBalanceConsistencyMode
        )
        balance(
          currency: $balanceCurrency
          at: $balanceAt
          consistencyMode: $balanceConsistencyMode
        )
      }
      pageInfo {
        hasNextPage
        endCursor
        hasPreviousPage
        startCursor
      }
    }
  }
}

query ListMultiCurrencyLedgerAccountBalances(
  $ledgerIk: SafeString!
  $after: String
  $first: Int
  $before: String
  $balanceAt: LastMoment
  $ownBalancesConsistencyMode: ReadBalanceConsistencyMode
  $childBalancesConsistencyMode: ReadBalanceConsistencyMode
  $balancesConsistencyMode: ReadBalanceConsistencyMode
) {
  ledger(ledger: { ik: $ledgerIk }) {
    id
    ik
    name
    created
    ledgerAccounts(after: $after, first: $first, before: $before) {
      nodes {
        id
        path
        name
        type
        created
        ownBalances(
          at: $balanceAt
          consistencyMode: $ownBalancesConsistencyMode
        ) {
          nodes {
            currency {
              code
              customCurrencyId
            }
            amount
          }
        }
        childBalances(
          at: $balanceAt
          consistencyMode: $childBalancesConsistencyMode
        ) {
          nodes {
            currency {
              code
              customCurrencyId
            }
            amount
          }
        }
        balances(
          at: $balanceAt
          consistencyMode: $balancesConsistencyMode
        ) {
          nodes {
            currency {
              code
              customCurrencyId
            }
            amount
          }
        }
      }
      pageInfo {
        hasNextPage
        endCursor
        hasPreviousPage
        startCursor
      }
    }
  }
}

query GetLedgerAccountLines(
  $path: String!
  $ledgerIk: SafeString!
  $after: String
  $first: Int
  $before: String
  $filter: LedgerLinesFilterSet
) {
  ledgerAccount(ledgerAccount: { ledger: { ik: $ledgerIk }, path: $path }) {
    id
    path
    lines(after: $after, first: $first, before: $before, filter: $filter) {
      nodes {
        id
        posted
        created
        amount
        description
      }
      pageInfo {
        hasNextPage
        endCursor
        hasPreviousPage
        startCursor
      }
    }
  }
}

query GetLedgerAccountBalance(
  $path: String!
  $ledgerIk: SafeString!
  $balanceCurrency: CurrencyMatchInput
  $balanceAt: LastMoment
  $balanceConsistencyMode: ReadBalanceConsistencyMode
) {
  ledgerAccount(ledgerAccount: { ledger: { ik: $ledgerIk }, path: $path }) {
    id
    path
    balance(
      currency: $balanceCurrency
      at: $balanceAt
      consistencyMode: $balanceConsistencyMode
    )
  }
}

query GetSchema($key: SafeString!, $version: Int) {
  schema(schema: { key: $key, version: $version }) {
    key
    name
    version {
      created
      version
      json
    }
  }
}

query ListLedgerEntries(
  $ledgerIk: SafeString!
  $after: String
  $first: Int
  $before: String
  $filter: LedgerEntriesFilterSet
) {
  ledger(ledger: { ik: $ledgerIk }) {
    ledgerEntries(
      after: $after
      first: $first
      before: $before
      filter: $filter
    ) {
      nodes {
        ik
        type
        typeVersion
        posted
        lines {
          nodes {
            amount
            account {
              path
            }
          }
        }
      }
      pageInfo {
        hasNextPage
        endCursor
        hasPreviousPage
        startCursor
      }
    }
  }
}

query GetWorkspace {
  workspace {
    id
    name
  }
}

query ListLedgerEntryGroupBalances(
  $ledgerIk: SafeString!
  $groupKey: SafeString!
  $groupValue: SafeString!
  $consistencyMode: ReadBalanceConsistencyMode = use_account
  $after: String
  $before: String
  $first: Int
  $last: Int
  $filter: LedgerEntryGroupBalanceFilterSet
) {
  ledgerEntryGroup(ledgerEntryGroup: {
    ledger: { ik: $ledgerIk },
    key: $groupKey,
    value: $groupValue,
  }) {
    key
    value
    created
    balances(
      after: $after,
      before: $before,
      first: $first,
      last: $last,
      filter: $filter,
    ){
      nodes {
        account {
          path
        }
        currency {
          code
          customCurrencyId
        }
        ownBalance(consistencyMode: $consistencyMode)
      }
      pageInfo {
        hasNextPage
        endCursor
        hasPreviousPage
        startCursor
      }
    }
  }
}

query GetEntryDataMigrations(
  $ledgerIk: SafeString!
  $filter: LedgerEntryDataMigrationsFilterSet
  $after: String
  $before: String
  $first: Int
  $last: Int
) {
  ledger(ledger: { ik: $ledgerIk }) {
    ledgerEntryDataMigrations(
      first: $first
      after: $after
      before: $before
      last: $last
      filter: $filter
    ) {
      nodes {
        entryType
        typeVersion
        status
        currentMigration {
          schemaVersion
          status
        }
        ledgerEntries {
          nodes {
            id
            type
            posted
            parameters
          }
          pageInfo {
            hasNextPage
            endCursor
            hasPreviousPage
            startCursor
          }
        }
        history {
          nodes {
            schemaVersion
            status
          }
          pageInfo {
            hasNextPage
            endCursor
            hasPreviousPage
            startCursor
          }
        }
      }
      pageInfo {
        hasNextPage
        endCursor
        hasPreviousPage
        startCursor
      }
    }
  }
}

query GetEntriesToMigrateForLedgerEntryDataMigration(
  $ledgerIk: SafeString!
  $entryType: String!
  $typeVersion: String!
  $after: String
  $before: String
  $first: Int
  $last: Int
) {
  ledger(ledger: { ik: $ledgerIk }) {
    ledgerEntryDataMigrations(
      filter: {
        entryType: {
          equalTo: $entryType
        }
        typeVersion: {
          equalTo: $typeVersion
        }
      }
    ) {
      nodes {
        ledgerEntries(
          first: $first
          after: $after
          last: $last
          before: $before
        ) {
          nodes {
            id
            ik
            type
            typeVersion
            description
            posted
            created
            parameters
            lines {
              nodes {
                id
                amount
                account {
                    path
                }
              }
            }
          }
          pageInfo {
            hasNextPage
            endCursor
            hasPreviousPage
            startCursor
          }
        }
      }
    }
  }
}

query GetAccountDataMigrations(
  $ledgerIk: SafeString!
  $filter: LedgerAccountDataMigrationsFilterSet
  $after: String
  $before: String
  $first: Int
  $last: Int
) {
  ledger(ledger: { ik: $ledgerIk }) {
    ledgerAccountDataMigrations(
      first: $first
      after: $after
      before: $before
      last: $last
      filter: $filter
    ) {
      nodes {
        accountPath
        status
        currentMigration {
          schemaVersion
          status
        }
        ledgerEntries {
          nodes {
            id
            type
            posted
            parameters
          }
          pageInfo {
            hasNextPage
            endCursor
            hasPreviousPage
            startCursor
          }
        }
        history {
          nodes {
            schemaVersion
            status
          }
          pageInfo {
            hasNextPage
            endCursor
            hasPreviousPage
            startCursor
          }
        }
      }
      pageInfo {
        hasNextPage
        endCursor
        hasPreviousPage
        startCursor
      }
    }
  }
}

query GetEntriesToMigrateForLedgerAccountDataMigration(
  $ledgerIk: SafeString!
  $accountPath: String!
  $after: String
  $before: String
  $first: Int
  $last: Int
) {
  ledger(ledger: { ik: $ledgerIk }) {
    ledgerAccountDataMigrations(
      filter: {
        accountPath: {
          equalTo: $accountPath
        }
      }
    ) {
      nodes {
        ledgerEntries(
         first: $first
         after: $after
         last: $last
         before: $before
        ) {
          nodes {
            id
            ik
            type
            typeVersion
            description
            posted
            created
            parameters
            lines {
              nodes {
                id
                amount
                account {
                  path
                }
              }
            }
          }
          pageInfo {
            hasNextPage
            endCursor
            hasPreviousPage
            startCursor
          }
        }
      }
    }
  }
}

mutation CreateCustomCurrency(
  $id: SafeString!,
  $name: String!,
  $precision: Int!,
  $customCode: String!,
) {
  createCustomCurrency(
    customCurrency: {
      customCurrencyId: $id,
      name: $name,
      precision: $precision,
      customCode: $customCode,
    }
  ) {
    __typename
    ... on CreateCustomCurrencyResult {
      customCurrency {
        code
        customCurrencyId
        precision
        name
        customCode
      }
    }
    ... on BadRequestError {
      code
      message
      retryable
    }
    ... on InternalError {
      code
      message
      retryable
    }
  }
}
`;

export {
  standardQueries
};
