Liferay.Loader.define("@liferay/analytics-settings-web@5.0.42/js/components/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","../pages/wizard/WizardPage","../utils/api","./BasePage","./DisconnectModal","./LoadingInline"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=L(a("@frontend-taglib-clay$clayui/alert")),l=L(a("@frontend-taglib-clay$clayui/button")),r=b(a("@frontend-taglib-clay$clayui/form")),o=L(a("@frontend-taglib-clay$clayui/icon")),c=a("@frontend-taglib-clay$clayui/modal"),u=L(a("liferay!frontend-js-react-web$classnames")),i=b(a("liferay!frontend-js-react-web$react")),d=a("../App"),f=a("../pages/wizard/WizardPage"),s=a("../utils/api"),y=L(a("./BasePage")),g=L(a("./DisconnectModal")),p=L(a("./LoadingInline"));function m(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return m=function(){return e},e}function b(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=m();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 L(e){return e&&e.__esModule?e:{default:e}}var w=({onChangeStep:e,title:t})=>{const[{connected:a,liferayAnalyticsURL:m,token:b},L]=(0,i.useContext)(d.AppContext),[w,E]=(0,i.useState)(b),{observer:v,onOpenChange:k,open:$}=(0,c.useModal)(),[h,j]=(0,i.useState)(!1);return i.default.createElement(y.default,{description:Liferay.Language.get("use-the-token-genereted-in-your-analytics-cloud-to-connect-this-workspace"),title:t},a&&i.default.createElement(n.default,{displayType:"success",title:Liferay.Language.get("connected")}),i.default.createElement(r.default,{onSubmit:t=>{t.preventDefault(),(async()=>{j(!0);const t=await(0,s.fetchConnection)(w);j(!1),(null==t?void 0:t.ok)?(L({payload:{connected:!0,token:w},type:d.Events.Connected}),e&&e(f.ESteps.Property)):Liferay.Util.openToast({message:Liferay.Language.get("an-unexpected-system-error-occurred"),type:"danger"})})()}},i.default.createElement(r.default.Group,null,i.default.createElement("label",{className:(0,u.default)({disabled:a}),htmlFor:"inputToken"},Liferay.Language.get("analytics-cloud-token")),i.default.createElement(r.ClayInput,{disabled:a,id:"inputToken",onChange:({target:{value:e}})=>E(e),type:"text",value:w}),i.default.createElement("label",{className:(0,u.default)({disabled:a})},i.default.createElement("small",{className:(0,u.default)({"text-secondary":!a})},Liferay.Language.get("analytics-cloud-token-help")))),i.default.createElement(y.default.Footer,null,a?i.default.createElement(i.default.Fragment,null,i.default.createElement(l.default,{className:"mr-3",displayType:"secondary",onClick:()=>window.open(m)},Liferay.Language.get("go-to-workspace"),i.default.createElement(o.default,{className:"ml-2",symbol:"shortcut"})),i.default.createElement(l.default,{displayType:"secondary",onClick:()=>k(!0)},Liferay.Language.get("disconnect"))):i.default.createElement(l.default,{disabled:!w||h,type:"submit"},h&&i.default.createElement(p.default,null),Liferay.Language.get("connect")))),$&&i.default.createElement(g.default,{observer:v,onOpenChange:k}))};t.default=w}}));
//# sourceMappingURL=Connect.js.map