// src/workflows/control-plane/user-onboarding/events.ts
var USER_ONBOARDING_EVENT_SOURCE = "openhi.control.user-onboarding";
var PROVISION_DEFAULT_WORKSPACE_DETAIL_TYPE = "ProvisionDefaultWorkspaceRequested";
var buildProvisionDefaultWorkspaceRequestedDetail = (event) => {
  const attrs = event.request?.userAttributes ?? {};
  const cognitoSub = attrs.sub?.trim();
  if (!cognitoSub) {
    return void 0;
  }
  const email = attrs.email?.trim();
  const displayName = email || event.userName || cognitoSub;
  return {
    cognitoSub,
    ...email ? { email } : {},
    displayName,
    trigger: {
      source: "cognito.post-confirmation",
      triggerSource: event.triggerSource,
      userPoolId: event.userPoolId,
      userName: event.userName,
      clientId: event.callerContext?.clientId
    }
  };
};

export {
  USER_ONBOARDING_EVENT_SOURCE,
  PROVISION_DEFAULT_WORKSPACE_DETAIL_TYPE,
  buildProvisionDefaultWorkspaceRequestedDetail
};
//# sourceMappingURL=chunk-2PM2NGXI.mjs.map