'use strict'; 'require form'; 'require fs'; 'require poll'; 'require rpc'; 'require uci'; 'require ui'; 'require view'; var LuciView=(()=>{var Jt=Object.defineProperty;var wr=Object.getOwnPropertyDescriptor;var Sr=Object.getOwnPropertyNames;var vr=Object.prototype.hasOwnProperty;var Nr=(t,e)=>{for(var r in e)Jt(t,r,{get:e[r],enumerable:!0})},Tr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Sr(e))!vr.call(t,s)&&s!==r&&Jt(t,s,{get:()=>e[s],enumerable:!(n=wr(e,s))||n.enumerable});return t};var Er=t=>Tr(Jt({},"__esModule",{value:!0}),t);var _s={};Nr(_s,{default:()=>gs});var d={CUSTOM:"custom",LOAD_BALANCE:"load_balance",HYSTERIA2:"hysteria2",SHADOWSOCKS:"shadowsocks",TUIC:"tuic",SHADOWTLS:"shadowtls",VLESS:"vless"},m={XRAY:"xray",SING_BOX:"sing-box",CUSTOM:"custom"},A={NONE:"none",PRE_ROUTING:"pre-routing",ROUTING:"routing"};function k(t){let e=(t||"").trim();return e==="singbox"?m.SING_BOX:e}var hs={[m.XRAY]:[d.SHADOWSOCKS,d.HYSTERIA2,d.VLESS],[m.SING_BOX]:[d.SHADOWSOCKS,d.HYSTERIA2,d.VLESS,d.TUIC,d.SHADOWTLS]},ys={DNS_STRATEGY_VALUES:[{label:"Prefer IPv6 (sing-box only, xray uses dual stack by default)",value:"64"},{label:"Prefer IPv4 (sing-box only, xray uses dual stack by default)",value:"46"},{label:"IPv6 only",value:"6"},{label:"IPv4 only",value:"4"}],SHUNT_LOG_LEVELS:["info","warn","error","debug"],PROXY_LOG_LEVELS:["info","warn","error","debug"],SHUNT_CONF_TYPE:[m.XRAY,m.SING_BOX],PROXY_TYPES:[{label:"Load Balancing",value:"load_balance"},{label:"Shadowsocks",value:"shadowsocks"},{label:"Hysteria2",value:"hysteria2"},{label:"VLESS",value:"vless"},{label:"TUIC",value:"tuic"},{label:"ShadowTLS",value:"shadowtls"}],SHADOWSOCKS_METHODS:[{label:"2022-blake3-aes-128-gcm",value:"2022-blake3-aes-128-gcm"},{label:"2022-blake3-aes-256-gcm",value:"2022-blake3-aes-256-gcm"},{label:"2022-blake3-chacha20-poly1305",value:"2022-blake3-chacha20-poly1305"},{label:"aes-128-gcm",value:"aes-128-gcm"},{label:"aes-192-gcm",value:"aes-192-gcm"},{label:"aes-256-gcm",value:"aes-256-gcm"},{label:"chacha20-ietf-poly1305",value:"chacha20-ietf-poly1305"},{label:"xchacha20-ietf-poly1305",value:"xchacha20-ietf-poly1305"}],MULTIPLEX_PROTOCOLS:[{label:"smux",value:"smux"},{label:"yamux",value:"yamux"},{label:"h2mux",value:"h2mux"}],TUIC_CONGESTION_CONTROLS:[{label:"cubic",value:"cubic"},{label:"new_reno",value:"new_reno"},{label:"bbr",value:"bbr"}],TUIC_UDP_RELAY_MODES:[{label:"Native UDP",value:"native"},{label:"QUIC Stream",value:"quic"}],SHADOWTLS_VERSIONS:[{label:"v1",value:"1"},{label:"v2",value:"2"},{label:"v3",value:"3"}],VLESS_FLOWS:[{label:"None",value:""},{label:"xtls-rprx-vision",value:"xtls-rprx-vision"},{label:"xtls-rprx-vision-udp443",value:"xtls-rprx-vision-udp443"}],VLESS_PACKET_ENCODINGS:[{label:"Disabled",value:""},{label:"packetaddr",value:"packetaddr"},{label:"xudp",value:"xudp"}],V2RAY_TRANSPORT_TYPES_XRAY:[{label:"None",value:""},{label:"HTTP",value:"http"},{label:"WebSocket",value:"ws"},{label:"gRPC",value:"grpc"},{label:"HTTPUpgrade",value:"httpupgrade"},{label:"XHTTP",value:"xhttp"}],HYSTERIA2_OBFS_TYPES:[{label:"Disabled",value:""},{label:"Salamander",value:"salamander"}],DUAL_CORES:[{label:"sing-box",value:m.SING_BOX},{label:"xray",value:m.XRAY},{label:"Custom",value:m.CUSTOM}]};var Ue=view;var a=uci;var S=form;var x=fs;var B=ui;var z=class{disabled;level;timestamp;constructor(e){this.disabled=!1,this.level=e||"info",this.timestamp=!0}},st=class{type;tag;server;server_port;detour;constructor(e,r,n,s,o){this.type=e,this.tag=r,this.server=n,this.server_port=Number.isFinite(s)&&s>0?s:void 0,this.detour=o==="direct-out"?void 0:o}},dt=class{servers;rules;strategy;disable_cache;disable_expire;final;constructor(e,r,n){this.servers=[],this.rules=[],this.strategy=r||"prefer_ipv6",this.disable_cache=!n,this.disable_expire=!n,this.final=e}},gt=class{action;outbound;constructor(e,r){this.action=e,this.outbound=r}},W=class extends gt{ip_version;protocol;port;port_range;domain;domain_suffix;domain_keyword;domain_regex;rule_set;ip_cidr;network;constructor(e,r){super(e,r)}initRule(e){return this.ip_version=e.ipVersion,this.network=e.network,this.protocol=e.protocol,this.port=e.port,this.port_range=e.portRange.map(r=>r.replace("-",":")),this.domain=e.domain,this.domain_suffix=e.domainSuffix,this.domain_keyword=e.domainKeyword,this.domain_regex=e.domainRegex,this.rule_set=e.ruleSet.map(r=>r.tag),this.ip_cidr=e.ipCidr,this}},ft=class extends gt{domain;domain_keyword;domain_regex;domain_suffix;rule_set;server;strategy;disable_cache;disable_expire;constructor(e,r,n){super(e,void 0),this.action=e,this.server=r,this.strategy=n,this.disable_cache=!0}initRule(e){return this.domain=e.domain,this.domain_suffix=e.domainSuffix,this.domain_keyword=e.domainKeyword,this.domain_regex=e.domainRegex,this.rule_set=e.ruleSet.map(r=>r.tag),this}},Qt=class extends W{constructor(){super("sniff",void 0)}},Zt=class extends W{constructor(){super("hijack-dns",void 0),this.protocol=["dns"]}},_t=class{type;tag;format;constructor(e,r,n){this.type=r,this.tag=e,this.format=n}},mt=class extends _t{url;http_client;update_interval;constructor(e,r,n,s,o){super(e,"remote",r),this.url=n,s&&(this.http_client=new te(s)),this.update_interval=o}},te=class{detour;constructor(e){this.detour=e}},ht=class extends _t{path;constructor(e,r,n){super(e,"local",r),this.path=n}},yt=class{rules;rule_set;default_domain_resolver;final;constructor(e,r){this.rules=[new Qt,new Zt],this.rule_set=[],this.default_domain_resolver=r,this.final=e}},K=class{type="tproxy";tag;listen;listen_port;constructor(e,r,n){this.tag=r,this.listen=n??"::",this.listen_port=e}},bt=class{type="direct";tag;listen;listen_port;constructor(e,r){this.tag=r,this.listen="::",this.listen_port=e}},ot=class{type="socks";tag;listen;listen_port;users;constructor(e,r,n){this.tag=r,this.listen=n??"::",this.listen_port=e}},xt=class{type="block";tag;constructor(e){this.tag=e}},wt=class{type="direct";tag;domain_resolver;constructor(e){this.tag=e}},St=class{type="urltest";tag;url;interval;tolerance;idle_timeout;interrupt_exist_connections;outbounds;constructor(e,r,n,s,o,i){this.tag=e,this.outbounds=[],this.url=r,this.interval=n,this.tolerance=s,this.idle_timeout=o,this.interrupt_exist_connections=i}},q=class{type="socks";tag;server;server_port;version="5";domain_resolver;constructor(e,r,n){this.tag=n,this.server=e,this.server_port=r,this.version="5"}},U=class{enabled;server_name;insecure;reality;constructor(e){this.enabled=!0,this.server_name=e}},$=class{enabled;up_mbps;down_mbps;constructor(){this.enabled=!0}},J=class{enabled;protocol;max_connections;min_streams;max_streams;brutal;constructor(){this.enabled=!0}};var ee=class{protocols=new Map;register(e){this.protocols.set(e.type,e)}build(e,r){let n=this.protocols.get(e);if(!n)throw new Error(`Unsupported sing-box protocol: ${e}`);return n.build(r)}},C=new ee;var re=class{type;password;constructor(e){this.type="salamander",this.password=e}},ne=class{type="hysteria2";tag;server;server_port;password;obfs;up_mbps;down_mbps;server_ports;hop_interval;network;tls;constructor(e,r,n,s){this.tag=e,this.server=r,this.server_port=n,this.tls=new U(s)}},Cr={type:"hysteria2",build(t){let e=t,r=new ne(e.name,e.server,parseInt(e.server_port),e.tls_server_name||e.server);return e.password&&(r.password=e.password),e.up_mbps&&(r.up_mbps=Number(e.up_mbps)),e.down_mbps&&(r.down_mbps=Number(e.down_mbps)),e.server_ports&&e.server_ports.length>0&&(r.server_ports=e.server_ports.map(n=>n.replace("-",":")).filter(n=>n.length>0)),e.hop_interval&&(r.hop_interval=e.hop_interval),e.network&&(r.network=e.network),e.obfs_type==="salamander"&&e.obfs_password&&(r.obfs=new re(e.obfs_password)),r.tls.insecure=e.tls_insecure==="1",r}};C.register(Cr);var se=class{type="shadowsocks";tag;server;server_port;method;password;network;udp_over_tcp;plugin;plugin_opts;multiplex;constructor(e,r,n,s,o){this.tag=e,this.server=r,this.server_port=n,this.method=s,this.password=o}};function Pr(t){let e=new J;if(t.multiplex_protocol&&(e.protocol=t.multiplex_protocol),t.multiplex_max_connections&&(e.max_connections=parseInt(t.multiplex_max_connections)),t.multiplex_min_streams&&(e.min_streams=parseInt(t.multiplex_min_streams)),t.multiplex_max_streams&&(e.max_streams=parseInt(t.multiplex_max_streams)),t.multiplex_brutal_enabled==="1"){let r=new $;t.multiplex_brutal_up_mbps&&(r.up_mbps=parseInt(t.multiplex_brutal_up_mbps)),t.multiplex_brutal_down_mbps&&(r.down_mbps=parseInt(t.multiplex_brutal_down_mbps)),e.brutal=r}return e}var Rr={type:"shadowsocks",build(t){let e=t,r=new se(e.name,e.server,parseInt(e.server_port),e.method,e.password);return e.network&&(r.network=e.network),e.udp_over_tcp==="1"&&(r.udp_over_tcp=!0),e.plugin&&(r.plugin=e.plugin),e.plugin_opts&&(r.plugin_opts=e.plugin_opts),e.multiplex_enabled==="1"&&(r.multiplex=Pr(e)),r}};C.register(Rr);var oe=class{type="vless";tag;server;server_port;uuid;flow;network;packet_encoding;tls;transport;multiplex;constructor(e,r,n,s,o){this.tag=e,this.server=r,this.server_port=n,this.uuid=s,this.tls=new U(o)}};function Dr(t){switch(t.transport_type){case"http":{let e={type:"http"};return t.transport_http_host&&(e.host=t.transport_http_host),t.transport_http_path&&(e.path=t.transport_http_path),t.transport_http_method&&(e.method=t.transport_http_method),t.transport_http_idle_timeout&&(e.idle_timeout=t.transport_http_idle_timeout),t.transport_http_ping_timeout&&(e.ping_timeout=t.transport_http_ping_timeout),e}case"ws":{let e={type:"ws"};return t.transport_ws_path&&(e.path=t.transport_ws_path),t.transport_ws_host&&(e.headers={Host:t.transport_ws_host}),t.transport_ws_max_early_data&&(e.max_early_data=parseInt(t.transport_ws_max_early_data)),t.transport_ws_early_data_header_name&&(e.early_data_header_name=t.transport_ws_early_data_header_name),e}case"grpc":{let e={type:"grpc"};return t.transport_grpc_service_name&&(e.service_name=t.transport_grpc_service_name),t.transport_grpc_idle_timeout&&(e.idle_timeout=t.transport_grpc_idle_timeout),t.transport_grpc_ping_timeout&&(e.ping_timeout=t.transport_grpc_ping_timeout),t.transport_grpc_permit_without_stream==="1"&&(e.permit_without_stream=!0),e}case"httpupgrade":{let e={type:"httpupgrade"};return t.transport_httpupgrade_host&&(e.host=t.transport_httpupgrade_host),t.transport_httpupgrade_path&&(e.path=t.transport_httpupgrade_path),e}default:return}}function Ar(t){let e=new J;if(t.multiplex_protocol&&(e.protocol=t.multiplex_protocol),t.multiplex_max_connections&&(e.max_connections=parseInt(t.multiplex_max_connections)),t.multiplex_min_streams&&(e.min_streams=parseInt(t.multiplex_min_streams)),t.multiplex_max_streams&&(e.max_streams=parseInt(t.multiplex_max_streams)),t.multiplex_brutal_enabled==="1"){let r=new $;t.multiplex_brutal_up_mbps&&(r.up_mbps=parseInt(t.multiplex_brutal_up_mbps)),t.multiplex_brutal_down_mbps&&(r.down_mbps=parseInt(t.multiplex_brutal_down_mbps)),e.brutal=r}return e}var Ur={type:"vless",build(t){let e=t,r=new oe(e.name,e.server,parseInt(e.server_port),e.uuid,e.tls_server_name||e.server);return e.flow&&(r.flow=e.flow),e.network&&(r.network=e.network),e.packet_encoding&&(r.packet_encoding=e.packet_encoding),r.tls.insecure=e.tls_insecure==="1",e.tls_reality_enabled==="1"&&e.tls_reality_public_key&&(r.tls.reality={enabled:!0,public_key:e.tls_reality_public_key,short_id:e.tls_reality_short_id||""}),e.transport_type&&(r.transport=Dr(e)),e.multiplex_enabled==="1"&&(r.multiplex=Ar(e)),r}};C.register(Ur);var ie=class{type="tuic";tag;server;server_port;uuid;password;congestion_control;udp_relay_mode;udp_over_stream;zero_rtt_handshake;heartbeat;network;tls;constructor(e,r,n,s,o,i){this.tag=e,this.server=r,this.server_port=n,this.uuid=s,this.password=o,this.tls=new U(i)}},Lr={type:"tuic",build(t){let e=t,r=new ie(e.name,e.server,parseInt(e.server_port),e.uuid,e.password,e.tls_server_name||e.server);return e.congestion_control&&(r.congestion_control=e.congestion_control),e.udp_relay_mode&&(r.udp_relay_mode=e.udp_relay_mode),e.udp_over_stream==="1"&&(r.udp_over_stream=!0),e.zero_rtt_handshake==="1"&&(r.zero_rtt_handshake=!0),e.heartbeat&&(r.heartbeat=e.heartbeat),e.network&&(r.network=e.network),r.tls.insecure=e.tls_insecure==="1",r}};C.register(Lr);var ae=class{type="shadowtls";tag;server;server_port;version;password;tls;constructor(e,r,n,s,o){this.tag=e,this.server=r,this.server_port=n,this.version=s,this.tls=new U(o)}},Fr={type:"shadowtls",build(t){let e=t,r=new ae(e.name,e.server,parseInt(e.server_port),parseInt(e.version),e.tls_server_name||e.server);return e.password&&(r.password=e.password),r.tls.insecure=e.tls_insecure==="1",r}};C.register(Fr);var vt=class{tag;type;server;port},Nt=class{defaultDnsNode;defaultStrategy;rulesetDnsNode;useCache;nodes;constructor(){this.nodes=[]}},Q=class{enabled;name;proxyNode;ipVersionSplit;proxyNodeV4;proxyNodeV6;protocol;network;port;portRange;domainList;ipList;dnsNode;dnsProxyNode;dnsStrategy;constructor(){this.port=[],this.portRange=[],this.network=[],this.protocol=[],this.ipVersionSplit="0"}},Tt=class{defaultProxyNode;rulesetOutNode;rulesetConvert;rules;constructor(){this.rules=[]}},Et=class{type;configType;shuntListenPort;dnsListenPort;logLevel;logPath;route;dns},Ot=class{domain;domainRegex;domainKeyword;domainSuffix;ipCidr;network;protocol;port;portRange;ipVersion;ruleSet;geoIp;geoSite;constructor(){this.domain=[],this.domainRegex=[],this.domainKeyword=[],this.domainSuffix=[],this.ruleSet=[],this.ipCidr=[],this.geoIp=[],this.geoSite=[],this.network=[],this.protocol=[],this.port=[],this.portRange=[]}containDomain(){return this.domain.length>0||this.domainRegex.length>0||this.domainSuffix.length>0||this.domainKeyword.length>0}containGeo(){return this.geoSite.length>0||this.geoIp.length>0}containRuleSet(){return this.ruleSet.length>0}containIp(){return this.ipCidr.length>0||this.geoIp.length>0}isEmpty(e){return!(this.containDomain()||this.containIp()||e==="geo"&&this.containGeo()||e==="set"&&this.containRuleSet()||this.network.length>0||this.port.length>0||this.portRange.length>0||this.protocol.length>0)}},Ct=class{name;type="load_balance";core=m.SING_BOX;enabled="1";listen_port;socks_port;member_node;procd_env;log_level;log_path;url;interval;tolerance;idle_timeout;interrupt_exist_connections;strategy;strategy_expected;strategy_max_rtt;strategy_tolerance;fallback_tag;probe_url;probe_connectivity;probe_interval;probe_timeout;probe_sampling;probe_http_method;constructor(){this.member_node=[],this.procd_env=[]}},Pt=class{name;type="custom";enabled="1";command;listen_port;socks_port;procd_env;log_enabled;log_path;constructor(){this.type="custom",this.enabled="1",this.procd_env=[]}},Rt=class{name;type="hysteria2";enabled="1";core;server;server_port;server_ports;hop_interval;obfs_type;obfs_password;brutal_debug;udp_idle_timeout;up_mbps;down_mbps;password;network;tls_server_name;tls_insecure;listen_port;socks_port;procd_env;log_path;constructor(){this.type="hysteria2",this.enabled="1",this.core=m.SING_BOX,this.server_ports=[],this.network="",this.brutal_debug="0",this.tls_insecure="0"}},Dt=class{name;type="shadowsocks";enabled="1";core;server;server_port;method;password;plugin;plugin_opts;network;udp_over_tcp;listen_port;socks_port;multiplex_enabled;multiplex_protocol;multiplex_max_connections;multiplex_min_streams;multiplex_max_streams;multiplex_brutal_enabled;multiplex_brutal_up_mbps;multiplex_brutal_down_mbps;procd_env;log_path;constructor(){this.type="shadowsocks",this.enabled="1",this.core=m.SING_BOX,this.network="",this.udp_over_tcp="0",this.multiplex_enabled="0",this.multiplex_protocol="h2mux",this.multiplex_brutal_enabled="0"}},At=class{name;type="tuic";enabled="1";core;server;server_port;uuid;password;congestion_control;udp_relay_mode;udp_over_stream;zero_rtt_handshake;heartbeat;network;tls_server_name;tls_insecure;listen_port;socks_port;procd_env;log_path;constructor(){this.type="tuic",this.enabled="1",this.core=m.SING_BOX,this.congestion_control="cubic",this.udp_relay_mode="",this.udp_over_stream="0",this.zero_rtt_handshake="0",this.heartbeat="10s",this.network="",this.tls_insecure="0"}},Ut=class{name;type="shadowtls";enabled="1";core;server;server_port;version;password;tls_server_name;tls_insecure;listen_port;socks_port;procd_env;log_path;constructor(){this.type="shadowtls",this.enabled="1",this.core=m.SING_BOX,this.version="1",this.tls_insecure="0"}},Lt=class{name;type="vless";enabled="1";core;server;server_port;uuid;flow;network;packet_encoding;tls_server_name;tls_insecure;tls_reality_enabled;tls_reality_public_key;tls_reality_short_id;listen_port;socks_port;multiplex_enabled;multiplex_protocol;multiplex_max_connections;multiplex_min_streams;multiplex_max_streams;multiplex_brutal_enabled;multiplex_brutal_up_mbps;multiplex_brutal_down_mbps;transport_type;transport_http_host;transport_http_path;transport_http_method;transport_http_idle_timeout;transport_http_ping_timeout;transport_ws_host;transport_ws_path;transport_ws_max_early_data;transport_ws_early_data_header_name;transport_grpc_service_name;transport_grpc_idle_timeout;transport_grpc_ping_timeout;transport_grpc_permit_without_stream;transport_httpupgrade_host;transport_httpupgrade_path;transport_xhttp_host;transport_xhttp_path;transport_xhttp_mode;procd_env;log_path;constructor(){this.type="vless",this.enabled="1",this.core=m.XRAY,this.network="tcp",this.packet_encoding="",this.tls_insecure="0",this.tls_reality_enabled="0",this.multiplex_enabled="0",this.multiplex_protocol="h2mux",this.multiplex_brutal_enabled="0",this.transport_type="",this.transport_http_idle_timeout="15s",this.transport_http_ping_timeout="15s",this.transport_grpc_idle_timeout="15s",this.transport_grpc_ping_timeout="15s",this.transport_grpc_permit_without_stream="0",this.transport_xhttp_path="/",this.transport_xhttp_mode="auto"}};var Y={camelToSnake:function(t){return t.replace(/([A-Z])/g,function(e){return"_"+e.toLowerCase()})},transFromUci:function(t,e){Object.keys(t).forEach(r=>{let n=Y.camelToSnake(r);e[n]&&(t[r]=e[n])})},generateUniqueSectionId:function(t="hijpass"){let e="abcdefghijklmnopqrstuvwxyz0123456789",r="";for(;;){r="";for(let n=0;n<8;n++)r+=e.charAt(Math.floor(Math.random()*e.length));if(!a.get(t,r))break}return r}};function Le(t,e){let r=t.substring(e==="remote"?16:15),n=r.split("/").pop(),s=n.substring(0,n.lastIndexOf("."))||n,o=(e==="remote"?r:n).endsWith("srs")?"binary":"source";return{tag:s,type:e,format:o,pathOrUrl:r}}var w={getShuntSection:function(){let t=new Et,e=a.get_first("hijpass","shunt");return Y.transFromUci(t,e),t.dns=w.getDnsSection(),t.route=w.getRouteSection(),t},getRouteSection:function(){let t=a.get_first("hijpass","shunt"),e=new Tt;return Y.transFromUci(e,t),a.sections("hijpass","shunt_route_rule",function(r){let n=new Q;Y.transFromUci(n,r),e.rules.push(n)}),e},getRouteRuleVariants:function(t){if(t.ipVersionSplit!=="1")return[{rule:t,proxyNode:t.proxyNode}];let e=[];if(t.proxyNodeV4){let r=Object.assign(new Q,t);r.name=t.name?t.name+"-ipv4":t.name,r.proxyNode=t.proxyNodeV4,e.push({rule:r,proxyNode:t.proxyNodeV4,ipVersion:4})}if(t.proxyNodeV6){let r=Object.assign(new Q,t);r.name=t.name?t.name+"-ipv6":t.name,r.proxyNode=t.proxyNodeV6,e.push({rule:r,proxyNode:t.proxyNodeV6,ipVersion:6})}return e},getDnsSection:function(){let t=a.get_first("hijpass","shunt"),e=new Nt;return e.nodes=[],Y.transFromUci(e,t),a.sections("hijpass","shunt_dns_node",function(r){if(r.enabled==="0")return;let n=new vt;Y.transFromUci(n,r),e.nodes.push(n)}),e},parseRuleList:function(t){let e=new Ot,r=t.domainList,n=t.ipList;if(e.network=t.network?t.network:[],e.protocol=t.protocol?t.protocol:[],t.port&&(e.port=t.port.map(s=>parseInt(s,10)).filter(s=>!isNaN(s))),t.portRange&&(e.portRange=t.portRange.map(s=>s.replace("-",":")).filter(s=>s.length>0)),r&&r.trim()!==""){let s=r.split(` `);for(let o of s)if(o=o.trim(),!(o===""||o.startsWith("#"))){if(o.startsWith("rule-set:")){let i=o.startsWith("rule-set:remote:")?"remote":"local",l=Le(o,i);e.ruleSet.push(l);continue}o.startsWith("regexp:")?e.domainRegex.push(o.substring(7)):o.startsWith("domain:")?e.domainSuffix.push(o.substring(7)):o.startsWith("full:")?e.domain.push(o.substring(5)):o.startsWith("geosite:")?e.geoSite.push(o):e.domainKeyword.push(o)}}if(n&&n.trim()!==""){let s=n.split(` `);for(let o of s)if(o=o.trim(),!(o===""||o.startsWith("#"))){if(o.startsWith("rule-set:")){let i=o.startsWith("rule-set:remote:")?"remote":"local",l=Le(o,i);e.ruleSet.push(l);continue}o.startsWith("geoip:")?e.geoIp.push(o):e.ipCidr.push(o)}}return e}};var le=3,Ft="lb-member-";function Fe(t){return t?.name||t?.[".name"]||""}function pe(t){return k(t?.core||m.SING_BOX)}function ue(t){if(!t)return!1;let e=Number(t);return Number.isInteger(e)&&e>0&&e<=65535}function ke(){let t=[];return a.sections("hijpass","proxy_node",function(e){t.push(e)}),t}function ce(){let t=new Map;return ke().forEach(e=>{let r=Fe(e);r&&t.set(r,e)}),t}function Ie(t){return"upstream-"+t}function de(t){return t?(Array.isArray(t)?t:[t]).filter(e=>!!e):[]}function je(t){return Ft+t}function kr(t,e=ce()){let r=de(t.member_node);if(r.length===0)throw new Error("Load balancing node has no members: "+t.name);return r.map((n,s)=>{if(n===t.name)throw new Error("Load balancing node cannot include itself: "+n);let o=e.get(n);if(!o)throw new Error("Load balancing member node not found: "+n);if(o.type===d.LOAD_BALANCE)throw new Error("Nested load balancing members are not supported: "+n);if(o.enabled!=="1")throw new Error("Load balancing member node disabled: "+n);if(!ue(o.socks_port))throw new Error("Load balancing member node SOCKS port invalid: "+n);return{name:n,socksPort:Number(o.socks_port),tag:je(s),core:pe(o),section:o}})}function Ir(t,e=ce()){let r=t.upstream_proxy_node;if(!r)return;if(r===t.name)throw new Error("Upstream proxy node cannot be itself: "+r);let n=e.get(r);if(!n)throw new Error("Upstream proxy node not found: "+r);if(n.enabled!=="1")throw new Error("Upstream proxy node disabled: "+r);if(!ue(n.socks_port))throw new Error("Upstream proxy node SOCKS port invalid: "+r);return{name:r,socksPort:Number(n.socks_port),tag:Ie(r),core:pe(n),section:n}}function jr(t,e){let r=[],n=new Set,s=t;for(;s;){if(n.has(s))return r.push(s),{chain:r,cycle:!0};n.add(s),r.push(s);let o=e.get(s);if(!o||!o.upstream_proxy_node)break;s=o.upstream_proxy_node}return{chain:r,cycle:!1}}function Me(t){let e=[];return t?.type===d.LOAD_BALANCE?e.push(...de(t.member_node)):t?.upstream_proxy_node&&e.push(t.upstream_proxy_node),e}function Mr(t){let e=new Set,r=new Set,n=[];function s(o){if(r.has(o)){let l=n.indexOf(o);return n.slice(l).concat(o)}if(e.has(o))return;let i=t.get(o);if(!(!i||i.enabled!=="1")){r.add(o),n.push(o);for(let l of Me(i)){let p=s(l);if(p)return p}n.pop(),r.delete(o),e.add(o)}}for(let o of t.keys()){let i=s(o);if(i)return i}}var h={getProxyName:Fe,getProxyCore:pe,getProxySections:ke,getProxySectionMap:ce,isPort:ue,getUpstreamProxyOutboundTag:Ie,normalizeProxyNodeList:de,getLoadBalanceMemberOutboundTag:je,resolveUpstreamProxy:Ir,resolveLoadBalanceMembers:kr,collectProxyChain:jr,getProxyDependencies:Me,findProxyDependencyCycle:Mr};var at={genShuntConf:Br,genProxyConf:Yr,writeGeoRule:Xr};function Br(){let t=w.getShuntSection();if(!t)return;let e=new Map,r=new Map,n=t.dns,s=t.route,o=new yt(it(s.defaultProxyNode),n.defaultDnsNode),i=new dt(n.defaultDnsNode,Ge(n.defaultStrategy),n.useCache==="1");n.nodes.forEach(function(u){let f=new st(u.type,u.tag,u.server,parseInt(u.port,10),void 0);e.set(u.tag,f)});let l=[new wt("direct-out"),new xt("block")];a.sections("hijpass","proxy_node",function(u){u.enabled==="1"&&l.push(new q("127.0.0.1",Number(u.socks_port),u.name))});let p=[new K(parseInt(t.shuntListenPort,10),"tproxy-in"),new bt(parseInt(t.dnsListenPort,10),"dns-in")];if(o.default_domain_resolver&&o.final){let u=e.get(o.default_domain_resolver);if(!u)throw new Error(_('Default global DNS "%s" does not exist').format(o.default_domain_resolver));i.servers.push(ge(u.tag,o.final,u))}if(s.rulesetOutNode){let u=it(s.rulesetOutNode),f=l.find(b=>b.tag===u);if(f){let b=structuredClone(f);if(b.tag="ruleset-out",n.rulesetDnsNode){b.domain_resolver="ruleset-dns-resolver";let y=e.get(n.rulesetDnsNode);if(!y)throw new Error(_('%s "%s" does not exist').format(_("Rule-set DNS"),n.rulesetDnsNode));i.servers.push(ge("ruleset-dns-resolver","ruleset-out",y))}l.push(b)}}return s.rules.forEach(function(u){if(u.enabled!=="1")return;let f=u.ipVersionSplit==="1",b,y=!1;if(w.getRouteRuleVariants(u).forEach(function(T){let c=w.parseRuleList(T.rule),g=qr(c,s.rulesetConvert);if(c.ipVersion=T.ipVersion,s.rulesetConvert==="1")zr(c);else if(c.containGeo()&&(Wr(c),!Kr(c)))return;if(c.isEmpty("set"))return;for(let D of c.ruleSet)r.set(D.tag,Vr(D,s.rulesetOutNode?"ruleset-out":void 0));let O="route",X=it(T.proxyNode);if(T.proxyNode==="hijpass-block"&&(O="reject",X=void 0),o.rules.push(new W(O,X).initRule(c)),O!=="reject"){if(f){g&&(b=b||c,y=!0);return}(c.containDomain()||c.containIp()||c.containRuleSet())&&Be(u,T.rule.name,c,it(u.dnsProxyNode)||X,e,o,i)}}),f&&y&&b){let T=it(u.dnsProxyNode);if(!T)throw new Error(_('Route rule "%s" uses IPv4/IPv6 split and must specify a DNS exit node').format(u.name));Be(u,u.name,b,T,e,o,i)}}),r.forEach(u=>o.rule_set.push(u)),{log:new z(t.logLevel),inbounds:p,outbounds:l,dns:i,route:o}}function Yr(t){if(t.type===d.LOAD_BALANCE)return Hr(t);let e=C.build(t.type,t),r=[e];return Gr(t,e,r),{log:new z(t.log_level),dns:{servers:[{type:"local",tag:"local"}]},inbounds:[new K(Number(t.listen_port),"tproxy-in","127.0.0.1"),new ot(Number(t.socks_port),"socks-in","127.0.0.1")],outbounds:r}}function Hr(t){let e=h.resolveLoadBalanceMembers(t),r=new St("slb",t.url||void 0,t.interval||void 0,t.tolerance?parseInt(t.tolerance,10):void 0,t.idle_timeout||void 0,t.interrupt_exist_connections==="1"?!0:void 0);return r.outbounds=e.map(n=>n.tag),{log:new z(t.log_level),dns:{servers:[{type:"local",tag:"local"}]},inbounds:[new K(Number(t.listen_port),"tproxy-in","127.0.0.1"),new ot(Number(t.socks_port),"socks-in","127.0.0.1")],outbounds:[r,...e.map(n=>new q("127.0.0.1",n.socksPort,n.tag))],route:{final:"slb"}}}function Gr(t,e,r){let n=h.resolveUpstreamProxy(t);n&&(e.detour=n.tag,r.push(new q("127.0.0.1",n.socksPort,n.tag)))}function Xr(){let t=w.getRouteSection(),e=new Set,r=new Set;for(let l of t.rules){if(l.enabled!=="1")continue;let p=w.parseRuleList(l);for(let u of p.geoSite)e.add(u.replace("geosite:",""));for(let u of p.geoIp)r.add(u.replace("geoip:",""))}let n=[...e],s=[...r],o=a.get_first("hijpass","shunt","geoip_ruleset")??[],i=a.get_first("hijpass","shunt","geosite_ruleset")??[];s.length>0?He(o,s)||a.set_first("hijpass","shunt","geoip_ruleset",s):a.set_first("hijpass","shunt","geoip_ruleset",void 0),n.length>0?He(i,n)||a.set_first("hijpass","shunt","geosite_ruleset",n):a.set_first("hijpass","shunt","geosite_ruleset",void 0)}function ge(t,e,r){return new st(r.type,t,r.server,r.server_port,e)}function Vr(t,e){return t.type==="remote"?new mt(t.tag,t.format,t.pathOrUrl,e,void 0):new ht(t.tag,t.format,t.pathOrUrl)}function Ge(t){switch(t){case"4":return"ipv4_only";case"6":return"ipv6_only";case"64":return"prefer_ipv6";case"46":return"prefer_ipv4";default:return}}function Be(t,e,r,n,s,o,i){let l=t.dnsNode,p=l?s.get(l):s.get(o.default_domain_resolver);if(!p)throw new Error(_('Route rule "%s" DNS node "%s" does not exist').format(t.name||e,t.dnsNode||o.default_domain_resolver||""));i.servers.push(ge(Ye(e),n,p)),i.rules.push(new ft("route",Ye(e),Ge(t.dnsStrategy)).initRule(r))}function it(t){return t==="hijpass-block"?"block":t==="hijpass-direct"?"direct-out":t}function Ye(t){return t+"-dns"}function zr(t){t.ruleSet=[];for(let e of t.geoSite){let r=e.replace("geosite:","geosite-");t.ruleSet.push({tag:r,type:"local",format:"binary",pathOrUrl:"/etc/hijpass/ruleset/"+r+".srs"})}for(let e of t.geoIp){let r=e.replace("geoip:","geoip-");t.ruleSet.push({tag:r,type:"local",format:"binary",pathOrUrl:"/etc/hijpass/ruleset/"+r+".srs"})}}function Wr(t){t.geoSite=[],t.geoIp=[]}function Kr(t){return t.containDomain()||t.containIp()||t.containRuleSet()}function qr(t,e){return t.containDomain()||t.containRuleSet()||e==="1"&&t.geoSite.length>0}function He(t,e){return!t||!e?!1:t.length===e.length&&t.every((r,n)=>r===e[n])}var _e=class{protocols=new Map;register(e){this.protocols.set(e.type,e)}build(e,r){let n=this.protocols.get(e);if(!n)throw new Error(`Unsupported xray protocol: ${e}`);return n.build(r)}},I=new _e;var me=class{settings;protocol;tag;streamSettings;constructor(e,r,n,s,o,i,l,p){this.protocol="hysteria",this.tag=n,this.settings={version:2,address:e,port:r},this.streamSettings={network:"hysteria",security:"tls",tlsSettings:{serverName:o,alpn:["h3"]},hysteriaSettings:{version:2,auth:s,...i!==void 0?{udpIdleTimeout:i}:{}},...l||p?{finalmask:{quicParams:{...l?{brutalUp:l}:{},...p?{brutalDown:p}:{}}}}:{}}}};function Xe(t){let e=(t||"").trim();if(e)return e==="0"?"0":e+" mbps"}var $r={type:"hysteria2",build(t){let e=t,r=e.udp_idle_timeout?Number(e.udp_idle_timeout):void 0,n=Xe(e.up_mbps),s=Xe(e.down_mbps);return new me(e.server,Number(e.server_port),e.name,e.password||"",e.tls_server_name||e.server,r,n,s)}};I.register($r);var he=class{settings;protocol;tag;constructor(e,r,n,s,o,i){this.protocol="shadowsocks",this.tag=n,this.settings={address:e,port:r,method:s,password:o,uot:i||void 0,level:0}}},Jr={type:"shadowsocks",build(t){let e=t;return new he(e.server,Number(e.server_port),e.name,e.method,e.password,e.udp_over_tcp==="1"?!0:void 0)}};I.register(Jr);var ye=class{settings;protocol;tag;streamSettings;constructor(e,r,n,s,o="none",i,l=0){this.protocol="vless",this.tag=s,this.settings={address:e,port:r,id:n,encryption:o,level:l},i&&(this.settings.flow=i)}};function kt(t){let e=(t||"").trim();if(!e)return;let r=e.match(/^(\d+)(?:s)?$/);if(!r)return;let n=Number(r[1]);return Number.isFinite(n)&&n>0?n:void 0}function Qr(t,e){let r=(e||"").trim();if(!r)return t;let n=t||"/",s=n.indexOf("#"),o=s>=0?n.slice(0,s):n,i=s>=0?n.slice(s):"",l=o.indexOf("?")>=0?"&":"?";return o+l+"ed="+encodeURIComponent(r)+i}var Zr={type:"vless",build(t){let e=t,r=new ye(e.server,Number(e.server_port),e.uuid,e.name,"none",e.flow||void 0,0),n=e.tls_reality_enabled==="1",s=n?{fingerprint:"chrome",serverName:e.tls_server_name||e.server,password:e.tls_reality_public_key||"",shortId:e.tls_reality_short_id||""}:void 0,o=n?void 0:{alpn:["h2","http/1.1"],serverName:e.tls_server_name||e.server},i=n?"reality":e.tls_server_name?"tls":"none",l={network:"raw",security:i};switch(s&&(l.realitySettings=s),o&&i==="tls"&&(l.tlsSettings=o),e.transport_type||""){case"xhttp":l.network="xhttp",l.xhttpSettings={host:e.transport_xhttp_host||void 0,path:e.transport_xhttp_path||"/",mode:e.transport_xhttp_mode||"auto"};break;case"ws":l.network="websocket",l.wsSettings={host:e.transport_ws_host||void 0,path:Qr(e.transport_ws_path||"/",e.transport_ws_max_early_data)};break;case"grpc":l.network="grpc",l.grpcSettings={serviceName:e.transport_grpc_service_name||"TunService",...kt(e.transport_grpc_idle_timeout)?{idle_timeout:kt(e.transport_grpc_idle_timeout)}:{},...kt(e.transport_grpc_ping_timeout)?{health_check_timeout:kt(e.transport_grpc_ping_timeout)}:{},...e.transport_grpc_permit_without_stream==="1"?{permit_without_stream:!0}:{}};break;case"http":l.network="xhttp",l.xhttpSettings={...e.transport_http_host?{host:e.transport_http_host}:{},path:e.transport_http_path||"/",mode:"stream-one",...e.transport_http_method?{uplinkHTTPMethod:e.transport_http_method}:{}};break;case"httpupgrade":l.network="httpupgrade",l.httpupgradeSettings={host:e.transport_httpupgrade_host||void 0,path:e.transport_httpupgrade_path||"/"};break}return r.streamSettings=l,r}};I.register(Zr);var Z=class{loglevel;dnsLog;constructor(e){this.loglevel=e||"info",this.dnsLog=!1}},It=class{tag;address;port;queryStrategy;domains;skipFallback;disableCache;constructor(e,r,n,s){switch(e){case"tcp":this.address="tcp://"+n,this.port=s;break;case"https":this.address="https://"+n,s&&(this.address+=":"+s),this.address+="/dns-query";break;case"quic":this.address="quic://"+n,this.port=s;break;case"udp":this.address=n,this.port=s;break;default:throw new Error("Invalid xray DNS server type: "+e)}this.tag=r,this.domains=[],this.skipFallback=!0}},jt=class{servers;rules;queryStrategy;disableCache;serveStale;serveExpiredTTL;disableFallback;disableFallbackIfMatch;constructor(e,r){this.servers=[],this.rules=[],this.queryStrategy=e||"UseIP",this.disableCache=!r,this.serveStale=!r,this.serveExpiredTTL=3600,this.disableFallback=!1,this.disableFallbackIfMatch=!0}},tt=class{ruleTag;inboundTag;outboundTag;balancerTag;constructor(e,r,n){this.ruleTag=e,this.inboundTag=r,n==="slb"?this.balancerTag=n:this.outboundTag=n}},Mt=class extends tt{domain;network;ip;protocol;port;constructor(e,r){super(e,void 0,r),this.inboundTag=["tproxy-in"],this.domain=[],this.network=[],this.ip=[],this.protocol=[]}},lt=class extends tt{constructor(e,r){super(void 0,e,r)}},pt=class{rules;domainStrategy;balancers;constructor(){this.rules=[],this.domainStrategy="AsIs",this.balancers=[]}},Bt=class{settings;protocol;tag;streamSettings;constructor(e){this.protocol="blackhole",this.tag=e}},et=class{settings;protocol;tag;constructor(e,r,n){this.protocol="socks",this.tag=n,this.settings={address:e,port:r}}},Yt=class{settings;protocol;tag;constructor(e){this.protocol="dns",this.tag=e,this.settings={rules:[{action:"hijack",qType:"1,28"},{action:"return",rCode:5}]}}},ut=class{settings;protocol;tag;constructor(e){this.protocol="freedom",this.tag=e,this.settings={domainStrategy:"UseIP"}}},Ht=class{tag;selector;fallbackTag;strategy;constructor(e){this.tag=e,this.selector=[],this.fallbackTag=void 0,this.strategy={type:"leastLoad",settings:{expected:1,maxRTT:"1s",tolerance:.05}}}},Gt=class{subjectSelector;pingConfig;constructor(e,r,n,s,o,i){this.subjectSelector=[],this.pingConfig={destination:e||"https://connectivitycheck.gstatic.com/generate_204",connectivity:r||void 0,interval:n||"60s",timeout:s||"2s",sampling:o||3,httpMethod:i||void 0}}},H=class{protocol;tag;listen;port;settings;streamSettings;sniffing;constructor(e,r,n,s){this.protocol="dokodemo-door",this.tag=n,this.listen=s,this.port=r,this.settings={network:"tcp,udp",followRedirect:void 0},e==="tproxy"&&(this.settings.followRedirect=!0,this.streamSettings={sockopt:{tproxy:"tproxy"}},this.sniffing={enabled:!0,destOverride:["http","tls","quic"],routeOnly:!0})}};var xe={genShuntConf:en,genProxyConf:rn};function en(){let t=w.getShuntSection(),e=new Map,r=new pt,n=t.dns,s=new jt(qe(n.defaultStrategy),n.useCache==="1");n.nodes.forEach(function(c){let g=new It(c.type,c.tag,c.server,Number(c.port));e.set(c.tag,g)});let o=t.route,i=[];a.sections("hijpass","proxy_node",function(c){if(c.enabled==="1"){let g=new et("127.0.0.1",Number(c.socks_port),Xt(c.name));c.name===o.defaultProxyNode?i.unshift(g):i.push(g)}}),o.defaultProxyNode==="hijpass-direct"?i.unshift(new ut("direct-out")):i.push(new ut("direct-out")),i.push(new Bt("block")),i.push(new Yt("dns-out"));let l=[new H("tproxy",parseInt(t.shuntListenPort,10),"tproxy-in"),new H("direct",parseInt(t.dnsListenPort,10),"dns-in","::")],p=[new lt(["dns-in"],"dns-out")],u=[],f=e.get(n.defaultDnsNode);if(!f)throw new Error(_('Default global DNS "%s" does not exist').format(n.defaultDnsNode||""));let b=new Map;o.rules.forEach(function(c){if(c.enabled!=="1")return;let g=c.ipVersionSplit==="1",O,X=!1;if(w.getRouteRuleVariants(c).forEach(function(D){let qt=Xt(D.proxyNode)||i[0].tag,V=w.parseRuleList(D.rule),Ae=pn(V);if(V.ipVersion=D.ipVersion,!ln(V)&&(un(D.rule.name,qt,V).forEach($t=>{u.push($t)}),qt!=="block")){if(g){Ae&&(O=O||V,X=!0);return}if(Ae){let $t=Xt(c.dnsProxyNode)||qt;Ve(c,D.rule.name,$t,V,e,f,s,b)}}}),g&&X&&O){let D=Xt(c.dnsProxyNode);if(!D)throw new Error(_('Route rule "%s" uses IPv4/IPv6 split and must specify a DNS exit node').format(c.name));Ve(c,c.name,D,O,e,f,s,b)}});let y=structuredClone(f);return y.tag=We("default"),y.skipFallback=!1,s.servers.push(y),b.forEach((c,g)=>p.push(new lt(c,g))),r.rules=r.rules.concat(p),r.rules=r.rules.concat(u),{log:new Z(we(t.logLevel)),inbounds:l,outbounds:i,dns:s,routing:r}}function rn(t){if(t.type===d.LOAD_BALANCE)return sn(t);let e=I.build(t.type,t);return nn(t,e)}function nn(t,e){let r=ze(t),n=[e];return on(t,e,n),{log:new Z(we(t.log_level)),inbounds:r,outbounds:n}}function ze(t){let e=new H("tproxy",Number(t.listen_port),"tproxy-in");e.sniffing=void 0;let r=new H("direct",Number(t.socks_port),"socks-in");return r.settings={udp:!0},r.protocol="socks",[e,r]}function sn(t){let e=h.resolveLoadBalanceMembers(t),r=new pt;r.rules.push(new tt(void 0,["tproxy-in","socks-in"],"slb"));let n=new Ht("slb");n.selector=[Ft];let s=e.find(p=>p.name===t.fallback_tag)||e[0];n.fallbackTag=s.tag;let o=t.strategy||"leastLoad";n.strategy.type=o,o==="leastLoad"?(t.strategy_expected&&(n.strategy.settings.expected=parseInt(t.strategy_expected,10)),t.strategy_max_rtt&&(n.strategy.settings.maxRTT=t.strategy_max_rtt),t.strategy_tolerance&&(n.strategy.settings.tolerance=parseFloat(t.strategy_tolerance))):n.strategy.settings=void 0,r.balancers.push(n);let i=new Gt(t.probe_url||void 0,t.probe_connectivity||void 0,t.probe_interval||void 0,t.probe_timeout||void 0,t.probe_sampling?parseInt(t.probe_sampling,10):void 0,t.probe_http_method||void 0);i.subjectSelector=[Ft];let l=e.map(p=>new et("127.0.0.1",p.socksPort,p.tag));return{log:new Z(we(t.log_level)),inbounds:ze(t),outbounds:l,routing:r,burstObservatory:i}}function we(t){return t==="warn"?"warning":t}function on(t,e,r){let n=h.resolveUpstreamProxy(t);n&&(an(e,n.tag),r.push(new et("127.0.0.1",n.socksPort,n.tag)))}function an(t,e){t.streamSettings=t.streamSettings||{},t.streamSettings.sockopt=t.streamSettings.sockopt||{},t.streamSettings.sockopt.dialerProxy=e,t.streamSettings.sockopt.domainStrategy="UseIP"}function We(t){return t+"-dns"}function ln(t){return t.isEmpty("geo")?!0:t.containRuleSet()&&!t.containDomain()&&!t.containIp()&&!t.containGeo()}function pn(t){return t.containDomain()||t.geoSite.length>0}function Ve(t,e,r,n,s,o,i,l){let p=We(e);l.has(r)?l.get(r).push(p):l.set(r,[p]);let u=t.dnsNode?s.get(t.dnsNode):o;if(!u)throw new Error(_('Route rule "%s" DNS node "%s" does not exist').format(t.name||e,t.dnsNode||""));let f=structuredClone(u);f.tag=p,f.queryStrategy=qe(t.dnsStrategy),f.domains=Ke(n),i.servers.push(f)}function un(t,e,r){let n=new Mt(t,e);n.network=r.network,n.protocol=fn(r.protocol);let s=r.port.map(l=>String(l));r.portRange&&r.portRange.length>0&&(s=s.concat(r.portRange)),n.port=s.join(","),n.domain=Ke(r),n.domain=n.domain.length>0?n.domain:void 0,n.ip=cn(r),n.ip=n.ip.length>0?n.ip:void 0;let o=[],i=gn(r.ipVersion);if(n.domain){let l=structuredClone(n);i?l.ip=[i]:l.ip=void 0,o.push(l)}if(n.ip){let l=structuredClone(n);l.domain=void 0,o.push(l)}return!n.domain&&!n.ip&&(i&&(n.ip=[i]),o.push(n)),o}function Ke(t){let e=[be(t.domain,"full:"),be(t.domainSuffix,"domain:"),t.domainKeyword,be(t.domainRegex,"regexp:"),t.geoSite];return[].concat(...e.filter(r=>Array.isArray(r)&&r.length>0))}function cn(t){let e=[dn(t.ipCidr,t.ipVersion),t.geoIp];return[].concat(...e.filter(r=>Array.isArray(r)&&r.length>0))}function dn(t,e){return!e||!Array.isArray(t)?t||[]:t.filter(r=>{let n=r.replace(/^!/,"");return n.startsWith("geoip:")||n.startsWith("ext:")?!0:n.indexOf(":")>=0?e===6:/^\d{1,3}(\.\d{1,3}){3}(\/\d+)?$/.test(n)?e===4:!0})}function gn(t){if(t===4)return"0.0.0.0/0";if(t===6)return"::/0"}function Xt(t){return t==="hijpass-block"?"block":t==="hijpass-direct"?"direct-out":t}function qe(t){switch(t){case"4":return"UseIPv4";case"6":return"UseIPv6";case"64":case"46":return"UseIP";default:return}}function fn(t){if(!t)return;let e=t.map(r=>{switch(r){case"http":case"tls":case"quic":case"bittorrent":return r;default:throw new Error("Unsupported xray rule protocol: "+r)}}).filter(r=>r!==void 0);return e.length===0?void 0:e}function be(t,e){return Array.isArray(t)?t.map(r=>e+r):[]}var N=m,$e={getCoreAdapter:function(t){switch(k(t)){case N.SING_BOX:return at;case N.XRAY:return xe;default:throw new Error("Unsupported core: "+t)}}},Se={genProxyConf:function(t,e){switch(k(t)){case N.SING_BOX:return at.genProxyConf(e);case N.XRAY:return xe.genProxyConf(e);default:throw new Error("Unsupported core: "+t)}}};var _n={hijpass:{client_dir:"/etc/hijpass/client",shunt_conf:"/etc/hijpass/shunt.json",ip_direct:"/etc/hijpass/rules/ip-direct.txt",ip_proxy:"/etc/hijpass/rules/ip-proxy.txt",domain_direct:"/etc/hijpass/rules/domain-direct.txt",domain_proxy:"/etc/hijpass/rules/domain-proxy.txt",nft:"/etc/hijpass/fw4-template.nft",nft_hook:"/etc/hijpass/hook/nft-hook.sh",dns_hook:"/etc/hijpass/hook/dns-hook.sh"},hijserver:{server_dir:"/etc/hijpass/server"}};function mn(t){let e=(t||"").trim().replace(/\r\n/g,` `);return e?e+` `:""}function ve(t,e="hijpass"){let r=a.get_first(e,e,t);if(r)return r;let n=_n[e]?.[t];return n||(console.log(t+" path is empty"),"")}function hn(t,e,r,n){if(!e)throw new Error(_("Configuration file directory is empty"));let o=n?.section?.formvalue?.(r,"name")||a.get(t,r,"name")||r;return e+"/"+o+"-"+r+".json"}function yn(t){let e=t.name||t[".name"];return ve("client_dir")+"/"+e+"-"+t[".name"]+".json"}function bn(t){let e=t.name||t[".name"];return ve("server_dir","hijserver")+"/"+e+"-"+t[".name"]+".json"}var P={normalizeFileContent:mn,getFilePath:ve,getNodeConfigFilePath:hn,getProxyConfigFilePath:yn,getServerConfigFilePath:bn};async function xn(t){async function e(r,n,s){let o=s?[r,n,s]:[r,n];await x.exec("/usr/lib/hijpass/rm.sh",o)}if(t?.hijpass){for(let r of t.hijpass)if(r.length===2&&r[0]==="remove"&&await e("proxy",r[1]),r.length===4&&r[0]==="set"&&r[2]==="name"){let n=a.get("hijpass",r[1]),s=n?P.getProxyConfigFilePath(n):void 0;await e("proxy",r[1],s)}}if(t?.hijserver){for(let r of t.hijserver)if(r.length===2&&r[0]==="remove"&&await e("server",r[1]),r.length===4&&r[0]==="set"&&r[2]==="name"){let n=a.get("hijserver",r[1]),s=n?P.getServerConfigFilePath(n):void 0;await e("server",r[1],s)}}}var Je={cleanupChangedNodeFiles:xn};function wn(t,e){if(!(Array.isArray(e)&&e.length===0)&&e!==null&&!(typeof e=="number"&&!Number.isFinite(e))&&!(typeof e=="string"&&!e.trim()))return e}var Vt={omitEmptyReplacer:wn};var Qe={getShuntConfData:function(){if(a.get_first("hijpass","shunt","enabled")==="0"||a.get_first("hijpass","shunt","config_type")!=="tmpl")return"";let r=a.get_first("hijpass","shunt","type");return JSON.stringify($e.getCoreAdapter(r).genShuntConf(),Vt.omitEmptyReplacer,2)}};var Ne=class{container=null;notifications=new Map;notificationId=0;autoCloseTimers=new Map;constructor(){this.initContainer()}initContainer(){this.container||(this.container=document.createElement("div"),this.container.id="notification-container",this.container.style.cssText=` position: fixed; top: 20px; right: 20px; z-index: 9999; pointer-events: none; `,document.body.appendChild(this.container))}getTypeConfig(e){let r={success:{bgColor:"#4caf50",borderColor:"#45a049",icon:"\u2713",textColor:"#fff"},error:{bgColor:"#f44336",borderColor:"#da190b",icon:"\u2715",textColor:"#fff"},warning:{bgColor:"#ff9800",borderColor:"#e68900",icon:"\u26A0",textColor:"#fff"},info:{bgColor:"#2196f3",borderColor:"#0b7dda",icon:"\u2139",textColor:"#fff"}};return r[e]||r.info}show(e){let{message:r,title:n,content:s,type:o="info",duration:i=3e3,icon:l=!1}=e;this.initContainer();let p=`notification-${++this.notificationId}`,u=this.getTypeConfig(o),f=n||r,b=s,y=document.createElement("div");if(y.id=p,y.style.cssText=` background-color: ${u.bgColor}; border-left: 4px solid ${u.borderColor}; color: ${u.textColor}; padding: 16px 20px; margin-bottom: 10px; border-radius: 4px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); display: flex; align-items: flex-start; gap: 12px; min-width: 300px; max-width: 400px; word-break: break-word; animation: slideInRight 0.3s ease-out; pointer-events: auto; transition: all 0.3s ease; font-size: 14px; font-weight: 500; `,l){let g=document.createElement("span");g.style.cssText=` font-size: 20px; font-weight: bold; flex-shrink: 0; display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; margin-top: 2px; `,g.textContent=u.icon,y.appendChild(g)}let T=document.createElement("div");if(T.style.cssText=` flex: 1; display: flex; flex-direction: column; gap: 4px; `,f){let g=document.createElement("div");g.style.cssText=` font-weight: 600; font-size: 14px; line-height: 1.4; `,g.textContent=f,T.appendChild(g)}if(b){let g=document.createElement("div");g.style.cssText=` font-weight: 400; font-size: 13px; line-height: 1.4; opacity: 0.9; white-space: pre-line; `,g.textContent=b,T.appendChild(g)}y.appendChild(T);let c=document.createElement("button");if(c.style.cssText=` background: none; border: none; color: ${u.textColor}; cursor: pointer; font-size: 20px; padding: 0; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; opacity: 0.7; transition: opacity 0.2s; `,c.innerHTML="\xD7",c.onmouseover=()=>c.style.opacity="1",c.onmouseout=()=>c.style.opacity="0.7",c.onclick=g=>{g.stopPropagation(),this.remove(p)},y.appendChild(c),this.container.appendChild(y),this.notifications.set(p,y),i>0){let g=setTimeout(()=>{this.remove(p)},i);this.autoCloseTimers.set(p,g),y.onmouseenter=()=>{let O=this.autoCloseTimers.get(p);O&&(clearTimeout(O),this.autoCloseTimers.delete(p))},y.onmouseleave=()=>{if(this.notifications.has(p)){let O=setTimeout(()=>{this.remove(p)},i);this.autoCloseTimers.set(p,O)}}}return p}remove(e){let r=this.notifications.get(e);if(!r)return;let n=this.autoCloseTimers.get(e);n&&(clearTimeout(n),this.autoCloseTimers.delete(e)),r.style.animation="slideOutRight 0.3s ease-in",r.style.opacity="0",setTimeout(()=>{r.remove(),this.notifications.delete(e)},300)}success(e,r){return this.show({message:e,type:"success",duration:r})}error(e,r){return this.show({message:e,type:"error",duration:r})}warning(e,r){return this.show({message:e,type:"warning",duration:r})}info(e,r){return this.show({message:e,type:"info",duration:r})}clear(){this.notifications.forEach((e,r)=>{this.remove(r)})}},Sn=new Ne;function Ze(){if(document.getElementById("notification-styles"))return;let t=document.createElement("style");t.id="notification-styles",t.textContent=` @keyframes slideInRight { from { transform: translateX(400px); opacity: 0; } to { transform: translateX(0); opacity: 1; } } @keyframes slideOutRight { from { transform: translateX(0); opacity: 1; } to { transform: translateX(400px); opacity: 0; } } @media (max-width: 768px) { #notification-container { left: 10px !important; right: 10px !important; top: 10px !important; } #notification-container > div { min-width: auto !important; max-width: 100% !important; } } `,document.head.appendChild(t)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Ze):Ze();var G=Sn;var ct={show:function(t){return G.show(t)},success:function(t,e,r){return G.show({title:t,content:e,type:"success",duration:r})},error:function(t,e,r){return G.show({title:t,content:e,type:"error",duration:r})},warning:function(t,e,r){return G.show({title:t,content:e,type:"warning",duration:r})},info:function(t,e,r){return G.show({title:t,content:e,type:"info",duration:r})},clear:function(){return G.clear()}};var Te={createProxyConfigFromSection:function(t){let e=t.type,r;switch(e){case d.LOAD_BALANCE:r=new Ct;break;case d.HYSTERIA2:r=new Rt;break;case d.SHADOWSOCKS:r=new Dt;break;case d.TUIC:r=new At;break;case d.SHADOWTLS:r=new Ut;break;case d.VLESS:r=new Lt;break;case d.CUSTOM:r=new Pt;break;default:return null}return Object.keys(t).forEach(n=>{n!==".type"&&n!==".name"&&n!==".anonymous"&&Reflect.set(r,n,t[n])}),r.cfgid=t[".name"],r}};function vn(t){return/^(\d{1,3}\.){3}\d{1,3}$/.test(t)||/^[0-9a-fA-F:]+$/.test(t)}function Nn(t){return Array.isArray(t?.outbounds)?t.outbounds[0]:void 0}function Tn(t,e){let r=Nn(t);return r?r.server?(r.server=e,!0):r.settings?.address?(r.settings.address=e,!0):r.settings?.servers?.[0]?.address?(r.settings.servers[0].address=e,!0):r.settings?.vnext?.[0]?.address?(r.settings.vnext[0].address=e,!0):!1:!1}async function En(t,e){if(!t.upstream_proxy_node||!t.server||vn(t.server))return;let r=await x.exec_direct("/usr/lib/hijpass/net.sh",["resolve",t.server],"json");if(!r?.address)throw new Error(_("Resolve proxy server failed: %s").format(t.server));if(!Tn(e,r.address))throw new Error(_("Unsupported proxy config server field: %s").format(t.name||t.server))}async function On(){let t=[];if(a.sections("hijpass","proxy_node",r=>{let n=Te.createProxyConfigFromSection(r);if(r.enabled!=="1"||!n||n.type===d.CUSTOM||n.core===N.CUSTOM)return;let s=Se.genProxyConf(n.core,n);t.push(En(n,s).then(()=>{let o=typeof s=="string"?s:JSON.stringify(s,Vt.omitEmptyReplacer,2);return x.write(P.getProxyConfigFilePath(r),o)}))}),t.length===0)return;(await Promise.allSettled(t)).forEach(r=>{if(r.status==="rejected")throw new Error(r.reason?.message||String(r.reason))})}function Cn(t){let e=Te.createProxyConfigFromSection(t);if(e)return Se.genProxyConf(e.core,e)}var tr={writeGeneratedProxyConfigs:On,generateProxyConfigFromSection:Cn};var rt={setAnonymousGridSectionMembers:function(t){rt.setGridSectionMembers(t),t.anonymous=!0,t.sectiontitle=function(e){return a.get("hijpass",e,"name")||a.get("hijpass",e,"tag")||e}},setGridSectionMembers:function(t){t.anonymous=!1,t.addremove=!0,t.sortable=!0,t.nodescriptions=!0,t.rowcolors=!0},setAnonymousSection:function(t){t.anonymous=!0,t.addremove=!1},simpleHash:function(t){let e=0;t=t||"";for(let r=0;r{if(e.listen_port&&e.enabled==="1"){let r=_("Proxy node %s: %s").format(e.name,e.listen_port);t.value(e.listen_port,r)}})},loadProxyNodeOptions:function(t,e=!0){t.load=function(r){return delete this.keylist,delete this.vallist,this.value("hijpass-direct",_("Direct")),e&&this.value("hijpass-block",_("Block")),a.sections("hijpass","proxy_node",function(n){if(n.name&&n.enabled==="1"){let s=n.name;n.socks_port&&(s+=" ("+n.socks_port+")"),this.value(n.name,s)}}.bind(this)),S.ListValue.prototype.load.apply(this,[r])}},getEnabledProxyNodeOptions:function(t=!0){let e=[];return t&&(e.push({value:"hijpass-direct",label:_("Direct")}),e.push({value:"hijpass-block",label:_("Block")})),a.sections("hijpass","proxy_node",r=>{if(r.name&&r.enabled==="1"){let n=r.name;r.socks_port&&(n+=" ("+r.socks_port+")"),e.push({value:r.name,label:n})}}),e}};function nr(t){let e=Number(t);return Number.isInteger(e)&&e>0&&e<=65535}function er(){let t=a.get_first("hijpass","dns"),e=t?.cdg_port||"";return{available:t?.dns_service==="chinadns-ng"&&nr(e),port:e}}function rr(){let t=a.get_first("hijpass","shunt"),e=t?.dns_listen_port||"";return{available:t?.enabled!=="0"&&nr(e),port:e}}function Pn(t,e){let r=t;return e.port&&(r+=": "+e.port),e.available||(r+=" - "+_("Not available")),r}var nt={getSource:function(){return a.get_first("hijpass","firewall","dns_forward")||A.NONE},getPreRoutingTarget:er,getRoutingTarget:rr,getTargetLabel:Pn,validateSource:function(t){return!t||t===A.NONE?!0:t===A.PRE_ROUTING?er().available?!0:_("Independent DNS is unavailable or has no valid listen port"):t===A.ROUTING?rr().available?!0:_("Core DNS is disabled or has no valid listen port"):_("Unknown DNS forwarding source: %s").format(t)}};var sr=["http","tls","quic","bittorrent"],Rn=["hysteria2","vless"];function Dn(t){return t?Array.isArray(t)?t.filter(e=>e):[t]:[]}function An(t){return t==="hijpass-direct"||t==="hijpass-block"}function R(t,e){return e.length===0?!0:(ct.warning(t,e.join(` `),8e3),!1)}function Un(){return a.get_first("hijpass","shunt","enabled")!=="0"&&a.get_first("hijpass","shunt","config_type")==="tmpl"}function Ln(){let t=new Set;a.sections("hijpass","proxy_node",function(o){o.name&&t.add(o.name)});let e=[];function r(o,i){o&&!An(o)&&!t.has(o)&&e.push(i)}let n=a.get_first("hijpass","shunt","default_proxy_node");n?r(n,_('Default global exit "%s" does not exist').format(n)):e.push(_("Default global exit is not configured"));let s=a.get_first("hijpass","shunt","ruleset_out_node");return r(s,_('Rule-set exit "%s" does not exist').format(s)),a.sections("hijpass","shunt_route_rule",function(o){if(o.enabled!=="1")return;let i=o.name||o[".name"];if(o.ip_version_split==="1"){o.proxy_node_v4?r(o.proxy_node_v4,_('Route rule "%s" IPv4 proxy node "%s" does not exist').format(i,o.proxy_node_v4)):e.push(_('Route rule "%s" IPv4 proxy node is not configured').format(i)),o.proxy_node_v6?r(o.proxy_node_v6,_('Route rule "%s" IPv6 proxy node "%s" does not exist').format(i,o.proxy_node_v6)):e.push(_('Route rule "%s" IPv6 proxy node is not configured').format(i));return}o.proxy_node?r(o.proxy_node,_('Route rule "%s" proxy node "%s" does not exist').format(i,o.proxy_node)):e.push(_('Route rule "%s" proxy node is not configured').format(i))}),R(_("Configuration contains missing proxy nodes"),e)}function Fn(){let t=new Set;if(a.sections("hijpass","proxy_node",function(s){s.enabled!=="1"&&s.name&&t.add(s.name)}),t.size===0)return!0;let e=[],r=a.get_first("hijpass","shunt","default_proxy_node");r&&t.has(r)&&e.push(_('Default global exit "%s" is not enabled').format(r));let n=a.get_first("hijpass","shunt","ruleset_out_node");return n&&t.has(n)&&e.push(_('Rule-set exit "%s" is not enabled').format(n)),a.sections("hijpass","shunt_route_rule",function(s){if(s.enabled!=="1")return;let o=s.name||s[".name"];s.ip_version_split==="1"?(s.proxy_node_v4&&t.has(s.proxy_node_v4)&&e.push(_('Route rule "%s" IPv4 proxy node "%s" is not enabled').format(o,s.proxy_node_v4)),s.proxy_node_v6&&t.has(s.proxy_node_v6)&&e.push(_('Route rule "%s" IPv6 proxy node "%s" is not enabled').format(o,s.proxy_node_v6))):s.proxy_node&&t.has(s.proxy_node)&&e.push(_('Route rule "%s" proxy node "%s" is not enabled').format(o,s.proxy_node)),s.dns_proxy_node&&t.has(s.dns_proxy_node)&&e.push(_('Route rule "%s" DNS exit node "%s" is not enabled').format(o,s.dns_proxy_node))}),R(_("Configuration contains disabled nodes"),e)}function kn(){let t=h.getProxySectionMap(),e=[];return t.forEach(r=>{if(r.enabled!=="1"||r.type!==d.LOAD_BALANCE)return;let n=h.getProxyName(r),s=k(r.core);s!==m.SING_BOX&&s!==m.XRAY&&e.push(_('Load balancing node "%s" has an unsupported backend core').format(n));let o=h.normalizeProxyNodeList(r.member_node);if(o.length===0){e.push(_('Load balancing node "%s" has no member nodes').format(n));return}let i=o.filter((l,p)=>o.indexOf(l)!==p);i.length>0&&e.push(_('Load balancing node "%s" contains duplicate member nodes: %s').format(n,Array.from(new Set(i)).join(", "))),o.forEach(l=>{if(l===n){e.push(_('Load balancing node "%s" cannot include itself').format(n));return}let p=t.get(l);if(!p){e.push(_('Load balancing node "%s" member node "%s" does not exist').format(n,l));return}p.type===d.LOAD_BALANCE&&e.push(_('Load balancing node "%s" cannot contain load balancing member "%s"').format(n,l)),p.enabled!=="1"&&e.push(_('Load balancing node "%s" member node "%s" is not enabled').format(n,l)),h.isPort(p.socks_port)||e.push(_('Load balancing node "%s" member node "%s" has no valid SOCKS port configured').format(n,l))}),r.fallback_tag&&o.indexOf(r.fallback_tag)<0&&e.push(_('Load balancing node "%s" fallback node "%s" is not a member').format(n,r.fallback_tag))}),R(_("Configuration contains invalid load balancing nodes"),e)}function In(){let t=h.getProxySectionMap(),e=[];t.forEach(n=>{if(n.enabled!=="1"||n.type===d.LOAD_BALANCE||!n.upstream_proxy_node)return;let s=h.getProxyName(n),o=n.upstream_proxy_node,i=t.get(o);if(!i){e.push(_('Proxy node "%s" upstream proxy node "%s" does not exist').format(s,o));return}i.enabled!=="1"&&e.push(_('Proxy node "%s" upstream proxy node "%s" is not enabled').format(s,o)),h.isPort(i.socks_port)||e.push(_('Proxy node "%s" upstream proxy node "%s" has no valid SOCKS port configured').format(s,o));let l=h.collectProxyChain(s,t);!l.cycle&&l.chain.length>le&&e.push(_('Proxy node "%s" nesting chain exceeds %d nodes: %s').format(s,le,l.chain.join(" -> ")))});let r=h.findProxyDependencyCycle(t);return r&&e.push(_("Proxy node dependency chain has a cycle: %s").format(r.join(" -> "))),R(_("Configuration contains invalid upstream proxy nodes"),e)}function jn(){let t=new Set,e=new Set;a.sections("hijpass","shunt_dns_node",function(i){i.tag&&(t.add(i.tag),i.enabled==="0"&&e.add(i.tag))});let r=[],n=[];function s(i,l){if(i){if(!t.has(i)){r.push(_('%s "%s" does not exist').format(l,i));return}e.has(i)&&n.push(_('%s "%s" is not enabled').format(l,i))}}let o=a.get_first("hijpass","shunt","default_dns_node");return o?s(o,_("Default global DNS")):r.push(_("Default global DNS is not configured")),s(a.get_first("hijpass","shunt","ruleset_dns_node"),_("Rule-set DNS")),a.sections("hijpass","shunt_route_rule",function(i){i.enabled==="1"&&s(i.dns_node,_('Route rule "%s" DNS node').format(i.name||i[".name"]))}),R(_("Configuration contains missing DNS nodes"),r)&&R(_("Configuration contains disabled DNS nodes"),n)}function Mn(){let t=new Set;a.sections("hijpass","proxy_node",function(s){s.name&&t.add(s.name)});let e=a.get_first("hijpass","shunt","type"),r=a.get_first("hijpass","shunt","ruleset_convert"),n=[];return w.getRouteSection().rules.forEach(function(s){if(s.enabled!=="1")return;let o=s.dnsProxyNode,i=s.name||_("Unnamed Rule");if(Bn(s,e,r)&&!o){n.push(_('Route rule "%s" uses IPv4/IPv6 split and must specify a DNS exit node').format(i));return}o&&o!=="hijpass-direct"&&!t.has(o)&&n.push(_('Route rule "%s" DNS exit node "%s" does not exist').format(i,o))}),R(_("Configuration contains invalid DNS exit nodes"),n)}function Bn(t,e,r){if(t.ipVersionSplit!=="1")return!1;let n=w.parseRuleList(t);return e===N.XRAY?n.containDomain()||n.geoSite.length>0:n.containDomain()||n.containRuleSet()||r==="1"&&n.geoSite.length>0}function Yn(){let t=new Set;a.sections("hijpass","proxy_node",function(i){i.enabled==="1"&&i.listen_port&&t.add(i.listen_port)});let e=a.get_first("hijpass","firewall","proxy_port"),r=a.get_first("hijpass","firewall","shunt_port"),n=a.get_first("hijpass","shunt","enabled")!=="0",s=a.get_first("hijpass","shunt","shunt_listen_port"),o=[];return e&&!t.has(e)&&o.push(_("Firewall proxy port %s does not reference an enabled proxy node").format(e)),r&&!t.has(r)&&!(n&&s===r)&&o.push(_("Firewall shunt port %s does not reference an enabled proxy node or shunt service").format(r)),R(_("Configuration conflict"),o)}function Hn(){let t=nt.validateSource(nt.getSource());return t===!0||R(_("Configuration conflict"),[t])}function Gn(){if(a.get_first("hijpass","dns","dns_service")!=="chinadns-ng")return!0;let e=nt.getRoutingTarget(),r=e.port?"127.0.0.1#"+e.port:"",n=[];return[["direct_dns",_("Direct Domain DNS")],["proxy_dns",_("Proxy Domain DNS")]].forEach(([s,o])=>{let i=a.get_first("hijpass","dns",s);!i||i==="dnsmasq"||i==="system"||i==="custom"||(!e.available||i!==r)&&n.push(_("%s references an unavailable Core DNS port").format(o))}),R(_("Configuration conflict"),n)}function Xn(){if(a.get_first("hijpass","shunt","type")!==N.XRAY)return!0;let e=[];return a.sections("hijpass","shunt_route_rule",function(r){if(r.enabled!=="1")return;let n=Dn(r.protocol).filter(s=>sr.indexOf(s)===-1);n.length>0&&e.push(_('Route rule "%s" contains protocols unsupported by Xray: %s').format(r.name||r[".name"],n.join(", ")))}),e.length>0?(ct.warning(_("Unsupported Xray protocol configuration"),e.join(` `)+` `+_("Xray route protocol only supports: %s").format(sr.join(", ")),8e3),!1):!0}function Vn(){if(a.get_first("hijpass","shunt","type")!==N.XRAY)return!0;let e=[];return a.sections("hijpass","shunt_dns_node",function(r){r.enabled!=="0"&&r.type==="tls"&&e.push(_('DNS node "%s" uses TLS, which is only supported by sing-box').format(r.tag||r[".name"]))}),R(_("Unsupported Xray DNS configuration"),e)}function zn(){let t=[];return a.sections("hijpass","proxy_node",function(e){e.enabled!=="1"||k(e.core)!==N.XRAY||e.tls_insecure!=="1"||Rn.indexOf(e.type)!==-1&&t.push(_('Proxy node "%s" enables insecure TLS, which is not supported by current Xray').format(e.name||e[".name"]))}),R(_("Unsupported Xray TLS configuration"),t)}function Wn(t,e,r){return new Promise(n=>{B.showModal(t,[E("div",{style:["box-sizing:border-box","width:100%","margin:0 0 14px 0","padding:14px 16px","border-radius:4px","background:rgba(127,127,127,0.08)","line-height:1.55"].join(";")},[E("div",{style:"margin:0 0 12px 0"},e),E("div",{style:"display:flex;flex-direction:column;gap:6px;margin:0"},r.map(s=>E("div",{style:"margin:0;word-break:break-word"},s)))]),E("div",{style:"display:flex;justify-content:flex-end;gap:10px;margin:0"},[E("button",{class:"btn cbi-button",click:function(s){s.preventDefault(),B.hideModal(),n(!1)}},_("Cancel")),E("button",{class:"btn cbi-button-action",click:function(s){s.preventDefault(),B.hideModal(),n(!0)}},_("Continue Apply"))])])})}function Kn(t,e,r){let n=w.parseRuleList(t),s=t.name||t[".name"]||_("Unnamed Rule"),o=r==="1";if(e===N.XRAY)return n.isEmpty("geo")?_('Route rule "%s" has no valid match conditions for Xray').format(s):n.containRuleSet()&&!n.containDomain()&&!n.containIp()&&!n.containGeo()?_('Route rule "%s" only contains rule-set target conditions unsupported by Xray').format(s):null;if(e===N.SING_BOX){if(!o&&n.containGeo()&&(n.geoSite=[],n.geoIp=[],!n.containDomain()&&!n.containIp()&&!n.containRuleSet()))return _('Route rule "%s" has no target conditions for sing-box after removing unconverted geosite/geoip').format(s);if(n.isEmpty("set")&&!(o&&n.containGeo()))return _('Route rule "%s" has no valid match conditions for sing-box').format(s)}return null}function qn(){let t=a.get_first("hijpass","shunt","type"),e=a.get_first("hijpass","shunt","ruleset_convert"),r=[];return w.getRouteSection().rules.forEach(n=>{if(n.enabled!=="1")return;let s=Kn(n,t,e);s&&r.push(s)}),r.length>0?Wn(_("Some route rules will be skipped"),_("The following rules have no valid configuration for the current core and options, so they will not be written to the final configuration. Continue applying the configuration?"),r):!0}var or={runSaveApplyPrechecks:async function(){return!In()||!kn()||!zn()||!Yn()||!Hn()||!Gn()?!1:Un()?Ln()&&Fn()&&jn()&&Mn()&&await qn()&&Xn()&&Vn():!0}};function $n(){return a.get_first("hijpass","hijpass","enabled")==="0"}var ir={genHandleSaveApply:function(){return async function(t,e){try{if(await this.handleSave(t),$n()){await a.save(),await B.changes.apply(e=="0");return}if(!await or.runSaveApplyPrechecks())return;if(a.get_first("hijpass","shunt","type")===N.SING_BOX&&a.get_first("hijpass","shunt","ruleset_convert")==="1"&&at.writeGeoRule(),a.get_first("hijpass","shunt","config_type")==="tmpl"){let o=Qe.getShuntConfData();await x.write(P.getFilePath("shunt_conf"),o),a.set_first("hijpass","shunt","shunt_hash",o?String(rt.simpleHash(o)):"-1")}await a.save();let s=await a.changes();await Je.cleanupChangedNodeFiles(s),await tr.writeGeneratedProxyConfigs(),await B.changes.apply(e=="0")}catch(r){console.log(r),ct.error(_("Configuration Apply Failed"),_(r.message),5e3)}}}};var ar=poll;var lr=rpc;var Ee=lr.declare({object:"service",method:"list",params:["name"],expect:{"":{}}}),Oe={};function ur(t){return t||"all"}function pr(t){return"service_status_"+ur(t)}var F={getServiceInstances:async function(t){return(await Ee(t))?.[t]?.instances??{}},getServiceInfo:async function(){let t=await Ee("hijpass"),r=(await Ee("hijserver"))?.hijserver?.instances??{},n=t?.hijpass?.instances??{};return{proxyInfos:F.getInstanceName("hijpass","proxy_node").map(s=>n?.[s]??void 0).filter(s=>s),shuntInfo:n?.[F.getInstanceName("hijpass","shunt")[0]]??void 0,dnsInfo:n?.[F.getInstanceName("hijpass","dns")[0]]??void 0,serverInfos:F.getInstanceName("hijserver","server_node").map(s=>r?.[s]??void 0).filter(s=>s)}},getInstanceName:function(t,e){return a.sections(t,e).map(r=>{let n=r[".name"],s=r.name??r.tag??r.dns_service;return s||(s=e),n+"-"+s})},renderServiceStatusText:function(t,e){let r="",n='%s %s',s=(t?.proxyInfos??[]).filter(u=>u?.running).length>0,o=(t?.serverInfos??[]).filter(u=>u?.running).length>0,i=t?.shuntInfo?.running??!1,l=t?.dnsInfo?.running??!1,p=function(u,f){return f?n.format("green",u,_("Running")):n.format("red",u,_("Not Running"))};switch(e){case"dns":r+=p(_("Independent DNS"),l);break;case"shunt":r+=p(_("Proxy Routing"),i);break;case"server":r+=p(_("Local Server"),o);break;case"proxy":r+=p(_("Proxy Node"),s);break;default:r+=p(_("Proxy Node"),s),r+=p(_("Proxy Routing"),i),r+=p(_("Independent DNS"),l),r+=p(_("Local Server"),o)}return r},refreshServiceStatus:function(t){let e=ur(t);if(!Oe[e]){let r=pr(t);Oe[e]=async function(){let n=await L.resolveDefault(F.getServiceInfo()),s=document.getElementById(r);s&&(s.innerHTML=F.renderServiceStatusText(n,t))}}return Oe[e]},renderServiceStatus:function(t){return function(){let e=F.refreshServiceStatus(t);return ar.add(e),window.setTimeout(e,0),E("div",{class:"hijpass-service-status"},E("fieldset",{class:"cbi-section"},[E("p",{id:pr(t),style:"display: flex; gap: 1rem;"},_("Fetching Status..."))]))}},createStatusSection:function(t,e){let r=t.section(S.TypedSection);return r.anonymous=!0,r.render=F.renderServiceStatus(e),r}};var Jn=[{id:"baidu",name:"Baidu",url:"https://www.baidu.com",svg:'Baidu'},{id:"google",name:"Google",url:"https://www.google.com/ncr",svg:'Google'},{id:"github",name:"GitHub",url:"https://github.com",svg:'Github'},{id:"bilibili",name:"Bilibili",url:"https://www.bilibili.com",svg:'bilibili'}];function Qn(t){j(t,_("Restarting Service"),"neutral"),x.exec("/etc/init.d/hijpass",["restart"]).then(function(e){e.code===0?(j(t,_("Service Restarted"),"success"),setTimeout(function(){location.reload()},2e3)):j(t,_("Service Restart Failed")+(e.stderr||e.stdout),"error")}).catch(function(e){j(t,_("Service Restart Failed")+e.message,"error")})}function Zn(t){j(t,_("Refreshing Firewall"),"neutral"),x.exec("/usr/lib/hijpass/nft.sh",["reset"]).then(function(e){e.code===0?j(t,_("Firewall Refreshed"),"success"):j(t,_("Firewall Refresh Failed")+(e.stderr||e.stdout),"error")}).catch(function(e){j(t,_("Firewall Refresh Failed")+e.message,"error")})}function j(t,e,r){t.textContent=e,t.style.color=r==="success"?"#4caf50":r==="error"?"#f44336":"#666"}function ts(t){let e=E("div",{style:"font-size: 13px; color: #f44336;"},_("Click to Test")),r;return r=E("div",{class:"connectivity-btn cbi-section",style:"width: 100%; height: 100px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 15px; border-radius: 8px; padding: 0; box-shadow: 0 0 2rem 0 rgba(136, 152, 170, .15); border:1px solid rgba(0, 0, 0, .05); cursor: pointer;",click:function(){es(t.url,r,e)}},[E("div",{style:"display: flex; align-items: center; justify-content: center;"},[E("span",{style:"width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;"},[E("raw",{},t.svg)])]),E("div",{style:"font-weight: bold; font-size: 16px; margin-bottom: 2px;"},_(t.name)),e]),E("div",{class:"connectivity-test-button",style:"flex: 1; min-width: 120px;"},[r])}function es(t,e,r){e.dataset.loading!=="1"&&(r.textContent=_("Testing"),r.style.color="#666",e.dataset.loading="1",e.style.opacity="0.7",x.exec_direct("/usr/lib/hijpass/connect.sh",[t,"5"],"json").then(n=>{cr(e,r,n.success,n)}).catch(n=>{console.error(n),cr(e,r,!1,void 0)}))}function cr(t,e,r,n){delete t.dataset.loading,t.style.opacity="1",r?/^([45])\d{2}$/.test(n.http_code)?(e.textContent=_("Connection Abnormal")+n.http_code,e.style.color="#f44336"):(e.textContent=n.tls_handshake_time_ms+" ms",e.style.color="#4caf50"):(e.textContent=_("Test Failed"),e.style.color="#f44336")}var Ce={createActionButtons:function(){let t=E("span",{style:"margin-left: 10px; font-size: 12px; color: #666;"});return E("div",{class:"cbi-value",style:"margin-bottom: 2rem;"},[E("label",{class:"cbi-value-title",style:"visibility: hidden"},_("Service Control")),E("div",{class:"cbi-value-field"},[E("button",{class:"cbi-button cbi-button-action",style:"margin-right: 10px;",type:"button",click:function(e){e.preventDefault(),Qn(t)}},_("Restart Service")),E("button",{class:"cbi-button cbi-button-action",style:"margin-right: 10px;",type:"button",click:function(e){e.preventDefault(),Zn(t)}},_("Refresh Firewall")),t])])},createConnectivityTest:function(){return E("div",{id:"custom-connectivity-test",class:"cbi-map"},[E("h2",{},_("Website Connectivity Test")),E("div",{class:"cbi-section",style:"display: flex; gap: 18px; padding: 18px; justify-content: center;"},Jn.map(t=>ts(t)))])}};function zt(t){return a.get_first("hijpass",t)||{}}function Wt(t){return t?(Array.isArray(t)?t:[t]).filter(Boolean):[]}function M(t){let e=Number(t);return Number.isInteger(e)&&e>0&&e<=65535}function dr(t){return t?t.replace("#",":"):_("Not configured")}function rs(t){return t.acl_default_allow==="1"?_("Bypass mode"):_("Proxy mode")}function _r(t){return _("Firewall ACL")+" \xB7 "+rs(t)}function Pe(t){if(t.acl_default_allow==="1"){let n=Wt(t.proxy_mac_exclude_list).length,s=Wt(t.proxy_iface_exclude_list).length;return _("Excluded: %s devices, %s interfaces").format(String(n),String(s))}let e=Wt(t.proxy_mac_list).length,r=Wt(t.proxy_iface_list).length;return _("Selected: %s devices, %s interfaces").format(String(e),String(r))}function mr(t,e){if(!M(t))return[{title:e,detail:_("No valid listen port"),tone:"warning",page:"firewall"}];let r=h.getProxySectionMap(),n=Array.from(r.values()).find(i=>i.enabled==="1"&&i.listen_port===t),s=[{title:e+": "+t,tone:"proxy",page:"firewall"}];if(!n)return s.push({title:_("Proxy node unavailable"),detail:_("No enabled node uses this port"),tone:"warning",page:"proxy"}),s;if(n.type===d.LOAD_BALANCE){let i=h.normalizeProxyNodeList(n.member_node);return s.push({title:_("Load balancing: %s").format(n.name),page:"proxy",detail:i.length>0?_("Members: %s").format(i.join(", ")):_("No member nodes"),tone:i.length>0?"proxy":"warning"}),s}s.push({title:_("Proxy node: %s").format(n.name),page:"proxy",detail:h.getProxyCore(n),tone:"proxy"});let o=h.collectProxyChain(n.name,r);return o.chain.slice(1).forEach(i=>{let l=r.get(i);s.push({title:_("Upstream proxy: %s").format(i),page:"proxy",detail:l?.socks_port?_("SOCKS port %s").format(l.socks_port):_("Node unavailable"),tone:l?"proxy":"warning"})}),o.cycle&&s.push({title:_("Proxy dependency cycle"),tone:"warning",page:"proxy"}),s}function Re(t,e){let r=e==="dns"?t.dns_listen_port:t.shunt_listen_port,n=e==="dns"?_("Core DNS"):_("Default shunt port");if(t.enabled==="0"||!M(r))return[{title:n,detail:_("Disabled or invalid listen port"),tone:"warning",page:"shunt"}];if(e==="traffic")return[{title:n+": "+r,tone:"proxy",page:"firewall"},{title:_("Default shunt"),detail:t.type==="xray"?"Xray":t.type||"",tone:"proxy",page:"shunt"}];let s=[{title:n+": "+r,page:"shunt",detail:t.type==="xray"?"Xray":t.type||"",tone:"proxy"}];if(t.config_type==="custom")return s.push({title:_("Custom core configuration"),detail:_("Internal path cannot be expanded"),tone:"muted",page:"shunt"}),s;let i=a.sections("hijpass","shunt_route_rule").filter(l=>l.enabled==="1").filter(l=>!!l.dns_node);return s.push({title:_("DNS routing rules"),page:"shunt",detail:_("%s enabled rules, default DNS: %s").format(String(i.length),t.default_dns_node||_("Not configured")),tone:"normal"}),s}function gr(t,e,r){if(t==="custom")return[{title:_("Custom DNS"),detail:dr(e),tone:"normal",page:"dns"}];if(t==="dnsmasq"||t==="system"){let s=a.get_first("dhcp","dnsmasq","port")||"53";return[{title:"dnsmasq",detail:_("Local port %s").format(s),tone:"direct",page:"dhcp"}]}let n=r.dns_listen_port||"";return t===A.ROUTING||t==="127.0.0.1#"+n?Re(r,"dns"):[{title:_("DNS upstream"),detail:dr(t),tone:"normal",page:"dns"}]}function ns(t,e,r,n){let s=nt.getSource(),o=s===A.NONE?Pe(e):[Pe(e),e.proxy_local==="1"?_("Router traffic included"):_("Router traffic excluded")].join(` `),i=[{title:_("Client DNS query"),detail:_("TCP/UDP port 53")},{title:_r(e),detail:o,page:"firewall"}];if(s===A.NONE)return i.push({title:_("No DNS redirect"),detail:_("Keep the original destination"),tone:"muted",page:"firewall"}),{id:"dns",title:_("DNS flow"),steps:i};if(s===A.ROUTING)return i.push(...Re(n,"dns")),{id:"dns",title:_("DNS flow"),steps:i};if(s!==A.PRE_ROUTING)return i.push({title:_("Unknown DNS forwarding source"),detail:s,tone:"warning"}),{id:"dns",title:_("DNS flow"),steps:i};if(r.dns_service!=="chinadns-ng"||!M(r.cdg_port))return i.push({title:_("Independent DNS unavailable"),detail:_("Disabled or invalid listen port"),tone:"warning",page:"dns"}),{id:"dns",title:_("DNS flow"),steps:i};i.push({title:_("Independent DNS: %s").format(r.cdg_port),detail:"chinadns-ng",tone:"proxy",page:"dns"});let l=[],p=[];return t.domain_direct&&l.push(_("Custom direct domain list")),t.domain_proxy&&p.push(_("Custom proxy domain list")),r.use_chn==="1"&&l.push(_("CHN domain list")),r.use_gfw==="1"&&p.push(_("GFW domain list")),{id:"dns",title:_("DNS flow"),steps:i,branches:[{condition:_("Direct domain branch"),page:"dns",detail:l.join(" + ")||void 0,steps:gr(r.direct_dns,r.direct_dns_custom,n)},{condition:_("Proxy domain branch"),page:"dns",detail:p.join(" + ")||void 0,steps:gr(r.proxy_dns,r.proxy_dns_custom,n)}]}}function hr(t,e){let r=t.shunt_port||"";return M(r)?r===e.shunt_listen_port?Re(e,"traffic"):mr(r,_("Default shunt port")):[{title:_("Direct"),detail:_("Default shunt port is disabled"),tone:"direct",page:"firewall"}]}function fr(t,e){return M(t.proxy_port)?mr(t.proxy_port,_("Proxy port")):M(t.shunt_port)?hr(t,e):[{title:_("No proxy target"),tone:"warning",page:"firewall"}]}function ss(t,e,r,n){let s=(e.tproxy_proto||"").split(",").filter(Boolean).map(f=>f.toUpperCase()),o={title:_("Client traffic"),page:"firewall",detail:s.join(" + ")||_("No protocol selected")},i={title:_r(e),page:"firewall",detail:[Pe(e),e.proxy_local==="1"?_("Router traffic included"):_("Router traffic excluded")].join(` `)},l=M(e.proxy_port),p=M(e.shunt_port);if(!l&&!p)return{id:"traffic",title:_("Traffic flow"),steps:[o,i,{title:_("No proxy target"),tone:"warning",page:"firewall"}]};let u=[];return(t.ip_proxy||r.dns_service==="chinadns-ng"&&t.domain_proxy)&&u.push({condition:_("Forced proxy address"),page:"firewall",steps:fr(e,n)}),(t.ip_direct||r.dns_service==="chinadns-ng"&&t.domain_direct)&&u.push({condition:_("Forced direct address"),page:"firewall",steps:[{title:_("Direct"),tone:"direct"}]}),r.dns_service==="chinadns-ng"&&r.use_gfw==="1"&&u.push({condition:_("GFW domain set"),page:"dns",steps:fr(e,n)}),p&&r.dns_service==="chinadns-ng"&&r.use_chn==="1"&&u.push({condition:_("CHN domain set"),page:"dns",steps:[{title:_("Direct"),tone:"direct"}]}),p&&e.use_chnroute==="1"&&u.push({condition:_("CHN route set"),page:"firewall",steps:[{title:_("Direct"),tone:"direct"}]}),u.push({condition:_("No address rule matched"),steps:hr(e,n)}),{id:"traffic",title:_("Traffic flow"),steps:[o,i],branches:u,branchMode:"ordered",branchDescription:_("Address rules are evaluated from top to bottom")}}function yr(){let t=zt("hijpass"),e=zt("firewall"),r=zt("dns"),n=zt("shunt");return{diagrams:[ns(t,e,r,n),ss(t,e,r,n)]}}var os=` a.hijpass-flow-step, a.hijpass-flow-branch__condition { display: block; color: inherit; text-decoration: none; } a.hijpass-flow-step:hover, a.hijpass-flow-branch__condition:hover { border-color: var(--primary-color, #4b6cb7); } a.hijpass-flow-step:focus-visible, a.hijpass-flow-branch__condition:focus-visible { outline: 2px solid var(--primary-color, #4b6cb7); outline-offset: 2px; } .hijpass-flow-card h3 { margin: 0; } .hijpass-flow-step[data-tone="warning"] { color: var(--warning-color, #b26a00); } .hijpass-flow-list { display: grid; gap: 1rem; } .hijpass-flow-card { --hijpass-flow-node-width: 14rem; --hijpass-flow-condition-width: 13rem; box-sizing: border-box; min-width: 0; padding: 1rem; } .hijpass-flow-scroll { max-width: 100%; margin-top: .75rem; padding: 0 0 .5rem; overflow-x: auto; overflow-y: hidden; overscroll-behavior-inline: contain; scrollbar-gutter: stable; } .hijpass-flow-scroll:focus-visible { outline: 2px solid var(--primary-color, #4b6cb7); outline-offset: 2px; } .hijpass-flow-tree { display: flex; align-items: center; width: max-content; min-width: max-content; } .hijpass-flow-chain { display: flex; flex-wrap: nowrap; align-items: center; gap: .5rem; width: max-content; min-width: max-content; margin: 0; padding: 0; list-style: none; } .hijpass-flow-chain > li:not(.hijpass-flow-arrow) { display: flex; flex: 0 0 var(--hijpass-flow-node-width); width: var(--hijpass-flow-node-width); } .hijpass-flow-step { box-sizing: border-box; width: 100%; min-width: 0; padding: .75rem; border: 1px solid rgba(127, 127, 127, .45); border-left-width: 4px; border-radius: 4px; overflow-wrap: anywhere; } .hijpass-flow-step[data-tone="proxy"] { border-left-color: var(--primary-color, #4b6cb7); } .hijpass-flow-step[data-tone="direct"] { border-left-color: var(--success-color, #2e7d32); } .hijpass-flow-step[data-tone="muted"] { opacity: .7; } .hijpass-flow-step[data-tone="warning"] { border-left-color: currentColor; } .hijpass-flow-step__detail, .hijpass-flow-branch__detail { display: block; margin-top: .25rem; color: var(--text-color-medium, #777); font-size: .8125rem; line-height: 1.4; } .hijpass-flow-step__detail { white-space: pre-line; } .hijpass-flow-arrow { display: flex; flex: 0 0 auto; align-items: center; justify-content: center; color: var(--text-color-medium, #777); font-size: 1.25rem; } .hijpass-flow-branches { position: relative; display: grid; gap: .75rem; margin: 0; padding: 0; list-style: none; } .hijpass-flow-branches--parallel { margin-left: 1.5rem; } .hijpass-flow-branches--parallel::before { position: absolute; top: 50%; right: 100%; width: 1.5rem; border-top: 2px solid rgba(127, 127, 127, .6); content: ''; } .hijpass-flow-branch { display: grid; align-items: stretch; gap: .5rem; min-height: 4.25rem; } .hijpass-flow-branch--parallel { grid-template-columns: 1.5rem var(--hijpass-flow-condition-width) 1.5rem auto; } .hijpass-flow-branch__joint { position: relative; display: flex; align-self: stretch; align-items: center; justify-content: flex-end; color: var(--text-color-medium, #777); font-size: 1.25rem; line-height: 1; } .hijpass-flow-branch__joint::after { position: absolute; top: -.375rem; bottom: -.375rem; left: 0; border-left: 2px solid rgba(127, 127, 127, .6); content: ''; } .hijpass-flow-branch--parallel:first-child .hijpass-flow-branch__joint::after { top: 50%; } .hijpass-flow-branch--parallel:last-child .hijpass-flow-branch__joint::after { bottom: 50%; } .hijpass-flow-branch--parallel:only-child .hijpass-flow-branch__joint::after { display: none; } .hijpass-flow-branch__condition { box-sizing: border-box; width: var(--hijpass-flow-condition-width); padding: .75rem; border: 1px dashed rgba(127, 127, 127, .55); border-radius: 4px; overflow-wrap: anywhere; } .hijpass-flow-branch .hijpass-flow-chain { margin: 0; } .hijpass-flow-ordered { display: grid; grid-template-columns: auto auto auto; grid-template-rows: auto auto auto; column-gap: .5rem; width: max-content; min-width: max-content; align-items: start; } .hijpass-flow-ordered__prefix { grid-column: 1; grid-row: 2; align-self: center; } .hijpass-flow-ordered__entry { grid-column: 2; grid-row: 2; align-self: center; width: auto; } .hijpass-flow-ordered__description { display: flex; grid-column: 3; grid-row: 1; align-items: center; height: 1.5rem; margin: 0 0 .25rem; color: var(--text-color-medium, #777); font-size: .8125rem; line-height: 1.25; white-space: nowrap; } .hijpass-flow-ordered__first, .hijpass-flow-ordered__rest { grid-column: 3; } .hijpass-flow-ordered__first { grid-row: 2; align-self: stretch; } .hijpass-flow-ordered__rest { grid-row: 3; } .hijpass-flow-branches--ordered { gap: 0; } .hijpass-flow-branch--ordered { grid-template-columns: var(--hijpass-flow-condition-width) 1.5rem auto; } .hijpass-flow-branch--ordered .hijpass-flow-branch__condition, .hijpass-flow-branch--ordered .hijpass-flow-step { display: flex; min-height: 4.25rem; flex-direction: column; justify-content: center; } .hijpass-flow-branch--ordered .hijpass-flow-chain { align-items: stretch; } .hijpass-flow-order-arrow { display: flex; width: var(--hijpass-flow-condition-width); height: 1.25rem; align-items: center; justify-content: center; color: var(--text-color-medium, #777); font-size: 1rem; line-height: 1; } @media (max-width: 900px) { .hijpass-flow-card { --hijpass-flow-node-width: 13rem; --hijpass-flow-condition-width: 12rem; } } `;function is(){if(document.getElementById("hijpass-flow-preview-styles"))return;let t=document.createElement("style");t.id="hijpass-flow-preview-styles",t.textContent=os,document.head.appendChild(t)}function De(t){return L.url(t==="dhcp"?"admin/network/dhcp":"admin/services/hijpass/"+t)}function as(t){return E(t.page?"a":"div",{...t.page?{href:De(t.page)}:{},class:"hijpass-flow-step","data-tone":t.tone||"normal"},[E("strong",{},t.title),t.detail?E("span",{class:"hijpass-flow-step__detail"},t.detail):""])}function Kt(t){let e=[];return t.forEach((r,n)=>{e.push(E("li",{},[as(r)])),n{n.push(E("li",{class:"hijpass-flow-order-arrow","aria-hidden":"true"},"\u2193")),n.push(br(s))}),E("div",{class:"hijpass-flow-tree hijpass-flow-ordered","data-branch-mode":"ordered"},[E("p",{class:"hijpass-flow-ordered__description"},r||""),E("div",{class:"hijpass-flow-ordered__prefix"},Kt(t)),E("span",{class:"hijpass-flow-arrow hijpass-flow-ordered__entry","aria-hidden":"true"},"\u2192"),E("ol",{class:"hijpass-flow-branches hijpass-flow-branches--ordered hijpass-flow-ordered__first"},[br(e[0])]),n.length>0?E("ol",{class:"hijpass-flow-branches hijpass-flow-branches--ordered hijpass-flow-ordered__rest"},n):""])}function us(t){return t.branches?.length?E("ul",{class:"hijpass-flow-branches hijpass-flow-branches--parallel"},t.branches.map(ls)):""}function cs(t){let e=t.branchMode==="ordered"&&t.branches?.length?ps(t.steps,t.branches,t.branchDescription):E("div",{class:"hijpass-flow-tree","data-branch-mode":t.branchMode||"parallel"},[Kt(t.steps),us(t)]);return E("div",{class:"hijpass-flow-scroll",role:"region","aria-label":t.title,tabindex:"0"},[e])}var xr={createConfigurationFlowPreview:function(){is();let t=yr();return E("div",{class:"hijpass-flow-preview"},[E("div",{class:"cbi-section-descr"},_("Generated from saved settings. Branches show configured decisions, not a live packet trace.")),E("div",{class:"hijpass-flow-list"},t.diagrams.map(e=>E("section",{class:"hijpass-flow-card","aria-labelledby":"hijpass-flow-"+e.id},[E("h3",{id:"hijpass-flow-"+e.id},e.title),cs(e)])))])}};var ds=Ue.extend({load:function(){return Promise.all([a.load("hijpass"),a.load("hijserver"),a.load("dhcp")])},handleSaveApply:ir.genHandleSaveApply(),render:async function(){let t=new S.Map("hijpass",_("HiJpass"));F.createStatusSection(t);let e=t.section(S.TypedSection,"hijpass");e.anonymous=!0,e.addremove=!1,e.tab("configuration",_("Configuration")),e.tab("flow",_("Flow preview"));let r=e.taboption("configuration",S.Flag,"enabled",_("Enable"),_("Enable or Disable HiJpass"));r.default="0",r.rmempty=!1;let n=e.taboption("configuration",S.Value,"delay_time",_("Delay Time"),_("Startup Delay"));n.datatype="uinteger",n.default="60",n.rmempty=!1;let s=e.taboption("configuration",S.ListValue,"log_level",_("Log Level"),_("Service Log Level"));s.modalonly=!0,s.value("DEBUG",_("Debug")),s.value("INFO",_("Info")),s.value("WARN",_("Warning")),s.value("ERROR",_("Error")),s.default="INFO",s.rmempty=!1;let o=e.taboption("configuration",S.Button,"_preview");o.render=function(){return Ce.createActionButtons()};let i=e.taboption("flow",S.DummyValue,"_flow_preview");i.render=xr.createConfigurationFlowPreview;let l=t.section(S.TypedSection,"connectivity_test_section");return l.anonymous=!0,l.addremove=!1,l.render=Ce.createConnectivityTest,t.render()}}),gs=ds;return Er(_s);})(); return LuciView.default;