Liferay.Loader.define("portal-workflow-kaleo-designer-web@5.0.115/designer/js/definition-builder/diagram-builder/components/sidebar/sections/timers/CurrentTimers",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/layout","@frontend-taglib-clay$clayui/link","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../../../../util/utils","../../../../DiagramBuilderContext"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=r("@frontend-taglib-clay$clayui/button"),n=_interopRequireDefault(r("@frontend-taglib-clay$clayui/layout")),o=_interopRequireDefault(r("@frontend-taglib-clay$clayui/link")),i=(_interopRequireDefault(r("liferay!frontend-js-react-web$prop-types")),function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var r={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var o=a?Object.getOwnPropertyDescriptor(e,n):null;o&&(o.get||o.set)?Object.defineProperty(r,n,o):r[n]=e[n]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react"))),c=r("../../../../../util/utils"),l=r("../../../../DiagramBuilderContext");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var _default=({setContentName:e,taskTimers:t})=>{const{setSelectedItem:r}=(0,i.useContext)(l.DiagramBuilderContext),[u,d]=(0,i.useState)([]);(0,i.useEffect)((()=>{const e=[];t.delay.forEach(((t,r)=>{e.push({duration:t.duration[0],durationScale:t.scale[0],identifier:"".concat(Date.now(),"-").concat(r),recurrence:t.duration[1],recurrenceScale:t.scale[1]})})),d(e)}),[]);const getTimersDetails=(e,t)=>"".concat((0,c.titleCase)(t),": ").concat(e[t]," ").concat(e[t+"Scale"]);return u.map(((t,c)=>i.default.createElement(n.default.ContentCol,{className:"current-node-data-area mb-3",float:!0,key:t.identifier},i.default.createElement(n.default.Row,{className:"current-node-data-row",justify:"between"},i.default.createElement(o.default,{button:!1,className:"truncate-container",displayType:"secondary",href:"#",onClick:()=>e("timers")},i.default.createElement("span",{key:c},getTimersDetails(t,"duration")),t.recurrence&&i.default.createElement("span",{key:c},i.default.createElement("br",null),getTimersDetails(t,"recurrence"))),i.default.createElement(a.ClayButtonWithIcon,{className:"delete-button text-secondary trash-button",displayType:"unstyled",onClick:()=>{return e=t.identifier,a=c,r((e=>{var t,r;if(1===(null===(t=e.data.taskTimers)||void 0===t||null===(r=t.delay)||void 0===r?void 0:r.length))return _objectSpread(_objectSpread({},e),{},{data:_objectSpread(_objectSpread({},e.data),{},{taskTimers:null})});const n={};for(const t of Object.entries(e.data.taskTimers))n[t[0]]=t[1].filter(((e,t)=>t!==a));return _objectSpread(_objectSpread({},e),{},{data:_objectSpread(_objectSpread({},e.data),{},{taskTimers:n})})})),void d((t=>t.filter((({identifier:t})=>t!==e))));var e,a},symbol:"trash"})))))};t.default=_default}}));
//# sourceMappingURL=CurrentTimers.js.map