{"size": 6106, "ext": "js", "max_stars_repo_path": "build/index.js", "max_stars_repo_name": "saundefined/test-wp-plugin", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "build/index.js", "max_issues_repo_name": "saundefined/test-wp-plugin", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "build/index.js", "max_forks_repo_name": "saundefined/test-wp-plugin", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 6106.0, "max_line_length": 6106, "alphanum_fraction": 0.7296102195}
!function(t){var e={};function o(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},o.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=9)}([function(t,e){!function(){t.exports=this.wp.element}()},function(t,e){!function(){t.exports=this.wp.components}()},function(t,e){function o(t,e){for(var o=0;o<e.length;o++){var n=e[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}t.exports=function(t,e,n){return e&&o(t.prototype,e),n&&o(t,n),t}},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){t.exports=React},function(t,e,o){var n=o(10);t.exports=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&n(t,e)}},function(t,e){function o(e){return t.exports=o=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},o(e)}t.exports=o},function(t,e,o){var n=o(12),r=o(11);t.exports=function(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?r(t):e}},function(t,e){!function(){t.exports=this.wp.blocks}()},function(t,e,o){"use strict";o.r(e);var n=o(0),r=o(8),c=o(3),u=o.n(c),s=o(2),i=o.n(s),a=o(7),f=o.n(a),l=o(6),p=o.n(l),d=o(5),h=o.n(d),y=o(4),b=o.n(y),g=o(1),m=wp.url.addQueryArgs,v=wp.apiFetch,I=function(){function t(){u()(this,t)}return i()(t,null,[{key:"callMethod",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return v({path:m("/api/"+t,e)}).then(function(t){return t})}},{key:"fetchCategories",value:function(){return this.callMethod("categories")}},{key:"fetchProducts",value:function(t){return this.callMethod("category/"+t)}},{key:"fetchProduct",value:function(t,e){return this.callMethod("category/"+t+"/"+e)}},{key:"sync",value:function(t,e){return this.callMethod("sync/"+t+"/"+e)}}]),t}(),P=function(t){function e(t){var o;return u()(this,e),(o=f()(this,p()(e).call(this,t))).state={categoryId:0,categories:[],productId:0,products:[],isProductsLoaded:!1,isCategoriesLoaded:!1,isButtonBusy:!1,hasError:!1},o}return h()(e,t),i()(e,[{key:"componentDidMount",value:function(){this.fetchCategories(),this.props.categoryId>0&&this.fetchProducts(this.props.categoryId),this.setState({categoryId:this.props.categoryId,productId:this.props.productId})}},{key:"fetchCategories",value:function(){var t=this;this.setState({isCategoriesLoaded:!1},function(){I.fetchCategories().then(function(e){t.setState({categories:e,isCategoriesLoaded:!0,hasError:!1})}).catch(function(){t.setState({hasError:!0})})})}},{key:"fetchProducts",value:function(t){var e=this;this.setState({isProductsLoaded:!1},function(){I.fetchProducts(t).then(function(t){e.setState({products:t,isProductsLoaded:!0,hasError:!1})}).catch(function(){e.setState({hasError:!0})})})}},{key:"sync",value:function(t,e){var o=this;this.setState({isButtonBusy:!0},function(){I.sync(t,e).then(function(){return o.setState({isButtonBusy:!1})})})}},{key:"render",value:function(){var t=this;return Object(n.createElement)("div",null,Object(n.createElement)(g.Placeholder,{icon:"wordpress-alt",label:"Awesome API"},this.state.hasError?Object(n.createElement)("p",null,"При запросе к API произошла ошибка. Проверьте ",Object(n.createElement)("a",{href:"/wp-admin/admin.php?page=api/api.php"},"настройки подключения")):Object(n.createElement)("div",null,this.state.isCategoriesLoaded&&Object(n.createElement)(g.SelectControl,{label:"Выберите категорию",value:this.state.categoryId,options:this.state.categories,onChange:function(e){t.setState({categoryId:e}),t.props.onCategoryChanged(e),e>0&&t.fetchProducts(e)}}),this.state.categoryId>0&&this.state.isProductsLoaded&&Object(n.createElement)(g.SelectControl,{label:"Выберите продукт",value:this.state.productId,options:this.state.products,onChange:function(e){t.setState({productId:e}),t.props.onProductChanged(e)}}),this.state.categoryId>0&&this.state.isCategoriesLoaded&&this.state.productId>0&&this.state.isProductsLoaded&&Object(n.createElement)("div",null,this.state.isButtonBusy?Object(n.createElement)("p",null,"Синхронизируем..."):Object(n.createElement)(g.Button,{onClick:function(){return t.sync(t.state.categoryId,t.state.productId)},isPrimary:!0,isLarge:!0},"Синхронизировать")))))}}]),e}(b.a.PureComponent);Object(r.registerBlockType)("api/fetch-data",{title:"Awesome API",icon:"universal-access-alt",category:"embed",supports:{html:!1},attributes:{categoryId:{type:"number",default:0},productId:{type:"number",default:0}},edit:function(t){var e=t.attributes,o=t.setAttributes;return Object(n.createElement)(P,{categoryId:e.categoryId,productId:e.productId,onCategoryChanged:function(t){return o({categoryId:parseInt(t)})},onProductChanged:function(t){return o({productId:parseInt(t)})}})},save:function(t){t.attributes;return null}})},function(t,e){function o(e,n){return t.exports=o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},o(e,n)}t.exports=o},function(t,e){t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}},function(t,e){function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(e){return"function"==typeof Symbol&&"symbol"===o(Symbol.iterator)?t.exports=n=function(t){return o(t)}:t.exports=n=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":o(t)},n(e)}t.exports=n}]);