var K=y;y.flatten=y;y.unflatten=A;function p(e){return e&&e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function h(e){return e}function y(e,r){r=r||{};const j=r.delimiter||".",u=r.maxDepth,a=r.transformKey||h,b={};function m(f,O,s){s=s||1,Object.keys(f).forEach(function(n){const t=f[n],c=r.safe&&Array.isArray(t),o=Object.prototype.toString.call(t),i=p(t),d=o==="[object Object]"||o==="[object Array]",l=O?O+j+a(n):a(n);if(!c&&!i&&d&&Object.keys(t).length&&(!r.maxDepth||s<u))return m(t,l,s+1);b[l]=t})}return m(e),b}function A(e,r){r=r||{};const j=r.delimiter||".",u=r.overwrite||!1,a=r.transformKey||h,b={};if(p(e)||Object.prototype.toString.call(e)!=="[object Object]")return e;function f(n){const t=Number(n);return isNaN(t)||n.indexOf(".")!==-1||r.object?n:t}function O(n,t,c){return Object.keys(c).reduce(function(o,i){return o[n+j+i]=c[i],o},t)}function s(n){const t=Object.prototype.toString.call(n),c=t==="[object Array]",o=t==="[object Object]";if(n){if(c)return!n.length;if(o)return!Object.keys(n).length}else return!0}return e=Object.keys(e).reduce(function(n,t){const c=Object.prototype.toString.call(e[t]);return!(c==="[object Object]"||c==="[object Array]")||s(e[t])?(n[t]=e[t],n):O(t,n,y(e[t],r))},{}),Object.keys(e).forEach(function(n){const t=n.split(j).map(a);let c=f(t.shift()),o=f(t[0]),i=b;for(;o!==void 0;){if(c==="__proto__")return;const d=Object.prototype.toString.call(i[c]),l=d==="[object Object]"||d==="[object Array]";if(!u&&!l&&typeof i[c]!="undefined")return;(u&&!l||!u&&i[c]==null)&&(i[c]=typeof o=="number"&&!r.object?[]:{}),i=i[c],t.length>0&&(c=f(t.shift()),o=f(t[0]))}i[c]=A(e[n],r)}),b}var x=K;export{x as f};
