"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/asyncToGenerator"),t=require("@babel/runtime/helpers/slicedToArray"),r=require("@babel/runtime/regenerator"),n=require("prop-types"),u=require("react"),a=require("./FeedItemEditModal.js");require("../../../utils/index.js");var s=require("../../../clients/jsonApi/index.js"),i=require("react/jsx-runtime"),c=require("../../../utils/notificationToasts.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=d(e),o=d(t),f=d(r),p=d(n),x=u.createContext(),m=function(e){var t,r=e.children,n=e.tracesMinDateSec,d=e.tracesMaxDateSec,p=e.tracesAssetId,m=e.exitFunc,v=u.useState(null),b=o.default(v,2),S=b[0],q=b[1],y=function(){m(),q(null)},I=(t=l.default(f.default.mark((function e(t){return f.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,s.patchFeedItem(S.id,{context:t});case 3:e.next=9;break;case 5:return e.prev=5,e.t0=e.catch(0),console.error(e.t0),e.abrupt("return");case 9:y(),c.showSuccessNotification("Successfully updated");case 11:case"end":return e.stop()}}),e,null,[[0,5]])}))),function(e){return t.apply(this,arguments)});return i.jsxs(x.Provider,{value:{editedFeedItem:S,setEditedFeedItem:q},children:[S&&i.jsx(a,{feedItem:S,onClose:y,onSave:function(e){var t=e.context;I(t)},tracesMinDateSec:n,tracesMaxDateSec:d,tracesAssetId:p}),r]})};m.propTypes={children:p.default.node.isRequired,tracesMinDateSec:p.default.oneOfType([p.default.string,p.default.number]),tracesMaxDateSec:p.default.oneOfType([p.default.string,p.default.number]),tracesAssetId:p.default.oneOfType([p.default.string,p.default.number]),exitFunc:p.default.func},m.defaultProps={tracesMinDateSec:null,tracesMaxDateSec:null,tracesAssetId:null,exitFunc:function(){return null}},exports.FeedItemEditProvider=m,exports.useFeedItemEditProvider=function(){return u.useContext(x)};
