Liferay.Loader.define("@liferay/analytics-settings-web@5.0.51/js/components/connect/Connect",["module","exports","require","@frontend-taglib-clay$clayui/alert","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/form","@frontend-taglib-clay$clayui/icon","@frontend-taglib-clay$clayui/modal","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$react","../../App","../../utils/api","../BasePage","../Loading","./DisconnectModal"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=_interopRequireDefault(a("@frontend-taglib-clay$clayui/alert")),l=_interopRequireDefault(a("@frontend-taglib-clay$clayui/button")),r=_interopRequireWildcard(a("@frontend-taglib-clay$clayui/form")),i=_interopRequireDefault(a("@frontend-taglib-clay$clayui/icon")),u=a("@frontend-taglib-clay$clayui/modal"),c=_interopRequireDefault(a("liferay!frontend-js-react-web$classnames")),o=_interopRequireWildcard(a("liferay!frontend-js-react-web$react")),d=a("../../App"),f=a("../../utils/api"),s=_interopRequireDefault(a("../BasePage")),y=_interopRequireDefault(a("../Loading")),p=_interopRequireDefault(a("./DisconnectModal"));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}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 a={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in e)if(Object.prototype.hasOwnProperty.call(e,l)){var r=n?Object.getOwnPropertyDescriptor(e,l):null;r&&(r.get||r.set)?Object.defineProperty(a,l,r):a[l]=e[l]}return a.default=e,t&&t.set(e,a),a}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var _default=({onConnect:e,title:t})=>{const{connected:a,liferayAnalyticsURL:g,token:m}=(0,d.useData)(),b=(0,d.useDispatch)(),[L,_]=(0,o.useState)(m),{observer:h,onOpenChange:E,open:k}=(0,u.useModal)(),[q,w]=(0,o.useState)(!1);return(0,o.useEffect)((()=>{_(m)}),[m]),o.default.createElement(s.default,{description:Liferay.Language.get("use-the-token-genereted-in-your-analytics-cloud-to-connect-this-workspace"),title:t},a&&o.default.createElement(n.default,{displayType:"success",title:Liferay.Language.get("connected")}),o.default.createElement(r.default,{onSubmit:e=>e.preventDefault()},o.default.createElement(r.default.Group,null,o.default.createElement("label",{className:(0,c.default)({disabled:a}),htmlFor:"inputToken"},Liferay.Language.get("analytics-cloud-token")),o.default.createElement(r.ClayInput,{disabled:a,id:"inputToken",onChange:({target:{value:e}})=>_(e),placeholder:Liferay.Language.get("paste-token-here"),type:"text",value:L}),o.default.createElement("label",{className:(0,c.default)({disabled:a})},o.default.createElement("small",{className:(0,c.default)({"text-secondary":!a})},Liferay.Language.get("analytics-cloud-token-help")))),o.default.createElement(s.default.Footer,null,a?o.default.createElement(o.default.Fragment,null,o.default.createElement(l.default,{className:"mr-3",displayType:"primary",onClick:()=>window.open(g)},Liferay.Language.get("go-to-workspace"),o.default.createElement(i.default,{className:"ml-2",symbol:"shortcut"})),o.default.createElement(l.default,{displayType:"secondary",onClick:()=>E(!0)},Liferay.Language.get("disconnect"))):o.default.createElement(l.default,{disabled:!L||q,onClick:async()=>{w(!0);const{ok:t}=await(0,f.fetchConnection)(L);w(!1),t&&(b({payload:{connected:!0,token:L},type:d.Events.Connect}),e&&e())}},q&&o.default.createElement(y.default,{inline:!0}),Liferay.Language.get("connect")))),k&&o.default.createElement(p.default,{observer:h,onOpenChange:E}))};t.default=_default}}));
//# sourceMappingURL=Connect.js.map