'use strict';
import { apiPathNames } from '../../fd-toolbox/api/api-path-names.js';
import { elements } from '../../fd-toolbox/constants/elements.js';
import { keyboardKeys } from '../../fd-toolbox/constants/keyboard-keys.js';
import { getUserDropDownMenuTriggerId } from '../../level2/fd-app-toolbox/menu/user-dropdown-menu/UserDropdownMenu.funcs.js';
import { getWorkspacePickerSelectTriggerId, getWorkspacePickerSelectItemId } from '../../level2/fd-app-toolbox/menu/workspace-picker/WorkspacePicker.funcs.js';
import { getUiTestPage, getUiTester } from '../ui-tester/global-ui-test.js';
import { ariaAttributes, htmlElementVisibilityState } from '../constants/ui-tester/html-contants.js';
import { booleanStringValues } from '../../base-repo/constants/type-string-values.js';
import { httpMethods } from '../../base-repo/constants/http-methods.js';

var __defProp=Object['defineProperty'],__name=(_0x3b2e4e,_0x388962)=>__defProp(_0x3b2e4e,'name',{'value':_0x388962,'configurable':!![]});async function selectWorkspacePoSelectWorkspace(_0x5f586b){const _0xf0f743=getUiTestPage(),_0x5123a3=getUiTester(),_0x5a3524=getUserDropDownMenuTriggerId(elements['toolbar']);await _0x5123a3['click'](_0x5a3524);const _0x5c90d8=getWorkspacePickerSelectTriggerId(_0x5a3524),_0x124829=getWorkspacePickerSelectItemId(_0x5a3524,_0x5f586b);await _0x5123a3['click'](_0x5c90d8);const _0x3db87b=_0xf0f743['locator']('[id=\x22'+_0x124829+'\x22]'),_0x331846=await _0x3db87b['evaluate'](_0x4c7471=>_0x4c7471['hasAttribute']('data-selected')),_0x557a51=await _0x3db87b['getAttribute'](ariaAttributes['selected'])===booleanStringValues['true']||_0x331846;if(_0x557a51){await _0xf0f743['keyboard']['press'](keyboardKeys['escape']),await _0xf0f743['keyboard']['press'](keyboardKeys['escape']);return;}const _0x45391e=_0xf0f743['waitForEvent']('framenavigated',{'predicate':__name(_0x227976=>_0x227976===_0xf0f743['mainFrame'](),'predicate')});await Promise['all']([_0xf0f743['waitForResponse'](_0x5ab4fd=>_0x5ab4fd['url']()['includes'](apiPathNames['changeWorkspace'])&&_0x5ab4fd['request']()['method']()===httpMethods['post']),_0x3db87b['click']()]),await _0x45391e,await _0xf0f743['waitForLoadState'](htmlElementVisibilityState['domcontentloaded']),await _0x5123a3['waitForElementWithIdPrefix'](elements['resourceList']['resourceListId']);}__name(selectWorkspacePoSelectWorkspace,'selectWorkspacePoSelectWorkspace');

export { selectWorkspacePoSelectWorkspace };
