var ConstrainObject=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let t=e=>Object.prototype.toString.call(e)===`[object Object]`,n=(e,r=new Map)=>{if(typeof e!=`object`||!e)return e;if(r.has(e))return r.get(e);if(Array.isArray(e)){let t=Array.from({length:e.length});r.set(e,t);for(let i=0;i<e.length;i++)t[i]=n(e[i],r);return t}if(!t(e))return e;let i=Object.create(null);r.set(e,i);for(let t of Object.getOwnPropertyNames(e))i[t]=n(e[t],r);for(let t of Object.getOwnPropertySymbols(e))i[t]=n(e[t],r);return i},r={maxDepth:20,maxNodes:1e4,maxArrayLength:1e3,maxObjectKeys:1e3,maxStringLength:1e4,onCycle:`null`,onLimitExceeded:`truncate`,allowFunctions:!1,allowBigint:!1,allowSymbols:!1,dangerousKeys:[`__proto__`,`constructor`,`prototype`]},i=e=>{let t={...r,...e};if(t.maxDepth<0||t.maxNodes<0||t.maxArrayLength<0||t.maxObjectKeys<0||t.maxStringLength<0||![`null`,`omit`,`throw`,`keep`].includes(t.onCycle)||![`truncate`,`throw`].includes(t.onLimitExceeded)||!Array.isArray(t.dangerousKeys))throw Error(`Invalid options provided to constrainObject`);let n=new Set(t.dangerousKeys);return{...t,dangerousKeys:n}};function a(e,t={}){let r=i(t),a=0;if(e==null||typeof e==`boolean`||typeof e==`number`)return e;let o={root:n(e)},s=[{depth:0,type:typeof e,parent:o,key:`root`}],c=new WeakSet;for(;s.length>0;){let e=s.pop();if(e===void 0)continue;if(e.depth>r.maxDepth){if(r.onLimitExceeded===`throw`)throw Error(`Object exceeded maximum depth`);if(r.onLimitExceeded===`truncate`){delete e.parent[e.key];continue}}if(a>=r.maxNodes){if(r.onLimitExceeded===`throw`)throw Error(`Object exceeded maximum nodes`);if(r.onLimitExceeded===`truncate`){delete e.parent[e.key];continue}}if(e.parent[e.key]===null||e.parent[e.key]===void 0||e.type===`boolean`||e.type===`number`){a++;continue}if(e.type===`string`){if(e.parent[e.key].length>r.maxStringLength){if(r.onLimitExceeded===`throw`)throw Error(`String size exceeded maximum length`);r.onLimitExceeded===`truncate`&&(e.parent[e.key]=e.parent[e.key].slice(0,r.maxStringLength))}a++;continue}if(e.type===`bigint`){if(!r.allowBigint){if(r.onLimitExceeded===`throw`)throw Error(`BigInt is not allowed`);if(r.onLimitExceeded===`truncate`){delete e.parent[e.key];continue}}a++;continue}if(e.type===`function`){if(!r.allowFunctions){if(r.onLimitExceeded===`throw`)throw Error(`Function is not allowed`);if(r.onLimitExceeded===`truncate`){delete e.parent[e.key];continue}}a++;continue}if(e.type===`symbol`){if(!r.allowSymbols){if(r.onLimitExceeded===`throw`)throw Error(`Symbol is not allowed`);if(r.onLimitExceeded===`truncate`){delete e.parent[e.key];continue}}a++;continue}if(e.type!==`object`){delete e.parent[e.key];continue}let t=e.parent[e.key];if(c.has(t)){if(r.onCycle===`null`)e.parent[e.key]=null;else if(r.onCycle===`omit`)delete e.parent[e.key];else if(r.onCycle===`throw`)throw Error(`Cycle in object detected`);else r.onCycle===`keep`&&a++;continue}if(c.add(t),Array.isArray(t)){let n=t.length;if(n>r.maxArrayLength){if(r.onLimitExceeded===`throw`)throw Error(`Array size exceeded maximum length`);r.onLimitExceeded===`truncate`&&(n=r.maxArrayLength,t.length=n)}for(let r=n-1;r>=0;r--)s.push({depth:e.depth+1,type:typeof t[r],parent:t,key:r});a++;continue}let n=[...Object.keys(t),...Object.getOwnPropertySymbols(t)];if(n.length>r.maxObjectKeys){let e=n.slice(r.maxObjectKeys);n=n.slice(0,r.maxObjectKeys);for(let n of e)delete t[n]}for(let i of n){if(typeof i==`string`&&r.dangerousKeys.has(i)){delete t[i];continue}s.push({depth:e.depth+1,type:typeof t[i],parent:t,key:i})}}return o?.root??void 0}return e.constrainObject=a,e})({});