#!/usr/bin/env node
import {
  ensureProjectSdk,
  loadRemoteProjectIdentity
} from "./chunk-KDBSVLCF.mjs";
import {
  updateProjectState
} from "./chunk-776W3UGV.mjs";

// src/services/project/remote-project.ts
async function resolveRemoteProject(options) {
  const identity = await loadRemoteProjectIdentity();
  const project = await ensureProjectSdk({
    projectId: options.projectConfig.projectId,
    slug: options.projectConfig.slug,
    updateAlias: options.updateAlias
  });
  const nextProjectConfig = {
    ...options.projectConfig,
    slug: project.slug,
    deploymentId: identity.deploymentId,
    ownerScopeId: identity.ownerScopeId,
    bindingKey: identity.bindingKey,
    remoteHeadDigest: project.head?.revisionDigest,
    apiBaseUrl: options.config.apiBaseUrl,
    webBaseUrl: options.config.webBaseUrl
  };
  await updateProjectState(options.projectRoot, nextProjectConfig);
  return {
    identity,
    project,
    projectConfig: nextProjectConfig
  };
}

export {
  resolveRemoteProject
};
//# sourceMappingURL=chunk-QZH6IEZS.mjs.map