import{o as e}from"./chunk-jRWAZmH_.js";import{n as t,t as n}from"./jsx-runtime-CEixWuwE.js";import{J as r,ir as i,mr as a,n as o,or as s,pr as c,sr as l}from"./axios-BAZB3l2q.js";import{i as u,t as d}from"./ctiAxios-z6-f5GoX.js";import{H as f}from"./notification-iew2j46e.js";import{t as p}from"./button-BwrlrBF7.js";import{t as m}from"./prop-types-CEsF4M7J.js";import{s as h}from"./sanitizeDataUtils-DWjcSNVm.js";import{t as g}from"./modal-ChM3JDNH.js";import{t as _}from"./input-vY_ggPFq.js";import{t as v}from"./queryOptions-8oqYyfXL.js";import{t as y}from"./RowLabelWithIcon-BiTwQp49.js";import{D as b,O as ee,c as te}from"./index-vzToGWaQ.js";import{t as x}from"./DiscardChangesButton-DYw1PWuZ.js";var S=e(t()),C=e(m()),w=e=>{let t=e.getElementsByTagName(`HTTP_SERVICE`)[0],n=s(t,`INDICATEUR`),r=s(t,`TABLE`),i=s(t,`THEME`),a=s(t,`THEME_SEARCH`);return{indicators:T(n),tables:E(r),themesSearch:ne(a),themes:D(i)}},T=e=>{let t=[];return e&&e.forEach((e,n)=>{let r=l(e),i=s(e,`THEME`),a=[],o=[],c=[];i&&i.forEach(e=>{let t=l(e);a.push(t.oid)});for(let e=1;e<=6;e++)r[`theme_${e}_id`]!==`0`&&o.push(r[`theme_${e}_id`]);for(let e=1;e<=5;e++)r[`dimension_date_${e}`]!==``&&c.push(Number(r[`dimension_date_${e}`]));let u=r.entete,d=r.description;r.entete=u.replaceAll(` `,` `),r.description=d.replaceAll(` `,` `),r.themesSearch=a,r.themes=o,r.dimensions=c,r.is_cti=r.is_cti===`1`,r.is_hide=r.is_hide===`1`,r.key=n,t.push(r)}),t},E=e=>{let t=[];return e&&e.forEach(e=>{let n=l(e),r=[];n.nb_dimensions_date=Number(n.nb_dimensions_date);for(let e=1;e<=5;e++)n[`dimensions_date_texte_${e}`]!==``&&r.push({value:e,label:n[`dimensions_date_texte_${e}`]});n.dimensions=r,t.push(n)}),t},D=e=>{let t=[];return e&&e.forEach((e,n)=>{let r=l(e);r.title=r.label,r.value=r.data,t.push(r)}),h(t)},ne=e=>{let t=[];return e&&e.forEach((e,n)=>{let r=l(e);r.title=r.label,r.value=r.data,t.push(r)}),h(t)},re=e=>{let t=e.getElementsByTagName(`HTTP_SERVICE`)[0],n=s(t,`RAPPORT`),r=s(t,`REFRAPPORT`),i=s(t,`COMBO_GROUP`),o=s(t,`COMBO_RAPPORT`),c=s(t,`COMBO_CONDITION`),l=s(t,`COMBO_TYPERAPPORT`);return{reports:a(n),refReports:a(r),comboGroup:A(i),comboReport:j(o),comboCondition:M(c),conditions:a(s(c[0],`RECORD`)),comboType:A(l)}},ie=e=>{let t=e.getElementsByTagName(`HTTP_SERVICE`)[0],n=s(t,`RAPPORT`)[0],r=s(n,`RUBRIQUE`),i=[];r&&r.length&&r.forEach((e,t)=>{let n=l(e),r=n.entete,a=n.description;n.entete=r.replaceAll(` `,` `),n.description=a.replaceAll(` `,` `),n.border_thickness=Number(n.border_thickness),n.is_hide=Number(n.is_hide),n.key=t,i.push(n)});let a=l(n);return a.sections=i,a},ae=e=>{let t=e.getElementsByTagName(`LASTSTATUS_ACTIVE`)[0];return l(t).status},O=e=>{let t=e.getElementsByTagName(`HTTP_SERVICE`)[0];return a(s(t,`VIEW`))},k=e=>{let t=e.getElementsByTagName(`HTTP_SERVICE`)[0],n=s(t,`INDICATEUR`),r=s(t,`TABLE`),i=s(t,`THEME`);return{tables:E(r),themes:D(i),indicators:T(n)}};function A(e){let t=s(e[0],`RECORD`),n=[];return t&&t.length&&t.forEach(e=>{let t=l(e);t.value=t.data??t.oid,n.push(t)}),n}function j(e){let t=s(e[0],`RECORD`),n=[];return t&&t.length&&t.forEach(e=>{let t=l(e);t.value=t.oid,n.push(t)}),n}function M(e){let t=s(e[0],`RECORD`),n=[];return t&&t.length&&t.forEach(e=>{let t=l(e);t.oid&&(t.value=t.oid,n.push(t))}),n=h(n),n}var N=async e=>re(await u(`modules/base/php/getRapports.php`,{softCode:e})),P=async(e,t)=>ie(await u(`modules/base/php/httpService_rapportsManager_getRapport.php`,{softCode:e,oid:t})),F=async()=>O(await u(`modules/base/php/httpService_rapportsManager_getLastViews.php`));async function I(e,t){await u(`modules/base/php/setRapport.php`,{action:`save`,softCode:e,xmldef:t})}async function L(e,t){await u(`modules/base/php/setRapport.php`,{action:`delete`,softCode:e,xmldef:t})}async function R(e,t){await u(`modules/base/php/setRapport.php`,{action:`copy`,softCode:e,xmldef:t})}async function z(e,t){await u(`modules/base/php/setRapport.php`,{action:`updateGeneralSettings`,softCode:e,xmldef:t})}async function B(e,t){await u(`modules/base/php/setRapport.php`,{action:`refcopy`,softCode:e,refoid:t})}async function V(){return ae(await u(`modules/outils/php/httpService_exploitManager_getExecStatus.php`,{job:`iCTI_aggregateCtiIndicators`}))}async function H(e){await u(`modules/outils/php/execSystemExploit.php`,{option:`calculEssentiels`,context:e})}var oe=async e=>{let t=i(),n=new FormData;n.append(`modules`,e),n.append(`options`,`-separator -fulldefinition`);let r=await d({method:`post`,url:t+`modules/base/php/httpService_chooseIndicateurs_getIndicateurs.php`,data:n,headers:{"Content-Type":`multipart/form-data`},responseType:`arraybuffer`});return k(c(new TextDecoder(`iso-8859-15`).decode(r.data)))},U={all:[`reports`],list:e=>[...U.all,`list`,e],detail:(e,t)=>[...U.all,`detail`,e,t],lastViews:()=>[...U.all,`lastViews`],indicators:e=>[...U.all,`indicators`,e],computingStatus:()=>[...U.all,`computingStatus`]},W={reports:[],refReports:[],comboGroup:[],comboReport:[],comboCondition:[],conditions:[],comboType:[]},G={},K={tables:[],themes:[],indicators:[]},q=e=>v({queryKey:U.list(e),queryFn:()=>N(e),enabled:!!e}),se=e=>o(q(e)),ce=(e,t)=>v({queryKey:U.detail(e,t),queryFn:()=>P(e,t),enabled:!!e&&!!t}),le=(e,t)=>o(ce(e,t)),ue=()=>v({queryKey:U.lastViews(),queryFn:F}),de=()=>o(ue()),fe=e=>v({queryKey:U.indicators(e),queryFn:()=>oe(e),enabled:!!e}),J=e=>o(fe(e));function pe(){return o({queryKey:U.computingStatus(),queryFn:V,refetchInterval:e=>e.state.data?1e4:!1})}var Y=n(),X=({selectedRowKeys:e,setSelectedRowKeys:t,selectionsModified:n,setSelectionsModified:i,handleAddIndicators:a,handleModifyIndicator:o,handleShowModal:s,tableData:c,options:l,joinedIndicatorIndex:u})=>{let d=t=>{if(!n)s();else{let n=[];e.forEach(e=>{n.push(c.find(t=>t.key===e))}),l.oneOnly?o(u?{value:n[0].oid,field:u}:n[0]):a(n),i(!1),t===!0?s():m(n.length)}},f=()=>{e.length?t([]):t(c.map(e=>e.key))};function m(e){r.success(`${e} indicateurs ajoutés`)}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(p,{onClick:s,children:n?`Annuler`:`Fermer`}),l.oneOnly===!1&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(p,{onClick:()=>d(!1),disabled:!n,children:`Ajouter et continuer`}),(0,Y.jsx)(p,{onClick:f,disabled:!n,children:`Tout (de) selectionner`})]}),(0,Y.jsx)(p,{type:`primary`,onClick:()=>d(!0),disabled:!n,children:`Ajouter et fermer`})]})};X.propTypes={handleAddIndicators:C.default.func,handleModifyIndicator:C.default.func,handleShowModal:C.default.func,options:C.default.object,selectedRowKeys:C.default.array,setSelectedRowKeys:C.default.func,selectionsModified:C.default.bool,setSelectionsModified:C.default.func,tableData:C.default.array};function Z(e){let t={width:`95%`,height:`100%`};for(let n in e)switch(n){case`font_size`:e[n]!==`0`&&(t.fontSize=`${e[n]}px`);break;case`font_weight`:t.fontWeight=e[n];break;case`padding`:t.paddingLeft=`${e[n]}px`;break;case`color`:e.is_hide!==1&&(t.color=e[n]);break;case`background_color`:e.is_hide!==1&&(t.backgroundColor=e[n]);break;case`border_thickness`:e[n]===1&&(t.border=`2px solid rgba(0, 0, 0, 0.5)`);break;case`is_hide`:e[n]===1&&(t.color=f.inactiveGrey);break;default:break}return t}var me=e=>{let t=[{title:`Contexte`,dataKey:`contexte`,width:100},{title:`Code`,dataKey:`code`},{title:`Nom`,dataKey:`texte`,frozen:`left`,width:600,cellRenderer:({rowData:e})=>(0,Y.jsx)(`div`,{className:`BaseTable__row-cell-text`,children:(0,Y.jsx)(y,{label:e.label?e.label:e.texte,isCti:e.is_cti,icon:`Hospital`,toolTipLabel:`Rapport créé par l'établissement`})})},{title:`Condition`,dataKey:`rapport_indicateur_condition`}];return((e,t)=>{t===`ESSENTIEL`&&e.unshift({title:`Groupe`,dataKey:`group_texte`,width:150})})(t,e),t.map(e=>({width:200,resizable:!0,key:e.dataKey,...e}))};function he(e,t,n,r){let i=[{title:`N°`,width:40,dataKey:`numero_rubrique`,frozen:`left`},{title:`Nom`,dataKey:`entete_etendue`,frozen:`left`,width:400,cellRenderer:({rowData:e})=>{let t=e.entete_etendue===``?e.indicateur_entete_etendue:e.entete_etendue,n=Z(e);return(0,Y.jsx)(`div`,{style:n,className:`BaseTable__row-cell-text`,children:(0,Y.jsx)(y,{label:t,isCti:e.is_cti,style:n,icon:`Hospital`,toolTipLabel:`Indicateur créé par l'établissement`})})}},{title:`Code`,width:150,dataKey:`code`},{title:`Format de sortie`,dataKey:`output_format`,width:120,dataGetter:({rowData:e})=>{let t=`output_format`;return e[t]===``?e.indicateur_output_format:e[t]}},{title:`Condition`,dataKey:`indicateur_condition`,width:120}];return e.type_rapport===`ESSENTIEL`?i.push({title:`Picto`,width:75,dataKey:`picto_enabled`,dataGetter:({rowData:e})=>{let t=``;return t+=e.picto_enabled===`1`?`+`:``,t+=e.positif_is_good===`1`?` OK`:``,t}},{title:`Série`,width:800,dataGetter:({rowData:e})=>{let t=``;return t=n(e,r).map(e=>e?.code).join(` / `),t}}):i.push({title:`Nom abrégé`,dataKey:`entete`,width:250,dataGetter:({rowData:e})=>e.entete===``?e.indicateur_entete:e.entete},{title:`Fonction Total`,width:150,dataKey:`total_function`,dataGetter:({rowData:e})=>{let n=``;return t.forEach(t=>{t.value===e.total_function&&(n+=t.title)}),n}}),e.type_rapport===`VUEPARAM`&&i.push({title:`Comparé avec`,width:300,dataKey:`compared_indicator_label`}),i.map(e=>({width:200,...e,resizable:!0,key:e.dataKey,className:`cti-default-table`,headerClassName:`cti-default-table`}))}var ge=e=>[{title:`Code`,dataIndex:`code`,dataKey:`code`,key:`code`,width:250,resizable:!0},{title:`Nom`,dataKey:`texte`,dataIndex:`texte`,key:`name`,frozen:`left`,width:400,cellRenderer:({rowData:e})=>{let t=e.texte===``?e.entete_etendue:e.texte,n=Z(e);return(0,Y.jsx)(`div`,{style:n,className:`BaseTable__row-cell-text`,children:(0,Y.jsx)(y,{label:t,isCti:e.is_cti?`1`:`0`,style:n,icon:`Hospital`,toolTipLabel:`Indicateur créé par l'établissement`})})}},{title:`Format de sortie`,dataKey:`output_format`,dataIndex:`output_format`,key:`output_format`,width:200},{title:`Table`,dataKey:`table_name`,dataGetter:({rowData:t})=>{let n=t.table_name,r=e.find(e=>e.code===n);return r?r.texte:n},width:200,key:`table`}],_e=[],Q=({showModal:e,handleShowModal:t,handleAddIndicators:n,handleModifyIndicator:r,options:i,specifiedIndicators:a=_e,joinedIndicatorIndex:o=null})=>{let[s,c]=(0,S.useState)(``),[l,u]=(0,S.useState)([]),[d,f]=(0,S.useState)(!1),{softCode:p}=ee(),m=J(p).data??K,h=(0,S.useMemo)(()=>b(a.length?a:m.indicators,s,[`texte`,`code`]),[m.indicators,s,a]);(0,S.useEffect)(()=>{u([])},[e]);let v=(0,Y.jsx)(X,{selectedRowKeys:l,setSelectedRowKeys:u,setSelectionsModified:f,selectionsModified:d,handleAddIndicators:n,handleModifyIndicator:r,handleShowModal:t,tableData:h,options:i,joinedIndicatorIndex:o});return(0,Y.jsx)(g,{open:e,onCancel:t,footer:v,width:`75%`,bodyStyle:{height:`70vh`},centered:!0,zIndex:3010,children:(0,Y.jsxs)(`div`,{className:`indicator-modal`,children:[(0,Y.jsxs)(`div`,{className:`indicator-modal-header`,children:[(0,Y.jsx)(`span`,{className:`modal-title`,children:`Choix d'un ou plusieurs indicateurs`}),(0,Y.jsxs)(`div`,{className:`modal-search`,children:[(0,Y.jsx)(`span`,{children:`Rechercher par texte:`}),(0,Y.jsx)(_,{value:s,onChange:e=>{c(e.target.value)}})]})]}),(0,Y.jsx)(`div`,{className:`indicator-modal-table`,children:(0,Y.jsx)(te,{rowKey:`key`,columns:ge(m.tables),data:h,selectedRow:i.oneOnly===!0?h.find(e=>e.key===l[0]):null,selectedRows:i.oneOnly===!1?l:null,shiftMulti:i.oneOnly!==!0,onRowSelect:e=>{if(f(!0),i.oneOnly)l.length&&l[0]===e?u([]):u([e]);else{let t=[...l];Array.isArray(e)?t=t.concat(e):t.includes(e)?t=t.filter(t=>t!==e):t.push(e),u(t)}}})})]})})};Q.propTypes={showModal:C.default.bool,handleShowModal:C.default.func,handleAddIndicators:C.default.func,handleModifyIndicator:C.default.func,options:C.default.object,specifiedIndicators:C.default.array};var $=({onConfirm:e,modified:t,disabled:n,placement:r=`topRight`})=>(0,Y.jsx)(x,{onConfirm:e,modified:t,disabled:n,text:`Annuler`,title:`Annuler les modifications ?`,okText:`Annuler les modifications`,cancelText:`Revenir à l'éditeur`,placement:r});$.propTypes={onConfirm:C.default.func.isRequired,modified:C.default.bool,disabled:C.default.bool,placement:C.default.string};export{I as _,W as a,w as b,pe as c,se as d,le as f,L as g,R as h,he as i,de as l,B as m,Q as n,K as o,U as p,me as r,G as s,$ as t,J as u,H as v,z as y};