{"version":3,"file":"id.cjs","names":[],"sources":["../src/id.ts"],"sourcesContent":["import { v5, v6 } from \"@langchain/core/utils/uuid\";\n\n// Monotonic timestamp state, mirroring uuid@10's internal v1 clock handling.\n// uuid@11+ dropped the sub-millisecond `nsecs` counter when an explicit\n// `clockseq` is provided, so successive `v6({ clockseq })` calls within the\n// same millisecond produce identical time bits and would only be ordered by\n// `clockseq`. Checkpoint IDs are sorted lexicographically, so we must keep the\n// time component strictly increasing across calls to preserve checkpoint\n// ordering regardless of the `clockseq` value passed in.\nlet lastMsecs = 0;\nlet lastNsecs = 0;\n\nexport function uuid6(clockseq: number): string {\n  let msecs = Date.now();\n  if (msecs <= lastMsecs) {\n    // Clock did not advance; bump the 100ns-resolution counter so the\n    // generated time bits remain strictly monotonic.\n    lastNsecs += 1;\n    if (lastNsecs >= 10000) {\n      lastNsecs = 0;\n      msecs = lastMsecs + 1;\n    }\n  } else {\n    lastNsecs = 0;\n  }\n  lastMsecs = msecs;\n  return v6({ clockseq, msecs, nsecs: lastNsecs });\n}\n\nexport function uuid5(name: string, namespace: string): string {\n  const namespaceBytes = namespace\n    .replace(/-/g, \"\")\n    .match(/.{2}/g)!\n    .map((byte) => parseInt(byte, 16));\n  return v5(name, new Uint8Array(namespaceBytes));\n}\n"],"mappings":";;AASA,IAAI,YAAY;AAChB,IAAI,YAAY;AAEhB,SAAgB,MAAM,UAA0B;CAC9C,IAAI,QAAQ,KAAK,KAAK;AACtB,KAAI,SAAS,WAAW;AAGtB,eAAa;AACb,MAAI,aAAa,KAAO;AACtB,eAAY;AACZ,WAAQ,YAAY;;OAGtB,aAAY;AAEd,aAAY;AACZ,SAAA,GAAA,2BAAA,IAAU;EAAE;EAAU;EAAO,OAAO;EAAW,CAAC;;AAGlD,SAAgB,MAAM,MAAc,WAA2B;CAC7D,MAAM,iBAAiB,UACpB,QAAQ,MAAM,GAAG,CACjB,MAAM,QAAQ,CACd,KAAK,SAAS,SAAS,MAAM,GAAG,CAAC;AACpC,SAAA,GAAA,2BAAA,IAAU,MAAM,IAAI,WAAW,eAAe,CAAC"}