'use strict';
import { paymentErrorMessages } from '../../level2/common/payments/payment-constants.js';
import { elementSuffixes } from '../../fd-toolbox/constants/element-suffixes.js';
import { elements } from '../../fd-toolbox/constants/elements.js';
import { wellKnownUserProps } from '../../fd-toolbox/constants/common-user-fields.js';
import { userDisplayProps } from '../../level2/fd-app-toolbox/user-dto.js';
import { createError } from '../../fd-toolbox/errors/errors.js';
import { getStripeDefaultPaymentMethod } from '../../level2/server/payments/stripe/stripes.js';
import { getCurrentWorkspace } from '../../level2/fd-app-toolbox/server/infra/workspaces/workspace-db.js';
import { getUiTester } from '../ui-tester/global-ui-test.js';
import { paymentPlanPoFillStripeCardNumber, paymentPlanPoFillStripeExpDateAndCvc } from './payment-plan-po.js';
import { userSettingsAndPaymentTestData } from '../constants/ui-tester/checkout-form-test-data.js';
import { headers } from '../constants/test-data/table-headers.js';

var __defProp=Object['defineProperty'],__name=(_0x40a9b6,_0x501d34)=>__defProp(_0x40a9b6,'name',{'value':_0x501d34,'configurable':!![]});async function userSettingPoSetFirstName(_0x13a0e3){const _0x4f6194=getUiTester();await _0x4f6194['page']['getByLabel'](userDisplayProps['firstName'])['fill'](_0x13a0e3);}__name(userSettingPoSetFirstName,'userSettingPoSetFirstName');async function userSettingPoSetLastName(_0x3c78c3){const _0x458bb2=getUiTester();await _0x458bb2['page']['getByLabel'](headers['lastName'])['fill'](_0x3c78c3);}__name(userSettingPoSetLastName,'userSettingPoSetLastName');async function userSettingPoOpenCountrySelector(){const _0x321ebc=getUiTester();await _0x321ebc['click']('country'+elementSuffixes['select']);}__name(userSettingPoOpenCountrySelector,'userSettingPoOpenCountrySelector');async function userSettingPoSelectCountry(_0x1007ad){const _0x328a60=getUiTester();await _0x328a60['click'](_0x1007ad+elementSuffixes['selectOption']);}__name(userSettingPoSelectCountry,'userSettingPoSelectCountry');async function userSettingPoSetEmail(_0x43582d){const _0x181d5f=getUiTester();await _0x181d5f['clearWithBackspacesAndSendKeys'](wellKnownUserProps['email'],_0x43582d);}__name(userSettingPoSetEmail,'userSettingPoSetEmail');async function userSettingPoSetCardholderName(_0x6ce280){const _0x5f4ba0=getUiTester();await _0x5f4ba0['clearWithBackspacesAndSendKeys'](wellKnownUserProps['name'],_0x6ce280);}__name(userSettingPoSetCardholderName,'userSettingPoSetCardholderName');async function userSettingPoSetZipCode(_0x16f84b){const _0x58afc4=getUiTester();await _0x58afc4['clearWithBackspacesAndSendKeys'](wellKnownUserProps['zip'],_0x16f84b);}__name(userSettingPoSetZipCode,'userSettingPoSetZipCode');async function userSettingPoSetCardNumber(_0x520614){await paymentPlanPoFillStripeCardNumber(_0x520614);}__name(userSettingPoSetCardNumber,'userSettingPoSetCardNumber');async function userSettingPoSetCardExpDateAndCvc(_0x678a48,_0x5e9647){await paymentPlanPoFillStripeExpDateAndCvc(_0x678a48,_0x5e9647);}__name(userSettingPoSetCardExpDateAndCvc,'userSettingPoSetCardExpDateAndCvc');async function userSettingPoClickChangePaymentMethod(){const _0x4f8075=getUiTester();await _0x4f8075['click'](elements['userSettings']['changePaymentMethodField']);}__name(userSettingPoClickChangePaymentMethod,'userSettingPoClickChangePaymentMethod');async function userSettingPoClickUpdatePaymentMethod(){const _0x44bc5d=getUiTester();await _0x44bc5d['click'](elements['userSettings']['payButton']);}__name(userSettingPoClickUpdatePaymentMethod,'userSettingPoClickUpdatePaymentMethod');async function userSettingPoWaitForMethodInputValueToMatch(_0x240c8b){const _0x5cdce8=_0x240c8b['slice'](-(0x1fc4+-0x5*-0x4f9+-0x389d)),_0x44c72e=userSettingsAndPaymentTestData['cardMaskedDigitsPrefix']+_0x5cdce8,_0x477e48=getUiTester();await _0x477e48['waitForInputValueToMatch'](elements['userSettings']['changePaymentMethodField'],_0x44c72e);}__name(userSettingPoWaitForMethodInputValueToMatch,'userSettingPoWaitForMethodInputValueToMatch');async function userSettingPoGetCurrentPaymentMethod(){const _0x37cc42=await getCurrentWorkspace(),_0x5205f6=_0x37cc42['paymentSystemCustomerId'];if(!_0x5205f6)throw createError(paymentErrorMessages['paymentSystemUserNotFound']);const _0x4452c2=await getStripeDefaultPaymentMethod(_0x5205f6);if(!_0x4452c2)throw createError(paymentErrorMessages['defaultPaymentMethodNotFound']);const _0x1ff757=_0x4452c2['card'];if(!_0x1ff757?.['last4']||!_0x1ff757['exp_month']||!_0x1ff757['exp_year'])throw createError(paymentErrorMessages['cardAttachedToPaymentMethodNotFound']);return {'safeCardNumber':_0x1ff757['last4'],'expDate':''+(_0x1ff757['exp_month']<-0x34*-0x77+-0xfef+-0x833?'0':'')+_0x1ff757['exp_month']+'/'+_0x1ff757['exp_year']['toString']()['slice'](-(0x2*-0x3e1+0x1be6+-0x1422))};}__name(userSettingPoGetCurrentPaymentMethod,'userSettingPoGetCurrentPaymentMethod');

export { userSettingPoClickChangePaymentMethod, userSettingPoClickUpdatePaymentMethod, userSettingPoGetCurrentPaymentMethod, userSettingPoOpenCountrySelector, userSettingPoSelectCountry, userSettingPoSetCardExpDateAndCvc, userSettingPoSetCardNumber, userSettingPoSetCardholderName, userSettingPoSetEmail, userSettingPoSetFirstName, userSettingPoSetLastName, userSettingPoSetZipCode, userSettingPoWaitForMethodInputValueToMatch };
