'use strict';
import { createError } from '../../../../../fd-toolbox/errors/errors.js';
import { getCurrentUrl } from '../../../../meta/server/web/current-url.js';
import { postBaseApi } from '../../../../../fd-toolbox/api/base-api.js';
import { webSockets } from './socket/web-sockets.js';
import { webSocketMethods } from '../../../../fd-app-toolbox/constants/web-socket-methods.js';
import { createNotification } from '../notifications/notification-db.js';
import { getCurrentWorkspaceId } from '../../../../meta/server/providers/current-workspace-id-provider.js';
import { getNewUuid } from '../../../../../fd-toolbox/uuids.js';
import { getUserId } from '../../../../meta/server/auth/users/current-user-id-provider.js';
import { getNowUtc } from '../../../../../fd-toolbox/dates/date-time.js';
import { buildUrl } from '../../../../../fd-toolbox/url/urls.js';

var __defProp=Object['defineProperty'],__name=(_0x3eb935,_0x48a220)=>__defProp(_0x3eb935,'name',{'value':_0x48a220,'configurable':!![]});async function sendWebsocketNotification(_0x3a5cf5,_0x609ab0,_0x41489a){const _0x34ca91=new URL(buildUrl(webSockets['sendUrl'],void(0x73f+0x1668+-0x1da7),getSocketIoUrl()));return _0x34ca91['searchParams']['set'](webSockets['methodParam'],_0x3a5cf5),_0x34ca91['searchParams']['set'](webSockets['userIdParam'],_0x609ab0),postBaseApi(_0x34ca91['href'],_0x41489a);}__name(sendWebsocketNotification,'sendWebsocketNotification');async function sendNotification(_0x49330c,_0x2a7f1f,_0x417bd3,_0x2df1af){const _0x5f0b65={'message':_0x2a7f1f,'description':_0x417bd3,'isRead':![],'userId':_0x49330c,'workspaceId':await getCurrentWorkspaceId(),'id':getNewUuid(),'createdDate':getNowUtc(),'modifiedDate':getNowUtc(),'createdByUserId':await getUserId(),'modifiedByUserId':await getUserId(),'isExternal':_0x2df1af};await sendWebsocketNotification(webSocketMethods['notification'],_0x49330c,_0x5f0b65),await createNotification(_0x5f0b65);}__name(sendNotification,'sendNotification');function getSocketIoUrl(){const _0x351c7c=getCurrentUrl();if(!_0x351c7c)throw createError(webSockets['socketUrlIsNotSet']);return _0x351c7c['origin'];}__name(getSocketIoUrl,'getSocketIoUrl');

export { sendNotification, sendWebsocketNotification };
