@ihabdevteam/core 0.136.0 → 0.138.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +98 -0
- package/dist/components.cjs.js +177 -177
- package/dist/components.esm.css +2 -2
- package/dist/hooks.cjs.js +1 -1
- package/dist/i18n.cjs.js +3 -3
- package/dist/ihabdevteam-core.cjs.js +182 -182
- package/dist/ihabdevteam-core.d.ts +20 -5
- package/dist/packages/core/src/components/Breadcrumb.js +1 -0
- package/dist/packages/core/src/components/Button.js +10 -1
- package/dist/packages/core/src/components/Effect/EffectPartyPopper.js +3 -2
- package/dist/packages/core/src/components/Icon.js +4 -1
- package/dist/packages/core/src/components/LandingHeader.d.ts +1 -1
- package/dist/packages/core/src/components/LandingHeader.js +5 -1
- package/dist/packages/core/src/components/PageTitle.js +1 -0
- package/dist/packages/core/src/components/Pagination.js +1 -1
- package/dist/packages/core/src/components/Panel.css +3 -0
- package/dist/packages/core/src/components/Panel.d.ts +11 -1
- package/dist/packages/core/src/components/Panel.js +3 -3
- package/dist/packages/core/src/components/PanelRow.js +8 -1
- package/dist/packages/core/src/components/PassCard/PassCard.js +1 -1
- package/dist/packages/core/src/components/PassCard/PassCardBgIHAB.js +1 -0
- package/dist/packages/core/src/components/PassCard/PassCardBgLeftColorGrid.js +1 -0
- package/dist/packages/core/src/components/PassCard/PassCardBgSoundMove.js +1 -0
- package/dist/packages/core/src/components/PassCard/PassCardBgSoundMoveV1.js +1 -0
- package/dist/packages/core/src/components/PassCard/PassCardBgTalk.js +1 -0
- package/dist/packages/core/src/components/PassCard/PassCardBgTalkV1.js +1 -0
- package/dist/packages/core/src/components/PassCard/PassCardBgTwoCircle.js +1 -0
- package/dist/packages/core/src/components/Popup/DeviceSideTable.js +8 -1
- package/dist/packages/core/src/components/Popup/LoadTablePopup.js +3 -1
- package/dist/packages/core/src/components/Popup/Popup.css +10 -0
- package/dist/packages/core/src/components/Popup/Popup.d.ts +5 -0
- package/dist/packages/core/src/components/Popup/Popup.js +5 -4
- package/dist/packages/core/src/components/Popup/TrainingResultPopup.js +6 -1
- package/dist/packages/core/src/components/ProgressIndicator.js +1 -0
- package/dist/packages/core/src/components/PromoBannerBg/PromoBannerBgDark.js +1 -0
- package/dist/packages/core/src/components/PromoBannerBg/PromoBannerBgDeep.js +1 -0
- package/dist/packages/core/src/components/PromoBannerBg/PromoBannerBgDiagonal.js +1 -0
- package/dist/packages/core/src/components/PromoBannerBg/PromoBannerBgDots.js +1 -0
- package/dist/packages/core/src/components/PromoBannerBg/PromoBannerBgInstagram.js +1 -0
- package/dist/packages/core/src/components/PromoBannerBg/PromoBannerBgMain.js +1 -0
- package/dist/packages/core/src/components/PromoBannerBg/PromoBannerBgNaver.js +1 -0
- package/dist/packages/core/src/components/PromoBannerBg/PromoBannerBgOutline.js +1 -0
- package/dist/packages/core/src/components/PromoBannerBg/PromoBannerBgRadial.js +1 -0
- package/dist/packages/core/src/components/PromoBannerBg/PromoBannerBgSoft.js +1 -0
- package/dist/packages/core/src/components/PromoBannerBg/PromoBannerBgSoftSub.js +1 -0
- package/dist/packages/core/src/components/PromoBannerBg/PromoBannerBgSub.js +1 -0
- package/dist/packages/core/src/components/PromoBannerBg/PromoBannerBgSuccess.js +1 -0
- package/dist/packages/core/src/components/PromoBannerBg/PromoBannerBgWarm.js +1 -0
- package/dist/packages/core/src/components/Table.js +4 -1
- package/dist/packages/core/src/components/TextField.js +3 -1
- package/dist/packages/core/src/components/Tooltip/DescriptionTooltip.js +1 -0
- package/dist/packages/core/src/components/Tooltip/MenuTooltip.js +23 -26
- package/dist/packages/core/src/components/Training/TrainingBlock.js +20 -3
- package/dist/packages/core/src/components/Training/TrainingBlockButton.js +10 -4
- package/dist/packages/core/src/components/Training/TrainingCardGroup.js +2 -1
- package/dist/packages/core/src/components/Training/TrainingPagePopup.js +20 -5
- package/dist/packages/core/src/components/Training/TrainingStepAudioPlayer.js +60 -3
- package/dist/packages/core/src/components/Training/TrainingStepCard.js +16 -1
- package/dist/packages/core/src/components/Training/TrainingStepConfirm.js +2 -1
- package/dist/packages/core/src/components/Training/TrainingStepConfirmWithText.js +26 -6
- package/dist/packages/core/src/components/Training/TrainingStepOrderList.d.ts +0 -1
- package/dist/packages/core/src/components/Training/TrainingStepOrderList.js +16 -1
- package/dist/packages/core/src/components/Training/TrainingStepTextBox.js +18 -3
- package/dist/packages/core/src/components/Training/TrainingWordCard.js +28 -5
- package/dist/packages/core/src/components/Training/currentSound.d.ts +5 -0
- package/dist/packages/core/src/components/Training/currentSound.js +13 -0
- package/dist/packages/core/src/components/Training/trainingPopupUtils.js +12 -1
- package/dist/packages/core/src/components/Training/useNoiseFade.js +7 -1
- package/dist/packages/core/src/components/Training/useTTSPlayback.js +5 -1
- package/dist/packages/core/src/components/Word/PhonemeSelectBlock.js +3 -1
- package/dist/packages/core/src/components/WordTable.js +25 -7
- package/dist/packages/core/src/hooks/useEditableList.js +13 -5
- package/dist/packages/core/src/hooks/useFontScale.js +13 -4
- package/dist/packages/core/src/hooks/useIcon.js +3 -0
- package/dist/packages/core/src/hooks/useLucideIcon.js +3 -0
- package/dist/packages/core/src/hooks/useMediaQuery.d.ts +2 -1
- package/dist/packages/core/src/hooks/useMediaQuery.js +37 -8
- package/dist/packages/core/src/hooks/usePagedList.js +1 -0
- package/dist/packages/core/src/hooks/usePasswordChange.js +7 -0
- package/dist/packages/core/src/hooks/useTrainingTypeLabels.js +1 -0
- package/dist/packages/core/src/hooks/useVisitHistory.js +1 -0
- package/dist/packages/core/src/hooks/useWordTrainingDataGeneration.js +18 -3
- package/dist/packages/core/src/i18n/locales/en.json +41 -4
- package/dist/packages/core/src/i18n/locales/ko.json +41 -4
- package/dist/packages/core/src/utils/errorMessage.js +7 -1
- package/dist/packages/core/src/utils/wordPairIndex.js +11 -3
- package/dist/packages/core/src/version.d.ts +1 -1
- package/dist/packages/core/src/version.js +1 -1
- package/dist/utils.cjs.js +2 -2
- package/package.json +1 -1
package/dist/hooks.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var s=require("react"),ce=require("react-i18next"),Ru=require("i18next"),iu=typeof document<"u"?document.currentScript:null;function Ut({storageKey:e="fontScale",baseFont:u=20,minScale:t=.8,maxScale:n=1.4,step:o=.1,lineHeightRatio:l=1.4}={}){const r=p=>Math.max(t,Math.min(n,Number(p))),[a,i]=s.useState(()=>{try{const p=localStorage.getItem(e),g=p?Number(p):1;return Number.isFinite(g)?r(g):r(1)}catch{return 1}});s.useEffect(()=>{try{localStorage.setItem(e,String(a))}catch{}},[e,a]);const c=p=>{i(typeof p=="function"?g=>r(p(g)):r(p))},h=()=>c(p=>+(p+o).toFixed(6)),C=()=>c(p=>+(p-o).toFixed(6)),d=a<n-Number.EPSILON,m=a>t+Number.EPSILON,f=Math.round(u*a),E=Math.round(f*l);return{scale:a,setScale:c,increase:h,decrease:C,canIncrease:d,canDecrease:m,fontSize:f,lineHeight:E}}const Mu=s.createContext(null);function Kt(e){return/max-width:\s*7[0-9][0-9]px/.test(e)}function Wt(e){const u=s.useContext(Mu),t=l=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(l).matches,[n,o]=s.useState(t(e));return s.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const l=window.matchMedia(e),r=i=>o(i.matches),a=l;return a.addEventListener?a.addEventListener("change",r):a.addListener&&a.addListener(r),o(l.matches),()=>{a.removeEventListener?a.removeEventListener("change",r):a.removeListener&&a.removeListener(r)}},[e]),u&&typeof u.mobile=="boolean"&&Kt(e)?u.mobile:n}function Lu(e){const u=s.useRef(e);return s.useEffect(()=>{u.current=e}),u}function ku(e,u){const t=Lu(u);s.useEffect(()=>{const n=()=>t.current();try{window.addEventListener(e,n)}catch{}return()=>{try{window.removeEventListener(e,n)}catch{}}},[e,t])}const cu=" \xB7 ",Pu=(()=>{if(typeof document>"u")return"";const e=document.title;return e.includes(cu)?e.split(cu).pop()??e:e})(),vu=s.createContext(!1),ge=[];let xu=null;function qt(e){const u=s.useContext(vu);s.useEffect(()=>{if(u||typeof e!="string"||!e)return;ge.length===0&&(xu=document.title);const t={text:Pu?`${e}${cu}${Pu}`:e};return ge.push(t),document.title=t.text,()=>{const n=ge.lastIndexOf(t);n>=0&&ge.splice(n,1),document.title=ge.length?ge[ge.length-1].text:xu??document.title}},[e,u])}function zt(){const{t:e}=ce.useTranslation();return s.useCallback(u=>{if(!u)return"";const t=new Date(u).getTime();if(Number.isNaN(t))return"";const n=Math.floor((Date.now()-t)/864e5);return n<=0?e("myHomework.relativeDay.today","\uC624\uB298"):n===1?e("myHomework.relativeDay.yesterday","\uC5B4\uC81C"):e("myHomework.relativeDay.daysAgo",{n})},[e])}const Jt=()=>{const e="\uC54C \uC218 \uC5C6\uB294 \uC624\uB958",u=typeof Ru?.t=="function"?Ru.t("common.unknownError",{defaultValue:e}):void 0;return typeof u=="string"&&u?u:e};function Qt(e,u){if(u===void 0&&(u=Jt()),e instanceof Error)return e.message||u;if(typeof e=="string")return e||u;if(e&&typeof e=="object"){const t=e;for(const n of[t.message,t.error_description,t.error])if(typeof n=="string"&&n)return n}return u}function Zt(e){const{t:u}=ce.useTranslation(),[t,n]=s.useState({current:"",next:"",confirm:""}),[o,l]=s.useState(null),[r,a]=s.useState(!1),i=s.useRef(null);s.useEffect(()=>()=>{i.current!==null&&clearTimeout(i.current)},[]);const c=s.useCallback(()=>{n({current:"",next:"",confirm:""}),l(null)},[]),h=s.useCallback(async()=>{if(!t.current){l({type:"error",text:u("account.security.password.currentRequired","\uD604\uC7AC \uBE44\uBC00\uBC88\uD638\uB97C \uC785\uB825\uD558\uC138\uC694.")});return}if(!t.next){l({type:"error",text:u("account.security.password.newRequired","\uC0C8 \uBE44\uBC00\uBC88\uD638\uB97C \uC785\uB825\uD558\uC138\uC694.")});return}if(t.next!==t.confirm){l({type:"error",text:u("account.security.password.mismatch","\uC0C8 \uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.")});return}a(!0);let C;try{C=e?await e(t.current,t.next):null}catch(d){C=Qt(d)}finally{a(!1)}if(C){l({type:"error",text:C});return}l({type:"success",text:u("account.security.password.changed","\uBE44\uBC00\uBC88\uD638\uAC00 \uBCC0\uACBD\uB418\uC5C8\uC2B5\uB2C8\uB2E4.")}),n({current:"",next:"",confirm:""}),i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>l(null),1500)},[t,e,u]);return{pw:t,setPw:n,pwMsg:o,setPwMsg:l,pwLoading:r,handleChangePw:h,reset:c}}const z=["\u3131","\u3132","\u3134","\u3137","\u3138","\u3139","\u3141","\u3142","\u3143","\u3145","\u3146","\u3147","\u3148","\u3149","\u314A","\u314B","\u314C","\u314D","\u314E"],ne=["\u314F","\u3150","\u3151","\u3152","\u3153","\u3154","\u3155","\u3156","\u3157","\u3158","\u3159","\u315A","\u315B","\u315C","\u315D","\u315E","\u315F","\u3160","\u3161","\u3162","\u3163"],ue=["","\u3131","\u3132","\u3133","\u3134","\u3135","\u3136","\u3137","\u3139","\u313A","\u313B","\u313C","\u313D","\u313E","\u313F","\u3140","\u3141","\u3142","\u3144","\u3145","\u3146","\u3147","\u3148","\u314A","\u314B","\u314C","\u314D","\u314E"];function V(e){if(!e)return null;const u=e.charCodeAt(0)-44032;return u<0||u>=11172?null:{cho:Math.floor(u/588),jung:Math.floor(u%588/28),jong:u%28}}function Xt(){const e=new Map;return u=>{let t=e.get(u);return t||(t=[...u].map(n=>V(n)),e.set(u,t)),t}}function Ce(e,u,t=0){return String.fromCharCode(44032+(e*21+u)*28+t)}function en(e,u){if(!e||!u||e===u||e.length!==u.length)return"random";let t=0,n=null;for(let o=0;o<e.length;o++){const l=V(e[o]),r=V(u[o]);if(!l||!r)return"random";if(l.cho===r.cho&&l.jung===r.jung&&l.jong===r.jong)continue;t++;const a=l.cho!==r.cho,i=l.jung!==r.jung,c=l.jong!==r.jong;(a?1:0)+(i?1:0)+(c?1:0)>1?n="multi":a?n="cho":i?n="jung":n="jong"}return t!==1?"random":n==="cho"?"cho":n==="jung"?"jung":n==="jong"?"jong":"random"}const be={3:["\u3131","\u3145"],5:["\u3134","\u3148"],6:["\u3134","\u314E"],9:["\u3139","\u3131"],10:["\u3139","\u3141"],11:["\u3139","\u3142"],12:["\u3139","\u3145"],13:["\u3139","\u314C"],14:["\u3139","\u314D"],15:["\u3139","\u314E"],18:["\u3142","\u3145"]};Object.fromEntries(Object.entries(be).map(([e,u])=>[u.join(""),ue[Number(e)]]));function un(e,u){if(!e||!u)return!1;for(const t of e){const n=V(t);if(n){if(z[n.cho]===u)return!0;if(n.jong>0){if(ue[n.jong]===u)return!0;const o=be[n.jong];if(o&&o.includes(u))return!0}}}return!1}function Ae(e){if(!e)return 0;let u=0;for(const t of e)V(t)&&u++;return u}function tn(e){if(!e)return!1;let u=!1;for(const t of e){const n=V(t);if(n&&(u=!0,n.jong>0))return!1}return u}function nn(e,u){if(e.jong<=0)return!1;if(u.includes(ue[e.jong]))return!0;const t=be[e.jong];return!!t&&t.some(n=>u.includes(n))}function on(e,u,t){if(!e)return!1;const n=[...e],o=l=>{const r=V(n[l]);if(!r||u.cho&&!u.cho.includes(z[r.cho])||u.jung&&!u.jung.includes(ne[r.jung]))return!1;if(u.jongNone){if(r.jong>0)return!1}else if(u.jong&&!nn(r,u.jong))return!1;return!0};if(t==="head")return o(0);if(t==="tail")return o(n.length-1);if(t==="mid"){for(let l=1;l<n.length-1;l++)if(o(l))return!0;return!1}for(let l=0;l<n.length;l++)if(o(l))return!0;return!1}const ln={cho:z.length,jung:ne.length,jong:ue.length};function rn(e,u,t,n,o=1/0){if(!e||t<1)return[];const l=[...e].map(C=>V(C));if(l.some(C=>!C))return[];const r=l,a=r.length;if(t>a)return[];const i=ln[u],c=new Set,h=[];(function C(d,m){if(m.length===t){h.push([...m]);return}for(let f=d;f<a;f++)m.push(f),C(f+1,m),m.pop()})(0,[]);for(const C of h)if((function d(m,f){if(c.size>=o)return;if(m===C.length){const g=f.map(S=>Ce(S.cho,S.jung,S.jong)).join("");g!==e&&n.has(g)&&c.add(g);return}const E=C[m],p=r[E][u];for(let g=0;g<i;g++){if(g===p)continue;const S=f.slice();if(S[E]={...f[E],[u]:g},d(m+1,S),c.size>=o)return}})(0,r),c.size>=o)break;return[...c]}function an(e,u){if(!e||!u||e.length!==u.length)return-1;let t=0;for(let n=0;n<e.length;n++){const o=V(e[n]),l=V(u[n]);if(!o||!l)return-1;o.cho!==l.cho&&t++,o.jung!==l.jung&&t++,o.jong!==l.jong&&t++}return t}const Fu="word_pair_index_v2",Vu="word_pair_index_sig_v2";let _e=null;function sn(){try{if(typeof localStorage>"u")return null;const e=localStorage.getItem(Fu),u=localStorage.getItem(Vu);return!e||!u?null:{index:JSON.parse(e),sig:u}}catch{return null}}function De(){if(_e)return _e;const e=sn();return e?(_e=e.index,e.sig,_e):null}function cn(){_e=null;try{typeof localStorage<"u"&&(localStorage.removeItem(Fu),localStorage.removeItem(Vu))}catch{}}const $u="word_image_existence_map_v1";let Ee=null;function Hu(){if(Ee)return Ee;try{const e=typeof localStorage<"u"?localStorage.getItem($u):null;Ee=e?JSON.parse(e):{}}catch{Ee={}}return Ee}function Cn(e,u){return`${e}_${u??1}`}function dn(e,u){const t=Hu(),n=Cn(e,u);return n in t?t[n]:void 0}function Gu(){const e=Hu(),u=Object.values(e);return u.length===0?null:{total:u.length,exists:u.filter(Boolean).length}}function fn(){Ee={};try{typeof localStorage<"u"&&localStorage.removeItem($u)}catch{}}const Yu=[{id:"wordData",labelKey:"settings.cache.group.wordData.label",subKey:"settings.cache.group.wordData.sub",keys:["word_data_cache","word_data_version"]},{id:"pairIndex",labelKey:"settings.cache.group.pairIndex.label",subKey:"settings.cache.group.pairIndex.sub",keys:["word_pair_index_v2","word_pair_index_sig_v2"]},{id:"imageCache",labelKey:"settings.cache.group.imageCache.label",subKey:"settings.cache.group.imageCache.sub",keys:["word_image_existence_map_v1"]}];function Uu(e){return e.reduce((u,t)=>{try{const n=localStorage.getItem(t);return u+(n?new Blob([n]).size:0)}catch{return u}},0)}function gn(e){return e===0?"0 B":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(2)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}function hn(e){const{t:u}=ce.useTranslation(),[t,n]=s.useState({}),[o,l]=s.useState(null),[r,a]=s.useState(null),[i,c]=s.useState(null),h=s.useCallback(()=>{const d={};Yu.forEach(m=>{d[m.id]=Uu([...m.keys])}),n(d),typeof navigator<"u"&&navigator.storage?.estimate&&navigator.storage.estimate().then(m=>{c({usage:m.usage??0,quota:m.quota??0})}).catch(()=>{})},[]);s.useEffect(()=>{h()},[h]);const C=s.useCallback(async d=>{l(d);try{d==="wordData"?(localStorage.removeItem("word_data_cache"),localStorage.removeItem("word_data_version")):d==="pairIndex"?cn():d==="imageCache"&&fn(),h(),e?.(u("settings.cache.cleared","\uCE90\uC2DC\uAC00 \uC0AD\uC81C\uB418\uC5C8\uC2B5\uB2C8\uB2E4."))}finally{l(null)}},[h,e,u]);return{cacheSizes:t,clearingId:o,confirmCacheId:r,setConfirmCacheId:a,storageEstimate:i,refreshCacheSizes:h,handleClearCache:C}}function mn(e){const[u,t]=s.useState(null),[n,o]=s.useState(null),l=s.useCallback(()=>{const r=De();if(r){const i=Object.values(r),c=i.filter(h=>h.cho.length+h.jung.length+h.jong.length>0).length;t({matched:c,total:i.length})}else t(null);const a=Gu();o(a?{exists:a.exists,total:a.total}:null)},[]);return s.useEffect(()=>{l();const r=setTimeout(l,1e3);return()=>clearTimeout(r)},[e?.length,l]),{pairStats:u,imgStats:n,setPairStats:t,setImgStats:o,refreshStats:l}}function Oe(e,u){if(e===u)return!0;const t=e?.id,n=u?.id;return t!=null&&t!==""&&t===n}function Ku(e,u=[]){const[t,n]=s.useState(u),[o,l]=s.useState(null),[r,a]=s.useState(!1),[i,c]=s.useState(e),h=s.useRef(r);s.useEffect(()=>{h.current=r});const C=s.useRef(null);s.useEffect(()=>{if(h.current)return;const g=C.current;g!==null&&g.length===u.length&&g.every((S,B)=>S===u[B])||(C.current=u,n(u),l(S=>S==null?S:u.find(B=>Oe(B,S))??S))},[u]),s.useEffect(()=>{!r&&o!=null&&c({...o})},[r,o]);const d=s.useCallback(g=>{l(g),a(!1),c({...g})},[]),m=s.useCallback(()=>a(!0),[]),f=s.useCallback(()=>a(!1),[]),E=s.useCallback((g,S)=>{n(g),l(S),a(!1)},[]),p=s.useCallback(g=>{n(S=>S.filter(B=>!Oe(B,g))),l(null)},[]);return{list:t,setList:n,selected:o,setSelected:l,isEditing:r,setIsEditing:a,editForm:i,setEditForm:c,openDetail:d,startEditing:m,cancelEditing:f,commitEdit:E,remove:p}}const Ne=()=>{const e=new Date;return{year:String(e.getFullYear()),month:String(e.getMonth()+1).padStart(2,"0"),day:String(e.getDate()).padStart(2,"0")}},pn={year:"",month:"",day:"",hour:"09",minute:"00",memo:""};function Sn(e=[]){const{list:u,setList:t,selected:n,setSelected:o,isEditing:l,setIsEditing:r,editForm:a,setEditForm:i,openDetail:c,commitEdit:h}=Ku(pn,e),{year:C,month:d,day:m}=Ne(),[f,E]=s.useState({year:C,month:d,day:m,hour:"09",minute:"00",memo:""});return{visitHistory:u,visitForm:f,setVisitForm:E,setVisit:p=>g=>E(S=>({...S,[p]:g})),selectedVisit:n,setSelectedVisit:o,isEditingVisit:l,setIsEditingVisit:r,editVisitForm:a,setEditVisitForm:i,openVisitDetail:c,handleVisitSave:p=>{t(b=>[f,...b]);const{year:g,month:S,day:B}=Ne();E({year:g,month:S,day:B,hour:"09",minute:"00",memo:""}),p?.()},handleVisitEditSave:()=>{h(p=>p.map(g=>n!=null&&Oe(g,n)?a:g),a)},addVisit:p=>{t(g=>[p,...g])},removeVisit:p=>{t(g=>g.filter(S=>S!==p))},revertVisitEdit:(p,g)=>{t(S=>S.map(B=>B===g?p:B)),o(S=>S===g?p:S)}}}const Wu=e=>`${e.year.padStart(4,"0")}-${e.month.padStart(2,"0")}-${e.day.padStart(2,"0")} ${e.hour.padStart(2,"0")}:${e.minute.padStart(2,"0")}`,Ye=e=>[...e].sort((u,t)=>{const n=Wu(u),o=Wu(t);return n<o?-1:n>o?1:0}),yn={year:"",month:"",day:"",hour:"09",minute:"00",memo:""};function En(e,u=[]){const t=s.useMemo(()=>Ye(u),[u]),{list:n,setList:o,selected:l,setSelected:r,isEditing:a,setIsEditing:i,editForm:c,setEditForm:h,openDetail:C,commitEdit:d,remove:m}=Ku(yn,t),[f,E]=s.useState([]),{year:p,month:g,day:S}=Ne(),[B,b]=s.useState({year:p,month:g,day:S,hour:"09",minute:"00",memo:""}),_=R=>L=>b(H=>({...H,[R]:L})),w=R=>{o(ee=>Ye([...ee,B]));const{year:L,month:H,day:U}=Ne();b({year:L,month:H,day:U,hour:"09",minute:"00",memo:""}),R?.()},O=()=>{d(R=>Ye(R.map(L=>l!=null&&Oe(L,l)?c:L)),c)},v=s.useCallback(R=>{m(R)},[m]),k=s.useCallback(R=>{e({year:R.year,month:R.month,day:R.day,hour:R.hour,minute:R.minute,memo:R.memo,...R.id!=null?{id:R.id}:{}}),m(R)},[e,m]),D=s.useCallback(R=>{o(L=>L.filter(H=>!Oe(H,R))),E(L=>[R,...L]),r(null)},[o,r]),$=s.useCallback(R=>{o(L=>Ye([...L,R]))},[o]),G=s.useCallback(R=>{o(L=>L.filter(H=>H!==R))},[o]),Y=s.useCallback((R,L)=>{o(H=>H.map(U=>U===L?R:U)),r(H=>H===L?R:H)},[o,r]);return{scheduleList:n,noShowList:f,addSchedule:$,removeSchedule:G,revertScheduleEdit:Y,scheduleForm:B,setScheduleForm:b,setSchedule:_,selectedSchedule:l,setSelectedSchedule:r,isEditingSchedule:a,setIsEditingSchedule:i,editScheduleForm:c,setEditScheduleForm:h,openScheduleDetail:C,handleScheduleSave:w,handleScheduleEditSave:O,handleScheduleDelete:v,handleScheduleToVisit:k,handleScheduleNoVisit:D}}const Ue=[{value:"10",label:"10\uAC1C\uC529 \uBCF4\uAE30"},{value:"25",label:"25\uAC1C\uC529 \uBCF4\uAE30"},{value:"50",label:"50\uAC1C\uC529 \uBCF4\uAE30"},{value:"100",label:"100\uAC1C\uC529 \uBCF4\uAE30"}];function Bn(e){const{t:u}=ce.useTranslation(),[t,n]=s.useState(""),[o,l]=s.useState("25"),[r,a]=s.useState("all"),[i,c]=s.useState(1),h=s.useMemo(()=>e.filter(({item:E,status:p})=>!(t&&!E.memo.includes(t)||r!=="all"&&p!==r)),[e,t,r]),C=Math.max(1,Math.ceil(h.length/Number(o))),d=Math.min(i,C),m=s.useMemo(()=>h.slice((d-1)*Number(o),d*Number(o)),[h,d,o]),f=s.useMemo(()=>Ue.map(E=>({...E,label:u("common.pageSizeLabel",{n:E.value,defaultValue:E.label})})),[u]);return{vapSearch:t,setVapSearch:n,vapPageSize:o,setVapPageSize:l,vapPageSizeOptions:f,vapStatus:r,setVapStatus:a,vapPage:d,setVapPage:c,vapFiltered:h,vapTotal:C,vapPageItems:m}}function wn(e,u,t){const{t:n}=ce.useTranslation(),[o,l]=s.useState(()=>{const f=t?.initialPageSize;return f&&Ue.some(E=>E.value===f)?f:"25"}),[r,a]=s.useState(1),[i,c]=s.useState(u);i!==u&&(c(u),r!==1&&a(1));const h=s.useMemo(()=>Ue.map(f=>({...f,label:n("visits.showN",{n:f.value})})),[n]),C=s.useCallback(f=>{l(f),a(1)},[]),d=Math.max(1,Math.ceil(e.length/Number(o)));r>d&&a(d);const m=Math.min(r,d);return{pageRows:s.useMemo(()=>e.slice((m-1)*Number(o),m*Number(o)),[e,m,o]),pageSizeProps:{options:h,value:o,onChange:C},paginationProps:{page:m,total:d,onChange:a},setPage:a}}function bn(){const[e,u]=s.useState(null),t=s.useCallback(o=>{u(l=>l?.key===o?{key:o,asc:!l.asc}:{key:o,asc:!0})},[]),n=s.useCallback((o,l)=>({label:o,sortDir:e?.key===l?e.asc?"asc":"desc":null,onClick:()=>t(l)}),[e,t]);return{\uC815\uB82C:e,\uCE78:n}}const qu=e=>e==="\uC88C"||e==="\uC6B0"?e:null;function An(){const[e,u]=s.useState(!1),[t,n]=s.useState("\uC88C"),[o,l]=s.useState({\uC88C:null,\uC6B0:null}),[r,a]=s.useState({\uC88C:[],\uC6B0:[]}),[i,c]=s.useState(!1),[h,C]=s.useState("\uC88C"),d=s.useCallback(f=>{const E=qu(f.direction);E&&(l(p=>({...p,[E]:f})),a(p=>({...p,[E]:[f,...p[E]]})),u(!1))},[]),m=s.useCallback(f=>{const E=qu(f.direction);E&&(l(p=>({...p,[E]:f})),c(!1))},[]);return{showDevice:e,setShowDevice:u,deviceDirection:t,setDeviceDirection:n,devices:o,setDevices:l,deviceHistory:r,setDeviceHistory:a,showDeviceList:i,setShowDeviceList:c,listForSide:h,setListForSide:C,handleDeviceSubmit:d,handleSelectFromList:m}}const _n="__ihab_core_word_pool__";function Ke(){return globalThis[_n]??null}function F(e,u=Math.random){const t=e.slice();for(let n=t.length-1;n>0;n--){const o=Math.floor(u()*(n+1));[t[n],t[o]]=[t[o],t[n]]}return t}function ae(e,u,t=Math.random){return!Array.isArray(e)||e.length===0||u<=0?[]:u>=e.length?F(e,t):F(e,t).slice(0,u)}const Cu={SAME_SOUND_PICK:{difficulty:!0,choseong:!0,group:"discrimination"},SAME_OR_DIFF:{difficulty:!0,choseong:!0,group:"discrimination"},HEAR_AND_PICK_SAME:{difficulty:!0,choseong:!0,group:"discrimination"},HEAR_AND_PICK_INCLUDED:{difficulty:!0,choseong:!0,group:"discrimination"},STARTS_WITH_SAME_SOUND:{difficulty:!1,choseong:!0,group:"discrimination"},LISTEN_AND_REMEMBER_ORDER:{difficulty:!1,choseong:!0,group:"attention"},MERGE_2_SYLLABLES:{difficulty:!1,choseong:!0,group:"synthesis"},MERGE_3_SYLLABLES:{difficulty:!1,choseong:!0,group:"synthesis"},MERGE_2_PHONEMES:{difficulty:!1,choseong:!0,group:"synthesis"},MERGE_3_PHONEMES:{difficulty:!1,choseong:!0,group:"synthesis"},DROP_1_FROM_2SYLL:{difficulty:!1,choseong:!0,group:"deletion"},DROP_1_FROM_3SYLL:{difficulty:!1,choseong:!0,group:"deletion"},DROP_PART_FROM_COMPOUND:{difficulty:!1,choseong:!0,group:"deletion"},DROP_FINAL_CONSONANT_FROM_1SYLL:{difficulty:!1,choseong:!0,group:"deletion"},REMOVE_CONSONANT_AND_IDENTIFY_PHONEME:{difficulty:!1,choseong:!0,group:"deletion"},CHANGE_1_SYLL_IN_2SYLL:{difficulty:!0,choseong:!0,group:"substitution"},CHANGE_1_SYLL_IN_3SYLL:{difficulty:!0,choseong:!0,group:"substitution"},CHANGE_1_PHONEME_IN_1SYLL:{difficulty:!1,choseong:!0,group:"substitution"},CHANGE_1_PHONEME_IN_2SYLL:{difficulty:!0,choseong:!0,group:"substitution"}},Dn=z.indexOf("\u3147"),zu={DROP_FINAL_CONSONANT_FROM_1SYLL:{syllables:1,syllable:e=>e.jong>0},REMOVE_CONSONANT_AND_IDENTIFY_PHONEME:{syllables:1,syllable:e=>e.jong===0&&e.cho!==Dn},MERGE_2_SYLLABLES:{syllables:2,syllable:()=>!0},MERGE_3_SYLLABLES:{syllables:3,syllable:()=>!0},MERGE_2_PHONEMES:{syllables:1,syllable:e=>e.jong===0},MERGE_3_PHONEMES:{syllables:1,syllable:e=>e.jong>0}},On={\u3131:"\u3131",\u3132:"\u3131",\u314B:"\u3131",\u3133:"\u3131",\u313A:"\u3131",\u3134:"\u3134",\u3135:"\u3134",\u3136:"\u3134",\u3137:"\u3137",\u3145:"\u3137",\u3146:"\u3137",\u3148:"\u3137",\u314A:"\u3137",\u314C:"\u3137",\u314E:"\u3137",\u3139:"\u3139",\u313C:"\u3139",\u313D:"\u3139",\u313E:"\u3139",\u3140:"\u3139",\u3141:"\u3141",\u313B:"\u3141",\u3142:"\u3142",\u314D:"\u3142",\u313F:"\u3142",\u3144:"\u3142",\u3147:"\u3147"},Nn={\u314F:{nucleus:"\u314F"},\u3151:{glide:"j",nucleus:"\u314F"},\u3153:{nucleus:"\u3153"},\u3155:{glide:"j",nucleus:"\u3153"},\u3157:{nucleus:"\u3157"},\u315B:{glide:"j",nucleus:"\u3157"},\u315C:{nucleus:"\u315C"},\u3160:{glide:"j",nucleus:"\u315C"},\u3161:{nucleus:"\u3161"},\u3163:{nucleus:"\u3163"},\u3150:{nucleus:"\u3154/\u3150"},\u3152:{glide:"j",nucleus:"\u3154/\u3150"},\u3154:{nucleus:"\u3154/\u3150"},\u3156:{glide:"j",nucleus:"\u3154/\u3150"},\u3158:{glide:"w",nucleus:"\u314F"},\u3159:{glide:"w",nucleus:"\u3154/\u3150"},\u315A:{glide:"w",nucleus:"\u3154/\u3150"},\u315D:{glide:"w",nucleus:"\u3153"},\u315E:{glide:"w",nucleus:"\u3154/\u3150"},\u315F:{glide:"w",nucleus:"\u3163"},\u3162:{glide:"\u0270",nucleus:"\u3163"}};function du(e){return On[e]??e}const fu={cho:z,jung:ne,jong:ue},W=e=>Array.isArray(e)?e.length>0:!!e;function gu(e,u){if(e.length!==u.length)return!1;for(let t=0;t<e.length;t++){const n=e[t],o=u[t];if(!(!n||!o)&&(n.cho!==o.cho&&z[n.cho]==="\u3147"!=(z[o.cho]==="\u3147")||n.jong!==o.jong&&n.jong===0!=(o.jong===0)))return!0}return!1}function Tn(e,u,t){const n=t.pronOf(e),o=t.decompOf,l=t.sameStructureOnly&&o?o(n):null,r=[];for(const a of u)a!==e&&(t.okSet&&!t.okSet.has(a)||t.pronOf(a)!==n&&(l&&o&&gu(l,o(t.pronOf(a)))||r.push(a)));return r}function Ju(e,u,t){const n=u?.[e];if(!n)return[];const o=t.kind?n[t.kind]??[]:[...n.cho??[],...n.jung??[],...n.jong??[]];return Tn(e,o,t)}function jn(e,u,t,n,o,l,r){const a=["cho","jung","jong"].filter(d=>W(e[d])),i={};for(const d of a){const m=e[d];i[d]=new Set(Array.isArray(m)?m:[m])}const c=o==="pron",h=new Map;for(const d of u){const m=t(l(d));if(m.some(g=>!g))continue;let f=m;if(!c&&(f=t(d),f.length!==m.length||f.some(g=>!g)))continue;const E=m.length,p=h.get(E);p?p.push({w:d,dPron:m,dPos:f}):h.set(E,[{w:d,dPron:m,dPos:f}])}const C=new Map;for(const[d,m]of h){const f=new Map,E=(p,g)=>{const S=p.dPos[g];return S!=null&&a.every(B=>i[B].has(fu[B][S[B]]))};for(const p of m){let g;if(r==="head")g=E(p,0)?0:-1;else if(r==="tail")g=E(p,d-1)?d-1:-1;else if(r==="mid"){g=-1;for(let B=1;B<d-1;B++)if(E(p,B)){g=B;break}}else g=p.dPos.findIndex(B=>B!=null&&a.every(b=>i[b].has(fu[b][B[b]])));if(g<0)continue;const S=f.get(g);S?S.push(p):f.set(g,[p])}for(const[p,g]of f){const S=new Set(a.map(_=>p+":"+_)),B=_=>{let w="";for(let O=0;O<d;O++){const v=_[O];for(const k of["cho","jung","jong"])w+=(S.has(O+":"+k)?"*":v[k])+"."}return w},b=new Map;for(const _ of m){const w=B(_.dPron),O=b.get(w);O?O.push(_):b.set(w,[_])}for(const _ of g){const w=b.get(B(_.dPron))??[],O=[];for(const v of w){if(v.w===_.w)continue;let k=!0;for(const D of a){const $=_.dPron[p][D],G=v.dPron[p][D];if(G===$){k=!1;break}if(c&&i[D].has(fu[D][G])){k=!1;break}}k&&(n&&gu(_.dPron,v.dPron)||O.push(v.w))}C.set(_.w,O)}}}return C}const In=e=>e==null?[]:Array.isArray(e)?e:[e];function Rn(e){if([...e].length!==1)return"";const u=V(e);if(!u)return"";const t=du(ue[u.jong]),n=t===""?0:ue.indexOf(t);return Ce(u.cho,u.jung,n<0?0:n)}function Qu(e,u){return u.get(e)||Rn(e)||e}function hu(e){return e?W(e.cho)?"cho":W(e.jung)?"jung":W(e.jong)?"jong":null:null}function Be(e,u){const t=(n,o)=>!W(n)||In(n).includes(o);return t(u.cho,z[e.cho])&&t(u.jung,ne[e.jung])&&t(u.jong,ue[e.jong])}function Te(e,u,t){const n=[...e];if(t!=="pron")return n.map(l=>V(l));const o=[...u.get(e)||e];return o.length!==n.length?n.map(l=>V(l)):o.map(l=>V(l))}function je(e,u,t,n,o){const l=u==="cho"?z:u==="jung"?ne:ue,r=e[u],a=[],i=C=>u==="jung"?Ln(Qu(C,o)):Qu(C,o),c=new Map([[i(t),-1]]),h=F(l.map((C,d)=>d).filter(C=>C!==r&&(u!=="cho"||l[C]!=="\u3147")&&(u!=="jong"||C!==0)));for(const C of h){if(a.length>=n)break;const d=u==="cho"?Ce(C,e.jung,e.jong):u==="jung"?Ce(e.cho,C,e.jong):Ce(e.cho,e.jung,C),m=i(d),f=c.get(m);if(f!==void 0){u==="jung"&&f>=0&&o.has(d)&&!o.has(a[f])&&(a[f]=d);continue}c.set(m,a.length),a.push(d)}return a}const Mn={\u3154:"\u3150",\u3156:"\u3152",\u315A:"\u3159",\u315E:"\u3159"};function Ln(e){if([...e].length!==1)return e;const u=V(e);if(!u)return e;const t=Mn[ne[u.jung]];return t?Ce(u.cho,ne.indexOf(t),u.jong):e}function kn(e,u,t,n,o,l=null){const r=[...e];if(r.length!==2)return null;const a=r.map(C=>V(C));if(a.some(C=>!C))return null;const i=Te(e,t,n);if(i.some(C=>!C))return null;const c=hu(u);let h=c&&u?i.map((C,d)=>Be(C,u)?d:-1).filter(C=>C>=0):[0,1];if(l!=null&&(h=h.filter(C=>C!==l)),!h.length)return null;for(const C of F(h)){const d=r[C];if(!o.has(d))continue;const m=je(a[C],c??"cho",d,40,t),f=[];for(const E of m)if(E!==d&&o.has(E)&&!f.includes(E)&&f.push(E),f.length>=2)break;if(!(f.length<2))return{question:e,distractors:[d,...f]}}return null}function Pn(e,u,t,n,o,l=null){const r=[...e];if(r.length!==3)return null;const a=r.map(C=>V(C));if(a.some(C=>!C))return null;const i=Te(e,t,n);if(i.some(C=>!C))return null;const c=hu(u),h=c&&u?i.map((C,d)=>Be(C,u)?d:-1).filter(C=>C>=0):[0,1,2];if(!h.length)return null;for(const C of F(h))for(const d of F([0,1,2].filter(m=>m!==C&&(l==null||m===l)))){const m=[0,1,2].filter(S=>S!==d),f=m.map(S=>r[S]).join("");if(!o.has(f))continue;const E=m.indexOf(C),p=je(a[C],c??"cho",r[C],40,t),g=[];for(const S of p){const B=m.map(_=>r[_]);B[E]=S;const b=B.join("");if(b!==f&&o.has(b)&&!g.includes(b)&&g.push(b),g.length>=2)break}if(!(g.length<2))return{question:e,distractors:[f,...g]}}return null}function vn(e,u,t,n,o,l=null){const r=[...e],a=r.length;if(a<2)return null;const i=[];for(let h=1;h<=a-1;h++)i.push({remain:r.slice(0,h).join(""),dropped:r.slice(h).join(""),droppedEnd:1}),i.push({remain:r.slice(a-h).join(""),dropped:r.slice(0,a-h).join(""),droppedEnd:0});const c=hu(u);for(const{remain:h,dropped:C,droppedEnd:d}of F(i)){if(l!=null&&d!==l||h===e||!o.has(h)||!o.has(C))continue;const m=[...h],f=m.map(g=>V(g));if(f.some(g=>!g))continue;const E=Te(h,t,n);if(E.some(g=>!g))continue;const p=c&&u?E.map((g,S)=>Be(g,u)?S:-1).filter(g=>g>=0):m.map((g,S)=>S);if(p.length)for(const g of F(p)){const S=je(f[g],c??"cho",m[g],40,t),B=[];for(const b of S){const _=[...m];_[g]=b;const w=_.join("");if(w!==h&&o.has(w)&&!B.includes(w)&&B.push(w),B.length>=2)break}if(B.length>=2)return{question:e,distractors:[h,...B]}}}return null}function xn(e,u,t,n,o,l=null){if([...e].length!==1)return null;const r=V(t.get(e)||e);if(!r||r.jong===0)return null;const a=Ce(r.cho,r.jung,0),i=je({cho:r.cho,jung:r.jung,jong:0},"cho",a,2,t);return i.length<2?null:{question:e,distractors:[a,...i]}}const mu=z.indexOf("\u3147");function Fn(e,u,t,n,o,l=null){if([...e].length!==1)return null;const r=V(t.get(e)||e);if(!r||r.jong!==0||r.cho===mu)return null;const a=Ce(mu,r.jung,0),i=je({cho:mu,jung:r.jung,jong:0},"jung",a,2,t);return i.length<2?null:{question:e,distractors:[a,...i]}}function Vn(e){const u=new Map;for(const t of e){const n=[...t],o=n.length;if(!(o<2||o>3))for(let l=0;l<o;l++){let r=o+"|"+l+"|";for(let i=0;i<o;i++)r+=i===l?"*":n[i];const a=u.get(r);a?a.push(t):u.set(r,[t])}}return u}function $n(e,u,t,n,o,l=null,r=null,a=2){const i=[...e],c=i.length;if(c<2||c>3)return null;const h=i.map(S=>V(S));if(h.some(S=>!S))return null;const C=Te(e,t,n);if(C.some(S=>!S))return null;const d=S=>t.get(S)??S,m=d(e),f=!!u&&(W(u.cho)||W(u.jung)||W(u.jong)),E=!!r&&(W(r.cho)||W(r.jung)||W(r.jong)),p=S=>{let B=c+"|"+S+"|";for(let b=0;b<c;b++)B+=b===S?"*":i[b];return B};let g;if(l!=null){if(l>=c||f&&!Be(C[l],u))return null;g=[l]}else f?g=C.map((S,B)=>Be(S,u)?B:-1).filter(S=>S>=0):g=Array.from({length:c},(S,B)=>B);for(const S of F(g)){const B=o.get(p(S))??[],b=[],_=[];for(const D of B){if(D===e)continue;const $=[...D].map(L=>V(L)),G=h[S],Y=$[S];if(!G||!Y)continue;let R=0;if(G.cho!==Y.cho&&R++,G.jung!==Y.jung&&R++,G.jong!==Y.jong&&R++,!(R<a||d(D)===m))if(E){const L=Te(D,t,n)[S];L&&Be(L,r)?b.push(D):_.push(D)}else b.push(D)}if(!b.length)continue;const w=F(b)[0],O=[],v=new Set([m,d(w)]),k=E?_:b.filter(D=>D!==w);for(const D of F(k)){const $=d(D);if(!v.has($)&&(v.add($),O.push(D),O.length>=2))break}if(!E&&O.length<2)for(const D of F(B)){if(D===e||D===w)continue;const $=d(D);if(!v.has($)&&(v.add($),O.push(D),O.length>=2))break}if(!(O.length<2))return{question:e,distractors:[w,...O]}}return null}let We=null,Zu=null,Xu=null;function Hn(){const e=Ke();if(e&&e.entries.length>0){const u=De();if(We&&Zu===e&&Xu===u)return We;const t=new Set,n=[];for(const o of e.entries)!o.word||t.has(o.word)||(t.add(o.word),n.push({w:o.word,s:o.syllables,p:u?.[o.word]?[...u[o.word].cho??[],...u[o.word].jung??[],...u[o.word].jong??[]]:[],pron:o.pronunciation||o.word,grade:o.grade}));return We=n,Zu=e,Xu=u,We}return[]}const oe=new Proxy([],{get(e,u){const t=Hn(),n=t[u];return typeof n=="function"?n.bind(t):n}});function pu(e){return e.length?e[Math.floor(Math.random()*e.length)]:void 0}function te(e,u){if(u>=e.length)return F(e);if(u===0)return[];const t=e.slice();for(let n=0;n<u;n++){const o=n+Math.floor(Math.random()*(t.length-n)),l=t[n];t[n]=t[o],t[o]=l}return t.slice(0,u)}let Su=null,et=null;function de(){const e=Ke();if(Su&&et===e)return Su;const u=new Map;for(const t of oe)t.w&&u.set(t.w,t.pron);return Su=u,et=e,u}function Z(e){return de().get(e)||e}function qe(e,u,t=new Set){const n=[];for(const o of F(e)){if(n.length>=u)break;const l=Z(o);t.has(l)||(t.add(l),n.push(o))}return n}let Gn=0;function J(e){return`${e}-rt-${++Gn}`}function Ie(e){const u=Gu();if(!u||u.total===0){const n=new Set;for(const o of e)n.add(o);return n}const t=new Set;for(const n of e)dn(n)===!0&&t.add(n);return t}const ze=new Map;let ut=null,tt=null;function Re(e){return e==null?"":Array.isArray(e)?e.slice().sort().join(","):e}function nt(e){const u=Re(e.choseong),t=e.composition,n=t?.syllable==null?"":Array.isArray(t.syllable)?t.syllable.slice().sort().join(","):String(t.syllable),o=t?`${Re(t.cho)}/${Re(t.jung)}/${Re(t.jong)}/${t.jongNone?"N":""}/${n}`:"",l=Re(e.grade);return`${e.difficulty??""}|${u}|${o}|${e.excludeNoImage?"1":"0"}|${e.count??""}|x${e.contrastCount??1}|${e.fullCount?"F":""}|s${e.sameStructureOnly===!1?"0":"1"}|v${e.phonemeView==="pron"?"p":"c"}|g${l}|t${e.targetSyllable??""}|c${e.choicesPerItem??""}`}async function X(e){const u=Ke(),t=De();(u!==ut||t!==tt)&&(ze.clear(),ut=u,tt=t);const n=nt(e);return ze.has(n)||ze.set(n,Yn(e)),ze.get(n)}function ot(e){if(!e)return null;const u=r=>r==null?null:Array.isArray(r)?r.length?r:null:[r],t=u(e.cho),n=u(e.jung),o=!!e.jongNone,l=o?null:u(e.jong);return t||n||l||o?o&&!t&&!n&&!l?r=>tn(r):r=>on(r,{cho:t,jung:n,jong:l,jongNone:o}):null}function lt(e){const u=e.grade&&e.grade.length>0?new Set(e.grade):null,t=e.composition??null,n=t?.syllable!=null?new Set(Array.isArray(t.syllable)?t.syllable:[t.syllable]):null,o=t?[ot(t),n?r=>n.has(Ae(r)):null].filter(r=>r!=null):[];if(!u&&o.length===0)return null;const l=e.phonemeView==="pron";return r=>{if(u&&(!r.grade||!u.has(r.grade)))return!1;if(o.length===0)return!0;const a=l?Z(r.w):r.w;return o.every(i=>i(a))}}async function Yn(e){const{difficulty:u=null,choseong:t=null,composition:n=null,targetSyllable:o=null,excludeNoImage:l=!1}=e,r=e.grade&&e.grade.length>0?new Set(e.grade):null,a=e.sameStructureOnly??!0,i=e.phonemeView==="pron"?"pron":"char",c=Math.max(1,e.contrastCount??1),h=u==="cho"||u==="jung"||u==="jong",C=h&&c>=2,d=u==="count",m=t?new Set(Array.isArray(t)?t:[t]):null,f=n?.syllable!=null?new Set(Array.isArray(n.syllable)?n.syllable:[n.syllable]):null,E=n?[ot(n),f?A=>f.has(Ae(A)):null].filter(A=>A!=null):[],p=u==="random"||u===null,g=p||d,S=p||C||d;let B=oe.filter(A=>!A.w||r&&(!A.grade||!r.has(A.grade))?!1:S?!0:Array.isArray(A.p)&&A.p.length>0);m&&(B=B.filter(A=>{for(const N of m)if(un(A.w,N))return!0;return!1})),E.length>0&&(B=B.filter(A=>{const N=i==="pron"?Z(A.w):A.w;return E.every(I=>I(N))})),o&&(B=B.filter(A=>A.w[0]===o));let b;if(l){const A=new Set;for(const N of B)if(A.add(N.w),Array.isArray(N.p))for(const I of N.p)A.add(I);if(g)for(const N of oe)N.w&&A.add(N.w);b=Ie(A)}else{const A=new Set;for(const N of B)if(A.add(N.w),Array.isArray(N.p))for(const I of N.p)A.add(I);if(g)for(const N of oe)N.w&&A.add(N.w);b=A}let _=null;if(C){const A=new Set;for(const N of oe)N.w&&A.add(N.w);_=l?Ie(A):A}const w=B.filter(A=>b.has(A.w)),O=600,v=Array.from(b),k=v.length>O?te(v,O):v,D=d&&n!=null&&(W(n.cho)||W(n.jung)||W(n.jong)),$=2500,G=new Map;if(d&&!D&&c>=2){for(const A of v){const N=Ae(A),I=G.get(N);I?I.push(A):G.set(N,[A])}for(const[A,N]of G)N.length>$&&G.set(A,te(N,$))}const Y=Xt(),R=D?jn(n,v,Y,a,i,Z):null,L=500,H=1500,U=e.fullCount?w:u==="random"?w.length>L?te(w,L):w:w.length>H?te(w,H):w,ee=De(),me=[];for(const A of U){let N;const I=Z(A.w);if(C)N=rn(A.w,u,c,_,24).filter(x=>Z(x)!==I);else if(d)D?N=(R.get(A.w)??[]).filter(x=>Z(x)!==I):c<=1?N=Ju(A.w,ee,{okSet:b,pronOf:Z,decompOf:Y,sameStructureOnly:!1}):N=(G.get(Ae(A.w))??[]).filter(x=>{if(x===A.w||Z(x)===I)return!1;const Q=an(A.w,x);return c>=5?Q>=5:Q===c});else if(p)N=k.filter(x=>x!==A.w&&x.length===A.w.length&&Z(x)!==I);else{const x=u;N=Ju(A.w,ee,{kind:x,okSet:b,pronOf:Z,decompOf:Y,sameStructureOnly:!1}),N.length===0&&(N=(k.length>30?te(k,30):k).filter(Q=>Q!==A.w&&en(A.w,Q)===u&&Z(Q)!==I))}if(a&&N.length>0&&(h||d&&!D)){const x=Y(Z(A.w));N=N.filter(Q=>!gu(x,Y(Z(Q))))}N.length!==0&&me.push({word:A,usable:N})}return me}async function rt(e,u){const{choicesPerItem:t=3,count:n=10}=u,o=t-1,l=(await X(u)).filter(a=>a.usable.length>=o),r=[];for(const a of F(l)){if(r.length>=n)break;const i=qe(a.usable,o);if(i.length<o)continue;const c=F([a.word.w,...i]);r.push({id:J(e+"-item"),index:r.length+1,word:a.word.w,syllables:a.word.s,choices:c,answerIndex:c.indexOf(a.word.w)})}return r}async function Un(e){const{choicesPerItem:u=3,count:t=10}=e,n=u-1,o=await X({...e,difficulty:null});if(o.length<u)return[];const l=[],r=F([...o]);for(const a of r){if(l.length>=t)break;const i=a.word.w,c=[...a.word.pron||i],h=pu(c);if(!h)continue;const C=o.filter(f=>f.word.w!==i&&f.word.s===a.word.s&&!(f.word.pron||f.word.w).includes(h)&&f.word.pron!==a.word.pron);if(C.length<n)continue;const d=qe(C.map(f=>f.word.w),n);if(d.length<n)continue;const m=F([i,...d]);l.push({id:J("HPI-item"),index:l.length+1,targetSyllable:h,word:i,choices:m,answerIndex:m.indexOf(i)})}return l}async function Kn(e){const{count:u=10}=e,t=(await X(e)).filter(l=>l.usable.length>=1);if(!t.length)return[];const n=t.length>=u?te(t,u):F(Array.from({length:u},(l,r)=>t[r%t.length])),o=F(Array.from({length:u},(l,r)=>r<Math.ceil(u/2)));return n.map((l,r)=>{const a=o[r];let i;if(a)i=[l.word.w,l.word.w];else{const c=pu(l.usable);i=Math.random()<.5?[l.word.w,c]:[c,l.word.w]}return{id:J("SOD-item"),index:r+1,word:l.word.w,pair:i,same:a}})}async function Wn(e){const{choicesPerItem:u=3,count:t=10}=e,n=u-1,o=await X({...e,difficulty:null});if(o.length<u+1)return[];const l=o.map(d=>d.word.w),r=new Map(o.map(d=>[d.word.w,d.word.pron])),a=d=>(r.get(d)||d)[0]??"",i={};for(const d of o){const m=a(d.word.w);m&&(i[m]||(i[m]=[]),i[m].push(d.word.w))}const c=Object.entries(i).filter(([,d])=>d.length>=2).map(([d])=>d);if(c.length===0)return[];const h=[],C=F([...c]);for(let d=0;h.length<t&&d<t*4;d++){const m=C[d%C.length],f=i[m];if(f.length<2)continue;const E=F([...f]),p=E[0],g=E[1];if(!p||!g||p===g||(r.get(p)||p)===(r.get(g)||g))continue;const S=r.get(g)||g,B=l.filter(w=>a(w)!==m&&w!==p&&w!==g&&w.length===g.length&&(r.get(w)||w)!==S);if(B.length<n)continue;const b=qe(B,n);if(b.length<n)continue;const _=F([g,...b]);h.push({id:J("SWS-item"),index:h.length+1,sourceWord:p,targetSyllable:m,word:g,choices:_,answerIndex:_.indexOf(g)})}return h}function at(e,u,t){const n=de(),o=a=>n.get(a)||a,l=(a,i)=>{const c=[...a],h=[...i];if(c.length!==h.length)return-1;let C=-1;for(let d=0;d<c.length;d++)if(c[d]!==h[d]){if(C>=0)return-1;C=d}return C},r=e.map(a=>({e:a,swaps:a.usable.filter(i=>!!i&&l(a.word.w,i)>=0&&o(i)!==o(a.word.w))})).filter(a=>a.swaps.length>0);return te(r,u).map(({e:a,swaps:i},c)=>{const h=pu(i)??"",C=[...a.word.w],d=[...h],m=l(a.word.w,h),f=qe(a.usable.filter(E=>E&&E!==h),2,new Set([o(h),o(a.word.w)]));return{id:J(t),index:c+1,word:a.word.w,original:a.word.w,changed:h,changedFrom:m>=0?C[m]:"",changedTo:m>=0?d[m]:"",distractors:f}})}async function st(e,u,t){const{count:n=10}=u,o=de(),l=oe.filter(f=>f.w&&f.s===e),r=u.excludeNoImage?Ie(l.map(f=>f.w)):null,a=r?l.filter(f=>r.has(f.w)):l,i=new Set(a.map(f=>f.w)),c=Vn(i),h=u.phonemeView??"char",C=u.composition??null,d=lt({grade:u.grade}),m=[];for(const f of F(a)){if(m.length>=n)break;if(d&&!d(f))continue;const E=$n(f.w,C,o,h,c,null,null);if(!E)continue;const p=E.distractors[0],g=[...f.w],S=[...p],B=g.findIndex((b,_)=>b!==S[_]);m.push({id:J(t),index:m.length+1,word:f.w,original:f.w,changed:p,changedFrom:B>=0?g[B]:"",changedTo:B>=0?S[B]:"",distractors:E.distractors.slice(1)})}return m}async function qn(e){return st(2,e,"CS2-item")}async function zn(e){return st(3,e,"CS3-item")}async function Jn(e){const u=(await X({...e,difficulty:"count",contrastCount:1})).filter(t=>t.word.s===1&&t.usable.length>=1);return at(u,e.count??10,"CP1-item")}async function Qn(e){const u=e.difficulty&&e.difficulty!=="random"?e.difficulty:"count",t=(await X({...e,difficulty:u,contrastCount:1})).filter(n=>n.word.s===2&&n.usable.length>=1);return at(t,e.count??10,"CP2-item")}async function Zn(e){const{count:u=10}=e,t=(await X({...e})).filter(n=>n.word.s===2);return te(t,u).map((n,o)=>({id:J("M2S-item"),index:o+1,word:n.word.w,answer:n.word.w,parts:[...n.word.w]}))}async function Xn(e){const{count:u=10}=e,t=(await X({...e})).filter(n=>n.word.s===3);return te(t,u).map((n,o)=>({id:J("M3S-item"),index:o+1,word:n.word.w,answer:n.word.w,parts:[...n.word.w]}))}async function eo(e){const{count:u=10}=e,t=(await X({...e})).filter(a=>a.word.s===2),n=de(),o=new Set(oe.map(a=>a.w)),l=e.phonemeView??"char",r=[];for(const a of F(t)){if(r.length>=u)break;const i=kn(a.word.w,e.composition??null,n,l,o);if(!i)continue;const[c,...h]=i.distractors,C=[...a.word.w],d=C[0]===c?C[1]:C[0];r.push({id:J("D2-item"),index:r.length+1,original:a.word.w,word:a.word.w,dropped:d,missingResult:c,distractors:h})}return r}async function uo(e){const{count:u=10}=e,t=(await X({...e})).filter(a=>a.word.s===3),n=de(),o=new Set(oe.map(a=>a.w)),l=e.phonemeView??"char",r=[];for(const a of F(t)){if(r.length>=u)break;const i=Pn(a.word.w,e.composition??null,n,l,o);if(!i)continue;const[c,...h]=i.distractors,C=[...a.word.w];let d="";for(let m=0;m<C.length;m++)if(C.filter((f,E)=>E!==m).join("")===c){d=C[m];break}r.push({id:J("D3-item"),index:r.length+1,original:a.word.w,word:a.word.w,dropped:d,missingResult:c,distractors:h})}return r}async function to(e){const{count:u=10}=e,t=(await X({...e})).filter(a=>a.word.s>=2),n=de(),o=new Set(oe.map(a=>a.w)),l=e.phonemeView??"char",r=[];for(const a of F(t)){if(r.length>=u)break;const i=vn(a.word.w,e.composition??null,n,l,o);if(!i)continue;const[c,...h]=i.distractors,C=a.word.w,d=C.startsWith(c)?C.slice(c.length):C.endsWith(c)?C.slice(0,C.length-c.length):"";r.push({id:J("DPC-item"),index:r.length+1,original:C,word:C,dropped:d,missingResult:c,distractors:h})}return r}async function no(e){const{count:u=10}=e,t=(await X({...e})).map(n=>n.word.w);return t.length<3?[]:Array.from({length:u},(n,o)=>{const l=te(t,3);return{id:J("LRO-item"),index:o+1,sequence:l,choices:F(l)}})}function Je(e,u,t){const n=oe.filter(a=>a.w&&a.s===e),o=u.excludeNoImage?Ie(n.map(a=>a.w)):null,l=lt(u),r=[];for(const a of n)if(!(o&&!o.has(a.w))&&!(l&&!l(a))){if(t){const i=V(a.w);if(!i||!t(i))continue}r.push(a)}return r}function oo(e){const u=Je(1,e,t=>t.jong===0);return te(u,e.count??10).map((t,n)=>{const o=V(t.w);return{id:J("M2P-item"),index:n+1,parts:[z[o.cho],ne[o.jung]],answer:t.w,word:t.w}})}function lo(e){const u=Je(1,e,t=>t.jong>0&&!be[t.jong]);return te(u,e.count??10).map((t,n)=>{const o=V(t.w);return{id:J("M3P-item"),index:n+1,parts:[z[o.cho],ne[o.jung],ue[o.jong]],answer:t.w,word:t.w}})}function ro(e){const u=zu.DROP_FINAL_CONSONANT_FROM_1SYLL,t=Je(u.syllables,e,u.syllable),n=de(),o=[];for(const l of F(t)){if(o.length>=(e.count??10))break;const r=xn(l.w,null,n);if(!r)continue;const[a,...i]=r.distractors;o.push({id:J("DFC-item"),index:o.length+1,original:l.w,word:l.w,result:a,distractors:i})}return o}function ao(e){const u=zu.REMOVE_CONSONANT_AND_IDENTIFY_PHONEME,t=Je(u.syllables,e,u.syllable),n=de(),o=[];for(const l of F(t)){if(o.length>=(e.count??10))break;const r=Fn(l.w,null,n);if(!r)continue;const a=V(n.get(l.w)||l.w);if(!a)continue;const[i,...c]=r.distractors;o.push({id:J("RCP-item"),index:o.length+1,base:l.w,word:l.w,missingConsonant:z[a.cho],remaining:i,distractors:c})}return o}const Qe=new Map;let it=null,ct=null;async function Ct(e,u={}){const t=Ke(),n=De();(t!==it||n!==ct)&&(Qe.clear(),it=t,ct=n);const o=`${e}:${nt(u)}`;if(Qe.has(o))return Qe.get(o);const l=await io(e,u);return Qe.set(o,l),l}const so={SAME_SOUND_PICK:e=>rt("SSP",e),HEAR_AND_PICK_SAME:e=>rt("HPS",e),HEAR_AND_PICK_INCLUDED:e=>Un(e),SAME_OR_DIFF:e=>Kn(e),STARTS_WITH_SAME_SOUND:e=>Wn(e),LISTEN_AND_REMEMBER_ORDER:e=>no(e),MERGE_2_SYLLABLES:e=>Zn(e),MERGE_3_SYLLABLES:e=>Xn(e),MERGE_2_PHONEMES:e=>oo(e),MERGE_3_PHONEMES:e=>lo(e),DROP_1_FROM_2SYLL:e=>eo(e),DROP_1_FROM_3SYLL:e=>uo(e),DROP_PART_FROM_COMPOUND:e=>to(e),DROP_FINAL_CONSONANT_FROM_1SYLL:e=>ro(e),REMOVE_CONSONANT_AND_IDENTIFY_PHONEME:e=>ao(e),CHANGE_1_SYLL_IN_2SYLL:e=>qn(e),CHANGE_1_SYLL_IN_3SYLL:e=>zn(e),CHANGE_1_PHONEME_IN_1SYLL:e=>Jn(e),CHANGE_1_PHONEME_IN_2SYLL:e=>Qn(e)};async function io(e,u={}){const t=so[e];return t?await t(u):[]}async function co(e){const u=["random","count"],t=Object.keys(Cu);let n=0;for(const o of u)for(const l of t){const r=Cu[l];Ct(l,{difficulty:r.difficulty?o:null,contrastCount:1,composition:null,count:5,excludeNoImage:e,sameStructureOnly:!0,phonemeView:"char",grade:null}).catch(()=>{}),++n%6===0&&await new Promise(a=>setTimeout(a,0))}}async function Co(e){return(await X({...e,fullCount:!0})).length}async function fo(e={}){const u=[];for(const a of oe)a.w&&u.push(a.w);const t=e.excludeNoImage?Ie(u):u,n=new Set,o=new Set,l=new Set,r=new Set;for(const a of t){r.add(Ae(a));for(const i of a){const c=V(i);if(c&&(z[c.cho]!=="\u3147"&&n.add(z[c.cho]),o.add(ne[c.jung]),c.jong>0)){l.add(ue[c.jong]);const h=be[c.jong];h&&h.forEach(C=>l.add(C))}}}return{cho:n,jung:o,jong:l,syllable:r}}const he="\uC804\uCCB4";function dt(){const{t:e}=ce.useTranslation();return s.useMemo(()=>({difficulty:e("wordSearch.filter.difficulty","\uB4F1\uAE09"),syllables:e("wordSearch.filter.syllables","\uC74C\uC808 \uC218"),syllable5plus:e("wordSearch.filter.syllable5plus","5\uC74C\uC808 \uC774\uC0C1"),partOfSpeech:e("wordSearch.filter.partOfSpeech","\uD488\uC0AC"),wordType:e("wordSearch.filter.wordType","\uC720\uD615"),posMap:{[e("wordSearch.filter.pos.noun","\uCCB4\uC5B8(\uBA85\uC0AC, \uC218\uC0AC)")]:["\uBA85","\uC218"],[e("wordSearch.filter.pos.verb","\uC6A9\uC5B8(\uB3D9\uC0AC, \uD615\uC6A9\uC0AC)")]:["\uB3D9","\uD615"],[e("wordSearch.filter.pos.modifier","\uC218\uC2DD\uC5B8(\uBD80\uC0AC, \uAD00\uD615\uC0AC)")]:["\uBD80","\uAD00"]},typeMap:{[e("wordSearch.filter.type.native","\uACE0\uC720\uC5B4")]:"\uACE0\uC720",[e("wordSearch.filter.type.sino","\uD55C\uC790\uC5B4")]:"\uD55C\uC790",[e("wordSearch.filter.type.foreign","\uC678\uB798\uC5B4")]:"\uC678\uB798",[e("wordSearch.filter.type.mixed","\uD63C\uC885\uC5B4")]:"\uD63C\uC885"}}),[e])}function ft(e,u,t){return{label:u.difficulty,items:[1,2,3,4].map(n=>e("wordSearch.filter.grade",{n})),multiple:!0,allOption:!0,allLabel:t?.allLabel,labelAction:t?.labelAction,labelInfo:t?.labelInfo}}function gt(e){return{label:e.partOfSpeech,items:Object.keys(e.posMap),multiple:!0,allOption:!0}}function ht(e){return{label:e.wordType,items:Object.keys(e.typeMap),multiple:!0,allOption:!0}}function go(e,u){return{label:u.syllables,items:[e("wordSearch.filter.syllable",{n:1}),e("wordSearch.filter.syllable",{n:2}),e("wordSearch.filter.syllable",{n:3}),e("wordSearch.filter.syllable",{n:4}),u.syllable5plus],multiple:!0,allOption:!0}}function ho(e,u){const t=[e("wordPairs.filter.onlyHasImage","\uC774\uBBF8\uC9C0 \uC788\uB294 \uB2E8\uC5B4\uB9CC")];return u?.includeStructure&&t.push(e("wordPairs.filter.onlySameStructure","\uC74C\uC18C \uAD6C\uC870 \uAC19\uC740 \uB2E8\uC5B4\uB9CC")),{label:e("wordPairs.filter.selectLabel","\uC120\uD0DD"),items:t,multiple:!0,labelAction:u?.labelAction,labelInfo:u?.labelInfo}}function mo(e,u){const{label:t,headValue:n,midValue:o,tailValue:l,includeMid:r=!0,headDisabled:a,midDisabled:i,tailDisabled:c,allOptionDisabled:h,groupLabel:C,labelAction:d}=u;return{label:t,...C?{groupLabel:C}:{},...d?{labelAction:d}:{},allOption:!0,allLabel:e("wordSearch.filter.positionAny",{defaultValue:"\uBB34\uAD00"}),...h?{allOptionDisabled:h}:{},items:[{value:n,displayLabel:e("wordSearch.filter.positionHead",{defaultValue:"\uC5B4\uB450"}),disabled:a},...r?[{value:o,displayLabel:e("wordSearch.filter.positionMid",{defaultValue:"\uC5B4\uC911"}),disabled:i}]:[],{value:l,displayLabel:e("wordSearch.filter.positionTail",{defaultValue:"\uC5B4\uB9D0"}),disabled:c}]}}function po(e,u,t){if(u===he){const{[t]:l,...r}=e;return r}const n=e[t]??[],o=n.includes(u)?n.filter(l=>l!==u):[...n,u];if(o.length===0){const{[t]:l,...r}=e;return r}return{...e,[t]:o}}Object.fromEntries(Object.entries(Nn).map(([e,{nucleus:u}])=>[e,u]));const So={\uACE0\uC720\uC5B4:"\uACE0\uC720",\uD55C\uC790\uC5B4:"\uD55C\uC790",\uC678\uB798\uC5B4:"\uC678\uB798",\uD63C\uC885\uC5B4:"\uD63C\uC885"},yo={"\uCCB4\uC5B8(\uBA85\uC0AC,\uC218\uC0AC)":["\uBA85","\uC218"],"\uC6A9\uC5B8(\uB3D9\uC0AC,\uD615\uC6A9\uC0AC)":["\uB3D9","\uD615"],"\uC218\uC2DD\uC5B8(\uBD80\uC0AC,\uAD00\uD615\uC0AC)":["\uBD80","\uAD00"]},Eo={difficulty:"\uB09C\uC774\uB3C4 \uB4F1\uAE09",syllables:"\uC74C\uC808 \uC218",syllable5plus:"5\uC74C\uC808 \uC774\uC0C1",partOfSpeech:"\uD488\uC0AC",wordType:"\uC720\uD615",posMap:yo,typeMap:So};function Bo(e,u,t=Eo){const n=u[t.difficulty];if(n?.length&&!n.some(a=>e.grade===a.replace(/\D/g,"")))return!1;const o=u[t.syllables];if(o?.length){const a=e.syllables??0;if(!o.some(i=>i===t.syllable5plus?a>=5:a===parseInt(i)))return!1}const l=u[t.partOfSpeech];if(l?.length&&!l.flatMap(a=>t.posMap[a]??[a]).some(a=>(e.pos??"").includes(a)))return!1;const r=u[t.wordType];return!(r?.length&&!r.some(a=>e.wordType===t.typeMap[a]))}const wo={labial:e=>e("common.phonetics.place.labial",{defaultValue:"\uC591\uC21C\uC74C"}),alveolar:e=>e("common.phonetics.place.alveolar",{defaultValue:"\uCE58\uC870\uC74C"}),palatal:e=>e("common.phonetics.place.palatal",{defaultValue:"\uACBD\uAD6C\uAC1C\uC74C"}),velar:e=>e("common.phonetics.place.velar",{defaultValue:"\uC5F0\uAD6C\uAC1C\uC74C"}),glottal:e=>e("common.phonetics.place.glottal",{defaultValue:"\uC131\uBB38\uC74C"})},bo={frontHigh:e=>e("common.phonetics.vowel.frontHigh",{defaultValue:"\uC804\uC124 \uACE0\uBAA8\uC74C"}),backHighUnrounded:e=>e("common.phonetics.vowel.backHighUnrounded",{defaultValue:"\uD6C4\uC124 \uACE0\uBAA8\uC74C \uD3C9\uC21C"}),backHighRounded:e=>e("common.phonetics.vowel.backHighRounded",{defaultValue:"\uD6C4\uC124 \uACE0\uBAA8\uC74C \uC6D0\uC21C"}),frontMid:e=>e("common.phonetics.vowel.frontMid",{defaultValue:"\uC804\uC124 \uC911\uBAA8\uC74C"}),backMidUnrounded:e=>e("common.phonetics.vowel.backMidUnrounded",{defaultValue:"\uD6C4\uC124 \uC911\uBAA8\uC74C \uD3C9\uC21C"}),backMidRounded:e=>e("common.phonetics.vowel.backMidRounded",{defaultValue:"\uD6C4\uC124 \uC911\uBAA8\uC74C \uC6D0\uC21C"}),low:e=>e("common.phonetics.vowel.low",{defaultValue:"\uC800\uBAA8\uC74C"})},Ao={j:e=>e("common.phonetics.glide.j",{defaultValue:"j\uD65C\uC74C"}),w:e=>e("common.phonetics.glide.w",{defaultValue:"w\uD65C\uC74C"}),velar:e=>e("common.phonetics.glide.velar",{defaultValue:"\u0270\uD65C\uC74C"})};function mt(e,u){if("place"in u)return wo[u.place](e);const t=bo[u.vowel](e);return u.glide?`${t} \xB7 ${Ao[u.glide](e)}`:t}const _o=(e,{defaultValue:u})=>u,pt=(e,u)=>({jamos:e,phonetic:u,tooltip:mt(_o,u)}),se=(e,u)=>u.map(t=>pt([t],{place:e})),q=(e,u,t)=>pt([...e],t?{vowel:u,glide:t}:{vowel:u}),yu={cho:[se("labial",["\u3142","\u3143","\u314D","\u3141"]),se("alveolar",["\u3137","\u3138","\u314C","\u3134","\u3139"]),se("alveolar",["\u3145","\u3146"]),se("palatal",["\u3148","\u3149","\u314A"]),se("velar",["\u3131","\u3132","\u314B"]),se("glottal",["\u314E"])],jung:[[q("\u3163","frontHigh"),q("\u315F","frontHigh","w"),q("\u3162","frontHigh","velar")],[q("\u3161","backHighUnrounded")],[q("\u315C","backHighRounded"),q("\u3160","backHighRounded","j")],[q("\u3154\u3150","frontMid"),q("\u3156\u3152","frontMid","j"),q("\u3159\u315A\u315E","frontMid","w")],[q("\u3153","backMidUnrounded"),q("\u3155","backMidUnrounded","j"),q("\u315D","backMidUnrounded","w")],[q("\u3157","backMidRounded"),q("\u315B","backMidRounded","j")],[q("\u314F","low"),q("\u3151","low","j"),q("\u3158","low","w")]],jong:[se("labial",["\u3142","\u3141"]),se("alveolar",["\u3137","\u3134","\u3139"]),se("velar",["\u3131","\u3147"])]},Do=[...z],Oo=[...ne],No=ue.filter(e=>e!==""),ie=e=>e===le?[]:Array.from(e),le="__NO_CODA__",St=[1,2,3,4],re=5,To=12,yt="SYL_",Eu=e=>`${yt}${e}`,jo=e=>Number(e.slice(yt.length));function Bu(e){return e>=re?Array.from({length:To-re+1},(u,t)=>re+t):[e]}const Et={cho:Do,jung:Oo,jong:No},wu=e=>e.map(u=>u.map(({jamos:t,phonetic:n,tooltip:o})=>({v:t.join(""),phonetic:n,tooltip:o}))),bu={cho:wu(yu.cho),jung:wu(yu.jung),jong:wu(yu.jong)},Bt={};bu.jung.flat().forEach(({v:e})=>{for(const u of ie(e))Bt[u]=e});const Io=new Set(bu.cho.flat().map(e=>e.v));function wt(e,u){return e==="cho"?Io.has(u)?u:null:e==="jung"?Bt[u]??u:du(u)}function bt(e,u,t){if(e==="jung"){const n=ie(u);return t&&n.includes(t)?t:n[0]??u}return e==="jong"&&t&&du(t)===u?t:u}function At(e,u,t,n){const o=(l,r)=>r?l==="jong"&&r===le?le:u==="pron"?wt(l,r):bt(l,r,l==="jung"?t:l==="jong"?n:null):null;return{...e,cho:o("cho",e.cho),jung:o("jung",e.jung),jong:o("jong",e.jong)}}const Au={cho:null,jung:null,jong:null,syllable:null},Ro="wt_filter",_t=e=>`wt_filter_${e}`;function Dt(e){try{const u=localStorage.getItem(_t(e))??localStorage.getItem(Ro);if(u)return JSON.parse(u)}catch{}return null}function Ot(e){const u=e?.phonemeView;return u==="pron"?"pron":u==="direct"?"direct":"char"}function Mo(e){const u=e;return u?.composition?{cho:u.composition.cho??null,jung:u.composition.jung??null,jong:u.composition.jong??null,syllable:u.composition.syllable??null}:u?.choseong?{...Au,cho:u.choseong}:Au}function Lo(e,u,t){const{t:n,i18n:o}=ce.useTranslation(),[l]=s.useState(()=>t?.resetOnMount?null:Dt(e)),[r,a]=s.useState(Ot(l)),[i,c]=s.useState(()=>Mo(l)),h=s.useCallback(()=>u.requireSyllable?{cho:"\u3131",jung:"\u314F",jong:le,syllable:u.fixedSyllable??null}:{cho:null,jung:null,jong:u.fixedNoCoda?le:null,syllable:u.fixedSyllable??null},[u.requireSyllable,u.fixedSyllable,u.fixedNoCoda]);s.useEffect(()=>{!u.requireSyllable&&u.fixedSyllable==null&&!u.fixedNoCoda||c(y=>y.cho||y.jung||y.syllable!=null||y.jong?y:h())},[]);const C=s.useMemo(()=>W(i.cho)||W(i.jung)||W(i.jong)?"count":"random",[i.cho,i.jung,i.jong]),d=s.useRef(r==="char"?i.jung:null),m=s.useRef(r==="char"?i.jong:null);s.useEffect(()=>{r==="char"&&(d.current=i.jung,m.current=i.jong)},[r,i.jung,i.jong]);const[f,E]=s.useState(t?.resetOnMount?!!t?.defaultImageOnly:l?.excludeNoImage??!0),[p,g]=s.useState(t?.resetOnMount?!1:l?.sameStructureOnly??!0),[S,B]=s.useState(Array.isArray(l?.gradeFilter)?l.gradeFilter:[]),[b,_]=s.useState(Array.isArray(l?.posFilter)?l.posFilter:[]),[w,O]=s.useState(Array.isArray(l?.wordTypeFilter)?l.wordTypeFilter:[]),v=s.useRef(t?.resetKey);s.useEffect(()=>{v.current!==t?.resetKey&&(v.current=t?.resetKey,c(h()),E(!!t?.defaultImageOnly),g(!1),B([]),_([]),O([]))},[t?.resetKey]);const k=dt(),[D,$]=s.useState({cho:new Set,jung:new Set,jong:new Set,syllable:new Set}),[G,Y]=s.useState(!1),[R,L]=s.useState(null),H=1,U=Math.max(1,[i.cho,i.jung,i.jong].filter(Boolean).length),[ee,me]=s.useState(e);s.useEffect(()=>{if(ee!==e){if(!t?.resetOnMount){const y=Dt(e);c(y?.composition??h()),E(y?.excludeNoImage??!0),g(y?.sameStructureOnly??!0),a(Ot(y)),B(Array.isArray(y?.gradeFilter)?y.gradeFilter:[]),_(Array.isArray(y?.posFilter)?y.posFilter:[]),O(Array.isArray(y?.wordTypeFilter)?y.wordTypeFilter:[])}me(e)}},[e,ee,t?.resetOnMount]),s.useEffect(()=>{if(!t?.resetOnMount&&ee===e)try{localStorage.setItem(_t(e),JSON.stringify({contrastCount:U,composition:i,excludeNoImage:f,sameStructureOnly:p,phonemeView:r,gradeFilter:S,posFilter:b,wordTypeFilter:w}))}catch{}},[t?.resetOnMount,e,ee,U,i,f,p,r,S,b,w]);const[A,N]=s.useState(0);ku("wordpool:update",()=>N(y=>y+1));const I=s.useRef(o.language);s.useEffect(()=>{I.current!==o.language&&(I.current=o.language,N(y=>y+1))},[o.language]),s.useEffect(()=>{if(!u.choseong)return;let y=!1;return fo({difficulty:C,excludeNoImage:f}).then(j=>{y||($(j),j.cho.size+j.jung.size+j.jong.size>0&&Y(!0))}).catch(()=>{y||$({cho:new Set,jung:new Set,jong:new Set,syllable:new Set})}),()=>{y=!0}},[u.choseong,C,f,A]),s.useEffect(()=>{let y=!1;const j=i,T=j.cho?ie(j.cho):null,P=j.jung?ie(j.jung):null,K=j.jong===le,pe=K?null:j.jong?ie(j.jong):null,Se=j.syllable!=null?Bu(j.syllable):null,He=!!(T||P||pe||K||Se);return Co({difficulty:u.difficulty?C:null,contrastCount:u.difficulty?U:1,composition:u.choseong&&He?{cho:T,jung:P,jong:pe,jongNone:K,syllable:Se}:null,excludeNoImage:f,sameStructureOnly:p,phonemeView:r==="pron"?"pron":"char",grade:S.length>0?S:null}).then(Ge=>{y||L(Ge)}).catch(()=>{y||L(null)}),()=>{y=!0}},[u.choseong,u.difficulty,C,U,i,r,f,p,A,S]),s.useEffect(()=>{G&&c(y=>{const j={...y};let T=!1;return["cho","jung","jong"].forEach(P=>{const K=y[P];!K||K===le||ie(K).some(pe=>D[P].has(pe))||(j[P]=null,T=!0)}),y.syllable!=null&&u.fixedSyllable==null&&(y.syllable>=re?[...D.syllable].some(P=>P>=re)||(j.syllable=null,T=!0):(!D.syllable.has(y.syllable)||y.syllable<H)&&(j.syllable=null,T=!0)),T?j:y})},[D,G,H,u.fixedSyllable]);const x=s.useMemo(()=>{const y=j=>{const T=new Set;for(const P of Et[j])D[j].has(P)&&T.add(P);return T};return{cho:y("cho"),jung:y("jung"),jong:y("jong")}},[D]),Q=s.useMemo(()=>({exact:new Set(St.filter(y=>D.syllable.has(y))),min:[...D.syllable].some(y=>y>=re)}),[D]),M=s.useMemo(()=>({composition:n("wordPairs.composition","\uC815\uB2F5 \uB2E8\uC5B4 \uAD6C\uC131"),syllableCount:n("wordPairs.syllableCount","\uC74C\uC808 \uC218"),onset:n("wordPairs.onset","\uCD08\uC131"),vowel:n("wordPairs.vowel","\uBAA8\uC74C"),coda:n("wordPairs.coda","\uC885\uC131"),phonemeGroup:n("training.filter.phonemeGroup",{defaultValue:"\uD6C8\uB828 \uC74C\uC808"}),trainOnset:n("training.filter.trainOnset",{defaultValue:"\uCD08\uC131"}),trainVowel:n("training.filter.trainVowel",{defaultValue:"\uBAA8\uC74C"}),trainCoda:n("training.filter.trainCoda",{defaultValue:"\uC885\uC131"}),random:n("training.filter.random","\uBB34\uC791\uC704"),exclude:n("wordSearch.filter.exclude","\uC81C\uC678"),selectLabel:n("training.filter.selectSection",{defaultValue:"\uC120\uD0DD"}),none:n("common.none","\uC5C6\uC74C"),noImage:n("wordSearch.filter.excludeNoImage","\uC774\uBBF8\uC9C0 \uC5C6\uC74C"),excludeImage:n("training.filter.excludeImage",{defaultValue:"\uC774\uBBF8\uC9C0 \uC788\uB294 \uB2E8\uC5B4\uB9CC"}),sameStructure:n("training.filter.sameStructure",{defaultValue:"\uC74C\uC18C \uAD6C\uC870 \uAC19\uC740 \uB2E8\uC5B4\uB9CC"}),noLimit:n("training.filter.noLimit",{defaultValue:"\uBB34\uAD00"}),codaExclude:n("training.filter.codaExclude",{defaultValue:"\uC81C\uC678"}),gradeLabel:n("training.filter.gradeLabel",{defaultValue:"\uB09C\uC774\uB3C4 \uB4F1\uAE09"})}),[n]),Tu=s.useMemo(()=>({[M.trainOnset]:"cho",[M.trainVowel]:"jung",[M.trainCoda]:"jong"}),[M]),$e=s.useCallback((y,j)=>({title:j,items:y}),[]),ru=s.useMemo(()=>[n("training.filter.excludeImageInfo",{defaultValue:"\uC774\uBBF8\uC9C0 \uC788\uB294 \uB2E8\uC5B4\uB9CC: \uB2E8\uC5B4 \uC911\uC5D0 \uC774\uBBF8\uC9C0\uAC00 \uC788\uB294 \uB2E8\uC5B4\uB9CC \uACB0\uACFC\uC5D0 \uBCF4\uC5EC\uC90D\uB2C8\uB2E4."}),n("training.filter.sameStructureInfo",{defaultValue:"\uC74C\uC18C \uAD6C\uC870 \uAC19\uC740 \uB2E8\uC5B4\uB9CC: \uC815\uB2F5\uACFC \uC624\uB2F5\uC758 \uC74C\uC808 \uAD6C\uC870(\uAE00\uC790 \uC218\xB7\uBC1B\uCE68 \uC720\uBB34 \uB4F1)\uAC00 \uAC19\uC740 \uACB0\uACFC\uB9CC \uB0A8\uACA8\uC694."})],[n]),kt=s.useMemo(()=>{const y=[];if(u.choseong){const j={value:le,displayLabel:M.codaExclude},T=u.fixedNoCoda===!0,P=(K,pe)=>{const Se=T&&K==="jong",He={label:pe,groupLabel:M.phonemeGroup,allOption:!u.requireSyllable,allLabel:M.noLimit,allOptionDisabled:Se};if(r==="pron"){const ye=bu[K].map(Ht=>Ht.map(({v:au,phonetic:Gt})=>{const su=ie(au),ju=mt(n,Gt),Iu=Se||!su.some(Yt=>D[K].has(Yt));return su.length>1?{value:au,labels:su,tooltip:ju,disabled:Iu}:{value:au,tooltip:ju,disabled:Iu}}));return K==="jong"&&!u.requireCoda&&ye.unshift([j]),{...He,groups:ye}}const Ge=Et[K].map(ye=>!Se&&x[K].has(ye)?ye:{value:ye,disabled:!0});return{...He,items:K==="jong"&&!u.requireCoda?[j,...Ge]:Ge}};y.push(P("cho",M.trainOnset)),y.push(P("jung",M.trainVowel)),y.push(P("jong",M.trainCoda))}if(y.push({...ft(n,k,{labelInfo:$e([n("wordPairs.filter.difficultyInfo",{defaultValue:"\uAD6D\uB9BD\uAD6D\uC5B4\uC6D0\uC758 \uAE30\uCD08 \uC5B4\uD718 \uB4F1\uAE09\uC774 \uACB0\uACFC\uC5D0 \uBC18\uC601\uB429\uB2C8\uB2E4."})])}),label:M.gradeLabel}),u.partOfSpeech&&y.push(gt(k)),u.wordType&&y.push(ht(k)),u.choseong||u.fixedSyllable!=null){const j=u.fixedSyllable;y.push({label:M.syllableCount,items:[...St.map(T=>({value:Eu(T),displayLabel:n("wordPairs.syllableN",{n:T,defaultValue:"{{n}}\uC74C\uC808"}),disabled:j!=null?T!==j:!Q.exact.has(T)||T<H})),{value:Eu(re),displayLabel:n("wordPairs.syllableNPlus",{n:re,defaultValue:"{{n}}\uC74C\uC808 \uC774\uC0C1"}),disabled:j!=null?re!==j:!Q.min}],allOption:!0,allOptionDisabled:j!=null})}return u.choseong?y.push({label:M.exclude,displayLabel:M.selectLabel,multiple:!0,items:[M.excludeImage,M.sameStructure],labelInfo:$e(ru)}):y.push({label:M.exclude,displayLabel:M.selectLabel,multiple:!0,items:[M.excludeImage],labelInfo:$e([ru[0]])}),y},[u.choseong,u.partOfSpeech,u.wordType,u.requireSyllable,u.fixedSyllable,u.fixedNoCoda,u.requireCoda,H,x,D,r,Q,M,n,$e,ru,k]),Pt={...(u.choseong||u.fixedSyllable!=null)&&i.syllable!=null?{[M.syllableCount]:Eu(i.syllable)}:{},...u.choseong&&i.cho?{[M.trainOnset]:i.cho}:{},...u.choseong&&i.jung?{[M.trainVowel]:i.jung}:{},...u.choseong&&i.jong?{[M.trainCoda]:i.jong}:{},[M.exclude]:[...f?[M.excludeImage]:[],...p?[M.sameStructure]:[]],[M.gradeLabel]:S.map(y=>n("wordSearch.filter.grade",{n:Number(y),defaultValue:"{{n}}\uB4F1\uAE09"})),...u.partOfSpeech?{[k.partOfSpeech]:b}:{},...u.wordType?{[k.wordType]:w}:{}},vt=s.useCallback((y,j)=>{if(j===M.exclude)y===M.excludeImage?E(T=>!T):y===M.sameStructure&&g(T=>!T);else if(j===M.syllableCount)c(T=>{if(!y||y===he)return{...T,syllable:null};const P=jo(y);return{...T,syllable:T.syllable===P?null:P}});else if(j===M.gradeLabel){if(!y||y===he){B([]);return}const T=y.replace(/\D/g,"");B(P=>P.includes(T)?P.filter(K=>K!==T):[...P,T])}else if(j===k.partOfSpeech){if(!y||y===he){_([]);return}_(T=>T.includes(y)?T.filter(P=>P!==y):[...T,y])}else if(j===k.wordType){if(!y||y===he){O([]);return}O(T=>T.includes(y)?T.filter(P=>P!==y):[...T,y])}else{const T=Tu[j];if(!T)return;c(P=>u.requireSyllable?y&&y!==he?{...P,[T]:y}:P:!y||y===he||P[T]===y?{...P,[T]:null}:{...P,[T]:y})}},[M,Tu,k,u.requireSyllable]),xt=s.useCallback(y=>!u.partOfSpeech&&!u.wordType?!0:Bo(y,{...u.partOfSpeech?{[k.partOfSpeech]:b}:{},...u.wordType?{[k.wordType]:w}:{}},k),[u.partOfSpeech,u.wordType,b,w,k]),Ft=s.useCallback(y=>{y!==r&&(y!=="direct"&&r!=="direct"&&c(j=>At(j,y,d.current,m.current)),a(y))},[r]),Vt=s.useCallback(()=>({composition:i,contrastCount:U,excludeNoImage:f,sameStructureOnly:p,phonemeView:r,gradeFilter:S,posFilter:b,wordTypeFilter:w}),[i,U,f,p,r,S,b,w]),$t=s.useCallback(y=>{c(y.composition),E(y.excludeNoImage),g(y.sameStructureOnly??!0),a(y.phonemeView),B(Array.isArray(y.gradeFilter)?y.gradeFilter:[]),Array.isArray(y.posFilter)&&_(y.posFilter),Array.isArray(y.wordTypeFilter)&&O(y.wordTypeFilter)},[]);return{difficulty:C,contrastCount:U,composition:i,choseong:i.cho,excludeNoImage:f,sameStructureOnly:p,gradeFilter:S,posFilter:b,wordTypeFilter:w,matchesWordAttributes:xt,poolVersion:A,filterSections:kt,filterSelected:Pt,handleFilterSelect:vt,phonemeView:r,setPhonemeView:Ft,phonemeGroupLabel:M.phonemeGroup,wordCount:R,getFilterSnapshot:Vt,restoreFilterSnapshot:$t}}function ko(e){const u=a=>a?ie(a):null,t=u(e.cho),n=u(e.jung),o=e.jong===le,l=o?null:u(e.jong),r=e.syllable!=null?Bu(e.syllable):null;return!t&&!n&&!l&&!o&&!r?null:{cho:t,jung:n,jong:l,jongNone:o,syllable:r}}function Po(e,u,t,n,o,l,r=!0,a="char",i=[]){const[c,h]=s.useState({}),[C,d]=s.useState(!1),{cho:m=null,jung:f=null,jong:E=null,syllable:p=null}=n??{},g=i.length>0?i.slice().sort().join(","):"";return s.useEffect(()=>{l>0&&co(o).catch(()=>{})},[l,o]),s.useEffect(()=>{let S=!1;return d(!0),(async()=>{const B=ko({cho:m,jung:f,jong:E,syllable:p}),b=`${m??""}_${f??""}_${E??""}_${p??""}_${g}`,_={};await Promise.all(e.map(async w=>{const O=Cu[w.key];try{const v=await Ct(w.key,{difficulty:O.difficulty?u:null,contrastCount:O.difficulty?t:1,composition:O.choseong?B:null,count:5,excludeNoImage:o,sameStructureOnly:r,phonemeView:a,grade:i.length>0?i:null});v&&v.length>0?_[w.key]={id:`wt-${w.key}-${u}-${b}-${Date.now()}`,name:w.label,training_type:w.key,category_main_code:"WORD",iconColor:w.color,subTitle:w.subTitle,items:v,itemCount:v.length}:_[w.key]={id:`wt-${w.key}-empty`,name:w.label,training_type:w.key,category_main_code:"WORD",iconColor:w.color,subTitle:w.subTitle,items:[],itemCount:0,__empty:!0}}catch{_[w.key]=null}})),S||(h(_),d(!1))})(),()=>{S=!0}},[u,t,m,f,E,p,o,r,a,l,g]),{perTypeData:c,generating:C}}function _u(){return Ze(new Date)}function Ze(e){if(e==null||e==="")return"";const u=e instanceof Date?e:new Date(e);return isNaN(u.getTime())?"":new Intl.DateTimeFormat("fr-CA",{timeZone:"Asia/Seoul"}).format(u)}const Me=[],Le=[],ke=[],Pe=[],Xe={LISTEN_IN_NOISE:[],SHORT_STORY:[],LONG_STORY:[],ORDERING_SENTENCE:[]},eu={LISTEN_IN_NOISE:[],SHORT_STORY:[],LONG_STORY:[],ORDERING_SENTENCE:[]},vo={LISTEN_IN_NOISE:3,SHORT_STORY:2,LONG_STORY:1,ORDERING_SENTENCE:2};let Du=null,Nt=null,fe=null;function xo({counts:e,forceRefresh:u}={}){const t=Object.assign({},vo,e||{}),n=_u(),o=Ze(new Date(`${n}T00:00:00+09:00`).getTime()-864e5),l=JSON.stringify(t);if(!u&&Nt===n&&Du===l&&fe)return Object.assign(Xe,fe.today),Object.assign(eu,fe.yesterday?.selection||{LISTEN_IN_NOISE:[],SHORT_STORY:[],LONG_STORY:[],ORDERING_SENTENCE:[]}),{today:Xe,yesterday:eu};const r={LISTEN_IN_NOISE:ae(Me,Math.max(0,Number(t.LISTEN_IN_NOISE)||0)),SHORT_STORY:ae(Le,Math.max(0,Number(t.SHORT_STORY)||0)),LONG_STORY:ae(ke,Math.max(0,Number(t.LONG_STORY)||0)),ORDERING_SENTENCE:ae(Pe,Math.max(0,Number(t.ORDERING_SENTENCE)||0))};let a=null;return fe&&Du===l&&fe.yesterday&&fe.yesterday.date===o&&(a=fe.yesterday.selection),a||(a={LISTEN_IN_NOISE:ae(Me,Math.max(0,Number(t.LISTEN_IN_NOISE)||0)),SHORT_STORY:ae(Le,Math.max(0,Number(t.SHORT_STORY)||0)),LONG_STORY:ae(ke,Math.max(0,Number(t.LONG_STORY)||0)),ORDERING_SENTENCE:ae(Pe,Math.max(0,Number(t.ORDERING_SENTENCE)||0))}),Object.assign(Xe,r),Object.assign(eu,a),Nt=n,Du=l,fe={today:r,yesterday:{date:o,countsKey:l,selection:a}},{today:Xe,yesterday:eu}}let Tt=!1,ve=null;async function Fo(){try{const e={url:typeof document>"u"?require("url").pathToFileURL(__filename).href:iu&&iu.tagName.toUpperCase()==="SCRIPT"&&iu.src||new URL("hooks.cjs.js",document.baseURI).href}&&void 0||"/",u=await fetch(`${e}data/allTrainingData.json`);return u.ok?await u.json():null}catch{return null}}async function Vo(){if(!Tt)return ve||(ve=(async()=>{const e=await Fo();if(!e){ve=null;try{window.dispatchEvent(new Event("speechear.data.error"))}catch{}return}const u={noise:[],short:[],long:[],order:[]};try{for(const t of Object.keys(e||{})){const n=e[t]||[];for(const o of n){const l=o,r=String(l.training_type||t),a=String(l.category_main_code||l.category_main||l.category_0||""),i=String(l.category_sub_code||l.category_sub||l.category_1||""),c=Object.assign({},l,{training_type:r,category_0:a,category_1:i});r==="LISTEN_IN_NOISE"?u.noise.push(c):r==="SHORT_STORY"?u.short.push(c):r==="LONG_STORY"?u.long.push(c):r==="ORDERING_SENTENCE"&&u.order.push(c)}}}catch{ve=null;try{window.dispatchEvent(new Event("speechear.data.error"))}catch{}return}Me.push(...u.noise),Le.push(...u.short),ke.push(...u.long),Pe.push(...u.order);try{window.dispatchEvent(new Event("speechear.data.updated"))}catch{}try{xo()}catch{}Tt=!0})(),ve)}async function $o(e=3e3){const u=Vo();return Promise.race([u,new Promise(t=>setTimeout(t,e))])}function Ho(e){let u=2166136261;for(let t=0;t<e.length;t++)u^=e.charCodeAt(t),u=Math.imul(u,16777619);return u>>>0}function Go(e){let u=e>>>0;return()=>{u|=0,u=u+1831565813|0;let t=Math.imul(u^u>>>15,1|u);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const uu=ae;function Ou(e,u){const t=u?Go(Ho(u)):Math.random;return{LISTEN_IN_NOISE:uu(Me,Math.max(0,e.LISTEN_IN_NOISE||0),t),SHORT_STORY:uu(Le,Math.max(0,e.SHORT_STORY||0),t),LONG_STORY:uu(ke,Math.max(0,e.LONG_STORY||0),t),ORDERING_SENTENCE:uu(Pe,Math.max(0,e.ORDERING_SENTENCE||0),t)}}function jt(e){return e?!!(e.LISTEN_IN_NOISE?.length||e.SHORT_STORY?.length||e.LONG_STORY?.length||e.ORDERING_SENTENCE?.length):!1}const Yo={LISTEN_IN_NOISE:3,SHORT_STORY:2,LONG_STORY:1,ORDERING_SENTENCE:2};function It(e=!1,u=Yo,t){const n=Ze(Date.now()),o=Ze(Date.now()-864e5),l=`${t??""}|${n}`,r=`${t??""}|${o}`;return Me.length>0||Le.length>0||ke.length>0||Pe.length>0?{today:Ou(u,l),yesterday:Ou(u,r)}:{today:Ou(u,l),yesterday:null}}function Uo(e){const u=s.useRef({LISTEN_IN_NOISE:[],SHORT_STORY:[],LONG_STORY:[],ORDERING_SENTENCE:[]}),t=s.useRef(null),[n,o]=s.useState(!1),[l,r]=s.useState(!1),[a,i]=s.useState(0),[c,h]=s.useState(!1),[C,d]=s.useState(()=>_u());s.useEffect(()=>{const f=()=>{const p=Date.now(),g=new Date(p+9*36e5),S=Date.UTC(g.getUTCFullYear(),g.getUTCMonth(),g.getUTCDate()+1)-9*36e5;return Math.max(1e3,S-p+1e3)};let E=setTimeout(function p(){d(_u()),E=setTimeout(p,f())},f());return()=>clearTimeout(E)},[]),s.useEffect(()=>{let f=!1,E,p=0;const g=40,S=()=>{E!==void 0&&(clearInterval(E),E=void 0)};let B=!1;try{const w=new URLSearchParams(window.location.search),O=w.get("forceRefresh")||w.get("force");B=O==="1"||O==="true"}catch{}const b=w=>{u.current=w.today,t.current=w.yesterday,o(!0),h(!0),i(O=>O+1),f=!0,S()},_=async()=>{if(f)return;if(!B){const O=It(!1,void 0,e);if(jt(O.today)){b(O);return}}try{await $o(3e3)}catch{}if(f)return;const w=It(B,void 0,e);if(jt(w.today)){b(w);return}++p>=g&&(o(!0),h(!1),f=!0,S())};return _(),E=setInterval(_,250),()=>{f=!0,S()}},[e,C]);const m=s.useCallback(f=>{const E=l?t.current:u.current,p=l?u.current:t.current;return E?.[f]?.length?E[f]:p?.[f]?.length?p[f]:void 0},[l,a]);return{loaded:n,hasData:c,showYesterday:l,setShowYesterday:r,getTrainingPerType:m}}const we=[];let tu=!1;function Rt(e){if(e.key!=="Escape"||e.defaultPrevented)return;const u=we[we.length-1];u&&(e.stopPropagation(),u())}function Mt(e){return we.push(e),!tu&&typeof document<"u"&&(document.addEventListener("keydown",Rt),tu=!0),()=>{const u=we.lastIndexOf(e);u>=0&&we.splice(u,1),we.length===0&&tu&&typeof document<"u"&&(document.removeEventListener("keydown",Rt),tu=!1)}}function Ko(e,u=!0){const t=Lu(e);s.useEffect(()=>{if(u)return Mt(()=>{t.current?.()})},[u,t])}const Nu=(e,u)=>`${e}:${u??1}`,nu=new Map,Lt=new Set;function Wo(e,u){const[t,n]=s.useState(0),o=Array.from(new Set(e.map(l=>Nu(l.word,l.homonum)))).sort().join("|");return s.useEffect(()=>{const l=(o?o.split("|"):[]).filter(i=>!nu.has(i)&&!Lt.has(i));if(l.length===0)return;let r=!1;const a=Array.from(new Set(l.map(i=>i.slice(0,i.lastIndexOf(":")))));return u(a).then(i=>{for(const c of i)c.Meaning&&nu.set(Nu(c.Word,c.Homonum??void 0),c.Meaning);for(const c of l)nu.has(c)||Lt.add(c);r||i.length===0||n(c=>c+1)}).catch(()=>{}),()=>{r=!0}},[o,u]),s.useMemo(()=>{const l=o?o.split("|"):[],r=new Map;for(const a of l){const i=nu.get(a);i!=null&&r.set(a,i)}return r},[o,t])}function qo(){const[e,u]=s.useState(null),t=s.useCallback(l=>u(l.getBoundingClientRect()),[]),n=s.useCallback(()=>u(null),[]),o=s.useCallback(l=>{const r=l.getBoundingClientRect();u(a=>a?null:r)},[]);return{anchorRect:e,isOpen:e!=null,openAt:t,close:n,toggleAt:o}}function zo(e){const[u,t]=s.useState(null),[n,o]=s.useState(null),l=s.useRef(null);s.useEffect(()=>()=>{l.current&&clearTimeout(l.current)},[]);const r=s.useCallback((i,c)=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{t(i),o(c)},e)},[e]),a=s.useCallback(()=>{l.current&&clearTimeout(l.current),t(null),o(null)},[]);return{payload:u,anchorRect:n,openAfterDelay:r,close:a}}function Jo(e,u,t){const n=Number.isFinite(u)&&u>=1?Math.floor(u):1,o=Math.max(1,Math.ceil(e.length/n)),l=Number.isFinite(t)?Math.min(Math.max(1,Math.floor(t)),o):1;return{pageItems:s.useMemo(()=>e.slice((l-1)*n,l*n),[e,l,n]),totalPages:o,curPage:l}}function Qo(e="warning"){const[u,t]=s.useState(""),[n,o]=s.useState(e),[l,r]=s.useState(0),a=s.useCallback((C,d)=>{o(d),t(C),r(m=>m+1)},[]),i=s.useCallback(C=>a(C,"warning"),[a]),c=s.useCallback(C=>a(C,"normal"),[a]),h=s.useCallback(()=>t(""),[]);return{toastMessage:u,toastType:n,toastKey:l,showToast:a,showWarning:i,showNormal:c,clearToast:h}}const Zo=[{key:"LISTEN_IN_NOISE",label:"\uC18C\uC74C \uD558 \uBB38\uC7A5 \uB4E3\uAE30",icon:"party-popper",desc:"\uB2E4\uC591\uD55C \uC18C\uC74C \uD658\uACBD\uC5D0\uC11C \uBB38\uC7A5 \uCCAD\uB825\uC744 \uD6C8\uB828\uD569\uB2C8\uB2E4."},{key:"SHORT_STORY",label:"\uC9E7\uC740 \uC774\uC57C\uAE30 \uB4E3\uAE30",icon:"message-square",desc:"\uC9E7\uC740 \uC774\uC57C\uAE30\uB97C \uB4E3\uACE0 \uAE30\uC5B5\uD558\uC5EC \uBB38\uC81C\uB97C \uD480\uC5B4\uBD05\uB2C8\uB2E4."},{key:"LONG_STORY",label:"\uAE34 \uC774\uC57C\uAE30 \uB4E3\uAE30",icon:"message-square-text",desc:"\uAE34 \uC774\uC57C\uAE30\uB97C \uB4E3\uACE0 \uAE30\uC5B5\uD558\uC5EC \uB2E4\uC218\uC758 \uBB38\uC81C\uB97C \uD480\uC5B4\uBD05\uB2C8\uB2E4."},{key:"ORDERING_SENTENCE",label:"\uBB38\uC7A5 \uC21C\uC11C\uD654 \uD558\uAE30",icon:"align-start-vertical",desc:"\uC5EC\uB7EC\uAC1C\uC758 \uC9E7\uC740 \uBB38\uC7A5\uC744 \uB4E3\uACE0 \uAE30\uC5B5\uD558\uC5EC \uADF8 \uC21C\uC11C\uC5D0 \uB9DE\uAC8C \uBC30\uC5F4\uD569\uB2C8\uB2E4."}],Xo={LISTEN_IN_NOISE:"listenInNoise",SHORT_STORY:"shortStory",LONG_STORY:"longStory",ORDERING_SENTENCE:"orderingSentence"};function el(e){return Zo.map(u=>{const t=Xo[u.key];return t?{...u,label:e(`trainingType.${t}.title`),desc:e(`trainingType.${t}.desc`)}:u})}const xe={blue:"#60A5FA",green:"#4ADE80",amber:"#FBBF24",purple:"#A78BFA",pink:"#F472B6"},Fe=xe.blue,ou=xe.green,Ve=xe.amber,lu=xe.purple,ul=xe.pink,tl=[{key:"discrimination",label:"\uBCC0\uBCC4\uD6C8\uB828",disc:"\uB450 \uC18C\uB9AC\uAC00 \uAC19\uC740\uC9C0 \uB2E4\uB978\uC9C0, \uB610\uB294 \uD2B9\uC815 \uC18C\uB9AC\uB97C \uAD6C\uBCC4\uD558\uB294 \uD6C8\uB828\uC785\uB2C8\uB2E4.",icon:"ear",types:[{key:"SAME_SOUND_PICK",label:"\uAC19\uC740 \uC18C\uB9AC \uACE0\uB974\uAE30",icon:"volume-2",color:Fe,subTitle:"\uB4E4\uC740 \uC18C\uB9AC\uC640 \uAC19\uC740 \uB2E8\uC5B4 \uCE74\uB4DC\uB97C \uACE0\uB974\uC138\uC694."},{key:"SAME_OR_DIFF",label:"\uAC19\uC740\uC9C0 \uB2E4\uB978\uC9C0 \uB9DE\uD788\uAE30",icon:"diff",color:Fe,subTitle:"\uB450 \uC18C\uB9AC\uAC00 \uAC19\uC740\uC9C0, \uB2E4\uB978\uC9C0 \uAD6C\uBD84\uD558\uC138\uC694."},{key:"HEAR_AND_PICK_SAME",label:"\uC77C\uCE58\uD558\uB294 \uB2E8\uC5B4 \uB9DE\uD788\uAE30",icon:"headphones",color:Fe,subTitle:"\uB4E4\uC740 \uC18C\uB9AC\uC758 \uB2E8\uC5B4 \uCE74\uB4DC\uB97C \uACE0\uB974\uC138\uC694."},{key:"HEAR_AND_PICK_INCLUDED",label:"\uD55C \uC74C\uC808 \uD3EC\uD568 \uB2E8\uC5B4 \uB9DE\uD788\uAE30",icon:"scan-search",color:Fe,subTitle:"\uB4E4\uC740 \uC74C\uC808\uC774 \uD3EC\uD568\uB41C \uB2E8\uC5B4 \uCE74\uB4DC\uB97C \uACE0\uB974\uC138\uC694."},{key:"STARTS_WITH_SAME_SOUND",label:"\uCCAB \uC74C\uC808\uC774 \uAC19\uC740 \uB2E8\uC5B4 \uB9DE\uD788\uAE30",icon:"play-circle",color:Fe,subTitle:"\uB4E4\uC740 \uB2E8\uC5B4\uC640 \uAC19\uC740 \uC18C\uB9AC\uB85C \uC2DC\uC791\uD558\uB294 \uB2E8\uC5B4\uB97C \uACE0\uB974\uC138\uC694."}]},{key:"synthesis",label:"\uD569\uC131\uD6C8\uB828",disc:"\uB450 \uAC1C \uC774\uC0C1\uC758 \uC74C\uC808\uC774\uB098 \uC74C\uC18C\uB97C \uD569\uCCD0 \uB2E8\uC5B4\uB97C \uB9CC\uB4DC\uB294 \uD6C8\uB828\uC785\uB2C8\uB2E4.",icon:"git-merge",types:[{key:"MERGE_2_SYLLABLES",label:"\uC74C\uC808 2\uAC1C \uD569\uCE58\uAE30",icon:"link-2",color:ou,subTitle:"\uB450 \uC74C\uC808\uC744 \uD569\uCE58\uBA74 \uC5B4\uB5A4 \uB2E8\uC5B4\uAC00 \uB420\uAE4C\uC694?"},{key:"MERGE_3_SYLLABLES",label:"\uC74C\uC808 3\uAC1C \uD569\uCE58\uAE30",icon:"git-merge",color:ou,subTitle:"\uC138 \uC74C\uC808\uC744 \uD569\uCE58\uBA74 \uC5B4\uB5A4 \uB2E8\uC5B4\uAC00 \uB420\uAE4C\uC694?"},{key:"MERGE_2_PHONEMES",label:"\uC74C\uC18C 2\uAC1C \uD569\uCE58\uAE30",icon:"combine",color:ou,subTitle:"\uB450 \uC74C\uC18C\uB97C \uD569\uCE58\uBA74 \uC5B4\uB5A4 \uC18C\uB9AC\uAC00 \uB420\uAE4C\uC694?"},{key:"MERGE_3_PHONEMES",label:"\uC74C\uC18C 3\uAC1C \uD569\uCE58\uAE30",icon:"braces",color:ou,subTitle:"\uC138 \uC74C\uC18C\uB97C \uD569\uCE58\uBA74 \uC5B4\uB5A4 \uC18C\uB9AC\uAC00 \uB420\uAE4C\uC694?"}]},{key:"deletion",label:"\uD0C8\uB77D\uD6C8\uB828",disc:"\uB2E8\uC5B4\uC5D0\uC11C \uC74C\uC808\uC774\uB098 \uC74C\uC18C\uB97C \uC81C\uAC70\uD588\uC744 \uB54C \uB0A8\uB294 \uC18C\uB9AC\uB97C \uC778\uC2DD\uD558\uB294 \uD6C8\uB828\uC785\uB2C8\uB2E4.",icon:"scissors",types:[{key:"DROP_1_FROM_2SYLL",label:"2\uC74C\uC808\uC5D0\uC11C 1\uC74C\uC808 \uD0C8\uB77D",icon:"scissors",color:Ve,subTitle:"2\uC74C\uC808 \uB2E8\uC5B4\uC5D0\uC11C \uD55C \uC74C\uC808\uC744 \uBE7C\uBA74 \uC5B4\uB5A4 \uC18C\uB9AC\uAC00 \uB420\uAE4C\uC694?"},{key:"DROP_1_FROM_3SYLL",label:"3\uC74C\uC808\uC5D0\uC11C 1\uC74C\uC808 \uD0C8\uB77D",icon:"minus-circle",color:Ve,subTitle:"3\uC74C\uC808 \uB2E8\uC5B4\uC5D0\uC11C \uD55C \uC74C\uC808\uC744 \uBE7C\uBA74 \uC5B4\uB5A4 \uC18C\uB9AC\uAC00 \uB420\uAE4C\uC694?"},{key:"DROP_PART_FROM_COMPOUND",label:"\uD569\uC131\uC5B4\uC5D0\uC11C \uBD80\uBD84\uD0C8\uB77D",icon:"unlink",color:Ve,subTitle:"\uD569\uC131\uC5B4\uC758 \uC77C\uBD80\uB97C \uBE7C\uBA74 \uC5B4\uB5A4 \uB2E8\uC5B4\uAC00 \uB420\uAE4C\uC694?"},{key:"DROP_FINAL_CONSONANT_FROM_1SYLL",label:"1\uC74C\uC808\uC5D0\uC11C \uBC1B\uCE68 \uD0C8\uB77D",icon:"eraser",color:Ve,subTitle:"\uBC1B\uCE68\uC744 \uBE7C\uBA74 \uC5B4\uB5A4 \uC18C\uB9AC\uAC00 \uB420\uAE4C\uC694?"},{key:"REMOVE_CONSONANT_AND_IDENTIFY_PHONEME",label:"1\uC74C\uC808\uC5D0\uC11C \uC790\uC74C \uD0C8\uB77D",icon:"audio-lines",color:Ve,subTitle:"\uC790\uC74C\uC744 \uBE7C\uBA74 \uC5B4\uB5A4 \uC18C\uB9AC\uAC00 \uB0A8\uC744\uAE4C\uC694?"}]},{key:"substitution",label:"\uB300\uCE58\uD6C8\uB828",disc:"\uB2E8\uC5B4\uC758 \uC77C\uBD80 \uC74C\uC808\uC774\uB098 \uC74C\uC18C\uB97C \uBC14\uAFB8\uC5B4 \uC0C8\uB85C\uC6B4 \uC18C\uB9AC\uB97C \uB9CC\uB4DC\uB294 \uD6C8\uB828\uC785\uB2C8\uB2E4.",icon:"replace",types:[{key:"CHANGE_1_SYLL_IN_2SYLL",label:"2\uC74C\uC808\uC5D0\uC11C \uD55C \uC74C\uC808 \uBC14\uAFB8\uAE30",icon:"replace",color:lu,subTitle:"2\uC74C\uC808 \uB2E8\uC5B4\uC758 \uD55C \uC74C\uC808\uC744 \uBC14\uAFD4 \uC0C8 \uB2E8\uC5B4\uB97C \uB9CC\uB4DC\uC138\uC694."},{key:"CHANGE_1_SYLL_IN_3SYLL",label:"3\uC74C\uC808\uC5D0\uC11C \uD55C \uC74C\uC808 \uBC14\uAFB8\uAE30",icon:"shuffle",color:lu,subTitle:"3\uC74C\uC808 \uB2E8\uC5B4\uC758 \uD55C \uC74C\uC808\uC744 \uBC14\uAFD4 \uC0C8 \uB2E8\uC5B4\uB97C \uB9CC\uB4DC\uC138\uC694."},{key:"CHANGE_1_PHONEME_IN_1SYLL",label:"1\uC74C\uC808\uC5D0\uC11C \uD55C \uC74C\uC18C \uBC14\uAFB8\uAE30",icon:"arrow-right-left",color:lu,subTitle:"1\uC74C\uC808 \uB2E8\uC5B4\uC758 \uD55C \uC74C\uC18C\uB97C \uBC14\uAFD4 \uC0C8 \uC18C\uB9AC\uB97C \uB9CC\uB4DC\uC138\uC694."},{key:"CHANGE_1_PHONEME_IN_2SYLL",label:"2\uC74C\uC808\uC5D0\uC11C \uD55C \uC74C\uC18C \uBC14\uAFB8\uAE30",icon:"flip-horizontal",color:lu,subTitle:"2\uC74C\uC808 \uB2E8\uC5B4\uC758 \uD55C \uC74C\uC18C\uB97C \uBC14\uAFD4 \uC0C8 \uB2E8\uC5B4\uB97C \uB9CC\uB4DC\uC138\uC694."}]},{key:"attention",label:"\uCCAD\uAC01\uC801\uC8FC\uC758\uB825\uD6C8\uB828",disc:"\uC5EC\uB7EC \uC18C\uB9AC\uB97C \uB4E3\uACE0 \uC21C\uC11C\uB97C \uAE30\uC5B5\uD558\uB294 \uC8FC\uC758\uB825\uACFC \uB2E8\uAE30 \uAE30\uC5B5 \uD6C8\uB828\uC785\uB2C8\uB2E4.",icon:"list-ordered",types:[{key:"LISTEN_AND_REMEMBER_ORDER",label:"\uB4E3\uACE0 \uC21C\uC11C\uB300\uB85C \uAE30\uC5B5\uD558\uAE30",icon:"list-ordered",color:ul,subTitle:"\uC138 \uB2E8\uC5B4\uB97C \uB4E4\uC740 \uC21C\uC11C\uB300\uB85C \uCE74\uB4DC\uB97C \uC120\uD0DD\uD558\uC138\uC694."}]}];function nl(){const{t:e}=ce.useTranslation();return s.useMemo(()=>{const u=Object.fromEntries(el(e).map(n=>[n.key,n.label])),t={...u};return tl.flatMap(n=>n.types).forEach(n=>{t[n.key]=e(`trainingType.${n.key}.label`,{defaultValue:n.label})}),{sentence:u,all:t}},[e])}const ol="0.136.0";function ll({computeStyle:e,onScroll:u="close",onResize:t="close",ignoreOutsideClickSelector:n}){const[o,l]=s.useState(!1),[r,a]=s.useState({}),i=s.useRef(null),c=s.useRef(null),h=s.useCallback(()=>{i.current&&a(e(i.current.getBoundingClientRect()))},[e]);s.useEffect(()=>{if(!o)return;h();const m=p=>{const g=p.target;n&&g.closest?.(n)||i.current?.contains(g)||c.current?.contains(g)||l(!1)};document.addEventListener("mousedown",m);const f=p=>{c.current?.contains(p.target)||(u==="reposition"?h():u==="close"&&l(!1))};u!=="ignore"&&window.addEventListener("scroll",f,!0);const E=()=>{t==="reposition"?h():t==="close"&&l(!1)};return t!=="ignore"&&window.addEventListener("resize",E),()=>{document.removeEventListener("mousedown",m),u!=="ignore"&&window.removeEventListener("scroll",f,!0),t!=="ignore"&&window.removeEventListener("resize",E)}},[o,h,u,t,n]),s.useEffect(()=>{if(o)return Mt(()=>l(!1))},[o]);const C=s.useCallback(()=>l(m=>!m),[]),d=s.useCallback(()=>l(!1),[]);return{open:o,setOpen:l,toggle:C,close:d,style:r,triggerRef:i,menuRef:c}}function rl(e,{mode:u="playback",autoStart:t=!1,onPlaySpeaker:n,onComplete:o,playMs:l=1100,feedbackMs:r=1500}={}){const[a,i]=s.useState([]),[c,h]=s.useState(0),[C,d]=s.useState("idle"),[m,f]=s.useState(null),[E,p]=s.useState([]),[g,S]=s.useState(null),[B,b]=s.useState(0),_=s.useRef(0),w=s.useCallback(I=>{_.current=typeof I=="function"?I(_.current):I,b(_.current)},[]),O=s.useRef(n),v=s.useRef(o);s.useEffect(()=>{O.current=n,v.current=o},[n,o]);const k=s.useRef([]),D=()=>{k.current.forEach(clearTimeout),k.current=[]},$=(I,x)=>{k.current.push(setTimeout(x,I))};s.useEffect(()=>()=>D(),[]);const G=a[c]?.id??null,Y=s.useRef(null),R=s.useCallback(()=>{D(),d("playing"),p([]),S(null),w(0);let I=0;e.forEach((x,Q)=>{$(I,()=>{h(Q),f(x.id),O.current?.(x)}),$(I+1e3,()=>{f(null),p(M=>[...M,x.id])}),I+=1300}),$(I,()=>{d("done"),v.current?.({score:0,total:e.length})})},[e,w]),L=s.useCallback((I,x)=>{if(x>=I.length){d("done"),v.current?.({score:_.current,total:I.length});return}Y.current=null,h(x),S(null),d("playing"),f(I[x].id),O.current?.(I[x]),$(l,()=>{f(null),d("waiting")})},[l]),H=s.useCallback(()=>{D();const I=F(e);i(I),w(0),p([]),L(I,0)},[e,L,w]),U=s.useCallback(()=>{u==="playback"?(i(e),R()):H()},[u,e,R,H]),ee=s.useCallback(()=>{D(),d("idle"),f(null),p([]),S(null),h(0),w(0),i([])},[w]),me=e.map(I=>I.id).join("|");s.useEffect(()=>(t?U():ee(),()=>D()),[u,me,t]);const A=s.useCallback(I=>{C!=="waiting"||u==="playback"||Y.current===c||(Y.current=c,S(I),I===a[c]?.id&&w(x=>x+1),u==="exam"?(d("playing"),$(400,()=>L(a,c+1))):(d("feedback"),$(r,()=>L(a,c+1))))},[C,u,a,c,L,r,w]),N=u==="playback"?e.length:a.length;return{bind:{activeSpeakerId:m,playedIds:E,selectedId:g,answerId:G,showFeedback:C==="feedback",clickable:C==="waiting",onSelectSpeaker:A},index:c,total:N,score:B,phase:C,done:C==="done",start:U,reset:ee}}exports.CACHE_GROUPS=Yu,exports.CORE_VERSION=ol,exports.DocumentTitleSuppressContext=vu,exports.EMPTY_COMPOSITION=Au,exports.MediaQueryOverrideContext=Mu,exports.NO_CODA=le,exports.SYLLABLE_MIN=re,exports.VAP_PAGE_SIZE_OPTIONS=Ue,exports.buildGradeSection=ft,exports.buildPartOfSpeechSection=gt,exports.buildPositionSection=mo,exports.buildSelectSection=ho,exports.buildSyllableSection=go,exports.buildWordTypeSection=ht,exports.charToPronValue=wt,exports.convertComposition=At,exports.fmtBytes=gn,exports.lsBytes=Uu,exports.meaningKey=Nu,exports.pronToCharValue=bt,exports.syllableToFilter=Bu,exports.today=Ne,exports.toggleAttributeFilter=po,exports.useAnchoredMenu=ll,exports.useCacheManagement=hn,exports.useDailyTrainingSelection=Uo,exports.useDelayedHoverAnchor=zo,exports.useDeviceManagement=An,exports.useDocumentTitle=qt,exports.useEscToClose=Ko,exports.useFontScale=Ut,exports.useHoverAnchor=qo,exports.useMediaQuery=Wt,exports.usePagedList=Jo,exports.usePasswordChange=Zt,exports.useRelativeDay=zt,exports.useSoundCompassExam=rl,exports.useTablePaging=wn,exports.useTableSort=bn,exports.useToastState=Qo,exports.useTrainingTypeLabels=nl,exports.useVisitAllPanel=Bn,exports.useVisitHistory=Sn,exports.useVisitSchedule=En,exports.useWindowEvent=ku,exports.useWordAttributeFilterKeys=dt,exports.useWordDataStats=mn,exports.useWordMeanings=Wo,exports.useWordTrainingDataGeneration=Po,exports.useWordTrainingFilter=Lo,exports.valueToJamos=ie;
|
|
1
|
+
"use strict";var s=require("react"),ce=require("react-i18next"),Ru=require("i18next"),iu=typeof document<"u"?document.currentScript:null;function Wt(e){var u=Object.create(null);return e&&Object.keys(e).forEach(function(t){if(t!=="default"){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(u,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),u.default=e,Object.freeze(u)}var Mu=Wt(s);function qt({storageKey:e="fontScale",baseFont:u=20,minScale:t=.8,maxScale:n=1.4,step:o=.1,lineHeightRatio:r=1.4}={}){const l=E=>Math.max(t,Math.min(n,Number(E))),a=E=>{try{const B=localStorage.getItem(E),_=B?Number(B):1;return Number.isFinite(_)?l(_):l(1)}catch{return l(1)}},[i,c]=s.useState(()=>a(e)),[g,d]=s.useState(e);g!==e&&(d(e),c(a(e))),s.useEffect(()=>{try{localStorage.setItem(e,String(i))}catch{}},[e,i]);const C=E=>{c(typeof E=="function"?B=>l(E(B)):l(E))},h=()=>C(E=>+(E+o).toFixed(6)),f=()=>C(E=>+(E-o).toFixed(6)),w=i<n-Number.EPSILON,y=i>t+Number.EPSILON,m=Math.round(u*i),p=Math.round(m*r);return{scale:i,setScale:C,increase:h,decrease:f,canIncrease:w,canDecrease:y,fontSize:m,lineHeight:p}}const Lu=s.createContext(null);function zt(e){return/max-width:\s*7[0-9][0-9]px/.test(e)}const vu=e=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(e).matches;function Jt(e){const u=s.useCallback(t=>{if(typeof window>"u"||!window.matchMedia)return()=>{};const n=window.matchMedia(e);return n.addEventListener?n.addEventListener("change",t):n.addListener&&n.addListener(t),()=>{n.removeEventListener?n.removeEventListener("change",t):n.removeListener&&n.removeListener(t)}},[e]);return Mu.useSyncExternalStore(u,()=>vu(e),()=>!1)}function Qt(e){const[u,t]=s.useState(vu(e));return s.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const n=window.matchMedia(e),o=l=>t(l.matches),r=n;return r.addEventListener?r.addEventListener("change",o):r.addListener&&r.addListener(o),t(n.matches),()=>{r.removeEventListener?r.removeEventListener("change",o):r.removeListener&&r.removeListener(o)}},[e]),u}const Zt=typeof Mu.useSyncExternalStore=="function"?Jt:Qt;function Xt(e){const u=s.useContext(Lu),t=Zt(e);return u&&typeof u.mobile=="boolean"&&zt(e)?u.mobile:t}function ku(e){const u=s.useRef(e);return s.useEffect(()=>{u.current=e}),u}function Pu(e,u){const t=ku(u);s.useEffect(()=>{const n=()=>t.current();try{window.addEventListener(e,n)}catch{}return()=>{try{window.removeEventListener(e,n)}catch{}}},[e,t])}const cu=" \xB7 ",xu=(()=>{if(typeof document>"u")return"";const e=document.title;return e.includes(cu)?e.split(cu).pop()??e:e})(),Fu=s.createContext(!1),ge=[];let Vu=null;function en(e){const u=s.useContext(Fu);s.useEffect(()=>{if(u||typeof e!="string"||!e)return;ge.length===0&&(Vu=document.title);const t={text:xu?`${e}${cu}${xu}`:e};return ge.push(t),document.title=t.text,()=>{const n=ge.lastIndexOf(t);n>=0&&ge.splice(n,1),document.title=ge.length?ge[ge.length-1].text:Vu??document.title}},[e,u])}function un(){const{t:e}=ce.useTranslation();return s.useCallback(u=>{if(!u)return"";const t=new Date(u).getTime();if(Number.isNaN(t))return"";const n=Math.floor((Date.now()-t)/864e5);return n<=0?e("myHomework.relativeDay.today","\uC624\uB298"):n===1?e("myHomework.relativeDay.yesterday","\uC5B4\uC81C"):e("myHomework.relativeDay.daysAgo",{n})},[e])}const tn=()=>{const e="\uC54C \uC218 \uC5C6\uB294 \uC624\uB958",u=typeof Ru?.t=="function"?Ru.t("common.unknownError",{defaultValue:e}):void 0;return typeof u=="string"&&u?u:e};function nn(e,u){if(u===void 0&&(u=tn()),e instanceof Error)return e.message||u;if(typeof e=="string")return e||u;if(e&&typeof e=="object"){const t=e;for(const n of[t.message,t.error_description,t.error])if(typeof n=="string"&&n)return n}return u}function on(e){const{t:u}=ce.useTranslation(),[t,n]=s.useState({current:"",next:"",confirm:""}),[o,r]=s.useState(null),[l,a]=s.useState(!1),i=s.useRef(null),c=s.useRef(!1);s.useEffect(()=>()=>{i.current!==null&&clearTimeout(i.current)},[]);const g=s.useCallback(()=>{n({current:"",next:"",confirm:""}),r(null)},[]),d=s.useCallback(async()=>{if(c.current)return;if(!t.current){r({type:"error",text:u("account.security.password.currentRequired","\uD604\uC7AC \uBE44\uBC00\uBC88\uD638\uB97C \uC785\uB825\uD558\uC138\uC694.")});return}if(!t.next){r({type:"error",text:u("account.security.password.newRequired","\uC0C8 \uBE44\uBC00\uBC88\uD638\uB97C \uC785\uB825\uD558\uC138\uC694.")});return}if(t.next!==t.confirm){r({type:"error",text:u("account.security.password.mismatch","\uC0C8 \uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.")});return}a(!0),c.current=!0;let C;try{C=e?await e(t.current,t.next):null}catch(h){C=nn(h)}finally{c.current=!1,a(!1)}if(C){r({type:"error",text:C});return}r({type:"success",text:u("account.security.password.changed","\uBE44\uBC00\uBC88\uD638\uAC00 \uBCC0\uACBD\uB418\uC5C8\uC2B5\uB2C8\uB2E4.")}),n({current:"",next:"",confirm:""}),i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>r(null),1500)},[t,e,u]);return{pw:t,setPw:n,pwMsg:o,setPwMsg:r,pwLoading:l,handleChangePw:d,reset:g}}const z=["\u3131","\u3132","\u3134","\u3137","\u3138","\u3139","\u3141","\u3142","\u3143","\u3145","\u3146","\u3147","\u3148","\u3149","\u314A","\u314B","\u314C","\u314D","\u314E"],ne=["\u314F","\u3150","\u3151","\u3152","\u3153","\u3154","\u3155","\u3156","\u3157","\u3158","\u3159","\u315A","\u315B","\u315C","\u315D","\u315E","\u315F","\u3160","\u3161","\u3162","\u3163"],ue=["","\u3131","\u3132","\u3133","\u3134","\u3135","\u3136","\u3137","\u3139","\u313A","\u313B","\u313C","\u313D","\u313E","\u313F","\u3140","\u3141","\u3142","\u3144","\u3145","\u3146","\u3147","\u3148","\u314A","\u314B","\u314C","\u314D","\u314E"];function V(e){if(!e)return null;const u=e.charCodeAt(0)-44032;return u<0||u>=11172?null:{cho:Math.floor(u/588),jung:Math.floor(u%588/28),jong:u%28}}function rn(){const e=new Map;return u=>{let t=e.get(u);return t||(t=[...u].map(n=>V(n)),e.set(u,t)),t}}function Ce(e,u,t=0){return String.fromCharCode(44032+(e*21+u)*28+t)}function ln(e,u){if(!e||!u||e===u||e.length!==u.length)return"random";let t=0,n=null;for(let o=0;o<e.length;o++){const r=V(e[o]),l=V(u[o]);if(!r||!l)return"random";if(r.cho===l.cho&&r.jung===l.jung&&r.jong===l.jong)continue;t++;const a=r.cho!==l.cho,i=r.jung!==l.jung,c=r.jong!==l.jong;(a?1:0)+(i?1:0)+(c?1:0)>1?n="multi":a?n="cho":i?n="jung":n="jong"}return t!==1?"random":n==="cho"?"cho":n==="jung"?"jung":n==="jong"?"jong":"random"}const be={3:["\u3131","\u3145"],5:["\u3134","\u3148"],6:["\u3134","\u314E"],9:["\u3139","\u3131"],10:["\u3139","\u3141"],11:["\u3139","\u3142"],12:["\u3139","\u3145"],13:["\u3139","\u314C"],14:["\u3139","\u314D"],15:["\u3139","\u314E"],18:["\u3142","\u3145"]};Object.fromEntries(Object.entries(be).map(([e,u])=>[u.join(""),ue[Number(e)]]));function an(e,u){if(!e||!u)return!1;for(const t of e){const n=V(t);if(n){if(z[n.cho]===u)return!0;if(n.jong>0){if(ue[n.jong]===u)return!0;const o=be[n.jong];if(o&&o.includes(u))return!0}}}return!1}function Ae(e){if(!e)return 0;let u=0;for(const t of e)V(t)&&u++;return u}function sn(e){if(!e)return!1;let u=!1;for(const t of e){const n=V(t);if(n&&(u=!0,n.jong>0))return!1}return u}function cn(e,u){if(e.jong<=0)return!1;if(u.includes(ue[e.jong]))return!0;const t=be[e.jong];return!!t&&t.some(n=>u.includes(n))}function Cn(e,u,t){if(!e)return!1;const n=[...e],o=r=>{const l=V(n[r]);if(!l||u.cho&&!u.cho.includes(z[l.cho])||u.jung&&!u.jung.includes(ne[l.jung]))return!1;if(u.jongNone){if(l.jong>0)return!1}else if(u.jong&&!cn(l,u.jong))return!1;return!0};if(t==="head")return o(0);if(t==="tail")return o(n.length-1);if(t==="mid"){for(let r=1;r<n.length-1;r++)if(o(r))return!0;return!1}for(let r=0;r<n.length;r++)if(o(r))return!0;return!1}const dn={cho:z.length,jung:ne.length,jong:ue.length};function fn(e,u,t,n,o=1/0){if(!e||t<1)return[];const r=[...e].map(d=>V(d));if(r.some(d=>!d))return[];const l=r,a=l.length;if(t>a)return[];const i=dn[u],c=new Set,g=[];(function d(C,h){if(h.length===t){g.push([...h]);return}for(let f=C;f<a;f++)h.push(f),d(f+1,h),h.pop()})(0,[]);for(const d of g)if((function C(h,f){if(c.size>=o)return;if(h===d.length){const m=f.map(p=>Ce(p.cho,p.jung,p.jong)).join("");m!==e&&n.has(m)&&c.add(m);return}const w=d[h],y=l[w][u];for(let m=0;m<i;m++){if(m===y)continue;const p=f.slice();if(p[w]={...f[w],[u]:m},C(h+1,p),c.size>=o)return}})(0,l),c.size>=o)break;return[...c]}function gn(e,u){if(!e||!u||e.length!==u.length)return-1;let t=0;for(let n=0;n<e.length;n++){const o=V(e[n]),r=V(u[n]);if(!o||!r)return-1;o.cho!==r.cho&&t++,o.jung!==r.jung&&t++,o.jong!==r.jong&&t++}return t}const $u="word_pair_index_v2",Hu="word_pair_index_sig_v2";let _e=null;function hn(){try{if(typeof localStorage>"u")return null;const e=localStorage.getItem($u),u=localStorage.getItem(Hu);return!e||!u?null:{index:JSON.parse(e),sig:u}}catch{return null}}function De(){if(_e)return _e;const e=hn();return e?(_e=e.index,e.sig,_e):null}function mn(){_e=null;try{typeof localStorage<"u"&&(localStorage.removeItem($u),localStorage.removeItem(Hu))}catch{}}const Gu="word_image_existence_map_v1";let Ee=null;function Yu(){if(Ee)return Ee;try{const e=typeof localStorage<"u"?localStorage.getItem(Gu):null;Ee=e?JSON.parse(e):{}}catch{Ee={}}return Ee}function pn(e,u){return`${e}_${u??1}`}function Sn(e,u){const t=Yu(),n=pn(e,u);return n in t?t[n]:void 0}function Uu(){const e=Yu(),u=Object.values(e);return u.length===0?null:{total:u.length,exists:u.filter(Boolean).length}}function yn(){Ee={};try{typeof localStorage<"u"&&localStorage.removeItem(Gu)}catch{}}const Ku=[{id:"wordData",labelKey:"settings.cache.group.wordData.label",subKey:"settings.cache.group.wordData.sub",keys:["word_data_cache","word_data_version"]},{id:"pairIndex",labelKey:"settings.cache.group.pairIndex.label",subKey:"settings.cache.group.pairIndex.sub",keys:["word_pair_index_v2","word_pair_index_sig_v2"]},{id:"imageCache",labelKey:"settings.cache.group.imageCache.label",subKey:"settings.cache.group.imageCache.sub",keys:["word_image_existence_map_v1"]}];function Wu(e){return e.reduce((u,t)=>{try{const n=localStorage.getItem(t);return u+(n?new Blob([n]).size:0)}catch{return u}},0)}function En(e){return e===0?"0 B":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(2)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}function wn(e){const{t:u}=ce.useTranslation(),[t,n]=s.useState({}),[o,r]=s.useState(null),[l,a]=s.useState(null),[i,c]=s.useState(null),g=s.useCallback(()=>{const C={};Ku.forEach(h=>{C[h.id]=Wu([...h.keys])}),n(C),typeof navigator<"u"&&navigator.storage?.estimate&&navigator.storage.estimate().then(h=>{c({usage:h.usage??0,quota:h.quota??0})}).catch(()=>{})},[]);s.useEffect(()=>{g()},[g]);const d=s.useCallback(async C=>{r(C);try{C==="wordData"?(localStorage.removeItem("word_data_cache"),localStorage.removeItem("word_data_version")):C==="pairIndex"?mn():C==="imageCache"&&yn(),g(),e?.(u("settings.cache.cleared","\uCE90\uC2DC\uAC00 \uC0AD\uC81C\uB418\uC5C8\uC2B5\uB2C8\uB2E4."))}finally{r(null)}},[g,e,u]);return{cacheSizes:t,clearingId:o,confirmCacheId:l,setConfirmCacheId:a,storageEstimate:i,refreshCacheSizes:g,handleClearCache:d}}function Bn(e){const[u,t]=s.useState(null),[n,o]=s.useState(null),r=s.useCallback(()=>{const l=De();if(l){const i=Object.values(l),c=i.filter(g=>g.cho.length+g.jung.length+g.jong.length>0).length;t({matched:c,total:i.length})}else t(null);const a=Uu();o(a?{exists:a.exists,total:a.total}:null)},[]);return s.useEffect(()=>{r();const l=setTimeout(r,1e3);return()=>clearTimeout(l)},[e?.length,r]),{pairStats:u,imgStats:n,setPairStats:t,setImgStats:o,refreshStats:r}}function Oe(e,u){if(e===u)return!0;const t=e?.id,n=u?.id;return t!=null&&t!==""&&t===n}function qu(e,u=[]){const[t,n]=s.useState(u),[o,r]=s.useState(null),[l,a]=s.useState(!1),[i,c]=s.useState(e),g=s.useRef(!1),d=s.useRef(null);s.useEffect(()=>{if(l)return;if(g.current){g.current=!1;return}const m=d.current;m!==null&&m.length===u.length&&m.every((p,E)=>p===u[E])||(d.current=u,n(u),r(p=>p==null?p:u.find(E=>Oe(E,p))??p))},[u,l]),s.useEffect(()=>{!l&&o!=null&&c({...o})},[l,o]);const C=s.useCallback(m=>{r(m),a(!1),c({...m})},[]),h=s.useCallback(()=>a(!0),[]),f=s.useCallback(()=>a(!1),[]),w=s.useCallback((m,p)=>{n(m),r(p),a(E=>(E&&(g.current=!0),!1))},[]),y=s.useCallback(m=>{n(p=>p.filter(E=>!Oe(E,m))),r(null)},[]);return{list:t,setList:n,selected:o,setSelected:r,isEditing:l,setIsEditing:a,editForm:i,setEditForm:c,openDetail:C,startEditing:h,cancelEditing:f,commitEdit:w,remove:y}}const Ne=()=>{const e=new Date;return{year:String(e.getFullYear()),month:String(e.getMonth()+1).padStart(2,"0"),day:String(e.getDate()).padStart(2,"0")}},bn={year:"",month:"",day:"",hour:"09",minute:"00",memo:""};function An(e=[]){const{list:u,setList:t,selected:n,setSelected:o,isEditing:r,setIsEditing:l,editForm:a,setEditForm:i,openDetail:c,commitEdit:g}=qu(bn,e),{year:d,month:C,day:h}=Ne(),[f,w]=s.useState({year:d,month:C,day:h,hour:"09",minute:"00",memo:""});return{visitHistory:u,visitForm:f,setVisitForm:w,setVisit:y=>m=>w(p=>({...p,[y]:m})),selectedVisit:n,setSelectedVisit:o,isEditingVisit:r,setIsEditingVisit:l,editVisitForm:a,setEditVisitForm:i,openVisitDetail:c,handleVisitSave:y=>{t(B=>[f,...B]);const{year:m,month:p,day:E}=Ne();w({year:m,month:p,day:E,hour:"09",minute:"00",memo:""}),y?.()},handleVisitEditSave:()=>{g(y=>y.map(m=>n!=null&&Oe(m,n)?a:m),a)},addVisit:y=>{t(m=>[y,...m])},removeVisit:y=>{t(m=>m.filter(p=>p!==y))},revertVisitEdit:(y,m)=>{t(p=>p.map(E=>E===m?y:E)),o(p=>p===m?y:p)}}}const zu=e=>`${e.year.padStart(4,"0")}-${e.month.padStart(2,"0")}-${e.day.padStart(2,"0")} ${e.hour.padStart(2,"0")}:${e.minute.padStart(2,"0")}`,Ye=e=>[...e].sort((u,t)=>{const n=zu(u),o=zu(t);return n<o?-1:n>o?1:0}),_n={year:"",month:"",day:"",hour:"09",minute:"00",memo:""};function Dn(e,u=[]){const t=s.useMemo(()=>Ye(u),[u]),{list:n,setList:o,selected:r,setSelected:l,isEditing:a,setIsEditing:i,editForm:c,setEditForm:g,openDetail:d,commitEdit:C,remove:h}=qu(_n,t),[f,w]=s.useState([]),{year:y,month:m,day:p}=Ne(),[E,B]=s.useState({year:y,month:m,day:p,hour:"09",minute:"00",memo:""}),_=M=>k=>B(H=>({...H,[M]:k})),b=M=>{o(ee=>Ye([...ee,E]));const{year:k,month:H,day:U}=Ne();B({year:k,month:H,day:U,hour:"09",minute:"00",memo:""}),M?.()},O=()=>{C(M=>Ye(M.map(k=>r!=null&&Oe(k,r)?c:k)),c)},T=s.useCallback(M=>{h(M)},[h]),L=s.useCallback(M=>{e({year:M.year,month:M.month,day:M.day,hour:M.hour,minute:M.minute,memo:M.memo,...M.id!=null?{id:M.id}:{}}),h(M)},[e,h]),D=s.useCallback(M=>{o(k=>k.filter(H=>!Oe(H,M))),w(k=>[M,...k]),l(null)},[o,l]),$=s.useCallback(M=>{o(k=>Ye([...k,M]))},[o]),G=s.useCallback(M=>{o(k=>k.filter(H=>H!==M))},[o]),Y=s.useCallback((M,k)=>{o(H=>H.map(U=>U===k?M:U)),l(H=>H===k?M:H)},[o,l]);return{scheduleList:n,noShowList:f,addSchedule:$,removeSchedule:G,revertScheduleEdit:Y,scheduleForm:E,setScheduleForm:B,setSchedule:_,selectedSchedule:r,setSelectedSchedule:l,isEditingSchedule:a,setIsEditingSchedule:i,editScheduleForm:c,setEditScheduleForm:g,openScheduleDetail:d,handleScheduleSave:b,handleScheduleEditSave:O,handleScheduleDelete:T,handleScheduleToVisit:L,handleScheduleNoVisit:D}}const Ue=[{value:"10",label:"10\uAC1C\uC529 \uBCF4\uAE30"},{value:"25",label:"25\uAC1C\uC529 \uBCF4\uAE30"},{value:"50",label:"50\uAC1C\uC529 \uBCF4\uAE30"},{value:"100",label:"100\uAC1C\uC529 \uBCF4\uAE30"}];function On(e){const{t:u}=ce.useTranslation(),[t,n]=s.useState(""),[o,r]=s.useState("25"),[l,a]=s.useState("all"),[i,c]=s.useState(1),g=s.useMemo(()=>e.filter(({item:w,status:y})=>!(t&&!w.memo.includes(t)||l!=="all"&&y!==l)),[e,t,l]),d=Math.max(1,Math.ceil(g.length/Number(o))),C=Math.min(i,d),h=s.useMemo(()=>g.slice((C-1)*Number(o),C*Number(o)),[g,C,o]),f=s.useMemo(()=>Ue.map(w=>({...w,label:u("common.pageSizeLabel",{n:w.value,defaultValue:w.label})})),[u]);return{vapSearch:t,setVapSearch:n,vapPageSize:o,setVapPageSize:r,vapPageSizeOptions:f,vapStatus:l,setVapStatus:a,vapPage:C,setVapPage:c,vapFiltered:g,vapTotal:d,vapPageItems:h}}function Nn(e,u,t){const{t:n}=ce.useTranslation(),[o,r]=s.useState(()=>{const f=t?.initialPageSize;return f&&Ue.some(w=>w.value===f)?f:"25"}),[l,a]=s.useState(1),[i,c]=s.useState(u);i!==u&&(c(u),l!==1&&a(1));const g=s.useMemo(()=>Ue.map(f=>({...f,label:n("visits.showN",{n:f.value})})),[n]),d=s.useCallback(f=>{r(f),a(1)},[]),C=Math.max(1,Math.ceil(e.length/Number(o)));l>C&&a(C);const h=Math.min(l,C);return{pageRows:s.useMemo(()=>e.slice((h-1)*Number(o),h*Number(o)),[e,h,o]),pageSizeProps:{options:g,value:o,onChange:d},paginationProps:{page:h,total:C,onChange:a},setPage:a}}function Tn(){const[e,u]=s.useState(null),t=s.useCallback(o=>{u(r=>r?.key===o?{key:o,asc:!r.asc}:{key:o,asc:!0})},[]),n=s.useCallback((o,r)=>({label:o,sortDir:e?.key===r?e.asc?"asc":"desc":null,onClick:()=>t(r)}),[e,t]);return{\uC815\uB82C:e,\uCE78:n}}const Ju=e=>e==="\uC88C"||e==="\uC6B0"?e:null;function jn(){const[e,u]=s.useState(!1),[t,n]=s.useState("\uC88C"),[o,r]=s.useState({\uC88C:null,\uC6B0:null}),[l,a]=s.useState({\uC88C:[],\uC6B0:[]}),[i,c]=s.useState(!1),[g,d]=s.useState("\uC88C"),C=s.useCallback(f=>{const w=Ju(f.direction);w&&(r(y=>({...y,[w]:f})),a(y=>({...y,[w]:[f,...y[w]]})),u(!1))},[]),h=s.useCallback(f=>{const w=Ju(f.direction);w&&(r(y=>({...y,[w]:f})),c(!1))},[]);return{showDevice:e,setShowDevice:u,deviceDirection:t,setDeviceDirection:n,devices:o,setDevices:r,deviceHistory:l,setDeviceHistory:a,showDeviceList:i,setShowDeviceList:c,listForSide:g,setListForSide:d,handleDeviceSubmit:C,handleSelectFromList:h}}const In="__ihab_core_word_pool__";function Ke(){return globalThis[In]??null}function F(e,u=Math.random){const t=e.slice();for(let n=t.length-1;n>0;n--){const o=Math.floor(u()*(n+1));[t[n],t[o]]=[t[o],t[n]]}return t}function ae(e,u,t=Math.random){return!Array.isArray(e)||e.length===0||u<=0?[]:u>=e.length?F(e,t):F(e,t).slice(0,u)}const Cu={SAME_SOUND_PICK:{difficulty:!0,choseong:!0,group:"discrimination"},SAME_OR_DIFF:{difficulty:!0,choseong:!0,group:"discrimination"},HEAR_AND_PICK_SAME:{difficulty:!0,choseong:!0,group:"discrimination"},HEAR_AND_PICK_INCLUDED:{difficulty:!0,choseong:!0,group:"discrimination"},STARTS_WITH_SAME_SOUND:{difficulty:!1,choseong:!0,group:"discrimination"},LISTEN_AND_REMEMBER_ORDER:{difficulty:!1,choseong:!0,group:"attention"},MERGE_2_SYLLABLES:{difficulty:!1,choseong:!0,group:"synthesis"},MERGE_3_SYLLABLES:{difficulty:!1,choseong:!0,group:"synthesis"},MERGE_2_PHONEMES:{difficulty:!1,choseong:!0,group:"synthesis"},MERGE_3_PHONEMES:{difficulty:!1,choseong:!0,group:"synthesis"},DROP_1_FROM_2SYLL:{difficulty:!1,choseong:!0,group:"deletion"},DROP_1_FROM_3SYLL:{difficulty:!1,choseong:!0,group:"deletion"},DROP_PART_FROM_COMPOUND:{difficulty:!1,choseong:!0,group:"deletion"},DROP_FINAL_CONSONANT_FROM_1SYLL:{difficulty:!1,choseong:!0,group:"deletion"},REMOVE_CONSONANT_AND_IDENTIFY_PHONEME:{difficulty:!1,choseong:!0,group:"deletion"},CHANGE_1_SYLL_IN_2SYLL:{difficulty:!0,choseong:!0,group:"substitution"},CHANGE_1_SYLL_IN_3SYLL:{difficulty:!0,choseong:!0,group:"substitution"},CHANGE_1_PHONEME_IN_1SYLL:{difficulty:!1,choseong:!0,group:"substitution"},CHANGE_1_PHONEME_IN_2SYLL:{difficulty:!0,choseong:!0,group:"substitution"}},Rn=z.indexOf("\u3147"),Qu={DROP_FINAL_CONSONANT_FROM_1SYLL:{syllables:1,syllable:e=>e.jong>0},REMOVE_CONSONANT_AND_IDENTIFY_PHONEME:{syllables:1,syllable:e=>e.jong===0&&e.cho!==Rn},MERGE_2_SYLLABLES:{syllables:2,syllable:()=>!0},MERGE_3_SYLLABLES:{syllables:3,syllable:()=>!0},MERGE_2_PHONEMES:{syllables:1,syllable:e=>e.jong===0},MERGE_3_PHONEMES:{syllables:1,syllable:e=>e.jong>0}},Mn={\u3131:"\u3131",\u3132:"\u3131",\u314B:"\u3131",\u3133:"\u3131",\u313A:"\u3131",\u3134:"\u3134",\u3135:"\u3134",\u3136:"\u3134",\u3137:"\u3137",\u3145:"\u3137",\u3146:"\u3137",\u3148:"\u3137",\u314A:"\u3137",\u314C:"\u3137",\u314E:"\u3137",\u3139:"\u3139",\u313C:"\u3139",\u313D:"\u3139",\u313E:"\u3139",\u3140:"\u3139",\u3141:"\u3141",\u313B:"\u3141",\u3142:"\u3142",\u314D:"\u3142",\u313F:"\u3142",\u3144:"\u3142",\u3147:"\u3147"},Ln={\u314F:{nucleus:"\u314F"},\u3151:{glide:"j",nucleus:"\u314F"},\u3153:{nucleus:"\u3153"},\u3155:{glide:"j",nucleus:"\u3153"},\u3157:{nucleus:"\u3157"},\u315B:{glide:"j",nucleus:"\u3157"},\u315C:{nucleus:"\u315C"},\u3160:{glide:"j",nucleus:"\u315C"},\u3161:{nucleus:"\u3161"},\u3163:{nucleus:"\u3163"},\u3150:{nucleus:"\u3154/\u3150"},\u3152:{glide:"j",nucleus:"\u3154/\u3150"},\u3154:{nucleus:"\u3154/\u3150"},\u3156:{glide:"j",nucleus:"\u3154/\u3150"},\u3158:{glide:"w",nucleus:"\u314F"},\u3159:{glide:"w",nucleus:"\u3154/\u3150"},\u315A:{glide:"w",nucleus:"\u3154/\u3150"},\u315D:{glide:"w",nucleus:"\u3153"},\u315E:{glide:"w",nucleus:"\u3154/\u3150"},\u315F:{glide:"w",nucleus:"\u3163"},\u3162:{glide:"\u0270",nucleus:"\u3163"}};function du(e){return Mn[e]??e}const fu={cho:z,jung:ne,jong:ue},W=e=>Array.isArray(e)?e.length>0:!!e;function gu(e,u){if(e.length!==u.length)return!1;for(let t=0;t<e.length;t++){const n=e[t],o=u[t];if(!(!n||!o)&&(n.cho!==o.cho&&z[n.cho]==="\u3147"!=(z[o.cho]==="\u3147")||n.jong!==o.jong&&n.jong===0!=(o.jong===0)))return!0}return!1}function vn(e,u,t){const n=t.pronOf(e),o=t.decompOf,r=t.sameStructureOnly&&o?o(n):null,l=[];for(const a of u)a!==e&&(t.okSet&&!t.okSet.has(a)||t.pronOf(a)!==n&&(r&&o&&gu(r,o(t.pronOf(a)))||l.push(a)));return l}function Zu(e,u,t){const n=u?.[e];if(!n)return[];const o=t.kind?n[t.kind]??[]:[...n.cho??[],...n.jung??[],...n.jong??[]];return vn(e,o,t)}function kn(e,u,t,n,o,r,l){const a=["cho","jung","jong"].filter(C=>W(e[C])),i={};for(const C of a){const h=e[C];i[C]=new Set(Array.isArray(h)?h:[h])}const c=o==="pron",g=new Map;for(const C of u){const h=t(r(C));if(h.some(m=>!m))continue;let f=h;if(!c&&(f=t(C),f.length!==h.length||f.some(m=>!m)))continue;const w=h.length,y=g.get(w);y?y.push({w:C,dPron:h,dPos:f}):g.set(w,[{w:C,dPron:h,dPos:f}])}const d=new Map;for(const[C,h]of g){const f=new Map,w=(y,m)=>{const p=y.dPos[m];return p!=null&&a.every(E=>i[E].has(fu[E][p[E]]))};for(const y of h){let m;if(l==="head")m=w(y,0)?0:-1;else if(l==="tail")m=w(y,C-1)?C-1:-1;else if(l==="mid"){m=-1;for(let E=1;E<C-1;E++)if(w(y,E)){m=E;break}}else m=y.dPos.findIndex(E=>E!=null&&a.every(B=>i[B].has(fu[B][E[B]])));if(m<0)continue;const p=f.get(m);p?p.push(y):f.set(m,[y])}for(const[y,m]of f){const p=new Set(a.map(_=>y+":"+_)),E=_=>{let b="";for(let O=0;O<C;O++){const T=_[O];for(const L of["cho","jung","jong"])b+=(p.has(O+":"+L)?"*":T[L])+"."}return b},B=new Map;for(const _ of h){const b=E(_.dPron),O=B.get(b);O?O.push(_):B.set(b,[_])}for(const _ of m){const b=B.get(E(_.dPron))??[],O=[];for(const T of b){if(T.w===_.w)continue;let L=!0;for(const D of a){const $=_.dPron[y][D],G=T.dPron[y][D];if(G===$){L=!1;break}if(c&&i[D].has(fu[D][G])){L=!1;break}}L&&(n&&gu(_.dPron,T.dPron)||O.push(T.w))}d.set(_.w,O)}}}return d}const Pn=e=>e==null?[]:Array.isArray(e)?e:[e];function xn(e){if([...e].length!==1)return"";const u=V(e);if(!u)return"";const t=du(ue[u.jong]),n=t===""?0:ue.indexOf(t);return Ce(u.cho,u.jung,n<0?0:n)}function Xu(e,u){return u.get(e)||xn(e)||e}function hu(e){return e?W(e.cho)?"cho":W(e.jung)?"jung":W(e.jong)?"jong":null:null}function we(e,u){const t=(n,o)=>!W(n)||Pn(n).includes(o);return t(u.cho,z[e.cho])&&t(u.jung,ne[e.jung])&&t(u.jong,ue[e.jong])}function Te(e,u,t){const n=[...e];if(t!=="pron")return n.map(r=>V(r));const o=[...u.get(e)||e];return o.length!==n.length?n.map(r=>V(r)):o.map(r=>V(r))}function je(e,u,t,n,o){const r=u==="cho"?z:u==="jung"?ne:ue,l=e[u],a=[],i=d=>u==="jung"?Vn(Xu(d,o)):Xu(d,o),c=new Map([[i(t),-1]]),g=F(r.map((d,C)=>C).filter(d=>d!==l&&(u!=="cho"||r[d]!=="\u3147")&&(u!=="jong"||d!==0)));for(const d of g){if(a.length>=n)break;const C=u==="cho"?Ce(d,e.jung,e.jong):u==="jung"?Ce(e.cho,d,e.jong):Ce(e.cho,e.jung,d),h=i(C),f=c.get(h);if(f!==void 0){u==="jung"&&f>=0&&o.has(C)&&!o.has(a[f])&&(a[f]=C);continue}c.set(h,a.length),a.push(C)}return a}const Fn={\u3154:"\u3150",\u3156:"\u3152",\u315A:"\u3159",\u315E:"\u3159"};function Vn(e){if([...e].length!==1)return e;const u=V(e);if(!u)return e;const t=Fn[ne[u.jung]];return t?Ce(u.cho,ne.indexOf(t),u.jong):e}function $n(e,u,t,n,o,r=null){const l=[...e];if(l.length!==2)return null;const a=l.map(d=>V(d));if(a.some(d=>!d))return null;const i=Te(e,t,n);if(i.some(d=>!d))return null;const c=hu(u);let g=c&&u?i.map((d,C)=>we(d,u)?C:-1).filter(d=>d>=0):[0,1];if(r!=null&&(g=g.filter(d=>d!==r)),!g.length)return null;for(const d of F(g)){const C=l[d];if(!o.has(C))continue;const h=je(a[d],c??"cho",C,40,t),f=[];for(const w of h)if(w!==C&&o.has(w)&&!f.includes(w)&&f.push(w),f.length>=2)break;if(!(f.length<2))return{question:e,distractors:[C,...f]}}return null}function Hn(e,u,t,n,o,r=null){const l=[...e];if(l.length!==3)return null;const a=l.map(d=>V(d));if(a.some(d=>!d))return null;const i=Te(e,t,n);if(i.some(d=>!d))return null;const c=hu(u),g=c&&u?i.map((d,C)=>we(d,u)?C:-1).filter(d=>d>=0):[0,1,2];if(!g.length)return null;for(const d of F(g))for(const C of F([0,1,2].filter(h=>h!==d&&(r==null||h===r)))){const h=[0,1,2].filter(p=>p!==C),f=h.map(p=>l[p]).join("");if(!o.has(f))continue;const w=h.indexOf(d),y=je(a[d],c??"cho",l[d],40,t),m=[];for(const p of y){const E=h.map(_=>l[_]);E[w]=p;const B=E.join("");if(B!==f&&o.has(B)&&!m.includes(B)&&m.push(B),m.length>=2)break}if(!(m.length<2))return{question:e,distractors:[f,...m]}}return null}function Gn(e,u,t,n,o,r=null){const l=[...e],a=l.length;if(a<2)return null;const i=[];for(let g=1;g<=a-1;g++)i.push({remain:l.slice(0,g).join(""),dropped:l.slice(g).join(""),droppedEnd:1}),i.push({remain:l.slice(a-g).join(""),dropped:l.slice(0,a-g).join(""),droppedEnd:0});const c=hu(u);for(const{remain:g,dropped:d,droppedEnd:C}of F(i)){if(r!=null&&C!==r||g===e||!o.has(g)||!o.has(d))continue;const h=[...g],f=h.map(m=>V(m));if(f.some(m=>!m))continue;const w=Te(g,t,n);if(w.some(m=>!m))continue;const y=c&&u?w.map((m,p)=>we(m,u)?p:-1).filter(m=>m>=0):h.map((m,p)=>p);if(y.length)for(const m of F(y)){const p=je(f[m],c??"cho",h[m],40,t),E=[];for(const B of p){const _=[...h];_[m]=B;const b=_.join("");if(b!==g&&o.has(b)&&!E.includes(b)&&E.push(b),E.length>=2)break}if(E.length>=2)return{question:e,distractors:[g,...E]}}}return null}function Yn(e,u,t,n,o,r=null){if([...e].length!==1)return null;const l=V(t.get(e)||e);if(!l||l.jong===0)return null;const a=Ce(l.cho,l.jung,0),i=je({cho:l.cho,jung:l.jung,jong:0},"cho",a,2,t);return i.length<2?null:{question:e,distractors:[a,...i]}}const mu=z.indexOf("\u3147");function Un(e,u,t,n,o,r=null){if([...e].length!==1)return null;const l=V(t.get(e)||e);if(!l||l.jong!==0||l.cho===mu)return null;const a=Ce(mu,l.jung,0),i=je({cho:mu,jung:l.jung,jong:0},"jung",a,2,t);return i.length<2?null:{question:e,distractors:[a,...i]}}function Kn(e){const u=new Map;for(const t of e){const n=[...t],o=n.length;if(!(o<2||o>3))for(let r=0;r<o;r++){let l=o+"|"+r+"|";for(let i=0;i<o;i++)l+=i===r?"*":n[i];const a=u.get(l);a?a.push(t):u.set(l,[t])}}return u}function Wn(e,u,t,n,o,r=null,l=null,a=2){const i=[...e],c=i.length;if(c<2||c>3)return null;const g=i.map(p=>V(p));if(g.some(p=>!p))return null;const d=Te(e,t,n);if(d.some(p=>!p))return null;const C=p=>t.get(p)??p,h=C(e),f=!!u&&(W(u.cho)||W(u.jung)||W(u.jong)),w=!!l&&(W(l.cho)||W(l.jung)||W(l.jong)),y=p=>{let E=c+"|"+p+"|";for(let B=0;B<c;B++)E+=B===p?"*":i[B];return E};let m;if(r!=null){if(r>=c||f&&!we(d[r],u))return null;m=[r]}else f?m=d.map((p,E)=>we(p,u)?E:-1).filter(p=>p>=0):m=Array.from({length:c},(p,E)=>E);for(const p of F(m)){const E=o.get(y(p))??[],B=[],_=[];for(const D of E){if(D===e)continue;const $=[...D].map(k=>V(k)),G=g[p],Y=$[p];if(!G||!Y)continue;let M=0;if(G.cho!==Y.cho&&M++,G.jung!==Y.jung&&M++,G.jong!==Y.jong&&M++,!(M<a||C(D)===h))if(w){const k=Te(D,t,n)[p];k&&we(k,l)?B.push(D):_.push(D)}else B.push(D)}if(!B.length)continue;const b=F(B)[0],O=[],T=new Set([h,C(b)]),L=w?_:B.filter(D=>D!==b);for(const D of F(L)){const $=C(D);if(!T.has($)&&(T.add($),O.push(D),O.length>=2))break}if(!w&&O.length<2)for(const D of F(E)){if(D===e||D===b)continue;const $=C(D);if(!T.has($)&&(T.add($),O.push(D),O.length>=2))break}if(!(O.length<2))return{question:e,distractors:[b,...O]}}return null}let We=null,et=null,ut=null;function qn(){const e=Ke();if(e&&e.entries.length>0){const u=De();if(We&&et===e&&ut===u)return We;const t=new Set,n=[];for(const o of e.entries)!o.word||t.has(o.word)||(t.add(o.word),n.push({w:o.word,s:o.syllables,p:u?.[o.word]?[...u[o.word].cho??[],...u[o.word].jung??[],...u[o.word].jong??[]]:[],pron:o.pronunciation||o.word,grade:o.grade}));return We=n,et=e,ut=u,We}return[]}const oe=new Proxy([],{get(e,u){const t=qn(),n=t[u];return typeof n=="function"?n.bind(t):n}});function pu(e){return e.length?e[Math.floor(Math.random()*e.length)]:void 0}function te(e,u){if(u>=e.length)return F(e);if(u===0)return[];const t=e.slice();for(let n=0;n<u;n++){const o=n+Math.floor(Math.random()*(t.length-n)),r=t[n];t[n]=t[o],t[o]=r}return t.slice(0,u)}let Su=null,tt=null;function de(){const e=Ke();if(Su&&tt===e)return Su;const u=new Map;for(const t of oe)t.w&&u.set(t.w,t.pron);return Su=u,tt=e,u}function Z(e){return de().get(e)||e}function qe(e,u,t=new Set){const n=[];for(const o of F(e)){if(n.length>=u)break;const r=Z(o);t.has(r)||(t.add(r),n.push(o))}return n}let zn=0;function J(e){return`${e}-rt-${++zn}`}function Ie(e){const u=Uu();if(!u||u.total===0){const n=new Set;for(const o of e)n.add(o);return n}const t=new Set;for(const n of e)Sn(n)===!0&&t.add(n);return t}const ze=new Map;let nt=null,ot=null;function Re(e){return e==null?"":Array.isArray(e)?e.slice().sort().join(","):e}function rt(e){const u=Re(e.choseong),t=e.composition,n=t?.syllable==null?"":Array.isArray(t.syllable)?t.syllable.slice().sort().join(","):String(t.syllable),o=t?`${Re(t.cho)}/${Re(t.jung)}/${Re(t.jong)}/${t.jongNone?"N":""}/${n}`:"",r=Re(e.grade);return`${e.difficulty??""}|${u}|${o}|${e.excludeNoImage?"1":"0"}|${e.count??""}|x${e.contrastCount??1}|${e.fullCount?"F":""}|s${e.sameStructureOnly===!1?"0":"1"}|v${e.phonemeView==="pron"?"p":"c"}|g${r}|t${e.targetSyllable??""}|c${e.choicesPerItem??""}`}async function X(e){const u=Ke(),t=De();(u!==nt||t!==ot)&&(ze.clear(),nt=u,ot=t);const n=rt(e);return ze.has(n)||ze.set(n,Jn(e)),ze.get(n)}function lt(e){if(!e)return null;const u=l=>l==null?null:Array.isArray(l)?l.length?l:null:[l],t=u(e.cho),n=u(e.jung),o=!!e.jongNone,r=o?null:u(e.jong);return t||n||r||o?o&&!t&&!n&&!r?l=>sn(l):l=>Cn(l,{cho:t,jung:n,jong:r,jongNone:o}):null}function at(e){const u=e.grade&&e.grade.length>0?new Set(e.grade):null,t=e.composition??null,n=t?.syllable!=null?new Set(Array.isArray(t.syllable)?t.syllable:[t.syllable]):null,o=t?[lt(t),n?l=>n.has(Ae(l)):null].filter(l=>l!=null):[];if(!u&&o.length===0)return null;const r=e.phonemeView==="pron";return l=>{if(u&&(!l.grade||!u.has(l.grade)))return!1;if(o.length===0)return!0;const a=r?Z(l.w):l.w;return o.every(i=>i(a))}}async function Jn(e){const{difficulty:u=null,choseong:t=null,composition:n=null,targetSyllable:o=null,excludeNoImage:r=!1}=e,l=e.grade&&e.grade.length>0?new Set(e.grade):null,a=e.sameStructureOnly??!0,i=e.phonemeView==="pron"?"pron":"char",c=Math.max(1,e.contrastCount??1),g=u==="cho"||u==="jung"||u==="jong",d=g&&c>=2,C=u==="count",h=t?new Set(Array.isArray(t)?t:[t]):null,f=n?.syllable!=null?new Set(Array.isArray(n.syllable)?n.syllable:[n.syllable]):null,w=n?[lt(n),f?A=>f.has(Ae(A)):null].filter(A=>A!=null):[],y=u==="random"||u===null,m=y||C,p=y||d||C;let E=oe.filter(A=>!A.w||l&&(!A.grade||!l.has(A.grade))?!1:p?!0:Array.isArray(A.p)&&A.p.length>0);h&&(E=E.filter(A=>{for(const N of h)if(an(A.w,N))return!0;return!1})),w.length>0&&(E=E.filter(A=>{const N=i==="pron"?Z(A.w):A.w;return w.every(R=>R(N))})),o&&(E=E.filter(A=>A.w[0]===o));let B;if(r){const A=new Set;for(const N of E)if(A.add(N.w),Array.isArray(N.p))for(const R of N.p)A.add(R);if(m)for(const N of oe)N.w&&A.add(N.w);B=Ie(A)}else{const A=new Set;for(const N of E)if(A.add(N.w),Array.isArray(N.p))for(const R of N.p)A.add(R);if(m)for(const N of oe)N.w&&A.add(N.w);B=A}let _=null;if(d){const A=new Set;for(const N of oe)N.w&&A.add(N.w);_=r?Ie(A):A}const b=E.filter(A=>B.has(A.w)),O=600,T=Array.from(B),L=T.length>O?te(T,O):T,D=C&&n!=null&&(W(n.cho)||W(n.jung)||W(n.jong)),$=2500,G=new Map;if(C&&!D&&c>=2){for(const A of T){const N=Ae(A),R=G.get(N);R?R.push(A):G.set(N,[A])}for(const[A,N]of G)N.length>$&&G.set(A,te(N,$))}const Y=rn(),M=D?kn(n,T,Y,a,i,Z):null,k=500,H=1500,U=e.fullCount?b:u==="random"?b.length>k?te(b,k):b:b.length>H?te(b,H):b,ee=De(),me=[];for(const A of U){let N;const R=Z(A.w);if(d)N=fn(A.w,u,c,_,24).filter(x=>Z(x)!==R);else if(C)D?N=(M.get(A.w)??[]).filter(x=>Z(x)!==R):c<=1?N=Zu(A.w,ee,{okSet:B,pronOf:Z,decompOf:Y,sameStructureOnly:!1}):N=(G.get(Ae(A.w))??[]).filter(x=>{if(x===A.w||Z(x)===R)return!1;const Q=gn(A.w,x);return c>=5?Q>=5:Q===c});else if(y)N=L.filter(x=>x!==A.w&&x.length===A.w.length&&Z(x)!==R);else{const x=u;N=Zu(A.w,ee,{kind:x,okSet:B,pronOf:Z,decompOf:Y,sameStructureOnly:!1}),N.length===0&&(N=(L.length>30?te(L,30):L).filter(Q=>Q!==A.w&&ln(A.w,Q)===u&&Z(Q)!==R))}if(a&&N.length>0&&(g||C&&!D)){const x=Y(Z(A.w));N=N.filter(Q=>!gu(x,Y(Z(Q))))}N.length!==0&&me.push({word:A,usable:N})}return me}async function st(e,u){const{choicesPerItem:t=3,count:n=10}=u,o=t-1,r=(await X(u)).filter(a=>a.usable.length>=o),l=[];for(const a of F(r)){if(l.length>=n)break;const i=qe(a.usable,o);if(i.length<o)continue;const c=F([a.word.w,...i]);l.push({id:J(e+"-item"),index:l.length+1,word:a.word.w,syllables:a.word.s,choices:c,answerIndex:c.indexOf(a.word.w)})}return l}async function Qn(e){const{choicesPerItem:u=3,count:t=10}=e,n=u-1,o=await X({...e,difficulty:null});if(o.length<u)return[];const r=[],l=F([...o]);for(const a of l){if(r.length>=t)break;const i=a.word.w,c=[...a.word.pron||i],g=pu(c);if(!g)continue;const d=o.filter(f=>f.word.w!==i&&f.word.s===a.word.s&&!(f.word.pron||f.word.w).includes(g)&&f.word.pron!==a.word.pron);if(d.length<n)continue;const C=qe(d.map(f=>f.word.w),n);if(C.length<n)continue;const h=F([i,...C]);r.push({id:J("HPI-item"),index:r.length+1,targetSyllable:g,word:i,choices:h,answerIndex:h.indexOf(i)})}return r}async function Zn(e){const{count:u=10}=e,t=(await X(e)).filter(r=>r.usable.length>=1);if(!t.length)return[];const n=t.length>=u?te(t,u):F(Array.from({length:u},(r,l)=>t[l%t.length])),o=F(Array.from({length:u},(r,l)=>l<Math.ceil(u/2)));return n.map((r,l)=>{const a=o[l];let i;if(a)i=[r.word.w,r.word.w];else{const c=pu(r.usable);i=Math.random()<.5?[r.word.w,c]:[c,r.word.w]}return{id:J("SOD-item"),index:l+1,word:r.word.w,pair:i,same:a}})}async function Xn(e){const{choicesPerItem:u=3,count:t=10}=e,n=u-1,o=await X({...e,difficulty:null});if(o.length<u+1)return[];const r=o.map(C=>C.word.w),l=new Map(o.map(C=>[C.word.w,C.word.pron])),a=C=>(l.get(C)||C)[0]??"",i={};for(const C of o){const h=a(C.word.w);h&&(i[h]||(i[h]=[]),i[h].push(C.word.w))}const c=Object.entries(i).filter(([,C])=>C.length>=2).map(([C])=>C);if(c.length===0)return[];const g=[],d=F([...c]);for(let C=0;g.length<t&&C<t*4;C++){const h=d[C%d.length],f=i[h];if(f.length<2)continue;const w=F([...f]),y=w[0],m=w[1];if(!y||!m||y===m||(l.get(y)||y)===(l.get(m)||m))continue;const p=l.get(m)||m,E=r.filter(b=>a(b)!==h&&b!==y&&b!==m&&b.length===m.length&&(l.get(b)||b)!==p);if(E.length<n)continue;const B=qe(E,n);if(B.length<n)continue;const _=F([m,...B]);g.push({id:J("SWS-item"),index:g.length+1,sourceWord:y,targetSyllable:h,word:m,choices:_,answerIndex:_.indexOf(m)})}return g}function it(e,u,t){const n=de(),o=a=>n.get(a)||a,r=(a,i)=>{const c=[...a],g=[...i];if(c.length!==g.length)return-1;let d=-1;for(let C=0;C<c.length;C++)if(c[C]!==g[C]){if(d>=0)return-1;d=C}return d},l=e.map(a=>({e:a,swaps:a.usable.filter(i=>!!i&&r(a.word.w,i)>=0&&o(i)!==o(a.word.w))})).filter(a=>a.swaps.length>0);return te(l,u).map(({e:a,swaps:i},c)=>{const g=pu(i)??"",d=[...a.word.w],C=[...g],h=r(a.word.w,g),f=qe(a.usable.filter(w=>w&&w!==g),2,new Set([o(g),o(a.word.w)]));return{id:J(t),index:c+1,word:a.word.w,original:a.word.w,changed:g,changedFrom:h>=0?d[h]:"",changedTo:h>=0?C[h]:"",distractors:f}})}async function ct(e,u,t){const{count:n=10}=u,o=de(),r=oe.filter(f=>f.w&&f.s===e),l=u.excludeNoImage?Ie(r.map(f=>f.w)):null,a=l?r.filter(f=>l.has(f.w)):r,i=new Set(a.map(f=>f.w)),c=Kn(i),g=u.phonemeView??"char",d=u.composition??null,C=at({grade:u.grade}),h=[];for(const f of F(a)){if(h.length>=n)break;if(C&&!C(f))continue;const w=Wn(f.w,d,o,g,c,null,null);if(!w)continue;const y=w.distractors[0],m=[...f.w],p=[...y],E=m.findIndex((B,_)=>B!==p[_]);h.push({id:J(t),index:h.length+1,word:f.w,original:f.w,changed:y,changedFrom:E>=0?m[E]:"",changedTo:E>=0?p[E]:"",distractors:w.distractors.slice(1)})}return h}async function eo(e){return ct(2,e,"CS2-item")}async function uo(e){return ct(3,e,"CS3-item")}async function to(e){const u=(await X({...e,difficulty:"count",contrastCount:1})).filter(t=>t.word.s===1&&t.usable.length>=1);return it(u,e.count??10,"CP1-item")}async function no(e){const u=e.difficulty&&e.difficulty!=="random"?e.difficulty:"count",t=(await X({...e,difficulty:u,contrastCount:1})).filter(n=>n.word.s===2&&n.usable.length>=1);return it(t,e.count??10,"CP2-item")}async function oo(e){const{count:u=10}=e,t=(await X({...e})).filter(n=>n.word.s===2);return te(t,u).map((n,o)=>({id:J("M2S-item"),index:o+1,word:n.word.w,answer:n.word.w,parts:[...n.word.w]}))}async function ro(e){const{count:u=10}=e,t=(await X({...e})).filter(n=>n.word.s===3);return te(t,u).map((n,o)=>({id:J("M3S-item"),index:o+1,word:n.word.w,answer:n.word.w,parts:[...n.word.w]}))}async function lo(e){const{count:u=10}=e,t=(await X({...e})).filter(a=>a.word.s===2),n=de(),o=new Set(oe.map(a=>a.w)),r=e.phonemeView??"char",l=[];for(const a of F(t)){if(l.length>=u)break;const i=$n(a.word.w,e.composition??null,n,r,o);if(!i)continue;const[c,...g]=i.distractors,d=[...a.word.w],C=d[0]===c?d[1]:d[0];l.push({id:J("D2-item"),index:l.length+1,original:a.word.w,word:a.word.w,dropped:C,missingResult:c,distractors:g})}return l}async function ao(e){const{count:u=10}=e,t=(await X({...e})).filter(a=>a.word.s===3),n=de(),o=new Set(oe.map(a=>a.w)),r=e.phonemeView??"char",l=[];for(const a of F(t)){if(l.length>=u)break;const i=Hn(a.word.w,e.composition??null,n,r,o);if(!i)continue;const[c,...g]=i.distractors,d=[...a.word.w];let C="";for(let h=0;h<d.length;h++)if(d.filter((f,w)=>w!==h).join("")===c){C=d[h];break}l.push({id:J("D3-item"),index:l.length+1,original:a.word.w,word:a.word.w,dropped:C,missingResult:c,distractors:g})}return l}async function so(e){const{count:u=10}=e,t=(await X({...e})).filter(a=>a.word.s>=2),n=de(),o=new Set(oe.map(a=>a.w)),r=e.phonemeView??"char",l=[];for(const a of F(t)){if(l.length>=u)break;const i=Gn(a.word.w,e.composition??null,n,r,o);if(!i)continue;const[c,...g]=i.distractors,d=a.word.w,C=d.startsWith(c)?d.slice(c.length):d.endsWith(c)?d.slice(0,d.length-c.length):"";l.push({id:J("DPC-item"),index:l.length+1,original:d,word:d,dropped:C,missingResult:c,distractors:g})}return l}async function io(e){const{count:u=10}=e,t=(await X({...e})).map(n=>n.word.w);return t.length<3?[]:Array.from({length:u},(n,o)=>{const r=te(t,3);return{id:J("LRO-item"),index:o+1,sequence:r,choices:F(r)}})}function Je(e,u,t){const n=oe.filter(a=>a.w&&a.s===e),o=u.excludeNoImage?Ie(n.map(a=>a.w)):null,r=at(u),l=[];for(const a of n)if(!(o&&!o.has(a.w))&&!(r&&!r(a))){if(t){const i=V(a.w);if(!i||!t(i))continue}l.push(a)}return l}function co(e){const u=Je(1,e,t=>t.jong===0);return te(u,e.count??10).map((t,n)=>{const o=V(t.w);return{id:J("M2P-item"),index:n+1,parts:[z[o.cho],ne[o.jung]],answer:t.w,word:t.w}})}function Co(e){const u=Je(1,e,t=>t.jong>0&&!be[t.jong]);return te(u,e.count??10).map((t,n)=>{const o=V(t.w);return{id:J("M3P-item"),index:n+1,parts:[z[o.cho],ne[o.jung],ue[o.jong]],answer:t.w,word:t.w}})}function fo(e){const u=Qu.DROP_FINAL_CONSONANT_FROM_1SYLL,t=Je(u.syllables,e,u.syllable),n=de(),o=[];for(const r of F(t)){if(o.length>=(e.count??10))break;const l=Yn(r.w,null,n);if(!l)continue;const[a,...i]=l.distractors;o.push({id:J("DFC-item"),index:o.length+1,original:r.w,word:r.w,result:a,distractors:i})}return o}function go(e){const u=Qu.REMOVE_CONSONANT_AND_IDENTIFY_PHONEME,t=Je(u.syllables,e,u.syllable),n=de(),o=[];for(const r of F(t)){if(o.length>=(e.count??10))break;const l=Un(r.w,null,n);if(!l)continue;const a=V(n.get(r.w)||r.w);if(!a)continue;const[i,...c]=l.distractors;o.push({id:J("RCP-item"),index:o.length+1,base:r.w,word:r.w,missingConsonant:z[a.cho],remaining:i,distractors:c})}return o}const Qe=new Map;let Ct=null,dt=null;async function ft(e,u={}){const t=Ke(),n=De();(t!==Ct||n!==dt)&&(Qe.clear(),Ct=t,dt=n);const o=`${e}:${rt(u)}`;if(Qe.has(o))return Qe.get(o);const r=await mo(e,u);return Qe.set(o,r),r}const ho={SAME_SOUND_PICK:e=>st("SSP",e),HEAR_AND_PICK_SAME:e=>st("HPS",e),HEAR_AND_PICK_INCLUDED:e=>Qn(e),SAME_OR_DIFF:e=>Zn(e),STARTS_WITH_SAME_SOUND:e=>Xn(e),LISTEN_AND_REMEMBER_ORDER:e=>io(e),MERGE_2_SYLLABLES:e=>oo(e),MERGE_3_SYLLABLES:e=>ro(e),MERGE_2_PHONEMES:e=>co(e),MERGE_3_PHONEMES:e=>Co(e),DROP_1_FROM_2SYLL:e=>lo(e),DROP_1_FROM_3SYLL:e=>ao(e),DROP_PART_FROM_COMPOUND:e=>so(e),DROP_FINAL_CONSONANT_FROM_1SYLL:e=>fo(e),REMOVE_CONSONANT_AND_IDENTIFY_PHONEME:e=>go(e),CHANGE_1_SYLL_IN_2SYLL:e=>eo(e),CHANGE_1_SYLL_IN_3SYLL:e=>uo(e),CHANGE_1_PHONEME_IN_1SYLL:e=>to(e),CHANGE_1_PHONEME_IN_2SYLL:e=>no(e)};async function mo(e,u={}){const t=ho[e];return t?await t(u):[]}async function po(e){const u=["random","count"],t=Object.keys(Cu);let n=0;for(const o of u)for(const r of t){const l=Cu[r];ft(r,{difficulty:l.difficulty?o:null,contrastCount:1,composition:null,count:5,excludeNoImage:e,sameStructureOnly:!0,phonemeView:"char",grade:null}).catch(()=>{}),++n%6===0&&await new Promise(a=>setTimeout(a,0))}}async function So(e){return(await X({...e,fullCount:!0})).length}async function yo(e={}){const u=[];for(const a of oe)a.w&&u.push(a.w);const t=e.excludeNoImage?Ie(u):u,n=new Set,o=new Set,r=new Set,l=new Set;for(const a of t){l.add(Ae(a));for(const i of a){const c=V(i);if(c&&(z[c.cho]!=="\u3147"&&n.add(z[c.cho]),o.add(ne[c.jung]),c.jong>0)){r.add(ue[c.jong]);const g=be[c.jong];g&&g.forEach(d=>r.add(d))}}}return{cho:n,jung:o,jong:r,syllable:l}}const he="\uC804\uCCB4";function gt(){const{t:e}=ce.useTranslation();return s.useMemo(()=>({difficulty:e("wordSearch.filter.difficulty","\uB4F1\uAE09"),syllables:e("wordSearch.filter.syllables","\uC74C\uC808 \uC218"),syllable5plus:e("wordSearch.filter.syllable5plus","5\uC74C\uC808 \uC774\uC0C1"),partOfSpeech:e("wordSearch.filter.partOfSpeech","\uD488\uC0AC"),wordType:e("wordSearch.filter.wordType","\uC720\uD615"),posMap:{[e("wordSearch.filter.pos.noun","\uCCB4\uC5B8(\uBA85\uC0AC, \uC218\uC0AC)")]:["\uBA85","\uC218"],[e("wordSearch.filter.pos.verb","\uC6A9\uC5B8(\uB3D9\uC0AC, \uD615\uC6A9\uC0AC)")]:["\uB3D9","\uD615"],[e("wordSearch.filter.pos.modifier","\uC218\uC2DD\uC5B8(\uBD80\uC0AC, \uAD00\uD615\uC0AC)")]:["\uBD80","\uAD00"]},typeMap:{[e("wordSearch.filter.type.native","\uACE0\uC720\uC5B4")]:"\uACE0\uC720",[e("wordSearch.filter.type.sino","\uD55C\uC790\uC5B4")]:"\uD55C\uC790",[e("wordSearch.filter.type.foreign","\uC678\uB798\uC5B4")]:"\uC678\uB798",[e("wordSearch.filter.type.mixed","\uD63C\uC885\uC5B4")]:"\uD63C\uC885"}}),[e])}function ht(e,u,t){return{label:u.difficulty,items:[1,2,3,4].map(n=>e("wordSearch.filter.grade",{n})),multiple:!0,allOption:!0,allLabel:t?.allLabel,labelAction:t?.labelAction,labelInfo:t?.labelInfo}}function mt(e){return{label:e.partOfSpeech,items:Object.keys(e.posMap),multiple:!0,allOption:!0}}function pt(e){return{label:e.wordType,items:Object.keys(e.typeMap),multiple:!0,allOption:!0}}function Eo(e,u){return{label:u.syllables,items:[e("wordSearch.filter.syllable",{n:1}),e("wordSearch.filter.syllable",{n:2}),e("wordSearch.filter.syllable",{n:3}),e("wordSearch.filter.syllable",{n:4}),u.syllable5plus],multiple:!0,allOption:!0}}function wo(e,u){const t=[e("wordPairs.filter.onlyHasImage","\uC774\uBBF8\uC9C0 \uC788\uB294 \uB2E8\uC5B4\uB9CC")];return u?.includeStructure&&t.push(e("wordPairs.filter.onlySameStructure","\uC74C\uC18C \uAD6C\uC870 \uAC19\uC740 \uB2E8\uC5B4\uB9CC")),{label:e("wordPairs.filter.selectLabel","\uC120\uD0DD"),items:t,multiple:!0,labelAction:u?.labelAction,labelInfo:u?.labelInfo}}function Bo(e,u){const{label:t,headValue:n,midValue:o,tailValue:r,includeMid:l=!0,headDisabled:a,midDisabled:i,tailDisabled:c,allOptionDisabled:g,groupLabel:d,labelAction:C}=u;return{label:t,...d?{groupLabel:d}:{},...C?{labelAction:C}:{},allOption:!0,allLabel:e("wordSearch.filter.positionAny",{defaultValue:"\uBB34\uAD00"}),...g?{allOptionDisabled:g}:{},items:[{value:n,displayLabel:e("wordSearch.filter.positionHead",{defaultValue:"\uC5B4\uB450"}),disabled:a},...l?[{value:o,displayLabel:e("wordSearch.filter.positionMid",{defaultValue:"\uC5B4\uC911"}),disabled:i}]:[],{value:r,displayLabel:e("wordSearch.filter.positionTail",{defaultValue:"\uC5B4\uB9D0"}),disabled:c}]}}function bo(e,u,t){if(u===he){const{[t]:r,...l}=e;return l}const n=e[t]??[],o=n.includes(u)?n.filter(r=>r!==u):[...n,u];if(o.length===0){const{[t]:r,...l}=e;return l}return{...e,[t]:o}}Object.fromEntries(Object.entries(Ln).map(([e,{nucleus:u}])=>[e,u]));const Ao={\uACE0\uC720\uC5B4:"\uACE0\uC720",\uD55C\uC790\uC5B4:"\uD55C\uC790",\uC678\uB798\uC5B4:"\uC678\uB798",\uD63C\uC885\uC5B4:"\uD63C\uC885"},_o={"\uCCB4\uC5B8(\uBA85\uC0AC,\uC218\uC0AC)":["\uBA85","\uC218"],"\uC6A9\uC5B8(\uB3D9\uC0AC,\uD615\uC6A9\uC0AC)":["\uB3D9","\uD615"],"\uC218\uC2DD\uC5B8(\uBD80\uC0AC,\uAD00\uD615\uC0AC)":["\uBD80","\uAD00"]},Do={difficulty:"\uB09C\uC774\uB3C4 \uB4F1\uAE09",syllables:"\uC74C\uC808 \uC218",syllable5plus:"5\uC74C\uC808 \uC774\uC0C1",partOfSpeech:"\uD488\uC0AC",wordType:"\uC720\uD615",posMap:_o,typeMap:Ao};function Oo(e,u,t=Do){const n=u[t.difficulty];if(n?.length&&!n.some(a=>e.grade===a.replace(/\D/g,"")))return!1;const o=u[t.syllables];if(o?.length){const a=e.syllables??0;if(!o.some(i=>i===t.syllable5plus?a>=5:a===parseInt(i)))return!1}const r=u[t.partOfSpeech];if(r?.length&&!r.flatMap(a=>t.posMap[a]??[a]).some(a=>(e.pos??"").includes(a)))return!1;const l=u[t.wordType];return!(l?.length&&!l.some(a=>e.wordType===t.typeMap[a]))}const No={labial:e=>e("common.phonetics.place.labial",{defaultValue:"\uC591\uC21C\uC74C"}),alveolar:e=>e("common.phonetics.place.alveolar",{defaultValue:"\uCE58\uC870\uC74C"}),palatal:e=>e("common.phonetics.place.palatal",{defaultValue:"\uACBD\uAD6C\uAC1C\uC74C"}),velar:e=>e("common.phonetics.place.velar",{defaultValue:"\uC5F0\uAD6C\uAC1C\uC74C"}),glottal:e=>e("common.phonetics.place.glottal",{defaultValue:"\uC131\uBB38\uC74C"})},To={frontHigh:e=>e("common.phonetics.vowel.frontHigh",{defaultValue:"\uC804\uC124 \uACE0\uBAA8\uC74C"}),backHighUnrounded:e=>e("common.phonetics.vowel.backHighUnrounded",{defaultValue:"\uD6C4\uC124 \uACE0\uBAA8\uC74C \uD3C9\uC21C"}),backHighRounded:e=>e("common.phonetics.vowel.backHighRounded",{defaultValue:"\uD6C4\uC124 \uACE0\uBAA8\uC74C \uC6D0\uC21C"}),frontMid:e=>e("common.phonetics.vowel.frontMid",{defaultValue:"\uC804\uC124 \uC911\uBAA8\uC74C"}),backMidUnrounded:e=>e("common.phonetics.vowel.backMidUnrounded",{defaultValue:"\uD6C4\uC124 \uC911\uBAA8\uC74C \uD3C9\uC21C"}),backMidRounded:e=>e("common.phonetics.vowel.backMidRounded",{defaultValue:"\uD6C4\uC124 \uC911\uBAA8\uC74C \uC6D0\uC21C"}),low:e=>e("common.phonetics.vowel.low",{defaultValue:"\uC800\uBAA8\uC74C"})},jo={j:e=>e("common.phonetics.glide.j",{defaultValue:"j\uD65C\uC74C"}),w:e=>e("common.phonetics.glide.w",{defaultValue:"w\uD65C\uC74C"}),velar:e=>e("common.phonetics.glide.velar",{defaultValue:"\u0270\uD65C\uC74C"})};function St(e,u){if("place"in u)return No[u.place](e);const t=To[u.vowel](e);return u.glide?`${t} \xB7 ${jo[u.glide](e)}`:t}const Io=(e,{defaultValue:u})=>u,yt=(e,u)=>({jamos:e,phonetic:u,tooltip:St(Io,u)}),se=(e,u)=>u.map(t=>yt([t],{place:e})),q=(e,u,t)=>yt([...e],t?{vowel:u,glide:t}:{vowel:u}),yu={cho:[se("labial",["\u3142","\u3143","\u314D","\u3141"]),se("alveolar",["\u3137","\u3138","\u314C","\u3134","\u3139"]),se("alveolar",["\u3145","\u3146"]),se("palatal",["\u3148","\u3149","\u314A"]),se("velar",["\u3131","\u3132","\u314B"]),se("glottal",["\u314E"])],jung:[[q("\u3163","frontHigh"),q("\u315F","frontHigh","w"),q("\u3162","frontHigh","velar")],[q("\u3161","backHighUnrounded")],[q("\u315C","backHighRounded"),q("\u3160","backHighRounded","j")],[q("\u3154\u3150","frontMid"),q("\u3156\u3152","frontMid","j"),q("\u3159\u315A\u315E","frontMid","w")],[q("\u3153","backMidUnrounded"),q("\u3155","backMidUnrounded","j"),q("\u315D","backMidUnrounded","w")],[q("\u3157","backMidRounded"),q("\u315B","backMidRounded","j")],[q("\u314F","low"),q("\u3151","low","j"),q("\u3158","low","w")]],jong:[se("labial",["\u3142","\u3141"]),se("alveolar",["\u3137","\u3134","\u3139"]),se("velar",["\u3131","\u3147"])]},Ro=[...z],Mo=[...ne],Lo=ue.filter(e=>e!==""),ie=e=>e===re?[]:Array.from(e),re="__NO_CODA__",Et=[1,2,3,4],le=5,vo=12,wt="SYL_",Eu=e=>`${wt}${e}`,ko=e=>Number(e.slice(wt.length));function wu(e){return e>=le?Array.from({length:vo-le+1},(u,t)=>le+t):[e]}const Bt={cho:Ro,jung:Mo,jong:Lo},Bu=e=>e.map(u=>u.map(({jamos:t,phonetic:n,tooltip:o})=>({v:t.join(""),phonetic:n,tooltip:o}))),bu={cho:Bu(yu.cho),jung:Bu(yu.jung),jong:Bu(yu.jong)},bt={};bu.jung.flat().forEach(({v:e})=>{for(const u of ie(e))bt[u]=e});const Po=new Set(bu.cho.flat().map(e=>e.v));function At(e,u){return e==="cho"?Po.has(u)?u:null:e==="jung"?bt[u]??u:du(u)}function _t(e,u,t){if(e==="jung"){const n=ie(u);return t&&n.includes(t)?t:n[0]??u}return e==="jong"&&t&&du(t)===u?t:u}function Dt(e,u,t,n){const o=(r,l)=>l?r==="jong"&&l===re?re:u==="pron"?At(r,l):_t(r,l,r==="jung"?t:r==="jong"?n:null):null;return{...e,cho:o("cho",e.cho),jung:o("jung",e.jung),jong:o("jong",e.jong)}}const Au={cho:null,jung:null,jong:null,syllable:null},xo="wt_filter",Ot=e=>`wt_filter_${e}`;function Nt(e){try{const u=localStorage.getItem(Ot(e))??localStorage.getItem(xo);if(u)return JSON.parse(u)}catch{}return null}function Tt(e){const u=e?.phonemeView;return u==="pron"?"pron":u==="direct"?"direct":"char"}function Fo(e){const u=e;return u?.composition?{cho:u.composition.cho??null,jung:u.composition.jung??null,jong:u.composition.jong??null,syllable:u.composition.syllable??null}:u?.choseong?{...Au,cho:u.choseong}:Au}function Vo(e,u,t){const{t:n,i18n:o}=ce.useTranslation(),[r]=s.useState(()=>t?.resetOnMount?null:Nt(e)),[l,a]=s.useState(Tt(r)),[i,c]=s.useState(()=>Fo(r)),g=s.useCallback(()=>u.requireSyllable?{cho:"\u3131",jung:"\u314F",jong:re,syllable:u.fixedSyllable??null}:{cho:null,jung:null,jong:u.fixedNoCoda?re:null,syllable:u.fixedSyllable??null},[u.requireSyllable,u.fixedSyllable,u.fixedNoCoda]);s.useEffect(()=>{!u.requireSyllable&&u.fixedSyllable==null&&!u.fixedNoCoda||c(S=>S.cho||S.jung||S.syllable!=null||S.jong?S:g())},[]);const d=s.useMemo(()=>W(i.cho)||W(i.jung)||W(i.jong)?"count":"random",[i.cho,i.jung,i.jong]),C=s.useRef(l==="char"?i.jung:null),h=s.useRef(l==="char"?i.jong:null);s.useEffect(()=>{l==="char"&&(C.current=i.jung,h.current=i.jong)},[l,i.jung,i.jong]);const[f,w]=s.useState(t?.resetOnMount?!!t?.defaultImageOnly:r?.excludeNoImage??!0),[y,m]=s.useState(t?.resetOnMount?!1:r?.sameStructureOnly??!0),[p,E]=s.useState(Array.isArray(r?.gradeFilter)?r.gradeFilter:[]),[B,_]=s.useState(Array.isArray(r?.posFilter)?r.posFilter:[]),[b,O]=s.useState(Array.isArray(r?.wordTypeFilter)?r.wordTypeFilter:[]),T=s.useRef(t?.resetKey);s.useEffect(()=>{T.current!==t?.resetKey&&(T.current=t?.resetKey,c(g()),w(!!t?.defaultImageOnly),m(!1),E([]),_([]),O([]))},[t?.resetKey]);const L=gt(),[D,$]=s.useState({cho:new Set,jung:new Set,jong:new Set,syllable:new Set}),[G,Y]=s.useState(!1),[M,k]=s.useState(null),H=1,U=Math.max(1,[i.cho,i.jung,i.jong].filter(Boolean).length),[ee,me]=s.useState(e);s.useEffect(()=>{if(ee!==e){if(!t?.resetOnMount){const S=Nt(e);c(S?.composition??g()),w(S?.excludeNoImage??!0),m(S?.sameStructureOnly??!0),a(Tt(S)),E(Array.isArray(S?.gradeFilter)?S.gradeFilter:[]),_(Array.isArray(S?.posFilter)?S.posFilter:[]),O(Array.isArray(S?.wordTypeFilter)?S.wordTypeFilter:[])}me(e)}},[e,ee,t?.resetOnMount]),s.useEffect(()=>{if(!t?.resetOnMount&&ee===e)try{localStorage.setItem(Ot(e),JSON.stringify({contrastCount:U,composition:i,excludeNoImage:f,sameStructureOnly:y,phonemeView:l,gradeFilter:p,posFilter:B,wordTypeFilter:b}))}catch{}},[t?.resetOnMount,e,ee,U,i,f,y,l,p,B,b]);const[A,N]=s.useState(0);Pu("wordpool:update",()=>N(S=>S+1));const R=s.useRef(o.language);s.useEffect(()=>{R.current!==o.language&&(R.current=o.language,N(S=>S+1))},[o.language]),s.useEffect(()=>{if(!u.choseong)return;let S=!1;return yo({difficulty:d,excludeNoImage:f}).then(I=>{S||($(I),I.cho.size+I.jung.size+I.jong.size>0&&Y(!0))}).catch(()=>{S||$({cho:new Set,jung:new Set,jong:new Set,syllable:new Set})}),()=>{S=!0}},[u.choseong,d,f,A]),s.useEffect(()=>{let S=!1;const I=i,j=I.cho?ie(I.cho):null,P=I.jung?ie(I.jung):null,K=I.jong===re,pe=K?null:I.jong?ie(I.jong):null,Se=I.syllable!=null?wu(I.syllable):null,He=!!(j||P||pe||K||Se);return So({difficulty:u.difficulty?d:null,contrastCount:u.difficulty?U:1,composition:u.choseong&&He?{cho:j,jung:P,jong:pe,jongNone:K,syllable:Se}:null,excludeNoImage:f,sameStructureOnly:y,phonemeView:l==="pron"?"pron":"char",grade:p.length>0?p:null}).then(Ge=>{S||k(Ge)}).catch(()=>{S||k(null)}),()=>{S=!0}},[u.choseong,u.difficulty,d,U,i,l,f,y,A,p]),s.useEffect(()=>{G&&c(S=>{const I={...S};let j=!1;return["cho","jung","jong"].forEach(P=>{const K=S[P];!K||K===re||ie(K).some(pe=>D[P].has(pe))||(I[P]=null,j=!0)}),S.syllable!=null&&u.fixedSyllable==null&&(S.syllable>=le?[...D.syllable].some(P=>P>=le)||(I.syllable=null,j=!0):(!D.syllable.has(S.syllable)||S.syllable<H)&&(I.syllable=null,j=!0)),j?I:S})},[D,G,H,u.fixedSyllable]);const x=s.useMemo(()=>{const S=I=>{const j=new Set;for(const P of Bt[I])D[I].has(P)&&j.add(P);return j};return{cho:S("cho"),jung:S("jung"),jong:S("jong")}},[D]),Q=s.useMemo(()=>({exact:new Set(Et.filter(S=>D.syllable.has(S))),min:[...D.syllable].some(S=>S>=le)}),[D]),v=s.useMemo(()=>({composition:n("wordPairs.composition","\uC815\uB2F5 \uB2E8\uC5B4 \uAD6C\uC131"),syllableCount:n("wordPairs.syllableCount","\uC74C\uC808 \uC218"),onset:n("wordPairs.onset","\uCD08\uC131"),vowel:n("wordPairs.vowel","\uBAA8\uC74C"),coda:n("wordPairs.coda","\uC885\uC131"),phonemeGroup:n("training.filter.phonemeGroup",{defaultValue:"\uD6C8\uB828 \uC74C\uC808"}),trainOnset:n("training.filter.trainOnset",{defaultValue:"\uCD08\uC131"}),trainVowel:n("training.filter.trainVowel",{defaultValue:"\uBAA8\uC74C"}),trainCoda:n("training.filter.trainCoda",{defaultValue:"\uC885\uC131"}),random:n("training.filter.random","\uBB34\uC791\uC704"),exclude:n("wordSearch.filter.exclude","\uC81C\uC678"),selectLabel:n("training.filter.selectSection",{defaultValue:"\uC120\uD0DD"}),none:n("common.none","\uC5C6\uC74C"),noImage:n("wordSearch.filter.excludeNoImage","\uC774\uBBF8\uC9C0 \uC5C6\uC74C"),excludeImage:n("training.filter.excludeImage",{defaultValue:"\uC774\uBBF8\uC9C0 \uC788\uB294 \uB2E8\uC5B4\uB9CC"}),sameStructure:n("training.filter.sameStructure",{defaultValue:"\uC74C\uC18C \uAD6C\uC870 \uAC19\uC740 \uB2E8\uC5B4\uB9CC"}),noLimit:n("training.filter.noLimit",{defaultValue:"\uBB34\uAD00"}),codaExclude:n("training.filter.codaExclude",{defaultValue:"\uC81C\uC678"}),gradeLabel:n("training.filter.gradeLabel",{defaultValue:"\uB09C\uC774\uB3C4 \uB4F1\uAE09"})}),[n]),Tu=s.useMemo(()=>({[v.trainOnset]:"cho",[v.trainVowel]:"jung",[v.trainCoda]:"jong"}),[v]),$e=s.useCallback((S,I)=>({title:I,items:S}),[]),lu=s.useMemo(()=>[n("training.filter.excludeImageInfo",{defaultValue:"\uC774\uBBF8\uC9C0 \uC788\uB294 \uB2E8\uC5B4\uB9CC: \uB2E8\uC5B4 \uC911\uC5D0 \uC774\uBBF8\uC9C0\uAC00 \uC788\uB294 \uB2E8\uC5B4\uB9CC \uACB0\uACFC\uC5D0 \uBCF4\uC5EC\uC90D\uB2C8\uB2E4."}),n("training.filter.sameStructureInfo",{defaultValue:"\uC74C\uC18C \uAD6C\uC870 \uAC19\uC740 \uB2E8\uC5B4\uB9CC: \uC815\uB2F5\uACFC \uC624\uB2F5\uC758 \uC74C\uC808 \uAD6C\uC870(\uAE00\uC790 \uC218\xB7\uBC1B\uCE68 \uC720\uBB34 \uB4F1)\uAC00 \uAC19\uC740 \uACB0\uACFC\uB9CC \uB0A8\uACA8\uC694."})],[n]),Pt=s.useMemo(()=>{const S=[];if(u.choseong){const I={value:re,displayLabel:v.codaExclude},j=u.fixedNoCoda===!0,P=(K,pe)=>{const Se=j&&K==="jong",He={label:pe,groupLabel:v.phonemeGroup,allOption:!u.requireSyllable,allLabel:v.noLimit,allOptionDisabled:Se};if(l==="pron"){const ye=bu[K].map(Yt=>Yt.map(({v:au,phonetic:Ut})=>{const su=ie(au),ju=St(n,Ut),Iu=Se||!su.some(Kt=>D[K].has(Kt));return su.length>1?{value:au,labels:su,tooltip:ju,disabled:Iu}:{value:au,tooltip:ju,disabled:Iu}}));return K==="jong"&&!u.requireCoda&&ye.unshift([I]),{...He,groups:ye}}const Ge=Bt[K].map(ye=>!Se&&x[K].has(ye)?ye:{value:ye,disabled:!0});return{...He,items:K==="jong"&&!u.requireCoda?[I,...Ge]:Ge}};S.push(P("cho",v.trainOnset)),S.push(P("jung",v.trainVowel)),S.push(P("jong",v.trainCoda))}if(S.push({...ht(n,L,{labelInfo:$e([n("wordPairs.filter.difficultyInfo",{defaultValue:"\uAD6D\uB9BD\uAD6D\uC5B4\uC6D0\uC758 \uAE30\uCD08 \uC5B4\uD718 \uB4F1\uAE09\uC774 \uACB0\uACFC\uC5D0 \uBC18\uC601\uB429\uB2C8\uB2E4."})])}),label:v.gradeLabel}),u.partOfSpeech&&S.push(mt(L)),u.wordType&&S.push(pt(L)),u.choseong||u.fixedSyllable!=null){const I=u.fixedSyllable;S.push({label:v.syllableCount,items:[...Et.map(j=>({value:Eu(j),displayLabel:n("wordPairs.syllableN",{n:j,defaultValue:"{{n}}\uC74C\uC808"}),disabled:I!=null?j!==I:!Q.exact.has(j)||j<H})),{value:Eu(le),displayLabel:n("wordPairs.syllableNPlus",{n:le,defaultValue:"{{n}}\uC74C\uC808 \uC774\uC0C1"}),disabled:I!=null?le!==I:!Q.min}],allOption:!0,allOptionDisabled:I!=null})}return u.choseong?S.push({label:v.exclude,displayLabel:v.selectLabel,multiple:!0,items:[v.excludeImage,v.sameStructure],labelInfo:$e(lu)}):S.push({label:v.exclude,displayLabel:v.selectLabel,multiple:!0,items:[v.excludeImage],labelInfo:$e([lu[0]])}),S},[u.choseong,u.partOfSpeech,u.wordType,u.requireSyllable,u.fixedSyllable,u.fixedNoCoda,u.requireCoda,H,x,D,l,Q,v,n,$e,lu,L]),xt={...(u.choseong||u.fixedSyllable!=null)&&i.syllable!=null?{[v.syllableCount]:Eu(i.syllable)}:{},...u.choseong&&i.cho?{[v.trainOnset]:i.cho}:{},...u.choseong&&i.jung?{[v.trainVowel]:i.jung}:{},...u.choseong&&i.jong?{[v.trainCoda]:i.jong}:{},[v.exclude]:[...f?[v.excludeImage]:[],...y?[v.sameStructure]:[]],[v.gradeLabel]:p.map(S=>n("wordSearch.filter.grade",{n:Number(S),defaultValue:"{{n}}\uB4F1\uAE09"})),...u.partOfSpeech?{[L.partOfSpeech]:B}:{},...u.wordType?{[L.wordType]:b}:{}},Ft=s.useCallback((S,I)=>{if(I===v.exclude)S===v.excludeImage?w(j=>!j):S===v.sameStructure&&m(j=>!j);else if(I===v.syllableCount)c(j=>{if(!S||S===he)return{...j,syllable:null};const P=ko(S);return{...j,syllable:j.syllable===P?null:P}});else if(I===v.gradeLabel){if(!S||S===he){E([]);return}const j=S.replace(/\D/g,"");E(P=>P.includes(j)?P.filter(K=>K!==j):[...P,j])}else if(I===L.partOfSpeech){if(!S||S===he){_([]);return}_(j=>j.includes(S)?j.filter(P=>P!==S):[...j,S])}else if(I===L.wordType){if(!S||S===he){O([]);return}O(j=>j.includes(S)?j.filter(P=>P!==S):[...j,S])}else{const j=Tu[I];if(!j)return;c(P=>u.requireSyllable?S&&S!==he?{...P,[j]:S}:P:!S||S===he||P[j]===S?{...P,[j]:null}:{...P,[j]:S})}},[v,Tu,L,u.requireSyllable]),Vt=s.useCallback(S=>!u.partOfSpeech&&!u.wordType?!0:Oo(S,{...u.partOfSpeech?{[L.partOfSpeech]:B}:{},...u.wordType?{[L.wordType]:b}:{}},L),[u.partOfSpeech,u.wordType,B,b,L]),$t=s.useCallback(S=>{S!==l&&(S!=="direct"&&l!=="direct"&&c(I=>Dt(I,S,C.current,h.current)),a(S))},[l]),Ht=s.useCallback(()=>({composition:i,contrastCount:U,excludeNoImage:f,sameStructureOnly:y,phonemeView:l,gradeFilter:p,posFilter:B,wordTypeFilter:b}),[i,U,f,y,l,p,B,b]),Gt=s.useCallback(S=>{c(S.composition),w(S.excludeNoImage),m(S.sameStructureOnly??!0),a(S.phonemeView),E(Array.isArray(S.gradeFilter)?S.gradeFilter:[]),Array.isArray(S.posFilter)&&_(S.posFilter),Array.isArray(S.wordTypeFilter)&&O(S.wordTypeFilter)},[]);return{difficulty:d,contrastCount:U,composition:i,choseong:i.cho,excludeNoImage:f,sameStructureOnly:y,gradeFilter:p,posFilter:B,wordTypeFilter:b,matchesWordAttributes:Vt,poolVersion:A,filterSections:Pt,filterSelected:xt,handleFilterSelect:Ft,phonemeView:l,setPhonemeView:$t,phonemeGroupLabel:v.phonemeGroup,wordCount:M,getFilterSnapshot:Ht,restoreFilterSnapshot:Gt}}function $o(e){const u=a=>a?ie(a):null,t=u(e.cho),n=u(e.jung),o=e.jong===re,r=o?null:u(e.jong),l=e.syllable!=null?wu(e.syllable):null;return!t&&!n&&!r&&!o&&!l?null:{cho:t,jung:n,jong:r,jongNone:o,syllable:l}}function Ho(e,u,t,n,o,r,l=!0,a="char",i=[]){const[c,g]=s.useState({}),[d,C]=s.useState(!1),{cho:h=null,jung:f=null,jong:w=null,syllable:y=null}=n??{},m=i.length>0?i.slice().sort().join(","):"",p=e.map(B=>B.key).join("|");s.useEffect(()=>{r>0&&po(o).catch(()=>{})},[r,o]),s.useEffect(()=>{let B=!1;return C(!0),(async()=>{const _=$o({cho:h,jung:f,jong:w,syllable:y}),b=`${h??""}_${f??""}_${w??""}_${y??""}_${m}`,O={};await Promise.all(e.map(async T=>{const L=Cu[T.key];try{const D=await ft(T.key,{difficulty:L.difficulty?u:null,contrastCount:L.difficulty?t:1,composition:L.choseong?_:null,count:5,excludeNoImage:o,sameStructureOnly:l,phonemeView:a,grade:i.length>0?i:null});D&&D.length>0?O[T.key]={id:`wt-${T.key}-${u}-${b}-${Date.now()}`,name:T.label,training_type:T.key,category_main_code:"WORD",iconColor:T.color,subTitle:T.subTitle,items:D,itemCount:D.length}:O[T.key]={id:`wt-${T.key}-empty`,name:T.label,training_type:T.key,category_main_code:"WORD",iconColor:T.color,subTitle:T.subTitle,items:[],itemCount:0,__empty:!0}}catch{O[T.key]=null}})),B||(g(O),C(!1))})(),()=>{B=!0}},[u,t,h,f,w,y,o,l,a,r,m,p]);const E=JSON.stringify(e.map(B=>[B.key,B.label,B.color,B.subTitle]));return{perTypeData:s.useMemo(()=>{const B={};for(const[_,b]of Object.entries(c)){const O=e.find(T=>T.key===_);B[_]=b&&O?{...b,name:O.label,iconColor:O.color,subTitle:O.subTitle}:b}return B},[c,E]),generating:d}}function _u(){return Ze(new Date)}function Ze(e){if(e==null||e==="")return"";const u=e instanceof Date?e:new Date(e);return isNaN(u.getTime())?"":new Intl.DateTimeFormat("fr-CA",{timeZone:"Asia/Seoul"}).format(u)}const Me=[],Le=[],ve=[],ke=[],Xe={LISTEN_IN_NOISE:[],SHORT_STORY:[],LONG_STORY:[],ORDERING_SENTENCE:[]},eu={LISTEN_IN_NOISE:[],SHORT_STORY:[],LONG_STORY:[],ORDERING_SENTENCE:[]},Go={LISTEN_IN_NOISE:3,SHORT_STORY:2,LONG_STORY:1,ORDERING_SENTENCE:2};let Du=null,jt=null,fe=null;function Yo({counts:e,forceRefresh:u}={}){const t=Object.assign({},Go,e||{}),n=_u(),o=Ze(new Date(`${n}T00:00:00+09:00`).getTime()-864e5),r=JSON.stringify(t);if(!u&&jt===n&&Du===r&&fe)return Object.assign(Xe,fe.today),Object.assign(eu,fe.yesterday?.selection||{LISTEN_IN_NOISE:[],SHORT_STORY:[],LONG_STORY:[],ORDERING_SENTENCE:[]}),{today:Xe,yesterday:eu};const l={LISTEN_IN_NOISE:ae(Me,Math.max(0,Number(t.LISTEN_IN_NOISE)||0)),SHORT_STORY:ae(Le,Math.max(0,Number(t.SHORT_STORY)||0)),LONG_STORY:ae(ve,Math.max(0,Number(t.LONG_STORY)||0)),ORDERING_SENTENCE:ae(ke,Math.max(0,Number(t.ORDERING_SENTENCE)||0))};let a=null;return fe&&Du===r&&fe.yesterday&&fe.yesterday.date===o&&(a=fe.yesterday.selection),a||(a={LISTEN_IN_NOISE:ae(Me,Math.max(0,Number(t.LISTEN_IN_NOISE)||0)),SHORT_STORY:ae(Le,Math.max(0,Number(t.SHORT_STORY)||0)),LONG_STORY:ae(ve,Math.max(0,Number(t.LONG_STORY)||0)),ORDERING_SENTENCE:ae(ke,Math.max(0,Number(t.ORDERING_SENTENCE)||0))}),Object.assign(Xe,l),Object.assign(eu,a),jt=n,Du=r,fe={today:l,yesterday:{date:o,countsKey:r,selection:a}},{today:Xe,yesterday:eu}}let It=!1,Pe=null;async function Uo(){try{const e={url:typeof document>"u"?require("url").pathToFileURL(__filename).href:iu&&iu.tagName.toUpperCase()==="SCRIPT"&&iu.src||new URL("hooks.cjs.js",document.baseURI).href}&&void 0||"/",u=await fetch(`${e}data/allTrainingData.json`);return u.ok?await u.json():null}catch{return null}}async function Ko(){if(!It)return Pe||(Pe=(async()=>{const e=await Uo();if(!e){Pe=null;try{window.dispatchEvent(new Event("speechear.data.error"))}catch{}return}const u={noise:[],short:[],long:[],order:[]};try{for(const t of Object.keys(e||{})){const n=e[t]||[];for(const o of n){const r=o,l=String(r.training_type||t),a=String(r.category_main_code||r.category_main||r.category_0||""),i=String(r.category_sub_code||r.category_sub||r.category_1||""),c=Object.assign({},r,{training_type:l,category_0:a,category_1:i});l==="LISTEN_IN_NOISE"?u.noise.push(c):l==="SHORT_STORY"?u.short.push(c):l==="LONG_STORY"?u.long.push(c):l==="ORDERING_SENTENCE"&&u.order.push(c)}}}catch{Pe=null;try{window.dispatchEvent(new Event("speechear.data.error"))}catch{}return}Me.push(...u.noise),Le.push(...u.short),ve.push(...u.long),ke.push(...u.order);try{window.dispatchEvent(new Event("speechear.data.updated"))}catch{}try{Yo()}catch{}It=!0})(),Pe)}async function Wo(e=3e3){const u=Ko();return Promise.race([u,new Promise(t=>setTimeout(t,e))])}function qo(e){let u=2166136261;for(let t=0;t<e.length;t++)u^=e.charCodeAt(t),u=Math.imul(u,16777619);return u>>>0}function zo(e){let u=e>>>0;return()=>{u|=0,u=u+1831565813|0;let t=Math.imul(u^u>>>15,1|u);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const uu=ae;function Ou(e,u){const t=u?zo(qo(u)):Math.random;return{LISTEN_IN_NOISE:uu(Me,Math.max(0,e.LISTEN_IN_NOISE||0),t),SHORT_STORY:uu(Le,Math.max(0,e.SHORT_STORY||0),t),LONG_STORY:uu(ve,Math.max(0,e.LONG_STORY||0),t),ORDERING_SENTENCE:uu(ke,Math.max(0,e.ORDERING_SENTENCE||0),t)}}function Rt(e){return e?!!(e.LISTEN_IN_NOISE?.length||e.SHORT_STORY?.length||e.LONG_STORY?.length||e.ORDERING_SENTENCE?.length):!1}const Jo={LISTEN_IN_NOISE:3,SHORT_STORY:2,LONG_STORY:1,ORDERING_SENTENCE:2};function Mt(e=!1,u=Jo,t){const n=Ze(Date.now()),o=Ze(Date.now()-864e5),r=`${t??""}|${n}`,l=`${t??""}|${o}`;return Me.length>0||Le.length>0||ve.length>0||ke.length>0?{today:Ou(u,r),yesterday:Ou(u,l)}:{today:Ou(u,r),yesterday:null}}function Qo(e){const u=s.useRef({LISTEN_IN_NOISE:[],SHORT_STORY:[],LONG_STORY:[],ORDERING_SENTENCE:[]}),t=s.useRef(null),[n,o]=s.useState(!1),[r,l]=s.useState(!1),[a,i]=s.useState(0),[c,g]=s.useState(!1),[d,C]=s.useState(()=>_u());s.useEffect(()=>{const f=()=>{const y=Date.now(),m=new Date(y+9*36e5),p=Date.UTC(m.getUTCFullYear(),m.getUTCMonth(),m.getUTCDate()+1)-9*36e5;return Math.max(1e3,p-y+1e3)};let w=setTimeout(function y(){C(_u()),w=setTimeout(y,f())},f());return()=>clearTimeout(w)},[]),s.useEffect(()=>{let f=!1,w,y=0;const m=40,p=()=>{w!==void 0&&(clearInterval(w),w=void 0)};let E=!1;try{const b=new URLSearchParams(window.location.search),O=b.get("forceRefresh")||b.get("force");E=O==="1"||O==="true"}catch{}const B=b=>{u.current=b.today,t.current=b.yesterday,o(!0),g(!0),i(O=>O+1),f=!0,p()},_=async()=>{if(f)return;if(!E){const O=Mt(!1,void 0,e);if(Rt(O.today)){B(O);return}}try{await Wo(3e3)}catch{}if(f)return;const b=Mt(E,void 0,e);if(Rt(b.today)){B(b);return}++y>=m&&(o(!0),g(!1),f=!0,p())};return _(),w=setInterval(_,250),()=>{f=!0,p()}},[e,d]);const h=s.useCallback(f=>{const w=r?t.current:u.current,y=r?u.current:t.current;return w?.[f]?.length?w[f]:y?.[f]?.length?y[f]:void 0},[r,a]);return{loaded:n,hasData:c,showYesterday:r,setShowYesterday:l,getTrainingPerType:h}}const Be=[];let tu=!1;function Lt(e){if(e.key!=="Escape"||e.defaultPrevented)return;const u=Be[Be.length-1];u&&(e.stopPropagation(),u())}function vt(e){return Be.push(e),!tu&&typeof document<"u"&&(document.addEventListener("keydown",Lt),tu=!0),()=>{const u=Be.lastIndexOf(e);u>=0&&Be.splice(u,1),Be.length===0&&tu&&typeof document<"u"&&(document.removeEventListener("keydown",Lt),tu=!1)}}function Zo(e,u=!0){const t=ku(e);s.useEffect(()=>{if(u)return vt(()=>{t.current?.()})},[u,t])}const Nu=(e,u)=>`${e}:${u??1}`,nu=new Map,kt=new Set;function Xo(e,u){const[t,n]=s.useState(0),o=Array.from(new Set(e.map(r=>Nu(r.word,r.homonum)))).sort().join("|");return s.useEffect(()=>{const r=(o?o.split("|"):[]).filter(i=>!nu.has(i)&&!kt.has(i));if(r.length===0)return;let l=!1;const a=Array.from(new Set(r.map(i=>i.slice(0,i.lastIndexOf(":")))));return u(a).then(i=>{for(const c of i)c.Meaning&&nu.set(Nu(c.Word,c.Homonum??void 0),c.Meaning);for(const c of r)nu.has(c)||kt.add(c);l||i.length===0||n(c=>c+1)}).catch(()=>{}),()=>{l=!0}},[o,u]),s.useMemo(()=>{const r=o?o.split("|"):[],l=new Map;for(const a of r){const i=nu.get(a);i!=null&&l.set(a,i)}return l},[o,t])}function er(){const[e,u]=s.useState(null),t=s.useCallback(r=>u(r.getBoundingClientRect()),[]),n=s.useCallback(()=>u(null),[]),o=s.useCallback(r=>{const l=r.getBoundingClientRect();u(a=>a?null:l)},[]);return{anchorRect:e,isOpen:e!=null,openAt:t,close:n,toggleAt:o}}function ur(e){const[u,t]=s.useState(null),[n,o]=s.useState(null),r=s.useRef(null);s.useEffect(()=>()=>{r.current&&clearTimeout(r.current)},[]);const l=s.useCallback((i,c)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{t(i),o(c)},e)},[e]),a=s.useCallback(()=>{r.current&&clearTimeout(r.current),t(null),o(null)},[]);return{payload:u,anchorRect:n,openAfterDelay:l,close:a}}function tr(e,u,t){const n=Number.isFinite(u)&&u>=1?Math.floor(u):1,o=Math.max(1,Math.ceil(e.length/n)),r=Number.isFinite(t)?Math.min(Math.max(1,Math.floor(t)),o):1;return{pageItems:s.useMemo(()=>e.slice((r-1)*n,r*n),[e,r,n]),totalPages:o,curPage:r}}function nr(e="warning"){const[u,t]=s.useState(""),[n,o]=s.useState(e),[r,l]=s.useState(0),a=s.useCallback((d,C)=>{o(C),t(d),l(h=>h+1)},[]),i=s.useCallback(d=>a(d,"warning"),[a]),c=s.useCallback(d=>a(d,"normal"),[a]),g=s.useCallback(()=>t(""),[]);return{toastMessage:u,toastType:n,toastKey:r,showToast:a,showWarning:i,showNormal:c,clearToast:g}}const or=[{key:"LISTEN_IN_NOISE",label:"\uC18C\uC74C \uD558 \uBB38\uC7A5 \uB4E3\uAE30",icon:"party-popper",desc:"\uB2E4\uC591\uD55C \uC18C\uC74C \uD658\uACBD\uC5D0\uC11C \uBB38\uC7A5 \uCCAD\uB825\uC744 \uD6C8\uB828\uD569\uB2C8\uB2E4."},{key:"SHORT_STORY",label:"\uC9E7\uC740 \uC774\uC57C\uAE30 \uB4E3\uAE30",icon:"message-square",desc:"\uC9E7\uC740 \uC774\uC57C\uAE30\uB97C \uB4E3\uACE0 \uAE30\uC5B5\uD558\uC5EC \uBB38\uC81C\uB97C \uD480\uC5B4\uBD05\uB2C8\uB2E4."},{key:"LONG_STORY",label:"\uAE34 \uC774\uC57C\uAE30 \uB4E3\uAE30",icon:"message-square-text",desc:"\uAE34 \uC774\uC57C\uAE30\uB97C \uB4E3\uACE0 \uAE30\uC5B5\uD558\uC5EC \uB2E4\uC218\uC758 \uBB38\uC81C\uB97C \uD480\uC5B4\uBD05\uB2C8\uB2E4."},{key:"ORDERING_SENTENCE",label:"\uBB38\uC7A5 \uC21C\uC11C\uD654 \uD558\uAE30",icon:"align-start-vertical",desc:"\uC5EC\uB7EC\uAC1C\uC758 \uC9E7\uC740 \uBB38\uC7A5\uC744 \uB4E3\uACE0 \uAE30\uC5B5\uD558\uC5EC \uADF8 \uC21C\uC11C\uC5D0 \uB9DE\uAC8C \uBC30\uC5F4\uD569\uB2C8\uB2E4."}],rr={LISTEN_IN_NOISE:"listenInNoise",SHORT_STORY:"shortStory",LONG_STORY:"longStory",ORDERING_SENTENCE:"orderingSentence"};function lr(e){return or.map(u=>{const t=rr[u.key];return t?{...u,label:e(`trainingType.${t}.title`),desc:e(`trainingType.${t}.desc`)}:u})}const xe={blue:"#60A5FA",green:"#4ADE80",amber:"#FBBF24",purple:"#A78BFA",pink:"#F472B6"},Fe=xe.blue,ou=xe.green,Ve=xe.amber,ru=xe.purple,ar=xe.pink,sr=[{key:"discrimination",label:"\uBCC0\uBCC4\uD6C8\uB828",disc:"\uB450 \uC18C\uB9AC\uAC00 \uAC19\uC740\uC9C0 \uB2E4\uB978\uC9C0, \uB610\uB294 \uD2B9\uC815 \uC18C\uB9AC\uB97C \uAD6C\uBCC4\uD558\uB294 \uD6C8\uB828\uC785\uB2C8\uB2E4.",icon:"ear",types:[{key:"SAME_SOUND_PICK",label:"\uAC19\uC740 \uC18C\uB9AC \uACE0\uB974\uAE30",icon:"volume-2",color:Fe,subTitle:"\uB4E4\uC740 \uC18C\uB9AC\uC640 \uAC19\uC740 \uB2E8\uC5B4 \uCE74\uB4DC\uB97C \uACE0\uB974\uC138\uC694."},{key:"SAME_OR_DIFF",label:"\uAC19\uC740\uC9C0 \uB2E4\uB978\uC9C0 \uB9DE\uD788\uAE30",icon:"diff",color:Fe,subTitle:"\uB450 \uC18C\uB9AC\uAC00 \uAC19\uC740\uC9C0, \uB2E4\uB978\uC9C0 \uAD6C\uBD84\uD558\uC138\uC694."},{key:"HEAR_AND_PICK_SAME",label:"\uC77C\uCE58\uD558\uB294 \uB2E8\uC5B4 \uB9DE\uD788\uAE30",icon:"headphones",color:Fe,subTitle:"\uB4E4\uC740 \uC18C\uB9AC\uC758 \uB2E8\uC5B4 \uCE74\uB4DC\uB97C \uACE0\uB974\uC138\uC694."},{key:"HEAR_AND_PICK_INCLUDED",label:"\uD55C \uC74C\uC808 \uD3EC\uD568 \uB2E8\uC5B4 \uB9DE\uD788\uAE30",icon:"scan-search",color:Fe,subTitle:"\uB4E4\uC740 \uC74C\uC808\uC774 \uD3EC\uD568\uB41C \uB2E8\uC5B4 \uCE74\uB4DC\uB97C \uACE0\uB974\uC138\uC694."},{key:"STARTS_WITH_SAME_SOUND",label:"\uCCAB \uC74C\uC808\uC774 \uAC19\uC740 \uB2E8\uC5B4 \uB9DE\uD788\uAE30",icon:"play-circle",color:Fe,subTitle:"\uB4E4\uC740 \uB2E8\uC5B4\uC640 \uAC19\uC740 \uC18C\uB9AC\uB85C \uC2DC\uC791\uD558\uB294 \uB2E8\uC5B4\uB97C \uACE0\uB974\uC138\uC694."}]},{key:"synthesis",label:"\uD569\uC131\uD6C8\uB828",disc:"\uB450 \uAC1C \uC774\uC0C1\uC758 \uC74C\uC808\uC774\uB098 \uC74C\uC18C\uB97C \uD569\uCCD0 \uB2E8\uC5B4\uB97C \uB9CC\uB4DC\uB294 \uD6C8\uB828\uC785\uB2C8\uB2E4.",icon:"git-merge",types:[{key:"MERGE_2_SYLLABLES",label:"\uC74C\uC808 2\uAC1C \uD569\uCE58\uAE30",icon:"link-2",color:ou,subTitle:"\uB450 \uC74C\uC808\uC744 \uD569\uCE58\uBA74 \uC5B4\uB5A4 \uB2E8\uC5B4\uAC00 \uB420\uAE4C\uC694?"},{key:"MERGE_3_SYLLABLES",label:"\uC74C\uC808 3\uAC1C \uD569\uCE58\uAE30",icon:"git-merge",color:ou,subTitle:"\uC138 \uC74C\uC808\uC744 \uD569\uCE58\uBA74 \uC5B4\uB5A4 \uB2E8\uC5B4\uAC00 \uB420\uAE4C\uC694?"},{key:"MERGE_2_PHONEMES",label:"\uC74C\uC18C 2\uAC1C \uD569\uCE58\uAE30",icon:"combine",color:ou,subTitle:"\uB450 \uC74C\uC18C\uB97C \uD569\uCE58\uBA74 \uC5B4\uB5A4 \uC18C\uB9AC\uAC00 \uB420\uAE4C\uC694?"},{key:"MERGE_3_PHONEMES",label:"\uC74C\uC18C 3\uAC1C \uD569\uCE58\uAE30",icon:"braces",color:ou,subTitle:"\uC138 \uC74C\uC18C\uB97C \uD569\uCE58\uBA74 \uC5B4\uB5A4 \uC18C\uB9AC\uAC00 \uB420\uAE4C\uC694?"}]},{key:"deletion",label:"\uD0C8\uB77D\uD6C8\uB828",disc:"\uB2E8\uC5B4\uC5D0\uC11C \uC74C\uC808\uC774\uB098 \uC74C\uC18C\uB97C \uC81C\uAC70\uD588\uC744 \uB54C \uB0A8\uB294 \uC18C\uB9AC\uB97C \uC778\uC2DD\uD558\uB294 \uD6C8\uB828\uC785\uB2C8\uB2E4.",icon:"scissors",types:[{key:"DROP_1_FROM_2SYLL",label:"2\uC74C\uC808\uC5D0\uC11C 1\uC74C\uC808 \uD0C8\uB77D",icon:"scissors",color:Ve,subTitle:"2\uC74C\uC808 \uB2E8\uC5B4\uC5D0\uC11C \uD55C \uC74C\uC808\uC744 \uBE7C\uBA74 \uC5B4\uB5A4 \uC18C\uB9AC\uAC00 \uB420\uAE4C\uC694?"},{key:"DROP_1_FROM_3SYLL",label:"3\uC74C\uC808\uC5D0\uC11C 1\uC74C\uC808 \uD0C8\uB77D",icon:"minus-circle",color:Ve,subTitle:"3\uC74C\uC808 \uB2E8\uC5B4\uC5D0\uC11C \uD55C \uC74C\uC808\uC744 \uBE7C\uBA74 \uC5B4\uB5A4 \uC18C\uB9AC\uAC00 \uB420\uAE4C\uC694?"},{key:"DROP_PART_FROM_COMPOUND",label:"\uD569\uC131\uC5B4\uC5D0\uC11C \uBD80\uBD84\uD0C8\uB77D",icon:"unlink",color:Ve,subTitle:"\uD569\uC131\uC5B4\uC758 \uC77C\uBD80\uB97C \uBE7C\uBA74 \uC5B4\uB5A4 \uB2E8\uC5B4\uAC00 \uB420\uAE4C\uC694?"},{key:"DROP_FINAL_CONSONANT_FROM_1SYLL",label:"1\uC74C\uC808\uC5D0\uC11C \uBC1B\uCE68 \uD0C8\uB77D",icon:"eraser",color:Ve,subTitle:"\uBC1B\uCE68\uC744 \uBE7C\uBA74 \uC5B4\uB5A4 \uC18C\uB9AC\uAC00 \uB420\uAE4C\uC694?"},{key:"REMOVE_CONSONANT_AND_IDENTIFY_PHONEME",label:"1\uC74C\uC808\uC5D0\uC11C \uC790\uC74C \uD0C8\uB77D",icon:"audio-lines",color:Ve,subTitle:"\uC790\uC74C\uC744 \uBE7C\uBA74 \uC5B4\uB5A4 \uC18C\uB9AC\uAC00 \uB0A8\uC744\uAE4C\uC694?"}]},{key:"substitution",label:"\uB300\uCE58\uD6C8\uB828",disc:"\uB2E8\uC5B4\uC758 \uC77C\uBD80 \uC74C\uC808\uC774\uB098 \uC74C\uC18C\uB97C \uBC14\uAFB8\uC5B4 \uC0C8\uB85C\uC6B4 \uC18C\uB9AC\uB97C \uB9CC\uB4DC\uB294 \uD6C8\uB828\uC785\uB2C8\uB2E4.",icon:"replace",types:[{key:"CHANGE_1_SYLL_IN_2SYLL",label:"2\uC74C\uC808\uC5D0\uC11C \uD55C \uC74C\uC808 \uBC14\uAFB8\uAE30",icon:"replace",color:ru,subTitle:"2\uC74C\uC808 \uB2E8\uC5B4\uC758 \uD55C \uC74C\uC808\uC744 \uBC14\uAFD4 \uC0C8 \uB2E8\uC5B4\uB97C \uB9CC\uB4DC\uC138\uC694."},{key:"CHANGE_1_SYLL_IN_3SYLL",label:"3\uC74C\uC808\uC5D0\uC11C \uD55C \uC74C\uC808 \uBC14\uAFB8\uAE30",icon:"shuffle",color:ru,subTitle:"3\uC74C\uC808 \uB2E8\uC5B4\uC758 \uD55C \uC74C\uC808\uC744 \uBC14\uAFD4 \uC0C8 \uB2E8\uC5B4\uB97C \uB9CC\uB4DC\uC138\uC694."},{key:"CHANGE_1_PHONEME_IN_1SYLL",label:"1\uC74C\uC808\uC5D0\uC11C \uD55C \uC74C\uC18C \uBC14\uAFB8\uAE30",icon:"arrow-right-left",color:ru,subTitle:"1\uC74C\uC808 \uB2E8\uC5B4\uC758 \uD55C \uC74C\uC18C\uB97C \uBC14\uAFD4 \uC0C8 \uC18C\uB9AC\uB97C \uB9CC\uB4DC\uC138\uC694."},{key:"CHANGE_1_PHONEME_IN_2SYLL",label:"2\uC74C\uC808\uC5D0\uC11C \uD55C \uC74C\uC18C \uBC14\uAFB8\uAE30",icon:"flip-horizontal",color:ru,subTitle:"2\uC74C\uC808 \uB2E8\uC5B4\uC758 \uD55C \uC74C\uC18C\uB97C \uBC14\uAFD4 \uC0C8 \uB2E8\uC5B4\uB97C \uB9CC\uB4DC\uC138\uC694."}]},{key:"attention",label:"\uCCAD\uAC01\uC801\uC8FC\uC758\uB825\uD6C8\uB828",disc:"\uC5EC\uB7EC \uC18C\uB9AC\uB97C \uB4E3\uACE0 \uC21C\uC11C\uB97C \uAE30\uC5B5\uD558\uB294 \uC8FC\uC758\uB825\uACFC \uB2E8\uAE30 \uAE30\uC5B5 \uD6C8\uB828\uC785\uB2C8\uB2E4.",icon:"list-ordered",types:[{key:"LISTEN_AND_REMEMBER_ORDER",label:"\uB4E3\uACE0 \uC21C\uC11C\uB300\uB85C \uAE30\uC5B5\uD558\uAE30",icon:"list-ordered",color:ar,subTitle:"\uC138 \uB2E8\uC5B4\uB97C \uB4E4\uC740 \uC21C\uC11C\uB300\uB85C \uCE74\uB4DC\uB97C \uC120\uD0DD\uD558\uC138\uC694."}]}];function ir(){const{t:e}=ce.useTranslation();return s.useMemo(()=>{const u=Object.fromEntries(lr(e).map(n=>[n.key,n.label])),t={...u};return sr.flatMap(n=>n.types).forEach(n=>{t[n.key]=e(`trainingType.${n.key}.label`,{defaultValue:n.label})}),{sentence:u,all:t}},[e])}const cr="0.138.0";function Cr({computeStyle:e,onScroll:u="close",onResize:t="close",ignoreOutsideClickSelector:n}){const[o,r]=s.useState(!1),[l,a]=s.useState({}),i=s.useRef(null),c=s.useRef(null),g=s.useCallback(()=>{i.current&&a(e(i.current.getBoundingClientRect()))},[e]);s.useEffect(()=>{if(!o)return;g();const h=y=>{const m=y.target;n&&m.closest?.(n)||i.current?.contains(m)||c.current?.contains(m)||r(!1)};document.addEventListener("mousedown",h);const f=y=>{c.current?.contains(y.target)||(u==="reposition"?g():u==="close"&&r(!1))};u!=="ignore"&&window.addEventListener("scroll",f,!0);const w=()=>{t==="reposition"?g():t==="close"&&r(!1)};return t!=="ignore"&&window.addEventListener("resize",w),()=>{document.removeEventListener("mousedown",h),u!=="ignore"&&window.removeEventListener("scroll",f,!0),t!=="ignore"&&window.removeEventListener("resize",w)}},[o,g,u,t,n]),s.useEffect(()=>{if(o)return vt(()=>r(!1))},[o]);const d=s.useCallback(()=>r(h=>!h),[]),C=s.useCallback(()=>r(!1),[]);return{open:o,setOpen:r,toggle:d,close:C,style:l,triggerRef:i,menuRef:c}}function dr(e,{mode:u="playback",autoStart:t=!1,onPlaySpeaker:n,onComplete:o,playMs:r=1100,feedbackMs:l=1500}={}){const[a,i]=s.useState([]),[c,g]=s.useState(0),[d,C]=s.useState("idle"),[h,f]=s.useState(null),[w,y]=s.useState([]),[m,p]=s.useState(null),[E,B]=s.useState(0),_=s.useRef(0),b=s.useCallback(R=>{_.current=typeof R=="function"?R(_.current):R,B(_.current)},[]),O=s.useRef(n),T=s.useRef(o);s.useEffect(()=>{O.current=n,T.current=o},[n,o]);const L=s.useRef([]),D=()=>{L.current.forEach(clearTimeout),L.current=[]},$=(R,x)=>{L.current.push(setTimeout(x,R))};s.useEffect(()=>()=>D(),[]);const G=a[c]?.id??null,Y=s.useRef(null),M=s.useCallback(()=>{D(),C("playing"),y([]),p(null),b(0);let R=0;e.forEach((x,Q)=>{$(R,()=>{g(Q),f(x.id),O.current?.(x)}),$(R+1e3,()=>{f(null),y(v=>[...v,x.id])}),R+=1300}),$(R,()=>{C("done"),T.current?.({score:0,total:e.length})})},[e,b]),k=s.useCallback((R,x)=>{if(x>=R.length){C("done"),T.current?.({score:_.current,total:R.length});return}Y.current=null,g(x),p(null),C("playing"),f(R[x].id),O.current?.(R[x]),$(r,()=>{f(null),C("waiting")})},[r]),H=s.useCallback(()=>{D();const R=F(e);i(R),b(0),y([]),k(R,0)},[e,k,b]),U=s.useCallback(()=>{u==="playback"?(i(e),M()):H()},[u,e,M,H]),ee=s.useCallback(()=>{D(),C("idle"),f(null),y([]),p(null),g(0),b(0),i([])},[b]),me=e.map(R=>R.id).join("|");s.useEffect(()=>(t?U():ee(),()=>D()),[u,me,t]);const A=s.useCallback(R=>{d!=="waiting"||u==="playback"||Y.current===c||(Y.current=c,p(R),R===a[c]?.id&&b(x=>x+1),u==="exam"?(C("playing"),$(400,()=>k(a,c+1))):(C("feedback"),$(l,()=>k(a,c+1))))},[d,u,a,c,k,l,b]),N=u==="playback"?e.length:a.length;return{bind:{activeSpeakerId:h,playedIds:w,selectedId:m,answerId:G,showFeedback:d==="feedback",clickable:d==="waiting",onSelectSpeaker:A},index:c,total:N,score:E,phase:d,done:d==="done",start:U,reset:ee}}exports.CACHE_GROUPS=Ku,exports.CORE_VERSION=cr,exports.DocumentTitleSuppressContext=Fu,exports.EMPTY_COMPOSITION=Au,exports.MediaQueryOverrideContext=Lu,exports.NO_CODA=re,exports.SYLLABLE_MIN=le,exports.VAP_PAGE_SIZE_OPTIONS=Ue,exports.buildGradeSection=ht,exports.buildPartOfSpeechSection=mt,exports.buildPositionSection=Bo,exports.buildSelectSection=wo,exports.buildSyllableSection=Eo,exports.buildWordTypeSection=pt,exports.charToPronValue=At,exports.convertComposition=Dt,exports.fmtBytes=En,exports.lsBytes=Wu,exports.meaningKey=Nu,exports.pronToCharValue=_t,exports.syllableToFilter=wu,exports.today=Ne,exports.toggleAttributeFilter=bo,exports.useAnchoredMenu=Cr,exports.useCacheManagement=wn,exports.useDailyTrainingSelection=Qo,exports.useDelayedHoverAnchor=ur,exports.useDeviceManagement=jn,exports.useDocumentTitle=en,exports.useEscToClose=Zo,exports.useFontScale=qt,exports.useHoverAnchor=er,exports.useMediaQuery=Xt,exports.usePagedList=tr,exports.usePasswordChange=on,exports.useRelativeDay=un,exports.useSoundCompassExam=dr,exports.useTablePaging=Nn,exports.useTableSort=Tn,exports.useToastState=nr,exports.useTrainingTypeLabels=ir,exports.useVisitAllPanel=On,exports.useVisitHistory=An,exports.useVisitSchedule=Dn,exports.useWindowEvent=Pu,exports.useWordAttributeFilterKeys=gt,exports.useWordDataStats=Bn,exports.useWordMeanings=Xo,exports.useWordTrainingDataGeneration=Ho,exports.useWordTrainingFilter=Vo,exports.valueToJamos=ie;
|