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.
1 line
21 KiB
1 line
21 KiB
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[33581,79817],{1631:function(e,t,n){n.d(t,{Q:function(){return C},Z:function(){return P}});var i=n(7557),r=n.n(i),o=n(41498),s=n.n(o),a=n(79800),l=n.n(a),c=n(59301),u="tags___kRRoe",d="text___IyyEa",f="tagWrap___v63mB",p="c___mZMPq",h="cpp___eaTie",v="java___gL98T",g="python___eNRkk",m="edit___tbVu0",x=n(92310),k=n.n(x),b=n(43418),y=n(8591),_=n(24905),w=n(37712),C=function(e){var t=e.title,n=void 0===t?"设置编程语言":t,i=e.dataSource,o=void 0===i?[]:i,a=e.visible,u=e.setVisible,d=e.tip,f=e.onOk,p=(0,c.useState)([]),h=l()(p,2),v=h[0],g=h[1],m=(0,c.useState)(!1),x=l()(m,2),k=x[0],C=x[1];return(0,c.useEffect)((function(){a&&g(o)}),[a]),(0,w.jsxs)(b.Z,{centered:!0,open:a,title:n,confirmLoading:k,width:564,onOk:s()(r()().mark((function e(){return r()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(v.length){e.next=3;break}return y.ZP.warning("请选择编程语言"),e.abrupt("return");case 3:return C(!0),e.next=6,f(v);case 6:C(!1);case 7:case"end":return e.stop()}}),e)}))),onCancel:function(){return u(!1)},children:[!!d&&(0,w.jsx)("div",{className:"c-grey-666 font16 mb10",children:d}),(0,w.jsx)("div",{style:{background:"#F6F7F9",padding:"20px 20px 20px 26px"},children:(0,w.jsx)(_.Z.Group,{value:v,options:[{label:"C语言",value:"C"},{label:"C++语言",value:"C++",style:{marginLeft:30}},{label:"Java语言",value:"Java",style:{marginLeft:30}},{label:"Python语言",value:"Python",style:{marginLeft:30}}],onChange:function(e){g(e)}})})]})},P=function(e){var t=e.title,n=void 0===t?"允许编程的语言":t,i=e.className,r=e.style,o=void 0===r?{}:r,s=e.onEdit,a=e.dataSource,l=void 0===a?[]:a,x={C:(0,w.jsx)("div",{className:p,children:"C"}),"C++":(0,w.jsx)("div",{className:h,children:"C++"}),Java:(0,w.jsx)("div",{className:v,children:"Java"}),Python:(0,w.jsx)("div",{className:g,children:"Python"})};return(0,w.jsxs)("div",{className:k()(u,i),style:o,children:[!!n&&(0,w.jsx)("div",{className:d,children:n}),(0,w.jsx)("div",{className:f,children:null==l?void 0:l.map((function(e){return(0,w.jsx)(c.Fragment,{children:x[e]},e)}))}),!!s&&(0,w.jsx)("div",{onClick:s,className:"iconfont icon-bianji_Hover ".concat(m)})]})}},29413:function(e,t,n){var i=n(82242),r=n.n(i),o=n(7557),s=n.n(o),a=n(41498),l=n.n(a),c=n(79800),u=n.n(c),d=n(18196),f=n(59301),p=n(8591),h=n(3113),v=n(43418),g=n(24334),m=n(93969),x=n(85324),k=n(59731),b=n(61186),y=n.n(b),_=n(37712);t.Z=function(e){var t=e.ButtonProps,n=e.ButtonText,i=e.form,o=e.answerKey,a=e.hackidentifier,c=void 0===a?"":a,b=e.items,w=void 0===b?{}:b,C=e.setIsSubmitCode,P=(0,f.useState)(!1),S=u()(P,2),j=S[0],E=S[1],T=(0,f.useState)(""),Z=u()(T,2),B=Z[0],N=Z[1],$=(0,d.useParams)(),O=(0,f.useState)({}),L=u()(O,2),R=L[0],z=L[1],F="edit"===$.type;window.location.href.includes("problemset");function I(e,t){return A.apply(this,arguments)}function A(){return(A=l()(s()().mark((function e(t,n){var r,a,l,c,u;return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=i.getFieldValue("hack_codes"),l=i.getFieldValue(o),a.code){e.next=5;break}return p.ZP.info("程序代码不能为空!"),e.abrupt("return");case 5:if(a.language){e.next=8;break}return p.ZP.info("编程语言不能为空!"),e.abrupt("return");case 8:if(!(l.length>0&&(null===(r=l.filter((function(e){return!e.answer_text})))||void 0===r?void 0:r.length)>0)){e.next=11;break}return p.ZP.info("填空项不能为空!"),e.abrupt("return");case 11:return c=a.code,l.length>0&&(null==l||l.map((function(e){c=e.multi_line?c.substring(0,c.indexOf("@▁▁@"))+e.answer_text+c.substring(c.indexOf("@▁▁@")+4):c.substring(0,c.indexOf("@▁@"))+e.answer_text+c.substring(c.indexOf("@▁@")+3)}))),e.next=15,(0,x.n4)(n,t||{code:g.Base64.encode(c),language:a.language,answers:null==l?void 0:l.map((function(e){return e.answer_text}))});case 15:return u=e.sent,e.abrupt("return",u);case 17:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function M(e,t){return D.apply(this,arguments)}function D(){return(D=l()(s()().mark((function e(t,n){var i,r,o;return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=w.userAnswer,r=g.Base64.decode(w.code),i.length>0&&(null==i||i.map((function(e){r=e.multi_line?r.substring(0,r.indexOf("@▁▁@"))+e.value+r.substring(r.indexOf("@▁▁@")+4):r.substring(0,r.indexOf("@▁@"))+e.value+r.substring(r.indexOf("@▁@")+3)}))),e.next=5,(0,x.n4)(n,t||{code:g.Base64.encode(r),language:w.language,answers:null==i?void 0:i.map((function(e){return e.value}))});case 5:return o=e.sent,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function H(){return(new Date).getTime()}return(0,f.useEffect)((function(){(F||c)&&N(c||$.id)}),[$]),(0,f.useEffect)((function(){return function(){sessionStorage.removeItem("projectFill")}}),[]),(0,_.jsxs)("div",{children:[(0,_.jsx)(h.ZP,r()(r()({loading:j},t),{},{onClick:l()(s()().mark((function e(){var t,o,a,c,u,d,f,h,k,b,y,_,P,S;return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("提交代码"!==n){e.next=21;break}if(E(!0),!j){e.next=4;break}return e.abrupt("return");case 4:return e.next=6,(0,m.ZP)("/api/problems/".concat(B,"/start.json"),{method:"get"});case 6:return t=e.sent,e.next=9,M(null,null==t?void 0:t.identifier);case 9:if(0!==(null==(o=e.sent)?void 0:o.status)){e.next=18;break}return a=function(){var e=l()(s()().mark((function e(){var n,i,r,o,l,u;return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,x.rX)(null==t?void 0:t.identifier,"submit");case 2:if(i=e.sent,r=i.status,i.message,o=i.data,l=H(),u=l-c>1e4*(null==w||null===(n=w.userAnswer)||void 0===n?void 0:n.length),0===r||u||setTimeout(a,1e3),!u){e.next=13;break}return v.Z.error({centered:!0,okText:"知道啦",title:"调试代码超时",content:"请检查程序代码是否存在死循环"}),E(!1),e.abrupt("return");case 13:0===r&&(E(!1),z(o),2===o.status&&(E(!1),v.Z.error({centered:!0,okText:"知道啦",title:"调试代码超时"})));case 14:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),c=H(),e.next=15,(0,x.bM)(null==t?void 0:t.identifier,{});case 15:a(),e.next=19;break;case 18:E(!1);case 19:return C&&C(!0),e.abrupt("return");case 21:return u=!0,e.next=24,i.validateFields().then((function(){u=!1}),(function(e){var t,n;e.errorFields[0].name.includes("standard_answers")?p.ZP.error("填空项答案不能为空"):p.ZP.error(e.errorFields[0].errors[0]),0===(null===(t=e.errorFields)||void 0===t?void 0:t.length)&&(u=!1),i.scrollToField(null==e||null===(n=e.errorFields)||void 0===n||null===(n=n[0])||void 0===n?void 0:n.name,{behavior:"smooth",block:"center"}),u=!0}));case 24:if(!u){e.next=26;break}return e.abrupt("return");case 26:if(E(!0),!j){e.next=29;break}return e.abrupt("return");case 29:if(d="",f=i.getFieldsValue(),B){e.next=40;break}return e.next=34,(0,m.ZP)("/api/problems.json",{method:"post",body:r()(r()({},f),{},{hack:r()(r()({},null==f?void 0:f.hack),{},{sub_discipline_id:null==f||null===(h=f.hack)||void 0===h||null===(h=h.sub_discipline_id)||void 0===h?void 0:h[1],difficult:f.difficulty,item_banks_group_id:f.item_banks_group_id}),hack_codes:r()(r()({},f.hack_codes),{},{code:g.Base64.encode(f.hack_codes.code)}),hack_sets:[r()({},f.hack_sets)],is_blank:!0})});case 34:d=e.sent,B=null===(k=d)||void 0===k?void 0:k.identifier,sessionStorage.projectFill=B,N(B),e.next=43;break;case 40:return e.next=42,(0,m.ZP)("/api/problems/".concat(B,".json"),{method:"put",body:r()(r()({},f),{},{hack:r()(r()({},null==f?void 0:f.hack),{},{sub_discipline_id:null==f||null===(b=f.hack)||void 0===b||null===(b=b.sub_discipline_id)||void 0===b?void 0:b[1],difficult:f.difficulty,item_banks_group_id:f.item_banks_group_id}),hack_codes:r()(r()({},f.hack_codes),{},{code:g.Base64.encode(f.hack_codes.code)}),update_hack_sets:[r()({},f.hack_sets)],is_blank:!0})});case 42:d=e.sent;case 43:return e.next=45,(0,m.ZP)("/api/problems/".concat(B,"/start.json"),{method:"get"});case 45:return y=e.sent,e.next=48,I(null,null==y?void 0:y.identifier);case 48:if(0!==(null==(_=e.sent)?void 0:_.status)){e.next=57;break}return P=function(){var e=l()(s()().mark((function e(){var t,n,i,r,o,a;return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,x.rX)(null==y?void 0:y.identifier,"submit");case 2:if(n=e.sent,i=n.status,n.message,r=n.data,o=H(),a=o-S>1e3*(f.hack.time_limit+3)*(null==f||null===(t=f.standard_answers)||void 0===t?void 0:t.length),0===i||a||setTimeout(P,1e3),!a){e.next=13;break}return v.Z.error({centered:!0,okText:"知道啦",title:"调试代码超时"}),E(!1),e.abrupt("return");case 13:0===i&&(E(!1),z(r),2===r.status&&(E(!1),v.Z.error({centered:!0,okText:"知道啦",title:"调试代码超时"})));case 14:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),S=H(),e.next=54,(0,x.bM)(null==y?void 0:y.identifier,{});case 54:P(),e.next=58;break;case 57:E(!1);case 58:case"end":return e.stop()}}),e)}))),children:n})),(null==R?void 0:R.id)&&2!==R.status&&(0,_.jsx)(v.Z,{open:(null==R?void 0:R.id)&&2!==R.status,title:"运行结果",width:1100,footer:!1,onOk:function(){z({})},onCancel:function(){z({})},children:(0,_.jsxs)("div",{style:{maxHeight:600,overflow:"auto",marginBottom:15},children:[(0,_.jsxs)("div",{style:{marginBottom:20,display:"flex",justifyContent:"space-between",fontSize:14},children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("span",{style:{color:"#666666"},children:"状态"}),(0,_.jsx)("span",{style:{marginLeft:12,color:0!==R.status&&"#E30000"},children:k.Im[R.status]})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("span",{style:{color:"#666666"},children:"提交时间"}),(0,_.jsx)("span",{style:{marginLeft:12},children:y()(R.created_at).format("YYYY-MM-DD HH:mm:ss")})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("span",{style:{color:"#666666"},children:"语言"}),(0,_.jsx)("span",{style:{marginLeft:12},children:R.language})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("span",{style:{color:"#666666"},children:"执行用时"}),(0,_.jsxs)("span",{style:{marginLeft:12},children:[R.execute_time,"ms"]})]})]}),(0,_.jsx)(k.Y4,r()({},R))]})})]})}},27666:function(e,t,n){var i=n(26390),r=n(62829);t.Z=function(e){let t;const n=n=>()=>{t=null,e.apply(void 0,(0,i.Z)(n))},o=function(){if(null==t){for(var e=arguments.length,i=new Array(e),o=0;o<e;o++)i[o]=arguments[o];t=(0,r.Z)(n(i))}};return o.cancel=()=>{r.Z.cancel(t),t=null},o}},81228:function(e,t,n){n.d(t,{Z:function(){return P}});var i=n(79545),r=n(68550),o=n(17928),s=n(7711),a=n(59301),l=n(92310),c=n.n(l),u=n(28647),d=n(84445),f=n(27666),p=n(36355),h=n(83116),v=n(37613);const g=e=>{const{componentCls:t}=e;return{[t]:{position:"fixed",zIndex:e.zIndexPopup}}};var m=(0,h.Z)("Affix",(e=>{const t=(0,v.TS)(e,{zIndexPopup:e.zIndexBase+10});return[g(t)]}));function x(e){return e!==window?e.getBoundingClientRect():{top:0,bottom:window.innerHeight}}function k(e,t,n){if(void 0!==n&&t.top>e.top-n)return n+t.top}function b(e,t,n){if(void 0!==n&&t.bottom<e.bottom+n){return n+(window.innerHeight-t.bottom)}}const y=["resize","scroll","touchstart","touchmove","touchend","pageshow","load"];function _(){return"undefined"!=typeof window?window:null}var w;!function(e){e[e.None=0]="None",e[e.Prepare=1]="Prepare"}(w||(w={}));let C=function(e){(0,o.Z)(n,e);var t=(0,s.Z)(n);function n(){var e;return(0,i.Z)(this,n),(e=t.apply(this,arguments)).state={status:w.None,lastAffix:!1,prevTarget:null},e.placeholderNodeRef=(0,a.createRef)(),e.fixedNodeRef=(0,a.createRef)(),e.addListeners=()=>{const t=e.getTargetFunc(),n=null==t?void 0:t(),{prevTarget:i}=e.state;i!==n&&(y.forEach((t=>{null==i||i.removeEventListener(t,e.lazyUpdatePosition),null==n||n.addEventListener(t,e.lazyUpdatePosition)})),e.updatePosition(),e.setState({prevTarget:n}))},e.removeListeners=()=>{e.timer&&(clearTimeout(e.timer),e.timer=null);const{prevTarget:t}=e.state,n=e.getTargetFunc(),i=null==n?void 0:n();y.forEach((n=>{null==i||i.removeEventListener(n,e.lazyUpdatePosition),null==t||t.removeEventListener(n,e.lazyUpdatePosition)})),e.updatePosition.cancel(),e.lazyUpdatePosition.cancel()},e.getOffsetTop=()=>{const{offsetBottom:t,offsetTop:n}=e.props;return void 0===t&&void 0===n?0:n},e.getOffsetBottom=()=>e.props.offsetBottom,e.measure=()=>{const{status:t,lastAffix:n}=e.state,{onChange:i}=e.props,r=e.getTargetFunc();if(t!==w.Prepare||!e.fixedNodeRef.current||!e.placeholderNodeRef.current||!r)return;const o=e.getOffsetTop(),s=e.getOffsetBottom(),a=r();if(a){const t={status:w.None},r=x(e.placeholderNodeRef.current);if(0===r.top&&0===r.left&&0===r.width&&0===r.height)return;const l=x(a),c=k(r,l,o),u=b(r,l,s);void 0!==c?(t.affixStyle={position:"fixed",top:c,width:r.width,height:r.height},t.placeholderStyle={width:r.width,height:r.height}):void 0!==u&&(t.affixStyle={position:"fixed",bottom:u,width:r.width,height:r.height},t.placeholderStyle={width:r.width,height:r.height}),t.lastAffix=!!t.affixStyle,i&&n!==t.lastAffix&&i(t.lastAffix),e.setState(t)}},e.prepareMeasure=()=>{e.setState({status:w.Prepare,affixStyle:void 0,placeholderStyle:void 0})},e.updatePosition=(0,f.Z)((()=>{e.prepareMeasure()})),e.lazyUpdatePosition=(0,f.Z)((()=>{const t=e.getTargetFunc(),{affixStyle:n}=e.state;if(t&&n){const i=e.getOffsetTop(),r=e.getOffsetBottom(),o=t();if(o&&e.placeholderNodeRef.current){const t=x(o),s=x(e.placeholderNodeRef.current),a=k(s,t,i),l=b(s,t,r);if(void 0!==a&&n.top===a||void 0!==l&&n.bottom===l)return}}e.prepareMeasure()})),e}return(0,r.Z)(n,[{key:"getTargetFunc",value:function(){const{getTargetContainer:e}=this.context,{target:t}=this.props;return void 0!==t?t:null!=e?e:_}},{key:"componentDidMount",value:function(){this.timer=setTimeout(this.addListeners)}},{key:"componentDidUpdate",value:function(e){this.addListeners(),e.offsetTop===this.props.offsetTop&&e.offsetBottom===this.props.offsetBottom||this.updatePosition(),this.measure()}},{key:"componentWillUnmount",value:function(){this.removeListeners()}},{key:"render",value:function(){const{affixStyle:e,placeholderStyle:t}=this.state,{affixPrefixCls:n,rootClassName:i,children:r}=this.props,o=c()(e&&i,{[n]:!!e});let s=(0,d.Z)(this.props,["prefixCls","offsetTop","offsetBottom","target","onChange","affixPrefixCls","rootClassName"]);return a.createElement(u.Z,{onResize:this.updatePosition},a.createElement("div",Object.assign({},s,{ref:this.placeholderNodeRef}),e&&a.createElement("div",{style:t,"aria-hidden":"true"}),a.createElement("div",{className:o,ref:this.fixedNodeRef,style:e},a.createElement(u.Z,{onResize:this.updatePosition},r))))}}]),n}(a.Component);C.contextType=p.E_;var P=(0,a.forwardRef)(((e,t)=>{const{prefixCls:n,rootClassName:i}=e,{getPrefixCls:r}=(0,a.useContext)(p.E_),o=r("affix",n),[s,l]=m(o),u=Object.assign(Object.assign({},e),{affixPrefixCls:o,rootClassName:c()(i,l)});return s(a.createElement(C,Object.assign({},u,{ref:t})))}))},79817:function(e,t,n){n.d(t,{Z:function(){return S}});var i=n(26390),r=n(92310),o=n.n(r),s=n(73270),a=n(59301),l=n(6774),c=n(13845),u=n(68031),d=n(81228),f=n(36355);var p=a.createContext(void 0);var h=e=>{const{href:t,title:n,prefixCls:i,children:r,className:s,target:l,replace:c}=e,u=a.useContext(p),{registerLink:d,unregisterLink:h,scrollTo:v,onClick:g,activeLink:m,direction:x}=u||{};a.useEffect((()=>(null==d||d(t),()=>{null==h||h(t)})),[t]);const{getPrefixCls:k}=a.useContext(f.E_),b=k("anchor",i),y=m===t,_=o()(`${b}-link`,s,{[`${b}-link-active`]:y}),w=o()(`${b}-link-title`,{[`${b}-link-title-active`]:y});return a.createElement("div",{className:_},a.createElement("a",{className:w,href:t,title:"string"==typeof n?n:"",target:l,onClick:e=>{c&&(e.preventDefault(),window.location.replace(t)),null==g||g(e,{title:n,href:t}),null==v||v(t)}},n),"horizontal"!==x?r:null)},v=n(17313),g=n(83116),m=n(37613);const x=e=>{const{componentCls:t,holderOffsetBlock:n,motionDurationSlow:i,lineWidthBold:r,colorPrimary:o,lineType:s,colorSplit:a}=e;return{[`${t}-wrapper`]:{marginBlockStart:-n,paddingBlockStart:n,[t]:Object.assign(Object.assign({},(0,v.Wf)(e)),{position:"relative",paddingInlineStart:r,[`${t}-link`]:{paddingBlock:e.linkPaddingBlock,paddingInline:`${e.linkPaddingInlineStart}px 0`,"&-title":Object.assign(Object.assign({},v.vS),{position:"relative",display:"block",marginBlockEnd:e.anchorTitleBlock,color:e.colorText,transition:`all ${e.motionDurationSlow}`,"&:only-child":{marginBlockEnd:0}}),[`&-active > ${t}-link-title`]:{color:e.colorPrimary},[`${t}-link`]:{paddingBlock:e.anchorPaddingBlockSecondary}}}),[`&:not(${t}-wrapper-horizontal)`]:{[t]:{"&::before":{position:"absolute",insetInlineStart:0,top:0,height:"100%",borderInlineStart:`${r}px ${s} ${a}`,content:'" "'},[`${t}-ink`]:{position:"absolute",insetInlineStart:0,display:"none",transform:"translateY(-50%)",transition:`top ${i} ease-in-out`,width:r,backgroundColor:o,[`&${t}-ink-visible`]:{display:"inline-block"}}}},[`${t}-fixed ${t}-ink ${t}-ink`]:{display:"none"}}}},k=e=>{const{componentCls:t,motionDurationSlow:n,lineWidthBold:i,colorPrimary:r}=e;return{[`${t}-wrapper-horizontal`]:{position:"relative","&::before":{position:"absolute",left:{_skip_check_:!0,value:0},right:{_skip_check_:!0,value:0},bottom:0,borderBottom:`1px ${e.lineType} ${e.colorSplit}`,content:'" "'},[t]:{overflowX:"scroll",position:"relative",display:"flex",scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"},[`${t}-link:first-of-type`]:{paddingInline:0},[`${t}-ink`]:{position:"absolute",bottom:0,transition:`left ${n} ease-in-out, width ${n} ease-in-out`,height:i,backgroundColor:r}}}}};var b=(0,g.Z)("Anchor",(e=>{const{fontSize:t,fontSizeLG:n,paddingXXS:i}=e,r=(0,m.TS)(e,{holderOffsetBlock:i,anchorPaddingBlockSecondary:i/2,anchorTitleBlock:t/14*3,anchorBallSize:n/2});return[x(r),k(r)]}),(e=>({linkPaddingBlock:e.paddingXXS,linkPaddingInlineStart:e.padding})));function y(){return window}function _(e,t){if(!e.getClientRects().length)return 0;const n=e.getBoundingClientRect();return n.width||n.height?t===window?(t=e.ownerDocument.documentElement,n.top-t.clientTop):n.top-t.getBoundingClientRect().top:n.top}const w=/#([\S ]+)$/,C=e=>{var t;const{rootClassName:n,anchorPrefixCls:r,className:v,style:g,offsetTop:m,affix:x=!0,showInkInFixed:k=!1,children:b,items:C,direction:P="vertical",bounds:S,targetOffset:j,onClick:E,onChange:T,getContainer:Z,getCurrentAnchor:B,replace:N}=e;const[$,O]=a.useState([]),[L,R]=a.useState(null),z=a.useRef(L),F=a.useRef(null),I=a.useRef(null),A=a.useRef(!1),{direction:M,getTargetContainer:D,anchor:H}=a.useContext(f.E_),U=null!==(t=null!=Z?Z:D)&&void 0!==t?t:y,W=JSON.stringify($),X=(0,s.useEvent)((e=>{$.includes(e)||O((t=>[].concat((0,i.Z)(t),[e])))})),Y=(0,s.useEvent)((e=>{$.includes(e)&&O((t=>t.filter((t=>t!==e))))})),J=(0,s.useEvent)((e=>{if(z.current===e)return;const t="function"==typeof B?B(e):e;R(t),z.current=t,null==T||T(e)})),V=a.useCallback((()=>{if(A.current)return;const e=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5;const i=[],r=U();if(e.forEach((e=>{const o=w.exec(null==e?void 0:e.toString());if(!o)return;const s=document.getElementById(o[1]);if(s){const o=_(s,r);o<t+n&&i.push({link:e,top:o})}})),i.length)return i.reduce(((e,t)=>t.top>e.top?t:e)).link;return""}($,void 0!==j?j:m||0,S);J(e)}),[W,j,m]),q=a.useCallback((e=>{J(e);const t=w.exec(e);if(!t)return;const n=document.getElementById(t[1]);if(!n)return;const i=U();let r=(0,c.Z)(i,!0)+_(n,i);r-=void 0!==j?j:m||0,A.current=!0,(0,u.Z)(r,{getContainer:U,callback(){A.current=!1}})}),[j,m]),G=o()(n,`${r}-wrapper`,{[`${r}-wrapper-horizontal`]:"horizontal"===P,[`${r}-rtl`]:"rtl"===M},v,null==H?void 0:H.className),K=o()(r,{[`${r}-fixed`]:!x&&!k}),Q=o()(`${r}-ink`,{[`${r}-ink-visible`]:L}),ee=Object.assign(Object.assign({maxHeight:m?`calc(100vh - ${m}px)`:"100vh"},null==H?void 0:H.style),g),te=e=>Array.isArray(e)?e.map((e=>a.createElement(h,Object.assign({replace:N},e,{key:e.key}),"vertical"===P&&te(e.children)))):null,ne=a.createElement("div",{ref:F,className:G,style:ee},a.createElement("div",{className:K},a.createElement("span",{className:Q,ref:I}),"items"in e?te(C):b));a.useEffect((()=>{const e=U();return V(),null==e||e.addEventListener("scroll",V),()=>{null==e||e.removeEventListener("scroll",V)}}),[W]),a.useEffect((()=>{"function"==typeof B&&J(B(z.current||""))}),[B]),a.useEffect((()=>{(()=>{var e;const t=null===(e=F.current)||void 0===e?void 0:e.querySelector(`.${r}-link-title-active`);if(t&&I.current){const{style:e}=I.current,n="horizontal"===P;e.top=n?"":`${t.offsetTop+t.clientHeight/2}px`,e.height=n?"":`${t.clientHeight}px`,e.left=n?`${t.offsetLeft}px`:"",e.width=n?`${t.clientWidth}px`:"",n&&(0,l.Z)(t,{scrollMode:"if-needed",block:"nearest"})}})()}),[P,B,W,L]);const ie=a.useMemo((()=>({registerLink:X,unregisterLink:Y,scrollTo:q,activeLink:L,onClick:E,direction:P})),[L,E,q,P]);return a.createElement(p.Provider,{value:ie},x?a.createElement(d.Z,{offsetTop:m,target:U},ne):ne)};const P=e=>{const{prefixCls:t,rootClassName:n}=e,{getPrefixCls:i}=a.useContext(f.E_),r=i("anchor",t),[s,l]=b(r);return s(a.createElement(C,Object.assign({},e,{rootClassName:o()(l,n),anchorPrefixCls:r})))};P.Link=h;var S=P}}]); |