/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import r from"../../../request.js";import s from"../../../core/Error.js";import{parseUrl as o,asValidOptions as e,encode as t}from"../../utils.js";import{addServerVersion as i}from"./serverVersionUtils.js";import n from"./support/RestoreRowsResult.js";const m=new Map;async function w(w,p,f,a){m.has(w)||await i(m,w);const u=m.get(w);if((u?.serverVersion??0)<=11.1)throw new s("restoreRows:enterprise-version","versioning API requires ArcGIS Enterprise version 11.2 or higher");if(!p)throw new s("restoreRows:missing-guid","guid for version is missing");const c=o(w),g=f.toJSON();f.rows&&(g.rows=JSON.stringify(f.rows));const h=e(c.query,{query:t({...g,f:"json"}),...a,method:"post"});p.startsWith("{")&&(p=p.slice(1,-1));const v=`${c.path}/versions/${p}/restoreRows`,{data:j}=await r(v,h);return n.fromJSON(j)}export{w as restoreRows,m as serverVersionCacheMap};
