import{_ as T}from"./IconUpload-DEJktZOp.js";import{_ as G}from"./InputText-B7svPZWH.js";import{_ as V}from"./ClausesKeeper-CyJ_9bTp.js";import{_ as D}from"./BlockBalanceAgreement-396E9Da8.js";import{r as n,g as B,l as C,D as F,x as S,o as U,c as q,b as a,a as t,n as m,w as N,B as K,K as M,S as $,F as j,e as L,t as O}from"./index-Bb2UEb_P.js";import{u as R}from"./edesks-DahqrBGV.js";import{u as z}from"./files-Bk5mgFCm.js";import{s as A}from"./multiselect-Bk-p1X5E.js";import{_ as H}from"./FileList.vue_vue_type_script_setup_true_lang-BR7R3aG7.js";import{_ as J}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./HtmlContent-DrkJBX3e.js";import"./IconCloseCircle-ctElXVvc.js";import"./clauses-Bhz_DuFa.js";import"./index-Dax_IkAt.js";import"./ButtonDefault-CzWpVlv6.js";import"./common-U_VzDrmL.js";import"./IconFile-CrvZD0mK.js";const P={class:"tw-px-4 md:tw-px-8 tw-mb-4"},Q={class:"form-field form-field--basic"},W={class:"tw-relative tw-flex tw-w-full"},X={class:"multiselect-option"},Y={class:"tw-flex tw-items-start form-field form-field--basic"},Z={class:"tw-relative tw-flex tw-w-full"},ee={class:"form-field form-field--file form-field--basic"},le={class:"tw-relative tw-flex tw-w-full"},te={class:"form-field-input__file tw-h-12 tw-w-full"},se={class:"tw-flex tw-justify-end"},oe={__name:"NewTicket",async setup(ae){let f,p;const r=R(),x=z(),b=L(),l=n({theme:{value:null,required:!0,isError:!1},selectGroup:{value:null,required:!0,isError:!1},message:{value:null,required:!0,isError:!1},file:{value:null,required:!1,isError:!1}}),c=n(null),u=n([]),v=n(null),d=B(()=>Object.keys(r.groups||[])?.map(s=>({value:r.groups?.[s]?.ID,name:r.groups?.[s]?.Name})));function h(s){l.value.file.value=s.target.files?.[0]||null,l.value.file.value&&(c.value.value="",x.sendFile(l.value.file.value).then(e=>{u.value.push({name:l.value.file.value?.name,value:e.slice(e.lastIndexOf("^")+1,e.length)})}))}function k(s){u.value=u.value.filter((e,i)=>i!==s)}function _(){let s=!1;Object.keys(l.value).map(e=>{l.value?.[e].required&&l.value?.[e].value===null&&(l.value[e].isError=!0,s=!0)}),s||r.ticketEdit({Theme:l.value?.theme.value||null,TargetGroupID:l.value?.selectGroup.value||null,Message:l.value?.message.value||null,TicketMessageFile:u.value?.map(e=>e?.value)||null}).then(e=>{e==="success"&&b.push("/Tickets")})}const w=s=>{s.key==="Enter"&&s.ctrlKey&&_()};C(()=>{document.addEventListener("keyup",w),g()}),F(()=>{document.removeEventListener("keyup",w)}),[f,p]=S(()=>r.fetchGroups().then(()=>{l.value.selectGroup.value=d.value?.[0]?.value})),await f,p();function g(){const s=v.value;s.style.height="auto",s.style.height=s.scrollHeight+10+"px"}return(s,e)=>{const i=D,y=V,E=G,I=T;return U(),q(j,null,[a(i),t("div",P,[e[9]||(e[9]=t("h1",{class:"tw-text-xl sm:tw-text-4xl tw-mb-4"},"Создать тикет",-1)),a(y),a(E,{modelValue:l.value.theme.value,"onUpdate:modelValue":e[0]||(e[0]=o=>l.value.theme.value=o),class:m([{"form-error":l.value.theme.isError},"tw-mb-4"]),label:"Тема запроса",placeholder:"Заголовок",name:"login"},null,8,["modelValue","class"]),t("label",Q,[e[4]||(e[4]=t("div",{class:"form-field__label"},"Отдел",-1)),t("div",W,[a(K(A),{modelValue:l.value.selectGroup.value,"onUpdate:modelValue":e[1]||(e[1]=o=>l.value.selectGroup.value=o),class:m(["tw-flex tw-w-full",{"multiselect--white":!0,"form-error":l.value.selectGroup.isError}]),options:d.value,label:"name"},{option:N(({option:o})=>[t("div",X,O(o.name),1)]),_:1},8,["modelValue","class","options"])])]),t("label",Y,[e[5]||(e[5]=t("div",{class:"form-field__label tw-pt-2"},"Сообщение",-1)),t("div",Z,[M(t("textarea",{ref_key:"messageInput",ref:v,"onUpdate:modelValue":e[2]||(e[2]=o=>l.value.message.value=o),class:m(["tw-min-h-48 tw-placeholder-gray-300",{"form-error":l.value.message.isError}]),placeholder:"Опишите проблему, указав сервер размещения, вашу учётную запись на сервере, имя сайта, УРЛ ошибки и способ её воспроизведения.",onInput:g},null,34),[[$,l.value.message.value]])])]),a(H,{class:"sm:tw-ml-[272px] tw-mb-4",files:u.value,onRemove:k},null,8,["files"]),t("label",ee,[e[7]||(e[7]=t("div",{class:"form-field__label"},null,-1)),t("div",le,[t("input",{ref_key:"fileInput",ref:c,type:"file",onChange:h},null,544),t("div",te,[a(I),e[6]||(e[6]=t("span",{class:"tw-text-sm"},"Прикрепить файл",-1))])])]),t("div",se,[t("button",{class:"btn btn--blue btn-default",onClick:e[3]||(e[3]=o=>_())},e[8]||(e[8]=[t("span",{class:"tw-text-sm tw-min-w-32"},"Отправить",-1)]))])])],64)}}},ye=J(oe,[["__scopeId","data-v-85d175a0"]]);export{ye as default};
