PageSourceSearch

https://cuflow.ai/_next/static/chunks/1882.6b675482627a1fea.js

js cuflow.ai collected 2026-10-05 11:58:43 UTC 231,454 bytes, 3 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1882],{35407:(e,t,r)=>{"use strict";r.r(t),r.d(t,{StartGeneration:()=>O});var n=r(95155),a=r(12115),s=r(79114),i=r(47650),l=r(9395);let o=(e,t)=>{let r={},n=!1;t.forEach(t=>{let a="number"==typeof t.pageSize&&t.pageSize>0,s=e[t.id];if(s){let e=a?s:{...s,ranges:[]};!a&&s.ranges.length>0&&(n=!0),r[t.id]=e;return}n=!0,r[t.id]={selected:!0,ranges:a?[{id:`${t.id}-0`,from:1,to:t.pageSize}]:[]}});let a=Object.keys(e).map(Number),s=new Set(t.map(e=>e.id));return a.some(e=>!s.has(e))&&(n=!0),n?r:e},c=({documentList:e,sourceRanges:t,setSourceRanges:r})=>{let{t:i}=(0,s.Bd)(),[l,o]=a.useState({}),c=(e,t,r)=>`${e}-${t}-${r}`,d=(e,t,n,a,s)=>{let i=Number(a);r(r=>{let a=[...r[e]?.ranges||[]];if(!a[t])return r;if("from"===n){let e=a[t].to,r=Math.max(1,Math.min(Number.isFinite(i)?i:a[t].from,s));a[t]={...a[t],from:r,to:Math.max(r,Math.min(e,s))}}else{let e=Math.max(a[t].from,Math.min(Number.isFinite(i)?i:a[t].to,s));a[t]={...a[t],to:e}}return{...r,[e]:{selected:r[e]?.selected??!0,ranges:a}}})};return(0,n.jsxs)("div",{className:"mt-1 bg-white",children:[(0,n.jsxs)("div",{className:"grid grid-cols-[1fr_auto] gap-4 text-[16px] font-bold text-gray-900",children:[(0,n.jsx)("span",{children:i("config.customizeSummary.sourcesRange")}),(0,n.jsx)("span",{className:"pr-10 text-[16px]",children:i("config.customizeSummary.pageRange")})]}),(0,n.jsx)("div",{className:"divide-y divide-gray-100",children:e.map(e=>{let a,s=t[e.id],u="number"==typeof e.pageSize&&e.pageSize>0,m=u?e.pageSize:1,f=s?.ranges||[];return(0,n.jsx)("div",{className:"py-4",children:(0,n.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,n.jsxs)("label",{className:"flex items-center gap-3 text-sm text-gray-900 min-w-0 cursor-pointer",children:[(0,n.jsx)("input",{type:"checkbox",className:"peer sr-only",checked:s?.selected??!1,onChange:t=>{let n=t.target.checked;r(t=>({...t,[e.id]:{selected:n,ranges:t[e.id]?.ranges||(u?[{id:`${e.id}-0`,from:1,to:m}]:[])}}))}}),(0,n.jsx)("span",{className:`inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-sm border transition-colors ${s?.selected?"border-primary bg-primary":"border-gray-300 bg-white"}`,children:s?.selected&&(0,n.jsx)("svg",{className:"h-3 w-3 text-white",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:(0,n.jsx)("path",{d:"M4 10l4 4 8-8",strokeLinecap:"round",strokeLinejoin:"round"})})}),(0,n.jsx)("img",{src:"pdf"===(a=(e.documentType||"").toLowerCase())?"/cdn/common/doc/pdf.svg":"doc"===a||"docx"===a?"/cdn/common/doc/doc.svg":"ppt"===a||"pptx"===a?"/cdn/common/doc/powerpoint.svg":["jpg","jpeg","png","gif","webp","bmp","svg"].includes(a)?"/cdn/common/doc/image.svg":"/cdn/common/doc/doc.svg",alt:"",className:"h-[16px] w-[16px] rounded-md"}),(0,n.jsx)("span",{className:"line-clamp-1 max-w-[320px]",children:e.documentName})]}),(0,n.jsxs)("div",{className:"flex flex-col items-end gap-2",children:[!u&&(0,n.jsx)("span",{className:"text-xs text-gray-400",children:i("config.customizeSummary.selectDocOnly","Only source selection is available")}),u&&f.map((t,a)=>{let s,i,u,f;return(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(s=c(e.id,t.id,"from"),i=c(e.id,t.id,"to"),u=l[s]??String(t.from),f=l[i]??String(t.to),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",className:"range-input w-[32px] h-[32px] rounded-md border border-gray-200 bg-gray-50 p-0 text-center text-xs text-gray-700 [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",value:u,min:1,max:m,onFocus:e=>{e.currentTarget.select()},onChange:e=>{let t=e.target.value.replace(/\D/g,"");o(e=>({...e,[s]:t}))},onBlur:()=>{let t=l[s]??"";d(e.id,a,"from",t,m),o(e=>{let t={...e};return delete t[s],t})},onKeyDown:e=>{"Enter"===e.key&&e.currentTarget.blur()}}),(0,n.jsx)("span",{className:"text-sm text-gray-500",children:"to"}),(0,n.jsx)("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",className:"range-input w-[32px] h-[32px] rounded-md border border-gray-200 bg-gray-50 p-0 text-center text-xs text-gray-700 [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",value:f,min:t.from,max:m,onFocus:e=>{e.currentTarget.select()},onChange:e=>{let t=e.target.value.replace(/\D/g,"");o(e=>({...e,[i]:t}))},onBlur:()=>{let t=l[i]??"";d(e.id,a,"to",t,m),o(e=>{let t={...e};return delete t[i],t})},onKeyDown:e=>{"Enter"===e.key&&e.currentTarget.blur()}})]})),0===a?(0,n.jsx)("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-gray-400 hover:bg-gray-100 hover:text-gray-700",onClick:()=>{r(t=>{let r=[...t[e.id]?.ranges||[]];return r.push({id:`${e.id}-${Date.now()}`,from:1,to:m}
1),{...t,[e.id]:{selected:t[e.id]?.selected??!0,ranges:r}}})},children:(0,n.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 5v14M5 12h14"})})}):(0,n.jsx)("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-gray-400 hover:bg-gray-100 hover:text-red-500",onClick:()=>{r(t=>{let r=(t[e.id]?.ranges||[]).filter((e,t)=>t!==a);return{...t,[e.id]:{selected:t[e.id]?.selected??!0,ranges:r}}})},children:(0,n.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]},t.id)})]})]})},e.id)})})]})};var d=r(58187),u=r(30596),m=r(28604);let f=({isOpen:e,onClose:t,onStartGeneration:r,onTranslate:f,initialSummaryType:g="extended",initialCustomPrompt:p="",initialOutputLanguage:x="en",initialModel:h=d.e.LITE,initialDocumentConfig:b=[],confirmButtonLabel:y})=>{let{t:v}=(0,s.Bd)(),w=(0,m.bh)(e=>e.projectDetail?.data?.isFeatured),{model:{modalRef:j,modelMenuRef:N,languageMenuRef:C,documentList:S,sourceRanges:k,selectedSummaryType:z,customPrompt:_,showAdvancedSettings:M,selectedModel:L,outputLanguage:E,isLanguageMenuOpen:T,showCustomPrompt:A,isPromptContentValid:I,summaryOptions:F,languageOptions:D},actions:{setCustomPrompt:P,setShowAdvancedSettings:O,setSelectedModel:R,setOutputLanguage:$,setIsLanguageMenuOpen:V,setIsPromptContentValid:B,setSourceRanges:q,handleSummaryTypeChange:G,handleStartGeneration:H}}=function({isOpen:e,onClose:t,onStartGeneration:r,initialSummaryType:n,initialCustomPrompt:i,initialOutputLanguage:l,initialModel:c,initialDocumentConfig:u}){let{t:f}=(0,s.Bd)(),[g,p]=(0,a.useState)(n),[x,h]=(0,a.useState)(i),[b,y]=(0,a.useState)(!1),[v,w]=(0,a.useState)(d.e.LITE),[j,N]=(0,a.useState)("en"),[C,S]=(0,a.useState)(!1),[k,z]=(0,a.useState)(!1),[_,M]=(0,a.useState)(!1),[L,E]=(0,a.useState)(!0),T=(0,a.useRef)(null),A=(0,a.useRef)(null),I=(0,a.useRef)(null),F=(0,m.bh)(e=>e.projectDetail?.data?.documentList),D=(0,a.useMemo)(()=>F??[],[F]),[P,O]=(0,a.useState)({});(0,a.useEffect)(()=>{p(n),h(i),M("custom"===n||!!i)},[n,i]),(0,a.useEffect)(()=>{let e;N((e=String(l||"").trim().toLowerCase())?"zh"===e||"cn"===e||"zh-cn"===e||"zh-hans"===e||e.includes("chinese")?"zh-Hans":"zh-tw"===e||"zh-hant"===e?"zh-Hant":l||"en":"en")},[l]),(0,a.useEffect)(()=>{w(c)},[c]),(0,a.useEffect)(()=>{O(e=>o(e,D))},[D]),(0,a.useEffect)(()=>{if(!e||!Array.isArray(u)||0===u.length)return;let t=new Map;u.forEach(e=>{let r=Number(e?.docId);if(!Number.isFinite(r))return;let n=Array.isArray(e?.rangeList)?e.rangeList:[];t.set(r,n)}),O(e=>{let r={...o(e,D)};return D.forEach(e=>{let n="number"==typeof e.pageSize&&e.pageSize>0,a=n?e.pageSize:1,s=t.get(e.id);if(!s){r[e.id]={...r[e.id]||{ranges:[]},selected:!1,ranges:n?r[e.id]?.ranges||[{id:`${e.id}-0`,from:1,to:a}]:[]};return}let i=s.map((t,r)=>{let n=0===Number(t?.start)&&0===Number(t?.end),s=n?1:Math.max(1,Math.min(Number(t?.start)||1,a)),i=n?a:Math.max(s,Math.min(Number(t?.end)||s,a));return{id:`${e.id}-${r}`,from:s,to:i}}).filter(e=>e.to>=e.from);r[e.id]={selected:!0,ranges:n?i.length>0?i:[{id:`${e.id}-0`,from:1,to:a}]:[]}}),r})},[e,u,D]);let R=(0,a.useMemo)(()=>[{id:"extended",title:f("config.customizeSummary.options.extendedSummary.title"),description:f("config.customizeSummary.options.extendedSummary.description"),isSelected:"extended"===g},{id:"summarized",title:f("config.customizeSummary.options.shortSummary.title"),description:f("config.customizeSummary.options.shortSummary.description"),isSelected:"summarized"===g},{id:"custom",title:f("config.customizeSummary.options.addCustomPrompt.title"),description:f("config.customizeSummary.options.addCustomPrompt.description"),isSelected:"custom"===g}],[f,g]),$=(0,a.useMemo)(()=>[{value:"en",label:"English"},{value:"zh-Hans",label:"简体中文"},{value:"zh-Hant",label:"繁體中文"},{value:"de",label:"Deutsch"},{value:"es",label:"Espa\xf1ol"},{value:"fr",label:"Fran\xe7ais"},{value:"ja",label:"日本語"},{value:"ko",label:"한국어"},{value:"it",label:"Italiano"},{value:"ru",label:"Русский"},{value:"nl",label:"Nederlands"}],[]);return(0,a.useEffect)(()=>{let r=e=>{let r=e.target;!T.current||T.current.contains(r)||r instanceof Element&&r.closest("[data-radix-popper-content-wrapper]")||t()};return e&&(document.addEventListener("mousedown",r),document.body.style.overflow="hidden"),()=>{document.removeEventListener("mousedown",r),document.body.style.overflow="unset"}},[e,t]),(0,a.useEffect)(()=>
1{if(!C)return;let e=e=>{A.current&&(A.current.contains(e.target)||S(!1))};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[C]),(0,a.useEffect)(()=>{if(!k)return;let e=e=>{I.current&&(I.current.contains(e.target)||z(!1))};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[k]),(0,a.useEffect)(()=>{let r=e=>{"Escape"===e.key&&t()};return e&&document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[e,t]),{model:{modalRef:T,modelMenuRef:A,languageMenuRef:I,documentList:D,sourceRanges:P,selectedSummaryType:g,customPrompt:x,showAdvancedSettings:b,selectedModel:v,outputLanguage:j,isModelMenuOpen:C,isLanguageMenuOpen:k,showCustomPrompt:_,isPromptContentValid:L,summaryOptions:R,languageOptions:$},actions:{setCustomPrompt:h,setShowAdvancedSettings:y,setSelectedModel:w,setOutputLanguage:N,setIsModelMenuOpen:S,setIsLanguageMenuOpen:z,setIsPromptContentValid:E,setSourceRanges:O,handleSummaryTypeChange:e=>{p(e),M("custom"===e)},handleStartGeneration:()=>{("custom"!==g||L)&&r({summaryType:g,customPrompt:"custom"===g?x:"",model:v,advancedSettings:{sources:D.map(e=>({documentId:e.id,documentName:e.documentName,selected:P[e.id]?.selected??!1,ranges:P[e.id]?.ranges.map(e=>({from:e.from,to:e.to}))||[]})),language:j}})}}}}({isOpen:e,onClose:t,onStartGeneration:r,initialSummaryType:g,initialCustomPrompt:p,initialOutputLanguage:x,initialModel:h,initialDocumentConfig:b});return e?(0,i.createPortal)((0,n.jsx)("div",{className:"fixed inset-0 flex items-center justify-center backdrop-blur-[5px] bg-white/50 pointer-events-auto",style:{zIndex:70},children:(0,n.jsxs)("div",{ref:j,className:"relative w-full max-w-[760px] bg-white rounded-xl border border-gray-200 shadow-[0px_0px_16px_0px_rgba(15,23,42,0.16)]",role:"dialog","aria-modal":"true","aria-labelledby":"customize-summary-title",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-6 py-4",children:[(0,n.jsx)("h2",{id:"customize-summary-title",className:"text-[18px] leading-none font-semibold text-gray-900",children:`${v("config.startGeneration.setting")} ${v("config.contentVersionPanel.tools.summary")}`}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[f&&(0,n.jsx)("button",{onClick:f,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-md transition-colors","aria-label":v("config.customizeSummary.translateSummary"),children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 5h12M9 3v2m1.048 9.5A18.022 18.022 0 016.412 9m6.088 9h7M11 21l5-10 5 10M12.751 5C11.783 10.77 8.07 15.61 3 18.129"})})}),(0,n.jsx)("button",{onClick:t,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-md transition-colors","aria-label":v("config.customizeSummary.closeModal"),children:(0,n.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,n.jsxs)("div",{className:"max-h-[64vh] overflow-y-auto px-6 pt-1",children:[(0,n.jsx)("div",{className:"space-y-2",children:F.map(e=>(0,n.jsxs)("button",{onClick:()=>G(e.id),className:`w-full flex items-start gap-3 px-4 py-3 rounded-md border transition-colors hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-gray-900 focus:ring-offset-2 ${e.isSelected?"border-primary bg-slate-50 shadow-sm":"border-border bg-white"}`,role:"radio","aria-checked":e.isSelected,children:[(0,n.jsx)("div",{className:"flex-shrink-0 mt-3",children:(0,n.jsx)("div",{className:`h-[16px] w-[16px] rounded-full border-2 bg-white flex items-center justify-center ${(e.isSelected,"border-gray-300")}`,children:e.isSelected&&(0,n.jsx)("div",{className:"h-2 w-2 rounded-full bg-primary"})})}),(0,n.jsxs)("div",{className:"flex-1 text-left",children:[(0,n.jsx)("div",{className:"text-[14px] font-semibold text-gray-900",children:e.title}),e.description&&(0,n.jsx)("div",{className:"text-xs text-gray-400 mt-1",children:e.description})]})]},e.id))}),A&&(0,n.jsxs)("div",{className:"mt-4",children:[(0,n.jsx)("label",{htmlFor:"custom-prompt",className:"block text-sm font-medium text-gray-700 mb-2",children:v("config.customizeSummary.customPrompt.label")}
1),(0,n.jsx)(l.W,{id:"custom-prompt",value:_,onChange:P,placeholder:v("config.customizeSummary.customPrompt.placeholder"),maxWords:150,height:"h-[152px]",textareaClassName:"w-full h-32 p-3 text-sm resize-none",wrapperClassName:"mt-0",onValidationChange:B})]}),(0,n.jsxs)("div",{className:"mt-4",children:[(0,n.jsx)("div",{className:"mb-2 text-[16px] font-semibold text-gray-900",children:v("config.customizeSummary.outputLanguage")}),(0,n.jsxs)("div",{className:"relative",ref:C,children:[(0,n.jsxs)("button",{type:"button",onClick:()=>V(e=>!e),className:"flex h-12 w-full items-center justify-between rounded-md border border-border bg-white px-4 text-sm text-gray-800 hover:border-gray-300 focus:outline-none focus:ring-2 focus:ring-gray-900/10",children:[(0,n.jsx)("span",{children:D.find(e=>e.value===E)?.label||"English"}),(0,n.jsx)("svg",{className:`h-5 w-5 text-gray-400 transition-transform ${T?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),T&&(0,n.jsx)("div",{className:"absolute left-0 right-0 top-14 z-20 max-h-56 overflow-y-auto rounded-md border border-border bg-white p-1 shadow-[0_12px_28px_rgba(15,23,42,0.12)]",children:D.map(e=>{let t=e.value===E;return(0,n.jsxs)("button",{type:"button",onClick:()=>{$(e.value),V(!1)},className:`flex w-full items-center justify-between rounded-lg px-3 py-2 text-sm ${t?"bg-gray-100 text-gray-900":"text-gray-700 hover:bg-gray-50"}`,children:[(0,n.jsx)("span",{children:e.label}),t&&(0,n.jsx)("svg",{className:"h-4 w-4 text-primary",viewBox:"0 0 20 20",fill:"currentColor",children:(0,n.jsx)("path",{fillRule:"evenodd",d:"M16.704 5.29a1 1 0 010 1.42l-7.33 7.33a1 1 0 01-1.415 0l-3.663-3.663a1 1 0 111.414-1.414l2.956 2.956 6.623-6.623a1 1 0 011.415 0z",clipRule:"evenodd"})})]},e.value)})}),(0,n.jsx)("svg",{className:"hidden",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),(0,n.jsxs)("button",{onClick:()=>O(e=>!e),className:"mt-4 mb-4 flex items-center gap-1 text-sm text-gray-500 hover:text-gray-700",type:"button",children:[v("config.customizeSummary.moreSettings"),(0,n.jsx)("svg",{className:`h-4 w-4 transition-transform ${M?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),M&&S.length>0&&(0,n.jsx)(c,{documentList:S,sourceRanges:k,setSourceRanges:q})]}),(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3 px-6 py-4 border-t border-gray-200",children:[(0,n.jsx)(d.E,{value:L,onModelChange:e=>R(e),placement:"top",className:"w-[118px]",height:40,backgroundColor:"#FFFFFF"}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("button",{onClick:t,className:"w-[120px] px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-border rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-gray-900 focus:ring-offset-2 transition-colors",children:v("config.customizeSummary.buttons.cancel")}),(0,n.jsx)(u.m_,{title:w?v("config.projectDetail.featuredRegenerateDisabled"):"",children:(0,n.jsx)("span",{className:"inline-flex",children:(0,n.jsx)("button",{onClick:H,disabled:!!w||"custom"===z&&!I,className:"w-[156px] px-4 py-2 text-sm font-medium text-white bg-primary border border-transparent rounded-md hover:bg-[#1e293b] focus:outline-none focus:ring-2 focus:ring-gray-900 focus:ring-offset-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:y||v("config.customizeSummary.buttons.regenerate")})})})]})]})]})}),document.body):null},g=({isOpen:e,onClose:t,onStartGeneration:r,initialDocumentConfig:l=[],confirmButtonLabel:f})=>{let{t:g}=(0,s.Bd)(),p=(0,m.bh)(e=>e.projectDetail?.data?.isFeatured),{model:{selectedModel:x,modalRef:h,documentList:b,sourceRanges:y},actions:{setSelectedModel:v,setSourceRanges:w,handleStartGeneration:j}}=function({isOpen:e,initialDocumentConfig:t,onClose:r,onStartGeneration:n}){let[s,i]=(0,a.useState)(d.e.LITE),l=(0,a.useRef)(null),c=(0,m.bh)(e=>e.projectDetail?.data?.documentList),u=(0,a.useMemo)(()=>c??[],[c]),[f,g]=(0,a.useState)({});return(0,a.useEffect)(()=>{queueMicrotask(()=>g(e=>o(e,u)))},[u]),(0,a.useEffect)(()=>
1{if(!e||!Array.isArray(t)||0===t.length)return;let r=new Map;t.forEach(e=>{let t=Number(e?.docId);if(!Number.isFinite(t))return;let n=Array.isArray(e?.rangeList)?e.rangeList:[];r.set(t,n)}),queueMicrotask(()=>g(e=>{let t={...o(e,u)};return u.forEach(e=>{let n="number"==typeof e.pageSize&&e.pageSize>0,a=n?e.pageSize:1,s=r.get(e.id);if(!s){t[e.id]={...t[e.id]||{ranges:[]},selected:!1,ranges:n?t[e.id]?.ranges||[{id:`${e.id}-0`,from:1,to:a}]:[]};return}let i=s.map((t,r)=>{let n=0===Number(t?.start)&&0===Number(t?.end),s=n?1:Math.max(1,Math.min(Number(t?.start)||1,a)),i=n?a:Math.max(s,Math.min(Number(t?.end)||s,a));return{id:`${e.id}-${r}`,from:s,to:i}}).filter(e=>e.to>=e.from);t[e.id]={selected:!0,ranges:n?i.length>0?i:[{id:`${e.id}-0`,from:1,to:a}]:[]}}),t}))},[e,t,u]),(0,a.useEffect)(()=>{let t=e=>{let t=e.target;!l.current||l.current.contains(t)||t instanceof Element&&t.closest("[data-radix-popper-content-wrapper]")||r()};return e&&(document.addEventListener("mousedown",t),document.body.style.overflow="hidden"),()=>{document.removeEventListener("mousedown",t),document.body.style.overflow="unset"}},[e,r]),(0,a.useEffect)(()=>{let t=e=>{"Escape"===e.key&&r()};return e&&document.addEventListener("keydown",t),()=>{document.removeEventListener("keydown",t)}},[e,r]),{model:{selectedModel:s,modalRef:l,documentList:u,sourceRanges:f},actions:{setSelectedModel:i,setSourceRanges:g,handleStartGeneration:()=>{n({documentConfig:u.map(e=>({docId:e.id,hasPageSize:"number"==typeof e.pageSize&&e.pageSize>0,selected:f[e.id]?.selected??!1,ranges:f[e.id]?.ranges||[]})).filter(e=>e.selected).map(e=>({docId:e.docId,rangeList:e.hasPageSize&&e.ranges.length?e.ranges.map(e=>({start:Math.max(0,Number(e.from)||0),end:Math.max(0,Number(e.to)||0)})):[{start:0,end:0}]}))||[],model:s})}}}}({isOpen:e,initialDocumentConfig:l,onClose:t,onStartGeneration:r});return e?(0,i.createPortal)((0,n.jsx)("div",{className:"fixed inset-0 flex items-center justify-center backdrop-blur-[5px] bg-white/50 pointer-events-auto",style:{zIndex:70},children:(0,n.jsxs)("div",{ref:h,className:"relative w-full max-w-[760px] bg-white rounded-xl border border-gray-200 shadow-[0px_0px_16px_0px_rgba(15,23,42,0.16)]",role:"dialog","aria-modal":"true","aria-labelledby":"customize-mindmap-title",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-6 py-4",children:[(0,n.jsx)("h2",{id:"customize-mindmap-title",className:"text-[18px] leading-none font-semibold text-gray-900",children:`${g("config.startGeneration.setting")} ${g("config.contentVersionPanel.tools.mindmap")}`}),(0,n.jsx)("button",{onClick:t,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-md transition-colors","aria-label":g("config.customizeSummary.closeModal"),children:(0,n.jsx)("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)("div",{className:"max-h-[64vh] overflow-y-auto px-6 pt-1",children:b.length>0&&(0,n.jsx)(c,{documentList:b,sourceRanges:y,setSourceRanges:w})}),(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3 px-6 py-4 border-t border-gray-200",children:[(0,n.jsx)(d.E,{value:x,onModelChange:e=>v(e),placement:"top",className:"w-[118px]",height:40,backgroundColor:"#FFFFFF"}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("button",{onClick:t,className:"w-[120px] px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-border rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-gray-900 focus:ring-offset-2 transition-colors",children:g("config.customizeSummary.buttons.cancel")}),(0,n.jsx)(u.m_,{title:p?g("config.projectDetail.featuredRegenerateDisabled"):"",children:(0,n.jsx)("span",{className:"inline-flex",children:(0,n.jsx)("button",{onClick:j,disabled:!!p,className:"w-[156px] px-4 py-2 text-sm font-medium text-white bg-primary border border-transparent rounded-md hover:bg-[#1e293b] focus:outline-none focus:ring-2 focus:ring-gray-900 focus:ring-offset-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:f||g("config.customizeSummary.buttons.regenerate")})})})]})]})]})}),document.body):null};var p=r(67101);let x=({isOpen:e,onClose:t,onStartGeneration:r,initialFlashcardCount:f=20,initialDifficulty:g="medium",initialFocus:x="",initialDocumentConfig:h=[],confirmButtonLabel:b})=>{let{t:y}=(0,s.Bd)(),v=(0,m.bh)(e=>e.projectDetail?.data?.isFeatured),{model:{modalRef:w,documentList:j,sourceRanges:N,selectedModel:C,flashcardCountInput:S,difficulty:k,focus:z,isValid:_,difficultyOptions:M},actions:{setSourceRanges:L,setSelectedModel:E,setFlashcardCountInput:T,setDifficulty:A,setIsFocusValid:I,commitFlashcardCount:F,handleFocusChange:D,handleStartGeneration:P}}=function({isOpen:e,onClose:t,onStartGeneration:r,initialFlashcardCount:n,initialDifficulty:i,initialFocus:l,initialDocumentConfig:c}
1){let{t:u}=(0,s.Bd)(),[f,g]=(0,a.useState)(n),[p,x]=(0,a.useState)(String(n)),[h,b]=(0,a.useState)(i),[y,v]=(0,a.useState)(l),[w,j]=(0,a.useState)(!0),N=(0,a.useRef)(null),[C,S]=(0,a.useState)(d.e.LITE),k=(0,m.bh)(e=>e.projectDetail?.data?.documentList),z=(0,a.useMemo)(()=>k??[],[k]),[_,M]=(0,a.useState)({});(0,a.useEffect)(()=>{queueMicrotask(()=>{g(n),x(String(n)),b(i),v(l)})},[n,i,l]);let L=(0,a.useMemo)(()=>[{id:"easy",label:u("config.customizeFlashcard.difficulty.easy")},{id:"medium",label:u("config.customizeFlashcard.difficulty.medium")},{id:"hard",label:u("config.customizeFlashcard.difficulty.hard")}],[u]);(0,a.useEffect)(()=>{let r=e=>{let r=e.target;!N.current||N.current.contains(r)||r instanceof Element&&r.closest("[data-radix-popper-content-wrapper]")||t()};return e&&(document.addEventListener("mousedown",r),document.body.style.overflow="hidden"),()=>{document.removeEventListener("mousedown",r),document.body.style.overflow="unset"}},[e,t]),(0,a.useEffect)(()=>{let r=e=>{"Escape"===e.key&&t()};return e&&document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[e,t]),(0,a.useEffect)(()=>{queueMicrotask(()=>M(e=>o(e,z)))},[z]),(0,a.useEffect)(()=>{if(!e||!Array.isArray(c)||0===c.length)return;let t=new Map;c.forEach(e=>{let r=Number(e?.docId);if(!Number.isFinite(r))return;let n=Array.isArray(e?.rangeList)?e.rangeList:[];t.set(r,n)}),queueMicrotask(()=>M(e=>{let r={...o(e,z)};return z.forEach(e=>{let n="number"==typeof e.pageSize&&e.pageSize>0,a=n?e.pageSize:1,s=t.get(e.id);if(!s){r[e.id]={...r[e.id]||{ranges:[]},selected:!1,ranges:n?r[e.id]?.ranges||[{id:`${e.id}-0`,from:1,to:a}]:[]};return}let i=s.map((t,r)=>{let n=0===Number(t?.start)&&0===Number(t?.end),s=n?1:Math.max(1,Math.min(Number(t?.start)||1,a)),i=n?a:Math.max(s,Math.min(Number(t?.end)||s,a));return{id:`${e.id}-${r}`,from:s,to:i}}).filter(e=>e.to>=e.from);r[e.id]={selected:!0,ranges:n?i.length>0?i:[{id:`${e.id}-0`,from:1,to:a}]:[]}}),r}))},[e,c,z]);let E=f>0&&f<=50&&w;return{model:{modalRef:N,documentList:z,sourceRanges:_,selectedModel:C,flashcardCount:f,flashcardCountInput:p,difficulty:h,focus:y,isValid:E,difficultyOptions:L},actions:{setSourceRanges:M,setSelectedModel:S,setFlashcardCountInput:x,setDifficulty:b,setIsFocusValid:j,commitFlashcardCount:e=>{let t=Number(e),r=Number.isFinite(t)?Math.max(1,Math.min(20,Math.floor(t))):1;g(r),x(String(r))},handleFocusChange:e=>{v(e)},handleStartGeneration:()=>{let e=z.map(e=>({docId:e.id,hasPageSize:"number"==typeof e.pageSize&&e.pageSize>0,selected:_[e.id]?.selected??!1,ranges:_[e.id]?.ranges||[]})).filter(e=>e.selected).map(e=>({docId:e.docId,rangeList:e.hasPageSize&&e.ranges.length?e.ranges.map(e=>({start:Math.max(0,Number(e.from)||0),end:Math.max(0,Number(e.to)||0)})):[{start:0,end:0}]}))||[];r({flashcardCount:f,difficulty:h,focus:y.trim(),documentConfig:e,model:C})}}}}({isOpen:e,onClose:t,onStartGeneration:r,initialFlashcardCount:f,initialDifficulty:g,initialFocus:x,initialDocumentConfig:h});return e?(0,i.createPortal)((0,n.jsx)("div",{className:"fixed inset-0 flex items-center justify-center backdrop-blur-[5px] bg-white/50 pointer-events-auto",style:{zIndex:70},children:(0,n.jsxs)("div",{ref:w,className:"relative w-full max-w-[760px] bg-white rounded-xl border border-gray-200 shadow-[0px_0px_16px_0px_rgba(15,23,42,0.16)]",role:"dialog","aria-modal":"true","aria-labelledby":"customize-flashcard-title",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-6 py-4",children:[(0,n.jsx)("h2",{id:"customize-flashcard-title",className:"text-[18px] leading-none font-semibold text-gray-900",children:`${y("config.startGeneration.setting")} ${y("config.contentVersionPanel.tools.flashcards")}`}),(0,n.jsx)("button",{onClick:t,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-md transition-colors","aria-label":y("config.customizeFlashcard.closeModal"),children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsxs)("div",{className:"max-h-[64vh] overflow-y-auto px-6 py-1 space-y-6",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{htmlFor:"flashcard-count",className:"block text-sm font-medium text-gray-700 mb-2",children:y("config.customizeFlashcard.numberOfFlashcards")}),(0,n.jsx)("div",{className:"flex items-center gap-3",children:(0,n.jsx)("input",{id:"flashcard-count",type:"text",inputMode:"numeric",pattern:"[0-9]*",min:"1",max:"20",value:S,onFocus:e=>e.currentTarget.select(),onChange:e=>T(e.target.value.replace(/\D/g,"")),onBlur:e=>F(e.target.value),onKeyDown:e=>{"Enter"===e.key&&e.currentTarget.blur()},className:"flex-1 px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-gray-900 focus:border-transparent"})})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{htmlFor:"difficulty",className:"block text-sm font-medium text-gray-700 mb-2",children:y("config.customizeFlashcard.difficultyLevel")}),(0,n.jsx)("div",{className:"h-[37px] flex items-center w-full",children:(0,n.jsx)(p.X,{options:M.map(e=>({label:e.label,value:e.id})),value:k,onChange:e=>A(e),containerClassName:"relative w-full h-full",triggerClassName:"w-full h-full flex items-center justify-between px-3 text-sm text-gray-700 bg-white border border-gray-300 rounded-md cursor-pointer focus:outline-none focus:ring-2 focus:ring-gray-900 focus:border-transparent",listClassName:"absolute left-0 top-full mt-1 bg-white border border-gray-300 rounded-md shadow-lg z-50 max-h-60 overflow-auto",itemClassName:"px-3 py-2 cursor-pointer hover:bg-gray-100 flex items-center justify-between text-sm text-gray-700 transition-colors first:rounded-t-md last:rounded-b-md"})})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{htmlFor:"focus",className:"block text-sm font-medium text-gray-700 mb-2",children:y("config.customizeFlashcard.focusOn")}),(0,n.jsx)(l.W,{id:"focus",value:z,onChange:D,placeholder:y("config.customizeFlashcard.focusPlaceholder"),maxWords:150,height:"h-[152px]",textareaClassName:"w-full h-32 p-3 text-sm resize-none",wrapperClassName:"mt-0",onValidationChange:I})]}),j.length>0&&(0,n.jsx)(c,{documentList:j,sourceRanges:N,setSourceRanges:L})]}),(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3 px-6 py-4 border-t border-gray-200",children:[(0,n.jsx)(d.E,{value:C,onModelChange:e=>E(e),placement:"top",className:"w-[118px]",height:40,backgroundColor:"#FFFFFF"}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("button",{onClick:t,className:"w-[120px] px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-border rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-gray-900 focus:ring-offset-2 transition-colors",children:y("config.customizeFlashcard.buttons.cancel")}),(0,n.jsx)(u.m_,{title:v?y("config.projectDetail.featuredRegenerateDisabled"):"",children:(0,n.jsx)("span",{className:"inline-flex",children:(0,n.jsx)("button",{onClick:P,disabled:!!v||!_,className:"w-[156px] px-4 py-2 text-sm font-medium text-white bg-primary border border-transparent roun
1ded-md hover:bg-[#1e293b] focus:outline-none focus:ring-2 focus:ring-gray-900 focus:ring-offset-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:b||y("config.customizeSummary.buttons.regenerate")})})})]})]})]})}),document.body):null};var h=r(58515),b=r(83687),y=r(48334),v=r(49387),w=r(98307),j=r(1465);let N=({isOpen:e,onClose:t,onStartGeneration:r,initialEnableExamMode:f=!1,initialQuestionCount:g=10,initialDifficulty:x="medium",initialQuestionTypes:N=["single_choice","multiple_choice"],initialQuizTheme:C="",initialDocumentConfig:S=[],confirmButtonLabel:k})=>{let{t:z}=(0,s.Bd)(),_=(0,m.bh)(e=>e.projectDetail?.data?.isFeatured),{model:{modalRef:M,documentList:L,sourceRanges:E,selectedModel:T,questionCount:A,questionCountInput:I,difficulty:F,questionTypes:D,quizTheme:P,moreSettingsOpen:O,questionTypeCounts:R,questionTypeCountInputs:$,difficultyOptions:V,questionTypeOptions:B,perTypeSum:q,totalExceedsPerType:G,totalLessThanPerType:H,hasEnoughQuestions:W,isValid:Q},actions:{setSourceRanges:U,setSelectedModel:Z,setQuestionCountInput:K,setDifficulty:Y,setIsQuizThemeValid:J,setMoreSettingsOpen:X,setQuestionTypeCountInputs:ee,commitQuestionCount:et,commitQuestionTypeCount:er,handleThemeChange:en,handleQuestionTypeToggle:ea,handleStartGeneration:es}}=function({isOpen:e,onClose:t,onStartGeneration:r,initialEnableExamMode:n,initialQuestionCount:i,initialDifficulty:l,initialQuestionTypes:c,initialQuizTheme:u,initialDocumentConfig:f}){let{t:g}=(0,s.Bd)(),[p,x]=(0,a.useState)(n),[N,C]=(0,a.useState)(i),[S,k]=(0,a.useState)(String(i)),[z,_]=(0,a.useState)(l),[M,L]=(0,a.useState)((0,j.Q2)(c)),[E,T]=(0,a.useState)(u),[A,I]=(0,a.useState)(!0),F=(0,a.useRef)(null),[D,P]=(0,a.useState)(!1),[O,R]=(0,a.useState)(d.e.LITE),$=(0,m.bh)(e=>e.projectDetail?.data?.documentList),V=(0,a.useMemo)(()=>$??[],[$]),[B,q]=(0,a.useState)({}),[G,H]=(0,a.useState)(()=>{let e={};for(let t of(0,j.Q2)(c))e[t]=4;return e}),[W,Q]=(0,a.useState)(()=>{let e={};for(let t of(0,j.Q2)(c))e[t]="4";return e}),U=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(!e){U.current=!1;return}if(U.current)return;U.current=!0;let t=(0,j.Q2)(c),r=t.length>0?t:["single_choice","multiple_choice"];x(n),C(i),k(String(i)),_(l),L(r),T(u)},[e,n,i,l,c,u]);let Z=(0,a.useMemo)(()=>[{id:"easy",label:g("config.customizeQuizzes.difficulty.easy")},{id:"medium",label:g("config.customizeQuizzes.difficulty.medium")},{id:"hard",label:g("config.customizeQuizzes.difficulty.hard")}],[g]),K=(0,a.useMemo)(()=>[{id:"single_choice",label:g("config.customizeQuizzes.questionTypeLabels.single_choice"),icon:h.A,selected:!1},{id:"multiple_choice",label:g("config.customizeQuizzes.questionTypeLabels.multiple_choice"),icon:b.A,selected:!1},{id:"true_false",label:g("config.customizeQuizzes.questionTypeLabels.true_false"),icon:y.A,selected:!1},{id:"fill_in_the_blank",label:g("config.customizeQuizzes.questionTypeLabels.fill_in_the_blank"),icon:v.A,selected:!1},{id:"free_response",label:g("config.customizeQuizzes.questionTypeLabels.free_response"),icon:w.A,selected:!1}].map(e=>({...e,selected:M.includes(e.id)}
1)),[g,M]);(0,a.useEffect)(()=>{let r=e=>{let r=e.target;!F.current||F.current.contains(r)||r instanceof Element&&r.closest("[data-radix-popper-content-wrapper]")||t()};return e&&(document.addEventListener("mousedown",r),document.body.style.overflow="hidden"),()=>{document.removeEventListener("mousedown",r),document.body.style.overflow="unset"}},[e,t]),(0,a.useEffect)(()=>{let r=e=>{"Escape"===e.key&&t()};return e&&document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[e,t]),(0,a.useEffect)(()=>{if(!D||0===M.length)return;let e=M.length,t=Math.floor(N/e),r=N%e,n={},a={};M.forEach((e,s)=>{let i=Math.max(1,t+ +(s<r));n[e]=i,a[e]=String(i)}),H(n),Q(a)},[D]),(0,a.useEffect)(()=>{q(e=>o(e,V))},[V]),(0,a.useEffect)(()=>{if(!e||!Array.isArray(f)||0===f.length)return;let t=new Map;f.forEach(e=>{let r=Number(e?.docId);if(!Number.isFinite(r))return;let n=Array.isArray(e?.rangeList)?e.rangeList:[];t.set(r,n)}),q(e=>{let r={...o(e,V)};return V.forEach(e=>{let n="number"==typeof e.pageSize&&e.pageSize>0,a=n?e.pageSize:1,s=t.get(e.id);if(!s){r[e.id]={...r[e.id]||{ranges:[]},selected:!1,ranges:n?r[e.id]?.ranges||[{id:`${e.id}-0`,from:1,to:a}]:[]};return}let i=s.map((t,r)=>{let n=0===Number(t?.start)&&0===Number(t?.end),s=n?1:Math.max(1,Math.min(Number(t?.start)||1,a)),i=n?a:Math.max(s,Math.min(Number(t?.end)||s,a));return{id:`${e.id}-${r}`,from:s,to:i}}).filter(e=>e.to>=e.from);r[e.id]={selected:!0,ranges:n?i.length>0?i:[{id:`${e.id}-0`,from:1,to:a}]:[]}}),r})},[e,f,V]);let Y=(0,a.useMemo)(()=>M.reduce((e,t)=>e+(G[t]??4),0),[M,G]),J=D&&N>Y&&Y>0,X=D&&N<Y&&Y>0,ee=N>=M.length,et=N>0&&M.length>0&&A&&ee;return{model:{modalRef:F,documentList:V,sourceRanges:B,selectedModel:O,questionCount:N,questionCountInput:S,difficulty:z,questionTypes:M,quizTheme:E,moreSettingsOpen:D,questionTypeCounts:G,questionTypeCountInputs:W,difficultyOptions:Z,questionTypeOptions:K,perTypeSum:Y,totalExceedsPerType:J,totalLessThanPerType:X,hasEnoughQuestions:ee,isValid:et},actions:{setSourceRanges:q,setSelectedModel:R,setQuestionCountInput:k,setDifficulty:_,setQuizTheme:T,setIsQuizThemeValid:I,setMoreSettingsOpen:P,setQuestionTypeCountInputs:Q,commitQuestionCount:e=>{let t=Number(e),r=Number.isFinite(t)?Math.max(1,Math.min(20,Math.floor(t))):1;C(r),k(String(r))},commitQuestionTypeCount:(e,t)=>{let r=Number(t),n=Number.isFinite(r)?Math.max(1,Math.min(20,Math.floor(r))):1;H(t=>({...t,[e]:n})),Q(t=>({...t,[e]:String(n)}))},handleThemeChange:e=>{T(e)},handleQuestionTypeToggle:e=>{M.includes(e)?L(M.filter(t=>t!==e)):L([...M,e])},handleStartGeneration:()=>{let e=V.map(e=>({docId:e.id,hasPageSize:"number"==typeof e.pageSize&&e.pageSize>0,selected:B[e.id]?.selected??!1,ranges:B[e.id]?.ranges||[]})).filter(e=>e.selected).map(e=>({docId:e.docId,rangeList:e.hasPageSize&&e.ranges.length?e.ranges.map(e=>({start:Math.max(0,Number(e.from)||0),end:Math.max(0,Number(e.to)||0)})):[{start:0,end:0}]}))||[],t={};for(let e of M)t[e]=G[e]??4;r({enableExamMode:p,questionCount:N,difficulty:z,questionTypes:M,questionTypeCounts:t,quizTheme:E.trim(),documentConfig:e,model:O})}}}}({isOpen:e,onClose:t,onStartGeneration:r,initialEnableExamMode:f,initialQuestionCount:g,initialDifficulty:x,initialQuestionTypes:N,initialQuizTheme:C,initialDocumentConfig:S});return e?(0,i.createPortal)((0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center backdrop-blur-[5px] justify-center bg-white/50",style:{zIndex:70},children:(0,n.jsxs)("div",{ref:M,className:"relative w-full max-w-[760px] bg-white rounded-xl border border-gray-200 shadow-[0px_0px_16px_0px_rgba(15,23,42,0.16)]",role:"dialog","aria-modal":"true","aria-labelledby":"customize-quizzes-title",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-6 py-4",children:[(0,n.jsx)("h2",{id:"customize-quizzes-title",className:"text-[18px] leading-none font-semibold text-gray-900",children:`${z("config.startGeneration.setting")} ${z("config.contentVersionPanel.tools.quizzes")}`}),(0,n.jsx)("button",{onClick:t,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-md transition-colors","aria-label":z("config.customizeQuizzes.closeModal"),children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsxs)("div",{className:"max-h-[64vh] overflow-y-auto px-6 pt-1 pb-4 space-y-6",children:[(0,n.jsxs)("div",{className:"w-full rounded-lg",children:[(0,n.jsx)("label",{className:"block text-sm font-bold text-gray-700 mb-2",children:z("config.customizeQuizzes.questionTypes")}),(0,n.jsx)("div",{className:"flex flex-wrap gap-2 p-3 border rounded-lg border-gray-200",children:B.map(e=>{let t=e.icon;return(0,n.jsxs)("button",{onClick:()=>ea(e.id),className:`flex items-center gap-1 px-3 py-2 rounded-md border text-xs transition-colors ${e.selected?"bg-gray-900 border-gray-900 text-white":"bg-[#E5F2FF] border-gray-300 text-gray-700 hover:bg-gray-50"}`,children:[(0,n.jsx)(t,{size:12}),e.label]},e.id)})})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{htmlFor:"difficulty",className:"block text-sm font-bold text-gray-700 mb-2",children:z("config.customizeQuizzes.difficultyLevel")}),(0,n.jsx)("div",{className:"h-[37px] flex items-center w-full",children:(0,n.jsx)(p.X,{options:V.map(e=>({label:e.label,value:e.id})),value:F,onChange:e=>Y(e),containerClassName:"relative w-full h-full",triggerClassName:"w-full h-full flex items-center justify-between px-3 text-sm text-gray-700 bg-white border border-gray-300 rounded-md cursor-pointer focus:outline-none focus:ring-2 focus:ring-gray-900 focus:border-transparent",listClassName:"absolute left-0 top-full mt-1 bg-white border border-gray-300 rounded-md shadow-lg z-50 max-h-60 overflow-auto",itemClassName:"px-3 py-2 cursor-pointer hover:bg-gray-100 flex items-center justify-between text-sm text-gray-700 transition-colors first:rounded-t-md last:rounded-b-md"})})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{htmlFor:"question-count",className:"block text-sm font-medium text-gray-700 mb-2",children:z("config.customizeQuizzes.numberOfQuestions")}),(0,n.jsx)("input",{id:"question-count",type:"text",inputMode:"numeric",pattern:"[0-9]*",min:"1",max:"20",value:I,onFocus:e=>e.currentTarget.select(),onChange:e=>K(e.target.value.replace(/\D/g,"")),onBlur:e=>et(e.target.value),onKeyDown:e=>{"Enter"===e.key&&e.currentTarget.blur()},className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-gray-900 focus:border-transparent"}),!W&&D.length>0&&(0,n.jsx)("p",{className:"mt-1 text-xs text-red-500",children:z("config.customizeQuizzes.validation.questionsMustBeGreater",{count:D.length})}),H&&(0,n.jsx)("p",{className:"mt-1 text-xs text-amber-600",children:z("config.customizeQuizzes.validation.totalLessThanPerType",{total:A,sum:q})})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{htmlFor:"quiz-theme",className:"block text-sm font-medium text-gray-700 mb-2",children:z("config.customizeQuizzes.quizTheme")}),(0,n.jsx)(l.W,{id:"quiz-theme",value:P,onChange:en,placeholder:z("config.customizeQuizzes.themePlaceholder"),maxWords:150,height:"h-[152px]",textareaClassName:"w-full h-32 p-3 border border-gray-300 rounded-md text-sm resize-none",wrapperClassName:"mt-0",onValidationChange:J})]}),(0,n.jsxs)("button",{onClick:()=>X(e=>!e),className:"mt-4 mb-4 flex items-center gap-1 text-sm text-gray-500 hover:text-gray-700",type:"button",children:[z("config.customizeQuizzes.moreSettings"),(0,n.jsx)("svg",{className:`h-4 w-4 transition-transform ${O?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),O&&(0,n.jsxs)(n.Fragment,{children:[D.length>0&&(0,n.jsxs)("div",{className:"mt-4",children:[(0,n.jsx)("label",{className:"block text-sm font-bold text-gray-700 mb-3",children:z("config.customizeQuizzes.numberOfQuestionsPerType")}),G&&(0,n.jsx)("p",{className:"mb-3 text-xs text-amber-600",children:z("config.customizeQuizzes.validation.totalExceedsPerType",{total:A,sum:q})}),(0,n.jsx)("div",{className:"space-y-3",children:B.filter(e=>e.selected).map(e=>{let t=e.icon;return(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 text-sm text-gray-700",children:[(0,n.jsx)(t,{size:16,className:"text-gray-500"}),(0,n.jsx)("span",{children:e.label})]}),(0,n.jsx)("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",min:"1",max:"20",value:$[e.id]??String(R[e.id]??4),onFocus:e=>e.currentTarget.select(),onChange:t=>{let r=t.target.value.replace(/\D/g,"");ee(t=>
1({...t,[e.id]:r}))},onBlur:t=>er(e.id,t.target.value),onKeyDown:e=>{"Enter"===e.key&&e.currentTarget.blur()},className:"w-[100px] px-3 py-1.5 border border-gray-300 rounded-md text-sm text-center focus:outline-none focus:ring-2 focus:ring-gray-900 focus:border-transparent"})]},e.id)})})]}),L.length>0&&(0,n.jsx)(c,{documentList:L,sourceRanges:E,setSourceRanges:U})]})]}),(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3 px-6 py-4 border-t border-gray-200",children:[(0,n.jsx)(d.E,{value:T,onModelChange:e=>Z(e),placement:"top",className:"w-[118px]",height:40,backgroundColor:"#FFFFFF"}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("button",{onClick:t,className:"w-[120px] px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-border rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-gray-900 focus:ring-offset-2 transition-colors",children:z("config.customizeQuizzes.buttons.cancel")}),(0,n.jsx)(u.m_,{title:_?z("config.projectDetail.featuredRegenerateDisabled"):"",children:(0,n.jsx)("span",{className:"inline-flex",children:(0,n.jsx)("button",{onClick:es,disabled:!!_||!Q,className:"w-[156px] px-4 py-2 text-sm font-medium text-white bg-primary border border-transparent rounded-md hover:bg-[#1e293b] focus:outline-none focus:ring-2 focus:ring-gray-900 focus:ring-offset-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:k||z("config.customizeSummary.buttons.regenerate")})})})]})]})]})}),document.body):null};var C=r(33210),S=r(38027);let k=({isOpen:e,isLoading:t=!1,onClose:r,onStartGeneration:l,initialDuration:f="8M",initialLanguage:g="en",initialVoice:p="male",initialDocumentConfig:x=[],confirmButtonLabel:h,selectedAiModel:b,onModelChange:y})=>{let{t:v}=(0,s.Bd)(),w=(0,m.bh)(e=>e.projectDetail?.data?.isFeatured),[j,N]=(0,a.useState)(d.e.LITE),{model:{modalRef:k,languageMenuRef:z,voiceMenuRef:_,documentList:M,sourceRanges:L,selectedDuration:E,selectedLanguage:T,selectedVoice:A,showAdvancedSettings:I,isLanguageMenuOpen:F,isVoiceMenuOpen:D,durationOptions:P,languageOptions:O,voiceOptions:R},actions:{setSourceRanges:$,setSelectedDuration:V,setSelectedLanguage:B,setSelectedVoice:q,setShowAdvancedSettings:G,setIsLanguageMenuOpen:H,setIsVoiceMenuOpen:W,handleConfirm:Q}}=function({isOpen:e,onClose:t,onStartGeneration:r,isLoading:n,initialDuration:i,initialLanguage:l,initialVoice:c,initialDocumentConfig:d}){let{t:u}=(0,s.Bd)(),f=e=>{let t=e.toLowerCase().trim();return"cn"===t||"zh-hans"===t||"zhHans"===t||"zh-hant"===t||"zhHant"===t||"zh-cn"===t||"zh-tw"===t||"zh"===t?"zh":e},[g,p]=(0,a.useState)(i),[x,h]=(0,a.useState)(()=>f(l)),[b,y]=(0,a.useState)(c),[v,w]=(0,a.useState)(!1),[j,N]=(0,a.useState)("lite"),[C,S]=(0,a.useState)(!1),[k,z]=(0,a.useState)(!1),[_,M]=(0,a.useState)(!1),L=(0,a.useRef)(null),E=(0,a.useRef)(null),T=(0,a.useRef)(null),A=(0,a.useRef)(null),I=(0,m.bh)(e=>e.projectDetail?.data?.documentList),F=(0,a.useMemo)(()=>I??[],[I]),[D,P]=(0,a.useState)({});(0,a.useEffect)(()=>{queueMicrotask(()=>{p(i),h(f(l)),y(c)})},[i,l,c]),(0,a.useEffect)(()=>{queueMicrotask(()=>P(e=>o(e,F)))},[F]),(0,a.useEffect)(()=>{if(!e||!Array.isArray(d)||0===d.length)return;let t=new Map;d.forEach(e=>{let r=Number(e?.docId);if(!Number.isFinite(r))return;let n=Array.isArray(e?.rangeList)?e.rangeList:[];t.set(r,n)}),queueMicrotask(()=>P(e=>{let r={...o(e,F)};return F.forEach(e=>{let n="number"==typeof e.pageSize&&e.pageSize>0,a=n?e.pageSize:1,s=t.get(e.id);if(!s){r[e.id]={...r[e.id]||{ranges:[]},selected:!1,ranges:n?r[e.id]?.ranges||[{id:`${e.id}-0`,from:1,to:a}]:[]};return}let i=s.map((t,r)=>{let n=0===Number(t?.start)&&0===Number(t?.end),s=n?1:Math.max(1,Math.min(Number(t?.start)||1,a)),i=n?a:Math.max(s,Math.min(Number(t?.end)||s,a));return{id:`${e.id}-${r}`,from:s,to:i}}).filter(e=>e.to>=e.from);r[e.id]={selected:!0,ranges:n?i.length>0?i:[{id:`${e.id}-0`,from:1,to:a}]:[]}}),r}))},[e,d,F]),(0,a.useEffect)(()=>{let r=e=>{let r=e.target;!L.current||L.current.contains(r)||r instanceof Element&&r.closest("[data-radix-popper-content-wrapper]")||t()};return e&&(document.addEventListener("mousedown",r),document.body.style.overflow="hidden"),()=>{document.removeEventListener("mousedown",r),document.body.style.overflow="unset"}},[e,t]),(0,a.useEffect)(()=>
1{if(!C)return;let e=e=>{E.current&&!E.current.contains(e.target)&&S(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[C]),(0,a.useEffect)(()=>{if(!k)return;let e=e=>{T.current&&!T.current.contains(e.target)&&z(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[k]),(0,a.useEffect)(()=>{if(!_)return;let e=e=>{A.current&&!A.current.contains(e.target)&&M(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[_]),(0,a.useEffect)(()=>{let r=e=>{"Escape"===e.key&&t()};return e&&document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[e,t]);let O=(0,a.useMemo)(()=>[{id:"3M",time:u("config.videoGen.settings.durations.3M.time"),description:u("config.videoGen.settings.durations.3M.description")},{id:"8M",time:u("config.videoGen.settings.durations.8M.time"),description:u("config.videoGen.settings.durations.8M.description")},{id:"12M",time:u("config.videoGen.settings.durations.12M.time"),description:u("config.videoGen.settings.durations.12M.description")}],[u]),R=(0,a.useMemo)(()=>[{value:"en",label:u("config.videoGen.settings.languageOptions.en")},{value:"zh",label:u("config.videoGen.settings.languageOptions.zh")},{value:"de",label:u("config.videoGen.settings.languageOptions.de")},{value:"es",label:u("config.videoGen.settings.languageOptions.es")},{value:"fr",label:u("config.videoGen.settings.languageOptions.fr")},{value:"ja",label:u("config.videoGen.settings.languageOptions.ja")},{value:"ko",label:u("config.videoGen.settings.languageOptions.ko")},{value:"it",label:u("config.videoGen.settings.languageOptions.it")},{value:"ru",label:u("config.videoGen.settings.languageOptions.ru")},{value:"nl",label:u("config.videoGen.settings.languageOptions.nl")},{value:"ar",label:u("config.videoGen.settings.languageOptions.ar")}],[u]);return{model:{modalRef:L,languageMenuRef:E,voiceMenuRef:T,modelMenuRef:A,documentList:F,sourceRanges:D,selectedDuration:g,selectedLanguage:x,selectedVoice:b,showAdvancedSettings:v,selectedModel:j,isLanguageMenuOpen:C,isVoiceMenuOpen:k,isModelMenuOpen:_,durationOptions:O,languageOptions:R,voiceOptions:(0,a.useMemo)(()=>[{value:"male",label:u("config.videoGen.settings.voiceOptions.male")},{value:"female",label:u("config.videoGen.settings.voiceOptions.female")}],[u])},actions:{setSourceRanges:P,setSelectedDuration:p,setSelectedLanguage:h,setSelectedVoice:y,setShowAdvancedSettings:w,setSelectedModel:N,setIsLanguageMenuOpen:S,setIsVoiceMenuOpen:z,setIsModelMenuOpen:M,handleConfirm:()=>{n||r({duration:g,language:x,voice:b,advancedSettings:{sources:F.map(e=>({documentId:e.id,documentName:e.documentName,selected:D[e.id]?.selected??!1,ranges:D[e.id]?.ranges.map(e=>({from:e.from,to:e.to}))||[]}))}})}}}}({isOpen:e,onClose:r,onStartGeneration:l,isLoading:t,initialDuration:f,initialLanguage:g,initialVoice:p,initialDocumentConfig:x});if(!e)return null;let U=(e,t,r,a,s,i,l)=>(0,n.jsxs)("div",{className:"flex-1",children:[(0,n.jsx)("div",{className:"mb-2 text-sm font-medium text-gray-700",children:e}),(0,n.jsxs)("div",{className:"relative",ref:l,children:[(0,n.jsxs)("button",{type:"button",onClick:()=>i(!s),className:"flex h-11 w-full items-center justify-between rounded-md border border-gray-200 bg-white px-4 text-sm text-gray-800 hover:border-gray-300 focus:outline-none focus:ring-2 focus:ring-gray-900/10",children:[(0,n.jsx)("span",{children:t.find(e=>e.value===r)?.label||r}),(0,n.jsx)("svg",{className:`h-4 w-4 text-gray-400 transition-transform ${s?"":"rotate-180"}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),s&&(0,n.jsx)("div",{className:"absolute left-0 right-0 bottom-12 z-20 max-h-56 overflow-y-auto rounded-md border border-gray-200 bg-white p-1 shadow-[0_12px_28px_rgba(15,23,42,0.12)]",children:t.map(e=>{let t=e.value===r;return(0,n.jsxs)("button",{type:"button",onClick:()=>{a(e.value),i(!1)},className:`flex w-full items-center justify-between rounded-lg px-3 py-2 text-sm ${t?"bg-gray-100 text-gray-900":"text-gray-700 hover:bg-gray-50"}`,children:[(0,n.jsx)("span",{children:e.label}),t&&(0,n.jsx)("svg",{className:"h-4 w-4 text-primary",viewBox:"0 0 20 20",fill:"currentColor",children:(0,n.jsx)("path",{fillRule:"evenodd",d:"M16.704 5.29a1 1 0 010 1.42l-7.33 7.33a1 1 0 01-1.415 0l-3.663-3.663a1 1 0 111.414-1.414l2.956 2.956 6.623-6.623a1 1 0 011.415 0z",clipRule:"evenodd"})})]},e.value)})})]})]});return(0,i.createPortal)((0,n.jsx)("div",{className:"fixed inset-0 flex items-center justify-center backdrop-blur-[5px] bg-white/50 pointer-events-auto",style:{zIndex:70},children:(0,n.jsxs)("div",{ref:k,className:"relative w-[550px] bg-white rounded-lg border border-gray-200 shadow-[0px_0px_16px_0px_rgba(15,23,42,0.16)]",role:"dialog","aria-modal":"true",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-6 py-4",children:[(0,n.jsx)("h2",{className:"text-[18px] leading-none font-semibold text-gray-900",children:`${v("config.startGeneration.setting")} ${v("config.contentVersionPanel.tools.video_gen")}`}),(0,n.jsx)("button",{onClick:r,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-md transition-colors",children:(0,n.jsx)(C.A,{className:"h-5 w-5"})})]}),(0,n.jsx)("div",{className:"max-h-[64vh] overflow-y-auto px-6 py-5",children:t?(0,n.jsxs)("div",{className:"flex h-56 flex-col items-center justify-center gap-3 text-gray-500",children:[(0,n.jsx)("div",{className:"h-7 w-7 animate-spin rounded-full border-2 border-gray-300 border-t-gray-700"}),(0,n.jsx)("p",{className:"text-sm",children:v("common.loading",{defaultValue:"Loading settings..."})})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"space-y-3",children:P.map(e=>(0,n.jsxs)("button",{onClick:()=>V(e.id),className:`w-full flex items-start gap-3 px-4 py-3 rounded-md border transition-colors hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-gray-900 focus:ring-offset-2 ${E===e.id?"border-primary bg-slate-50 shadow-sm":"border-border bg-white"}`,role:"radio","aria-checked":E===e.id,children:[(0,n.jsx)("div",{className:"flex-shrink-0 mt-0.5",children:(0,n.jsx)("div",{className:"h-4 w-4 roun
1ded-full border-2 border-gray-300 bg-white flex items-center justify-center",children:E===e.id&&(0,n.jsx)("div",{className:"h-2 w-2 rounded-full bg-primary"})})}),(0,n.jsxs)("div",{className:"flex-1 text-left",children:[(0,n.jsx)("div",{className:"text-sm font-semibold text-gray-900",children:e.time}),(0,n.jsx)("div",{className:"text-xs text-gray-400 mt-1",children:e.description})]})]},e.id))}),(0,n.jsxs)("div",{className:"mt-6 flex gap-4",children:[U(v("config.videoGen.settings.language"),O,T,B,F,H,z),U(v("config.videoGen.settings.narratingVoices"),R,A,q,D,W,_)]}),(0,n.jsxs)("button",{onClick:()=>G(e=>!e),className:"mt-4 flex items-center gap-1 text-sm text-gray-500 hover:text-gray-700",type:"button",children:[v("config.customizeVideoExplainer.moreSettings"),(0,n.jsx)("svg",{className:`h-4 w-4 transition-transform ${I?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),I&&M.length>0&&(0,n.jsx)(c,{documentList:M,sourceRanges:L,setSourceRanges:$})]})}),(0,n.jsx)("div",{className:"h-px w-full bg-border"}),(0,n.jsxs)("div",{className:"flex items-center justify-between px-6 py-4",children:[(0,n.jsx)(d.E,{value:b??j,onModelChange:y??N,placement:"top"}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)(S.$,{variant:"outline",className:"w-[120px]",onClick:r,children:v("config.customizeVideoExplainer.buttons.cancel")}),(0,n.jsx)(u.m_,{title:w?v("config.projectDetail.featuredRegenerateDisabled"):"",children:(0,n.jsx)("span",{className:"inline-flex",children:(0,n.jsx)(S.$,{variant:"default",className:"w-[156px]",onClick:Q,disabled:t||!!w,children:h||v("config.customizeVideoExplainer.buttons.regenerate")})})})]})]})]})}),document.body)};var z=r(14490),_=r(11910),M=r(81554),L=r(67511),E=r(66058);let T="project_config";var A=r(54159),I=r(32535),F=r(8695),D=r(20416),P=r(13171);let O=({isOpen:e=!0,onClose:t,className:r="",title:i,description:l,apiType:o="summary",variant:c="full",refreshActionId:m,showSettingsButton:p=!1,customizeSaveOnly:h=!1,onAfterStart:b})=>{let{t:y}=(0,s.Bd)(),{projectId:v}=(0,z.g)(),w=(0,M.Vw)(),C=i||y("config.startGeneration.title"),O=l||y("config.startGeneration.description"),R=(0,_.O)(e=>e.getProjectConfig),$=(0,_.O)(e=>e.updateProjectConfig),[V,B]=(0,a.useState)(d.e.LITE),{actions:{callCreateOrRefreshAction:q}}=(0,A.e)({projectId:v,refreshActionId:m,variant:c,selectedAiModel:V}),[G,H]=(0,a.useState)(!1),{model:{initialConfig:W,initialVideoConfig:Q,initialFlashcardConfig:U,initialQuizzesConfig:Z,latestConfigRef:K},actions:{setInitialConfig:Y,setInitialVideoConfig:J,setInitialFlashcardConfig:X,setInitialQuizzesConfig:ee,getConfigTypeByApiType:et,buildRequestFromSavedConfig:er,persistConfig:en,loadConfigurations:ea,getLocalProjectConfig:es}}=function({currentApiType:e,projectId:t,selectedAiModel:r,setSelectedAiModel:n,getProjectConfig:s,updateProjectConfig:i}){let[l,o]=(0,a.useState)(null),[c,d]=(0,a.useState)(null),[u,m]=(0,a.useState)(null),[f,g]=(0,a.useState)(null),p=(0,a.useRef)({}),x=(0,a.useCallback)((e,t)=>{"flashcards"===e?m(t):"quizzes"===e?g(t):"video_gen"===e?d(t):o(t)},[]),h=(0,a.useCallback)((e,t,r)=>{p.current[e]=r,r?.model&&n(r.model),x(t,r)},[x,n]),b=(0,a.useCallback)(e=>"summary"===e?"summary":"chapter"===e?"chapter":"mindmap"===e?"mind_map":"flashcards"===e?"flashcard":"quizzes"===e?"quiz":"video_gen"===e?"video_generation":"summary",[]),y=(0,a.useCallback)(e=>t?`${t}:${e}`:null,[t]),v=(0,a.useCallback)(()=>{let e=window.localStorage.getItem(T);if(!e)return{};try{let t=JSON.parse(e);if(t&&"object"==typeof t)return t;return{}}catch{return{}}},[]),w=(0,a.useCallback)(e=>{let t=y(e);if(!t)return null;let r=v(),n=r[t];if("string"==typeof n)return n;let a=r[`start_generation_config:${t}`];return"string"==typeof a?a:window.localStorage.getItem(t)||window.localStorage.getItem(`start_generation_config:${t}`)},[y,v]),N=(0,a.useCallback)((e,t)=>{let r=y(e);if(!r)return;let n=v();n[r]=t,window.localStorage.setItem(T,JSON.stringify(n))},[y,v]),C=(0,a.useCallback)((e,n)=>{let a={project_id:t||0,user_prompt:"",model:n?.model||r};switch(e){case"summary":{let e=(e=>{let t=String(e||"").trim();if(!t)return"en";let r=t.toLowerCase();return"zh-hans"===r||"zh-hant"===r||"zh"===r||"zh-cn"===r||"zh-tw"===r||"cn"===r||r.includes("chinese")?"zh":r})(n?.outputLanguage||n?.language);return{...a,mode:n?.mode||"extended",user_prompt:n?.userPrompt??n?.user_prompt??"",outputLanguage:e,...Array.isArray(n?.documentConfig)&&n.documentConfig.length>0?{documentConfig:n.documentConfig}:{}}}case"flashcards":return{...a,mode:"extended",count:Number(n?.flashcardCount??n?.count??20),level:n?.difficulty||n?.level||"medium",user_prompt:n?.focus??n?.userPrompt??n?.user_prompt??"",...Array.isArray(n?.documentConfig)&&n.documentConfig.length>0?{documentConfig:n.documentConfig}:{}};case"quizzes":{let e=(0,j.Q2)(n?.questionTypes||n?.questionTypeList||["single_choice","multiple_choice"]),t=Math.max(Number(n?.questionCount??10),e.length),r=e.length||1,s=Math.floor(t/r),i=t%r,l=e.map(e=>{let t=+(i>0);return i-=1,{type:e,count:s+t}});return{...a,level:n?.difficulty||n?.level||"medium",user_prompt:n?.quizTheme??n?.userPrompt??n?.user_prompt??"",questions_request:l,...Array.isArray(n?.documentConfig)&&n.documentConfig.length>0?{documentConfig:n.documentConfig}:{}}}case"video_gen":return{...a,duration_mode:n?.duration_mode||n?.duration||"3M",language:n?.language||"en",voice:n?.voice||"male",...Array.isArray(n?.documentConfig)&&n.documentConfig.length>0?{documentConfig:n.documentConfig}:{}};default:return{...a,...Array.isArray(n?.documentConfig)&&n.documentConfig.length>0?{documentConfig:n.documentConfig}:{}}}},[t,r]),S=(0,a.useCallback)((e,t)=>{i(e,t),N(e,t),p.current[e]=(0,L.q)(t)},[N,i]),k=(0,a.useMemo)(()=>b(e),[b,e]),z=(0,a.useMemo)(()=>w(k),[w,k]),{data:_,mutate:M}=(0,E.TP)({type:k},{swr:{enabled:null===z}}),A=(0,a.useRef)(null);return(0,a.useEffect)(()=>{null===z&&void 0!==_&&N(k,("string"==typeof _?_:JSON.stringify(_))||"{}");let t=z||_;if(!t)return;let r="string"==typeof t?t:JSON.stringify(t);if(A.current!==r){A.current=r;
1try{let r="string"==typeof t?(0,L.q)(t):t,n=window.setTimeout(()=>{h(k,e,r)},0);return()=>window.clearTimeout(n)}catch(e){console.error("\uD83D\uDFE1 StartGeneration - Failed to parse config:",e)}}},[z,_,k,e,h,N]),{model:{initialConfig:l,initialVideoConfig:c,initialFlashcardConfig:u,initialQuizzesConfig:f,latestConfigRef:p},actions:{setInitialConfig:o,setInitialVideoConfig:d,setInitialFlashcardConfig:m,setInitialQuizzesConfig:g,getConfigTypeByApiType:b,buildRequestFromSavedConfig:C,persistConfig:S,loadConfigurations:(0,a.useCallback)(async()=>{let t=w(k)||await s(k,{force:!0});if(t)try{let r=(0,L.q)(t);h(k,e,r)}catch(e){console.error("\uD83D\uDFE1 StartGeneration - Failed to parse config:",e)}M()},[k,e,w,s,M,h]),getLocalProjectConfig:w}}}({currentApiType:o,projectId:v,selectedAiModel:V,setSelectedAiModel:B,getProjectConfig:R,updateProjectConfig:$}),{model:{showCustomizeSummary:ei,showCustomizeMindmap:el,showCustomizeFlashcard:eo,showCustomizeQuizzes:ec,showCustomizeVideoExplainer:ed,isVideoCustomizeLoading:eu},actions:{setShowCustomizeSummary:em,setShowCustomizeMindmap:ef,setShowCustomizeFlashcard:eg,setShowCustomizeQuizzes:ep,setShowCustomizeVideoExplainer:ex,handleCloseCustomizeSummary:eh,handleCloseCustomizeMindmap:eb,handleCloseCustomizeFlashcard:ey,handleCloseCustomizeQuizzes:ev,handleCloseCustomizeVideoExplainer:ew,handleOpenCustomize:ej}}=function({currentApiType:e,isAnonymous:t,loadConfigurations:r,setInitialConfig:n,setInitialVideoConfig:s,setInitialFlashcardConfig:i,setInitialQuizzesConfig:l}){let[o,c]=(0,a.useState)(!1),[d,u]=(0,a.useState)(!1),[m,f]=(0,a.useState)(!1),[g,p]=(0,a.useState)(!1),[x,h]=(0,a.useState)(!1),[b,y]=(0,a.useState)(!1),v=async()=>{if(t){I.default?.capture("anonymous_signin_gate_shown",{trigger_source:"regenerate_tool",page:window.location.pathname}),window.dispatchEvent(new CustomEvent("login-required",{detail:{}}));return}if("video_gen"===e){h(!0),y(!0);try{await r()}finally{y(!1)}return}await r(),"flashcards"===e?f(!0):"quizzes"===e?p(!0):"mindmap"===e?u(!0):c(!0)};return{model:{showCustomizeSummary:o,showCustomizeMindmap:d,showCustomizeFlashcard:m,showCustomizeQuizzes:g,showCustomizeVideoExplainer:x,isVideoCustomizeLoading:b},actions:{setShowCustomizeSummary:c,setShowCustomizeMindmap:u,setShowCustomizeFlashcard:f,setShowCustomizeQuizzes:p,setShowCustomizeVideoExplainer:h,handleCloseCustomizeSummary:()=>{c(!1),n(null)},handleCloseCustomizeMindmap:()=>{u(!1),n(null)},handleCloseCustomizeFlashcard:()=>{f(!1),i(null)},handleCloseCustomizeQuizzes:()=>{p(!1),l(null)},handleCloseCustomizeVideoExplainer:()=>{h(!1),y(!1),s(null)},handleOpenCustomize:v}}}({currentApiType:o,isAnonymous:w,loadConfigurations:ea,setInitialConfig:Y,setInitialVideoConfig:J,setInitialFlashcardConfig:X,setInitialQuizzesConfig:ee}),{actions:{handleStartGeneration:eN,handleCustomizeSummaryConfirm:eC,handleCustomizeMindmapConfirm:eS,handleCustomizeFlashcardConfirm:ek,handleCustomizeQuizzesConfirm:ez,handleCustomizeVideoExplainerConfirm:e_}}=function({currentApiType:e,projectId:t,selectedAiModel:r,setSelectedAiModel:n,isAnonymous:i,customizeSaveOnly:l,onAfterStart:o,getProjectConfig:c,getConfigTypeByApiType:d,getLocalProjectConfig:u,latestConfigRef:m,buildRequestFromSavedConfig:f,persistConfig:g,callCreateOrRefreshAction:p,setInitialConfig:x,setInitialVideoConfig:h,setInitialFlashcardConfig:b,setInitialQuizzesConfig:y,setShowCustomizeSummary:v,setShowCustomizeMindmap:w,setShowCustomizeFlashcard:N,setShowCustomizeQuizzes:C,setShowCustomizeVideoExplainer:S,setIsLoading:k}){let{t:z}=(0,s.Bd)(),{toast:_}=(0,F.u)(),M=(0,D.Xu)(e=>e.isWorkspaceActive),E=(0,a.useCallback)(()=>{let n={project_id:t||0,user_prompt:""};switch(e){case"summary":n.model=r,n.mode="extended";break;case"chapter":case"flashcards":n.mode="extended";break;case"quizzes":n.level="medium",n.questions_request=[{count:2,type:"single_choice"},{count:2,type:"multiple_choice"},{count:2,type:"true_false"},{count:2,type:"fill_in_the_blank"},{count:2,type:"free_response"}];break;case"video_gen":n.model=r,n.duration_mode="3M",n.language="en",n.voice="male"}return n},[e,t,r]),T=(0,a.useCallback)(()=>
1!(0,P.Jd)(M)||(_.warning(z("transcription.finishRecordingFirst",{defaultValue:"Please finish recording first"})),!1),[M,z,_]),A=(0,a.useCallback)(async()=>{if(T()){if(i){I.default?.capture("anonymous_signin_gate_shown",{trigger_source:"start_generation_tool",page:window.location.pathname}),window.dispatchEvent(new CustomEvent("login-required",{detail:{}}));return}try{k(!0);let t=E(),n=d(e),a=m.current[n];if(a&&"object"==typeof a)t=f(e,{...a,model:r});else{let a=u(n)||await c(n);if(a){let s=(0,L.q)(a);s&&"object"==typeof s&&(m.current[n]=s,t=f(e,{...s,model:r}))}}await p(e,t)}catch(e){console.error("Start generation failed:",e)}finally{k(!1),o?.()}}},[i,k,E,T,d,e,m,r,n,f,u,c,p,o]),O=(0,a.useCallback)(async a=>{if(!T())return;v(!1),x(null);let s=a.model||r;a.model&&n(a.model);let i={summarized:"concise",extended:"extended",custom:"customized"}[a.summaryType]||"extended",c="custom"===a.summaryType&&a.customPrompt||"",u=(e=>{let t=String(e||"").trim();if(!t)return"en";let r=t.toLowerCase();return"zh-hans"===r||"zh-hant"===r||"zh"===r||"zh-cn"===r||"zh-tw"===r||"cn"===r||r.includes("chinese")?"zh":r})(a.advancedSettings?.language),m=d(e),f=a.advancedSettings?.sources?.filter(e=>e.selected).map(e=>({docId:e.documentId,rangeList:e.ranges?.length?e.ranges.map(e=>({start:Math.max(0,Number(e.from)||0),end:Math.max(0,Number(e.to)||0)})):[{start:0,end:0}]}))||[],h={project_id:t||0,user_prompt:c,mode:i,model:s,outputLanguage:u,...f.length>0?{documentConfig:f}:{}};try{let e=JSON.stringify({mode:i,userPrompt:c,model:s,outputLanguage:u,...f.length>0?{documentConfig:f}:{}});g(m,e)}catch(e){console.error("\uD83D\uDFE1 StartGeneration - Failed to save config:",e)}if(!l)try{k(!0),await p(e,h)}finally{k(!1),o?.()}},[v,x,T,d,e,t,r,n,g,l,k,p,o]),R=(0,a.useCallback)(async e=>{if(!T())return;w(!1),x(null);let a=e.model||r;e.model&&n(e.model);let s={project_id:t||0,model:a,...Array.isArray(e.documentConfig)&&e.documentConfig.length>0?{documentConfig:e.documentConfig}:{}};try{let t=JSON.stringify({model:a,...Array.isArray(e.documentConfig)&&e.documentConfig.length>0?{documentConfig:e.documentConfig}:{}});g("mind_map",t)}catch(e){console.error("\uD83D\uDFE1 StartGeneration - Failed to save mindmap config:",e)}if(!l)try{k(!0),await p("mindmap",s)}finally{k(!1),o?.()}},[w,x,T,t,r,n,g,l,k,p,o]),$=(0,a.useCallback)(async a=>{if(!T())return;N(!1),b(null);let s=a.model||r;a.model&&n(a.model);try{let e=JSON.stringify({flashcardCount:a.flashcardCount,difficulty:a.difficulty,focus:a.focus||"",model:s,...Array.isArray(a.documentConfig)&&a.documentConfig.length>0?{documentConfig:a.documentConfig}:{}});g("flashcard",e)}catch(e){console.error("\uD83D\uDFE1 StartGeneration - Failed to save flashcard config:",e)}let i="easy"===a.difficulty?"easy":"hard"===a.difficulty?"hard":"medium",c={project_id:t||0,user_prompt:a.focus||"",mode:"extended",count:a.flashcardCount,level:i,model:s,...Array.isArray(a.documentConfig)&&a.documentConfig.length>0?{documentConfig:a.documentConfig}:{}};if(!l)try{k(!0),await p(e,c)}finally{k(!1),o?.()}},[N,b,T,r,n,g,t,l,k,p,e,o]);return{actions:{handleStartGeneration:A,handleCustomizeSummaryConfirm:O,handleCustomizeMindmapConfirm:R,handleCustomizeFlashcardConfirm:$,handleCustomizeQuizzesConfirm:(0,a.useCallback)(async a=>{if(!T())return;C(!1),y(null);let s=a.model||r;a.model&&n(a.model);let i=(0,j.Q2)(a.questionTypes);if(0===i.length||a.questionCount<i.length)return;try{let e=JSON.stringify({enableExamMode:a.enableExamMode,questionCount:a.questionCount,difficulty:a.difficulty,questionTypes:i,quizTheme:a.quizTheme||"",model:s,...Array.isArray(a.documentConfig)&&a.documentConfig.length>0?{documentConfig:a.documentConfig}:{}});g("quiz",e)}catch(e){console.error("\uD83D\uDFE1 StartGeneration - Failed to save quizzes config:",e)}let c="easy"===a.difficulty?"easy":"hard"===a.difficulty?"hard":"medium",d=i.length,u=Math.floor(a.questionCount/d),m=a.questionCount%d,f=i.map(e=>{let t=+(m>0);return m-=1,{type:e,count:u+t}}),x=f.reduce((e,t)=>e+(t.count||0),0),h=f.some(e=>!e.count||e.count<=0);if(x<=0||h)return;let b={project_id:t||0,user_prompt:a.quizTheme||"",level:c,questions_request:f,model:s,...Array.isArray(a.documentConfig)&&a.documentConfig.length>0?{documentConfig:a.documentConfig}:{}};if(!l)try{k(!0),await p(e,b)}finally{k(!1),o?.()}},[C,y,T,r,n,g,t,l,k,p,e,o]),handleCustomizeVideoExplainerConfirm:(0,a.useCallback)(async e=>{if(!T())return;S(!1),h(null);let n=e.advancedSettings?.sources?.filter(e=>e.selected&&e.ranges.length>0).map(e=>({docId:e.documentId,rangeList:e.ranges.map(e=>({start:e.from,end:e.to}))}))||[],a=JSON.stringify({duration_mode:e.duration,language:e.language,voice:e.voice,...n.length>0?{documentConfig:n}:{}});if(t)try{g("video_generation",a)}catch{}if(l)return;let s={project_id:t||0,duration_mode:e.duration,language:e.language,voice:e.voice,model:r,...n.length>0?{documentConfig:n}:{}};try{k(!0),await p("video_gen",s)}finally{k(!1)}},[S,h,T,t,g,l,r,k,p])}}}({currentApiType:o,projectId:v,selectedAiModel:V,setSelectedAiModel:B,isAnonymous:w,customizeSaveOnly:h,onAfterStart:b,getProjectConfig:R,getConfigTypeByApiType:et,getLocalProjectConfig:es,latestConfigRef:K,buildRequestFromSavedConfig:er,persistConfig:en,callCreateOrRefreshAction:q,setInitialConfig:Y,setInitialVideoConfig:J,setInitialFlashcardConfig:X,setInitialQuizzesConfig:ee,setShowCustomizeSummary:em,setShowCustomizeMindmap:ef,setShowCustomizeFlashcard:eg,setShowCustomizeQuizzes:ep,setShowCustomizeVideoExplainer:ex,setIsLoading:H}),eM=(0,a.useMemo)(()=>Array.isArray(Z?.documentConfig)?Z.documentConfig:[],[Z?.documentConfig]),eL=(0,a.useMemo)(()=>(0,j.Q2)(Z?.questionTypes||Z?.questionTypeList||["single_choice","multiple_choice"]),[Z?.questionTypes,Z?.questionTypeList]);if(!e)return null;let eE=(0,n.jsx)(u.m_,{title:y("config.startGeneration.setting"),children:(0,n.jsx)("button",{className:"inline-flex items-center p-1.5 relative flex-[0_0_auto] rounded hover:bg-gray-100 transition-colors cursor-pointer bg-transparent border-none",onClick:ej,"aria-label":y("config.startGeneration.openCustomizeSettings"),children:(0,n.jsx)("img",{className:"relative w-5 h-5 aspect-[1]",alt:"Settings",src:"/icons/tabbtn-settings2.svg"})})}),eT=h?y("config.settings.save"):void 0,eA=(0,n.jsxs)(n.Fragment,{children:[ei&&(0,n.jsx)(f,{isOpen:ei,onClose:eh,onStartGeneration:eC,initialSummaryType:{concise:"summarized",extended:"extended",customized:"custom"}[W?.mode]||"extended",initialCustomPrompt:W?.userPrompt||"",initialOutputLanguage:W?.outputLanguage||W?.language||"en",initialModel:W?.model||"lite",initialDocumentConfig:Array.isArray(W?.documentConfig)?W.documentConfig:[],confirmButtonLabel:eT}),el&&(0,n.jsx)(g,{isOpen:el,onClose:eb,onStartGeneration:eS,initialDocumentConfig:Array.isArray(W?.documentConfig)?W.documentConfig:[],confirmButtonLabel:eT}),eo&&(0,n.jsx)(x,{isOpen:eo,onClose:ey,onStartGeneration:ek,initialFlashcardCount:U?.flashcardCount||U?.count||20,initialDifficulty:U?.difficulty||U?.level||"medium",initialFocus:U?.focus||U?.userPrompt||"",initialDocumentConfig:Array.isArray(U?.documentConfig)?U.documentConfig:[],confirmButtonLabel:eT}),ec&&(0,n.jsx)(N,{isOpen:ec,onClose:ev,onStartGeneration:ez,initialEnableExamMode:Z?.enableExamMode||!1,initialQuestionCount:Z?.questionCount??(Z?.questionConfigList?.reduce((e,t)=>
1e+(t.count||0),0)||10),initialDifficulty:Z?.difficulty||Z?.level||"medium",initialQuestionTypes:eL,initialQuizTheme:Z?.quizTheme||Z?.userPrompt||"",initialDocumentConfig:eM,confirmButtonLabel:eT}),ed&&(0,n.jsx)(k,{isOpen:ed,isLoading:eu,onClose:ew,onStartGeneration:e_,initialDuration:Q?.duration_mode||Q?.duration||"3M",initialLanguage:Q?.language||"en",initialVoice:Q?.voice||"male",initialDocumentConfig:Array.isArray(Q?.documentConfig)?Q.documentConfig:[],confirmButtonLabel:eT})]});return"gearOnly"===c?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:`flex justify-start ${r}`,children:eE}),eA]}):(0,n.jsxs)("div",{className:`flex flex-col items-start relative bg-gray-50 rounded-lg border border-solid border-gray-200 w-full max-w-full ${r}`,"data-model-id":"1060:19002",role:"main","aria-label":y("config.startGeneration.createSummaryInterface"),children:[(0,n.jsxs)("header",{className:"flex items-center gap-4 p-4 relative self-stretch w-full flex-[0_0_auto]",children:[(0,n.jsxs)("div",{className:"flex flex-col items-start justify-center gap-0.5 relative flex-1 grow",children:[(0,n.jsx)("h1",{className:"relative w-fit mt-[-1.00px] font-medium text-gray-900 text-base tracking-[0] leading-6",children:C}),(0,n.jsx)("p",{className:"relative flex items-center justify-center w-fit font-normal text-gray-600 text-sm tracking-[0] leading-[21px]",children:O})]}),(0,n.jsx)("div",{className:"flex items-center gap-2 flex-shrink-0",children:(0,n.jsxs)(S.$,{variant:"default",size:"sm",onClick:eN,disabled:G,"aria-label":y("config.startGeneration.startGenerationProcess"),children:[G&&(0,n.jsx)("img",{src:"https://cdn.eu.cuflow.ai/frontend/cdn/common/loading/loading.svg",alt:"Loading",className:"w-3.5 h-3.5 animate-spin"}),(0,n.jsx)("span",{children:w?y("anonymous.signUpToGenerate",{defaultValue:"Sign up to Generate"}):y("config.startGeneration.startGeneration")})]})})]}),"flownote"===o?null:(0,n.jsxs)("footer",{className:"flex justify-between px-4 py-2 self-stretch w-full border-t border-solid border-gray-200 items-center relative flex-[0_0_auto]",children:[p&&("summary"===o||"quizzes"===o||"flashcards"===o||"mindmap"===o||"video_gen"===o)?(0,n.jsx)("div",{className:"inline-flex gap-1 items-center relative flex-[0_0_auto]",children:eE}):(0,n.jsx)("div",{}),"video_gen"===o?(0,n.jsx)("div",{}):(0,n.jsx)(d.E,{placement:"top",value:V,onModelChange:B})]}),eA]})}},41188:()=>{},51882:(e,t,r)=>{"use strict";r.r(t),r.d(t,{ToolSelection:()=>tJ});var n,a=r(95155),s=r(12115),i=r(28604),l=r(47650),o=r(79114),c=r(47939),d=r(75345);let u=e=>{let t=e.replace("_","-").toLowerCase();return t.startsWith("zh-hans")||t.startsWith("zh-cn")?"zh-Hans":t.startsWith("zh-hant")||t.startsWith("zh-tw")||t.startsWith("zh-hk")?"zh-Hant":t.split("-")[0]||""};var m=r(22396);function f(){let{model:e,actions:t,refs:r,text:n}=function(){let{t:e,i18n:t}=(0,o.Bd)(),r=(0,i.bh)(e=>e.pageState.activeTab),n=(0,i.bh)(e=>e.toggleShowTranslations),a=(0,i.bh)(e=>e.showTranslations),l=(0,i.bh)(e=>e.isTranslating),m=(0,i.bh)(e=>e.translationTargetLanguage),f=(0,i.bh)(e=>e.setTranslationTargetLanguage),g=(0,i.bh)(e=>e.translationDisplayMode),p=(0,i.bh)(e=>
1e.setTranslationDisplayMode),[x,h]=(0,s.useState)(!1),[b,y]=(0,s.useState)(!1),[v,w]=(0,s.useState)(!1),[j,N]=(0,s.useState)(!1),[C,S]=(0,s.useState)(!1),[k,z]=(0,s.useState)({top:0,left:0}),_=(0,s.useRef)(null),M=(0,s.useRef)(null),L=(0,s.useRef)(l),E=(0,s.useRef)(a),T="summarization"===r,A=l?"/icons/loading-black.svg":"/icons/tranlate.svg",I=(0,s.useMemo)(()=>[{value:"ar",label:"العربية",englishName:"Arabic"},{value:"zh-Hans",label:"简体中文",englishName:"Simplified Chinese"},{value:"en",label:"English",englishName:"English"},{value:"fr",label:"Fran\xe7ais",englishName:"French"},{value:"de",label:"Deutsch",englishName:"German"},{value:"it",label:"Italiano",englishName:"Italian"},{value:"ja",label:"日本語",englishName:"Japanese"},{value:"ko",label:"한국어",englishName:"Korean"},{value:"es",label:"Espa\xf1ol",englishName:"Spanish"},{value:"zh-Hant",label:"繁體中文",englishName:"Traditional Chinese"},{value:"ru",label:"Русский",englishName:"Russian"},{value:"nl",label:"Nederlands",englishName:"Dutch"}],[]),F=u(m||(0,d.Sb)()||t.language||""),D=I.find(e=>e.value===F)?.label||I[0]?.label,P=e("config.toolHeader.toasts.revertTooltip"),O=()=>{T&&(n(),a||(0,c.oR)({title:e("config.toolHeader.toasts.translationStartedTitle"),description:e("config.toolHeader.toasts.translationStartedDescription"),variant:"warning"}))};return(0,s.useEffect)(()=>{if(null!=m)return;let e=u((0,d.Sb)()||t.language||"en");I.some(t=>t.value===e)?f(e):e.startsWith("zh")?f("zh-Hans"):f("en")},[t.language,f,I,m]),(0,s.useEffect)(()=>{if(!x)return;let e=e=>{_.current&&(_.current.contains(e.target)||h(!1))};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[x]),(0,s.useEffect)(()=>{x||queueMicrotask(()=>{y(!1),w(!1),N(!1),S(!1)})},[x]),(0,s.useEffect)(()=>{if(!v)return;let e=()=>{let e=M.current;if(!e)return;let t=e.getBoundingClientRect();z({top:t.top-6+window.scrollY,left:t.left-400-10+window.scrollX})};return e(),window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[v]),(0,s.useEffect)(()=>{let t=L.current,r=E.current;t&&!l&&a&&(0,c.oR)({title:e("config.toolHeader.toasts.translationCompleteTitle"),description:e("config.toolHeader.toasts.translationCompleteDescription"),variant:"success"}),r&&!a&&(0,c.oR)({title:e("config.toolHeader.toasts.originalRestoredTitle"),description:e("config.toolHeader.toasts.restoredDescription"),variant:"success"}),L.current=l,E.current=a},[l,a,e]),{model:{isSummarizationActive:T,showTranslations:a,isTranslating:l,translateIconSrc:A,isTranslateMenuOpen:x,isTargetLanguageMenuOpen:b,translationMode:g,isTranslationHelpOpen:v,isTranslationHelpPinned:j,isHelpIconHovered:C,translationHelpPosition:k,translationLanguageOptions:I,selectedLanguageCode:F,selectedLanguageLabel:D,revertTranslationTooltipText:P},refs:{translateMenuRef:_,translationHelpTriggerRef:M},actions:{setIsTranslateMenuOpen:h,setIsTargetLanguageMenuOpen:y,setIsTranslationHelpOpen:w,setIsTranslationHelpPinned:N,setIsHelpIconHovered:S,setTranslationTargetLanguage:f,setTranslationMode:p,handleTranslateIconClick:()=>{a||l?O():h(e=>!e)},handleConfirmTranslate:()=>{O(),h(!1)}},text:{t:e}}}(),{t:f}=n,g=(0,m.r)(e=>e.getTab(m.SL.SUMMARY).viewState);return e.isSummarizationActive&&g===m.Pf.CONTENT?(0,a.jsxs)("div",{className:"relative flex items-center",ref:r.translateMenuRef,children:[(0,a.jsxs)("button",{onClick:t.handleTranslateIconClick,className:`relative p-1.5 mr-2 rounded-md transition-colors cursor-pointer ${e.showTranslations?"bg-gray-200":"hover:bg-gray-100"} ${e.isTranslating?"animate-pulse":""}`,"aria-label":f("config.toolHeader.translate"),"aria-pressed":e.showTranslations,title:e.showTranslations?e.revertTranslationTooltipText:void 0,children:[(0,a.jsx)("img",{src:e.translateIconSrc,alt:f("config.toolHeader.translate"),className:`w-5 h-5 ${e.isTranslating?"animate-spin":""} ${e.showTranslations?"opacity-100":"opacity-70"}`}),e.isTranslating&&(0,a.jsx)("span",{className:"absolute top-1.5 right-1.5 h-1.5 w-1.5 rounded-full bg-[#4bdc8b] ring-1 ring-white"})]}
1),e.isTranslateMenuOpen&&(0,a.jsxs)("div",{className:"absolute right-0 top-10 z-20 flex w-[240px] flex-col items-start gap-3 rounded-xl bg-white p-3 shadow-[0_0_16px_rgba(15,23,42,0.16)] animate-in fade-in zoom-in-95 duration-150",children:[(0,a.jsxs)("div",{className:"relative flex w-full flex-col items-start justify-center gap-[6px]",children:[(0,a.jsx)("p",{className:"text-sm font-medium leading-[1.5] text-foreground",children:f("config.toolHeader.translationMenu.targetLanguage")}),(0,a.jsxs)("button",{type:"button",onClick:()=>t.setIsTargetLanguageMenuOpen(e=>!e),className:"flex h-[39px] w-full items-center justify-between rounded-md bg-muted px-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium leading-[22px] text-foreground",children:e.selectedLanguageLabel}),(0,a.jsx)("svg",{className:`h-3 w-3 text-muted-foreground transition-transform ${e.isTargetLanguageMenuOpen?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),e.isTargetLanguageMenuOpen&&(0,a.jsx)("div",{className:"absolute left-0 right-0 top-[68px] z-30 max-h-[500px] overflow-y-auto rounded-md border border-border bg-white p-1 shadow-[0_8px_20px_rgba(15,23,42,0.12)]",children:e.translationLanguageOptions.map(r=>{let n=r.value===e.selectedLanguageCode;return(0,a.jsxs)("button",{type:"button",onClick:()=>{t.setTranslationTargetLanguage(r.value),t.setIsTargetLanguageMenuOpen(!1)},className:`flex w-full items-start justify-between rounded-md px-2.5 py-2 text-left ${n?"bg-muted text-foreground":"text-foreground hover:bg-slate-50"}`,children:[(0,a.jsx)("span",{className:"flex flex-col gap-0.5",children:(0,a.jsx)("span",{className:"text-sm font-medium leading-[1.35] text-foreground",children:r.label})}),n&&(0,a.jsx)("svg",{className:"mt-2 h-4 w-4 text-foreground",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M16.704 5.29a1 1 0 010 1.42l-7.33 7.33a1 1 0 01-1.415 0l-3.663-3.663a1 1 0 111.414-1.414l2.956 2.956 6.623-6.623a1 1 0 011.415 0z",clipRule:"evenodd"})})]},r.value)})})]}),(0,a.jsxs)("div",{className:"flex w-full flex-col items-start justify-center gap-[10px]",children:[(0,a.jsxs)("div",{className:"flex items-start gap-[6px]",children:[(0,a.jsx)("p",{className:"text-sm font-medium leading-[22px] text-foreground",children:f("config.toolHeader.translationMenu.translationMode")}),(0,a.jsxs)("div",{ref:r.translationHelpTriggerRef,className:"relative",onMouseEnter:()=>{t.setIsTranslationHelpOpen(!0),t.setIsHelpIconHovered(!0)},onMouseLeave:()=>{e.isTranslationHelpPinned||t.setIsTranslationHelpOpen(!1),t.setIsHelpIconHovered(!1)},children:[(0,a.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),t.setIsTranslationHelpPinned(e=>{let r=!e;return t.setIsTranslationHelpOpen(r),r})},className:"inline-flex h-[22px] w-[22px] items-center justify-center rounded-sm p-[6px]","aria-label":f("config.toolHeader.translationMenu.translationModeHelp"),"aria-expanded":e.isTranslationHelpOpen,children:(0,a.jsx)("span",{className:`inline-flex h-[14px] w-[14px] items-center justify-center transition-transform duration-1000 ${e.isHelpIconHovered?"-rotate-[360deg]":"rotate-0"}`,children:(0,a.jsxs)("svg",{className:"h-[14px] w-[14px] text-muted-foreground",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","aria-hidden":"true",children:[(0,a.jsx)("circle",{cx:"10",cy:"10",r:"7.25",strokeWidth:"1.5"}),(0,a.jsx)("path",{d:"M10 12.6v-.4c0-1.2 1.9-1.6 1.9-3.5a1.9 1.9 0 10-3.8 0",strokeWidth:"1.5",strokeLinecap:"round"}),(0,a.jsx)("circle",{cx:"10",cy:"14.8",r:".75",fill:"currentColor",stroke:"none"})]})})}),e.isTranslationHelpOpen&&"u">typeof document&&(0,l.createPortal)((0,a.jsxs)("div",{className:"fixed z-[40] w-[400px] rounded-xl border border-border bg-white p-4 shadow-[0_12px_32px_rgba(15,23,42,0.16)]",style:{top:e.translationHelpPosition.top,left:e.translationHelpPosition.left},children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("p",{className:"text-sm font-semibold leading-6 text-foreground",children:f("config.toolHeader.translationMenu.fullTranslation")}),(0,a.jsxs)("div",{className:"rounded-lg bg-muted p-3",children:[(0,a.jsx)("div",{className:"h-2.5 w-full rounded bg-white"}),(0,a.jsx)("div",{className:"mt-2 h-2.5 w-full rounded bg-white"}),(0,a.jsx)("div",{className:"mt-2 h-2.5 w-[42%] rounded bg-white"}),(0,a.jsx)("div",{className:"mt-2 h-2.5 w-full rounded bg-white"}),(0,a.jsx)("div",{className:"mt-2 h-2.5 w-full rounded bg-white"}),(0,a.jsx)("div",{className:"mt-2 h-2.5 w-[42%] rounded bg-white"})]})]}),(0,a.jsxs)("div",{className:"mt-4 space-y-2",children:[(0,a.jsx)("p",{className:"text-sm font-semibold leading-6 text-foreground",children:f("config.toolHeader.translationMenu.bilingualMode")}),(0,a.jsxs)("div",{className:"rounded-lg bg-muted p-3",children:[(0,a.jsx)("p",{className:"text-[10px] leading-[2] text-muted-foreground",children:'CuFlow is an AI-native learning platform. With its core positioning of \xa0"becoming students\' personal AI Partner",\xa0it aims to address the pain points of scattered tools and fragmented processes in traditional learning, and build a closed-loop intelligent learning journey for students from input to output.'}),(0,a.jsx)("div",{className:"mt-2 h-2.5 w-full rounded bg-white"}),(0,a.jsx)("div",{className:"mt-2 h-2.5 w-full rounded bg-white"}),(0,a.jsx)("div",{className:"mt-2 h-2.5 w-[42%] rounded bg-white"})]})]})]}),document.body)]})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>t.setTranslationMode("full"),className:`flex w-full items-center gap-3 rounded-md border px-4 py-3 text-left ${"full"===e.translationMode?"border-primary bg-slate-50":"border-border bg-white"}`,children:[(0,a.jsx)("span",{className:`inline-flex h-4 w-4 items-center justify-center rounded-full border ${"full"===e.translationMode?"border-primary":"border-border"}`,children:"full"===e.translationMode&&(0,a.jsx)("span",{className:"h-[7px] w-[7px] rounded-full bg-primary"})}),(0,a.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[(0,a.jsx)("span",{className:"text-sm font-medium leading-[1.5] text-foreground",children:f("config.toolHeader.translationMenu.fullTranslation")}),(0,a.jsx)("span",{className:"text-xs font-normal leading-[1.5] text-muted-foreground",children:f("config.toolHeader.translationMenu.translationOnly")})]})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>t.setTranslationMode("bilingual"),className:`flex w-full items-center gap-3 rounded-md border px-4 py-3 text-left ${"bilingual"===e.translationMode?"border-primary bg-slate-50":"border-border bg-white"}`,children:[(0,a.jsx)("span",{className:`inline-flex h-4 w-4 items-center justify-center rounded-full border ${"bilingual"===e.translationMode?"border-primary":"border-border"}`,children:"bilingual"===e.translationMode&&(0,a.jsx)("span",{className:"h-[7px] w-[7px] rounded-full bg-primary"})}),(0,a.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[(0,a.jsx)("span",{className:"text-sm font-medium leading-[1.5] text-foreground",children:f("config.toolHeader.translationMenu.bilingualMode")}),(0,a.jsx)("span",{className:"text-xs font-normal leading-[1.4] text-muted-foreground",children:f("config.toolHeader.translationMenu.originalPlusTranslation")})]})]})]}),(0,a.jsx)("div",{className:"flex h-9 w-full items-center justify-end rounded-md",children:(0,a.jsx)("button",{type:"button",onClick:t.handleConfirmTranslate,className:"flex h-9 w-[100px] items-center justify-center rounded-md bg-primary px-6 py-2.5 text-[15px] font-semibold leading-[1.5] text-white hover:bg-[#1e293b]",children:f("config.toolHeader.translationMenu.translateButton")})})]})]}):null}var g=r(91999),p=r(17765);let x={summary:{id:"summarization",labelKey:"summarization",icon:"/cdn/common/tool/tabbtn-summarisation.svg"},mind_map:{id:"mindmap",labelKey:"mindmap",icon:"/cdn/common/tool/tabbtn-mindmap.svg"},flownote:{id:"flownote",labelKey:"flownote",icon:"/cdn/common/tool/flow-notes.svg"}
1,chapter:{id:"chapters",labelKey:"chapters",icon:"/cdn/common/tool/tabbtn-chapters.svg"},quiz:{id:"quizzes",labelKey:"quizzes",icon:"/cdn/common/tool/icon-quizzes.svg"},flashcard:{id:"flashcards",labelKey:"flashcards",icon:"/cdn/common/tool/icon-flashcards.svg"},video_gen:{id:"video_gen",labelKey:"videoExplanation",icon:"/cdn/common/tool/video.svg"}};function h(){let{t:e}=(0,o.Bd)(),{activeTab:t,handleTabChange:r,navRef:n,isOverflowing:l,tabOptions:c}=function(){let{t:e}=(0,o.Bd)(),t=(0,i.bh)(e=>e.pageState.activeTab),{onTabChange:r}=(0,p.p)(),n=(0,i.bh)(e=>e.projectDetail),a=(0,i.bh)(e=>e.projectDetailError),l=(0,s.useMemo)(()=>{let t={};return Object.entries(x).forEach(([r,n])=>{t[r]={id:n.id,label:e(`config.toolHeader.tabs.${n.labelKey}`),icon:n.icon}}),t},[e]);(0,s.useEffect)(()=>{let e=()=>r("flownote"),t=()=>r("flashcards");return document.addEventListener("switchToFlowNotes",e),document.addEventListener("switchToFlashcards",t),()=>{document.removeEventListener("switchToFlowNotes",e),document.removeEventListener("switchToFlashcards",t)}},[r]);let c=(0,s.useRef)(null),[d,u]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=c.current;if(!e)return;let t=()=>{u(e.scrollWidth>e.clientWidth)};t();let r=new ResizeObserver(()=>{window.requestAnimationFrame(t)});return r.observe(e),()=>{r.unobserve(e),r.disconnect()}},[]);let m=(0,s.useMemo)(()=>n?.data?.actionTabs?JSON.stringify(n.data.actionTabs.map(e=>({action:e.action,status:e.status}))):"",[n?.data?.actionTabs]);return{activeTab:t,handleTabChange:r,navRef:c,isOverflowing:d,tabOptions:(0,s.useMemo)(()=>{try{if(a||!n?.data?.actionTabs?.length)return[];let e=[];return n.data.actionTabs.forEach(t=>{if(!t?.action)return;let r=l[t.action];r&&e.push({...r,status:t.status})}),e}catch{return[]}},[m,a,l,n?.data?.actionTabs])}}();return 0===c.length?(0,a.jsx)(a.Fragment,{}):(0,a.jsxs)("div",{className:"relative flex-1 grow overflow-hidden",id:g.O.TOOL_LIST_ID,children:[(0,a.jsx)("nav",{ref:n,className:"flex items-center gap-1 overflow-x-auto [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]",role:"tablist",children:c.map(n=>(0,a.jsxs)("button",{role:"tab","aria-selected":t===n.id,onClick:()=>r(n.id),id:`step-${n.id}`,className:`inline-flex items-center gap-1 px-2 py-1.5 relative flex-[0_0_auto] rounded-md transition-colors cursor-pointer ${t===n.id?"bg-muted":"hover:bg-muted"}`,children:[(0,a.jsx)("img",{className:"relative w-5 h-5 aspect-[1] flex-shrink-0",alt:e("config.toolHeader.tabAriaLabel",{label:n.label}),src:n.icon}),(0,a.jsx)("span",{className:`relative w-fit [font-family:"Inter",Helvetica] text-xs tracking-[0] leading-[normal] whitespace-nowrap transition-colors font-medium ${t===n.id?"text-black":"text-gray-600"}`,children:n.label})]},n.id))}),l&&(0,a.jsx)("div",{className:"absolute top-0 right-0 bottom-0 w-16 bg-gradient-to-l from-white pointer-events-none"})]})}function b(){return(0,a.jsx)(a.Fragment,{})}let y=()=>{let e=(0,i.bh)(e=>e.projectDetailError),t=(0,i.bh)(e=>!!e.projectDetail?.data?.actionTabs&&e.projectDetail.data.actionTabs.length>0);return e||!t?(0,a.jsx)(a.Fragment,{}):(0,a.jsxs)("header",{className:"flex items-center gap-2 px-4 py-2 relative self-stretch w-full flex-[0_0_auto] border-b-[0.5px] [border-bottom-style:solid] border-x-01",children:[(0,a.jsx)(h,{}),(0,a.jsx)(f,{}),(0,a.jsx)(b,{})]})};var v=r(51245);let w={summarization:m.SL.SUMMARY,mindmap:m.SL.MIND_MAP,chapters:m.SL.CHAPTER,flashcards:m.SL.FLASHCARD,quizzes:m.SL.QUIZ,flownote:m.SL.FLOWNOTE,video_gen:m.SL.VIDEO_GEN},j={summarization:"summarization",summary:"summarization",chapters:"chapters",chapter:"chapters",mindmap:"mindmap",mind_map:"mindmap",flashcards:"flashcards",flashcard:"flashcards",quizzes:"quizzes",quiz:"quizzes",flownote:"flownote",video_gen:"video_gen"},N="/cdn/common/loading/cat-loading.gif",C={list:[{id:1,success:"File parsed successfully",failed:"File parsed failed",pending:"Parsing your file"},{id:2,success:"Video generated successfully",failed:"Video generated failed",pending:"Generating your video"},{id:3,success:"Video details optimized successfully",failed:"Video details optimized faild",pending:"Optimizing video details"}],icon:N,description:"This process may take up to 5 minutes. Please check back shortly.",title:"Your video is being generated..."},S={list:[{id:1,success:"File parsed successfully",failed:"File parsed failed",pending:"Parsing your file"},{id:2,success:"Summary generated successfully",failed:"Summary generated failed",pending:"Generating your summary"},{id:3,success:"Summary optimized successfully",failed:"Summary optimized failed",pending:"Optimizing summary details"}],icon:N,description:"",title:"Your summary is being generated..."},k={summary:S,summarization:S,mind_map:{list:[{id:1,success:"File parsed successfully",failed:"File parsed failed",pending:"Parsing your file"},{id:2,success:"Mind map generated successfully",failed:"Mind map generated failed",pending:"Generating your mind map"},{id:3,success:"Mind map optimized successfully",failed:"Mind map optimized failed",pending:"Optimizing mind map details"}],icon:N,description:"",title:"Your mind map is being generated..."},video_generation:C,video_gen:C,flashcard:{list:[{id:1,success:"File parsed successfully",failed:"File parsed failed",pending:"Parsing your file"},{id:2,success:"Flashcard generated successfully",failed:"Flashcard generated failed",pending:"Generating your flashcard"}
1,{id:3,success:"Flashcard optimized successfully",failed:"Flashcard optimized failed",pending:"Optimizing flashcard details"}],icon:N,description:"",title:"Your flashcard is being generated..."},quiz:{list:[{id:1,success:"File parsed successfully",failed:"File parsed failed",pending:"Parsing your file"},{id:2,success:"Quiz generated successfully",failed:"Quiz generated failed",pending:"Generating your quiz"},{id:3,success:"Quiz optimized successfully",failed:"Quiz optimized failed",pending:"Optimizing quiz details"}],icon:N,description:"",title:"Your quiz is being generated..."}};var z=((n={}).SUCCESS="success",n.FAILED="failed",n.PENDING="pending",n);let _=e=>{let{list:t,description:r,title:n,icon:s}=(e=>{try{let{action:t,...r}=e,n=k[t];if(n)return n;return{list:r?.list||[],description:r?.description||"",title:r?.title||"",icon:r?.icon||""}}catch{return{list:[],description:"",title:"",icon:""}}})(e),{visible:i=!0,step:l,className:o}=e;return 0!==l&&i&&i?(0,a.jsx)("main",{className:`w-full h-full inline-flex flex-col items-center justify-center gap-2.5 px-0 py-[120px] relative ${o}`,role:"main","aria-label":"Video generation progress",children:(0,a.jsxs)("section",{className:"inline-flex flex-col items-start justify-center gap-4 relative flex-[0_0_auto]",children:[s?(0,a.jsx)("img",{className:"w-[180px] aspect-[1] self-center",alt:"#",src:s}):null,n?(0,a.jsx)("h1",{className:"font-16-EN-bold font-[number:var(--16-EN-bold-font-weight)] text-slate-900 text-[length:var(--16-EN-bold-font-size)] text-left tracking-[var(--16-EN-bold-letter-spacing)] leading-[var(--16-EN-bold-line-height)] whitespace-nowrap [font-style:var(--16-EN-bold-font-style)]",children:n}):null,t.length>0?(0,a.jsx)("ul",{className:"flex flex-col items-start gap-3 relative flex-[0_0_auto]",role:"list","aria-label":"Video generation steps","aria-live":"polite",children:t.map((e,t)=>(0,a.jsx)(M,{item:e,status:status,step:l},e.id))}):null,r?(0,a.jsx)("p",{className:"font-Inter font-normal text-[#9eaab887] text-[10px] tracking-[0] leading-[22px] text-left",children:r}):null]})}):(0,a.jsx)(a.Fragment,{})},M=e=>{let{item:t,step:r}=e,n=t.id>r,i=z.PENDING,l="",o="";t.id<r?(i=z.SUCCESS,l=t.success,o="/cdn/common/icons/check-circle-fill.svg"):(l=t[i=z.PENDING],o="/icons/loading-black.svg");let c=!n&&i===z.PENDING,[d,u]=s.useState(0);return(s.useEffect(()=>{if(!c)return void u(1);let e=setInterval(()=>{u(e=>e>=3?0:e+1)},350);return()=>clearInterval(e)},[c]),n)?null:(0,a.jsxs)("li",{className:"inline-flex items-center gap-2 relative flex-[0_0_auto]",children:[(0,a.jsx)("span",{className:`relative inline-flex w-4 h-4 items-center justify-center ${c?"animate-spin":""}`,children:(0,a.jsx)("img",{className:"block w-4 h-4 aspect-[1]",alt:"",src:o,"aria-hidden":"true"})}),(0,a.jsxs)("span",{className:"relative w-fit mt-[-1.00px] font-Inter font-normal text-slate-900 text-sm tracking-[0] leading-[21px] whitespace-nowrap",children:[l,c?(0,a.jsx)("span",{children:".".repeat(d)}):null]})]},t.id)};var L=r(72984);let E=[.895,.03,.685,.22],T={position:"fixed",top:0,left:0,right:0,height:5,zIndex:9999,overflow:"hidden",pointerEvents:"none"},A={height:"100%",background:"linear-gradient(90deg, rgba(255, 221, 0, 0.00) 0%, rgba(255, 221, 0, 0.60) 100%)"},I=({progress:e=0,visible:t=!0,duration:r=.4})=>{if(!t)return null;let n=Math.min(100,Math.max(0,e));return(0,a.jsx)("div",{style:T,role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,children:(0,a.jsx)(L.P.div,{style:A,initial:{width:0},animate:{width:`${n}%`},transition:{duration:r,ease:E}})})};var F=r(35407),D=r(98550),P=r(32664),O=r(67342),R=r(53978),$=r(98494),V=r(21246),B=r(69366);let q={summary:"summary",mindmap:"mind_map",quizzes:"quiz",flashcards:"flashcard",video_gen:"video_gen"},G={async listVersions(e,t){let r=q[t]||t,n=await (0,D.p_)({projectId:e,action:r}),a=(Array.isArray(n)?n:[n]).map(r=>{let n;return n=String(r.id),{id:n,action_id:n,content_id:null!=r.contentId?String(r.contentId):void 0,query_id:n,project_id:e,tool:t,title:r.title||`Version ${r.id}`,created_at:r.createTime||new Date().toISOString(),source_count:r.fileCount,status:r.status||"completed",sequence:r.id}});return{success:!0,data:{versions:a,currentVersionId:a.length>0?a[0].id:null}}},async createVersion(e){let t=q[e.tool]||e.tool,r=e.payload?JSON.stringify(e.payload):"{}";await (0,P.VP)({projectId:e.projectId,action:t,actionConfig:r});let n=new Date().toISOString(),a={id:`new-${Date.now()}`,project_id:e.projectId,tool:e.tool,title:e.title||"New Version",created_at:n,status:"processing",sequence:0,data:e.payload||{}};return{success:!0,data:{version:a,currentVersionId:a.id}}},renameVersion:async(e,t)=>(await (0,D.nI)({id:Number(e),title:t}),{success:!0}),deleteVersion:async(e,t,r)=>(await (0,D.ST)({id:Number(r)}),{success:!0}),setCurrentVersion:async(e,t,r)=>({success:!0}),async getVersion(e,t,r,n){let a=Number(n??r),s={};switch(t){case"summary":s=await (0,O._A)({projectId:e,actionId:a});break;case"flashcards":s=await (0,$.v5)({projectId:e,actionId:a});break;case"mindmap":s=await (0,R.CH)({projectId:e,actionId:a});break;case"quizzes":s=await (0,V.tH)({projectId:e,actionId:a});break;case"video_gen":s=await (0,B.Ug)({projectId:e,actionId:a});break;default:throw Error(`Unsupported tool: ${t}`)}return{success:!0,data:{version:{id:r,action_id:r,project_id:e,tool:t,title:s.title||`Version ${r}`,created_at:s.createTime||new Date().toISOString(),status:"completed",sequence:a,data:s},currentVersionId:r}}}},H=({version:e,isBusy:t,isBusyMinor:r,isMenuOpen:n,isFeatured:s,onApply:i,onMenuToggle:l,onDelete:c,onRename:d,buildVersionMeta:u})=>{let{t:m}=(0,o.Bd)();return(0,a.jsxs)("div",{className:`relative flex items-center justify-between gap-3 rounded-xl border border-gray-200 bg-white px-4 py-4 transition hover:border-gray-300 hover:bg-gray-50 hover:shadow-sm ${r?"opacity-60":""}`,children:[(0,a.jsxs)("button",{className:"flex-1 text-left",onClick:i,disabled:t,children:[(0,a.jsx)("div",{className:"text-sm font-semibold text-gray-900 line-clamp-1 flex items-center gap-2",children:e.title}),(0,a.jsx)("div",{className:"mt-1 text-xs text-gray-500 line-clamp-1",children:u(e)})]}),!s&&(0,a.jsxs)("div",{className:"group/menu relative",children:[(0,a.jsx)("button",{onClick:e=>{e.stopPropagation(),l()},onMouseDown:e=>e.stopPropagation(),className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-gray-500 hover:bg-gray-100","aria-label":m("config.contentVersionPanel.actions.moreOptions"),children:(0,a.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"
1currentColor",children:[(0,a.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,a.jsx)("circle",{cx:"12",cy:"12",r:"2"}),(0,a.jsx)("circle",{cx:"12",cy:"19",r:"2"})]})}),(0,a.jsxs)("div",{onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:`absolute right-0 top-full z-50 w-[100px] rounded-xl border border-gray-200 bg-white p-1 shadow-[0_12px_30px_rgba(15,23,42,0.12)] transition-opacity duration-150 ${n?"pointer-events-auto opacity-100":"pointer-events-none opacity-0 group-hover/menu:pointer-events-auto group-hover/menu:opacity-100"}`,children:[(0,a.jsxs)("button",{className:"flex w-full items-center gap-[6px] rounded-lg px-[6px] py-2.5 text-[12px] text-red-500 hover:bg-red-50",onClick:c,children:[(0,a.jsx)("span",{className:"inline-flex h-[18px] w-[18px] items-center justify-center shrink-0",children:(0,a.jsx)("img",{src:"/cdn/common/icons/delete.svg",alt:"",className:"h-[15px] w-[15px] object-contain"})}),m("config.contentVersionPanel.actions.delete")]}),(0,a.jsxs)("button",{className:"flex w-full items-center gap-[6px] rounded-lg px-[6px] py-2.5 text-[12px] text-gray-700 hover:bg-gray-50",onClick:d,children:[(0,a.jsx)("span",{className:"inline-flex h-[18px] w-[18px] items-center justify-center shrink-0",children:(0,a.jsx)("img",{src:"/cdn/common/icons/edit.svg",alt:"",className:"h-full w-full object-contain"})}),m("config.contentVersionPanel.actions.rename")]})]})]}),r&&(0,a.jsx)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center rounded-xl bg-white/65",children:(0,a.jsx)("span",{className:"inline-block h-4 w-4 animate-spin rounded-full border-2 border-gray-300 border-t-gray-700"})})]})};var W=r(95703),Q=r(23555),U=r(38027);let Z=({renameModal:e,onRenameModalChange:t,onConfirmRename:r})=>{let{t:n}=(0,o.Bd)();return(0,a.jsx)(W.lG,{open:!!e,onOpenChange:e=>{e||t(null)},children:(0,a.jsxs)(W.Cf,{className:"max-w-[500px] rounded-2xl p-0 gap-0",overlayClassName:"bg-black/20",children:[(0,a.jsx)(W.c7,{className:"px-5 py-4",children:(0,a.jsx)(W.L3,{className:"text-xl font-semibold text-gray-900",children:n("config.contentVersionPanel.renameDialog.title")})}),(0,a.jsx)("div",{className:"border-b border-gray-200 px-5 pb-4",children:(0,a.jsx)("div",{className:"rounded-xl border border-gray-200 px-3.5 py-2.5",children:(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("input",{className:"w-full bg-transparent text-sm text-gray-800 outline-none placeholder:text-gray-400",value:e?.title??"",onChange:r=>t(e?{...e,title:r.target.value}:null),placeholder:n("config.contentVersionPanel.renameDialog.placeholder"),maxLength:100,onKeyDown:e=>{"Enter"===e.key&&r()},autoFocus:!0}),(0,a.jsx)("span",{className:"text-sm text-gray-400",children:`${e?.title.length??0}/100`})]})})}),(0,a.jsxs)(W.Es,{className:"gap-2.5 px-5 py-3.5",children:[(0,a.jsx)(U.$,{variant:"outline",className:"min-w-[100px]",onClick:()=>t(null),children:n("config.contentVersionPanel.actions.cancel")}),(0,a.jsx)(U.$,{variant:"default",className:"min-w-[120px]",onClick:r,disabled:!e?.title.trim(),children:n("config.contentVersionPanel.actions.save")})]})]})})},K=({deleteModal:e,onDeleteModalChange:t,onConfirmDelete:r})=>{let{t:n}=(0,o.Bd)();return(0,a.jsx)(Q.Lt,{open:!!e,onOpenChange:e=>{e||t(null)},children:(0,a.jsxs)(Q.EO,{className:"max-w-[440px] rounded-2xl p-0",children:[(0,a.jsx)(Q.wd,{className:"px-5 py-4",children:(0,a.jsx)(Q.r7,{className:"text-lg font-semibold text-gray-900",children:n("config.contentVersionPanel.deleteDialog.title")})}),(0,a.jsx)("div",{className:"border-t border-gray-100 px-5 py-4",children:(0,a.jsx)(Q.$v,{children:n("config.contentVersionPanel.deleteDialog.description")})}),(0,a.jsxs)(Q.ck,{className:"gap-2.5 border-t border-gray-200 px-5 py-3.5",children:[(0,a.jsx)(Q.Zr,{className:"min-w-[96px] rounded-md border border-gray-200 bg-white px-4 py-2 text-sm font-medium text-gray-700 transition hover:bg-gray-50",children:n("config.contentVersionPanel.actions.cancel")}),(0,a.jsx)(Q.Rx,{className:"min-w-[96px] rounded-md bg-red-600 px-4 py-2 text-sm font-medium text-white transition hover:bg-red-700",onClick:r,children:n("config.contentVersionPanel.actions.delete")})]})]})})},Y={summary:m.SL.SUMMARY,mindmap:m.SL.MIND_MAP,quizzes:m.SL.QUIZ,flashcards:m.SL.FLASHCARD,video_gen:m.SL.VIDEO_GEN},J=({projectId:e,tool:t,className:r="",onSelectVersion:n,title:l,showCreateButton:c=!1})=>{let{t:d}=(0,o.Bd)(),u=(0,i.bh)(e=>e.projectDetail?.data?.isFeatured),{selectVersion:f,pollAfterAction:g}=(0,m.r)(e=>
1e.lifecycle),p=Y[t],[x,h]=(0,s.useState)([]),[b,y]=(0,s.useState)(!1),[v,w]=(0,s.useState)(null),[j,N]=(0,s.useState)(null),[C,S]=(0,s.useState)(null),[k,z]=(0,s.useState)(null),[_,M]=(0,s.useState)(null),[L,E]=(0,s.useState)(null),T=(0,s.useMemo)(()=>[...x].sort((e,t)=>e.created_at<t.created_at?1:-1),[x]),A=(e,t)=>e instanceof Error?e.message:t;(0,s.useEffect)(()=>{let e=()=>{S(null)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]);let I=(0,s.useCallback)(async()=>{let r=await G.listVersions(e,t);return h(r.data.versions),r.data.versions},[e,t]);(0,s.useEffect)(()=>{y(!0),I().finally(()=>y(!1))},[I]);let F=(0,s.useCallback)(async e=>{let t=e.id,r=Number(e.action_id||e.id);w(t),N("apply"),E(null);try{await f(p,r,e.status),n?.(t)}catch(e){E(A(e,"Failed to switch version"))}finally{w(null),N(null)}},[p,f,n]),D=async()=>{w("create"),N("create"),E(null);try{await G.createVersion({projectId:e,tool:t}),await g(p);let r=[...await I()].sort((e,t)=>e.created_at<t.created_at?1:-1)[0];r&&n?.(r.id)}catch(e){E(A(e,"Failed to create version"))}finally{w(null),N(null)}},P=l||({summary:d("config.contentVersionPanel.generatedSummary"),mindmap:d("config.contentVersionPanel.generatedMindmap"),quizzes:d("config.contentVersionPanel.generatedQuizzes"),flashcards:d("config.contentVersionPanel.generatedFlashcards"),video_gen:d("config.contentVersionPanel.generatedVideo")})[t]||d("config.contentVersionPanel.generated"),O=(0,s.useCallback)(async()=>{let e;if(!k||!k.title.trim())return;let t=(e=k.version).action_id||e.id;w(k.version.id),N("rename"),E(null);try{await G.renameVersion(t,k.title.trim()),await I()}catch(e){E(A(e,"Failed to rename version"))}finally{w(null),N(null)}z(null)},[k,I]),R=(0,s.useCallback)(async()=>{let r;if(!_)return;let n=(r=_.version).action_id||r.id;w(_.version.id),N("delete"),E(null);try{await G.deleteVersion(e,t,n),await I()}catch(e){E(A(e,"Failed to delete version"))}finally{w(null),N(null)}M(null)},[_,e,t,I]),$=e=>{let r=d(`config.contentVersionPanel.tools.${t}`,{defaultValue:{summary:"Summary",mindmap:"Mindmap",quizzes:"Quizzes",flashcards:"Flashcards",video_gen:"Video"}[t]}),n=e.source_count??0,a=d("config.contentVersionPanel.sourceCount",{count:n,defaultValue:1===n?`${n} source`:`${n} sources`});return`${r} \xb7 ${a}`};return(0,a.jsxs)("div",{className:`w-full ${r}`,children:[(0,a.jsx)("div",{className:"text-base font-semibold text-gray-900",children:P}),c&&(0,a.jsx)("button",{onClick:D,disabled:"create"===v||b,className:"mt-2 inline-flex items-center gap-2 px-2.5 py-1.5 text-xs font-medium rounded-md border border-gray-200 text-gray-700 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"create"===v?d("config.contentVersionPanel.creating"):d("config.contentVersionPanel.newVersion")}),L&&(0,a.jsx)("div",{className:"mt-2 text-xs text-red-600",children:L}),(0,a.jsxs)("div",{className:"mt-3 flex flex-col gap-2",children:[b&&(0,a.jsx)("div",{className:"text-xs text-gray-500",children:d("config.contentVersionPanel.loading")}),!b&&0===T.length&&(0,a.jsx)("div",{className:"text-xs text-gray-500",children:d("config.contentVersionPanel.empty")}),!b&&T.map(e=>{let t=v===e.id,r=t&&("delete"===j||"rename"===j);return(0,a.jsx)(H,{version:e,isBusy:t,isBusyMinor:r,isMenuOpen:C===e.id,isFeatured:u,onApply:()=>F(e),onMenuToggle:()=>S(C===e.id?null:e.id),onDelete:()=>{S(null),M({version:e})},onRename:()=>{S(null),z({version:e,title:e.title})},buildVersionMeta:$},e.id)})]}),(0,a.jsx)(Z,{renameModal:k,onRenameModalChange:z,onConfirmRename:O}),(0,a.jsx)(K,{deleteModal:_,onDeleteModalChange:M,onConfirmDelete:R})]})};var X=r(14490);let ee={summary:"summary",mind_map:"mindmap",quiz:"quizzes",flashcard:"flashcards",video_gen:"video_gen"},et=({tabId:e,children:t,shouldDisableGeneration:r,disableGeneration:n=!1})=>{let{t:l}=(0,o.Bd)(),{projectId:c}=(0,X.g)(),d=c?Number(c):null,u=(0,i.bh)(e=>e.pageState.activeTab),f=Array.isArray(e)?e:[e],g=f.includes(u),[p,x]=(0,s.useState)(g);(0,s.useEffect)(()=>{g&&!p&&x(!0)},[g,p]);let h=f[0]||"",b=j[h]||h,y=w[b]||"",v=(0,m.r)(e=>e.getTab(y).viewState),N=(0,s.useMemo)(()=>y?({summary:{title:l("config.tabContainer.createSummarization"),description:l("config.tabContainer.createSummarizationDesc"),apiType:"summary"},mind_map:{title:l("config.tabContainer.createMindmap"),description:l("config.tabContainer.createMindmapDesc"),apiType:"mindmap"},chapter:{title:l("config.tabContainer.createChapters"),description:l("config.tabContainer.createChaptersDesc"),apiType:"chapter"},flashcard:{title:l("config.tabContainer.createFlashcards"),description:l("config.tabContainer.createFlashcardsDesc"),apiType:"flashcards"},quiz:{title:l("config.tabContainer.createQuizzes"),description:l("config.tabContainer.createQuizzesDesc"),apiType:"quizzes"},flownote:{title:l("config.tabContainer.createFlowNote"),description:l("config.tabContainer.createFlowNoteDesc"),apiType:"flownote"},video_gen:{title:l("config.tabContainer.createVideoExplanation"),description:l("config.tabContainer.createVideoExplanationDesc"),apiType:"video_gen"}})[y]||{}:{},[y,l]),C=(0,s.useMemo)(()=>y?ee[y]??null:null,[y]),S=(0,s.useMemo)(()=>!(v!==m.Pf.LIST||!y||r&&r()),[v,y,r]),k=(0,s.useMemo)(()=>v===m.Pf.LIST&&null!=d&&null!=C,[g,v,d,C]);return p?(0,a.jsx)("div",{className:`w-full h-full tool-container-${b}`,style:{visibility:g?"visible":"hidden",opacity:+!!g,position:g?"absolute":"fixed",top:g?0:"-200vh",left:g?0:"-200vw",right:g?0:"auto",bottom:g?0:"auto",pointerEvents:g?"auto":"none",overflow:g?"auto":"hidden",contain:"style paint"},children:n?t:k?(0,a.jsxs)("div",{className:"px-6 py-6 w-full",children:[(0,a.jsx)(F.StartGeneration,{title:N.title,de
1scription:N.description,className:"w-full flex justify-center items-center",apiType:N.apiType,showSettingsButton:!0,customizeSaveOnly:!0},`${f.join("-")}-generation`),(0,a.jsx)("div",{className:"mt-6",children:(0,a.jsx)(J,{projectId:d,tool:C,showCreateButton:!1})})]}):S?(0,a.jsx)("div",{className:"px-6 py-6 w-full",children:(0,a.jsx)(F.StartGeneration,{title:N.title,description:N.description,className:"w-full flex justify-center items-center",apiType:N.apiType},`${f.join("-")}-generation`)}):(0,a.jsx)(a.Fragment,{children:t})}):null};var er=r(422);let en=[{key:"summary",tabId:["summarization","summary"],module:"summary"},{key:"chapters",tabId:"chapters",module:"chapter"},{key:"mindmap",tabId:"mindmap",module:"mindmap"},{key:"flownote",tabId:"flownote",module:"flownote",disableGeneration:!0},{key:"flashcards",tabId:"flashcards",module:"flashcard"},{key:"quizzes",tabId:"quizzes",module:"quiz"},{key:"video_gen",tabId:"video_gen",module:"video"}];var ea=r(74420),es=r(81554);r(67889);var ei=r(44197);let el=(e,t)=>(0,ei.Tv)({url:"/api/v1/translate",method:"POST",headers:{"Content-Type":"application/json"},data:e},t);var eo=r(15352);let ec=0;function ed(e,t){let r=Date.now();r-ec<5e3||(ec=r,e({title:t("config.projectDetail.featuredEditDisabledTitle"),description:t("config.projectDetail.featuredEditDisabledDescription"),variant:"info",duration:5e3}))}var eu=r(55258),em=r(4407),ef=r(77744),eg=r(60772);function ep({versionsLoading:e,sortedVersions:t,versionsError:r,openMenuId:n,t:s,buildSummaryMeta:i,setOpenMenuId:l,setDeleteModal:o,setRenameModal:c,handleSelectVersion:d,enterDetailAfterStart:u}){return(0,a.jsxs)("div",{className:"flex-1 w-full flex flex-col gap-6 p-6",children:[(0,a.jsx)(F.StartGeneration,{title:s("config.tabContainer.createSummarization"),description:s("config.tabContainer.createSummarizationDesc"),className:"w-full",apiType:"summary",showSettingsButton:!0,customizeSaveOnly:!0,onAfterStart:u}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)("div",{className:"text-base font-semibold text-gray-900",children:s("config.contentVersionPanel.generatedSummary")}),r&&(0,a.jsx)("div",{className:"text-sm text-red-600",children:r}),e&&(0,a.jsx)("div",{className:"text-sm text-gray-500",children:s("config.summary.versionList.loading")}),!e&&0===t.length&&(0,a.jsx)("div",{className:"text-sm text-gray-500",children:s("config.summary.versionList.empty")}),t.map(e=>(0,a.jsxs)("div",{className:"group relative flex items-center justify-between gap-3 rounded-xl border border-gray-200 bg-white px-4 py-4 transition hover:border-gray-300 hover:bg-gray-50 hover:shadow-sm",children:[(0,a.jsxs)("button",{className:"flex-1 text-left cursor-pointer",onClick:()=>e.id&&d(e.id),children:[(0,a.jsx)("div",{className:"text-sm font-semibold text-gray-900 line-clamp-1",children:e.title}),(0,a.jsx)("div",{className:"mt-1 text-xs text-gray-500 line-clamp-1",children:i(e)})]}),(0,a.jsxs)("div",{className:"group/menu relative",children:[(0,a.jsx)("button",{onClick:t=>{t.stopPropagation(),e.id&&l(n===e.id?null:e.id)},onMouseDown:e=>e.stopPropagation(),className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-gray-500 hover:bg-gray-100","aria-label":"More options",children:(0,a.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,a.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,a.jsx)("circle",{cx:"12",cy:"12",r:"2"}),(0,a.jsx)("circle",{cx:"12",cy:"19",r:"2"})]})}),(0,a.jsxs)("div",{onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:`absolute right-0 top-full z-50 w-[100px] rounded-xl border border-gray-200 bg-white p-1 shadow-[0_12px_30px_rgba(15,23,42,0.12)] transition-opacity duration-150 ${n===e.id?"pointer-events-auto opacity-100":"pointer-events-none opacity-0 group-hover/menu:pointer-events-auto group-hover/menu:opacity-100"}`,children:[(0,a.jsxs)("button",{className:"flex w-full items-center gap-[6px] rounded-lg text-[12px] px-[6px] py-2.5 text-sm text-red-500 hover:bg-red-50",onClick:()=>{e.id&&o({versionId:e.id,title:e.title||""}),l(null)},children:[(0,a.jsx)("span",{className:"inline-flex h-[18px] w-[18px] items-center justify-center shrink-0",children:(0,a.jsx)("img",{src:"/cdn/common/icons/delete.svg",alt:"",className:"h-[15p
1x] w-[15px] object-contain"})}),s("config.summary.versionList.actions.delete")]}),(0,a.jsxs)("button",{className:"flex w-full items-center gap-[6px] rounded-lg px-[6px] text-[12px] py-2.5 text-sm text-gray-700 hover:bg-gray-50",onClick:()=>{e.id&&c({versionId:e.id,title:e.title||""}),l(null)},children:[(0,a.jsx)("span",{className:"inline-flex h-[18px] w-[18px] items-center justify-center shrink-0",children:(0,a.jsx)("img",{src:"/cdn/common/icons/edit.svg",alt:"",className:"h-full w-full object-contain"})}),s("config.summary.versionList.actions.rename")]})]})]})]},e.id))]})]})}function ex({renameModal:e,deleteModal:t,setRenameModal:r,setDeleteModal:n,handleConfirmRename:s,handleConfirmDelete:i,t:l}){return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(W.lG,{open:!!e,onOpenChange:e=>{e||r(null)},children:(0,a.jsxs)(W.Cf,{className:"max-w-[500px] rounded-2xl p-0 gap-0",overlayClassName:"bg-black/20",children:[(0,a.jsx)(W.c7,{className:"px-5 py-4",children:(0,a.jsx)(W.L3,{className:"text-xl font-semibold text-gray-900",children:l("config.summary.versionList.renameDialog.title")})}),(0,a.jsx)("div",{className:"border-b border-gray-200 px-5 pb-4",children:(0,a.jsx)("div",{className:"rounded-xl border border-gray-200 px-3.5 py-2.5",children:(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("input",{className:"w-full bg-transparent text-sm text-gray-800 outline-none placeholder:text-gray-400",value:e?.title??"",onChange:e=>r(t=>t?{...t,title:e.target.value}:t),placeholder:l("config.summary.versionList.renameDialog.placeholder"),maxLength:100}),(0,a.jsx)("span",{className:"text-sm text-gray-400",children:`${e?.title.length??0}/100`})]})})}),(0,a.jsxs)(W.Es,{className:"gap-2.5 px-5 py-3.5",children:[(0,a.jsx)(U.$,{variant:"outline",className:"min-w-[100px]",onClick:()=>r(null),children:l("config.summary.versionList.actions.cancel")}),(0,a.jsx)(U.$,{variant:"default",className:"min-w-[120px]",onClick:s,disabled:!e?.title.trim(),children:l("config.summary.versionList.actions.confirm")})]})]})}),(0,a.jsx)(Q.Lt,{open:!!t,onOpenChange:e=>{e||n(null)},children:(0,a.jsxs)(Q.EO,{className:"max-w-[440px] rounded-2xl p-0",children:[(0,a.jsx)(Q.wd,{className:"px-5 py-4",children:(0,a.jsx)(Q.r7,{className:"text-lg font-semibold text-gray-900",children:l("config.summary.versionList.deleteDialog.title")})}),(0,a.jsx)("div",{className:"border-t border-gray-100 px-5 py-4",children:(0,a.jsx)(Q.$v,{children:l("config.summary.versionList.deleteDialog.description")})}),(0,a.jsxs)(Q.ck,{className:"gap-2.5 border-t border-gray-200 px-5 py-3.5",children:[(0,a.jsx)(Q.Zr,{className:"min-w-[96px] rounded-md border border-gray-200 bg-white px-4 py-2 text-sm font-medium text-gray-700 transition hover:bg-gray-50",children:l("config.summary.versionList.actions.cancel")}),(0,a.jsx)(Q.Rx,{className:"min-w-[96px] rounded-md bg-red-600 px-4 py-2 text-sm font-medium text-white transition hover:bg-red-700",onClick:i,children:l("config.summary.versionList.actions.delete")})]})]})})]})}var eh=r(67888);let eb={sm:"h-4 w-4 border-[1.5px]",md:"h-6 w-6 border-2",lg:"h-9 w-9 border-[3px]"};function ey({size:e="md",className:t}){return(0,a.jsx)("div",{className:(0,eh.cn)("animate-spin rounded-full border-slate-200 border-t-slate-900",eb[e],t),role:"status","aria-label":"Loading",children:(0,a.jsx)("span",{className:"sr-only",children:"Loading..."})})}function ev({t:e,currentActionId:t,isDownloading:r,handleDownload:n,goBackToList:s,enterDetailAfterStart:i}){return(0,a.jsxs)("div",{className:"sticky top-0 z-30 flex items-center justify-between px-6 py-2 bg-white",children:[(0,a.jsxs)("button",{className:"inline-flex items-center gap-2 text-sm text-gray-600 hover:text-gray-900 cursor-pointer",onClick:s,children:[(0,a.jsx)("img",{src:"/cdn/common/icons/icon-arrow-left.svg",alt:"",className:"h-4 w-4"}),e("config.summary.versionList.back")]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(F.StartGeneration,{variant:"gearOnly",className:"",apiType:"summary",refreshActionId:t?Number(t):void 0,onAfterStart:i}),(0,a.jsx)("button",{onClick:n,disabled:r,className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",title:e(r?"config.summary.downloading":"config.summary.downloadPdf"),children:r?(0,a.jsx)(ey,{size:"sm"}):(0,a.jsx)("img",{src:"/icons/download.svg",alt:"",className:"h-5 w-5"})})]})]})}var ew=r(39092),ej=r.n(ew),eN=r(85782),eC=r(10025),eS=r(98817),ek=r(74643);let ez=({text:e,lang:t,rate:r=1,pitch:n=1,volume:i=1,className:l="",onSpeakStart:o,onSpeakEnd:c,onSpeakError:d})=>
1{let[u,m]=(0,s.useState)(!1),f=(0,s.useRef)(null);return(0,s.useEffect)(()=>()=>{window.speechSynthesis.speaking&&window.speechSynthesis.cancel()},[]),(0,a.jsx)("button",{onClick:()=>{if(!("speechSynthesis"in window)){let e=Error("Speech Synthesis API is not supported in this browser");console.error(e),d?.(e);return}if(e&&e.trim()){if(u){window.speechSynthesis.cancel(),m(!1);return}try{let a=new SpeechSynthesisUtterance(e.trim());t&&(a.lang=t),a.rate=r,a.pitch=n,a.volume=i,a.onstart=()=>{m(!0),o?.()},a.onend=()=>{m(!1),f.current=null,c?.()},a.onerror=e=>{m(!1),f.current=null;let t=Error(`Speech synthesis error: ${e.error}`);console.error(t),d?.(t)},f.current=a,window.speechSynthesis.speak(a)}catch(t){let e=t instanceof Error?t:Error("Unknown error occurred");console.error("Failed to speak:",e),m(!1),d?.(e)}}},disabled:!e||!e.trim(),className:`w-7 h-7 p-1.5 rounded-md flex justify-center items-center gap-1 hover:bg-muted transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${l}`,title:u?"Stop speaking":"Read aloud","aria-label":u?"Stop speaking":"Read aloud",children:u?(0,a.jsx)(eS.A,{className:"w-4 h-4 stroke-muted-foreground"}):(0,a.jsx)(ek.A,{className:"w-4 h-4 stroke-muted-foreground"})})},e_=({text:e,type:t,targetId:r,showCopy:n=!0,showSound:s=!0,showLike:i=!0,showDislike:l=!0,className:o="",onCopySuccess:c,onSpeakSuccess:d,onLikeSuccess:u,onDislikeSuccess:m,copyIcon:f,likeIcon:g,dislikeIcon:p,soundIcon:x,children:h})=>{let b=i||l;return(0,a.jsxs)("div",{className:`py-1.5 bg-white inline-flex justify-start items-center gap-1 ${o}`,children:[n&&(0,a.jsx)(eN.i,{text:e,onCopySuccess:c,icon:f}),s&&(0,a.jsx)(ez,{text:e,onSpeakEnd:d}),h,n&&b&&(0,a.jsx)("div",{className:"w-px h-4 bg-slate-200"}),b&&(0,a.jsx)(eC.c,{type:t,targetId:r,showLike:i,showDislike:l,onLikeSuccess:u,onDislikeSuccess:m,likeIcon:g,dislikeIcon:p})]})};function eM({currentSummaryId:e,currentSummaryText:t,displaySources:r}){return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{"data-print-exclude":"true",className:"jsx-fed39112d1ad8d7f w-full flex items-center justify-between gap-4",children:[(0,a.jsx)(e_,{type:"summary",className:"",text:t,targetId:e,showSound:!1}),r.length>0&&(0,a.jsxs)("div",{className:"jsx-fed39112d1ad8d7f source-trigger-group relative flex items-center gap-2",children:[(0,a.jsx)("div",{className:"jsx-fed39112d1ad8d7f flex items-center rounded-lg border border-gray-200 bg-gray-50 px-1.5 py-1",children:r.slice(0,3).map((e,t)=>(0,a.jsx)("img",{src:e.icon,alt:"",className:`jsx-fed39112d1ad8d7f h-4 w-4 rounded-sm border border-gray-200 bg-white ${t>0?"-ml-0.5":""}`},e.id))}),(0,a.jsx)("div",{className:"jsx-fed39112d1ad8d7f source-popover pointer-events-none absolute right-0 bottom-full hidden w-[220px] rounded-xl border border-gray-200 bg-white p-3 text-xs text-gray-700 shadow-[0_10px_30px_rgba(15,23,42,0.12)]",children:(0,a.jsx)("div",{className:"jsx-fed39112d1ad8d7f flex flex-col gap-2 max-h-[132px] overflow-y-auto pr-1",children:r.map(e=>(0,a.jsxs)("div",{className:"jsx-fed39112d1ad8d7f flex items-center gap-2",children:[(0,a.jsx)("img",{src:e.icon,alt:"",className:"jsx-fed39112d1ad8d7f h-4 w-4 shrink-0"}),(0,a.jsx)("div",{title:e.name,className:"jsx-fed39112d1ad8d7f w-full truncate text-[13px] text-gray-700",children:e.name})]},e.id))})})]})]}),(0,a.jsx)(ej(),{id:"fed39112d1ad8d7f",children:".source-trigger-group.jsx-fed39112d1ad8d7f:hover .source-popover.jsx-fed39112d1ad8d7f{display:block;pointer-events:auto}"})]})}var eL=r(16142);let eE=e=>{try{if(String(e?.id??"").startsWith("translation-"))return!0;let t=e?.props||{};return!0===t.isTranslation||"true"===t.isTranslation}catch{return!1}},eT=/^https?:\/\/\S+$/i,eA=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,eI=/__NT_(\d+)__/g,eF=e=>`| ${e.map(e=>e.replace(/\|/g,"\\|")).join(" | ")} |`,eD=new Set(["paragraph","heading","bulletListItem","numberedListItem","checkListItem","blockquote"]),eP=e=>({...e,id:e?.id?String(e.id):`translation-${(0,eL.A)()}`}),eO=async(e,t,r)=>{if(!e||!Array.isArray(e))return[];let n=[];for(let a of e){if(r())break;if("text"===a.type){let e=a.text||"";if(!e.trim()||a.styles?.code){n.push(a);continue}let r=await t(e);n.push({...a,text:r||e})}else if("link"===a.type){let e=await eO(a.content||[],t,r);n.push({...a,content:e})}else n.push(a)}return n},eR=async(e,t,r,n,a)=>{let s=await eO(e.content||[],t,r),i=[];if(Array.isArray(e.children))for(let a=0;a<e.children.length;a++)i.push(await eR(e.children[a],t,r,n,a));let l=e?.props?.className??"",o=s;return"bilingual"===n&&"numberedListItem"===e.type&&(o=[{type:"text",text:`${(a??0)+1}. `,styles:{}},...s]),{...e,id:`translation-${(0,eL.A)()}`,props:{...e.props||{},isTranslation:!0,textColor:"gray",className:`${l} bn-translation-block`.trim()},content:o,children:i}},e$=new Map,eV=e=>{try{let t=e?._tiptapEditor;if(!t||t.destroyed)return!1;let r=t.view;return!!(r&&!r.destroyed&&r.dom&&r.dom.isConnected)}catch{return!1}};async function eB(e){let{editor:t,summaryText:r,summaryHash:n,showTranslations:a,translationDisplayMode:s,translationTargetLanguage:i,originalBlocksRef:l,lastInjectedSummaryHashRef:o,lastInjectedDisplayModeRef:c,summaryTranslations:d,summaryTranslationsHash:u,setIsTranslating:m,setSummaryTranslations:f,translateApi:g,markdownToBlocks:p,isCancelled:x}=e;try{if(!a){if(![...t.document].some(eE)){o.current=null,c.current=null;return}let e=l.current??e$.get(n)??null;if(e&&e.length>0){if(!eV(t))return void console.warn("[SummaryContent][translate] editor view disconnected, skipping restore");t.focus(),t.replaceBlocks(t.document,e)}else try{let e=await p(t,r,!1,!0);if(!eV(t)||x())return;t.replaceBlocks(t.document,e)}catch(e){console.error("[SummaryContent][translate] Rebuild fallback failed:",e)}o.current=null,c.current=null;return}m(!0);let e=[...t.document],h=e.some(eE);if(h||(l.current=e,e$.set(n,e)),h&&o.current===n&&c.current===s)return;let b=l.current||e,y=!!d&&u===n,v={},w=async e=>{let t=e||"";if(!t.trim())return t;let r=t.trim();if(eT.test(r)||eA.test(r))return t;let n=t.match(/^\s*/)?.[0]??"",a=t.match(/\s*$/)?.[0]??"",s=t.slice(n.length,t.length-a.length);if(!s.trim())return t;let l=y&&d?d[s]:void 0;if(!l){let e,r,{protectedText:n,tokens:a}=(e=[],r=t=>{let r=e.push(t)-1;return`__NT_${r}__`},{protectedText:s.replace(/```[\s\S]*?```/g,e=>r(e)).replace(/`[^`\n]+`/g,e=>r(e)).replace(/\bhttps?:\/\/[^\s<>()]+/gi,e=>r(e)).replace(/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi,e=>r(e)).replace(/^(\s*(?:[-*+]|\d+\.)?\s*(?:>\s*)?)(["'][A-Za-z_][A-Za-z0-9_.-]*["']\s*:|[A-Za-z_][A-Za-z0-9_]*[._\-][A-Za-z0-9_.-]*\s*:)/gm,(e,t,n)=>`${t}${r(n)}`).replace(/([{\[,]\s*)(["']?[A-Za-z_][A-Za-z0-9_.-]*["']?\s*:)/g,(e,t,n)=>`${t}${r(n)}`),tokens:e}),o=n.trim();if(!o||""===o.replace(eI,"").trim())return t;try{let e=await g(i?{text:n,targetLanguage:i}:{text:n}),t=e?.translatedText;l=t?t.replace(eI,(e,t)=>{let r=Number(t);return Number.isInteger(r)&&void 0!==a[r]?a[r]:e}):void 0}catch(e){console.error("[SummaryContent][translate] 文本翻译失败:",e)}l&&(v[s]=l)}return`${n}${l||s}${a}`},j=async e=>(await w(e)).replace(/\r?\n/g,"<br />"),N=(e=>{let t=[],r=null;for(let n of e){let e=n.type;if("table"===e){r&&r.blocks.length>0&&(t.push(r),r=null),t.push({type:"table",blocks:[n]});continue}if(!eD.has(e)){r&&r.blocks.length>0&&(t.push(r),r=null);continue}if("paragraph"===e||"heading"===e){r&&r.blocks.length>0&&t.push(r),t.push({type:e,blocks:[n]}
1),r=null;continue}if(!r){r={type:e,blocks:[n]};continue}r.type===e?r.blocks.push(n):(t.push(r),r={type:e,blocks:[n]})}return r&&r.blocks.length>0&&t.push(r),t})(b),C=new Map;for(let e of N){if(x())return;let r="table"===e.type?await eq(e,t,j,p,x):await eG(e,w,s,x);if(C.set(e,r),!x()&&eV(t)){let e=function(e,t,r,n){let a=new Map;for(let e of t)for(let t of e.blocks)a.set(t,e);let s=[],i=new Set;for(let t of e){let e=a.get(t);if(!e){s.push(t);continue}if(i.has(e))continue;i.add(e);let l=r.get(e);if(void 0===l){s.push(...e.blocks);continue}"full"===n?s.push(...l):s.push(...e.blocks,...l)}return s}(b,N,C,s);t.replaceBlocks(t.document,e)}}if(x())return;if(!x()){let e=Object.keys(v).length>0;(!y||e)&&f(n,{...d||{},...v}),o.current=n,c.current=s}}catch(e){console.error("注入翻译失败:",e)}finally{m(!1)}}async function eq(e,t,r,n,a){let s="";try{s=await t.blocksToMarkdownLossy(e.blocks)}catch(e){return console.error("[SummaryContent][translate] 表格导出为 markdown 失败:",e),[]}let i=(e=>{let t=e.split("\n").map(e=>e.trim()).filter(e=>e.length>0);if(t.length<2)return null;let r=t[0],n=t[1];if(!(/\|/.test(n)&&/-/.test(""===n.replace(/[:\s|\-]/g,"")?"-":n)))return null;let a=e=>{let t=e.trim();if(!t)return[];t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1));let r="___ESCAPED_PIPE___";return t.replace(/\\\|/g,r).split("|").map(e=>e.replace(RegExp(r,"g"),"|").trim())},s=a(r);if(!s.length)return null;let i=[];for(let e=2;e<t.length;e+=1){let r=t[e];if(!r.trim())continue;let n=a(r);if(n.length!==s.length)return null;i.push(n)}return{headerCells:s,rows:i,separatorLine:n}})(s);if(!i)return console.warn("[SummaryContent][translate] 表格 markdown 结构异常,跳过结构化翻译"),[];let{headerCells:l,rows:o,separatorLine:c}=i,d=[];for(let e of l){if(a())return[];d.push(await r(e))}let u=[];if(!a())for(let e of o){if(a())return[];let t=[];for(let n of e)t.push(await r(n));u.push(t)}if(a())return[];let m=[eF(d),c,...u.map(eF)].join("\n"),f=[];try{f=(await n(t,m,!1,!0)||[]).map(e=>({...e,id:`translation-${(0,eL.A)()}`,props:{...e.props||{},isTranslation:!0,textColor:e.props&&e.props.textColor||"gray",className:`${e.props?.className??""} bn-translation-block`.trim()}}))}catch(e){return console.error("[SummaryContent][translate] 译文表格解析为 blocks 失败:",e),[]}return f.map(eP)}async function eG(e,t,r,n){let a=[];for(let s=0;s<e.blocks.length&&!n();s++){let i=await eR(e.blocks[s],t,n,r,s);a.push(i)}return a}let eH=s.memo(e=>{let{isActive:t=!0}=e,{t:r}=(0,o.Bd)(),{projectId:n}=(0,X.g)(),{toast:l}=(0,c.dj)(),d=(0,i.bh)(e=>e.showTranslations),u=(0,i.bh)(e=>e.isTranslating),f=(0,i.bh)(e=>e.setIsTranslating),g=(0,i.bh)(e=>e.setSummaryTranslations),p=(0,i.bh)(e=>e.projectDetail),x=(0,i.bh)(e=>e.translationTargetLanguage),h=(0,i.bh)(e=>e.translationDisplayMode),b=(0,m.r)(e=>e.getTab(m.SL.SUMMARY).actionId),y=(0,i.bh)(e=>e.fetchAllIndexes),v=(0,m.r)(e=>e.getTab(m.SL.SUMMARY)),{viewState:w,actionList:j,actionId:N,content:C}=v;m.Pf.LOADING,(0,s.useEffect)(()=>{b&&y(b)},[b]);let S=s.useMemo(()=>C&&w===m.Pf.CONTENT?C:null,[C,w]),[k,z]=(0,s.useState)(null),[_,M]=(0,s.use
1State)(null),[L,E]=(0,s.useState)(null),T=s.useMemo(()=>[...j].sort((e,t)=>{let r=new Date(e.createTime||0).getTime();return new Date(t.createTime||0).getTime()-r}),[j]),A=v.error,I=(0,s.useCallback)(e=>{m.r.getState().lifecycle.selectVersion(m.SL.SUMMARY,e)},[]),F=(0,s.useCallback)(()=>{m.r.getState().lifecycle.goToList(m.SL.SUMMARY)},[]),P=(0,s.useCallback)(()=>{},[]),R=(0,s.useCallback)(e=>{let t=e.fileCount??0,n=r("config.summary.versionList.types.extendedSummary"),a=r("config.contentVersionPanel.sourceCount",{count:t,defaultValue:1===t?`${t} source`:`${t} sources`});return`${n} \xb7 ${a}`},[r]),$=(0,s.useCallback)(async()=>{if(_)try{await (0,D.nI)({id:_.versionId,title:_.title.trim()}),M(null),await m.r.getState().lifecycle.goToList(m.SL.SUMMARY)}catch(e){l({title:"Failed to rename",description:e.message||"Operation failed",variant:"destructive"})}},[_,l]),V=(0,s.useCallback)(async()=>{if(L)try{await (0,D.ST)({id:L.versionId}),E(null),await m.r.getState().lifecycle.goToList(m.SL.SUMMARY)}catch(e){l({title:"Failed to delete",description:e.message||"Operation failed",variant:"destructive"})}},[L,l]),B=s.useRef(!1),q=s.useRef(!0),G=s.useRef(t);G.current=t,(0,s.useEffect)(()=>{B.current=!1},[S?.id]),(0,s.useEffect)(()=>()=>{q.current=!1},[]);let{model:{editorRef:H,markdownEditorRef:W,lastSavedContentRef:Q,isEditorReadyRef:U,lastInjectedSummaryHashRef:Z,lastInjectedDisplayModeRef:K,originalBlocksRef:Y,editorContainerRef:J,lastReadonlyWarnAtRef:ee,editorInstance:et,contentToRender:er,editorKey:en,downloadFilename:ei,displaySources:ec},actions:{handleEditorCreated:eh,handleEditorReady:eb}}=function({projectId:e,currentSummary:t,currentVersion:r,projectDetail:n,t:a,showTranslations:i,isTranslating:l,setIsTranslating:o}){let c=(0,eg.R)(e=>e.navigationItems),d=(0,s.useRef)(null),u=(0,s.useRef)(null),m=(0,s.useRef)(""),f=(0,s.useRef)(!1),g=(0,s.useRef)(null),p=(0,s.useRef)(null),x=(0,s.useRef)(null),h=(0,s.useRef)(null),b=(0,s.useRef)(null),y=(0,s.useRef)(0),[v,w]=(0,s.useState)(null),j=(0,s.useMemo)(()=>{let e=t?.summary;"string"!=typeof e&&(e="");let n=r?.title;if(n){let t=/^#\s+.*$/m;e=t.test(e)?e.replace(t,`# ${n}`):`# ${n}
2
3${e}`}return e},[t?.summary,r?.title]),N=(0,s.useMemo)(()=>`summary-editor-${t?.id??e}`,[t?.id,e]),C=(0,s.useMemo)(()=>{let e=new Date().toISOString().split("T")[0],r=t?.id?`-summary-${t.id}`:"";return`summary${r}-${e}`},[t?.id]),S=n?.data?.documentList||[],k=e=>({pdf:"/cdn/common/doc/pdf.svg",doc:"/cdn/common/doc/doc.svg",docx:"/cdn/common/doc/doc.svg",ppt:"/cdn/common/doc/powerpoint.svg",pptx:"/cdn/common/doc/powerpoint.svg",jpg:"/cdn/common/doc/image.svg",jpeg:"/cdn/common/doc/image.svg",png:"/cdn/common/doc/image.svg",gif:"/cdn/common/doc/image.svg",mp4:"/cdn/common/doc/video.svg",avi:"/cdn/common/doc/video.svg",mov:"/cdn/common/doc/video.svg",mp3:"/cdn/common/doc/audio.svg",wav:"/cdn/common/doc/audio.svg",txt:"/cdn/common/doc/text.svg",text:"/cdn/common/doc/text.svg",link:"/cdn/common/doc/link.svg"})[e?.toLowerCase()]||"/cdn/common/doc/doc.svg",z=(0,s.useMemo)(()=>{if(!S.length)return[];let e=t?.document_list||[];return e.length?e.map(e=>S.find(t=>t.id===e)).filter(Boolean):S},[t?.document_list,S]),_=(0,s.useMemo)(()=>z.map(e=>({id:e.id,name:e.documentName||e.content||"Untitled",icon:k(e.documentType||"doc")})),[z]),M=(0,s.useMemo)(()=>c.length?c.map(e=>({id:e.id,name:e.name||"Untitled",icon:e.icon||k(e.documentType||"doc")})):[],[c]),L=_.length>0?_:M;(0,s.useEffect)(()=>{let e=t?.id??null;null===e||e!==g.current&&(m.current="string"==typeof t?.summary?t.summary:"",f.current=!1,g.current=e)},[t?.id,t?.summary]),(0,s.useEffect)(()=>{t?.id!==g.current&&(p.current=null,x.current=null,h.current=null,g.current=t?.id??null,o(!1))},[t?.id,o]);let E=(0,s.useCallback)(e=>{d.current=e},[]),T=(0,s.useCallback)(()=>{f.current=!0;try{let e=d.current;if(!e)return;w(e)}catch(e){console.warn("[SummaryContent] Failed to inspect top-level blocks",e)}},[]);return{model:{editorRef:d,markdownEditorRef:u,lastSavedContentRef:m,isEditorReadyRef:f,processedSummaryIdRef:g,lastInjectedSummaryHashRef:p,lastInjectedDisplayModeRef:x,originalBlocksRef:h,editorContainerRef:b,lastReadonlyWarnAtRef:y,editorInstance:v,contentToRender:j,editorKey:N,downloadFilename:C,displaySources:L,showTranslations:i,isTranslating:l,t:a},actions:{handleEditorCreated:E,handleEditorReady:T,setEditorInstance:w}}}({projectId:n,currentSummary:S,currentVersion:null,projectDetail:p,t:r,showTranslations:d,isTranslating:u,setIsTranslating:f}),{isPrinting:ey,handlePrint:ew}=(0,ea.usePrintMarkdown)(J),ej=(0,s.useCallback)(async(e,t=!1)=>
3{if(!q.current||!G.current)return;let n=m.r.getState().getTab(m.SL.SUMMARY).content;if("number"!=typeof n?.id||!U.current||!t&&!B.current)return;let a=es.nc.getState().user?.email?.toLowerCase(),s=!!a&&(a.endsWith("@cuflow.ai")||a.endsWith("@sigmatrx.ai"));if(i.bh.getState().projectDetail?.data?.isFeatured&&!s)return void ed(l,r);if(es.nc.getState().isAnonymous)return;let{showTranslations:o,isTranslating:c}=i.bh.getState();if(!o&&!c&&(t||e!==Q.current)&&H.current&&0!==H.current.topLevelBlocks.length)try{m.r.getState().setContent(m.SL.SUMMARY,{...n,summary:e,modify_time:new Date().toISOString()});let r=await (0,O.MT)({summaryId:n.id,content:e});Q.current=e,m.r.getState().setContent(m.SL.SUMMARY,{...n,summary:e,modify_time:r?.modifyTime||new Date().toISOString()}),t&&l({title:"Success",description:"Summary saved successfully",variant:"success"})}catch(e){console.error("Failed to save Summary:",e),t&&l({title:"Save failed",description:e instanceof Error?e.message:"Failed to save",variant:"destructive"})}},[n,l,r]),eN=(0,s.useCallback)(e=>{B.current=!0,ej(e,!1)},[ej]),eC=(0,s.useCallback)((e,t=!0)=>{ej(e,t)},[ej]);return((0,s.useEffect)(()=>{let e=S?.summary||"";if(!et||!e)return;let t=(0,i.Uq)(e),r=!1,{summaryTranslations:n,summaryTranslationsHash:a}=i.bh.getState(),s=setTimeout(()=>{r||eB({editor:et,summaryText:e,summaryHash:t,showTranslations:d,translationDisplayMode:h,translationTargetLanguage:x,originalBlocksRef:Y,lastInjectedSummaryHashRef:Z,lastInjectedDisplayModeRef:K,summaryTranslations:n,summaryTranslationsHash:a,setIsTranslating:f,setSummaryTranslations:g,translateApi:el,markdownToBlocks:eu.L2,isCancelled:()=>r})},0);return()=>{r=!0,clearTimeout(s)}},[d,h,S?.summary,S?.id,et]),(0,s.useEffect)(()=>{if(!d&&!u)return;let e=J.current;if(!e)return;let t=()=>{let e=Date.now();e-ee.current<1200||(ee.current=e,l({title:r("config.toolHeader.toasts.readonlyTitle"),description:r("config.toolHeader.toasts.readonlyDescription"),variant:"warning"}))},n=e=>{(d||u)&&(e.preventDefault(),t())},a=e=>{!d&&!u||new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End","Escape","Tab"]).has(e.key)||(e.metaKey||e.ctrlKey)&&"c"===e.key.toLowerCase()||(e.preventDefault(),t())};return e.addEventListener("beforeinput",n,!0),e.addEventListener("paste",n,!0),e.addEventListener("drop",n,!0),e.addEventListener("keydown",a,!0),()=>{e.removeEventListener("beforeinput",n,!0),e.removeEventListener("paste",n,!0),e.removeEventListener("drop",n,!0),e.removeEventListener("keydown",a,!0)}},[d,u,l,r]),S&&null!==S.summary&&void 0!==S.summary)?(0,a.jsxs)("div",{className:"w-full min-h-full flex flex-col",children:[w===m.Pf.LIST&&(0,a.jsx)(ep,{versionsLoading:!1,sortedVersions:T,versionsError:A,openMenuId:k,t:r,buildSummaryMeta:R,setOpenMenuId:z,setDeleteModal:E,setRenameModal:M,handleSelectVersion:I,enterDetailAfterStart:P}),(0,a.jsx)(ex,{renameModal:_,deleteModal:L,setRenameModal:M,setDeleteModal:E,handleConfirmRename:$,handleConfirmDelete:V,t:r}),w===m.Pf.CONTENT&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ev,{t:r,currentActionId:N?String(N):null,isDownloading:ey,handleDownload:ew,goBackToList:F,enterDetailAfterStart:P}),(0,a.jsxs)("div",{id:"tool-container-summarization",className:"tool-container-summarization px-6",ref:J,children:[(0,a.jsx)(em.MarkdownEditor,{ref:W,content:er,visible:!0,editable:!0,forceEditorView:!0,onChange:eN,onSave:eC,onEditorReady:eb,onEditorCreated:eh,isLoading:!1,excludeTranslationBlocksOnChange:!0,showAddToFlowNoteButton:!0,showChatButton:!0,chatIconSrc:"/cdn/common/tool/ai-chat.png",enableFlowNoteBlock:!0,enableMathBlock:!0,enableFormattingToolbar:!0,scrollContainer:"tool-container-summarization",downloadConfig:{enabled:!1,filename:ei,exportOptions:{scale:2,quality:.98,margin:10,onProgress:e=>{100===e&&l({title:r("config.summary.downloadComplete"),description:r("config.summary.downloadSuccessDescription"),variant:"success"})}}},onChatWithEditor:({contentText:e})=>{try{let{addSelectedTextForChat:t,setShowChat:r}=i.bh.getState();e&&e.trim()&&t(e.trim()),r(!0)}catch(e){console.error("Failed to open chat with selection",e)}},onAddToFlowNoteWithEditor:async({contentText:e})=>{try{let t=(0,ef.l)((e||"").trim()),a=Number(n);if(!t||!a)return;let s=await (0,eo.r3)({projectId:a,insertedContent:t,label:"From Summary"});try{let e={projectId:a},t=s?.content;t&&"string"==typeof t?(e.content=t,document.dispatchEvent(new CustomEvent("flownote:inserted",{detail:e}))):document.dispatchEvent(new CustomEvent("flownote:refresh",{detail:e})),l({title:r("config.summary.flownote"),description:r("config.summary.addedSuccessfully"),variant:"success"})}catch{}}catch(e){console.error("Add to FlowNote from Summary failed:",e)}}},en),(0,a.jsx)(eM,{currentSummaryId:S.id,currentSummaryText:S.summary,displaySources:ec})]})]})]}):(0,a.jsx)(s.Fragment,{})});eH.displayName="SummaryContent";let eW=({className:e="",content:t,id:r,isActive:n=!0})=>{let{projectId:i}=(0,X.g)(),{model:{content:l},actions:{handleEditorCreated:o,handleEditorReady:c,handleContentChange:d}}=function({initialContent:e}
3){let[t,r]=(0,s.useState)(e),[n,a]=(0,s.useState)(!1),i=(0,s.useRef)(null);(0,s.useEffect)(()=>{void 0!==e&&queueMicrotask(()=>r(e))},[e]);let l=(0,s.useCallback)(e=>{i.current=e},[]);return{model:{content:t,isEditorReady:n,editorRef:i},actions:{handleEditorCreated:l,handleEditorReady:(0,s.useCallback)(()=>{a(!0)},[]),handleContentChange:(0,s.useCallback)(e=>{r(e)},[])}}}({initialContent:t});return(0,a.jsx)("div",{className:`w-full h-full flex flex-col ${e}`,children:"string"==typeof l&&l.length>0&&(0,a.jsx)("div",{className:"p-6",children:(0,a.jsx)(em.MarkdownEditor,{content:l,visible:n,onChange:d,onEditorReady:c,onEditorCreated:o,showAddToFlowNoteButton:!1,showChatButton:!1,enableFormattingToolbar:!1,editable:!1,enableFlowNoteBlock:!0,enableMathBlock:!0},`chapter-description-editor-${r??i}`)})})};var eQ=r(60332);function eU(e){let{t}=(0,o.Bd)(),{isActive:r=!0}=e,{model:{chapters:n,selectedId:i,isLoading:l},actions:{handleChapterClick:c}}=function(){let e=(0,m.r)(e=>e.getTab(m.SL.CHAPTER)),t=e.viewState===m.Pf.LOADING,r=e.viewState===m.Pf.CONTENT?e.content:null,n=(0,eg.R)(e=>
3e.setSelectedId),[a,i]=(0,s.useState)([]),[l,o]=(0,s.useState)(null),[c,d]=(0,s.useState)(null),[u,f]=(0,s.useState)(""),[g,p]=(0,s.useState)(!1),x=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(r?.id!==x.current||!(a.length>0)){if(r&&r.content){try{let e=JSON.parse(r.content);d(e);let t=[];if(e.summarized_documents&&Array.isArray(e.summarized_documents)){let r=new Map;e.summarized_documents.forEach(e=>{let t=e.document_id;r.has(t)||r.set(t,[]),r.get(t).push(e)});let n=1;if(r.forEach((e,a)=>{let s=Array.from(r.keys()).indexOf(a);e.forEach((e,r)=>{t.push({id:n,title:e.title||`Chapter ${n}`,description:e.summary||"",pageNumber:`Page ${n}`,documentIndex:s,chapterIndex:r,chapterId:e.chapter_id,documentId:e.document_id}),n+=1})}),0===t.length){let r=1;e.summarized_documents.forEach((e,n)=>{e.chapters&&Array.isArray(e.chapters)&&e.chapters.forEach((e,a)=>{t.push({id:r,title:e.title||`Chapter ${r}`,description:e.summary||"",pageNumber:`Page ${r}`,documentIndex:n,chapterIndex:a}),r+=1})})}}else if(e.document_chapter_summaries&&Array.isArray(e.document_chapter_summaries)){let r=1;e.document_chapter_summaries.forEach((e,n)=>{e.chapters&&Array.isArray(e.chapters)&&e.chapters.forEach((e,a)=>{t.push({id:r,title:e.title||`Chapter ${r}`,description:e.summary||"",pageNumber:`Page ${r}`,documentIndex:n,chapterIndex:a}),r+=1})})}else Array.isArray(e)&&(t=e.map((e,t)=>({id:t+1,title:e.title||e.chapter?.title||`Chapter ${t+1}`,description:e.description||e.summary||e.chapter?.summary||"",pageNumber:e.pageNumber||`Page ${t+1}`,documentIndex:-1,chapterIndex:-1})));i(t),x.current=r.id,t.length>0&&null===l&&(o(t[0].id),f(t[0].description))}catch(e){console.error("Chapter parse error",e),i([]),x.current=null}return}i([]),x.current=null}},[r?.id,r?.content,a.length,l]);let h=(0,s.useMemo)(()=>a.find(e=>e.id===l),[a,l]),b=async e=>{if(!l||!c||!r)return;let t=a.find(e=>e.id===l);if(t&&-1!==t.documentIndex&&-1!==t.chapterIndex){f(e),i(t=>t.map(t=>t.id===l?{...t,description:e}:t));try{let n=JSON.parse(JSON.stringify(c));if(n.summarized_documents&&Array.isArray(n.summarized_documents)){let r=!1;if(t.chapterId){let a=n.summarized_documents.findIndex(e=>e.chapter_id===t.chapterId);a>=0&&(n.summarized_documents[a].summary=e,r=!0)}if(!r&&void 0!==t.documentId){let a=n.summarized_documents.filter(e=>e.document_id===t.documentId);if(t.chapterIndex>=0&&t.chapterIndex<a.length){let s=a[t.chapterIndex],i=n.summarized_documents.findIndex(e=>e.chapter_id===s.chapter_id);i>=0&&(n.summarized_documents[i].summary=e,r=!0)}}if(!r&&n.summarized_documents[t.documentIndex]?.chapters){let r=n.summarized_documents[t.documentIndex];r&&r.chapters&&r.chapters[t.chapterIndex]&&(r.chapters[t.chapterIndex].summary=e)}}else if(n.document_chapter_summaries){let r=n.document_chapter_summaries[t.documentIndex];r&&r.chapters&&r.chapters[t.chapterIndex]&&(r.chapters[t.chapterIndex].summary=e)}p(!0);let a=n.summarized_documents||n.document_chapter_summaries||n,s=await (0,eQ.QC)({summary_id:r.id,summarized_documents:a}),i={...r,content:JSON.stringify(n),modify_time:s?.modify_time||new Date().toISOString()};m.r.getState().setContent(m.SL.CHAPTER,i),d(n)}catch(e){console.error("Chapter update error:",e)}finally{p(!1)}}};return{model:{chapters:a,selectedId:l,selectedChapter:h,selectedChapterContent:u,isLoading:t,isUpdating:g},actions:{handleChapterClick:e=>{o(e.id),f(e.description),void 0!==e.documentId&&null!==e.documentId&&n(e.documentId)},handleContentChange:b}}}();return l?(0,a.jsx)("div",{className:"w-full h-full flex items-center justify-center",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"}),(0,a.jsx)("p",{className:"mt-2 text-gray-600",children:t("config.projectDetail.loadingChapters")})]})}):0===n.length?(0,a.jsx)("div",{className:"w-full h-full flex items-center justify-center",children:(0,a.jsx)("div",{className:"text-center",children:(0,a.jsx)("p",{className:"text-gray-600",children:"No chapters available"})})}):(0,a.jsx)("div",{className:"relative bg-white overflow-hidden w-full h-full",children:(0,a.jsx)("div",{className:"flex h-full w-full",children:(0,a.jsx)("div",{className:"flex-1 w-full overflow-y-auto",children:(0,a.jsx)("div",{className:"p-6",children:(0,a.jsx)("div",{className:"max-w-4xl mx-auto",children:(0,a.jsx)("main",{className:"flex flex-col items-start p-3 relative rounded-[var(--colors-surface-border-radius-radius-s-md)] overflow-hidden border border-solid border-transparent","data-model-id":"I622:7621;148:1026",role:"main","aria-label":"Page content list",children:n.map((e,t)=>{let s=i===e.id;return(0,a.jsxs)("article",{className:`flex flex-col items-start gap-2 p-3 relative self-stretch w-full flex-[0_0_auto] rounded-md cursor-pointer hover:bg-gray-50 transition-colors border-2 ${s?"bg-blue-50 border-blue-300 shadow-sm":"border-transparent hover:bg-gray-50"}
3 ${t===n.length-1?"mb-[-12.00px]":""}`,onClick:()=>c(e),children:[(0,a.jsxs)("header",{className:"inline-flex items-center justify-center gap-1.5 px-2 py-1.5 relative flex-[0_0_auto] bg-gray-100 rounded-md",children:[(0,a.jsx)("div",{className:"relative w-1 h-1 bg-gray-500 rounded-sm aspect-[1]","aria-hidden":"true"}),(0,a.jsx)("span",{className:"w-fit font-normal text-xs leading-[normal] relative mt-[-1.00px] [font-family:'Inter',Helvetica] text-gray-700 tracking-[0]",children:e.pageNumber})]}),(0,a.jsxs)("div",{className:"inline-flex flex-col items-start gap-2 px-2 py-0 relative flex-[0_0_auto]",children:[(0,a.jsx)("h2",{className:"w-full font-semibold text-base leading-6 relative mt-[-1.00px] [font-family:'Inter',Helvetica] text-gray-900 tracking-[0] line-clamp-2",children:(e=>{try{return e.replace(/\s*\[R\]\(source=\d+\)\s*$/g,"").trim()}catch(t){return console.error("❌ Chapter cleanTitle error:",t),e}})(e.title)}),(0,a.jsx)("div",{className:"relative flex items-center justify-center w-full [font-family:'Inter',Helvetica] font-normal text-gray-700 text-sm tracking-[0] leading-[21px] line-clamp-3",children:e.description?(0,a.jsx)(eW,{content:e.description,id:e.id,isActive:r}):""})]})]},e.id)})})})})})})})}var eZ=r(32109),eK=r(23519),eY=r(6949),eJ=r(89301),eX=r(14825),e0=r(12669),e1=r(6958),e2=r(92205),e4=r(91971),e5=r(25031),e3=r(55841);let e6=e=>{let{text:t,readonly:r,onChange:n,onComposition:i,afterInit:l}=e,o=(0,s.useCallback)(e=>(0,a.jsx)(e9,{...e}),[]),c=[t],d=(0,s.useMemo)(()=>{let e=(0,e3.Ni)((0,e5.$k)((0,e4.o$)((0,e1.ie)())));return l&&l(e),e},[]);return(0,s.useEffect)(()=>{t!==d.children[0]&&(d.children=[t],d.onChange())},[t,d]),(0,a.jsx)(e4.A,{editor:d,initialValue:c,onChange:e=>{n&&n({newText:d.children[0],operations:d.operations})},children:(0,a.jsx)(e4.Fo,{className:"slate-editable-container plait-text-container",renderElement:e=>(0,a.jsx)(e7,{...e}),renderLeaf:o,readOnly:void 0===r||r,onCompositionStart:e=>{i&&i(e)},onCompositionUpdate:e=>{i&&i(e)},onCompositionEnd:e=>{i&&i(e)},onKeyDown:e=>{let{selection:t}=d;if(t&&e1.Q6.isCollapsed(t)){let{nativeEvent:t}=e;if((0,e2.Sn)("left",t)){e.preventDefault(),e1.gB.move(d,{unit:"offset",reverse:!0});return}if((0,e2.Sn)("right",t)){e.preventDefault(),e1.gB.move(d,{unit:"offset"});return}}}})})},e7=e=>{let{attributes:t,children:r,element:n}=e;return"link"===n.type?(0,a.jsx)("a",{...t,href:n.url,target:"_blank",rel:"noopener noreferrer",style:{color:"blue",textDecoration:"underline"},children:r}):(0,a.jsx)(e8,{...e})},e8=({attributes:e,children:t,element:r})=>{let n={textAlign:r.align};return(0,a.jsx)("div",{style:n,...e,children:t})},e9=({children:e,leaf:t,attributes:r})=>(t.bold&&(e=(0,a.jsx)("strong",{children:e})),t.code&&(e=(0,a.jsx)("code",{children:e})),t.italic&&(e=(0,a.jsx)("em",{children:e})),t.underlined&&(e=(0,a.jsx)("u",{children:e})),(0,a.jsx)("span",{style:{color:t.color},...r,children:e})),te=(0,s.createContext)(null),tt=new WeakMap;var tr=r(32535);let tn=({value:e,children:t,options:r,plugins:n,viewport:i,theme:l,onChange:o,onSelectionChange:c,onValueChange:d,onViewportChange:u,onThemeChange:m})=>{let[f,g]=(0,s.useState)(()=>{let t=ta(e,r,n,i,l),a=ts(t);return{v:0,board:t,listRender:a}}),{board:p,listRender:x}=f,h=(0,s.useRef)(f);h.current=f;let b=(0,s.useCallback)(()=>{let{board:e,listRender:t}=h.current;o&&o({children:e.children,operations:e.operations,viewport:e.viewport,selection:e.selection,theme:e.theme});let r=e.operations.some(e=>eX.K9d.isSetSelectionOperation(e)),n=e.operations.some(e=>eX.K9d.isSetViewportOperation(e)),a=e.operations.some(e=>eX.K9d.isSetThemeOperation(e)),s=e.operations.length>0&&!e.operations.every(e=>eX.K9d.isSetSelectionOperation(e)||eX.K9d.isSetViewportOperation(e)||eX.K9d.isSetThemeOperation(e));d&&s&&d(e.children),c&&r&&c(e.selection),u&&n&&u(e.viewport),m&&a&&m(e.theme.themeColorMode),g(r=>({v:r.v+1,board:e,listRender:t}))},[o,c,d]);(0,s.useEffect)(()=>(eX.EJk.set(p,()=>{try{if(p.operations.length&&p.operations.every(e=>"set_selection"===e.type))return void x.update(p.children,{board:p,parent:p,parentG:eX.baC.getElementHost(p)});let e=p.operations.length&&p.operations.some(e=>"set_viewport"===e.type);if(e&&(0,eX.Ah0)(p)){(0,eX.qFw)(p,!1),x.update(p.children,{board:p,parent:p,parentG:eX.baC.getElementHost(p)});return}x.update(p.children,{board:p,parent:p,parentG:eX.baC.getElementHost(p)}),e?(0,eX.LIL)(p):(0,eX.md1)(p),(0,eX.pY6)(p),(0,eX.lV$)(p).forEac
3h(e=>{eX.ZRF.getElementRef(e).updateActiveSection()})}catch(e){tr.default.capture("mindmap_board_on_change_error",{error:e instanceof Error?e.message:String(e)})}}),eX.HRK.set(p,()=>{b()}),()=>{eX.EJk.delete(p),eX.HRK.delete(p)}),[p]);let y=(0,s.useRef)(!0);return(0,s.useEffect)(()=>{if(y.current){y.current=!1;return}if(e!==f.board.children&&!eX.nAq.get(p))try{p.children=e,x.update(p.children,{board:p,parent:p,parentG:eX.baC.getElementHost(p)}),eX.kM2.fitViewport(p)}catch(s){tr.default.capture("mindmap_board_reinitialize",{error:s instanceof Error?s.message:String(s)});let t=ta(e,r,n,i,l),a=ts(t);g(e=>({v:e.v+1,board:t,listRender:a}))}},[e]),(0,a.jsx)(te.Provider,{value:f,children:t})},ta=(e,t,r,n,s)=>{var i;let l=(0,eX.gnu)((0,eX.Fne)((0,eX.bzg)((0,eX.$kC)((0,eX.VMe)((0,eX.$Ez)((0,eX.dJ_)((0,eX.znj)((0,eX.tq0)(((i=(0,eJ.Mo)((0,eJ.ij)((0,eX.NJD)(e,t)))).renderText=(e,t)=>{let r,n=(0,e0.createRoot)(e),s=(0,a.jsx)(e6,{...t,afterInit:e=>{r=e,t.afterInit&&t.afterInit(e)}});n.render(s);let i={...t};return{destroy:()=>{setTimeout(()=>{n.unmount()},0)},update:e=>{if(!(e&&i&&!Object.keys(e).every(t=>e[t]===i[t])))return;let t=e4.rL.isReadOnly(r);i={...i,...e},n.render((0,a.jsx)(e6,{...i})),!0===t&&!1===i.readonly?setTimeout(()=>{e4.rL.focus(r)},0):!1===t&&!0===i.readonly&&(e4.rL.blur(r),e4.rL.deselect(r))}}},i))))))))));return r.forEach(e=>{l=e(l)}),(e=>{let{touchStart:t,touchMove:r,touchEnd:n}=e,a=[],s=!1;return e.touchStart=r=>{a=Array.from(r.touches).map(e=>({pointerId:e.identifier,lastPoint:[e.clientX,e.clientY],currentPoint:[e.clientX,e.clientY],hasMoved:!1})),tt.set(e,a),a.length>=2&&e.viewport.zoom,t(r)},e.touchMove=t=>{if(Array.from(t.changedTouches).forEach(e=>{let t=a.find(t=>t.pointerId===e.identifier);t&&(t.lastPoint=t.currentPoint,t.currentPoint=[e.clientX,e.clientY],t.hasMoved=!0)}),2===a.length&&t.preventDefault(),2===a.length&&a.every(e=>e.hasMoved)){let[t,r]=a,n=(0,eX.t4)(...t.lastPoint,...r.lastPoint),i=(0,eX.t4)(...t.currentPoint,...r.currentPoint),l=i[0]-n[0],o=i[1]-n[1],c=eX.baC.getBoardContainer(e).getBoundingClientRect(),d=c.width/2,u=c.height/2,m=e.viewport.zoom,f=(0,eX._ay)(e),g=f[0]+d/m-l/m,p=f[1]+u/m-o/m,x=[g-c.width/2/m,p-c.height/2/m],h=m,b=(0,eX.vH6)(...t.lastPoint,...r.lastPoint),y=(0,eX.vH6)(...t.currentPoint,...r.currentPoint)/b,v=[t.currentPoint[0]-t.lastPoint[0],t.currentPoint[1]-t.lastPoint[1]],w=[r.currentPoint[0]-r.lastPoint[0],r.currentPoint[1]-r.lastPoint[1]],j=(v[0]*w[0]+v[1]*w[1])/(Math.sqrt(v[0]*v[0]+v[1]*v[1])*Math.sqrt(w[0]*w[0]+w[1]*w[1])||1);if(s=!!(j<-.7)||!!(j<=.8)&&!!s&&!!(y>=.01)){h=Math.min(Math.max(e.viewport.zoom*y,eX.DQk),eX.nDQ);let t=eX.baC.getBoardContainer(e).getBoundingClientRect(),r=i[0]-t.x,n=i[1]-t.y;x=[(g=x[0]+r/m)-r/h,(p=x[1]+n/m)-n/h]}eX.kM2.updateViewport(e,x,h),a[0].lastPoint=t.currentPoint,a[1].lastPoint=r.currentPoint,a[0].hasMoved=!1,a[1].hasMoved=!1;return}r(t)},e.touchEnd=t=>{let r=a.findIndex(e=>e.pointerId===t.changedTouches[0].identifier);-1!==r&&a.splice(r,1),tt.set(e,a),n(t)}})(l),l.pointer=eX.iP5.selection,n&&(l.viewport=n),s&&(l.theme=s),l},ts=e=>new eX.xE4(e);var ti=r(66935),tl=r(69730),to=r.n(tl),tc=r(81328);r(41188);let td=({style:e,className:t,children:r,afterInit:n})=>{let i,l=(0,s.useRef)(null),o=(0,s.useRef)(null),c=(0,s.useRef)(null),d=(0,s.useRef)(null),u=(0,s.useRef)(null),m=(0,s.useRef)(null),f=(0,s.useRef)(null),g=(0,s.useRef)(null),p=(()=>{let e=(0,s.useContext)(te);if(!e)throw Error("The `useBoard` hook must be used inside the <PlaitMindMapWrapper> component's context.");let{board:t}=e;return t})(),x=(()=>{let e=(0,s.useContext)(te);if(!e)throw Error("The `useListRender` hook must be used inside the <PlaitMindMapWrapper> component's context.");let{listRender:t}=e;return t})();return(0,s.useEffect)(()=>{for(let e of[o,c,d,u,m])if(e.current)for(;e.current.firstChild;)e.current.removeChild(e.current.firstChild);let e=ti.A.svg(l.current,{options:{roughness:0,strokeWidth:1}});eX.YUW.set(p,e),eX.mAE.set(p,l.current),eX._qh.set(p,!0),eX.$VP.set(p,{lowerHost:o.current,host:c.current,upperHost:d.current,topHost:u.current,activeHost:m.current,container:g.current,viewportContainer:f.current});let t=new eX.Q6Z;if(eX.n1I.set(p,t),eX.EkJ.set(p,new Map),!x.initialized)try{x.initialize(p.children,{board:p,parent:p,parentG:eX.baC.getElementHost(p)}),n&&n(p)}catch(e){console.warn("Failed to initialize listRender:",e)}return(0,eX.e48)(p),(0,eX.LIL)(p),(0,eX.kuF)(p),setTimeout(()=>{try{x.update(p.children,{board:p,parent:p,parentG:eX.baC.getElementHost(p)}),eX.kM2.fitViewport(p)}catch(e){console.warn("Failed to fit viewport:",e)}},100),()=>{eX.n1I.delete(p),eX.HRK.delete(p),eX.EJk.delete(p),eX.$VP.delete(p),eX._qh.delete(p),eX.mAE.delete(p),eX.YUW.delete(p),eX.EkJ.delete(p)}},[p,x]),(0,tc.A)("pointerdown",e=>{p.pointerDown(e)},{target:l}),(0,tc.A)("pointermove",e=>{eX.WD9.set(p,[e.x,e.y]),p.pointerMove(e)},{target:f}),(0,tc.A)("pointerleave",e=>{eX.WD9.delete(p),p.pointerLeave(e)},{target:f}),(0,tc.A)("pointerup",e=>{p.pointerUp(e)},{target:f}),(0,tc.A)("touchstart",e=>{p.touchStart(e)},{target:f}),(0,tc.A)("touchmove",e=>{p.touchMove(e)},{target:f}),(0,tc.A)("touchend",e=>{p.touchEnd(e)},{target:f}),(0,tc.A)("dblclick",e=>{eX.baC.isFocus(p)&&!eX.baC.hasBeenTextEditing(p)&&p.dblClick(e)},{target:l}),(0,tc.A)("pointermove",e=>{eX.D7r.set(p,[e.x,e.y]),p.globalPointerMove(e)}),(0,tc.A)("pointerup",e=>{p.globalPointerUp(e)}),(0,tc.A)("keydown",e=>{p.globalKeyDown(e),!eX.baC.isFocus(p)||eX.baC.hasBeenTextEditing(p)||(0,eX.f2k)(e.target)||p.keyD
3own(e)}),(0,tc.A)("keyup",e=>{eX.baC.isFocus(p)&&!eX.baC.hasBeenTextEditing(p)&&p?.keyUp(e)}),(0,tc.A)("copy",e=>{eX.baC.isFocus(p)&&!eX.baC.hasBeenTextEditing(p)&&(e.preventDefault(),(0,eX.pNi)(p,eX.MwK.copy,e.clipboardData))}),(0,tc.A)("paste",async e=>{if(eX.baC.isFocus(p)&&!eX.baC.isReadonly(p)&&!eX.baC.hasBeenTextEditing(p)){let t=eX.baC.getMovingPointInBoard(p);if(t){let r=(0,eX.Ahc)(p,(0,eX.Wui)(p,t[0],t[1])),n=await (0,eX.bE$)(e.clipboardData);p.insertFragment(n,r,eX.MwK.paste)}}}),(0,tc.A)("cut",e=>{!eX.baC.isFocus(p)||eX.baC.isReadonly(p)||eX.baC.hasBeenTextEditing(p)||(e.preventDefault(),(0,eX.pNi)(p,eX.MwK.cut,e.clipboardData),(0,eX.WD8)(p))}),(0,tc.A)("drop",e=>{eX.baC.isReadonly(p)||(e.preventDefault(),p.drop(e))},{target:f}),(0,tc.A)("dragover",e=>{e.preventDefault()},{target:f}),(0,s.useEffect)(()=>{let e=f.current;if(!e)return;let t=e=>{if((0,eX.bU_)(p))(0,eX.rxT)(p,!1);else{let{scrollLeft:t,scrollTop:r}=e.target;(0,eX.uxW)(p,t,r)}};return e.addEventListener("scroll",t),()=>{e.removeEventListener("scroll",t)}},[p,f]),(0,s.useEffect)(()=>{let e=f.current;if(!e)return;let t=e=>{e.preventDefault()};return e.addEventListener("contextmenu",t),()=>{e.removeEventListener("contextmenu",t)}},[f]),(0,s.useEffect)(()=>{let e=f.current;if(!e)return;let t=e=>{if(e.metaKey||e.ctrlKey){e.preventDefault();let{deltaX:t,deltaY:r}=e,n=p.viewport.zoom,a=Math.sign(r),s=100*eX.bLU,i=Math.abs(r),l=r;i>s&&(l=s*a);let o=n-l/100;o+=-(Math.log10(Math.max(1,n))*a)*Math.min(1,i/20),eX.kM2.updateZoom(p,o,eX.baC.getMovingPointInBoard(p))}};return e.addEventListener("wheel",t,{passive:!1}),()=>{e.removeEventListener("wheel",t)}},[p,f]),i=(0,s.useRef)(!1),(0,s.useEffect)(()=>{let e=new ResizeObserver(()=>{window.requestAnimationFrame(()=>{if(!i.current){i.current=!0;return}(0,eX.e48)(p),(0,eX.LIL)(p),(0,eX.pY6)(p)})});return e.observe(eX.baC.getBoardContainer(p)),()=>{e&&e.disconnect()}},[p]),(0,s.useEffect)(()=>{let e=()=>{l.current&&l.current.querySelectorAll(".collapse-button").forEach(e=>{if(e.hasAttribute("data-arrow-replaced"))return;let t=e.querySelectorAll("path"),r=null,n=e.querySelector('g[stroke-linecap="round"]');if(n&&(r=n.querySelector("path")),!r&&t.length>=3&&(r=t[2]),r){e.setAttribute("data-arrow-replaced","true"),r.style.display="none";let t=e.getBBox(),n=t.x+t.width/2,a=t.y+t.height/2,s=document.createElementNS("http://www.w3.org/2000/svg","path"),i=`M ${n+5} ${a-5} L ${n-5} ${a} L ${n+5} ${a+5}`;s.setAttribute("d",i),s.setAttribute("stroke",getComputedStyle(r).stroke||"#B1C675"),s.setAttribute("stroke-width","2"),s.setAttribute("stroke-linecap","round"),s.setAttribute("stroke-linejoin","round"),s.setAttribute("fill","none"),e.appendChild(s)}})};setTimeout(e,200),setTimeout(e,500),setTimeout(e,1e3),setTimeout(e,2e3);let t=new MutationObserver(()=>{e()});return l.current&&t.observe(l.current,{childList:!0,subtree:!0}),()=>{t.disconnect()}},[]),(0,a.jsx)("div",{className:to()(t,eX.gIz,`${tu()}`,`theme-${p.theme?.themeColorMode}`,`pointer-${p.pointer}`,{focused:eX.baC.isFocus(p),readonly:eX.baC.isReadonly(p)}),ref:g,style:e,children:(0,a.jsxs)("div",{className:"viewport-container viewport-container-hide-scrollbar",ref:f,style:{width:"100%",height:"100%",overflow:"auto"},children:[(0,a.jsxs)("svg",{ref:l,width:"100%",height:"100%",style:{position:"relative"},className:"board-host-svg",children:[(0,a.jsx)("g",{className:"element-lower-host",ref:o}),(0,a.jsx)("g",{className:"element-host",ref:c}),(0,a.jsx)("g",{className:"element-upper-host",ref:d}),(0,a.jsx)("g",{className:"element-top-host",ref:u})]}),(0,a.jsx)("svg",{width:"100%",height:"100%",className:"board-active-svg",children:(0,a.jsx)("g",{className:"active-host-g",ref:m})}),r]})})},tu=()=>eX.YwR?"safari":eX.G_2?"chrome":eX.$Mp?"firefox":"",tm=()=>{let e=(0,s.useContext)(te),[t,r]=(0,s.useState)(!1);if(!e)return null;let n=e.board;return n&&n.viewport?(0,a.jsxs)("div",{className:"absolute bottom-4 left-4 bg-white rounded-lg shadow-lg p-1.5 flex items-center gap-1.5 z-50",style:{fontFamily:"system-ui"},children:[(0,a.jsx)("button",{className:"px-2 py-1 rounded hover:bg-gray-100 flex items-center justify-center",title:"Zoom Out",onClick:e=>{e.preventDefault(),e.stopPropagation();try{eX.kM2.updateZoom(n,n.viewport.zoom-.1)}catch(e){console.error("Failed to update zoom:",e)}},children:(0,a.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:(0,a.jsx)("path",{d:"M3 8h10",
3stroke:"currentColor",strokeWidth:"2"})})}),(0,a.jsxs)("div",{className:"relative",onMouseLeave:()=>r(!1),children:[(0,a.jsxs)("button",{className:"px-2 py-1 rounded hover:bg-gray-100 min-w-[50px] text-sm",title:"Zoom",onClick:()=>{r(!t)},children:[Number((100*(n?.viewport?.zoom||1)).toFixed(0)),"%"]}),t&&(0,a.jsxs)("div",{className:"absolute top-full right-0 mt-1 bg-white rounded-lg shadow-lg py-1 min-w-[120px] z-50",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[(0,a.jsx)("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-gray-100",onClick:e=>{e.preventDefault(),e.stopPropagation();try{eX.kM2.fitViewport(n),r(!1)}catch(e){console.error("Failed to fit viewport:",e)}},children:"Fit View"}),(0,a.jsx)("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-gray-100",onClick:e=>{e.preventDefault(),e.stopPropagation();try{eX.kM2.updateZoom(n,1),r(!1)}catch(e){console.error("Failed to update zoom:",e)}},children:"100%"})]})]}),(0,a.jsx)("button",{className:"px-2 py-1 rounded hover:bg-gray-100 flex items-center justify-center",title:"Zoom In",onClick:e=>{e.preventDefault(),e.stopPropagation();try{eX.kM2.updateZoom(n,n.viewport.zoom+.1)}catch(e){console.error("Failed to update zoom:",e)}},children:(0,a.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:(0,a.jsx)("path",{d:"M8 3v10M3 8h10",stroke:"currentColor",strokeWidth:"2"})})}),(0,a.jsx)("button",{className:"px-2 py-1 rounded hover:bg-gray-100 flex items-center justify-center",title:"Fit to Screen",onClick:e=>{e.preventDefault(),e.stopPropagation();try{eX.kM2.fitViewport(n)}catch(e){console.error("Failed to fit viewport:",e)}},children:(0,a.jsx)("img",{src:"/cdn/components/mindmap/mindmap_location.svg",alt:"Fit to Screen",width:"16",height:"16"})}),t&&(0,a.jsx)("div",{className:"fixed inset-0 z-40",onClick:()=>r(!1)})]}):null},tf=e=>e&&"string"==typeof e.text?e.text:e&&e.children&&Array.isArray(e.children)?e.children.map(e=>"string"==typeof e?e:e&&"string"==typeof e.text?e.text:e&&e.children?tf(e):"").join(""):"",tg=({className:e="",projectId:t,data:r,onChange:n,onValueChange:i})=>{let{t:l}=(0,o.Bd)(),c=(0,s.useRef)(null),d=(0,s.useCallback)(e=>{if(i){let t=(e=>{if(!e||0===e.length)return null;let t=e[0];if(!t||"mindmap"!==t.type)return null;let r=t.data?.topic?tf(t.data.topic):"",n=e=>{let t=e.data?.topic?tf(e.data.topic):"",r=[];return e.children&&Array.isArray(e.children)&&e.children.length>0&&e.children.forEach(e=>{"mind_child"===e.type&&r.push(n(e))}),{name:t,children:r.length>0?r:null}},a=[];return t.children&&Array.isArray(t.children)&&t.children.forEach(e=>{"mind_child"===e.type&&a.push(n(e))}),{name:r,children:a.length>0?a:[]}})(e);t&&(c.current=t,i(t))}},[i]),u=(0,s.useRef)({element:null,error:null}),m=(0,s.useRef)(""),f=(0,s.useMemo)(()=>{if(r&&u.current.element){if(r===c.current)return u.current;try{if(JSON.stringify(r)===m.current)return u.current}catch{}}if(!r){let e={element:null,error:null};return u.current=e,m.current="",e}try{let e={element:((e,t)=>{if(!e)return null;let r=e=>null==e?"":String(e).normalize("NFKC").replace(/[\u2010-\u2015]/g,"-").replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/\u00A0/g," ").trim(),n=0,a=(e="node")=>`${e}-${n++}`,s=(e,n="root",i=1)=>{let l=r(e.name||e.label||e.text);l&&""!==l||(l=t?t("config.projectDetail.defaultNodeName",{parentId:n}):`Node ${n}`);let o=(0,eJ.e0)(l),c=[];e.children&&Array.isArray(e.children)&&e.children.forEach((e,t)=>{e&&c.push(s(e,a(n),i+1))});let d={id:e.id||a(n),type:"mind_child",children:c,data:{topic:o},points:[[0,0]]};return i>=2&&c.length>0&&(d.isCollapsed=!0),d},i=r(e.name||e.title||e.center);i&&""!==i||(i=t?t("config.projectDetail.centralTopic"):"Central Topic");let l=(0,eJ.e0)(i),o=[],c=e.children||e.nodes;return c&&Array.isArray(c)&&c.forEach((e,t)=>{e&&o.push(s(e,a("root")))}),{id:e.id||"root",type:"mindmap",points:[[400,300]],layout:eK.dD.right,children:o,data:{topic:l}}})(r,l),error:null};u.current=e;try{m.current=JSON.stringify(r)}catch{m.current=""}return e}catch(t){console.error("Failed to parse mindmap data:",t);let e={element:null,error:l("config.projectDetail.unableToParseMindmapData")};return u.current=e,m.current="",e}},[r,l]),g=(0,s.useMemo)(()=>f.element?[f.element]:[],[f.element]);if(f.error){let e=(0,eY.O)(f.error,"mindmap");return(0,a.jsx)("div",{className:"w-full h-full flex items-center justify-center",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("p",{className:"text-red-600 mb-4",children:e}),(0,a.jsx)("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700",children:l("config.projectDetail.retry")})]})})}if(!f.element)return(0,a.jsx)("div",{className:"w-full h-full flex items-center justify-center",children:(0,a.jsx)("div",{className:"text-center",children:(0,a.jsx)("p",{className:"text-gray-600",children:l("config.projectDetail.noMindmapDataAvailable")})})});let p={readonly:!1,hideScrollbar:!1,themeColors:eZ.cq},x=[eZ.Dl];return(0,a.jsx)("div",{className:e,style:{width:"100%",height:"100%",position:"relative"},children:(0,a.jsxs)(tn,{value:g,options:p,plugins:x,onChange:n,onValueChange:d,children:[(0,a.jsx)(td,{className:e}),(0,a.jsx)(tm,{})]})})};var tp=r(86048);let tx=s.memo(({isActive:e=!0})=>{let{t}=(0,o.Bd)(),{projectId:r}=(0,X.g)(),{model:{viewState:n,selectedActionId:l,mindmapData:d,isDetailLoa
3ding:u},actions:{backToList:f}}=function(){let{projectId:e}=(0,X.g)(),{viewState:t,actionId:r,content:n}=(0,m.r)(e=>e.getTab(m.SL.MIND_MAP)),a=(0,s.useMemo)(()=>n&&t===m.Pf.CONTENT?n:null,[n,t]),i=t===m.Pf.LOADING,l=(0,s.useMemo)(()=>{if(!a?.content)return null;try{let e=JSON.parse(a.content),t=e?.map_data??e?.mapData??e?.data?.map_data??e?.data?.mapData??e;if(t?.name)return t;return null}catch{return null}},[a]),o=t!==m.Pf.LIST&&!l&&i;return{model:{projectId:e,viewState:t,selectedActionId:r,mindmapData:l,isDetailLoading:o},actions:{backToList:(0,s.useCallback)(()=>{m.r.getState().lifecycle.goToList(m.SL.MIND_MAP)},[])}}}(),{model:{isSaving:g,saveError:p},actions:{handleMindmapChange:x}}=function({projectId:e,mindmapData:t,t:r}){let{toast:n}=(0,c.dj)(),[a,l]=(0,s.useState)(!1),[o,d]=(0,s.useState)(null),u=(0,s.useRef)(""),m=(0,s.useRef)(null),f=(0,s.useRef)(null);(0,s.useEffect)(()=>{t&&(u.current=JSON.stringify(t))},[t]),(0,s.useEffect)(()=>{f.current=null},[e]);let g=(0,s.useCallback)(t=>{let a=JSON.stringify(t);m.current&&clearTimeout(m.current),m.current=setTimeout(async()=>{if(!e||a===u.current)return;let s=es.nc.getState().user?.email?.toLowerCase(),o=!!s&&(s.endsWith("@cuflow.ai")||s.endsWith("@sigmatrx.ai"));if(i.bh.getState().projectDetail?.data?.isFeatured&&!o)return void ed(n,r);try{if(l(!0),null===f.current){let t,r=await (t={project_id:Number(e)},(0,ei.$b)({url:"/api/v1/mindmap/getById",method:"GET",params:t},void 0));f.current=r?.id??0}if(!f.current)return;await (0,R.A_)({mindMapId:f.current,mapData:t})?(d(null),u.current=a):d(r("config.projectDetail.failedToSaveMindmap"))}catch(t){let e=r("config.projectDetail.failedToSave");t instanceof Error&&(e=t.message),d(e),n({title:r("config.projectDetail.saveFailed"),description:e,variant:"destructive",className:"bg-white"}),setTimeout(()=>{d(null)},3e3)}finally{l(!1)}},1e3)},[e,r,n]);return(0,s.useEffect)(()=>()=>{m.current&&clearTimeout(m.current)},[]),{model:{isSaving:a,saveError:o},actions:{handleMindmapChange:g}}}({projectId:r,mindmapData:d,t});return n===m.Pf.LIST?(0,a.jsxs)("div",{className:"w-full h-full flex flex-col gap-6 p-6",children:[r&&(0,a.jsx)("div",{children:(0,a.jsx)(F.StartGeneration,{title:t("config.tabContainer.createMindmap"),description:t("config.tabContainer.createMindmapDesc"),className:"w-full",apiType:"mindmap",showSettingsButton:!0,customizeSaveOnly:!0})}),r&&(0,a.jsx)("div",{children:(0,a.jsx)(J,{projectId:Number(r),tool:"mindmap"})})]}):u?(0,a.jsx)(tp.e,{visible:!0,variant:"versions",overlay:!1,label:t("config.projectDetail.loading",{defaultValue:"Loading..."})}):d?(0,a.jsxs)("div",{className:"w-full h-full flex flex-col overflow-hidden",children:[g&&(0,a.jsxs)("div",{className:"px-4 py-2 bg-blue-50 border-b border-blue-100 flex items-center gap-2 text-sm text-blue-700",children:[(0,a.jsx)("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"}),(0,a.jsx)("span",{children:t("config.projectDetail.savingChanges")})]}),p&&(0,a.jsxs)("div",{className:"px-4 py-2 bg-red-50 border-b border-red-100 flex items-center gap-2 text-sm text-red-700",children:[(0,a.jsx)("svg",{className:"w-4 h-4 flex-shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})}),(0,a.jsx)("span",{children:t("config.projectDetail.autoSaveFailed",{error:p})})]}),(0,a.jsxs)("div",{className:"sticky top-0 z-30 flex items-center justify-between px-6 py-2 bg-white",children:[(0,a.jsxs)("button",{className:"inline-flex items-center gap-2 text-sm text-gray-600 hover:text-gray-900",onClick:f,children:[(0,a.jsx)("img",{src:"/cdn/common/icons/icon-arrow-left.svg",alt:"",className:"h-4 w-4"}),t("config.back")]}),(0,a.jsx)("div",{className:"flex items-center gap-2",children:(0,a.jsx)(F.StartGeneration,{variant:"gearOnly",className:"",apiType:"mindmap",refreshActionId:l?Number(l):void 0})})]}),(0,a.jsx)("div",{className:"flex-1 w-full min-h-0 overflow-hidden",children:e?(0,a.jsx)(tg,{className:"w-full h-full",projectId:r,data:d,onValueChange:x}):null})]}):(0,a.jsx)("div",{className:"w-full h-full flex flex-col items-center justify-center text-xs text-gray-500 gap-2 p-4",children:(0,a.jsx)("div",{children:t("config.projectDetail.noMindmapDataAvailable")})})});tx.displayName="MindmapContent";var th=r(37206),tb=r(75574),ty=r(15947),tv=r(33908);let tw=(0,th.default)(()=>Promise.resolve().then(r.bind(r,4407)).then(e=>
3e.MarkdownEditor),{loadableGenerated:{webpack:()=>[4407]},ssr:!1,loading:()=>(0,a.jsx)("div",{className:"text-gray-400"})}),tj=s.memo(({className:e="",isActive:t=!0})=>{let{model:{projectId:r,currentFlowNote:n,isLoadingFlowNote:l,isDownloading:d,contentToRender:u,downloadFilename:f,t:g},refs:{markdownEditorRef:p,editorContainerRef:x},actions:{handleEditorCreated:h,handleContentChange:b,handleSave:y,handleDownload:v,toast:w}}=function({isActive:e=!0}){let{t}=(0,o.Bd)(),{toast:r}=(0,c.dj)(),{projectId:n}=(0,X.g)(),a=n?Number(n):null,l=(0,m.r)(e=>e.getTab(m.SL.FLOWNOTE)),d=l.viewState===m.Pf.CONTENT?l.content:null,u=l.viewState===m.Pf.LOADING,f=(0,s.useCallback)(async()=>{if(a)try{let e=await (0,tv.gl)({project_id:a}),t="new"===e.status?"pending":e.status||"success",r={id:e.flow_note_id??0,project_id:e.project_id||a,status:t,message:e.message||null,content:e.content||"",document_list:e.document_list||[],document_count:e.document_count||0,create_time:e.create_time||new Date().toISOString(),modify_time:e.modify_time||new Date().toISOString()};m.r.getState().setContent(m.SL.FLOWNOTE,r)}catch(e){console.error("Failed to refetch FlowNote:",e)}}
3,[a]),[g,p]=(0,s.useState)(!1),[x,h]=(0,s.useState)(null),[b,y]=(0,s.useState)(""),v=(0,s.useRef)(null),w=(0,s.useRef)(null),j=(0,s.useRef)(null),{isPrinting:N,handlePrint:C}=(0,tb.c)(j),S=(0,s.useRef)(null),k=(0,s.useRef)(""),z=(0,s.useRef)(null),_=(0,s.useRef)(e),M=(0,s.useMemo)(()=>{let e=new Date().toISOString().split("T")[0],t=d?.id?`-flownote-${d.id}`:"";return`flownote${t}-${e}`},[d?.id]),L=(0,s.useMemo)(()=>d?.content||"",[d?.content]);(0,s.useEffect)(()=>{(d?.id!==z.current||d.content!==k.current)&&(d&&d.content?(k.current=d.content,y(d.content),z.current=d.id):d&&!d.content&&(k.current="",y(""),z.current=d.id))},[d?.id,d?.content]),(0,s.useEffect)(()=>{if(!n)return;let e=e=>{try{let t=e.detail;if(!t?.projectId||Number(t.projectId)!==Number(n))return;if(t.content&&"string"==typeof t.content){if(d&&d.id){let e={...d,content:t.content,modify_time:new Date().toISOString()};m.r.getState().setContent(m.SL.FLOWNOTE,e),k.current=t.content,y(t.content)}else f();return}f()}catch(e){console.error("Error handling flownote:inserted event:",e)}},t=e=>{try{let t=e.detail;if(!t?.projectId||Number(t.projectId)!==Number(n))return;f()}catch(e){console.error("Error handling flownote:refresh event:",e)}};return document.addEventListener("flownote:inserted",e),document.addEventListener("flownote:refresh",t),()=>{document.removeEventListener("flownote:inserted",e),document.removeEventListener("flownote:refresh",t)}},[n,f,d]);let E=(0,s.useCallback)(e=>{v.current=e},[]),T=(0,s.useCallback)(async(e,n=!1)=>{let a=ty.d.getState().updateFlowNote,s=m.r.getState().getTab(m.SL.FLOWNOTE).content;if("number"!=typeof s?.id||!n&&e===k.current)return;let l=es.nc.getState().user?.email?.toLowerCase(),o=!!l&&(l.endsWith("@cuflow.ai")||l.endsWith("@sigmatrx.ai"));if(i.bh.getState().projectDetail?.data?.isFeatured&&!o)return void ed(r,t);try{p(!0),h(null),await a(s.id,e),k.current=e,n&&r({title:"Success",description:"FlowNote saved successfully",variant:"success"})}catch(e){h(e instanceof Error?e.message:"Failed to save"),setTimeout(()=>h(null),3e3)}finally{p(!1)}},[r,t]),A=(0,s.useCallback)(e=>{y(e),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{T(e)},1e3)},[T]),I=(0,s.useCallback)((e,t=!0)=>{S.current&&(clearTimeout(S.current),S.current=null),T(e,t)},[T]);return(0,s.useEffect)(()=>()=>{S.current&&clearTimeout(S.current)},[]),(0,s.useEffect)(()=>{_.current&&!e&&!u&&b&&b!==k.current&&(S.current&&(clearTimeout(S.current),S.current=null),T(b,!1)),_.current=e},[e,b,T,u]),{model:{projectId:n,currentFlowNote:d,isLoadingFlowNote:u,isSaving:g,saveError:x,isDownloading:N,editorContent:b,contentToRender:L,downloadFilename:M,t},refs:{markdownEditorRef:w,editorContainerRef:j},actions:{handleEditorCreated:E,handleContentChange:A,handleSave:I,handleDownload:C,toast:r}}}({isActive:t});return l?(0,a.jsx)(tp.e,{visible:!0,label:g("config.projectDetail.loading",{defaultValue:"Loading..."})}):(0,a.jsxs)("div",{className:`w-full h-full flex flex-col ${e}`,children:[(0,a.jsx)("div",{className:"flex justify-end px-6 pt-4 pb-2",children:(0,a.jsx)("button",{onClick:v,disabled:d,className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",title:d?g("config.projectDetail.downloading"):g("config.projectDetail.downloadPdf"),children:d?(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("img",{src:"https://cdn.eu.cuflow.ai/frontend/cdn/common/loading/loading-black.svg",alt:g("config.projectDetail.loading"),width:16,height:16,className:"animate-spin"},"loading-icon")}):(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("img",{src:"/icons/download.svg",alt:g("config.projectDetail.downloadPdf"),width:20,height:20},"download-icon")})})}),(0,a.jsx)("div",{className:"p-6 relative",ref:x,children:(0,a.jsx)(tw,{ref:p,content:u,visible:!0,onChange:b,onSave:y,onEditorCreated:h,isLoading:l,placeholder:g("config.projectDetail.flowNotePlaceholder"),showAddToFlowNoteButton:!1,showChatButton:!0,chatIconSrc:"/cdn/common/tool/ai-chat.png",enableFlowNoteBlock:!0,enableMathBlock:!0,enableFormattingToolbar:!0,scrollContainer:"tool-container-flownote",downloadConfig:{enabled:!1,filename:f,exportOptions:{scale:2,quality:.98,margin:10,onProgress:e=>{100===e&&w({title:g("config.projectDetail.downloadComplete"),description:g("config.projectDetail.downloadSuccessDescription"),variant:"success"})}}},onChatWithEditor:({contentText:e})=>{try{let{addSelectedTextForChat:t,setShowChat:r}=i.bh.getState();e&&e.trim()&&t(e.trim()),r(!0)}catch(e){console.error("Failed to open chat with selection",e)}}},`flownote-editor-${n?.id??r}`)})]})});var tN=r(45113);let tC=({onViewAll:e,onPrevious:t,onComplete:r})=>{let{t:n}=(0,o.Bd)();return(0,a.jsxs)("section",{className:"flex flex-col w-full h-[660px] items-start relative",children:[(0,a.jsxs)("section",{className:"relative flex flex-col items-center justify-center gap-1 flex-1 self-stretch w-full bg-white rounded-xl border border-solid border-gray-200 shadow-sm overflow-hidden min-h-0 bg-gradient-to-b from-[rgba(255,204,0,0.12)] to-[rgba(255,204,0,0)]",children:[(0,a.jsxs)("div",{className:"absolute top-24 left-1/2 -translate-x-1/2 w-[410px] h-[200px] pointer-events-none select-none",children:[(0,a.jsx)("img",{className:"absolute w-[72.68%] h-full top-0 left-[17.32%]",alt:n("config.flashcardCompleted.flashcardCompletionIllustration"),src:"/cdn/components/flashcard/1.svg"}),(0,a.jsxs)("div",{className:"absolute w-full h-[52.35%] top-0 left-0",children:[(0,a.jsx)("img",{className:"absolute w-[6.07%] h-[15.10%] top-[16.53%] left-[93.93%]",alt:"",src:"/cdn/components/flashcard/3.svg"}),(0,a.jsx)("img",{className:"absolute w-[4.56%] h-[11.47%] top-[88.53%] left-[14.89%]",alt:"",src:"/cdn/components/flashcard/3-1.svg"}),(0,a.jsx)("img",{className:"absolute w-[2.41%] h-[8.48%] top-0 left-[74.00%]",alt:"",src:"/cdn/components/flashcard/25-6.svg"}),(0,a.jsx)("img",{className:"absolute w-[3.27%] h-[6.78%] top-[4.86%] left-[28.27%]",alt:"",src:"/cdn/components/flashcard/271.svg"}),(0,a.jsx)("img",{className:"absolute w-[7.33%] top-3 left-0 h-[19px] aspect-[1.61]",alt:"",src:"/cdn/components/flashcard/11.svg"})]})]}),(0,a.jsxs)("div",{className:"flex flex-col h-auto items-center justify-center gap-1 px-6 py-0 relative self-stretch w-full -mb-24",children:[(0,a.jsxs)("h1",{className:"relative flex items-center justify-center self-stretch text-slate-900 text-4xl text-center font-semibold italic",children:[n("config.flashcardCompleted.allFlashcardsCompleted")," ",(0,a.jsxs)("span",{className:"font-semibold inline-block relative",children:[(0,a.jsx)("span",{className:"relative z-[2] ml-2",children:n("config.flashcardCompleted.completed")}),(0,a.jsx)("svg",{viewBox:"0 0 71 17",preserveAspectRatio:"none",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"absolute left-0 bottom-[-7px] w-full h-[18px] z-[1]",children:(0,a.jsx)("path",{d:"M2.00055 9.48306C8.70055 6.89701 21.1869 -0.343967 30.9324 2.75931C36.3286 4.47765 3.82782 17.2413 15.4005 14.6552C26.9733 12.0691 50.1187 5.34537 69.0006 12.0691",stroke:"#FFDD00",strokeWidth:"4",strokeLinecap:"round"})})]})]}),(0,a.jsxs)("p",{className:"relative flex items-center justify-center self-stretch text-slate-900 text-xl text-center font-medium mt
3-4",children:[n("config.flashcardCompleted.finishedAllCards")," ",(0,a.jsx)("br",{}),n("config.flashcardCompleted.greatJob")]})]})]}),(0,a.jsx)("footer",{className:"flex items-center justify-end relative self-stretch w-full mt-4",children:(0,a.jsxs)("div",{className:"inline-flex items-center gap-3",children:[(0,a.jsxs)("button",{className:"inline-flex items-center gap-1 px-4 py-2.5 bg-white rounded-md border border-gray-300 hover:bg-gray-50 transition-colors",onClick:t,children:[(0,a.jsx)("img",{className:"relative w-4 h-4",alt:"",src:"/cdn/common/icons/icon-arrow-left.svg"}),(0,a.jsx)("span",{className:"text-gray-700 text-sm",children:n("config.flashcardCompleted.previous")})]}),(0,a.jsx)("button",{className:"inline-flex items-center justify-center px-5 py-2.5 bg-gray-900 text-white rounded-md hover:opacity-90 transition-opacity",onClick:r,children:(0,a.jsx)("span",{className:"text-sm",children:n("config.flashcardCompleted.complete")})})]})})]})};var tS=r(73321),tk=r(19232),tz=r(1465);let t_=({projectId:e,flashcards:t=[]})=>{let{t:r}=(0,o.Bd)(),n=(0,tS.useSearchParams)(),i=e||(n?.get("projectId")?parseInt(n.get("projectId")):void 0),[l,c]=(0,s.useState)(null),[d,u]=(0,s.useState)(!0),[m,f]=(0,s.useState)(null),[g,p]=(0,s.useState)({}
3),[x,h]=(0,s.useState)({}),[b,y]=(0,s.useState)(0),v=(i?t.filter(e=>e.project_id===i):t).map((e,t)=>({id:e.id,cardNumber:r("config.flashcardResultOverview.card",{number:t+1}),isBookmarked:void 0!==x[e.id]?x[e.id]:e.isStarred||!1,term:e.term,definition:e.definition,isExpanded:g[e.id]||!1}));(0,s.useEffect)(()=>{(async()=>{if(i)try{u(!0),f(null);let e=await (0,tk.Vt)({project_id:i});c(e.statistics)}catch(e){console.error("\uD83D\uDFE1 FlashcardResultOverview: Failed to fetch flashcard statistics:",e),f(e instanceof Error?e.message:r("config.flashcardResultOverview.failedToLoadStatistics",{error:"Unknown error"}))}finally{u(!1)}})()},[i,e,n,r]);let w=Array.from({length:v.length},(e,t)=>({id:t+1,label:String(t+1)}));return(0,a.jsxs)("div",{className:"flex flex-col w-full h-full items-center pt-0 pb-6 px-4 sm:px-6 relative bg-white overflow-auto",children:[(0,a.jsx)("section",{className:"flex flex-col w-full max-w-[710px] min-h-[660px] items-start relative mb-[-8.00px]",children:(0,a.jsxs)("div",{className:"flex-col flex-1 grow flex items-center gap-4 sm:gap-6 relative self-stretch w-full",children:[(0,a.jsx)("article",{className:"flex-col items-center justify-center rounded-lg overflow-hidden border-[0.5px] border-solid border-gray-200 shadow-[0px_0px_12px_#0f172a0f] bg-gradient-to-b from-yellow-50 to-white flex relative self-stretch w-full flex-[0_0_auto]",children:m?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4 p-8",children:[(0,a.jsx)("p",{className:"text-red-600 text-center",children:r("config.flashcardResultOverview.failedToLoadStatistics",{error:m})}),(0,a.jsx)("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700",children:r("config.flashcardResultOverview.retry")})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("header",{className:"gap-2.5 px-4 py-3 self-stretch w-full flex items-center relative flex-[0_0_auto]",children:(0,a.jsx)("h2",{className:"relative flex items-center justify-center w-fit mt-[-1.00px] font-medium text-gray-600 text-xs text-center tracking-[0] leading-[18px] whitespace-nowrap",children:r("config.flashcardResultOverview.studyStatistics")})}),(0,a.jsxs)("div",{className:"pt-2 pb-6 px-4 sm:px-10 flex-[0_0_auto] flex flex-col sm:flex-row items-center gap-4 sm:gap-6 relative self-stretch w-full overflow-x-auto",children:[(0,a.jsxs)("div",{className:"inline-flex items-center justify-center gap-2.5 relative flex-[0_0_auto] flex-shrink-0",children:[(0,a.jsx)("img",{className:"relative w-[80px] h-[80px] sm:w-[110px] sm:h-[110px] mt-[-1.00px] mb-[-1.00px] ml-[-1.00px] mr-[-1.00px] aspect-[1]",alt:r("config.flashcardResultOverview.completionCircle"),src:"/cdn/components/flashcard/70-85-30-30-00.svg"}),(0,a.jsx)("div",{className:"absolute top-[calc(50.00%_-_8px)] left-[calc(50.00%_-_24px)] sm:left-[calc(50.00%_-_31px)] h-[17px] flex items-center justify-center font-medium text-slate-900 text-xl sm:text-2xl text-center tracking-[-0.48px] leading-9 whitespace-nowrap",children:d?"...":l?"100%":"0%"}),(0,a.jsx)("div",{className:"absolute left-[calc(50.00%_-_65px)] sm:left-[calc(50.00%_-_87px)] -bottom-3 w-[130px] sm:w-[173px] h-[52px] sm:h-[69px] bg-[100%_100%]",style:{backgroundImage:"url(/cdn/components/flashcard/2x.png)"},children:(0,a.jsx)("div",{className:"inline-flex gap-2.5 px-2.5 py-[7px] absolute left-[calc(50.00%_-_30px)] sm:left-[calc(50.00%_-_38px)] bottom-[9px] bg-yellow-300 rounded-full items-center justify-center",children:(0,a.jsx)("span",{className:"relative flex w-fit font-normal italic text-slate-900 text-xs sm:text-sm text-center tracking-[0] leading-[21px] whitespace-nowrap items-center justify-center",children:r("config.flashcardResultOverview.perfect")})})})]}),(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center gap-2 px-2 sm:px-6 py-0 relative flex-shrink-0 min-w-[100px] sm:flex-1 sm:self-stretch sm:grow rounded-lg",children:[(0,a.jsx)("span",{className:"relative flex items-center justify-center w-fit font-medium text-slate-900 text-xs sm:text-sm md:text-base text-center tracking-[0] leading-6 whitespace-nowrap",children:r("config.flashcardResultOverview.cardsStudied")}),(0,a.jsx)("span",{className:"relative flex items-center justify-center w-fit font-medium text-slate-900 text-lg sm:text-xl md:text-2xl text-center tracking-[0] leading-9 whitespace-nowrap",children:d?"...":l?.cards_studied||
30})]}),(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center gap-2 px-2 sm:px-6 py-0 relative flex-shrink-0 min-w-[100px] sm:flex-1 sm:self-stretch sm:grow rounded-lg",children:[(0,a.jsx)("span",{className:"relative flex items-center justify-center w-fit font-medium text-slate-900 text-xs sm:text-sm md:text-base text-center tracking-[0] leading-6 whitespace-nowrap",children:r("config.flashcardResultOverview.markedAsEasy")}),(0,a.jsx)("span",{className:"relative flex items-center justify-center w-fit font-medium text-green-500 text-lg sm:text-xl md:text-2xl text-center tracking-[0] leading-9 whitespace-nowrap",children:d?"...":l?.marked_as_easy||0})]}),(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center gap-2 px-2 sm:px-6 py-0 relative flex-shrink-0 min-w-[100px] sm:flex-1 sm:self-stretch sm:grow rounded-lg",children:[(0,a.jsx)("span",{className:"relative flex items-center justify-center w-fit font-medium text-slate-900 text-xs sm:text-sm md:text-base text-center tracking-[0] leading-6 whitespace-nowrap",children:r("config.flashcardResultOverview.markedAsHard")}),(0,a.jsx)("span",{className:"relative flex items-center justify-center w-fit font-medium text-red-500 text-lg sm:text-xl md:text-2xl text-center tracking-[0] leading-9 whitespace-nowrap",children:d?"...":l?.marked_as_hard||0})]})]})]})}),(0,a.jsxs)("div",{className:"flex flex-col min-h-[425px] sm:h-[425px] items-start gap-3 relative self-stretch w-full mb-[-19.00px]",children:[(0,a.jsx)("div",{className:"justify-between self-stretch w-full flex flex-col sm:flex-row items-start sm:items-center gap-2 sm:gap-0 relative flex-[0_0_auto]",children:(0,a.jsx)("h2",{className:"relative w-fit font-bold text-slate-900 text-lg sm:text-xl tracking-[0] leading-[normal] whitespace-nowrap",children:r("config.flashcardResultOverview.allFlashcards")})}),(0,a.jsx)(tz.e5,{items:v,getLabel:(e,t)=>t+1,renderItem:(e,t)=>(0,a.jsxs)("article",{className:"flex-col items-start gap-3 sm:gap-4 pt-0 pb-4 px-3 sm:px-4 bg-white rounded-xl flex w-full",children:[(0,a.jsx)("header",{className:"flex items-center justify-between px-0 py-2 w-full border-b border-gray-200",children:(0,a.jsx)("span",{className:"text-gray-600 text-sm",children:r("config.flashcardResultOverview.card",{number:t+1})})}),(0,a.jsxs)("div",{className:"flex flex-col gap-4 w-full",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"font-bold text-sm",children:r("config.flashcardResultOverview.term")}),(0,a.jsx)("div",{className:"px-4 py-3 bg-gray-50 rounded-lg",children:(0,a.jsx)(ea.MarkdownViewer,{content:e.term,theme:"default",enableMath:!0})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"font-bold text-sm",children:r("config.flashcardResultOverview.definition")}),(0,a.jsx)("div",{className:"px-4 py-3 bg-gray-50 rounded-lg",children:(0,a.jsx)(ea.MarkdownViewer,{content:e.definition,theme:"default",enableMath:!0})})]})]})]},e.id)})]})]})}),(0,a.jsx)("nav",{className:"md:hidden flex flex-wrap items-center gap-2 p-3 w-full max-w-[710px] mt-4",role:"navigation","aria-label":r("config.flashcardResultOverview.flashcardNavigation"),children:w.map((e,t)=>(0,a.jsx)("button",{onClick:()=>y(t),className:`flex items-center justify-center w-9 h-9 rounded-md transition-colors ${t===b?"bg-slate-900 text-white":"bg-white text-gray-600 hover:bg-gray-100 border border-gray-200"}`,"aria-label":r("config.flashcardResultOverview.goToFlashcard",{label:e.label}),"aria-current":t===b?"page":void 0,children:(0,a.jsx)("span",{className:"text-xs font-medium",children:e.label})},e.id))})]})},tM=(0,th.default)(()=>Promise.resolve().then(r.bind(r,74420)).then(e=>({default:e.MarkdownViewer})),{loadableGenerated:{webpack:()=>[74420]},ssr:!1,loading:()=>(0,a.jsx)("div",{className:"text-gray-400",children:"Loading..."})}),tL=({flashcards:e,currentCard:t,onCardSelect:r})=>{let{t:n}=(0,o.Bd)();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("nav",{className:"flex flex-wrap items-center gap-2 w-full",children:e.map((e,n)=>(0,a.jsx)("button",{onClick:()=>r(n),className:`flex items-center justify-center w-[28px] h-[28px] rounded-md transition-colors ${n+1===t?"bg-primary text-white":"bg-muted text-muted-foreground hover:bg-[#e2e8f0]"}`,children:(0,a.jsx)("span",{className:"text-xs font-medium leading-[1.5]",children:e.cardNumber})},e.id))}),e.map(e=>(0,a.jsxs)("article",{className:"flex flex-col gap-4 bg-white rounded-xl border border-border pb-4 px-4 w-full",children:[(0,a.jsxs)("div",{className:"py-2 border-b-[0.5px] border-border flex items-center justify-between w-full",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)("div",{className:"font-normal text-muted-foreground text-sm leading-[1.5] whitespace-nowrap",children:n("config.flashcardStudyList.card",{number:e.cardNumber})}),(0,a.jsx)("button",{className:"flex items-center p-1 rounded hover:bg-gray-100 transition-colors","aria-label":e.isStarred?n("config.flashcardStudyList.unstarFlashcard"):n("config.flashcardStudyList.starFlashcard"),children:(0,a.jsx)("img",{className:"w-5 h-5",alt:e.isStarred?"Starred":"Not starred",src:e.isStarred?"/cdn/components/flashcard/icon-starfill.svg":"/cdn/components/flashcard/icon-star.svg"})})]}),(0,a.jsx)("button",{className:"flex items-center p-1.5 rounded hover:bg-gray-100 transition-colors","aria-label":"Delete card",children:(0,a.jsx)("img",{className:"w-5 h-5",alt:"Delete",src:"/cdn/common/icons/icon-trash.svg"})})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-4 w-full",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1 w-full",children:[(0,a.jsx)("label",{className:"font-bold text-foreground text-sm leading-[22px] whitespace-nowrap",children:n("config.flashcardStudyList.term")}),(0,a.jsx)("div",{className:"flex items-center px-4 py-3 bg-slate-50 rounded-lg w-full",children:(0,a.jsx)("div",{className:"flex-1 font-normal text-foreground text-base leading-6",children:(0,a.jsx)(tM,{content:e.term,theme:"default",enableMath:!0})})})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 w-full",children:[(0,a.jsx)("label",{className:"font-bold text-foreground text-sm leading-[22px] whitespace-nowrap",children:n("config.flashcardStudyList.definition")}),(0,a.jsx)("div",{className:"flex items-center px-4 py-3 bg-slate-50 rounded-lg w-full",children:(0,a.jsx)("div",{className:"flex-1 font-normal text-foreground text-base leading-6",children:(0,a.jsx)(tM,{content:e.definition,theme:"default",enableMath:!0})})})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 w-full",children:[(0,a.jsx)("label",{className:"font-bold text-foreground text-sm leading-[22px] whitespace-nowrap",children:n("config.flashcardStudyList.hint")}),(0,a.jsx)("div",{className:"flex items-center px-4 py-3 bg-slate-50 rounded-lg w-full",children:(0,a.jsx)("div",{className:"flex-1 font-normal text-foreground text-base leading-6",children:(0,a.jsx)(tM,{content:e.hint,theme:"default",enableMath:!0})})})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 w-full",children:[(0,a.jsx)("label",{className:"font-bold text-foreground text-sm leading-[22px] whitespace-nowrap",children:n("config.flashcardStudyList.explanation")}),(0,a.jsx)("div",{className:"flex items-center px-4 py-3 bg-slate-50 rounded-lg w-full",children:(0,a.jsx)("div",{className:"flex-1 font-normal text-foreground text-base leading-6",children:(0,a.jsx)(tM,{content:e.explanation,theme:"default",enableMath:!0})})})]})]})]},e.id))]})},tE=(0,th.default)(()=>Promise.resolve().then(r.bind(r,74420)).then(e=>({default:e.MarkdownViewer})),{loadableGenerated:{webpack:()=>[74420]},ssr:!1,loading:()=>(0,a.jsx)("div",{className:"text-gray-400",children:"Loading..."})}),tT=({currentCardData:e,showAnswer:t,onCardClick:r})=>{let{t:n}=(0,o.Bd)();return(0,a.jsxs)("article",{className:"flex flex-col items-center justify-center gap-3 relative flex-1 self-stretch w-full grow bg-white rounded-xl overflow-hidden border-[0.5px] border-solid border-gray-200 shadow-sm cursor-pointer",onClick:r,role:"button","aria-label":n(t?"config.flashcardStudyList.hideAnswer":"config.flashcardStudyList.showAnswer"),children:[(0,a.jsx)("div",{className:"flex flex-col px-6 py-0 relative flex-1 self-stretch w-full grow mt-5 mb-3",style:{perspective:"1000px"},children:(0,a.jsxs)("div",{className:"relative w-full h-full flex-1 font-medium text-gray-900 tracking-[0] leading-9",style:{transformStyle:"preserve-3d",transition:"transform 0.6s ease-in-out",transform:t?"rotateY(180deg)":"rotateY(0deg)"},children:[(0,a.jsxs)("div",{className:"absolute inset-0 w-full h-full flex flex-col",style:{backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden",transform:"rotateY(0deg)"},children:[(0,a.jsx)("div",{className:"absolute bottom-0 left-0 w-full h-12 bg-gradient-to-t from-white to-transparent pointer-events-none z-10"}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto w-full [scrollbar-width:none] flex flex-col pb-8",children:(0,a.jsx)("div",{className:"my-auto w-full flex flex-col items-center justify-center",children:(0,a.jsx)(tE,{content:e?"## "+e.question:"## "+n("config.flashcardStudyList.noQuestionAvailable"),theme:"default",className:"font-semibold w-full text-2xl leading-[32.0px] text-center",enableMath:!0,enableGFM:!0,textAlign:"center"})})})]}),(0,a.jsxs)("div",{className:"absolute inset-0 w-full h-full flex flex-col",style:{backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden",transform:"rotateY(180deg)"},children:[(0,a.jsx)("div",{className:"absolute bottom-0 left-0 w-full h-12 bg-gradient-to-t from-white to-transparent pointer-events-none z-10"}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto w-full [scrollbar-width:none] flex flex-col pb-8",children:(0,a.jsx)("div",{className:"my-auto w-full flex flex-col items-start justify-center",children:(0,a.jsx)(tE,{content:e?"## "+e.answer:"## "+n("config.flashcardStudyList.noAnswerAvailable"),theme:"default",className:"font-semibold w-full text-xl leading-[32.0px] text-left",enableMath:!0,enableGFM:!0,textAlign:"left"})})})]})]})}),(0,a.jsx)("div",{className:"flex items-center justify-center px-6 py-4 relative self-stretch w-full flex-[0_0_auto] select-none pointer-events-none",style:{perspective:"1000px"},children:(0,a.jsxs)("div",{style:{transformStyle:"preserve-3d",transition:"transform 0.6s ease-in-out",transform:t?"rotateY(180deg)":"rotateY(0deg)"},children:[(0,a.jsx)("div",{style:{backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden",transform:"rotateY(0deg)"},children:(0,a.jsx)("span",{className:"relative flex items-center justify-center w-fit mt-[-1.00px] font-normal italic text-gray-500 text-sm text-center tracking-[0] leading-[21px] whitespace-nowrap",children:n("config.flashcardStudyList.tapToViewAnswer")})}),(0,a.jsx)("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden",transform:"rotateY(180deg)",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,a.jsx)("span",{className:"relative flex items-center justify-center w-fit mt-[-1.00px] font-normal italic text-gray-500 text-sm text-center tracking-[0] leading-[21px] whitespace-nowrap",children:n("config.flashcardStudyList.tapToViewQuestion")})})]})})]})},tA=({showAnswer:e,currentCard:t,totalCards:r,animate:n,onPreviousCard:s,onNextCard:i,onSetDifficulty:l,onFinish:c})=>{let{t:d}=(0,o.Bd)();return(0,a.jsx)("nav",{className:"flex flex-wrap items-center justify-end relative self-stretch w-full flex-[0_0_auto] gap-y-2",children:(0,a.jsx)("div",{className:"inline-flex items-center gap-2 md:gap-3 relative flex-[0_0_auto] h-12",children:e?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"relative h-12 flex items-center justify-center",children:[(0,a.jsx)("img",{src:"/cdn/components/flashcard/easy.svg",alt:"Hard",className:`absolute bottom-2 left-1/2 -translate-x-1/2 transition-transform duration-1000 ${"easy"===n?"opacity-100 -translate-y-9":"op
3acity-0 translate-y-0"}`}),(0,a.jsx)("button",{className:"inline-flex items-center justify-center px-3 md:px-6 py-2.5 relative flex-[0_0_auto] cursor-pointer transition-opacity hover:bg-[#FFD6DB] hover:border-[#E62822] hover:shadow-md",style:{borderRadius:"6px",border:"1px solid #34C759",background:"#E7F8EB",color:"#34C759"},onClick:()=>l("easy"),"aria-label":d("config.flashcardStudyList.markAsEasy"),children:(0,a.jsx)("span",{className:"relative flex items-center justify-center w-fit font-normal text-sm tracking-[0] leading-5 whitespace-nowrap",children:d("config.flashcardStudyList.easy")})})]}),(0,a.jsxs)("div",{className:"relative h-12 flex items-center justify-center",children:[(0,a.jsx)("img",{src:"/cdn/components/flashcard/hard.svg",alt:"Hard",className:`absolute bottom-2 left-1/2 -translate-x-1/2 transition-transform duration-1000 ${"hard"===n?"opacity-100 -translate-y-9":"opacity-0 translate-y-0"}`}),(0,a.jsx)("button",{className:"relative z-10 inline-flex items-center justify-center px-3 md:px-6 py-2.5 cursor-pointer hover:bg-[#FFD6DB] hover:border-[#E62822] hover:shadow-md",style:{borderRadius:"6px",border:"1px solid #FF3B30",background:"#FFEAEE",color:"#FF3B30"},onClick:()=>l("hard"),"aria-label":d("config.flashcardStudyList.markAsHard"),children:(0,a.jsx)("span",{className:"relative flex items-center justify-center w-fit font-normal text-sm tracking-[0] leading-5 whitespace-nowrap",children:d("config.flashcardStudyList.hard")})})]})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("button",{className:"all-[unset] box-border inline-flex px-4 py-2.5 flex-[0_0_auto] items-center gap-1 relative bg-white rounded-md border border-solid border-gray-300 cursor-pointer hover:bg-gray-50 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:s,disabled:1===t,"aria-label":d("config.flashcardStudyList.previousQuestion"),children:[(0,a.jsx)("img",{className:"relative w-4 h-4",alt:"",src:"/cdn/common/icons/icon-arrow-left.svg"}),(0,a.jsx)("span",{className:"relative flex items-center justify-center w-fit mt-[-1.00px] font-normal text-gray-700 text-sm tracking-[0] leading-5 whitespace-nowrap",children:d("config.flashcardStudyList.previous")})]}),r===t?(0,a.jsxs)("button",{className:"all-[unset] box-border flex w-[109px] justify-center px-5 py-2.5 items-center gap-1 relative bg-white rounded-md border border-solid border-gray-300 cursor-pointer hover:bg-gray-50 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:c,"aria-label":d("config.flashcardStudyList.nextQuestion"),children:[(0,a.jsx)("span",{className:"relative flex items-center justify-center w-fit mt-[-1.00px] font-normal text-gray-700 text-sm tracking-[0] leading-5 whitespace-nowrap",children:d("config.flashcardStudyList.finish")}),(0,a.jsx)("img",{className:"relative w-4 h-4",alt:"",src:"/cdn/common/icons/icon-arrow-left-1.svg"})]}):(0,a.jsxs)("button",{className:"all-[unset] box-border flex w-[109px] justify-center px-5 py-2.5 items-center gap-1 relative bg-white rounded-md border border-solid border-gray-300 cursor-pointer hover:bg-gray-50 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:i,disabled:t===r,"aria-label":d("config.flashcardStudyList.nextQuestion"),children:[(0,a.jsx)("span",{className:"relative flex items-center justify-center w-fit mt-[-1.00px] font-normal text-gray-700 text-sm tracking-[0] leading-5 whitespace-nowrap",children:d("config.flashcardStudyList.next")}),(0,a.jsx)("img",{className:"relative w-4 h-4",alt:"",src:"/cdn/common/icons/icon-arrow-left-1.svg"})]})]})})})},tI=({isVisible:e=!0,onClose:t,className:r="",view:n,onViewChange:i,lockViewTo:l,projectId:c,viewAllTrigger:d,flashcards:u=[]})=>{let[m,f]=(0,s.useState)(1),[g,p]=(0,s.useState)(!1),[x,h]=(0,s.use
3State)(!1),[b,y]=(0,s.useState)(!1),[v,w]=(0,s.useState)("study"),[j,N]=(0,s.useState)(!1),[C,S]=(0,s.useState)(!1),{t:k}=(0,o.Bd)(),z=u.filter(e=>e.project_id===(c||0)).map((e,t)=>({id:e.id,cardNumber:t+1,title:k("config.flashcardStudyList.card",{number:t+1}),term:e.term,definition:e.definition,hint:e.hint||"",explanation:e.explanation||"",isStarred:e.isStarred||!1})),_=z.map(e=>({id:e.id,question:e.term,answer:e.definition,isStarred:e.isStarred||!1,isImportant:!1})),M=n??v,L=e=>{i&&i(e),void 0===n&&w(e)},E=_.length,T=_[m-1]||_[0]||null;(0,s.useEffect)(()=>{d&&queueMicrotask(()=>N(!0))},[d]);let[A,I]=(0,s.useState)(""),F=e=>{if(!C){if(m<E){f(e=>e+1),p(!1),S(!1);let e=_[m];e&&(h(e.isStarred||!1),y(e.isImportant||!1));return}if(e?.forceShowAnswer||!g)return void p(!0);L("completed")}},D=async e=>{if(T)try{I(e),await (0,tk.rL)({flashcard_id:T.id,level:e}),setTimeout(()=>{I(""),m<E?F():g?L("completed"):p(!0)},300)}catch(e){console.error("Failed to set flashcard difficulty:",e),m<E?F():L("completed")}},P=m/E*100;return e?"overview"===M?(0,a.jsx)(t_,{projectId:c,flashcards:u}):"completed"===M?(0,a.jsx)(tC,{onBack:t,onViewAll:()=>{N(!0)},onPrevious:()=>{p(!1),L("study")},onComplete:()=>L("overview")}):(0,a.jsxs)("main",{className:`flex flex-col w-full max-w-[710px] xl:max-w-[9
360px] 2xl:max-w-[1120px] min-h-[660px] h-full pb-[58px] items-start relative ${r}`,"data-model-id":"1262:18945",children:[(0,a.jsx)("div",{className:"absolute top-0 left-0 flex flex-col items-start gap-4 relative self-stretch w-full flex-1 overflow-auto min-h-0",style:{display:j?"flex":"none"},children:(0,a.jsx)(tL,{flashcards:z,currentCard:m,onCardSelect:e=>{p(!1),N(!1),f(e+1)}})}),(0,a.jsxs)("div",{className:"flex flex-col items-center gap-6 relative flex-1 self-stretch w-full grow",style:{display:j?"none":"flex"},children:[(0,a.jsxs)("div",{className:"flex items-center gap-4 relative self-stretch w-full flex-[0_0_auto]",children:[(0,a.jsx)("div",{className:"relative flex-1 grow h-2 bg-gray-200 rounded-full",role:"progressbar","aria-valuenow":m,"aria-valuemin":1,"aria-valuemax":E,"aria-label":k("config.flashcardStudyList.questionProgress",{current:m,total:E}),children:(0,a.jsx)("div",{className:"h-full bg-gray-900 rounded-full transition-all duration-300",style:{width:`${P}%`}})}),(0,a.jsxs)("div",{className:"inline-flex items-center justify-center gap-0.5 relative flex-[0_0_auto]",children:[(0,a.jsx)("span",{className:"relative w-7 mt-[-1.00px] font-normal text-gray-900 text-xl text-right tracking-[0] leading-[30px]",children:m}),(0,a.jsxs)("span",{className:"relative w-fit font-normal text-gray-500 text-base text-center tracking-[0] leading-6 whitespace-nowrap",children:["/",E]})]})]}),(0,a.jsx)(tT,{currentCardData:T,showAnswer:g,onCardClick:()=>{C||(S(!0),setTimeout(()=>{p(!g)},300),setTimeout(()=>{S(!1)},600))}}),(0,a.jsx)(tA,{showAnswer:g,currentCard:m,totalCards:E,animate:A,onPreviousCard:()=>{if(m>1){f(m-1),p(!1),S(!1);let e=_[m-2];e&&(h(e.isStarred||!1),y(e.isImportant||!1))}},onNextCard:()=>F(),onSetDifficulty:D,onFinish:()=>L("completed")})]})]}):null},tF=({isOpen:e,onClose:t,onCancel:r,onRestart:n})=>{let{t:s}=(0,o.Bd)();return e?(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50",children:(0,a.jsxs)("div",{className:"flex flex-col w-[440px] items-start relative bg-white rounded-xl shadow-lg",role:"dialog","aria-labelledby":"dialog-title","aria-describedby":"dialog-description","aria-modal":"true",children:[(0,a.jsxs)("header",{className:"flex items-center gap-3 px-6 py-4 relative self-stretch w-full flex-[0_0_auto]",children:[(0,a.jsx)("h2",{id:"dialog-title",className:"relative flex-1 font-bold text-slate-900 text-lg tracking-[0] leading-[normal]",children:s("config.restartModal.restart")}),(0,a.jsx)("button",{className:"inline-flex items-center gap-2.5 p-1 relative flex-[0_0_auto] rounded-md cursor-pointer hover:bg-slate-100 transition-colors",onClick:t,"aria-label":s("config.restartModal.closeDialog"),type:"button",children:(0,a.jsx)("img",{className:"relative w-5 h-5 aspect-[1]",alt:"",src:"/cdn/common/icons/icon-close.svg","aria-hidden":"true"})})]}),(0,a.jsxs)("div",{className:"flex flex-col items-start justify-center gap-0.5 px-6 py-3 relative self-stretch w-full flex-[0_0_auto]",children:[(0,a.jsx)("p",{id:"dialog-description",className:"relative w-fit mt-[-1.00px] font-medium text-slate-900 text-base tracking-[0] leading-6 whitespace-nowrap",children:s("config.restartModal.confirmRestart")}),(0,a.jsx)("p",{className:"relative flex items-center justify-start self-stretch font-normal text-gray-600 text-sm tracking-[0] leading-[21px]",children:s("config.restartModal.restartDescription")})]}),(0,a.jsxs)("footer",{className:"justify-end flex items-center gap-3 px-6 py-4 relative self-stretch w-full flex-[0_0_auto]",children:[(0,a.jsx)("button",{className:"px-4 py-1.5 border border-solid border-slate-200 inline-flex items-center justify-center relative flex-[0_0_auto] rounded-md cursor-pointer hover:bg-slate-50 active:bg-slate-100 transition-colors",onClick:r,type:"button","aria-label":s("config.restartModal.cancelRestart"),children:(0,a.jsx)("span",{className:"relative w-fit mt-[-1.00px] font-medium text-slate-900 text-sm tracking-[0] leading-6 whitespace-nowrap",children:s("config.restartModal.cancel")})}),(0,a.jsx)("button",{className:"px-4 py-2 bg-slate-900 inline-flex items-center justify-center relative flex-[0_0_auto] rounded-md cursor-pointer hover:opacity-90 active:opacity-80 transition-opacity",onClick:n,type:"button","aria-label":s("config.restartModal.confirmRestartButton"),children:(0,a.jsx)("span",{className:"relative w-fit mt-[-1.00px] font-medium text-white text-sm tracking-[0] leading-6 whitespace-nowrap",children:s("config.restartModal.restartButton")})})]})]})}):null};function tD(){let{t:e}
3=(0,o.Bd)(),[t,r]=(0,s.useState)("study"),[n,l]=(0,s.useState)(!1),{model:{projectId:c,activeTab:d,viewState:u,selectedActionId:f,showFlashcardStudyList:g,viewAllTrigger:p,isDetailLoading:x,flashcards:h,error:b},actions:{setViewAllTrigger:y,handleStudyCards:v,handleCloseFlashcardStudyList:w,handleBack:j}}=function(){let{projectId:e}=(0,X.g)(),t=(0,i.bh)(e=>e.pageState.activeTab),r=e?Number(e):null,n=(0,m.r)(e=>e.getTab(m.SL.FLASHCARD)),{viewState:a,actionId:l,content:o}=n,c=(0,s.useMemo)(()=>o&&a===m.Pf.CONTENT?o:[],[o,a]),d=(0,s.useMemo)(()=>r?c.filter(e=>e.project_id===r).length:0,[c,r]),u=(0,s.useMemo)(()=>"flashcards"===t&&a!==m.Pf.LIST&&0===d&&a===m.Pf.LOADING,[t,a,d]),[f,g]=(0,s.useState)(!1),[p,x]=(0,s.useState)(0);(0,s.useEffect)(()=>{"flashcards"!==t&&queueMicrotask(()=>g(!1))},[t]);let h=(0,s.useCallback)(()=>{g(!0)},[]),b=(0,s.useCallback)(()=>{g(!1)},[]),y=(0,s.useCallback)(()=>{m.r.getState().lifecycle.goToList(m.SL.FLASHCARD)},[]),v=(0,s.useCallback)(()=>{f?g(!1):y()},[f,y]);return{model:{projectId:e,activeTab:t,projectIdNumber:r,viewState:a,selectedActionId:l,showFlashcardStudyList:f,viewAllTrigger:p,isDetailLoading:u,flashcards:c,error:n.error},actions:{setViewAllTrigger:x,handleStudyCards:h,handleCloseFlashcardStudyList:b,handleBack:v}}}(),N=(0,s.useMemo)(()=>({isVisible:!0,className:"w-full h-full overflow-hidden",scrollMode:"external",onClose:()=>{},onStudyCards:v,projectId:Number(c),shouldInitialize:"flashcards"===d,data:h,error:b}),[v,c,d,h,b]),C=g&&"overview"===t,S=()=>{l(!1)};return u===m.Pf.LIST?(0,a.jsxs)("div",{className:"w-full h-full min-h-0 overflow-y-auto p-6",children:[c&&(0,a.jsx)("div",{children:(0,a.jsx)(F.StartGeneration,{title:e("config.tabContainer.createFlashcards"),description:e("config.tabContainer.createFlashcardsDesc"),className:"w-full",apiType:"flashcards",showSettingsButton:!0,customizeSaveOnly:!0})}),c&&(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(J,{projectId:Number(c),tool:"flashcards"})})]}):(0,a.jsxs)("div",{className:"w-full min-h-full flex flex-col",children:[(0,a.jsxs)("div",{className:"sticky top-0 z-30 flex items-center justify-between px-6 py-2 bg-white",children:[(0,a.jsxs)("button",{className:"inline-flex items-center gap-2 text-sm text-gray-600 hover:text-gray-900",onClick:j,children:[(0,a.jsx)("img",{src:"/cdn/common/icons/icon-arrow-left.svg",alt:"",className:"h-4 w-4"}),e("config.back")]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[g&&!C&&(0,a.jsx)("button",{type:"button",className:"inline-flex items-center p-1.5 relative flex-[0_0_auto] rounded hover:bg-gray-100 transition-colors cursor-pointer bg-transparent border-none",onClick:()=>y(e=>e+1),"aria-label":e("config.flashcardStudyList.viewAll"),title:e("config.flashcardStudyList.viewAll"),children:(0,a.jsx)("img",{src:"/cdn/common/icons/view-all.svg",alt:"",className:"relative w-5 h-5 aspect-[1]"})}),(0,a.jsx)(F.StartGeneration,{variant:"gearOnly",className:"",apiType:"flashcards",refreshActionId:f?Number(f):void 0}),C&&(0,a.jsx)("button",{type:"button",className:"inline-flex items-center justify-center px-[12px] py-[4px] relative flex-shrink-0 bg-slate-900 rounded-md hover:opacity-90 transition-opacity cursor-pointer",onClick:()=>{l(!0)},children:(0,a.jsx)("span",{className:"relative w-fit font-medium text-white text-sm tracking-[0] leading-[18px] whitespace-nowrap",children:e("config.flashcardResultOverview.restart")})})]})]}),x?(0,a.jsx)(tp.e,{visible:!0,variant:"versions",overlay:!1,className:"flex-1",label:e("config.projectDetail.loading",{defaultValue:"Loading..."})}):(0,a.jsx)("div",{className:"w-full px-6 py-3",children:(0,a.jsx)("div",{className:"mx-auto w-full max-w-[710px] xl:max-w-[9
360px] 2xl:max-w-[1120px]",children:g?(0,a.jsx)(tI,{isVisible:!0,className:"w-full h-full overflow-hidden",onClose:()=>{w(),r("study")},onViewChange:r,projectId:Number(c),viewAllTrigger:p,flashcards:h}):(0,a.jsx)(tN.pp,{...N},"flashcard-list")})}),(0,a.jsx)(tF,{isOpen:n,onClose:S,onCancel:S,onRestart:()=>{l(!1),w(),r("study")}})]})}var tP=r(5772),tO=r(81836),tR=r(37288);function t$(e){return(0,a.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,a.jsx)("path",{d:"M15.3953 13.1438V2.19219C15.3891 2.12344 15.3813 2.05469 15.3735 1.98594C15.3516 1.85156 15.3188 1.72031 15.275 1.59063C15.0953 1.10625 14.7485 0.700002 14.2985 0.446877C14.0438 0.315627 13.7672 0.232814 13.4813 0.200002C13.186 0.200002 11.3282 0.195314 11.0328 0.195314H3.15315C2.7594 0.167189 2.36409 0.209377 1.9844 0.318752C1.31878 0.560939 0.820339 1.12344 0.659402 1.8125C0.604714 2.14063 0.587527 2.475 0.606277 2.80781V13.1219C0.585964 13.4438 0.596902 13.7688 0.639089 14.0891C0.714089 14.4438 0.871902 14.7766 1.09846 15.0609C1.41565 15.4375 1.85628 15.6906 2.34221 15.7766C2.58753 15.8109 2.8344 15.8203 3.08128 15.8063H12.9282C13.1953 15.8219 13.4641 15.8078 13.7282 15.7641C14.2141 15.6609 14.6485 15.3906 14.9547 14.9984C15.1703 14.7078 15.3157 14.3719 15.3766 14.0156C15.4094 13.7266 15.4157 13.4344 15.3969 13.1438H15.3953ZM14.0375 14.2625C13.9094 14.4297 13.7282 14.55 13.525 14.6047C13.311 14.6391 13.0938 14.6484 12.8766 14.6328H3.20784C2.66878 14.6328 2.27034 14.6391 2.02971 14.3406C1.91878 14.2141 1.83909 14.0625 1.79534 13.9C1.76409 13.6625 1.75628 13.4219 1.77503 13.1844V2.70469C1.75784 2.47656 1.7719 2.24688 1.81565 2.02188C1.91096 1.71563 2.15784 1.47969 2.46721 1.39688C2.74221 1.35313 3.0219 1.34375 3.30003 1.36719H12.8766C13.1813 1.32969 13.4907 1.375 13.7719 1.49844C13.9485 1.60781 14.086 1.77031 14.1625 1.96406L14.2157 2.17031L14.2235 2.25625V13.1469C14.2235 13.65 14.25 13.9688 14.0344 14.2625H14.0375Z",fill:"#8A94A1"}),(0,a.jsx)("path",{d:"M12.7953 7.8C12.7422 7.66719 12.6422 7.55938 12.5125 7.5C12.3453 7.45469 12.1719 7.43906 12 7.45469H6.7875C6.63594 7.44219 6.48281 7.44688 6.33125 7.47031C6.07969 7.54375 5.91406 7.78438 5.93594 8.04688C5.95781 8.30781 6.16094 8.51875 6.42188 8.54844H11.9625C12.1062 8.55938 12.25 8.55781 12.3922 8.54063C12.675 8.48438 12.8656 8.21719 12.8266 7.93125L12.7953 7.8ZM12.7375 11.3422C12.6939 11.2128 12.6052 11.1036 12.4875 11.0344C12.1328 10.9453 11.7641 10.9219 11.4 10.9641H7.25313C6.68438 10.9641 6.19844 10.8656 5.99687 11.2609C5.94219 11.3578 5.92188 11.4688 5.93594 11.5781C6.03281 12.1469 6.53125 12.0594 7.175 12.0594H11.5734L12.3125 12.0547C12.5906 12.0078 12.7875 11.7563 12.7641 11.475L12.7375 11.3438V11.3422ZM12.8938 4.29063C12.8422 4.15781 12.7422 4.05156 12.6141 3.99063C12.3594 3.93125 12.0984 3.91406 11.8391 3.94063H7.11094C6.57969 3.94063 6.18594 3.87344 5.99844 4.2375C5.94375 4.33438 5.92344 4.44531 5.9375 4.55469C6.02969 5.10156 6.47656 5.04063 7.09844 5.04063H11.6313C11.975 5.0875 12.3234 5.0625 12.6562 4.96719C12.8438 4.85469 12.9484 4.64219 12.9234 4.42344L12.8938 4.29219V4.29063ZM3.70312 3.7125C3.49531 3.7125 3.29688 3.79531 3.15 3.94063C3.00313 4.0875 2.92188 4.28594 2.92188 4.49375C2.92188 4.925 3.27187 5.275 3.70312 5.275C4.13437 5.275 4.48438 4.925 4.48438 4.49375C4.48438 4.0625 4.13437 3.7125 3.70312 3.7125ZM3.70312 7.22813C3.49531 7.22813 3.29688 7.31094 3.15 7.45625C3.00313 7.60313 2.92188 7.80156 2.92188 8.00938C2.92188 8.44063 3.27187 8.79063 3.70312 8.79063C4.13437 8.79063 4.48438 8.44063 4.48438 8.00938C4.48438 7.57813 4.13437 7.22813 3.70312 7.22813ZM3.70312 10.7453C3.49531 10.7453 3.29688 10.8281 3.15 10.9734C3.00313 11.1203 2.92188 11.3188 2.92188 11.5266C2.92188 11.9578 3.27187 12.3078 3.70312 12.3078C4.13437 12.3078 4.48438 11.9578 4.48438 11.5266C4.48438 11.0953 4.13437 10.7453 3.70312 10.7453Z",fill:"#8A94A1"})]})}function tV(e){return(0,a.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",...e,children:(0,a.jsx)("path",{d:"M5.25 10.5L8.75 7L5.25 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function tB(e){return(0,a.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",...e,children:(0,a.jsx)("path",{d:"M7 1.5A5.5 5.5 0 1 1 1.5 7",
3stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}let tq=({isOpen:e,onClose:t,chapters:r=[],activeChapterId:n,onSelectChapter:i,targetPanelId:c="right-panel"})=>{let{t:d}=(0,o.Bd)(),[u,m]=(0,s.useState)({x:0,y:0,width:320,height:600}),[f,g]=(0,s.useState)(!1),[p,x]=(0,s.useState)(!1),h=(0,s.useRef)(null),b=(0,s.useCallback)(()=>{let e=document.getElementById(c)||document.getElementById("middle-panel");if(e){let t=e.getBoundingClientRect();if(t.width>0){m({x:t.left,y:t.top,width:t.width,height:t.height}),g(!0);return}}m({x:.6*window.innerWidth,y:48,width:.4*window.innerWidth,height:window.innerHeight-48-16}),g(!0)},[c]);if((0,s.useEffect)(()=>{if(!e){let e=requestAnimationFrame(()=>{g(!1),x(!1)});return()=>cancelAnimationFrame(e)}if(p)return;let t=requestAnimationFrame(()=>g(!1)),r=()=>{requestAnimationFrame(()=>setTimeout(b,100))};r(),window.addEventListener("resize",r);let n=document.getElementById("main-panel-group");n&&(h.current=new ResizeObserver(r),h.current.observe(n));let a=document.getElementById(c)||document.getElementById("main-panel-group"),s=null;return a&&(s=new MutationObserver(r)).observe(a,{childList:"main-panel-group"===a.id,subtree:"main-panel-group"===a.id,attributes:!0,attributeFilter:["style","class"]}),()=>{cancelAnimationFrame(t),window.removeEventListener("resize",r),h.current?.disconnect(),h.current=null,s?.disconnect()}},[e,p,b,c]),!e||!f)return null;let y=r.filter(e=>"generated"===e.status).length,v=(0,a.jsx)(tR.p,{position:{x:u.x,y:u.y},size:{width:u.width,height:u.height},onDragStop:(e,t)=>{m(e=>({...e,x:t.x,y:t.y})),x(!0)},onResizeStop:(e,t,r,n,a)=>{m({width:parseInt(r.style.width),height:parseInt(r.style.height),x:a.x,y:a.y})},minWidth:260,minHeight:300,maxWidth:window.innerWidth,maxHeight:window.innerHeight-48,bounds:"window",dragHandleClassName:"course-sheet-drag-handle",style:{zIndex:40},className:"!fixed",children:(0,a.jsxs)("div",{className:"flex h-full w-full flex-col overflow-hidden rounded-lg border border-border bg-background shadow-sm",children:[(0,a.jsxs)("header",{className:"course-sheet-drag-handle flex h-12 shrink-0 cursor-move items-center justify-between border-b border-border px-4",children:[(0,a.jsx)("span",{className:"text-[14px] font-bold leading-normal text-foreground",children:d("config.videoGen.course.title",{defaultValue:"Course"})}),(0,a.jsx)("button",{onClick:t,"aria-label":"Close course panel",className:"flex h-6 w-6 items-center justify-center rounded-[2px] transition-colors hover:bg-muted",children:(0,a.jsx)(tP.default,{alt:"close",src:"/cdn/components/animaapp/0cSbfWuR/icon-arrow-down-circle.svg",width:16,height:16,className:"w-4 h-4"})})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 shrink-0",children:[(0,a.jsxs)("span",{className:"text-[14px] text-muted-foreground",children:[r.length,"\xa0",d("config.videoGen.course.videos",{defaultValue:"videos"})]}),(0,a.jsx)("span",{className:"text-[14px] text-muted-foreground",children:r.length>0?`${y}/${r.length}`:""})]}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto px-4 pb-4 flex flex-col gap-2",children:[r.map(e=>{let t=e.id===n,r="generated"===e.status;return(0,a.jsxs)("button",{disabled:!r,onClick:()=>r&&i?.(e.id),className:`w-full flex items-center gap-2 h-8 px-1 rounded-[6px] text-left transition-colors ${t?"cursor-pointer bg-accent":r?"cursor-pointer bg-background hover:bg-muted":"cursor-default bg-background"}`,children:[(0,a.jsx)("span",{className:`flex-1 min-w-0 text-[14px] leading-[22px] truncate ${r?"text-foreground":"text-muted-foreground"}`,children:e.title??d("config.videoGen.course.chapter",{defaultValue:"Chapter {{index}}",index:e.chapter_index})}),"generated"===e.status?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"shrink-0 px-2 text-[12px] text-muted-foreground",children:function(e){if(null==e||!Number.isFinite(e))return"--";let t=Math.max(0,Math.round(e)),r=Math.floor(t/60);return`${String(r).padStart(2,"0")}:${String(t%60).padStart(2,"0")}`}(e.duration)}),(0,a.jsx)(tV,{className:`shrink-0 ${e.id===n?"text-foreground":"text-border"}`})]}):"generating"===e.status?(0,a.jsx)("span",{className:"flex shrink-0 items-center justify-center",role:"status","aria-label":d("config.videoGen.course.generating",{defaultValue:"Generating"}),children:(0,a.jsx)(tB,{className:"h-4 w-4 shrink-0 animate-spin text-muted-foreground"})}):"not_generated"===e.status?(0,a.jsx)("span",{className:"shrink-0 whitespace-nowrap text-[12px] leading-[22px] text-muted-foreground",children:d("config.videoGen.course.pending",{defaultValue:"Waiting"})}):(0,a.jsx)("span",{className:"text-[12px] text-red-400 shrink-0",children:d("config.videoGen.course.failed",{defaultValue:"Failed"})})]},e.id)}),0===r.length&&(0,a.jsx)("p",{className:"mt-8 text-center text-[13px] text-muted-foreground",children:d("config.videoGen.course.noChapter
3s",{defaultValue:"No chapters available"})})]})]})});return(0,l.createPortal)(v,document.body)};var tG=r(20878),tH=r(56662);let tW=(0,th.default)(()=>Promise.resolve().then(r.bind(r,35407)).then(e=>e.StartGeneration),{loadableGenerated:{webpack:()=>[35407]},ssr:!1}),tQ=()=>{let{t:e}=(0,o.Bd)(),{model:{projectId:t,viewState:r,selectedActionId:n,currentVideoExplanation:i,videoExplanationError:l},actions:{showList:c,showDetail:d,startGeneration:u}}=function(){let{projectId:e}=(0,X.g)(),t=(0,m.r)(e=>e.getTab(m.SL.VIDEO_GEN)),{viewState:r,actionId:n,content:a}=t,s=r===m.Pf.CONTENT?a:null;return{model:{projectId:e,viewState:r,selectedActionId:n,currentVideoExplanation:s,videoExplanationError:t.error},actions:{showList:()=>{m.r.getState().lifecycle.goToList(m.SL.VIDEO_GEN)},showDetail:()=>{},startGeneration:()=>{}}}}(),[f,g]=(0,s.useState)(!1),p=(0,s.useCallback)(()=>g(e=>!e),[]),x=null!=n&&n>0?n:i?.id??null,{mode:h,chapters:b,activeChapterId:y,setActiveChapterId:v}=function({projectId:e,actionId:t,intervalMs:r=5e3,enabled:n=!0}
3){let[a,i]=(0,s.useState)("unknown"),[l,o]=(0,s.useState)(null),[c,d]=(0,s.useState)([]),[u,m]=(0,s.useState)(null),[f,g]=(0,s.useState)(!1),[p,x]=(0,s.useState)(null),h=(0,s.useRef)(null),b=(0,s.useRef)(!0),y=(0,s.useRef)(!1),v=(0,s.useRef)(0),w=(0,s.useRef)(null),j=(0,s.useCallback)(()=>{null!==h.current&&(clearTimeout(h.current),h.current=null)},[]),N=(0,s.useCallback)(async()=>{if(!e||!b.current)return;let n=e=>{j(),h.current=setTimeout(()=>{b.current&&w.current?.()},e)};try{g(!0),x(null);let a=new URLSearchParams({projectId:String(e),action:"video_gen"});null!=t&&a.set("actionId",String(t));let s=await (0,ei.Tv)({url:`/api/v1/poll/action?${a.toString()}`,method:"GET"});if(!b.current)return;v.current=0,x(null);let l=function(e){if(!e||"object"!=typeof e)return null;let t=e.data;return t&&"object"==typeof t&&"string"==typeof t.status?t:"string"==typeof e.status?e:null}(s),c=l?function(e){if("string"!=typeof e.status)return null;let t=e.subProjectActionList??e.sub_project_action_list,r=(Array.isArray(t)?t:[]).map(e=>{let t=e.title;return{id:Number(e.id),chapter_index:Number(e.chapterIndex??e.chapter_index??0),title:"string"==typeof t?t:null==t?null:String(t),status:e.status,duration:function(e){if(null==e||""===e)return null;let t=Number(e);if(!Number.isFinite(t)||t<0)return null;let r=Math.round(t);return r>=1e3?Math.round(r/1e3):r}(e.duration)}});return{status:e.status,subProjectActionList:r}}(l):null;if(!c)return void n(r);o(c.status);let u=c.subProjectActionList.length>0;if(u){if(i("multi"),d(c.subProjectActionList),!y.current){let e=[...c.subProjectActionList].sort((e,t)=>e.chapter_index-t.chapter_index).find(e=>"generated"===e.status);e&&(y.current=!0,m(e.id))}}else i("single"),d([]);let f=c.subProjectActionList,p=u&&f.every(e=>"generated"===e.status||"failed"===e.status);"failed"===c.status||!u&&("completed"===c.status||"not_added"===c.status)||u&&p?(g(!1),j()):n(r)}catch(e){if(!b.current)return;console.error("[useVideoGenPolling] poll error",e),v.current+=1,x(e instanceof Error?e.message:"Polling error"),n(Math.min(r*2**v.current,3e4))}},[e,t,r,j]);return(0,s.useEffect)(()=>(w.current=N,()=>{w.current=null}),[N]),(0,s.useEffect)(()=>{if(b.current=!0,!n||!e)return void j();y.current=!1,v.current=0,m(null);let t=setTimeout(()=>{N()},0);return()=>{clearTimeout(t),b.current=!1,j()}},[n,e,t,N,j]),{mode:a,parentStatus:l,chapters:c,activeChapterId:u,setActiveChapterId:m,isPolling:!!n&&!!e&&f,error:p}}({projectId:t,actionId:x,enabled:r===m.Pf.CONTENT&&!!i&&!!x}),w="multi"===h&&b.length>0,j=w&&!!y&&!!x&&y!==x,{data:N,isLoading:C}=function(e,t,r){let n=r?.subActionId,a=r?.enabled!==!1&&!!e&&e>0&&!!t&&t>0,i=(0,s.useMemo)(()=>{let r={projectId:e,actionId:t};return null!=n&&n>0&&n!==t&&(r.subActionId=n),r},[e,t,n]),{data:l,error:o,isLoading:c,isValidating:d,mutate:u}=(0,B.R8)(i,{swr:{enabled:a,revalidateOnFocus:!1,revalidateIfStale:!1,dedupingInterval:6e4,keepPreviousData:!1}}),{data:m}=(0,tG.XU)({projectId:e},{swr:{enabled:r?.enabled!==!1&&!!e&&e>0,revalidateOnFocus:!1,dedupingInterval:3e5}}),f="string"==typeof m?m:null;return{data:(0,s.useMemo)(()=>{let r,a,s;if(!l||!e||!t)return null;let i=null!=n&&n>0&&n!==t?n:t;return r=e=>(0,tH.q)(e,f),a=(l.pageList||[]).map(e=>({...e,pageUrl:r(e.pageUrl||"")})),{id:i,project_id:e,status:"success",message:null,video_url:(s={...l,mp3:r(l.mp3||""),pageList:a}).mp3||null,title:null,description:null,script:null,document_id:null,video_detail:s,document_list:[],document_count:0,create_time:new Date().toISOString(),modify_time:new Date().toISOString()}},[l,e,f,t,n]),isLoading:c||d,error:(0,s.useMemo)(()=>{if(!o)return null;let e=o instanceof Error?o.message:"获取视频详情失败";return(0,eY.O)(e,"generic")},[o]),mutate:()=>{u()}}}(w&&t?Number(t):null,w?x:null,{enabled:j,subActionId:w?y??void 0:void 0}),S=j&&null!=N&&null!=y&&N.id===y,k=w&&j?S?N.video_detail:void 0:i?.video_detail,z=w&&j&&!S&&C;return r===m.Pf.LOADING?(0,a.jsx)("div",{className:"w-full h-full flex flex-col",children:(0,a.jsx)(tp.e,{visible:!0,variant:"versions",overlay:!1,className:"flex-1 min-h-[240px]",label:e("config.projectDetail.loading",{defaultValue:"Loading..."})})}):r===m.Pf.LIST||l||!i?(0,a.jsxs)("div",{className:"w-full h-full flex flex-col gap-6 p-6",children:[t&&(0,a.jsx)("div",{children:(0,a.jsx)(tW,{title:e("config.tabContainer.createVideoExplanation"),description:e("config.tabContainer.createVideoExplanationDesc"),className:"w-full",apiType:"video_gen",showSettingsButton:!0,customizeSaveOnly:!0,onAfterStart:u})}),t&&(0,a.jsx)(J,{projectId:Number(t),tool:"video_gen",onSelectVersion:d})]}):(0,a.jsxs)("div",{className:"relative flex h-full min-h-0 w-full min-w-0 flex-1 flex-col overflow-hidden",id:"video-explanation-wrapper",children:[(0,a.jsxs)("div",{className:"sticky top-0 z-30 flex shrink-0 items-center justify-between bg-white px-6 py-2",children:[(0,a.jsxs)("button",{className:"inline-flex items-center gap-2 text-sm text-gray-600 hover:text-gray-900",onClick:c,children:[(0,a.jsx)(tP.default,{src:"/cdn/common/icons/icon-arrow-left.svg",alt:"",width:16,height:16,className:"h-4 w-4"}),e("config.back")]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:["multi"===h&&(0,a.jsxs)("button",{onClick:p,className:"inline-flex items-center gap-1 rounded-[6px] px-[6px] py-[6px] text-[12px] text-muted-foreground transition-colors hover:bg-muted",children:[(0,a.jsx)(t$,{className:"shrink-0"}),e("config.videoGen.course.title",{defaultValue:"Course"})]}),(0,a.jsx)(tW,{variant:"gearOnly",className:"",apiType:"video_gen",onAfterStart:u,refreshActionId:n?Number(n):void 0})]})]}),(0,a.jsxs)("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[z&&(0,a.jsx)("div",{className:"pointer-events-auto absolute inset-0 z-[40] bg-white",children:(0,a.jsx)(tp.e,{visible:!0,variant:"versions",overlay:!1,className:"h-full min-h-[240px]",label:e("config.projectDetail.loading",{defaultValue:"Loading..."})})}),(0,a.jsx)(tO.uf,{data:k,documentId:w?void 0:i.document_id||void 0,actionId:x||void 0,subActionId:w?y??void 0:void 0,inlineScriptWithChapters:!0},w?`multi-${x}-${y??"x"}`:`single-${x}`),w&&(0,a.jsx)(tq,{isOpen:f,onClose:()=>g(!1),chapters:b,activeChapterId:y,onSelectChapter:v})]})]})};var tU=r(37238);function tZ(){let{t:e}
3=(0,o.Bd)(),[t,r]=(0,s.useState)("study"),[n,i]=(0,s.useState)(!1),[l,c]=(0,s.useState)(0),{model:{projectIdNumber:d,selectedActionId:u,viewState:f,isDetailLoading:g,quizzes:p,error:x},actions:{backToList:h}}=function(){let{projectId:e}=(0,X.g)(),t=e?Number(e):null,r=(0,m.r)(e=>e.getTab(m.SL.QUIZ)),{viewState:n,actionId:a,content:i}=r,l=(0,s.useMemo)(()=>i&&n===m.Pf.CONTENT?i:[],[i,n]),o=(0,s.useMemo)(()=>t?l.filter(e=>e.project_id===t).length:0,[l,t]),c=n===m.Pf.LOADING,d=n!==m.Pf.LIST&&0===o&&c,u=(0,s.useCallback)(()=>{m.r.getState().lifecycle.goToList(m.SL.QUIZ)},[]);return{model:{projectId:e,projectIdNumber:t,viewState:n,selectedActionId:a,isDetailLoading:d,quizzes:l,error:r.error},actions:{backToList:u}}}();return f===m.Pf.LIST?(0,a.jsxs)("div",{className:"w-full h-full flex flex-col gap-6 p-6",children:[d&&(0,a.jsx)(F.StartGeneration,{title:e("config.tabContainer.createQuizzes"),description:e("config.tabContainer.createQuizzesDesc"),className:"w-full",apiType:"quizzes",showSettingsButton:!0,customizeSaveOnly:!0}),d&&(0,a.jsx)(J,{projectId:d,tool:"quizzes"})]}):(0,a.jsxs)("div",{className:"w-full min-h-full flex flex-col",children:[(0,a.jsxs)("div",{className:"sticky top-0 z-30 flex items-center justify-between px-6 py-2 bg-white",children:[(0,a.jsxs)("button",{className:"inline-flex items-center gap-2 text-sm text-gray-600 hover:text-gray-900",onClick:h,children:[(0,a.jsx)("img",{src:"/cdn/common/icons/icon-arrow-left.svg",alt:"",className:"h-4 w-4"}),e("config.back")]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(F.StartGeneration,{variant:"gearOnly",className:"",apiType:"quizzes",refreshActionId:u?Number(u):void 0}),"overview"===t&&(0,a.jsx)("button",{type:"button",className:"inline-flex items-center justify-center px-[12px] py-[4px] relative flex-shrink-0 bg-slate-900 rounded-md hover:opacity-90 transition-opacity cursor-pointer",onClick:()=>i(!0),children:(0,a.jsx)("span",{className:"relative w-fit font-medium text-white text-sm tracking-[0] leading-[18px] whitespace-nowrap",children:e("config.quizResultOverview.restart")})})]})]}),g?(0,a.jsx)(tp.e,{visible:!0,variant:"versions",overlay:!1,className:"flex-1",label:e("config.projectDetail.loading",{defaultValue:"Loading..."})}):(0,a.jsx)("div",{className:"px-3 py-3",children:(0,a.jsx)(tz.gA,{isVisible:!0,onClose:h,onViewAll:()=>{},projectId:d??void 0,data:p,error:x,onViewChange:e=>r("overview"===e?"overview":"study")},l)}),(0,a.jsx)(tU.v,{isOpen:n,onClose:()=>i(!1),onConfirm:()=>{i(!1),r("study"),c(e=>e+1)},title:e("config.quizResultOverview.restartQuiz"),message:e("config.quizResultOverview.restartQuizMessage")})]})}function tK(){let{model:{projectIdNumber:e,tabMetaByKey:t,isSummaryActive:r,isChaptersActive:n,isMindmapActive:l,isFlowNoteActive:o}}=function(){let{projectIdNumber:e,visitedTabs:t,isSummaryActive:r,isChaptersActive:n,isMindmapActive:a,isFlowNoteActive:l}=function(){let{projectId:e}=(0,X.g)(),t=e?Number(e):null,r=(0,i.bh)(e=>e.pageState.activeTab),[n,a]=(0,s.useState)(new Set);return(0,s.useEffect)(()=>{r&&queueMicrotask(()=>{a(e=>{let t=new Set(e);return t.add(r),("summarization"===r||"summary"===r)&&(t.add("summarization"),t.add("summary")),t})})},[r]),{projectId:e,projectIdNumber:t,visitedTabs:n,isSummaryActive:"summarization"===r||"summary"===r,isChaptersActive:"chapters"===r,isMindmapActive:"mindmap"===r,isFlowNoteActive:"flownote"===r,isFlashcardsActive:"flashcards"===r,isQuizzesActive:"quizzes"===r}}(),o=(0,s.useMemo)(()=>en.map(e=>{let r="summary"===e.key?t.has("summarization")||t.has("summary"):t.has(e.tabId);return{...e,visited:r}}),[t]),c=(0,s.useMemo)(()=>o.reduce((e,t)=>(e[t.key]=t,e),{}),[o]);return{model:{projectIdNumber:e,tabMetaWithVisited:o,tabMetaByKey:c,isSummaryActive:r,isChaptersActive:n,isMindmapActive:a,isFlowNoteActive:l},actions:{}}}(),c=function({tabMetaByKey:e,isSummaryActive:t,isChaptersActive:r,isMindmapActive:n,isFlowNoteActive:s}){return[{key:"summary",tabId:e.summary?.tabId??["summarization","summary"],module:"summary",content:()=>(0,a.jsx)(eH,{isActive:t})},{key:"chapters",tabId:e.chapters?.tabId??"chapters",module:"chapter",content:()=>(0,a.jsx)(eU,{isActive:r})},{key:"mindmap",tabId:e.mindmap?.tabId??"mindmap",module:"mindmap",content:()=>(0,a.jsx)(tx,{isActive:n})},{key:"flownote",tabId:e.flownote?.tabId??"flownote",module:"flownote",disableGeneration:!0,content:()=>(0,a.jsx)(tj,{isActive:s})},{key:"flashcards",tabId:e.flashcards?.tabId??"flashcards",module:"flashcard",content:()=>(0,a.jsx)(tD,{})},{key:"quizzes",tabId:e.quizzes?.tabId??"quizzes",module:"quiz",content:()=>(0,a.jsx)(tZ,{})},{key:"video_gen",tabId:e.video_gen?.tabId??"video_gen",module:"video",disableGeneration:!0,content:()=>(0,a.jsx)(tQ,{})}]}({tabMetaByKey:t,isSummaryActive:r,isChaptersActive:n,isMindmapActive:l,isFlowNoteActive:o});return(0,a.jsx)(a.Fragment,{children:c.map(t=>(0,a.jsx)(et,{tabId:t.tabId,disableGeneration:t.disableGeneration,shouldDisableGeneration:t.shouldDisableGeneration,children:(0,a.jsx)(er.L,{module:t.module,resetKey:e??void 0,children:t.content()})},t.key))})}let tY=s.memo(()=>{let{t:e}=(0,o.Bd)(),{projectId:t}=(0,X.g)(),r=t?Number(t):null,n=(0,i.bh)(e=>e.projectDetail?.data?.documentList),l=!n||!Array.isArray(n)||0===n.length,c=(0,i.bh)(e=>e.pageState.activeTab),d=(0,m.r)(e=>e.getTab(m.SL.VIDEO_GEN).viewState),u="video_gen"===c&&d===m.Pf.CONTENT,f=(0,i.bh)(e=>e.projectDetail?.data?.actionTabs),g=(0,i.bh)(e=>e.projectDetail?.data?.id);(0,p.i)();let x=w[j[c||""]||c||""]??null,h=(0,m.Fi)(r??0),b=(0,m.r)(e=>x?e.getTab(x):null),y=b?.viewState,N=b?.progress??{status:"",step:0};(0,s.useEffect)(()=>{m.r.getState().reset()},[]);let C=(0,s.useRef)(!1);return((0,s.useEffect)(()=>{!f||0===f.length||C.current||g===r&&(C.current=!0,m.r.getState().initFromActionTabs(f))},[f,g,r]),(0,s.useEffect)(()=>{m.r.getState().setLifecycle({selectVersion:h.selectVersion,pollAfterAction:h.pollAfterAction,goToList:h.goToList})},[h.selectVersion,h.pollAfterAction,h.goToList]),(0,s.useEffect)(()=>
3{if(x&&r&&g===r)return h.enter(x),()=>{h.leave(x)}},[c,x,r,g]),l)?(0,a.jsx)(v.s8,{}):(0,a.jsxs)("main",{className:(0,eh.cn)("relative flex flex-1 flex-col items-start gap-6 self-stretch rounded-[var(--colors-surface-border-radius-radius-s-md)] px-6 py-4",u?"min-h-0 w-full overflow-x-visible overflow-y-hidden":"w-full overflow-x-visible overflow-y-auto"),"data-color-scheme":"light","data-mantine-color-scheme":"light",style:{position:"relative"},children:[(0,a.jsx)(I,{progress:10*N.step/4*10,visible:y===m.Pf.LOADING,duration:4}),(0,a.jsxs)("div",{className:"flex-1 w-full h-full bg-white",style:{position:"absolute",top:0,left:0,right:0,bottom:0,contain:"style paint"},children:[(0,a.jsx)(_,{className:"absolute top-0 left-0 right-0 bottom-0 bg-white z-9999",action:x,visible:y===m.Pf.LOADING,status:N.status,step:N.step}),y===m.Pf.LOADING&&N.step>0&&x&&(0,a.jsxs)("button",{className:"absolute top-4 left-6 z-[10000] inline-flex items-center gap-2 text-sm text-gray-600 hover:text-gray-900 cursor-pointer",onClick:()=>m.r.getState().lifecycle.goToList(x),children:[(0,a.jsx)("img",{src:"/cdn/common/icons/icon-arrow-left.svg",alt:"",className:"h-4 w-4"}),e("config.back")]}),(0,a.jsx)("div",{className:(0,eh.cn)("relative h-full w-full",u?"min-h-0 overflow-hidden":"overflow-auto"),children:(0,a.jsx)(tK,{})})]})]})}),tJ=()=>(0,a.jsxs)("div",{className:"flex flex-col flex-1 h-full items-start bg-white rounded-lg overflow-visible",children:[(0,a.jsx)(y,{}),(0,a.jsx)("div",{className:"flex flex-col items-start gap-2.5 px-4 py-0 relative self-stretch w-full flex-[0_0_auto]",children:(0,a.jsx)("img",{className:"relative self-stretch w-full h-px mt-[-0.25px]",alt:"Divider line",src:"/cdn/components/tool-section/line.svg"})}),(0,a.jsx)(tY,{})]})},67889:()=>{}}]);

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