'use strict';
import { apiGetWithOData } from '../../../../fd-toolbox/api/api-client.js';
import { withIdProps } from '../../../../fd-toolbox-core/types/resource-with-id.js';
import { oDataOperators } from '../../../../fd-toolbox/enums/enums.js';
import { fetchRelatedResourcesList } from '../../one-to-many-relations.js';
import { oDataComparisonTypes, oDataLogicalOperationTypes, oDataFilterTypes } from '../../../../fd-toolbox/odata/odata-enums.js';
import { clearBrowserSelection, getBrowserSelectionResourceMetaIfNeeded, setBrowserSelectionPropertyResourceMeta } from '../browser-selection.js';

var __defProp=Object['defineProperty'],__name=(_0x131e78,_0x27b4a7)=>__defProp(_0x131e78,'name',{'value':_0x27b4a7,'configurable':!![]});async function onInitMultiBrowser(_0x49e98b,_0x498ab3,_0x3c69ca,_0x49aa26,_0x1aafc9,_0x5110d2,_0x402141,_0x502f8f,_0x4735da){await writeMultiBrowserValue(_0x49e98b,_0x498ab3,_0x3c69ca,_0x1aafc9,_0x5110d2,_0x402141,_0x502f8f,_0x4735da),_0x49aa26(!![]);}__name(onInitMultiBrowser,'onInitMultiBrowser');function handleInputModelChange(_0x58688c,_0x386b85,_0x1b57d3,_0x500d2c){_0x500d2c&&onMultiBrowserInputUpdate(_0x58688c['target']['value'],_0x386b85,_0x500d2c,_0x1b57d3);}__name(handleInputModelChange,'handleInputModelChange');function onMultiBrowserInputUpdate(_0x2ac303,_0x469943,_0x5679d9,_0x123af2){_0x2ac303===''&&clearBrowserSelection(_0x469943,_0x5679d9,_0x123af2);}__name(onMultiBrowserInputUpdate,'onMultiBrowserInputUpdate');async function writeMultiBrowserValue(_0x3db059,_0x228108,_0x2b6320,_0x36da56,_0xca0bac,_0x48f9d6,_0x507f43,_0x59bddf){const _0xa4dbd8=await fetchMultiBrowserSelectedResources(_0x3db059,_0x36da56,_0xca0bac,_0x48f9d6);if(_0xa4dbd8){const _0x430f39=_0xa4dbd8['map'](_0x1624b0=>_0x1624b0['id']);_0x228108(_0xa4dbd8),_0x507f43?.(_0x430f39);const _0x338304=await getBrowserSelectionResourceMetaIfNeeded(_0x3db059,_0x36da56);!_0xca0bac&&_0x59bddf?.(_0xa4dbd8,_0x338304),await setBrowserSelectionPropertyResourceMeta(_0x3db059,_0x2b6320,_0x338304);}}__name(writeMultiBrowserValue,'writeMultiBrowserValue');async function fetchMultiBrowserSelectedResources(_0x30ab4d,_0x565cec,_0x3271e1,_0x2d7000){let _0x29aa53=[];if(_0x3271e1){if(_0x3271e1['length']>0x6*0x1a5+0x267f+0x1*-0x305d){const _0x4d0416=buildODataFiltersFromIds(_0x3271e1),_0x44e4ad=await apiGetWithOData(_0x30ab4d['relation']['relatedResourceName'],{'filters':_0x4d0416});_0x29aa53=_0x44e4ad['data'];}else _0x29aa53=[];}else {const _0x66c519=await fetchRelatedResourcesList(_0x30ab4d,_0x565cec,_0x2d7000);_0x29aa53=_0x66c519;}return _0x29aa53;}__name(fetchMultiBrowserSelectedResources,'fetchMultiBrowserSelectedResources');function buildODataFiltersFromIds(_0x56fd83){const _0x588811=[];for(const _0x2c0f3a of _0x56fd83){_0x588811['push']({'leftSide':withIdProps['id'],'rightSide':_0x2c0f3a,'type':oDataFilterTypes['guid'],'operator':oDataOperators['in'],'logicalOperationType':oDataLogicalOperationTypes['or'],'comparisonType':oDataComparisonTypes['equal']});}return _0x588811;}__name(buildODataFiltersFromIds,'buildODataFiltersFromIds');

export { handleInputModelChange, onInitMultiBrowser, onMultiBrowserInputUpdate };
