'use strict';
import { logWarning } from '../logging/logger.js';
import { toolboxErrorMessages } from '../../constants/toolbox-error-messages-constants.js';
import { createError } from '../../errors/errors.js';

var __defProp=Object['defineProperty'],__name=(_0x5da38d,_0x95ca91)=>__defProp(_0x5da38d,'name',{'value':_0x95ca91,'configurable':!![]});function singleWithWarning(_0xe3e8c3){if(_0xe3e8c3['length']===-0x4fd*0x3+0x1b08+-0xc11)throw createError(toolboxErrorMessages['emptyArray']);const _0x360b8b=_0xe3e8c3[-0x12*0x1fc+0x1*0x2075+0x343*0x1];if(_0xe3e8c3['length']===-0x1*-0x1f51+0x1f2*0xc+-0x3*0x1238)return _0x360b8b;if(_0xe3e8c3['length']>0x70a*-0x1+0xab*-0x11+-0x5*-0x3ae)logWarning(getCollectionElementsMessage(_0xe3e8c3['length']));return _0x360b8b;}__name(singleWithWarning,'singleWithWarning');function singleOrUndefinedWithWarning(_0x3f1d01){if(_0x3f1d01['length']===-0x12ca+-0x9f4+-0x236*-0xd)return void(0x820+0x1032+0xc29*-0x2);const _0x579373=_0x3f1d01[0xa*-0x13+0x17*-0x1b1+0x27a5];if(_0x3f1d01['length']===0x1c*0xb0+0x2*-0xaff+0x2bf)return _0x579373;if(_0x3f1d01['length']>0x1*-0xca5+-0x9*-0x8b+0x1*0x7c3)logWarning(getCollectionElementsMessage(_0x3f1d01['length']));return _0x579373;}__name(singleOrUndefinedWithWarning,'singleOrUndefinedWithWarning');function getSingleOrEmpty(_0x18a0a7){let _0x3e9828;if(_0x18a0a7['length']===0x2f*0x9d+0x13*0x43+0xd3*-0x29)_0x3e9828=_0x18a0a7[-0x17ba+0x129c*-0x2+0x3cf2];if(_0x18a0a7['length']>-0x1*0x3c1+0xca*-0x7+0x948)throw createError(getCollectionElementsMessage(_0x18a0a7['length']));return _0x3e9828;}__name(getSingleOrEmpty,'getSingleOrEmpty');function singleOrUndefined(_0x27faa9,_0x5ac593=()=>!![]){const _0xcdf9cc=_0x27faa9['filter'](_0x5ac593);if(_0xcdf9cc['length']>-0x2290+-0x6*-0x50b+0x44f)throw createError(getCollectionElementsMessage(_0xcdf9cc['length']));return _0xcdf9cc['length']===0x6*0x5b1+0x6a8+-0x1*0x28cd?_0xcdf9cc[-0x3*0x378+-0x757*-0x4+-0x97a*0x2]:void(-0x183c+-0x1e1+0x23*0xbf);}__name(singleOrUndefined,'singleOrUndefined');async function singleAsync(_0x165b6a){const _0x18ffd2=await _0x165b6a,_0x277319=_0x18ffd2[-0x7*0x569+0x805*0x4+0x5cb];if(_0x18ffd2['length']>-0x1834+0xd16+0xb1f)logWarning(getCollectionElementsMessage(_0x18ffd2['length']));return _0x277319;}__name(singleAsync,'singleAsync');async function singleOrUndefinedAsync(_0xb140a6,_0x2783a3=()=>!![]){const _0x573c8e=await _0xb140a6,_0x56ed13=_0x573c8e['filter'](_0x2783a3),_0x5417a9=firstOrUndefined(_0x56ed13);if(_0x56ed13['length']===0x5e*-0x3+-0x10b+0x16*0x19)return _0x5417a9;else {if(_0x56ed13['length']>-0x768*0x2+0x24cd*0x1+-0x10c*0x15)throw createError(getCollectionElementsMessage(_0x56ed13['length']));}return _0x5417a9;}__name(singleOrUndefinedAsync,'singleOrUndefinedAsync');function first(_0x4e8fc6){if(_0x4e8fc6['length']===0xc5*0x2f+-0x13f3*0x1+-0x1038)throw createError(toolboxErrorMessages['emptyArray']);return _0x4e8fc6[0x1*-0x1e4a+0x52*0x62+-0x11a*0x1];}__name(first,'first');function firstOrUndefined(_0x129e6b){return _0x129e6b[-0xf02+-0x106b+0x1f6d*0x1];}__name(firstOrUndefined,'firstOrUndefined');function getCollectionElementsMessage(_0x481091){return 'Collection\x20had\x20'+_0x481091+'\x20elements,\x20expected\x20one';}__name(getCollectionElementsMessage,'getCollectionElementsMessage');

export { first, firstOrUndefined, getSingleOrEmpty, singleAsync, singleOrUndefined, singleOrUndefinedAsync, singleOrUndefinedWithWarning, singleWithWarning };
