import{_ as P}from"./ProfileForm-BB6yjYT8.js";import{_ as V}from"./SimpleCheckbox-DxdM8U6J.js";import{_ as D}from"./ClausesKeeper-CyJ_9bTp.js";import{_ as B}from"./BlockBalanceAgreement-396E9Da8.js";import{am as S,r as u,g as q,v as y,o as m,c as k,b as g,a as f,F as x,h,m as b,i as E,e as M,j as N}from"./index-Bb2UEb_P.js";import{u as F}from"./index-Dax_IkAt.js";import{_ as $}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./ButtonDefault-CzWpVlv6.js";import"./HtmlContent-DrkJBX3e.js";import"./bootstrap-vue-next-C0pyDr3k.js";import"./IconClip-BGYNmTdK.js";import"./IconCloseCircle-ctElXVvc.js";import"./IconFile-CrvZD0mK.js";import"./InputSelect.vue_vue_type_script_setup_true_lang-DDGr1dhD.js";import"./IconChevronDown-NfcUpI8U.js";import"./BasicInput-BG-lQkv5.js";import"./component-C-Q4t0gB.js";import"./common-U_VzDrmL.js";import"./files-Bk5mgFCm.js";import"./clauses-Bhz_DuFa.js";const j={class:"tw-px-4 md:tw-px-8 tw-mb-10"},A={class:"tw-mb-10"},L={__name:"ProfileMake",setup(O){const _=S(),d=F(),c=M(),a=N(),l=u({}),v=u(null),p=u(null),t=u(null),i=q(()=>Object.values(_.data?.Contracts?.Types||{}).filter(e=>e?.ProfileTemplateID!==""));async function C(s){v.value=!0;const e=await d.profileEdit(s);if(v.value=!1,e.status==="success")if(a.query.CreateContract==="true"){const o=await d.contractMake({ProfileID:e.data?.ProfileID,TypeID:t.value});o.status==="success"&&o.data?.Status==="Ok"?c.push("/Contracts"):p.value=o.data?.Exception||"Не удалось создать договор"}else a.query.Contract?c.push(`/Balance/${a.query.Contract}`):c.push("/Contracts");else p.value=e.data?.Exception||"Не удалось создать профиль"}return y(i,()=>{a.query.TemplateID?t.value=a.query.TemplateID:t.value=i.value[0]?.ProfileTemplateID||null},{immediate:!0}),y(t,s=>{l.value={};const e=_.data?.Profiles?.Templates?.[s]?.Template?.Attribs||{};for(const o in e){const n=e[o]?.Value;n&&(l.value[o]=n)}},{immediate:!0}),(s,e)=>{const o=B,n=D,T=V,w=P;return m(),k(x,null,[g(o),f("div",j,[e[2]||(e[2]=f("h1",{class:"tw-text-xl sm:tw-text-4xl tw-mb-4"},"Создать профиль",-1)),g(n),f("div",A,[(m(!0),k(x,null,h(i.value,r=>(m(),b(T,{key:r.ProfileTemplateID,modelValue:t.value,"onUpdate:modelValue":e[0]||(e[0]=I=>t.value=I),label:r.Name,value:r.ProfileTemplateID},null,8,["modelValue","label","value"]))),128))]),t.value?(m(),b(w,{key:0,modelValue:l.value,"onUpdate:modelValue":e[1]||(e[1]=r=>l.value=r),template:t.value,"error-message":p.value,onSend:C},null,8,["modelValue","template","error-message"])):E("",!0)])],64)}}},ue=$(L,[["__scopeId","data-v-5cb7fafe"]]);export{ue as default};
