import{r as T,j as t}from"./v_7_4_3_4_e110faba-0ecf-462e-819c-68342bb684f6.js";import{m as D,ar as y}from"./v_7_4_3_4_e110faba-0ecf-462e-819c-68342bb684f623.js";import{u as $}from"./v_7_4_3_4_e110faba-0ecf-462e-819c-68342bb684f620.js";import{U as h,X as z,bq as l,$ as N,I as g}from"./v_7_4_3_4_e110faba-0ecf-462e-819c-68342bb684f611.js";import"./v_7_4_3_4_e110faba-0ecf-462e-819c-68342bb684f68.js";import"./v_7_4_3_4_e110faba-0ecf-462e-819c-68342bb684f67.js";import"./v_7_4_3_4_e110faba-0ecf-462e-819c-68342bb684f619.js";import"./v_7_4_3_4_e110faba-0ecf-462e-819c-68342bb684f64.js";import"./v_7_4_3_4_e110faba-0ecf-462e-819c-68342bb684f63.js";import"./v_7_4_3_4_e110faba-0ecf-462e-819c-68342bb684f62.js";import"./v_7_4_3_4_e110faba-0ecf-462e-819c-68342bb684f610.js";import"./v_7_4_3_4_e110faba-0ecf-462e-819c-68342bb684f66.js";import"./v_7_4_3_4_e110faba-0ecf-462e-819c-68342bb684f69.js";function u(i,s){const n=new Date(`${i}T${s}:00`).getTimezoneOffset(),e=Math.abs(Math.floor(n/60)),c=Math.abs(n%60),d=`${n>0?"-":"+"}${e.toString().padStart(2,"0")}:${c.toString().padStart(2,"0")}`;return`${i}T${s}:00${d}`}function A(){const{language:i}=$(),{close:s}=D(),r=h.dayDate(),n=h.timeDate(),[e,c]=T.useState({title:document.getElementById("chatName")?.innerHTML,init_date:r.year+"-"+r.month+"-"+r.day,init_hora:n.hours+":"+n.minutes,fim_date:"",fim_hora:"",location:"",descricao:""}),o=(a,p)=>{c({...e,[a]:p})},d=async()=>{if(e.init_date.length===0||e.init_hora.length===0||e.fim_date.length===0||e.fim_hora.length===0){g({type:"Error",message:i.preenchaTodosCamposDataHora,position:"top-right"});return}const a=new Date(e.init_date+" "+e.init_hora).getTime();if(new Date(e.fim_date+" "+e.fim_hora).getTime()<a){g({type:"Error",message:i.dataDeTerminoInferiorDataInicio,position:"top-right"});return}if(await y("googleCalendario")===!0)return;g({type:"Success",message:i.eventoGoogleCalendarioCriado,position:"top-right"});let m="https://calendar.google.com/calendar/render?action=TEMPLATE",x=`&text=${encodeURIComponent(e.title)}`,_=u(e.init_date,e.init_hora),v=u(e.fim_date,e.fim_hora),j=`&dates=${_.replace(new RegExp("[-:+]","g"),"")}/${v.replace(new RegExp("[-:+]","g"),"")}`,C=`&details=${encodeURIComponent(e.descricao)}`,w=`&location=${encodeURIComponent(e.location)}`;m=m+x+j+C+w,window.open(m,"_blank"),s()};return t.jsxs("div",{className:"w-[35rem] p-2 flex flex-col items-center",children:[t.jsx("header",{className:"w-full",children:t.jsx(z,{size:"22px",weight:"bold",children:i.modal_schedulingCallendar_title})}),t.jsxs("main",{className:"w-full flex flex-col gap-3 mt-2",children:[t.jsx(l,{size:"15px",title:i.modal_schedulingCallendar_placeTitle,type:"text",placeHolder:i.modal_schedulingCallendar_placeMessage,value:e.title,onchange:a=>o("title",a.target.value)}),t.jsxs("div",{className:"w-full flex flex-col gap-2",children:[t.jsxs("div",{className:"w-full gap-3 flex items-center",children:[t.jsx("div",{className:"w-3/6",children:t.jsx(l,{size:"12px",title:i.modal_schedulingCallendar_since,type:"date",value:e.init_date,onchange:a=>o("init_date",a.target.value)})}),t.jsx("div",{className:"w-3/6 self-end",children:t.jsx(l,{title:"",type:"time",value:e.init_hora,onchange:a=>o("init_hora",a.target.value)})})]}),t.jsxs("div",{className:"w-full gap-3 flex items-center",children:[t.jsx("div",{className:"w-3/6",children:t.jsx(l,{size:"12px",title:i.modal_schedulingCallendar_until,type:"date",value:e.fim_date,onchange:a=>o("fim_date",a.target.value)})}),t.jsx("div",{className:"w-3/6 self-end",children:t.jsx(l,{title:"",type:"time",value:e.fim_hora,onchange:a=>o("fim_hora",a.target.value)})})]})]}),t.jsx(l,{size:"15px",title:i.modal_schedulingCallendar_location,type:"text",placeHolder:i.inserirLocalizacao,value:e.location,onchange:a=>o("location",a.target.value)}),t.jsx(l,{size:"15px",title:i.modal_schedulingCallendar_description,type:"text",placeHolder:i.modal_schedulingCallendar_placeMessageAbout,value:e.descricao,onchange:a=>o("descricao",a.target.value)})]}),t.jsx("footer",{className:"mt-2",children:t.jsx(N,{funcao:d,name:i.modal_schedulingCallendar_saveButton})})]})}export{A as default};
