wrong-notebook 2026.11.7-1 → 2026.11.8-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +3 -3
- package/.next/prerender-manifest.json +3 -3
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/api/analyze/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/[id]/figure/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/[id]/fix-latex/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/[id]/geogebra/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/[id]/reanswer/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/[id]/retag/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/[id]/svg-animation/narration/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/[id]/svg-animation/route.js.nft.json +1 -1
- package/.next/server/app/api/error-items/route.js.nft.json +1 -1
- package/.next/server/app/api/exams/[id]/questions/[questionId]/regenerate/route.js.nft.json +1 -1
- package/.next/server/app/api/exams/[id]/results/route.js.nft.json +1 -1
- package/.next/server/app/api/exams/[id]/retry/route.js.nft.json +1 -1
- package/.next/server/app/api/exams/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/exams/route.js.nft.json +1 -1
- package/.next/server/app/api/geogebra-analyze/route.js.nft.json +1 -1
- package/.next/server/app/api/import/route.js.nft.json +1 -1
- package/.next/server/app/api/import-batches/[id]/confirm-all/route.js.nft.json +1 -1
- package/.next/server/app/api/import-batches/[id]/fix-text/route.js.nft.json +1 -1
- package/.next/server/app/api/import-batches/[id]/read/route.js.nft.json +1 -1
- package/.next/server/app/api/import-batches/[id]/retry/route.js.nft.json +1 -1
- package/.next/server/app/api/import-batches/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/import-batches/[id]/start/route.js.nft.json +1 -1
- package/.next/server/app/api/import-batches/route.js.nft.json +1 -1
- package/.next/server/app/api/import-tasks/[id]/confirm/route.js.nft.json +1 -1
- package/.next/server/app/api/import-tasks/[id]/read/route.js.nft.json +1 -1
- package/.next/server/app/api/import-tasks/[id]/retry/route.js.nft.json +1 -1
- package/.next/server/app/api/import-tasks/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/import-tasks/route.js.nft.json +1 -1
- package/.next/server/app/api/notebooks/[id]/retag/route.js.nft.json +1 -1
- package/.next/server/app/api/openclaw/batch-upload/route.js.nft.json +1 -1
- package/.next/server/app/api/practice/generate/route.js.nft.json +1 -1
- package/.next/server/app/api/reanswer/route.js.nft.json +1 -1
- package/.next/server/app/api/tasks/route.js.nft.json +1 -1
- package/.next/server/app/api/tts/batch/route.js.nft.json +1 -1
- package/.next/server/app/error-items/[id]/page.js.nft.json +1 -1
- package/.next/server/app/error-items/[id]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/notebooks/[id]/add/page.js.nft.json +1 -1
- package/.next/server/app/notebooks/[id]/add/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/chunks/ssr/src_components_image-cropper_tsx_0pcp8-ifruyx-._.js +1 -1
- package/.next/server/middleware-build-manifest.js +3 -3
- package/.next/server/pages/500.html +1 -1
- package/.next/server/preview-props.json +3 -3
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/{0v0aq-qavci47.js → 0wn8i_n7wpzhy.js} +2 -2
- package/.next/static/chunks/16qwioc_q7wfz.js +8 -0
- package/.next/static/chunks/{2lj8xffcdf-gx.js → 3mnblmrqi_tcr.js} +1 -1
- package/package.json +1 -1
- package/prisma/seed.db +0 -0
- package/.next/static/chunks/039sn7yqi6e6q.js +0 -8
- /package/.next/static/{PyK_g5Rym102F6WwGPS2g → 8txIetq9muxlc0OqsgaeI}/_buildManifest.js +0 -0
- /package/.next/static/{PyK_g5Rym102F6WwGPS2g → 8txIetq9muxlc0OqsgaeI}/_clientMiddlewareManifest.js +0 -0
- /package/.next/static/{PyK_g5Rym102F6WwGPS2g → 8txIetq9muxlc0OqsgaeI}/_ssgManifest.js +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(()=>{"use strict";(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,232660,e=>{var t=e.i(271645),n={x:0,y:0,width:0,height:0,unit:"px"},i=(e,t,n)=>Math.min(Math.max(e,t),n),r=(e,t)=>e===t||e.width===t.width&&e.height===t.height&&e.x===t.x&&e.y===t.y&&e.unit===t.unit;function a(e,t,i){return"%"===e.unit?{...n,...e,unit:"%"}:{unit:"%",x:e.x?e.x/t*100:0,y:e.y?e.y/i*100:0,width:e.width?e.width/t*100:0,height:e.height?e.height/i*100:0}}function l(e,t,i){return e.unit&&"px"!==e.unit?{unit:"px",x:e.x?e.x*t/100:0,y:e.y?e.y*i/100:0,width:e.width?e.width*t/100:0,height:e.height?e.height*i/100:0}:{...n,...e,unit:"px"}}function o(e,t,n,i,r,a=0,l=0,s=i,h=r){let c={...e},u=Math.min(a,i),d=Math.min(l,r),m=Math.min(s,i),g=Math.min(h,r);t&&(t>1?(d=(u=l?l*t:u)/t,m=s*t):(u=(d=a?a/t:d)*t,g=h/t)),c.y<0&&(c.height=Math.max(c.height+c.y,d),c.y=0),c.x<0&&(c.width=Math.max(c.width+c.x,u),c.x=0);let p=i-(c.x+c.width);p<0&&(c.x=Math.min(c.x,i-u),c.width+=p);let f=r-(c.y+c.height);if(f<0&&(c.y=Math.min(c.y,r-d),c.height+=f),c.width<u&&(("sw"===n||"nw"==n)&&(c.x-=u-c.width),c.width=u),c.height<d&&(("nw"===n||"ne"==n)&&(c.y-=d-c.height),c.height=d),c.width>m&&(("sw"===n||"nw"==n)&&(c.x-=m-c.width),c.width=m),c.height>g&&(("nw"===n||"ne"==n)&&(c.y-=g-c.height),c.height=g),t){let e=c.width/c.height;if(e<t){let e=Math.max(c.width/t,d);("nw"===n||"ne"==n)&&(c.y-=e-c.height),c.height=e}else if(e>t){let e=Math.max(c.height*t,u);("sw"===n||"nw"==n)&&(c.x-=e-c.width),c.width=e}}return c}var s={capture:!0,passive:!1},h=0,c=class e extends t.PureComponent{static xOrds=["e","w"];static yOrds=["n","s"];static xyOrds=["nw","ne","se","sw"];static nudgeStep=1;static nudgeStepMedium=10;static nudgeStepLarge=100;static defaultProps={ariaLabels:{cropArea:"Use the arrow keys to move the crop selection area",nwDragHandle:"Use the arrow keys to move the north west drag handle to change the crop selection area",nDragHandle:"Use the up and down arrow keys to move the north drag handle to change the crop selection area",neDragHandle:"Use the arrow keys to move the north east drag handle to change the crop selection area",eDragHandle:"Use the up and down arrow keys to move the east drag handle to change the crop selection area",seDragHandle:"Use the arrow keys to move the south east drag handle to change the crop selection area",sDragHandle:"Use the up and down arrow keys to move the south drag handle to change the crop selection area",swDragHandle:"Use the arrow keys to move the south west drag handle to change the crop selection area",wDragHandle:"Use the up and down arrow keys to move the west drag handle to change the crop selection area"}};get document(){return document}docMoveBound=!1;mouseDownOnCrop=!1;dragStarted=!1;evData={startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0};componentRef=(0,t.createRef)();mediaRef=(0,t.createRef)();resizeObserver;initChangeCalled=!1;instanceId=`rc-${h++}`;state={cropIsActive:!1,newCropIsBeingDrawn:!1};getBox(){let e=this.mediaRef.current;if(!e)return{x:0,y:0,width:0,height:0};let{x:t,y:n,width:i,height:r}=e.getBoundingClientRect();return{x:t,y:n,width:i,height:r}}componentDidUpdate(e){let{crop:t,onComplete:n}=this.props;if(n&&!e.crop&&t){let{width:e,height:i}=this.getBox();e&&i&&n(l(t,e,i),a(t,e,i))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||=(this.document.addEventListener("pointermove",this.onDocPointerMove,s),this.document.addEventListener("pointerup",this.onDocPointerDone,s),this.document.addEventListener("pointercancel",this.onDocPointerDone,s),!0)}unbindDocMove(){this.docMoveBound&&=(this.document.removeEventListener("pointermove",this.onDocPointerMove,s),this.document.removeEventListener("pointerup",this.onDocPointerDone,s),this.document.removeEventListener("pointercancel",this.onDocPointerDone,s),!1)}onCropPointerDown=e=>{let{crop:t,disabled:n}=this.props,i=this.getBox();if(!t)return;let r=l(t,i.width,i.height);if(n)return;e.cancelable&&e.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});let a=e.target.dataset.ord,o=e.clientX,s=e.clientY,h=r.x,c=r.y;if(a){let t=e.clientX-i.x,n=e.clientY-i.y,l=0,u=0;"ne"===a||"e"==a?(l=t-(r.x+r.width),u=n-r.y,h=r.x,c=r.y+r.height):"se"===a||"s"===a?(l=t-(r.x+r.width),u=n-(r.y+r.height),h=r.x,c=r.y):"sw"===a||"w"==a?(l=t-r.x,u=n-(r.y+r.height),h=r.x+r.width,c=r.y):("nw"===a||"n"==a)&&(l=t-r.x,u=n-r.y,h=r.x+r.width,c=r.y+r.height),o=h+i.x+l,s=c+i.y+u}this.evData={startClientX:o,startClientY:s,startCropX:h,startCropY:c,clientX:e.clientX,clientY:e.clientY,isResize:!!a,ord:a},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})};onComponentPointerDown=e=>{let{crop:t,disabled:n,locked:i,keepSelection:r,onChange:o}=this.props,s=this.getBox();if(n||i||r&&t)return;e.cancelable&&e.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});let h=e.clientX-s.x,c=e.clientY-s.y,u={unit:"px",x:h,y:c,width:0,height:0};this.evData={startClientX:e.clientX,startClientY:e.clientY,startCropX:h,startCropY:c,clientX:e.clientX,clientY:e.clientY,isResize:!0},this.mouseDownOnCrop=!0,o(l(u,s.width,s.height),a(u,s.width,s.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})};onDocPointerMove=e=>{let t,{crop:n,disabled:i,onChange:o,onDragStart:s}=this.props,h=this.getBox();if(i||!n||!this.mouseDownOnCrop)return;e.cancelable&&e.preventDefault(),this.dragStarted||(this.dragStarted=!0,s&&s(e));let{evData:c}=this;c.clientX=e.clientX,c.clientY=e.clientY,r(n,t=c.isResize?this.resizeCrop():this.dragCrop())||o(l(t,h.width,h.height),a(t,h.width,h.height))};onComponentKeyDown=t=>{let{crop:n,disabled:r,onChange:o,onComplete:s}=this.props;if(r)return;let h=t.key,c=!1;if(!n)return;let u=this.getBox(),d=this.makePixelCrop(u),m=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?e.nudgeStepLarge:t.shiftKey?e.nudgeStepMedium:e.nudgeStep;if("ArrowLeft"===h?(d.x-=m,c=!0):"ArrowRight"===h?(d.x+=m,c=!0):"ArrowUp"===h?(d.y-=m,c=!0):"ArrowDown"===h&&(d.y+=m,c=!0),c){t.cancelable&&t.preventDefault(),d.x=i(d.x,0,u.width-d.width),d.y=i(d.y,0,u.height-d.height);let e=l(d,u.width,u.height),n=a(d,u.width,u.height);o(e,n),s&&s(e,n)}};onHandlerKeyDown=(t,n)=>{var i,s;let h,{aspect:c=0,crop:u,disabled:d,minWidth:m=0,minHeight:g=0,maxWidth:p,maxHeight:f,onChange:w,onComplete:x}=this.props,y=this.getBox();if(d||!u||"ArrowUp"!==t.key&&"ArrowDown"!==t.key&&"ArrowLeft"!==t.key&&"ArrowRight"!==t.key)return;t.stopPropagation(),t.preventDefault();let b=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?e.nudgeStepLarge:t.shiftKey?e.nudgeStepMedium:e.nudgeStep,v=o((i=l(u,y.width,y.height),s=t.key,h={...i},"ArrowLeft"===s?"nw"===n?(h.x-=b,h.y-=b,h.width+=b,h.height+=b):"w"===n?(h.x-=b,h.width+=b):"sw"===n?(h.x-=b,h.width+=b,h.height+=b):"ne"===n?(h.y+=b,h.width-=b,h.height-=b):"e"===n?h.width-=b:"se"===n&&(h.width-=b,h.height-=b):"ArrowRight"===s&&("nw"===n?(h.x+=b,h.y+=b,h.width-=b,h.height-=b):"w"===n?(h.x+=b,h.width-=b):"sw"===n?(h.x+=b,h.width-=b,h.height-=b):"ne"===n?(h.y-=b,h.width+=b,h.height+=b):"e"===n?h.width+=b:"se"===n&&(h.width+=b,h.height+=b)),"ArrowUp"===s?"nw"===n?(h.x-=b,h.y-=b,h.width+=b,h.height+=b):"n"===n?(h.y-=b,h.height+=b):"ne"===n?(h.y-=b,h.width+=b,h.height+=b):"sw"===n?(h.x+=b,h.width-=b,h.height-=b):"s"===n?h.height-=b:"se"===n&&(h.width-=b,h.height-=b):"ArrowDown"===s&&("nw"===n?(h.x+=b,h.y+=b,h.width-=b,h.height-=b):"n"===n?(h.y+=b,h.height-=b):"ne"===n?(h.y+=b,h.width-=b,h.height-=b):"sw"===n?(h.x-=b,h.width+=b,h.height+=b):"s"===n?h.height+=b:"se"===n&&(h.width+=b,h.height+=b)),h),c,n,y.width,y.height,m,g,p,f);if(!r(u,v)){let e=a(v,y.width,y.height);w(v,e),x&&x(v,e)}};onDocPointerDone=e=>{let{crop:t,disabled:n,onComplete:i,onDragEnd:r}=this.props,o=this.getBox();this.unbindDocMove(),!(n||!t)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,r&&r(e),i&&i(l(t,o.width,o.height),a(t,o.width,o.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))};onDragFocus=()=>{this.componentRef.current?.scrollTo(0,0)};getCropStyle(){let{crop:e}=this.props;if(e)return{top:`${e.y}${e.unit}`,left:`${e.x}${e.unit}`,width:`${e.width}${e.unit}`,height:`${e.height}${e.unit}`}}dragCrop(){let{evData:e}=this,t=this.getBox(),n=this.makePixelCrop(t),r=e.clientX-e.startClientX,a=e.clientY-e.startClientY;return n.x=i(e.startCropX+r,0,t.width-n.width),n.y=i(e.startCropY+a,0,t.height-n.height),n}getPointRegion(e,t,n,i){let{evData:r}=this,a=r.clientX-e.x,l=r.clientY-e.y,o;return o=i&&t?"nw"===t||"n"===t||"ne"===t:l<r.startCropY,(n&&t?"nw"===t||"w"===t||"sw"===t:a<r.startCropX)?o?"nw":"sw":o?"ne":"se"}resolveMinDimensions(e,t,n=0,i=0){let r=Math.min(n,e.width),a=Math.min(i,e.height);return t&&(r||a)?t>1?r?[r,r/t]:[a*t,a]:a?[a*t,a]:[r,r/t]:[r,a]}resizeCrop(){let{evData:t}=this,{aspect:n=0,maxWidth:r,maxHeight:a}=this.props,l=this.getBox(),[s,h]=this.resolveMinDimensions(l,n,this.props.minWidth,this.props.minHeight),c=this.makePixelCrop(l),u=this.getPointRegion(l,t.ord,s,h),d=t.ord||u,m=t.clientX-t.startClientX,g=t.clientY-t.startClientY;(s&&"nw"===d||"w"===d||"sw"===d)&&(m=Math.min(m,-s)),(h&&"nw"===d||"n"===d||"ne"===d)&&(g=Math.min(g,-h));let p={unit:"px",x:0,y:0,width:0,height:0};"ne"===u?(p.x=t.startCropX,p.width=m,n?p.height=p.width/n:p.height=Math.abs(g),p.y=t.startCropY-p.height):"se"===u?(p.x=t.startCropX,p.y=t.startCropY,p.width=m,n?p.height=p.width/n:p.height=g):"sw"===u?(p.x=t.startCropX+m,p.y=t.startCropY,p.width=Math.abs(m),n?p.height=p.width/n:p.height=g):"nw"===u&&(p.x=t.startCropX+m,p.width=Math.abs(m),n?(p.height=p.width/n,p.y=t.startCropY-p.height):(p.height=Math.abs(g),p.y=t.startCropY+g));let f=o(p,n,u,l.width,l.height,s,h,r,a);return n||e.xyOrds.indexOf(d)>-1?c=f:e.xOrds.indexOf(d)>-1?(c.x=f.x,c.width=f.width):e.yOrds.indexOf(d)>-1&&(c.y=f.y,c.height=f.height),c.x=i(c.x,0,l.width-c.width),c.y=i(c.y,0,l.height-c.height),c}renderCropSelection(){let{ariaLabels:n=e.defaultProps.ariaLabels,disabled:i,locked:r,renderSelectionAddon:a,ruleOfThirds:l,crop:o}=this.props,s=this.getCropStyle();if(o)return t.default.createElement("div",{style:s,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":n.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!i&&!r&&t.default.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},t.default.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),t.default.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),t.default.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),t.default.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":n.nwDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"nw"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":n.nDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"n"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":n.neDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"ne"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":n.eDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"e"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":n.seDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"se"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":n.sDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"s"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":n.swDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"sw"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":n.wDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"w"),role:"button"})),a&&t.default.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:e=>e.stopPropagation()},a(this.state)),l&&t.default.createElement(t.default.Fragment,null,t.default.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),t.default.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(e){return l({...n,...this.props.crop||{}},e.width,e.height)}render(){let{aspect:e,children:n,circularCrop:i,className:r,crop:a,disabled:l,locked:o,style:s,ruleOfThirds:h}=this.props,{cropIsActive:c,newCropIsBeingDrawn:u}=this.state,d=a?this.renderCropSelection():null,m=((...e)=>e.filter(e=>e&&"string"==typeof e).join(" "))("ReactCrop",r,c&&"ReactCrop--active",l&&"ReactCrop--disabled",o&&"ReactCrop--locked",u&&"ReactCrop--new-crop",a&&e&&"ReactCrop--fixed-aspect",a&&i&&"ReactCrop--circular-crop",a&&h&&"ReactCrop--rule-of-thirds",!this.dragStarted&&a&&!a.width&&!a.height&&"ReactCrop--invisible-crop",i&&"ReactCrop--no-animate");return t.default.createElement("div",{ref:this.componentRef,className:m,style:s},t.default.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},n),a?t.default.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},t.default.createElement("defs",null,t.default.createElement("mask",{id:`hole-${this.instanceId}`},t.default.createElement("rect",{width:"100%",height:"100%",fill:"white"}),i?t.default.createElement("ellipse",{cx:`${a.x+a.width/2}${a.unit}`,cy:`${a.y+a.height/2}${a.unit}`,rx:`${a.width/2}${a.unit}`,ry:`${a.height/2}${a.unit}`,fill:"black"}):t.default.createElement("rect",{x:`${a.x}${a.unit}`,y:`${a.y}${a.unit}`,width:`${a.width}${a.unit}`,height:`${a.height}${a.unit}`,fill:"black"}))),t.default.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,d)}};e.s(["f",0,c])},12130,271945,e=>{var t=e.i(843476),n=e.i(271645),i=e.i(232660),r=e.i(519455),a=e.i(776639),l=e.i(263676),o=e.i(111110);async function s(e,t){let{naturalWidth:n,naturalHeight:i}=e;return Promise.all(t.map(t=>new Promise((r,a)=>{let l=document.createElement("canvas"),o=Math.round(t.x*n),s=Math.round(t.y*i);l.width=Math.max(1,Math.round(t.width*n)),l.height=Math.max(1,Math.round(t.height*i));let h=l.getContext("2d");h?(h.drawImage(e,o,s,l.width,l.height,0,0,l.width,l.height),l.toBlob(e=>e?r(e):a(Error("Canvas is empty")),"image/jpeg",.95)):a(Error("Canvas is not supported"))})))}let h={maxHeight:"65vh",maxWidth:"100%",objectFit:"contain"},c=(0,n.forwardRef)(function({imageSrc:e,regions:i,onChange:r,imageStyle:a=h,onImageLoad:s},c){let{t:u}=(0,o.b)(),d=(0,n.useRef)(null),m=(0,n.useRef)(null),[g,p]=(0,n.useState)(null),f=e=>{let t=d.current.getBoundingClientRect();return{x:(e.clientX-t.left)/t.width,y:(e.clientY-t.top)/t.height}},w=()=>{g&&g.width>=.02&&g.height>=.02&&r([...i,g]),m.current=null,p(null)},x=e=>({left:`${100*e.x}%`,top:`${100*e.y}%`,width:`${100*e.width}%`,height:`${100*e.height}%`});return(0,t.jsxs)("div",{className:"relative inline-block select-none",children:[(0,t.jsx)("img",{ref:c,src:e,alt:"",draggable:!1,style:a,onLoad:s,className:"block"}),(0,t.jsxs)("div",{ref:d,className:"absolute inset-0 cursor-crosshair",style:{touchAction:"none"},onPointerDown:e=>{0===e.button&&(d.current?.setPointerCapture(e.pointerId),m.current=f(e),p(null))},onPointerMove:e=>{var t,n,i,r;let a,l,o;if(!m.current)return;let s=f(e);p((t=m.current.x,n=m.current.y,i=s.x,r=s.y,l=(a=e=>Math.min(1,Math.max(0,e)))(Math.min(t,i)),o=a(Math.min(n,r)),{x:l,y:o,width:a(Math.max(t,i))-l,height:a(Math.max(n,r))-o}))},onPointerUp:w,onPointerCancel:w,children:[i.map((e,n)=>(0,t.jsxs)("div",{className:"absolute border-2 border-sky-400 bg-sky-400/15",style:x(e),children:[(0,t.jsx)("span",{className:"absolute left-0 top-0 bg-sky-500 px-1.5 text-xs font-bold text-white",children:n+1}),(0,t.jsx)("button",{type:"button",className:"absolute -right-3 -top-3 flex h-6 w-6 items-center justify-center rounded-full bg-red-500 text-white shadow","aria-label":u.batchImport.removeRegion.replace("{index}",String(n+1)),onPointerDown:e=>e.stopPropagation(),onClick:()=>r(i.filter((e,t)=>t!==n)),children:(0,t.jsx)(l.X,{className:"h-3 w-3"})})]},n)),g&&(0,t.jsx)("div",{className:"absolute border-2 border-dashed border-yellow-300 bg-yellow-300/10",style:x(g)})]})]})});var u=e.i(456420);let d={name:"zoom-in",size:24,node:[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]};d.node;let m=(0,u.f)(d),g={name:"zoom-out",size:24,node:[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]};g.node;let p=(0,u.f)(g);function f({zoom:e,onZoomIn:n,onZoomOut:i,onReset:r}){let{t:a}=(0,o.b)(),l="outline-none focus-visible:ring-2 focus-visible:ring-white/70",s=`flex h-9 w-9 items-center justify-center rounded-full text-white transition-colors hover:bg-white/20 disabled:opacity-40 disabled:hover:bg-transparent ${l}`;return(0,t.jsxs)("div",{className:"flex items-center gap-0.5 rounded-full bg-black/60 p-1 shadow-lg backdrop-blur-sm",children:[(0,t.jsx)("button",{type:"button",className:s,onClick:i,disabled:e<=1,"aria-label":a.common.cropper.zoomOut,title:a.common.cropper.zoomOut,children:(0,t.jsx)(p,{className:"h-4 w-4"})}),(0,t.jsxs)("button",{type:"button",className:`h-9 min-w-14 rounded-full px-2 text-center text-xs font-medium tabular-nums text-white hover:bg-white/20 ${l}`,onClick:r,"aria-label":a.common.cropper.resetZoom,title:a.common.cropper.resetZoom,children:[Math.round(100*e),"%"]}),(0,t.jsx)("button",{type:"button",className:s,onClick:n,disabled:e>=5,"aria-label":a.common.cropper.zoomIn,title:a.common.cropper.zoomIn,children:(0,t.jsx)(m,{className:"h-4 w-4"})})]})}var w=e.i(201276),x=e.i(804536);let y="image-cropper-mode",b=["single","auto","multi"];e.s(["U",0,b,"p",0,y,"S",0,["image","text","file","direct"],"c",0,"question-input-mode","k",0,["image","text"]],271945);let v={single:{maxHeight:"70vh",maxWidth:"100%",objectFit:"contain"},auto:{maxHeight:"65vh",maxWidth:"100%",objectFit:"contain"},multi:{maxHeight:"65vh",maxWidth:"100%",objectFit:"contain"}};e.s(["f",0,function({imageSrc:e,open:l,onClose:h,onCropComplete:u,onMultiCropComplete:d,onRegionsSelected:m,allowMulti:g=!0,onAutoSplit:p,onAddPart:C,partCount:k=0}){let{t:M}=(0,o.b)(),D=/^(blob:|data:image\/)/i.test(e)?e:void 0,[E,_]=(0,n.useState)(),j=(0,n.useRef)(null),[R,I]=(0,x.y)(y,b,"single"),S=["single",...p?["auto"]:[],...d||m&&g?["multi"]:[]],N=S.includes(R)?R:"single",{containerRef:$,zoom:P,imageStyle:L,measureImage:A,zoomIn:H,zoomOut:O,reset:U}=function(e){let[t,i]=(0,n.useState)(null),r=(0,n.useRef)(null),a=(0,n.useCallback)(e=>{r.current=e,i(e)},[]),[l,o]=(0,n.useState)(1),s=(0,n.useRef)(1),[h,c]=(0,n.useState)(null),u=(0,n.useRef)(null),d=(0,n.useRef)(!1),m=(0,n.useCallback)((e,t,n)=>{let i=r.current,a=s.current,l=Math.min(5,Math.max(1,e));if(!i||l===a)return;if(1===a){let e=i.querySelector("img");e&&c(e.clientWidth)}let h=i.getBoundingClientRect(),d=(t??h.left+h.width/2)-h.left,m=(n??h.top+h.height/2)-h.top;u.current={viewX:d,viewY:m,contentX:i.scrollLeft+d,contentY:i.scrollTop+m,ratio:l/a},s.current=l,o(l)},[]);(0,n.useLayoutEffect)(()=>{let e=r.current,t=u.current;e&&t&&(e.scrollLeft=t.contentX*t.ratio-t.viewX,e.scrollTop=t.contentY*t.ratio-t.viewY,u.current=null)},[l]),(0,n.useEffect)(()=>{if(!t)return;let e=e=>{e.preventDefault(),m(s.current*Math.exp(-(.0015*e.deltaY)),e.clientX,e.clientY)},n=null,i=e=>{let[t,n]=[e[0],e[1]];return{distance:Math.hypot(t.clientX-n.clientX,t.clientY-n.clientY),centerX:(t.clientX+n.clientX)/2,centerY:(t.clientY+n.clientY)/2}},r=e=>{2===e.touches.length&&(n={distance:i(e.touches).distance,zoom:s.current},d.current=!0)},a=e=>{if(!n||2!==e.touches.length)return;e.preventDefault();let{distance:t,centerX:r,centerY:a}=i(e.touches);n.distance>0&&m(n.zoom*(t/n.distance),r,a)},l=e=>{e.touches.length<2&&(n=null,d.current=!1)},o=e=>{d.current&&e.stopPropagation()};return t.addEventListener("wheel",e,{passive:!1}),t.addEventListener("touchstart",r,{passive:!0}),t.addEventListener("touchmove",a,{passive:!1}),t.addEventListener("touchend",l),t.addEventListener("touchcancel",l),t.addEventListener("pointermove",o,{capture:!0}),()=>{t.removeEventListener("wheel",e),t.removeEventListener("touchstart",r),t.removeEventListener("touchmove",a),t.removeEventListener("touchend",l),t.removeEventListener("touchcancel",l),t.removeEventListener("pointermove",o,{capture:!0})}},[t,m]);let g=(0,n.useCallback)(e=>{e&&1===s.current&&c(e.clientWidth)},[]),p=(0,n.useCallback)(()=>m(1.25*s.current),[m]),f=(0,n.useCallback)(()=>m(s.current/1.25),[m]),w=(0,n.useCallback)(()=>{s.current=1,u.current=null,o(1)},[]),x=1!==l&&h?{...e,width:h*l,height:"auto",maxWidth:"none",maxHeight:"none"}:e;return{containerRef:a,zoom:l,imageStyle:x,measureImage:g,zoomIn:p,zoomOut:f,reset:w}}(v[N]);(0,n.useEffect)(()=>{U()},[e,U]);let[X,Y]=(0,n.useState)({src:e,regions:[]}),B=X.src===e?X.regions:[],T=t=>Y({src:e,regions:t}),z=(0,n.useRef)(null),K={single:M.batchImport.singleMode,auto:M.batchImport.autoMode,multi:M.batchImport.multiMode},F=async()=>{if(0!==B.length){if(m){m(B,!0),T([]);return}if(z.current&&d)try{d(await s(z.current,B)),T([])}catch(e){w.V.error("[ImageCropper]","Multi-image crop failed",{error:e})}}},q=()=>E&&E.width>0&&E.height>0?{x:E.x/100,y:E.y/100,width:E.width/100,height:E.height/100}:{x:0,y:0,width:1,height:1},W=async()=>{let e=q();if("auto"===N&&p)return void p(e);if(m)return void m([e],!1);if(j.current&&u)try{let[t]=await s(j.current,[e]);u(t)}catch(e){w.V.error("[ImageCropper]","Crop failed",{error:e})}};return(0,t.jsx)(a.N,{open:l,onOpenChange:e=>!e&&h(),children:(0,t.jsxs)(a.d,{className:"max-w-3xl h-[90vh] flex flex-col p-0 gap-0",children:[(0,t.jsx)(a.s,{className:"p-4 border-b shrink-0",children:(0,t.jsx)(a.F,{children:M.common.cropper?.title||"Crop Image"})}),(0,t.jsxs)("div",{className:"relative min-h-0 flex-1 bg-black",children:[(0,t.jsx)("div",{ref:$,className:"flex h-full w-full overflow-auto p-4",children:(0,t.jsx)("div",{className:"m-auto",children:"multi"===N?(0,t.jsx)(c,{ref:z,imageSrc:D,regions:B,onChange:T,imageStyle:L,onImageLoad:e=>A(e.currentTarget)}):(0,t.jsx)(i.f,{crop:E,onChange:(e,t)=>_(t),children:(0,t.jsx)("img",{ref:j,alt:"Crop me",src:D,onLoad:function(e){_({unit:"%",x:0,y:0,width:100,height:100}),A(e.currentTarget)},style:L})})})}),(0,t.jsx)("div",{className:"absolute right-3 top-3",children:(0,t.jsx)(f,{zoom:P,onZoomIn:H,onZoomOut:O,onReset:U})})]}),(0,t.jsxs)("div",{className:"p-4 border-t bg-background shrink-0 space-y-3",children:[S.length>1&&(0,t.jsx)("div",{className:`grid gap-1 rounded-md bg-muted p-1 ${3===S.length?"grid-cols-3 sm:w-[28rem]":"grid-cols-2 sm:w-80"}`,children:S.map(e=>(0,t.jsx)("button",{type:"button","aria-pressed":N===e,onClick:()=>{U(),I(e)},className:`rounded px-2 py-1.5 text-sm font-medium transition-colors ${N===e?"bg-background shadow-sm":"text-muted-foreground"}`,children:K[e]},e))}),(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row sm:justify-between sm:items-center gap-3",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"multi"===N?`${M.batchImport.hint} ${M.batchImport.regionCount.replace("{count}",String(B.length))}`:"auto"===N?M.batchImport.autoHint:k>0?M.upload.parts.cropHint.replace("{n}",String(k+1)):M.common.cropper?.hint||"💡 Drag to adjust crop area"}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2 justify-end",children:["multi"===N&&B.length>0&&(0,t.jsx)(r.f,{variant:"ghost",onClick:()=>T([]),children:M.batchImport.clear}),(0,t.jsx)(r.f,{variant:"outline",onClick:h,children:M.common.cancel||"Cancel"}),"multi"===N?(0,t.jsx)(r.f,{onClick:F,disabled:0===B.length,children:M.batchImport.start.replace("{count}",String(B.length))}):(0,t.jsxs)(t.Fragment,{children:["single"===N&&C&&(0,t.jsx)(r.f,{variant:"secondary",onClick:()=>C(q()),"data-testid":"crop-add-part",children:M.upload.parts.addNext}),(0,t.jsx)(r.f,{onClick:W,children:"auto"===N?M.batchImport.autoStart:k>0?M.upload.parts.confirm.replace("{count}",String(k+1)):M.common.confirm||"Confirm"})]})]})]})]})]})})}],12130)},574041,e=>{var t=e.i(843476),n=e.i(271645),i=e.i(263676),r=e.i(487486),a=e.i(793479),l=e.i(41931),o=e.i(201276);e.s(["f",0,function({value:e=[],onChange:s,placeholder:h="Enter tags...",className:c="",enterHint:u,subject:d,gradeStage:m}){let[g,p]=(0,n.useState)(""),[f,w]=(0,n.useState)([]),[x,y]=(0,n.useState)(!1),[b,v]=(0,n.useState)(0),C=(0,n.useRef)(null),k=(0,n.useRef)(null),M=(0,n.useCallback)(async t=>{try{let n=new URLSearchParams({q:t});d&&n.append("subject",d),m&&n.append("stage",m);let i=((await l.k.get(`/api/tags/suggestions?${n.toString()}`)).suggestions||[]).filter(t=>!e.includes(t));w(i.slice(0,20)),y(i.length>0),v(0)}catch(e){o.V.error("[TagInput]","Failed to fetch suggestions",{error:e})}},[d,m,e]);(0,n.useEffect)(()=>{g.trim()&&M(g)},[g,M]);let D=t=>{t.trim()&&!e.includes(t.trim())&&(s([...e,t.trim()]),p(""),w([]),y(!1),v(0))},E=t=>{s(e.filter(e=>e!==t))};return(0,n.useEffect)(()=>{let e=e=>{!k.current||k.current.contains(e.target)||C.current?.contains(e.target)||y(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,t.jsxs)("div",{className:`relative ${c}`,children:[(0,t.jsxs)("div",{className:"flex flex-wrap gap-2 p-2 border rounded-lg bg-background min-h-[42px]",children:[e.map(e=>(0,t.jsxs)(r.f,{variant:"secondary",className:"flex items-center gap-1 px-2 py-1",children:[e,(0,t.jsx)("button",{type:"button",onClick:()=>E(e),className:"hover:text-destructive ml-1",children:(0,t.jsx)(i.X,{className:"h-3 w-3"})})]},e)),(0,t.jsx)(a.f,{ref:C,type:"text",value:g,onChange:e=>{p(e.target.value),e.target.value.trim()||(w([]),y(!1))},onKeyDown:t=>{"Enter"===t.key?(t.preventDefault(),b>=0&&f[b]?D(f[b]):g.trim()&&D(g)):"ArrowDown"===t.key?(t.preventDefault(),v(e=>Math.min(e+1,f.length-1))):"ArrowUp"===t.key?(t.preventDefault(),v(e=>Math.max(e-1,0))):"Escape"===t.key?(y(!1),v(0)):"Backspace"===t.key&&!g&&e.length>0&&E(e[e.length-1])},onFocus:()=>{f.length>0&&y(!0)},placeholder:0===e.length?h:"",className:"flex-1 min-w-[120px] border-none focus-visible:ring-0 focus-visible:ring-offset-0 h-8 px-0"})]}),x&&f.length>0&&(0,t.jsx)("div",{ref:k,className:"absolute z-50 w-full mt-1 bg-popover border rounded-md shadow-md max-h-48 overflow-y-auto",children:f.map((e,n)=>(0,t.jsx)("div",{className:`px-3 py-2 cursor-pointer hover:bg-accent ${n===b?"bg-accent":""}`,onClick:()=>D(e),onMouseEnter:()=>v(n),children:e},e))}),g&&!x&&(0,t.jsx)("div",{className:"text-xs text-muted-foreground mt-1",children:u?`${u} "${g}"`:`Press Enter to create "${g}"`})]})}])},185592,e=>{var t=e.i(843476),n=e.i(975157);e.s(["f",0,function({options:e,value:i,onChange:r,className:a}){return(0,t.jsx)("div",{className:(0,n.f)("grid gap-1 rounded-xl bg-muted p-1",a),style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},role:"tablist",children:e.map(({value:e,label:a,icon:l})=>{let o=e===i;return(0,t.jsxs)("button",{type:"button",role:"tab","aria-selected":o,className:(0,n.f)("flex items-center justify-center gap-1.5 rounded-lg px-2 py-2.5 text-sm font-medium transition-all",o?"bg-card text-primary shadow-sm":"text-muted-foreground hover:text-foreground"),onClick:()=>r(e),children:[l&&(0,t.jsx)(l,{className:"h-4 w-4 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:a})]},e)})})}])},804536,e=>{var t=e.i(271645);let n=new Map,i=new Set;function r(e){return i.add(e),window.addEventListener("storage",e),()=>{i.delete(e),window.removeEventListener("storage",e)}}function a(e,a,l){let o=(0,t.useSyncExternalStore)(r,()=>(function(e){if(n.has(e))return n.get(e)??null;try{return window.localStorage.getItem(e)}catch{return null}})(e),()=>null);return[(0,t.useMemo)(()=>a(o),[a,o]),(0,t.useCallback)(t=>(function(e,t){try{window.localStorage.setItem(e,t),n.delete(e)}catch{n.set(e,t)}i.forEach(e=>e())})(e,l(t)),[e,l])]}let l=e=>e;e.s(["y",0,function(e,n,i){return a(e,(0,t.useCallback)(e=>n.includes(e??"")?e:i,[n,i]),l)},"x",0,a])},213761,e=>{let t={maxLongEdge:4096,maxPixels:4915200,maxBytes:1572864,startQuality:.9,minQuality:.8};class n extends Error{code;format;constructor(e,t,n){super(e,void 0===n?void 0:{cause:n}),this.code=e,this.format=t,this.name="ImageDecodeError"}}let i=new Set(["heic","heix","heim","heis","hevc","hevx","hevm","hevs"]),r=new Set(["mif1","msf1","mif2"]),a=new Set(["avif","avis"]);function l(e,n,i=t){let r=Math.min(1,i.maxLongEdge/Math.max(e,n),Math.sqrt(i.maxPixels/Math.max(1,e*n)));return{width:Math.max(1,Math.floor(e*r)),height:Math.max(1,Math.floor(n*r)),scale:r}}async function o(e){let t,n;if("function"==typeof createImageBitmap)try{return await createImageBitmap(e,{imageOrientation:"from-image"})}catch{}let i=await (t=URL.createObjectURL(e),(n=new Image).decoding="async",new Promise((e,i)=>{n.onload=()=>e(n),n.onerror=()=>i(Error("IMAGE_ELEMENT_DECODE_FAILED")),n.src=t}).finally(()=>URL.revokeObjectURL(t)));if(!i.naturalWidth||!i.naturalHeight)throw Error("IMAGE_EMPTY");return i}async function s(t){let{heicTo:n}=await e.A(462684);return n({blob:t,type:"image/jpeg",quality:.95})}function h(e,t){return new Promise((n,i)=>{e.toBlob(e=>e?n(e):i(Error("CANVAS_EMPTY")),"image/jpeg",t)})}function c(e,t,n,i,r,a,l){let o,s=((o=document.createElement("canvas")).width=a,o.height=l,o),h=s.getContext("2d");if(!h)throw Error("CANVAS_UNSUPPORTED");return h.fillStyle="#ffffff",h.fillRect(0,0,a,l),h.imageSmoothingEnabled=!0,h.imageSmoothingQuality="high",h.drawImage(e,t,n,i,r,0,0,a,l),s}async function u(e,t){var u;let d,m=performance.now(),g=await e.arrayBuffer(),p=performance.now()-m,f=function(e){let t=(t,n)=>String.fromCharCode(...e.subarray(t,n));if(e.length>=3&&255===e[0]&&216===e[1]&&255===e[2])return"jpeg";if(e.length>=8&&137===e[0]&&"PNG"===t(1,4))return"png";if(e.length>=12&&"RIFF"===t(0,4)&&"WEBP"===t(8,12))return"webp";if(e.length>=6&&("GIF87a"===t(0,6)||"GIF89a"===t(0,6)))return"gif";if(e.length>=2&&"BM"===t(0,2))return"bmp";if(e.length>=12&&"ftyp"===t(4,8)){let n=Math.min(e.length,(e[0]<<24|e[1]<<16|e[2]<<8|e[3])>>>0||e.length),l=[t(8,12)];for(let e=16;e+4<=n;e+=4)l.push(t(e,e+4));if(l.some(e=>i.has(e)))return"heic";if(l.some(e=>a.has(e)))return"avif";if(l.some(e=>r.has(e)))return"heic"}return"unknown"}(new Uint8Array(g,0,Math.min(g.byteLength,64))),w=e.type||"",x=performance.now(),y="native",b=new Blob([g],{type:w||"application/octet-stream"});try{d=await o(b)}catch(e){if("heic"!==f)throw new n("unknown"===f?"UNSUPPORTED_IMAGE":"IMAGE_DECODE_FAILED",f,e);t?.();try{d=await o(await s(b)),y="heic"}catch(e){throw new n("HEIC_DECODE_FAILED",f,e)}}let{width:v,height:C}=(u=d)instanceof HTMLImageElement?{width:u.naturalWidth,height:u.naturalHeight}:{width:u.width,height:u.height};if(!v||!C)throw new n("IMAGE_DECODE_FAILED",f);let k=l(v,C,{maxLongEdge:1600,maxPixels:1/0}),M=await h(c(d,0,0,v,C,k.width,k.height),.85),D=URL.createObjectURL(M),E=performance.now()-x;return{source:d,width:v,height:C,format:f,decoder:y,previewUrl:D,sourceType:w,sourceBytes:e.size,timings:{read:Math.round(p),convert:Math.round(E)},dispose:()=>{URL.revokeObjectURL(D),d instanceof HTMLImageElement||d.close()}}}let d={x:0,y:0,width:1,height:1};async function m(e,n=d,i=t){var r;let a=performance.now(),o=e=>Math.min(1,Math.max(0,e)),s=Math.round(o(n.x)*e.width),u=Math.round(o(n.y)*e.height),g=Math.max(1,Math.min(e.width-s,Math.round(o(n.width)*e.width))),p=Math.max(1,Math.min(e.height-u,Math.round(o(n.height)*e.height))),f=l(g,p,i),w=c(e.source,s,u,g,p,f.width,f.height),x=performance.now()-a,y=performance.now(),b=i.startQuality,v=await h(w,b);for(let t=0;v.size>i.maxBytes&&t<12;t++)b-.05>=i.minQuality-1e-9?b=Math.round((b-.05)*100)/100:(f={width:Math.max(1,Math.floor(.85*f.width)),height:Math.max(1,Math.floor(.85*f.height)),scale:.85*f.scale},w=c(e.source,s,u,g,p,f.width,f.height)),v=await h(w,b);return{dataUrl:await (r=v,new Promise((e,t)=>{let n=new FileReader;n.onload=()=>e(n.result),n.onerror=()=>t(n.error??Error("READ_FAILED")),n.readAsDataURL(r)})),width:f.width,height:f.height,bytes:v.size,quality:b,timings:{crop:Math.round(x),compress:Math.round(performance.now()-y)}}}e.s(["K",0,t,"o",0,n,"N",0,function(e,t){return{sourceType:e.sourceType||e.format,sourceBytes:e.sourceBytes,sourceWidth:e.width,sourceHeight:e.height,outputWidth:t.width,outputHeight:t.height,outputBytes:t.bytes,decoder:e.decoder,quality:t.quality}},"p",0,u,"X",0,m])},499930,e=>{var t=e.i(213761);function n(e,t=.008){let i=Math.max(0,e.x-t),r=Math.max(0,e.y-t);return{x:i,y:r,width:Math.min(1,e.x+e.width+t)-i,height:Math.min(1,e.y+e.height+t)-r}}async function i(e){let t=new Image;if(t.decoding="async",t.src=e,await t.decode(),!t.naturalWidth||!t.naturalHeight)throw Error("IMAGE_EMPTY");return t}async function r(e,n){let i=function(e,t=16,n=!1){let i=Math.max(...e.map(e=>e.width)),r=0,a=e.map(e=>{let a=n?i/e.width:e.scale??1,l={x:0,y:r,width:Math.round(e.width*a),height:Math.round(e.height*a)};return r+=l.height+t,l});return{width:Math.max(...a.map(e=>e.width)),height:r-t,rects:a}}(e.map(e=>({width:e.sw,height:e.sh,scale:e.scale})),16,n),r=document.createElement("canvas");r.width=i.width,r.height=i.height;let a=r.getContext("2d");if(!a)throw Error("CANVAS_UNSUPPORTED");a.fillStyle="#ffffff",a.fillRect(0,0,r.width,r.height),e.forEach((e,t)=>{let n=i.rects[t];a.drawImage(e.source,e.sx,e.sy,e.sw,e.sh,n.x,n.y,n.width,n.height)});let l=await createImageBitmap(r);try{return await (0,t.X)({source:l,width:r.width,height:r.height})}finally{l.close()}}async function a(e,i){let a=e.naturalWidth,l=e.naturalHeight,o=i.map(e=>n(e));return 1===o.length?(0,t.X)({source:e,width:a,height:l},o[0]):r(o.map(t=>({source:e,sx:Math.round(t.x*a),sy:Math.round(t.y*l),sw:Math.max(1,Math.round(t.width*a)),sh:Math.max(1,Math.round(t.height*l))})),!1)}async function l(e){return r((await Promise.all(e.map(i))).map(e=>({source:e,sx:0,sy:0,sw:e.naturalWidth,sh:e.naturalHeight})),!0)}async function o(e,t,i){let a=e.naturalWidth,l=e.naturalHeight,o=i.width/a,s=t.map(e=>n(e)).map(t=>({source:e,sx:Math.round(t.x*a),sy:Math.round(t.y*l),sw:Math.max(1,Math.round(t.width*a)),sh:Math.max(1,Math.round(t.height*l)),scale:o}));return s.push({source:i.source,sx:0,sy:0,sw:i.width,sh:i.height}),r(s,!1)}e.s(["y",0,i,"k",0,o,"M",0,a,"v",0,l])},119472,e=>{var t=e.i(41931),n=e.i(127175);async function i(e){let t;for(let n=0;n<3;n++)try{return await e()}catch(e){if(t=e,!function(e){let t=e?.status;return void 0===t||408===t||502===t||503===t||504===t}(e)||2===n)break;await new Promise(e=>setTimeout(e,1e3*(n+1)))}throw t}async function r(e,a=(0,n.c)()){let{batch:l}=await i(()=>t.k.post("/api/import-batches",{...e,clientRequestId:a,subjectId:e.subjectId||void 0,targetSubjectId:e.targetSubjectId||void 0,paperLevel:e.paperLevel||void 0,items:e.items?.map(e=>({...e})),origin:e.origin},{timeout:12e4}));return(0,n.P)(),l}async function a(e,n={}){let i=n.image?"?include=image":"",{batch:r}=await t.k.get(`/api/import-batches/${encodeURIComponent(e)}${i}`);return r}async function l(e,n,i){let{batch:r}=await t.k.patch(`/api/import-batches/${encodeURIComponent(e)}`,{version:n,draft:i});return r}async function o(e,r,a,l){let{batch:o}=await i(()=>t.k.post(`/api/import-batches/${encodeURIComponent(e)}/start`,{version:r,images:a,analysis:l},{timeout:12e4}));return(0,n.P)(),o}async function s(e){let{batch:i}=await t.k.post(`/api/import-batches/${encodeURIComponent(e)}/retry`,{});return(0,n.P)(),i}async function h(e){let i=await t.k.post(`/api/import-batches/${encodeURIComponent(e)}/confirm-all`,{});return(0,n.P)(),i}async function c(e){await t.k.delete(`/api/import-batches/${encodeURIComponent(e)}`),(0,n.P)()}async function u(e){await t.k.post(`/api/import-batches/${encodeURIComponent(e)}/read`,{}),(0,n.P)()}async function d(e,n,i){return t.k.post(`/api/import-batches/${encodeURIComponent(e)}/fix-text`,{items:n},{timeout:6e5,recoverable:!0,requestId:i})}e.s(["J",0,h,"n",0,function(e){return e?.status===409?e.data?.details?.batch??null:null},"v",0,r,"o",0,c,"w",0,a,"$",0,d,"f",0,u,"s",0,s,"S",0,l,"g",0,o])},25197,e=>{var t=e.i(41931);function n(e){return e.trim()?e:""}async function i(){try{return!!(await t.k.get("/api/user")).confirmBeforeImport}catch{return!1}}async function r(e,i){let r=await t.k.post("/api/error-items",{questionText:e.questionText,answerText:n(e.answerText),analysis:n(e.analysis),wrongAnswerText:e.wrongAnswerText||null,mistakeAnalysis:e.mistakeAnalysis||null,mistakeStatus:e.mistakeStatus||"unknown",knowledgePoints:e.knowledgePoints||[],difficultyStars:e.difficultyStars??null,recognizedGradeSemester:e.gradeSemester??null,hasFigure:e.hasFigure??!1,figureSvg:e.figureSvg??null,questionType:e.questionType??null,subjectId:i.subjectId||void 0,subjectName:i.subjectId?void 0:e.subject,originalImageUrl:i.imageUrl||"",paperLevel:i.paperLevel||void 0});return{id:r.id,shortId:r.shortId??null,subjectId:r.subjectId??null,notebookName:r.subject?.name??null,duplicate:r.duplicate}}e.i(201276),e.s(["x",0,i,"a",0,r],25197)},825624,e=>{let t=/^[\s ]+/,n="一二三四五六七八九十",i=[{family:"dot",pattern:/^(\d{1,3})\s*(?:.|\.(?!\d))\s*/},{family:"comma",pattern:/^(\d{1,3})\s*[、,,](?!\d)\s*/},{family:"paren",pattern:/^(\d{1,3})\s*[))]\s*/},{family:"colon",pattern:/^(\d{1,3})\s*[::](?!\d)\s*/},{family:"ti",pattern:/^第\s*(\d{1,3}|[一二三四五六七八九十]{1,3})\s*题\s*[..、::]?\s*/},{family:"example",pattern:/^(?:例题?|练习|习题)\s*(\d{1,3})\s*[..、::]?\s*/},{family:"q",pattern:/^(?:Q|Question|Problem|Exercise)\s*(\d{1,3})\s*[..::)]?\s+/i},{family:"cn",pattern:/^([一二三四五六七八九十]{1,3})\s*[、..]\s*/}];function r(e){let r=e.replace(t,"");for(let{family:e,pattern:t}of i){let i=r.match(t);if(!i||r.length<=i[0].length)continue;let a=function(e){if(/^\d+$/.test(e))return Number(e);if("十"===e)return 10;let t=e.indexOf("十");return -1===t?n.indexOf(e)+1:10*(0===t?1:n.indexOf(e[0])+1)+(t===e.length-1?0:n.indexOf(e[t+1])+1)}(i[1]);if(Number.isFinite(a)&&!(a<=0))return{value:a,family:e,prefixLength:i[0].length,label:i[1]}}return null}function a(e){let n=e.split("\n"),i=n[0]?.replace(t,"")??"",a=r(i);return a&&"cn"!==a.family&&(n[0]=i.slice(a.prefixLength)),n.join("\n")}function l(e){let t=[];for(let n of e)(n||0!==t.length&&""!==t[t.length-1])&&t.push(n);for(;t.length>0&&""===t[t.length-1];)t.pop();return t.join("\n")}let o=/(姓名|班级|学号|日期|得分|分数|评分|考号|座位号|家长签字|用时|Name\s*[::_]|Class\s*[::_]|Date\s*[::_]|Score\s*[::_])|_{3,}|共\s*\d+\s*(道|题|小题)|做完|答案(见|在)|最后一页|满分\s*\d+\s*分/i,s=/(阅读|材料|短文|文章|选文|诗歌|古诗|文言文|下[面列]的?(表格|图表|统计|信息)|根据.{0,20}(回答|完成)|passage|read the|according to the)/i,h=/^(参考答案|答案与解析|答案|Answers?|Answer Key)\s*[::]?$/i,c=/^(第[一二三四五六七八九十]+(部分|大题|节)|(Part|Section)\s+[A-Z0-9IVX]+\b)/i,u=/(选择|填空|判断|计算|解答|应用|解决问题|操作|作图|阅读|写作|作文|综合|口算|听力|单项|完形|题)/,d=/(\d{1,3})\s*[~~\-—–至到]\s*(\d{1,3})\s*(?:小?题|questions?)/i,m=/(小问|小题|下列问题|以下问题|下列各题|下面各题|完成下列|回答下列|回答以下|following questions|answer the following)/i;function g(e){let t=[],n=[];for(let i of e)i?n.push(i):n.length&&(t.push(n.join("\n")),n=[]);return n.length&&t.push(n.join("\n")),t}function p(e,t=[]){let n=e.trim();return!(!n||n.length>12||/[。!?!?,,、;;::..()()【】\[\]{}]$/.test(n)||/\d/.test(n)||/[。!?!?;;,,]/.test(n))&&!!(/(篇|章|节|部分|组)$/.test(n)||/^(Part|Section)\s+[A-Z0-9]+$/i.test(n))&&(!t.length||t.some(e=>{let t=r(e);return null!==t&&1===t.value}))}function f(e,t){let n=[];for(let i=0;i<e.length;i++){let r=e[i],a=[r];for(let n=i+1;n<e.length;n++){let i=e[n],l=a[a.length-1];if(i.family!==r.family)continue;let o=1===i.value&&[...t].some(e=>e>l.line&&e<i.line);(i.value===l.value+1||o)&&a.push(i)}a.length>n.length&&(n=a)}return n}function w(e,t,n){return!!c.test(e)||!!t&&"cn"===t.family&&"cn"!==n&&null!==n&&(e.length<=40||u.test(e.slice(0,20)))}function x(e,t,n,i,r){for(let a=e-1;a>=0;a--)if(t[a]){if(r.has(a)||w(t[a],n[a],i)||p(t[a]))return t[a];break}return null}function y(e){let t=e.match(d);if(!t)return null;let n=Number(t[1]),i=Number(t[2]);return n<=i?{from:n,to:i}:null}let b={answer:/^(?:【\s*(?:参考答案|答案)\s*】|(?:参考答案|答案)\s*[::]|Answer\s*[::])\s*(.*)$/i,analysis:/^(?:【\s*(?:解析|分析|详解|解答|点评)\s*】|(?:解析|分析|详解|解答|点评)\s*[::])\s*(.*)$/,knowledge:/^(?:【\s*(?:知识点|考点)\s*】|(?:知识点|考点)\s*[::])\s*(.*)$/,difficulty:/^(?:【\s*难度\s*】|难度\s*[::])\s*(.*)$/,questionType:/^(?:【\s*题型\s*】|题型\s*[::])\s*(.*)$/,wrongAnswer:/^(?:【\s*错答\s*】|我的答案\s*[::]|学生答案\s*[::])\s*(.*)$/},v={易:1,较易:2,中等:3,较难:4,难:5};function C(e){return e.split(/[、,,;;]/).map(e=>e.trim()).filter(Boolean)}function k(e){let t={answer:[],analysis:[],knowledge:[],difficulty:[],questionType:[],wrongAnswer:[]},n=[],i=null;for(let r of e){let e=null;for(let n of Object.keys(b)){let a=r.match(b[n]);if(!a)continue;e=n,i=n;let l=a[1].trim();l&&t[n].push(l);break}e||(i&&r.trim()?t[i].push(r.trim()):n.push(r))}let r={},a=t.answer.join("\n").trim();a&&(r.answer=a);let o=t.analysis.join("\n").trim();o&&(r.analysis=o);let s=t.knowledge.flatMap(C);s.length&&(r.knowledgePoints=s);let h=t.difficulty.join(" ").trim(),c=h?function(e){let t=e.trim();if(!t)return null;let n=t.match(/^(\d{1,2})\s*(?:星|级)?$/);if(n){let e=Number(n[1]);return e>=1&&e<=5?e:null}if(/^[★☆]{1,5}$/.test(t)){let e=(t.match(/★/g)??[]).length;return e>=1?e:null}return t in v?v[t]:null}(h):null;null!==c&&(r.difficultyStars=c);let u=t.questionType.join(" ").trim();u&&(r.questionType=u);let d=t.wrongAnswer.join("\n").trim();return d&&(r.wrongAnswer=d),{text:l(n),fields:r}}let M=/^(\d{1,3})\s*[..、,,)]\s*(\S[\s\S]*)$/,D=/^(\d{1,3})\s*[~~—–-]\s*(\d{1,3})\s*[::..、]?\s*([A-Za-z]+)$/;function E(e){let t=e.trim();if(!t)return null;let n=function(e){let t=e.trim().match(D);if(!t)return null;let n=Number(t[1]),i=Number(t[2]),r=t[3];if(!Number.isFinite(n)||!Number.isFinite(i)||n<=0||i<=n||i-n+1>60)return null;let a=i-n+1;return r.length!==a?null:Array.from({length:a},(e,t)=>({label:String(n+t),text:r[t]}))}(t);if(n)return n;let i=function(e){let t=e.trim(),n=[];for(let e of t.matchAll(/(\d{1,3})\s*[..、,,;;]\s*/g)){let i=e.index??0,r=t[i+e[0].length];r&&/\d/.test(r)||n.push({index:i,label:e[1],afterIndex:i+e[0].length})}if(n.length<2)return null;for(let e=1;e<n.length;e++)if(Number(n[e].label)<=Number(n[e-1].label))return null;let i=[];for(let e=0;e<n.length;e++){let r=n[e].afterIndex,a=e+1<n.length?n[e+1].index:t.length,l=t.slice(r,a).trim().replace(/[;;]+$/,"").trim();if(!l||l.length>30||/[。!?!?]/.test(l))return null;i.push({label:n[e].label,text:l})}return i}(t);if(i)return i.map(e=>({label:e.label??"",text:e.text})).filter(e=>e.label);let r=t.match(M);if(!r)return null;let a=Number(r[1]);return!Number.isFinite(a)||a<=0?null:[{label:r[1],text:r[2].trim()}]}function _(e){let t=e.match(/^(.*?)(?:【?\s*(?:解析|分析|详解|解答|点评)\s*】?\s*[::])([\s\S]*)$/);if(t){let n=t[1].replace(/^(?:【?\s*(?:参考答案|答案)\s*】?\s*[::])\s*/,"").trim(),i=t[2].trim();return i?{answer:n,analysis:i}:{answer:e.trim()}}return{answer:e.replace(/^(?:【?\s*(?:参考答案|答案)\s*】?\s*[::])\s*/,"").trim()||e.trim()}}function j(e,t){let n=[],i=!1;for(let r of e){let e={value:!1},a=[];for(let n of r.split("\n")){let i=n.trim()?E(n):null;if(!i){n.trim()&&a.push(n);continue}let r=!1;for(let l of i){let i=t.find(e=>e.label===l.label);if(!i){a.push(n);break}r=!0,e.value=!0;let o=_(l.text);o.answer&&!i.answer&&(i.answer=o.answer),o.analysis&&(i.analysis=i.analysis?`${i.analysis}
|
|
2
|
-
${o.analysis}`:o.analysis)}!r&&!a.includes(n)&&n.trim()&&!a.includes(n)&&a.push(n)}i=i||e.value,e.value?a.length&&n.push(a.join("\n")):n.push(r)}return[n,i]}e.s(["k",0,2e3,"f",0,1e6,"S",0,60,"i",0,2e4,"J",0,function(e,n={}){let i,u,b=void 0===n.maxLength?2e4:Math.min(Math.max(n.maxLength,1e3),1e6),v=void 0===n.maxQuestions?60:Math.min(Math.max(n.maxQuestions,2),2e3),C=e.length>b,M=e.slice(0,b).replace(/\r\n?/g,"\n").split("\n").map(e=>e.replace(t,"").replace(/[\s ]+$/,"")),D=M.map(e=>e?r(e):null),R=M.length;for(let e=0;e<M.length;e++)if(h.test(M[e])){R=e;break}let
|
|
1
|
+
(()=>{"use strict";(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,232660,e=>{var t=e.i(271645),n={x:0,y:0,width:0,height:0,unit:"px"},i=(e,t,n)=>Math.min(Math.max(e,t),n),r=(e,t)=>e===t||e.width===t.width&&e.height===t.height&&e.x===t.x&&e.y===t.y&&e.unit===t.unit;function a(e,t,i){return"%"===e.unit?{...n,...e,unit:"%"}:{unit:"%",x:e.x?e.x/t*100:0,y:e.y?e.y/i*100:0,width:e.width?e.width/t*100:0,height:e.height?e.height/i*100:0}}function l(e,t,i){return e.unit&&"px"!==e.unit?{unit:"px",x:e.x?e.x*t/100:0,y:e.y?e.y*i/100:0,width:e.width?e.width*t/100:0,height:e.height?e.height*i/100:0}:{...n,...e,unit:"px"}}function o(e,t,n,i,r,a=0,l=0,s=i,h=r){let c={...e},u=Math.min(a,i),d=Math.min(l,r),m=Math.min(s,i),g=Math.min(h,r);t&&(t>1?(d=(u=l?l*t:u)/t,m=s*t):(u=(d=a?a/t:d)*t,g=h/t)),c.y<0&&(c.height=Math.max(c.height+c.y,d),c.y=0),c.x<0&&(c.width=Math.max(c.width+c.x,u),c.x=0);let p=i-(c.x+c.width);p<0&&(c.x=Math.min(c.x,i-u),c.width+=p);let f=r-(c.y+c.height);if(f<0&&(c.y=Math.min(c.y,r-d),c.height+=f),c.width<u&&(("sw"===n||"nw"==n)&&(c.x-=u-c.width),c.width=u),c.height<d&&(("nw"===n||"ne"==n)&&(c.y-=d-c.height),c.height=d),c.width>m&&(("sw"===n||"nw"==n)&&(c.x-=m-c.width),c.width=m),c.height>g&&(("nw"===n||"ne"==n)&&(c.y-=g-c.height),c.height=g),t){let e=c.width/c.height;if(e<t){let e=Math.max(c.width/t,d);("nw"===n||"ne"==n)&&(c.y-=e-c.height),c.height=e}else if(e>t){let e=Math.max(c.height*t,u);("sw"===n||"nw"==n)&&(c.x-=e-c.width),c.width=e}}return c}var s={capture:!0,passive:!1},h=0,c=class e extends t.PureComponent{static xOrds=["e","w"];static yOrds=["n","s"];static xyOrds=["nw","ne","se","sw"];static nudgeStep=1;static nudgeStepMedium=10;static nudgeStepLarge=100;static defaultProps={ariaLabels:{cropArea:"Use the arrow keys to move the crop selection area",nwDragHandle:"Use the arrow keys to move the north west drag handle to change the crop selection area",nDragHandle:"Use the up and down arrow keys to move the north drag handle to change the crop selection area",neDragHandle:"Use the arrow keys to move the north east drag handle to change the crop selection area",eDragHandle:"Use the up and down arrow keys to move the east drag handle to change the crop selection area",seDragHandle:"Use the arrow keys to move the south east drag handle to change the crop selection area",sDragHandle:"Use the up and down arrow keys to move the south drag handle to change the crop selection area",swDragHandle:"Use the arrow keys to move the south west drag handle to change the crop selection area",wDragHandle:"Use the up and down arrow keys to move the west drag handle to change the crop selection area"}};get document(){return document}docMoveBound=!1;mouseDownOnCrop=!1;dragStarted=!1;evData={startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0};componentRef=(0,t.createRef)();mediaRef=(0,t.createRef)();resizeObserver;initChangeCalled=!1;instanceId=`rc-${h++}`;state={cropIsActive:!1,newCropIsBeingDrawn:!1};getBox(){let e=this.mediaRef.current;if(!e)return{x:0,y:0,width:0,height:0};let{x:t,y:n,width:i,height:r}=e.getBoundingClientRect();return{x:t,y:n,width:i,height:r}}componentDidUpdate(e){let{crop:t,onComplete:n}=this.props;if(n&&!e.crop&&t){let{width:e,height:i}=this.getBox();e&&i&&n(l(t,e,i),a(t,e,i))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||=(this.document.addEventListener("pointermove",this.onDocPointerMove,s),this.document.addEventListener("pointerup",this.onDocPointerDone,s),this.document.addEventListener("pointercancel",this.onDocPointerDone,s),!0)}unbindDocMove(){this.docMoveBound&&=(this.document.removeEventListener("pointermove",this.onDocPointerMove,s),this.document.removeEventListener("pointerup",this.onDocPointerDone,s),this.document.removeEventListener("pointercancel",this.onDocPointerDone,s),!1)}onCropPointerDown=e=>{let{crop:t,disabled:n}=this.props,i=this.getBox();if(!t)return;let r=l(t,i.width,i.height);if(n)return;e.cancelable&&e.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});let a=e.target.dataset.ord,o=e.clientX,s=e.clientY,h=r.x,c=r.y;if(a){let t=e.clientX-i.x,n=e.clientY-i.y,l=0,u=0;"ne"===a||"e"==a?(l=t-(r.x+r.width),u=n-r.y,h=r.x,c=r.y+r.height):"se"===a||"s"===a?(l=t-(r.x+r.width),u=n-(r.y+r.height),h=r.x,c=r.y):"sw"===a||"w"==a?(l=t-r.x,u=n-(r.y+r.height),h=r.x+r.width,c=r.y):("nw"===a||"n"==a)&&(l=t-r.x,u=n-r.y,h=r.x+r.width,c=r.y+r.height),o=h+i.x+l,s=c+i.y+u}this.evData={startClientX:o,startClientY:s,startCropX:h,startCropY:c,clientX:e.clientX,clientY:e.clientY,isResize:!!a,ord:a},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})};onComponentPointerDown=e=>{let{crop:t,disabled:n,locked:i,keepSelection:r,onChange:o}=this.props,s=this.getBox();if(n||i||r&&t)return;e.cancelable&&e.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});let h=e.clientX-s.x,c=e.clientY-s.y,u={unit:"px",x:h,y:c,width:0,height:0};this.evData={startClientX:e.clientX,startClientY:e.clientY,startCropX:h,startCropY:c,clientX:e.clientX,clientY:e.clientY,isResize:!0},this.mouseDownOnCrop=!0,o(l(u,s.width,s.height),a(u,s.width,s.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})};onDocPointerMove=e=>{let t,{crop:n,disabled:i,onChange:o,onDragStart:s}=this.props,h=this.getBox();if(i||!n||!this.mouseDownOnCrop)return;e.cancelable&&e.preventDefault(),this.dragStarted||(this.dragStarted=!0,s&&s(e));let{evData:c}=this;c.clientX=e.clientX,c.clientY=e.clientY,r(n,t=c.isResize?this.resizeCrop():this.dragCrop())||o(l(t,h.width,h.height),a(t,h.width,h.height))};onComponentKeyDown=t=>{let{crop:n,disabled:r,onChange:o,onComplete:s}=this.props;if(r)return;let h=t.key,c=!1;if(!n)return;let u=this.getBox(),d=this.makePixelCrop(u),m=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?e.nudgeStepLarge:t.shiftKey?e.nudgeStepMedium:e.nudgeStep;if("ArrowLeft"===h?(d.x-=m,c=!0):"ArrowRight"===h?(d.x+=m,c=!0):"ArrowUp"===h?(d.y-=m,c=!0):"ArrowDown"===h&&(d.y+=m,c=!0),c){t.cancelable&&t.preventDefault(),d.x=i(d.x,0,u.width-d.width),d.y=i(d.y,0,u.height-d.height);let e=l(d,u.width,u.height),n=a(d,u.width,u.height);o(e,n),s&&s(e,n)}};onHandlerKeyDown=(t,n)=>{var i,s;let h,{aspect:c=0,crop:u,disabled:d,minWidth:m=0,minHeight:g=0,maxWidth:p,maxHeight:f,onChange:w,onComplete:x}=this.props,y=this.getBox();if(d||!u||"ArrowUp"!==t.key&&"ArrowDown"!==t.key&&"ArrowLeft"!==t.key&&"ArrowRight"!==t.key)return;t.stopPropagation(),t.preventDefault();let b=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?e.nudgeStepLarge:t.shiftKey?e.nudgeStepMedium:e.nudgeStep,v=o((i=l(u,y.width,y.height),s=t.key,h={...i},"ArrowLeft"===s?"nw"===n?(h.x-=b,h.y-=b,h.width+=b,h.height+=b):"w"===n?(h.x-=b,h.width+=b):"sw"===n?(h.x-=b,h.width+=b,h.height+=b):"ne"===n?(h.y+=b,h.width-=b,h.height-=b):"e"===n?h.width-=b:"se"===n&&(h.width-=b,h.height-=b):"ArrowRight"===s&&("nw"===n?(h.x+=b,h.y+=b,h.width-=b,h.height-=b):"w"===n?(h.x+=b,h.width-=b):"sw"===n?(h.x+=b,h.width-=b,h.height-=b):"ne"===n?(h.y-=b,h.width+=b,h.height+=b):"e"===n?h.width+=b:"se"===n&&(h.width+=b,h.height+=b)),"ArrowUp"===s?"nw"===n?(h.x-=b,h.y-=b,h.width+=b,h.height+=b):"n"===n?(h.y-=b,h.height+=b):"ne"===n?(h.y-=b,h.width+=b,h.height+=b):"sw"===n?(h.x+=b,h.width-=b,h.height-=b):"s"===n?h.height-=b:"se"===n&&(h.width-=b,h.height-=b):"ArrowDown"===s&&("nw"===n?(h.x+=b,h.y+=b,h.width-=b,h.height-=b):"n"===n?(h.y+=b,h.height-=b):"ne"===n?(h.y+=b,h.width-=b,h.height-=b):"sw"===n?(h.x-=b,h.width+=b,h.height+=b):"s"===n?h.height+=b:"se"===n&&(h.width+=b,h.height+=b)),h),c,n,y.width,y.height,m,g,p,f);if(!r(u,v)){let e=a(v,y.width,y.height);w(v,e),x&&x(v,e)}};onDocPointerDone=e=>{let{crop:t,disabled:n,onComplete:i,onDragEnd:r}=this.props,o=this.getBox();this.unbindDocMove(),!(n||!t)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,r&&r(e),i&&i(l(t,o.width,o.height),a(t,o.width,o.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))};onDragFocus=()=>{this.componentRef.current?.scrollTo(0,0)};getCropStyle(){let{crop:e}=this.props;if(e)return{top:`${e.y}${e.unit}`,left:`${e.x}${e.unit}`,width:`${e.width}${e.unit}`,height:`${e.height}${e.unit}`}}dragCrop(){let{evData:e}=this,t=this.getBox(),n=this.makePixelCrop(t),r=e.clientX-e.startClientX,a=e.clientY-e.startClientY;return n.x=i(e.startCropX+r,0,t.width-n.width),n.y=i(e.startCropY+a,0,t.height-n.height),n}getPointRegion(e,t,n,i){let{evData:r}=this,a=r.clientX-e.x,l=r.clientY-e.y,o;return o=i&&t?"nw"===t||"n"===t||"ne"===t:l<r.startCropY,(n&&t?"nw"===t||"w"===t||"sw"===t:a<r.startCropX)?o?"nw":"sw":o?"ne":"se"}resolveMinDimensions(e,t,n=0,i=0){let r=Math.min(n,e.width),a=Math.min(i,e.height);return t&&(r||a)?t>1?r?[r,r/t]:[a*t,a]:a?[a*t,a]:[r,r/t]:[r,a]}resizeCrop(){let{evData:t}=this,{aspect:n=0,maxWidth:r,maxHeight:a}=this.props,l=this.getBox(),[s,h]=this.resolveMinDimensions(l,n,this.props.minWidth,this.props.minHeight),c=this.makePixelCrop(l),u=this.getPointRegion(l,t.ord,s,h),d=t.ord||u,m=t.clientX-t.startClientX,g=t.clientY-t.startClientY;(s&&"nw"===d||"w"===d||"sw"===d)&&(m=Math.min(m,-s)),(h&&"nw"===d||"n"===d||"ne"===d)&&(g=Math.min(g,-h));let p={unit:"px",x:0,y:0,width:0,height:0};"ne"===u?(p.x=t.startCropX,p.width=m,n?p.height=p.width/n:p.height=Math.abs(g),p.y=t.startCropY-p.height):"se"===u?(p.x=t.startCropX,p.y=t.startCropY,p.width=m,n?p.height=p.width/n:p.height=g):"sw"===u?(p.x=t.startCropX+m,p.y=t.startCropY,p.width=Math.abs(m),n?p.height=p.width/n:p.height=g):"nw"===u&&(p.x=t.startCropX+m,p.width=Math.abs(m),n?(p.height=p.width/n,p.y=t.startCropY-p.height):(p.height=Math.abs(g),p.y=t.startCropY+g));let f=o(p,n,u,l.width,l.height,s,h,r,a);return n||e.xyOrds.indexOf(d)>-1?c=f:e.xOrds.indexOf(d)>-1?(c.x=f.x,c.width=f.width):e.yOrds.indexOf(d)>-1&&(c.y=f.y,c.height=f.height),c.x=i(c.x,0,l.width-c.width),c.y=i(c.y,0,l.height-c.height),c}renderCropSelection(){let{ariaLabels:n=e.defaultProps.ariaLabels,disabled:i,locked:r,renderSelectionAddon:a,ruleOfThirds:l,crop:o}=this.props,s=this.getCropStyle();if(o)return t.default.createElement("div",{style:s,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":n.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!i&&!r&&t.default.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},t.default.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),t.default.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),t.default.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),t.default.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":n.nwDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"nw"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":n.nDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"n"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":n.neDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"ne"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":n.eDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"e"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":n.seDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"se"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":n.sDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"s"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":n.swDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"sw"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":n.wDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"w"),role:"button"})),a&&t.default.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:e=>e.stopPropagation()},a(this.state)),l&&t.default.createElement(t.default.Fragment,null,t.default.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),t.default.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(e){return l({...n,...this.props.crop||{}},e.width,e.height)}render(){let{aspect:e,children:n,circularCrop:i,className:r,crop:a,disabled:l,locked:o,style:s,ruleOfThirds:h}=this.props,{cropIsActive:c,newCropIsBeingDrawn:u}=this.state,d=a?this.renderCropSelection():null,m=((...e)=>e.filter(e=>e&&"string"==typeof e).join(" "))("ReactCrop",r,c&&"ReactCrop--active",l&&"ReactCrop--disabled",o&&"ReactCrop--locked",u&&"ReactCrop--new-crop",a&&e&&"ReactCrop--fixed-aspect",a&&i&&"ReactCrop--circular-crop",a&&h&&"ReactCrop--rule-of-thirds",!this.dragStarted&&a&&!a.width&&!a.height&&"ReactCrop--invisible-crop",i&&"ReactCrop--no-animate");return t.default.createElement("div",{ref:this.componentRef,className:m,style:s},t.default.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},n),a?t.default.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},t.default.createElement("defs",null,t.default.createElement("mask",{id:`hole-${this.instanceId}`},t.default.createElement("rect",{width:"100%",height:"100%",fill:"white"}),i?t.default.createElement("ellipse",{cx:`${a.x+a.width/2}${a.unit}`,cy:`${a.y+a.height/2}${a.unit}`,rx:`${a.width/2}${a.unit}`,ry:`${a.height/2}${a.unit}`,fill:"black"}):t.default.createElement("rect",{x:`${a.x}${a.unit}`,y:`${a.y}${a.unit}`,width:`${a.width}${a.unit}`,height:`${a.height}${a.unit}`,fill:"black"}))),t.default.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,d)}};e.s(["f",0,c])},12130,271945,e=>{var t=e.i(843476),n=e.i(271645),i=e.i(232660),r=e.i(519455),a=e.i(776639),l=e.i(263676),o=e.i(111110);async function s(e,t){let{naturalWidth:n,naturalHeight:i}=e;return Promise.all(t.map(t=>new Promise((r,a)=>{let l=document.createElement("canvas"),o=Math.round(t.x*n),s=Math.round(t.y*i);l.width=Math.max(1,Math.round(t.width*n)),l.height=Math.max(1,Math.round(t.height*i));let h=l.getContext("2d");h?(h.drawImage(e,o,s,l.width,l.height,0,0,l.width,l.height),l.toBlob(e=>e?r(e):a(Error("Canvas is empty")),"image/jpeg",.95)):a(Error("Canvas is not supported"))})))}let h={maxHeight:"65vh",maxWidth:"100%",objectFit:"contain"},c=(0,n.forwardRef)(function({imageSrc:e,regions:i,onChange:r,imageStyle:a=h,onImageLoad:s},c){let{t:u}=(0,o.b)(),d=(0,n.useRef)(null),m=(0,n.useRef)(null),[g,p]=(0,n.useState)(null),f=e=>{let t=d.current.getBoundingClientRect();return{x:(e.clientX-t.left)/t.width,y:(e.clientY-t.top)/t.height}},w=()=>{g&&g.width>=.02&&g.height>=.02&&r([...i,g]),m.current=null,p(null)},x=e=>({left:`${100*e.x}%`,top:`${100*e.y}%`,width:`${100*e.width}%`,height:`${100*e.height}%`});return(0,t.jsxs)("div",{className:"relative inline-block select-none",children:[(0,t.jsx)("img",{ref:c,src:e,alt:"",draggable:!1,style:a,onLoad:s,className:"block"}),(0,t.jsxs)("div",{ref:d,className:"absolute inset-0 cursor-crosshair",style:{touchAction:"none"},onPointerDown:e=>{0===e.button&&(d.current?.setPointerCapture(e.pointerId),m.current=f(e),p(null))},onPointerMove:e=>{var t,n,i,r;let a,l,o;if(!m.current)return;let s=f(e);p((t=m.current.x,n=m.current.y,i=s.x,r=s.y,l=(a=e=>Math.min(1,Math.max(0,e)))(Math.min(t,i)),o=a(Math.min(n,r)),{x:l,y:o,width:a(Math.max(t,i))-l,height:a(Math.max(n,r))-o}))},onPointerUp:w,onPointerCancel:w,children:[i.map((e,n)=>(0,t.jsxs)("div",{className:"absolute border-2 border-sky-400 bg-sky-400/15",style:x(e),children:[(0,t.jsx)("span",{className:"absolute left-0 top-0 bg-sky-500 px-1.5 text-xs font-bold text-white",children:n+1}),(0,t.jsx)("button",{type:"button",className:"absolute -right-3 -top-3 flex h-6 w-6 items-center justify-center rounded-full bg-red-500 text-white shadow","aria-label":u.batchImport.removeRegion.replace("{index}",String(n+1)),onPointerDown:e=>e.stopPropagation(),onClick:()=>r(i.filter((e,t)=>t!==n)),children:(0,t.jsx)(l.X,{className:"h-3 w-3"})})]},n)),g&&(0,t.jsx)("div",{className:"absolute border-2 border-dashed border-yellow-300 bg-yellow-300/10",style:x(g)})]})]})});var u=e.i(456420);let d={name:"zoom-in",size:24,node:[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]};d.node;let m=(0,u.f)(d),g={name:"zoom-out",size:24,node:[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]};g.node;let p=(0,u.f)(g);function f({zoom:e,onZoomIn:n,onZoomOut:i,onReset:r}){let{t:a}=(0,o.b)(),l="outline-none focus-visible:ring-2 focus-visible:ring-white/70",s=`flex h-9 w-9 items-center justify-center rounded-full text-white transition-colors hover:bg-white/20 disabled:opacity-40 disabled:hover:bg-transparent ${l}`;return(0,t.jsxs)("div",{className:"flex items-center gap-0.5 rounded-full bg-black/60 p-1 shadow-lg backdrop-blur-sm",children:[(0,t.jsx)("button",{type:"button",className:s,onClick:i,disabled:e<=1,"aria-label":a.common.cropper.zoomOut,title:a.common.cropper.zoomOut,children:(0,t.jsx)(p,{className:"h-4 w-4"})}),(0,t.jsxs)("button",{type:"button",className:`h-9 min-w-14 rounded-full px-2 text-center text-xs font-medium tabular-nums text-white hover:bg-white/20 ${l}`,onClick:r,"aria-label":a.common.cropper.resetZoom,title:a.common.cropper.resetZoom,children:[Math.round(100*e),"%"]}),(0,t.jsx)("button",{type:"button",className:s,onClick:n,disabled:e>=5,"aria-label":a.common.cropper.zoomIn,title:a.common.cropper.zoomIn,children:(0,t.jsx)(m,{className:"h-4 w-4"})})]})}var w=e.i(201276),x=e.i(804536);let y="image-cropper-mode",b=["single","auto","multi"];e.s(["U",0,b,"p",0,y,"S",0,["image","text","file","direct"],"c",0,"question-input-mode","k",0,["image","text"]],271945);let v={single:{maxHeight:"70vh",maxWidth:"100%",objectFit:"contain"},auto:{maxHeight:"65vh",maxWidth:"100%",objectFit:"contain"},multi:{maxHeight:"65vh",maxWidth:"100%",objectFit:"contain"}};e.s(["f",0,function({imageSrc:e,open:l,onClose:h,onCropComplete:u,onMultiCropComplete:d,onRegionsSelected:m,allowMulti:g=!0,onAutoSplit:p,onAddPart:C,partCount:k=0}){let{t:M}=(0,o.b)(),D=/^(blob:|data:image\/)/i.test(e)?e:void 0,[E,_]=(0,n.useState)(),j=(0,n.useRef)(null),[R,S]=(0,x.y)(y,b,"single"),I=["single",...p?["auto"]:[],...d||m&&g?["multi"]:[]],N=I.includes(R)?R:"single",[$,P]=(0,n.useState)(null),L=null===$?v[N]:{...v[N],maxHeight:`${Math.max(0,$-16)}px`},{containerRef:A,container:H,zoom:O,imageStyle:U,measureImage:X,zoomIn:Y,zoomOut:B,reset:T}=function(e){let[t,i]=(0,n.useState)(null),r=(0,n.useRef)(null),a=(0,n.useCallback)(e=>{r.current=e,i(e)},[]),[l,o]=(0,n.useState)(1),s=(0,n.useRef)(1),[h,c]=(0,n.useState)(null),u=(0,n.useRef)(null),d=(0,n.useRef)(!1),m=(0,n.useCallback)((e,t,n)=>{let i=r.current,a=s.current,l=Math.min(5,Math.max(1,e));if(!i||l===a)return;if(1===a){let e=i.querySelector("img");e&&c(e.clientWidth)}let h=i.getBoundingClientRect(),d=(t??h.left+h.width/2)-h.left,m=(n??h.top+h.height/2)-h.top;u.current={viewX:d,viewY:m,contentX:i.scrollLeft+d,contentY:i.scrollTop+m,ratio:l/a},s.current=l,o(l)},[]);(0,n.useLayoutEffect)(()=>{let e=r.current,t=u.current;e&&t&&(e.scrollLeft=t.contentX*t.ratio-t.viewX,e.scrollTop=t.contentY*t.ratio-t.viewY,u.current=null)},[l]),(0,n.useEffect)(()=>{if(!t)return;let e=e=>{e.preventDefault(),m(s.current*Math.exp(-(.0015*e.deltaY)),e.clientX,e.clientY)},n=null,i=e=>{let[t,n]=[e[0],e[1]];return{distance:Math.hypot(t.clientX-n.clientX,t.clientY-n.clientY),centerX:(t.clientX+n.clientX)/2,centerY:(t.clientY+n.clientY)/2}},r=e=>{2===e.touches.length&&(n={distance:i(e.touches).distance,zoom:s.current},d.current=!0)},a=e=>{if(!n||2!==e.touches.length)return;e.preventDefault();let{distance:t,centerX:r,centerY:a}=i(e.touches);n.distance>0&&m(n.zoom*(t/n.distance),r,a)},l=e=>{e.touches.length<2&&(n=null,d.current=!1)},o=e=>{d.current&&e.stopPropagation()};return t.addEventListener("wheel",e,{passive:!1}),t.addEventListener("touchstart",r,{passive:!0}),t.addEventListener("touchmove",a,{passive:!1}),t.addEventListener("touchend",l),t.addEventListener("touchcancel",l),t.addEventListener("pointermove",o,{capture:!0}),()=>{t.removeEventListener("wheel",e),t.removeEventListener("touchstart",r),t.removeEventListener("touchmove",a),t.removeEventListener("touchend",l),t.removeEventListener("touchcancel",l),t.removeEventListener("pointermove",o,{capture:!0})}},[t,m]);let g=(0,n.useCallback)(e=>{e&&1===s.current&&c(e.clientWidth)},[]),p=(0,n.useCallback)(()=>m(1.25*s.current),[m]),f=(0,n.useCallback)(()=>m(s.current/1.25),[m]),w=(0,n.useCallback)(()=>{s.current=1,u.current=null,o(1)},[]),x=1!==l&&h?{...e,width:h*l,height:"auto",maxWidth:"none",maxHeight:"none"}:e;return{containerRef:a,container:t,zoom:l,imageStyle:x,measureImage:g,zoomIn:p,zoomOut:f,reset:w}}(L);(0,n.useEffect)(()=>{T()},[e,T]),(0,n.useEffect)(()=>{if(!H)return;let e=new ResizeObserver(([e])=>P(e.contentRect.height));return e.observe(H),()=>e.disconnect()},[H]),(0,n.useEffect)(()=>{let e=H?.querySelector("img");X(e instanceof HTMLImageElement?e:null)},[H,L.maxHeight,O,X]);let[z,K]=(0,n.useState)({src:e,regions:[]}),F=z.src===e?z.regions:[],q=t=>K({src:e,regions:t}),W=(0,n.useRef)(null),G={single:M.batchImport.singleMode,auto:M.batchImport.autoMode,multi:M.batchImport.multiMode},Q=async()=>{if(0!==F.length){if(m){m(F,!0),q([]);return}if(W.current&&d)try{d(await s(W.current,F)),q([])}catch(e){w.V.error("[ImageCropper]","Multi-image crop failed",{error:e})}}},V=()=>E&&E.width>0&&E.height>0?{x:E.x/100,y:E.y/100,width:E.width/100,height:E.height/100}:{x:0,y:0,width:1,height:1},Z=async()=>{let e=V();if("auto"===N&&p)return void p(e);if(m)return void m([e],!1);if(j.current&&u)try{let[t]=await s(j.current,[e]);u(t)}catch(e){w.V.error("[ImageCropper]","Crop failed",{error:e})}};return(0,t.jsx)(a.N,{open:l,onOpenChange:e=>!e&&h(),children:(0,t.jsxs)(a.d,{className:"max-w-3xl h-[90vh] flex flex-col p-0 gap-0",children:[(0,t.jsx)(a.s,{className:"p-4 border-b shrink-0",children:(0,t.jsx)(a.F,{children:M.common.cropper?.title||"Crop Image"})}),(0,t.jsxs)("div",{className:"relative min-h-0 flex-1 bg-black",children:[(0,t.jsx)("div",{ref:A,className:"flex h-full w-full overflow-auto p-4",children:(0,t.jsx)("div",{className:"m-auto",children:"multi"===N?(0,t.jsx)(c,{ref:W,imageSrc:D,regions:F,onChange:q,imageStyle:U,onImageLoad:e=>X(e.currentTarget)}):(0,t.jsx)(i.f,{crop:E,onChange:(e,t)=>_(t),children:(0,t.jsx)("img",{ref:j,alt:"Crop me",src:D,onLoad:function(e){_({unit:"%",x:0,y:0,width:100,height:100}),X(e.currentTarget)},style:U})})})}),(0,t.jsx)("div",{className:"absolute right-3 top-3",children:(0,t.jsx)(f,{zoom:O,onZoomIn:Y,onZoomOut:B,onReset:T})})]}),(0,t.jsxs)("div",{className:"p-4 border-t bg-background shrink-0 space-y-3",children:[I.length>1&&(0,t.jsx)("div",{className:`grid gap-1 rounded-md bg-muted p-1 ${3===I.length?"grid-cols-3 sm:w-[28rem]":"grid-cols-2 sm:w-80"}`,children:I.map(e=>(0,t.jsx)("button",{type:"button","aria-pressed":N===e,onClick:()=>{T(),S(e)},className:`rounded px-2 py-1.5 text-sm font-medium transition-colors ${N===e?"bg-background shadow-sm":"text-muted-foreground"}`,children:G[e]},e))}),(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row sm:justify-between sm:items-center gap-3",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"multi"===N?`${M.batchImport.hint} ${M.batchImport.regionCount.replace("{count}",String(F.length))}`:"auto"===N?M.batchImport.autoHint:k>0?M.upload.parts.cropHint.replace("{n}",String(k+1)):M.common.cropper?.hint||"💡 Drag to adjust crop area"}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2 justify-end",children:["multi"===N&&F.length>0&&(0,t.jsx)(r.f,{variant:"ghost",onClick:()=>q([]),children:M.batchImport.clear}),(0,t.jsx)(r.f,{variant:"outline",onClick:h,children:M.common.cancel||"Cancel"}),"multi"===N?(0,t.jsx)(r.f,{onClick:Q,disabled:0===F.length,children:M.batchImport.start.replace("{count}",String(F.length))}):(0,t.jsxs)(t.Fragment,{children:["single"===N&&C&&(0,t.jsx)(r.f,{variant:"secondary",onClick:()=>C(V()),"data-testid":"crop-add-part",children:M.upload.parts.addNext}),(0,t.jsx)(r.f,{onClick:Z,children:"auto"===N?M.batchImport.autoStart:k>0?M.upload.parts.confirm.replace("{count}",String(k+1)):M.common.confirm||"Confirm"})]})]})]})]})]})})}],12130)},574041,e=>{var t=e.i(843476),n=e.i(271645),i=e.i(263676),r=e.i(487486),a=e.i(793479),l=e.i(41931),o=e.i(201276);e.s(["f",0,function({value:e=[],onChange:s,placeholder:h="Enter tags...",className:c="",enterHint:u,subject:d,gradeStage:m}){let[g,p]=(0,n.useState)(""),[f,w]=(0,n.useState)([]),[x,y]=(0,n.useState)(!1),[b,v]=(0,n.useState)(0),C=(0,n.useRef)(null),k=(0,n.useRef)(null),M=(0,n.useCallback)(async t=>{try{let n=new URLSearchParams({q:t});d&&n.append("subject",d),m&&n.append("stage",m);let i=((await l.k.get(`/api/tags/suggestions?${n.toString()}`)).suggestions||[]).filter(t=>!e.includes(t));w(i.slice(0,20)),y(i.length>0),v(0)}catch(e){o.V.error("[TagInput]","Failed to fetch suggestions",{error:e})}},[d,m,e]);(0,n.useEffect)(()=>{g.trim()&&M(g)},[g,M]);let D=t=>{t.trim()&&!e.includes(t.trim())&&(s([...e,t.trim()]),p(""),w([]),y(!1),v(0))},E=t=>{s(e.filter(e=>e!==t))};return(0,n.useEffect)(()=>{let e=e=>{!k.current||k.current.contains(e.target)||C.current?.contains(e.target)||y(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,t.jsxs)("div",{className:`relative ${c}`,children:[(0,t.jsxs)("div",{className:"flex flex-wrap gap-2 p-2 border rounded-lg bg-background min-h-[42px]",children:[e.map(e=>(0,t.jsxs)(r.f,{variant:"secondary",className:"flex items-center gap-1 px-2 py-1",children:[e,(0,t.jsx)("button",{type:"button",onClick:()=>E(e),className:"hover:text-destructive ml-1",children:(0,t.jsx)(i.X,{className:"h-3 w-3"})})]},e)),(0,t.jsx)(a.f,{ref:C,type:"text",value:g,onChange:e=>{p(e.target.value),e.target.value.trim()||(w([]),y(!1))},onKeyDown:t=>{"Enter"===t.key?(t.preventDefault(),b>=0&&f[b]?D(f[b]):g.trim()&&D(g)):"ArrowDown"===t.key?(t.preventDefault(),v(e=>Math.min(e+1,f.length-1))):"ArrowUp"===t.key?(t.preventDefault(),v(e=>Math.max(e-1,0))):"Escape"===t.key?(y(!1),v(0)):"Backspace"===t.key&&!g&&e.length>0&&E(e[e.length-1])},onFocus:()=>{f.length>0&&y(!0)},placeholder:0===e.length?h:"",className:"flex-1 min-w-[120px] border-none focus-visible:ring-0 focus-visible:ring-offset-0 h-8 px-0"})]}),x&&f.length>0&&(0,t.jsx)("div",{ref:k,className:"absolute z-50 w-full mt-1 bg-popover border rounded-md shadow-md max-h-48 overflow-y-auto",children:f.map((e,n)=>(0,t.jsx)("div",{className:`px-3 py-2 cursor-pointer hover:bg-accent ${n===b?"bg-accent":""}`,onClick:()=>D(e),onMouseEnter:()=>v(n),children:e},e))}),g&&!x&&(0,t.jsx)("div",{className:"text-xs text-muted-foreground mt-1",children:u?`${u} "${g}"`:`Press Enter to create "${g}"`})]})}])},185592,e=>{var t=e.i(843476),n=e.i(975157);e.s(["f",0,function({options:e,value:i,onChange:r,className:a}){return(0,t.jsx)("div",{className:(0,n.f)("grid gap-1 rounded-xl bg-muted p-1",a),style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},role:"tablist",children:e.map(({value:e,label:a,icon:l})=>{let o=e===i;return(0,t.jsxs)("button",{type:"button",role:"tab","aria-selected":o,className:(0,n.f)("flex items-center justify-center gap-1.5 rounded-lg px-2 py-2.5 text-sm font-medium transition-all",o?"bg-card text-primary shadow-sm":"text-muted-foreground hover:text-foreground"),onClick:()=>r(e),children:[l&&(0,t.jsx)(l,{className:"h-4 w-4 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:a})]},e)})})}])},804536,e=>{var t=e.i(271645);let n=new Map,i=new Set;function r(e){return i.add(e),window.addEventListener("storage",e),()=>{i.delete(e),window.removeEventListener("storage",e)}}function a(e,a,l){let o=(0,t.useSyncExternalStore)(r,()=>(function(e){if(n.has(e))return n.get(e)??null;try{return window.localStorage.getItem(e)}catch{return null}})(e),()=>null);return[(0,t.useMemo)(()=>a(o),[a,o]),(0,t.useCallback)(t=>(function(e,t){try{window.localStorage.setItem(e,t),n.delete(e)}catch{n.set(e,t)}i.forEach(e=>e())})(e,l(t)),[e,l])]}let l=e=>e;e.s(["y",0,function(e,n,i){return a(e,(0,t.useCallback)(e=>n.includes(e??"")?e:i,[n,i]),l)},"x",0,a])},213761,e=>{let t={maxLongEdge:4096,maxPixels:4915200,maxBytes:1572864,startQuality:.9,minQuality:.8};class n extends Error{code;format;constructor(e,t,n){super(e,void 0===n?void 0:{cause:n}),this.code=e,this.format=t,this.name="ImageDecodeError"}}let i=new Set(["heic","heix","heim","heis","hevc","hevx","hevm","hevs"]),r=new Set(["mif1","msf1","mif2"]),a=new Set(["avif","avis"]);function l(e,n,i=t){let r=Math.min(1,i.maxLongEdge/Math.max(e,n),Math.sqrt(i.maxPixels/Math.max(1,e*n)));return{width:Math.max(1,Math.floor(e*r)),height:Math.max(1,Math.floor(n*r)),scale:r}}async function o(e){let t,n;if("function"==typeof createImageBitmap)try{return await createImageBitmap(e,{imageOrientation:"from-image"})}catch{}let i=await (t=URL.createObjectURL(e),(n=new Image).decoding="async",new Promise((e,i)=>{n.onload=()=>e(n),n.onerror=()=>i(Error("IMAGE_ELEMENT_DECODE_FAILED")),n.src=t}).finally(()=>URL.revokeObjectURL(t)));if(!i.naturalWidth||!i.naturalHeight)throw Error("IMAGE_EMPTY");return i}async function s(t){let{heicTo:n}=await e.A(462684);return n({blob:t,type:"image/jpeg",quality:.95})}function h(e,t){return new Promise((n,i)=>{e.toBlob(e=>e?n(e):i(Error("CANVAS_EMPTY")),"image/jpeg",t)})}function c(e,t,n,i,r,a,l){let o,s=((o=document.createElement("canvas")).width=a,o.height=l,o),h=s.getContext("2d");if(!h)throw Error("CANVAS_UNSUPPORTED");return h.fillStyle="#ffffff",h.fillRect(0,0,a,l),h.imageSmoothingEnabled=!0,h.imageSmoothingQuality="high",h.drawImage(e,t,n,i,r,0,0,a,l),s}async function u(e,t){var u;let d,m=performance.now(),g=await e.arrayBuffer(),p=performance.now()-m,f=function(e){let t=(t,n)=>String.fromCharCode(...e.subarray(t,n));if(e.length>=3&&255===e[0]&&216===e[1]&&255===e[2])return"jpeg";if(e.length>=8&&137===e[0]&&"PNG"===t(1,4))return"png";if(e.length>=12&&"RIFF"===t(0,4)&&"WEBP"===t(8,12))return"webp";if(e.length>=6&&("GIF87a"===t(0,6)||"GIF89a"===t(0,6)))return"gif";if(e.length>=2&&"BM"===t(0,2))return"bmp";if(e.length>=12&&"ftyp"===t(4,8)){let n=Math.min(e.length,(e[0]<<24|e[1]<<16|e[2]<<8|e[3])>>>0||e.length),l=[t(8,12)];for(let e=16;e+4<=n;e+=4)l.push(t(e,e+4));if(l.some(e=>i.has(e)))return"heic";if(l.some(e=>a.has(e)))return"avif";if(l.some(e=>r.has(e)))return"heic"}return"unknown"}(new Uint8Array(g,0,Math.min(g.byteLength,64))),w=e.type||"",x=performance.now(),y="native",b=new Blob([g],{type:w||"application/octet-stream"});try{d=await o(b)}catch(e){if("heic"!==f)throw new n("unknown"===f?"UNSUPPORTED_IMAGE":"IMAGE_DECODE_FAILED",f,e);t?.();try{d=await o(await s(b)),y="heic"}catch(e){throw new n("HEIC_DECODE_FAILED",f,e)}}let{width:v,height:C}=(u=d)instanceof HTMLImageElement?{width:u.naturalWidth,height:u.naturalHeight}:{width:u.width,height:u.height};if(!v||!C)throw new n("IMAGE_DECODE_FAILED",f);let k=l(v,C,{maxLongEdge:1600,maxPixels:1/0}),M=await h(c(d,0,0,v,C,k.width,k.height),.85),D=URL.createObjectURL(M),E=performance.now()-x;return{source:d,width:v,height:C,format:f,decoder:y,previewUrl:D,sourceType:w,sourceBytes:e.size,timings:{read:Math.round(p),convert:Math.round(E)},dispose:()=>{URL.revokeObjectURL(D),d instanceof HTMLImageElement||d.close()}}}let d={x:0,y:0,width:1,height:1};async function m(e,n=d,i=t){var r;let a=performance.now(),o=e=>Math.min(1,Math.max(0,e)),s=Math.round(o(n.x)*e.width),u=Math.round(o(n.y)*e.height),g=Math.max(1,Math.min(e.width-s,Math.round(o(n.width)*e.width))),p=Math.max(1,Math.min(e.height-u,Math.round(o(n.height)*e.height))),f=l(g,p,i),w=c(e.source,s,u,g,p,f.width,f.height),x=performance.now()-a,y=performance.now(),b=i.startQuality,v=await h(w,b);for(let t=0;v.size>i.maxBytes&&t<12;t++)b-.05>=i.minQuality-1e-9?b=Math.round((b-.05)*100)/100:(f={width:Math.max(1,Math.floor(.85*f.width)),height:Math.max(1,Math.floor(.85*f.height)),scale:.85*f.scale},w=c(e.source,s,u,g,p,f.width,f.height)),v=await h(w,b);return{dataUrl:await (r=v,new Promise((e,t)=>{let n=new FileReader;n.onload=()=>e(n.result),n.onerror=()=>t(n.error??Error("READ_FAILED")),n.readAsDataURL(r)})),width:f.width,height:f.height,bytes:v.size,quality:b,timings:{crop:Math.round(x),compress:Math.round(performance.now()-y)}}}e.s(["K",0,t,"o",0,n,"N",0,function(e,t){return{sourceType:e.sourceType||e.format,sourceBytes:e.sourceBytes,sourceWidth:e.width,sourceHeight:e.height,outputWidth:t.width,outputHeight:t.height,outputBytes:t.bytes,decoder:e.decoder,quality:t.quality}},"p",0,u,"X",0,m])},499930,e=>{var t=e.i(213761);function n(e,t=.008){let i=Math.max(0,e.x-t),r=Math.max(0,e.y-t);return{x:i,y:r,width:Math.min(1,e.x+e.width+t)-i,height:Math.min(1,e.y+e.height+t)-r}}async function i(e){let t=new Image;if(t.decoding="async",t.src=e,await t.decode(),!t.naturalWidth||!t.naturalHeight)throw Error("IMAGE_EMPTY");return t}async function r(e,n){let i=function(e,t=16,n=!1){let i=Math.max(...e.map(e=>e.width)),r=0,a=e.map(e=>{let a=n?i/e.width:e.scale??1,l={x:0,y:r,width:Math.round(e.width*a),height:Math.round(e.height*a)};return r+=l.height+t,l});return{width:Math.max(...a.map(e=>e.width)),height:r-t,rects:a}}(e.map(e=>({width:e.sw,height:e.sh,scale:e.scale})),16,n),r=document.createElement("canvas");r.width=i.width,r.height=i.height;let a=r.getContext("2d");if(!a)throw Error("CANVAS_UNSUPPORTED");a.fillStyle="#ffffff",a.fillRect(0,0,r.width,r.height),e.forEach((e,t)=>{let n=i.rects[t];a.drawImage(e.source,e.sx,e.sy,e.sw,e.sh,n.x,n.y,n.width,n.height)});let l=await createImageBitmap(r);try{return await (0,t.X)({source:l,width:r.width,height:r.height})}finally{l.close()}}async function a(e,i){let a=e.naturalWidth,l=e.naturalHeight,o=i.map(e=>n(e));return 1===o.length?(0,t.X)({source:e,width:a,height:l},o[0]):r(o.map(t=>({source:e,sx:Math.round(t.x*a),sy:Math.round(t.y*l),sw:Math.max(1,Math.round(t.width*a)),sh:Math.max(1,Math.round(t.height*l))})),!1)}async function l(e){return r((await Promise.all(e.map(i))).map(e=>({source:e,sx:0,sy:0,sw:e.naturalWidth,sh:e.naturalHeight})),!0)}async function o(e,t,i){let a=e.naturalWidth,l=e.naturalHeight,o=i.width/a,s=t.map(e=>n(e)).map(t=>({source:e,sx:Math.round(t.x*a),sy:Math.round(t.y*l),sw:Math.max(1,Math.round(t.width*a)),sh:Math.max(1,Math.round(t.height*l)),scale:o}));return s.push({source:i.source,sx:0,sy:0,sw:i.width,sh:i.height}),r(s,!1)}e.s(["y",0,i,"k",0,o,"M",0,a,"v",0,l])},119472,e=>{var t=e.i(41931),n=e.i(127175);async function i(e){let t;for(let n=0;n<3;n++)try{return await e()}catch(e){if(t=e,!function(e){let t=e?.status;return void 0===t||408===t||502===t||503===t||504===t}(e)||2===n)break;await new Promise(e=>setTimeout(e,1e3*(n+1)))}throw t}async function r(e,a=(0,n.c)()){let{batch:l}=await i(()=>t.k.post("/api/import-batches",{...e,clientRequestId:a,subjectId:e.subjectId||void 0,targetSubjectId:e.targetSubjectId||void 0,paperLevel:e.paperLevel||void 0,items:e.items?.map(e=>({...e})),origin:e.origin},{timeout:12e4}));return(0,n.P)(),l}async function a(e,n={}){let i=n.image?"?include=image":"",{batch:r}=await t.k.get(`/api/import-batches/${encodeURIComponent(e)}${i}`);return r}async function l(e,n,i){let{batch:r}=await t.k.patch(`/api/import-batches/${encodeURIComponent(e)}`,{version:n,draft:i});return r}async function o(e,r,a,l){let{batch:o}=await i(()=>t.k.post(`/api/import-batches/${encodeURIComponent(e)}/start`,{version:r,images:a,analysis:l},{timeout:12e4}));return(0,n.P)(),o}async function s(e){let{batch:i}=await t.k.post(`/api/import-batches/${encodeURIComponent(e)}/retry`,{});return(0,n.P)(),i}async function h(e){let i=await t.k.post(`/api/import-batches/${encodeURIComponent(e)}/confirm-all`,{});return(0,n.P)(),i}async function c(e){await t.k.delete(`/api/import-batches/${encodeURIComponent(e)}`),(0,n.P)()}async function u(e){await t.k.post(`/api/import-batches/${encodeURIComponent(e)}/read`,{}),(0,n.P)()}async function d(e,n,i){return t.k.post(`/api/import-batches/${encodeURIComponent(e)}/fix-text`,{items:n},{timeout:6e5,recoverable:!0,requestId:i})}e.s(["J",0,h,"n",0,function(e){return e?.status===409?e.data?.details?.batch??null:null},"v",0,r,"o",0,c,"w",0,a,"$",0,d,"f",0,u,"s",0,s,"S",0,l,"g",0,o])},25197,e=>{var t=e.i(41931);function n(e){return e.trim()?e:""}async function i(){try{return!!(await t.k.get("/api/user")).confirmBeforeImport}catch{return!1}}async function r(e,i){let r=await t.k.post("/api/error-items",{questionText:e.questionText,answerText:n(e.answerText),analysis:n(e.analysis),wrongAnswerText:e.wrongAnswerText||null,mistakeAnalysis:e.mistakeAnalysis||null,mistakeStatus:e.mistakeStatus||"unknown",knowledgePoints:e.knowledgePoints||[],difficultyStars:e.difficultyStars??null,recognizedGradeSemester:e.gradeSemester??null,hasFigure:e.hasFigure??!1,figureSvg:e.figureSvg??null,questionType:e.questionType??null,subjectId:i.subjectId||void 0,subjectName:i.subjectId?void 0:e.subject,originalImageUrl:i.imageUrl||"",paperLevel:i.paperLevel||void 0});return{id:r.id,shortId:r.shortId??null,subjectId:r.subjectId??null,notebookName:r.subject?.name??null,duplicate:r.duplicate}}e.i(201276),e.s(["x",0,i,"a",0,r],25197)},825624,e=>{let t=/^[\s ]+/,n="一二三四五六七八九十",i=[{family:"dot",pattern:/^(\d{1,3})\s*(?:.|\.(?!\d))\s*/},{family:"comma",pattern:/^(\d{1,3})\s*[、,,](?!\d)\s*/},{family:"paren",pattern:/^(\d{1,3})\s*[))]\s*/},{family:"colon",pattern:/^(\d{1,3})\s*[::](?!\d)\s*/},{family:"ti",pattern:/^第\s*(\d{1,3}|[一二三四五六七八九十]{1,3})\s*题\s*[..、::]?\s*/},{family:"example",pattern:/^(?:例题?|练习|习题)\s*(\d{1,3})\s*[..、::]?\s*/},{family:"q",pattern:/^(?:Q|Question|Problem|Exercise)\s*(\d{1,3})\s*[..::)]?\s+/i},{family:"cn",pattern:/^([一二三四五六七八九十]{1,3})\s*[、..]\s*/}];function r(e){let r=e.replace(t,"");for(let{family:e,pattern:t}of i){let i=r.match(t);if(!i||r.length<=i[0].length)continue;let a=function(e){if(/^\d+$/.test(e))return Number(e);if("十"===e)return 10;let t=e.indexOf("十");return -1===t?n.indexOf(e)+1:10*(0===t?1:n.indexOf(e[0])+1)+(t===e.length-1?0:n.indexOf(e[t+1])+1)}(i[1]);if(Number.isFinite(a)&&!(a<=0))return{value:a,family:e,prefixLength:i[0].length,label:i[1]}}return null}function a(e){let n=e.split("\n"),i=n[0]?.replace(t,"")??"",a=r(i);return a&&"cn"!==a.family&&(n[0]=i.slice(a.prefixLength)),n.join("\n")}function l(e){let t=[];for(let n of e)(n||0!==t.length&&""!==t[t.length-1])&&t.push(n);for(;t.length>0&&""===t[t.length-1];)t.pop();return t.join("\n")}let o=/(姓名|班级|学号|日期|得分|分数|评分|考号|座位号|家长签字|用时|Name\s*[::_]|Class\s*[::_]|Date\s*[::_]|Score\s*[::_])|_{3,}|共\s*\d+\s*(道|题|小题)|做完|答案(见|在)|最后一页|满分\s*\d+\s*分/i,s=/(阅读|材料|短文|文章|选文|诗歌|古诗|文言文|下[面列]的?(表格|图表|统计|信息)|根据.{0,20}(回答|完成)|passage|read the|according to the)/i,h=/^(参考答案|答案与解析|答案|Answers?|Answer Key)\s*[::]?$/i,c=/^(第[一二三四五六七八九十]+(部分|大题|节)|(Part|Section)\s+[A-Z0-9IVX]+\b)/i,u=/(选择|填空|判断|计算|解答|应用|解决问题|操作|作图|阅读|写作|作文|综合|口算|听力|单项|完形|题)/,d=/(\d{1,3})\s*[~~\-—–至到]\s*(\d{1,3})\s*(?:小?题|questions?)/i,m=/(小问|小题|下列问题|以下问题|下列各题|下面各题|完成下列|回答下列|回答以下|following questions|answer the following)/i;function g(e){let t=[],n=[];for(let i of e)i?n.push(i):n.length&&(t.push(n.join("\n")),n=[]);return n.length&&t.push(n.join("\n")),t}function p(e,t=[]){let n=e.trim();return!(!n||n.length>12||/[。!?!?,,、;;::..()()【】\[\]{}]$/.test(n)||/\d/.test(n)||/[。!?!?;;,,]/.test(n))&&!!(/(篇|章|节|部分|组)$/.test(n)||/^(Part|Section)\s+[A-Z0-9]+$/i.test(n))&&(!t.length||t.some(e=>{let t=r(e);return null!==t&&1===t.value}))}function f(e,t){let n=[];for(let i=0;i<e.length;i++){let r=e[i],a=[r];for(let n=i+1;n<e.length;n++){let i=e[n],l=a[a.length-1];if(i.family!==r.family)continue;let o=1===i.value&&[...t].some(e=>e>l.line&&e<i.line);(i.value===l.value+1||o)&&a.push(i)}a.length>n.length&&(n=a)}return n}function w(e,t,n){return!!c.test(e)||!!t&&"cn"===t.family&&"cn"!==n&&null!==n&&(e.length<=40||u.test(e.slice(0,20)))}function x(e,t,n,i,r){for(let a=e-1;a>=0;a--)if(t[a]){if(r.has(a)||w(t[a],n[a],i)||p(t[a]))return t[a];break}return null}function y(e){let t=e.match(d);if(!t)return null;let n=Number(t[1]),i=Number(t[2]);return n<=i?{from:n,to:i}:null}let b={answer:/^(?:【\s*(?:参考答案|答案)\s*】|(?:参考答案|答案)\s*[::]|Answer\s*[::])\s*(.*)$/i,analysis:/^(?:【\s*(?:解析|分析|详解|解答|点评)\s*】|(?:解析|分析|详解|解答|点评)\s*[::])\s*(.*)$/,knowledge:/^(?:【\s*(?:知识点|考点)\s*】|(?:知识点|考点)\s*[::])\s*(.*)$/,difficulty:/^(?:【\s*难度\s*】|难度\s*[::])\s*(.*)$/,questionType:/^(?:【\s*题型\s*】|题型\s*[::])\s*(.*)$/,wrongAnswer:/^(?:【\s*错答\s*】|我的答案\s*[::]|学生答案\s*[::])\s*(.*)$/},v={易:1,较易:2,中等:3,较难:4,难:5};function C(e){return e.split(/[、,,;;]/).map(e=>e.trim()).filter(Boolean)}function k(e){let t={answer:[],analysis:[],knowledge:[],difficulty:[],questionType:[],wrongAnswer:[]},n=[],i=null;for(let r of e){let e=null;for(let n of Object.keys(b)){let a=r.match(b[n]);if(!a)continue;e=n,i=n;let l=a[1].trim();l&&t[n].push(l);break}e||(i&&r.trim()?t[i].push(r.trim()):n.push(r))}let r={},a=t.answer.join("\n").trim();a&&(r.answer=a);let o=t.analysis.join("\n").trim();o&&(r.analysis=o);let s=t.knowledge.flatMap(C);s.length&&(r.knowledgePoints=s);let h=t.difficulty.join(" ").trim(),c=h?function(e){let t=e.trim();if(!t)return null;let n=t.match(/^(\d{1,2})\s*(?:星|级)?$/);if(n){let e=Number(n[1]);return e>=1&&e<=5?e:null}if(/^[★☆]{1,5}$/.test(t)){let e=(t.match(/★/g)??[]).length;return e>=1?e:null}return t in v?v[t]:null}(h):null;null!==c&&(r.difficultyStars=c);let u=t.questionType.join(" ").trim();u&&(r.questionType=u);let d=t.wrongAnswer.join("\n").trim();return d&&(r.wrongAnswer=d),{text:l(n),fields:r}}let M=/^(\d{1,3})\s*[..、,,)]\s*(\S[\s\S]*)$/,D=/^(\d{1,3})\s*[~~—–-]\s*(\d{1,3})\s*[::..、]?\s*([A-Za-z]+)$/;function E(e){let t=e.trim();if(!t)return null;let n=function(e){let t=e.trim().match(D);if(!t)return null;let n=Number(t[1]),i=Number(t[2]),r=t[3];if(!Number.isFinite(n)||!Number.isFinite(i)||n<=0||i<=n||i-n+1>60)return null;let a=i-n+1;return r.length!==a?null:Array.from({length:a},(e,t)=>({label:String(n+t),text:r[t]}))}(t);if(n)return n;let i=function(e){let t=e.trim(),n=[];for(let e of t.matchAll(/(\d{1,3})\s*[..、,,;;]\s*/g)){let i=e.index??0,r=t[i+e[0].length];r&&/\d/.test(r)||n.push({index:i,label:e[1],afterIndex:i+e[0].length})}if(n.length<2)return null;for(let e=1;e<n.length;e++)if(Number(n[e].label)<=Number(n[e-1].label))return null;let i=[];for(let e=0;e<n.length;e++){let r=n[e].afterIndex,a=e+1<n.length?n[e+1].index:t.length,l=t.slice(r,a).trim().replace(/[;;]+$/,"").trim();if(!l||l.length>30||/[。!?!?]/.test(l))return null;i.push({label:n[e].label,text:l})}return i}(t);if(i)return i.map(e=>({label:e.label??"",text:e.text})).filter(e=>e.label);let r=t.match(M);if(!r)return null;let a=Number(r[1]);return!Number.isFinite(a)||a<=0?null:[{label:r[1],text:r[2].trim()}]}function _(e){let t=e.match(/^(.*?)(?:【?\s*(?:解析|分析|详解|解答|点评)\s*】?\s*[::])([\s\S]*)$/);if(t){let n=t[1].replace(/^(?:【?\s*(?:参考答案|答案)\s*】?\s*[::])\s*/,"").trim(),i=t[2].trim();return i?{answer:n,analysis:i}:{answer:e.trim()}}return{answer:e.replace(/^(?:【?\s*(?:参考答案|答案)\s*】?\s*[::])\s*/,"").trim()||e.trim()}}function j(e,t){let n=[],i=!1;for(let r of e){let e={value:!1},a=[];for(let n of r.split("\n")){let i=n.trim()?E(n):null;if(!i){n.trim()&&a.push(n);continue}let r=!1;for(let l of i){let i=t.find(e=>e.label===l.label);if(!i){a.push(n);break}r=!0,e.value=!0;let o=_(l.text);o.answer&&!i.answer&&(i.answer=o.answer),o.analysis&&(i.analysis=i.analysis?`${i.analysis}
|
|
2
|
+
${o.analysis}`:o.analysis)}!r&&!a.includes(n)&&n.trim()&&!a.includes(n)&&a.push(n)}i=i||e.value,e.value?a.length&&n.push(a.join("\n")):n.push(r)}return[n,i]}e.s(["k",0,2e3,"f",0,1e6,"S",0,60,"i",0,2e4,"J",0,function(e,n={}){let i,u,b=void 0===n.maxLength?2e4:Math.min(Math.max(n.maxLength,1e3),1e6),v=void 0===n.maxQuestions?60:Math.min(Math.max(n.maxQuestions,2),2e3),C=e.length>b,M=e.slice(0,b).replace(/\r\n?/g,"\n").split("\n").map(e=>e.replace(t,"").replace(/[\s ]+$/,"")),D=M.map(e=>e?r(e):null),R=M.length;for(let e=0;e<M.length;e++)if(h.test(M[e])){R=e;break}let S=[],I=[];for(let e=0;e<R;e++){let t=D[e];t&&("cn"===t.family?I:S).push({...t,line:e})}let N=new Set;for(let e=0;e<R;e++)(c.test(M[e])||D[e]?.family==="cn"||p(M[e],M.slice(e+1,e+5)))&&N.add(e);let $=[],P=f(S,N);if(P.length<2){let e=f(I,new Set);e.length>=2&&($=[{chain:e,sectionHeading:null}])}else $=function(e,t,n,i){if(e.length<2)return[];let r=e[0].family,a=[0];for(let t=1;t<e.length;t++)1===e[t].value&&a.push(t);if(a.length<2){let a=x(e[0].line,t,n,r,i);return null!==a?[{chain:e,sectionHeading:a}]:[]}let l=[];for(let o=0;o<a.length;o++){let s=a[o],h=o+1<a.length?a[o+1]:e.length,c=e.slice(s,h),u=0===o?x(e[0].line,t,n,r,i):function(e,t,n,i,r,a){for(let l=e+1;l<t;l++)if(n[l]&&(a.has(l)||w(n[l],i[l],r)||p(n[l])))return n[l];return null}(e[s-1].line,e[s].line,t,n,r,i);if(null===u&&o>0){l[l.length-1].chain.push(...c);continue}l.push({chain:c,sectionHeading:u})}return l.filter(e=>e.chain.length>0)}(P,M,D,N);let L=$.length?$.flatMap(e=>e.chain):P,A=l(M.slice(0,R)),H=R<M.length?g(M.slice(R)):[],O=(u=r(M[L[0]?.line??0]??""))?u.label:null,U=e=>({questions:A?[{label:O,text:A,material:null,section:null,lineRange:{from:0,to:R}}]:[],ignored:H,detected:!1,ambiguous:e,candidateCount:e?L.length:+!!A,overflow:0,tooLong:C});if(L.length<2){if(!A)return U(!1);let e=k(A.split("\n")),t=U(!1);if(t.questions.length>0&&Object.keys(e.fields).length>0&&(t.questions[0]={...t.questions[0],text:a(e.text),...e.fields}),t.questions.length>0&&H.length){let[e,n]=j(H,t.questions);t.ignored=e,n||(t.ignored=H)}return t}let X=L[0].family;if(!n.forceNumbered&&function(e,t,n,i){let r=null;for(let a=t-1;a>=0;a--)if(e[a]){r=w(e[a],i[a],n)?null:e[a];break}return!(!r||o.test(r)||d.test(r))&&("paren"===n?r.length>=15||/[。?!?!::,,;;]$/.test(r):/[::]$/.test(r)&&m.test(r))}(M,L[0].line,X,D)){let e=U(!0);if(e.questions.length>0&&A){let t=k(A.split("\n"));Object.keys(t.fields).length>0&&(e.questions[0]={...e.questions[0],text:a(t.text),...t.fields})}return e}let Y=new Set(L.map(e=>e.line)),B=[],T=[],z=null,K=[],F=[],q=(e,t)=>{for(let n of g(e))(!o.test(n)||!(n.length<80))&&(s.test(n)||n.length>=80&&/[。!?.!?;;]/.test(n))?K.push({text:n,range:y(n)}):t?B.push(n):z&&!T.some(e=>e.section===z)?z=`${z}
|
|
3
3
|
${n}`:B.push(n)},W=L[0].line,G=[];for(let e=0;e<W;e++)M[e]&&(w(M[e],D[e],X)||p(M[e],M.slice(e+1,e+5)))?(q(G.splice(0),!0),z=M[e],F=[]):G.push(M[e]);q(G,!0);let Q=$.length>1,V=e=>{if(!Q)return -1;let t=0;for(let n=0;n<$.length;n++)if(e<(t+=$[n].chain.length))return n;return $.length-1};for(let e=0;e<L.length;e++){let t=L[e].line,n=e+1<L.length?L[e+1].line:R,i=V(e);if(Q&&i>=0){let e=$[i].sectionHeading;null!==e&&(z=e,F=[])}K.length&&(F=[...F.filter(e=>e.range),...K],K=[]);let r=n,o=null;for(let e=t+1;e<n;e++)if(M[e]&&!Y.has(e)&&w(M[e],D[e],X)){r=e,o=M[e];break}let h=M.slice(t,r),c=g(h),u=[];for(;c.length>1&&s.test(c[c.length-1].slice(0,30));)u.unshift(c.pop());let d=u.length?c.join("\n"):l(h),m=L[e].value,p=F.filter(e=>!e.range||m>=e.range.from&&m<=e.range.to),f=k(a(d).split("\n"));for(let i of(T.push({label:L[e].label,text:f.text,material:p.length?p.map(e=>e.text).join("\n\n"):null,section:z,lineRange:{from:t,to:n},...f.fields}),u))K.push({text:i,range:y(i)});null!==o&&(z=o,F=[],q(M.slice(r+1,n),!1))}if(Q&&H.length){let e=$.map(e=>e.sectionHeading).filter(e=>null!==e),t=H.join("\n");i=e.some(e=>t.includes(e))?function(e,t,n){let i=[],r=0,a=t.map(e=>{let t=n.slice(r,r+e.chain.length);return r+=e.chain.length,t}),l=-1;for(let r of e){let e=r.split("\n"),o=[],s=!1;for(let i of e){let e=i.trim();if(!e){o.push(i);continue}let r=t.findIndex(t=>t.sectionHeading&&e.includes(t.sectionHeading));if(r>=0){l=r;continue}let h=E(e);if(!h){o.push(i);continue}let c=l>=0?a[l]:n,u=!1;for(let e of h){let t=c.find(t=>t.label===e.label);if(!t){o.push(i);break}u=!0,s=!0;let n=_(e.text);n.answer&&!t.answer&&(t.answer=n.answer),n.analysis&&(t.analysis=t.analysis?`${t.analysis}
|
|
4
4
|
${n.analysis}`:n.analysis)}u||o.includes(i)||o.push(i)}s?o.length&&i.push(o.join("\n")):i.push(r)}return i}(H,$,T):H}else i=j(H,T)[0];let Z=T.slice(v);return{questions:T.slice(0,v),ignored:[...B,...i,...Z.map(e=>{var t;let n,i,r,a;return n=(t=e).text.trim(),r=(i=t.material?.trim())?`${i}
|
|
5
5
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
(()=>{"use strict";(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,399847,e=>{var t=e.i(456420);let n={name:"circle-alert",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],aliases:["alert-circle"]};n.node;let i=(0,t.f)(n);e.s(["f",0,i],399847)},13285,e=>{var t=e.i(456420);let n={name:"layers",size:24,node:[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],aliases:["layers-3"]};n.node;let i=(0,t.f)(n);e.s(["f",0,i],13285)},232660,e=>{var t=e.i(271645),n={x:0,y:0,width:0,height:0,unit:"px"},i=(e,t,n)=>Math.min(Math.max(e,t),n),r=(e,t)=>e===t||e.width===t.width&&e.height===t.height&&e.x===t.x&&e.y===t.y&&e.unit===t.unit;function a(e,t,i){return"%"===e.unit?{...n,...e,unit:"%"}:{unit:"%",x:e.x?e.x/t*100:0,y:e.y?e.y/i*100:0,width:e.width?e.width/t*100:0,height:e.height?e.height/i*100:0}}function l(e,t,i){return e.unit&&"px"!==e.unit?{unit:"px",x:e.x?e.x*t/100:0,y:e.y?e.y*i/100:0,width:e.width?e.width*t/100:0,height:e.height?e.height*i/100:0}:{...n,...e,unit:"px"}}function o(e,t,n,i,r,a=0,l=0,s=i,h=r){let c={...e},u=Math.min(a,i),d=Math.min(l,r),m=Math.min(s,i),g=Math.min(h,r);t&&(t>1?(d=(u=l?l*t:u)/t,m=s*t):(u=(d=a?a/t:d)*t,g=h/t)),c.y<0&&(c.height=Math.max(c.height+c.y,d),c.y=0),c.x<0&&(c.width=Math.max(c.width+c.x,u),c.x=0);let p=i-(c.x+c.width);p<0&&(c.x=Math.min(c.x,i-u),c.width+=p);let f=r-(c.y+c.height);if(f<0&&(c.y=Math.min(c.y,r-d),c.height+=f),c.width<u&&(("sw"===n||"nw"==n)&&(c.x-=u-c.width),c.width=u),c.height<d&&(("nw"===n||"ne"==n)&&(c.y-=d-c.height),c.height=d),c.width>m&&(("sw"===n||"nw"==n)&&(c.x-=m-c.width),c.width=m),c.height>g&&(("nw"===n||"ne"==n)&&(c.y-=g-c.height),c.height=g),t){let e=c.width/c.height;if(e<t){let e=Math.max(c.width/t,d);("nw"===n||"ne"==n)&&(c.y-=e-c.height),c.height=e}else if(e>t){let e=Math.max(c.height*t,u);("sw"===n||"nw"==n)&&(c.x-=e-c.width),c.width=e}}return c}var s={capture:!0,passive:!1},h=0,c=class e extends t.PureComponent{static xOrds=["e","w"];static yOrds=["n","s"];static xyOrds=["nw","ne","se","sw"];static nudgeStep=1;static nudgeStepMedium=10;static nudgeStepLarge=100;static defaultProps={ariaLabels:{cropArea:"Use the arrow keys to move the crop selection area",nwDragHandle:"Use the arrow keys to move the north west drag handle to change the crop selection area",nDragHandle:"Use the up and down arrow keys to move the north drag handle to change the crop selection area",neDragHandle:"Use the arrow keys to move the north east drag handle to change the crop selection area",eDragHandle:"Use the up and down arrow keys to move the east drag handle to change the crop selection area",seDragHandle:"Use the arrow keys to move the south east drag handle to change the crop selection area",sDragHandle:"Use the up and down arrow keys to move the south drag handle to change the crop selection area",swDragHandle:"Use the arrow keys to move the south west drag handle to change the crop selection area",wDragHandle:"Use the up and down arrow keys to move the west drag handle to change the crop selection area"}};get document(){return document}docMoveBound=!1;mouseDownOnCrop=!1;dragStarted=!1;evData={startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0};componentRef=(0,t.createRef)();mediaRef=(0,t.createRef)();resizeObserver;initChangeCalled=!1;instanceId=`rc-${h++}`;state={cropIsActive:!1,newCropIsBeingDrawn:!1};getBox(){let e=this.mediaRef.current;if(!e)return{x:0,y:0,width:0,height:0};let{x:t,y:n,width:i,height:r}=e.getBoundingClientRect();return{x:t,y:n,width:i,height:r}}componentDidUpdate(e){let{crop:t,onComplete:n}=this.props;if(n&&!e.crop&&t){let{width:e,height:i}=this.getBox();e&&i&&n(l(t,e,i),a(t,e,i))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||=(this.document.addEventListener("pointermove",this.onDocPointerMove,s),this.document.addEventListener("pointerup",this.onDocPointerDone,s),this.document.addEventListener("pointercancel",this.onDocPointerDone,s),!0)}unbindDocMove(){this.docMoveBound&&=(this.document.removeEventListener("pointermove",this.onDocPointerMove,s),this.document.removeEventListener("pointerup",this.onDocPointerDone,s),this.document.removeEventListener("pointercancel",this.onDocPointerDone,s),!1)}onCropPointerDown=e=>{let{crop:t,disabled:n}=this.props,i=this.getBox();if(!t)return;let r=l(t,i.width,i.height);if(n)return;e.cancelable&&e.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});let a=e.target.dataset.ord,o=e.clientX,s=e.clientY,h=r.x,c=r.y;if(a){let t=e.clientX-i.x,n=e.clientY-i.y,l=0,u=0;"ne"===a||"e"==a?(l=t-(r.x+r.width),u=n-r.y,h=r.x,c=r.y+r.height):"se"===a||"s"===a?(l=t-(r.x+r.width),u=n-(r.y+r.height),h=r.x,c=r.y):"sw"===a||"w"==a?(l=t-r.x,u=n-(r.y+r.height),h=r.x+r.width,c=r.y):("nw"===a||"n"==a)&&(l=t-r.x,u=n-r.y,h=r.x+r.width,c=r.y+r.height),o=h+i.x+l,s=c+i.y+u}this.evData={startClientX:o,startClientY:s,startCropX:h,startCropY:c,clientX:e.clientX,clientY:e.clientY,isResize:!!a,ord:a},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})};onComponentPointerDown=e=>{let{crop:t,disabled:n,locked:i,keepSelection:r,onChange:o}=this.props,s=this.getBox();if(n||i||r&&t)return;e.cancelable&&e.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});let h=e.clientX-s.x,c=e.clientY-s.y,u={unit:"px",x:h,y:c,width:0,height:0};this.evData={startClientX:e.clientX,startClientY:e.clientY,startCropX:h,startCropY:c,clientX:e.clientX,clientY:e.clientY,isResize:!0},this.mouseDownOnCrop=!0,o(l(u,s.width,s.height),a(u,s.width,s.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})};onDocPointerMove=e=>{let t,{crop:n,disabled:i,onChange:o,onDragStart:s}=this.props,h=this.getBox();if(i||!n||!this.mouseDownOnCrop)return;e.cancelable&&e.preventDefault(),this.dragStarted||(this.dragStarted=!0,s&&s(e));let{evData:c}=this;c.clientX=e.clientX,c.clientY=e.clientY,r(n,t=c.isResize?this.resizeCrop():this.dragCrop())||o(l(t,h.width,h.height),a(t,h.width,h.height))};onComponentKeyDown=t=>{let{crop:n,disabled:r,onChange:o,onComplete:s}=this.props;if(r)return;let h=t.key,c=!1;if(!n)return;let u=this.getBox(),d=this.makePixelCrop(u),m=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?e.nudgeStepLarge:t.shiftKey?e.nudgeStepMedium:e.nudgeStep;if("ArrowLeft"===h?(d.x-=m,c=!0):"ArrowRight"===h?(d.x+=m,c=!0):"ArrowUp"===h?(d.y-=m,c=!0):"ArrowDown"===h&&(d.y+=m,c=!0),c){t.cancelable&&t.preventDefault(),d.x=i(d.x,0,u.width-d.width),d.y=i(d.y,0,u.height-d.height);let e=l(d,u.width,u.height),n=a(d,u.width,u.height);o(e,n),s&&s(e,n)}};onHandlerKeyDown=(t,n)=>{var i,s;let h,{aspect:c=0,crop:u,disabled:d,minWidth:m=0,minHeight:g=0,maxWidth:p,maxHeight:f,onChange:w,onComplete:x}=this.props,y=this.getBox();if(d||!u||"ArrowUp"!==t.key&&"ArrowDown"!==t.key&&"ArrowLeft"!==t.key&&"ArrowRight"!==t.key)return;t.stopPropagation(),t.preventDefault();let b=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?e.nudgeStepLarge:t.shiftKey?e.nudgeStepMedium:e.nudgeStep,v=o((i=l(u,y.width,y.height),s=t.key,h={...i},"ArrowLeft"===s?"nw"===n?(h.x-=b,h.y-=b,h.width+=b,h.height+=b):"w"===n?(h.x-=b,h.width+=b):"sw"===n?(h.x-=b,h.width+=b,h.height+=b):"ne"===n?(h.y+=b,h.width-=b,h.height-=b):"e"===n?h.width-=b:"se"===n&&(h.width-=b,h.height-=b):"ArrowRight"===s&&("nw"===n?(h.x+=b,h.y+=b,h.width-=b,h.height-=b):"w"===n?(h.x+=b,h.width-=b):"sw"===n?(h.x+=b,h.width-=b,h.height-=b):"ne"===n?(h.y-=b,h.width+=b,h.height+=b):"e"===n?h.width+=b:"se"===n&&(h.width+=b,h.height+=b)),"ArrowUp"===s?"nw"===n?(h.x-=b,h.y-=b,h.width+=b,h.height+=b):"n"===n?(h.y-=b,h.height+=b):"ne"===n?(h.y-=b,h.width+=b,h.height+=b):"sw"===n?(h.x+=b,h.width-=b,h.height-=b):"s"===n?h.height-=b:"se"===n&&(h.width-=b,h.height-=b):"ArrowDown"===s&&("nw"===n?(h.x+=b,h.y+=b,h.width-=b,h.height-=b):"n"===n?(h.y+=b,h.height-=b):"ne"===n?(h.y+=b,h.width-=b,h.height-=b):"sw"===n?(h.x-=b,h.width+=b,h.height+=b):"s"===n?h.height+=b:"se"===n&&(h.width+=b,h.height+=b)),h),c,n,y.width,y.height,m,g,p,f);if(!r(u,v)){let e=a(v,y.width,y.height);w(v,e),x&&x(v,e)}};onDocPointerDone=e=>{let{crop:t,disabled:n,onComplete:i,onDragEnd:r}=this.props,o=this.getBox();this.unbindDocMove(),!(n||!t)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,r&&r(e),i&&i(l(t,o.width,o.height),a(t,o.width,o.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))};onDragFocus=()=>{this.componentRef.current?.scrollTo(0,0)};getCropStyle(){let{crop:e}=this.props;if(e)return{top:`${e.y}${e.unit}`,left:`${e.x}${e.unit}`,width:`${e.width}${e.unit}`,height:`${e.height}${e.unit}`}}dragCrop(){let{evData:e}=this,t=this.getBox(),n=this.makePixelCrop(t),r=e.clientX-e.startClientX,a=e.clientY-e.startClientY;return n.x=i(e.startCropX+r,0,t.width-n.width),n.y=i(e.startCropY+a,0,t.height-n.height),n}getPointRegion(e,t,n,i){let{evData:r}=this,a=r.clientX-e.x,l=r.clientY-e.y,o;return o=i&&t?"nw"===t||"n"===t||"ne"===t:l<r.startCropY,(n&&t?"nw"===t||"w"===t||"sw"===t:a<r.startCropX)?o?"nw":"sw":o?"ne":"se"}resolveMinDimensions(e,t,n=0,i=0){let r=Math.min(n,e.width),a=Math.min(i,e.height);return t&&(r||a)?t>1?r?[r,r/t]:[a*t,a]:a?[a*t,a]:[r,r/t]:[r,a]}resizeCrop(){let{evData:t}=this,{aspect:n=0,maxWidth:r,maxHeight:a}=this.props,l=this.getBox(),[s,h]=this.resolveMinDimensions(l,n,this.props.minWidth,this.props.minHeight),c=this.makePixelCrop(l),u=this.getPointRegion(l,t.ord,s,h),d=t.ord||u,m=t.clientX-t.startClientX,g=t.clientY-t.startClientY;(s&&"nw"===d||"w"===d||"sw"===d)&&(m=Math.min(m,-s)),(h&&"nw"===d||"n"===d||"ne"===d)&&(g=Math.min(g,-h));let p={unit:"px",x:0,y:0,width:0,height:0};"ne"===u?(p.x=t.startCropX,p.width=m,n?p.height=p.width/n:p.height=Math.abs(g),p.y=t.startCropY-p.height):"se"===u?(p.x=t.startCropX,p.y=t.startCropY,p.width=m,n?p.height=p.width/n:p.height=g):"sw"===u?(p.x=t.startCropX+m,p.y=t.startCropY,p.width=Math.abs(m),n?p.height=p.width/n:p.height=g):"nw"===u&&(p.x=t.startCropX+m,p.width=Math.abs(m),n?(p.height=p.width/n,p.y=t.startCropY-p.height):(p.height=Math.abs(g),p.y=t.startCropY+g));let f=o(p,n,u,l.width,l.height,s,h,r,a);return n||e.xyOrds.indexOf(d)>-1?c=f:e.xOrds.indexOf(d)>-1?(c.x=f.x,c.width=f.width):e.yOrds.indexOf(d)>-1&&(c.y=f.y,c.height=f.height),c.x=i(c.x,0,l.width-c.width),c.y=i(c.y,0,l.height-c.height),c}renderCropSelection(){let{ariaLabels:n=e.defaultProps.ariaLabels,disabled:i,locked:r,renderSelectionAddon:a,ruleOfThirds:l,crop:o}=this.props,s=this.getCropStyle();if(o)return t.default.createElement("div",{style:s,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":n.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!i&&!r&&t.default.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},t.default.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),t.default.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),t.default.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),t.default.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":n.nwDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"nw"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":n.nDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"n"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":n.neDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"ne"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":n.eDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"e"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":n.seDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"se"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":n.sDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"s"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":n.swDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"sw"),role:"button"}),t.default.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":n.wDragHandle,onKeyDown:e=>this.onHandlerKeyDown(e,"w"),role:"button"})),a&&t.default.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:e=>e.stopPropagation()},a(this.state)),l&&t.default.createElement(t.default.Fragment,null,t.default.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),t.default.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(e){return l({...n,...this.props.crop||{}},e.width,e.height)}render(){let{aspect:e,children:n,circularCrop:i,className:r,crop:a,disabled:l,locked:o,style:s,ruleOfThirds:h}=this.props,{cropIsActive:c,newCropIsBeingDrawn:u}=this.state,d=a?this.renderCropSelection():null,m=((...e)=>e.filter(e=>e&&"string"==typeof e).join(" "))("ReactCrop",r,c&&"ReactCrop--active",l&&"ReactCrop--disabled",o&&"ReactCrop--locked",u&&"ReactCrop--new-crop",a&&e&&"ReactCrop--fixed-aspect",a&&i&&"ReactCrop--circular-crop",a&&h&&"ReactCrop--rule-of-thirds",!this.dragStarted&&a&&!a.width&&!a.height&&"ReactCrop--invisible-crop",i&&"ReactCrop--no-animate");return t.default.createElement("div",{ref:this.componentRef,className:m,style:s},t.default.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},n),a?t.default.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},t.default.createElement("defs",null,t.default.createElement("mask",{id:`hole-${this.instanceId}`},t.default.createElement("rect",{width:"100%",height:"100%",fill:"white"}),i?t.default.createElement("ellipse",{cx:`${a.x+a.width/2}${a.unit}`,cy:`${a.y+a.height/2}${a.unit}`,rx:`${a.width/2}${a.unit}`,ry:`${a.height/2}${a.unit}`,fill:"black"}):t.default.createElement("rect",{x:`${a.x}${a.unit}`,y:`${a.y}${a.unit}`,width:`${a.width}${a.unit}`,height:`${a.height}${a.unit}`,fill:"black"}))),t.default.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,d)}};e.s(["f",0,c])},12130,271945,e=>{var t=e.i(843476),n=e.i(271645),i=e.i(232660),r=e.i(519455),a=e.i(776639),l=e.i(263676),o=e.i(111110);async function s(e,t){let{naturalWidth:n,naturalHeight:i}=e;return Promise.all(t.map(t=>new Promise((r,a)=>{let l=document.createElement("canvas"),o=Math.round(t.x*n),s=Math.round(t.y*i);l.width=Math.max(1,Math.round(t.width*n)),l.height=Math.max(1,Math.round(t.height*i));let h=l.getContext("2d");h?(h.drawImage(e,o,s,l.width,l.height,0,0,l.width,l.height),l.toBlob(e=>e?r(e):a(Error("Canvas is empty")),"image/jpeg",.95)):a(Error("Canvas is not supported"))})))}let h={maxHeight:"65vh",maxWidth:"100%",objectFit:"contain"},c=(0,n.forwardRef)(function({imageSrc:e,regions:i,onChange:r,imageStyle:a=h,onImageLoad:s},c){let{t:u}=(0,o.b)(),d=(0,n.useRef)(null),m=(0,n.useRef)(null),[g,p]=(0,n.useState)(null),f=e=>{let t=d.current.getBoundingClientRect();return{x:(e.clientX-t.left)/t.width,y:(e.clientY-t.top)/t.height}},w=()=>{g&&g.width>=.02&&g.height>=.02&&r([...i,g]),m.current=null,p(null)},x=e=>({left:`${100*e.x}%`,top:`${100*e.y}%`,width:`${100*e.width}%`,height:`${100*e.height}%`});return(0,t.jsxs)("div",{className:"relative inline-block select-none",children:[(0,t.jsx)("img",{ref:c,src:e,alt:"",draggable:!1,style:a,onLoad:s,className:"block"}),(0,t.jsxs)("div",{ref:d,className:"absolute inset-0 cursor-crosshair",style:{touchAction:"none"},onPointerDown:e=>{0===e.button&&(d.current?.setPointerCapture(e.pointerId),m.current=f(e),p(null))},onPointerMove:e=>{var t,n,i,r;let a,l,o;if(!m.current)return;let s=f(e);p((t=m.current.x,n=m.current.y,i=s.x,r=s.y,l=(a=e=>Math.min(1,Math.max(0,e)))(Math.min(t,i)),o=a(Math.min(n,r)),{x:l,y:o,width:a(Math.max(t,i))-l,height:a(Math.max(n,r))-o}))},onPointerUp:w,onPointerCancel:w,children:[i.map((e,n)=>(0,t.jsxs)("div",{className:"absolute border-2 border-sky-400 bg-sky-400/15",style:x(e),children:[(0,t.jsx)("span",{className:"absolute left-0 top-0 bg-sky-500 px-1.5 text-xs font-bold text-white",children:n+1}),(0,t.jsx)("button",{type:"button",className:"absolute -right-3 -top-3 flex h-6 w-6 items-center justify-center rounded-full bg-red-500 text-white shadow","aria-label":u.batchImport.removeRegion.replace("{index}",String(n+1)),onPointerDown:e=>e.stopPropagation(),onClick:()=>r(i.filter((e,t)=>t!==n)),children:(0,t.jsx)(l.X,{className:"h-3 w-3"})})]},n)),g&&(0,t.jsx)("div",{className:"absolute border-2 border-dashed border-yellow-300 bg-yellow-300/10",style:x(g)})]})]})});var u=e.i(456420);let d={name:"zoom-in",size:24,node:[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]};d.node;let m=(0,u.f)(d),g={name:"zoom-out",size:24,node:[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]};g.node;let p=(0,u.f)(g);function f({zoom:e,onZoomIn:n,onZoomOut:i,onReset:r}){let{t:a}=(0,o.b)(),l="outline-none focus-visible:ring-2 focus-visible:ring-white/70",s=`flex h-9 w-9 items-center justify-center rounded-full text-white transition-colors hover:bg-white/20 disabled:opacity-40 disabled:hover:bg-transparent ${l}`;return(0,t.jsxs)("div",{className:"flex items-center gap-0.5 rounded-full bg-black/60 p-1 shadow-lg backdrop-blur-sm",children:[(0,t.jsx)("button",{type:"button",className:s,onClick:i,disabled:e<=1,"aria-label":a.common.cropper.zoomOut,title:a.common.cropper.zoomOut,children:(0,t.jsx)(p,{className:"h-4 w-4"})}),(0,t.jsxs)("button",{type:"button",className:`h-9 min-w-14 rounded-full px-2 text-center text-xs font-medium tabular-nums text-white hover:bg-white/20 ${l}`,onClick:r,"aria-label":a.common.cropper.resetZoom,title:a.common.cropper.resetZoom,children:[Math.round(100*e),"%"]}),(0,t.jsx)("button",{type:"button",className:s,onClick:n,disabled:e>=5,"aria-label":a.common.cropper.zoomIn,title:a.common.cropper.zoomIn,children:(0,t.jsx)(m,{className:"h-4 w-4"})})]})}var w=e.i(201276),x=e.i(804536);let y="image-cropper-mode",b=["single","auto","multi"];e.s(["U",0,b,"p",0,y,"S",0,["image","text","file","direct"],"c",0,"question-input-mode","k",0,["image","text"]],271945);let v={single:{maxHeight:"70vh",maxWidth:"100%",objectFit:"contain"},auto:{maxHeight:"65vh",maxWidth:"100%",objectFit:"contain"},multi:{maxHeight:"65vh",maxWidth:"100%",objectFit:"contain"}};e.s(["f",0,function({imageSrc:e,open:l,onClose:h,onCropComplete:u,onMultiCropComplete:d,onRegionsSelected:m,allowMulti:g=!0,onAutoSplit:p,onAddPart:C,partCount:M=0}){let{t:k}=(0,o.b)(),D=/^(blob:|data:image\/)/i.test(e)?e:void 0,[E,j]=(0,n.useState)(),R=(0,n.useRef)(null),[I,S]=(0,x.y)(y,b,"single"),$=["single",...p?["auto"]:[],...d||m&&g?["multi"]:[]],N=$.includes(I)?I:"single",[P,L]=(0,n.useState)(null),A=null===P?v[N]:{...v[N],maxHeight:`${Math.max(0,P-16)}px`},{containerRef:_,container:H,zoom:O,imageStyle:U,measureImage:X,zoomIn:Y,zoomOut:B,reset:T}=function(e){let[t,i]=(0,n.useState)(null),r=(0,n.useRef)(null),a=(0,n.useCallback)(e=>{r.current=e,i(e)},[]),[l,o]=(0,n.useState)(1),s=(0,n.useRef)(1),[h,c]=(0,n.useState)(null),u=(0,n.useRef)(null),d=(0,n.useRef)(!1),m=(0,n.useCallback)((e,t,n)=>{let i=r.current,a=s.current,l=Math.min(5,Math.max(1,e));if(!i||l===a)return;if(1===a){let e=i.querySelector("img");e&&c(e.clientWidth)}let h=i.getBoundingClientRect(),d=(t??h.left+h.width/2)-h.left,m=(n??h.top+h.height/2)-h.top;u.current={viewX:d,viewY:m,contentX:i.scrollLeft+d,contentY:i.scrollTop+m,ratio:l/a},s.current=l,o(l)},[]);(0,n.useLayoutEffect)(()=>{let e=r.current,t=u.current;e&&t&&(e.scrollLeft=t.contentX*t.ratio-t.viewX,e.scrollTop=t.contentY*t.ratio-t.viewY,u.current=null)},[l]),(0,n.useEffect)(()=>{if(!t)return;let e=e=>{e.preventDefault(),m(s.current*Math.exp(-(.0015*e.deltaY)),e.clientX,e.clientY)},n=null,i=e=>{let[t,n]=[e[0],e[1]];return{distance:Math.hypot(t.clientX-n.clientX,t.clientY-n.clientY),centerX:(t.clientX+n.clientX)/2,centerY:(t.clientY+n.clientY)/2}},r=e=>{2===e.touches.length&&(n={distance:i(e.touches).distance,zoom:s.current},d.current=!0)},a=e=>{if(!n||2!==e.touches.length)return;e.preventDefault();let{distance:t,centerX:r,centerY:a}=i(e.touches);n.distance>0&&m(n.zoom*(t/n.distance),r,a)},l=e=>{e.touches.length<2&&(n=null,d.current=!1)},o=e=>{d.current&&e.stopPropagation()};return t.addEventListener("wheel",e,{passive:!1}),t.addEventListener("touchstart",r,{passive:!0}),t.addEventListener("touchmove",a,{passive:!1}),t.addEventListener("touchend",l),t.addEventListener("touchcancel",l),t.addEventListener("pointermove",o,{capture:!0}),()=>{t.removeEventListener("wheel",e),t.removeEventListener("touchstart",r),t.removeEventListener("touchmove",a),t.removeEventListener("touchend",l),t.removeEventListener("touchcancel",l),t.removeEventListener("pointermove",o,{capture:!0})}},[t,m]);let g=(0,n.useCallback)(e=>{e&&1===s.current&&c(e.clientWidth)},[]),p=(0,n.useCallback)(()=>m(1.25*s.current),[m]),f=(0,n.useCallback)(()=>m(s.current/1.25),[m]),w=(0,n.useCallback)(()=>{s.current=1,u.current=null,o(1)},[]),x=1!==l&&h?{...e,width:h*l,height:"auto",maxWidth:"none",maxHeight:"none"}:e;return{containerRef:a,container:t,zoom:l,imageStyle:x,measureImage:g,zoomIn:p,zoomOut:f,reset:w}}(A);(0,n.useEffect)(()=>{T()},[e,T]),(0,n.useEffect)(()=>{if(!H)return;let e=new ResizeObserver(([e])=>L(e.contentRect.height));return e.observe(H),()=>e.disconnect()},[H]),(0,n.useEffect)(()=>{let e=H?.querySelector("img");X(e instanceof HTMLImageElement?e:null)},[H,A.maxHeight,O,X]);let[q,z]=(0,n.useState)({src:e,regions:[]}),K=q.src===e?q.regions:[],F=t=>z({src:e,regions:t}),W=(0,n.useRef)(null),G={single:k.batchImport.singleMode,auto:k.batchImport.autoMode,multi:k.batchImport.multiMode},Q=async()=>{if(0!==K.length){if(m){m(K,!0),F([]);return}if(W.current&&d)try{d(await s(W.current,K)),F([])}catch(e){w.V.error("[ImageCropper]","Multi-image crop failed",{error:e})}}},V=()=>E&&E.width>0&&E.height>0?{x:E.x/100,y:E.y/100,width:E.width/100,height:E.height/100}:{x:0,y:0,width:1,height:1},Z=async()=>{let e=V();if("auto"===N&&p)return void p(e);if(m)return void m([e],!1);if(R.current&&u)try{let[t]=await s(R.current,[e]);u(t)}catch(e){w.V.error("[ImageCropper]","Crop failed",{error:e})}};return(0,t.jsx)(a.N,{open:l,onOpenChange:e=>!e&&h(),children:(0,t.jsxs)(a.d,{className:"max-w-3xl h-[90vh] flex flex-col p-0 gap-0",children:[(0,t.jsx)(a.s,{className:"p-4 border-b shrink-0",children:(0,t.jsx)(a.F,{children:k.common.cropper?.title||"Crop Image"})}),(0,t.jsxs)("div",{className:"relative min-h-0 flex-1 bg-black",children:[(0,t.jsx)("div",{ref:_,className:"flex h-full w-full overflow-auto p-4",children:(0,t.jsx)("div",{className:"m-auto",children:"multi"===N?(0,t.jsx)(c,{ref:W,imageSrc:D,regions:K,onChange:F,imageStyle:U,onImageLoad:e=>X(e.currentTarget)}):(0,t.jsx)(i.f,{crop:E,onChange:(e,t)=>j(t),children:(0,t.jsx)("img",{ref:R,alt:"Crop me",src:D,onLoad:function(e){j({unit:"%",x:0,y:0,width:100,height:100}),X(e.currentTarget)},style:U})})})}),(0,t.jsx)("div",{className:"absolute right-3 top-3",children:(0,t.jsx)(f,{zoom:O,onZoomIn:Y,onZoomOut:B,onReset:T})})]}),(0,t.jsxs)("div",{className:"p-4 border-t bg-background shrink-0 space-y-3",children:[$.length>1&&(0,t.jsx)("div",{className:`grid gap-1 rounded-md bg-muted p-1 ${3===$.length?"grid-cols-3 sm:w-[28rem]":"grid-cols-2 sm:w-80"}`,children:$.map(e=>(0,t.jsx)("button",{type:"button","aria-pressed":N===e,onClick:()=>{T(),S(e)},className:`rounded px-2 py-1.5 text-sm font-medium transition-colors ${N===e?"bg-background shadow-sm":"text-muted-foreground"}`,children:G[e]},e))}),(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row sm:justify-between sm:items-center gap-3",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"multi"===N?`${k.batchImport.hint} ${k.batchImport.regionCount.replace("{count}",String(K.length))}`:"auto"===N?k.batchImport.autoHint:M>0?k.upload.parts.cropHint.replace("{n}",String(M+1)):k.common.cropper?.hint||"💡 Drag to adjust crop area"}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2 justify-end",children:["multi"===N&&K.length>0&&(0,t.jsx)(r.f,{variant:"ghost",onClick:()=>F([]),children:k.batchImport.clear}),(0,t.jsx)(r.f,{variant:"outline",onClick:h,children:k.common.cancel||"Cancel"}),"multi"===N?(0,t.jsx)(r.f,{onClick:Q,disabled:0===K.length,children:k.batchImport.start.replace("{count}",String(K.length))}):(0,t.jsxs)(t.Fragment,{children:["single"===N&&C&&(0,t.jsx)(r.f,{variant:"secondary",onClick:()=>C(V()),"data-testid":"crop-add-part",children:k.upload.parts.addNext}),(0,t.jsx)(r.f,{onClick:Z,children:"auto"===N?k.batchImport.autoStart:M>0?k.upload.parts.confirm.replace("{count}",String(M+1)):k.common.confirm||"Confirm"})]})]})]})]})]})})}],12130)},574041,e=>{var t=e.i(843476),n=e.i(271645),i=e.i(263676),r=e.i(487486),a=e.i(793479),l=e.i(41931),o=e.i(201276);e.s(["f",0,function({value:e=[],onChange:s,placeholder:h="Enter tags...",className:c="",enterHint:u,subject:d,gradeStage:m}){let[g,p]=(0,n.useState)(""),[f,w]=(0,n.useState)([]),[x,y]=(0,n.useState)(!1),[b,v]=(0,n.useState)(0),C=(0,n.useRef)(null),M=(0,n.useRef)(null),k=(0,n.useCallback)(async t=>{try{let n=new URLSearchParams({q:t});d&&n.append("subject",d),m&&n.append("stage",m);let i=((await l.k.get(`/api/tags/suggestions?${n.toString()}`)).suggestions||[]).filter(t=>!e.includes(t));w(i.slice(0,20)),y(i.length>0),v(0)}catch(e){o.V.error("[TagInput]","Failed to fetch suggestions",{error:e})}},[d,m,e]);(0,n.useEffect)(()=>{g.trim()&&k(g)},[g,k]);let D=t=>{t.trim()&&!e.includes(t.trim())&&(s([...e,t.trim()]),p(""),w([]),y(!1),v(0))},E=t=>{s(e.filter(e=>e!==t))};return(0,n.useEffect)(()=>{let e=e=>{!M.current||M.current.contains(e.target)||C.current?.contains(e.target)||y(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,t.jsxs)("div",{className:`relative ${c}`,children:[(0,t.jsxs)("div",{className:"flex flex-wrap gap-2 p-2 border rounded-lg bg-background min-h-[42px]",children:[e.map(e=>(0,t.jsxs)(r.f,{variant:"secondary",className:"flex items-center gap-1 px-2 py-1",children:[e,(0,t.jsx)("button",{type:"button",onClick:()=>E(e),className:"hover:text-destructive ml-1",children:(0,t.jsx)(i.X,{className:"h-3 w-3"})})]},e)),(0,t.jsx)(a.f,{ref:C,type:"text",value:g,onChange:e=>{p(e.target.value),e.target.value.trim()||(w([]),y(!1))},onKeyDown:t=>{"Enter"===t.key?(t.preventDefault(),b>=0&&f[b]?D(f[b]):g.trim()&&D(g)):"ArrowDown"===t.key?(t.preventDefault(),v(e=>Math.min(e+1,f.length-1))):"ArrowUp"===t.key?(t.preventDefault(),v(e=>Math.max(e-1,0))):"Escape"===t.key?(y(!1),v(0)):"Backspace"===t.key&&!g&&e.length>0&&E(e[e.length-1])},onFocus:()=>{f.length>0&&y(!0)},placeholder:0===e.length?h:"",className:"flex-1 min-w-[120px] border-none focus-visible:ring-0 focus-visible:ring-offset-0 h-8 px-0"})]}),x&&f.length>0&&(0,t.jsx)("div",{ref:M,className:"absolute z-50 w-full mt-1 bg-popover border rounded-md shadow-md max-h-48 overflow-y-auto",children:f.map((e,n)=>(0,t.jsx)("div",{className:`px-3 py-2 cursor-pointer hover:bg-accent ${n===b?"bg-accent":""}`,onClick:()=>D(e),onMouseEnter:()=>v(n),children:e},e))}),g&&!x&&(0,t.jsx)("div",{className:"text-xs text-muted-foreground mt-1",children:u?`${u} "${g}"`:`Press Enter to create "${g}"`})]})}])},804536,e=>{var t=e.i(271645);let n=new Map,i=new Set;function r(e){return i.add(e),window.addEventListener("storage",e),()=>{i.delete(e),window.removeEventListener("storage",e)}}function a(e,a,l){let o=(0,t.useSyncExternalStore)(r,()=>(function(e){if(n.has(e))return n.get(e)??null;try{return window.localStorage.getItem(e)}catch{return null}})(e),()=>null);return[(0,t.useMemo)(()=>a(o),[a,o]),(0,t.useCallback)(t=>(function(e,t){try{window.localStorage.setItem(e,t),n.delete(e)}catch{n.set(e,t)}i.forEach(e=>e())})(e,l(t)),[e,l])]}let l=e=>e;e.s(["y",0,function(e,n,i){return a(e,(0,t.useCallback)(e=>n.includes(e??"")?e:i,[n,i]),l)},"x",0,a])},213761,e=>{let t={maxLongEdge:4096,maxPixels:4915200,maxBytes:1572864,startQuality:.9,minQuality:.8};class n extends Error{code;format;constructor(e,t,n){super(e,void 0===n?void 0:{cause:n}),this.code=e,this.format=t,this.name="ImageDecodeError"}}let i=new Set(["heic","heix","heim","heis","hevc","hevx","hevm","hevs"]),r=new Set(["mif1","msf1","mif2"]),a=new Set(["avif","avis"]);function l(e,n,i=t){let r=Math.min(1,i.maxLongEdge/Math.max(e,n),Math.sqrt(i.maxPixels/Math.max(1,e*n)));return{width:Math.max(1,Math.floor(e*r)),height:Math.max(1,Math.floor(n*r)),scale:r}}async function o(e){let t,n;if("function"==typeof createImageBitmap)try{return await createImageBitmap(e,{imageOrientation:"from-image"})}catch{}let i=await (t=URL.createObjectURL(e),(n=new Image).decoding="async",new Promise((e,i)=>{n.onload=()=>e(n),n.onerror=()=>i(Error("IMAGE_ELEMENT_DECODE_FAILED")),n.src=t}).finally(()=>URL.revokeObjectURL(t)));if(!i.naturalWidth||!i.naturalHeight)throw Error("IMAGE_EMPTY");return i}async function s(t){let{heicTo:n}=await e.A(462684);return n({blob:t,type:"image/jpeg",quality:.95})}function h(e,t){return new Promise((n,i)=>{e.toBlob(e=>e?n(e):i(Error("CANVAS_EMPTY")),"image/jpeg",t)})}function c(e,t,n,i,r,a,l){let o,s=((o=document.createElement("canvas")).width=a,o.height=l,o),h=s.getContext("2d");if(!h)throw Error("CANVAS_UNSUPPORTED");return h.fillStyle="#ffffff",h.fillRect(0,0,a,l),h.imageSmoothingEnabled=!0,h.imageSmoothingQuality="high",h.drawImage(e,t,n,i,r,0,0,a,l),s}async function u(e,t){var u;let d,m=performance.now(),g=await e.arrayBuffer(),p=performance.now()-m,f=function(e){let t=(t,n)=>String.fromCharCode(...e.subarray(t,n));if(e.length>=3&&255===e[0]&&216===e[1]&&255===e[2])return"jpeg";if(e.length>=8&&137===e[0]&&"PNG"===t(1,4))return"png";if(e.length>=12&&"RIFF"===t(0,4)&&"WEBP"===t(8,12))return"webp";if(e.length>=6&&("GIF87a"===t(0,6)||"GIF89a"===t(0,6)))return"gif";if(e.length>=2&&"BM"===t(0,2))return"bmp";if(e.length>=12&&"ftyp"===t(4,8)){let n=Math.min(e.length,(e[0]<<24|e[1]<<16|e[2]<<8|e[3])>>>0||e.length),l=[t(8,12)];for(let e=16;e+4<=n;e+=4)l.push(t(e,e+4));if(l.some(e=>i.has(e)))return"heic";if(l.some(e=>a.has(e)))return"avif";if(l.some(e=>r.has(e)))return"heic"}return"unknown"}(new Uint8Array(g,0,Math.min(g.byteLength,64))),w=e.type||"",x=performance.now(),y="native",b=new Blob([g],{type:w||"application/octet-stream"});try{d=await o(b)}catch(e){if("heic"!==f)throw new n("unknown"===f?"UNSUPPORTED_IMAGE":"IMAGE_DECODE_FAILED",f,e);t?.();try{d=await o(await s(b)),y="heic"}catch(e){throw new n("HEIC_DECODE_FAILED",f,e)}}let{width:v,height:C}=(u=d)instanceof HTMLImageElement?{width:u.naturalWidth,height:u.naturalHeight}:{width:u.width,height:u.height};if(!v||!C)throw new n("IMAGE_DECODE_FAILED",f);let M=l(v,C,{maxLongEdge:1600,maxPixels:1/0}),k=await h(c(d,0,0,v,C,M.width,M.height),.85),D=URL.createObjectURL(k),E=performance.now()-x;return{source:d,width:v,height:C,format:f,decoder:y,previewUrl:D,sourceType:w,sourceBytes:e.size,timings:{read:Math.round(p),convert:Math.round(E)},dispose:()=>{URL.revokeObjectURL(D),d instanceof HTMLImageElement||d.close()}}}let d={x:0,y:0,width:1,height:1};async function m(e,n=d,i=t){var r;let a=performance.now(),o=e=>Math.min(1,Math.max(0,e)),s=Math.round(o(n.x)*e.width),u=Math.round(o(n.y)*e.height),g=Math.max(1,Math.min(e.width-s,Math.round(o(n.width)*e.width))),p=Math.max(1,Math.min(e.height-u,Math.round(o(n.height)*e.height))),f=l(g,p,i),w=c(e.source,s,u,g,p,f.width,f.height),x=performance.now()-a,y=performance.now(),b=i.startQuality,v=await h(w,b);for(let t=0;v.size>i.maxBytes&&t<12;t++)b-.05>=i.minQuality-1e-9?b=Math.round((b-.05)*100)/100:(f={width:Math.max(1,Math.floor(.85*f.width)),height:Math.max(1,Math.floor(.85*f.height)),scale:.85*f.scale},w=c(e.source,s,u,g,p,f.width,f.height)),v=await h(w,b);return{dataUrl:await (r=v,new Promise((e,t)=>{let n=new FileReader;n.onload=()=>e(n.result),n.onerror=()=>t(n.error??Error("READ_FAILED")),n.readAsDataURL(r)})),width:f.width,height:f.height,bytes:v.size,quality:b,timings:{crop:Math.round(x),compress:Math.round(performance.now()-y)}}}e.s(["K",0,t,"o",0,n,"N",0,function(e,t){return{sourceType:e.sourceType||e.format,sourceBytes:e.sourceBytes,sourceWidth:e.width,sourceHeight:e.height,outputWidth:t.width,outputHeight:t.height,outputBytes:t.bytes,decoder:e.decoder,quality:t.quality}},"p",0,u,"X",0,m])},499930,e=>{var t=e.i(213761);function n(e,t=.008){let i=Math.max(0,e.x-t),r=Math.max(0,e.y-t);return{x:i,y:r,width:Math.min(1,e.x+e.width+t)-i,height:Math.min(1,e.y+e.height+t)-r}}async function i(e){let t=new Image;if(t.decoding="async",t.src=e,await t.decode(),!t.naturalWidth||!t.naturalHeight)throw Error("IMAGE_EMPTY");return t}async function r(e,n){let i=function(e,t=16,n=!1){let i=Math.max(...e.map(e=>e.width)),r=0,a=e.map(e=>{let a=n?i/e.width:e.scale??1,l={x:0,y:r,width:Math.round(e.width*a),height:Math.round(e.height*a)};return r+=l.height+t,l});return{width:Math.max(...a.map(e=>e.width)),height:r-t,rects:a}}(e.map(e=>({width:e.sw,height:e.sh,scale:e.scale})),16,n),r=document.createElement("canvas");r.width=i.width,r.height=i.height;let a=r.getContext("2d");if(!a)throw Error("CANVAS_UNSUPPORTED");a.fillStyle="#ffffff",a.fillRect(0,0,r.width,r.height),e.forEach((e,t)=>{let n=i.rects[t];a.drawImage(e.source,e.sx,e.sy,e.sw,e.sh,n.x,n.y,n.width,n.height)});let l=await createImageBitmap(r);try{return await (0,t.X)({source:l,width:r.width,height:r.height})}finally{l.close()}}async function a(e,i){let a=e.naturalWidth,l=e.naturalHeight,o=i.map(e=>n(e));return 1===o.length?(0,t.X)({source:e,width:a,height:l},o[0]):r(o.map(t=>({source:e,sx:Math.round(t.x*a),sy:Math.round(t.y*l),sw:Math.max(1,Math.round(t.width*a)),sh:Math.max(1,Math.round(t.height*l))})),!1)}async function l(e){return r((await Promise.all(e.map(i))).map(e=>({source:e,sx:0,sy:0,sw:e.naturalWidth,sh:e.naturalHeight})),!0)}async function o(e,t,i){let a=e.naturalWidth,l=e.naturalHeight,o=i.width/a,s=t.map(e=>n(e)).map(t=>({source:e,sx:Math.round(t.x*a),sy:Math.round(t.y*l),sw:Math.max(1,Math.round(t.width*a)),sh:Math.max(1,Math.round(t.height*l)),scale:o}));return s.push({source:i.source,sx:0,sy:0,sw:i.width,sh:i.height}),r(s,!1)}e.s(["y",0,i,"k",0,o,"M",0,a,"v",0,l])},119472,e=>{var t=e.i(41931),n=e.i(127175);async function i(e){let t;for(let n=0;n<3;n++)try{return await e()}catch(e){if(t=e,!function(e){let t=e?.status;return void 0===t||408===t||502===t||503===t||504===t}(e)||2===n)break;await new Promise(e=>setTimeout(e,1e3*(n+1)))}throw t}async function r(e,a=(0,n.c)()){let{batch:l}=await i(()=>t.k.post("/api/import-batches",{...e,clientRequestId:a,subjectId:e.subjectId||void 0,targetSubjectId:e.targetSubjectId||void 0,paperLevel:e.paperLevel||void 0,items:e.items?.map(e=>({...e})),origin:e.origin},{timeout:12e4}));return(0,n.P)(),l}async function a(e,n={}){let i=n.image?"?include=image":"",{batch:r}=await t.k.get(`/api/import-batches/${encodeURIComponent(e)}${i}`);return r}async function l(e,n,i){let{batch:r}=await t.k.patch(`/api/import-batches/${encodeURIComponent(e)}`,{version:n,draft:i});return r}async function o(e,r,a,l){let{batch:o}=await i(()=>t.k.post(`/api/import-batches/${encodeURIComponent(e)}/start`,{version:r,images:a,analysis:l},{timeout:12e4}));return(0,n.P)(),o}async function s(e){let{batch:i}=await t.k.post(`/api/import-batches/${encodeURIComponent(e)}/retry`,{});return(0,n.P)(),i}async function h(e){let i=await t.k.post(`/api/import-batches/${encodeURIComponent(e)}/confirm-all`,{});return(0,n.P)(),i}async function c(e){await t.k.delete(`/api/import-batches/${encodeURIComponent(e)}`),(0,n.P)()}async function u(e){await t.k.post(`/api/import-batches/${encodeURIComponent(e)}/read`,{}),(0,n.P)()}async function d(e,n,i){return t.k.post(`/api/import-batches/${encodeURIComponent(e)}/fix-text`,{items:n},{timeout:6e5,recoverable:!0,requestId:i})}e.s(["J",0,h,"n",0,function(e){return e?.status===409?e.data?.details?.batch??null:null},"v",0,r,"o",0,c,"w",0,a,"$",0,d,"f",0,u,"s",0,s,"S",0,l,"g",0,o])},25197,e=>{var t=e.i(41931);function n(e){return e.trim()?e:""}async function i(){try{return!!(await t.k.get("/api/user")).confirmBeforeImport}catch{return!1}}async function r(e,i){let r=await t.k.post("/api/error-items",{questionText:e.questionText,answerText:n(e.answerText),analysis:n(e.analysis),wrongAnswerText:e.wrongAnswerText||null,mistakeAnalysis:e.mistakeAnalysis||null,mistakeStatus:e.mistakeStatus||"unknown",knowledgePoints:e.knowledgePoints||[],difficultyStars:e.difficultyStars??null,recognizedGradeSemester:e.gradeSemester??null,hasFigure:e.hasFigure??!1,figureSvg:e.figureSvg??null,questionType:e.questionType??null,subjectId:i.subjectId||void 0,subjectName:i.subjectId?void 0:e.subject,originalImageUrl:i.imageUrl||"",paperLevel:i.paperLevel||void 0});return{id:r.id,shortId:r.shortId??null,subjectId:r.subjectId??null,notebookName:r.subject?.name??null,duplicate:r.duplicate}}e.i(201276),e.s(["x",0,i,"a",0,r],25197)},825624,e=>{let t=/^[\s ]+/,n="一二三四五六七八九十",i=[{family:"dot",pattern:/^(\d{1,3})\s*(?:.|\.(?!\d))\s*/},{family:"comma",pattern:/^(\d{1,3})\s*[、,,](?!\d)\s*/},{family:"paren",pattern:/^(\d{1,3})\s*[))]\s*/},{family:"colon",pattern:/^(\d{1,3})\s*[::](?!\d)\s*/},{family:"ti",pattern:/^第\s*(\d{1,3}|[一二三四五六七八九十]{1,3})\s*题\s*[..、::]?\s*/},{family:"example",pattern:/^(?:例题?|练习|习题)\s*(\d{1,3})\s*[..、::]?\s*/},{family:"q",pattern:/^(?:Q|Question|Problem|Exercise)\s*(\d{1,3})\s*[..::)]?\s+/i},{family:"cn",pattern:/^([一二三四五六七八九十]{1,3})\s*[、..]\s*/}];function r(e){let r=e.replace(t,"");for(let{family:e,pattern:t}of i){let i=r.match(t);if(!i||r.length<=i[0].length)continue;let a=function(e){if(/^\d+$/.test(e))return Number(e);if("十"===e)return 10;let t=e.indexOf("十");return -1===t?n.indexOf(e)+1:10*(0===t?1:n.indexOf(e[0])+1)+(t===e.length-1?0:n.indexOf(e[t+1])+1)}(i[1]);if(Number.isFinite(a)&&!(a<=0))return{value:a,family:e,prefixLength:i[0].length,label:i[1]}}return null}function a(e){let n=e.split("\n"),i=n[0]?.replace(t,"")??"",a=r(i);return a&&"cn"!==a.family&&(n[0]=i.slice(a.prefixLength)),n.join("\n")}function l(e){let t=[];for(let n of e)(n||0!==t.length&&""!==t[t.length-1])&&t.push(n);for(;t.length>0&&""===t[t.length-1];)t.pop();return t.join("\n")}let o=/(姓名|班级|学号|日期|得分|分数|评分|考号|座位号|家长签字|用时|Name\s*[::_]|Class\s*[::_]|Date\s*[::_]|Score\s*[::_])|_{3,}|共\s*\d+\s*(道|题|小题)|做完|答案(见|在)|最后一页|满分\s*\d+\s*分/i,s=/(阅读|材料|短文|文章|选文|诗歌|古诗|文言文|下[面列]的?(表格|图表|统计|信息)|根据.{0,20}(回答|完成)|passage|read the|according to the)/i,h=/^(参考答案|答案与解析|答案|Answers?|Answer Key)\s*[::]?$/i,c=/^(第[一二三四五六七八九十]+(部分|大题|节)|(Part|Section)\s+[A-Z0-9IVX]+\b)/i,u=/(选择|填空|判断|计算|解答|应用|解决问题|操作|作图|阅读|写作|作文|综合|口算|听力|单项|完形|题)/,d=/(\d{1,3})\s*[~~\-—–至到]\s*(\d{1,3})\s*(?:小?题|questions?)/i,m=/(小问|小题|下列问题|以下问题|下列各题|下面各题|完成下列|回答下列|回答以下|following questions|answer the following)/i;function g(e){let t=[],n=[];for(let i of e)i?n.push(i):n.length&&(t.push(n.join("\n")),n=[]);return n.length&&t.push(n.join("\n")),t}function p(e,t=[]){let n=e.trim();return!(!n||n.length>12||/[。!?!?,,、;;::..()()【】\[\]{}]$/.test(n)||/\d/.test(n)||/[。!?!?;;,,]/.test(n))&&!!(/(篇|章|节|部分|组)$/.test(n)||/^(Part|Section)\s+[A-Z0-9]+$/i.test(n))&&(!t.length||t.some(e=>{let t=r(e);return null!==t&&1===t.value}))}function f(e,t){let n=[];for(let i=0;i<e.length;i++){let r=e[i],a=[r];for(let n=i+1;n<e.length;n++){let i=e[n],l=a[a.length-1];if(i.family!==r.family)continue;let o=1===i.value&&[...t].some(e=>e>l.line&&e<i.line);(i.value===l.value+1||o)&&a.push(i)}a.length>n.length&&(n=a)}return n}function w(e,t,n){return!!c.test(e)||!!t&&"cn"===t.family&&"cn"!==n&&null!==n&&(e.length<=40||u.test(e.slice(0,20)))}function x(e,t,n,i,r){for(let a=e-1;a>=0;a--)if(t[a]){if(r.has(a)||w(t[a],n[a],i)||p(t[a]))return t[a];break}return null}function y(e){let t=e.match(d);if(!t)return null;let n=Number(t[1]),i=Number(t[2]);return n<=i?{from:n,to:i}:null}let b={answer:/^(?:【\s*(?:参考答案|答案)\s*】|(?:参考答案|答案)\s*[::]|Answer\s*[::])\s*(.*)$/i,analysis:/^(?:【\s*(?:解析|分析|详解|解答|点评)\s*】|(?:解析|分析|详解|解答|点评)\s*[::])\s*(.*)$/,knowledge:/^(?:【\s*(?:知识点|考点)\s*】|(?:知识点|考点)\s*[::])\s*(.*)$/,difficulty:/^(?:【\s*难度\s*】|难度\s*[::])\s*(.*)$/,questionType:/^(?:【\s*题型\s*】|题型\s*[::])\s*(.*)$/,wrongAnswer:/^(?:【\s*错答\s*】|我的答案\s*[::]|学生答案\s*[::])\s*(.*)$/},v={易:1,较易:2,中等:3,较难:4,难:5};function C(e){return e.split(/[、,,;;]/).map(e=>e.trim()).filter(Boolean)}function M(e){let t={answer:[],analysis:[],knowledge:[],difficulty:[],questionType:[],wrongAnswer:[]},n=[],i=null;for(let r of e){let e=null;for(let n of Object.keys(b)){let a=r.match(b[n]);if(!a)continue;e=n,i=n;let l=a[1].trim();l&&t[n].push(l);break}e||(i&&r.trim()?t[i].push(r.trim()):n.push(r))}let r={},a=t.answer.join("\n").trim();a&&(r.answer=a);let o=t.analysis.join("\n").trim();o&&(r.analysis=o);let s=t.knowledge.flatMap(C);s.length&&(r.knowledgePoints=s);let h=t.difficulty.join(" ").trim(),c=h?function(e){let t=e.trim();if(!t)return null;let n=t.match(/^(\d{1,2})\s*(?:星|级)?$/);if(n){let e=Number(n[1]);return e>=1&&e<=5?e:null}if(/^[★☆]{1,5}$/.test(t)){let e=(t.match(/★/g)??[]).length;return e>=1?e:null}return t in v?v[t]:null}(h):null;null!==c&&(r.difficultyStars=c);let u=t.questionType.join(" ").trim();u&&(r.questionType=u);let d=t.wrongAnswer.join("\n").trim();return d&&(r.wrongAnswer=d),{text:l(n),fields:r}}let k=/^(\d{1,3})\s*[..、,,)]\s*(\S[\s\S]*)$/,D=/^(\d{1,3})\s*[~~—–-]\s*(\d{1,3})\s*[::..、]?\s*([A-Za-z]+)$/;function E(e){let t=e.trim();if(!t)return null;let n=function(e){let t=e.trim().match(D);if(!t)return null;let n=Number(t[1]),i=Number(t[2]),r=t[3];if(!Number.isFinite(n)||!Number.isFinite(i)||n<=0||i<=n||i-n+1>60)return null;let a=i-n+1;return r.length!==a?null:Array.from({length:a},(e,t)=>({label:String(n+t),text:r[t]}))}(t);if(n)return n;let i=function(e){let t=e.trim(),n=[];for(let e of t.matchAll(/(\d{1,3})\s*[..、,,;;]\s*/g)){let i=e.index??0,r=t[i+e[0].length];r&&/\d/.test(r)||n.push({index:i,label:e[1],afterIndex:i+e[0].length})}if(n.length<2)return null;for(let e=1;e<n.length;e++)if(Number(n[e].label)<=Number(n[e-1].label))return null;let i=[];for(let e=0;e<n.length;e++){let r=n[e].afterIndex,a=e+1<n.length?n[e+1].index:t.length,l=t.slice(r,a).trim().replace(/[;;]+$/,"").trim();if(!l||l.length>30||/[。!?!?]/.test(l))return null;i.push({label:n[e].label,text:l})}return i}(t);if(i)return i.map(e=>({label:e.label??"",text:e.text})).filter(e=>e.label);let r=t.match(k);if(!r)return null;let a=Number(r[1]);return!Number.isFinite(a)||a<=0?null:[{label:r[1],text:r[2].trim()}]}function j(e){let t=e.match(/^(.*?)(?:【?\s*(?:解析|分析|详解|解答|点评)\s*】?\s*[::])([\s\S]*)$/);if(t){let n=t[1].replace(/^(?:【?\s*(?:参考答案|答案)\s*】?\s*[::])\s*/,"").trim(),i=t[2].trim();return i?{answer:n,analysis:i}:{answer:e.trim()}}return{answer:e.replace(/^(?:【?\s*(?:参考答案|答案)\s*】?\s*[::])\s*/,"").trim()||e.trim()}}function R(e,t){let n=[],i=!1;for(let r of e){let e={value:!1},a=[];for(let n of r.split("\n")){let i=n.trim()?E(n):null;if(!i){n.trim()&&a.push(n);continue}let r=!1;for(let l of i){let i=t.find(e=>e.label===l.label);if(!i){a.push(n);break}r=!0,e.value=!0;let o=j(l.text);o.answer&&!i.answer&&(i.answer=o.answer),o.analysis&&(i.analysis=i.analysis?`${i.analysis}
|
|
2
|
+
${o.analysis}`:o.analysis)}!r&&!a.includes(n)&&n.trim()&&!a.includes(n)&&a.push(n)}i=i||e.value,e.value?a.length&&n.push(a.join("\n")):n.push(r)}return[n,i]}e.s(["k",0,2e3,"f",0,1e6,"S",0,60,"i",0,2e4,"J",0,function(e,n={}){let i,u,b=void 0===n.maxLength?2e4:Math.min(Math.max(n.maxLength,1e3),1e6),v=void 0===n.maxQuestions?60:Math.min(Math.max(n.maxQuestions,2),2e3),C=e.length>b,k=e.slice(0,b).replace(/\r\n?/g,"\n").split("\n").map(e=>e.replace(t,"").replace(/[\s ]+$/,"")),D=k.map(e=>e?r(e):null),I=k.length;for(let e=0;e<k.length;e++)if(h.test(k[e])){I=e;break}let S=[],$=[];for(let e=0;e<I;e++){let t=D[e];t&&("cn"===t.family?$:S).push({...t,line:e})}let N=new Set;for(let e=0;e<I;e++)(c.test(k[e])||D[e]?.family==="cn"||p(k[e],k.slice(e+1,e+5)))&&N.add(e);let P=[],L=f(S,N);if(L.length<2){let e=f($,new Set);e.length>=2&&(P=[{chain:e,sectionHeading:null}])}else P=function(e,t,n,i){if(e.length<2)return[];let r=e[0].family,a=[0];for(let t=1;t<e.length;t++)1===e[t].value&&a.push(t);if(a.length<2){let a=x(e[0].line,t,n,r,i);return null!==a?[{chain:e,sectionHeading:a}]:[]}let l=[];for(let o=0;o<a.length;o++){let s=a[o],h=o+1<a.length?a[o+1]:e.length,c=e.slice(s,h),u=0===o?x(e[0].line,t,n,r,i):function(e,t,n,i,r,a){for(let l=e+1;l<t;l++)if(n[l]&&(a.has(l)||w(n[l],i[l],r)||p(n[l])))return n[l];return null}(e[s-1].line,e[s].line,t,n,r,i);if(null===u&&o>0){l[l.length-1].chain.push(...c);continue}l.push({chain:c,sectionHeading:u})}return l.filter(e=>e.chain.length>0)}(L,k,D,N);let A=P.length?P.flatMap(e=>e.chain):L,_=l(k.slice(0,I)),H=I<k.length?g(k.slice(I)):[],O=(u=r(k[A[0]?.line??0]??""))?u.label:null,U=e=>({questions:_?[{label:O,text:_,material:null,section:null,lineRange:{from:0,to:I}}]:[],ignored:H,detected:!1,ambiguous:e,candidateCount:e?A.length:+!!_,overflow:0,tooLong:C});if(A.length<2){if(!_)return U(!1);let e=M(_.split("\n")),t=U(!1);if(t.questions.length>0&&Object.keys(e.fields).length>0&&(t.questions[0]={...t.questions[0],text:a(e.text),...e.fields}),t.questions.length>0&&H.length){let[e,n]=R(H,t.questions);t.ignored=e,n||(t.ignored=H)}return t}let X=A[0].family;if(!n.forceNumbered&&function(e,t,n,i){let r=null;for(let a=t-1;a>=0;a--)if(e[a]){r=w(e[a],i[a],n)?null:e[a];break}return!(!r||o.test(r)||d.test(r))&&("paren"===n?r.length>=15||/[。?!?!::,,;;]$/.test(r):/[::]$/.test(r)&&m.test(r))}(k,A[0].line,X,D)){let e=U(!0);if(e.questions.length>0&&_){let t=M(_.split("\n"));Object.keys(t.fields).length>0&&(e.questions[0]={...e.questions[0],text:a(t.text),...t.fields})}return e}let Y=new Set(A.map(e=>e.line)),B=[],T=[],q=null,z=[],K=[],F=(e,t)=>{for(let n of g(e))(!o.test(n)||!(n.length<80))&&(s.test(n)||n.length>=80&&/[。!?.!?;;]/.test(n))?z.push({text:n,range:y(n)}):t?B.push(n):q&&!T.some(e=>e.section===q)?q=`${q}
|
|
3
|
+
${n}`:B.push(n)},W=A[0].line,G=[];for(let e=0;e<W;e++)k[e]&&(w(k[e],D[e],X)||p(k[e],k.slice(e+1,e+5)))?(F(G.splice(0),!0),q=k[e],K=[]):G.push(k[e]);F(G,!0);let Q=P.length>1,V=e=>{if(!Q)return -1;let t=0;for(let n=0;n<P.length;n++)if(e<(t+=P[n].chain.length))return n;return P.length-1};for(let e=0;e<A.length;e++){let t=A[e].line,n=e+1<A.length?A[e+1].line:I,i=V(e);if(Q&&i>=0){let e=P[i].sectionHeading;null!==e&&(q=e,K=[])}z.length&&(K=[...K.filter(e=>e.range),...z],z=[]);let r=n,o=null;for(let e=t+1;e<n;e++)if(k[e]&&!Y.has(e)&&w(k[e],D[e],X)){r=e,o=k[e];break}let h=k.slice(t,r),c=g(h),u=[];for(;c.length>1&&s.test(c[c.length-1].slice(0,30));)u.unshift(c.pop());let d=u.length?c.join("\n"):l(h),m=A[e].value,p=K.filter(e=>!e.range||m>=e.range.from&&m<=e.range.to),f=M(a(d).split("\n"));for(let i of(T.push({label:A[e].label,text:f.text,material:p.length?p.map(e=>e.text).join("\n\n"):null,section:q,lineRange:{from:t,to:n},...f.fields}),u))z.push({text:i,range:y(i)});null!==o&&(q=o,K=[],F(k.slice(r+1,n),!1))}if(Q&&H.length){let e=P.map(e=>e.sectionHeading).filter(e=>null!==e),t=H.join("\n");i=e.some(e=>t.includes(e))?function(e,t,n){let i=[],r=0,a=t.map(e=>{let t=n.slice(r,r+e.chain.length);return r+=e.chain.length,t}),l=-1;for(let r of e){let e=r.split("\n"),o=[],s=!1;for(let i of e){let e=i.trim();if(!e){o.push(i);continue}let r=t.findIndex(t=>t.sectionHeading&&e.includes(t.sectionHeading));if(r>=0){l=r;continue}let h=E(e);if(!h){o.push(i);continue}let c=l>=0?a[l]:n,u=!1;for(let e of h){let t=c.find(t=>t.label===e.label);if(!t){o.push(i);break}u=!0,s=!0;let n=j(e.text);n.answer&&!t.answer&&(t.answer=n.answer),n.analysis&&(t.analysis=t.analysis?`${t.analysis}
|
|
4
|
+
${n.analysis}`:n.analysis)}u||o.includes(i)||o.push(i)}s?o.length&&i.push(o.join("\n")):i.push(r)}return i}(H,P,T):H}else i=R(H,T)[0];let Z=T.slice(v);return{questions:T.slice(0,v),ignored:[...B,...i,...Z.map(e=>{var t;let n,i,r,a;return n=(t=e).text.trim(),r=(i=t.material?.trim())?`${i}
|
|
5
|
+
|
|
6
|
+
${n}`:n,a=[],(t.answer?.trim()&&a.push(`参考答案:${t.answer.trim()}`),t.analysis?.trim()&&a.push(`参考解析:${t.analysis.trim()}`),t.wrongAnswer?.trim()&&a.push(`学生作答:${t.wrongAnswer.trim()}`),a.length)?`${r}
|
|
7
|
+
|
|
8
|
+
${a.join("\n\n")}`:r})],detected:!0,ambiguous:!1,candidateCount:T.length,overflow:Z.length,tooLong:C}}])}])})();
|