1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3202],{93202:function(e,t,n){n.d(t,{L:function(){return h},l:function(){return m}});var r=n(57437),a=n(2265),o=n(99376),i=n(83008),l=n(98319),s=n(84929),u=n(9244),c=n(7153),d=n(41681);let f=(0,a.createContext)(null);function m(){let e=(0,a.useContext)(f);if(!e)throw Error("useAI must be used within an AIProvider");return e}function v(e,t,n,r){t(t=>{let n=new Set(t);return n.delete(e),n}),n(t=>{let n={...t};return delete n[e],n}),r(t=>{let n={...t};return delete n[e],n})}function h(e){let{children:t}=e,[n,m]=(0,a.useState)(new Set),[h,w]=(0,a.useState)({}),[g,p]=(0,a.useState)({}),[y,k]=(0,a.useState)({}),[I,b]=(0,a.useState)(null),C=(0,a.useRef)(null),S=(0,a.useRef)({}),E=(0,a.useRef)(null),A=(0,a.useRef)(!1),P=(0,o.usePathname)(),{showToast:T}=(0,l.p)(),{openQuotaModal:R}=(0,s.f)(),L=(0,a.useRef)({}),x=(0,a.useCallback)(e=>{L.current[e]&&(clearInterval(L.current[e]),delete L.current[e])},[]),D=(0,a.useCallback)(async e=>{let{studentId:t,studentName:n,classId:r,attitude:a,sources:o,targetRange:l="1500",onSuccess:s,onError:f}=e;if((0,u.I)()){T(c.Ad,"info");return}m(e=>new Set(e).add(t)),w(e=>({...e,[t]:{message:"ì¸í¹ ì´ì ìì± ì¤...",percent:0}})),p(e=>({...e,[t]:n}));try{let e=await (0,i.X)("generateSeteukDraft",{studentId:t,studentName:n,classId:r,attitude:a,sources:o,targetRange:l},{path:P||"/unknown"},{timeout:6e5});if(e&&e.success&&e.data)x(t),w(e=>({...e,[t]:{message:"ìì± ìë£",percent:100}})),setTimeout(()=>{v(t,m,w,p)},2500),s&&s(e.data),T("".concat(n," ì¸í¹ ì´ìì ìì±íìµëë¤."),"success"),e.error&&T("".concat(n," ").concat(e.error),"warning");else{let t=(null==e?void 0:e.error)||"ì ì ìë ì¤ë¥ê° ë°ìíìµëë¤. (ìëµ ìì)",n=Error(t);throw(null==e?void 0:e.needCredit)&&(n.needCredit=!0),n}}catch(e){throw console.error("AI Generation Error:",e),(null==e?void 0:e.needCredit)||(0,d.F)(e,{boundary:"ai:seteuk"}),T(e.message||"AI ìì± ì¤ ì¤ë¥ê° ë°ìíìµëë¤.","error"),f&&f(e),e}finally{x(t),m(e=>(e.has(t)&&setTimeout(()=>{v(t,m,w,p)},0),e))}},[P,T,x]),N=(0,a.useCallback)(async e=>{let{studentId:t,studentName:n,category:r,activityName:a,details:o,onSuccess:l,onError:s}=e;if((0,u.I)()){T(c.Ad,"info");return}let f="".concat(t,"-").concat(r),h="autonomous"===r?"ìì¨":"ì§ë¡";m(e=>new Set(e).add(f)),w(e=>({...e,[f]:{message:"íë ì´ì ìì± ì¤...",percent:0}})),p(e=>({...e,[f]:"".concat(n," (").concat(h,")")}));try{let e=await (0,i.X)("generateActivityDraft",{studentId:t,studentName:n,category:r,activityName:a,details:o},{path:P||"/activity"},{timeout:6e5});if(e&&e.success&&e.data)w(e=>({...e,[f]:{message:"ìì± ìë£",percent:100}})),setTimeout(()=>{v(f,m,w,p)},2500),l&&l(e.data),T("".concat(n," (").concat(h,") ì´ìì ìì±íìµëë¤."),"success");else throw Error((null==e?void 0:e.error)||"AI ìì± ì¤ ì¤ë¥ê° ë°ìíìµëë¤.")}catch(e){console.error("Activity Draft AI Generation Error:",e),(null==e?void 0:e.needCredit)||(0,d.F)(e,{boundary:"ai:activity"}),T(e.message||"AI ìì± ì¤ ì¤ë¥ê° ë°ìíìµëë¤.","error"),v(f,m,w,p),s&&s(e)}},[P,T]),F=(0,a.useCallback)(async e=>{let{file:t,studentId:n,onSuccess:r,onError:a}=e;if((0,u.I)()){T(c.rc,"info");return}let o=n||"upload-".concat(Date.now()),l=n?"ìí기ë¡ë¶":"ìí기ë¡ë¶ ì ì²´";m(e=>new Set(e).add(o)),w(e=>({...e,[o]:{message:"íì¼ ë¶ì ì¤...",percent:0}})),p(e=>({...e,[o]:l}));try{let e=await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>{let t=r.result;e(t.split(",")[1])}
1,r.onerror=n,r.readAsDataURL(t)}),a=await (0,i.X)("processLifeRecordUpload",{studentId:n,fileBase64:e},{path:P||"/unknown"},{timeout:6e5});if(a&&a.quotaExceeded){v(o,m,w,p),R({currentUsage:a.currentUsage,limit:a.limit,message:a.error});return}if(a&&a.success)w(e=>({...e,[o]:{message:"ë¶ì ìë£",percent:100}})),setTimeout(()=>{v(o,m,w,p)},2e3),r&&r(a.data),T(a.message||"ìí기ë¡ë¶ ë¶ìì´ ìë£ëììµëë¤.","success");else throw Error((null==a?void 0:a.error)||"ìí기ë¡ë¶ ë¶ì ì¤ ì¤ë¥ê° ë°ìíìµëë¤.")}catch(e){console.error("Life Record Upload Error:",e),(0,d.F)(e,{boundary:"ai:lifeRecord"}),T(e.message||"ìí기ë¡ë¶ ì
ë¡ë ì¤ ì¤ë¥ê° ë°ìíìµëë¤.","error"),v(o,m,w,p),a&&a(e)}},[P,T,R]);a.useEffect(()=>{C.current=I},[I]),a.useEffect(()=>{S.current=y},[y]),a.useEffect(()=>{let e="saemo-ai-batch-queue",t=e=>"processing"===e.status?{...e,status:"failed",error:"íì´ì§ê° ìë¡ê³ 침ëì´ ì¤ë¨ë¨. ìì¡ì íì¸í ë¤ ì¬ìëí´ì£¼ì¸ì."}:e;try{let n=localStorage.getItem("saemo-ai-batch-queues");if(n){let e=JSON.parse(n);if(e&&"object"==typeof e&&!Array.isArray(e)){let n={};for(let[r,a]of Object.entries(e))Array.isArray(a)&&(n[r]=a.map(t));k(n);return}}let r=localStorage.getItem(e);if(r){let n=JSON.parse(r);if(Array.isArray(n)){let e={};for(let r of n){let n=r.classId||"_unknown";(e[n]=e[n]||[]).push(t(r))}k(e)}localStorage.removeItem(e)}}catch(e){console.error("Failed to parse batch queues from local storage",e)}},[]),a.useEffect(()=>{try{localStorage.setItem("saemo-ai-batch-queues",JSON.stringify(y))}catch(e){console.error("Failed to save batch queues to local storage",e)}},[y]);let M=(0,a.useCallback)((e,t)=>{k(n=>{let r={...n},a=t(r[e]||[]);return 0===a.length?delete r[e]:r[e]=a,r})},[]),O=(0,a.useCallback)(async()=>{let e=C.current;if(e&&!A.current){A.current=!0;try{let o=(S.current[e]||[]).find(e=>"pending"===e.status);if(!o){b(null);return}M(e,e=>e.map(e=>e.studentId===o.studentId?{...e,status:"processing",error:void 0}:e));try{await D({studentId:o.studentId,studentName:o.studentName,classId:o.classId,attitude:o.attitude,sources:o.sources,targetRange:o.targetRange,onSuccess:e=>{var t,n;null===(n=E.current)||void 0===n||null===(t=n.onTaskSuccess)||void 0===t||t.call(n,o.studentId,e)}}),M(e,e=>e.map(e=>e.studentId===o.studentId?{...e,status:"success"}:e))}catch(u){var t,n,r,a;if(null===(n=E.current)||void 0===n||null===(t=n.onTaskError)||void 0===t||t.call(n,o.studentId,u),null==u?void 0:u.needCredit){M(e,e=>e.map(e=>e.studentId===o.studentId?{...e,status:"failed",error:u.message||"í¬ë ë§ ë¶ì¡±"}:e)),b(null),null===(a=E.current)||void 0===a||null===(r=a.onInsufficientCredits)||void 0===r||r.call(a);return}let i=(null==u?void 0:u.message)||"",l=/ìê°ì´ ì´ê³¼|íììì|Timeout|Failed to fetch|NetworkError|Load failed|ë¤í¸ìí¬/i.test(i),s=o.retryCount||0;l?M(e,e=>e.map(e=>e.studentId===o.studentId?{...e,status:"failed",error:"ìëµì ë°ì§ ëª»í´ ì¤ë¨íìµëë¤. ì´ë¯¸ ìì±ëì ì ìì¼ë ê²°ê³¼ì ìì¡ì íì¸í ë¤ ë¤ì ìëí´ ì£¼ì¸ì."}:e)):s<2?M(e,e=>e.map(e=>e.studentId===o.studentId?{...e,status:"pending",retryCount:s+1}:e)):M(e,e=>e.map(e=>e.studentId===o.studentId?{...e,status:"failed",error:u.message||"ì ì ìë ì¤ë¥"}:e))}}finally{A.current=!1}C.current===e&&setTimeout(()=>{O()},1500)}},[D,M]);a.useEffect(()=>{I&&O()},[I,O]);let j=(0,a.useCallback)(e=>y[e]||[],[y]),q=(0,a.useCallback)(e=>I===e,[I]),_=(0,a.useCallback)((e,t)=>{M(e,e=>{let n=t.map(e=>({...e,status:"pending",retryCount:0})),r=new Set(e.map(e=>e.studentId));return[...e,...n.filter(e=>!r.has(e.studentId))]})},[M]),U=(0,a.useCallback)((e,t)=>{t&&(E.current=t),b(e)},[]),J=(0,a.useCallback)(()=>b(null),[]),B=(0,a.useCallback)(e=>{C.current===e&&b(null),M(e,()=>[])},[M]),H=(0,a.useCallback)((e,t)=>{M(e,e=>e.filter(e=>e.studentId!==t))},[M]),X=(0,a.useCallback)((e,t)=>{M(e,e=>e.map(e=>e.studentId===t?{...e,status:"pending",error:void 0,retryCount:0}:e))},[M]);return(0,r.jsx)(f.Provider,{value:{generateSeteuk:D,generateActivityDraft:N,uploadLifeRecord:F,generatingIds:n,progressState:h,getBatchQueue:j,isBatchRunningFor:q,enqueueBatch:_,startBatch:U,pauseBatch:J,clearBatchQueue:B,removeBatchTask:H,retryBatchTask:X},children:t})}},84929:function(e,t,n){n.d(t,{E:function(){return l},f:function(){return i}});var r=n(57437),a=n(2265);let o=(0,a.createContext)(void 0);function i(){let e=(0,a.useContext)(o);if(!e)throw Error("useQuota must be used within a QuotaProvider");return e}function l(e){let{children:t}=e,[n,i]=(0,a.useState)(!1),[l,s]=(0,a.useState)(null),u=(0,a.useCallback)(e=>{s(e),i(!0)},[]),c=(0,a.useCallback)(()=>{i(!1),setTimeout(()=>s(null),300)},[]);return(0,r.jsx)(o.Provider,{value:{isQuotaModalOpen:n,quotaInfo:l,openQuotaModal:u,closeQuotaModal:c},children:t})}},7153:function(e,t,n){n.d(t,{Ad:function(){return r},ZO:function(){return i},rc:function(){return a}});let r="AI ìì±ì PCìì ì´ì©í ì ìì´ì.",a="ìí기ë¡ë¶ AI ë¶ìì PCìì ì´ì©í ì ìì´ì.",o=["plans","checkout"];function i(e){return o.includes(e)}},41681:function(e,t,n){n.d(t,{F:function(){return i}});var r=n(96720);let a=new Set;function o(e){try{return e()}catch(e){return}}function i(e,t){try{var n,i;let l=e instanceof Error&&e.name||"Error",s=e instanceof Error?e.message:"string"==typeof e?e:String(e);if(!s||(0,r.lP)({name:l,message:s}))return;let u="".concat(l,"|").concat(s);if(a.has(u)||a.size>=10)return;a.add(u);let c=function(e){var t;let n={},r=o(()=>window.location);if(r){let t=r.hash.replace(/^#/,"");n.href=r.href.slice(0,500),n.pathname=r.pathname.slice(0,200),n.search=r.search.slice(0,200),n.hash=r.hash.slice(0,80),n.view=(null==e?void 0:e.view
1)||t||o(()=>sessionStorage.getItem("naemo:currentView")||void 0),n.guest="1"===new URLSearchParams(r.search).get("guest")}n.viewport=o(()=>({w:window.innerWidth,h:window.innerHeight})),n.screen=o(()=>window.screen?{w:window.screen.width,h:window.screen.height}:void 0),n.language=o(()=>navigator.language),n.languages=o(()=>{var e;return(null===(e=navigator.languages)||void 0===e?void 0:e.slice(0,6).join(", "))||void 0}),n.timezone=o(()=>Intl.DateTimeFormat().resolvedOptions().timeZone),n.online=o(()=>navigator.onLine),n.visibility=o(()=>document.visibilityState),n.native=!0===o(()=>{var e;let t=window.Capacitor;return(null==t?void 0:null===(e=t.isNativePlatform)||void 0===e?void 0:e.call(t))===!0}),n.pwa=!0===o(()=>{var e,t;let n=null===(e=(t=window).matchMedia)||void 0===e?void 0:e.call(t,"(display-mode: standalone)").matches,r=!0===navigator.standalone;return!!(n||r)}),n.theme=o(()=>{var e,t;let n=document.documentElement;return n.classList.contains("dark")||"dark"===n.dataset.theme?"dark":n.classList.contains("light")||"light"===n.dataset.theme?"light":(null===(e=(t=window).matchMedia)||void 0===e?void 0:e.call(t,"(prefers-color-scheme: dark)").matches)?"dark-system":"light-system"}),n.orientation=o(()=>{var e;return(null===(e=screen.orientation)||void 0===e?void 0:e.type)||(window.innerWidth>=window.innerHeight?"landscape":"portrait")}),n.pointer=o(()=>{var e,t,n,r;return(null===(e=(t=window).matchMedia)||void 0===e?void 0:e.call(t,"(pointer: coarse)").matches)?"coarse":(null===(n=(r=window).matchMedia)||void 0===n?void 0:n.call(r,"(pointer: fine)").matches)?"fine":void 0}),n.reducedMotion=o(()=>{var e,t;return null===(e=(t=window).matchMedia)||void 0===e?void 0:e.call(t,"(prefers-reduced-motion: reduce)").matches}),n.cookies=o(()=>navigator.cookieEnabled),n.secure=o(()=>window.isSecureContext),n.dpr=o(()=>window.devicePixelRatio),n.pageLoadMs=o(()=>Math.round(performance.now())),n.historyLength=o(()=>window.history.length),n.touchPoints=o(()=>navigator.maxTouchPoints),n.cores=o(()=>navigator.hardwareConcurrency),n.scrollY=o(()=>Math.round(window.scrollY||document.documentElement.scrollTop||0)),n.referrer=o(()=>document.referrer||void 0),n.title=o(()=>document.title||void 0),n.buildId=o(()=>{for(let e of Array.from(document.querySelectorAll('script[src*="/_next/static/"]'))){let t=e.src.match(/\/_next\/static\/([^/]+)\//);if((null==t?void 0:t[1])&&!["chunks","css","media","webpack"].includes(t[1]))return t[1]}});let a=null!==(t=o(()=>{let e=navigator.connection;return e?{type:e.effectiveType,downlink:e.downlink,rtt:e.rtt,saveData:e.saveData}:{}}))&&void 0!==t?t:{};return a.type&&(n.connection=a.type),null!=a.downlink&&(n.downlink=a.downlink),null!=a.rtt&&(n.rtt=a.rtt),null!=a.saveData&&(n.saveData=a.saveData),(null==e?void 0:e.componentStack)&&(n.componentStack=e.componentStack.slice(0,4e3)),(null==e?void 0:e.boundary)&&(n.boundary=e.boundary.slice(0,120)),(null==e?void 0:e.digest)&&(n.digest=e.digest.slice(0,80)),(null==e?void 0:e.filename)&&(n.filename=e.filename.slice(0,300)),"number"==typeof(null==e?void 0:e.lineno)&&(n.lineno=e.lineno),"number"==typeof(null==e?void 0:e.colno)&&(n.colno=e.colno),n}(t),d=function(e){if(!(e instanceof Error)||null==e.cause)return;let t=e.cause;if(t instanceof Error)return"".concat(t.name,": ").concat(t.message).slice(0,500);try{return String(t).slice(0,500)}catch(e){return}}(e);d&&(c.cause=d);let f={name:l,message:s,stack:e instanceof Error?e.stack:void 0,url:null!==(i=null!==(n=null==t?void 0:t.url)&&void 0!==n?n:c.pathname)&&void 0!==i?i:window.location.pathname+window.location.search,situation:c},m=JSON.stringify(f);if(m.length>24e3&&c.componentStack&&(f.situation={...c,componentStack:c.componentStack.slice(0,400)},m=JSON.stringify(f)),navigator.sendBeacon){navigator.sendBeacon("/api/client-error",new Blob([m],{type:"application/json"}));return}fetch("/api/client-error",{method:"POST",headers:{"Content-Type":"application/json"},body:m,keepalive:!0}).catch(()=>{})}catch(e){}}},96720:function(e,t,n){n.d(t,{Fv:function(){return l},Hu:function(){return s},lP:function(){return o},wt:function(){return u},yl:function(){return i}});let r="naemo:sw-silent-reload",a="naemo:chunk-silent-reload";function o(e){var t;let n=(null!==(t=e.message)&&void 0!==t?t:"").toLowerCase();return"ChunkLoadError"===e.name||n.includes("chunk")||n.includes("load failed")}function i(e){return"1"!==e.getItem(r)&&(e.setItem(r,"1"),!0)}function l(e){e.removeItem(r)}
1function s(e,t,n){return!!o(e)&&"1"!==t.getItem(a)&&(t.setItem(a,"1"),n(),!0)}function u(e){e.removeItem(a)}}}]);
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.