function e({apps:e,connectors:t}){let r=new Map(e.map(e=>[e.id,e])),a=new Map;e.forEach(e=>{let t=i(e.name);a.set(t,[...a.get(t)??[],e])});let o=[],s=new Set;for(let e of t){let t=(e.codexAppId==null?void 0:r.get(e.codexAppId))??[...a.get(i(e.name))??[]].sort(n)[0];t==null||s.has(t.id)||(s.add(t.id),o.push(t))}return o}function t({apps:e,plugins:t}){let n=new Set;return e.flatMap(e=>{let r=a(e,t);return r==null||n.has(r.plugin.id)?[]:(n.add(r.plugin.id),[{app:e,plugin:o(e,r)}])})}function n(e,t){return r(t)-r(e)}function r(e){return e.logoUrl!=null||e.logoUrlDark!=null?1:0}function i(e){return e.trim().toLowerCase()}function a(e,t){let n=new Set([e.name,...e.pluginDisplayNames].map(s));return t.find(e=>[e.plugin.name,e.displayName??``,e.plugin.interface?.displayName??``].some(e=>n.has(s(e))))??null}function o(e,t){return{...t,plugin:{...t.plugin,installed:e.isAccessible,enabled:e.isEnabled}}}function s(e){return e.trim().toLowerCase().replaceAll(/[^a-z0-9]+/g,``)}export{t as n,e as t};
//# sourceMappingURL=imported-connector-apps-DyHYf8Rw.js.map