import {
  AuthenticatedCommand
} from "./chunk-G2JISDKX.js";
import {
  require_lib
} from "./chunk-XECLOG6B.js";
import {
  require_source
} from "./chunk-M5OAS5QZ.js";
import {
  __toESM,
  init_cjs_shims
} from "./chunk-7GH3YGSC.js";

// src/commands/update-ledger-account.ts
init_cjs_shims();
var import_core = __toESM(require_lib(), 1);
var import_chalk = __toESM(require_source(), 1);
var UpdateLedgerAccount = class extends AuthenticatedCommand {
  static {
    this.summary = "Update a Ledger Account within your Fragment Ledger.";
  }
  static {
    this.description = `This mirrors the ${import_chalk.default.magentaBright(
      "updateLedgerAccount"
    )} mutation in the GraphQL API.`;
  }
  static {
    this.examples = ["<%= config.bin %> <%= command.id %>"];
  }
  static {
    this.flags = {
      "ledgerAccount.path": import_core.Flags.string({
        char: "p",
        exclusive: ["ledgerAccount.id"],
        // Only one of ledgerAccount.id or ledgerAccount.path should be provided.
        exactlyOne: ["ledgerAccount.id", "ledgerAccount.path"],
        description: "The unique path of the Ledger Account.",
        // If ledgerAccount.path is provided, ledger.id or ledger.ik should be provided.
        relationships: [{ type: "some", flags: ["ledger.id", "ledger.ik"] }]
      }),
      "ledger.ik": import_core.Flags.string({
        char: "l",
        description: "The Idempotency Key of the Ledger the Ledger Account is in."
      }),
      "ledger.id": import_core.Flags.string({
        description: "The Fragment ID of the Ledger the Ledger Account is in."
      }),
      "ledgerAccount.id": import_core.Flags.string({
        description: "The Fragment ID of the Ledger Account."
      }),
      "update.name": import_core.Flags.string({
        // Set to required because this is the only possible value for
        // UpdateLedgerAccount. Remove once there's more than one.
        required: true
      })
    };
  }
  async run() {
    const res = await this.sdk.UpdateLedgerAccount({
      ledgerAccount: {
        id: this.flags["ledgerAccount.id"],
        ledger: {
          ik: this.flags["ledger.ik"],
          id: this.flags["ledger.id"]
        },
        path: this.flags["ledgerAccount.path"]
      },
      update: {
        name: this.flags["update.name"]
      }
    });
    if (res.updateLedgerAccount.__typename !== "UpdateLedgerAccountResult") {
      this.exit(1);
    }
  }
};

export {
  UpdateLedgerAccount
};
