import{NotificationManager}from'./notifications.js';export function getTaskNotificationGroupId(_0x1b255e){return _0x1b255e?.['groupId']||_0x1b255e?.['group_id']||_0x1b255e?.['originalGroupId']||null;}export function createGroupCompletionNotifier({getTaskGroup:_0x23610c,getTrackedTasks:_0x31af1f,getGroupNotificationChecks:_0x4faef6,getCurrentUser:_0x3b7356,onTaskNotified:onTaskNotified=()=>{},logger:logger=console}){async function _0x953e2e(_0xb8c2ca){const _0xc41736=getTaskNotificationGroupId(_0xb8c2ca);if(!_0xc41736)return{'suppressTaskNotification':![],'notified':![]};const _0x4ce6fd=_0x4faef6(),_0x24baa4=_0x4ce6fd['get'](_0xc41736);if(_0x24baa4)return _0x24baa4['needsRefresh']=!![],_0x24baa4['latestTask']=_0xb8c2ca,!_0x24baa4['refreshPromise']&&(_0x24baa4['refreshPromise']=_0x24baa4['promise']['then'](async _0x4d1aff=>{if(!_0x4d1aff['notified']&&_0x24baa4['needsRefresh'])return _0x953e2e(_0x24baa4['latestTask']||_0xb8c2ca);return _0x4d1aff;})['finally'](()=>{_0x24baa4['refreshPromise']=null;})),_0x24baa4['refreshPromise'];const _0x8c84e9={'latestTask':_0xb8c2ca,'needsRefresh':![],'promise':null,'refreshPromise':null},_0x27ac7d=((async()=>{try{const _0x298bc6=await _0x23610c(_0xc41736),_0x592d7e=(_0x298bc6['tasks']||[])['map'](_0x10635e=>_0x10635e['taskId']===_0xb8c2ca?.['taskId']?{..._0xb8c2ca,..._0x10635e}:_0x10635e);if(_0x592d7e['length']<=0x1)return{'suppressTaskNotification':![],'notified':![]};if(_0x298bc6['completionNotificationReady']!==!![])return{'suppressTaskNotification':!![],'notified':![],'pending':!![]};const _0x9e5a77=_0x31af1f();if(!NotificationManager['shouldNotifyGroup'](_0xc41736,_0x592d7e,_0x9e5a77))return{'suppressTaskNotification':!![],'notified':![]};return await NotificationManager['notifyTaskGroupComplete'](_0x298bc6,_0x592d7e),NotificationManager['markGroupNotified'](_0xc41736),_0x592d7e['forEach'](_0x23d8d2=>{_0x23d8d2['taskId']&&(NotificationManager['markNotified'](_0x23d8d2['taskId']),_0x9e5a77['delete'](_0x23d8d2['taskId']),onTaskNotified(_0x23d8d2));}),{'suppressTaskNotification':!![],'notified':!![]};}catch(_0xab0438){return logger['error']('Failed\x20to\x20check\x20task\x20group\x20notification\x20state:',_0xab0438),{'suppressTaskNotification':![],'notified':![]};}})());return _0x8c84e9['promise']=_0x27ac7d['finally'](()=>{_0x4ce6fd['get'](_0xc41736)===_0x8c84e9&&_0x4ce6fd['delete'](_0xc41736);}),_0x4ce6fd['set'](_0xc41736,_0x8c84e9),_0x8c84e9['promise'];}async function _0x257ea4(_0x1ac872){if(!_0x1ac872?.['groupId']||_0x1ac872['isTerminal']!==!![]||_0x1ac872['completionNotificationReady']!==!![])return;if(!NotificationManager['isGroupMode'](_0x3b7356()))return;await _0x953e2e({'groupId':_0x1ac872['groupId']});}return{'maybeNotifyGroupCompletionForTask':_0x953e2e,'maybeNotifyGroupCompletionFromStatusSignal':_0x257ea4};}