"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/classCallCheck"),t=require("@babel/runtime/helpers/createClass"),r=require("@babel/runtime/helpers/possibleConstructorReturn"),n=require("@babel/runtime/helpers/getPrototypeOf"),o=require("@babel/runtime/helpers/inherits"),a=require("@babel/runtime/helpers/defineProperty"),i=require("react"),l=require("@babel/runtime/helpers/taggedTemplateLiteral"),u=require("@babel/runtime/helpers/slicedToArray"),c=require("@prom-ui/core/Button"),s=require("@prom-ui/core/BodyProvider"),d=require("@prom-ui/icons/Reload"),f=require("@prom-ui/icons/Close");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function h(e){if(e&&"object"==typeof e&&"default"in e)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var m,b,E,_=p(e),v=p(t),y=p(r),q=p(n),g=p(o),C=p(a),w=h(i),x=p(l),O=p(u),R=function(e,t,r){console.error(e,t,r)},N="EI1z9",j="E5oQs",k="RhcQc",B="mrpfL",P=function(e){var t=e.name,r=e.onClose,n=e.onReload,o=w.useState(!1),a=O.default(o,2),i=a[0],l=a[1],u=s.useBodyStoreTTag().t;return"production"!==process.env.NODE_ENV?w.createElement("div",{className:N,"data-qaid":"error_catch","data-testid":"error_catch","data-pds-color-scheme":"light"},w.createElement("div",{className:j,"data-qaid":"error_catch_text","data-testid":"error_catch_text"},u(m||(m=x.default(["Ошибка:"]))),!!t&&w.createElement(w.Fragment,null," ",w.createElement("span",{className:k,"data-qaid":"error_catch_component_name","data-testid":"error_catch_component_name"},t))),n&&w.createElement(c.Button,{"button-theme":"white-inherit","button-padding":"xxs",type:"button",className:B,onClick:function(){l(!0),setTimeout((function(){l(!1),n&&n()}),500)},title:u(b||(b=x.default(["Обновить"]))),loading:i,"data-qaid":"error_catch_button_reload","data-testid":"error_catch_button_reload"},w.createElement(d.SvgReload,{width:18,height:18})),r&&w.createElement(c.Button,{"button-theme":"white-inherit","button-padding":"xxs",type:"button",disabled:i,className:B,onClick:r,title:u(E||(E=x.default(["Скрыть"]))),"data-qaid":"error_catch_button_close","data-testid":"error_catch_button_close"},w.createElement(f.SvgClose,{width:18,height:18}))):null};function S(e,t,r){return t=q.default(t),y.default(e,T()?Reflect.construct(t,r||[],q.default(e).constructor):t.apply(e,r))}function T(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(T=function(){return!!e})()}P.displayName="ErrorView";var V=function(e){function t(e){var r;return _.default(this,t),r=S(this,t,[e]),C.default(r,"onClose",(function(){r.setState({isHidden:!0})})),C.default(r,"onReload",(function(){r.setState({isError:!1})})),r.state={isError:!1,isHidden:!1},r}return g.default(t,e),v.default(t,[{key:"componentDidCatch",value:function(e,t){var r=this.props.name;R("".concat(r,": Failed to render component"),e,t)}},{key:"render",value:function(){var e=this.props,t=e.name,r=e.errorView,n=e.children,o=this.state,a=o.isError;return o.isHidden?null:a?"undefined"==typeof window?null:r&&w.isValidElement(r)?w.cloneElement(r,{name:t,onReload:this.onReload,onClose:this.onClose}):null:n}}],[{key:"getDerivedStateFromError",value:function(){return{isError:!0}}}])}(w.Component);C.default(V,"defaultProps",{errorView:w.createElement(P,null)});exports.ErrorCatch=V,exports.setErrorCatchLog=function(e){R=e},exports.withErrorCatch=function(e,t){var r=function(r){return w.createElement(V,t,w.createElement(e,r))};return r.displayName="WithErrorCatch",r},require("./style.production.v2.css");
