import{d as V,c as g,b as v,o as r,r as q,w as N,h as i,q as n,i as b,bu as f,p as k,c6 as F,e as K,dd as O,b$ as R,g as W,G as z,j as $,F as G,I as H,H as L}from"./index-BX34W763.js";import{V as U,g as B,ah as D,i as P,n as T,h as M}from"./ReferenceContentLoader-D7Cnl9bC.js";import{r as Z}from"./EmptyState.vue-Crf0mdO_.js";import{m as J,g as Q}from"./SidebarButton.vue-CoW3Pkpb.js";import{_ as X,p as Y}from"./SidebarListElement.vue-CYFeUkZW.js";import{u as ee}from"./ViewLayout.vue-Ct_O07yw.js";import{x as ae}from"./ViewLayoutContent.vue-B5mQggcF.js";import{b as oe}from"./ViewLayoutSection.vue-jyo-hhqX.js";import{q as te}from"./Form.vue-rqr1_W68.js";import{h as se,E as y}from"./CommandActionInput.vue-Cs8CJnM9.js";import"./__vite-browser-external-D7Ct-6yo.js";import"./DocumentMobileHeader.vue-CXp3gXuT.js";import"./ScalarHotkey.vue-DbDm3TVb.js";import"./ScalarAsciiArt.vue-DfOJg2Wf.js";import"./Draggable.vue-Csiddntz.js";import"./DeleteSidebarListElement.vue-BV2fba9G.js";const le=V({__name:"CookieForm",setup(x){const{activeCookieId:d}=U(),{cookies:c,cookieMutators:p}=B(),o=[{label:"Name",key:"name",placeholder:"session_id"},{label:"Value",key:"value",placeholder:"my-cookie-session-id"},{label:"Domain",key:"domain",placeholder:"example.com"}],m=g(()=>c[d.value]||D.parse({name:"",value:"",domain:"",path:""})),h=(l,e)=>{p.edit(d.value,l,e)};return(l,e)=>(r(),v(te,{data:m.value,onUpdate:h,options:o},null,8,["data"]))}}),ie={class:"flex h-8 items-start gap-2 text-sm"},ue={class:"flex h-8 items-start gap-2 text-sm"},ne={class:"flex h-8 items-start gap-2 text-sm"},de=V({__name:"CookieModal",props:{state:{}},emits:["cancel","submit"],setup(x,{emit:d}){const c=x,p=d,o=q({name:"",value:"",domain:""}),{toast:m}=P(),h=()=>{if(!o.value.name||!o.value.value){m("Please fill in all fields before adding a cookie.","error");return}p("submit",o.value),c.state.hide()};return N(()=>c.state.open,l=>{l&&(o.value={name:"",value:"",domain:""})}),(l,e)=>(r(),v(k(F),{size:"xs",state:l.state,title:"Add Cookie"},{default:i(()=>[n(se,{disabled:!o.value.name||!o.value.value,onCancel:e[3]||(e[3]=u=>p("cancel")),onSubmit:h},{submit:i(()=>e[7]||(e[7]=[f("Add Cookie")])),default:i(()=>[b("div",ie,[e[4]||(e[4]=f(" Name: ")),n(y,{modelValue:o.value.name,"onUpdate:modelValue":e[0]||(e[0]=u=>o.value.name=u),autofocus:"",class:"!p-0",placeholder:"session_id"},null,8,["modelValue"])]),b("div",ue,[e[5]||(e[5]=f(" Value: ")),n(y,{modelValue:o.value.value,"onUpdate:modelValue":e[1]||(e[1]=u=>o.value.value=u),autofocus:"",class:"!p-0",placeholder:"my-cookie-session-id"},null,8,["modelValue"])]),b("div",ne,[e[6]||(e[6]=f(" Domain: ")),n(y,{modelValue:o.value.domain,"onUpdate:modelValue":e[2]||(e[2]=u=>o.value.domain=u),autofocus:"",class:"!p-0",placeholder:"example.com"},null,8,["modelValue"])])]),_:1},8,["disabled"])]),_:1},8,["state"]))}}),me=T(de,[["__scopeId","data-v-694018d6"]]),re={class:"flex-1"},ce={class:"relative mb-[.5px] last:mb-0"},Ue=V({__name:"Cookies",setup(x){const{cookies:d,cookieMutators:c,events:p,workspaceMutators:o}=B(),{activeWorkspace:m,activeCookieId:h}=U(),l=K(),e=O(),u=R(),j=s=>{const t=D.parse({name:s.name,value:s.value,domain:s.domain,path:"/"});c.add(t),o.edit(m.value?.uid,"cookies",[...m.value?.cookies??[],t.uid]),l.push({name:"cookies",params:{cookies:t.uid}})},A=s=>{c.delete(s),o.edit(m.value?.uid,"cookies",[...(m.value?.cookies??[]).filter(a=>a!==s)]);const t=Object.values(d).filter(a=>a.uid!==s);if(t.length>0){const a=t[t.length-1];a&&l.push(a.uid)}else l.push({name:"cookies",params:{[M.Cookies]:"default"}})},C=()=>{u.show()},w=s=>{s?.createNew&&e.name==="cookies"&&C()},E=(s,t)=>{const a={name:"cookies",params:{workspace:m.value?.uid??"default",cookies:t}};if(s.metaKey){const _=l.resolve(a).href;window.open(_,"_blank");return}l.push(a)};W(()=>p.hotKeys.on(w)),z(()=>p.hotKeys.off(w));const I=g(()=>d[h.value]),S=g(()=>Object.keys(d).length>0&&I.value);return N(()=>e.query.openCookieModal,s=>{s==="true"&&C()},{immediate:!0}),(s,t)=>(r(),v(ee,null,{default:i(()=>[n(k(J),{title:"Cookies"},{content:i(()=>[b("div",re,[n(X,null,{default:i(()=>[(r(!0),$(G,null,H(Object.values(k(d)),a=>(r(),$("li",{key:a.uid,class:"gap-1/2 flex flex-col"},[b("div",ce,[(r(),v(Y,{key:a.uid,class:"text-xs",isDeletable:"",to:{name:"cookies",params:{[k(M).Cookies]:a.uid}},type:"cookies",variable:{name:a.name,uid:a.uid},warningMessage:"Are you sure you want to delete this cookie?",onClick:L(_=>E(_,a.uid),["prevent"]),onDelete:_=>A(a.uid)},null,8,["to","variable","onClick","onDelete"]))])]))),128))]),_:1})])]),button:i(()=>[n(Q,{click:C,hotkey:"N"},{title:i(()=>t[1]||(t[1]=[f(" Add Cookie ")])),_:1})]),_:1}),n(ae,{class:"flex-1"},{default:i(()=>[S.value?(r(),v(oe,{key:0,class:"*:border-b-0"},{title:i(()=>t[2]||(t[2]=[f("Edit Cookie")])),default:i(()=>[n(le)]),_:1})):(r(),v(Z,{key:1}))]),_:1}),n(me,{state:k(u),onCancel:t[0]||(t[0]=a=>k(u).hide()),onSubmit:j},null,8,["state"])]),_:1}))}});export{Ue as default};
