/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../core/Logger","../Entity","../GraphObject","../ObjectValue","../Path","../Relationship","./KnowledgeWasmInterface","./WasmQueryWrapperInterfaces","./wasmToGeometryFactories"],(function(e,t,n,r,o,s,a,u,p,c){"use strict";const y=t.getLogger("esri.rest.knowledgeGraph.WasmToQueryResponseObjConstructors");function l(e){const t=[],n=e.count();for(let r=0;r<n;r++){const n=e.get_value_at(r);t.push(i(n))}return t}function i(e){if(!e)return null;if("object"!=typeof e)return e;if("getDate"in e)return e;if("geometry_type"in e)switch(e.geometry_type.value){case null:return null;case u.WasmGeometryTypeCodes.ESRI_GEOMETRY_POINT:return c.wasmToPointGeometry(e);case u.WasmGeometryTypeCodes.ESRI_GEOMETRY_MULTIPOINT:return c.wasmToMultipointGeometry(e);case u.WasmGeometryTypeCodes.ESRI_GEOMETRY_POLYLINE:return c.wasmToPolylineGeometry(e);case u.WasmGeometryTypeCodes.ESRI_GEOMETRY_POLYGON:return c.wasmToPolygonGeometry(e);case u.WasmGeometryTypeCodes.ESRI_GEOMETRY_ENVELOPE:case u.WasmGeometryTypeCodes.ESRI_GEOMETRY_MULTI_PATCH:return y.warnOnce("Envelope and Multipatch are not supported on knowledge entities, but one of those geometry types was detected.  Result interpreted as null"),null;case u.WasmGeometryTypeCodes.ESRI_GEOMETRY_NULL:case u.WasmGeometryTypeCodes.ESRI_GEOMETRY_ANY:default:return y.warnOnce("Unknown or blank geometry type returned - Result interpreted as null"),null}else{if(!("object_value_type"in e))return y.warnOnce("A decoded value came back of a type that is not supported.  Result interpreted as null"),null;switch(e.object_value_type.value){case p.WasmGraphQueryResponseTypeCodes.OBJECT:return _(e);case p.WasmGraphQueryResponseTypeCodes.ENTITY:return m(e);case p.WasmGraphQueryResponseTypeCodes.RELATIONSHIP:return R(e);case p.WasmGraphQueryResponseTypeCodes.PATH:return E(e);case p.WasmGraphQueryResponseTypeCodes.ARRAY:return l(e);default:return y.warnOnce("Unknown graph object type detected!  Result interpreted as null"),null}}}function m(e){const t=e.type_name;return new n(Object.assign({typeName:t},d(e)))}function T(e){return new r(d(e))}function d(e){const t={},n=e.key_count();for(let r=0;r<n;r++)t[e.get_key_at(r)]=i(e.get_value_at(r));return{properties:t}}function _(e){return new o(d(e))}function E(e){const t=e.entity_count(),n=e.relationship_count(),r=[];for(let o=0;o<t;o++)r.push(m(e.get_entity_at(o))),o<n&&r.push(R(e.get_relationship_at(o)));return new s({path:r})}function R(e){const t=e.type_name;return new a(Object.assign({typeName:t},d(e)))}e.decodedWasmObjToQueryResponseObj=i,e.wasmArrayToArray=l,e.wasmToEntity=m,e.wasmToGraphObject=T,e.wasmToObjectValue=_,e.wasmToPath=E,e.wasmToRelationship=R,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
