import{d as C,u as M,ai as S,Y as s,o as V,g as k,w as c,a,i as l,k as f,af as m,h as p,l as i,aY as A,N as x,X as O,aM as B,ah as I,aN as L,_ as U}from"./v5WcX6fg.js";import{N as T}from"./TS9ft8Ya.js";const Y={class:"flex flex-col gap-3"},P={class:"flex flex-col gap-2"},R={class:"flex flex-col gap-2"},X={class:"text-input-wrapper"},$={class:"flex flex-col gap-2"},j={class:"textarea-wrapper"},D={class:"flex gap-2"},E=C({__name:"OrganizationCreateModal",setup(F,{expose:v}){const b=M(),{addNotification:w}=S(),n=s(""),r=s(""),d=s(""),g=s(!1),u=s();async function h(){var e;B();try{const t={name:n.value.trim(),description:d.value.trim(),slug:r.value.trim().replace(/ +/g,"")},o=await I("organization",{method:"POST",body:JSON.stringify(t),apiVersion:3});(e=u.value)==null||e.hide(),await b.push(`/organization/${o.slug}`)}catch(t){console.error(t),w({title:"An error occurred",text:t.data?t.data.description:t,type:"error"})}L()}function _(e){var t;n.value="",d.value="",(t=u.value)==null||t.show(e)}function y(){var e;(e=u.value)==null||e.hide()}function z(){g.value||(r.value=n.value.trim().toLowerCase().replaceAll(" ","-").replaceAll(/[^a-zA-Z0-9!@$()`.+,_"-]/g,"").replaceAll(/--+/gm,"-"))}function N(){g.value=!0}return v({show:_}),(e,t)=>(V(),k(i(T),{ref_key:"modal",ref:u,header:"Creating an organization"},{default:c(()=>[a("div",Y,[a("div",P,[t[3]||(t[3]=a("label",{for:"name"},[a("span",{class:"text-lg font-semibold text-contrast"},[l(" Name "),a("span",{class:"text-brand-red"},"*")])],-1)),f(a("input",{id:"name","onUpdate:modelValue":t[0]||(t[0]=o=>n.value=o),type:"text",maxlength:"64",placeholder:"Enter organization name...",autocomplete:"off",onInput:z},null,544),[[m,n.value]])]),a("div",R,[t[5]||(t[5]=a("label",{for:"slug"},[a("span",{class:"text-lg font-semibold text-contrast"},[l(" URL "),a("span",{class:"text-brand-red"},"*")])],-1)),a("div",X,[t[4]||(t[4]=a("div",{class:"text-input-wrapper__before"},"https://test.kalataka.ru/organization/",-1)),f(a("input",{id:"slug","onUpdate:modelValue":t[1]||(t[1]=o=>r.value=o),type:"text",maxlength:"64",autocomplete:"off",onInput:N},null,544),[[m,r.value]])])]),a("div",$,[t[6]||(t[6]=a("label",{for:"additional-information",class:"flex flex-col gap-1"},[a("span",{class:"text-lg font-semibold text-contrast"},[l(" Summary "),a("span",{class:"text-brand-red"},"*")]),a("span",null,"A sentence or two that describes your organization.")],-1)),a("div",j,[f(a("textarea",{id:"additional-information","onUpdate:modelValue":t[2]||(t[2]=o=>d.value=o),maxlength:"256"},null,512),[[m,d.value]])])]),t[9]||(t[9]=a("p",{class:"m-0 max-w-[30rem]"}," You will be the owner of this organization, but you can invite other members and transfer ownership at any time. ",-1)),a("div",D,[p(i(x),{color:"brand"},{default:c(()=>[a("button",{onClick:h},[p(i(A),{"aria-hidden":"true"}),t[7]||(t[7]=l(" Create organization "))])]),_:1}),p(i(x),null,{default:c(()=>[a("button",{onClick:y},[p(i(O),{"aria-hidden":"true"}),t[8]||(t[8]=l(" Cancel "))])]),_:1})])])]),_:1},512))}}),q=U(E,[["__scopeId","data-v-db56f522"]]);export{q as O};