{"ast":null,"code":"\"use client\";\n\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport * as React from 'react';\nimport usePatchElement from '../../_util/hooks/usePatchElement';\nimport { withConfirm, withError, withInfo, withSuccess, withWarn } from '../confirm';\nimport destroyFns from '../destroyFns';\nimport HookModal from './HookModal';\nlet uuid = 0;\nconst ElementsHolder = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef((_props, ref) => {\n const [elements, patchElement] = usePatchElement();\n React.useImperativeHandle(ref, () => ({\n patchElement\n }), []);\n // eslint-disable-next-line react/jsx-no-useless-fragment\n return /*#__PURE__*/React.createElement(React.Fragment, null, elements);\n}));\nfunction useModal() {\n const holderRef = React.useRef(null);\n // ========================== Effect ==========================\n const [actionQueue, setActionQueue] = React.useState([]);\n React.useEffect(() => {\n if (actionQueue.length) {\n const cloneQueue = _toConsumableArray(actionQueue);\n cloneQueue.forEach(action => {\n action();\n });\n setActionQueue([]);\n }\n }, [actionQueue]);\n // =========================== Hook ===========================\n const getConfirmFunc = React.useCallback(withFunc => function hookConfirm(config) {\n var _a;\n uuid += 1;\n const modalRef = /*#__PURE__*/React.createRef();\n // Proxy to promise with `onClose`\n let resolvePromise;\n const promise = new Promise(resolve => {\n resolvePromise = resolve;\n });\n let silent = false;\n let closeFunc;\n const modal = /*#__PURE__*/React.createElement(HookModal, {\n key: `modal-${uuid}`,\n config: withFunc(config),\n ref: modalRef,\n afterClose: () => {\n closeFunc === null || closeFunc === void 0 ? void 0 : closeFunc();\n },\n isSilent: () => silent,\n onConfirm: confirmed => {\n resolvePromise(confirmed);\n }\n });\n closeFunc = (_a = holderRef.current) === null || _a === void 0 ? void 0 : _a.patchElement(modal);\n if (closeFunc) {\n destroyFns.push(closeFunc);\n }\n const instance = {\n destroy: () => {\n function destroyAction() {\n var _a;\n (_a = modalRef.current) === null || _a === void 0 ? void 0 : _a.destroy();\n }\n if (modalRef.current) {\n destroyAction();\n } else {\n setActionQueue(prev => [].concat(_toConsumableArray(prev), [destroyAction]));\n }\n },\n update: newConfig => {\n function updateAction() {\n var _a;\n (_a = modalRef.current) === null || _a === void 0 ? void 0 : _a.update(newConfig);\n }\n if (modalRef.current) {\n updateAction();\n } else {\n setActionQueue(prev => [].concat(_toConsumableArray(prev), [updateAction]));\n }\n },\n then: resolve => {\n silent = true;\n return promise.then(resolve);\n }\n };\n return instance;\n }, []);\n const fns = React.useMemo(() => ({\n info: getConfirmFunc(withInfo),\n success: getConfirmFunc(withSuccess),\n error: getConfirmFunc(withError),\n warning: getConfirmFunc(withWarn),\n confirm: getConfirmFunc(withConfirm)\n }), []);\n return [fns, /*#__PURE__*/React.createElement(ElementsHolder, {\n key: \"modal-holder\",\n ref: holderRef\n })];\n}\nexport default useModal;","map":{"version":3,"names":["_toConsumableArray","React","usePatchElement","withConfirm","withError","withInfo","withSuccess","withWarn","destroyFns","HookModal","uuid","ElementsHolder","memo","forwardRef","_props","ref","elements","patchElement","useImperativeHandle","createElement","Fragment","useModal","holderRef","useRef","actionQueue","setActionQueue","useState","useEffect","length","cloneQueue","forEach","action","getConfirmFunc","useCallback","withFunc","hookConfirm","config","_a","modalRef","createRef","resolvePromise","promise","Promise","resolve","silent","closeFunc","modal","key","afterClose","isSilent","onConfirm","confirmed","current","push","instance","destroy","destroyAction","prev","concat","update","newConfig","updateAction","then","fns","useMemo","info","success","error","warning","confirm"],"sources":["C:/Users/Аришина)/source/repos/PromoCursed/node_modules/antd/es/modal/useModal/index.js"],"sourcesContent":["\"use client\";\n\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport * as React from 'react';\nimport usePatchElement from '../../_util/hooks/usePatchElement';\nimport { withConfirm, withError, withInfo, withSuccess, withWarn } from '../confirm';\nimport destroyFns from '../destroyFns';\nimport HookModal from './HookModal';\nlet uuid = 0;\nconst ElementsHolder = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef((_props, ref) => {\n const [elements, patchElement] = usePatchElement();\n React.useImperativeHandle(ref, () => ({\n patchElement\n }), []);\n // eslint-disable-next-line react/jsx-no-useless-fragment\n return /*#__PURE__*/React.createElement(React.Fragment, null, elements);\n}));\nfunction useModal() {\n const holderRef = React.useRef(null);\n // ========================== Effect ==========================\n const [actionQueue, setActionQueue] = React.useState([]);\n React.useEffect(() => {\n if (actionQueue.length) {\n const cloneQueue = _toConsumableArray(actionQueue);\n cloneQueue.forEach(action => {\n action();\n });\n setActionQueue([]);\n }\n }, [actionQueue]);\n // =========================== Hook ===========================\n const getConfirmFunc = React.useCallback(withFunc => function hookConfirm(config) {\n var _a;\n uuid += 1;\n const modalRef = /*#__PURE__*/React.createRef();\n // Proxy to promise with `onClose`\n let resolvePromise;\n const promise = new Promise(resolve => {\n resolvePromise = resolve;\n });\n let silent = false;\n let closeFunc;\n const modal = /*#__PURE__*/React.createElement(HookModal, {\n key: `modal-${uuid}`,\n config: withFunc(config),\n ref: modalRef,\n afterClose: () => {\n closeFunc === null || closeFunc === void 0 ? void 0 : closeFunc();\n },\n isSilent: () => silent,\n onConfirm: confirmed => {\n resolvePromise(confirmed);\n }\n });\n closeFunc = (_a = holderRef.current) === null || _a === void 0 ? void 0 : _a.patchElement(modal);\n if (closeFunc) {\n destroyFns.push(closeFunc);\n }\n const instance = {\n destroy: () => {\n function destroyAction() {\n var _a;\n (_a = modalRef.current) === null || _a === void 0 ? void 0 : _a.destroy();\n }\n if (modalRef.current) {\n destroyAction();\n } else {\n setActionQueue(prev => [].concat(_toConsumableArray(prev), [destroyAction]));\n }\n },\n update: newConfig => {\n function updateAction() {\n var _a;\n (_a = modalRef.current) === null || _a === void 0 ? void 0 : _a.update(newConfig);\n }\n if (modalRef.current) {\n updateAction();\n } else {\n setActionQueue(prev => [].concat(_toConsumableArray(prev), [updateAction]));\n }\n },\n then: resolve => {\n silent = true;\n return promise.then(resolve);\n }\n };\n return instance;\n }, []);\n const fns = React.useMemo(() => ({\n info: getConfirmFunc(withInfo),\n success: getConfirmFunc(withSuccess),\n error: getConfirmFunc(withError),\n warning: getConfirmFunc(withWarn),\n confirm: getConfirmFunc(withConfirm)\n }), []);\n return [fns, /*#__PURE__*/React.createElement(ElementsHolder, {\n key: \"modal-holder\",\n ref: holderRef\n })];\n}\nexport default useModal;"],"mappings":"AAAA,YAAY;;AAEZ,OAAOA,kBAAkB,MAAM,8CAA8C;AAC7E,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,OAAOC,eAAe,MAAM,mCAAmC;AAC/D,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,QAAQ,QAAQ,YAAY;AACpF,OAAOC,UAAU,MAAM,eAAe;AACtC,OAAOC,SAAS,MAAM,aAAa;AACnC,IAAIC,IAAI,GAAG,CAAC;AACZ,MAAMC,cAAc,GAAG,aAAaV,KAAK,CAACW,IAAI,EAAE,aAAaX,KAAK,CAACY,UAAU,CAAC,CAACC,MAAM,EAAEC,GAAG,KAAK;EAC7F,MAAM,CAACC,QAAQ,EAAEC,YAAY,CAAC,GAAGf,eAAe,CAAC,CAAC;EAClDD,KAAK,CAACiB,mBAAmB,CAACH,GAAG,EAAE,OAAO;IACpCE;EACF,CAAC,CAAC,EAAE,EAAE,CAAC;EACP;EACA,OAAO,aAAahB,KAAK,CAACkB,aAAa,CAAClB,KAAK,CAACmB,QAAQ,EAAE,IAAI,EAAEJ,QAAQ,CAAC;AACzE,CAAC,CAAC,CAAC;AACH,SAASK,QAAQA,CAAA,EAAG;EAClB,MAAMC,SAAS,GAAGrB,KAAK,CAACsB,MAAM,CAAC,IAAI,CAAC;EACpC;EACA,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGxB,KAAK,CAACyB,QAAQ,CAAC,EAAE,CAAC;EACxDzB,KAAK,CAAC0B,SAAS,CAAC,MAAM;IACpB,IAAIH,WAAW,CAACI,MAAM,EAAE;MACtB,MAAMC,UAAU,GAAG7B,kBAAkB,CAACwB,WAAW,CAAC;MAClDK,UAAU,CAACC,OAAO,CAACC,MA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