PageSourceSearch

https://distant-nik.psychologos.ru/ContentForm.page.njk75g0n.js

js psychologos.ru collected 2026-10-02 04:59:50 UTC 37,962 bytes, 1 lines download raw bytes

1import{aY as M,bS as Q,e2 as ze,bU as pe,eT as Pe,eo as j,cR as h,eN as me,cb as We,f1 as V,cs as d,cp as t,i as F,T as G,U as Me,aj as S,J as he,az as k,ee as Qe,dm as B,ak as Se,v as Y,al as Ke,ei as Ne,eY as J,ef as De,b2 as Oe,et as Re,bX as Ue,R as Ae,cF as A,eA as je,es as Ge,ao as ke,u as ge,aX as He,S as z,d_ as Ye,eO as fe,cT as Je,cL as Ve,dX as Xe,ft as Ze,dx as et,cz as tt,dn as nt,br as it,bq as at,dw as st,dN as rt,eC as ot,cI as lt,bj as de,bn as Ie,bl as O,bm as D,bi as Fe,fs as U,x as ct,bu as dt,C as ut,eX as gt,c9 as Te,eQ as pt,bF as mt,a3 as Ee,g as ht,L as ft,an as bt,N as yt,b as vt,dZ as xt,dO as Be}from"./index.hjxr7fye.js";import{c as Ct}from"./changeContentWeight.query.37ojww99.js";import{V as _t}from"./ViewWeightInput.n6m12g2g.js";import{F as wt}from"./FileItem.icejrvkb.js";import{f as St,c as kt,m as It,a as Ft}from"./category.selectors.o7orurvj.js";import{I as Tt}from"./ImageInputFieldWidget.jzc6u0wv.js";import{u as Et}from"./contentList.nssogccl.js";import{F as Bt}from"./FileInput.eau10i0z.js";import{a as se,b as $e,u as Lt}from"./contentFormBreadcrumbs.fqgajpt1.js";import{h as Pt}from"./handleFormError.lf5y5ack.js";import{g as Wt}from"./getContentBySlug.query.pfnivoob.js";import{u as Nt}from"./useGetLearningDirectionGradeList.dgt2pv33.js";import"./urlParams.e4p3g7ih.js";function ue(e){return e.id}function Dt(e){return M.get(Q.accessLevels(ze(e))).then(pe)}function Rt(e,n){return M.post(Q.content(`/${e}/featured-contents/attach`),{content_ids:n})}function At(e,n,i){return M.post(Q.content(`/${e}/attach-file/${n}`),{title:i})}function Vt(e){return M.post(Q.content(`/${e}/copy`)).then(pe)}async function $t(e,n){return M.get(Q.contentViews(`/${e}?days=${n}`)).then(pe)}function qt(e,n){return M.delete(Q.content(`/${e}/featured-contents/detach`),{data:{content_ids:n}})}function zt(e,n){return M.post(Q.content(`/${e}/sync-categories`),{category_ids:n})}function Mt(e,n,i){return Pe({queryKey:["content-views",e,n],queryFn:()=>$t(e,n),...i})}function Qt(e){const n=j(),[i,s]=h.useState(2),[r,c]=h.useState(0),[a,o]=h.useState(void 0),[g,u]=h.useState(null),{refetch:l,isRefetching:p}=Mt(e,i,{enabled:!1,meta:{onSuccess(x){c(Number((x==null?void 0:x.view_weight)??0)),u(x==null?void 0:x.id)}}}),[v,f]=h.useState(!1),{mutate:m,isPending:C}=me({mutationFn:Ct}),_=()=>{g&&m({contentId:g,weight:a??1,days:i},{onSuccess(){c(a??1),n.success("Вес статьи сохранен")},onError(x){n.error(We(x,"Не удалось обновить вес статьи"))}})};return h.useEffect(()=>{o(r)},[r]),h.useEffect(()=>{f(r!==a)},[a,r]),h.useEffect(()=>{e&&l()},[i,e]),{days:i,setDays:s,weight:{set:o,get:()=>a??1},isDirty:v,isViewsLoading:p,isSaving:C,onViewWeightsSave:_}}const Kt=({className:e,slug:n})=>{V();const i=Ot(),{days:s,setDays:r,weight:c,isDirty:a,isViewsLoading:o,onViewWeightsSave:g,isSaving:u}=Qt(n);return d("div",{css:[i.EditViewWeights,e],children:[d("div",{css:i.header,children:[t("span",{css:i.label,children:"Популярность"}),d("div",{css:i.tabs,children:[t(F,{size:"small",type:"button",flat:!0,active:s===2,onClick:()=>r(2),children:"За 2 дня"}),t(F,{size:"small",type:"button",flat:!0,active:s===7,onClick:()=>r(7),children:"За неделю"})]})]}),d("div",{css:i.loading,children:[o&&t(Me,{position:"absolute",opacity:.3,children:t(G,{})}),t("div",{css:i.form,children:t(_t,{weight:c.get(),onChange:c.set,fieldProps:{className:i.weight,label:"Вес статьи"}})}),t("div",{css:i.actions,children:t(F,{flat:!0,type:"button",disabled:!a,processing:u,onClick:g,children:"Сохранить"})})]})]})},Ot=e=>({EditViewWeights:{},header:{display:"flex",alignItems:"center",gap:15},label:{fontWeight:500},tabs:{display:"flex",alignItems:"center",gap:10},loading:{position:"relative"},form:{margin:"20px 0 15px",width:"100%"},actions:{marginTop:20},weight:{width:130}}),Ut=({isInWarehouse:e,toggleInWarehouse:n,className:i,contentType:s,formMethods:{register:r,getValues:c,watch:a}})=>{const o=V(),g=!!c("text_inner"),u=a("is_decorative_views"),l=jt({theme:o,isOpacityWarehouseBtn:!g&&!e});return d("div",{css:[l.EditControl,i],children:[d("ul",{css:l.checkList,children:[t("li",{css:l.checkItem,children:t(S,{...r("is_active"),children:"Включено"})}),t("li",{css:l.checkItem,children:t(S,{...r("is_public"),children:"Публичный просмотр"})}),t("li",{css:l.checkItem,children:t(S,{...r("is_hidden"),helpInfo:d("div",{style:{maxWidth:300},children:["Если вы хотите скрыть материал из общих списков, и поиска установите этот флажок.",t("br",{}),t("br",{}),"Это может понадобиться, например, для игр."]}),children:"Скрыто"})}),t("li",{css:l.checkItem,children:t(S,{...r("is_club_proposal"),children:"Выводить предложение вступить в клуб"})}),t("li",{css:l.checkItem,children:t(S,{...r("is_attached"),children:"Закрепить вверху"})}),t("li",{css:l.checkItem,children:t(S,{...r("is_showcase"),children:"Выводить на витрину (блоки на главной странице)"})}),t("li",{css:l.checkItem,children:t(S,{...r("is_preview_permanent"),children:s.option_preview})}),t("li",{css:l.checkItem,children:t(S,{...r("is_contract_required"),
1children:"Контракт обязателен"})}),s.name!=="distance"&&t("li",{css:l.checkItem,children:t(S,{...r("is_free_passing"),helpInfo:d("div",{style:{maxWidth:300},children:["Если включить, то пользователь сможет проходить самостоятельно.",t("br",{}),"Отчеты будут приниматься сразу после сохранения.",t("br",{}),t("br",{}),'Если отключить эту опцию, то все материалы в статусе "Доступно"'," ",t("b",{children:'перейдут в статус "Заблокировано"'}),", даже те, которые в текущем уровне пользователя!",t("br",{}),"Это не затронет материалы, с которыми пользователь начал работу."]}),children:"Для свободного прохождения"})}),s.name==="sprint"&&t("li",{css:l.checkItem,children:t(S,{...r("is_extracurricular"),helpInfo:d("div",{style:{maxWidth:300},children:["Если включить, то пользователь сможет проходить самостоятельно.",t("br",{}),"Упражнения можно будет проходить в любом порядке. Отчеты будут приниматься сразу после сохранения."]}),children:"Внеурочный спринт"})}),s.name==="sprint"&&t("li",{css:l.checkItem,children:t(S,{...r("is_autocourse"),helpInfo:d("div",{style:{maxWidth:300},children:['Спринт попадет в отдельный раздел в Магазине - "Автокурсы", и в раздел Библиотеки на дистантнике – "Автокурсы". Задания, которые будут добавлены в авто-курс, можно найти отдельно в Библиотеке, в разделе ',t("b",{children:'"Задания к автокурсам"'}),t("br",{}),t("br",{}),"В остальном отличий нет. Все режимы прохождения и покупка остаются такими же.",t("br",{}),t("br",{}),"Этот флаг удобен для тех спринтов, которые редактируются крайне редко. В это случае есть смысл сделать спринт автокурсом."]}),children:"Автокурс"})}),s.name==="article"&&d(he,{children:[t("li",{css:l.checkItem,children:d(S,{...r("is_popular_block"),helpInfo:t("div",{style:{maxWidth:300},children:'Управляет выводом материала в блоках популярности "Популярные статьи", "Хиты недели" и пр., если отключить, то материал будет исключен из этих блоков'}),children:["Выводить в блоках",t("br",{})," популярности"]})}),t("li",{css:l.checkItem,children:t(S,{...r("is_recent_pin"),helpInfo:t("div",{style:{maxWidth:300},children:'Закрепляет статью в блоке "Новые статьи". Закрепленные статьи выводятся выше всех в этом блоке.'}),children:'Закрепить в "Новых статьях"'})}),d("li",{css:l.checkItem,children:[t(S,{...r("is_decorative_views"),helpInfo:t("div",{style:{maxWidth:300},children:"Отображаются вместо реальных просмотров"}),children:"Декоративные просмотры"}),u&&t(k,{children:t("input",{type:"number",min:0,step:1,...r("decorative_views"),css:l.decorativeViews})})]})]})]}),s.name==="article"&&t("div",{css:l.weights,children:t(Kt,{slug:c("slug")})}),t("div",{css:l.actions,children:t(F,{type:"button",onClick:n,color:"primary",flat:!0,className:l.skladBtn,children:e?"Редактор":"Склад"})})]})},jt=({theme:e,isOpacityWarehouseBtn:n})=>({EditControl:{background:e.pattern.main,borderRadius:5,padding:"5px 20px 20px"},heading:{fontSize:"1.125rem",fontWeight:"bold",margin:0,padding:"0 0 15px",borderBottom:`1px solid ${e.pattern.separator}`},checkList:{listStyle:"none",margin:"0 0 30px",padding:0},checkItem:{marginTop:20},weights:{marginBottom:20,paddingTop:20,borderTop:`1px solid ${e.pattern.separator}`},actions:{paddingTop:20,borderTop:`1px solid ${e.pattern.separator}`},skladBtn:{display:"block",width:"100%",backgroundColor:`${e.pattern.primary}${n?"44":""}`},decorativeViews:{marginTop:10,marginLeft:41,maxWidth:130}}),Gt=({slug:e,className:n})=>{const i=V(),s=Yt(i),r=Qe(),c=r.can("manage","distance_level")&&t(Se,{routeLink:e?B.editDistanceLevels.url({slug:e}):"#",color:"primary",flat:!0,className:s.moveBtn,children:"Уровни"}
1,1),a=r.can("add_task","sprint")&&t(Se,{routeLink:e?B.editSprintTasks.url({slug:e}):"#",color:"primary",flat:!0,className:s.moveBtn,children:"Задачи"},2),o=[c,a];return o.every(Ht)?null:d("div",{css:[s.EditActions,n],children:[t("h2",{css:s.heading,children:"Управление"}),t("div",{css:s.actions,children:o})]})},Ht=e=>!e,Yt=e=>({EditActions:{background:e.pattern.main,borderRadius:5,padding:"15px 20px 20px"},heading:{fontSize:"1.125rem",fontWeight:"bold",margin:0,padding:"0 0 15px",borderBottom:`1px solid ${e.pattern.separator}`},actions:{paddingTop:20,display:"grid",gridGap:"10px"},moveBtn:{display:"block",width:"100%"}}),Jt=({control:e,setValue:n,getValues:i})=>{const[s,r]=h.useState(i("days_to_pass_min")||0),[c,a]=h.useState(i("days_to_pass_max")||0),o=(u,l)=>{const p=+u.target.value;return r(p),p>c&&requestAnimationFrame(()=>n("days_to_pass_max",p+1)),l(u)},g=(u,l)=>{const p=+u.target.value;return a(p),+u.target.value<s&&requestAnimationFrame(()=>n("days_to_pass_min",Math.max(0,p-1))),l(u)};return d(he,{children:[t(Y,{name:"days_to_pass_min",control:e,render:({field:{onBlur:u,value:l,...p}})=>t(k,{label:"Минимум дней на прохождение",children:t("input",{value:l||"",type:"number",id:"title",onBlur:v=>o(v,u),...p})})}),t(Y,{name:"days_to_pass_max",control:e,render:({field:{onBlur:u,value:l,...p}})=>t(k,{label:"Максимум дней на прохождение",children:t("input",{value:l||"",type:"number",id:"title",onBlur:v=>g(v,u),...p})})})]})},Xt=({className:e,contentType:n,defaultContent:i,formMethods:s})=>{const r=V(),c=Zt(r),{setValue:a,getValues:o,control:g}=s;return d("div",{css:[c.EditAdditional,e],children:[t(Y,{name:"parent_content_id",control:g,render:u=>t(Ke,{label:`${n.attribute_parent_content_id}:`,onChange:u.field.onChange,defaultContent:i==null?void 0:i.parent_content,excludeContent:i&&[i]})}),t(Jt,{control:g,setValue:a,getValues:o})]})},Zt=e=>({EditAdditional:{background:e.pattern.main,borderRadius:5,padding:"20px 20px 1px"},themeSearchList:{listStyle:"none",padding:0,margin:"-15px 0 20px","&:empty":{display:"none"}}});function en(){return Ne(({can:e},{findRule:n})=>{n("create","category")&&e("create","category")})}function tn(){const e=J(St),[n,i]=h.useState(""),[s,r]=h.useState({includes:[]}),c=a=>{i(a.target.value??"")};return h.useEffect(()=>{r(e(n))},[n,e]),{searchResult:s,handleChangeSearch:c,searchText:n}}function nn(e,n,i){const s=j(),[r,c]=h.useState(!1),a=De(Oe.addTopLevelCategory),o=()=>{e.searchText.length<3||i.cannot("create","category")||(c(!0),kt(e.searchText).then(l=>{a(l),n.addCategory(It(l))}).catch(()=>s.error("Произошла ошибка при создании новой категории")).finally(()=>c(!1)))},g=()=>{const l=e.searchResult.strictMatch;l?n.addCategory(l):o()};return{handleKeyPress:l=>{l.key==="Enter"&&(l.preventDefault(),g())},loading:r}}function an(e,n){const i=a=>!!e.find(o=>(o==null?void 0:o.id)===(a==null?void 0:a.id)),s=a=>{n(e.filter(o=>(o==null?void 0:o.id)!==a))},r=a=>{i(a)||n([...e,a])};return{selectedList:e,removeCategory:s,addCategory:r,toggleCategory:a=>{i(a)?s(a.id):r(a)},isItemInSelectedList:i}}const sn=(e=[],n)=>{const i=Re(),s=J(Ft),r=en(),c=an(e,n),a=tn(),{handleKeyPress:o,loading:g}=nn(a,c,r);return h.useEffect(()=>{s.length||i(Ue())},[s]),{categoriesList:c,search:a,handleSearchKeyPress:o,loading:g}},rn=e=>(n,i)=>i<e,on=({className:e,label:n,onChange:i,value:s})=>{const r=V(),c=ln(r),{handleSearchKeyPress:a,categoriesList:o,search:g,loading:u}=sn(s,i);return d("div",{css:[c.CategoriesField,e],children:[d("div",{css:c.top,children:[n&&t("label",{css:c.label,children:n}),d("div",{css:c.selectedList,children:[o.selectedList.map(l=>d("div",{css:c.selectedItem,children:[l.name,t("button",{css:c.removeBtn,onClick:()=>o.removeCategory(l.id),children:t("img",{src:"/images/close.svg",alt:"Убрать из категорий"})})]},l.id)),u&&t(G,{className:c.createLoading,size:20,flexAlign:"start",block:!0})]}),t(Ae,{to:"/categories",css:c.link,children:"Поиск по категориям"})]}),d("div",{css:c.bottom,children:[t(k,{search:!0,children:t("input",{type:"text",placeholder:"Поиск по категориям",value:g.searchText,onChange:g.handleChangeSearch,onKeyPress:a})}),t("div",{css:c.searchList,children:g.searchResult.includes.filter(l=>typeof(l==null?void 0:l.target_id)!="number").filter(rn(10)).map(l=>t("button",{css:[c.searchItem,o.isItemInSelectedList(l)&&c.active],onClick:()=>o.toggleCategory(l),type:"button",children:l.name},l.id))})]})]})},ln=e=>({CategoriesField:{},top:{display:"flex",alignItems:"flex-start",[A]:{display:"block"}},createLoading:{marginTop:2,marginLeft:6,marginRight:6},bottom:{},label:{fontWeight:500,marginRight:10,marginBottom:10,flexShrink:0,"&:empty":{display:"none"},[A]:{display:"block",marginBottom:10}},selectedList:{marginTop:-2,marginBottom:5,display:"flex",flexWrap:"wrap",alignItems:"center"},selectedItem:{margin:"0 10px 5px 0",background:e.pattern.second,borderRadius:5,padding:"5px 40px 5px 10px",fontSize:"0.75rem",color:e.pattern.main,position:"relative",textTransform:"uppercase"},searchList:{marginTop:-7,marginBottom:20,"&:empty":{display:"none"}},link:{display:"inline-block",whiteSpace:"nowrap",marginTop:3,marginBottom:10,fontSize:"0.75rem",fontWeight:500,textTransform:"uppercase",textDecoration:"underline",flexShrink:0,"&:hover":{textDecoration:"none"}},removeBtn:{position:"absolute",background:"none",border:0,margin:0,padding:0,r
1ight:8,top:"50%",transform:"translateY(-50%)",cursor:"pointer","& img":{display:"block",width:10,height:10,filter:"invert(1)"}},searchItem:{margin:"0 10px 5px 0",border:`1px solid ${e.pattern.second}`,background:"none",borderRadius:5,padding:"4px 9px",fontSize:"0.75rem",color:e.pattern.font,textTransform:"uppercase",fontFamily:e.font,transition:"all .2s",cursor:"pointer","&:hover":{color:e.pattern.main,background:e.pattern.second}},active:{color:e.pattern.main,background:e.pattern.second}});function cn(e){return[4,8].includes(typeof e=="number"?e:e.id)}function qe(e){return!cn(e)}function dn(){const[e,n]=h.useState(""),{data:i,isRefetching:s,refetch:r}=Et({title:e},{enabled:!1}),c=a=>{n(a.target.value??"")};return h.useEffect(()=>{e.trim()!==""&&r()},[e]),{searchResult:(i==null?void 0:i.data)??[],handleChangeSearch:c,searchText:e,loading:s}}function un(e,n){const i=a=>!!e.find(o=>(o==null?void 0:o.id)===(a==null?void 0:a.id)),s=a=>{n(e.filter(o=>(o==null?void 0:o.id)!==a))},r=a=>{i(a)||n([...e,a])};return{selectedList:e,removeContent:s,addContent:r,toggleContent:a=>{i(a)?s(a.id):r(a)},isItemInSelectedList:i}}const gn=(e=[],n)=>
1{const i=un(e,n),{loading:s,...r}=dn();return{featuredContentList:i,search:r,loading:s}},pn=e=>(n,i)=>i<e,mn=({className:e,label:n,onChange:i,value:s})=>{const r=V(),c=hn(r),{featuredContentList:a,search:o,loading:g}=gn(s,i);return d("div",{css:[c.CategoriesField,e],children:[d("div",{css:c.top,children:[n&&t("label",{css:c.label,children:n}),d("div",{css:c.selectedList,children:[a.selectedList.map(u=>d("div",{css:c.selectedItem,children:[u.title,t("button",{css:c.removeBtn,onClick:()=>a.removeContent(u.id),children:t("img",{src:"/images/close.svg",alt:"Убрать из списка"})})]},u.id)),g&&t(G,{className:c.createLoading,size:20,flexAlign:"start",block:!0})]})]}),d("div",{css:c.bottom,children:[t(k,{search:!0,children:t("input",{type:"text",placeholder:"Поиск по материалам",value:o.searchText,onChange:o.handleChangeSearch})}),t("div",{css:c.searchList,children:o.searchResult.filter(pn(10)).map(u=>t("button",{css:[c.searchItem,a.isItemInSelectedList(u)&&c.active],onClick:()=>a.toggleContent(u),type:"button",children:u.title},u.id))})]})]})},hn=e=>({CategoriesField:{},top:{display:"flex",alignItems:"flex-start",[A]:{display:"block"}},createLoading:{marginTop:2,marginLeft:6,marginRight:6},bottom:{},label:{fontWeight:500,marginRight:10,marginBottom:10,flexShrink:0,"&:empty":{display:"none"},[A]:{display:"block",marginBottom:10}},selectedList:{marginTop:-2,marginBottom:5,display:"flex",flexWrap:"wrap",alignItems:"center"},selectedItem:{margin:"0 10px 5px 0",background:e.pattern.second,borderRadius:5,padding:"5px 40px 5px 10px",fontSize:"0.75rem",color:e.pattern.main,position:"relative",textTransform:"uppercase"},searchList:{marginTop:-7,marginBottom:20,"&:empty":{display:"none"}},link:{display:"inline-block",whiteSpace:"nowrap",marginTop:3,marginBottom:10,fontSize:"0.75rem",fontWeight:500,textTransform:"uppercase",textDecoration:"underline",flexShrink:0,"&:hover":{textDecoration:"none"}},removeBtn:{position:"absolute",background:"none",border:0,margin:0,padding:0,right:8,top:"50%",transform:"translateY(-50%)",cursor:"pointer","& img":{display:"block",width:10,height:10,filter:"invert(1)"}},searchItem:{margin:"0 10px 5px 0",border:`1px solid ${e.pattern.second}`,background:"none",borderRadius:5,padding:"4px 9px",fontSize:"0.75rem",color:e.pattern.font,textTransform:"uppercase",fontFamily:e.font,transition:"all .2s",cursor:"pointer",textAlign:"left","&:hover":{color:e.pattern.main,background:e.pattern.second}},active:{color:e.pattern.main,background:e.pattern.second}});function fn(e){const n=j();return me({mutationFn:i=>At(i.slug,i.id,i.name),onError(i){n.error(We(i,"Не удалось добавить файл"))},...e})}const bn=({contentTypeSelect:e,isLoading:n,className:i,contentType:s,accessLevels:r,learningDirectionGrades:c,userSettings:a,formMethods:o,slug:g})=>{var Z,ee,te,H,ne,ie,b,N;const u=V(),l=vn(u),{control:p,register:v,formState:{errors:f},watch:m}=o,C=m("files"),[_,x]=h.useState([]),[T,E]=h.useState(null),{mutateAsync:L,isPending:K}=fn(),{handleChangeFile:P,loadingCreate:re}=je({testFileType:()=>!0,uploadErrorMessage:"Что-то пошло не так.",chunked:!0},y=>{y&&g&&L({slug:g,id:y.id,name:y.name||y.filename}).then(()=>{x(w=>[...w,y])})}),{mutate:X,isPending:$}=Ge(),oe=y=>{y&&(E(y.id),X(y,{onSuccess(){x(_.filter(w=>w.id!==y.id))},onSettled(){E(null)}}))};function W(y){const w=y.target.files;if(w)for(let q=0;q<w.length;q++)_.some(ae=>ae.name===w[q].name)||P(w[q])}return h.useEffect(()=>{C&&x(C)},[C]),d("div",{css:[l.EditVisual,i],children:[e,t(ke,{required:!0,options:(r==null?void 0:r.map(y=>({label:y.name,value:y.id})))??[],label:"Уровень доступа:",message:(Z=f==null?void 0:f.access_level_id)==null?void 0:Z.message,name:"access_level_id",control:p}),t(ke,{options:(c==null?void 0:c.map(y=>({label:y.label,value:y.id})))??[],label:"Только для завершивших курс:",message:(ee=f==null?void 0:f.access_level_id)==null?void 0:ee.message,name:"min_completed_grade_id",control:p}),t(k,{label:`${s.attribute_title}:`,message:(te=f==null?void 0:f.title)==null?void 0:te.message,required:!0,children:t("input",{type:"text",id:"title",...v("title")})}),t(k,{label:"Цена (руб.)",message:(H=f==null?void 0:f.price)==null?void 0:H.message,children:t("input",{onWheel:y=>y.currentTarget.blur(),type:"number",id:"price",min:0,disabled:(ne=o.getValues())==null?void 0:ne.origin_content,placeholder:(ie=o.getValues())!=null&&ie.origin_content?"Это копия, копия не может продаваться в магазине":"",...v("price")})}),t(k,{label:"Название админ.:",message:(b=f==null?void 0:f.title_inner)==null?void 0:b.message,children:t("input",{type:"text",id:"title_inner",...v("title_inner")})}),qe(s)&&d(he,{children:[t(k,{label:`${s.attribute_preview}:`,message:(N=f==null?void 0:f.preview)==null?void 0:N.message,required:!0,children:t(ge,{isSyncBlocked:n,config:{height:200,...yn()},name:"preview",control:p})}
1),t(k,{children:t(Tt,{control:p,fileName:"preview_image",fileNameId:"preview_image_id",className:l.fileInput,label:"Добавить фото:"})})]}),t(Y,{name:"categories",control:p,render:({field:{onChange:y,value:w}})=>t(on,{label:"Категории:",className:l.categories,onChange:y,value:w})}),t(Y,{name:"featured_contents",control:p,render:({field:{onChange:y,value:w}})=>t(mn,{label:"Материалы по теме:",className:l.categories,onChange:y,value:w})}),t(k,{label:"Автор:",children:t(ge,{name:"author_overrides",isSyncBlocked:n,config:{height:100,...He()},control:p,placeholder:typeof(a==null?void 0:a.author_overrides)=="string"?a.author_overrides:""})}),d("div",{children:[d("div",{css:l.filesInput,children:[t("label",{css:l.filesInputLabel,children:"Добавить файлы:"}),t(G,{show:re===z.pending||K,size:14,border:2,children:t(Bt,{className:l.filesInputInput,name:"files",multiple:!0,hideNames:!0,buttonLabel:"ВЫБЕРИТЕ ФАЙЛ(Ы)",onChange:W})})]}),t("div",{css:l.filesList,children:_.map(y=>t(wt,{file:y,deleting:T===y.id&&$,onRemove:oe},y.id))})]})]})},yn=()=>({toolbarGroups:[{name:"document",groups:["mode","document","doctools"]},{name:"clipboard",groups:["clipboard","undo"]},{name:"editing",groups:["find","selection","spellchecker","editing"]},{name:"forms",groups:["forms"]},{name:"basicstyles",groups:["basicstyles","cleanup"]},{name:"paragraph",groups:["list","indent","blocks","align","bidi","paragraph"]},{name:"links",groups:["links"]},{name:"insert",groups:["insert"]},{name:"style:ws",groups:["styles"]},{name:"colors",groups:["colors"]},{name:"tools",groups:["tools"]},{name:"others",groups:["others"]}],removeButtons:"Save,ExportPdf,NewPage,Print,ShowBlocks,Maximize,BGColor,TextColor,Templates,Find,Replace,SelectAll,Scayt,Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField,Str
1ike,Subscript,Superscript,RemoveFormat,CopyFormatting,Outdent,Indent,BulletedList,NumberedList,Blockquote,CreateDiv,JustifyLeft,JustifyCenter,JustifyRight,JustifyBlock,BidiLtr,BidiRtl,Language,Image,Flash,Table,HorizontalRule,Smiley,SpecialChar,PageBreak,Iframe,Styles,Format,FontSize,Font,Preview"}),vn=e=>({EditVisual:{background:e.pattern.main,borderRadius:5,padding:"30px 50px",[Ye]:{padding:20}},fileInput:{marginTop:-7,marginBottom:20},categories:{marginTop:25},mb0:{marginBottom:0},filesInput:{display:"flex",alignItems:"center"},filesInputLabel:{marginRight:15,fontWeight:500},filesInputInput:{height:15},filesList:{marginTop:15,display:"flex",flexDirection:"column",gap:10,"&:empty":{display:"none"}}});function xn(e){return Ne(({can:n},{findRule:i},s)=>{var v,f,m;const r=((v=e==null?void 0:e.author)==null?void 0:v.id)===(s==null?void 0:s.id);i("create","content")&&n("create","content");const a=i("update","content");(f=a==null?void 0:a.conditions)!=null&&f.own?n("update","content",{author_id:s==null?void 0:s.id}):a&&n("update","content");const o=(e==null?void 0:e.content_type.name)==="distance",g=i("manage","distance_level");o&&g&&(!((m=g==null?void 0:g.conditions)!=null&&m.own)||r)&&n("manage","distance_level");const u=(e==null?void 0:e.content_type.name)==="sprint",l=i("add_task","
1sprint",{own:!1}),p=i("add_task","sprint",{own:!0});u&&(l||p&&r)&&n("add_task","sprint")},[e])}const Cn=()=>{const e=fe(),n=Re();return async i=>{try{const s=await Je(i);e(B.contentList.url({pluralContentTypeName:Ve(s.content_type.name)}),{replace:!0}),n(Xe(`Контент "${s.title}" удален!`))}catch(s){n(Ze(s.message))}}},_n=()=>{const e=Cn(),{slug:n}=se();return()=>{if(n&&window.confirm("Вы уверены что хотите удалить?"))return e(n)}},be=e=>{const n=J(et)(e),i=De(tt.setLoader),s=h.useCallback(()=>i({name:e,loading:z.pending}),[e,i]),r=h.useCallback(()=>i({name:e,loading:z.failed}),[e,i]),c=h.useCallback(()=>i({name:e,loading:z.idle}),[e,i]),a=h.useMemo(()=>({isPending:n===z.pending,isError:n===z.failed,isIdle:n===z.idle}),[n]),o=h.useMemo(()=>({pending:s,failed:r,idle:c}),[r,c,s]);return[a,o]};var R=(e=>(e.none="none",e.redirectPreview="redirectPreview",e.redirectEdit="redirectEdit",e.reFetchDefaultContent="reFetchDefaultContent",e))(R||{});function wn(e,n,i){const{slug:s}=se(),r=j(),[,c]=be("EDIT_FORM_SAVE"),a=fe(),o=$e();return(g="none")=>e.handleSubmit(async({categories:u=[],featured_contents:l=[],...p})=>{var f;const v={...p};o&&(v.content_type_id=o.id),v.is_decorative_views||(v.decorative_views=null,delete v.is_decorative_views);try{c.pending();const m=await nt(v,s),C=((f=n==null?void 0:n.featured_contents)==null?void 0:f.map(ue))??[],_=(l==null?void 0:l.map(ue))??[],x=C.filter(E=>!_.includes(E)),T=_.filter(E=>!C.includes(E));await zt(m.slug,u.map(ue)),x.length>0&&await qt(m.slug,x),T.length>0&&await Rt(m.slug,T),r.success(s?"Сохранено":"Добавлено"),g==="redirectEdit"&&a(it(m)),g==="redirectPreview"&&a(at(m)),g==="reFetchDefaultContent"&&i()}catch(m){c.failed(),Pt(m,e.setError,()=>{var C,_;r.warn((_=(C=m==null?void 0:m.response)==null?void 0:C.data)==null?void 0:_.message,1e4)})}finally{c.idle()}})}function Sn(){const[e,n]=h.useState(!1);return{isInWarehouse:e,toggleInWarehouse:()=>{n(s=>!s)}}}function kn(){const{slug:e}=se(),[n,i]=h.useState(),[s,r]=be("EDIT_FORM_DEFAULT_CONTENT"),c=j(),a=()=>{e&&(r.pending(),Wt(e).then(i).then(r.idle).catch(o=>{r.failed(),c.warn(o.message)}))};return h.useEffect(a,[e,c,r]),[n,s,a]}function In({reset:e},n){h.useEffect(()=>{requestAnimationFrame(()=>{n&&e({...n,is_decorative_views:typeof(n==null?void 0:n.decorative_views)=="number"})})},[n,e])}function Fn(e,n){return Pe({queryKey:["access_levels"],queryFn:()=>Dt(e),...n})}function Tn(e,n){const i=J(st),s=fe(),r=i.map(o=>({value:o.name,label:o.title})),c=n?{value:n.name,label:n.title}:null;return{options:r,value:c,onChange:o=>{if(!o)return;const g=Ve(o.value),u=e?B.editContent.url({pluralContentTypeName:g,slug:e}):B.createContent.url({pluralContentTypeName:g});s(u)}}}const En=de().shape({content_type_id:O().positive().required(),access_level_id:O().positive().required(),title:D().max(100,U.max+100).required(U.required),title_inner:D().max(100,U.max+100).nullable().default(""),price:O().min(0,U.minNumber+0).transform((e,n)=>isNaN(n)?null:Number(n)).nullable(),preview:D().when("content_type_id",{is:qe,then:e=>e.required(U.required),otherwise:e=>e.nullable().default("")}),text:D().required(U.required).default(""),text_inner:D().optional().nullable().default(""),categories:Fe().of(de().shape({id:O(),name:D()}).default([])),featured_contents:Fe().of(de().shape({id:O(),title:D()}).default([])),parent_content_id:D().nullable(),is_decorative_views:Ie(),decorative_views:O().nullable(),is_active:Ie()}),Bn=()=>{const{slug:e}=se(),n=J(rt),i=j(),[s,r,c]=kn(),a=xn(s),o=$e(),g=ot({resolver:lt(En),defaultValues:{is_active:!0,is_decorative_views:!1}}),{mutate:u,isPending:l}=me({mutationFn:Vt,onSuccess(L){window.location.href=B.content.url({slug:L.slug,pluralContentTypeName:void 0})},onError(L){var K;i.error((((K=L.response)==null?void 0:K.data)||L).message)}}),p=wn(g,s,c),v=_n(),f=Sn(),[m]=be("EDIT_FORM_SAVE"),C=!!e,_=Tn(e,o),x=Lt(o,s),{data:T}=Fn(),{data:E}=Nt();return In(g,s),h.useEffect(()=>{g.register("text")},[]),{contentFormAbility:a,slug:e,contentType:o,copyContent:u,createSubmit:p,deleteContent:v,isEdit:C,isCopying:l,formMethods:g,loadingDefaultContent:r,loadingSave:m,warehouse:f,defaultContent:s,contentTypeSelect:_,breadcrumbs:x,accessLevels:T==null?void 0:T.data,learningDirectionGrades:E??[],userSettings:n}}
1,Ln="/ckeditor/ckeditor.js",Le=({initData:e,onBlur:n,onChange:i,onSave:s,changeReboundDelay:r=400,...c})=>{const[a,o]=h.useState(!1);let g;const u=p=>{clearTimeout(g),g=setTimeout(()=>{i==null||i(p.editor.getData())},r)},l=p=>{n==null||n(p.editor.getData())};return h.useEffect(()=>{let p;return a?p&&clearInterval(p):p=setInterval(()=>{console.log("process..."),window.CKEDITOR&&o(!0)},100),()=>{p&&clearInterval(p)}},[a]),a?t(ut,{initData:e||"",editorUrl:Ln,onChange:u,onBlur:l,onSave:s,onMode:p=>{const v=p.editor;if(v.mode==="source"){const f=v.editable();f.attachListener(f,"input",function(){u(p)})}},config:{extraPlugins:["media","tabs","banners",s?"allowsave":""],removePlugins:["image",s?"":"save"],contentsCss:["/css/ckeditor-tabs.css","/ckeditor/contents.css"],mediaApi:{createFileQuery:dt,DEFAULT_CHUNK_BYTES_SIZE:ct}},...c}):t(G,{})},Un=()=>{var w,q,ae,ye,ve,xe,Ce;const[e,n]=gt(),{contentType:i,copyContent:s,createSubmit:r,deleteContent:c,isCopying:a,isEdit:o,slug:g,formMethods:u,warehouse:{toggleInWarehouse:l,isInWarehouse:p},loadingDefaultContent:v,loadingSave:f,defaultContent:m,contentFormAbility:C,contentTypeSelect:_,breadcrumbs:x,accessLevels:T,learningDirectionGrades:E,userSettings:L}=Bn(),{register:K,formState:{errors:P},control:re,setValue:X}=u;if(!i)throw new Error("error");const[$,oe]=h.useState(!!(Te("contentShowVisualPanel")??!0)),[W,Z]=h.useState(!!(Te("contentShowEditPanel")??!0)),{title:ee}=pt((o?i.edit_title:i.add_title)??""),te=I=>{I.preventDefault(),oe(!$),Be("contentShowVisualPanel",!$)},H=I=>{I.preventDefault(),Z(!W),Be("contentShowEditPanel",!W)},ne=I=>{I.preventDefault(),m&&s(m.slug)},ie=V(),b=Pn({theme:ie,isInWarehouse:p,showEditPanel:W}),N=h.useRef(null);h.useEffect(()=>{const I=e.get("warehouse");let le;return I&&(N!=null&&N.current)&&(p||l(),le=setTimeout(()=>{var _e,we;let ce=((we=(_e=N.current)==null?void 0:_e.getBoundingClientRect())==null?void 0:we.top)??0;ce&&(ce+=window.scrollY-80,window.scroll({top:ce,behavior:"smooth"}),e.delete("warehouse"),n(e))},800)),()=>{le&&clearTimeout(le)}},[e,l,p]);const y=({className:I})=>d("div",{css:[b.actions,I],children:[t("div",{css:b.leftActions,children:o&&d(F,{type:"button",variant:"outline",color:"primary",flat:!0,className:b.removeBtn,onClick:c,children:[i.delete_title,t("img",{src:"/images/remove2.svg",alt:"",width:17})]})}),d("div",{css:b.rightActions,children:[t(F,{flat:!0,variant:"outline",color:"primary",onClick:ne,processing:f.isPending||a,disabled:!1,children:"Сделать копию"}),t(F,{variant:"outline",color:"primary",flat:!0,processing:f.isPending||a,onClick:r(o?R.reFetchDefaultContent:R.redirectEdit),children:"Сохранить и продолжить"}),t(F,{onClick:r(R.redirectPreview),color:"primary",flat:!0,processing:f.isPending||a,children:"Сохранить"})]})]});if(o){if(m&&C.cannot("update",mt("content",m)))return t(Ee,{to:B.home.url(),replace:!0})}else if(C.cannot("create","content"))return t(Ee,{to:B.home.url(),replace:!0});return t(vt,{ability:C,children:t("div",{css:b.EditContent,children:d(yt,{children:[t(ht,{list:x}),!W&&d(F,{size:"medium",flat:!0,className:b.toggleBtn,onClick:H,children:[t("img",{src:"/images/settings.svg",alt:"",css:b.icon}),"Управление",t("div",{css:[b.btnArrow,b.closed],children:t("img",{src:"/images/arrow.svg",alt:""})})]}),d("form",{method:"post",css:b.box,encType:"multipart/form-data",children:[t("input",{type:"hidden",defaultValue:i.id,...K("content_type_id")}),W&&d("div",{css:b.leftSide,children:[d(F,{size:"medium",flat:!0,className:b.toggleBtn,onClick:H,children:[t("img",{src:"/images/settings.svg",alt:"",css:b.icon}),"Управление",t("div",{css:b.btnArrow,children:t("img",{src:"/images/arrow.svg",alt:""})})]}),t(Ut,{isInWarehouse:p,toggleInWarehouse:l,className:b.controlWidget,contentType:i,formMethods:u}),t(Gt,{slug:g,className:b.actionsWidget}),t(Xt,{formMethods:u,contentType:i,defaultContent:m})]}),d("div",{css:[b.rightSide,!W&&b.fullRow],children:[d("div",{css:b.header,children:[d(ft,{align:"left",className:b.heading,children:[t("h1",{children:ee}),v.isPending&&t(G,{size:30,delay:700,className:b.headingLoading})]}),t("div",{css:b.headerActions,children:d(F,{className:[b.visualPanelToggler,$?b.visualPanelActive:""],variant:"outline",color:"primary",flat:!0,onClick:te,children:[i.format_input_label,t("img",{src:"/images/Categories/arrow.svg",alt:""})]})})]}),(m==null?void 0:m.origin_content)&&d("div",{children:[d("p",{children:["Вы редактируете"," ",d("b",{children:['копию "',t(Ae,{target:"_blank",to:B.content.url({pluralContentTypeName:((q=(w=m==null?void 0:m.origin_content)==null?void 0:w.content_type)==null?void 0:q.name)+"s",slug:(ae=m==null?void 0:m.origin_content)==null?void 0:ae.slug}),children:m==null?void 0:m.origin_content.title}),'"']}),", ",(ve=(ye=m==null?void 0:m.origin_content)==null?void 0:ye.content_type)==null?void 0:ve.title]}),d("p",{children:["Есть ограничения на работу с копиями:",d("ul",{children:[d("li",{children:[t("b",{children:"копии не выводятся в поиске"}),", для студентов, дистантников, членов клуба и демо."]}),d("li",{children:[t("b",{children:"копии не могут продаваться"}),", т.е. Вы не можете копию материала сделать товаром в магазине"]})]})]})]}),t("div",{}),t(y,{className:b.topActionsPanel}),t(bn,{className:[b.visualPanel,$?b.visualPanelVisible:""],contentType:i,formMethods:u,isLoading:v.isPending,isEdit:o,userSettings:L,contentTypeSelect:t(k,{label:"Тип контента:",required:!0,children:t(bt,{..._})}),accessLevels:T,learningDirectionGrades:E,slug:g}),$&&t(y,{className:b.middleActionsPanel}),d("div",{css:b.main,ref:N,children:[d(k,{className:b.text,label:"Текст",message:(xe=P==null?void 0:P.text)==null?void 0:xe.message,required:!0,children:[o&&typeof(m==null?void 0:m.text)<"u"&&t(Le,{initData:m.text,onChange:I=>X("text",I),onSave:r(o?R.reFetchDefaultContent:R.redirectEdit)}),o||t(Le,{onChange:I=>X("text",I)})]}),t(k,{className:b.text_inner,label:"Текст (Склад)",message:(Ce=P==null?void 0:P.text_inner)==null?void 0:Ce.message,children:t(ge,{isSyncBlocked:v.isPending,control:re,name:"text_inner",placeholder:"Введите служебный текст, будет доступен только для внутреннего использования",onSave:r(o?R.reFetchDefaultContent:R.redirectEdit)})})]}),t(y,{})]})]})]})})})},Pn=({theme:e,...n})=>({EditContent:{paddingBottom:100,[A]:{paddingBottom:40}},box:{display:"grid",gridTemplateColumns:"338px 1fr",gap:"30px",marginTop:n.showEditPanel?10:30,[xt]:{display:"flex",flexDirection:"column"}},fullRow:{gridColumn:"1 / -1"},toggleBtn:{width:"100%",maxWidth:338,display:"flex",alignItems:"center",justifyContent:"flex-start",padding:10,marginBottom:10,"&:hover > img":{filter:"invert(1)"}},icon:{display:"block",width:20,height:20,marginRight:14,filter:e.filter.optional,transition:"filter .2s"},btnArrow:{display:"flex",alignItems:"center",justifyContent:"center",width:30,height:30,marginLeft:"auto",borderRadius:5,background:e.pattern.main,"& img":{display:"block",width:10,height:5,transform:"rotate(180deg)"}},closed:{"& img":{transform:"none"}},leftSide:{},rightSide:{minWidth:1},header:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",flexWrap:"wrap"},headerActions:{display:"flex",alignItems:"flex-start",marginBottom:5,paddingTop:5,flexWrap:"wrap",[A]:{paddingTop:0}},heading:{marginBottom:15,display:"flex"},headingLoading:{marginLeft:"10px",alignSelf:"center"},main:{marginTop:15,background:e.pattern.main,borderRadius:5,padding:"30px",[A]:{padding:"15px"}},controlWidget:{marginBottom:10},actionsWidget:{marginBottom:10},actions:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",marginTop:20,padding:"20px 0 0",borderTop:`1px solid ${e.pattern.separator}`},leftActions:{marginRight:15,marginBottom:10},rightActions:{display:"inline-flex",gap:10,"& > button":{marginBottom:10}},removeBtn:{"& img":{marginLeft:15,filter:e.filter.primary},"&:hover img":{filter:"invert(1)"}},previewBtn:{marginRight:15},topActionsPanel:{margin:"20px 0 10px",borderTop:0,paddingTop:0},middleActionsPanel:{marginBottom:-5},visualPanel:{display:"none",marginBottom:20},visualPanelVisible:{display:"block"},visualPanelToggler:{marginBottom:10,paddingRight:10,textAlign:"left","& img":{display:"block",marginLeft:22},[A]:{order:2}},visualPanelActive:{"& img":{transform:"rotate(180deg)",transformOrigin:"50% 50%"}},text:{display:n.isInWarehouse?"none":"block"},text_inner:{display:n.isInWarehouse?"block":"none"}});export{Un 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.