"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkMKBKT4DIjs = require('./chunk-MKBKT4DI.js');var _chunkNQ46PE7Hjs = require('./chunk-NQ46PE7H.js');var _chunkB5ZUUBXUjs = require('./chunk-B5ZUUBXU.js');var _icons = require('@baseapp-frontend/design-system/components/web/icons');var _inputs = require('@baseapp-frontend/design-system/components/web/inputs');var _utils = require('@baseapp-frontend/utils');var _zod = require('@hookform/resolvers/zod');var _lab = require('@mui/lab');var _material = require('@mui/material');var _reacthookform = require('react-hook-form');var _reactrelay = require('react-relay');var _slugify = require('slugify'); var _slugify2 = _interopRequireDefault(_slugify);var _jsxruntime = require('react/jsx-runtime');function $(e,o){return E(e)||V(e,o)||U(e,o)||R()}function R(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function U(e,o){if(e){if(typeof e=="string")return L(e,o);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?L(e,o):void 0}}function L(e,o){(o==null||o>e.length)&&(o=e.length);for(var r=0,i=Array(o);r<o;r++)i[r]=e[r];return i}function V(e,o){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var i,d,c,s,m=[],a=!0,f=!1;try{if(c=(r=r.call(e)).next,o===0){if(Object(r)!==r)return;a=!1}else for(;!(a=(i=c.call(r)).done)&&(m.push(i.value),m.length!==o);a=!0);}catch(u){f=!0,d=u}finally{try{if(!a&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(f)throw d}}return m}}function E(e){if(Array.isArray(e))return e}var D=0,ne=function(o){var r=o.addNewProfileLabel,i=r===void 0?"New organization":r,d=o.termsAndConditionsUrl,c=d===void 0?"":d,s=o.addNewProfileDescription,m=s===void 0?"Create an organization and invite multiple members to manage and collaborate.":s,a=o.submitLabel,f=a===void 0?"Create Organization":a,u=o.onClose,O=o.open,_=o.setOpen,M=o.userId,t=_reacthookform.useForm.call(void 0, {mode:"onChange",defaultValues:{name:"",urlPath:""},resolver:_zod.zodResolver.call(void 0, _chunkNQ46PE7Hjs.a)}),T=_chunkB5ZUUBXUjs.b.call(void 0, ),C=$(T,2),N=C[0],g=C[1],h=function(){_(!1),t.reset(),_optionalChain([u, 'optionalCall', _2 => _2()])},k=function(P){if(!g){D+=1;var B=D.toString(),F=_reactrelay.ConnectionHandler.getConnectionID(M,"ProfilesListFragment_profiles");N({variables:{input:{name:P.name,urlPath:P.urlPath,clientMutationId:B},connections:[F]},onCompleted:function(b,z){var y;if(z){console.error(z);return}var p=b==null||(y=b.organizationCreate)===null||y===void 0?void 0:y.errors;_utils.setFormRelayErrors.call(void 0, t,p),p!=null&&p.length||h()},onError:console.error})}};return _jsxruntime.jsxs.call(void 0, _material.Dialog,{open:O,onClose:h,"aria-labelledby":"organization-modal-title","aria-describedby":"organization-modal-description",PaperProps:{sx:{borderRadius:{xs:0,sm:2},minWidth:{xs:"100%",sm:0},margin:{xs:0,sm:2},maxWidth:{sm:366},height:{xs:"100%",sm:"auto"},minHeight:{xs:"100%",sm:"auto"}}},children:[_jsxruntime.jsx.call(void 0, _material.DialogTitle,{id:"organization-modal-title",children:_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{display:"flex",alignItems:"center",gap:2,justifyContent:"space-between"},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"h6",children:i}),_jsxruntime.jsx.call(void 0, _material.IconButton,{onClick:h,children:_jsxruntime.jsx.call(void 0, _icons.CloseIcon,{})})]})}),_jsxruntime.jsxs.call(void 0, _chunkMKBKT4DIjs.a,{onSubmit:t.handleSubmit(k),children:[_jsxruntime.jsxs.call(void 0, _material.DialogContent,{sx:{display:"flex",flexDirection:"column",gap:4},id:"organization-modal-description",children:[_jsxruntime.jsx.call(void 0, _material.Typography,{color:"text.secondary",children:m}),_jsxruntime.jsxs.call(void 0, _material.Box,{display:"flex",flexDirection:"column",gap:2,children:[_jsxruntime.jsx.call(void 0, _inputs.TextField,{label:"Name",name:"name",size:"medium",control:t.control,onBlur:function(){t.getValues("urlPath")||(t.setValue("urlPath",_slugify2.default.call(void 0, t.getValues("name").toLocaleLowerCase())),t.trigger("urlPath"))}}),_jsxruntime.jsx.call(void 0, _inputs.TextField,{label:"URL Path",name:"urlPath",size:"medium",control:t.control}),_jsxruntime.jsxs.call(void 0, _material.Typography,{color:"text.primary",children:["Upon confirming, you agree to our"," ",_jsxruntime.jsx.call(void 0, _material.Link,{display:"inline",href:c,target:"_blank",children:"Terms and Conditions."})]})]})]}),_jsxruntime.jsxs.call(void 0, _material.DialogActions,{sx:{justifyContent:"flex-end"},children:[_jsxruntime.jsx.call(void 0, _material.Button,{variant:"outlined",color:"inherit",onClick:h,sx:{width:"auto"},children:"Cancel"}),_jsxruntime.jsx.call(void 0, _lab.LoadingButton,{variant:"contained",color:"inherit",sx:{width:"auto"},type:"submit",loading:g,disabled:g||Object.keys(t.formState.errors).length>0||!t.formState.isValid,children:f})]})]})]})},ve= exports.a =ne;exports.a = ve;
//# sourceMappingURL=chunk-T2LKK6A4.js.map