{"version":3,"file":"merge-refs.mjs","sources":["../../../../../src/components/Reorder/utils/merge-refs.ts"],"sourcesContent":["import type { Ref } from \"react\"\n\n/**\n * A callback ref that sets our own `ref` and an external one, a callback\n * ref or ref object. A callback ref's cleanup is called instead of the ref\n * with null, so it's returned wrapped to clear our own ref too.\n */\nexport const mergeRefs =\n    <T>(ref: { current: T | null }, externalRef?: Ref<T>) =>\n    (value: T | null) => {\n        ref.current = value\n        const cleanup =\n            typeof externalRef === \"function\"\n                ? externalRef(value)\n                : externalRef &&\n                  ((externalRef as { current: T | null }).current = value)\n\n        if (typeof cleanup === \"function\") {\n            return () => {\n                ref.current = null\n                cleanup()\n            }\n        }\n    }\n"],"names":[],"mappings":"AAEA;;;;AAIG;AACI,MAAM,SAAS,GAClB,CAAI,GAA0B,EAAE,WAAoB,KACpD,CAAC,KAAe,KAAI;AAChB,IAAA,GAAG,CAAC,OAAO,GAAG,KAAK;AACnB,IAAA,MAAM,OAAO,GACT,OAAO,WAAW,KAAK;AACnB,UAAE,WAAW,CAAC,KAAK;AACnB,UAAE,WAAW;AACX,aAAE,WAAqC,CAAC,OAAO,GAAG,KAAK,CAAC;AAElE,IAAA,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;AAC/B,QAAA,OAAO,MAAK;AACR,YAAA,GAAG,CAAC,OAAO,GAAG,IAAI;AAClB,YAAA,OAAO,EAAE;AACb,QAAA,CAAC;IACL;AACJ;;;;"}