'use strict';
import { expect } from 'playwright/test';
import { formatBlobName } from '../../fd-toolbox/http/url/urls.js';
import { createError } from '../../fd-toolbox/errors/errors.js';
import { elements } from '../../fd-toolbox/constants/elements.js';
import { htmlElementAttributes } from '../../fd-toolbox/constants/html-element-attributes.js';
import { getUiTester, getUiTestPage } from '../ui-tester/global-ui-test.js';
import { isNullOrUndefined, ensureNotNullOrUndefined } from '../../fd-toolbox/functions/value-checking-functions.js';
import { booleanStringValues } from '../../base-repo/constants/type-string-values.js';
import { uiElementVisibilityState } from '../../base-repo/constants/ui-constants.js';
import { ariaAttributes, inputTypes } from '../constants/ui-tester/html-contants.js';
import { npmPackageProperties } from '../../base-repo/constants/internal-common-strings.js';
import { testInfraPaths } from '../constants/ui-tester/paths.js';

var __defProp=Object['defineProperty'],__name=(_0x55079e,_0x82db6c)=>__defProp(_0x55079e,'name',{'value':_0x82db6c,'configurable':!![]});const maxAttemptNumber=-0x21f6+-0x6a5*-0x1+-0x1*-0x1b6f,actualString='\x22,\x20Actual:\x20\x22',expectedString=',\x20Expected:\x20\x22';async function uiAssertEqual(_0x43822d,_0x799ba0){return expect(_0x43822d)['toBe'](_0x799ba0);}__name(uiAssertEqual,'uiAssertEqual');async function uiAssertNotEqual(_0x319457,_0x337d41){return expect(_0x319457)['not']['toBe'](_0x337d41);}__name(uiAssertNotEqual,'uiAssertNotEqual');async function uiAssertValue(_0x3a50be,_0x17db64){const _0x3eb089=getUiTester();await assertWithRetry(_0x3a50be,async()=>{const _0x1b49a7=await _0x3eb089['getById'](_0x3a50be);return await _0x1b49a7['getAttribute'](htmlElementAttributes['value'])??void(0x4f*0x9+-0x10e9*-0x1+-0x13b0);},_0x17db64);}__name(uiAssertValue,'uiAssertValue');async function uiAssertAttribute(_0x379c69,_0x35134d,_0xe761c9){const _0x180bb8=getUiTester(),_0x431e74=await _0x180bb8['getById'](_0x379c69);await expect(_0x431e74)['toHaveAttribute'](_0x35134d,_0xe761c9);}__name(uiAssertAttribute,'uiAssertAttribute');async function uiAssertInnerText(_0x58c1f8,_0x156716){const _0x322ec8=getUiTester();await assertWithRetry(_0x58c1f8,async()=>{const _0x2b90f7=await _0x322ec8['getText'](_0x58c1f8);return isNullOrUndefined(_0x2b90f7)?void(0xc9c+0xf39+-0x1bd5):_0x2b90f7;},_0x156716);}__name(uiAssertInnerText,'uiAssertInnerText');async function uiAssertElementVisibility(_0x1edbe4,_0x35ac9e){const _0x3ac2c4=getUiTester();await assertWithRetry(_0x1edbe4,async()=>_0x3ac2c4['waitForElementToLoad'](_0x1edbe4),_0x35ac9e);}__name(uiAssertElementVisibility,'uiAssertElementVisibility');async function uiAssertInnerHtml(_0x2f54fa,_0x9d8402){const _0x143a72=getUiTester();for(let _0x50029c=-0x6b*0x3c+-0x1*-0xb5+0x11*0x16f;_0x50029c<maxAttemptNumber;_0x50029c++){const _0x3347c0=await _0x143a72['getInnerHtml'](_0x2f54fa);if(_0x3347c0===_0x9d8402)return;if(_0x50029c===maxAttemptNumber-(-0x3d5*0x3+0x1c4b*0x1+0x599*-0x3))throw createError('HTML\x20is\x20not\x20as\x20expected.\x20Id:\x20'+_0x2f54fa+expectedString+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'+_0x9d8402+actualString+_0x3347c0+'\x22.');await _0x143a72['page']['waitForTimeout'](-0x1*0x1657+-0x1935+0x19ba*0x2);}}__name(uiAssertInnerHtml,'uiAssertInnerHtml');async function uiAssertAllElementsHaveText(_0x644a99,_0x43d13f){for(const _0x4f275b of _0x644a99){await expect(_0x4f275b)['toHaveText'](_0x43d13f);}}__name(uiAssertAllElementsHaveText,'uiAssertAllElementsHaveText');async function uiAssertImage(_0x11a1e5,_0x3aaf6a){const _0x4e88c1=getUiTester(),_0x3d5668=await _0x4e88c1['getById'](_0x11a1e5),_0x151633=ensureNotNullOrUndefined(await _0x3d5668['getAttribute'](htmlElementAttributes['src']));expect(_0x151633)['not']['toBeNull'](),_0x151633['startsWith'](testInfraPaths['optimizedImagePrefix'])?expect(formatBlobName(_0x151633))['toContain'](_0x3aaf6a):expect(_0x151633)['toEqual'](_0x3aaf6a),await expect(_0x3d5668)['toBeVisible']();}__name(uiAssertImage,'uiAssertImage');async function uiAssertScreenshot(_0x577472){const _0x22a191=getUiTestPage(),_0x510c4c=getUiTester();await expect(_0x22a191)['toHaveScreenshot'](_0x577472,{'mask':[await _0x510c4c['getById'](elements['toolbar'])]});}__name(uiAssertScreenshot,'uiAssertScreenshot');async function uiAssertCheckboxValue(_0x48c44e,_0x4b9b9b){const _0x413750=await getCheckboxOrSwitchAssertTarget(_0x48c44e),_0x1d74e0=_0x413750['locator'];await _0x1d74e0['waitFor']({'state':uiElementVisibilityState['visible']});let _0x1c6777;_0x413750['usesAriaCheckedAttribute']&&(_0x4b9b9b?_0x1c6777=booleanStringValues['true']:_0x1c6777=booleanStringValues['false']);if(_0x413750['usesAriaCheckedAttribute'])await expect(_0x1d74e0)['toHaveAttribute'](ariaAttributes['checked'],ensureNotNullOrUndefined(_0x1c6777));else _0x4b9b9b?await expect(_0x1d74e0)['toBeChecked']():await expect(_0x1d74e0)['not']['toBeChecked']();}__name(uiAssertCheckboxValue,'uiAssertCheckboxValue');async function uiClickCheckboxOrSwitch(_0x5ce91c){const _0x9f93b=getUiTester(),_0x4ca16f=await _0x9f93b['getById'](_0x5ce91c),_0x2a47dd=_0x4ca16f['getByRole'](inputTypes['checkbox']),_0x26ae53=await _0x2a47dd['getAttribute'](ariaAttributes['checked']);await _0x2a47dd['click'](),await expect(_0x2a47dd)['not']['toHaveAttribute'](ariaAttributes['checked'],_0x26ae53??'');}__name(uiClickCheckboxOrSwitch,'uiClickCheckboxOrSwitch');async function uiAssertElementDoesntExist(_0x429c61){const _0x3efd97=getUiTester(),_0x3a53a8=await _0x3efd97['getById'](_0x429c61);await expect(_0x3a53a8)['toHaveCount'](-0x8*0x3d8+0xb1b+0x13a5);}__name(uiAssertElementDoesntExist,'uiAssertElementDoesntExist');async function getCheckboxOrSwitchAssertTarget(_0x20a6d3){const _0x3080f5=getUiTester(),_0x26177c=await _0x3080f5['getById'](_0x20a6d3),_0xecbd02=await _0x26177c['getAttribute'](ariaAttributes['checked']),_0x3584e5=_0x26177c['getByRole'](inputTypes['checkbox']),_0x24da63=_0x26177c['locator']('input[type=checkbox],\x20input[type=radio]');let _0x17cb72;if(_0xecbd02===booleanStringValues['true']||_0xecbd02===booleanStringValues['false'])_0x17cb72={'usesAriaCheckedAttribute':!![],'locator':_0x26177c};else {const _0x1052a8=await _0x26177c['getAttribute'](npmPackageProperties['type']);if(_0x1052a8===inputTypes['checkbox']||_0x1052a8==='radio')_0x17cb72={'usesAriaCheckedAttribute':![],'locator':_0x26177c};else {if(await _0x3584e5['count']()>0x192b+-0x1*-0x1552+-0x2e7d)_0x17cb72={'usesAriaCheckedAttribute':!![],'locator':_0x3584e5['first']()};else await _0x24da63['count']()>0x2673+0x17b*0x17+0xe8*-0x50&&(_0x17cb72={'usesAriaCheckedAttribute':![],'locator':_0x24da63['first']()});}}if(!_0x17cb72){const _0x488efb=await _0x26177c['evaluate'](_0x3a303d=>_0x3a303d['tagName']);throw createError('Element\x20is\x20not\x20a\x20checkbox\x20or\x20switch:\x20'+_0x488efb);}return _0x17cb72;}__name(getCheckboxOrSwitchAssertTarget,'getCheckboxOrSwitchAssertTarget');async function assertWithRetry(_0x19f774,_0x2dea50,_0x11fbca){const _0x22cea1=getUiTester();for(let _0x1b090a=-0x645*0x3+0x147d+0xd7*-0x2;_0x1b090a<maxAttemptNumber;_0x1b090a++){const _0x4cb298=await _0x2dea50();if(_0x4cb298!==void(0x18ca+-0x1*-0x779+-0x2043)&&_0x4cb298===_0x11fbca)return;if(_0x1b090a===maxAttemptNumber-(-0x2ef*-0x3+0x220*-0xf+0x1714))throw createError('Value\x20is\x20not\x20as\x20expected.\x20Id:\x20'+_0x19f774+expectedString+_0x11fbca+actualString+_0x4cb298+'\x22.');await _0x22cea1['page']['waitForTimeout'](-0x1*0x9a3+-0x2377+0x3102);}}__name(assertWithRetry,'assertWithRetry');

export { uiAssertAllElementsHaveText, uiAssertAttribute, uiAssertCheckboxValue, uiAssertElementDoesntExist, uiAssertElementVisibility, uiAssertEqual, uiAssertImage, uiAssertInnerHtml, uiAssertInnerText, uiAssertNotEqual, uiAssertScreenshot, uiAssertValue, uiClickCheckboxOrSwitch };
