PageSourceSearch

https://www.iprbookshop.ru/build/assets/index-B9Un9q4V.js

js iprbookshop.ru collected 2026-09-24 10:27:05 UTC 59,713 bytes, 1 lines download raw bytes

1import{e as L,$ as He,i as te,W as $,q as I,r as o,j as e,n as v,R as pt,S as mt}from"./app-DoaXZv-P.js";import{D as gt}from"./dashboardLayout-BMXFacEM.js";import{n as ht,g as bt,e as xt,m as ft,D as be,j as Re,d as Ee,P as Pe,i as Ae,A as H,a as le,k as yt,f as _e,b as ve,c as Me,S as oe,l as nt,s as R}from"./SpoPublicationSelectionModal.module-DPCBkx_5.js";import{D as re,C as h,P as Ne}from"./column.esm-BfdGGoqq.js";import{u as jt}from"./classifiers.api-BtR3rZX7.js";import{u as vt}from"./useGetAppProps-CgZMrP5R.js";import{S}from"./collections.types-DLf59eff.js";import{r as Pt}from"./search.payload-BPQmPT1S.js";import{g as Ye}from"./search.types-B70f2CFi.js";import{D as z}from"./DashboardInputText-Q_y1Vy3C.js";import{R as lt,a as ot}from"./router-B3PhLOcU.js";import{i as $e,c as _t}from"./tableTemplates-DGvXvVEg.js";import{D as ie}from"./dialog.esm-D8VcfAQV.js";import{C as Ue,c as Le}from"./confirmdialog.esm-mpWYoH9r.js";import{h as Nt,p as kt}from"./parseNameListInput-Bv-Q7clI.js";import{D as ne}from"./DashboardFormDialogFooter-DMZi_9om.js";import{D as ee}from"./DashboardSelect-BOwvA7Ik.js";import{a as Ct}from"./books.api-CvMmykRl.js";import{D as ze}from"./DashboardCalendarInput-Dgreos9q.js";import{z as St}from"./field-ko5yChfi.js";import{f as Dt}from"./format-Ln8TNNwN.js";import{D as wt}from"./DashboardCheckbox-CE3G6jHI.js";import{T as Tt,a as Je}from"./tabview.esm-DvzkPnbH.js";import{P as Lt}from"./PublicationTypesSelect-DXhFDKqe.js";import"./ScrollToTopButton-Dop9I2pa.js";import"./useAuth-HKSBaMEI.js";import"./logo-BFou7uDw.js";/* empty css                   */import"./roles.types-E2dAPaKE.js";import"./inputnumber.esm-kM6J2uTP.js";import"./inputtext.esm-OtfE0lK3.js";import"./keyfilter.esm-BduySNhv.js";import"./index.esm-Dvm9bdM9.js";import"./overlayservice.esm-CLWP1-B6.js";import"./index.esm-C6OwWC6n.js";import"./csstransition.esm-D5Git-CX.js";import"./setPrototypeOf-SZTCiYDs.js";import"./index.esm-BfQ3PQA-.js";import"./index.esm-DJo6HR9u.js";import"./classifiers.types-Dwukm4y8.js";import"./createEntityAdapter-DDq-tnWI.js";import"./entities.types-CAAeLS-h.js";import"./AdditionalSubscriptionIndicator-DTvFi1AS.js";import"./books.types-Bdr-lizN.js";import"./calendar.esm-yCpcHBCM.js";import"./index.esm-C89jSbGM.js";import"./ReactSelect-BmoICwk4.js";import"./react-select.esm-Debf1tJ3.js";import"./assertThisInitialized-B9jnkVVz.js";import"./floating-ui.dom-bOIXkmBX.js";import"./parse-lVCZwRz1.js";import"./defaultDateRanges-DKPIE-cs.js";import"./differenceInMonths-DgUJBum1.js";import"./endOfDay-BQ8iXHi2.js";import"./isBefore-C0zbHRqr.js";import"./ru-Cg7cUcMO.js";import"./parseISO-Dv1KoZFf.js";import"./checkbox.esm-2PprUYli.js";function rt(t){var a;const s=(a=t==null?void 0:t.data)==null?void 0:a.publications;return!s||!Array.isArray(s.data)?null:s}function ct(t,s){const a=t??{};return{...a,data:{...a.data,publications:s}}}function It(t,s){const a=rt(t);if(!a)return t;const n=a.data.filter(p=>p.id!==s),l=a.data.length-n.length;return l===0?t:ct(t,{...a,data:n,total:Math.max(0,a.total-l),active_total:a.active_total!=null?Math.max(0,a.active_total-l):void 0})}function Et(t,s){const a=rt(t);if(!a)return{data:{publications:{data:[s],current_page:1,last_page:1,per_page:15,total:1,active_total:1}}};const n=a.data.filter(p=>p.id!==s.id),l=n.length!==a.data.length;return ct(t,{...a,data:[s,...n],total:l?a.total:a.total+1,active_total:a.active_total!=null&&!l?a.active_total+1:a.active_total})}async function Rt(t,{disciplineId:s,linkId:a,newType:n,listParams:l,publication:p}){if(!l)return;const c=S.publications.key(s,l),x={...l,type:n,page:1},b=S.publications.key(s,x);await t.cancelQueries({queryKey:c}),await t.cancelQueries({queryKey:b});const g=t.getQueryData(c),P=t.getQueryData(b);return t.setQueryData(c,_=>It(_,a)),p&&t.setQueryData(b,_=>Et(_,{...p,type:n})),{currentKey:c,oppositeKey:b,previousCurrent:g,previousOpposite:P}}function Ut(t,s){s&&(t.setQueryData(s.currentKey,s.previousCurrent),t.setQueryData(s.oppositeKey,s.previousOpposite))}var D;(t=>{t.getUgps=()=>"/dashboard/supply/spo/ugps/get",t.createUgp=()=>"/dashboard/supply/spo/ugps/0/add",t.removeUgp=s=>`/dashboard/supply/spo/ugps/${s}/remove`,t.getProfiles=()=>"/dashboard/supply/spo/profiles/get",t.createProfile=()=>"/dashboard/supply/spo/profiles/create",t.updateProfile=s=>`/dashboard/supply/spo/profiles/${s}/update`,t.copyProfile=s=>`/dashboard/supply/spo/profiles/${s}/copy`,t.exportProfile=s=>`/dashboard/supply/spo/profiles/${s}/export`,t.hideProfile=s=>`/dashboard/supply/spo/profiles/${s}/hide`,t.restoreProfile=s=>`/dashboard/supply/spo/profiles/${s}/restore`,t.deleteProfile=s=>`/dashboard/supply/spo/profiles/${s}/delete`,t.getDisciplines=()=>"/dashboard/supply/spo/disciplines/get",t.createDiscipline=()=>"/dashboard/supply/spo/disciplines/create",t.updateDiscipline=s=>`/dashboard/supply/spo/disciplines/${s}/update`,t.copyDiscipline=s=>`/dashboard/supply/spo/disciplines/${s}/copy`,t.getDisciplineReport=s=>`/dashboard/supply/spo/disciplines/report?name=${encodeURIComponent(s)}`,t.exportDisciplineReport=s=>`/dashboard/supply/spo/disciplines/report/export?name=${encodeURIComponent(s)}`,t.deleteDiscipline=s=>`/dashboard/supply/spo/disciplines/${s}/delete`,t.getPublications=s=>`/dashboard/supply/spo/disciplines/${s}/publications/get`,t.addPublications=s=>`/dashboard/supply/spo/disciplines/${s}/publications/add`,t.removePublications=s=>`/dashboard/supply/spo/disciplines/${s}/publications/remove`,t.updatePublicationType=s=>`/dashboard/supply/spo/disciplines/${s}/publications/update-type`,t.exportDisciplinePublications=(s,a)=>{const n=a?`?profile_id=${a}`:"";return`/dashboard/supply/spo/disciplines/${s}/publications/export${n}`},t.getMissingBooks=s=>`/dashboard/supply/spo/disciplines/${s}/publications/missing`,t.getLinkedPublicationIds=s=>`/dashboard/supply/spo/disciplines/${s}/publications/linked-ids`,t.getBooks=()=>"/dashboard/supply/spo/books/get",t.getBookDisciplines=s=>`/dashboard/supply/spo/books/${s}/disciplines`})(D||(D={}));var w;(t=>{t.getUgps=async a=>L.get(D.getUgps(),{params:a}).then(n=>n.data),t.createUgp=async a=>L.post(D.createUgp(),a).then(n=>n.data),t.removeUgp=async a=>L.post(D.removeUgp(a)).then(n=>n.data),t.getProfiles=async a=>L.get(D.getProfiles(),{params:a}).then(n=>n.data),t.createProfile=async a=>L.post(D.createProfile(),a).then(n=>n.data),t.updateProfile=async(a,n)=>L.post(D.updateProfile(a),n).then(l=>l.data),t.copyProfile=async(a,n)=>L.post(D.copyProfile(a),n).then(l=>l.data);const s=(a,n)=>{const l=window.URL.createObjectURL(a),p=document.createElement("a");p.href=l,p.setAttribute("download",n),document.body.appendChild(p),p.click(),p.remove(),window.URL.revokeObjectURL(l)};t.exportProfile=async a=>{const n=await L.get(D.exportProfile(a),{responseType:"blob"});return s(new Blob([n.data]),`spo_profile_${a}_books.xlsx`),n.data},t.exportDisciplinePublications=async(a,n)=>{const l=await L.get(D.exportDisciplinePublications(a,n),{responseType:"blob"});return s(new Blob([l.data]),`spo_discipline_${a}_books.xlsx`),l.data},t.deleteProfile=async a=>L.post(D.deleteProfile(a)).then(n=>n.data),t.hideProfile=async a=>L.post(D.hideProfile(a)).then(n=>n.data),t.restoreProfile=async a=>L.post(D.restoreProfile(a)).then(n=>n.data),t.getBooks=async a=>L.get(D.getBooks(),{params:a}).then(n=>n.data),t.getBookDisciplines=async a=>L.get(D.getBookDisciplines(a)).then(n=>n.data),t.getDisciplines=async a=>L.get(D.getDisciplines(),{params:a}).then(n=>n.data),t.createDiscipline=async a=>L.post(D.createDiscipline(),a).then(n=>n.data),t.updateDiscipline=async(a,n)=>L.post(D.updateDiscipline(a),n).then(l=>l.data),t.copyDiscipline=async(a,n)=>L.post(D.copyDiscipline(a),n).then(l=>l.data),t.getDisciplineReport=async a=>L.get(D.getDisciplineReport(a)).then(n=>n.data),t.exportDisciplineReport=async a=>{const n=await L.get(D.exportDisciplineReport(a),{responseType:"blob"}),l=a.trim().replace(/[^\p{L}\p{N}\-_]+/gu,"_")||"discipline";return s(new Blob([n.data]),`spo_discipline_${l}_books.xlsx`),n.data},t.deleteDiscipline=async(a,n)=>L.post(D.deleteDiscipline(a),n).then(l=>l.data),t.getPublications=async(a,n)=>L.get(D.getPublications(a),{params:{...n,discipline_id:a,paginate:!0}}).then(l=>l.data),t.addPublications=async(a,n)=>L.post(D.addPublications(a),n).then(l=>l.data),t.removePublications=async(a,n)=>L.post(D.removePublications(a),n).then(l=>l.data),t.updatePublicationType=async(a,n)=>L.post(D.updatePublicationType(a),n).then(l=>l.data),t.getMissingBooks=async(a,n)=>L.get(D.getMissingBooks(a),{params:n}).then(l=>l.data),t.getLinkedPublicationIds=async a=>L.get(D.getLinkedPublicationIds(a)).then(n=>n.data)})(w||(w={}));const Ft="2";async function Bt(t,s,a,n,l){var u;const p=(a==null?void 0:a.page)??1,c=(a==null?void 0:a.per_page)??20,x=(p-1)*c;He.defaults.baseURL=l;const b=await w.getLinkedPublicationIds(t),g=new Set(((u=b==null?void 0:b.data)==null?void 0:u.publication_ids)??[]),P=ht(s);if(!P)return{books:{data:[],current_page:p,from:null,to:null,per_page:c,last_page:1,total:0}};const _=bt(n),k=Pt({search:P,search_by:[Ye.TITLE,Ye.DESCRIPTION],purposes_ids:[Ft],start:x,limit:c,..._.length>0?{publication_types_ids:_}:{}}),C=await He.get("/books/get",{params:k}),m=xt(C.data),j=(m==null?void 0:m.total)??0,N=((m==null?void 0:m.data)??[]).filter(y=>!g.has(Number(y.id))).map(ft);return{books:{data:N,current_page:p,from:N.length>0?x+1:null,to:N.length>0?x+N.length:null,per_page:c,last_page:Math.max(1,Math.ceil(j/c)),total:j}
1}}const dt=t=>te({queryKey:S.ugps.key(t),queryFn:()=>w.getUgps(t),staleTime:1/0,refetchOnWindowFocus:!0}),At=()=>$({mutationFn:t=>w.createUgp(t),onSuccess:()=>{I.invalidateQueries([S.ugps.UNIQUE_PART])}}),Mt=()=>$({mutationFn:t=>w.removeUgp(t),onSuccess:()=>{I.invalidateQueries([S.ugps.UNIQUE_PART])}}),$t=(t,s=!0)=>te({queryKey:S.profiles.key(t),queryFn:()=>w.getProfiles(t),enabled:s,staleTime:1/0,refetchOnWindowFocus:!0}),Ot=()=>$({mutationFn:t=>w.createProfile(t),onSuccess:()=>{I.invalidateQueries([S.profiles.UNIQUE_PART])}}),Qt=()=>$({mutationFn:({profileId:t,body:s})=>w.updateProfile(t,s),onSuccess:()=>{I.invalidateQueries([S.profiles.UNIQUE_PART])}}),Kt=()=>$({mutationFn:({profileId:t,body:s})=>w.copyProfile(t,s),onSuccess:()=>{I.invalidateQueries([S.profiles.UNIQUE_PART])}}),Vt=()=>$({mutationFn:t=>w.exportProfile(t)}),Wt=()=>$({mutationFn:({disciplineId:t,profileId:s})=>w.exportDisciplinePublications(t,s)}),qt=()=>$({mutationFn:t=>w.deleteProfile(t),onSuccess:()=>{I.invalidateQueries([S.profiles.UNIQUE_PART])}}),Gt=()=>$({mutationFn:t=>w.hideProfile(t),onSuccess:()=>{I.invalidateQueries([S.profiles.UNIQUE_PART])}}),Ht=()=>$({mutationFn:t=>w.restoreProfile(t),onSuccess:()=>{I.invalidateQueries([S.profiles.UNIQUE_PART])}}),Yt=(t,s=!0)=>te({queryKey:S.disciplines.key(t),queryFn:()=>w.getDisciplines(t),enabled:s,staleTime:1/0,refetchOnWindowFocus:!0}),zt=()=>$({mutationFn:t=>w.createDiscipline(t),onSuccess:()=>{I.invalidateQueries([S.disciplines.UNIQUE_PART]),I.invalidateQueries([S.publications.UNIQUE_PART])}}),Jt=()=>$({mutationFn:({disciplineId:t,body:s})=>w.copyDiscipline(t,s),onSuccess:()=>{I.invalidateQueries([S.disciplines.UNIQUE_PART]),I.invalidateQueries([S.publications.UNIQUE_PART])}}),Xt=(t,s=!0)=>te({queryKey:S.disciplineReport.key(t),queryFn:()=>w.getDisciplineReport(t),enabled:s&&!!(t!=null&&t.trim()),staleTime:0}),Zt=()=>$({mutationFn:t=>w.exportDisciplineReport(t)}),es=()=>$({mutationFn:({disciplineId:t,body:s})=>w.updateDiscipline(t,s),onSuccess:()=>{I.invalidateQueries([S.disciplines.UNIQUE_PART])}}),ts=()=>$({mutationFn:({disciplineId:t,profileId:s,type:a})=>w.deleteDiscipline(t,{profile_id:s,type:a}),onSuccess:()=>{I.invalidateQueries([S.disciplines.UNIQUE_PART])}}),ss=(t,s)=>te({queryKey:S.publications.key(t,s),queryFn:()=>w.getPublications(t,s),enabled:t!=null,staleTime:1/0,refetchOnWindowFocus:!0}),as=()=>$({mutationFn:({disciplineId:t,body:s})=>w.addPublications(t,s),onSuccess:(t,s)=>{I.invalidateQueries([S.publications.UNIQUE_PART,s.disciplineId]),I.invalidateQueries([S.missingBooks.UNIQUE_PART,s.disciplineId]),I.invalidateQueries([S.autoSelectionBooks.UNIQUE_PART,s.disciplineId]),I.invalidateQueries([S.disciplines.UNIQUE_PART])}}),is=()=>$({mutationFn:({disciplineId:t,body:s})=>w.removePublications(t,s),onSuccess:(t,s)=>{I.invalidateQueries([S.publications.UNIQUE_PART,s.disciplineId]),I.invalidateQueries([S.missingBooks.UNIQUE_PART,s.disciplineId]),I.invalidateQueries([S.autoSelectionBooks.UNIQUE_PART,s.disciplineId]),I.invalidateQueries([S.disciplines.UNIQUE_PART])}}),ns=()=>$({mutationFn:({disciplineId:t,body:s})=>w.updatePublicationType(t,s),onMutate:async t=>Rt(I,{disciplineId:t.disciplineId,linkId:t.body.publication_link_id,newType:t.body.type,listParams:t.listParams,publication:t.publication}),onError:(t,s,a)=>{Ut(I,a)},onSettled:(t,s,a)=>{I.invalidateQueries([S.publications.UNIQUE_PART,a.disciplineId])}}),ls=(t,s,a=!1)=>te({queryKey:S.missingBooks.key(t,s),queryFn:()=>w.getMissingBooks(t,s),enabled:a&&t!=null,staleTime:0}),os=(t,s,a,n=!1)=>{const{api_url:l}=vt(),{data:p}=jt();return te({queryKey:S.autoSelectionBooks.key(t,{...a,disciplineName:s}),queryFn:async()=>({data:await Bt(t,s,a,p,l)}),enabled:n&&t!=null&&!!l,staleTime:0,placeholderData:c=>c})},rs=(t,s=!0)=>te({queryKey:S.books.key(t),queryFn:()=>w.getBooks(t),enabled:s,staleTime:0,refetchOnWindowFocus:!0}),cs=(t,s=!1)=>te({queryKey:S.bookDisciplines.key(t),queryFn:()=>w.getBookDisciplines(t),enabled:s&&t!=null,staleTime:0}),Oe=[{label:"Специальность",value:1},{label:"Профессия",value:2}],ds=[{label:"Все уровни",value:null},...Oe],Ie=0,Fe=1,us=[{label:"Основные издания",value:Ie},{label:"Дополнительные издания",value:Fe}],ps=[{label:"Основная",value:Ie},{label:"Дополнительная",value:Fe}],ut=[{label:"Общеобразовательный цикл",value:0},{label:"Общепрофессиональный цикл",value:1},{label:"Профессиональный цикл",value:2},{label:"Социально-гуманитарный",value:3}];function Qe(t){var s;return t==null?"—":((s=Oe.find(a=>a.value===t))==null?void 0:s.label)??String(t)}function Be(t){var s;return t==null?"—":((s=ut.find(a=>a.value===t))==null?void 0:s.label)??String(t)}function Xe(t,s,a){var p,c,x,b;const n=(p=t.pivot)==null?void 0:p.type;if(n!=null)return Number(n);const l=(b=(x=(c=t.profiles)==null?void 0:c.find(g=>g.id===s))==null?void 0:x.pivot)==null?void 0:b.type;return l!=null?Number(l):a??null}const ms=()=>{var C,m;const[t,s]=o.useState(""),[a,n]=o.useState(null),{data:l,isLoading:p,isFetching:c,isError:x,error:b}=cs(a,a!=null),g=(C=l==null?void 0:l.data)==null?void 0:C.book,P=((m=l==null?void 0:l.data)==null?void 0:m.disciplines)??[],_=o.useMemo(()=>{const j=[];return P.forEach(N=>{var u;if(!((u=N.profiles)!=null&&u.length)){j.push({id:`${N.id}-empty`,discipline_name:N.name,publication_type:N.publication_type,ugp_label:"—",profile_label:"—",profile_level:"—",cycle_label:"—"});return}
1N.profiles.forEach(y=>{j.push({id:`${N.id}-${y.id}`,discipline_name:N.name,publication_type:N.publication_type,ugp_label:y.ugp?`${y.ugp.code} ${y.ugp.name}`.trim():"—",profile_label:`${y.code} ${y.name}`.trim(),profile_level:Qe(y.type),cycle_label:Be(y.cycle_type)})})}),j},[P]),k=()=>{const j=Number(t.trim());if(!j||j<=0){n(null);return}n(j)};return e.jsxs(be,{title:"Отчёт по книге",description:"Введите ID книги — будут показаны все дисциплины и профессии СПО, в которые она входит",filters:e.jsxs("div",{className:"flex flex-col md:flex-row gap-4 items-end",children:[e.jsx("div",{className:"w-full max-w-xs",children:e.jsx(z,{label:"ID книги",value:t,onChange:j=>s(j.target.value),placeholder:"ID из каталога изданий",className:"!bg-white",onKeyDown:j=>j.key==="Enter"&&k()})}),e.jsx(Pe,{label:"Найти",onClick:k})]}),children:[g&&e.jsxs("div",{className:"m-4 mb-0 p-4 bg-slate-50 border border-slate-200 rounded-lg text-sm space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{children:[e.jsx("strong",{children:"Книга:"})," ",g.title??"—"]}),e.jsx(Re,{item:{book:g}})]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Авторы:"})," ",g.authors??"—"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Год:"})," ",g.year??"—"]})]}),e.jsxs(re,{value:_,loading:p||c,dataKey:"id",emptyMessage:a?x?b instanceof Error?b.message:"Запись с указанным ID не найдена в каталоге изданий":"Книга не входит ни в одну дисциплину СПО":"Введите ID книги и нажмите «Найти»",className:"min-w-full p-datatable-sm",pt:Ee,children:[e.jsx(h,{field:"discipline_name",header:"Дисциплина"}),e.jsx(h,{field:"ugp_label",header:"УГП"}),e.jsx(h,{field:"profile_label",header:"Профессия"}),e.jsx(h,{field:"profile_level",header:"Уровень"}),e.jsx(h,{field:"cycle_label",header:"Цикл"}),e.jsx(h,{field:"publication_type",header:"Вид издания"})]})]})},gs=()=>{var O,F,A,W;const[t,s]=o.useState(""),[a,n]=o.useState(null),[l,p]=o.useState(!1),{data:c,isLoading:x,isFetching:b,isError:g,error:P}=Xt(a,a!=null),_=Zt(),k=(O=c==null?void 0:c.data)==null?void 0:O.discipline,C=((F=c==null?void 0:c.data)==null?void 0:F.disciplines_count)??0,m=((A=c==null?void 0:c.data)==null?void 0:A.books)??[],j=((W=c==null?void 0:c.data)==null?void 0:W.profiles)??[],N=r=>({exclude:r.exclude,book:{excluded:r.excluded,deleted_at:r.deleted_at,reissue_id:r.reissue_id,has_redirect_from_old:r.has_redirect_from_old,redirect_sources_count:r.redirect_sources_count,redirect_source_ids:r.redirect_source_ids}}),u=()=>{const r=t.trim();if(!r){n(null);return}n(r),p(!1)},y=()=>{a&&_.mutate(a,{onSuccess:()=>{v({type:"success",message:"Список книг выгружен в Excel"})},onError:()=>{v({type:"error",message:"Ошибка при выгрузке"})}})};return e.jsxs(be,{title:"Отчёт по дисциплине",description:"Одноимённые дисциплины в одном цикле имеют одинаковые книги во всех профессиях. Разные циклы — разные списки.",filters:e.jsxs("div",{className:"flex flex-col md:flex-row gap-4 items-end flex-wrap",children:[e.jsx("div",{className:"w-full max-w-md",children:e.jsx(z,{label:"Название дисциплины",value:t,onChange:r=>s(r.target.value),placeholder:"Например, Информатика",className:"!bg-white",onKeyDown:r=>r.key==="Enter"&&u()})}),e.jsx(Pe,{label:"Найти",onClick:u}),a&&m.length>0&&e.jsx(H,{icon:"pi-download",title:"Выгрузить Excel",onClick:y})]}),children:[k&&e.jsxs("div",{className:"m-4 mb-0 p-4 bg-slate-50 border border-slate-200 rounded-lg text-sm space-y-2",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Дисциплина:"})," ",k.name??"—"]}),C>1&&e.jsxs("div",{children:[e.jsx("strong",{children:"Найдено записей:"})," ",C," ","(книги объединены по всем профессиÑ
1Ð¼)"]}),j.length>0&&e.jsxs("div",{children:[e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 text-left hover:text-orange-600 transition-colors",onClick:()=>p(r=>!r),"aria-expanded":l,children:[e.jsx("i",{className:`pi ${l?"pi-chevron-down":"pi-chevron-right"} text-xs`}),e.jsx("strong",{children:"Профессии:"}),!l&&e.jsx("span",{className:"font-normal text-slate-600",children:j.length})]}),l&&e.jsx("ul",{className:"mt-2 ml-5 space-y-1 list-none",children:j.map(r=>{const M=r.ugp?`${r.ugp.code} ${r.ugp.name}`.trim():"",q=`${r.code} ${r.name}`.trim(),V=Qe(r.type),f=[M,q,V].filter(Boolean).join(" — ");return e.jsx("li",{children:f},r.id)})})]})]}),e.jsxs(re,{value:m,loading:x||b,dataKey:"id",rowClassName:r=>Ae(N(r)),emptyMessage:a?g?P instanceof Error?P.message:"Дисциплина с указанным названием не найдена":"В дисциплине нет активных книг":"Введите название дисциплины и нажмите «Найти»",className:"min-w-full p-datatable-sm",pt:Ee,children:[e.jsx(h,{field:"id",header:"ID",style:{width:"80px"},body:r=>e.jsx("a",{href:lt[ot.BOOK_DETAILS](r.id),target:"_blank",rel:"noreferrer",className:"text-sm font-mono hover:text-orange-500",children:r.id})}
1),e.jsx(h,{field:"title",header:"Название"}),e.jsx(h,{field:"authors",header:"Авторы"}),e.jsx(h,{field:"year",header:"Год",style:{width:"80px"}}),e.jsx(h,{header:"Версия",body:r=>$e({is_additional:r.is_additional}),style:{width:"150px"}}),e.jsx(h,{field:"publication_type",header:"Вид издания"}),e.jsx(h,{field:"publishers",header:"Издательство",body:r=>{var M;return((M=r.publishers)==null?void 0:M.trim())||"—"}}),e.jsx(h,{header:"Статус",body:r=>e.jsx(Re,{item:N(r)}),style:{minWidth:"180px"}})]})]})},hs=({ugp:t,profile:s,selectedDisciplineId:a,onSelect:n,onBack:l})=>{const[p,c]=o.useState(1),[x,b]=o.useState(""),[g,P]=o.useState(0),[_,k]=o.useState(!1),[C,m]=o.useState([]),[j,N]=o.useState(""),[u,y]=o.useState(!1),[O,F]=o.useState(null),[A,W]=o.useState(""),[r,M]=o.useState(!1),[q,V]=o.useState(null),[f,E]=o.useState(""),Q=o.useRef(null),{data:B,isLoading:X}=Yt({ugnp_id:t.id,profile_id:s.id,type:g},!!s.id),Z=zt(),ce=Jt(),Y=es(),de=ts(),xe=Wt(),J=o.useMemo(()=>{const i=le(B,"disciplines");return yt(i.data,p,x)},[B,p,x]),ue=o.useMemo(()=>{const i=B==null?void 0:B.data;return(i==null?void 0:i.cycle_books_count)!=null?Number(i.cycle_books_count)||0:le(B,"disciplines").data.reduce((U,d)=>U+(Number(d.books_count)||0),0)},[B]),G=o.useMemo(()=>Be(g),[g]),se=i=>{const T=i.trim();T&&m(U=>U.includes(T)?U:[...U,T])},fe=i=>{m(T=>T.filter((U,d)=>d!==i))},ye=()=>{m([]),N("")},ke=()=>{const i=j.trim(),T=i?[...C,i]:C;T.length!==0&&Z.mutate({profile_id:s.id,names:T,type:g},{onSuccess:U=>{var We,qe,Ge;const d=Number((We=U==null?void 0:U.data)==null?void 0:We.copied_publications_count)||0,Ke=Number((qe=U==null?void 0:U.data)==null?void 0:qe.created_count)||0,Ve=Number((Ge=U==null?void 0:U.data)==null?void 0:Ge.already_existed_count)||0,je=[];Ke>0&&je.push(`Добавлено дисциплин: ${Ke}`),Ve>0&&je.push(`Уже было в этом цикле: ${Ve}`),je.length===0&&je.push(`Добавлено дисциплин: ${T.length}`),d>0&&je.push(`Скопировано книг: ${d}`),v({type:"success",message:je.join(". ")}),ye(),k(!1)},onError:()=>{v({type:"error",message:"Ошибка при создании"})}})},Ce=i=>{(i.key==="Enter"||i.key===";")&&(i.preventDefault(),j.trim()&&(se(j),N(""))),i.key==="Backspace"&&!j&&C.length>0&&fe(C.length-1)},K=()=>{j.trim()&&(se(j),N(""))},Se=i=>{const T=i.clipboardData.getData("text");Nt(T)&&(i.preventDefault(),kt(T).forEach(U=>se(U)),N(""))},De=i=>{F(i),W(i.name),y(!0)},pe=()=>{!O||!A.trim()||Y.mutate({disciplineId:O.id,body:{name:A.trim(),profiles_ids:[s.id]}},{onSuccess:()=>{v({type:"success",message:"Дисциплина обновлена"}),y(!1),F(null)},onError:()=>{v({type:"error",message:"Ошибка при обновлении"})}})},we=i=>{V(i),E(`${i.name} (копия)`),M(!0)},me=()=>{!q||!f.trim()||ce.mutate({disciplineId:q.id,body:{name:f.trim(),profile_id:s.id,type:g}},{onSuccess:()=>{v({type:"success",message:"Дисциплина скопирована"}),M(!1),V(null)},onError:()=>{v({type:"error",message:"Ошибка при копировании"})}})},ae=i=>{xe.mutate({disciplineId:i.id,profileId:s.id},{onSuccess:()=>{v({type:"success",message:"Список книг выгружен в Excel"})},onError:()=>{v({type:"error",message:"Ошибка при выгрузке"})}})},ge=i=>{const T=Xe(i,s.id,g);Le({message:`Удалить дисциплину «${i.name}» из профессии?`,header:"Подтверждение удаления",icon:"pi pi-exclamation-triangle",acceptLabel:"Удалить",rejectLabel:"Отмена",acceptClassName:"p-button-danger",accept:()=>{de.mutate({disciplineId:i.id,profileId:s.id,...T!=null?{type:T}:{}},{onSuccess:()=>{v({type:"success",message:"Дисциплина удалена из профессии"})},onError:()=>{v({type:"error",message:"Ошибка при удалении"})}})}})},he=i=>e.jsxs("div",{className:"flex items-center gap-1 justify-center",children:[e.jsx(H,{icon:"pi-copy",title:"Копировать",onClick:()=>we(i)}),e.jsx(H,{icon:"pi-download",title:"Выгрузить книги (Excel)",onClick:()=>ae(i)}),e.jsx(H,{icon:"pi-pencil",title:"Редактировать",onClick:()=>De(i)}
1),e.jsx(H,{icon:"pi-trash",title:"Удалить",variant:"delete",onClick:()=>ge(i)})]});o.useEffect(()=>{_&&Q.current&&setTimeout(()=>{var i;return(i=Q.current)==null?void 0:i.focus()},100)},[_]);const Te=C.length>0||!!j.trim();return e.jsxs(e.Fragment,{children:[e.jsx(Ue,{}),e.jsx("div",{className:"mb-4",children:e.jsxs("button",{type:"button",onClick:l,className:"flex items-center gap-2 text-sm text-gray-600 hover:text-gray-900 transition-colors",children:[e.jsx("i",{className:"pi pi-arrow-left text-xs"}),"Назад к профессиям"]})}),e.jsx(be,{title:"Дисциплины",description:`${_e(t)} → ${ve(s)}`,actions:e.jsx(Pe,{label:"Добавить дисциплину",onClick:()=>{ye(),k(!0)}}),filters:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(ee,{label:"Цикл",value:g,options:ut,onChange:i=>{P(i.value),c(1)},className:"w-full",variant:"filled"}),e.jsx(oe,{label:"Название",value:x,placeholder:"Поиск по названию дисциплины",onChange:i=>{b(i),c(1)},showReset:!!x,onReset:()=>{b(""),c(1)}})]}),footer:J.total>0?e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 w-full",children:[e.jsxs("span",{className:"text-sm text-gray-600",children:["Книг в цикле «",G,"»: ",ue]}),e.jsx(Ne,{first:(p-1)*J.per_page,rows:J.per_page,totalRecords:J.total,onPageChange:i=>c(i.page+1),className:"border-0 p-0",template:"FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport",currentPageReportTemplate:"Дисциплин: {totalRecords}"})]}):e.jsxs("span",{className:"text-sm text-gray-600",children:["Нет записей. Книг в цикле: ",ue]}),children:e.jsxs(re,{value:J.data,loading:X,dataKey:"id",selectionMode:"single",selection:J.data.find(i=>i.id===a)??null,onSelectionChange:i=>{i.value&&n(i.value)},onRowClick:i=>n(i.data),emptyMessage:"Дисциплины не найдены. Добавьте первую дисциплину",className:"min-w-full p-datatable-sm",pt:Me,children:[e.jsx(h,{field:"name",header:"НаÐ
1·Ð²Ð°Ð½Ð¸Ðµ дисциплины"}),e.jsx(h,{header:"Цикл",body:i=>Be(Xe(i,s.id,g)),style:{width:"220px"}}),e.jsx(h,{header:"Книг",body:i=>Number(i.books_count)||0,style:{width:"90px"},bodyStyle:{textAlign:"center"}}),e.jsx(h,{header:"Действия",body:he,style:{width:"170px"},bodyStyle:{textAlign:"center"}})]})}),e.jsx(ie,{header:"Копирование дисциплины",visible:r,style:{width:"90vw",maxWidth:"520px"},className:"dashboard-crud-dialog",onHide:()=>M(!1),footer:e.jsx(ne,{onCancel:()=>M(!1),onSubmit:me,submitLabel:"Копировать",loading:ce.isLoading,disabled:!f.trim(),loadingLabel:"Копирование..."}),children:e.jsx(z,{label:"Новое название *",value:f,onChange:i=>E(i.target.value),variant:"filled",onKeyDown:i=>i.key==="Enter"&&me(),autoFocus:!0})}),e.jsx(ie,{header:"Создание дисциплин",visible:_,style:{width:"90vw",maxWidth:"520px"},className:"dashboard-crud-dialog",onHide:()=>k(!1),footer:e.jsx(ne,{onCancel:()=>k(!1),onSubmit:ke,submitLabel:"Создать",loading:Z.isLoading,disabled:!Te,loadingLabel:"Создание..."}),children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("p",{className:"text-sm text-gray-600",children:["Дисциплины будут добавлены в цикл: ",G]}),e.jsxs("div",{className:"spo-discipline-input-container",children:[e.jsx("div",{className:"spo-chips-container",children:C.map((i,T)=>e.jsxs("div",{className:"spo-discipline-chip",children:[e.jsx("span",{children:i}),e.jsx("button",{type:"button",onClick:()=>fe(T),className:"spo-chip-remove-btn",children:"×"})]},T))}),e.jsx("textarea",{ref:Q,value:j,onChange:i=>N(i.target.value),onKeyDown:Ce,onBlur:K,onPaste:Se,placeholder:"Введите дисциплины через Enter. Запятая остаётся в названии; несколько сразу — с новой строки",className:"spo-discipline-textarea",rows:3})]})]})}),e.jsx(ie,{header:"Редактирование дисциплины",visible:u,style:{width:"90vw",maxWidth:"520px"},className:"dashboard-crud-dialog",onHide:()=>y(!1),footer:e.jsx(ne,{onCancel:()=>y(!1),onSubmit:pe,submitLabel:"Сохранить",loading:Y.isLoading,disabled:!A.trim()}),children:e.jsx(z,{label:"Название *",value:A,onChange:i=>W(i.target.value),variant:"filled",onKeyDown:i=>i.key==="Enter"&&pe(),autoFocus:!0})})]})},Ze=t=>t?Dt(t,"dd.MM.yyyy"):void 0,et=t=>({book:{excluded:t.excluded,reissue_id:t.reissue_id,has_redirect_from_old:t.has_redirect_from_old,redirect_sources_count:t.redirect_sources_count,redirect_source_ids:t.redirect_source_ids}}),bs=()=>{const[t,s]=o.useState(1),[a,n]=o.useState(""),[l,p]=o.useState(null),[c,x]=o.useState(St(new Date,30)),[b,g]=o.useState(new Date),{mutate:P}=Ct(),_={page:t,start_date:Ze(c),end_date:Ze(b),...a.trim()?{name:a.trim()}:{},excluded:0},{data:k,isLoading:C}=rs(_),m=o.useMemo(()=>le(k,"books"),[k]),N=_t((u,y)=>{p(u),P({books_ids:[u],is_additional:y},{onSuccess:()=>{v({type:"success",message:y?"Книга переведена в дополнительную подписку":"Книга переведена в основную подписку"})},onError:()=>{v({type:"error",message:"Не удалось изменить тип подписки"})},onSettled:()=>p(null)})},l);return e.jsx(be,{title:"Новые поступления СПО",description:"Список новых книг каталога с назначением «Только для СПО» за выбранный период",filters:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(ze,{label:"Дата с",value:c,onChange:u=>{x(u.value),s(1)},className:"w-full"}),e.jsx(ze,{label:"Дата по",value:b,onChange:u=>{g(u.value),s(1)},className:"w-full"}),e.jsx(oe,{label:"Поиск",value:a,placeholder:"Название или автор",onChange:u=>{n(u),s(1)},showReset:!!a,onReset:()=>{n(""),s(1)}})]}),footer:m.total>0?e.jsx(Ne,{first:(t-1)*m.per_page,rows:m.per_page,totalRecords:m.total,onPageChange:u=>s(u.page+1),className:"border-0 p-0",template:"FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport",currentPageReportTemplate:"Всего: {totalRecords}"}):e.jsx("span",{className:"text-sm text-gray-600",children:"Нет записей"}),children:e.jsxs(re,{value:m.data,loading:C,dataKey:"id",emptyMessage:"За выбранный период Ð
1½Ð¾Ð²Ñ‹Ðµ книги СПО не найдены",className:"min-w-full p-datatable-sm",pt:Ee,rowClassName:u=>Ae(et(u)),children:[e.jsx(h,{field:"id",header:"ID",style:{width:"80px"},body:u=>e.jsx("a",{href:lt[ot.BOOK_DETAILS](u.id),target:"_blank",rel:"noreferrer",className:"text-sm font-mono hover:text-orange-500",children:u.id})}),e.jsx(h,{field:"title",header:"Название",body:u=>u.title??"—"}),e.jsx(h,{field:"authors",header:"Авторы",body:u=>u.authors??"—"}),e.jsx(h,{field:"publishers",header:"Издательство",body:u=>{var y;return((y=u.publishers)==null?void 0:y.trim())||"—"}}),e.jsx(h,{field:"year",header:"Год",body:u=>u.year??"—",style:{width:"80px"}}),e.jsx(h,{header:"Версия",body:N,style:{width:"160px"}}),e.jsx(h,{field:"created_at",header:"Дата поступления",body:u=>u.created_at??"—",style:{width:"160px"}}),e.jsx(h,{header:"Статус",body:u=>e.jsx(Re,{item:et(u)}),style:{minWidth:"180px"}})]})})},xs=({ugp:t,selectedProfileId:s,onSelect:a,onBack:n})=>{const[l,p]=o.useState(1),[c,x]=o.useState(""),[b,g]=o.useState(""),[P,_]=o.useState(null),[k,C]=o.useState(!1),[m,j]=o.useState(!1),[N,u]=o.useState(""),[y,O]=o.useState(""),[F,A]=o.useState(1),[W,r]=o.useState(!1),[M,q]=o.useState(null),[V,f]=o.useState(""),[E,Q]=o.useState(!1),[B,X]=o.useState(null),[Z,ce]=o.useState(""),[Y,de]=o.useState(""),{data:xe,isLoading:J}=$t({ugnp_id:t.id,is_hidden:k?1:0,...P!=null?{type:P}:{}
1,...b.trim()?{code:b.trim()}:{},...c.trim()?{name:c.trim()}:{}},!!t.id),ue=Ot(),G=Qt(),se=Kt(),fe=Vt(),ye=qt(),ke=Gt(),Ce=Ht(),K=o.useMemo(()=>{const d=le(xe,"profiles");return nt(d.data,l)},[xe,l]),Se=!!c||!!b||P!=null,De=()=>{x(""),g(""),_(null),p(1)},pe=()=>{y.trim()&&ue.mutate({ugnp_id:t.id,code:N.trim(),name:y.trim(),type:F},{onSuccess:()=>{v({type:"success",message:"Профессия СПО создана"}),u(""),O(""),A(1),j(!1)},onError:()=>{v({type:"error",message:"Ошибка при создании"})}})},we=d=>{q(d),f(d.name),r(!0)},me=()=>{!M||!V.trim()||G.mutate({profileId:M.id,body:{name:V.trim()}},{onSuccess:()=>{v({type:"success",message:"Профессия обновлена"}),r(!1),q(null)},onError:()=>{v({type:"error",message:"Ошибка при обновлении"})}})},ae=d=>{X(d),ce(""),de(`${d.name} (копия)`),Q(!0)},ge=()=>{!B||!Y.trim()||se.mutate({profileId:B.id,body:{code:Z.trim(),name:Y.trim()}},{onSuccess:()=>{v({type:"success",message:"Профессия скопирована"}),Q(!1),X(null)},onError:()=>{v({type:"error",message:"Ошибка при копировании"})}})},he=d=>{fe.mutate(d.id,{onSuccess:()=>{v({type:"success",message:"Список книг выгружен в Excel"})},onError:()=>{v({type:"error",message:"Ошибка при выгрузке"})}})},Te=d=>{Le({message:`Удалить профессию «${ve(d)}»? Её можно будет восстановить позже.`,header:"Подтверждение удаления",icon:"pi pi-exclamation-triangle",acceptLabel:"Удалить",rejectLabel:"Отмена",acceptClassName:"p-button-danger",accept:()=>{ye.mutate(d.id,{onSuccess:()=>{v({type:"success",message:"Профессия удалена"})},onError:()=>{v({type:"error",message:"Ошибка при удалении"})}})}})},i=d=>{Le({message:`Скрыть профессию «${ve(d)}»? Её можно будет восстановить позже.`,header:"Скрытие профессии",icon:"pi pi-eye-slash",acceptLabel:"Скрыть",rejectLabel:"Отмена",accept:()=>{ke.mutate(d.id,{onSuccess:()=>{v({type:"success",message:"Профессия скрыта"})},onError:()=>{v({type:"error",message:"Ошибка при скрытии"})}})}})},T=d=>{Ce.mutate(d.id,{onSuccess:()=>{v({type:"success",message:"Профессия восстановлена"})},onError:()=>{v({type:"error",message:"Ошибка при восстановлении"})}})},U=d=>e.jsxs("div",{className:"flex items-center gap-1 justify-center",children:[!k&&e.jsxs(e.Fragment,{children:[e.jsx(H,{icon:"pi-pencil",title:"Редактировать",onClick:()=>we(d)}),e.jsx(H,{icon:"pi-download",title:"Выгрузить книги (Excel)",onClick:()=>he(d)}),e.jsx(H,{icon:"pi-copy",title:"Копировать",onClick:()=>ae(d)}),e.jsx(H,{icon:"pi-eye-slash",title:"Скрыть",onClick:()=>i(d)}),e.jsx(H,{icon:"pi-trash",title:"Удалить",variant:"delete",onClick:()=>Te(d)})]}),k&&e.jsx(H,{icon:"pi-eye",title:"Восстановить",onClick:()=>T(d)})]});return e.jsxs(e.Fragment,{children:[e.jsx(Ue,{}),e.jsx("div",{className:"mb-4",children:e.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-2 text-sm text-gray-600 hover:text-gray-900 transition-colors",children:[e.jsx("i",{className:"pi pi-arrow-left text-xs"}),"Назад к УГП"]})}),e.jsx(be,{title:"Профессии СПО",description:`УГП: ${_e(t)}`,actions:k?void 0:e.jsx(Pe,{label:"Добавить профессию",onClick:()=>j(!0)}),filters:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(wt,{label:"Показать скрытые и удалённые",checked:k,onChange:d=>{C(!!d.checked),p(1)},className:"items-center"}),e.jsx(ee,{label:"Уровень",value:P,options:ds,onChange:d=>{_(d.value),p(1)},className:"w-full",variant:"filled"}),e.jsx(oe,{label:"Код",value:b,placeholder:"Поиск по коду",onChange:d=>{g(d),p(1)},showReset:!!b,onReset:()=>{g(""),p(1)}}),e.jsx(oe,{label:"Название",value:c,placeholder:"Поиск по Ð
1½Ð°Ð·Ð²Ð°Ð½Ð¸ÑŽ",onChange:d=>{x(d),p(1)},showReset:Se,onReset:De})]}),footer:K.total>0?e.jsx(Ne,{first:(l-1)*K.per_page,rows:K.per_page,totalRecords:K.total,onPageChange:d=>p(d.page+1),className:"border-0 p-0",template:"FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport",currentPageReportTemplate:"Всего: {totalRecords}"}):e.jsx("span",{className:"text-sm text-gray-600",children:"Нет записей"}),children:e.jsxs(re,{value:K.data,loading:J,dataKey:"id",selectionMode:"single",selection:K.data.find(d=>d.id===s)??null,onSelectionChange:d=>{d.value&&a(d.value)},onRowClick:d=>a(d.data),emptyMessage:k?"Скрытые и удалённые профессии не найдены":"Профессии не найдены. Добавьте первую профессию",className:"min-w-full p-datatable-sm",pt:Me,children:[e.jsx(h,{field:"code",header:"Код",style:{width:"140px"}}),e.jsx(h,{field:"name",header:"Наименование"}),e.jsx(h,{header:"Уровень",body:d=>Qe(d.type),style:{width:"160px"}}),e.jsx(h,{header:"Действия",body:U,style:{width:k?"100px":"190px"},bodyStyle:{textAlign:"center"}})]})}),e.jsx(ie,{header:"Создание профессии СПО",visible:m,style:{width:"90vw",maxWidth:"520px"},className:"dashboard-crud-dialog",onHide:()=>j(!1),footer:e.jsx(ne,{onCancel:()=>j(!1),onSubmit:pe,submitLabel:"Создать",loading:ue.isLoading,disabled:!y.trim(),loadingLabel:"Создание..."}),children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(ee,{label:"Уровень *",value:F,options:Oe,onChange:d=>A(d.value),className:"w-full",variant:"filled"}),e.jsx(z,{label:"Код",value:N,onChange:d=>u(d.target.value),placeholder:"09.02.07",variant:"filled"}),e.jsx(z,{label:"Наименование *",value:y,onChange:d=>O(d.target.value),placeholder:"Информационные системы и программирование",variant:"filled",onKeyDown:d=>d.key==="Enter"&&pe()})]})}),e.jsx(ie,{header:"Редактирование профессии СПО",visible:W,style:{width:"90vw",maxWidth:"520px"},className:"dashboard-crud-dialog",onHide:()=>r(!1),footer:e.jsx(ne,{onCancel:()=>r(!1),onSubmit:me,submitLabel:"Сохранить",loading:G.isLoading,disabled:!V.trim()}),children:e.jsx(z,{label:"Наименование *",value:V,onChange:d=>f(d.target.value),variant:"filled",onKeyDown:d=>d.key==="Enter"&&me(),autoFocus:!0})}),e.jsx(ie,{header:"Копирование профессии СПО",visible:E,style:{width:"90vw",maxWidth:"520px"},className:"dashboard-crud-dialog",onHide:()=>Q(!1),footer:e.jsx(ne,{onCancel:()=>Q(!1),onSubmit:ge,submitLabel:"Копировать",loading:se.isLoading,disabled:!Y.trim(),loadingLabel:"Копирование..."}),children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("p",{className:"text-sm text-gray-600",children:["Будут скопированы дисциплины и издания из профессии «",B?ve(B):"","»."]}),e.jsx(z,{label:"Код",value:Z,onChange:d=>ce(d.target.value),placeholder:"09.02.07",variant:"filled"}),e.jsx(z,{label:"Наименование *",value:Y,onChange:d=>de(d.target.value),variant:"filled",onKeyDown:d=>d.key==="Enter"&&ge()})]})})]})},fs=(t,s)=>a=>{const n=Number(a.type)===Fe,l=s===a.id;return e.jsxs("button",{type:"button",disabled:l,onClick:p=>{p.stopPropagation(),t(a.id,!n)},title:n?"Перевести в основную литературу":"Перевести в дополнительную литературу",className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors ${n?"bg-amber-100 text-amber-700 hover:bg-amber-200":"bg-gray-100 text-gray-600 hover:bg-gray-200"} ${l?"opacity-50 cursor-wait":"cursor-pointer"}`,children:[e.jsx("i",{className:`pi ${n?"pi-bookmark":"pi-book"} text-[10px]`}),n?"Доп.":"Основ."]})};function ys(t){return t?Fe:Ie}const js=ps,vs=[{label:"Все издания",value:null},{label:"Только для СПО",value:2}],Ps=[10,20,50,100],tt=new Date().getFullYear(),st=Array.from({length:tt-1969},(t,s)=>{const a=tt-s;return{label:String(a),value:a}});function _s(t){var s,a;return((s=t.publicationType)==null?void 0:s.name)??((a=t.publication_type)==null?void 0:a.name)??"—"}const Ns=({visible:t,onHide:s,discipline:a,addType:n,onAddTypeChange:l,onSubmit:p,isSubmitting:c})=>{const[x,b]=o.useState(0),[g,P]=o.useState(1),[_,k]=o.useState(20),[C,m]=o.useState([]),[j,N]=o.useState(null),[u,y]=o.useState(""),[O,F]=o.use
1State(""),[A,W]=o.useState([]),[r,M]=o.useState(null),[q,V]=o.useState(null),[f,E]=o.useState(null),[Q,B]=o.useState({}),[X,Z]=o.useState(!1),[ce,Y]=o.useState(!0),{data:de}=dt(),xe=o.useMemo(()=>le(de,"ugps").data.map(T=>({label:_e(T),value:T.id})),[de]),J=o.useMemo(()=>({page:g,per_page:_,...Q}),[g,_,Q]),ue=o.useMemo(()=>({page:g,per_page:_}),[g,_]),G=x===0,{data:se,isLoading:fe}=ls(a.id,J,t&&G&&X),{data:ye,isLoading:ke,isError:Ce}=os(a.id,a.name,ue,t&&!G),K=le(G?se:ye,"books");o.useEffect(()=>{t&&(N(null),y(""),F(""),W([]),M(null),V(null),E(null),B({}),Z(!1),Y(!0),P(1),k(20),m([]),b(0))},[t,a.id]);const Se=()=>{const i={};j&&(i.spo_ugp_id=j),u.trim()&&(i.title=u.trim()),O.trim()&&(i.publishers=O.trim()),A.length>0&&(i.publication_types_ids=A.map(T=>Number(T)).filter(T=>!Number.isNaN(T))),r&&(i.start_year=r),q&&(i.end_year=q),f&&(i.target_purpose_id=f),m([]),B(i),Z(!0),Y(!1),P(1)},De=()=>{N(null),y(""),F(""),W([]),M(null),V(null),E(null),B({}),Z(!1),Y(!0),m([]),P(1)},pe=i=>{P(i.page+1),k(i.rows),m([])},we=i=>{b(i),P(1),m([])},me=G?fe:ke,ae=G&&!X,ge=K.per_page||_,he=Number(K.total)||0,Te=!ae&&(he>0||K.data.length>0||K.last_page>1);return e.jsx(ie,{header:e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-medium text-gray-900",children:"Подбор изданий"}),e.jsxs("div",{className:"text-sm text-gray-500 font-normal mt-1",children:["Дисциплина: ",a.name]})]}),visible:t,style:{width:"95vw",maxWidth:"1200px"},className:`dashboard-crud-dialog ${R.dialog}`,onHide:s,footer:e.jsxs("div",{className:R.footer,children:[e.jsxs("div",{className:R.footerLeft,children:["Выбрано:"," ",e.jsx("strong",{className:"text-gray-900",children:C.length})]}),e.jsxs("div",{className:R.footerRight,children:[e.jsxs("div",{className:R.addTypeField,children:[e.jsx("span",{className:R.addTypeLabel,children:"Добавить как"}),e.jsx(ee,{value:n,options:js,onChange:i=>l(i.value),className:"w-full",variant:"filled"})]}),e.jsx(ne,{onCancel:s,onSubmit:()=>p(C),submitLabel:"Добавить",loading:c,disabled:C.length===0,loadingLabel:"Добавление..."})]})]}),children:e.jsxs("div",{className:R.body,children:[e.jsxs(Tt,{activeIndex:x,onTabChange:i=>we(i.index),className:R.tabView,children:[e.jsx(Je,{header:"Все книги",children:ce?e.jsxs("div",{className:R.filtersPanel,children:[e.jsxs("div",{className:R.filtersGrid,children:[e.jsx(ee,{label:"УГПС",value:j,options:xe,onChange:i=>N(i.value??null),placeholder:"Выберите УГПС",className:"w-full",variant:"filled",filter:!0,showClear:!0}),e.jsx(oe,{label:"Название",value:u,placeholder:"Введите название",onChange:y,showReset:!!u,onReset:()=>y("")}),e.jsx(oe,{label:"Издательство",value:O,placeholder:"Введите издательство",onChange:F,showReset:!!O,onReset:()=>F("")}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Тип издания"}),e.jsx("div",{className:R.classifierSelect,children:e.jsx(Lt,{placeholder:"Выберите тип издания",values:A,updateFn:i=>W(Array.isArray(i)?i:i?[i]:[])})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Год издания"}),e.jsxs("div",{className:R.yearRange,children:[e.jsx(ee,{value:r,options:st,onChange:i=>M(i.value??null),placeholder:"От",className:"w-full",variant:"filled",showClear:!0}),e.jsx(ee,{value:q,options:st,onChange:i=>V(i.value??null),placeholder:"До",className:"w-full",variant:"filled",showClear:!0})]})]}),e.jsx(ee,{label:"Все издания / Только для СПО",value:f,options:vs,onChange:i=>E(i.value??null),className:"w-full",variant:"filled"})]}),e.jsxs("div",{className:R.filtersActions,children:[e.jsx("button",{type:"button",className:"p-button-primary",onClick:Se,children:"Найти"}),e.jsx("button",{type:"button",className:"p-button-normal",onClick:De,children:"Очистить"})]})]}):e.jsx("div",{className:R.filtersCollapsedBar,children:e.jsxs("button",{type:"button",className:"p-button-normal",onClick:()=>Y(!0),children:[e.jsx("i",{className:"pi pi-sliders-h mr-2"}),"Фильтры"]})})}),e.jsx(Je,{header:"Автоподборка",children:e.jsxs("div",{className:R.autoHint,children:["Подбор релевантных изданий по наÐ
1·Ð²Ð°Ð½Ð¸ÑŽ и описанию дисциплины «",a.name,"». Результаты обновляются автоматически при переключении на этот таб."]})})]}),e.jsxs("div",{className:R.resultsSection,children:[e.jsxs("div",{className:R.resultsHeader,children:[e.jsx("h4",{className:R.resultsTitle,children:G?"Результаты поиска":"Автоподборка"}),!ae&&e.jsxs("span",{className:R.resultsMeta,children:["Найдено: ",he||K.data.length]})]}),e.jsx("div",{className:R.tableWrap,children:e.jsxs(re,{value:ae?[]:K.data,loading:me,dataKey:"id",selection:C,onSelectionChange:i=>m(i.value??[]),emptyMessage:ae?"Задайте фильтры и нажмите «Найти»":Ce&&!G?"Не удалось загрузить автоподборку из поискового API":"Подходящие издания не найдены",className:"min-w-full p-datatable-sm",pt:Ee,children:[e.jsx(h,{selectionMode:"multiple",headerStyle:{width:"3rem"}}),e.jsx(h,{field:"id",header:"ID",style:{width:"80px"}}
1),e.jsx(h,{field:"title",header:"Название",body:i=>i.title??"—"}),e.jsx(h,{field:"authors",header:"Авторы",body:i=>i.authors??"—"}),e.jsx(h,{field:"publishers",header:"Издательство",body:i=>i.publishers??"—"}),e.jsx(h,{field:"year",header:"Год",body:i=>i.year??"—",style:{width:"80px"}}),e.jsx(h,{header:"Версия",body:i=>$e({is_additional:i.is_additional}),style:{width:"150px"}}),e.jsx(h,{header:"Тип издания",body:i=>_s(i)})]})}),Te&&e.jsx("div",{className:R.pagination,children:e.jsx(Ne,{first:(g-1)*ge,rows:ge,totalRecords:Math.max(he,K.data.length),rowsPerPageOptions:Ps,onPageChange:pe,className:"border-0 p-0",template:"FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown CurrentPageReport",currentPageReportTemplate:"Всего: {totalRecords}"})})]})]})})},ks=us;function at(t){var s;return((s=t.book)==null?void 0:s.title)??"—"}function Cs(t){var s;return((s=t.book)==null?void 0:s.authors)??"—"}function Ss(t){var s,a;return((a=(s=t.book)==null?void 0:s.publishers)==null?void 0:a.trim())||"—"}function Ds(t){var s,a,n,l;return((a=(s=t.book)==null?void 0:s.publicationType)==null?void 0:a.name)??((l=(n=t.book)==null?void 0:n.publication_type)==null?void 0:l.name)??"—"}function ws(t){return Ae(t)}const Ts=({ugp:t,profile:s,discipline:a,onBack:n})=>{const[l,p]=o.useState(1),[c,x]=o.useState(Ie),[b,g]=o.useState(!1),[P,_]=o.useState(Ie),[k,C]=o.useState(null),m={page:l,profile_id:s.id,type:c},{data:j,isLoading:N}=ss(a.id,m),u=le(j,"publications"),y=u.active_total??u.total,O=is(),F=as(),A=ns(),r=fs((f,E)=>{const Q=ys(E),B=u.data.find(X=>X.id===f);C(f),A.mutate({disciplineId:a.id,body:{publication_link_id:f,type:Q},listParams:m,publication:B?{...B,type:Q}:void 0},{onSuccess:()=>{v({type:"success",message:E?"Издание переведено в дополнительную литературу":"Издание переведено в основную литературу"})},onError:()=>{v({type:"error",message:"Не удалось изменить тип издания"})},onSettled:()=>C(null)})},k),M=f=>{var Q;const E=f.publication_id??((Q=f.book)==null?void 0:Q.id)??f.id;Le({message:`Отвязать издание «${at(f)}» от дисциплины?`,header:"Подтверждение",icon:"pi pi-exclamation-triangle",acceptLabel:"Отвязать",rejectLabel:"Отмена",acceptClassName:"p-button-danger",accept:()=>{O.mutate({disciplineId:a.id,body:{publications_ids:[E]}},{onSuccess:()=>{v({type:"success",message:"Издание отвязано"})},onError:()=>{v({type:"error",message:"Ошибка при отвязке"})}})}})},q=f=>{f.length!==0&&F.mutate({disciplineId:a.id,body:{publications_ids:f.map(E=>E.id),type:P}},{onSuccess:()=>{v({type:"success",message:`Добавлено изданий: ${f.length}`}),g(!1)},onError:()=>{v({type:"error",message:"Ошибка при добавлении изданий"})}})},V=f=>e.jsx("div",{className:"flex items-center gap-1 justify-center",children:e.jsx(H,{icon:"pi-times",title:"Отвязать",variant:"delete",onClick:()=>M(f)})});return e.jsxs(e.Fragment,{children:[e.jsx(Ue,{}),e.jsx("div",{className:"mb-4",children:e.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-2 text-sm text-gray-600 hover:text-gray-900 transition-colors",children:[e.jsx("i",{className:"pi pi-arrow-left text-xs"}),"Назад к дисциплинам"]})}),e.jsx(be,{title:"Издания дисциплины",description:`${_e(t)} → ${ve(s)} → ${a.name}`,actions:e.jsx(Pe,{label:"Добавить издание",icon:"pi-plus",onClick:()=>{_(c),g(!0)}}),filters:e.jsx(ee,{label:"Тип публикаций",value:c,options:ks,onChange:f=>{x(f.value),p(1)},className:"w-full max-w-xs",variant:"filled"}),footer:u.total>0?e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 w-full",children:[e.jsxs("span",{className:"text-sm text-gray-600",children:["Всего: ",y]}),e.jsx(Ne,{first:(l-1)*u.per_page,rows:u.per_page,totalRecords:u.total,onPageChange:f=>p(f.page+1),className:"border-0 p-0",template:"FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink"})]}):e.jsx("span",{className:"text-sm text-gray-600",children:"Нет привязанных изданий"}),children:e.jsxs(re,{value:u.data,loading:N,dataKey:"id",rowClassName:ws,emptyMessage:"К этой дисциплине ещё не привязаны издания",className:"min-w-full p-datatable-sm",pt:Ee,children:[e.jsx(h,{header:"ID",body:f=>{var E;return f.publication_id??((E=f.book)==null?void 0:E.id)??f.id},style:{width:"80px"}}
1),e.jsx(h,{header:"Название",body:at}),e.jsx(h,{header:"Авторы",body:Cs}),e.jsx(h,{header:"Издательство",body:Ss}),e.jsx(h,{header:"Год",body:f=>{var E;return((E=f.book)==null?void 0:E.year)??"—"},style:{width:"80px"}}),e.jsx(h,{header:"Версия",body:f=>{var E;return $e({is_additional:(E=f.book)==null?void 0:E.is_additional})},style:{width:"150px"}}),e.jsx(h,{header:"Тип издания",body:Ds,style:{width:"160px"}}),e.jsx(h,{header:"Тип публикации",body:f=>r(f),style:{width:"120px"}}),e.jsx(h,{header:"Статус",body:f=>e.jsx(Re,{item:f}),style:{minWidth:"180px"}}),e.jsx(h,{header:"Действия",body:V,style:{width:"80px"},bodyStyle:{textAlign:"center"}})]})}),e.jsx(Ns,{visible:b,onHide:()=>g(!1),discipline:a,addType:P,onAddTypeChange:_,onSubmit:q,isSubmitting:F.isLoading})]})},it=[{id:"ugnps",label:"УГП",icon:"pi-sitemap"},{id:"profiles",label:"Профессии",icon:"pi-book"},{id:"disciplines",label:"Дисциплины",icon:"pi-list"},{id:"publications",label:"Издания",icon:"pi-file"}],Ls=({currentStep:t,ugpLabel:s,profileLabel:a,disciplineLabel:n,onStepClick:l})=>{const p=it.findIndex(x=>x.id===t),c={ugnps:s,profiles:a,disciplines:n};return e.jsx("div",{className:"bg-white rounded-xl shadow-sm border border-slate-200 p-4 mb-6",children:e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:it.map((x,b)=>{const g=x.id===t,P=b<p,_=b<=p;return e.jsxs(pt.Fragment,{children:[b>0&&e.jsx("i",{className:"pi pi-chevron-right text-slate-300 text-xs hidden sm:inline"}),e.jsxs("button",{type:"button",disabled:!_,onClick:()=>_&&l(x.id),className:["flex items-center gap-2 px-3 py-2 rounded-lg text-sm font-medium transition-colors",g?"bg-blue-50 text-blue-800 border border-blue-300 shadow-sm":P?"bg-slate-100 text-slate-800 hover:bg-slate-200 border border-slate-300":"bg-slate-50 text-slate-400 border border-slate-200 cursor-not-allowed"].join(" "),children:[e.jsx("i",{className:`pi ${x.icon} text-sm`}),e.jsx("span",{children:x.label}),c[x.id]&&e.jsxs("span",{className:"text-xs text-gray-500 max-w-[160px] truncate hidden md:inline",children:["— ",c[x.id]]})]})]},x.id)})})})},Is=({selectedUgpId:t,onSelect:s})=>{const[a,n]=o.useState(1),[l,p]=o.useState(""),[c,x]=o.useState(""),[b,g]=o.useState(!1),[P,_]=o.useState(""),[k,C]=o.useState(""),{data:m,isLoading:j}=dt(),N=At(),u=Mt(),y=o.useMemo(()=>{const r=le(m,"ugps");return r.total>0&&r.data.length===r.total?nt(r.data,a,{name:l,code:c}):r},[m,a,l,c]),O=!!l||!!c,F=()=>{!P.trim()||!k.trim()||N.mutate({code:P.trim(),name:k.trim()},{onSuccess:()=>{v({type:"success",message:"УГП создано"}),_(""),C(""),g(!1)},onError:()=>{v({type:"error",message:"Ошибка при создании УГП"})}})},A=r=>{Le({message:`Удалить УГП «${_e(r)}»? Удаление мягкое — данные профессий сохранятся.`,header:"Подтверждение удаления",icon:"pi pi-exclamation-triangle",acceptLabel:"Удалить",rejectLabel:"Отмена",acceptClassName:"p-button-danger",accept:()=>{u.mutate(r.id,{onSuccess:()=>{v({type:"success",message:"УГП удалено"})},onError:()=>{v({type:"error",message:"Ошибка при удалении"})}})}})},W=r=>e.jsx("div",{className:"flex items-center gap-1 justify-center",children:e.jsx(H,{icon:"pi-trash",title:"Удалить",variant:"delete",onClick:()=>A(r)})});return e.jsxs(e.Fragment,{children:[e.jsx(Ue,{}),e.jsx(be,{title:"УГП",description:"Укрупнённые группы профессий для среднего профессионального образования",actions:e.jsx(Pe,{label:"Добавить УГП",onClick:()=>g(!0)}),filters:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.jsx(oe,{label:"Код",value:c,placeholder:"Например, 09.00.00",onChange:r=>{x(r),n(1)}}),e.jsx(oe,{label:"Название",value:l,placeholder:"Поиск по названию",onChange:r=>{p(r),n(1)},showReset:O,onReset:()=>{p(""),x(""),n(1)}})]}),footer:y.total>0?e.jsx(Ne,{first:(a-1)*y.per_page,rows:y.per_page,totalRecords:y.total,onPageChange:r=>n(r.page+1),className:"border-0 p-0",template:"FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport",currentPageReportTemplate:"Всего: {totalRecords}"}):e.jsx("span",{className:"text-sm text-gray-600",children:"Нет записей"}),children:e.jsxs(re,{value:y.data,loading:j,dataKey:"id",selectionMode:"single",selection:y.data.find(r=>r.id===t)??null,onSelectionChange:r=>{r.value&&s(r.value)},onRowClick:r=>s(r.data),emptyMessage:"УГП не найдены. Добавьте первую запись",className:"min-w-full p-datatable-sm",pt:Me,children:[e.jsx(h,{field:"code",header:"Код",style:{width:"140px"}}
1),e.jsx(h,{field:"name",header:"Название"}),e.jsx(h,{header:"Действия",body:W,style:{width:"80px"},bodyStyle:{textAlign:"center"}})]})}),e.jsx(ie,{header:"Создание УГП",visible:b,style:{width:"90vw",maxWidth:"520px"},className:"dashboard-crud-dialog",onHide:()=>g(!1),footer:e.jsx(ne,{onCancel:()=>g(!1),onSubmit:F,submitLabel:"Создать",loading:N.isLoading,disabled:!P.trim()||!k.trim(),loadingLabel:"Создание..."}),children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(z,{label:"Код *",value:P,onChange:r=>_(r.target.value),placeholder:"09.00.00",variant:"filled"}),e.jsx(z,{label:"Название *",value:k,onChange:r=>C(r.target.value),placeholder:"Информатика и вычислительная техника",variant:"filled",onKeyDown:r=>r.key==="Enter"&&F()})]})})]})},Es=[{id:"manage",label:"Управление"},{id:"newBooks",label:"Новые поступления"},{id:"bookReport",label:"Отчёт по книге"},{id:"disciplineReport",label:"Отчёт по дисциплине"}],Rs=()=>{const[t,s]=o.useState("manage"),[a,n]=o.useState("ugnps"),[l,p]=o.useState(null),[c,x]=o.useState(null),[b,g]=o.useState(null),P=o.useCallback(m=>{p(m),x(null),g(null),n("profiles")},[]),_=o.useCallback(m=>{x(m),g(null),n("disciplines")},[]),k=o.useCallback(m=>{g(m),n("publications")},[]),C=o.useCallback(m=>{if(m==="ugnps"){n("ugnps"),x(null),g(null);return}if(m==="profiles"&&l){n("profiles"),g(null);return}if(m==="disciplines"&&l&&c){n("disciplines"),g(null);return}m==="publications"&&l&&c&&b&&n("publications")},[l,c,b]);return e.jsxs("div",{children:[e.jsx("div",{className:"flex flex-wrap gap-2 mb-6",children:Es.map(m=>e.jsx("button",{type:"button",onClick:()=>s(m.id),className:`px-4 py-2 rounded-lg text-sm font-medium transition-colors border ${t===m.id?"bg-slate-900 text-white border-slate-900":"bg-white text-slate-700 border-slate-300 hover:bg-slate-50"}`,children:m.label},m.id))}),t==="newBooks"&&e.jsx(bs,{}),t==="bookReport"&&e.jsx(ms,{}),t==="disciplineReport"&&e.jsx(gs,{}),t==="manage"&&e.jsxs(e.Fragment,{children:[e.jsx(Ls,{currentStep:a,ugpLabel:l?_e(l):void 0,profileLabel:c?ve(c):void 0,disciplineLabel:b==null?void 0:b.name,onStepClick:C}),a==="ugnps"&&e.jsx(Is,{selectedUgpId:(l==null?void 0:l.id)??null,onSelect:P}),a==="profiles"&&l&&e.jsx(xs,{ugp:l,selectedProfileId:(c==null?void 0:c.id)??null,onSelect:_,onBack:()=>C("ugnps")}),a==="disciplines"&&l&&c&&e.jsx(hs,{ugp:l,profile:c,selectedDisciplineId:(b==null?void 0:b.id)??null,onSelect:k,onBack:()=>C("profiles")}),a==="publications"&&l&&c&&b&&e.jsx(Ts,{ugp:l,profile:c,discipline:b,onBack:()=>C("disciplines")})]})]})};function Ma(){return e.jsxs(gt,{children:[e.jsx(mt,{children:e.jsx("title",{children:"Издания для СПО"})}),e.jsxs("div",{className:"dashboard-crud-page",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"font-medium text-lg text-mono m-0",children:"Издания для СПО"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1 mb-0",children:"Управление УГП, профессиями, дисциплинами и изданиями для среднего профессионального образования"})]}),e.jsx(Rs,{})]})]})}export{Ma as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.