import{At as e,B as t,Bt as n,Dt as r,G as i,L as a,Mt as o,N as s,Q as c,R as l,T as u,Tt as d,Ut as f,bt as p,j as m,ot as h,qt as g,y as _}from"./vue-3bs2-dMU.js";import{K as v,U as y,p as b,z as x}from"./stores-DmetsdTd.js";import{C as S,D as C,G as w,K as T,S as E,T as D,U as O,W as k,_t as A,d as j,f as M,gt as N,w as P,y as F}from"./vuetify-gGrfRH2I.js";i(),d(),f(),_();var I=t({__name:`CookieFormDialog`,props:{guid:{},initialCookie:{}},setup(t){let i=t,{isOpened:d}=y(i.guid),{t:f}=v(),_=b(),I=m(()=>!!i.initialCookie),L=[()=>{let e=_.cookies.filter(e=>e.equals(z));return!I.value&&e.length!==0||I.value&&e.length>0&&!i.initialCookie.equals(z)?f(`dialogs.cookiesManager.rules.duplicate`):!0}],R=o(!1),z=e(new x({name:``,value:``,domain:``,path:``,expirationDate:0})),B=m({get:()=>new Date(z.expirationDate*1e3).toDateString(),set:e=>{let t=new Date(z.expirationDate*1e3),n=new Date(e);t.setFullYear(n.getFullYear()),t.setMonth(n.getMonth()),t.setDate(n.getDate()),z.expirationDate=t.getTime()/1e3}}),V=m({get:()=>{let e=new Date(z.expirationDate*1e3);return`${e.getHours()}:${e.getMinutes()}:${e.getSeconds()}`},set:e=>{let t=new Date(z.expirationDate*1e3),[n,r,i]=e.split(`:`);t.setHours(+n),t.setMinutes(+r),t.setSeconds(+i),z.expirationDate=t.getTime()/1e3}});async function H(){R.value&&(I.value&&await _.removeCookie(i.initialCookie),await _.addCookie(z,!0),U())}function U(){d.value=!1}return c(()=>{if(I.value)Object.assign(z,i.initialCookie);else{let e=new Date;e.setMilliseconds(0),e.setFullYear(new Date().getFullYear()+1),z.expirationDate=e.getTime()/1e3}}),(e,t)=>(h(),s(E,{modelValue:n(d),"onUpdate:modelValue":t[8]||=e=>r(d)?d.value=e:null,"max-width":`1250`},{default:p(()=>[l(S,null,{default:p(()=>[l(D,{class:`ios-margin`},{default:p(()=>[l(O,{color:`transparent`},{default:p(()=>[l(k,null,{default:p(()=>[a(g(n(f)(`dialogs.cookiesManager.title`)),1)]),_:1}),l(T,{icon:`mdi-close`,onClick:U})]),_:1})]),_:1}),l(P,null,{default:p(()=>[l(F,{modelValue:R.value,"onUpdate:modelValue":t[6]||=e=>R.value=e,onSubmit:t[7]||=u(()=>{},[`prevent`])},{default:p(()=>[l(N,null,{default:p(()=>[l(A,{cols:`12`,sm:`6`},{default:p(()=>[l(w,{modelValue:z.domain,"onUpdate:modelValue":t[0]||=e=>z.domain=e,label:n(f)(`dialogs.cookiesManager.domain`)},null,8,[`modelValue`,`label`])]),_:1}),l(A,{cols:`12`,sm:`6`},{default:p(()=>[l(w,{modelValue:z.path,"onUpdate:modelValue":t[1]||=e=>z.path=e,label:n(f)(`dialogs.cookiesManager.path`)},null,8,[`modelValue`,`label`])]),_:1}),l(A,{cols:`12`,sm:`6`},{default:p(()=>[l(w,{modelValue:z.name,"onUpdate:modelValue":t[2]||=e=>z.name=e,label:n(f)(`dialogs.cookiesManager.name`),rules:L},null,8,[`modelValue`,`label`])]),_:1}),l(A,{cols:`12`,sm:`6`},{default:p(()=>[l(w,{modelValue:z.value,"onUpdate:modelValue":t[3]||=e=>z.value=e,label:n(f)(`dialogs.cookiesManager.value`)},null,8,[`modelValue`,`label`])]),_:1}),l(A,{cols:`12`,sm:`6`,class:`d-flex justify-center`},{default:p(()=>[l(M,{modelValue:B.value,"onUpdate:modelValue":t[4]||=e=>B.value=e,min:new Date},null,8,[`modelValue`,`min`])]),_:1}),l(A,{cols:`12`,sm:`6`,class:`d-flex justify-center`},{default:p(()=>[l(j,{modelValue:V.value,"onUpdate:modelValue":t[5]||=e=>V.value=e,format:`24hr`,"use-seconds":``},null,8,[`modelValue`])]),_:1})]),_:1})]),_:1},8,[`modelValue`])]),_:1}),l(C,null,{default:p(()=>[l(T,{disabled:!R.value,color:`accent`,onClick:H},{default:p(()=>[a(g(n(f)(`common.submit`)),1)]),_:1},8,[`disabled`]),l(T,{color:`error`,onClick:U},{default:p(()=>[a(g(n(f)(`common.close`)),1)]),_:1})]),_:1})]),_:1})]),_:1},8,[`modelValue`]))}});export{I as default};