"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/asyncToGenerator"),r=require("@babel/runtime/regenerator");require("../../DevCenter/DevCenterRouterContext/DevCenterRouterContext.js");var t=require("../../DevCenter/DevCenterRouterContext/UniversalLink/UniversalLink.js");require("react"),require("@babel/runtime/helpers/defineProperty"),require("@babel/runtime/helpers/objectWithoutProperties"),require("react-router-dom"),require("query-string");var n=require("react/jsx-runtime"),i=require("../constants.js"),u=require("../style.css.js"),a=require("../../UserCardPopover.js"),s=require("../../../clients/jsonApi/index.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c,l=o(e),p=o(r),d=function(e){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")},f=function(e){var r=d(e),t=e[e.indexOf(i.PLACEHOLDERS.display)+i.PLACEHOLDERS.display.length],n=e[e.indexOf(i.PLACEHOLDERS.display)+i.PLACEHOLDERS.display.length];return new RegExp(r.replace(i.PLACEHOLDERS.display,"([^".concat(d(t||""),"]+?)")).replace(i.PLACEHOLDERS.id,"([^".concat(d(n||""),"]+?)")),"g")},v=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}}))},h=(c=l.default(p.default.mark((function e(r,t,n){var i,u;return p.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r){e.next=2;break}return e.abrupt("return",t([]));case 2:return e.prev=2,e.next=5,s.getUserAutocomplete(null,r,n);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",t([]));case 13:return u=v(i),e.abrupt("return",t(u));case 15:case"end":return e.stop()}}),e,null,[[2,8]])}))),function(e,r,t){return c.apply(this,arguments)});exports.formatMentionText=function(e,r,u){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"#039be5",o=arguments.length>4?arguments[4]:void 0;if(!e)return e;var c=f(i.USER_MARKUP),l=e.split(c),p=3,d=l.reduce((function(e,i,c){var d=e;if(c%p-1==0){var f="@".concat(l[c+1]),v=r&&r.length&&r.find((function(e){return e.id===Number(i)})),h=v&&!u?n.jsx(a,{user:v,wrapperStyle:{display:"inline-block",color:s},currentUser:o,children:f},"userCard-".concat(c)):n.jsx(t.UniversalLink,{href:"/config/users/".concat(i),children:f},"userLink-".concat(c));d.push(h)}return c%p==0&&d.push(i),d}),[]);return d},exports.handleFetchUsers=h,exports.isSuggestionsListOpened=function(){return document.getElementsByClassName(u.mention__suggestions__list).length>0};
//# sourceMappingURL=index.js.map
