1import{d as M,M as b,a7 as k,B as v,aN as w,aq as m,a8 as $,aT as O,_ as B,b as d,h as _,w as x,j as i,t as o,aD as f,e as r,ab as h,c as y,F as V,n as u,i as A}from"./BEf7-8Bi.js";import{_ as C}from"./BvdfoaL8.js";import{v as g}from"./xPGEof6T.js";const E=M({name:"ProxyAuthorization",components:{UiNotice:w,TagsInput:C,ButtonBox:v,InputBox:k,Modal:b},props:{show:{type:Boolean},order:{type:Object}},emits:["close"],data(){return{isLoading:!1,authorizationLocked:!1,credentials:{isPerforming:!1,isErrored:!1,isPerformed:!1,entity:{login:"",password:""},validateOptions:Object.freeze({login:{label:"labels.login",validate:{required:!0}},password:{label:"labels.password",validate:{required:!0}}}),entity_errors:{}},ip:{isPerforming:!1,isErrored:!1,isPerformed:!1,entity:{ip_auth:[]},validateOptions:Object.freeze({ip_auth:{label:"",validate:{required:!0}}}),entity_errors:{}}}},computed:{isMobileProxy(){return O(this.order?this.order.service.id:1)},fillMyIpAvailable(){const e=m().user_meta.ip;return!!e&&this.ip.entity.ip_auth.indexOf(e)===-1}},watch:{show:{handler:function(e){e&&(this.resetData(),this.checkAuthorizationLocked())}}},mounted(){this.resetData(),this.show&&this.checkAuthorizationLocked()},methods:{async updateCredentials(e){if(!(this.credentials.isPerforming||!this.order||this.authorizationLocked)){this.credentials.isErrored=!1,this.credentials.isPerformed=!1,this.credentials.isPerforming=!1;try{const{status:t,errors:a}=await g(this.credentials.validateOptions,this.credentials.entity);if(this.credentials.entity_errors=a,!t)return;this.credentials.isPerforming=!0;let n={};e==="update"?n={login:this.credentials.entity.login,password:this.credentials.entity.password}:e==="generate"&&(n.gen_password=!0);const l=await this.updateOrder(this.order.id,n);l.order.access&&(this.credentials.entity.login=l.order.access.login,this.credentials.entity.password=l.order.access.password),this.credentials.isPerformed=!0}catch(t){console.error("update order",t),this.credentials.isErrored=!0}this.credentials.isPerforming=!1}},async updateIpWhiteList(){if(!(this.ip.isPerforming||!this.order)){this.ip.isErrored=!1,this.ip.isPerformed=!1,this.ip.isPerforming=!1;try{const{status:e,errors:t}=await g(this.ip.validateOptions,this.ip.entity);if(this.ip.entity_errors=t,!e)return;this.ip.isPerforming=!0,await this.updateOrder(this.order.id,{ip_auth:this.ip.entity.ip_auth}),this.ip.isPerformed=!0}catch(e){console.error("update order",e),this.ip.isErrored=!0}this.ip.isPerforming=!1}},async updateOrder(e,t){const a={order_id:e,entity:t};return $().updateOrder(a)},async checkAuthorizationLocked(){if(this.authorizationLocked=!1,!!this.order){this.isLoading=!0;try{const e=await this.$api.usersOrders.get(this.order.id);this.authorizationLocked=!!e.order.proxies?.some(t=>t.mux===!1)}catch(e){console.error("get order, proxy authorization",e)}this.isLoading=!1}},fillMyIp(){const e=m().user_meta.ip;!e||this.ip.entity.ip_auth.indexOf(e)>-1||this.ip.entity.ip_auth.push(e)},close(){this.resetData(),this.$emit("close")},resetData(){this.ip.entity.ip_auth=this.order&&this.order.access&&Array.isArray(this.order.access.ip_auth)?this.order.access.ip_auth:[],this.credentials.entity_errors={},this.ip.isErrored=!1,this.ip.isPerformed=!1,this.ip.isPerforming=!1,this.credentials.entity.password=this.order&&this.order.access?this.order.access.password:"",this.credentials.entity.login=this.order&&this.order.access?this.order.access.login:"",this.credentials.entity_errors={},this.credentials.isErrored=!1,this.credentials.isPerformed=!1,this.credentials.isPerforming=!1}}}),I={class:"ui-modal__head"},S=["textContent"],T={class:"ui-modal__block_head"},D=["textContent"],N=["textContent"],U={class:"ui-modal__block_fields"},j={class:"ui-field-row _2-3"},q={class:"ui-modal__buttons"},H=["textContent"],W=["textContent"],F=["textContent"],R={class:"ui-modal__block_head"},G=["textContent"],J={class:"ui-modal__text"},K=["innerHTML"],Q=["innerHTML"],X={class:"ui-modal__block_fields"},Y={class:"ui-modal__buttons"},Z=["textContent"],ee=["textContent"];function te(e,t,a,n,l,ie){const p=k,P=w,c=v,z=C,L=b;return d(),_(L,{show:e.show,"is-loading":e.isLoading,onClose:e.close},{default:x(()=>[i("div",I,[i("div",{class:"ui-modal__h1",textContent:o(e.$t("lk.proxy.authorization.name"))},null,8,S)]),i("form",{class:"ui-modal__block",onSubmit:t[3]||(t[3]=f(s=>e.updateCredentials("update"),["prevent"]))},[i("div",T,[i("div",{class:"ui-modal__h2",textContent:o(e.$t("lk.proxy.authorization.credentials.title"))},null,8,D),i("div",{class:"ui-modal__text",textContent:o(e.$t("lk.proxy.authorization.credentials.subtitle"))},null,8,N)]),i("div",U,[i("div",j,[r(p,h({modelValue:e.credentials.entity.login,"onUpdate:modelValue":t[0]||(t[0]=s=>e.credentials.entity.login=s),modelModifiers:{trim:!0}},e.credentials.validateOptions.login,{error:e.credentials.entity_errors.login,"silent-disabled":e.authorizationLocked}),null,16,["modelValue","error","silent-disabled"]),r(p,h({modelValue:e.credentials.entity.password,"onUpdate:modelValue":t[1]||(t[1]=s=>e.credentials.entity.password=s),modelModifiers:{trim:!0}},e.credentials.validateOptions.password,{error:e.credentials.entity_errors.password,"silent-disabled":e.authorizationLocked}),null,16,["modelValue","error","silent-disabled"])])]),e.authorizationLocked?(d(),_(P,{key:0,text:"lk.proxy.authorization.credentials.locked"})):(d(),y(V,{key:1},[i("div",q,[r(c,{loading:e.credentials.isPerforming,color:"blue",title:"buttons.apply",type:"submit"},null,8,["loading"]),i("button",{type:"button",class:"ui-button-text",onClick:t[2]||(t[2]=s=>e.updateCredentials("generate")),textContent:o(e.$t("lk.proxy.authorization.credentials.generate"))},null,8,H)]),i("div",{class:u(["ui-modal__msg _error",{_show:e.credentials.isErrored}]),textContent:o(e.$t("errors.internal"))},null,10,W),i("div",{class:u(["ui-modal__msg _success",{_show:e.credentials.isPerformed}]),textContent:o(e.$t("lk.proxy.authorization.credentials.success"))},null,10,F)],64))],32),i("form",{class:"ui-modal__block",onSubmit:t[5]||
1(t[5]=f((...s)=>e.updateIpWhiteList&&e.updateIpWhiteList(...s),["prevent"]))},[i("div",R,[i("div",{class:"ui-modal__h2",textContent:o(e.$t("lk.proxy.authorization.ip.title"))},null,8,G),i("div",J,[i("p",{innerHTML:e.$t("lk.proxy.authorization.ip.subtitle")},null,8,K),e.isMobileProxy?(d(),y("p",{key:0,innerHTML:e.$t("lk.proxy.authorization.ip.subtitle_mobile")},null,8,Q)):A("",!0)])]),i("div",X,[r(z,h({modelValue:e.ip.entity.ip_auth,"onUpdate:modelValue":t[4]||(t[4]=s=>e.ip.entity.ip_auth=s),modelModifiers:{trim:!0}},e.ip.validateOptions.ip_auth,{max:3,error:e.credentials.entity_errors.ip_auth,"sub-action":e.fillMyIpAvailable?"lk.proxy.authorization.ip.fill_my_ip":"",onSubActionClick:e.fillMyIp}),null,16,["modelValue","error","sub-action","onSubActionClick"])]),i("div",Y,[r(c,{loading:e.ip.isPerforming,color:"blue",title:"buttons.apply",type:"submit"},null,8,["loading"])]),i("div",{class:u(["ui-modal__msg _error",{_show:e.ip.isErrored}]),textContent:o(e.$t("errors.internal"))},null,10,Z),i("div",{class:u(["ui-modal__msg _success",{_show:e.ip.isPerformed}]),textContent:o(e.$t("lk.proxy.authorization.ip.success"))},null,10,ee)],32)]),_:1},8,["show","is-loading","onClose"])}const ae=B(E,[["render",te]]);export{ae as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.