import{NotificationManager}from'./notifications.js';export function getTaskNotificationGroupId(_0xe28511){return _0xe28511?.['groupId']||_0xe28511?.['group_id']||_0xe28511?.['originalGroupId']||null;}export function createGroupCompletionNotifier({getTaskGroup:_0x38d59d,getTrackedTasks:_0x506d8b,getGroupNotificationChecks:_0x3be209,getCurrentUser:_0x10a2b7,onTaskNotified:onTaskNotified=()=>{},logger:logger=console}){async function _0x3895e2(_0x15eba8){const _0x44ec08=getTaskNotificationGroupId(_0x15eba8);if(!_0x44ec08)return{'suppressTaskNotification':![],'notified':![]};const _0x572006=_0x3be209(),_0xcab25c=_0x572006['get'](_0x44ec08);if(_0xcab25c)return _0xcab25c['needsRefresh']=!![],_0xcab25c['latestTask']=_0x15eba8,!_0xcab25c['refreshPromise']&&(_0xcab25c['refreshPromise']=_0xcab25c['promise']['then'](async _0x1302e2=>{if(!_0x1302e2['notified']&&_0xcab25c['needsRefresh'])return _0x3895e2(_0xcab25c['latestTask']||_0x15eba8);return _0x1302e2;})['finally'](()=>{_0xcab25c['refreshPromise']=null;})),_0xcab25c['refreshPromise'];const _0x1fe6db={'latestTask':_0x15eba8,'needsRefresh':![],'promise':null,'refreshPromise':null},_0x5adf40=((async()=>{try{const _0x412888=await _0x38d59d(_0x44ec08),_0x297c70=(_0x412888['tasks']||[])['map'](_0x53b068=>_0x53b068['taskId']===_0x15eba8?.['taskId']?{..._0x15eba8,..._0x53b068}:_0x53b068);if(_0x297c70['length']<=0x1)return{'suppressTaskNotification':![],'notified':![]};if(_0x412888['completionNotificationReady']!==!![])return{'suppressTaskNotification':!![],'notified':![],'pending':!![]};const _0x1874e8=_0x506d8b();if(!NotificationManager['shouldNotifyGroup'](_0x44ec08,_0x297c70,_0x1874e8))return{'suppressTaskNotification':!![],'notified':![]};return await NotificationManager['notifyTaskGroupComplete'](_0x412888,_0x297c70),NotificationManager['markGroupNotified'](_0x44ec08),_0x297c70['forEach'](_0x516f5f=>{_0x516f5f['taskId']&&(NotificationManager['markNotified'](_0x516f5f['taskId']),_0x1874e8['delete'](_0x516f5f['taskId']),onTaskNotified(_0x516f5f));}),{'suppressTaskNotification':!![],'notified':!![]};}catch(_0x2d0eca){return logger['error']('Failed\x20to\x20check\x20task\x20group\x20notification\x20state:',_0x2d0eca),{'suppressTaskNotification':![],'notified':![]};}})());return _0x1fe6db['promise']=_0x5adf40['finally'](()=>{_0x572006['get'](_0x44ec08)===_0x1fe6db&&_0x572006['delete'](_0x44ec08);}),_0x572006['set'](_0x44ec08,_0x1fe6db),_0x1fe6db['promise'];}async function _0x1f0c0c(_0xbc0ecc){if(!_0xbc0ecc?.['groupId']||_0xbc0ecc['isTerminal']!==!![]||_0xbc0ecc['completionNotificationReady']!==!![])return;if(!NotificationManager['isGroupMode'](_0x10a2b7()))return;await _0x3895e2({'groupId':_0xbc0ecc['groupId']});}return{'maybeNotifyGroupCompletionForTask':_0x3895e2,'maybeNotifyGroupCompletionFromStatusSignal':_0x1f0c0c};}