import{g as t}from"./p-28c66a78.js";import{N as i}from"./p-35267d98.js";import{T as e}from"./p-681f800a.js";import{F as s,M as r}from"./p-b1fbf520.js";import{V as o}from"./p-ad6da9fe.js";import{T as a}from"./p-48f43f2a.js";import{A as n}from"./p-32f47ea6.js";import{c as m,f as l}from"./p-d49099be.js";import{a as f,s as p,b as u}from"./p-214632d0.js";import{c}from"./p-63545896.js";import{a as b}from"./p-65434c2b.js";import{N as d}from"./p-6cf8ecf7.js";import"./p-7e860896.js";import"./p-944da115.js";import"./p-d343a062.js";import{m as h}from"./p-d4bb09bf.js";import{g as j}from"./p-8dfe8365.js";const N={formView:{fetchError:"Fetching data failed.",retry:"Retry",submit:"Update Info"},formFields:{bio:"Bio",firstName:"First name",lastName:"Last name",pairLimit:"Pair limit",skills:"Professional Expertise",title:"Title"}},w={formView:{fetchError:"Veri alırken hata oluştu.",retry:"Tekrar Dene",submit:"Bilgileri Güncelle"},formFields:{bio:"Kısaca kendinizi tanıtın",firstName:"İsim",lastName:"Soyisim",pairLimit:"Eşleşme sınırı",skills:"Uzmanlık Alanlarınız",title:"Ünvan"}};class v{constructor(t,i,e){this.user=t,this.userMetadata=i,this.userMentorship=e;const{headers:s}=j();this.api=m(h,s)}onSubmit(t){const{values:i}=t.detail,{firstName:e,lastName:s,bio:r,skills:o,title:a,subscriptionLimit:n}=i,m=function(t,i){var e={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&i.indexOf(s)<0&&(e[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(s=Object.getOwnPropertySymbols(t);r<s.length;r++)i.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(t,s[r])&&(e[s[r]]=t[s[r]])}return e}(i,["firstName","lastName","bio","skills","title","subscriptionLimit"]),l={firstName:e,lastName:s,bio:r,skills:o,title:a},f={subscriptionLimit:parseInt(n)},p=m;return new Promise(((t,i)=>{let e=[this.api.update("users",this.user._id,l)];this.userMetadata&&e.push(this.api.update("metadatas",this.userMetadata._id,{data:p})),this.userMentorship&&void 0!==n&&e.push(this.api.update("mentorships",this.userMentorship._id,f)),Promise.all(e).then((()=>t({events:[new d(b.congratulate("Info updated"))]}))).catch((()=>{i(["Unexpected error"])}))}))}}function k(t,i,e,s,r){const o={firstName:e.firstName,lastName:e.lastName,bio:e.bio,title:e.title,skills:e.skills},{role:a}=t;return("mentor"===a?i.metadatas.mentorsCanEditMetadata:i.metadatas.menteesCanEditMetadata)&&(("mentor"===a?i.metadatas.mentor:i.metadatas.mentee)||[]).map(f).forEach((t=>{o[t.id]=s.data[t.id]})),r&&(o.subscriptionLimit=r.subscriptionLimit),o}function y(t,i,e,r,o,m,l){var f;if(!e)return null;const p="tr"===i?w:N,{role:u}=t,b=L(p,u,e),d=(null===(f=null==r?void 0:r.dvnAppViewConfig)||void 0===f?void 0:f.ui.fields)||c(b),h="mentor"===u?e.metadatas.mentorsCanEditMetadata:e.metadatas.menteesCanEditMetadata;return s.decode({_id:"update-membership-info-page",base:"mentornity",title:"My info",table:a.decode({name:"mentees",fields:b}),type:n.FormView,handler:new v(o,h?m:void 0,l),ui:{fields:d,i18n:p.formView}})}function L(s,a,n){const m="mentor"===a?n.profileFieldVisibilities.mentor:n.profileFieldVisibilities.mentee,c=[new e("firstName",s.formFields.firstName).addInterceptor("onSubmit",new o(2,32)).addInterceptor("onSubmit",new r).require(),new e("lastName",s.formFields.lastName).addInterceptor("onSubmit",new o(2,32)).addInterceptor("onSubmit",new r).require(),...[new e("title",s.formFields.title).addInterceptor("onSubmit",new r),new e("bio",s.formFields.bio).setLines(3).setLinesMax(10),t({id:"skills",title:s.formFields.skills,type:"multiple-choice",inputType:"select",options:p.map((t=>({label:u[t],value:t})))})].filter((t=>m[t.id]))];let b=[];return("mentor"===a?n.metadatas.mentorsCanEditMetadata:n.metadatas.menteesCanEditMetadata)&&(b=(("mentor"===a?n.metadatas.mentor:n.metadatas.mentee)||[]).map(f)),"mentor"===a&&n.mentorMenteeSubscription===l.Restricted?[...c,new i("subscriptionLimit",s.formFields.pairLimit),...b]:[...c,...b]}export{y as a,k as b,L as g}