'use strict';
import { withIdProps } from '../../../../../fd-toolbox-core/types/resource-with-id.js';
import { addPaging } from '../../../../../fd-toolbox/odata/odataconfig.js';
import { moveArrayItems } from '../../../../../fd-toolbox/collections/internal-arrays.js';
import { fetchResources } from '../../../resource-providers.js';
import { fetchUiResourceMeta } from '../../../ui-meta-providers.js';
import { oDataOperators, tableSortDirections, oDataOrderByDirections } from '../../../../../fd-toolbox/enums/enums.js';
import { oDataFilterTypes } from '../../../../../fd-toolbox/odata/odata-enums.js';
import { getElementId } from '../../../../../fd-toolbox/html/element-ids.js';
import { elements } from '../../../../../fd-toolbox/constants/elements.js';
import { elementPrefixes } from '../../../constants/element-prefixes.js';

var __defProp=Object['defineProperty'],__name=(_0x5df2a2,_0x1d30c4)=>__defProp(_0x5df2a2,'name',{'value':_0x1d30c4,'configurable':!![]});function getMultiBrowserLeftTableId(_0x19cbd0=-0x1f33+0x1*-0x1b97+0x23*0x1ae){return getElementId(elements['multiBrowser']['leftTable'],void(-0xea6+0x38c*0x6+-0x6a2),_0x19cbd0);}__name(getMultiBrowserLeftTableId,'getMultiBrowserLeftTableId');function getMultiBrowserRightTableId(_0x53e86a=0x164a+-0x455*0x2+-0xda0){return getElementId(elements['multiBrowser']['rightTable'],void(-0x4*0x524+-0x1a1b+0x2eab),_0x53e86a);}__name(getMultiBrowserRightTableId,'getMultiBrowserRightTableId');function getMultiBrowserTableContextId(_0x4abc88=-0x2*-0xe2d+-0x2*0x2f1+-0x1678){return getElementId(elements['table']['tableElementId'],elementPrefixes['right'],_0x4abc88);}__name(getMultiBrowserTableContextId,'getMultiBrowserTableContextId');function getMultiBrowserTableId(_0x2dd556=0x1*-0x3b9+0xc67+-0x2*0x457){return getMultiBrowserRightTableId(_0x2dd556);}__name(getMultiBrowserTableId,'getMultiBrowserTableId');function getMultiBrowserMoveResourcesToRightTableId(_0x32c54a=0x2019+-0x6f7*0x4+0x9b*-0x7){return getElementId(elements['multiBrowser']['moveResourcesToRightTable'],void(-0x3*0x6d3+0x1*-0xa8b+0x1f04),_0x32c54a);}__name(getMultiBrowserMoveResourcesToRightTableId,'getMultiBrowserMoveResourcesToRightTableId');function getMultiBrowserMoveResourcesToLeftTableId(_0x2f6fd5=0x207*-0x7+-0x2ea*-0x8+-0x91f){return getElementId(elements['multiBrowser']['moveResourcesToLeftTable'],void(-0x1*0x1e9a+-0xf5e+-0x1*-0x2df8),_0x2f6fd5);}__name(getMultiBrowserMoveResourcesToLeftTableId,'getMultiBrowserMoveResourcesToLeftTableId');function getMultiBrowserOkButtonId(_0x18b453=0x1*-0xdd9+-0x1*-0x1645+-0x1*0x86c){return getElementId(elements['browser']['okBrowserButton'],void(0xa99*0x1+0x1f0b+0x14d2*-0x2),_0x18b453);}__name(getMultiBrowserOkButtonId,'getMultiBrowserOkButtonId');async function initBaseMultiBrowserDialog(_0x5f44de,_0x578911,_0x2ca0ef,_0x5db776,_0x575de8){_0x578911(_0x5f44de['relatedResourcePropertyMeta']['displayName']),_0x2ca0ef(_0x5f44de['selectedResources']);const _0x2b51e6=_0x5f44de['relatedResourcePropertyMeta']['relation']['relatedResourceName'],_0x28e6e9=await fetchUiResourceMeta(_0x2b51e6),_0x13cbfe=_0x28e6e9['properties']?.[_0x5f44de['relatedResourcePropertyMeta']['name']];_0x13cbfe?.['isFilterDisplayable']&&(_0x13cbfe['isFilterDisplayable']=![]),_0x5db776(_0x28e6e9['resourceMeta']),_0x575de8(_0x28e6e9);}__name(initBaseMultiBrowserDialog,'initBaseMultiBrowserDialog');function moveResourcesFromRightTable(_0x148be4,_0x5aed17,_0x2cf943,_0x51c6f5,_0x2a8a5e){if(_0x2cf943){let _0x1e78b4=[..._0x2cf943],_0x4e36b3=![];for(let _0x51eb61 of _0x2a8a5e){!_0x2cf943['includes'](_0x51eb61['item'])&&(_0x1e78b4['push'](_0x51eb61['item']),_0x4e36b3=!![]);}if(_0x4e36b3)_0x51c6f5(_0x1e78b4);}let _0x35157e=_0x2a8a5e['map'](_0x5580df=>_0x5580df['item']);moveArrayItems(_0x35157e,_0x51c6f5,_0x5aed17,()=>_0x2cf943,()=>_0x148be4);}__name(moveResourcesFromRightTable,'moveResourcesFromRightTable');function moveAllResourcesFromRightTable(_0x2861cf,_0x538d31,_0x5f2a99,_0x5148ab){_0x5f2a99&&_0x5148ab([]),moveArrayItems(_0x5f2a99,_0x5148ab,_0x538d31,()=>_0x5f2a99,()=>_0x2861cf);}__name(moveAllResourcesFromRightTable,'moveAllResourcesFromRightTable');function moveResourceBetweenTables(_0x577c05,_0x5a3869,_0x1d9bdb,_0xf4ae27,_0x460c18){const _0x40be70=Array['isArray'](_0x577c05)?_0x577c05:[_0x577c05],_0x3e0d9e=_0x40be70['some'](_0x5a3869['includes']['bind'](_0x5a3869)),_0x7d32ea=_0x40be70['some'](_0xf4ae27['includes']['bind'](_0xf4ae27));if(_0x3e0d9e)_0x1d9bdb(_0x5a3869['filter'](_0x337bec=>!_0x40be70['includes'](_0x337bec))),_0x460c18([..._0xf4ae27,..._0x40be70['filter'](_0x5a3869['includes']['bind'](_0x5a3869))]);else _0x7d32ea&&(_0x460c18(_0xf4ae27['filter'](_0x49311b=>!_0x40be70['includes'](_0x49311b))),_0x1d9bdb([..._0x5a3869,..._0x40be70['filter'](_0xf4ae27['includes']['bind'](_0xf4ae27))]));}__name(moveResourceBetweenTables,'moveResourceBetweenTables');function moveMultipleResources(_0x5e1fb8,_0x157459,_0x3b625d,_0x3fdf0b,_0x384053,_0x18d29b){_0x5e1fb8['length']>0x1*0x2695+0xe1*0x19+0x2*-0x1e47&&moveResourceBetweenTables(_0x5e1fb8,_0x3b625d,_0x3fdf0b,_0x384053,_0x18d29b),_0x157459['length']>0x656+-0x79f*0x1+0x149&&moveResourceBetweenTables(_0x157459,_0x3b625d,_0x3fdf0b,_0x384053,_0x18d29b);}__name(moveMultipleResources,'moveMultipleResources');function moveSingleResource(_0x406429,_0xa310f3,_0x40e537,_0x4235ff,_0x4142ca){moveResourceBetweenTables(_0x406429,_0xa310f3,_0x40e537,_0x4235ff,_0x4142ca);}__name(moveSingleResource,'moveSingleResource');function moveResourcesFromLeftTable(_0x44ffea,_0x2d894a,_0x3c520e,_0x595b51,_0x2d6f1e,_0x37f1a0){const _0x2d559e=_0x37f1a0['relatedResourcePropertyMeta']['relation']['relatedPropertyName'],_0x557336=_0x37f1a0['relatedResourceId'];if(_0x44ffea){let _0x1d32cc=[..._0x44ffea],_0x39b3f2=![];for(let _0x3c3102 of _0x2d6f1e){!_0x44ffea['includes'](_0x3c3102['item'])&&(_0x1d32cc['push'](_0x3c3102['item']),_0x39b3f2=!![]);}if(_0x39b3f2)_0x2d894a(_0x1d32cc);}let _0x594539=_0x2d6f1e['map'](_0x414248=>_0x414248['item']),_0x3f4b13=_0x37f1a0['relatedResourcePropertyMeta']['relation']['relatedResourceRequiresRelation'];_0x3f4b13&&(_0x594539=(_0x44ffea??_0x594539)['filter'](_0x4837be=>_0x4837be[_0x2d559e]!==_0x557336)),moveArrayItems(_0x594539,_0x2d894a,_0x595b51,()=>_0x44ffea,()=>_0x3c520e);}__name(moveResourcesFromLeftTable,'moveResourcesFromLeftTable');function moveAllResourcesFromLeftTable(_0x4464f1,_0x1ebcf2,_0x251066,_0x1955af){_0x4464f1&&_0x1ebcf2([]),moveArrayItems(_0x4464f1,_0x1ebcf2,_0x1955af,()=>_0x4464f1,()=>_0x251066);}__name(moveAllResourcesFromLeftTable,'moveAllResourcesFromLeftTable');async function refreshRightResources(_0x2af5ab,_0x33624c,_0x2ccb9c,_0x13f9c3,_0x5808ea,_0x3b8dd3,_0x2cb53b,_0x3f752b){if(!_0x5808ea)return;const _0x3c6432=getFilledODataConfigWithUserFilters(_0x13f9c3,_0x2cb53b);try{const _0x15680e=_0x33624c['map'](_0x367b6b=>_0x367b6b?.['id']);_0x2af5ab['relatedResourceId']&&_0x15680e['push'](_0x2af5ab['relatedResourceId']);_0x3c6432['filters']??=[],_0x3c6432['filters']['push']({'leftSide':withIdProps['id'],'rightSide':_0x15680e,'operator':oDataOperators['nin'],'type':oDataFilterTypes['guid']}),_0x3c6432['orderBys']??=[];_0x3f752b&&_0x3c6432['orderBys']['push']({'propertyName':_0x3f752b['columnName'],'direction':_0x3f752b['direction']===tableSortDirections['desc']?oDataOrderByDirections['desc']:oDataOrderByDirections['asc'],'priority':0x1});const _0x150653=await fetchResources(_0x5808ea['resourceName'],_0x3c6432);_0x2ccb9c(_0x150653??[]);}catch(_0x32a625){_0x2ccb9c([]);throw _0x32a625;}finally{_0x3b8dd3?.(![]);}}__name(refreshRightResources,'refreshRightResources');async function onBrowserTablePaging(_0x486443,_0x2a15db,_0x582381,_0xac355,_0x21cbf0,_0x3c1f47,_0x111d74,_0x88f31b,_0x3754b2,_0x16555f){_0x21cbf0&&(_0x582381(_0xac355['pageSize']),_0x2a15db(addPaging(_0x486443,_0xac355['pageSize'],_0xac355['pagingSkip'])),_0x3c1f47&&_0x111d74&&_0x88f31b&&_0x3754b2&&_0x16555f&&await _0x3c1f47(_0x111d74,_0x88f31b,_0x3754b2,_0x486443,_0x21cbf0));}__name(onBrowserTablePaging,'onBrowserTablePaging');function getFilledODataConfigWithUserFilters(_0x4a4e48,_0x366e45){const _0x374a17=Object['values'](_0x366e45?.['getFilters']()??{}),_0x21b3d6={..._0x4a4e48};return _0x21b3d6['filters']=(_0x4a4e48['filters']??[])['concat'](_0x374a17),_0x21b3d6;}__name(getFilledODataConfigWithUserFilters,'getFilledODataConfigWithUserFilters');function onMultiBrowserDialogOpenChange(_0x3589bf,_0x2a80c3,_0x2bd0b6,_0x11f870){if(!_0x3589bf&&_0x2a80c3['length']===-0x16e9+-0x6ad+0x1d96)_0x2bd0b6([]);_0x11f870(_0x3589bf);}__name(onMultiBrowserDialogOpenChange,'onMultiBrowserDialogOpenChange');function onResourceClickFunc(_0x2f9a06,_0x52865f,_0x19378a,_0x6e2c17,_0x3e6ab0,_0x23e8a6,_0x42e153){if(_0x23e8a6&&_0x42e153){const _0x4ab80d=_0x23e8a6['getSelectedRows']()['map'](_0x19d401=>_0x19d401['item']),_0x57a516=_0x42e153['getSelectedRows']()['map'](_0x468223=>_0x468223['item']);_0x4ab80d['length']>0xc*0x7+-0x591+0x7a*0xb||_0x57a516['length']>-0x24f3+0x1652+0xea2?moveMultipleResources(_0x4ab80d,_0x57a516,_0x52865f,_0x19378a,_0x6e2c17,_0x3e6ab0):moveSingleResource(_0x2f9a06,_0x52865f,_0x19378a,_0x6e2c17,_0x3e6ab0);}}__name(onResourceClickFunc,'onResourceClickFunc');function setResourceFilterListRef(_0x288bfe,_0x2e6204,_0x41e3a2){_0x288bfe&&(_0x2e6204['current']=_0x288bfe,_0x41e3a2(!![]));}__name(setResourceFilterListRef,'setResourceFilterListRef');async function onSortCallbackFunc(_0x30cea0,_0x439e9b,_0x1fab5a,_0x2ffa2a,_0x3910d6,_0x4ea498,_0x25934b,_0x22a133){await refreshRightResources(_0x439e9b,_0x1fab5a,_0x2ffa2a,_0x3910d6,_0x25934b,_0x4ea498,_0x22a133,_0x30cea0);}__name(onSortCallbackFunc,'onSortCallbackFunc');function onMoveResourcesFromLeftToRightFunc(_0x13dd7a,_0x35c512,_0x1d63d4,_0x3b3454,_0x9c3dac,_0x5115c4){if(_0x5115c4)moveResourcesFromLeftTable(_0x13dd7a,_0x35c512,_0x1d63d4,_0x3b3454,_0x5115c4['getSelectedRows'](),_0x9c3dac);}__name(onMoveResourcesFromLeftToRightFunc,'onMoveResourcesFromLeftToRightFunc');function onMoveResourcesFromRightToLeftFunc(_0x1c1b74,_0x48c3c9,_0x7f451,_0x12cc5a,_0x3c3347){if(_0x3c3347)moveResourcesFromRightTable(_0x1c1b74,_0x48c3c9,_0x7f451,_0x12cc5a,_0x3c3347['getSelectedRows']());}__name(onMoveResourcesFromRightToLeftFunc,'onMoveResourcesFromRightToLeftFunc');function onTriggerClickHandler(_0x26c545,_0x35d575,_0x2b3a66){_0x35d575?.(_0x26c545),_0x2b3a66?.();}__name(onTriggerClickHandler,'onTriggerClickHandler');

export { getFilledODataConfigWithUserFilters, getMultiBrowserLeftTableId, getMultiBrowserMoveResourcesToLeftTableId, getMultiBrowserMoveResourcesToRightTableId, getMultiBrowserOkButtonId, getMultiBrowserRightTableId, getMultiBrowserTableContextId, getMultiBrowserTableId, initBaseMultiBrowserDialog, moveAllResourcesFromLeftTable, moveAllResourcesFromRightTable, moveMultipleResources, moveResourceBetweenTables, moveResourcesFromLeftTable, moveResourcesFromRightTable, moveSingleResource, onBrowserTablePaging, onMoveResourcesFromLeftToRightFunc, onMoveResourcesFromRightToLeftFunc, onMultiBrowserDialogOpenChange, onResourceClickFunc, onSortCallbackFunc, onTriggerClickHandler, refreshRightResources, setResourceFilterListRef };
