import { idlFactory as ManagerFactory } from '../canisters/manager/manager.utils.did';
import { idlFactory as DeckBucketFactory } from '../canisters/deck/deck.utils.did';
import { createActor } from './actor.utils';
import { fromNullable } from './did.utils';
export const createManagerActor = ({ identity, host }) => {
  return createActor({ canisterId: process.env.MANAGER_CANISTER_ID, idlFactory: ManagerFactory, identity, host });
};
export const createDeckBucketActor = ({ identity, bucket, host }) => {
  return createActor({ canisterId: bucket, idlFactory: DeckBucketFactory, identity, host });
};
export const initDeckBucket = async ({ managerActor, deckId }) => {
  const existingBucket = fromNullable(await managerActor.get(deckId));
  if (!existingBucket) {
    return await managerActor.init(deckId);
  }
  return existingBucket;
};
