"use strict";var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/asyncToGenerator"),r=require("@babel/runtime/helpers/slicedToArray"),n=require("@babel/runtime/regenerator"),i=require("react"),a=require("prop-types"),o=require("@material-ui/core"),u=require("lodash"),s=require("classnames"),c=require("./UsersChipSelector.js"),l=require("../../../clients/jsonApi/index.js"),p=require("react/jsx-runtime");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=d(e),h=d(t),b=d(r),g=d(n),m=d(a),y=d(s);function j(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 x(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?j(Object(r),!0).forEach((function(t){f.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var v=o.makeStyles({dialog:{width:"600px",height:"600px"},actions:{padding:"8px 40px",boxShadow:"0px -4px 10px rgb(0 0 0 / 25%)"},mobileActions:{paddingRight:"100px"}});function S(e){var t=e.title,r=e.open,n=e.onSave,a=e.onCancel,s=e.currentUser,d=v(),m=!1,j=i.useState([]),S=b.default(j,2),O=S[0],q=S[1],w=i.useState(new Set),P=b.default(w,2),C=P[0],D=P[1];i.useEffect((function(){function e(){return(e=h.default(g.default.mark((function e(){var t,r,n;return g.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t={companyId:u.get(s,["company","id"])},e.next=4,l.getUsers(t);case 4:r=e.sent,n=(r||[]).filter((function(e){return u.get(e,"id")!==u.get(s,"id")})).map((function(e){return x(x({},e),{},{id:u.get(e,"id"),displayName:"".concat(u.get(e,"first_name")," ").concat(u.get(e,"last_name"))})})),q(n),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(0),console.error(e.t0);case 12:case"end":return e.stop()}}),e,null,[[0,9]])})))).apply(this,arguments)}!function(){e.apply(this,arguments)}()}),[]);var U=function(){D(new Set),a()};return p.jsxs(o.Dialog,{open:r,onClose:U,fullScreen:m,classes:{paper:y.default(f.default({},d.dialog,!0))},children:[p.jsx(o.DialogTitle,{children:t||"Share Templates"}),p.jsxs(o.DialogContent,{children:[p.jsx(o.Typography,{variant:"subtitle1",gutterBottom:!0,children:"Share with users"}),p.jsx(c,{users:O,selectedUsers:C,onAddUser:function(e){D((function(t){return new Set(t.add(e))}))},onRemoveUser:function(e){D((function(t){return t.delete(e),new Set(t)}))}})]}),p.jsxs(o.DialogActions,{className:y.default(d.actions,f.default({},d.mobileActions,m)),children:[p.jsx(o.Button,{color:"primary",onClick:U,children:"Cancel"}),p.jsx(o.Button,{variant:"contained",color:"primary",onClick:function(){n(O.filter((function(e){return C.has(u.get(e,"id"))}))),D(new Set)},children:"Save"})]})]})}S.propTypes={title:m.default.string,open:m.default.bool.isRequired,onSave:m.default.func.isRequired,onCancel:m.default.func.isRequired,currentUser:m.default.shape({}).isRequired},S.defaultProps={title:null},module.exports=S;
//# sourceMappingURL=index.js.map
