import{g as t}from"./p-8fd375f7.js";import{N as i}from"./p-cc3f853d.js";import{T as e}from"./p-b7a1e5c3.js";import{M as s}from"./p-0b1ac773.js";import{V as r}from"./p-ad6da9fe.js";import{F as o}from"./p-4a8ff3c9.js";import{T as a}from"./p-9224a4e9.js";import{A as n}from"./p-b897fb97.js";import{c as m,f as l}from"./p-2cf91d8b.js";import{a as f,s as p,b as c}from"./p-924483bf.js";import{c as b}from"./p-99ec0044.js";import{a as u}from"./p-65434c2b.js";import{N as d}from"./p-6cf8ecf7.js";import"./p-e476a838.js";import"./p-944da115.js";import"./p-d343a062.js";import{m as j}from"./p-d4bb09bf.js";import{g as h}from"./p-6fb74cfc.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}=h();this.api=m(j,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(u.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,s,r,m,l){var f;if(!e)return null;const p="tr"===i?w:N,{role:c}=t,u=L(p,c,e),d=(null===(f=null==s?void 0:s.dvnAppViewConfig)||void 0===f?void 0:f.ui.fields)||b(u),j="mentor"===c?e.metadatas.mentorsCanEditMetadata:e.metadatas.menteesCanEditMetadata;return o.decode({_id:"update-membership-info-page",base:"mentornity",title:"My info",table:a.decode({name:"mentees",fields:u}),type:n.FormView,handler:new v(r,j?m:void 0,l),ui:{fields:d,i18n:p.formView}})}function L(o,a,n){const m="mentor"===a?n.profileFieldVisibilities.mentor:n.profileFieldVisibilities.mentee,b=[new e("firstName",o.formFields.firstName).addInterceptor("onSubmit",new r(2,32)).addInterceptor("onSubmit",new s).require(),new e("lastName",o.formFields.lastName).addInterceptor("onSubmit",new r(2,32)).addInterceptor("onSubmit",new s).require(),...[new e("title",o.formFields.title).addInterceptor("onSubmit",new s),new e("bio",o.formFields.bio).setLines(3).setLinesMax(10),t({id:"skills",title:o.formFields.skills,type:"multiple-choice",inputType:"select",options:p.map((t=>({label:c[t],value:t})))})].filter((t=>m[t.id]))];let u=[];return("mentor"===a?n.metadatas.mentorsCanEditMetadata:n.metadatas.menteesCanEditMetadata)&&(u=(("mentor"===a?n.metadatas.mentor:n.metadatas.mentee)||[]).map(f)),"mentor"===a&&n.mentorMenteeSubscription===l.Restricted?[...b,new i("subscriptionLimit",o.formFields.pairLimit),...u]:[...b,...u]}export{y as a,k as b,L as g}