import{L as P,bc as F,c4 as L,az as N,aj as k,ao as e,aF as b,e3 as q,ck as T,aq as E,m as d,v as R,f as x,e as f}from"./app-k0jcl5PQ.js";import{F as w}from"./DzRq1F5-.chunk.js";import{F as h}from"./DV1GpLCe.chunk.js";import{F as y}from"./C3DvQ1wU.chunk.js";import{L as v}from"./uC6ielRn.chunk.js";import{l as c}from"./DLmnDxSd.chunk.js";import"./Di9d6zcy.chunk.js";import"./CKctgafI.chunk.js";import"./CW7x8M-z.chunk.js";const I="settings.createLtiPlatform",l=P.encloseNamespace(I),A=c.object().shape({name:c.string().max(255,()=>l("nameExceeds")).required(()=>l("nameRequired")).default("").trim(),version:c.string().required(()=>l("versionRequired")).default("")}),j="settings.createLtiPlatform",t=P.encloseNamespace(j);function U(a){const o=q();return e.jsxs(T,{children:[e.jsx(h,{label:t("name"),type:"text",name:"name",id:"name",placeholder:t("namePlaceholder"),autoFocus:!0,showRequiredStar:!0}),e.jsxs(h,{as:"select",label:t("version"),id:"version",name:"version",showRequiredStar:!0,className:o.values.version?"":"text-secondary",children:[e.jsx("option",{className:"text-secondary",value:"",children:t("selectVersion")}),e.jsx("option",{className:"text-dark",value:"1.3",children:t("version1.3")}),e.jsx("option",{className:"text-dark",value:"1.1",children:t("version1.1")})]}),e.jsxs("div",{className:"btn-container d-flex justify-content-end align-items-center border-top pt-3 px-3 mx-n3",children:[e.jsx("button",{type:"button",className:"btn btn-link me-2",onClick:a.onClickCancel,children:e.jsx(E,{namespace:j,phrase:"cancel"})}),e.jsx(w,{isNew:!0,variant:"dark"})]})]})}function H(a){const o=F(),m=L(),u=N(k.currentUser());function g(s){const{name:r,version:n}=s;switch(n){case"1.1":return C(r);case"1.3":return S(r);default:return i()}}function p(s){o.success(t("success")),a.closePopup(),R.trigger(s)}function i(){o.error("error"),a.closePopup()}function C(s){const r=v.createConsumer({name:s,installedByUserId:u.data.id},n=>p({application:f.SETTINGS,action:x.Settings.EDIT_LTI_CONSUMER,args:[n.key]}),i);d(m,r)}function S(s){const r=v.createPlatform({name:s,initialCreation:!0},n=>p({application:f.SETTINGS,action:x.Settings.EDIT_LTI_PLATFORM,args:[n.id]}),i);d(m,r)}return e.jsx(b,{title:t("title"),closePopup:a.closePopup,showLoadingSpinner:!u.data,children:e.jsx(y,{initialValues:{version:null,name:""},onSubmit:g,validationSchema:A,children:e.jsx(U,{onClickCancel:a.closePopup})})})}export{H as CreateLtiPlatformView};
//# sourceMappingURL=BNLbtDyL.chunk.js.map
