"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("react/jsx-runtime"),r=require("../../../Menu/Menu.js"),n=require("../../../../constants/appPackages.js"),s=require("../../../TextEndTruncated/TextEndTruncated.js"),o=require("../../../Text/Text.js"),a=require("./VersionSelect.constants.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l,c=i(e);function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function d(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){c.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var p=(l={},c.default(l,n.PACKAGE_LABELS.PROD,"Stable Release"),c.default(l,n.PACKAGE_LABELS.BETA,"Beta"),c.default(l,n.PACKAGE_LABELS.DEV,"Dev"),l),f=function(e){var n=e.pkg,i=e.testId,l=e.onChange,c=p[n.label||""];return t.jsx(r.Menu.Item,{testId:i,onClick:function(){return l(n)},disabled:"failure"===n.status,children:t.jsxs(s.TextEndTruncated,{children:[c&&"".concat(c," "),a.formatVersionText(n.package_code_version||"")," ",t.jsx(o.Text,{color:"T6",size:"inherit",children:n.notes})]})})};exports.MenuItems=function(e){var s=e.packages,o=e.onChange;if(!s||0===s.length)return t.jsx(r.Menu.Item,{disabled:!0,children:"No available versions found"});var i=Object.values(n.PACKAGE_LABELS),l=s.filter((function(e){var t=e.label;return t&&i.includes(t)})).reduce((function(e,t){return d(d({},e),{},c.default({},t.label||"",t))}),{}),u=s.filter((function(e){var t=e.label;return!t||!i.includes(t)}));return t.jsxs(t.Fragment,{children:[Object.keys(l).length>0&&t.jsxs(r.Menu.Group,{label:"Labeled Versions (When selected always shows current Stable Release, Beta or Dev version)",children:[l[n.PACKAGE_LABELS.PROD]&&t.jsx(f,{pkg:l[n.PACKAGE_LABELS.PROD],onChange:o,testId:a.VersionSelectTestIds.StableVersionItemTestId}),l[n.PACKAGE_LABELS.BETA]&&t.jsx(f,{pkg:l[n.PACKAGE_LABELS.BETA],onChange:o,testId:a.VersionSelectTestIds.BetaVersionItemTestId}),l[n.PACKAGE_LABELS.DEV]&&t.jsx(f,{pkg:l[n.PACKAGE_LABELS.DEV],onChange:o,testId:a.VersionSelectTestIds.DevVersionItemTestId})]}),u.length>0&&t.jsx(r.Menu.Group,{label:"Other versions (App will always show selected version until version is deleted)",children:u.map((function(e){return t.jsx(f,{testId:"".concat(a.VersionSelectTestIds.AppVersionItemTestId,"_").concat(e.id),pkg:e,onChange:o},e.id)}))})]})};
//# sourceMappingURL=MenuItems.js.map
