"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../../utils/common.js"),e=require("../../utils/clone.js"),n=require("../../utils/amap-helpers.js");function r(t){return t&&"function"==typeof t.then}function i(e){if(!e)return e;if(r(e))return e;if(e.$amapContext&&e.$amapContext.ready)return e.$amapContext.ready;if(Array.isArray(e))return Promise.all(e.map(i));if(t.isPlainObject(e)){const t={},o=Object.keys(e),a=[];function n(e,n){t[n]=void 0,a.push(e.then(e=>{t[n]=e}))}for(let u=0;u<o.length;u++){const s=o[u],f=i(e[s]);f&&r(a)?n(f,s):t[s]=e[s]}return Promise.all(a).then((function(){return t}))}return e}exports.defineDeferredMethod=function(t){return async function(...e){const r=this.$amapContext;await r.ready;const o=n.getBindTarget(r);if(!o)return this.$amapLogger.warn(`calling ${t} on ${o}`);if("function"!=typeof o[t])return this.$amapLogger.warn(t+" is not a function.");const a=e.map(i),u=await Promise.all(a);return r.destroyed?void 0:o[t](...u)}},exports.defineMethod=function(t,r){return function(...i){const o=n.getBindTarget(this.$amapContext);return o?"function"!=typeof o[t]?this.$amapLogger.warn(t+" is not a function."):(r&&(i=e.default(i)),o[t](...i)):this.$amapLogger.warn(`calling ${t} on ${o}`)}};
