'use strict';
import { getNewUuid } from '../../../../fd-toolbox/uuids.js';
import { getResourceImageDescription } from '../../core/resource-description/resource-description.js';
import { crudActions } from '../../../../fd-toolbox/enums/enums.js';
import { hasCrudPermission } from '../../auth/permissions/permission-checker.js';
import { deleteResource } from '../../edit-resource/services/edit-resources.js';
import { getResourceUrl } from '../../services/meta-navigations.js';
import { routes } from '../../../../fd-toolbox/routing/routes.js';
import { silentChangeUrl } from '../../../../fd-toolbox/routing/routers.js';
import { getPropertyDisplayValue } from '../../core/resource-description/resource-descriptions.js';

var __defProp=Object['defineProperty'],__name=(_0x4eaaeb,_0x4ef9b1)=>__defProp(_0x4eaaeb,'name',{'value':_0x4ef9b1,'configurable':!![]});async function initDataCard(_0x2a7e3c,_0x36ce36,_0x118d1f,_0x269ae9,_0x489cca,_0x22b439,_0x442859){const _0x3ba155=_0x2a7e3c['resourceMeta'];_0x269ae9(await getDataCardImageFromItem(_0x2a7e3c['resourceMeta'],_0x36ce36)),_0x118d1f(await getDataCardItemProperties(_0x2a7e3c,_0x36ce36)),_0x3ba155&&(_0x489cca(hasCrudPermission(crudActions['update'],_0x3ba155)),_0x22b439(hasCrudPermission(crudActions['view'],_0x3ba155)),_0x442859(hasCrudPermission(crudActions['delete'],_0x3ba155)));}__name(initDataCard,'initDataCard');function onDialogResponse(_0x3875fc,_0x41bc13,_0x2cb316,_0x1efe7f,_0x129a6d){if(!_0x41bc13||!_0x2cb316['resourceMeta'])return;_0x3875fc&&_0x129a6d&&deleteResource(_0x3875fc,_0x1efe7f,{'id':_0x41bc13['id']},_0x129a6d);}__name(onDialogResponse,'onDialogResponse');function onViewClick(_0x44a06c,_0x333acc){if(_0x44a06c){const _0x480f26=getResourceUrl(routes['view'],_0x333acc,_0x44a06c['id']);silentChangeUrl(_0x480f26);}}__name(onViewClick,'onViewClick');async function getDataCardImageFromItem(_0x5d77cd,_0x171065){const _0x2bd137=await getResourceImageDescription(_0x5d77cd,_0x171065);return _0x2bd137['imageUrl'];}__name(getDataCardImageFromItem,'getDataCardImageFromItem');async function getDataCardItemProperties(_0x27f0c1,_0x154972){const _0x347af8={'id':getNewUuid()};for(const _0x870cc4 of Object['keys'](_0x27f0c1['properties'])){if(_0x27f0c1['properties'][_0x870cc4]['isListDisplayable']){const _0x562fcf=_0x27f0c1['resourceMeta']['properties'][_0x870cc4],_0x3b43fc=await getPropertyDisplayValue(_0x562fcf,_0x27f0c1['resourceMeta'],_0x154972,_0x870cc4);_0x3b43fc&&(_0x347af8[_0x870cc4]=_0x3b43fc);}}return _0x347af8;}__name(getDataCardItemProperties,'getDataCardItemProperties');

export { getDataCardImageFromItem, initDataCard, onDialogResponse, onViewClick };
