"use strict";var c=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var p=(o,e)=>c(o,"name",{value:e,configurable:true});var m=(o,e)=>{for(var s in e)c(o,s,{get:e[s],enumerable:true})};var $=(o,e,s,n)=>{if(e&&typeof e==="object"||typeof e==="function"){for(let r of g(e))if(!v.call(o,r)&&r!==s)c(o,r,{get:()=>e[r],enumerable:!(n=b(e,r))||n.enumerable})}return o};var P=o=>$(c({},"__esModule",{value:true}),o);var E={};m(E,{config:()=>d,default:()=>x});module.exports=P(E);var u=require("@electron/remote");var t=require("mobx");const a=require("../../preload-safe-debug")("Ferdium:feature:serviceProxy");const d=(0,t.observable)({isEnabled:true});function x(o){a("Initializing `serviceProxy` feature");const e=(0,t.action)(s=>{d.isEnabled=s});(0,t.autorun)(()=>{e(true);const s=o.services.enabled;const n=o.settings.proxy;a("Service Proxy autorun");for(const r of s){const y=u.session.fromPartition(`persist:service-${r.id}`);if(d.isEnabled){const i=n[r.id];if(i?.isEnabled&&i.host){const f=`${i.host}${i.port?`:${i.port}`:""}`;a(`Setting proxy config from service settings for "${r.name}" (${r.id}) to`,f);y.setProxy({proxyRules:f}).then(()=>{a(`Using proxy "${f}" for "${r.name}" (${r.id})`)}).catch(l=>console.error(l))}}}})}p(x,"init");
