import{j as a,Y as I,h as d,i as r,R as b,dj as A,a as S,o as l,S as u,F as T}from"./app-BgLa5dit.js";import{W as g}from"./B3eOBVf8.chunk.js";import{W as m}from"./DJ0pq8J_.chunk.js";import{W as R,a as f}from"./MEkA24R1.chunk.js";function p(t){function i(){if(t.isEditing)return{application:r.DASHBOARD_EDITOR,action:d.DashboardEditor.EDIT_DASHBOARD,args:[t.dashboardId]};switch(t.currentStep){case"select-widget":return{application:r.DASHBOARD_EDITOR,action:d.DashboardEditor.EDIT_DASHBOARD,args:[t.dashboardId]};case"select-template":return{application:r.DASHBOARD_EDITOR,action:d.DashboardEditor.WIZARD_SELECT_WIDGET,args:[t.dashboardId]};case"add-content":return{application:r.DASHBOARD_EDITOR,action:d.DashboardEditor.WIZARD_SELECT_TEMPLATE,args:[t.dashboardId,t.widgetTypeId]}}}return a.jsx(I,{className:"btn btn-link me-2",appLink:i(),children:t.currentStep==="select-widget"?"Cancel":"Back"})}function x(t){const{disableNext:i,onClickConfirm:e,showSpinner:s}=b.useContext(R);function n(){return!!(i||t.currentStep==="select-widget"&&!t.widgetTypeId||t.currentStep==="select-template"&&!t.templateId)}function c(){return n()?null:t.currentStep==="select-widget"?{application:r.DASHBOARD_EDITOR,action:d.DashboardEditor.WIZARD_SELECT_TEMPLATE,args:[t.dashboardId,t.widgetTypeId]}:{application:r.DASHBOARD_EDITOR,action:d.DashboardEditor.WIZARD_ADD_CONTENT,args:[t.dashboardId,t.widgetTypeId,t.templateId]}}return t.currentStep==="add-content"?a.jsx(A,{variant:"dark",onClick:e,disabled:n(),showSpinner:s,children:t.isEditing?a.jsx(a.Fragment,{children:"Save changes"}):a.jsx(a.Fragment,{children:"Create widget"})}):a.jsx(I,{className:`btn btn-dark ${n()?"disabled":""}`,appLink:c(),disabled:n(),children:"Next"})}function _(t){var D,E;const i=S.getDashboardTargetInfo(t),e=S.isClassificationDashboard(i),s=l(e&&u.classification(i.classificationId)),n=l(((D=s.data)==null?void 0:D.presentationId)&&u.presentation(s.data.presentationId)),c=l(((E=s.data)==null?void 0:E.id)&&u.classificationsPath(s.data.id));if(!e||!n.data||!t)return;const o=[{name:n.data.name,appLink:{application:r.SUBJECTS,action:d.Subjects.EDIT_PRESENTATION,args:[n.data.id]}}];return Array.isArray(c.data)&&(c.data.forEach(h=>{o.push({name:h.name,appLink:{application:r.SUBJECTS,action:d.Subjects.EDIT_CLASSIFICATION_DASHBOARDS,args:[n.data.id,h.id]}})}),o.push({name:"Edit Content",appLink:{application:r.DASHBOARD_EDITOR,action:d.DashboardEditor.EDIT_DASHBOARD,args:[t.id]}})),o}const L="dashboardEditor.dashboardWizardLayout";function O(t,i,e){return[{id:"select-widget",text:"Select a widget",appLink:!e&&{application:r.DASHBOARD_EDITOR,action:d.DashboardEditor.WIZARD_SELECT_WIDGET,args:[t]},disabled:e},{id:"select-template",text:"Select a template",appLink:!!(i&&!e)&&{application:r.DASHBOARD_EDITOR,action:d.DashboardEditor.WIZARD_SELECT_TEMPLATE,args:[t,i]},disabled:!i||e},{id:"add-content",text:e?"Edit content":"Add content"}]}function k(t){var e,s,n;const i=_(t.dashboard);return a.jsx(f,{children:a.jsxs("div",{className:"px-3 container pt-3",children:[a.jsx(g,{currentStep:t.currentStep,breadcrumbs:i,title:T.getPhrase(L,t.isEditing?"editHeader":"createHeader"),continueButton:a.jsx(x,{currentStep:t.currentStep,dashboardId:(e=t.dashboard)==null?void 0:e.id,widgetTypeId:t.widgetTypeId,templateId:t.templateId,isEditing:t.isEditing}),backButton:a.jsx(p,{currentStep:t.currentStep,dashboardId:(s=t.dashboard)==null?void 0:s.id,widgetTypeId:t.widgetTypeId,isEditing:t.isEditing}),loaded:!0}),a.jsxs("div",{className:"row g-0",children:[a.jsx("div",{className:"col-2",children:a.jsx(m,{currentStep:t.currentStep,steps:O((n=t.dashboard)==null?void 0:n.id,t.widgetTypeId,t.isEditing)})}),a.jsx("div",{className:"col-10",children:t.children})]})]})})}export{k as D};
//# sourceMappingURL=CeYzlQh9.chunk.js.map
