{"version":3,"sources":["node_modules/phoenix/priv/static/phoenix.mjs","apps/web-portal/src/app/socket.service.ts"],"sourcesContent":["// js/phoenix/utils.js\nvar closure = value => {\n if (typeof value === \"function\") {\n return value;\n } else {\n let closure2 = function () {\n return value;\n };\n return closure2;\n }\n};\n\n// js/phoenix/constants.js\nvar globalSelf = typeof self !== \"undefined\" ? self : null;\nvar phxWindow = typeof window !== \"undefined\" ? window : null;\nvar global = globalSelf || phxWindow || global;\nvar DEFAULT_VSN = \"2.0.0\";\nvar SOCKET_STATES = {\n connecting: 0,\n open: 1,\n closing: 2,\n closed: 3\n};\nvar DEFAULT_TIMEOUT = 1e4;\nvar WS_CLOSE_NORMAL = 1e3;\nvar CHANNEL_STATES = {\n closed: \"closed\",\n errored: \"errored\",\n joined: \"joined\",\n joining: \"joining\",\n leaving: \"leaving\"\n};\nvar CHANNEL_EVENTS = {\n close: \"phx_close\",\n error: \"phx_error\",\n join: \"phx_join\",\n reply: \"phx_reply\",\n leave: \"phx_leave\"\n};\nvar TRANSPORTS = {\n longpoll: \"longpoll\",\n websocket: \"websocket\"\n};\nvar XHR_STATES = {\n complete: 4\n};\n\n// js/phoenix/push.js\nvar Push = class {\n constructor(channel, event, payload, timeout) {\n this.channel = channel;\n this.event = event;\n this.payload = payload || function () {\n return {};\n };\n this.receivedResp = null;\n this.timeout = timeout;\n this.timeoutTimer = null;\n this.recHooks = [];\n this.sent = false;\n }\n /**\n *\n * @param {number} timeout\n */\n resend(timeout) {\n this.timeout = timeout;\n this.reset();\n this.send();\n }\n /**\n *\n */\n send() {\n if (this.hasReceived(\"timeout\")) {\n return;\n }\n this.startTimeout();\n this.sent = true;\n this.channel.socket.push({\n topic: this.channel.topic,\n event: this.event,\n payload: this.payload(),\n ref: this.ref,\n join_ref: this.channel.joinRef()\n });\n }\n /**\n *\n * @param {*} status\n * @param {*} callback\n */\n receive(status, callback) {\n if (this.hasReceived(status)) {\n callback(this.receivedResp.response);\n }\n this.recHooks.push({\n status,\n callback\n });\n return this;\n }\n /**\n * @private\n */\n reset() {\n this.cancelRefEvent();\n this.ref = null;\n this.refEvent = null;\n this.receivedResp = null;\n this.sent = false;\n }\n /**\n * @private\n */\n matchReceive({\n status,\n response,\n _ref\n }) {\n this.recHooks.filter(h => h.status === status).forEach(h => h.callback(response));\n }\n /**\n * @private\n */\n cancelRefEvent() {\n if (!this.refEvent) {\n return;\n }\n this.channel.off(this.refEvent);\n }\n /**\n * @private\n */\n cancelTimeout() {\n clearTimeout(this.timeoutTimer);\n this.timeoutTimer = null;\n }\n /**\n * @private\n */\n startTimeout() {\n if (this.timeoutTimer) {\n this.cancelTimeout();\n }\n this.ref = this.channel.socket.makeRef();\n this.refEvent = this.channel.replyEventName(this.ref);\n this.channel.on(this.refEvent, payload => {\n this.cancelRefEvent();\n this.cancelTimeout();\n this.receivedResp = payload;\n this.matchReceive(payload);\n });\n this.timeoutTimer = setTimeout(() => {\n this.trigger(\"timeout\", {});\n }, this.timeout);\n }\n /**\n * @private\n */\n hasReceived(status) {\n return this.receivedResp && this.receivedResp.status === status;\n }\n /**\n * @private\n */\n trigger(status, response) {\n this.channel.trigger(this.refEvent, {\n status,\n response\n });\n }\n};\n\n// js/phoenix/timer.js\nvar Timer = class {\n constructor(callback, timerCalc) {\n this.callback = callback;\n this.timerCalc = timerCalc;\n this.timer = null;\n this.tries = 0;\n }\n reset() {\n this.tries = 0;\n clearTimeout(this.timer);\n }\n /**\n * Cancels any previous scheduleTimeout and schedules callback\n */\n scheduleTimeout() {\n clearTimeout(this.timer);\n this.timer = setTimeout(() => {\n this.tries = this.tries + 1;\n this.callback();\n }, this.timerCalc(this.tries + 1));\n }\n};\n\n// js/phoenix/channel.js\nvar Channel = class {\n constructor(topic, params, socket) {\n this.state = CHANNEL_STATES.closed;\n this.topic = topic;\n this.params = closure(params || {});\n this.socket = socket;\n this.bindings = [];\n this.bindingRef = 0;\n this.timeout = this.socket.timeout;\n this.joinedOnce = false;\n this.joinPush = new Push(this, CHANNEL_EVENTS.join, this.params, this.timeout);\n this.pushBuffer = [];\n this.stateChangeRefs = [];\n this.rejoinTimer = new Timer(() => {\n if (this.socket.isConnected()) {\n this.rejoin();\n }\n }, this.socket.rejoinAfterMs);\n this.stateChangeRefs.push(this.socket.onError(() => this.rejoinTimer.reset()));\n this.stateChangeRefs.push(this.socket.onOpen(() => {\n this.rejoinTimer.reset();\n if (this.isErrored()) {\n this.rejoin();\n }\n }));\n this.joinPush.receive(\"ok\", () => {\n this.state = CHANNEL_STATES.joined;\n this.rejoinTimer.reset();\n this.pushBuffer.forEach(pushEvent => pushEvent.send());\n this.pushBuffer = [];\n });\n this.joinPush.receive(\"error\", () => {\n this.state = CHANNEL_STATES.errored;\n if (this.socket.isConnected()) {\n this.rejoinTimer.scheduleTimeout();\n }\n });\n this.onClose(() => {\n this.rejoinTimer.reset();\n if (this.socket.hasLogger()) this.socket.log(\"channel\", `close ${this.topic} ${this.joinRef()}`);\n this.state = CHANNEL_STATES.closed;\n this.socket.remove(this);\n });\n this.onError(reason => {\n if (this.socket.hasLogger()) this.socket.log(\"channel\", `error ${this.topic}`, reason);\n if (this.isJoining()) {\n this.joinPush.reset();\n }\n this.state = CHANNEL_STATES.errored;\n if (this.socket.isConnected()) {\n this.rejoinTimer.scheduleTimeout();\n }\n });\n this.joinPush.receive(\"timeout\", () => {\n if (this.socket.hasLogger()) this.socket.log(\"channel\", `timeout ${this.topic} (${this.joinRef()})`, this.joinPush.timeout);\n let leavePush = new Push(this, CHANNEL_EVENTS.leave, closure({}), this.timeout);\n leavePush.send();\n this.state = CHANNEL_STATES.errored;\n this.joinPush.reset();\n if (this.socket.isConnected()) {\n this.rejoinTimer.scheduleTimeout();\n }\n });\n this.on(CHANNEL_EVENTS.reply, (payload, ref) => {\n this.trigger(this.replyEventName(ref), payload);\n });\n }\n /**\n * Join the channel\n * @param {integer} timeout\n * @returns {Push}\n */\n join(timeout = this.timeout) {\n if (this.joinedOnce) {\n throw new Error(\"tried to join multiple times. 'join' can only be called a single time per channel instance\");\n } else {\n this.timeout = timeout;\n this.joinedOnce = true;\n this.rejoin();\n return this.joinPush;\n }\n }\n /**\n * Hook into channel close\n * @param {Function} callback\n */\n onClose(callback) {\n this.on(CHANNEL_EVENTS.close, callback);\n }\n /**\n * Hook into channel errors\n * @param {Function} callback\n */\n onError(callback) {\n return this.on(CHANNEL_EVENTS.error, reason => callback(reason));\n }\n /**\n * Subscribes on channel events\n *\n * Subscription returns a ref counter, which can be used later to\n * unsubscribe the exact event listener\n *\n * @example\n * const ref1 = channel.on(\"event\", do_stuff)\n * const ref2 = channel.on(\"event\", do_other_stuff)\n * channel.off(\"event\", ref1)\n * // Since unsubscription, do_stuff won't fire,\n * // while do_other_stuff will keep firing on the \"event\"\n *\n * @param {string} event\n * @param {Function} callback\n * @returns {integer} ref\n */\n on(event, callback) {\n let ref = this.bindingRef++;\n this.bindings.push({\n event,\n ref,\n callback\n });\n return ref;\n }\n /**\n * Unsubscribes off of channel events\n *\n * Use the ref returned from a channel.on() to unsubscribe one\n * handler, or pass nothing for the ref to unsubscribe all\n * handlers for the given event.\n *\n * @example\n * // Unsubscribe the do_stuff handler\n * const ref1 = channel.on(\"event\", do_stuff)\n * channel.off(\"event\", ref1)\n *\n * // Unsubscribe all handlers from event\n * channel.off(\"event\")\n *\n * @param {string} event\n * @param {integer} ref\n */\n off(event, ref) {\n this.bindings = this.bindings.filter(bind => {\n return !(bind.event === event && (typeof ref === \"undefined\" || ref === bind.ref));\n });\n }\n /**\n * @private\n */\n canPush() {\n return this.socket.isConnected() && this.isJoined();\n }\n /**\n * Sends a message `event` to phoenix with the payload `payload`.\n * Phoenix receives this in the `handle_in(event, payload, socket)`\n * function. if phoenix replies or it times out (default 10000ms),\n * then optionally the reply can be received.\n *\n * @example\n * channel.push(\"event\")\n * .receive(\"ok\", payload => console.log(\"phoenix replied:\", payload))\n * .receive(\"error\", err => console.log(\"phoenix errored\", err))\n * .receive(\"timeout\", () => console.log(\"timed out pushing\"))\n * @param {string} event\n * @param {Object} payload\n * @param {number} [timeout]\n * @returns {Push}\n */\n push(event, payload, timeout = this.timeout) {\n payload = payload || {};\n if (!this.joinedOnce) {\n throw new Error(`tried to push '${event}' to '${this.topic}' before joining. Use channel.join() before pushing events`);\n }\n let pushEvent = new Push(this, event, function () {\n return payload;\n }, timeout);\n if (this.canPush()) {\n pushEvent.send();\n } else {\n pushEvent.startTimeout();\n this.pushBuffer.push(pushEvent);\n }\n return pushEvent;\n }\n /** Leaves the channel\n *\n * Unsubscribes from server events, and\n * instructs channel to terminate on server\n *\n * Triggers onClose() hooks\n *\n * To receive leave acknowledgements, use the `receive`\n * hook to bind to the server ack, ie:\n *\n * @example\n * channel.leave().receive(\"ok\", () => alert(\"left!\") )\n *\n * @param {integer} timeout\n * @returns {Push}\n */\n leave(timeout = this.timeout) {\n this.rejoinTimer.reset();\n this.joinPush.cancelTimeout();\n this.state = CHANNEL_STATES.leaving;\n let onClose = () => {\n if (this.socket.hasLogger()) this.socket.log(\"channel\", `leave ${this.topic}`);\n this.trigger(CHANNEL_EVENTS.close, \"leave\");\n };\n let leavePush = new Push(this, CHANNEL_EVENTS.leave, closure({}), timeout);\n leavePush.receive(\"ok\", () => onClose()).receive(\"timeout\", () => onClose());\n leavePush.send();\n if (!this.canPush()) {\n leavePush.trigger(\"ok\", {});\n }\n return leavePush;\n }\n /**\n * Overridable message hook\n *\n * Receives all events for specialized message handling\n * before dispatching to the channel callbacks.\n *\n * Must return the payload, modified or unmodified\n * @param {string} event\n * @param {Object} payload\n * @param {integer} ref\n * @returns {Object}\n */\n onMessage(_event, payload, _ref) {\n return payload;\n }\n /**\n * @private\n */\n isMember(topic, event, payload, joinRef) {\n if (this.topic !== topic) {\n return false;\n }\n if (joinRef && joinRef !== this.joinRef()) {\n if (this.socket.hasLogger()) this.socket.log(\"channel\", \"dropping outdated message\", {\n topic,\n event,\n payload,\n joinRef\n });\n return false;\n } else {\n return true;\n }\n }\n /**\n * @private\n */\n joinRef() {\n return this.joinPush.ref;\n }\n /**\n * @private\n */\n rejoin(timeout = this.timeout) {\n if (this.isLeaving()) {\n return;\n }\n this.socket.leaveOpenTopic(this.topic);\n this.state = CHANNEL_STATES.joining;\n this.joinPush.resend(timeout);\n }\n /**\n * @private\n */\n trigger(event, payload, ref, joinRef) {\n let handledPayload = this.onMessage(event, payload, ref, joinRef);\n if (payload && !handledPayload) {\n throw new Error(\"channel onMessage callbacks must return the payload, modified or unmodified\");\n }\n let eventBindings = this.bindings.filter(bind => bind.event === event);\n for (let i = 0; i < eventBindings.length; i++) {\n let bind = eventBindings[i];\n bind.callback(handledPayload, ref, joinRef || this.joinRef());\n }\n }\n /**\n * @private\n */\n replyEventName(ref) {\n return `chan_reply_${ref}`;\n }\n /**\n * @private\n */\n isClosed() {\n return this.state === CHANNEL_STATES.closed;\n }\n /**\n * @private\n */\n isErrored() {\n return this.state === CHANNEL_STATES.errored;\n }\n /**\n * @private\n */\n isJoined() {\n return this.state === CHANNEL_STATES.joined;\n }\n /**\n * @private\n */\n isJoining() {\n return this.state === CHANNEL_STATES.joining;\n }\n /**\n * @private\n */\n isLeaving() {\n return this.state === CHANNEL_STATES.leaving;\n }\n};\n\n// js/phoenix/ajax.js\nvar Ajax = class {\n static request(method, endPoint, accept, body, timeout, ontimeout, callback) {\n if (global.XDomainRequest) {\n let req = new global.XDomainRequest();\n return this.xdomainRequest(req, method, endPoint, body, timeout, ontimeout, callback);\n } else {\n let req = new global.XMLHttpRequest();\n return this.xhrRequest(req, method, endPoint, accept, body, timeout, ontimeout, callback);\n }\n }\n static xdomainRequest(req, method, endPoint, body, timeout, ontimeout, callback) {\n req.timeout = timeout;\n req.open(method, endPoint);\n req.onload = () => {\n let response = this.parseJSON(req.responseText);\n callback && callback(response);\n };\n if (ontimeout) {\n req.ontimeout = ontimeout;\n }\n req.onprogress = () => {};\n req.send(body);\n return req;\n }\n static xhrRequest(req, method, endPoint, accept, body, timeout, ontimeout, callback) {\n req.open(method, endPoint, true);\n req.timeout = timeout;\n req.setRequestHeader(\"Content-Type\", accept);\n req.onerror = () => callback && callback(null);\n req.onreadystatechange = () => {\n if (req.readyState === XHR_STATES.complete && callback) {\n let response = this.parseJSON(req.responseText);\n callback(response);\n }\n };\n if (ontimeout) {\n req.ontimeout = ontimeout;\n }\n req.send(body);\n return req;\n }\n static parseJSON(resp) {\n if (!resp || resp === \"\") {\n return null;\n }\n try {\n return JSON.parse(resp);\n } catch (e) {\n console && console.log(\"failed to parse JSON response\", resp);\n return null;\n }\n }\n static serialize(obj, parentKey) {\n let queryStr = [];\n for (var key in obj) {\n if (!Object.prototype.hasOwnProperty.call(obj, key)) {\n continue;\n }\n let paramKey = parentKey ? `${parentKey}[${key}]` : key;\n let paramVal = obj[key];\n if (typeof paramVal === \"object\") {\n queryStr.push(this.serialize(paramVal, paramKey));\n } else {\n queryStr.push(encodeURIComponent(paramKey) + \"=\" + encodeURIComponent(paramVal));\n }\n }\n return queryStr.join(\"&\");\n }\n static appendParams(url, params) {\n if (Object.keys(params).length === 0) {\n return url;\n }\n let prefix = url.match(/\\?/) ? \"&\" : \"?\";\n return `${url}${prefix}${this.serialize(params)}`;\n }\n};\n\n// js/phoenix/longpoll.js\nvar arrayBufferToBase64 = buffer => {\n let binary = \"\";\n let bytes = new Uint8Array(buffer);\n let len = bytes.byteLength;\n for (let i = 0; i < len; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n};\nvar LongPoll = class {\n constructor(endPoint) {\n this.endPoint = null;\n this.token = null;\n this.skipHeartbeat = true;\n this.reqs = /* @__PURE__ */new Set();\n this.awaitingBatchAck = false;\n this.currentBatch = null;\n this.currentBatchTimer = null;\n this.batchBuffer = [];\n this.onopen = function () {};\n this.onerror = function () {};\n this.onmessage = function () {};\n this.onclose = function () {};\n this.pollEndpoint = this.normalizeEndpoint(endPoint);\n this.readyState = SOCKET_STATES.connecting;\n setTimeout(() => this.poll(), 0);\n }\n normalizeEndpoint(endPoint) {\n return endPoint.replace(\"ws://\", \"http://\").replace(\"wss://\", \"https://\").replace(new RegExp(\"(.*)/\" + TRANSPORTS.websocket), \"$1/\" + TRANSPORTS.longpoll);\n }\n endpointURL() {\n return Ajax.appendParams(this.pollEndpoint, {\n token: this.token\n });\n }\n closeAndRetry(code, reason, wasClean) {\n this.close(code, reason, wasClean);\n this.readyState = SOCKET_STATES.connecting;\n }\n ontimeout() {\n this.onerror(\"timeout\");\n this.closeAndRetry(1005, \"timeout\", false);\n }\n isActive() {\n return this.readyState === SOCKET_STATES.open || this.readyState === SOCKET_STATES.connecting;\n }\n poll() {\n this.ajax(\"GET\", \"application/json\", null, () => this.ontimeout(), resp => {\n if (resp) {\n var {\n status,\n token,\n messages\n } = resp;\n this.token = token;\n } else {\n status = 0;\n }\n switch (status) {\n case 200:\n messages.forEach(msg => {\n setTimeout(() => this.onmessage({\n data: msg\n }), 0);\n });\n this.poll();\n break;\n case 204:\n this.poll();\n break;\n case 410:\n this.readyState = SOCKET_STATES.open;\n this.onopen({});\n this.poll();\n break;\n case 403:\n this.onerror(403);\n this.close(1008, \"forbidden\", false);\n break;\n case 0:\n case 500:\n this.onerror(500);\n this.closeAndRetry(1011, \"internal server error\", 500);\n break;\n default:\n throw new Error(`unhandled poll status ${status}`);\n }\n });\n }\n // we collect all pushes within the current event loop by\n // setTimeout 0, which optimizes back-to-back procedural\n // pushes against an empty buffer\n send(body) {\n if (typeof body !== \"string\") {\n body = arrayBufferToBase64(body);\n }\n if (this.currentBatch) {\n this.currentBatch.push(body);\n } else if (this.awaitingBatchAck) {\n this.batchBuffer.push(body);\n } else {\n this.currentBatch = [body];\n this.currentBatchTimer = setTimeout(() => {\n this.batchSend(this.currentBatch);\n this.currentBatch = null;\n }, 0);\n }\n }\n batchSend(messages) {\n this.awaitingBatchAck = true;\n this.ajax(\"POST\", \"application/x-ndjson\", messages.join(\"\\n\"), () => this.onerror(\"timeout\"), resp => {\n this.awaitingBatchAck = false;\n if (!resp || resp.status !== 200) {\n this.onerror(resp && resp.status);\n this.closeAndRetry(1011, \"internal server error\", false);\n } else if (this.batchBuffer.length > 0) {\n this.batchSend(this.batchBuffer);\n this.batchBuffer = [];\n }\n });\n }\n close(code, reason, wasClean) {\n for (let req of this.reqs) {\n req.abort();\n }\n this.readyState = SOCKET_STATES.closed;\n let opts = Object.assign({\n code: 1e3,\n reason: void 0,\n wasClean: true\n }, {\n code,\n reason,\n wasClean\n });\n this.batchBuffer = [];\n clearTimeout(this.currentBatchTimer);\n this.currentBatchTimer = null;\n if (typeof CloseEvent !== \"undefined\") {\n this.onclose(new CloseEvent(\"close\", opts));\n } else {\n this.onclose(opts);\n }\n }\n ajax(method, contentType, body, onCallerTimeout, callback) {\n let req;\n let ontimeout = () => {\n this.reqs.delete(req);\n onCallerTimeout();\n };\n req = Ajax.request(method, this.endpointURL(), contentType, body, this.timeout, ontimeout, resp => {\n this.reqs.delete(req);\n if (this.isActive()) {\n callback(resp);\n }\n });\n this.reqs.add(req);\n }\n};\n\n// js/phoenix/presence.js\nvar Presence = class {\n constructor(channel, opts = {}) {\n let events = opts.events || {\n state: \"presence_state\",\n diff: \"presence_diff\"\n };\n this.state = {};\n this.pendingDiffs = [];\n this.channel = channel;\n this.joinRef = null;\n this.caller = {\n onJoin: function () {},\n onLeave: function () {},\n onSync: function () {}\n };\n this.channel.on(events.state, newState => {\n let {\n onJoin,\n onLeave,\n onSync\n } = this.caller;\n this.joinRef = this.channel.joinRef();\n this.state = Presence.syncState(this.state, newState, onJoin, onLeave);\n this.pendingDiffs.forEach(diff => {\n this.state = Presence.syncDiff(this.state, diff, onJoin, onLeave);\n });\n this.pendingDiffs = [];\n onSync();\n });\n this.channel.on(events.diff, diff => {\n let {\n onJoin,\n onLeave,\n onSync\n } = this.caller;\n if (this.inPendingSyncState()) {\n this.pendingDiffs.push(diff);\n } else {\n this.state = Presence.syncDiff(this.state, diff, onJoin, onLeave);\n onSync();\n }\n });\n }\n onJoin(callback) {\n this.caller.onJoin = callback;\n }\n onLeave(callback) {\n this.caller.onLeave = callback;\n }\n onSync(callback) {\n this.caller.onSync = callback;\n }\n list(by) {\n return Presence.list(this.state, by);\n }\n inPendingSyncState() {\n return !this.joinRef || this.joinRef !== this.channel.joinRef();\n }\n // lower-level public static API\n /**\n * Used to sync the list of presences on the server\n * with the client's state. An optional `onJoin` and `onLeave` callback can\n * be provided to react to changes in the client's local presences across\n * disconnects and reconnects with the server.\n *\n * @returns {Presence}\n */\n static syncState(currentState, newState, onJoin, onLeave) {\n let state = this.clone(currentState);\n let joins = {};\n let leaves = {};\n this.map(state, (key, presence) => {\n if (!newState[key]) {\n leaves[key] = presence;\n }\n });\n this.map(newState, (key, newPresence) => {\n let currentPresence = state[key];\n if (currentPresence) {\n let newRefs = newPresence.metas.map(m => m.phx_ref);\n let curRefs = currentPresence.metas.map(m => m.phx_ref);\n let joinedMetas = newPresence.metas.filter(m => curRefs.indexOf(m.phx_ref) < 0);\n let leftMetas = currentPresence.metas.filter(m => newRefs.indexOf(m.phx_ref) < 0);\n if (joinedMetas.length > 0) {\n joins[key] = newPresence;\n joins[key].metas = joinedMetas;\n }\n if (leftMetas.length > 0) {\n leaves[key] = this.clone(currentPresence);\n leaves[key].metas = leftMetas;\n }\n } else {\n joins[key] = newPresence;\n }\n });\n return this.syncDiff(state, {\n joins,\n leaves\n }, onJoin, onLeave);\n }\n /**\n *\n * Used to sync a diff of presence join and leave\n * events from the server, as they happen. Like `syncState`, `syncDiff`\n * accepts optional `onJoin` and `onLeave` callbacks to react to a user\n * joining or leaving from a device.\n *\n * @returns {Presence}\n */\n static syncDiff(state, diff, onJoin, onLeave) {\n let {\n joins,\n leaves\n } = this.clone(diff);\n if (!onJoin) {\n onJoin = function () {};\n }\n if (!onLeave) {\n onLeave = function () {};\n }\n this.map(joins, (key, newPresence) => {\n let currentPresence = state[key];\n state[key] = this.clone(newPresence);\n if (currentPresence) {\n let joinedRefs = state[key].metas.map(m => m.phx_ref);\n let curMetas = currentPresence.metas.filter(m => joinedRefs.indexOf(m.phx_ref) < 0);\n state[key].metas.unshift(...curMetas);\n }\n onJoin(key, currentPresence, newPresence);\n });\n this.map(leaves, (key, leftPresence) => {\n let currentPresence = state[key];\n if (!currentPresence) {\n return;\n }\n let refsToRemove = leftPresence.metas.map(m => m.phx_ref);\n currentPresence.metas = currentPresence.metas.filter(p => {\n return refsToRemove.indexOf(p.phx_ref) < 0;\n });\n onLeave(key, currentPresence, leftPresence);\n if (currentPresence.metas.length === 0) {\n delete state[key];\n }\n });\n return state;\n }\n /**\n * Returns the array of presences, with selected metadata.\n *\n * @param {Object} presences\n * @param {Function} chooser\n *\n * @returns {Presence}\n */\n static list(presences, chooser) {\n if (!chooser) {\n chooser = function (key, pres) {\n return pres;\n };\n }\n return this.map(presences, (key, presence) => {\n return chooser(key, presence);\n });\n }\n // private\n static map(obj, func) {\n return Object.getOwnPropertyNames(obj).map(key => func(key, obj[key]));\n }\n static clone(obj) {\n return JSON.parse(JSON.stringify(obj));\n }\n};\n\n// js/phoenix/serializer.js\nvar serializer_default = {\n HEADER_LENGTH: 1,\n META_LENGTH: 4,\n KINDS: {\n push: 0,\n reply: 1,\n broadcast: 2\n },\n encode(msg, callback) {\n if (msg.payload.constructor === ArrayBuffer) {\n return callback(this.binaryEncode(msg));\n } else {\n let payload = [msg.join_ref, msg.ref, msg.topic, msg.event, msg.payload];\n return callback(JSON.stringify(payload));\n }\n },\n decode(rawPayload, callback) {\n if (rawPayload.constructor === ArrayBuffer) {\n return callback(this.binaryDecode(rawPayload));\n } else {\n let [join_ref, ref, topic, event, payload] = JSON.parse(rawPayload);\n return callback({\n join_ref,\n ref,\n topic,\n event,\n payload\n });\n }\n },\n // private\n binaryEncode(message) {\n let {\n join_ref,\n ref,\n event,\n topic,\n payload\n } = message;\n let metaLength = this.META_LENGTH + join_ref.length + ref.length + topic.length + event.length;\n let header = new ArrayBuffer(this.HEADER_LENGTH + metaLength);\n let view = new DataView(header);\n let offset = 0;\n view.setUint8(offset++, this.KINDS.push);\n view.setUint8(offset++, join_ref.length);\n view.setUint8(offset++, ref.length);\n view.setUint8(offset++, topic.length);\n view.setUint8(offset++, event.length);\n Array.from(join_ref, char => view.setUint8(offset++, char.charCodeAt(0)));\n Array.from(ref, char => view.setUint8(offset++, char.charCodeAt(0)));\n Array.from(topic, char => view.setUint8(offset++, char.charCodeAt(0)));\n Array.from(event, char => view.setUint8(offset++, char.charCodeAt(0)));\n var combined = new Uint8Array(header.byteLength + payload.byteLength);\n combined.set(new Uint8Array(header), 0);\n combined.set(new Uint8Array(payload), header.byteLength);\n return combined.buffer;\n },\n binaryDecode(buffer) {\n let view = new DataView(buffer);\n let kind = view.getUint8(0);\n let decoder = new TextDecoder();\n switch (kind) {\n case this.KINDS.push:\n return this.decodePush(buffer, view, decoder);\n case this.KINDS.reply:\n return this.decodeReply(buffer, view, decoder);\n case this.KINDS.broadcast:\n return this.decodeBroadcast(buffer, view, decoder);\n }\n },\n decodePush(buffer, view, decoder) {\n let joinRefSize = view.getUint8(1);\n let topicSize = view.getUint8(2);\n let eventSize = view.getUint8(3);\n let offset = this.HEADER_LENGTH + this.META_LENGTH - 1;\n let joinRef = decoder.decode(buffer.slice(offset, offset + joinRefSize));\n offset = offset + joinRefSize;\n let topic = decoder.decode(buffer.slice(offset, offset + topicSize));\n offset = offset + topicSize;\n let event = decoder.decode(buffer.slice(offset, offset + eventSize));\n offset = offset + eventSize;\n let data = buffer.slice(offset, buffer.byteLength);\n return {\n join_ref: joinRef,\n ref: null,\n topic,\n event,\n payload: data\n };\n },\n decodeReply(buffer, view, decoder) {\n let joinRefSize = view.getUint8(1);\n let refSize = view.getUint8(2);\n let topicSize = view.getUint8(3);\n let eventSize = view.getUint8(4);\n let offset = this.HEADER_LENGTH + this.META_LENGTH;\n let joinRef = decoder.decode(buffer.slice(offset, offset + joinRefSize));\n offset = offset + joinRefSize;\n let ref = decoder.decode(buffer.slice(offset, offset + refSize));\n offset = offset + refSize;\n let topic = decoder.decode(buffer.slice(offset, offset + topicSize));\n offset = offset + topicSize;\n let event = decoder.decode(buffer.slice(offset, offset + eventSize));\n offset = offset + eventSize;\n let data = buffer.slice(offset, buffer.byteLength);\n let payload = {\n status: event,\n response: data\n };\n return {\n join_ref: joinRef,\n ref,\n topic,\n event: CHANNEL_EVENTS.reply,\n payload\n };\n },\n decodeBroadcast(buffer, view, decoder) {\n let topicSize = view.getUint8(1);\n let eventSize = view.getUint8(2);\n let offset = this.HEADER_LENGTH + 2;\n let topic = decoder.decode(buffer.slice(offset, offset + topicSize));\n offset = offset + topicSize;\n let event = decoder.decode(buffer.slice(offset, offset + eventSize));\n offset = offset + eventSize;\n let data = buffer.slice(offset, buffer.byteLength);\n return {\n join_ref: null,\n ref: null,\n topic,\n event,\n payload: data\n };\n }\n};\n\n// js/phoenix/socket.js\nvar Socket = class {\n constructor(endPoint, opts = {}) {\n this.stateChangeCallbacks = {\n open: [],\n close: [],\n error: [],\n message: []\n };\n this.channels = [];\n this.sendBuffer = [];\n this.ref = 0;\n this.timeout = opts.timeout || DEFAULT_TIMEOUT;\n this.transport = opts.transport || global.WebSocket || LongPoll;\n this.primaryPassedHealthCheck = false;\n this.longPollFallbackMs = opts.longPollFallbackMs;\n this.fallbackTimer = null;\n this.sessionStore = opts.sessionStorage || global && global.sessionStorage;\n this.establishedConnections = 0;\n this.defaultEncoder = serializer_default.encode.bind(serializer_default);\n this.defaultDecoder = serializer_default.decode.bind(serializer_default);\n this.closeWasClean = false;\n this.binaryType = opts.binaryType || \"arraybuffer\";\n this.connectClock = 1;\n if (this.transport !== LongPoll) {\n this.encode = opts.encode || this.defaultEncoder;\n this.decode = opts.decode || this.defaultDecoder;\n } else {\n this.encode = this.defaultEncoder;\n this.decode = this.defaultDecoder;\n }\n let awaitingConnectionOnPageShow = null;\n if (phxWindow && phxWindow.addEventListener) {\n phxWindow.addEventListener(\"pagehide\", _e => {\n if (this.conn) {\n this.disconnect();\n awaitingConnectionOnPageShow = this.connectClock;\n }\n });\n phxWindow.addEventListener(\"pageshow\", _e => {\n if (awaitingConnectionOnPageShow === this.connectClock) {\n awaitingConnectionOnPageShow = null;\n this.connect();\n }\n });\n }\n this.heartbeatIntervalMs = opts.heartbeatIntervalMs || 3e4;\n this.rejoinAfterMs = tries => {\n if (opts.rejoinAfterMs) {\n return opts.rejoinAfterMs(tries);\n } else {\n return [1e3, 2e3, 5e3][tries - 1] || 1e4;\n }\n };\n this.reconnectAfterMs = tries => {\n if (opts.reconnectAfterMs) {\n return opts.reconnectAfterMs(tries);\n } else {\n return [10, 50, 100, 150, 200, 250, 500, 1e3, 2e3][tries - 1] || 5e3;\n }\n };\n this.logger = opts.logger || null;\n if (!this.logger && opts.debug) {\n this.logger = (kind, msg, data) => {\n console.log(`${kind}: ${msg}`, data);\n };\n }\n this.longpollerTimeout = opts.longpollerTimeout || 2e4;\n this.params = closure(opts.params || {});\n this.endPoint = `${endPoint}/${TRANSPORTS.websocket}`;\n this.vsn = opts.vsn || DEFAULT_VSN;\n this.heartbeatTimeoutTimer = null;\n this.heartbeatTimer = null;\n this.pendingHeartbeatRef = null;\n this.reconnectTimer = new Timer(() => {\n this.teardown(() => this.connect());\n }, this.reconnectAfterMs);\n }\n /**\n * Returns the LongPoll transport reference\n */\n getLongPollTransport() {\n return LongPoll;\n }\n /**\n * Disconnects and replaces the active transport\n *\n * @param {Function} newTransport - The new transport class to instantiate\n *\n */\n replaceTransport(newTransport) {\n this.connectClock++;\n this.closeWasClean = true;\n clearTimeout(this.fallbackTimer);\n this.reconnectTimer.reset();\n if (this.conn) {\n this.conn.close();\n this.conn = null;\n }\n this.transport = newTransport;\n }\n /**\n * Returns the socket protocol\n *\n * @returns {string}\n */\n protocol() {\n return location.protocol.match(/^https/) ? \"wss\" : \"ws\";\n }\n /**\n * The fully qualified socket url\n *\n * @returns {string}\n */\n endPointURL() {\n let uri = Ajax.appendParams(Ajax.appendParams(this.endPoint, this.params()), {\n vsn: this.vsn\n });\n if (uri.charAt(0) !== \"/\") {\n return uri;\n }\n if (uri.charAt(1) === \"/\") {\n return `${this.protocol()}:${uri}`;\n }\n return `${this.protocol()}://${location.host}${uri}`;\n }\n /**\n * Disconnects the socket\n *\n * See https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#Status_codes for valid status codes.\n *\n * @param {Function} callback - Optional callback which is called after socket is disconnected.\n * @param {integer} code - A status code for disconnection (Optional).\n * @param {string} reason - A textual description of the reason to disconnect. (Optional)\n */\n disconnect(callback, code, reason) {\n this.connectClock++;\n this.closeWasClean = true;\n clearTimeout(this.fallbackTimer);\n this.reconnectTimer.reset();\n this.teardown(callback, code, reason);\n }\n /**\n *\n * @param {Object} params - The params to send when connecting, for example `{user_id: userToken}`\n *\n * Passing params to connect is deprecated; pass them in the Socket constructor instead:\n * `new Socket(\"/socket\", {params: {user_id: userToken}})`.\n */\n connect(params) {\n if (params) {\n console && console.log(\"passing params to connect is deprecated. Instead pass :params to the Socket constructor\");\n this.params = closure(params);\n }\n if (this.conn) {\n return;\n }\n if (this.longPollFallbackMs && this.transport !== LongPoll) {\n this.connectWithFallback(LongPoll, this.longPollFallbackMs);\n } else {\n this.transportConnect();\n }\n }\n /**\n * Logs the message. Override `this.logger` for specialized logging. noops by default\n * @param {string} kind\n * @param {string} msg\n * @param {Object} data\n */\n log(kind, msg, data) {\n this.logger && this.logger(kind, msg, data);\n }\n /**\n * Returns true if a logger has been set on this socket.\n */\n hasLogger() {\n return this.logger !== null;\n }\n /**\n * Registers callbacks for connection open events\n *\n * @example socket.onOpen(function(){ console.info(\"the socket was opened\") })\n *\n * @param {Function} callback\n */\n onOpen(callback) {\n let ref = this.makeRef();\n this.stateChangeCallbacks.open.push([ref, callback]);\n return ref;\n }\n /**\n * Registers callbacks for connection close events\n * @param {Function} callback\n */\n onClose(callback) {\n let ref = this.makeRef();\n this.stateChangeCallbacks.close.push([ref, callback]);\n return ref;\n }\n /**\n * Registers callbacks for connection error events\n *\n * @example socket.onError(function(error){ alert(\"An error occurred\") })\n *\n * @param {Function} callback\n */\n onError(callback) {\n let ref = this.makeRef();\n this.stateChangeCallbacks.error.push([ref, callback]);\n return ref;\n }\n /**\n * Registers callbacks for connection message events\n * @param {Function} callback\n */\n onMessage(callback) {\n let ref = this.makeRef();\n this.stateChangeCallbacks.message.push([ref, callback]);\n return ref;\n }\n /**\n * Pings the server and invokes the callback with the RTT in milliseconds\n * @param {Function} callback\n *\n * Returns true if the ping was pushed or false if unable to be pushed.\n */\n ping(callback) {\n if (!this.isConnected()) {\n return false;\n }\n let ref = this.makeRef();\n let startTime = Date.now();\n this.push({\n topic: \"phoenix\",\n event: \"heartbeat\",\n payload: {},\n ref\n });\n let onMsgRef = this.onMessage(msg => {\n if (msg.ref === ref) {\n this.off([onMsgRef]);\n callback(Date.now() - startTime);\n }\n });\n return true;\n }\n /**\n * @private\n */\n transportConnect() {\n this.connectClock++;\n this.closeWasClean = false;\n this.conn = new this.transport(this.endPointURL());\n this.conn.binaryType = this.binaryType;\n this.conn.timeout = this.longpollerTimeout;\n this.conn.onopen = () => this.onConnOpen();\n this.conn.onerror = error => this.onConnError(error);\n this.conn.onmessage = event => this.onConnMessage(event);\n this.conn.onclose = event => this.onConnClose(event);\n }\n getSession(key) {\n return this.sessionStore && this.sessionStore.getItem(key);\n }\n storeSession(key, val) {\n this.sessionStore && this.sessionStore.setItem(key, val);\n }\n connectWithFallback(fallbackTransport, fallbackThreshold = 2500) {\n clearTimeout(this.fallbackTimer);\n let established = false;\n let primaryTransport = true;\n let openRef, errorRef;\n let fallback = reason => {\n this.log(\"transport\", `falling back to ${fallbackTransport.name}...`, reason);\n this.off([openRef, errorRef]);\n primaryTransport = false;\n this.replaceTransport(fallbackTransport);\n this.transportConnect();\n };\n if (this.getSession(`phx:fallback:${fallbackTransport.name}`)) {\n return fallback(\"memorized\");\n }\n this.fallbackTimer = setTimeout(fallback, fallbackThreshold);\n errorRef = this.onError(reason => {\n this.log(\"transport\", \"error\", reason);\n if (primaryTransport && !established) {\n clearTimeout(this.fallbackTimer);\n fallback(reason);\n }\n });\n this.onOpen(() => {\n established = true;\n if (!primaryTransport) {\n if (!this.primaryPassedHealthCheck) {\n this.storeSession(`phx:fallback:${fallbackTransport.name}`, \"true\");\n }\n return this.log(\"transport\", `established ${fallbackTransport.name} fallback`);\n }\n clearTimeout(this.fallbackTimer);\n this.fallbackTimer = setTimeout(fallback, fallbackThreshold);\n this.ping(rtt => {\n this.log(\"transport\", \"connected to primary after\", rtt);\n this.primaryPassedHealthCheck = true;\n clearTimeout(this.fallbackTimer);\n });\n });\n this.transportConnect();\n }\n clearHeartbeats() {\n clearTimeout(this.heartbeatTimer);\n clearTimeout(this.heartbeatTimeoutTimer);\n }\n onConnOpen() {\n if (this.hasLogger()) this.log(\"transport\", `${this.transport.name} connected to ${this.endPointURL()}`);\n this.closeWasClean = false;\n this.establishedConnections++;\n this.flushSendBuffer();\n this.reconnectTimer.reset();\n this.resetHeartbeat();\n this.stateChangeCallbacks.open.forEach(([, callback]) => callback());\n }\n /**\n * @private\n */\n heartbeatTimeout() {\n if (this.pendingHeartbeatRef) {\n this.pendingHeartbeatRef = null;\n if (this.hasLogger()) {\n this.log(\"transport\", \"heartbeat timeout. Attempting to re-establish connection\");\n }\n this.triggerChanError();\n this.closeWasClean = false;\n this.teardown(() => this.reconnectTimer.scheduleTimeout(), WS_CLOSE_NORMAL, \"heartbeat timeout\");\n }\n }\n resetHeartbeat() {\n if (this.conn && this.conn.skipHeartbeat) {\n return;\n }\n this.pendingHeartbeatRef = null;\n this.clearHeartbeats();\n this.heartbeatTimer = setTimeout(() => this.sendHeartbeat(), this.heartbeatIntervalMs);\n }\n teardown(callback, code, reason) {\n if (!this.conn) {\n return callback && callback();\n }\n this.waitForBufferDone(() => {\n if (this.conn) {\n if (code) {\n this.conn.close(code, reason || \"\");\n } else {\n this.conn.close();\n }\n }\n this.waitForSocketClosed(() => {\n if (this.conn) {\n this.conn.onopen = function () {};\n this.conn.onerror = function () {};\n this.conn.onmessage = function () {};\n this.conn.onclose = function () {};\n this.conn = null;\n }\n callback && callback();\n });\n });\n }\n waitForBufferDone(callback, tries = 1) {\n if (tries === 5 || !this.conn || !this.conn.bufferedAmount) {\n callback();\n return;\n }\n setTimeout(() => {\n this.waitForBufferDone(callback, tries + 1);\n }, 150 * tries);\n }\n waitForSocketClosed(callback, tries = 1) {\n if (tries === 5 || !this.conn || this.conn.readyState === SOCKET_STATES.closed) {\n callback();\n return;\n }\n setTimeout(() => {\n this.waitForSocketClosed(callback, tries + 1);\n }, 150 * tries);\n }\n onConnClose(event) {\n let closeCode = event && event.code;\n if (this.hasLogger()) this.log(\"transport\", \"close\", event);\n this.triggerChanError();\n this.clearHeartbeats();\n if (!this.closeWasClean && closeCode !== 1e3) {\n this.reconnectTimer.scheduleTimeout();\n }\n this.stateChangeCallbacks.close.forEach(([, callback]) => callback(event));\n }\n /**\n * @private\n */\n onConnError(error) {\n if (this.hasLogger()) this.log(\"transport\", error);\n let transportBefore = this.transport;\n let establishedBefore = this.establishedConnections;\n this.stateChangeCallbacks.error.forEach(([, callback]) => {\n callback(error, transportBefore, establishedBefore);\n });\n if (transportBefore === this.transport || establishedBefore > 0) {\n this.triggerChanError();\n }\n }\n /**\n * @private\n */\n triggerChanError() {\n this.channels.forEach(channel => {\n if (!(channel.isErrored() || channel.isLeaving() || channel.isClosed())) {\n channel.trigger(CHANNEL_EVENTS.error);\n }\n });\n }\n /**\n * @returns {string}\n */\n connectionState() {\n switch (this.conn && this.conn.readyState) {\n case SOCKET_STATES.connecting:\n return \"connecting\";\n case SOCKET_STATES.open:\n return \"open\";\n case SOCKET_STATES.closing:\n return \"closing\";\n default:\n return \"closed\";\n }\n }\n /**\n * @returns {boolean}\n */\n isConnected() {\n return this.connectionState() === \"open\";\n }\n /**\n * @private\n *\n * @param {Channel}\n */\n remove(channel) {\n this.off(channel.stateChangeRefs);\n this.channels = this.channels.filter(c => c !== channel);\n }\n /**\n * Removes `onOpen`, `onClose`, `onError,` and `onMessage` registrations.\n *\n * @param {refs} - list of refs returned by calls to\n * `onOpen`, `onClose`, `onError,` and `onMessage`\n */\n off(refs) {\n for (let key in this.stateChangeCallbacks) {\n this.stateChangeCallbacks[key] = this.stateChangeCallbacks[key].filter(([ref]) => {\n return refs.indexOf(ref) === -1;\n });\n }\n }\n /**\n * Initiates a new channel for the given topic\n *\n * @param {string} topic\n * @param {Object} chanParams - Parameters for the channel\n * @returns {Channel}\n */\n channel(topic, chanParams = {}) {\n let chan = new Channel(topic, chanParams, this);\n this.channels.push(chan);\n return chan;\n }\n /**\n * @param {Object} data\n */\n push(data) {\n if (this.hasLogger()) {\n let {\n topic,\n event,\n payload,\n ref,\n join_ref\n } = data;\n this.log(\"push\", `${topic} ${event} (${join_ref}, ${ref})`, payload);\n }\n if (this.isConnected()) {\n this.encode(data, result => this.conn.send(result));\n } else {\n this.sendBuffer.push(() => this.encode(data, result => this.conn.send(result)));\n }\n }\n /**\n * Return the next message ref, accounting for overflows\n * @returns {string}\n */\n makeRef() {\n let newRef = this.ref + 1;\n if (newRef === this.ref) {\n this.ref = 0;\n } else {\n this.ref = newRef;\n }\n return this.ref.toString();\n }\n sendHeartbeat() {\n if (this.pendingHeartbeatRef && !this.isConnected()) {\n return;\n }\n this.pendingHeartbeatRef = this.makeRef();\n this.push({\n topic: \"phoenix\",\n event: \"heartbeat\",\n payload: {},\n ref: this.pendingHeartbeatRef\n });\n this.heartbeatTimeoutTimer = setTimeout(() => this.heartbeatTimeout(), this.heartbeatIntervalMs);\n }\n flushSendBuffer() {\n if (this.isConnected() && this.sendBuffer.length > 0) {\n this.sendBuffer.forEach(callback => callback());\n this.sendBuffer = [];\n }\n }\n onConnMessage(rawMessage) {\n this.decode(rawMessage.data, msg => {\n let {\n topic,\n event,\n payload,\n ref,\n join_ref\n } = msg;\n if (ref && ref === this.pendingHeartbeatRef) {\n this.clearHeartbeats();\n this.pendingHeartbeatRef = null;\n this.heartbeatTimer = setTimeout(() => this.sendHeartbeat(), this.heartbeatIntervalMs);\n }\n if (this.hasLogger()) this.log(\"receive\", `${payload.status || \"\"} ${topic} ${event} ${ref && \"(\" + ref + \")\" || \"\"}`, payload);\n for (let i = 0; i < this.channels.length; i++) {\n const channel = this.channels[i];\n if (!channel.isMember(topic, event, payload, join_ref)) {\n continue;\n }\n channel.trigger(event, payload, ref, join_ref);\n }\n for (let i = 0; i < this.stateChangeCallbacks.message.length; i++) {\n let [, callback] = this.stateChangeCallbacks.message[i];\n callback(msg);\n }\n });\n }\n leaveOpenTopic(topic) {\n let dupChannel = this.channels.find(c => c.topic === topic && (c.isJoined() || c.isJoining()));\n if (dupChannel) {\n if (this.hasLogger()) this.log(\"transport\", `leaving duplicate topic \"${topic}\"`);\n dupChannel.leave();\n }\n }\n};\nexport { Channel, LongPoll, Presence, serializer_default as Serializer, Socket };\n","import { Injectable, inject } from '@angular/core';\nimport { Socket, Channel } from 'phoenix';\nimport { AuthService } from 'app/core/auth/auth.service';\nimport { BehaviorSubject, combineLatest } from 'rxjs';\nimport * as Sentry from '@sentry/angular-ivy';\nimport { ReportItemService } from 'app/modules/report/services/report-item.service';\nimport { ReportService } from './modules/report/services/report.service';\nimport { ActivitySocketResponse } from './modules/activity/types/activity.types';\nimport { ActivityService } from './modules/activity/services/activity.service';\nimport { AlertService } from './alert.service';\nimport { UserService } from 'app/modules/users/services/user.service';\nimport { AccountService } from 'app/core/account/account.service';\nimport { Account } from './core/account/account.types';\nimport { User } from './modules/users/types/user.types';\nimport { environment } from 'environments/environment';\nimport { IdleService } from './idle.service';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class SocketService {\n private _authService = inject(AuthService);\n private _userService = inject(UserService);\n private _accountService = inject(AccountService);\n private _reportItemService = inject(ReportItemService);\n private _activityService = inject(ActivityService);\n private _alertService = inject(AlertService);\n private _reportService = inject(ReportService);\n private _idleService = inject(IdleService);\n\n private socket: Socket | null = null;\n private channels: Map = new Map();\n private pendingJoins: Set = new Set();\n\n public socketIsConnected$: BehaviorSubject = new BehaviorSubject(true);\n\n // -----------------------------------------------------------------------------------------------------\n // @Socket Service Methods\n // -----------------------------------------------------------------------------------------------------\n\n connectSocket(): void {\n if (this.socket) {\n this.socketIsConnected$.next(true);\n return\n }\n\n combineLatest([this._accountService.account$, this._userService.user$]).subscribe({\n next: ([account, user]: [Account, User]) => {\n Sentry.setUser({ id: `${account.tenant_id}-${user.user_id}` });\n Sentry.setTag('user', `id:${account.tenant_id}-${user.user_id}`);\n\n let accessToken = null;\n\n if (this._idleService.getRememberMeState()) {\n accessToken = localStorage.getItem('accessToken') ?? '';\n } else {\n accessToken = sessionStorage.getItem('accessToken') ?? '';\n }\n\n this.socket = new Socket(environment.apiNextWs, {\n params: {\n access_token: accessToken,\n tenant_id: account.tenant_id,\n user\n }\n });\n\n this.socket.connect();\n\n this.socket.onOpen(() => {\n this.socketIsConnected$.next(true);\n this.pendingJoins.add(`web_portal:activity:${account.tenant_id}-${user.user_id}`);\n this.rejoinChannels();\n this.joinPendingChannels();\n });\n\n this.socket.onError(() => {\n Sentry.captureException(new Error('Web Socket Error: Could not connect to socket.'));\n this.socket.disconnect();\n this.socket = null;\n this.socketIsConnected$.next(false);\n });\n\n this.socket.onClose((event) => {\n Sentry.captureException(new Error('Web Socket Closed: Socket connection closed.'));\n this.socket = null;\n this.socketIsConnected$.next(false);\n });\n },\n error: (error) => {\n console.error('Error connecting to socket: could not fetch account and user.', error);\n }\n });\n }\n\n socketConnected(): BehaviorSubject {\n return this.socketIsConnected$;\n }\n\n joinChannel(topic: string): Channel | null {\n if (!this.socket) {\n console.log('Socket is not connected, storing channel for later:', topic);\n this.pendingJoins.add(topic);\n this.connectSocket();\n return null;\n }\n\n if (this.channels.has(topic)) {\n return this.channels.get(topic);\n }\n\n const channel = this.socket.channel(topic, { access_token: this._authService.accessToken });\n channel.join()\n .receive('ok', (resp) => {\n console.info('Joined channel ' + topic + ' successfully', resp);\n })\n .receive('error', (error) => {\n console.error('Channel ' + topic + ' join failed:', error);\n });\n\n this.channels.set(topic, channel);\n\n this.handleChannelEvents(channel, topic);\n }\n\n leaveChannel(topic: string): void {\n const channel = this.channels.get(topic);\n if (channel) {\n channel?.leave()\n .receive('ok', (response) => {\n console.info(`${topic} channel left:`, response);\n })\n .receive('error', (error) => {\n console.error(`${topic} channel leave failed:`, error);\n });\n }\n }\n\n private handleChannelEvents(channel: Channel, topic: string): Channel {\n channel.onError((error) => {\n console.error(`Something has went wrong with ${topic} channel:`, error);\n });\n\n channel.on('activity_update', (message) => {\n this.activityChannelUpdates(message);\n });\n\n channel.on('activity_detail_update', (activity: ActivitySocketResponse) => {\n this._activityService.getActivityDetail(activity.activity.activity_log_id).subscribe();\n });\n\n channel.on('reorder_requested', (message) => {\n this._reportItemService.tableReorderUpdates = {status: 'in_progress', message: message};\n });\n\n channel.on('reorder_completed', (message) => {\n this._reportItemService.tableReorderUpdates = {status: 'complete', message: message};\n });\n\n channel.on('refresh_report_list', (message) => {\n console.log('Refreshing report list:', message);\n this._reportService.refreshReportList = true;\n });\n\n return channel;\n }\n\n private rejoinChannels(): void {\n this.channels.forEach((channel, topic) => {\n this.joinChannel(topic);\n });\n }\n\n private joinPendingChannels(): void {\n this.pendingJoins.forEach((topic) => {\n this.joinChannel(topic);\n });\n }\n\n private activityChannelUpdates(activity: ActivitySocketResponse): void {\n this._activityService.getActivityList().subscribe();\n this._activityService.getRecentActivity().subscribe();\n\n if (activity?.activity?.data?.status === 'completed' &&\n activity?.activity?.data?.progress?.total_count > 0 &&\n activity?.activity?.data?.progress?.failure === activity?.activity?.data?.progress?.total_count) {\n this._alertService.showActivityFailedAlert(activity?.activity);\n } else if (activity?.activity?.data?.status === 'completed' && activity?.activity?.data?.progress?.success > 0) {\n this._alertService.showActivityCompletedAlert(activity?.activity);\n }\n\n if (activity?.activity?.data?.status === 'requested') {\n this._alertService.showActivityRequestedAlert(activity?.activity);\n }\n if (activity?.activity?.data?.status === 'failed') {\n this._alertService.showActivityFailedAlert(activity?.activity);\n }\n }\n\n}\n"],"names":["closure","value","globalSelf","phxWindow","global","DEFAULT_VSN","SOCKET_STATES","DEFAULT_TIMEOUT","WS_CLOSE_NORMAL","CHANNEL_STATES","CHANNEL_EVENTS","TRANSPORTS","XHR_STATES","Push","channel","event","payload","timeout","status","callback","response","_ref","h","Timer","timerCalc","Channel","topic","params","socket","pushEvent","reason","ref","bind","onClose","leavePush","_event","joinRef","handledPayload","eventBindings","i","Ajax","method","endPoint","accept","body","ontimeout","req","resp","obj","parentKey","queryStr","key","paramKey","paramVal","url","prefix","arrayBufferToBase64","buffer","binary","bytes","len","LongPoll","code","wasClean","token","messages","msg","opts","contentType","onCallerTimeout","serializer_default","msg","callback","payload","rawPayload","join_ref","ref","topic","event","message","metaLength","header","view","offset","char","combined","buffer","kind","decoder","joinRefSize","topicSize","eventSize","joinRef","data","refSize","CHANNEL_EVENTS","Socket","endPoint","opts","DEFAULT_TIMEOUT","global","LongPoll","awaitingConnectionOnPageShow","phxWindow","_e","tries","closure","TRANSPORTS","DEFAULT_VSN","Timer","newTransport","uri","Ajax","code","reason","params","startTime","onMsgRef","error","key","val","fallbackTransport","fallbackThreshold","established","primaryTransport","openRef","errorRef","fallback","rtt","WS_CLOSE_NORMAL","SOCKET_STATES","closeCode","transportBefore","establishedBefore","channel","c","refs","chanParams","chan","Channel","result","newRef","rawMessage","i","dupChannel","SocketService","constructor","_authService","inject","AuthService","_userService","UserService","_accountService","AccountService","_reportItemService","ReportItemService","_activityService","ActivityService","_alertService","AlertService","_reportService","ReportService","_idleService","IdleService","socket","channels","Map","pendingJoins","Set","socketIsConnected$","BehaviorSubject","connectSocket","next","combineLatest","account$","user$","subscribe","account","user","setUser","id","tenant_id","user_id","setTag","accessToken","getRememberMeState","localStorage","getItem","sessionStorage","Socket","environment","apiNextWs","params","access_token","connect","onOpen","add","rejoinChannels","joinPendingChannels","onError","captureException","Error","disconnect","onClose","event","error","console","socketConnected","joinChannel","topic","log","has","get","channel","join","receive","resp","info","set","handleChannelEvents","leaveChannel","leave","response","on","message","activityChannelUpdates","activity","getActivityDetail","activity_log_id","tableReorderUpdates","status","refreshReportList","forEach","getActivityList","getRecentActivity","data","progress","total_count","failure","showActivityFailedAlert","success","showActivityCompletedAlert","showActivityRequestedAlert","factory","ɵfac","providedIn"],"mappings":";;4bACA,IAAIA,EAAUC,GACR,OAAOA,GAAU,WACZA,EAEQ,UAAY,CACzB,OAAOA,CACT,EAMAC,EAAa,OAAO,KAAS,IAAc,KAAO,KAClDC,EAAY,OAAO,OAAW,IAAc,OAAS,KACrDC,EAASF,GAAcC,GAAaC,EACpCC,EAAc,QACdC,EAAgB,CAClB,WAAY,EACZ,KAAM,EACN,QAAS,EACT,OAAQ,CACV,EACIC,EAAkB,IAClBC,EAAkB,IAClBC,EAAiB,CACnB,OAAQ,SACR,QAAS,UACT,OAAQ,SACR,QAAS,UACT,QAAS,SACX,EACIC,EAAiB,CACnB,MAAO,YACP,MAAO,YACP,KAAM,WACN,MAAO,YACP,MAAO,WACT,EACIC,EAAa,CACf,SAAU,WACV,UAAW,WACb,EACIC,EAAa,CACf,SAAU,CACZ,EAGIC,EAAO,KAAM,CACf,YAAYC,EAASC,EAAOC,EAASC,EAAS,CAC5C,KAAK,QAAUH,EACf,KAAK,MAAQC,EACb,KAAK,QAAUC,GAAW,UAAY,CACpC,MAAO,CAAC,CACV,EACA,KAAK,aAAe,KACpB,KAAK,QAAUC,EACf,KAAK,aAAe,KACpB,KAAK,SAAW,CAAC,EACjB,KAAK,KAAO,EACd,CAKA,OAAOA,EAAS,CACd,KAAK,QAAUA,EACf,KAAK,MAAM,EACX,KAAK,KAAK,CACZ,CAIA,MAAO,CACD,KAAK,YAAY,SAAS,IAG9B,KAAK,aAAa,EAClB,KAAK,KAAO,GACZ,KAAK,QAAQ,OAAO,KAAK,CACvB,MAAO,KAAK,QAAQ,MACpB,MAAO,KAAK,MACZ,QAAS,KAAK,QAAQ,EACtB,IAAK,KAAK,IACV,SAAU,KAAK,QAAQ,QAAQ,CACjC,CAAC,EACH,CAMA,QAAQC,EAAQC,EAAU,CACxB,OAAI,KAAK,YAAYD,CA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