import "zod";
import { j as campfire_config_json, a as metadata, k as demodesk_config_json, l as dialpad_config_json, n as discord_config_json, o as eightxeight_config_json, p as element_call_config_json, h as appConfig, q as fathom_config_json, r as ga4_config_json, m as metadata$1, s as gtm_config_json, t as horizon_workrooms_config_json, u as metadata$2, v as insihts_config_json, w as jelly_config_json, x as metadata$3, y as matomo_config_json, z as metapixel_config_json, A as mirotalk_config_json, B as config, C as config$1, D as ping_config_json, e as appConfig$1, E as posthog_config_json, F as riverside_config_json, G as roam_config_json, H as salesroom_config_json, I as config$2, J as signal_config_json, K as sirius_video_config_json, L as skype_config_json, M as config$3, N as metadata$4, i as appConfig$2, O as booking_pages_tag_config_json, P as event_type_location_video_static_config_json, Q as twipla_config_json, R as umami_config_json, S as config$4, T as whatsapp_config_json, U as whereby_config_json, V as metadata$5, W as getNormalizedAppMetadata } from "./CalEventParser-NbcDfXYU.js";
import { l as logger } from "./orgDomains-eTg-cjth.js";
const appStoreMetadata$1 = {
  campfire: campfire_config_json,
  dailyvideo: metadata,
  demodesk: demodesk_config_json,
  dialpad: dialpad_config_json,
  discord: discord_config_json,
  eightxeight: eightxeight_config_json,
  "element-call": element_call_config_json,
  facetime: appConfig,
  fathom: fathom_config_json,
  ga4: ga4_config_json,
  googlevideo: metadata$1,
  gtm: gtm_config_json,
  "horizon-workrooms": horizon_workrooms_config_json,
  huddle01video: metadata$2,
  insihts: insihts_config_json,
  jelly: jelly_config_json,
  jitsivideo: metadata$3,
  matomo: matomo_config_json,
  metapixel: metapixel_config_json,
  mirotalk: mirotalk_config_json,
  nextcloudtalk: config,
  office365video: config$1,
  ping: ping_config_json,
  plausible: appConfig$1,
  posthog: posthog_config_json,
  riverside: riverside_config_json,
  roam: roam_config_json,
  salesroom: salesroom_config_json,
  shimmervideo: config$2,
  signal: signal_config_json,
  sirius_video: sirius_video_config_json,
  skype: skype_config_json,
  sylapsvideo: config$3,
  tandemvideo: metadata$4,
  telegram: appConfig$2,
  "booking-pages-tag": booking_pages_tag_config_json,
  "event-type-location-video-static": event_type_location_video_static_config_json,
  twipla: twipla_config_json,
  umami: umami_config_json,
  webex: config$4,
  whatsapp: whatsapp_config_json,
  whereby: whereby_config_json,
  zoomvideo: metadata$5
};
const appStoreMetadata = {};
for (const [key, value] of Object.entries(appStoreMetadata$1)) {
  appStoreMetadata[key] = getNormalizedAppMetadata(value);
}
const DailyLocationType = "integrations:daily";
const MeetLocationType = "integrations:google:meet";
const OrganizerDefaultConferencingAppType = "conferencing";
var DefaultEventLocationTypeEnum = /* @__PURE__ */ ((DefaultEventLocationTypeEnum2) => {
  DefaultEventLocationTypeEnum2["AttendeeInPerson"] = "attendeeInPerson";
  DefaultEventLocationTypeEnum2["InPerson"] = "inPerson";
  DefaultEventLocationTypeEnum2["Phone"] = "phone";
  DefaultEventLocationTypeEnum2["UserPhone"] = "userPhone";
  DefaultEventLocationTypeEnum2["Link"] = "link";
  DefaultEventLocationTypeEnum2["Conferencing"] = "conferencing";
  DefaultEventLocationTypeEnum2["SomewhereElse"] = "somewhereElse";
  return DefaultEventLocationTypeEnum2;
})(DefaultEventLocationTypeEnum || {});
const defaultLocations = [
  {
    default: true,
    type: "attendeeInPerson",
    label: "in_person_attendee_address",
    variable: "address",
    organizerInputType: null,
    messageForOrganizer: "Cal will ask your invitee to enter an address before scheduling.",
    attendeeInputType: "attendeeAddress",
    attendeeInputPlaceholder: "enter_address",
    defaultValueVariable: "attendeeAddress",
    iconUrl: "/map-pin-dark.svg",
    category: "in person",
    linkType: "static"
  },
  {
    default: true,
    type: "somewhereElse",
    label: "custom_attendee_location",
    variable: "address",
    organizerInputType: null,
    messageForOrganizer: "Cal will ask your invitee to enter any location before scheduling.",
    attendeeInputType: "somewhereElse",
    attendeeInputPlaceholder: "any_location",
    defaultValueVariable: "somewhereElse",
    iconUrl: "/message-pin.svg",
    category: "other",
    linkType: "static"
  },
  {
    default: true,
    type: "inPerson",
    label: "in_person",
    organizerInputType: "text",
    messageForOrganizer: "Provide an Address or Place",
    // HACK:
    variable: "locationAddress",
    defaultValueVariable: "address",
    iconUrl: "/map-pin-dark.svg",
    category: "in person",
    linkType: "static"
  },
  {
    default: true,
    type: "conferencing",
    iconUrl: "/link.svg",
    organizerInputType: null,
    label: "organizer_default_conferencing_app",
    variable: "hostDefault",
    defaultValueVariable: "hostDefault",
    category: "conferencing",
    messageForOrganizer: "",
    linkType: "static"
  },
  {
    default: true,
    type: "link",
    label: "link_meeting",
    organizerInputType: "text",
    variable: "locationLink",
    messageForOrganizer: "Provide a Meeting Link",
    defaultValueVariable: "link",
    iconUrl: "/link.svg",
    category: "other",
    linkType: "static"
  },
  {
    default: true,
    type: "phone",
    label: "attendee_phone_number",
    variable: "phone",
    organizerInputType: null,
    attendeeInputType: "phone",
    attendeeInputPlaceholder: `enter_phone_number`,
    defaultValueVariable: "phone",
    messageForOrganizer: "Cal will ask your invitee to enter a phone number before scheduling.",
    // This isn't inputType phone because organizer doesn't need to provide it.
    // inputType: "phone"
    iconUrl: "/phone.svg",
    category: "phone",
    linkType: "static"
  },
  {
    default: true,
    type: "userPhone",
    label: "organizer_phone_number",
    messageForOrganizer: "Provide your phone number",
    organizerInputType: "phone",
    variable: "locationPhoneNumber",
    defaultValueVariable: "hostPhoneNumber",
    iconUrl: "/phone.svg",
    category: "phone",
    linkType: "static"
  }
];
const AppStoreLocationType = {};
const locationsFromApps = [];
for (const [appName, meta] of Object.entries(appStoreMetadata)) {
  const location = meta.appData?.location;
  if (location) {
    for (const [key, value] of Object.entries(location)) {
      if (typeof value === "string") {
        location[key] = value.replace(/{SLUG}/g, meta.slug).replace(/{TITLE}/g, meta.name);
      }
    }
    const newLocation = {
      ...location,
      messageForOrganizer: location.messageForOrganizer || `Set ${location.label} link`,
      iconUrl: meta.logo,
      // For All event location apps, locationLink is where we store the input
      // TODO: locationLink and link seems redundant. We can modify the code to keep just one of them.
      variable: location.variable || "locationLink",
      defaultValueVariable: location.defaultValueVariable || "link"
    };
    if (newLocation.linkType === "static") {
      newLocation.organizerInputType = location.organizerInputType || "text";
      if (newLocation.organizerInputPlaceholder?.match(/https?:\/\//)) {
        newLocation.organizerInputPlaceholder = ` ${newLocation.organizerInputPlaceholder}`;
      }
    } else {
      newLocation.organizerInputType = null;
    }
    AppStoreLocationType[appName] = newLocation.type;
    locationsFromApps.push({
      ...newLocation
    });
  }
}
const locations = [...defaultLocations, ...locationsFromApps];
const getLocationFromApp = (locationType) => locationsFromApps.find((l) => l.type === locationType);
const getEventLocationType = (locationType) => locations.find((l) => l.type === locationType);
const getStaticLinkLocationByValue = (value) => {
  if (!value) {
    return null;
  }
  return locations.find((l) => {
    if (l.default || l.linkType == "dynamic" || !l.urlRegExp) {
      return;
    }
    return new RegExp(l.urlRegExp).test(value);
  });
};
const guessEventLocationType = (locationTypeOrValue) => getEventLocationType(locationTypeOrValue) || getStaticLinkLocationByValue(locationTypeOrValue);
({ ...DefaultEventLocationTypeEnum, ...AppStoreLocationType });
const privacyFilteredLocations = (locations2) => {
  const locationsAfterPrivacyFilter = locations2.map((location) => {
    const eventLocationType = getEventLocationType(location.type);
    if (!eventLocationType) {
      logger.debug(`Couldn't find location type. App might be uninstalled: ${location.type} `);
    }
    if (location.displayLocationPublicly || !eventLocationType) {
      return location;
    } else {
      const { address: _1, link: _2, hostPhoneNumber: _3, ...privacyFilteredLocation } = location;
      logger.debug("Applied Privacy Filter", location, privacyFilteredLocation);
      return privacyFilteredLocation;
    }
  });
  return locationsAfterPrivacyFilter;
};
const getHumanReadableLocationValue = (linkValue, translationFunction) => {
  if (!linkValue) {
    return translationFunction("no_location");
  }
  const eventLocationType = getEventLocationType(linkValue);
  const isDefault = eventLocationType?.default;
  if (eventLocationType) {
    return isDefault ? translationFunction(eventLocationType.label) : `${eventLocationType.label}`;
  }
  return linkValue || "";
};
const getLocationValueForDB = (bookingLocationTypeOrValue, eventLocations) => {
  let bookingLocation = bookingLocationTypeOrValue;
  let conferenceCredentialId = void 0;
  eventLocations.forEach((location) => {
    if (location.type === bookingLocationTypeOrValue) {
      const eventLocationType = getEventLocationType(bookingLocationTypeOrValue);
      conferenceCredentialId = location.credentialId;
      if (!eventLocationType) {
        return;
      }
      if (!eventLocationType.default && eventLocationType.linkType === "dynamic") {
        return;
      }
      bookingLocation = location[eventLocationType.defaultValueVariable] || bookingLocation;
    }
  });
  if (bookingLocation.trim().length === 0) {
    bookingLocation = DailyLocationType;
  }
  return { bookingLocation, conferenceCredentialId };
};
export {
  AppStoreLocationType as A,
  DailyLocationType as D,
  MeetLocationType as M,
  OrganizerDefaultConferencingAppType as O,
  getLocationFromApp as a,
  getLocationValueForDB as b,
  guessEventLocationType as c,
  defaultLocations as d,
  getHumanReadableLocationValue as g,
  privacyFilteredLocations as p
};
