import * as Schema from 'effect/Schema';
import { InboxSenderAuthPolicy } from '../inboxes/types.js';
import { AcceptInvitationEvent, CreateInvitationEvent, CreateSpaceEvent, CreateSpaceInboxEvent, SpaceEvent } from '../space-events/index.js';
import { SignatureWithRecovery } from '../types.js';
export const SignedUpdate = /*#__PURE__*/Schema.Struct({
  update: Schema.Uint8Array,
  accountAddress: Schema.String,
  signature: SignatureWithRecovery,
  updateId: Schema.String
});
export const Updates = /*#__PURE__*/Schema.Struct({
  updates: /*#__PURE__*/Schema.Array(SignedUpdate),
  firstUpdateClock: Schema.Number,
  lastUpdateClock: Schema.Number
});
export const KeyBox = /*#__PURE__*/Schema.Struct({
  accountAddress: Schema.String,
  ciphertext: Schema.String,
  nonce: Schema.String,
  authorPublicKey: Schema.String
});
export const KeyBoxWithKeyId = /*#__PURE__*/Schema.Struct({
  ...KeyBox.fields,
  id: Schema.String
});
export const IdentityKeyBox = /*#__PURE__*/Schema.Struct({
  signer: Schema.String,
  accountAddress: Schema.String,
  ciphertext: Schema.String,
  nonce: Schema.String
});
export const RequestCreateSpaceEvent = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('create-space-event'),
  spaceId: Schema.String,
  event: CreateSpaceEvent,
  keyBox: KeyBoxWithKeyId,
  name: Schema.String
});
export const RequestConnectCreateSpaceEvent = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('connect-create-space-event'),
  accountAddress: Schema.String,
  spaceId: Schema.String,
  event: CreateSpaceEvent,
  keyBox: KeyBoxWithKeyId,
  infoContent: Schema.String,
  infoSignature: SignatureWithRecovery,
  name: Schema.String
});
export const RequestCreateInvitationEvent = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('create-invitation-event'),
  spaceId: Schema.String,
  event: CreateInvitationEvent,
  keyBoxes: /*#__PURE__*/Schema.Array(KeyBoxWithKeyId)
});
export const RequestConnectAddAppIdentityToSpaces = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('connect-add-app-identity-to-spaces'),
  appIdentityAddress: Schema.String,
  accountAddress: Schema.String,
  spacesInput: /*#__PURE__*/Schema.Array(/*#__PURE__*/Schema.Struct({
    id: Schema.String,
    keyBoxes: /*#__PURE__*/Schema.Array(KeyBoxWithKeyId)
  }))
});
export const RequestAcceptInvitationEvent = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('accept-invitation-event'),
  spaceId: Schema.String,
  event: AcceptInvitationEvent
});
export const RequestSubscribeToSpace = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('subscribe-space'),
  id: Schema.String,
  lastKnownUpdateClock: /*#__PURE__*/Schema.optional(Schema.Number)
});
export const RequestListSpaces = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('list-spaces')
});
export const RequestListInvitations = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('list-invitations')
});
export const RequestCreateUpdate = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('create-update'),
  accountAddress: Schema.String,
  update: Schema.Uint8Array,
  spaceId: Schema.String,
  updateId: Schema.String,
  // used to identify the confirmation message
  signature: SignatureWithRecovery
});
export const RequestCreateAccountInbox = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('create-account-inbox'),
  accountAddress: Schema.String,
  inboxId: Schema.String,
  isPublic: Schema.Boolean,
  authPolicy: InboxSenderAuthPolicy,
  encryptionPublicKey: Schema.String,
  signature: SignatureWithRecovery
});
export const RequestCreateSpaceInboxEvent = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('create-space-inbox-event'),
  spaceId: Schema.String,
  event: CreateSpaceInboxEvent
});
export const RequestGetLatestSpaceInboxMessages = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('get-latest-space-inbox-messages'),
  spaceId: Schema.String,
  inboxId: Schema.String,
  since: Schema.Date
});
export const RequestGetLatestAccountInboxMessages = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('get-latest-account-inbox-messages'),
  accountAddress: Schema.String,
  inboxId: Schema.String,
  since: Schema.Date
});
export const RequestGetAccountInboxes = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('get-account-inboxes')
});
export const RequestMessage = /*#__PURE__*/Schema.Union(RequestCreateSpaceEvent, RequestCreateInvitationEvent, RequestAcceptInvitationEvent, RequestSubscribeToSpace, RequestListSpaces, RequestListInvitations, RequestCreateUpdate, RequestCreateAccountInbox, RequestCreateSpaceInboxEvent, RequestGetLatestSpaceInboxMessages, RequestGetLatestAccountInboxMessages, RequestGetAccountInboxes);
export const RequestLoginNonce = /*#__PURE__*/Schema.Struct({
  accountAddress: Schema.String
});
export const RequestLogin = /*#__PURE__*/Schema.Struct({
  accountAddress: Schema.String,
  message: Schema.String,
  signature: Schema.String
});
export const RequestLoginWithSigningKey = /*#__PURE__*/Schema.Struct({
  accountAddress: Schema.String,
  message: Schema.String,
  publicKey: Schema.String,
  signature: Schema.String
});
export const RequestCreateIdentity = /*#__PURE__*/Schema.Struct({
  keyBox: IdentityKeyBox,
  accountProof: Schema.String,
  keyProof: Schema.String,
  message: Schema.String,
  signaturePublicKey: Schema.String,
  encryptionPublicKey: Schema.String,
  signature: Schema.String
});
export const RequestConnectCreateIdentity = /*#__PURE__*/Schema.Struct({
  keyBox: IdentityKeyBox,
  accountProof: Schema.String,
  keyProof: Schema.String,
  signaturePublicKey: Schema.String,
  encryptionPublicKey: Schema.String
});
export const RequestConnectCreateAppIdentity = /*#__PURE__*/Schema.Struct({
  appId: Schema.String,
  address: Schema.String,
  accountAddress: Schema.String,
  ciphertext: Schema.String,
  signaturePublicKey: Schema.String,
  encryptionPublicKey: Schema.String,
  accountProof: Schema.String,
  keyProof: Schema.String
});
export const ResponseConnectCreateIdentity = /*#__PURE__*/Schema.Struct({
  success: Schema.Boolean
});
export const RequestCreateSpaceInboxMessage = /*#__PURE__*/Schema.Struct({
  ciphertext: Schema.String,
  signature: /*#__PURE__*/Schema.optional(SignatureWithRecovery),
  authorAccountAddress: /*#__PURE__*/Schema.optional(Schema.String)
});
export const RequestCreateAccountInboxMessage = /*#__PURE__*/Schema.Struct({
  ciphertext: Schema.String,
  signature: /*#__PURE__*/Schema.optional(SignatureWithRecovery),
  authorAccountAddress: /*#__PURE__*/Schema.optional(Schema.String)
});
export const ResponseListSpaces = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('list-spaces'),
  spaces: /*#__PURE__*/Schema.Array(/*#__PURE__*/Schema.Struct({
    id: Schema.String,
    name: Schema.String
  }))
});
export const Invitation = /*#__PURE__*/Schema.Struct({
  id: Schema.String,
  previousEventHash: Schema.String,
  spaceId: Schema.String
});
export const ResponseListInvitations = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('list-invitations'),
  invitations: /*#__PURE__*/Schema.Array(Invitation)
});
export const ResponseSpaceEvent = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('space-event'),
  spaceId: Schema.String,
  event: SpaceEvent
});
export const InboxMessage = /*#__PURE__*/Schema.Struct({
  id: Schema.String,
  ciphertext: Schema.String,
  signature: /*#__PURE__*/Schema.optional(SignatureWithRecovery),
  authorAccountAddress: /*#__PURE__*/Schema.optional(Schema.String),
  createdAt: Schema.Date
});
export const SpaceInbox = /*#__PURE__*/Schema.Struct({
  inboxId: Schema.String,
  isPublic: Schema.Boolean,
  authPolicy: InboxSenderAuthPolicy,
  encryptionPublicKey: Schema.String,
  secretKey: Schema.String
});
export const AccountInbox = /*#__PURE__*/Schema.Struct({
  accountAddress: Schema.String,
  inboxId: Schema.String,
  isPublic: Schema.Boolean,
  authPolicy: InboxSenderAuthPolicy,
  encryptionPublicKey: Schema.String,
  signature: SignatureWithRecovery
});
export const ResponseAccountInbox = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('account-inbox'),
  inbox: AccountInbox
});
export const ResponseSpace = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('space'),
  id: Schema.String,
  name: Schema.String,
  events: /*#__PURE__*/Schema.Array(SpaceEvent),
  keyBoxes: /*#__PURE__*/Schema.Array(KeyBoxWithKeyId),
  updates: /*#__PURE__*/Schema.optional(Updates),
  inboxes: /*#__PURE__*/Schema.Array(SpaceInbox)
});
export const ResponseUpdateConfirmed = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('update-confirmed'),
  updateId: Schema.String,
  clock: Schema.Number,
  spaceId: Schema.String
});
export const ResponseUpdatesNotification = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('updates-notification'),
  updates: Updates,
  spaceId: Schema.String
});
export const ResponseSpaceInboxMessage = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('space-inbox-message'),
  spaceId: Schema.String,
  inboxId: Schema.String,
  message: InboxMessage
});
export const ResponseSpaceInboxMessages = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('space-inbox-messages'),
  spaceId: Schema.String,
  inboxId: Schema.String,
  messages: /*#__PURE__*/Schema.Array(InboxMessage)
});
export const ResponseAccountInboxMessage = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('account-inbox-message'),
  accountAddress: Schema.String,
  inboxId: Schema.String,
  message: InboxMessage
});
export const ResponseAccountInboxMessages = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('account-inbox-messages'),
  accountAddress: Schema.String,
  inboxId: Schema.String,
  messages: /*#__PURE__*/Schema.Array(InboxMessage)
});
export const ResponseAccountInboxes = /*#__PURE__*/Schema.Struct({
  type: /*#__PURE__*/Schema.Literal('account-inboxes'),
  inboxes: /*#__PURE__*/Schema.Array(AccountInbox)
});
export const ResponseMessage = /*#__PURE__*/Schema.Union(ResponseListSpaces, ResponseListInvitations, ResponseSpace, ResponseSpaceEvent, ResponseUpdateConfirmed, ResponseUpdatesNotification, ResponseAccountInbox, ResponseSpaceInboxMessage, ResponseSpaceInboxMessages, ResponseAccountInboxMessage, ResponseAccountInboxMessages, ResponseAccountInboxes);
export const ResponseIdentityEncrypted = /*#__PURE__*/Schema.Struct({
  keyBox: IdentityKeyBox
});
export const ResponseIdentity = /*#__PURE__*/Schema.Struct({
  accountAddress: Schema.String,
  signaturePublicKey: Schema.String,
  encryptionPublicKey: Schema.String,
  accountProof: Schema.String,
  keyProof: Schema.String,
  appId: /*#__PURE__*/Schema.optional(Schema.String)
});
export const SpaceInboxPublic = /*#__PURE__*/Schema.Struct({
  inboxId: Schema.String,
  isPublic: Schema.Boolean,
  authPolicy: InboxSenderAuthPolicy,
  encryptionPublicKey: Schema.String,
  creationEvent: CreateSpaceInboxEvent
});
export const ResponseSpaceInboxPublic = /*#__PURE__*/Schema.Struct({
  inbox: SpaceInboxPublic
});
export const ResponseListSpaceInboxesPublic = /*#__PURE__*/Schema.Struct({
  inboxes: /*#__PURE__*/Schema.Array(SpaceInboxPublic)
});
export const AccountInboxPublic = /*#__PURE__*/Schema.Struct({
  accountAddress: Schema.String,
  inboxId: Schema.String,
  isPublic: Schema.Boolean,
  authPolicy: InboxSenderAuthPolicy,
  encryptionPublicKey: Schema.String,
  signature: SignatureWithRecovery
});
export const ResponseAccountInboxPublic = /*#__PURE__*/Schema.Struct({
  inbox: AccountInboxPublic
});
export const ResponseListAccountInboxesPublic = /*#__PURE__*/Schema.Struct({
  inboxes: /*#__PURE__*/Schema.Array(AccountInboxPublic)
});
export const ResponseIdentityNotFoundError = /*#__PURE__*/Schema.Struct({
  accountAddress: Schema.String
});
export const ResponseIdentityExistsError = /*#__PURE__*/Schema.Struct({
  accountAddress: Schema.String
});
//# sourceMappingURL=types.js.map