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,P as c,R as l,Tt as u,Ut as d,bt as f,h as p,j as m,ot as h,qt as g}from"./vue-3bs2-dMU.js";import{K as _,U as v,p as y,z as b}from"./stores-DmetsdTd.js";import{C as x,D as S,G as C,K as w,N as T,S as E,T as D,U as O,W as k,_t as A,b as j,d as M,f as N,gt as P,w as F}from"./vuetify-gGrfRH2I.js";i(),u(),d();var I=t({__name:`CookieImportDialog`,props:{guid:{}},setup(t){let{isOpened:i}=v(t.guid),{t:u}=_(),d=y(),I=[{title:u(`dialogs.cookiesImport.type.netscape`),value:0,props:{prependIcon:`mdi-table`}},{title:u(`dialogs.cookiesImport.type.json`),value:1,props:{prependIcon:`mdi-code-json`}},{title:u(`dialogs.cookiesImport.type.header`),value:2,props:{prependIcon:`mdi-text-long`}}],L=o(0),R=o(``),z=e({domain:``,path:``,expirationDate:0}),B=o(!1),V=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}}),H=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}});function U(){let e=JSON.parse(R.value);return Array.isArray(e)?e.map(e=>new b(e)):[new b(e)]}function W(){let e=[],t=R.value.split(`
`);for(let n of t){if(!n||n.startsWith(`#`))continue;let t=n.split(`	`);if(t.length!==7)continue;let[r,,i,,a,o,s]=t;e.push(new b({domain:r.trim(),path:i.trim(),name:o.trim(),value:decodeURIComponent(s.trim()),expirationDate:parseInt(a.trim(),10)}))}return e}function G(){return R.value.split(`;`).map(e=>{let[t,n]=e.split(`=`);return new b({domain:z.domain,path:z.path,name:t.trim(),value:n.trim(),expirationDate:z.expirationDate})})}async function K(){B.value=!0;try{let e;switch(L.value){case 1:e=U();break;case 0:e=W();break;case 2:e=G()}await d.importCookies(e,!0)}catch(e){p.error(e),B.value=!1}B.value&&q()}function q(){i.value=!1}return(e,t)=>(h(),s(E,{modelValue:n(i),"onUpdate:modelValue":t[6]||=e=>r(i)?i.value=e:null,"max-width":`1250`},{default:f(()=>[l(x,null,{default:f(()=>[l(D,{class:`ios-margin`},{default:f(()=>[l(O,{color:`transparent`},{default:f(()=>[l(k,null,{default:f(()=>[a(g(n(u)(`dialogs.cookiesImport.title`)),1)]),_:1}),l(w,{icon:`mdi-close`,onClick:q})]),_:1})]),_:1}),l(F,null,{default:f(()=>[l(T,{modelValue:L.value,"onUpdate:modelValue":t[0]||=e=>L.value=e,items:I,label:n(u)(`dialogs.cookiesImport.type.label`)},null,8,[`modelValue`,`label`]),l(j,{modelValue:R.value,"onUpdate:modelValue":t[1]||=e=>R.value=e,label:n(u)(`dialogs.cookiesImport.input`)},null,8,[`modelValue`,`label`]),L.value===2?(h(),s(P,{key:0},{default:f(()=>[l(A,{cols:`12`,sm:`6`},{default:f(()=>[l(C,{modelValue:z.domain,"onUpdate:modelValue":t[2]||=e=>z.domain=e,label:n(u)(`dialogs.cookiesManager.domain`)},null,8,[`modelValue`,`label`])]),_:1}),l(A,{cols:`12`,sm:`6`},{default:f(()=>[l(C,{modelValue:z.path,"onUpdate:modelValue":t[3]||=e=>z.path=e,label:n(u)(`dialogs.cookiesManager.path`)},null,8,[`modelValue`,`label`])]),_:1}),l(A,{cols:`12`,sm:`6`,class:`d-flex justify-center`},{default:f(()=>[l(N,{modelValue:V.value,"onUpdate:modelValue":t[4]||=e=>V.value=e,min:new Date},null,8,[`modelValue`,`min`])]),_:1}),l(A,{cols:`12`,sm:`6`,class:`d-flex justify-center`},{default:f(()=>[l(M,{modelValue:H.value,"onUpdate:modelValue":t[5]||=e=>H.value=e,format:`24hr`,"use-seconds":``},null,8,[`modelValue`])]),_:1})]),_:1})):c(``,!0)]),_:1}),l(S,null,{default:f(()=>[l(w,{color:`accent`,onClick:K},{default:f(()=>[a(g(n(u)(`common.submit`)),1)]),_:1}),l(w,{color:`error`,onClick:q},{default:f(()=>[a(g(n(u)(`common.close`)),1)]),_:1})]),_:1})]),_:1})]),_:1},8,[`modelValue`]))}});export{I as default};