import{a0 as L,bp as T,bq as k,aX as B}from"./appDialogsManager-DnVhdlim.js";import{s as C}from"./putPreloader-WBjcuDFX.js";import{cY as E,v as A}from"./index-6Jqoo2rk.js";import"./emailSetup-CFcJlzt-.js";import"./iconTsx-Cr8T7ZIv.js";import"./bootstrapIm-BS8HLnlI.js";import"./transition-DuxZkCEv.js";import"./mediaHeader-B5k-4_FU.js";import"./animations-O3syBkMX.js";import"./accumulate-BydAFozl.js";import"./browser-BlRx6CLO.js";import"./_commonjsHelpers-DsqdWQfm.js";import"./htmlToSpan-DhAls8qz.js";import"./anchorCallback-DsA1XczG.js";import"./toast-B3QB1-N7.js";import"./paintQrCode-u2FNs0A8.js";import"./fastBlur-Co-79rP4.js";import"./space-DBcSn32d.js";import"./telInputField-Fj4gE689.js";import"./readBlobAsDataURL-DL2tTmc_.js";import"./tracking-CIK7NCFD.js";import"./getInputPasskeyResponse-RiY9Fe0r.js";import"./base64ToBytes-B7rMxzcy.js";import"./sha256-BMgYLqDy.js";import"./bytesCmp-DgkPox5J.js";const re=()=>{const[t]=L(),{type:u,placeholder:x,takeOut:y,skippable:d,selectedPeerIds:h,selectedExtras:f,extraCategories:m,extraCategoriesSectionLangKey:v}=t.payload;t.container.classList.add("add-members-container");const i=T({icon:"arrow_next"});t.content.append(i),t.scrollable.container.remove(),i.addEventListener("click",()=>{const r=o.getSelected(),n=[],c=new Set;for(const e of r)e.isPeerId()?n.push(e.toPeerId()):c.add(e);const a=y(n,c);d&&!(a instanceof Promise)?t.close():a instanceof Promise?b(a):a===void 0&&t.close()});const s=u==="privacy",o=new k({middleware:t.middlewareHelper.get(),appendTo:t.content,onChange:d?null:r=>{i.classList.toggle("is-visible",!!r)},peerType:[s?"dialogs":"contacts"],placeholder:x,exceptSelf:s,filterPeerTypeBy:s?["isAnyGroup","isUser"]:void 0,managers:t.managers,design:s?"round":"square",checkboxSide:s?"right":"left"});if(m?.length){const r=new Map(m.map(e=>[e.key,e])),n=new B({noDelimiter:!0,name:v});n.container.classList.add("folder-categories");const c=document.createDocumentFragment();for(const e of m){const l=E("btn-primary btn-transparent folder-category-button",{icon:e.icon,text:e.text});l.dataset.peerId=e.key,l.append(o.checkbox()),c.append(l)}n.content.append(c);const a=o.add.bind(o);o.add=({key:e,title:l,scroll:S,fireOnChange:w,fallbackIcon:I})=>{const p=typeof e=="string"?r.get(e):void 0;return a({key:e,title:p?A(p.text):l,scroll:S,fireOnChange:w,fallbackIcon:p?p.icon:I})},o.scrollable.append(n.container,o.scrollable.container.lastElementChild)}const P=h||[],g=[...f?[...f]:[],...P];g.length&&o.addInitial(g),i.disabled=!1,i.classList.toggle("is-visible",d);function b(r){const n=C(i,"arrow_next");r.then(()=>{t.close()},()=>{n()})}return t.payload.attachToPromise=b,[]};export{re as default};
//# sourceMappingURL=addMembers-BKcsqEEN.js.map
