/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import a from"./UBPCOTIY.js";import{ua as i}from"./ACTJS4TX.js";export default $arcgis.t(([{a:p}])=>{async function D(o,a){let r=await v(a,o),I=[],m=[],d=[],f=r.map(async e=>{let c=await h(e.id,"reverse","Solution2Item",o);return{template:e,relatedItems:c}}),u=await Promise.all(f);for(let{template:e,relatedItems:c}of u)for(let w of c){let s=[];for(let t of w.relatedItemIds)s.push({controlItemId:e.id,dependencyItemId:t});let S=s.reduce((t,n)=>(t[n.controlItemId]||(t[n.controlItemId]=new Set),t[n.controlItemId].add(n.dependencyItemId),t),{}),l=Object.entries(S).filter(([t,n])=>n.size>1).flatMap(([t,n])=>Array.from(n).map(g=>({controlItemId:t,dependencyItemId:g})));l.length>0&&(d=d.concat(l))}m=Array.from(new Map([...d].map(e=>[`${e.controlItemId}:${e.dependencyItemId}`,e])).values());let y=m.map(e=>e.controlItemId);return I=[...new Set(y)],{uniqueIitemIds:I,_nonSolutionDependencyItems:m,templateInfos:r}}async function h(o,a,r,I){let m=await i(o,r,a,I);return[{relationshipType:r,relatedItemIds:m.relatedItems.map(d=>d.id)}]}async function v(o,a){return await p(o.id,a)}return{a:D,b:v}},a)