"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/functions/context/dateTime.ts
var dateTime_exports = {};
__export(dateTime_exports, {
  dateTime: () => dateTime
});
module.exports = __toCommonJS(dateTime_exports);
async function dateTime(context, event, task) {
  console.log(`dateTime called with context ${context} event ${event} task ${task}`);
  const lastStackKey = context?.stack?.find((stackItem) => stackItem.indexOf("userProfile") >= 0);
  const userDetails = {
    name: void 0,
    id: void 0,
    email: void 0,
    timezone: "America/Los_Angeles"
  };
  if (lastStackKey) {
    const retrievedUser = context[lastStackKey];
    userDetails.name = retrievedUser.name;
    userDetails.id = retrievedUser.id;
    userDetails.email = retrievedUser.email;
    userDetails.timezone = retrievedUser.timezone;
  }
  const options = {
    timeZone: userDetails.timezone ?? "America/Los_Angeles",
    timeZoneName: "short"
    // This will produce "PST" or "PDT"
  };
  const formatter = new Intl.DateTimeFormat("en-US", options);
  const formatted = formatter.format(/* @__PURE__ */ new Date());
  console.log(`formatted int date: ${formatted}`);
  const isPacificDaylightTime = formatted.includes("PDT");
  const currentLocalDateTime = (/* @__PURE__ */ new Date()).toLocaleString("en-US", { timeZone: userDetails.timezone });
  const currentGMTDateTme = (/* @__PURE__ */ new Date()).toISOString();
  return {
    isPacificDaylightTime,
    currentLocalDateTime,
    currentGMTDateTme
  };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  dateTime
});
