Liferay.Loader.define("adaptive-media-web@5.0.41/adaptive_media/js/AdaptiveMediaProgress",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/icon","@frontend-taglib-clay$clayui/progress-bar","@liferay/frontend-js-react-web","frontend-js-web","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","./utils/entryIcons"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=u(a("@frontend-taglib-clay$clayui/button")),r=u(a("@frontend-taglib-clay$clayui/icon")),l=u(a("@frontend-taglib-clay$clayui/progress-bar")),o=a("@liferay/frontend-js-react-web"),c=a("frontend-js-web"),i=(u(a("liferay!frontend-js-react-web$prop-types")),function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=d();if(t&&t.has(e))return t.get(e);var a={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var l=n?Object.getOwnPropertyDescriptor(e,r):null;l&&(l.get||l.set)?Object.defineProperty(a,r,l):a[r]=e[r]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react"))),s=a("./utils/entryIcons");function d(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return d=function(){return e},e}function u(e){return e&&e.__esModule?e:{default:e}}var f=({adaptedImages:e,adaptiveMediaProgressComponentId:t,autoStartProgress:a=!1,disabled:d=!1,intervalSpeed:u=1e3,namespace:f,percentageUrl:g,tooltip:y,totalImages:p,uuid:m})=>{const b=(0,o.useTimeout)(),v=(0,o.useIsMounted)(),[j,E]=(0,i.useState)(a),[w,I]=(0,i.useState)(Math.ceil(e/p*100)||0),[L,M]=(0,i.useState)(e+"/"+p),[O,P]=(0,i.useState)(0),$=(0,i.useCallback)((()=>{(0,c.fetch)(g).then((e=>e.json())).then((({adaptedImages:e,errors:t,totalImages:a})=>{v()&&(P(t),I(Math.ceil(e/a*100)||0),M(y||e+"/"+a)),e+t===a?(v()&&E(!1),(0,s.enableEntryIcon)(document.getElementById("".concat(f,"icon-disable-").concat(m)))):b($,u)}))}),[b,u,v,f,g,y,m]),h=(0,i.useCallback)((e=>((0,c.fetch)(e),v()&&E(!0),(0,s.disableEntryIcon)(document.getElementById("".concat(f,"icon-adapt-remaining").concat(m))),(0,s.disableEntryIcon)(document.getElementById("".concat(f,"icon-disable-").concat(m))),b($,u))),[b,u,v,f,$,m]);return(0,i.useEffect)((()=>{a&&$()}),[a,$]),Liferay.component(t)||Liferay.component(t,{startProgress:h},{destroyOnNavigate:!0}),O>0?i.default.createElement("div",{className:"progress-error-container"},i.default.createElement("span",{className:"text-danger"},i.default.createElement(r.default,{symbol:"exclamation-full"}),i.default.createElement("span",null,i.default.createElement("strong",null,Liferay.Language.get("error"),": "),1===O?Liferay.Language.get("1-image-failed-process"):(0,c.sub)(Liferay.Language.get("x-images-failed-process"),O))),i.default.createElement(n.default,{borderless:!0,className:"text-danger",onClick:()=>{P(0),h()},small:!0},Liferay.Language.get("retry"))):i.default.createElement(i.default.Fragment,null,i.default.createElement("div",{className:"progress-container ".concat(d?"disabled":""),"data-percentage":w,"data-title":L},i.default.createElement(l.default,{value:w})),i.default.createElement("span",{className:"".concat(j?"":"hide ","loading-animation loading-animation-sm")}))};t.default=f}}));
//# sourceMappingURL=AdaptiveMediaProgress.js.map