!function(){"use strict";var t={n:function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,{a:n}),n},d:function(e,n){for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}},e=window.wp.blocks,n=window.wp.element,r=window.wp.apiFetch,a=t.n(r),l=window.wp.blockEditor,o=window.wp.i18n,i=window.wp.components;function u(t,e){if(t){if("string"==typeof t)return c(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(t,e):void 0}}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}(0,e.registerBlockType)("asl/asl-battle",{apiVersion:2,title:"WP Battle",category:"text",icon:"format-chat",attributes:{battleId:{type:"string"}},edit:function(t){var e,r,c=t.attributes,s=t.setAttributes,f=c.battleId,d=(e=(0,n.useState)(null),r=2,function(t){if(Array.isArray(t))return t}(e)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,a,l=[],_n=!0,o=!1;try{for(n=n.call(t);!(_n=(r=n.next()).done)&&(l.push(r.value),!e||l.length!==e);_n=!0);}catch(t){o=!0,a=t}finally{try{_n||null==n.return||n.return()}finally{if(o)throw a}}return l}}(e,r)||u(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),b=d[0],y=d[1],p=[{label:(0,o.__)("No Battles found. Please add a battle first","asl-battles")}];if((0,n.useEffect)((function(){a()({path:"/asl-battle/v1/battles"}).then((function(t){0!==t.length?s({battleId:t[0].id}):s({battleId:void 0}),y(t)}))}),[]),b){p=[];var v,h=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=u(t))){n&&(t=n);var r=0,a=function(){};return{s:a,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,o=!0,i=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){i=!0,l=t},f:function(){try{o||null==n.return||n.return()}finally{if(i)throw l}}}}(b);try{for(h.s();!(v=h.n()).done;){var w=v.value;p.push({label:w.title,value:w.id})}}catch(t){h.e(t)}finally{h.f()}0===b.length&&p.push({label:(0,o.__)("No Battles found. Please add a battle first","asl-battles")})}var m=(0,l.useBlockProps)({className:"asl-battle-block"});return React.createElement("div",m,React.createElement(i.Card,null,React.createElement(i.CardHeader,{isShady:!0,size:"large"},React.createElement(i.FlexBlock,null,React.createElement(i.SelectControl,{label:(0,o.__)("Select a battle","asl-battles"),value:f,options:p,onChange:function(t){return s({battleId:t})}})))))}})}();