1import{_ as ae}from"./Dwxvvo-6.js";import{_ as oe}from"./CHs4k8os.js";import{T as ne}from"./4aB1CrDw.js";import{s as ie,a as de}from"./BtA5FOIj.js";import{s as re}from"./WKNRbnUy.js";import{s as me}from"./CffdPQOO.js";import{s as ce}from"./CEIJRxab.js";import{s as ue}from"./BrlBjkEj.js";import{s as pe}from"./DNFwZRCX.js";import{a as fe}from"./DWp4X3o3.js";import{L as ve,M as he,_ as ye,a4 as _e,a3 as be,aa as ge,j as z,f as $e,u as we,$ as ke,e as Ne,c as m,a,b as n,l,t as i,w as f,m as h,p as b,V as I,o as d,Q as F,B as N,F as U,r as B,d as E}from"./Bz8us78L.js";import{u as De}from"./B_3KwAEc.js";import{u as Ve}from"./BefQyaIo.js";import{_ as xe}from"./DlAUqK2U.js";import"./DYNwYtqn.js";import"./DjS4onLz.js";import"./DdN93gyM.js";import"./2cBKvzEf.js";import"./ALCykLjL.js";import"./Dsba7oWP.js";import"./DtNK7EeP.js";import"./BW8Yb0gV.js";import"./CoZlq1aF.js";import"./KlAiHPjq.js";import"./Bs0gpJfT.js";import"./DHbG3l_2.js";import"./0KrBcLYJ.js";import"./skiP90sr.js";import"./BUn5dKXq.js";import"./DWIrm_GH.js";const Ce={class:"form-page"},Ae={class:"page-header"},Le={key:0,class:"text-center py-12",style:{color:"var(--p-text-muted-color)"}},Te={key:1},Se={class:"top-row"},ze={class:"flex flex-col gap-4"},Fe={class:"fio-row"},Ue={class:"field"},Be={class:"field-label"},Ee={class:"field"},Me={class:"field-label"},Pe={class:"field"},je={class:"field-label"},Ie={class:"grid grid-cols-2 gap-4"},Oe={class:"field"},Re={class:"field-label"},qe={class:"field"},He={class:"field-label"},Ye={class:"field"},Qe={class:"field-label"},Ge={class:"flex gap-2"},Je={class:"field"},Ke={class:"field-label"},We={class:"field"},Xe={class:"field-label"},Ze={class:"field"},et={class:"field-label"},tt={class:"comments-scroll"},st={class:"text-sm"},lt={class:"text-xs mt-1",style:{color:"var(--p-text-muted-color)"}},at={key:0,class:"text-sm",style:{color:"var(--p-text-muted-color)"}},ot={class:"bottom-row"},nt={class:"flex flex-col gap-3"},it={class:"flex items-start justify-between gap-2"},dt={class:"text-sm"},rt={key:0,class:"rounded-lg overflow-hidden border border-surface-200 mt-2",style:{height:"150px"}},mt=["src"],ct={key:0,class:"text-sm",style:{color:"var(--p-text-muted-color)"}},ut={key:1,class:"flex flex-col gap-2 p-3 rounded-lg",style:{background:"var(--app-ground)"}},pt={class:"field"},ft={class:"field-label"},vt={class:"field"},ht={class:"field-label"},yt={class:"flex gap-2"},_t={class:"flex flex-col gap-2"},bt={key:0,class:"text-sm py-3 text-center",style:{color:"var(--p-text-muted-color)"}},gt={class:"flex items-center gap-2 mb-1"},$t={class:"text-sm font-semibold"},wt={key:0,class:"text-xs",style:{color:"var(--p-text-muted-color)"}},kt={key:1,class:"text-xs",style:{color:"var(--p-text-muted-color)"}},Nt={class:"text-center py-4",style:{color:"var(--p-text-muted-color)"}},Dt={class:"text-sm"},Vt=ve({__name:"[id]",setup(xt){const{t:u}=he(),g=ye(),D=_e(),{adminFetch:$}=De(),y=be(),O=ge(),c=b(null),M=z(()=>c.value?[c.value.lastName,c.value.name,c.value.middleName].filter(Boolean).join(" "):""),R=$e();we({title:z(()=>`${R.clinicName} â ${M.value||u("appointments.client")}`)});const P=b(!1),V=b(!1),x=b(!1),w=b(!1),s=I({lastName:"",name:"",middleName:"",birthDate:null,gender:null,phone:"",email:"",notes:""}),q=z(()=>{if(!s.birthDate)return"";const t=new Date(s.birthDate),o=new Date;let r=o.getFullYear()-t.getFullYear();const v=o.getMonth()-t.getMonth();return(v<0||v===0&&o.getDate()<t.getDate())&&r--,`${r}`}),p=I({label:"",address:"",mapLat:null,mapLng:null}),{statusLabels:H,statusSeverity:Y}=Ve(),Q={scheduled:"ÐапланиÑована",arrived:"ÐаÑÐ¸ÐµÐ½Ñ Ð¿ÑиÑÑл",completed:"ÐавеÑÑена",cancelled:"ÐÑменена",no_show:"Ðе пÑиÑÑл"},G={scheduled:"info",arrived:"warn",completed:"success",cancelled:"secondary",no_show:"danger"};function C(t){return new Date(t).toLocaleDateString("ru-RU",{day:"numeric",month:"short",year:"numeric"})}function J(t){const o=t.data;o?.geo_lat&&(p.mapLat=Number.parseFloat(o.geo_lat)),o?.geo_lon&&(p.mapLng=Number.parseFloat(o.geo_lon))}async function A(){try{const t=await $(`clients/${g.params.id}`);
1c.value=t.item,s.lastName=t.item.lastName||"",s.name=t.item.name||"",s.middleName=t.item.middleName||"",s.birthDate=t.item.birthDate?new Date(t.item.birthDate):null,s.gender=t.item.gender||null,s.phone=t.item.phone||"",s.email=t.item.email||"",s.notes=t.item.notes||""}catch{P.value=!0}}async function K(){if(!s.name.trim()){y.add({severity:"warn",summary:u("clients.fillName"),life:3e3});return}V.value=!0;try{const t=await $(`clients/${g.params.id}`,{method:"PUT",body:{lastName:s.lastName,name:s.name,middleName:s.middleName,birthDate:s.birthDate?new Date(s.birthDate).toISOString().split("T")[0]:null,gender:s.gender||null,phone:s.phone,email:s.email,notes:s.notes}});c.value={...c.value,...t.item},y.add({severity:"success",summary:u("common.saved"),life:2e3})}catch{y.add({severity:"error",summary:u("common.error"),life:3e3})}finally{V.value=!1}}async function W(){if(!p.address.trim()){y.add({severity:"warn",summary:u("clients.fillAddress"),life:3e3});return}x.value=!0;try{await $(`clients/${g.params.id}/addresses`,{method:"POST",body:{...p}}),w.value=!1,p.label="",p.address="",p.mapLat=null,p.mapLng=null,await A(),y.add({severity:"success",summary:u("clients.addressAdded"),life:2e3})}catch{y.add({severity:"error",summary:u("common.error"),life:3e3})}finally{x.value=!1}}function X(t){O.require({message:u("common.confirmDelete"),header:u("common.delete"),icon:"pi pi-exclamation-triangle",rejectProps:{label:u("common.cancel"),text:!0},acceptProps:{label:u("common.delete"),severity:"danger"},accept:async()=>{try{await $(`clients/addresses/${t}`,{method:"DELETE"}),await A(),y.add({severity:"success",summary:u("common.deleted"),life:2e3})}catch{y.add({severity:"error",summary:u("common.error"),life:3e3})}}})}let j;return ke(()=>[s.lastName,s.name,s.middleName],()=>{s.gender||(clearTimeout(j),j=setTimeout(async()=>{const t=[s.lastName,s.name,s.middleName].filter(Boolean).join(" ");if(!(t.length<2))try{const r=(await $fetch("/api/dadata/suggest",{method:"POST",body:{type:"fio",query:t}}))?.suggestions?.[0]?.data;r?.gender==="MALE"?s.gender="male":r?.gender==="FEMALE"&&(s.gender="female")}catch{}},800))}),Ne(A),(t,o)=>{const r=fe,v=pe,Z=ue,ee=ce,_=me,te=ae,L=re,se=oe,k=de,le=ie,T=ne;return d(),m("div",Ce,[a("div",Ae,[n(r,{icon:"pi pi-arrow-left",text:"",label:t.$t("common.back"),onClick:o[0]||(o[0]=e=>l(D).push("/admin/clients"))},null,8,["label"]),a("h2",null,i(l(M)||t.$t("appointments.client")),1),n(r,{label:t.$t("common.newAppointment"),icon:"pi pi-plus",onClick:o[1]||(o[1]=e=>l(D).push(`/admin/appointments/new?clientId=${l(g).params.id}`))},null,8,["label"])]),l(P)?(d(),m("div",Le,i(t.$t("clients.notFound")),1)):l(c)?(d(),m("div",Te,[a("div",Se,[n(_,{header:t.$t("common.main"),class:"top-row-main"},{default:f(()=>[a("div",ze,[a("div",Fe,[a("div",Ue,[a("label",Be,i(t.$t("clients.lastName")),1),n(v,{modelValue:l(s).lastName,"onUpdate:modelValue":o[2]||(o[2]=e=>l(s).lastName=e),class:"w-full"},null,8,["modelValue"])]),a("div",Ee,[a("label",Me,i(t.$t("clients.firstName"))+" *",1),n(v,{modelValue:l(s).name,"onUpdate:modelValue":o[3]||(o[3]=e=>l(s).name=e),class:"w-full"},null,8,["modelValue"])]),a("div",Pe,[a("label",je,i(t.$t("clients.middleName")),1),n(v,{modelValue:l(s).middleName,"onUpdate:modelValue":o[4]||(o[4]=e=>l(s).middleName=e),class:"w-full"},null,8,["modelValue"])])]),a("div",Ie,[a("div",Oe,[a("label",Re,i(t.$t("clients.birthDate")),1),n(Z,{modelValue:l(s).birthDate,"onUpdate:modelValue":o[5]||(o[5]=e=>l(s).birthDate=e),"date-format":"dd.mm.yy",class:"w-full"},null,8,["modelValue"])]),a("div",qe,[a("label",He,i(t.$t("clients.age")),1),n(v,{"model-value":l(q),disabled:"",class:"w-full"},null,8,["model-value"])])]),a("div",Ye,[a("label",Qe,i(t.$t("clients.gender")),1),a("div",Ge,[n(r,{label:t.$t("clients.male"),size:"small",severity:l(s).gender==="male"?void 0:"secondary",outlined:l(s).gender!=="male",onClick:o[6]||(o[6]=e=>l(s).gender="male")},null,8,["label","severity","outlined"]),n(r,{label:t.$t("clients.female"),size:"small",severity:l(s).gender==="female"?void 0:"secondary",outlined:l(s).gender!=="female",onClick:o[7]||(o[7]=e=>l(s).gender="female")},null,8,["label","severity","outlined"]),l(s).gender?F((d(),N(r,{key:0,icon:"pi pi-times",size:"small",text:"",rounded:"",onClick:o[8]||(o[8]=e=>l(s).gender=null)},null,512)),[[T,t.$t("common.remove"),void 0,{bottom:!0}]]):h("",!0)])]),a("div",Je,[a("label",Ke,i(t.$t("common.phone")),1),n(v,{modelValue:l(s).phone,"onUpdate:modelValue":o[9]||(o[9]=e=>l(s).phone=e),class:"w-full"},null,8,["modelValue"])]),a("div",We,[a("label",Xe,i(t.$t("common.email")),1),n(v,{modelValue:l(s).email,"onUpdate:modelValue":o[10]||(o[10]=e=>l(s).email=e),class:"w-full"},null,8,["modelValue"])]),a("div",Ze,[a("label",et,i(t.$t("common.notes")),1),n(ee,{modelValue:l(s).notes,"onUpdate:modelValue":o[11]||(o[11]=e=>l(s).notes=e),"auto-resize":!0,rows:"2",class:"w-full"},null,8,["modelValue"])]),n(r,{label:t.$t("common.save"),loading:l(V),icon:"pi pi-check",size:"small",class:"self
1-start",onClick:K},null,8,["label","loading"])])]),_:1},8,["header"]),n(_,{header:t.$t("appointments.comments"),class:"top-row-comments"},{default:f(()=>[a("div",tt,[(d(!0),m(U,null,B(l(c).recentComments,e=>(d(),m("div",{key:e.id,class:"comment-item"},[a("div",st,i(e.text),1),a("div",lt,[E(i(e.author?.displayName||e.author?.email||"")+" · "+i(C(e.createdAt))+" ",1),e.Appointment?(d(),N(te,{key:0,to:`/admin/appointments/${e.Appointment.id}`,class:"ml-1",style:{color:"var(--p-primary-color)"}},{default:f(()=>[E(" #"+i(e.Appointment.id),1)]),_:2},1032,["to"])):h("",!0)])]))),128)),l(c).recentComments?.length?h("",!0):(d(),m("div",at,i(t.$t("common.noComments")),1))])]),_:1},8,["header"])]),a("div",ot,[n(_,{header:t.$t("clients.addresses")},{default:f(()=>[a("div",nt,[(d(!0),m(U,null,B(l(c).addresses,e=>(d(),m("div",{key:e.id,class:"address-card"},[a("div",it,[a("div",null,[e.label?(d(),N(L,{key:0,value:e.label,severity:"secondary",class:"mb-1"},null,8,["value"])):h("",!0),a("div",dt,i(e.address),1)]),F(n(r,{icon:"pi pi-trash",size:"small",text:"",rounded:"",severity:"danger",onClick:S=>X(e.id)},null,8,["onClick"]),[[T,t.$t("common.delete"),void 0,{bottom:!0}]])]),e.mapLat&&e.mapLng?(d(),m("div",rt,[a("iframe",{src:`https://yandex.ru/map-widget/v1/?ll=${e.mapLng},${e.mapLat}&z=16&l=map&pt=${e.mapLng},${e.mapLat},pm2blm`,width:"100%",height:"100%",frameborder:"0",class:"w-full h-full",title:"ÐдÑеÑ"},null,8,mt)])):h("",!0)]))),128)),l(c).addresses?.length?h("",!0):(d(),m("div",ct,i(t.$t("clients.noAddresses")),1)),l(w)?(d(),m("div",ut,[a("div",pt,[a("label",ft,i(t.$t("clients.addressLabel")),1),n(v,{modelValue:l(p).label,"onUpdate:modelValue":o[12]||(o[12]=e=>l(p).label=e),class:"w-full",placeholder:"Ðом, РабоÑа..."},null,8,["modelValue"])]),a("div",vt,[a("label",ht,i(t.$t("common.address")),1),n(se,{modelValue:l(p).address,"onUpdate:modelValue":o[13]||(o[13]=e=>l(p).address=e),placeholder:"ÐаÑниÑе вводиÑÑ Ð°Ð´ÑеÑ","suggest-type":"address","input-class":"w-full p-inputtext",onSelect:J},null,8,["modelValue"])]),a("div",yt,[n(r,{label:t.$t("common.create"),size:"small",loading:l(x),onClick:W},null,8,["label","loading"]),n(r,{label:t.$t("common.cancel"),size:"small",text:"",onClick:o[14]||(o[14]=e=>w.value=!1)},null,8,["label"])])])):(d(),N(r,{key:2,icon:"pi pi-plus",label:t.$t("clients.addAddress"),severity:"secondary",text:"",size:"small",class:"self-start",onClick:o[15]||(o[15]=e=>w.value=!0)},null,8,["label"]))])]),_:1},8,["header"]),n(_,{header:"ÐапиÑи",class:"mt-4"},{default:f(()=>[a("div",_t,[l(c).visits?.length?h("",!0):(d(),m("div",bt," ÐÐµÑ Ð·Ð°Ð¿Ð¸Ñей ")),(d(!0),m(U,null,B(l(c).visits,e=>(d(),m("div",{key:e.id,class:"visit-card"},[a("div",gt,[n(L,{value:Q[e.status],severity:G[e.status],class:"text-xs"},null,8,["value","severity"]),a("span",$t," ð
"+i(C(e.date))+" · "+i(e.startTime)+i(e.endTime?` â ${e.endTime}`:""),1)]),e.doctor?(d(),m("div",wt," ð¨ââï¸ "+i(e.doctor.name?.ru||"â"),1)):h("",!0),e.services?.length?(d(),m("div",kt," ð "+i(e.services.map(S=>S.name?.ru||"â").join(", ")),1)):h("",!0)]))),128))])]),_:1}),n(_,{header:t.$t("clients.appointmentHistory"),class:"mt-4"},{default:f(()=>[n(le,{value:l(c).appointments,"row-hover":""},{empty:f(()=>[a("div",Nt,i(t.$t("clients.noAppointments")),1)]),default:f(()=>[n(k,{header:t.$t("common.date"),style:{width:"180px"}},{body:f(({data:e})=>[a("div",Dt,i(C(e.createdAt)),1)]),_:1},8,["header"]),n(k,{header:t.$t("directions.direction")},{body:f(({data:e})=>[E(i(e.direction?.name?.ru||"â"),1)]),_:1},8,["header"]),n(k,{header:t.$t("common.status"),style:{width:"130px"}},{body:f(({data:e})=>[n(L,{value:l(H)[e.status],severity:l(Y)[e.status]},null,8,["value","severity"])]),_:1},8,["header"]),n(k,{style:{width:"50px"}},{body:f(({data:e})=>[F(n(r,{icon:"pi pi-eye",size:"small",text:"",rounded:"",onClick:S=>l(D).push(`/admin/appointments/${e.id}`)},null,8,["onClick"]),[[T,t.$t("common.view"),void 0,{bottom:!0}]])]),_:1})]),_:1},8,["value"])]),_:1},8,["header"])])])):h("",!0)])}}}),as=xe(Vt,[["__scopeId","data-v-7cdd8094"]]);export{as 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.