/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../Accessor","../Collection","../maybe","./utils"],(function(e,t,n,o,i){"use strict";const r=["esri.Color","esri.portal.Portal","esri.symbols.support.Symbol3DAnchorPosition2D","esri.symbols.support.Symbol3DAnchorPosition3D"];function f(e){return e instanceof t}function s(e){return e instanceof n?Object.keys(e.items):f(e)?i.getProperties(e).keys():e?Object.keys(e):[]}function c(e,t){return e instanceof n?e.items[t]:e[t]}function l(e,t){return!(!Array.isArray(e)||!Array.isArray(t))&&e.length!==t.length}function u(e){return e?e.declaredClass:null}function a(e,t){const n=e.diff;if(n&&"function"==typeof n)return n(e,t);const i=s(e),p=s(t);if(0===i.length&&0===p.length)return;if(!i.length||!p.length||l(e,t))return{type:"complete",oldValue:e,newValue:t};const y=p.filter((e=>!i.includes(e))),d=i.filter((e=>!p.includes(e))),m=i.filter((n=>p.includes(n)&&c(e,n)!==c(t,n))).concat(y,d).sort(),b=u(e);if(b&&r.includes(b)&&m.length)return{type:"complete",oldValue:e,newValue:t};let g;const h=f(e)&&f(t);for(const r of m){const i=c(e,r),f=c(t,r);let s;if((h||"function"!=typeof i&&"function"!=typeof f)&&(i!==f&&(null!=i||null!=f))){if(n&&n[r]&&"function"==typeof n[r])s=n[r](i,f);else if(i instanceof Date&&f instanceof Date){if(i.getTime()===f.getTime())continue;s={type:"complete",oldValue:i,newValue:f}}else s="object"==typeof i&&"object"==typeof f&&u(i)===u(f)?a(i,f):{type:"complete",oldValue:i,newValue:f};o.isSome(s)&&(o.isSome(g)?g.diff[r]=s:g={type:"partial",diff:{[r]:s}})}}return g}function p(e,t){if(o.isNone(e))return!1;const n=t.split(".");let i=e;for(const o of n){if("complete"===i.type)return!0;if("partial"!==i.type)return!1;{const e=i.diff[o];if(!e)return!1;i=e}}return!0}function y(e,t){for(const n of t)if(p(e,n))return!0;return!1}function d(e,t){if(!("function"==typeof e||"function"==typeof t||o.isNone(e)&&o.isNone(t)))return o.isNone(e)||o.isNone(t)||"object"==typeof e&&"object"==typeof t&&u(e)!==u(t)?{type:"complete",oldValue:e,newValue:t}:a(e,t)}function m(e){if(o.isNone(e))return!0;switch(e.type){case"complete":return!1;case"collection":{const t=e;for(const e of t.added)if(!m(e))return!1;for(const e of t.removed)if(!m(e))return!1;for(const e of t.changed)if(!m(e))return!1;return!0}case"partial":for(const t in e.diff){if(!m(e.diff[t]))return!1}return!0}}e.diff=d,e.hasDiff=p,e.hasDiffAny=y,e.isEmpty=m,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
