"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("lodash");class s{static replaceURLVariables(e,i){try{const r=e.match(/\${(.*?)}/g);if(r)for(let t=0;t<r.length;t++){const a=i.filter(l=>l.name===r[t].substring(2,r[t].length-1));a&&n.isArray(a)&&a.length>0&&(e=e.replaceAll(r[t],a[0]._value))}return e}catch{return e}}static replaceObjectVariables(e,i){try{let r=JSON.stringify(e);const t=r.match(/\$g{(.*?)}/g);if(t){for(let a=0;a<t.length;a++){const l=i.filter(c=>c.name===t[a].substring(3,t[a].length-1));l&&n.isArray(l)&&l.length>0&&(r=r.replaceAll(t[a],l[0]._value))}return JSON.parse(r)}return e}catch{return e}}static replaceStringVariables(e,i){try{const r=e.match(/\$g{(.*?)}/g);if(r)for(let t=0;t<r.length;t++){const a=i.filter(l=>l.name===r[t].substring(3,r[t].length-1));a&&n.isArray(a)&&a.length>0&&(e=e.replaceAll(r[t],a[0]._value))}return e}catch{return e}}static replaceEnvVariables(e,i){try{let r="";if(!e.includes("http")&&i){const t=i.filter(a=>a.selected);t&&n.isArray(t)&&t.length>0&&(r=t[0].envBaseUrl||"")}return r}catch{return""}}static noneData(e){return{id:e,finalKeyData:[],finalUserData:{id:e,data:[]},filteredData:[],rawData:[],noMappingData:[]}}static getEnvironments(){let e=localStorage.getItem("currentApiEnvironments");return e&&(e=JSON.parse(e)),e}static getVariableData(){let e=localStorage.getItem("currentVariableData");return e&&(e=JSON.parse(e)),e}static hasValidWebSocket(e,i,r){const t=e.get(i);if(!t)return!1;for(const a of t)if(a.getId()===r&&a.isConnected())return!0;return!1}static cleanupPreviousWebSockets(e,i,r){const t=e.get(r);t&&(t.forEach(a=>{i.includes(a.getId())||(a.disconnect(),t.delete(a))}),t.size===0&&e.delete(r))}}exports.DataSourceUtils=s;
