import e from"@babel/runtime/helpers/asyncToGenerator";import r from"@babel/runtime/regenerator";import"../../DevCenter/DevCenterRouterContext/DevCenterRouterContext.js";import{UniversalLink as t}from"../../DevCenter/DevCenterRouterContext/UniversalLink/UniversalLink.js";import"react";import"@babel/runtime/helpers/defineProperty";import"@babel/runtime/helpers/objectWithoutProperties";import"react-router";import{jsx as n}from"react/jsx-runtime";import{PLACEHOLDERS as o,USER_MARKUP as i}from"../constants.js";import a from"../style.css.js";import s from"../../UserCardPopover.js";import{getUserAutocomplete as c}from"../../../clients/jsonApi/index.js";var u,p=function(e){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")},l=function(e){var r=p(e),t=e[e.indexOf(o.display)+o.display.length],n=e[e.indexOf(o.display)+o.display.length];return new RegExp(r.replace(o.display,"([^".concat(p(t||""),"]+?)")).replace(o.id,"([^".concat(p(n||""),"]+?)")),"g")},m=function(e,r,o){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"#039be5",c=arguments.length>4?arguments[4]:void 0;if(!e)return e;var u=l(i),p=e.split(u),m=3,f=p.reduce((function(e,i,u){var l=e;if(u%m-1==0){var f="@".concat(p[u+1]),d=r&&r.length&&r.find((function(e){return e.id===Number(i)})),h=d&&!o?n(s,{user:d,wrapperStyle:{display:"inline-block",color:a},currentUser:c,children:f},"userCard-".concat(u)):n(t,{href:"/config/users/".concat(i),children:f},"userLink-".concat(u));l.push(h)}return u%m==0&&l.push(i),l}),[]);return f},f=function(e){return e.data.map((function(e){return{id:e.id,display:"".concat(e.first_name," ").concat(e.last_name),photo:e.profile_photo,title:e.title}}))},d=(u=e(r.mark((function e(t,n,o){var i,a;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=2;break}return e.abrupt("return",n([]));case 2:return e.prev=2,e.next=5,c(null,t,o);case 5:i=e.sent,e.next=11;break;case 8:e.prev=8,e.t0=e.catch(2),console.error(e.t0);case 11:if(i&&0!==i.data.length){e.next=13;break}return e.abrupt("return",n([]));case 13:return a=f(i),e.abrupt("return",n(a));case 15:case"end":return e.stop()}}),e,null,[[2,8]])}))),function(e,r,t){return u.apply(this,arguments)}),h=function(){return document.getElementsByClassName(a.mention__suggestions__list).length>0};export{m as formatMentionText,d as handleFetchUsers,h as isSuggestionsListOpened};
