You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
NewEduCoderBuild/p__Problemset__NewItem__ind...

1 line
106 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[41953,71212,79462],{78988:function(e,n,t){function i(e){var n=!0;if(e.length>0){for(var t=0;t<e.length;t++)if(0==e[t].compile_success||!e[t].compile_success){n=!1;break}}else n=!1;return n}function r(e){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",t=[],i=0;i<e.length;i++){var r=e[i],a=n?"".concat(n,"/").concat(r.name):"".concat(r.name);t.push({title:r.name,isLeaf:"tree"!==r.type,key:a})}return t}function a(e,n,t){for(var i=0;i<e.length;i++){var r=e[i];if(r.key===n){r.children=t;break}r.children&&a(r.children,n,t)}return e}function l(e,n,t){var i;return function(){var r=this,a=arguments,l=function(){i=null,t||e.apply(r,a)},s=t&&!i;clearTimeout(i),i=setTimeout(l,n),s&&e.apply(r,a)}}t.d(n,{Ax:function(){return a},Ds:function(){return l},KI:function(){return s},SI:function(){return r},f1:function(){return i}});var s=t(91689).Z.API_SERVER},10615:function(e,n,t){t.d(n,{Z:function(){return j}});var i=t(82242),r=t.n(i),a=t(7557),l=t.n(a),s=t(41498),c=t.n(s),o=t(79800),u=t.n(o),d=t(59301),p=t(17574),f="folderWrapper___G__0a",h="folderIcon___oTG6c",m=t(73631),v=t(5623),x=t(32701),g=t(37712),j=function(e){var n=e.value,t=e.onChange,i=e.scrollId,a=(0,d.useState)([]),s=u()(a,2),o=s[0],j=s[1];(0,d.useEffect)((function(){_()}),[]);var _=function(){var e=c()(l()().mark((function e(){var n,t;return l()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,x.NZ)({});case 2:null!=(n=e.sent)&&n.data&&(t=[{title:"根目录",value:0,key:0,icon:(0,g.jsx)("img",{src:m,className:h}),isLeaf:!1,children:b(n.data||[])}],j(t));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),b=function e(n){return n.map((function(n){return{title:n.name,key:n.group_id,icon:(0,g.jsx)("img",{src:m,className:h}),isLeaf:0===n.children.length,children:e(n.children)}}))},y=function e(n,t,i){return n.map((function(n){return n.key===t?r()(r()({},n),{},{icon:i?(0,g.jsx)("img",{src:v,className:h}):(0,g.jsx)("img",{src:m,className:h})}):n.children?r()(r()({},n),{},{children:e(n.children,t,i)}):void 0}))},k=n?{selectedKeys:n,defaultExpandedKeys:n}:{};return o.length>0&&(0,g.jsx)("div",{id:i||"",children:(0,g.jsx)(p.Z,r()({showLine:{showLeafIcon:!1},showIcon:!0,treeData:o,className:f,onSelect:t,onExpand:function(e,n){j((function(e){return y(e,n.node.key,n.expanded)}))}},k))})}},52058:function(e,n,t){t.d(n,{N:function(){return C}});var i=t(7557),r=t.n(i),a=t(41498),l=t.n(a),s=t(37205),c=t.n(s),o=t(79800),u=t.n(o),d=t(59301),p=t(57809),f=t(43418),h=t(95237),m=t(43604),v=t(10249),x=t(8591),g=t(94171),j="wrap___F7E3F",_="selectWrapper____kESB",b="tips___aHjQY",y="linkBtn___uggVr",k="mainText____S1I0",w=t(87169),Z=t(37712),N=p.default.Option,C=function(e){var n=e.subId,t=e.value,i=e.selectvalues,a=e.disabled,s=e.knowledgeOptions,o=void 0===s?[]:s,C=e.onChange,E=void 0===C?function(){}:C,I=e.onAddKnowledgeFinish,S=void 0===I?function(){}:I,A=(0,d.useRef)(),P=(0,d.useState)([]),T=u()(P,2),R=T[0],O=T[1];t=t||[];(0,d.useEffect)((function(){(null==i?void 0:i.length)>0&&(O(c()(i)),E(c()(i)))}),[o]),(0,d.useEffect)((function(){var e;(null===(e=t)||void 0===e?void 0:e.length)>0&&E(c()(t))}),[o]);return(0,Z.jsxs)(h.Z,{wrap:!1,align:"middle",className:j,children:[(0,Z.jsx)(m.Z,{children:(0,Z.jsx)(p.default,{disabled:!n||a,className:_,placeholder:"请选择知识点",onChange:function(e,n){e?(O([n.key]),E([n.key])):(O([]),E([]))},style:{width:490},showSearch:!0,allowClear:!0,value:null==o?void 0:o.filter((function(e){return(null==R?void 0:R.includes(null==e?void 0:e.id))||(null==R?void 0:R.includes((null==e?void 0:e.id)+""))})).map((function(e){return e.name})),children:null==o?void 0:o.map((function(e){return(0,Z.jsx)(N,{value:e.name,children:(0,Z.jsxs)("div",{style:{display:"flex",justifyContent:"space-between"},children:[(0,Z.jsx)("span",{style:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:e.name}),(0,Z.jsx)("span",{children:"personal"===e.type?"(自用)":""})]})},e.id)}))})}),n&&(0,Z.jsxs)(m.Z,{className:"ml20",children:[(0,Z.jsx)("span",{className:b,children:"没有合适的知识点?"}),(0,Z.jsx)("span",{className:y,onClick:function(e){e.preventDefault(),A.current="",f.Z.confirm({centered:!0,width:640,okText:"确定",cancelText:"取消",icon:null,title:"新建知识点",className:"custom-modal-divider",content:(0,Z.jsxs)("div",{className:"font14",children:[(0,Z.jsxs)(h.Z,{className:"mb20",children:[(0,Z.jsx)(m.Z,{children:(0,Z.jsx)(w.Z,{style:{color:"#FF8C29"}})}),(0,Z.jsxs)(m.Z,{className:"ml10 ".concat(k),children:["新建的知识点仅本人可见,平台审核列入公开知识点后,对所有用户可见。",(0,Z.jsx)("br",{}),"平台有权删除不合适的知识点,请认真填写知识点名称。"]})]}),(0,Z.jsx)(v.Z,{maxLength:20,size:"middle",showCount:!0,placeholder:"请输入知识点名称",defaultValue:A.current,onChange:function(e){A.current=e.target.value}})]}),onOk:function(){return new Promise(function(){var e=l()(r()().mark((function e(t,i){var a,l;return r()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(A.current){e.next=3;break}return x.ZP.warning("请输入知识点名称"),e.abrupt("return",i());case 3:if(!(A.current.length>20)){e.next=6;break}return x.ZP.warning("请输入不超过20字的知识点名称"),e.abrupt("return",i());case 6:return e.next=8,(0,g.ZP)("/api/tag_disciplines.json",{method:"post",body:{name:A.current,sub_discipline_id:n}});case 8:return 0===(null==(a=e.sent)?void 0:a.status)&&(S({id:a.tag_discipline_id,name:A.current,type:"personal"}),(l=[]).push(a.tag_discipline_id),E([].concat(l)),O([a.tag_discipline_id]),E([].concat(l))),e.abrupt("return",t());case 11:case"end":return e.stop()}}),e)})));return function(n,t){return e.apply(this,arguments)}}())}})},children:"新建知识点"})]})]})}},32831:function(e,n,t){t.d(n,{Z:function(){return y}});var i=t(82242),r=t.n(i),a=t(7557),l=t.n(a),s=t(41498),c=t.n(s),o=t(79800),u=t.n(o),d=t(59301),p={wrp:"wrp___dq7YK",bgBlack:"bgBlack___ARIUV",monaco:"monaco___VnZC3",darkBlue:"darkBlue___UprA9",close:"close___LKoWu",embed:"embed___hvpEJ"},f=t(3113),h=t(70557),m=t(63631),v=t(6848),x=t(83287),g=t(94280),j=t(13767),_=t(91689),b=t(37712),y=function(e){var n,t,i,a,s,o,y,k=e.editOffice,w=void 0===k?"view":k,Z=e.data,N=(e.theme,e.type),C=e.filename,E=e.monacoEditor,I=e.className,S=e.style,A=e.close,P=e.onClose,T=e.hasMask,R=e.disabledDownload,O=e.onImgDimensions,F=e.showNodata,B=(0,d.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),L=u()(B,2),M=(L[0],L[1],(0,d.useState)("")),V=u()(M,2),W=(V[0],V[1]),D=(0,d.useState)(),q=u()(D,2),U=q[0],K=q[1],H="build"===window.ENV?"/react/build":"",G=location.host.startsWith("localhost")?_.Z.PROXY_SERVER:_.Z.API_SERVER,z=(0,d.useRef)();null!==(n=Z)&&void 0!==n&&n.startsWith("/api")&&"txt"!==N&&(Z=_.Z.API_SERVER+Z),C&&(E.filename=C),(0,d.useEffect)((function(){var e,n=null===(e=document.cookie)||void 0===e||null===(e=e.replace(/\s/g,""))||void 0===e?void 0:e.split(";");null==n||n.map((function(e){var n=e.split("=");"_educoder_session"===n[0]&&W(n[1])}))}),[]),(0,d.useEffect)((function(){"office"===N&&J()}),[N,Z]);var J=function(){var e=c()(l()().mark((function e(){var n,t,i;return l()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Z,Z.startsWith("http")||(n=location.origin+n),t=new URL(n).pathname.split("/").pop(),e.next=5,(0,g.gJ)({attachment_id:t});case 5:i=e.sent,K(i);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Y=function(){X()},X=function(){(0,x.Nd)(C||"educoder",decodeURIComponent(Z))};return(0,b.jsxs)("div",{style:r()({},S||{}),className:"".concat(T&&p.bgBlack," ").concat(N?p.wrp:"hide"),children:[A&&(0,b.jsxs)("div",{className:p.close,ref:z,children:[!!O&&(0,b.jsx)(v.Z,{title:"点击对图片进行批注",getPopupContainer:function(){return z.current},children:(0,b.jsx)("span",{onClick:function(){P(),O()},children:(0,b.jsx)("i",{className:"icon-yulanpizhu"})})}),!R&&(0,b.jsx)(v.Z,{title:"点击下载此文件",getPopupContainer:function(){return z.current},children:(0,b.jsx)("span",{onClick:X,children:(0,b.jsx)("i",{className:"icon-quxiaozhiding"})})}),(0,b.jsx)(v.Z,{title:"关闭",getPopupContainer:function(){return z.current},children:(0,b.jsx)("span",{className:"",onClick:P,children:(0,b.jsx)("i",{className:"icon-guanbi1"})})})]}),(0,b.jsx)("div",{className:"".concat(p[I]," ").concat(I," ").concat(p.monaco," ").concat("txt"===N?"show":"hide"),children:"txt"===N&&(0,b.jsx)(m.ZP,r()({},E))}),"audio"===N&&(0,b.jsx)("audio",{src:(null===(t=Z)||void 0===t?void 0:t.indexOf("http"))>-1||null!==(i=Z)&&void 0!==i&&i.startsWith("/api")?Z:"data:image/png;base64,".concat(Z),autoPlay:!0}),"video"===N&&(0,b.jsx)(b.Fragment,{children:(null===(a=Z)||void 0===a?void 0:a.indexOf("http"))>-1||null!==(s=Z)&&void 0!==s&&s.startsWith("/api")?(0,b.jsx)("video",{controls:!0,src:"".concat(Z),autoPlay:!0}):(0,b.jsx)("video",{controls:!0,src:"data:video/mp4;base64,".concat(Z),autoPlay:!0})}),"office"===N&&U&&(0,b.jsx)("iframe",{src:"".concat(H,"/office.html?key=").concat(U.key,"&url=").concat(G+U.url,"&callbackUrl=").concat(G+U.callbackUrl,"&fileType=").concat(U.fileType,"&title=").concat(U.title,"&model=").concat(w,"&officeServer=").concat(_.Z.ONLYOFFICE,"&disabledDownload=").concat(!!R)}),"html"===N&&(0,b.jsx)("iframe",{src:Z+"&disposition=inline"}),"pdf"===N&&(0,b.jsx)("iframe",{src:"".concat(H,"/js/pdfview/index.html?url=").concat(Z,"&disabledDownload=").concat(!!R)}),"image"===N&&(0,b.jsx)("img",{src:(null===(o=Z)||void 0===o?void 0:o.indexOf("http"))>-1||null!==(y=Z)&&void 0!==y&&y.startsWith("/api")?Z:"data:image/png;base64,".concat(Z)}),("other"===N||"download"===N)&&(0,b.jsx)(b.Fragment,{children:F?(0,b.jsx)(j.Z,{customText:"当前文件不支持预览,可点击下载查看",ButtonTwo:(0,b.jsx)(f.ZP,{icon:(0,b.jsx)("i",{className:"iconfont icon-xiazai4 font14"}),type:"primary",size:"middle",onClick:Y,children:"下载"})}):(0,b.jsxs)(f.ZP,{type:"primary",size:"middle",onClick:Y,children:[(0,b.jsx)(h.Z,{}),"点击下载"]})})]})}},60030:function(e,n,t){t.d(n,{t:function(){return P}});var i=t(39647),r=t.n(i),a=t(91232),l=t.n(a),s=t(85573),c=t.n(s),o=t(82242),u=t.n(o),d=t(79800),p=t.n(d),f=t(59301),h=t(10249),m=t(78673),v=t(78241),x=t(95237),g=t(43604),j=t(5871),_=t(57809),b=t(58605),y=t(49389),k=t(69092),w=t(37426),Z=t(37712),N=["key","name"],C=h.Z.TextArea,E=[{title:"C",key:"C"},{title:"C++",key:"C++"},{title:"Python",key:"Python"},{title:"Java",key:"Java"},{title:"JavaScript",key:"JavaScript"},{title:"Ruby",key:"Ruby"}],I=function(e){var n=e.value,t=e.onChange;return(0,Z.jsx)(m.Z,{checked:n,onChange:function(e){t(e)}})},S="@▁@",A="@▁▁@",P=function(e){var n=e.questionTitlePlaceholder,t=e.form,i=e.scoreByBlank,a=void 0!==i&&i,s=e.hackidentifier,o=e.answerKey,d=(0,f.useState)(!1),m=p()(d,2),P=m[0],T=m[1],R=(0,f.useState)(!1),O=p()(R,2),F=(O[0],O[1],(0,y.useParams)().type,function(e,n){for(var t=n.line,i=0,r=0;r<t;r++)i+=e.getLine(r).split(S).length-1;for(var a=0;a<t;a++)i+=e.getLine(a).split(A).length-1;var l=e.getLine(t).substring(0,n.ch);return i+=l.split(S).length-1,i+=l.split(A).length-1}),B=function(){var e=t.getFieldValue(o);t.setFieldsValue(c()({},o,e.map((function(e,n){return u()(u()({},e),{},{position:n+1})}))))},L=(0,f.useRef)(),M=function(e,n){for(var t=0;t<e;t++)L.current({position:null,answer_text:""},n+t);B()},V=(0,f.useRef)(),W=function(e){V.current(e),B()},D=v.Z.useWatch(o,t);return(0,Z.jsxs)("div",{className:k.Z.wrap,children:[(0,Z.jsx)(v.Z.Item,{label:"试题描述",name:["hack","description"],style:{display:"table"},className:"w100",labelCol:{span:24},rules:[{required:!0}],children:(0,Z.jsx)(b.h,{scrollId:"name",watch:!0,height:140})}),(0,Z.jsx)("div",{className:k.Z.questionTitleEditorWrap,children:(0,Z.jsx)(v.Z.Item,{label:"程序代码",name:["hack_codes","code"],labelCol:{span:24},rules:[{required:!0}],children:(0,Z.jsx)(b.h,{scrollId:"name",watch:!0,height:400,showNullProgramButton:!0,onChange:function(e,n){var i=t.getFieldValue(o);console.log("--preAnswerData",i,n),t.setFieldsValue(c()({},o,null==i?void 0:i.map((function(e,t){var i;return u()(u()({},e),{},{position:t+1,multi_line:null==n||null===(i=n[t])||void 0===i?void 0:i.multiLine})}))))},placeholder:n,onCMBeforeChange:function(e,n){!function(e,n,t,i){var r=e.getRange(n.from,n.to),a=0;if(n.text.forEach((function(e){a+=e.split(S).length-1})),n.text.forEach((function(e){a+=e.split(A).length-1})),"setValue"!==n.origin)if(!r||-1===r.indexOf(S)&&-1===r.indexOf(A)){if(a>0){var l=F(e,n.from);console.log("新增".concat(a,"个,之前有").concat(l,"个")),t(a,l)}}else{var s=r.split(S).length-1+r.split(A).length-1,c=F(e,n.from);console.log("删除".concat(s,"个, 前面有").concat(c,"个,新增").concat(a,"个")),i(s>1?Array.from({length:s},(function(e,n){return c+n})):c)}}(e,n,M,W)}})})}),(0,Z.jsx)(v.Z.List,{name:o,rules:[{validator:function(e,n){if(0===(null==n?void 0:n.length))return Promise.reject(new Error("答案不能为空"));var t,i=l()(n);try{for(i.s();!(t=i.n()).done;){var r=(t.value||{}).answer_text;if(0===(null==r?void 0:r.length))return Promise.reject(new Error("填空项答案不能为空"))}}catch(e){i.e(e)}finally{i.f()}return Promise.resolve()}}],children:function(e,n,t){var i=n.add,l=n.remove;t.errors;return L.current=i,V.current=l,(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(v.Z.Item,{label:"填空项答案",required:!0,labelCol:{span:24}}),e.map((function(e,n){var t,i,l=e.key,s=e.name,c=r()(e,N);return(0,Z.jsxs)(x.Z,{className:"mb20",align:"middle",wrap:!1,children:[(0,Z.jsxs)(g.Z,{flex:"0 0 auto",className:"".concat(k.Z.blankIndex),children:["填空项",n+1]}),(0,Z.jsx)(g.Z,{flex:1,children:(0,Z.jsxs)(x.Z,{align:"top",justify:"space-between",wrap:!1,children:[(0,Z.jsx)(g.Z,{children:(0,Z.jsx)(v.Z.Item,u()(u()({},c),{},{name:[s,"answer_text"],noStyle:!0,children:null!=D&&null!==(t=D[s])&&void 0!==t&&t.multi_line||null!=D&&null!==(i=D[s])&&void 0!==i&&i.multiLine?(0,Z.jsx)(C,{spellCheck:!1,style:{marginLeft:10,width:550}}):(0,Z.jsx)(h.Z,{style:{marginLeft:10,width:550},className:k.Z.blankInput,size:"large",maxLength:1e3,onBlur:function(e){}})}))}),a&&(0,Z.jsx)(g.Z,{flex:"224px",children:(0,Z.jsx)(v.Z.Item,u()(u()({},c),{},{name:[s,"score"],label:"分值",rules:[{required:!0}],children:(0,Z.jsx)(j.Z,{size:"large",className:k.Z.blankInput,min:.1,max:100,precision:1,style:{width:"100%"},placeholder:"按空给分请输入分值"})}))})]})})]},l)}))]})}}),(0,Z.jsx)("div",{onClick:function(){return T(!0)},children:(0,Z.jsx)(v.Z.Item,{name:["hack","analysis"],label:"题目解析",labelCol:{span:24},children:(0,Z.jsx)(b.x,{placeholder:"请编辑题目解析(非必填)",isEdit:P})})}),(0,Z.jsx)(v.Z.Item,{label:"编程语言",style:{marginTop:30},name:["hack_codes","language"],labelCol:{span:24},rules:[{required:!0,message:"请选择编程语言"}],children:(0,Z.jsx)(_.default,{size:"large",children:E.map((function(e){return(0,Z.jsxs)(_.default.Option,{value:e.key,children:[" ",e.title]},e.title)}))})}),(0,Z.jsxs)(v.Z.Item,{label:"最大评测时长(秒)",style:{marginTop:30},labelCol:{span:24},required:!0,children:[(0,Z.jsx)(v.Z.Item,{name:["hack","time_limit"],rules:[{required:!0,message:"请输入单个测试集评测时长限制"},{type:"number",min:3,message:"最小限制时间是3秒"}],noStyle:!0,children:(0,Z.jsx)(j.Z,{precision:0,max:10,min:3,size:"large",style:{width:"97%"}})}),(0,Z.jsx)("span",{className:"ml10 font14",children:"秒"})]}),(0,Z.jsxs)(x.Z,{align:"middle",style:{marginTop:30},children:[(0,Z.jsx)(v.Z.Item,{name:["hack","allow_student_debug"],children:(0,Z.jsx)(I,{})}),(0,Z.jsx)(g.Z,{className:"ml10",children:"允许学生答题时进行代码调试"})]}),(0,Z.jsx)(v.Z.Item,{label:"测试用例",required:!0}),(0,Z.jsxs)("div",{style:{background:"#F6F7F9",padding:15},children:[(0,Z.jsx)(v.Z.Item,{label:"输入",labelCol:{span:24},name:["hack_sets","input"],children:(0,Z.jsx)(C,{rows:4})}),(0,Z.jsx)(v.Z.Item,{label:"输出",labelCol:{span:24},name:["hack_sets","output"],rules:[{required:!0,message:"请输入输出内容"}],children:(0,Z.jsx)(C,{rows:4})})]}),(0,Z.jsx)(w.Z,{answerKey:o,hackidentifier:s,ButtonText:"自测运行",ButtonProps:{ghost:!0,icon:(0,Z.jsx)("i",{className:"iconfont icon-ceshi"}),style:{background:"rgba(55,173,131,0.05)",borderRadius:19,border:"1px solid #37AD83",width:116,height:38,display:"inline-flex",fontSize:14,alignItems:"center",justifyContent:"center",marginTop:20,cursor:"pointer",color:"#37AD83"}},form:t})]})}},37426:function(e,n,t){var i=t(82242),r=t.n(i),a=t(7557),l=t.n(a),s=t(41498),c=t.n(s),o=t(79800),u=t.n(o),d=t(49389),p=t(59301),f=t(8591),h=t(3113),m=t(43418),v=t(24334),x=t(94171),g=t(66375),j=t(65593),_=t(56656),b=t.n(_),y=t(37712);n.Z=function(e){var n=e.ButtonProps,t=e.ButtonText,i=e.form,a=e.answerKey,s=e.hackidentifier,o=void 0===s?"":s,_=e.items,k=void 0===_?{}:_,w=(0,p.useState)(!1),Z=u()(w,2),N=Z[0],C=Z[1],E=(0,p.useState)(""),I=u()(E,2),S=I[0],A=I[1],P=(0,d.useParams)(),T=(0,p.useState)({}),R=u()(T,2),O=R[0],F=R[1],B="edit"===P.type;window.location.href.includes("problemset");function L(e,n){return M.apply(this,arguments)}function M(){return(M=c()(l()().mark((function e(n,t){var r,s,c,o,u;return l()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=i.getFieldValue("hack_codes"),c=i.getFieldValue(a),s.code){e.next=5;break}return f.ZP.info("程序代码不能为空!"),e.abrupt("return");case 5:if(s.language){e.next=8;break}return f.ZP.info("编程语言不能为空!"),e.abrupt("return");case 8:if(!(c.length>0&&(null===(r=c.filter((function(e){return!e.answer_text})))||void 0===r?void 0:r.length)>0)){e.next=11;break}return f.ZP.info("填空项不能为空!"),e.abrupt("return");case 11:return o=s.code,c.length>0&&(null==c||c.map((function(e){o=e.multi_line?o.substring(0,o.indexOf("@▁▁@"))+e.answer_text+o.substring(o.indexOf("@▁▁@")+4):o.substring(0,o.indexOf("@▁@"))+e.answer_text+o.substring(o.indexOf("@▁@")+3)}))),e.next=15,(0,g.n4)(t,n||{code:v.Base64.encode(o),language:s.language});case 15:return u=e.sent,e.abrupt("return",u);case 17:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function V(e,n){return W.apply(this,arguments)}function W(){return(W=c()(l()().mark((function e(n,t){var i,r,a,s;return l()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=k.userAnswer,a=v.Base64.decode(k.code),!(r.length>0&&(null===(i=r.filter((function(e){return!e.value})))||void 0===i?void 0:i.length)>0)){e.next=6;break}return f.ZP.info("填空项不能为空!"),e.abrupt("return");case 6:return r.length>0&&(null==r||r.map((function(e){a=e.multi_line?a.substring(0,a.indexOf("@▁▁@"))+e.value+a.substring(a.indexOf("@▁▁@")+4):a.substring(0,a.indexOf("@▁@"))+e.value+a.substring(a.indexOf("@▁@")+3)}))),e.next=9,(0,g.n4)(t,n||{code:v.Base64.encode(a),language:k.language});case 9:return s=e.sent,e.abrupt("return",s);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function D(){return(new Date).getTime()}return(0,p.useEffect)((function(){(B||o)&&A(o||P.id)}),[P]),(0,p.useEffect)((function(){return function(){sessionStorage.removeItem("projectFill")}}),[]),(0,y.jsxs)("div",{children:[(0,y.jsx)(h.ZP,r()(r()({loading:N},n),{},{onClick:c()(l()().mark((function e(){var n,a,s,o,u,d,p,h,j,_,b,y,k,w;return l()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("运行调试"!==t){e.next=20;break}if(C(!0),!N){e.next=4;break}return e.abrupt("return");case 4:return e.next=6,(0,x.ZP)("/api/problems/".concat(S,"/start.json"),{method:"get"});case 6:return n=e.sent,e.next=9,V(null,null==n?void 0:n.identifier);case 9:if(0!==(null==(a=e.sent)?void 0:a.status)){e.next=18;break}return s=function(){var e=c()(l()().mark((function e(){var t,i,r,a,c;return l()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,g.rX)(null==n?void 0:n.identifier,"submit");case 2:if(t=e.sent,i=t.status,t.message,r=t.data,a=D(),c=a-o>6e3,0===i||c||setTimeout(s,1e3),!c){e.next=13;break}return m.Z.error({centered:!0,okText:"知道啦",title:"调试代码超时"}),C(!1),e.abrupt("return");case 13:0===i&&(C(!1),F(r),2===r.status&&(C(!1),m.Z.error({centered:!0,okText:"知道啦",title:"调试代码超时"})));case 14:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),o=D(),e.next=15,(0,g.bM)(null==n?void 0:n.identifier,{});case 15:s(),e.next=19;break;case 18:C(!1);case 19:return e.abrupt("return");case 20:return u=!0,e.next=23,i.validateFields().then((function(){u=!1}),(function(e){var n,t;e.errorFields[0].name.includes("standard_answers")?f.ZP.error("填空项答案不能为空"):f.ZP.error(e.errorFields[0].errors[0]),0===(null===(n=e.errorFields)||void 0===n?void 0:n.length)&&(u=!1),i.scrollToField(null==e||null===(t=e.errorFields)||void 0===t||null===(t=t[0])||void 0===t?void 0:t.name,{behavior:"smooth",block:"center"}),u=!0}));case 23:if(!u){e.next=25;break}return e.abrupt("return");case 25:if(C(!0),!N){e.next=28;break}return e.abrupt("return");case 28:if(d="",p=i.getFieldsValue(),S){e.next=39;break}return e.next=33,(0,x.ZP)("/api/problems.json",{method:"post",body:r()(r()({},p),{},{hack:r()(r()({},null==p?void 0:p.hack),{},{sub_discipline_id:null==p||null===(h=p.hack)||void 0===h||null===(h=h.sub_discipline_id)||void 0===h?void 0:h[1],difficult:p.difficulty,item_banks_group_id:p.item_banks_group_id}),hack_codes:r()(r()({},p.hack_codes),{},{code:v.Base64.encode(p.hack_codes.code)}),hack_sets:[r()({},p.hack_sets)],is_blank:!0})});case 33:d=e.sent,S=null===(j=d)||void 0===j?void 0:j.identifier,sessionStorage.projectFill=S,A(S),e.next=42;break;case 39:return e.next=41,(0,x.ZP)("/api/problems/".concat(S,".json"),{method:"put",body:r()(r()({},p),{},{hack:r()(r()({},null==p?void 0:p.hack),{},{sub_discipline_id:null==p||null===(_=p.hack)||void 0===_||null===(_=_.sub_discipline_id)||void 0===_?void 0:_[1],difficult:p.difficulty,item_banks_group_id:p.item_banks_group_id}),hack_codes:r()(r()({},p.hack_codes),{},{code:v.Base64.encode(p.hack_codes.code)}),update_hack_sets:[r()({},p.hack_sets)],is_blank:!0})});case 41:d=e.sent;case 42:return e.next=44,(0,x.ZP)("/api/problems/".concat(S,"/start.json"),{method:"get"});case 44:return b=e.sent,e.next=47,L(null,null==b?void 0:b.identifier);case 47:if(0!==(null==(y=e.sent)?void 0:y.status)){e.next=56;break}return k=function(){var e=c()(l()().mark((function e(){var n,t,i,r,a;return l()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,g.rX)(null==b?void 0:b.identifier,"submit");case 2:if(n=e.sent,t=n.status,n.message,i=n.data,r=D(),a=r-w>1e3*(p.hack.time_limit+3),0===t||a||setTimeout(k,1e3),!a){e.next=13;break}return m.Z.error({centered:!0,okText:"知道啦",title:"调试代码超时"}),C(!1),e.abrupt("return");case 13:0===t&&(C(!1),F(i),2===i.status&&(C(!1),m.Z.error({centered:!0,okText:"知道啦",title:"调试代码超时"})));case 14:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),w=D(),e.next=53,(0,g.bM)(null==b?void 0:b.identifier,{});case 53:k(),e.next=57;break;case 56:C(!1);case 57:case"end":return e.stop()}}),e)}))),children:t})),(null==O?void 0:O.id)&&2!==O.status&&(0,y.jsx)(m.Z,{open:(null==O?void 0:O.id)&&2!==O.status,title:"运行结果",width:1100,footer:!1,onOk:function(){F({})},onCancel:function(){F({})},children:(0,y.jsxs)("div",{style:{maxHeight:600,overflow:"auto",marginBottom:15},children:[(0,y.jsxs)("div",{style:{marginBottom:20,display:"flex",justifyContent:"space-between",fontSize:14},children:[(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{style:{color:"#666666"},children:"状态"}),(0,y.jsx)("span",{style:{marginLeft:12,color:0!==O.status&&"#E30000"},children:j.Im[O.status]})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{style:{color:"#666666"},children:"提交时间"}),(0,y.jsx)("span",{style:{marginLeft:12},children:b()(O.created_at).format("YYYY-MM-DD HH:mm:ss")})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{style:{color:"#666666"},children:"语言"}),(0,y.jsx)("span",{style:{marginLeft:12},children:O.language})]}),(0,y.jsxs)("div",{children:[(0,y.jsx)("span",{style:{color:"#666666"},children:"执行用时"}),(0,y.jsxs)("span",{style:{marginLeft:12},children:[O.execute_time,"ms"]})]})]}),(0,y.jsx)(j.Y4,r()({},O))]})})]})}},2648:function(e,n,t){t.d(n,{u:function(){return w}});var i=t(39647),r=t.n(i),a=t(79800),l=t.n(a),s=t(85573),c=t.n(s),o=t(82242),u=t.n(o),d=t(59301),p=t(95237),f=t(43604),h=t(6848),m=t(78241),v=t(69092),x=t(32134),g=t(12893),j=t(58605),_=t(37712),b=["key","name"],y=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],k=function(e){var n=e.value,t=e.onChange,i=e.choiceTextKey,r=e.answerKey,a=e.index,l=e.isEdit,s=e.setInputActive,o=e.form,d=e.choiceOptionsPath,m=e.allowChangeMode,b=e.showAddIcon,k=e.addItem,w=e.deleteItem,Z=1===(null==n?void 0:n[r]),N=function(){var e;Z?t(u()(u()({},n),{},c()({},r,0))):(m||(e=o.getFieldValue(d),o.setFieldValue(d,e.map((function(e){return u()(u()({},e),{},c()({},r,0))})))),t(u()(u()({},n),{},c()({},r,1))))};return(0,_.jsxs)(p.Z,{className:v.Z.choiceWrap,align:"middle",wrap:!1,children:[(0,_.jsx)(f.Z,{onClick:N,className:"".concat(v.Z.choiceIndex," ").concat(Z?v.Z.activeAnswer:""),children:y[a]}),(0,_.jsx)(f.Z,{flex:1,className:"".concat(v.Z.editorWrap," ml15"),onClick:s,children:(0,_.jsx)(j.x,{height:155,placeholder:"请您输入选项",isEdit:l,value:null==n?void 0:n[i],onChange:function(e){t(u()(u()({},n),{},c()({},i,e)))}})}),(0,_.jsx)(f.Z,{flex:"0 0 auto",className:"ml15",children:(0,_.jsx)("div",{onClick:N,className:"".concat(v.Z.setAnswerBtn," ").concat(Z?v.Z.activeAnswer:""),children:Z?"正确答案":"设为答案"})}),(0,_.jsxs)(f.Z,{className:v.Z.actionWrapper,children:[(0,_.jsx)(h.Z,{title:"新增参考答案",children:(0,_.jsx)(x.Z,{className:v.Z.addIcon,onClick:k,style:{visibility:b?"visible":"hidden"}})}),(0,_.jsx)(h.Z,{title:"删除",children:(0,_.jsx)(g.Z,{className:v.Z.deleteIcon,onClick:w,style:{visibility:a>1?"visible":"hidden"}})})]})]})},w=function(e){var n=e.questionTitlePlaceholder,t=e.titleKey,i=e.choiceKey,a=e.analysisKey,s=e.choiceTextKey,o=e.answerKey,p=e.choiceOptionsPath,f=e.allowChangeMode,h=void 0===f||f,x=e.form,g=e.showAnalysis,w=void 0===g||g,Z=(0,d.useState)(),N=l()(Z,2),C=N[0],E=N[1],I=(0,d.useState)(!1),S=l()(I,2),A=S[0],P=S[1];return(0,_.jsxs)("div",{className:v.Z.wrap,children:[(0,_.jsx)("div",{className:v.Z.questionTitleEditorWrap,children:(0,_.jsx)(m.Z.Item,{label:"题干",name:t,labelCol:{span:24},rules:[{required:!0}],children:(0,_.jsx)(j.h,{scrollId:Array.isArray(t)?t.join("_"):"".concat(t),watch:!0,height:140,placeholder:n})})}),(0,_.jsx)(m.Z.Item,{label:"答案选项",required:!0,labelCol:{span:24}}),(0,_.jsx)(m.Z.List,{name:i,rules:[{validator:function(e,n){var t=n.some((function(e){return 1===e[o]})),i=n.findIndex((function(e){var n;return(null===(n=e[s])||void 0===n?void 0:n.length)<=0}));return-1!==i?Promise.reject(new Error("请先输入".concat(y[i],"选项的内容"))):t?Promise.resolve():Promise.reject(new Error("请设置正确答案"))}}],children:function(e,n){var t=n.add,i=n.remove;return(0,_.jsxs)("div",{id:Array.isArray(p)?p.join("_"):"".concat(p),children:[e.map((function(n,a){var l=n.key,f=n.name,v=r()(n,b),g=C===l,j=a<7&&a===e.length-1;return(0,d.createElement)(m.Z.Item,u()(u()({},v),{},{key:l,name:f,noStyle:!0}),(0,_.jsx)(k,{choiceTextKey:s,answerKey:o,index:a,isEdit:g,setInputActive:function(){E(l)},form:x,choiceOptionsPath:p,allowChangeMode:h,showAddIcon:j,addItem:function(){return t(c()(c()({},s,""),o,0))},deleteItem:function(){return i(f)}}))})),e.length<8&&(0,_.jsx)("div",{className:"".concat(v.Z.addBtn," mb30"),onClick:function(){return t(c()(c()({},s,""),o,0))},children:"添加选项"})]})}}),w&&(0,_.jsx)("div",{onClick:function(){return P(!0)},children:(0,_.jsx)(m.Z.Item,{name:a,label:"题目解析",labelCol:{span:24},children:(0,_.jsx)(j.x,{placeholder:"请编辑题目解析(非必填)",isEdit:A})})})]})}},87651:function(e,n,t){t.d(n,{r:function(){return j}});var i=t(82242),r=t.n(i),a=t(39647),l=t.n(a),s=(t(59301),t(36381)),c=t(78241),o=t(95237),u=t(5871),d=t(6848),p=t(69092),f=t(12893),h=t(58605),m=t(2648),v=t(37712),x=["key","name"],g=s.Z.Panel,j=function(e){var n=e.questionTitlePlaceholder,t=(e.choiceKey,e.form),i=e.withScore;return(0,v.jsxs)("div",{className:p.Z.wrap,children:[(0,v.jsx)("div",{className:p.Z.questionTitleEditorWrap,children:(0,v.jsx)(c.Z.Item,{label:"题干",name:"name",labelCol:{span:24},rules:[{required:!0}],children:(0,v.jsx)(h.h,{scrollId:"name",watch:!0,height:140,placeholder:n})})}),(0,v.jsx)(c.Z.Item,{label:"小题",required:!0,labelCol:{span:24}}),(0,v.jsx)(c.Z.List,{name:"sub_item_banks",rules:[{validator:function(e,n){return n?Promise.resolve():Promise.reject(new Error("请添加小题"))}}],children:function(e,n){var a=n.add,h=n.remove;return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.Z,{className:e.length>0?p.Z.collapseWrapper:"",bordered:!1,expandIcon:function(e){var n=e.isActive;return(0,v.jsx)("i",{className:"iconfont icon-weizhankai ".concat(n?p.Z.open:p.Z.close),style:{fontSize:14,transition:"all .2s"}})},children:e.map((function(e,n){var a=e.key,s=e.name,j=l()(e,x);return(0,v.jsx)(g,{className:p.Z.panel,forceRender:!0,header:(0,v.jsxs)("div",{className:p.Z.panelHeader,children:["第",n+1,"小题",(0,v.jsx)("span",{children:"(单选题)"})]}),extra:(0,v.jsxs)(o.Z,{align:"middle",onClick:function(e){return e.stopPropagation()},children:[i&&(0,v.jsx)(c.Z.Item,r()(r()({},j),{},{rules:[{required:!0,message:"请输入小题分值"}],label:"分值",name:[s,"question_score"],className:p.Z.blankInputNumberWrapper,children:(0,v.jsx)(u.Z,{className:p.Z.blankInput,placeholder:"请输入当前小题分数",min:.1,precision:1,max:100,style:{width:150}})})),(0,v.jsx)(d.Z,{title:"删除",children:(0,v.jsx)(f.Z,{className:"".concat(p.Z.deleteIcon," ml40"),onClick:function(){return h(s)}})})]}),children:(0,v.jsx)(c.Z.Item,r()(r()({},j),{},{name:s,children:(0,v.jsx)(m.u,{questionTitlePlaceholder:"请编辑选择题题干内容",allowChangeMode:!1,form:t,choiceKey:[s,"choices"],titleKey:[s,"name"],analysisKey:[s,"analysis"],choiceOptionsPath:["sub_item_banks",s,"choices"],choiceTextKey:"choice_text",answerKey:"is_answer"})}))},a)}))}),e.length<20&&(0,v.jsx)("div",{className:"".concat(p.Z.addBtn),onClick:function(){return a({name:"",choices:Array.from({length:4},(function(){return{choice_text:"",is_answer:0}})),analysis:""})},children:"添加小题"})]})}})]})}},30286:function(e,n,t){t.d(n,{u:function(){return P}});var i=t(39647),r=t.n(i),a=t(91232),l=t.n(a),s=t(85573),c=t.n(s),o=t(82242),u=t.n(o),d=t(79800),p=t.n(d),f=t(37205),h=t.n(f),m=t(59301),v=t(43418),x=t(95237),g=t(43604),j=t(10249),_=t(6848),b=t(78673),y=t(78241),k=t(5871),w=t(58605),Z=t(12893),N=t(69092),C=t(37712),E=["key","name"],I=function(e){var n=e.value,t=e.onChange;return(0,C.jsxs)(x.Z,{align:"middle",className:"ml20",gutter:[40,20],children:[null==n?void 0:n.map((function(e,i){return(0,C.jsxs)(g.Z,{className:N.Z.blankWrapper,children:[(0,C.jsx)(j.Z,{className:N.Z.blankInput,defaultValue:e,maxLength:1e3,onBlur:function(e){var r=h()(n),a=e.target.value.trim();r[i]=a,t(r)}}),(0,C.jsx)(_.Z,{title:"删除",children:(0,C.jsx)(Z.Z,{className:N.Z.deleteIcon,style:{marginLeft:15,visibility:i>0?"visible":"hidden"},onClick:function(){return function(e){v.Z.confirm({centered:!0,okText:"确定",cancelText:"取消",title:"提示",content:"确认要删除这个参考答案吗?",className:N.Z.modal,onOk:function(){var i=h()(n);i.splice(e,1),t(i)}})}(i)}})})]},"".concat(e,"_").concat(i))})),(0,C.jsx)(g.Z,{children:(0,C.jsx)("div",{className:"".concat(N.Z.addBtn),onClick:function(){var e;(e=h()(n)).push(""),t(e)},children:"新增答案"})})]})},S=function(e){var n=e.value,t=void 0===n||n,i=e.onChange;return(0,C.jsx)(b.Z,{checked:!t,onChange:function(e){i(!e)}})},A="▁",P=function(e){var n=e.questionTitlePlaceholder,t=e.form,i=e.scoreByBlank,a=void 0!==i&&i,s=e.answerKey,o=(0,m.useState)(!1),d=p()(o,2),f=d[0],h=d[1],v=function(e,n){for(var t=n.line,i=0,r=0;r<t;r++)i+=e.getLine(r).split(A).length-1;return i+=e.getLine(t).substring(0,n.ch).split(A).length-1},_=function(){var e=t.getFieldValue(s);t.setFieldsValue(c()({},s,e.map((function(e,n){return u()(u()({},e),{},{position:n+1})}))))},b=(0,m.useRef)(),Z=function(e,n){for(var t=0;t<e;t++)b.current({position:null,answer_text:[""]},n+t);_()},P=(0,m.useRef)(),T=function(e){P.current(e),_()},R=y.Z.useWatch(s,t);return(0,C.jsxs)("div",{className:N.Z.wrap,children:[(0,C.jsx)("div",{className:N.Z.questionTitleEditorWrap,children:(0,C.jsx)(y.Z.Item,{label:"题干",name:"name",labelCol:{span:24},rules:[{required:!0}],children:(0,C.jsx)(w.h,{scrollId:"name",watch:!0,height:140,placeholder:n,showNullButton:!0,onCMBeforeChange:function(e,n){!function(e,n,t,i){var r=e.getRange(n.from,n.to),a=0;if(n.text.forEach((function(e){a+=e.split(A).length-1})),"setValue"!==n.origin)if(r&&-1!==r.indexOf(A)){var l=r.split(A).length-1,s=v(e,n.from);console.log("删除".concat(l,"个, 前面有").concat(s,"个,新增").concat(a,"个")),i(l>1?Array.from({length:l},(function(e,n){return s+n})):s)}else if(a>0){var c=v(e,n.from);console.log("新增".concat(a,"个,之前有").concat(c,"个")),t(a,c)}}(e,n,Z,T)}})})}),(0,C.jsx)(y.Z.List,{name:s,rules:[{validator:function(e,n){if(0===(null==n?void 0:n.length))return Promise.reject(new Error("答案不能为空"));var t,i=l()(n);try{for(i.s();!(t=i.n()).done;){var r=(t.value||{}).answer_text;if(null!=r&&r.some((function(e){return 0===(null==e?void 0:e.length)})))return Promise.reject(new Error("填空项答案不能为空"))}}catch(e){i.e(e)}finally{i.f()}return Promise.resolve()}}],children:function(e,n,t){var i=n.add,l=n.remove;t.errors;return b.current=i,P.current=l,(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(y.Z.Item,{label:"答案选项",required:!0,labelCol:{span:24}}),e.map((function(e,n){var t=e.key,i=e.name,l=r()(e,E);return(0,C.jsxs)(x.Z,{className:"mb20",align:"middle",wrap:!1,children:[(0,C.jsxs)(g.Z,{flex:"0 0 auto",className:"".concat(N.Z.blankIndex),children:["填空项",n+1]}),(0,C.jsxs)(g.Z,{flex:1,children:[(0,C.jsxs)(x.Z,{align:"top",justify:"space-between",wrap:!1,children:[(0,C.jsx)(g.Z,{children:(0,C.jsx)(y.Z.Item,u()(u()({},l),{},{name:[i,"answer_text"],noStyle:!0,children:(0,C.jsx)(I,{})}))}),a&&(0,C.jsx)(g.Z,{flex:"224px",children:(0,C.jsx)(y.Z.Item,u()(u()({},l),{},{name:[i,"score"],label:"分值",rules:[{required:!0}],className:N.Z.blankInputNumberWrapper,children:(0,C.jsx)(k.Z,{className:N.Z.blankInput,min:.1,max:100,precision:1,style:{width:"100%"},placeholder:"按空给分请输入分值"})}))})]}),(0,C.jsx)(y.Z.Item,u()(u()({},l),{},{name:[i,"position"],noStyle:!0,children:(0,C.jsx)(j.Z,{type:"hidden"})}))]})]},t)}))]})}}),(null==R?void 0:R.length)>1&&(0,C.jsxs)(x.Z,{align:"middle",className:(null==R?void 0:R.length)>1?"mb30":"".concat(N.Z.hide),children:[(0,C.jsx)(y.Z.Item,{name:"is_ordered",children:(0,C.jsx)(S,{})}),(0,C.jsx)(g.Z,{className:"ml10",children:"允许学生每个填空的答案与标准答案的顺序不一致"})]}),(0,C.jsx)("div",{onClick:function(){return h(!0)},children:(0,C.jsx)(y.Z.Item,{name:"analysis",label:"题目解析",labelCol:{span:24},children:(0,C.jsx)(w.x,{placeholder:"请编辑题目解析(非必填)",isEdit:f})})})]})}},23361:function(e,n,t){t.d(n,{Z:function(){return b}});var i=t(39647),r=t.n(i),a=t(79800),l=t.n(a),s=t(82242),c=t.n(s),o=t(85573),u=t.n(o),d=t(59301),p=t(95237),f=t(43604),h=t(78241),m=t(69092),v=t(58605),x=t(37712),g=["key","name"],j=u()(u()({},"正确","T"),"错误","F"),_=function(e){var n=e.value,t=e.onChange,i=e.form,r=1===(null==n?void 0:n.is_answer),a=null==n?void 0:n.choice_text,l=function(){var e=i.getFieldsValue().choices.map((function(e){return{choice_text:e.choice_text,is_answer:0}}));i.setFieldsValue({choices:e}),t(c()(c()({},n),{},{is_answer:1}))};return(0,x.jsxs)(p.Z,{className:m.Z.choiceWrap,align:"middle",wrap:!1,children:[(0,x.jsx)(f.Z,{onClick:l,className:"".concat(m.Z.choiceIndex," ").concat(m.Z.judgementIndex," ").concat(r?m.Z.activeAnswer:""),children:j[a]}),(0,x.jsx)(f.Z,{flex:1,className:"".concat(m.Z.editorWrap," ml15"),children:(0,x.jsx)("div",{className:"".concat(m.Z.inputBorder," ").concat(m.Z.placeholder," ").concat(r?m.Z.activeJudgementAnswer:""),children:a})}),(0,x.jsx)(f.Z,{flex:"0 0 auto",className:"ml15",children:(0,x.jsx)("div",{onClick:l,className:"".concat(m.Z.setAnswerBtn," ").concat(r?m.Z.activeAnswer:""),children:r?"正确答案":"设为答案"})})]})},b=function(e){var n=e.questionTitlePlaceholder,t=(e.choiceKey,e.form),i=(0,d.useState)(!1),a=l()(i,2),s=a[0],o=a[1];return(0,x.jsxs)("div",{className:m.Z.wrap,children:[(0,x.jsx)("div",{className:m.Z.questionTitleEditorWrap,children:(0,x.jsx)(h.Z.Item,{label:"题干",name:"name",labelCol:{span:24},rules:[{required:!0}],children:(0,x.jsx)(v.h,{scrollId:"name",watch:!0,height:140,placeholder:n})})}),(0,x.jsx)(h.Z.Item,{label:"答案选项",required:!0,labelCol:{span:24},children:(0,x.jsx)(h.Z.List,{name:"choices",rules:[{validator:function(e,n){return n.some((function(e){return 1===(null==e?void 0:e.is_answer)}))?Promise.resolve():Promise.reject(new Error("请设置正确答案"))}}],children:function(e){return(0,x.jsx)("div",{id:"choices",children:e.map((function(e){var n=e.key,i=e.name,a=r()(e,g);return(0,d.createElement)(h.Z.Item,c()(c()({},a),{},{key:n,name:i,noStyle:!0}),(0,x.jsx)(_,{form:t}))}))})}})}),(0,x.jsx)("div",{onClick:function(){return o(!0)},children:(0,x.jsx)(h.Z.Item,{name:"analysis",label:"题目解析",labelCol:{span:24},children:(0,x.jsx)(v.x,{placeholder:"请编辑题目解析(非必填)",isEdit:s})})})]})}},58605:function(e,n,t){t.d(n,{h:function(){return p},x:function(){return f}});var i=t(82242),r=t.n(i),a=t(39647),l=t.n(a),s=t(59081),c=t(69092),o=(t(59301),t(71212)),u=t(37712),d=["value","onChange","scrollId"],p=function(e){var n=e.value,t=e.onChange,i=e.scrollId,a=l()(e,d);return(0,u.jsx)("div",{id:i||"",children:(0,u.jsx)(s.Z,r()(r()({},a),{},{hidetoolBar:!0,defaultValue:n,onChange:function(e,n){console.log("a:",e,n),null!=n&&n.length?t(e,n):t(e)}}))})},f=function(e){var n=e.value,t=e.onChange,i=e.placeholder,r=e.height,a=void 0===r?140:r;return e.isEdit?(0,u.jsx)(s.Z,{watch:!0,isFocus:!0,height:a,placeholder:i,defaultValue:n,onChange:t}):(0,u.jsx)("div",{style:{cursor:"pointer"},children:n?(0,u.jsx)(o.Z,{className:c.Z.inputBorder,value:n}):(0,u.jsx)("div",{className:"".concat(c.Z.inputBorder," ").concat(c.Z.placeholder),children:i})})}},29137:function(e,n,t){t.d(n,{W:function(){return S}});var i=t(91232),r=t.n(i),a=t(79800),l=t.n(a),s=t(82242),c=t.n(s),o=t(39647),u=t.n(o),d=t(59301),p=t(8591),f=t(12563),h=t(78241),m=t(78673),v=t(95237),x=t(43604),g=t(6848),j=t(10249),_=t(5871),b=t(69092),y=t(58605),k=t(59081),w=t(61485),Z=t(37712),N=["value","onChange"],C=["key","name"],E=function(e){var n=e.value,t=e.onChange,i=u()(e,N);return(0,Z.jsx)(k.Z,c()(c()({},i),{},{defaultValue:null==n?void 0:n[0],onChange:function(e){t([e])}}))},I=function(e){var n=e.value,t=void 0===n?[]:n,i=e.onClose;return(0,Z.jsx)(f.Z,{closable:!0,onClose:i,className:b.Z.keywordTag,children:null==t?void 0:t.join(" 或 ")})},S=function(e){var n=e.questionTitlePlaceholder,t=e.form,i=e.showKeywords,a=e.isMustKeyWords,s=void 0===a?i:a,o=(0,d.useState)(!1),f=l()(o,2),k=f[0],N=f[1],S=(0,d.useState)(""),A=l()(S,2),P=A[0],T=A[1],R=h.Z.useWatch("use_keywords",t),O=h.Z.useWatch("question_score",t);return(0,Z.jsxs)("div",{className:b.Z.wrap,children:[(0,Z.jsx)("div",{className:b.Z.questionTitleEditorWrap,children:(0,Z.jsx)(h.Z.Item,{label:"题干",name:"name",labelCol:{span:24},rules:[{required:!0}],children:(0,Z.jsx)(y.h,{scrollId:"name",watch:!0,height:140,placeholder:n})})}),(0,Z.jsx)(h.Z.Item,{label:"参考答案",name:"answer_texts",labelCol:{span:24},children:(0,Z.jsx)(E,{watch:!0,height:140,placeholder:"请编辑参考答案(非必填)"})}),i&&!s&&(0,Z.jsx)(h.Z.Item,{hidden:!0,name:"use_keywords",valuePropName:"checked",children:(0,Z.jsx)(m.Z,{defaultChecked:!0})}),i&&s&&(0,Z.jsxs)(v.Z,{align:"middle",className:"mb30",children:[(0,Z.jsx)(h.Z.Item,{name:"use_keywords",valuePropName:"checked",children:(0,Z.jsx)(m.Z,{})}),(0,Z.jsx)(x.Z,{className:"ml10",children:"开启关键词自动判分"}),(0,Z.jsx)(x.Z,{children:(0,Z.jsx)(g.Z,{placement:"right",title:"选中后,需要设置每个关键词的分值,系统会根据设置的关键词进行自动判分; 所有关键词分值之和必须小于等于小题分值。",children:(0,Z.jsx)(w.Z,{style:{color:"#3061D0",marginLeft:6,cursor:"pointer"}})})})]}),(R||!s)&&(0,Z.jsx)(h.Z.List,{name:"keywords",rules:[{validator:function(e,n){return s?null!=n&&n.length?(null==n?void 0:n.reduce((function(e,n){return e+n.score}),0))>parseFloat(O)?Promise.reject(new Error("所有关键词的分值之和必须小于等于该小题的分值")):Promise.resolve():Promise.reject(new Error("请输入关键词")):Promise.resolve()}}],children:function(e,n){var i=n.add,a=n.remove;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)("div",{className:"".concat(b.Z.title," mb10"),children:s?"关键词":(0,Z.jsx)("span",{style:{color:"#9096A3"},children:"判分关键词"})}),(0,Z.jsxs)(v.Z,{align:"middle",className:"font14 mb30",children:[(0,Z.jsx)(x.Z,{flex:1,children:(0,Z.jsx)(j.Z,{value:P,onChange:function(e){T(e.target.value)},maxLength:50,allowClear:!0,onPressEnter:function(e){var n,a,l,s,c,o="".concat(null===(n=e.target)||void 0===n?void 0:n.value).replaceAll(" ",""),u=null==o||null===(a=o.split("|"))||void 0===a?void 0:a.filter((function(e){return!!e})),d=t.getFieldValue("keywords"),f=(null==d||null===(l=d.map((function(e){return null==e?void 0:e.keyword})))||void 0===l?void 0:l.flat())||[],h=r()(u);try{for(h.s();!(s=h.n()).done;){var m=s.value;if(f.includes(m))return void p.ZP.error("为避免判分错误,请勿设置相同的关键词")}}catch(e){h.e(e)}finally{h.f()}(c=o)&&(new RegExp("[ `~!@#$^&*()={}':;,\\[\\].<>/?~@#¥……&*—【】”“。「」『』_\\+\\-·%《》]|[\\\\/]"),"|"!==c||(p.ZP.warning("关键词不能只输入一个“|”字符!"),0))&&(i({keyword:u,score:1}),T(""))},className:b.Z.inputBorder,placeholder:"支持设置多个关键词;并列关键词(或的关系)请用“|”分隔开"})}),(0,Z.jsx)(x.Z,{flex:"148px",style:{textAlign:"right",color:"#9096A3"},children:"“回车键”保存关键词"})]}),e.map((function(e){var n=e.key,t=e.name,i=u()(e,C);return(0,Z.jsx)(v.Z,{className:"mb20",style:{marginRight:148},children:(0,Z.jsx)(x.Z,{flex:1,children:(0,Z.jsxs)(v.Z,{align:"middle",justify:"space-between",children:[(0,Z.jsx)(h.Z.Item,c()(c()({},i),{},{name:[t,"keyword"],children:(0,Z.jsx)(I,{onClose:function(){return a(t)}})})),s&&(0,Z.jsx)(h.Z.Item,c()(c()({},i),{},{name:[t,"score"],label:"分值",rules:[{required:!0}],className:b.Z.blankInputNumberWrapper,children:(0,Z.jsx)(_.Z,{className:b.Z.blankInput,min:.1,max:100,precision:1,style:{width:"100%"},placeholder:"请输入关键词分数"})}))]})})},n)}))]})}}),(0,Z.jsx)("div",{onClick:function(){return N(!0)},children:(0,Z.jsx)(h.Z.Item,{name:"analysis",label:"题目解析",labelCol:{span:24},children:(0,Z.jsx)(y.x,{placeholder:"请编辑题目解析(非必填)",isEdit:k})})})]})}},96196:function(e,n,t){t.d(n,{Wk:function(){return l.W},ZZ:function(){return r.Z},rL:function(){return s.r},tc:function(){return c.t},u8:function(){return a.u},uh:function(){return i.u}});var i=t(2648),r=t(23361),a=t(30286),l=t(29137),s=t(87651),c=t(60030)},71212:function(e,n,t){t.d(n,{Z:function(){return q}});var i=t(82242),r=t.n(i),a=t(37205),l=t.n(a),s=t(91232),c=t.n(s),o=t(79800),u=t.n(o),d=t(59301),p=(t(88831),t(32834)),f=t.n(p),h=t(11690);var m=[],v=["<ul>"],x=new(f().Renderer),g=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function j(){m.length=0,v=["<ul>"]}var _={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function b(e,n,t,i){if(n>=e.length||e[n].level<=t)return n;var r=e[n];i.push("<li><a href='#"+r.anchor+"'>"+r.text+"</a>");var a=[];return n=b(e,++n,r.level,a),a.length>0&&(i.push("<ul>"),a.forEach((function(e){i.push(e)})),i.push("</ul>")),i.push("</li>"),n=b(e,n,t,i)}function y(){return b(m,0,0,v),v.push("</ul>"),v.join("")}var k={heading:function(e){var n=g.exec(e);if(n)return{type:"heading",raw:n[0],depth:n[1].length,text:n[2]}},fences:function(e){var n=this.rules.block.fences.exec(e);if(n){var t=n[0],i=function(e,n){var t=e.match(/^(\s+)(?:```)/);if(null===t)return n;var i=t[1];return n.split("\n").map((function(e){var n=e.match(/^\s+/);return null===n?e:u()(n,1)[0].length>=i.length?e.slice(i.length):e})).join("\n")}(t,n[3]||""),r=n[2]?n[2].trim():n[2];if(["latex","katex","math"].indexOf(r)>=0){var a=N(),l=i;i=a,C[a]={type:"block",expression:l}}return{type:"code",raw:t,lang:r,text:i}}}},w=/(?:\${2})([^\n`]+?)(?:\${2})/gi,Z=0,N=function(){return"__special_katext_id_".concat(Z++,"__")},C={};function E(){return C}function I(){Z=0,C={}}function S(e){return e=e.replace(w,(function(e,n){var t=N();return C[t]={type:"inline",expression:n},t}))}var A=x.listitem;x.listitem=function(e){return A(S(e))};var P=x.paragraph;x.paragraph=function(e){return P(S(e))};var T=x.tablecell;x.tablecell=function(e,n){return T(S(e),n)},x.code=function(e,n,t){var i=(n||"").match(/\S*/)[0];return i?["latex","katex","math"].indexOf(i)>=0?"<p class='editormd-tex'>".concat(e,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(n,'">').concat(t?e:(0,h.escape)(e,!0),"</code></pre>\n"):'<pre class="prettyprint linenums"><code>'+(t?e:(0,h.escape)(e,!0))+"</code></pre>"},x.heading=function(e,n,t){var i=this.options.headerPrefix+t.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return m.push({anchor:i,level:n,text:e}),"<h"+n+' id="'+i+'">'+e+"</h"+n+">"},f().setOptions({silent:!0,gfm:!0,pedantic:!1}),f().use({tokenizer:k,renderer:x});var R=f(),O=(t(64018),t(44523)),F=t(91689),B=t(15342),L=t(1012),M=t(32831),V=t(37712),W="@▁@",D=/<pre[^>]*>/g;var q=function(e){var n=e.value,t=void 0===n?"":n,i=e.className,a=e.showTextOnly,s=e.showLines,o=e.style,p=void 0===o?{}:o,f=e.stylesPrev,h=void 0===f?{}:f,m=e.highlightKeywords,v=e.showProgramFill,x=(e.isProgramFill,e.disabledFill),g=void 0!==x&&x,b=e.programFillValue,k=e.onFillChange,w=void 0===k?function(e){}:k,Z=e.onFillBlur,N=void 0===Z?function(){}:Z,C=String(t),S=(0,d.useState)(""),A=u()(S,2),P=A[0],T=A[1],q=(0,d.useState)("office"),U=u()(q,2),K=U[0],H=U[1],G=(0,d.useState)([]),z=u()(G,2),J=z[0],Y=z[1],X=(0,d.useRef)("a"+(0,L.Z)()),Q={},$=function(e){return e.replace(/<style.*?>([\s\S]+?)<\/style>/gim,(function(e,n){var t=n.replace(/(\n|\r)/g,"").split("}"),i=[];return t.map((function(e){""!=e&&i.push(".".concat(X.current," ").concat(e))})),"<style>".concat(i.join("}"),"</style>")}))},ee=(0,d.useMemo)((function(){try{C=C.replace(/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,"("+F.Z.API_SERVER+"/api/attachments/").replace(/\"\/api\/attachments\/|\"\/attachments\/download\//g,'"'+F.Z.API_SERVER+"/api/attachments/").replace(/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g,'"'+F.Z.API_SERVER+"/files/uploads/").replaceAll("http://video.educoder","https://video.educoder").replaceAll("http://www.educoder.net/api","https://data.educoder.net/api").replaceAll("https://www.educoder.net/api","https://data.educoder.net/api").replace(/\r\n/g,"\n")}catch(e){}if(v){var e=-1;return C=C.replaceAll("<","&lt;").replaceAll(">","&gt;").replace(/(@▁▁@|@▁@)/g,(function(n,t,i){return function(e,n){var t=document.createElement(e===W?"input":"textarea");t.style.width="100%",t.style.height=e===W?"40px":"151px",t.rows=5,t.spellcheck=!1,t.name="edu-program-fill",t.placeholder="请输入",t.dataset.id=n;var i=Object.keys(Q).length;return Q[i]=t,'<span class="edu-program-fill-wrap '.concat(e===W?"":"show",'" style="width:').concat(e===W?"200px":"100%",'"><span>').concat(t.outerHTML,'<span class="edu-program-fill-score"></span></span></span>')}(n,++e)})),'<pre style="background:#fff;padding:4px">'.concat($(C||""),"</pre>")}var n=R(C);n=$(n);var t=E();C.match(/\[TOC\]/)&&(n=n.replace("<p>[TOC]</p>",y()),j()),n=n.replace(/(__special_katext_id_\d+__)/g,(function(e,n){var i=t[n],r=i.type,a=i.expression;return(0,B.renderToString)(function(e){var n=document.createElement("div");return n.innerHTML=e,0===n.childNodes.length?"":n.childNodes[0].nodeValue}(a)||"",{displayMode:"block"===r,throwOnError:!1,output:"html"})})),n=n.replace(/▁/g,"▁▁▁"),I();var i=document.createElement("div");return i.innerHTML=n,m?(ie(i,m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),i.innerHTML):a?i.innerText:(setTimeout((function(){return le()}),500),i.innerHTML)}),[C,m]);(0,d.useEffect)((function(){re.current&&re.current.querySelectorAll(["input","textarea"]).forEach((function(e){e.oninput=ne,e.onblur=te}))}),[J]),(0,d.useEffect)((function(){if(null!=b&&b.length){var e,n=re.current.querySelectorAll(".edu-program-fill-score"),t=re.current.querySelectorAll('[name="edu-program-fill"]'),i=c()(t.entries());try{for(i.s();!(e=i.n()).done;){var r,a=u()(e.value,2),l=a[0],s=a[1];s.value=null===(r=b[l])||void 0===r?void 0:r.value,"warning"===b[l].type?s.className="program-fill-warning":"success"===b[l].type?s.className="program-fill-success":s.className=""}}catch(e){i.e(e)}finally{i.f()}var o,d=c()(n.entries());try{for(d.s();!(o=d.n()).done;){var p,f,h=u()(o.value,2),m=h[0];h[1].innerHTML=null!==(p=b[m])&&void 0!==p&&p.score?"".concat(null===(f=b[m])||void 0===f?void 0:f.score,"分"):""}}catch(e){d.e(e)}finally{d.f()}Y(b)}}),[b]);var ne=function(e){J[e.target.dataset.id]=J[e.target.dataset.id]||{},J[e.target.dataset.id].value=e.target.value,Y(l()(J)),w(J,e.target.dataset.id)},te=function(e){J[e.target.dataset.id]=J[e.target.dataset.id]||{},J[e.target.dataset.id].value=e.target.value,Y(l()(J)),N(J,e.target.dataset.id)};function ie(e,n){return e.childNodes.forEach((function(e){if(e.childNodes.length>0)ie(e,n);else if("IMG"!==e.nodeName)if(e.innerHTML){var t;e.innerHTML=null===(t=e.innerHTML)||void 0===t?void 0:t.replace(new RegExp(n,"gi"),'<span style="color:#0152d9;background-color:#1890ff33">$&</span>')}else{var i=document.createElement("span");i.innerHTML=e.textContent.replace(new RegExp(n,"gi"),'<span style="color:#0152d9;background-color:#1890ff33">$&</span>'),e.replaceWith(i)}}))}var re=(0,d.useRef)();function ae(e){var n=e.target;if("A"===n.tagName.toUpperCase()){var t=n.getAttribute("href");if(t.indexOf("office")>-1)e.preventDefault(),T(t),H("office");else if(t.indexOf("application/pdf")>-1)e.preventDefault(),T(t),H("pdf");else if(t.indexOf("text/html")>-1)e.preventDefault(),T(t),H("html");else if(t.startsWith("#")){e.preventDefault();var i=document.getElementById(t.replace("#",""));i&&i.scrollIntoView(!0)}}}_.WebkitLineClamp=s,s&&(p=r()(r()({},p),_));var le=function(){var e,n=null===(e=re.current)||void 0===e?void 0:e.querySelectorAll("video");null==n||n.forEach((function(e){if(e.oncontextmenu=function(){return!1},e.src.indexOf(".m3u8")>-1)if(e.canPlayType("application/vnd.apple.mpegurl"));else if(O.ZP.isSupported()){var n=new O.ZP;n.loadSource(e.src),n.attachMedia(e)}}))};return(0,d.useEffect)((function(){if(re.current&&ee&&ee.match(D)&&window.PR.prettyPrint(),re.current)return re.current.addEventListener("click",ae),function(){var e;null===(e=re.current)||void 0===e||e.removeEventListener("click",ae),I(),j()}}),[ee,re.current,ae]),(0,V.jsxs)(V.Fragment,{children:[a&&(0,V.jsx)("div",{ref:re,children:ee}),!a&&(0,V.jsx)("div",{ref:re,style:r()({},p),className:"".concat(i||""," ").concat(g?"disabled-fill":""," markdown-body ").concat(X.current),dangerouslySetInnerHTML:{__html:ee}}),(0,V.jsx)(M.Z,{close:!0,data:P,type:null!=P&&P.length?K:"",style:r()({},h),onClose:function(){return T("")}})]})}},48049:function(e,n,t){t.d(n,{Z:function(){return s}});t(59301);var i=t(49389),r="ldsRing___mpBZC",a="idsRingWrapper___Of9_n",l=t(37712),s=function(e){var n=e.message,t=e.className,s=(e.children,e.style),c=void 0===s?{}:s;return(0,l.jsxs)("div",{className:"".concat(a," ").concat(t),children:[(0,l.jsxs)("div",{className:r,children:[(0,l.jsx)("div",{}),(0,l.jsx)("div",{}),(0,l.jsx)("div",{}),(0,l.jsx)("div",{})]}),n?(0,l.jsx)("p",{style:c,children:n}):null,(0,l.jsx)(i.Outlet,{})]})}},17124:function(e,n,t){t.d(n,{h:function(){return x}});var i=t(82242),r=t.n(i),a=t(79800),l=t.n(a),s=t(59301),c=t(57809),o=t(78241),u=t(3113),d=t(89780),p=t.n(d),f=(t(66543),t(59598),t(37712)),h=c.default.Option,m={labelCol:{span:4},wrapperCol:{span:20}},v={asp:["ASP","vbscript"],actionscript:["ActionScript(3.0)/Flash/Flex","clike"],bash:["Bash/Bat","shell"],css:["CSS","css"],c:["C","clike"],cpp:["C++","clike"],csharp:["C#","clike"],coffeescript:["CoffeeScript","coffeescript"],d:["D","d"],dart:["Dart","dart"],delphi:["Delphi/Pascal","pascal"],erlang:["Erlang","erlang"],go:["Golang","go"],groovy:["Groovy","groovy"],html:["HTML","text/html"],java:["Java","clike"],json:["JSON","text/json"],javascript:["Javascript","javascript"],lua:["Lua","lua"],less:["LESS","css"],markdown:["Markdown","gfm"],"objective-c":["Objective-C","clike"],php:["PHP","php"],perl:["Perl","perl"],python:["Python","python"],r:["R","r"],rst:["reStructedText","rst"],ruby:["Ruby","ruby"],sql:["SQL","sql"],sass:["SASS/SCSS","sass"],shell:["Shell","shell"],scala:["Scala","clike"],swift:["Swift","clike"],vb:["VB/VBScript","vb"],xml:["XML","text/xml"],yaml:["YAML","yaml"]};function x(e){var n=e.value,t=e.onChange,i=e.mode,a=e.options,c=void 0===a?{}:a,o=(0,s.useRef)(),u=(0,s.useState)(),d=l()(u,2),h=d[0],m=d[1];return(0,s.useEffect)((function(){if(h){var e=function(e){var n=e.getValue();t&&t(n)};return h.on("change",e),function(){h.off("change",e)}}}),[h,t]),(0,s.useEffect)((function(){h&&h.setOption("mode",i)}),[h,i]),(0,s.useEffect)((function(){h&&(n===h.getValue()&&""!==n||setTimeout((function(){h.setValue(n||"")}),300))}),[h,n]),(0,s.useEffect)((function(){if(o.current&&!h){var e=p().fromTextArea(o.current,r()({mode:i,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},c));m(e)}}),[o.current,h]),(0,f.jsx)("div",{className:"my-codemirror-container",children:(0,f.jsx)("textarea",{ref:o})})}n.Z=function(e){var n=e.callback,t=e.onCancel,i=(0,s.useState)("python"),a=l()(i,2),d=a[0],p=a[1];return(0,f.jsxs)(o.Z,r()(r()({},m),{},{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:function(e){n(e)},children:[(0,f.jsx)(o.Z.Item,{label:"代码语言",name:"language",children:(0,f.jsx)(c.default,{getPopupContainer:function(e){return e.parentNode},onChange:function(e){p(v[e][1])},children:Object.keys(v).map((function(e){return(0,f.jsx)(h,{value:e,children:v[e][0]},e)}))})}),(0,f.jsx)(o.Z.Item,{label:"代码内容",name:"content",rules:[{required:!0,message:"请输入代码内容"}],children:(0,f.jsx)(x,{mode:d})}),(0,f.jsxs)("div",{className:"flex-container flex-end",children:[(0,f.jsx)(u.ZP,{type:"primary",htmlType:"submit",style:{marginRight:10},children:"确定"}),(0,f.jsx)(u.ZP,{type:"ghost",onClick:t,children:"取消"})]})]}))}},59081:function(e,n,t){t.d(n,{Z:function(){return ce}});var i=t(91232),r=t.n(i),a=t(7557),l=t.n(a),s=t(41498),c=t.n(s),o=t(79800),u=t.n(o),d=t(85573),p=t.n(d),f=t(59301),h=t(89780),m=t.n(h),v=t(76374),x=(t(66543),t(6313),t(25717),t(99498),t(25419),t(67549),t(71212)),g=t(37712),j=function(e){var n=e.value,t=void 0===n?"":n,i=(e.className,e.showTextOnly,e.showLines,e.style,(0,f.useMemo)((function(){return""}),[t]));return(0,g.jsx)(g.Fragment,{children:(0,g.jsx)("div",{dangerouslySetInnerHTML:{__html:i}})})},_=t(82242),b=t.n(_),y=[{title:"粗体",icon:"icon-bold",actionName:"bold"},{title:"斜体",icon:"icon-italic",actionName:"italic"},"|",{title:"无序列表",icon:"icon-unorder-list",actionName:"list-ul"},{title:"有序列表",icon:"icon-order-list",actionName:"list-ol"},"|",{title:"行内代码",icon:"icon-code",actionName:"code"},{title:"代码块(多语言风格)",icon:"icon-file-code",actionName:"code-block"},{title:"链接",icon:"icon-link",actionName:"link"},"|",{title:"行内公式",icon:"icon-sum",actionName:"inline-latex"},{title:"多行公式",icon:"icon-formula",actionName:"latex"},"|",{title:"添加图片",icon:"icon-picture",actionName:"upload-image"},{title:"表格",icon:"icon-table",actionName:"add-table"},"|",{title:"换行",icon:"icon-minus",actionName:"line-break"},{title:"清空",icon:"icon-eraser",actionName:"eraser"}];function k(e){var n=e.onActionCallback,t=e.title,i=e.icon,r=e.actionName,a=e.className,l=void 0===a?"":a,s=e.children;return(0,g.jsxs)("a",{title:t,className:l,onClick:function(){n(r)},children:[(0,g.jsx)("i",{className:"md-iconfont ".concat(i)}),s]})}var w=function(e){var n=e.watch,t=e.showNullButton,i=e.showNullProgramButton,r=e.onActionCallback,a=e.fullScreen,l=e.insertTemp,s=e.hidetoolBar,c=[].concat(y,[{title:"".concat(n?"关闭实时预览":"开启实时预览"),icon:"".concat(n?"icon-eye-slash":"icon-eye"),actionName:"trigger-watch"}]);return(0,g.jsxs)("ul",{className:"markdown-toolbar-container",children:[!s&&c.map((function(e,n){return(0,g.jsx)("li",{children:e.actionName?(0,g.jsx)(k,b()(b()({},e),{},{onActionCallback:r})):(0,g.jsx)("span",{className:"v-line"})},n)})),t?(0,g.jsx)("li",{children:(0,g.jsx)(k,{icon:"icon-edit insert-blank",className:"btn-null",title:"增加填空",actionName:"add-null-ch",onActionCallback:r,children:(0,g.jsx)("span",{className:"fill-tip",children:"点击插入\b填空项"})})}):null,i?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("li",{children:(0,g.jsx)(k,{icon:"icon-edit insert-blank",className:"btn-null",title:"增加填空",actionName:"add-signal",onActionCallback:r,children:(0,g.jsx)("span",{className:"fill-tip",children:"添加单行填空项"})})}),(0,g.jsx)("li",{children:(0,g.jsx)(k,{icon:"icon-uniE900 insert-blank",className:"btn-null",title:"增加填空",actionName:"add-multiple",onActionCallback:r,children:(0,g.jsx)("span",{className:"fill-tip",children:"添加多行填空项"})})})]}):null,l&&(0,g.jsx)("li",{children:(0,g.jsx)(k,{icon:"icon-edit",className:"btn-null",title:"插入模板",actionName:"inster-template-".concat(l),onActionCallback:r,children:(0,g.jsx)("span",{className:"fill-tip",children:"插入模板"})})}),(0,g.jsx)("li",{className:"btn-full-screen",children:(0,g.jsx)(k,{icon:"".concat(a?"icon-shrink":"icon-enlarge"),title:a?"关闭全屏":"开启全屏",actionName:"trigger-full-screen",onActionCallback:r})})]})},Z=t(82255),N=t(78241),C=t(10249),E=t(3113),I={labelCol:{span:4},wrapperCol:{span:20}},S=function(e){var n=e.callback,t=e.onCancel;return(0,g.jsxs)(N.Z,b()(b()({},I),{},{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:function(e){n(e)},children:[(0,g.jsx)(N.Z.Item,{label:"链接地址",name:"link",rules:[{required:!0,message:"请输入链接地址"}],children:(0,g.jsx)(C.Z,{})}),(0,g.jsx)(N.Z.Item,{label:"链接标题",name:"title",rules:[{required:!0,message:"请输入链接标题"}],children:(0,g.jsx)(C.Z,{})}),(0,g.jsxs)("div",{className:"flex-container flex-end",children:[(0,g.jsx)(E.ZP,{type:"primary",htmlType:"submit",style:{marginRight:10},children:"确定"}),(0,g.jsx)(E.ZP,{type:"ghost",onClick:t,children:"取消"})]})]}))},A=t(17124),P=t(8591),T=t(78988),R=N.Z.useForm,O={width:280,marginRight:10},F={labelCol:{span:5},wrapperCol:{span:19}},B=function(e){var n=e.callback,t=e.onCancel,i=R(),r=u()(i,1)[0],a=(0,f.useRef)();function l(e,n){-1!==e.status?r.setFieldsValue({src:"/api/attachments/".concat(e.id),type:n.type}):P.ZP.error(e.message)}return(0,g.jsxs)(N.Z,b()(b()({form:r},F),{},{className:"upload-image-panel",onFinish:function(e){n(b()(b()({},e),{},{name:a.current}))},style:{width:470,overflow:"hidden"},children:[(0,g.jsx)(N.Z.Item,{label:"图片地址",required:!0,children:(0,g.jsxs)("div",{className:"flex-container",children:[(0,g.jsx)(N.Z.Item,{noStyle:!0,name:"src",rules:[{required:!0,message:"请输入文件地址"}],children:(0,g.jsx)(C.Z,{style:O})}),(0,g.jsx)(L,{onFileChange:function(e){var n=e.target.files[0];a.current=n.name,M(n,l)}})]})}),(0,g.jsx)(N.Z.Item,{label:"图片描述",name:"alt",children:(0,g.jsx)(C.Z,{style:{width:264}})}),(0,g.jsxs)(N.Z.Item,{style:{textAlign:"right"},children:[(0,g.jsx)(E.ZP,{type:"primary",htmlType:"submit",style:{marginRight:10},children:"确定"}),(0,g.jsx)(E.ZP,{type:"default",onClick:t,children:"取消"})]})]}))};function L(e){var n=e.onFileChange;return(0,g.jsxs)("label",{className:"upload-button",style:{cursor:"pointer"},children:["本地上传",(0,g.jsx)("input",{type:"file",onChange:n})]})}function M(e,n){if(!e)throw new String("没有文件");var t=new FormData;t.append("editormd-image-file",e),t.append("file_param_name","editormd-image-file"),t.append("byxhr","true");var i=new window.XMLHttpRequest;i.withCredentials=!0,i.addEventListener("load",(function(t){n(JSON.parse(t.target.responseText),e)}),!1),i.addEventListener("error",(function(e){console.error(e)}),!1),i.open("POST","".concat(T.KI,"/api/attachments.json")),i.send(t)}var V=t(5112),W=t(5871),D=V.ZP.Group,q={margin:"0 8px"},U=function(e){var n=e.callback,t=e.onCancel;return(0,g.jsxs)(N.Z,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:function(e){n(e)},children:[(0,g.jsxs)("div",{className:"flex-container",style:{alignItems:"baseline"},children:[(0,g.jsx)("span",{style:q,children:"单元格数:"}),(0,g.jsx)("span",{style:q,children:"行数"}),(0,g.jsx)(N.Z.Item,{name:"row",rules:[{required:!0,message:"请输入行数"}],children:(0,g.jsx)(W.Z,{})}),(0,g.jsx)("span",{style:q,children:"列数"}),(0,g.jsx)(N.Z.Item,{name:"col",rules:[{required:!0,message:"请输入列数"}],children:(0,g.jsx)(W.Z,{})})]}),(0,g.jsxs)("div",{className:"flex-container",style:{marginTop:12,alignItems:"baseline"},children:[(0,g.jsx)("span",{style:q,children:"对齐方式:"}),(0,g.jsx)(N.Z.Item,{name:"align",children:(0,g.jsxs)(D,{children:[(0,g.jsx)(V.ZP,{value:"default",children:(0,g.jsx)("i",{className:"fa fa-align-justify"})}),(0,g.jsx)(V.ZP,{value:"left",children:(0,g.jsx)("i",{className:"fa fa-align-left"})}),(0,g.jsx)(V.ZP,{value:"center",children:(0,g.jsx)("i",{className:"fa fa-align-center"})}),(0,g.jsx)(V.ZP,{value:"right",children:(0,g.jsx)("i",{className:"fa fa-align-right"})})]})})]}),(0,g.jsxs)("div",{className:"flex-container flex-end",children:[(0,g.jsx)(E.ZP,{type:"primary",htmlType:"submit",style:{marginRight:10},children:"确定"}),(0,g.jsx)(E.ZP,{type:"ghost",onClick:t,children:"取消"})]})]})},K=t(91689),H=t(94171),G=t(1012),z=t(43418),J="link",Y="upload-image",X="code-block",Q="add-table",$="------------",ee={default:$,left:":".concat($),center:":".concat($,":"),right:"".concat($,":")},ne=t(22336);var te="@▁▁@";function ie(e){return/^\d+$/.test(e)?"".concat(e,"px"):e}var re=navigator.platform.toUpperCase().indexOf("MAC")>=0?"Cmd":"Ctrl",ae=["pptm","pptx","ppt","pot","pps","ppa","potx","ppsx","ppam","pptm","potm","ppsm","doc","docx","dot","dotx","docm","dotm","xls","xlsx","csv","xlt","xla","xltx","xlsm","xltm","xlam","xlsb"],le=p()(p()({},re+"-B","bold"),re+"-I","italic"),se=p()(p()(p()(p()({},J,"添加链接"),X,"添加代码块"),Y,"添加文件"),Q,"添加表格"),ce=function(e){var n=e.defaultValue,t=void 0===n?"":n,i=e.onChange,a=e.width,s=void 0===a?"100%":a,o=e.height,d=void 0===o?400:o,h=e.miniToolbar,_=void 0!==h&&h,b=e.isFocus,y=void 0!==b&&b,k=e.watch,N=e.insertTemp,C=e.mode,E=void 0===C?"markdown":C,I=e.id,T=void 0===I?"markdown-editor-id":I,R=e.showResizeBar,O=void 0!==R&&R,F=e.noStorage,L=void 0!==F&&F,V=e.showNullButton,W=void 0!==V&&V,D=e.showNullProgramButton,q=void 0!==D&&D,$=e.hidetoolBar,re=void 0!==$&&$,ce=e.fullScreen,oe=void 0!==ce&&ce,ue=e.onBlur,de=e.onCMBeforeChange,pe=e.onFullScreen,fe=e.className,he=void 0===fe?"":fe,me=e.disablePaste,ve=void 0!==me&&me,xe=e.disabled,ge=void 0!==xe&&xe,je=e.disabledFill,_e=void 0!==je&&je,be=e.placeholder,ye=void 0===be?"":be,ke=e.values,we=void 0===ke?"":ke,Ze=(0,f.useState)(null),Ne=u()(Ze,2),Ce=Ne[0],Ee=Ne[1],Ie=(0,f.useState)(t),Se=u()(Ie,2),Ae=Se[0],Pe=Se[1],Te=(0,f.useState)(k),Re=u()(Te,2),Oe=Re[0],Fe=Re[1],Be=(0,f.useState)(oe),Le=u()(Be,2),Me=Le[0],Ve=Le[1],We=(0,f.useState)(""),De=u()(We,2),qe=De[0],Ue=De[1],Ke=(0,f.useState)(0),He=u()(Ke,2),Ge=He[0],ze=He[1],Je=(0,f.useState)(d),Ye=u()(Je,2),Xe=Ye[0],Qe=Ye[1],$e=(0,f.useState)(!1),en=u()($e,2),nn=(en[0],en[1]),tn=(0,f.useRef)((0,G.Z)()),rn=(0,f.useRef)(!1),an=(0,f.useRef)(),ln=(0,f.useRef)(),sn=(0,f.useRef)(),cn=(0,f.useRef)(),on=(0,f.useRef)(),un=function(){var e=c()(l()().mark((function e(){var n,t;return l()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,H.ZP)("/api/attachments/distinct_hash_val.json",{method:"post",body:{hash_val:tn.current}});case 2:null!=(t=e.sent)&&null!==(n=t.attachments)&&void 0!==n&&n.length&&(console.log("cm:",Ce,ln),t.attachments.map((function(e){e.content_type.indexOf("image")>-1?Ce.replaceSelection("![,](/api/attachments/".concat(e.id,"?type=").concat(e.content_type,")")):e.content_type.indexOf("video")>-1?Ce.replaceSelection('<video width="100%" controls src="'.concat(K.Z.API_SERVER,"/api/attachments/").concat(data.id,'"></video>')):e.content_type.indexOf("pdf")>-1?Ce.replaceSelection('<a href="'.concat(K.Z.API_SERVER,"/api/attachments/").concat(e.id,"?type=").concat(e.content_type,'&disposition=inline" target="_blank">').concat(e.name,"</a>")):Ce.replaceSelection("[".concat(e.name,"](").concat(K.Z.API_SERVER,"/api/attachments/").concat(e.id,"?type=").concat(e.content_type,")"))})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();(0,f.useEffect)((function(){var e=window.scrollY||window.pageYOffset;Pe(we),null==Ce||Ce.setValue(we),window.scrollTo(0,e)}),[we]),(0,f.useEffect)((function(){null==pe||pe(Me)}),[Me]),(0,f.useEffect)((function(){if(ln.current){var e=function(e,t){if(!ve){var i=t.clipboardData;if(i){var r=i.types.toString(),a=i.items;if("Files"===r||i.types.indexOf("Files")>-1){if(t.preventDefault(),"stex"==E)return;try{var l,s=a[1];"file"===(null===(l=a[0])||void 0===l?void 0:l.kind)&&(s=a[0]);var c=s.getAsFile(),o=c.name.split(".").pop();M(c,(function(e){var t,i,r;e.id?(null==c||null===(t=c.type)||void 0===t?void 0:t.indexOf("image"))>-1?n.replaceSelection("![,](/api/attachments/".concat(e.id,"?type=").concat(e.content_type,")")):(null==c||null===(i=c.type)||void 0===i?void 0:i.indexOf("video"))>-1?n.replaceSelection('<video width="100%" controls src="'.concat(K.Z.API_SERVER,"/api/attachments/").concat(e.id,'"></video>')):(null==c||null===(r=c.type)||void 0===r?void 0:r.indexOf("pdf"))>-1?n.replaceSelection('<a href="'.concat(K.Z.API_SERVER,"/api/attachments/").concat(e.id,"?type=").concat(c.type,'&disposition=inline" target="_blank">').concat(c.name,"</a>")):ae.includes(o)?n.replaceSelection('<a href="'.concat(K.Z.API_SERVER,"/api/attachments/").concat(e.id,'?type=office&disposition=inline" target="_blank">').concat(c.name,"</a>")):n.replaceSelection("[".concat(c.name,"](").concat(K.Z.API_SERVER,"/api/attachments/").concat(e.id,"?type=").concat(e.content_type,")")):401===(null==e?void 0:e.status)&&(document.location.href="/user/login")}))}catch(t){P.ZP.warning("请使用chrome浏览器粘贴")}return!0}return!0}return!0}t.preventDefault()},n=m().fromTextArea(ln.current,{mode:E,lineNumbers:!_,lineWrapping:!0,value:t,autoCloseTags:!q,autoCloseBrackets:!0});return n.on("keyup",(function(e,t){8===t.keyCode&&(""==e.getValue()?n.setOption("placeholder",ye):n.setOption("placeholder",null))})),n.on("keydown",(function(e,n){if(8===n.keyCode){var t=function(e,n){var t=e.getDoc(),i=t.getCursor(),r=t.getLine(i.line),a=r.charAt(i.ch-1),l=r.lastIndexOf("@▁@",i.ch),s=r.lastIndexOf("@▁▁@",i.ch),c=l>s?l:s,o=l>s?3:4;if(-1===te.indexOf(a))return null;if(console.log("change1:",n,e,r,i,c,l,s,a),c>=0&&i.ch-c<5){var u=c+o;return t.replaceRange("",{line:i.line,ch:c},{line:i.line,ch:u}),{line:i.line,ch:u}}return null}(e);t&&n.preventDefault()}})),y&&n.focus(),n.on("paste",e),n.on("dragleave",(function(e,n){sn.current.classList.remove("mouse-hover-md")})),n.on("dragover",(function(e,n){sn.current.classList.add("mouse-hover-md")})),n.on("drop",(function(e,t){var i;if(sn.current.classList.add("mouse-hover-md"),(i=t.dataTransfer.files).length>0){t.preventDefault(),t.stopPropagation();for(var r=function(){var e=i[a],t=e.name.split(".").pop();M(e,(function(i){var r,a,l;i.id?(null==e||null===(r=e.type)||void 0===r?void 0:r.indexOf("image"))>-1?n.replaceSelection("![,](/api/attachments/".concat(i.id,"?type=").concat(i.content_type,")")):(null==e||null===(a=e.type)||void 0===a?void 0:a.indexOf("video"))>-1?n.replaceSelection('<video width="100%" controls src="'.concat(K.Z.API_SERVER,"/api/attachments/").concat(i.id,'"></video>')):(null==e||null===(l=e.type)||void 0===l?void 0:l.indexOf("pdf"))>-1?n.replaceSelection('<a href="'.concat(K.Z.API_SERVER,"/api/attachments/").concat(i.id,"?type=").concat(e.type,'&disposition=inline" target="_blank">').concat(e.name,"</a>")):ae.includes(t)?n.replaceSelection('<a href="'.concat(K.Z.API_SERVER,"/api/attachments/").concat(i.id,'?type=office&disposition=inline" target="_blank">').concat(e.name,"</a>")):n.replaceSelection("[".concat(e.name,"](").concat(K.Z.API_SERVER,"/api/attachments/").concat(i.id,"?type=").concat(i.content_type,")")):401===(null==i?void 0:i.status)&&(document.location.href="/user/login")}))},a=0;a<i.length;a++)r()}})),ge&&n.on("beforeChange",(function(e,n){"paste"!==n.origin&&"+input"!==n.origin||n.cancel()})),Ee(n),function(){n.off("paste",e)}}}),[]);var dn=(0,f.useCallback)((function(){sn.current}),[Xe,sn,Me]);(0,f.useEffect)((function(){if(Ce){var e=function(){var e=new v.Z((function(e){var n,t=r()(e);try{for(t.s();!(n=t.n()).done;){var i=n.value;(i.target.offsetHeight>0||i.target.offsetWidth>0)&&(dn(),Ce.setSize("100%","100%"),Ce.refresh())}}catch(e){t.e(e)}finally{t.f()}}));return e.observe(ln.current.parentElement),e}();return function(){var n,t;null!==(n=ln.current)&&void 0!==n&&n.parentElement&&e.unobserve(null===(t=ln.current)||void 0===t?void 0:t.parentElement)}}}),[Ce,dn]),(0,f.useEffect)((function(){if(Ce){for(var e=[],n=function(){var n=u()(i[t],2),r=n[0],a=n[1],l=p()({},r,(function(){pn(a)}));e.push(l),Ce.addKeyMap(l)},t=0,i=Object.entries(le);t<i.length;t++)n();return an.current=setInterval((function(){rn.current&&un()}),4e3),function(){clearInterval(an.current);for(var n=0,t=e;n<t.length;n++){var i=t[n];Ce.removeKeyMap(i)}}}}),[Ce]),(0,f.useEffect)((function(){oe!==Me&&Ve(oe)}),[oe]),(0,ne.Z)((function(){if(!L&&Ge>0){var e=(new Date).getTime(),n=window.sessionStorage.getItem(T);e>=Ge+1e4&&(!n||n!==Ae)&&(window.sessionStorage.setItem(T,Ae),nn(!0))}}),1e4),(0,f.useEffect)((function(){Fe(k)}),[Ce,k]),(0,f.useEffect)((function(){Ce&&y&&Ce.focus()}),[Ce,y]),(0,f.useEffect)((function(){if(Oe&&Ce){var e=function(e){var n=e.target;if(on.current){var t=n.scrollTop/n.scrollHeight;on.current.scrollTop=on.current.scrollHeight*t}},n=Ce.getScrollerElement();return n.addEventListener("scroll",e),function(){n.removeEventListener("scroll",e)}}}),[Ce,Oe]),(0,f.useEffect)((function(){if(Ce&&de){var e=function(e,n){de(e,n)};return Ce.on("beforeChange",e),function(){Ce.off("beforeChange",e)}}}),[Ce,de]),(0,f.useEffect)((function(){if(Ce&&ue){var e=function(){ue(Ce.getValue())};return Ce.on("blur",e),function(){Ce.off("blur",e)}}}),[Ce,ue]),(0,f.useEffect)((function(){if(Ce){var e=function(e,n){var t=e.getValue();Pe(t),ze((new Date).getTime()),e.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),i&&(q?i(t,xn(t)):i(t))};return Ce.on("change",e),function(){Ce.off("change",e)}}}),[Ce,i]),(0,f.useEffect)((function(){if(Ce)if(null==t)Ce.setValue(""),Pe("");else{var e=window.scrollY||window.pageYOffset;t!==Ce.getValue()&&(Ce.setValue(t),Pe(t),Ce.setCursor(ge?1:Ce.lineCount(),0),window.scrollTo(0,e))}}),[Ce,t]);var pn=(0,f.useCallback)((function(e){var n=Ce.getCursor(),t=Ce.getSelection(),i=t.split("\n");switch(e){case"bold":return Ce.replaceSelection("**"+t+"**"),""===t&&Ce.setCursor(n.line,n.ch+2),Ce.focus();case"italic":return Ce.replaceSelection("*"+t+"*"),""===t&&Ce.setCursor(n.line,n.ch+1),Ce.focus();case"code":return Ce.replaceSelection("`"+t+"`"),""===t&&Ce.setCursor(n.line,n.ch+1),Ce.focus();case"inline-latex":return Ce.replaceSelection("`$$"+t+"$$`"),""===t&&Ce.setCursor(n.line,n.ch+3),Ce.focus();case"latex":return Ce.replaceSelection("```latex\n"+t+"\n```"),Ce.setCursor(n.line+1,t.length+1),Ce.focus();case"line-break":return Ce.replaceSelection("<br/>\n"),Ce.focus();case"list-ul":return""===t?Ce.replaceSelection("- "+t):Ce.replaceSelection(i.map((function(e){return""===e?"":"- ".concat(e)})).join("\n")),Ce.focus();case"list-ol":return""===t?Ce.replaceSelection("1. "+t):Ce.replaceSelection(i.map((function(e,n){return""===e?"":"".concat(n+1,". ").concat(e)})).join("\n")),Ce.focus();case"add-null-ch":return""===t&&Ce.setCursor(n.line,n.ch),Ce.replaceSelection("▁"),Ce.focus();case"add-signal":return""===t&&Ce.setCursor(n.line,n.ch),Ce.replaceSelection("@▁@"),Ce.focus();case"add-multiple":return""===t&&Ce.setCursor(n.line,n.ch),Ce.replaceSelection(te),Ce.focus();case"inster-template-1":return""===t&&Ce.setCursor(n.line,n.ch),Ce.replaceSelection("\n**模板标题**\n模板正文内容可输入文本内容和粘贴图片等操作"),Ce.focus();case"eraser":return Ce.setValue(""),Ce.focus();case"trigger-watch":return Fe(!Oe),Ce.focus();case"trigger-full-screen":return Ve(!Me),Ce.focus();case J:return void Ue(J);case X:return void Ue(X);case Y:return void Ue(Y);case Q:return void Ue(Q);default:throw new Error}}),[Ce,Oe,Me]),fn=(0,f.useCallback)((function(e){switch(Ue(""),qe){case J:var n=e.title,t=e.link;return Ce.replaceSelection("[".concat(n,"](").concat(t,")")),Ce.focus();case X:var i=e.language,r=e.content;return Ce.replaceSelection(["```"+i,r,"```"].join("\n")),Ce.focus();case Y:var a=e.src,l=e.alt;return l?Ce.replaceSelection("![ ".concat(l," ]( ").concat(a,' "').concat(l,'" )')):Ce.replaceSelection("![,](".concat(a,")")),Ce.focus();case Q:for(var s=e.row,c=e.col,o=e.align,u="\n",d=0;d<s;d++){for(var p=[],f=[],h=0;h<c;h++)1===d&&f.push(ee[o]),p.push(" ");1===d&&(u+="| ".concat(f.join(" | ")," |\n")),u+="| ".concat(p.join(1===c?"":" | ")," |\n")}return Ce.replaceSelection(u+"\n"),Ce.focus();default:throw new Error}}),[Ce,qe]),hn=(0,f.useMemo)((function(){switch(qe){case J:return(0,g.jsx)(S,{callback:fn,onCancel:mn});case X:return(0,g.jsx)(A.Z,{callback:fn,onCancel:mn});case Y:return(0,g.jsx)(B,{callback:fn,onCancel:mn});case Q:return(0,g.jsx)(U,{callback:fn,onCancel:mn});default:return null}}),[qe]);function mn(){Ue("")}(0,f.useEffect)((function(){if(cn.current){var e=function(e){r=!0,a=e.pageY},n=function(){r=!1},t=function(e){if(r){var n=e.pageY-a;n<0&&(n=0),n>300&&(n=300),Qe(d+n+"px")}},i=cn.current,r=!1,a=0;return i.addEventListener("mousedown",e),document.addEventListener("mousemove",t),document.addEventListener("mouseup",n),function(){i.removeEventListener("mousedown",e),document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",n)}}}),[Ce,cn]),(0,f.useEffect)((function(){Qe(d)}),[d]);var vn={width:ie(s),height:ie(Xe)},xn=((0,f.useMemo)((function(){if(Ge){var e=new Date(Ge),n=e.getHours(),t=e.getMinutes(),i=e.getSeconds();return t=t<10?"0"+t:t,i=i<10?"0"+i:i,"".concat(n=n<10?"0"+n:n,":").concat(t,":").concat(i)}return 0}),[Ge]),function(e){var n=[];if(q){e=e.replace(/(@▁▁@|@▁@)/g,(function(e,t,i){n.push({multiLine:!("@▁@"===e)})}))}return n});return(0,g.jsxs)(f.Fragment,{children:[(0,g.jsx)("div",{className:"markdown-editor-wrapper",ref:sn,children:(0,g.jsxs)("div",{className:"markdown-editor-container ".concat(he," ").concat(Oe?"on-preview":""," ").concat(_?"mini":""," ").concat(Me?"full-screen":""),style:vn,children:[(0,g.jsx)(w,{insertTemp:N,watch:Oe,fullScreen:Me,showNullButton:W,showNullProgramButton:q,onActionCallback:pn,hidetoolBar:re,uuid:tn.current,setOpenPhones:function(){rn.current=!0}}),(0,g.jsxs)("div",{className:"markdown-editor-body",children:[(0,g.jsx)("div",{className:"codemirror-container",children:(0,g.jsx)("textarea",{ref:ln,placeholder:ye})}),Oe?(0,g.jsxs)("div",{ref:on,className:"preview-container",children:["stex"===E&&(0,g.jsx)(j,{value:Ae}),"stex"!==E&&(0,g.jsx)(x.Z,{disabledFill:_e,showProgramFill:q,value:Ae})]}):null]})]})}),O?(0,g.jsx)("a",{ref:cn,className:"editor-resize"}):null,(0,g.jsx)(Z.Z,{children:se[qe]?(0,g.jsx)(z.Z,{centered:!0,title:se[qe],open:!0,onCancel:mn,footer:null,className:"markdown-popup-form",children:hn}):null})]})}},82255:function(e,n,t){t.d(n,{Z:function(){return f}});var i=t(82100),r=t.n(i),a=t(29186),l=t.n(a),s=t(80619),c=t.n(s),o=t(47074),u=t.n(o),d=t(59301),p=t(4676),f=function(e){c()(t,e);var n=u()(t);function t(e){var i;r()(this,t),i=n.call(this,e);var a=window.document;return i.node=a.createElement("div"),a.body.appendChild(i.node),i}return l()(t,[{key:"render",value:function(){var e=this.props.children;return(0,p.createPortal)(e,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),t}(d.Component)},22336:function(e,n,t){t.d(n,{Z:function(){return r}});var i=t(59301);function r(e,n){var t=(0,i.useRef)();(0,i.useEffect)((function(){t.current=e})),(0,i.useEffect)((function(){if(null!==n){var e=setInterval((function(){t.current()}),n);return function(){return clearInterval(e)}}}),[n])}},65593:function(e,n,t){t.d(n,{Y4:function(){return P},Im:function(){return I},ZP:function(){return R}});var i=t(79800),r=t.n(i),a=t(7557),l=t.n(a),s=t(41498),c=t.n(s),o=t(82242),u=t.n(o),d=t(85573),p=t.n(d),f=t(59301),h=t(10249),m=t(3113),v=t(84105),x=t(87395),g=t(27392),j=t(24334),_=t(48049),b=t(71212),y=t(83287),k=t(34376),w=t(94171),Z=t(49389),N=t(37712),C=h.Z.TextArea,E={visible:!1,tabIndex:"0"},I=p()(p()(p()(p()(p()(p()({},g.h.NOMATCH,"测试用例结果不匹配"),g.h.OK,"调试通过"),2,"调试超时"),3,"调试pod失败"),4,"编译失败"),5,"执行失败"),S=function(e){return e[e.SET_VISIBLE=0]="SET_VISIBLE",e[e.SET_TABINDEX=1]="SET_TABINDEX",e}(S||{});function A(e,n){switch(n.type){case S.SET_VISIBLE:return u()(u()({},e),{},{visible:n.payload});case S.SET_TABINDEX:return u()(u()({},e),{},{tabIndex:n.payload});default:throw new Error}}function P(e){var n=e.status,t=e.error_msg,i=e.output,r=e.input,a=e.expected_output,s=e.is_file,o=e.input_file_url,u=e.output_file_url,d=e.expected_output_file_url,p=e.setMonacoValue,h=e.setData,m=(0,f.useRef)(),v=(0,f.useRef)(),x=(0,f.useRef)(),_=null,Z={minHeight:150,marginBottom:10,paddingLeft:24,background:"#070f19",color:"#fff"};switch((0,f.useEffect)((function(){if(i&&!s&&m.current){var e=new k.Terminal({fontSize:14,letterSpacing:1,cols:83,rows:10});e.open(m.current);var n=(0,y.pp)(j.Base64.decode(i));e.write(n),e.setOption("theme",{background:"#1e1e1e"})}if(r&&!s&&v.current){var t=new k.Terminal({fontSize:14,letterSpacing:1,cols:83,rows:10});t.open(v.current),t.write((0,y.pp)(r)),t.setOption("theme",{background:"#1e1e1e"})}if(a&&!s&&x.current){var l=new k.Terminal({fontSize:14,letterSpacing:1,cols:83,rows:10});l.open(x.current),l.write((0,y.pp)(j.Base64.decode(a))),l.setOption("theme",{background:"#1e1e1e"})}}),[i]),n){case g.h.NOMATCH:_=(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)("p",{className:"c-red",children:"实际输入:"}),!s&&(0,N.jsx)("div",{ref:v}),s&&(0,N.jsx)("div",{style:Z,children:(0,N.jsx)("a",{style:{fontSize:"16px"},onClick:c()(l()().mark((function e(){var n;return l()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(o,{method:"Get",headers:{"Content-Type":"application/octet-stream",Accept:"*/*"}});case 2:return n=e.sent,e.t0=p,e.next=6,n.text();case 6:e.t1=e.sent,(0,e.t0)(e.t1),setTimeout((function(){h(o)}),200);case 9:case"end":return e.stop()}}),e)}))),children:r})}),(0,N.jsx)("p",{className:"c-red",children:"实际输出:"}),!s&&(0,N.jsx)("div",{ref:m}),s&&(0,N.jsx)("div",{style:Z,children:(0,N.jsx)("a",{style:{fontSize:"16px"},onClick:c()(l()().mark((function e(){var n;return l()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,w.ZP)(u,{method:"Get",headers:{"Content-Type":"application/xml",Accept:"*/*"}});case 2:n=e.sent,p(n),setTimeout((function(){h(u)}),200);case 5:case"end":return e.stop()}}),e)}))),children:i})}),(0,N.jsx)("p",{className:"c-red",children:"预期输出:"}),!s&&(0,N.jsx)("div",{ref:x}),s&&(0,N.jsx)("div",{style:Z,children:(0,N.jsx)("a",{style:{fontSize:"16px"},onClick:c()(l()().mark((function e(){var n;return l()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(d,{method:"Get",headers:{"Content-Type":"application/octet-stream",Accept:"*/*"}});case 2:return n=e.sent,e.t0=p,e.next=6,n.text();case 6:e.t1=e.sent,(0,e.t0)(e.t1),setTimeout((function(){h(d)}),200);case 9:case"end":return e.stop()}}),e)}))),children:a})})]});break;case g.h.EXECUTEFAILURE:_=(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)("div",{style:{border:"1px #F6F7F9 solid"},children:[(0,N.jsx)("p",{style:{width:"100%",height:40,background:"#F6F7F9",lineHeight:"40px",color:"#666666",paddingLeft:"12px"},children:"最后执行的输入:"}),!s&&(0,N.jsx)(b.Z,{value:r,style:Z}),s&&(0,N.jsx)("div",{style:Z,children:(0,N.jsx)("a",{onClick:function(){return(0,y.LR)(o,r)},children:r})})]}),(0,N.jsxs)("div",{style:{border:"1px #F6F7F9 solid",marginTop:"10px"},children:[(0,N.jsx)("p",{style:{width:"100%",height:40,background:"#F6F7F9",lineHeight:"40px",color:"#666666",paddingLeft:"12px"},children:"执行出错信息:"}),(0,N.jsxs)("pre",{className:"error",style:{color:"#E30000",padding:"0 10px"},children:[j.Base64.decode(t),"111"]})]})]});break;case g.h.COMPILEFAILURE:_=(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)("p",{children:"最后执行的输入:"}),!s&&(0,N.jsx)("div",{ref:v}),s&&(0,N.jsx)("div",{style:Z,children:(0,N.jsx)("a",{onClick:function(){return(0,y.LR)(o,r)},children:r})}),(0,N.jsx)("p",{children:"执行出错信息:"}),(0,N.jsx)("pre",{className:"error",children:j.Base64.decode(t)})]});break;case g.h.PODFAILURE:_=(0,N.jsx)("p",{children:"创建pod失败请稍后重试"});break;case g.h.TIMEOUT:_=(0,N.jsx)("p",{children:"评测超时,请稍后重试"})}return(0,N.jsxs)(N.Fragment,{children:[" ",_," "]})}function T(e){var n=e.status,t=e.error_msg,i=e.execute_time,r=e.output,a=e.input,l=e.expected_output,s=(e.is_file,e.input_file_url,e.output_file_url,e.expected_output_file_url,null);switch(n){case g.h.OK:s=(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)("p",{children:["执行用时:",i/1e3,"秒"]}),(0,N.jsx)("p",{children:"执行结果:"}),(0,N.jsx)("pre",{children:j.Base64.decode(r)})]});break;case g.h.NOMATCH:s=(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)("p",{children:["输入:",(0,N.jsx)("pre",{children:a})]}),(0,N.jsxs)("p",{children:["输出:",r&&j.Base64.decode(r)]}),(0,N.jsxs)("p",{children:["预期输出:",l&&j.Base64.decode(l)]})]});break;case g.h.EXECUTEFAILURE:case g.h.COMPILEFAILURE:s=(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)("p",{children:["最后执行的输入:",(0,N.jsx)("pre",{children:a})]}),(0,N.jsx)("p",{children:"执行出错信息:"}),(0,N.jsx)("pre",{className:"error",children:j.Base64.decode(t)})]});break;case g.h.PODFAILURE:s=(0,N.jsx)("p",{children:"创建pod失败请稍后重试"});break;case g.h.TIMEOUT:s=(0,N.jsx)("p",{children:"评测超时,请稍后重试"})}return(0,N.jsxs)(N.Fragment,{children:[" ",s," "]})}var R=function(e){var n=e.input,t=e.debuging,i=e.submitting,a=e.executingMessage,s=e.debugResult,o=e.onChangeInput,u=e.onDebugCode,d=e.onSubmitCode,p=e.hack,h=e.user,g=(0,f.useReducer)(A,E),j=r()(g,2),b=j[0],y=j[1],k=b.visible,I=b.tabIndex,P=(0,Z.useSearchParams)(),R=r()(P,1)[0];function O(e){var n=e.target.id;y({type:S.SET_TABINDEX,payload:n})}var F=(0,f.useMemo)((function(){if(s){s.status;return(0,N.jsx)(N.Fragment,{children:T(s)})}return null}),[s]);var B=function(){var e=c()(l()().mark((function e(n){var t;return l()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,w.ZP)("/api/problems/".concat(n,"/start.json"),{method:"get",params:{hack_user_id:null==h?void 0:h.user_id}});case 2:(t=e.sent)&&(window.location.href="/myproblems/".concat(null==t?void 0:t.identifier,"?type=1"));case 4:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}();return(0,N.jsxs)("div",{className:"test-case-panel",children:[(0,N.jsxs)("div",{className:"test-case-panel-body ".concat(k?"active":""),children:[(0,N.jsxs)("ul",{className:"s-navs",children:[(0,N.jsx)("li",{children:(0,N.jsx)("a",{className:"0"===I?"active":"",id:"0",onClick:O,children:"自定义测试用例"})}),(0,N.jsx)("li",{children:(0,N.jsx)("a",{className:"1"===I?"active":"",id:"1",onClick:O,children:"代码执行结果"})})]}),(0,N.jsx)("div",{className:"tab-panel-body ".concat("0"===I?"":"hide"),children:(0,N.jsx)(C,{placeholder:"请填写测试用例的输入值,点击“调试代码”",value:n,onChange:o})}),(0,N.jsx)("div",{className:"tab-panel-body ".concat("1"===I?"":"hide"),children:t?(0,N.jsx)(_.Z,{message:a}):s?(0,N.jsxs)("section",{style:{height:200},children:[" ",F," "]}):(0,N.jsx)("p",{className:"tip",children:"请填写测试用例的输入值,点击“调试代码”"})})]}),(0,N.jsx)("a",{className:"btn-collapse ".concat(k?"up":""),onClick:function(){y({type:S.SET_VISIBLE,payload:!k})},children:k?(0,N.jsx)(v.Z,{}):(0,N.jsx)(x.Z,{})}),(0,N.jsxs)("footer",{className:"footer",children:[(0,N.jsx)("span",{children:"控制台"}),(0,N.jsxs)("div",{className:"flex-container",children:[(null==p?void 0:p.is_program)&&(null==p?void 0:p.above_question)&&(0,N.jsx)(m.ZP,{onClick:function(){return B(null==p?void 0:p.above_question)},id:"oj-prev",className:"btn-blue",type:"ghost",children:"上一题"}),(null==p?void 0:p.is_program)&&(null==p?void 0:p.under_question)&&(0,N.jsx)(m.ZP,{onClick:function(){return B(null==p?void 0:p.under_question)},id:"oj-next",className:"btn-blue",type:"ghost",children:"下一题"}),(0,N.jsx)(m.ZP,{className:"btn-green",type:"ghost",loading:t,onClick:function(){y({type:S.SET_VISIBLE,payload:!0}),y({type:S.SET_TABINDEX,payload:"1"}),u()},children:"调试代码"}),"8"!==R.get("qtype")&&(0,N.jsx)(m.ZP,{type:"primary",className:"custom-ant-disabled",loading:i,disabled:i,onClick:function(){y({type:S.SET_VISIBLE,payload:!1}),d()},children:"评测并提交"})]})]})]})}},27392:function(e,n,t){t.d(n,{h:function(){return i}});var i=function(e){return e[e.NOMATCH=-1]="NOMATCH",e[e.OK=0]="OK",e[e.TIMEOUT=2]="TIMEOUT",e[e.PODFAILURE=3]="PODFAILURE",e[e.COMPILEFAILURE=4]="COMPILEFAILURE",e[e.EXECUTEFAILURE=5]="EXECUTEFAILURE",e}({})},66375:function(e,n,t){t.d(n,{H7:function(){return f},MK:function(){return p},MU:function(){return c},X6:function(){return u},bM:function(){return s},fi:function(){return h},fu:function(){return l},n4:function(){return m},rX:function(){return d},vl:function(){return v},zO:function(){return o}});var i=t(82242),r=t.n(i),a=t(94171);function l(e,n){return(0,a.U2)("myproblems/".concat(e,".json"),r()({hidePopLogin:!0},n||{}))}function s(e,n){return(0,a.v_)("myproblems/".concat(e,"/code_submit.json"),n)}function c(e,n){return(0,a.v_)("myproblems/".concat(e,"/code_debug.json"),n)}function o(e,n){return n.language&&(n.language=encodeURIComponent(n.language)),(0,a.U2)("myproblems/".concat(e,"/submit_records.json"),n)}function u(e){return(0,a.U2)("myproblems/record_detail.json",{id:e})}function d(e,n){return(0,a.U2)("myproblems/".concat(e,"/result.json"),{mode:n})}function p(e,n){return(0,a.v_)("myproblems/".concat(e,"/add_notes.json"),n)}function f(e){return(0,a.v_)("myproblems/".concat(e,"/restore_initial_code.json"))}function h(e){return(0,a.v_)("myproblems/".concat(e,"/sync_code.json"))}function m(e,n){return(0,a.v_)("myproblems/".concat(e,"/update_code.json"),n)}function v(e,n){return(0,a.v_)("discusses/".concat(e,"/plus.json"),n)}},42190:function(e,n,t){t.d(n,{D0:function(){return d},R8:function(){return c},jw:function(){return u},y3:function(){return p}});var i=t(85573),r=t.n(i),a=t(57809),l=(t(59301),t(37712)),s=a.default.Option,c=function(e){return e[e.language=0]="language",e[e.difficult=1]="difficult",e[e.category=2]="category",e[e.openOrNot=3]="openOrNot",e}({}),o=r()(r()(r()(r()({},c.language,[{title:"C",key:"C"},{title:"C++",key:"C++"},{title:"Python",key:"Python"},{title:"Java",key:"Java"},{title:"JavaScript",key:"JavaScript"},{title:"Ruby",key:"Ruby"}]),c.difficult,[{title:"简单",key:1},{title:"中等",key:2},{title:"困难",key:3}]),c.category,[{title:"程序设计",key:1},{title:"算法",key:2}]),c.openOrNot,[{title:"公开",key:1},{title:"私有",key:0}]);function u(e){return o[e].map((function(e){return(0,l.jsxs)(s,{value:e.key,children:[" ",e.title," "]},e.title)}))}function d(e,n){e.map((function(e){var t=e.id,i=e.name,r=e.sub_disciplines,a={value:t,label:i};n.push(a),r&&r.length>0&&(a.children=[],d(r,a.children))}))}function p(e,n){for(var t=[],i=0;i<e.length;i++){var r,a=e[i];if((null===(r=a.sub_disciplines)||void 0===r?void 0:r.length)>0){t[0]=a.id;for(var l=0;l<a.sub_disciplines.length;l++){var s=a.sub_disciplines[l];if(s.id===n)return t[1]=s.id,[t,s.tag_disciplines||s.sub_disciplines||[]]}}}return[t,[]]}},20853:function(e,n,t){t.r(n),t.d(n,{default:function(){return ce}});var i=t(7557),r=t.n(i),a=t(41498),l=t.n(a),s=t(37205),c=t.n(s),o=t(79800),u=t.n(o),d=t(82242),p=t.n(d),f=t(59301),h=t(49389),m=t(78241),v=t(43418),x=t(8591),g=t(66104),j=t(5112),_=t(19842),b=t(6848),y=t(54580),k=t(1710),w=t(3113),Z=t(91689),N="bgWrapper___yZrnF",C="bg___DMAyj",E="main___l1oS8",I="addTypeRadio___eH2zI",S="formWrap___ydPvR",A="questionTypeRadio___jQze1",P="difficultyWrapper___W9ML_",T="difficultyRadio___z9UyX",R="easy___5Owsm",O="medium___NeHBc",F="hard___Hrees",B="cascaderWrapper___AUd1O",L="courseCascader___UEeI3",M="knowledgeWrapper___sIao8",V="uploadTips___v_XSU",W="uploadTipsIcon___gfQUD",D="downloadBtn___BqNPb",q="uploadBtn___p7bAk",U="buttonFixed___j1UZJ",K="buttonWrap___FfqsJ",H="button___TuRr2",G="topicWrap___v5_lJ",z="cascaderPopup___nXZ4B",J="unfold____IJ2y",Y=t(96196),X=t(83287),Q=t(52058),$=t(61485),ee=t(94171),ne=t(10615),te=t(42190),ie=t(24334),re=t(37712),ae=function(e){return"SINGLE"===e||"MULTIPLE"===e?"SELECT":e},le=function(e){return e.map((function(e){return p()(p()({},e),{},{is_answer:e.is_answer?1:0})}))},se=function(e){var n=e.form,t=e.currentItemType;return{SELECT:(0,re.jsx)(Y.uh,{form:n,questionTitlePlaceholder:"请编辑选择题题干内容",titleKey:"name",choiceKey:"choices",analysisKey:"analysis",choiceOptionsPath:"choices",choiceTextKey:"choice_text",answerKey:"is_answer",allowChangeMode:!0}),JUDGMENT:(0,re.jsx)(Y.ZZ,{form:n,questionTitlePlaceholder:"请编辑判断题题干内容",choiceKey:"choices"}),COMPLETION:(0,re.jsx)(Y.u8,{form:n,questionTitlePlaceholder:"请编辑题干并设置填空项",scoreByBlank:!1,answerKey:"standard_answers"}),SUBJECTIVE:(0,re.jsx)(Y.Wk,{showKeywords:!0,isMustKeyWords:!1,form:n,questionTitlePlaceholder:"请编辑简答题题干内容"}),COMBINATION:(0,re.jsx)(Y.rL,{form:n,questionTitlePlaceholder:"请编辑组合题题干内容",choiceKey:"choices",withScore:!1}),BPROGRAM:(0,re.jsx)(Y.tc,{form:n,questionTitlePlaceholder:"请编辑题干并设置填空项",scoreByBlank:!1,answerKey:"standard_answers"})}[t]||null},ce=(0,h.connect)((function(e){var n=e.problemset,t=e.loading;return{problemset:n,globalSetting:e.globalSetting,loading:t.effects}}))((function(e){var n,t,i,a=e.problemset,s=e.loading,o=e.dispatch,d=(0,h.useParams)(),Y=(0,h.useSearchParams)(),ce=u()(Y,1)[0],oe=m.Z.useForm(),ue=u()(oe,1)[0],de=(0,f.useState)(),pe=u()(de,2),fe=(pe[0],pe[1]),he=(0,f.useState)([]),me=u()(he,2),ve=me[0],xe=me[1],ge=(0,f.useRef)(),je=(0,f.useState)(1),_e=u()(je,2),be=_e[0],ye=_e[1],ke=(0,f.useState)([]),we=u()(ke,2),Ze=we[0],Ne=we[1],Ce=(0,f.useState)(),Ee=u()(Ce,2),Ie=Ee[0],Se=Ee[1],Ae=(0,f.useState)(!1),Pe=u()(Ae,2),Te=Pe[0],Re=Pe[1],Oe=(0,f.useState)(!1),Fe=u()(Oe,2),Be=Fe[0],Le=Fe[1],Me=(0,f.useState)(),Ve=u()(Me,2),We=Ve[0],De=Ve[1],qe=(0,f.useState)("SELECT"),Ue=u()(qe,2),Ke=Ue[0],He=Ue[1],Ge="BPROGRAM"===Ke?null===(n=m.Z.useWatch("hack",ue))||void 0===n?void 0:n.tag_discipline_ids:m.Z.useWatch("knowledge",ue);(0,f.useEffect)((function(){return o({type:"globalSetting/footerToggle",payload:!1}),function(){o({type:"globalSetting/footerToggle",payload:!0})}}),[]),(0,f.useEffect)((function(){return window.addEventListener("beforeunload",Je),function(){window.removeEventListener("beforeunload",Je)}}),[]),(0,f.useEffect)((function(){var e=ce.get("pages");fe(e);var n=d.id;ge.current=n}),[]);var ze="edit"===d.type;(0,f.useEffect)((function(){o({type:"problemset/getEditDisciplines",payload:{source:"new_question"}}),"1"===ce.get("type")?ge.current&&o({type:"problemset/getEditDataBprogram",payload:{id:ge.current}}):ge.current&&o({type:"problemset/getEditData",payload:{id:ge.current}})}),[]),console.log("----",We),(0,f.useEffect)((function(){if(ze){if(null==a||!a.editData)return;var e=(null==a?void 0:a.editData)||{},n=e.discipline,t=e.sub_discipline,i=e.sub_discipline_id,r=e.tag_disciplines,l=e.item_type,s=e.choices,o=void 0===s?[]:s,d=e.sub_item_banks,f=void 0===d?[]:d;if("1"===ce.get("type")){var h;if(He("BPROGRAM"),null!=a&&null!==(h=a.disciplinesData)&&void 0!==h&&h.disciplines){var m,v,x,g,j=(0,te.y3)(null==a||null===(m=a.disciplinesData)||void 0===m?void 0:m.disciplines,i),_=u()(j,2),b=_[0],y=(_[1],{item_type:"BPROGRAM",standard_answers:a.editData.standard_answer,difficulty:a.editData.difficult,item_banks_group_id:a.editData.item_banks_group_id,hack:p()(p()({},a.editData),{},{sub_discipline_id:b,tag_discipline_ids:null===(v=a.editData)||void 0===v?void 0:v.tag_discipline_ids}),hack_codes:p()(p()({},a.editData),{},{code:ie.Base64.decode((null===(x=a.editData)||void 0===x?void 0:x.code)||"")}),hack_sets:p()({},null===(g=a.editData)||void 0===g||null===(g=g.hack_sets)||void 0===g?void 0:g[0])});De(y),i&&en(i).then((function(e){}))}}else{var k=p()(p()({},null==a?void 0:a.editData),{},{item_type:ae(l),choices:le(o),course:[null==n?void 0:n.id,null==t?void 0:t.id],knowledge:null==r?void 0:r.map((function(e){return e.id})),sub_item_banks:f.map((function(e){return p()(p()({},e),{},{choices:le(e.choices)})}))});De(k),He(ae(l)),null!=t&&t.id&&en(null==t?void 0:t.id).then((function(e){var n,t=null==e?void 0:e.map((function(e){return e.id}));null!=t&&t.includes(null==r||null===(n=r[0])||void 0===n?void 0:n.id)||xe((function(e){return[].concat(c()(e),c()(r))}))}))}}else De({item_type:"SELECT",choices:Array.from({length:4},(function(){return{choice_text:"",is_answer:0}})),difficulty:2,item_banks_group_id:[Number(ce.get("group_id"))||0]})}),[a.editData,null==a?void 0:a.disciplinesData]),console.log("---",ve,We);var Je=function(e){e.preventDefault(),e.returnValue=""},Ye=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;switch(ue.resetFields(),ue.setFieldsValue({item_type:e,item_banks_group_id:n}),He(e),e){case"SELECT":ue.setFieldsValue({choices:Array.from({length:4},(function(){return{choice_text:"",is_answer:0}}))});break;case"JUDGMENT":ue.setFieldsValue({choices:[{choice_text:"正确",is_answer:0},{choice_text:"错误",is_answer:0}]});break;case"COMPLETION":ue.setFieldsValue({standard_answers:[]});break;case"SUBJECTIVE":ue.setFieldsValue({answer_texts:[],use_keywords:!0});break;case"COMBINATION":case"PROGRAM":break;case"BPROGRAM":ue.setFieldsValue({hack:{time_limit:3,allow_student_debug:!1}})}},Xe=function(e,n){var t;if(null!=e&&e.item_type&&("PROGRAM"===(null==e?void 0:e.item_type)&&(0,X.xg)("/problems/newcreate"),Ye(null==e?void 0:e.item_type,null==n?void 0:n.item_banks_group_id),Le(!1)),null!=e&&e.course){var i=u()(e.course,2),r=(i[0],i[1]);en(r),ue.setFieldsValue({knowledge:[]})}if(null!=e&&null!==(t=e.hack)&&void 0!==t&&t.sub_discipline_id){var a=u()(e.hack.sub_discipline_id,2),l=(a[0],a[1]);en(l),ue.setFieldsValue({hack:{tag_discipline_ids:[]}})}},Qe=function(){var e=l()(r()().mark((function e(){var n,t,i,a,l,s,c,d,f,m,g,j,_,b,y,k,w,Z,N,C,E;return r()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("COMPLETION"==(null==(n=ue.getFieldsValue())?void 0:n.item_type)&&null==n.is_ordered&&(n.is_ordered=!0),i=(t=n||{}).course,a=void 0===i?[]:i,l=t.item_type,s=t.item_banks_group_id,c=t.knowledge,d=void 0===c?[]:c,f=t.choices,m=u()(a,2),g=m[0],j=m[1],1!==be){e.next=37;break}if("PROGRAM"!==l){e.next=8;break}return(0,X.xg)("/problems/newcreate"),e.abrupt("return");case 8:if("BPROGRAM"!==l){e.next=22;break}if(b=p()(p()({},n),{},{hack:p()(p()({},null==n?void 0:n.hack),{},{sub_discipline_id:null==n||null===(_=n.hack)||void 0===_||null===(_=_.sub_discipline_id)||void 0===_?void 0:_[1],difficult:n.difficulty,item_banks_group_ids:n.item_banks_group_id}),hack_codes:p()(p()({},n.hack_codes),{},{code:ie.Base64.encode(n.hack_codes.code)}),hack_sets:[p()({},n.hack_sets)],update_hack_sets:[p()({},n.hack_sets)],is_blank:!0}),!ze&&!sessionStorage.projectFill){e.next=17;break}return e.next=13,(0,ee.ZP)("/api/problems/".concat(ge.current||sessionStorage.projectFill,".json"),{method:"put",body:p()({},b)});case 13:0===e.sent.status&&h.history.replace("/problemset?group_id=".concat(n.hack.item_banks_group_id)),e.next=21;break;case 17:return e.next=19,(0,ee.ZP)("/api/problems.json",{method:"post",body:p()({},b)});case 19:0===e.sent.status&&v.Z.confirm({title:"提示",centered:!0,icon:null,content:"试题新增成功",okText:"继续新增",cancelText:"返回列表",onOk:function(){Ye(Ke,s)},onCancel:function(){h.history.replace("/problemset?group_id=".concat(s))}});case 21:return e.abrupt("return");case 22:if("SELECT"===l&&(l=f.filter((function(e){return 1===e.is_answer})).length>1?"MULTIPLE":"SINGLE"),"COMBINATION"===l&&(y=(n||{}).sub_item_banks,n.sub_item_banks=null==y?void 0:y.map((function(e){return p()(p()({},e),{},{item_type:"SINGLE"})}))),k=p()(p()({},n),{},{discipline_id:g,sub_discipline_id:j,item_banks_group_ids:s,tag_discipline_ids:d,item_type:l}),!ze){e.next=31;break}return e.next=28,o({type:"problemset/editProblemset",payload:p()(p()({},k),{},{id:ge.current})});case 28:w=e.sent,e.next=34;break;case 31:return e.next=33,o({type:"problemset/addProblemset",payload:k});case 33:w=e.sent;case 34:0===w.status&&(ze?h.history.replace("/problemset?group_id=".concat(s)):v.Z.confirm({title:"提示",centered:!0,icon:null,content:"试题新增成功",okText:"继续新增",cancelText:"返回列表",onOk:function(){Ye(Ke,s)},onCancel:function(){h.history.replace("/problemset?group_id=".concat(s))}})),e.next=57;break;case 37:if(!((null==Ze?void 0:Ze.length)<=0)){e.next=40;break}return x.ZP.info("请上传试题文件"),e.abrupt("return");case 40:return Re(!0),(Z=new FormData).append("file",Ze[0]),Z.append("sub_discipline_id",j),e.next=46,(0,ee.ZP)("/api/item_banks/file_import.json",{method:"post",body:Z},!0);case 46:if(N=e.sent,Re(!1),0!==(null==N?void 0:N.status)){e.next=57;break}if(!((null==N||null===(C=N.fail)||void 0===C?void 0:C.length)>0)){e.next=53;break}return Se(null==N?void 0:N.fail),x.ZP.error("上传失败题数为"+(null==N||null===(E=N.fail)||void 0===E?void 0:E.length)+",可在底部试题列表查看错误原因。"),e.abrupt("return");case 53:ue.setFieldsValue({course:[]}),Ne([]),Se([]),x.ZP.info("上传成功");case 57:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),$e=function(){var e=l()(r()().mark((function e(n){var t;return r()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n.errorFields[0].name.includes("standard_answers")?x.ZP.error("填空项答案不能为空"):x.ZP.error(n.errorFields[0].errors[0]),ue.scrollToField(null==n||null===(t=n.errorFields)||void 0===t||null===(t=t[0])||void 0===t?void 0:t.name,{behavior:"smooth",block:"center"});case 2:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),en=function(){var e=l()(r()().mark((function e(n){var t;return r()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o({type:"exercise/getTagDiscipline",payload:{sub_discipline_id:n}});case 2:return t=e.sent,xe(t.tag_disciplines),e.abrupt("return",null==t?void 0:t.tag_disciplines);case 5:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}();return(0,re.jsx)("div",{className:N,children:(0,re.jsxs)("section",{className:C,children:[(0,re.jsxs)(g.Z,{className:"mb20",separator:">",children:[(0,re.jsx)(g.Z.Item,{href:"/problemset",children:"试题库"}),(0,re.jsxs)(g.Z.Item,{children:[ze?"编辑":"新增","试题"]})]}),(0,re.jsxs)("div",{className:E,children:[(0,re.jsx)(j.ZP.Group,{className:I,optionType:"button",options:[{label:"单个添加",value:1},{label:"批量导入",value:2}],onChange:function(e){ye(e.target.value),ue.setFieldsValue({course:[]}),Ne([]),Se([])},value:be}),1===be&&We&&(0,re.jsxs)(m.Z,{form:ue,className:S,layout:"horizontal",colon:!1,onValuesChange:Xe,onFinish:Qe,onFinishFailed:$e,initialValues:We,children:[(0,re.jsx)(m.Z.Item,{label:"试题类型",name:"item_type",rules:[{required:!0,message:"请选择题型"}],children:(0,re.jsx)(j.ZP.Group,{disabled:ze,optionType:"button",className:A,options:[{label:"选择题",value:"SELECT"},{label:"判断题",value:"JUDGMENT"},{label:"填空题",value:"COMPLETION"},{label:"简答题",value:"SUBJECTIVE"},{label:"编程题",value:"PROGRAM"},{label:"组合题",value:"COMBINATION"},{label:"程序填空题",value:"BPROGRAM"}]})}),(0,re.jsx)("div",{className:G,children:(0,re.jsx)(se,{currentItemType:Ke,form:ue})}),"PROGRAM"!==Ke&&(0,re.jsxs)(re.Fragment,{children:[(0,re.jsx)(m.Z.Item,{label:"方向&课程",className:"".concat(B," mb30"),labelCol:{span:24},style:{marginTop:"PROGRAM"===Ke?0:30},name:"BPROGRAM"===Ke?["hack","sub_discipline_id"]:"course",rules:[{required:!0,message:"请选择课程"}],children:(0,re.jsx)(_.Z,{className:L,popupClassName:z,dropdownMenuColumnStyle:{padding:"8px 12px",fontSize:14},showArrow:!0,placeholder:"请选择方向&课程",allowClear:!1,options:a.courseOptions})}),(0,re.jsx)("div",{className:J,children:(0,re.jsxs)("div",{onClick:function(){return Le(!Be)},children:["更多设置",Be?(0,re.jsx)("i",{className:"iconfont icon-xialajiantou1"}):(0,re.jsx)("i",{className:"iconfont icon-xialajiantoubeifen"})]})}),(0,re.jsxs)("div",{style:{display:Be?"block":"none"},children:[(0,re.jsx)(m.Z.Item,{label:"知识点",name:"BPROGRAM"===Ke?["hack","tag_discipline_ids"]:"knowledge",labelCol:{flex:"62px"},labelAlign:"left",className:"".concat(M," mb30"),children:(0,re.jsx)(Q.N,{selectvalues:Ge,subId:(null===(t=ue.getFieldsValue().course)||void 0===t?void 0:t[1])||(null===(i=ue.getFieldsValue())||void 0===i||null===(i=i.hack)||void 0===i||null===(i=i.sub_discipline_id)||void 0===i?void 0:i[1]),knowledgeOptions:ve,onAddKnowledgeFinish:function(e){xe([].concat(c()(ve),[p()({},e)]))}})}),(0,re.jsx)(m.Z.Item,{labelCol:{flex:"62px"},labelAlign:"left",name:"difficulty",label:"难度",className:"".concat(P," mb30"),rules:[{required:!0,message:"请选择难度"}],children:(0,re.jsxs)(j.ZP.Group,{optionType:"button",className:T,children:[(0,re.jsx)(j.ZP.Button,{value:1,className:R,children:"简单"}),(0,re.jsx)(j.ZP.Button,{value:2,className:O,children:"适中"}),(0,re.jsx)(j.ZP.Button,{value:3,className:F,children:"困难"})]})}),(0,re.jsx)(m.Z.Item,{label:"放入文件夹目录",rules:[{required:!0,message:"请选择文件夹"}],name:"item_banks_group_id",labelCol:{span:24},wrapperCol:{span:24},children:(0,re.jsx)(ne.Z,{scrollId:"item_banks_group_id"})})]})]})]}),2===be&&(0,re.jsxs)("div",{children:[(0,re.jsxs)(m.Z,{form:ue,className:S,layout:"vertical",onValuesChange:Xe,onFinish:Qe,children:[(0,re.jsx)(m.Z.Item,{className:B,label:"方向&课程:",name:"course",rules:[{required:!0,message:"请选择课程"}],children:(0,re.jsx)(_.Z,{className:L,popupClassName:z,dropdownMenuColumnStyle:{padding:"8px 12px",fontSize:14},placeholder:"请选择方向&课程",showArrow:!0,allowClear:!1,options:a.courseOptions,style:{width:490}})}),(0,re.jsxs)("div",{className:"mb30",children:[(0,re.jsxs)("span",{className:V,children:["根据模板要求编辑需要上传的试题",(0,re.jsx)(b.Z,{title:(0,re.jsxs)("div",{children:[(0,re.jsx)("div",{children:"提示:"}),(0,re.jsx)("div",{children:"1、目前仅支持Excel格式模板"}),(0,re.jsx)("div",{children:"2、不支持组合题和实训题导入"}),(0,re.jsx)("div",{children:"3、每次最多导入300题"}),(0,re.jsx)("div",{children:"4、填空题导入最多支持5个填空项。"})]}),children:(0,re.jsx)($.Z,{className:W})})]}),(0,re.jsxs)("a",{className:"".concat(D," ml30"),href:Z.Z.API_SERVER+"/api/item_banks/down_template",download:!0,children:["下载试题模版",(0,re.jsx)("i",{className:"iconfont icon-xiazai4 ml10",style:{fontSize:14}})]})]}),(0,re.jsx)(y.Z,{onRemove:function(){Ne([])},beforeUpload:function(e){if(console.log(e),(null==e?void 0:e.size)>52428800)return x.ZP.info("文件超过50M不符合上传要求"),!1;var n=[];return n.push(e),Ne([].concat(n)),!1},fileList:Ze,accept:".xls,.xlsx",showUploadList:{removeIcon:(0,re.jsx)("i",{className:"iconfont icon-shanchu12",style:{color:"#F65160"}})},children:(0,re.jsxs)("div",{className:q,children:[(0,re.jsx)("i",{className:"iconfont icon-shangchuan3",style:{fontSize:14}}),"点击上传"]})})]}),(0,re.jsx)("br",{}),(null==Ie?void 0:Ie.length)>0&&(0,re.jsx)("span",{style:{fontSize:"18px",display:"flex",width:"100%",justifyContent:"center"},children:"错误列表"}),(null==Ie?void 0:Ie.length)>0&&(0,re.jsx)(k.Z,{style:{marginTop:"10px"},dataSource:Ie,columns:[{title:"题目名称",dataIndex:"name",key:"name"},{title:"错误原因",dataIndex:"message",key:"message"}]})]})]}),(0,re.jsx)("div",{className:U,children:(0,re.jsxs)("div",{className:K,children:[(0,re.jsx)(w.ZP,{size:"middle",className:"".concat(H," mr20"),onClick:function(){return h.history.push("/problemset")},children:"取消"}),(0,re.jsx)(w.ZP,{size:"middle",type:"primary",className:"".concat(H," mr20"),onClick:function(){return ue.submit()},loading:s["problemset/editProblemset"]||s["problemset/addProblemset"]||Te,children:"PROGRAM"===Ke&&1===be?"立即创建":"保存题目"})]})})]})})}))},69092:function(e,n){n.Z={wrap:"wrap___ilWvf",deleteIcon:"deleteIcon___JBDG8",keywordTag:"keywordTag___iieCb",questionTitleEditorWrap:"questionTitleEditorWrap___MHB5s",choiceWrap:"choiceWrap___QFkTc",choiceIndex:"choiceIndex___Mr2YO",judgementIndex:"judgementIndex___fUVWK",setAnswerBtn:"setAnswerBtn___Whox5",activeAnswer:"activeAnswer___fGU6Y",activeJudgementAnswer:"activeJudgementAnswer___wJv8P",actionWrapper:"actionWrapper___ERQ7k",addIcon:"addIcon___L9TE0",inputBorder:"inputBorder___Q5tRE",placeholder:"placeholder___p9sFY",blankWrapper:"blankWrapper___nC45e",blankInput:"blankInput___pEHsx",blankInputNumberWrapper:"blankInputNumberWrapper___uEHb0",addBtn:"addBtn___WR5ZI",blankIndex:"blankIndex___x9Pny",baseInputWrapper:"baseInputWrapper___eVsG7",collapseWrapper:"collapseWrapper___ZTysU",panelHeader:"panelHeader___QSN9g",open:"open___B6FU9",close:"close___QX19r",hide:"hide___mn25n"}},73631:function(e){e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAAXNSR0IArs4c6QAAAZxJREFUOBGtlL1Ow0AMgH2XUIkOLFXVASgTsDHxBIAEzAwMPBQjT8AATGVBgEBCYmHmFcICYmBogCbNYSe52HUTVZWwFJ3PP599Z+WMcy6Af5SwYkWnLYifTyBzq5XNK8YNwbbvYP381ZuaVlN1+HJwAc4d1QYaA+gDsHYANrhGHTdCMtSDMILtwSMDn7ZiANPKwyjeQ0Reo4r1gEoEwRkDb7spdPcBeocMk1Cv00oii5L+fgPwcR/zHfb3AJY2sEpUVLOUhB/l+w7I1iS9TYDFrM3AzhqGDstPZ3li2Z12U2WLvk4fGJh+F0elYN8ZrbWiA7igAP4WR6sFzDAKPgPHP0VnlMsFS5IyyIGoeAamCKybYI5UQLWVE2fgGI/s72wqQXRd9jyxiHgGJtihFxGQm8Qd5XvtF3fEQOrQH9mDm1Z9hyJuEphXIq9uSWSQqv8a4RbAUTFdcs7gifwplYGjT3wzbPFz6Q70EZv8WZoxMP66ApMc86inirNBA8njcFIuvOTXhowPyzuQJiukzi3hQgS7b+I9nJtQn/AHsLGsvlcPPWsAAAAASUVORK5CYII="},5623:function(e){e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAAXNSR0IArs4c6QAAAedJREFUOBGtVDtLA0EQ/jY5z7dgEBVJLHyAitpYWQqKjVZa5BfEKpWlWPgrLG0UEdTexkILRUQiSBBBCAhGUINFHia53Dm7ufXcvfgIOHA3O69vvtnbPeY4ThD/KIF/xBJQhg/wbmkZtj0KMKbEGNIweg4xuPmq+DWDKSOfz2/AqaxpOVWzip8HC2xTsydfjoMHhMd2VMDjkSswTPqSucOhh3PmupaIediBOnL52UTLENC7QCV1bC9vkjkF3i4WVUDeORIF2sf5ymOk7mY1pr87hoHEhekHDLYQOfck8c6c6OeYfPHN3LyOxEB2KwQru0LrBvTPdaGRipj7ISUzqUWJ/moiRyc1tUXAQP42Tsa6sEIRCtwDRXqESDYS8RuG5iyRMEWFAat4CbvsAmgFmukmeYofJYeSAimab0L4DfQNHiF1laFAyMv840o2zN3Q1FMuIOIWStF9OtAxH4xkIC8NZyN9SnIOsNISkLRd3EWlFBP0lQJtDzVTyc8mBKB3U65nUnBYmDaFAr98BFGqvYKtwOMZHRsp1vsedVxV8bQRJXu5BbKWa6sAmK1lj2FiOoLcS5LYNX/N+3ktp+GapFJMeoDccdI9gEJ2nW5HhJjKuXmktih7yjJoC8VVwNpldXnr+KX8DfcD09mnwzz7SXEAAAAASUVORK5CYII="}}]);