/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import t from"../../request.js";import{parseUrl as s,asValidOptions as r,encode as e}from"../utils.js";import o from"./support/TraceResult.js";async function n(o,n,a){const i=s(o),u=n.toJSON();u.traceLocations=JSON.stringify(n.traceLocations),n.resultTypes&&(u.resultTypes=JSON.stringify(n.resultTypes)),n.moment||"SDE.DEFAULT"!==n.gdbVersion?.toUpperCase()&&n.gdbVersion||(u.moment=Date.now());const y=r(i.query,{query:e({...u,f:"json"}),...a}),p=`${i.path}/trace`;return t(p,y).then(t=>c(t))}async function a(o,n,a){const c=s(o),i=n.toJSON();i.traceLocations=JSON.stringify(n.traceLocations),n.resultTypes&&(i.resultTypes=JSON.stringify(n.resultTypes));const u=r(c.query,{query:e({...i,async:!0,f:"json"}),...a}),y=`${c.path}/trace`,{data:p}=await t(y,u);return p.statusUrl}function c(t){const{data:s}=t;return o.fromJSON(s.traceResults)}export{a as submitTraceJob,n as trace};
