import { h } from './index-38ad4957.js';
import { i as intl } from './global-96c14d63.js';
import { d as dist } from './index.module-b23fdad8.js';
import { c as createStyleSheet } from './JSS-67b5cff8.js';

const style = {
  Container: {
    display: "flex",
    flexDirection: "column",
    gap: "35px",
  },
  HeaderContainer: {
    display: "flex",
    flexDirection: "column",
    gap: "10px",
  },
};
const sheet = createStyleSheet(style);
const styleString = sheet.toString();
const LoadingView = () => {
  return (h("div", { class: sheet.classes.Container },
    h("style", { type: "text/css" }, styleString),
    h("sqm-skeleton", { width: "45%", height: "40px !important" }),
    h("div", { class: sheet.classes.HeaderContainer },
      h("sqm-skeleton", { width: "15%" }),
      h("sqm-skeleton", { width: "25%", height: "30px !important" })),
    h("sqm-skeleton", { width: "75%", height: "35px" }),
    h("sqm-skeleton", { width: "75%", height: "35px" }),
    h("sqm-skeleton", { width: "75%", height: "35px" }),
    h("sqm-skeleton", { width: "75%", height: "35px" }),
    h("sqm-skeleton", { width: "75%", height: "35px" }),
    h("sqm-skeleton", { width: "75%", height: "35px" }),
    h("sqm-skeleton", { width: "75%", height: "35px" }),
    h("sqm-skeleton", { width: "75%", height: "35px" }),
    h("sqm-skeleton", { width: "75%", height: "35px" }),
    h("sqm-skeleton", { width: "75%", height: "35px" }),
    h("sqm-skeleton", { width: "75%", height: "35px" }),
    h("sqm-skeleton", { width: "15%" }),
    h("sqm-skeleton", { width: "80px", height: "30px !important" })));
};

function validTaxDocument(requiredType) {
  const validTypes = ["W9", "W8BENE", "W8BEN"];
  if (validTypes.includes(requiredType))
    return true;
  return false;
}
const objectIsFull = (obj) => {
  return !Object.keys(obj).find((k) => obj[k] == undefined);
};
const taxTypeToName = (taxType) => {
  switch (taxType) {
    case "W9":
      return "W-9";
    case "W8BEN":
    case "W8BENE":
      return "W-8";
    default:
      return "";
  }
};
function validateBillingField(regex, value) {
  const trimmed = value.trim();
  const idx = trimmed.search(regex);
  return idx > -1;
}
const formatErrorMessage = (fieldName, errorMessage) => {
  return intl.formatMessage({
    id: fieldName,
    defaultMessage: errorMessage,
  }, {
    fieldName,
  });
};
function getCountryObj({ countryCode, locale, }) {
  // @ts-ignore DisplayNames not in Intl type
  const displayName = new Intl.DisplayNames([locale], {
    type: "region",
  }).of(countryCode);
  return {
    countryCode,
    displayName,
  };
}

const TAX_CONTEXT_NAMESPACE = "sq:tax-and-cash";
const TAX_FORM_CONTEXT_NAMESPACE = "sq:tax-form-context";
const USER_QUERY_NAMESPACE = "sq:user-info-query";
const USER_FORM_CONTEXT_NAMESPACE = "sq:user-form-context";
const FINANCE_NETWORK_SETTINGS_NAMESPACE = "sq:finance-network-settings";
const COUNTRIES_NAMESPACE = "sq:countries:list";
const SORTED_COUNTRIES_NAMESPACE = "sq:countries:sorted";
const COUNTRIES_QUERY_NAMESPACE = "sq:countries:query";
const CURRENCIES_NAMESPACE = "sq:currencies:list";
const CURRENCIES_QUERY_NAMESPACE = "sq:currencies:query";
const GET_USER = dist.gql `
  query getUserTaxInfo {
    user: viewer {
      ... on User {
        id
        firstName
        lastName
        email
        countryCode
        customFields
        rewards(limit: 1000) {
          data {
            statuses
            partnerFundsTransfer {
              id
              status
              dateScheduled
              dateCreated
              dateTransferred
            }
          }
        }
        managedIdentity {
          uid
          email
          emailVerified
        }
        impactConnection {
          connected
          user {
            firstName
            lastName
          }
          publisher {
            id
            brandedSignup
            countryCode
            currency
            billingAddress
            billingCity
            billingState
            billingCountryCode
            billingPostalCode
            phoneNumberCountryCode
            phoneNumber
            taxInformation {
              indirectTaxId
              indirectTaxCountryCode
              indirectTaxRegion
              additionalTaxId
              withholdingTaxId
              withholdingTaxCountryCode
            }
            requiredTaxDocumentType
            currentTaxDocument {
              status
              type
              dateCreated
            }
            withdrawalSettings {
              paymentMethod
              paypalEmailAddress
              bankCountry
              bankAccountNumber
              paymentSchedulingType
              paymentThreshold
              paymentDay
            }
            payoutsAccount {
              hold
              holdReasons
              balance
            }
          }
        }
      }
    }
  }
`;
const GET_COUNTRIES = dist.gql `
  query getCountries {
    impactPayoutCountries(limit: 1000) {
      data {
        countryCode
        displayName
      }
    }
  }
`;
const GET_CURRENCIES = dist.gql `
  query currencies($locale: RSLocale) {
    currencies(limit: 300) {
      data {
        displayName(locale: $locale)
        currencyCode
      }
    }
  }
`;
const GET_FINANCE_NETWORK_SETTINGS = dist.gql `
  query impactFinanceNetworkSettings(
    $filter: ImpactFinanceNetworkSettingsFilterInput
  ) {
    impactFinanceNetworkSettings(filter: $filter, limit: 1000) {
      data {
        countryCode
        currency
        defaultFinancePaymentMethodId
        thresholdOptions
        withdrawalSettingId
        internationalEftFee
        foreignFxFee
        defaultFxFee
      }
      totalCount
    }
  }
`;
const FORM_STEPS = 4;

export { CURRENCIES_NAMESPACE as C, FORM_STEPS as F, GET_USER as G, LoadingView as L, SORTED_COUNTRIES_NAMESPACE as S, TAX_CONTEXT_NAMESPACE as T, USER_FORM_CONTEXT_NAMESPACE as U, TAX_FORM_CONTEXT_NAMESPACE as a, COUNTRIES_NAMESPACE as b, USER_QUERY_NAMESPACE as c, COUNTRIES_QUERY_NAMESPACE as d, GET_COUNTRIES as e, formatErrorMessage as f, getCountryObj as g, FINANCE_NETWORK_SETTINGS_NAMESPACE as h, GET_FINANCE_NETWORK_SETTINGS as i, CURRENCIES_QUERY_NAMESPACE as j, GET_CURRENCIES as k, validTaxDocument as l, objectIsFull as o, taxTypeToName as t, validateBillingField as v };
