import valueToKey from"./valueToKey.js";const extractKey=(keyPath,value)=>{if(Array.isArray(keyPath)){const result=[];for(let item of keyPath)null!=item&&"string"!=typeof item&&item.toString&&(item=item.toString()),result.push(valueToKey(extractKey(item,value)));return result}if(""===keyPath)return value;let remainingKeyPath=keyPath,object=value;for(;null!==remainingKeyPath;){let identifier;const i=remainingKeyPath.indexOf(".");if(i>=0?(identifier=remainingKeyPath.slice(0,i),remainingKeyPath=remainingKeyPath.slice(i+1)):(identifier=remainingKeyPath,remainingKeyPath=null),null==object||!Object.hasOwn(object,identifier))return;object=object[identifier]}return object};export default extractKey;