"use strict";Liferay.Loader.define("@liferay!analytics-settings-web$testing-library/dom@8.20.0/dist/wait-for",["module","exports","require","./helpers","./config"],(function(e,r,t){window;{var a=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e};Object.defineProperty(r,"__esModule",{value:!0}),r.waitFor=function waitForWrapper(e,r){const t=new Error("STACK_TRACE_MESSAGE");return(0,i.getConfig)().asyncWrapper((()=>function waitFor(e,{container:r=(0,n.getDocument)(),timeout:t=(0,i.getConfig)().asyncUtilTimeout,showOriginalStackTrace:a=(0,i.getConfig)().showOriginalStackTrace,stackTraceError:o,interval:s=50,onTimeout:c=(e=>(e.message=(0,i.getConfig)().getElementError(e.message,r).message,e)),mutationObserverOptions:l={subtree:!0,childList:!0,attributes:!0,characterData:!0}}){if("function"!=typeof e)throw new TypeError("Received `callback` arg must be a function");return new Promise((async(u,g)=>{let m,f,d,h=!1,b="idle";const y=setTimeout(handleTimeout,t),k=(0,n.jestFakeTimersAreEnabled)();if(k){const{unstable_advanceTimersWrapper:e}=(0,i.getConfig)();for(checkCallback();!h;){if(!(0,n.jestFakeTimersAreEnabled)()){const e=new Error("Changed from using fake timers to real timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to real timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830");return a||copyStackTrace(e,o),void g(e)}if(e((()=>{jest.advanceTimersByTime(s)})),checkCallback(),h)break;await e((async()=>{await new Promise((e=>{setTimeout(e,0),jest.advanceTimersByTime(0)}))}))}}else{try{(0,n.checkContainerType)(r)}catch(e){return void g(e)}f=setInterval(checkRealTimersCallback,s);const{MutationObserver:e}=(0,n.getWindowFromNode)(r);d=new e(checkRealTimersCallback),d.observe(r,l),checkCallback()}function onDone(e,r){h=!0,clearTimeout(y),k||(clearInterval(f),d.disconnect()),e?g(e):u(r)}function checkRealTimersCallback(){if((0,n.jestFakeTimersAreEnabled)()){const e=new Error("Changed from using real timers to fake timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to fake timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830");return a||copyStackTrace(e,o),g(e)}return checkCallback()}function checkCallback(){if("pending"!==b)try{const r=(0,i.runWithExpensiveErrorDiagnosticsDisabled)(e);"function"==typeof(null==r?void 0:r.then)?(b="pending",r.then((e=>{b="resolved",onDone(null,e)}),(e=>{b="rejected",m=e}))):onDone(null,r)}catch(e){m=e}}function handleTimeout(){let e;m?(e=m,a||"TestingLibraryElementError"!==e.name||copyStackTrace(e,o)):(e=new Error("Timed out in waitFor."),a||copyStackTrace(e,o)),onDone(c(e),null)}}))}(e,a({stackTraceError:t},r))))};var n=t("./helpers"),i=t("./config");function copyStackTrace(e,r){e.stack=r.stack.replace(r.message,e.message)}}}));
//# sourceMappingURL=wait-for.js.map