1import he from"./DEIW5kST.js";import{_ as Ve}from"./CWqE-Q2O.js";import{k as Se,r as Ue,I as Ce,x as n,V as $e,v as ee,f as Le,c as j,a as _,b as t,w as o,q as l,D as c,F as Te,d as g,A as De,G,n as te,y as J,o as P}from"./BrkecvL-.js";import{_ as Re}from"./By7nLsMb.js";import{_ as ke}from"./DNwzUh5m.js";import Pe from"./CiGzBY0A.js";import Ie from"./phojq1F-.js";import Ee from"./nfK6dNsP.js";import Ae from"./Hd2bUqY8.js";import Be from"./BDq_QRNL.js";import Fe from"./DzjlwqdM.js";import ze from"./D0kFXJMG.js";import Ne from"./Danq_jvm.js";import Oe from"./xvHkWpOM.js";import qe from"./fEnMOZhx.js";import je from"./BUUEe1Bl.js";import Ge from"./DnvqGMjd.js";import Me from"./DiR_9q0S.js";import He from"./DDiPjWxh.js";import Xe from"./CRxT52Nu.js";import{u as Je}from"./CjUXpmsH.js";import{h as Ke,i as E}from"./DriSxad0.js";import{_ as Qe}from"./DlAUqK2U.js";import"./hyjFpzdr.js";import"./fFiXWMDk.js";import"./V7R8siDq.js";import"./CdUapByI.js";import"./DfbQtUfl.js";import"./xSSxg6Px.js";import"./BKbaG_33.js";import"./DUtg4XGi.js";import"./Ddlc_1IA.js";import"./CASPRpuT.js";import"./fxXxSX-4.js";import"./q-TicHYr.js";import"./DhV-vYrl.js";import"./D9ZSq6k7.js";import"./DYhftwlw.js";import"./CS2lKLWG.js";import"./Be9FUOsi.js";import"./DT36qFB5.js";import"./BOHEeBgn.js";import"./DwkNrcZA.js";import"./D7OjAjXY.js";import"./E5hnjbWG.js";import"./BlrzcdpB.js";import"./BvJU0dNw.js";import"./DjyQeiBl.js";const We={class:"grid-container"},Ye={class:"left-box"},Ze={class:"page-container",style:{width:"100%"}},et={class:"page-container",style:{width:"100%"}},tt={class:"page-container",style:{width:"100%"}},lt={class:"page-container",style:{width:"100%"}},at={class:"right-box"},ot={style:{display:"flex","flex-direction":"row","justify-content":"space-between","align-items":"center"}},nt={class:"thumbnail-box"},st={key:1},it=["src"],rt={style:{display:"flex","flex-direction":"column","justify-content":"flex-start","align-items":"flex-start",gap:"6px"}},ut={key:0,style:{color:"red"}},dt=Se({__name:"[id]",setup(mt){const le=Ue().public.siteUrl,K=Ce(),V=n(!1),u=Je(),ae=$e(),f=n(""),S=n(""),U=n(""),C=n(""),w=n(""),$=n(""),L=n(""),T=n(""),b=n(),Q=n(""),I=n(),W=n([{name:"Published",value:"publish"},{name:"Draft",value:"draft"}]),oe=()=>{!b.value?.trim()&&f.value&&(b.value=Ke(f.value).toLowerCase().replace(/ /g,"-").replace(/[^\w-]+/g,""))},D=n(),ne=ee(()=>D.value?new Date(D.value).toISOString():new Date().toISOString()),d=n(!1),se=()=>{ae.require({message:"Are you sure you want to translate before saving?",header:"Confirm Translation",accept:async()=>{if(!f.value||!w.value){u.showError("No content for translation.");return}d.value=!0;try{const a=await E(w.value),e=await $fetch("/api/translate",{method:"post",body:{title:f.value,content:a}});S.value=e.translationTitle,U.value=e.translationTitleRu,C.value=e.translationTitlePl,$.value=e.translationContent,L.value=e.translationContentRu,T.value=e.translationContentPl,d.value=!1,u.showSuccess("Translation successful!")}catch(a){u.showError(a),d.value=!1}},reject:()=>{u.showInfo("Translation cancelled.")}})},R=n(),m=n(),M=n(),H=n(),k=n(!1);function ie(a){const e=a.files[0],p=new FileReader;p.onload=async v=>{v.target&&(k.value=!0,R.value=v.target.result,m.value=e)},p.readAsDataURL(e)}const re=async()=>{R.value=null,M.value.clear(),m.value=null,k.value=!0},ue=async()=>{if(m.value){const a=new FormData;a.append("file",m.value);try{const e=await $fetch("/api/upload/fileUpload",{method:"POST",body:a});H.value=e.file}catch(e){u.showError(e)}}},A=n(),B=n(),x=n(),de=async()=>{try{const a=await $fetch("/api/locations/getLocations");a.success?(A.value=a.statesData,B.value=a.citiesData):u.showError(a.message)}catch(a){u.showError(a)}},me=ee(()=>!A.value||!B.value?[]:A.value.map(a=>({name:a.name,cities:B.value.filter(e=>e.state_id===a.id).map(e=>({cname:e.name,id:e.id,state_id:e.state_id,state_name:a.name}))}))),i=n(),Y=async()=>{V.value=!0;try{const a=await $fetch(`/api/diaspors/getSingleDiasporsById?id=${K.params.id}`);if(a.success){i.value=a.data,f.value=i.value?.title,S.value=i.value?.titleUS,U.value=i.value?.titleRU,C.value=i.value?.titlePL,w.value=i.value?.content,$.value=i.value?.contentUS,L.value=i.value?.contentRU,T.value=i.value?.contentPL,b.value=i.value?.slug,m.value=i.value?.image,Q.value=i.value?.author;const e=i.value?.status;I.value=W.value.find(r=>r.value===e)||null;const p=i.value?.state,v=i.value?.city,y=A.value.find(r=>r.name.toLowerCase()===p?.toLowerCase());if(y){const r=B.value.find(h=>h.name.toLowerCase()===v?.toLowerCase()&&h.state_id===y.id);r&&(x.value={cname:r.name,id:r.id,state_id:r.state_id,state_name:y.name})}i.value?.createdAt&&(D.value=new Date(i.value.createdAt))}else u.showError(a.error)}catch(a){u.showError(a)}finally{V.value=!1}},X=n(!1),ce=async()=>{V.value=!0;try{if(x.value)X.value=!1;else{X.value=!0,u.showError("City is required."),V.value=!1;return}M.value.files.length>0?await ue():H.value=m.value;const a=await E(w.value),e=await E($.value),p=await E(L.value),v=await E(T.value),y=await $fetch("/api/diaspors/updateDiasporsById",{method:"POST",body:{id:Number(K.params.id),title:f.value,titleUS:S.value,titleRU:U.value,titlePL:C.value,content:a,contentUS:e,contentRU:p,contentPL:v,author:Q.value,slug:b.value,image:k.value?H.value:m.value,state:x.value?.state_name,city:x.value?.cname,status:I.value?.value,createdAt:ne.value}});y.success?(u.showSuccess(y.message),k.value=!1,Y()):u.showError(y.message)}catch(a){u.showError(a)}finally{V.value=!1}};return Le(async()=>{await de(),Y(),m||(k.value=!0)}),(a,e)=>{const p=he,v=Xe,y=He,r=Me,h=Ve,F=De,z=Ge,pe=je,ve=qe,Z=Oe,N=Ne,O=ze,q=Fe,fe=Be,_e=Re,ye=ke,ge=Ae,we=Ee,be=Ie,xe
1=Pe;return P(),j(Te,null,[_("div",We,[_("div",Ye,[t(pe,{value:"0",style:{width:"100%"}},{default:o(()=>[t(y,{style:{"margin-bottom":"24px"}},{default:o(()=>[t(v,{value:"0",style:{display:"inline-flex","align-items":"center",gap:"3px"}},{default:o(()=>[t(p,{name:"material-symbols-light:language",size:"20px"}),e[12]||(e[12]=g(" UA ",-1))]),_:1}),t(v,{value:"1",style:{display:"inline-flex","align-items":"center",gap:"3px"}},{default:o(()=>[t(p,{name:"material-symbols-light:language",size:"20px"}),e[13]||(e[13]=g(" US ",-1))]),_:1}),t(v,{value:"2",style:{display:"inline-flex","align-items":"center",gap:"3px"}},{default:o(()=>[t(p,{name:"material-symbols-light:language",size:"20px"}),e[14]||(e[14]=g(" RU ",-1))]),_:1}),t(v,{value:"3",style:{display:"inline-flex","align-items":"center",gap:"3px"}},{default:o(()=>[t(p,{name:"material-symbols-light:language",size:"20px"}),e[15]||(e[15]=g(" PL ",-1))]),_:1})]),_:1}),t(z,{value:"0"},{default:o(()=>[t(r,{type:"text",modelValue:l(f),"onUpdate:modelValue":e[0]||(e[0]=s=>c(f)?f.value=s:null),style:{width:"100%","margin-bottom":"24px"},placeholder:"Title",disabled:l(d)},null,8,["modelValue","disabled"]),_("div",Ze,[t(F,null,{default:o(()=>[t(h,{modelValue:l(w),"onUpdate:modelValue":e[1]||(e[1]=s=>c(w)?w.value=s:null),style:G(l(d)?"pointer-events: none; opacity: 0.5":"")},null,8,["modelValue","style"])]),_:1})])]),_:1}),t(z,{value:"1"},{default:o(()=>[t(r,{type:"text",modelValue:l(S),"onUpdate:modelValue":e[2]||(e[2]=s=>c(S)?S.value=s:null),style:{width:"100%","margin-bottom":"24px"},placeholder:"Title",disabled:l(d)},null,8,["modelValue","disabled"]),_("div",et,[t(F,null,{default:o(()=>[t(h,{modelValue:l($),"onUpdate:modelValue":e[3]||(e[3]=s=>c($)?$.value=s:null),style:G(l(d)?"pointer-events: none; opacity: 0.5":"")},null,8,["modelValue","style"])]),_:1})])]),_:1}),t(z,{value:"2"},{default:o(()=>[t(r,{type:"text",modelValue:l(U),"onUpdate:modelValue":e[4]||(e[4]=s=>c(U)?U.value=s:null),style:{width:"100%","margin-bottom":"24px"},placeholder:"Title",disabled:l(d)},null,8,["modelValue","disabled"]),_("div",tt,[t(F,null,{default:o(()=>[t(h,{modelValue:l(L),"onUpdate:modelValue":e[5]||(e[5]=s=>c(L)?L.value=s:null),style:G(l(d)?"pointer-events: none; opacity: 0.5":"")},null,8,["modelValue","style"])]),_:1})])]),_:1}),t(z,{value:"3"},{default:o(()=>[t(r,{type:"text",modelValue:l(C),"onUpdate:modelValue":e[6]||(e[6]=s=>c(C)?C.value=s:null),style:{width:"100%","margin-bottom":"24px"},placeholder:"Title",disabled:l(d)},null,8,["modelValue","disabled"]),_("div",lt,[t(F,null,{default:o(()=>[t(h,{modelValue:l(T),"onUpdate:modelValue":e[7]||(e[7]=s=>c(T)?T.value=s:null),style:G(l(d)?"pointer-events: none; opacity: 0.5":"")},null,8,["modelValue","style"])]),_:1})])]),_:1})]),_:1})]),_("div",at,[_("div",ot,[t(ve,{modelValue:l(I),"onUpdate:modelValue":e[8]||(e[8]=s=>c(I)?I.value=s:null),options:l(W),optionLabel:"name",placeholder:"Select status"},null,8,["modelValue","options"]),t(Z,{label:"Save",severity:"contrast",variant:"outlined",loading:l(V),onClick:ce,disabled:!l(f)},null,8,["loading","disabled"])]),t(Z,{label:"Translate",severity:"info",variant:"outlined",loading:l(d),onClick:se,style:{"margin-top":"24px",width:"100%"}},null,8,["loading"]),t(be,{value:["2","3"],multiple:"",style:{width:"100%"}},{default:o(()=>[t(q,{value:"0"},{default:o(()=>[t(N,null,{default:o(()=>[...e[16]||(e[16]=[g("Slug",-1)])]),_:1}),t(O,null,{default:o(()=>[t(r,{type:"text",modelValue:l(b),"onUpdate:modelValue":e[9]||(e[9]=s=>c(b)?b.value=s:null),style:{width:"100%"},onBlur:oe},null,8,["modelValue"])]),_:1})]),_:1}),t(q,{value:"1"},{default:o(()=>[t(N,null,{default:o(()=>[...e[17]||(e[17]=[g("Date",-1)])]),_:1}),t(O,null,{default:o(()=>[t(fe,{modelValue:l(D),"onUpdate:modelValue":e[10]||(e[10]=s=>c(D)?D.value=s:null),inline:"",showTime:"",hourFormat:"24",style:{width:"100%"}},null,8,["modelValue"])]),_:1})]),_:1}),t(q,{value:"2"},{default:o(()=>[t(N,null,{default:o(()=>[...e[18]||(e[18]=[g("Main image",-1)])]),_:1}),t(O,null,{default:o(()=>[_("div",nt,[!l(R)&&!l(m)?(P(),te(_e,{key:0})):J("",!0),!l(R)&&!l(m)?(P(),j("small",st,"No image")):(P(),j("img",{key:2,src:l(k)?`${l(R)}`:`${l(le)}${l(m)}`,alt:"post thumbnail"},null,8,it)),l(R)||l(m)?(P(),te(ye,{key:3,style:{position:"absolute",top:"7px",right:"7px","z-index":"2",cursor:"pointer",background:"white",padding:"4px","border-radius":"50%"},onClick:re})):J("",!0)]),t(ge,{mode:"basic",ref_key:"fileUploadRef",ref:M,onSelect:ie,customUpload:"",severity:"secondary",class:"p-button-outlined",multiple:!1,accept:"image/*",maxFileSize:4194304},null,512)]),_:1})]),_:1}),t(q,{value:"3"},{default:o(()=>[t(N,null,{default:o(()=>[...e[19]||(e[19]=[g("Locations",-1)])]),_:1}),t(O,null,{default:o(()=>[_("div",rt,[t(we,{modelValue:l(x),"onUpdate:modelValue":e[11]||(e[11]=s=>c(x)?x.value=s:null),options:l(me),optionLabel:"cname",optionGroupLabel:"name",optionGroupChildren:["cities"],showClear:"",placeholder:"Select a City",style:{"min-width":"80px"}},null,8,["modelValue","options"]),l(X)?(P(),j("small",ut,"City is required.")):J("",!0)])]),_:1})]),_:1})]),_:1})])]),t(xe)],64)}}}),sl=Qe(dt,[["__scopeId","data-v-1ab86da0"]]);export{sl 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.