@readerseye2/cr_viewer 1.0.31 → 1.0.33
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/dist/CR_Viewer.d.ts +5 -1
- package/dist/CR_Viewer.d.ts.map +1 -1
- package/dist/components/btns/SolveQuizBtn.d.ts.map +1 -1
- package/dist/components/quiz/QuizRenderer.d.ts.map +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.js +2249 -2191
- package/dist/stores/quizprogress/quiz_progress.provider.d.ts +2 -0
- package/dist/stores/quizprogress/quiz_progress.provider.d.ts.map +1 -1
- package/dist/stores/quizprogress/quiz_progress.store.d.ts +8 -2
- package/dist/stores/quizprogress/quiz_progress.store.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('@charset "UTF-8";._run_zzb61_3{cursor:pointer}._runWrap_zzb61_7{position:relative;isolation:isolate;z-index:0}._highlight_zzb61_13:before,._highlightleft_zzb61_14:before,._highlightright_zzb61_15:before,._highlightcenter_zzb61_16:before{content:"";position:absolute;z-index:-1;top:-4px;bottom:-4px;background:var(--hl-color, pink);pointer-events:none}._highlight_zzb61_13:before{left:-4px;right:-4px}._highlightleft_zzb61_14:before{left:-4px;right:0}._highlightright_zzb61_15:before{left:0;right:-4px}._highlightcenter_zzb61_16:before{left:0;right:0}._underline_zzb61_48:after,._underlineleft_zzb61_49:after,._underlineright_zzb61_50:after,._underlinecenter_zzb61_51:after{content:"";position:absolute;left:0;right:0;height:var(--ul-thickness, .2em);bottom:calc(-1 * var(--ul-offset, .35em));background:var(--ul-color, red);pointer-events:none}._underline_zzb61_48:after{left:-4px;right:-4px}._underlineleft_zzb61_49:after{left:-4px;right:0}._underlineright_zzb61_50:after{left:0;right:0}._underlinecenter_zzb61_51:after{left:0;right:0}._scroller_kqkmq_3{height:100%;overflow-y:auto;overflow-x:hidden;outline:none;scrollbar-width:none;-ms-overflow-style:none}._scroller_kqkmq_3::-webkit-scrollbar{width:0;height:0;background:transparent;pointer-events:none}._scroller_kqkmq_3::-webkit-scrollbar-track{background:transparent;pointer-events:none}._scroller_kqkmq_3::-webkit-scrollbar-thumb{background:transparent;pointer-events:none}._scroller_kqkmq_3::-webkit-scrollbar-button,._scroller_kqkmq_3::-webkit-scrollbar-corner{display:none;pointer-events:none}@media(forced-colors:active){._scroller_kqkmq_3{scrollbar-width:auto}}._navBtn_1fciy_2{-webkit-appearance:none;-moz-appearance:none;appearance:none;display:flex;flex-direction:column;align-items:center;justify-content:center;width:44px;height:44px;border:none;border-radius:8px;background:none;flex-shrink:0;color:#222;font-size:12px;font-weight:600;cursor:pointer;transition:all .15s ease}._navBtn_1fciy_2:hover:not(:disabled){background:#0000000f}._navBtn_1fciy_2:active:not(:disabled){background:#0000001a}._navBtn_1fciy_2:disabled,._navBtn_1fciy_2._disabled_1fciy_26{opacity:.4;cursor:not-allowed;transform:none}._label_1fciy_32{margin-top:2px;font-size:.55rem;font-weight:500;text-align:center}._navGroup_1fciy_40{display:flex;gap:8px}._wrap_1hfub_4{position:absolute;left:0;right:0;bottom:0;height:auto;display:flex;flex-direction:column;padding:8px 8px 10px;box-sizing:border-box;background:#fff;color:#333;border-top:1px solid #ddd;transition:opacity .15s ease;opacity:0;pointer-events:none;container-type:inline-size;container-name:bottombar}._visible_1hfub_25{opacity:1;pointer-events:auto}._compact_1hfub_31{padding:6px 8px 8px}._compact_1hfub_31 ._row2_1hfub_34{display:none}@container bottombar (min-width: 600px){._compact_1hfub_31 ._row2_1hfub_34{display:contents}}._controls_1hfub_44{display:flex;flex-wrap:wrap;align-items:center;gap:4px}._row1_1hfub_52,._row2_1hfub_34{display:flex;align-items:center;justify-content:space-between;width:100%;gap:4px}._row2_1hfub_34{margin-top:4px}@container bottombar (min-width: 500px){._row1_1hfub_52,._row2_1hfub_34{display:contents}._controls_1hfub_44{flex-wrap:nowrap;justify-content:space-between}._row2_1hfub_34{margin-top:0}}._groupExpand_1hfub_80,._groupPlayback_1hfub_81,._groupSpeed_1hfub_82,._groupFeatures_1hfub_83,._groupNav_1hfub_84{display:flex;align-items:center;flex-shrink:0}._groupExpand_1hfub_80{gap:0}._groupPlayback_1hfub_81{gap:2px}._groupSpeed_1hfub_82{gap:0}._groupFeatures_1hfub_83,._groupNav_1hfub_84{gap:2px}._btn_1hfub_116{-webkit-appearance:none;-moz-appearance:none;appearance:none;display:flex;flex-direction:column;align-items:center;justify-content:center;width:44px;height:44px;border:none;border-radius:8px;background:none;color:#222;font-size:12px;font-weight:600;cursor:pointer;transition:all .15s ease;flex-shrink:0}._btn_1hfub_116:hover{background:#0000000f}._btn_1hfub_116:active{background:#0000001f}._btnForbidden_1hfub_141{opacity:.4;cursor:not-allowed;background:#f2f2f2!important}._btnActive_1hfub_147{background:#333;color:#fff}._btnActive_1hfub_147:hover{background:#555}._btnActive_1hfub_147:active{background:#666}._label_1hfub_158{margin-top:2px;font-size:.55rem;font-weight:500;text-align:center;font-variant-numeric:tabular-nums;white-space:nowrap}._compactBtn_1hfub_168{display:flex;align-items:center;justify-content:center;width:34px;height:34px;border:none;border-radius:4px;background:none;color:#000;cursor:pointer;padding:2px;flex-shrink:0}._compactBtn_1hfub_168:hover{background:#0000000f}._compactBtn_1hfub_168:active{background:#0000001f}._scrubberWrap_uw0cd_2{display:grid;gap:8px;-webkit-user-select:none;user-select:none;margin-bottom:6px}._labels_uw0cd_9{display:flex;justify-content:space-between;font-size:12px;color:var(--text-subtle, #666)}._labels_uw0cd_9 ._index_uw0cd_15{font-variant-numeric:tabular-nums}._controls_uw0cd_19{display:grid;grid-template-columns:1fr 40px;align-items:center;gap:8px}._controls_uw0cd_19 ._percent_uw0cd_25{display:flex;justify-content:flex-end;font-size:.8rem;font-variant-numeric:tabular-nums}._stepBtn_uw0cd_32{height:28px;border:1px solid var(--line, #ddd);background:var(--bg, #fff);border-radius:8px;font-size:16px;line-height:1;cursor:pointer}._stepBtn_uw0cd_32:disabled{opacity:.5;cursor:not-allowed}._range_uw0cd_46{width:100%;-webkit-appearance:none;-moz-appearance:none;appearance:none;height:6px;border-radius:999px;background:linear-gradient(to right,currentColor var(--pct, 50%),#e5e7eb 0);outline:none}._range_uw0cd_46::-webkit-slider-thumb{-webkit-appearance:none;width:16px;height:16px;border-radius:999px;background:currentColor;cursor:pointer}._range_uw0cd_46::-moz-range-thumb{width:16px;height:16px;border-radius:999px;background:currentColor;border:none;cursor:pointer}._WPMSpeedButtonsWrap_r3byt_1{float:right;box-sizing:border-box;display:flex;flex-direction:column}._WPMSpeedButtonsWrap_r3byt_1 ._btnWrap_r3byt_7{box-sizing:border-box;padding:2px;display:flex;gap:1px;align-items:center}._WPMSpeedButtonsWrap_r3byt_1 ._btnWrap_r3byt_7 ._label_r3byt_14{font-size:.55rem;display:flex;flex-direction:column;justify-content:center;align-items:center;min-width:24px}._WPMSpeedButtonsWrap_r3byt_1 ._btnWrap_r3byt_7 ._iconBtn_r3byt_22{padding:2px;border-radius:4px;border:1px solid #888;background:none;width:34px;height:34px;flex-shrink:0;cursor:pointer;transition:all .15s ease}._WPMSpeedButtonsWrap_r3byt_1 ._btnWrap_r3byt_7 ._iconBtn_r3byt_22:hover{background:#0000000f}._WPMSpeedButtonsWrap_r3byt_1 ._btnWrap_r3byt_7 ._iconBtn_r3byt_22:active{background:#0000001f}._WPMSpeedButtonsWrap_r3byt_1 ._btnWrap_r3byt_7 ._iconBtn_r3byt_22 img{width:100%;height:100%;object-fit:contain}._StepBtn_15t0r_1{background:none;border:none;border-radius:8px;font-size:1.6rem;display:flex;justify-content:center;align-items:center;color:#000;flex-shrink:0;width:34px;height:34px;cursor:pointer;transition:all .15s ease}._StepBtn_15t0r_1:hover{background:#0000000f}._StepBtn_15t0r_1:active{background:#0000001f}._GCPlayBtn_n54mc_1{width:var(--btn-size);height:var(--btn-size);box-sizing:border-box;border:none;outline:none;position:relative;background:none;border-radius:8px;transition:all .15s ease;cursor:pointer}._GCPlayBtn_n54mc_1:hover{background:#0000000f}._GCPlayBtn_n54mc_1:active{background:#0000001f}._GCPlayBtn_n54mc_1:focus{outline:none}._GCPlayBtn_n54mc_1:before{content:"";position:absolute;top:calc(var(--btn-size) * .3);left:calc(var(--btn-size) * .34);height:0;border-style:solid;border-width:calc(var(--btn-size) * .2) 0 calc(var(--btn-size) * .2) calc(var(--btn-size) * .4);border-color:transparent transparent transparent var(--icon-color);transition:.2s ease;transform:scale(1.3)}._GCPlayBtn_n54mc_1._playing_n54mc_34:before{top:calc(var(--btn-size) * .3);left:calc(var(--btn-size) * .32);width:calc(var(--btn-size) * .12);height:calc(var(--btn-size) * .4);border:none;background-color:var(--icon-color);box-shadow:calc(var(--btn-size) * .18) 0 0 0 var(--icon-color)}._host_gafql_3{position:absolute;left:0;right:0;top:0;z-index:30}._topbar_gafql_11{position:absolute;left:0;right:0;top:0;height:48px;display:flex;align-items:center;gap:8px;padding:0 12px;background:#fff;color:#033233;-webkit-backdrop-filter:saturate(120%) blur(6px);backdrop-filter:saturate(120%) blur(6px);transition:opacity .15s ease;opacity:0;pointer-events:none;border-bottom:4px solid #033233;box-sizing:border-box}._visible_gafql_32{opacity:1;pointer-events:auto}._backBtn_gafql_37{display:flex;align-items:center;justify-content:center;width:44px;height:44px;border:none;background:transparent;color:#033233;cursor:pointer;border-radius:50%;flex-shrink:0;transition:background .15s ease}._backBtn_gafql_37:hover{background:#0000000d}._backBtn_gafql_37:active{background:#0000004d}._title_gafql_58{font-size:18px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1}._calibrationBtn_gafql_67{display:flex;align-items:center;justify-content:center;width:44px;height:44px;border:none;background:transparent;color:#033233;cursor:pointer;border-radius:50%;flex-shrink:0;transition:background .15s ease}._calibrationBtn_gafql_67:hover{background:#0000000d}._calibrationBtn_gafql_67:active{background:#0000004d}._calibrationBtn_gafql_67._disabled_gafql_87{opacity:.4;cursor:not-allowed}._calibrationBtn_gafql_67._disabled_gafql_87:hover,._calibrationBtn_gafql_67._disabled_gafql_87:active{background:transparent}._settingsBtn_gafql_95{display:flex;align-items:center;justify-content:center;width:44px;height:44px;border:none;background:transparent;color:#033233;cursor:pointer;border-radius:50%;flex-shrink:0;transition:background .15s ease}._settingsBtn_gafql_95:hover{background:#0000000d}._settingsBtn_gafql_95:active{background:#0000004d}._wrap_62su0_7{position:absolute;pointer-events:auto;background:#fff;color:#111;box-shadow:0 -6px 24px #0000001f;padding:20px 0;box-sizing:border-box;display:flex;flex-direction:column;align-items:center;gap:10px;overflow-y:auto;left:0;right:0;bottom:0;max-height:70%;border-top:1px solid rgba(0,0,0,.08);border-radius:16px 16px 0 0}._wrapHidden_62su0_29{transform:translateY(100%);visibility:hidden;transition:transform .22s ease,visibility 0s .22s}._wrapVisible_62su0_35{transform:translateY(0);visibility:visible;transition:transform .22s ease,visibility 0s 0s}@container viewer (min-aspect-ratio: 1/1){._wrap_62su0_7{left:auto;right:0;top:0;bottom:0;max-height:100%;width:400px;max-width:60%;border-top:none;border-left:1px solid rgba(0,0,0,.08);border-radius:0;box-shadow:-6px 0 24px #0000001f;padding:20px}._wrapHidden_62su0_29{transform:translate(100%);visibility:hidden;transition:transform .22s ease,visibility 0s .22s}._wrapVisible_62su0_35{transform:translate(0);visibility:visible;transition:transform .22s ease,visibility 0s 0s}}._scrollArea_62su0_71{width:100%;display:flex;flex-direction:column;max-width:400px;padding:0 20px;gap:10px;box-sizing:border-box}._row_62su0_81{display:flex;align-items:center;justify-content:space-between;gap:20px;min-height:45px}._label_62su0_89{width:78px;flex:0 0 78px;font-weight:700}._btn_62su0_95{-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:pointer;border:1px solid rgba(0,0,0,.16);background:#fff;color:#111;border-radius:8px;padding:8px 10px;font-size:13px}._btnActive_62su0_106{background:#00000014}._btnSmall_62su0_110{-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:pointer;border:1px solid rgba(0,0,0,.16);background:#fff;color:#111;border-radius:8px;padding:4px 8px;font-size:14px;line-height:1}._pill_62su0_122{-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:pointer;background:#fff;color:#111;border:1px solid rgba(0,0,0,.16);border-radius:999px;padding:8px 12px;font-size:13px}._themeCircle_62su0_133{width:40px;height:40px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-weight:600;cursor:pointer;transition:all .2s ease;border:1px solid rgba(0,0,0,.15)}._themeCircleActive_62su0_146{border:2px solid #007aff;box-shadow:0 0 0 2px #007aff40}._stepRow_62su0_151{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:40px}._stepLabel_62su0_159{width:78px;flex:0 0 78px;font-weight:700}._stepValue_62su0_165{margin-left:auto;width:72px;text-align:right;font-variant-numeric:tabular-nums}._levelBox_62su0_172{width:28px;text-align:center}._inlineFlex_62su0_177{display:flex;align-items:center;gap:6px;flex-wrap:wrap}._wrapper_dbk3n_1{display:grid;place-items:center;position:absolute;top:0;right:0;bottom:0;left:0;z-index:10000;pointer-events:none}._spinner_dbk3n_10{border-radius:50%;border:3px solid #e5e7eb;border-top-color:#3b82f6;animation:_spin_dbk3n_10 linear infinite}@keyframes _spin_dbk3n_10{to{transform:rotate(360deg)}}._Overlay_ybic8_3{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%;background:#11182773;display:flex;align-items:center;justify-content:center;z-index:50}._Dialog_ybic8_15{width:min(760px,90%);max-height:80vh;overflow:auto;background:#fff;border-radius:16px;box-shadow:0 24px 48px #00000040;padding:20px}._Body_ybic8_25{margin-left:20px;margin-right:20px;display:block}._Header_ybic8_32{display:flex;align-items:center;gap:12px;margin-bottom:12px}._Paging_ybic8_39{font-weight:700;font-size:1rem;color:#333;display:flex;justify-content:center;width:100%}._Remaining_ybic8_48{margin-left:auto;font-weight:700;font-size:1rem;color:#fff}._RemainingDanger_ybic8_55{color:#dc2626}._NextBtn_ybic8_59{padding:10px 16px;border-radius:10px;border:none;background:#2563eb;color:#fff;font-size:1.2rem;font-weight:700;cursor:pointer;width:100%}@keyframes _nextbtn-blink_ybic8_1{0%,49%{transform:none;box-shadow:0 0 #dc262600;outline:0 solid rgba(220,38,38,0);filter:none}50%,to{box-shadow:0 0 0 2px #dc262659,0 6px 14px #dc262640;outline:2px solid rgba(220,38,38,.45)}}._NextBtn_ybic8_59:has(._RemainingDanger_ybic8_55){animation:_nextbtn-blink_ybic8_1 1s steps(2,start) infinite}._NextBtn_ybic8_59:has(._RemainingDanger_ybic8_55):hover,._NextBtn_ybic8_59:has(._RemainingDanger_ybic8_55):focus-visible{animation-play-state:running}._CloseBtn_ybic8_96{margin-left:8px;border:none;background:transparent;color:#6b7280;cursor:pointer;font-size:14px}._Title_ybic8_106{font-weight:700;font-size:18px;margin-bottom:8px;color:#111827}._Question_ybic8_113{font-size:1.2rem;color:#111827;font-weight:700;display:flex;justify-content:center;align-items:center}._Score_ybic8_123{display:flex;justify-content:center;align-items:center;margin-bottom:16px}._Image_ybic8_130{width:100%;display:flex;justify-content:center}._Image_ybic8_130 img{width:80%}._Options_ybic8_140{display:grid;gap:8px}._OptionBtn_ybic8_145{text-align:left;padding:12px 14px;border-radius:10px;border:1px solid #e5e7eb;background:#fff;color:#111827;cursor:pointer;font-size:1rem;transition:box-shadow .15s ease,border-color .15s ease,background .15s ease;display:flex;justify-content:center;align-items:center}._OptionBtn_ybic8_145:hover{border-color:#cbd5e1;background:#f9fafb}._OptionBtnActive_ybic8_165{border-color:#2563eb;background:#2563eb14;box-shadow:0 4px 10px #2563eb33}._Footer_ybic8_172{display:flex;justify-content:space-between;margin-top:16px;gap:8px}._PrevBtn_ybic8_179{flex:0 0 auto;padding:10px 14px;border-radius:10px;border:1px solid #e5e7eb;background:#fff;color:#111827;cursor:pointer}._PrevBtn_ybic8_179:disabled{cursor:not-allowed;opacity:.6}._OptionBtnCorrect_ybic8_195{border-color:#16a34a!important;box-shadow:0 4px 10px #16a34a33}._Judge_ybic8_201{margin:6px 0 10px;font-weight:700;font-size:1.5rem;padding:4px;width:100%;border-radius:10px;display:flex;justify-content:center;color:#fff}._Judge_ybic8_201._Correct_ybic8_212{background:#16a34a}._Judge_ybic8_201._Incorrect_ybic8_215{background:#dc2626}._ResultHeader_ybic8_220{font-weight:800;font-size:20px;margin-bottom:8px;color:#111827}._ResultText_ybic8_227{font-size:16px;margin-bottom:12px;color:#111827}._ResultActions_ybic8_233{display:flex;justify-content:flex-end;gap:8px}._CloseBtnSoft_ybic8_239{padding:10px 16px;border-radius:10px;border:1px solid #e5e7eb;background:#fff;color:#111827;cursor:pointer}._SummaryGrid_ybic8_249{display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:12px;margin:12px 0 16px}._StatCard_ybic8_257{border:1px solid #e5e7eb;border-radius:12px;padding:12px 14px;background:#fff;box-shadow:0 2px 6px #1118270f}._StatLabel_ybic8_265{font-size:12px;color:#6b7280}._StatValue_ybic8_270{font-size:22px;font-weight:800;margin-top:4px;color:#111827}._StatSub_ybic8_277{font-size:12px;color:#6b7280}._SplitGrid_ybic8_282{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:8px 0 12px}._SplitBox_ybic8_289{border:1px dashed #e5e7eb;border-radius:10px;padding:10px 12px}._SplitTitle_ybic8_295{font-size:12px;color:#6b7280}._SplitText_ybic8_300{font-size:16px;font-weight:700;color:#111827;margin-top:2px}._Pairs_ybic8_307{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:8px 0 12px}._PairItem_ybic8_314{border:1px solid #f3f4f6;border-radius:10px;padding:10px 12px;background:#fafafa}._PairLabel_ybic8_321{font-size:12px;color:#6b7280}._PairValue_ybic8_326{font-size:15px;font-weight:700;margin-top:2px;color:#111827}._WrongBox_ybic8_333{margin-top:8px;border-top:1px solid #e5e7eb;padding-top:10px}._WrongTitle_ybic8_339{font-weight:700;font-size:14px;color:#111827;margin-bottom:6px}._WrongList_ybic8_346{list-style:none;padding:0;margin:0}._WrongList_ybic8_346 li{display:flex;align-items:center;gap:8px;padding:6px 0;border-bottom:1px dashed #f3f4f6}._Badge_ybic8_360{display:inline-block;font-size:12px;padding:2px 6px;border-radius:999px;background:#eef2ff;color:#3730a3;font-weight:700}._WrongName_ybic8_370{flex:1;color:#111827;font-size:14px}._WrongTime_ybic8_376{font-size:12px;color:#6b7280}._Empty_ybic8_381{color:#6b7280;font-size:13px}._Hint_ybic8_387{margin-top:8px;font-size:12px;color:#6b7280}._handle_1ihf3_1{position:absolute;width:26px;height:26px;background-color:#3b82f6;box-shadow:0 2px 4px #0000004d;cursor:grab;z-index:10001;touch-action:none}._handle_1ihf3_1:active{cursor:grabbing;background-color:#2563eb}._handleStart_1ihf3_16{border-radius:13px 0 13px 13px}._handleEnd_1ihf3_21{border-radius:0 13px 13px}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var zs=Object.defineProperty;var Ps=(e,t,n)=>t in e?zs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ir=(e,t,n)=>Ps(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react/jsx-runtime"),h=require("react"),Bs=require("react-dom");function As(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const $e=As(h),ir=h.createContext(void 0);var Yt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Po(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Qt={exports:{}},Sn={},Zt={exports:{}},yn={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* use-sync-external-store-shim.production.js
|
|
5
5
|
*
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* This source code is licensed under the MIT license found in the
|
|
9
9
|
* LICENSE file in the root directory of this source tree.
|
|
10
|
-
*/var Tr;function
|
|
10
|
+
*/var Tr;function Gs(){if(Tr)return yn;Tr=1;var e=h;function t(m,p){return m===p&&(m!==0||1/m===1/p)||m!==m&&p!==p}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,s=e.useLayoutEffect,i=e.useDebugValue;function u(m,p){var b=p(),S=r({inst:{value:b,getSnapshot:p}}),w=S[0].inst,c=S[1];return s(function(){w.value=b,w.getSnapshot=p,a(w)&&c({inst:w})},[m,b,p]),o(function(){return a(w)&&c({inst:w}),m(function(){a(w)&&c({inst:w})})},[m]),i(b),b}function a(m){var p=m.getSnapshot;m=m.value;try{var b=p();return!n(m,b)}catch{return!0}}function l(m,p){return p()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:u;return yn.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:d,yn}var wn={};/**
|
|
11
11
|
* @license React
|
|
12
12
|
* use-sync-external-store-shim.development.js
|
|
13
13
|
*
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*
|
|
16
16
|
* This source code is licensed under the MIT license found in the
|
|
17
17
|
* LICENSE file in the root directory of this source tree.
|
|
18
|
-
*/var kr;function Ls(){return kr||(kr=1,process.env.NODE_ENV!=="production"&&(function(){function e(S
|
|
18
|
+
*/var kr;function Ls(){return kr||(kr=1,process.env.NODE_ENV!=="production"&&(function(){function e(b,S){return b===S&&(b!==0||1/b===1/S)||b!==b&&S!==S}function t(b,S){d||o.startTransition===void 0||(d=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var w=S();if(!m){var c=S();s(w,c)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),m=!0)}c=i({inst:{value:w,getSnapshot:S}});var f=c[0].inst,g=c[1];return a(function(){f.value=w,f.getSnapshot=S,n(f)&&g({inst:f})},[b,w,S]),u(function(){return n(f)&&g({inst:f}),b(function(){n(f)&&g({inst:f})})},[b]),l(w),w}function n(b){var S=b.getSnapshot;b=b.value;try{var w=S();return!s(b,w)}catch{return!0}}function r(b,S){return S()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=h,s=typeof Object.is=="function"?Object.is:e,i=o.useState,u=o.useEffect,a=o.useLayoutEffect,l=o.useDebugValue,d=!1,m=!1,p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:t;wn.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:p,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),wn}var Rr;function Bo(){return Rr||(Rr=1,process.env.NODE_ENV==="production"?Zt.exports=Gs():Zt.exports=Ls()),Zt.exports}/**
|
|
19
19
|
* @license React
|
|
20
20
|
* use-sync-external-store-shim/with-selector.production.js
|
|
21
21
|
*
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the MIT license found in the
|
|
25
25
|
* LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/var _r;function Hs(){if(_r)return Sn;_r=1;var e=h,t=Bo();function n(
|
|
26
|
+
*/var _r;function Hs(){if(_r)return Sn;_r=1;var e=h,t=Bo();function n(l,d){return l===d&&(l!==0||1/l===1/d)||l!==l&&d!==d}var r=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,s=e.useRef,i=e.useEffect,u=e.useMemo,a=e.useDebugValue;return Sn.useSyncExternalStoreWithSelector=function(l,d,m,p,b){var S=s(null);if(S.current===null){var w={hasValue:!1,value:null};S.current=w}else w=S.current;S=u(function(){function f(E){if(!g){if(g=!0,C=E,E=p(E),b!==void 0&&w.hasValue){var x=w.value;if(b(x,E))return T=x}return T=E}if(x=T,r(C,E))return x;var y=p(E);return b!==void 0&&b(x,y)?(C=E,x):(C=E,T=y)}var g=!1,C,T,M=m===void 0?null:m;return[function(){return f(d())},M===null?void 0:function(){return f(M())}]},[d,m,p,b]);var c=o(l,S[0],S[1]);return i(function(){w.hasValue=!0,w.value=c},[c]),a(c),c},Sn}var Cn={};/**
|
|
27
27
|
* @license React
|
|
28
28
|
* use-sync-external-store-shim/with-selector.development.js
|
|
29
29
|
*
|
|
@@ -31,4 +31,4 @@
|
|
|
31
31
|
*
|
|
32
32
|
* This source code is licensed under the MIT license found in the
|
|
33
33
|
* LICENSE file in the root directory of this source tree.
|
|
34
|
-
*/var Mr;function Ns(){return Mr||(Mr=1,process.env.NODE_ENV!=="production"&&(function(){function e(a,d){return a===d&&(a!==0||1/a===1/d)||a!==a&&d!==d}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=h,n=Bo(),r=typeof Object.is=="function"?Object.is:e,o=n.useSyncExternalStore,s=t.useRef,i=t.useEffect,c=t.useMemo,l=t.useDebugValue;Cn.useSyncExternalStoreWithSelector=function(a,d,x,m,S){var v=s(null);if(v.current===null){var w={hasValue:!1,value:null};v.current=w}else w=v.current;v=c(function(){function f(E){if(!p){if(p=!0,C=E,E=m(E),S!==void 0&&w.hasValue){var g=w.value;if(S(g,E))return T=g}return T=E}if(g=T,r(C,E))return g;var y=m(E);return S!==void 0&&S(g,y)?(C=E,g):(C=E,T=y)}var p=!1,C,T,M=x===void 0?null:x;return[function(){return f(d())},M===null?void 0:function(){return f(M())}]},[d,x,m,S]);var u=o(a,v[0],v[1]);return i(function(){w.hasValue=!0,w.value=u},[u]),l(u),u},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Cn}var Er;function Fs(){return Er||(Er=1,process.env.NODE_ENV==="production"?Qt.exports=Hs():Qt.exports=Ns()),Qt.exports}var Ws=Fs();const Ds=zo(Ws),jr=e=>{let t;const n=new Set,r=(a,d)=>{const x=typeof a=="function"?a(t):a;if(!Object.is(x,t)){const m=t;t=d??(typeof x!="object"||x===null)?x:Object.assign({},t,x),n.forEach(S=>S(t,m))}},o=()=>t,c={setState:r,getState:o,getInitialState:()=>l,subscribe:a=>(n.add(a),()=>n.delete(a))},l=t=e(r,o,c);return c},qt=(e=>e?jr(e):jr),{useSyncExternalStoreWithSelector:$s}=Ds,Vs=e=>e;function pn(e,t=Vs,n){const r=$s(e.subscribe,e.getState,e.getInitialState,t,n);return h.useDebugValue(r),r}function J(e,t){const n=h.useContext(ir);if(!n)throw new Error("useCRViewerScopedStore must be used inside <InternalCRViewerProvider>");return pn(n,e,t)}function gn(){const e=h.useContext(ir);if(!e)throw new Error("useCRViewerStoreApi must be used inside <InternalCRViewerProvider>");return e}const yt=h.createContext(void 0),Go=h.createContext(void 0);function qs(){return qt((e,t)=>({emitCallback:null,isPlaybackMode:!1,playbackScale:1,dispatchHandler:null,applySnapshotHandler:null,setEmitCallback:n=>e({emitCallback:n}),emit:(n,r)=>{const{emitCallback:o,isPlaybackMode:s}=t();s||o&&o({...n,timestamp:r??Date.now()})},setPlaybackMode:n=>e({isPlaybackMode:n}),setPlaybackScale:n=>e({playbackScale:n}),setDispatchHandler:n=>e({dispatchHandler:n}),dispatch:n=>{const{dispatchHandler:r,isPlaybackMode:o}=t();if(!o){console.warn("[ViewerEventBridge] dispatch called but not in playback mode");return}r?r(n):console.warn("[ViewerEventBridge] dispatch called but no handler registered")},setApplySnapshotHandler:n=>e({applySnapshotHandler:n}),applySnapshot:n=>{const{applySnapshotHandler:r,isPlaybackMode:o}=t();if(!o){console.warn("[ViewerEventBridge] applySnapshot called but not in playback mode");return}r?r(n):console.warn("[ViewerEventBridge] applySnapshot called but no handler registered")}}))}function Us({children:e,onViewerEvent:t,isPlaybackMode:n=!1,playbackScale:r=1,viewerRef:o}){const s=h.useMemo(()=>qs(),[]);return h.useLayoutEffect(()=>(s.getState().setEmitCallback(t??null),()=>s.getState().setEmitCallback(null)),[t,s]),h.useLayoutEffect(()=>{s.getState().setPlaybackMode(n)},[n,s]),h.useLayoutEffect(()=>{s.getState().setPlaybackScale(r)},[r,s]),h.useLayoutEffect(()=>()=>{o&&(o.current=null)},[o]),b.jsx(yt.Provider,{value:s,children:b.jsx(Go.Provider,{value:o,children:e})})}function wt(){const e=h.useContext(yt);if(!e)throw new Error("useViewerEventBridgeStoreApi must be used inside <ViewerEventBridgeProvider>");return e}const lr=h.createContext(void 0);function vt(){const e=h.useContext(lr);if(!e)throw new Error("useProgressStoreApi must be used within InternalCRViewerProgressProvider");return e}function U(e,t){const n=h.useContext(lr);if(!n)throw new Error("useProgressStore must be used within InternalCRViewerProgressProvider");return pn(n,o=>e(o.progress),t)}function Ks({onSingle:e,onDouble:t,delay:n=250,shouldIgnoreTarget:r}){const o=h.useRef(null);h.useEffect(()=>()=>{o.current!=null&&(clearTimeout(o.current),o.current=null)},[]);const s=h.useCallback(c=>{if(!(r!=null&&r(c.target))&&c.detail===1){if(o.current!=null)return;o.current=window.setTimeout(()=>{o.current=null,e==null||e(c)},n)}},[n,e,r]),i=h.useCallback(c=>{r!=null&&r(c.target)||o.current!=null&&(clearTimeout(o.current),o.current=null)},[t,r]);return{onClick:s,onDoubleClick:i}}const on={light:{bg:"#ffffff",fg:"#111827",overlayBg:"#ffffff",overlayFg:"#111827",borderColor:"#333333"},dark:{bg:"#0b0b0b",fg:"#e5e7eb",overlayBg:"#0b0b0b",overlayFg:"#e5e7eb",borderColor:"#ffffff"},sepia:{bg:"#f4ecd8",fg:"#3e2f1c",overlayBg:"#f4ecd8",overlayFg:"#3e2f1c",borderColor:"#bfa87a"},green:{bg:"#e9f5e1",fg:"#1b3d1f",overlayBg:"#e9f5e1",overlayFg:"#1b3d1f",borderColor:"#93b48b"}},In=[8,16,24,40,64],Tn=[1.2,1.4,1.6,1.8,2,2.2,2.4],kn=[4,8,12,16,24],Zn=e=>Math.round(12+(e-1)*(16/11)),Xs=e=>{let t=1,n=1/0;for(let r=1;r<=12;r++){const o=Zn(r),s=Math.abs(o-e);s<n&&(t=r,n=s)}return t},Rn=(e,t)=>{let n=0,r=1/0;return t.forEach((o,s)=>{const i=Math.abs(o-e);i<r&&(r=i,n=s)}),n+1},Ao=[{label:"고딕체",value:"'Noto Sans KR', sans-serif"},{label:"명조체",value:"'Noto Serif KR', serif"},{label:"바탕체",value:"'Nanum Myeongjo', serif"}],He={mode:"page",theme:"light",fontFamily:Ao.find(e=>e.label==="명조체").value,fontSizePx:18,lineHeight:1.8,marginX:20,marginY:24,showOverlays:!0,overlayCompactMode:!0,isSettingsOpen:!1,pointerStyle:"highlight",pointerColor:"#fff59d",breakMarks:{slash:!0},breakGapPx:8,muteAudio:!1,audioSpeed:1,showPointer:!0,showSplit:!0,viewportWidth:0,viewportHeight:0,isDev:!1};function Ys(e){const{init:t,recorderStore:n}=e??{};return qt((r,o)=>({...He,...t,setMode:s=>r({mode:s}),setTheme:s=>r({theme:s}),setFontFamily:s=>r({fontFamily:s}),setFontSizePx:s=>r({fontSizePx:s}),setLineHeight:s=>r({lineHeight:s}),setMarginX:s=>r({marginX:s}),setMarginY:s=>r({marginY:s}),setShowOverlays:s=>r({showOverlays:s}),toggleOverlays:()=>{const s=!o().showOverlays;r({showOverlays:s,...s&&{overlayCompactMode:!0}})},setOverlayCompactMode:s=>r({overlayCompactMode:s}),toggleOverlayCompactMode:()=>r({overlayCompactMode:!o().overlayCompactMode}),setSettingsOpen:s=>r({isSettingsOpen:s}),resetToDefaults:()=>r(s=>({mode:He.mode,theme:He.theme,fontFamily:He.fontFamily,fontSizePx:He.fontSizePx,lineHeight:He.lineHeight,marginX:He.marginX,marginY:He.marginY,showOverlays:!1,isSettingsOpen:!0,pointerStyle:He.pointerStyle,pointerColor:He.pointerColor,breakMarks:He.breakMarks,breakGapPx:He.breakGapPx,muteAudio:He.muteAudio,audioSpeed:He.audioSpeed,showPointer:He.showPointer,showSplit:He.showSplit})),maps:{MARGIN_MAP:In,LINEHEIGHT_MAP:Tn,BREAK_GAP_MAP:kn,fontSizeFromLevel:Zn},setPointerStyle:s=>r({pointerStyle:s}),setPointerColor:s=>r({pointerColor:s}),toggleBreakMark:s=>{const i=o().breakMarks;r({breakMarks:{...i,[s]:!i[s]}})},setBreakMarks:s=>{r({breakMarks:{...o().breakMarks,...s}})},setBreakGapPx:s=>r({breakGapPx:s}),setBreakGapLevel:s=>{const i=kn[Math.max(1,Math.min(5,s))-1];r({breakGapPx:i})},getBreakGapLevel:()=>Rn(o().breakGapPx,kn),getFontLevel:()=>Xs(o().fontSizePx),getLineLevel:()=>Rn(o().lineHeight,Tn),getMarginLevel:()=>Rn(o().marginX,In),setFontLevel:s=>r({fontSizePx:Zn(Math.max(1,Math.min(12,s)))}),setLineLevel:s=>r({lineHeight:Tn[Math.max(1,Math.min(7,s))-1]}),setMarginLevel:s=>{const i=In[Math.max(1,Math.min(5,s))-1];r({marginX:i,marginY:i})},setMuteAudio:s=>{r({muteAudio:s}),n==null||n.getState().emit({type:"settings_change",payload:{key:"muteAudio",value:s}})},toggleMuteAudio:()=>{const s=!o().muteAudio;r({muteAudio:s}),n==null||n.getState().emit({type:"settings_change",payload:{key:"muteAudio",value:s}})},setAudioSpeed:s=>{const i=Math.max(.3,Math.min(2,s));r({audioSpeed:i}),n==null||n.getState().emit({type:"settings_change",payload:{key:"audioSpeed",value:i}})},incAudioSpeed:()=>{const s=Math.min(2,Math.round((o().audioSpeed+.05)*100)/100);r({audioSpeed:s}),n==null||n.getState().emit({type:"settings_change",payload:{key:"audioSpeed",value:s}})},decAudioSpeed:()=>{const s=Math.max(.3,Math.round((o().audioSpeed-.05)*100)/100);r({audioSpeed:s}),n==null||n.getState().emit({type:"settings_change",payload:{key:"audioSpeed",value:s}})},setShowPointer:s=>r({showPointer:s}),toggleShowPointer:()=>r({showPointer:!o().showPointer}),setShowSplit:s=>r({showSplit:s}),toggleShowSplit:()=>r({showSplit:!o().showSplit}),setViewportSize:(s,i)=>r({viewportWidth:s,viewportHeight:i})}))}const hn=0,gt=1,jt=2,Lo=4;function Or(e){return()=>e}function Qs(e){e()}function Ho(e,t){return n=>e(t(n))}function Pr(e,t){return()=>e(t)}function Zs(e,t){return n=>e(t,n)}function ar(e){return e!==void 0}function Js(...e){return()=>{e.map(Qs)}}function Ot(){}function mn(e,t){return t(e),e}function ei(e,t){return t(e)}function Te(...e){return e}function xe(e,t){return e(gt,t)}function ce(e,t){e(hn,t)}function cr(e){e(jt)}function _e(e){return e(Lo)}function ne(e,t){return xe(e,Zs(t,hn))}function nt(e,t){const n=e(gt,r=>{n(),t(r)});return n}function zr(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function No(e,t){return e===t}function Ie(e=No){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function se(e){return t=>n=>{e(n)&&t(n)}}function Y(e){return t=>Ho(t,e)}function it(e){return t=>()=>{t(e)}}function H(e,...t){const n=ti(...t);return((r,o)=>{switch(r){case jt:cr(e);return;case gt:return xe(e,n(o))}})}function lt(e,t){return n=>r=>{n(t=e(t,r))}}function St(e){return t=>n=>{e>0?e--:t(n)}}function ct(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function de(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const c=Math.pow(2,i);xe(s,l=>{const a=n;n=n|c,t[i]=l,a!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const c=()=>{s([i].concat(t))};n===o?c():r=c}}function ti(...e){return t=>e.reduceRight(ei,t)}function ni(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case gt:return s?n===s?void 0:(r(),n=s,t=xe(e,s),t):(r(),Ot);case jt:r(),n=null;return}}}function W(e){let t=e;const n=pe();return((r,o)=>{switch(r){case hn:t=o;break;case gt:{o(t);break}case Lo:return t}return n(r,o)})}function Fe(e,t){return mn(W(t),n=>ne(e,n))}function pe(){const e=[];return((t,n)=>{switch(t){case hn:e.slice().forEach(r=>{r(n)});return;case jt:e.splice(0,e.length);return;case gt:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}})}function Ke(e){return mn(pe(),t=>ne(e,t))}function he(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:ri(),singleton:n}}const ri=()=>Symbol();function oi(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const c=r(o.map(l=>n(l)));return i&&t.set(s,c),c};return n(e)}function ze(...e){const t=pe(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const c=Math.pow(2,i);xe(s,l=>{n[i]=l,r=r|c,r===o&&ce(t,n)})}),function(s,i){switch(s){case jt:{cr(t);return}case gt:return r===o&&i(n),xe(t,i)}}}function oe(e,t=No){return H(e,Ie(t))}function Jn(...e){return function(t,n){switch(t){case jt:return;case gt:return Js(...e.map(r=>xe(r,n)))}}}var Ve=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ve||{});const si={0:"debug",3:"error",1:"log",2:"warn"},ii=()=>typeof globalThis>"u"?window:globalThis,ht=he(()=>{const e=W(3);return{log:W((t,n,r=1)=>{var o;const s=(o=ii().VIRTUOSO_LOG_LEVEL)!=null?o:_e(e);r>=s&&console[si[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Ct(e,t,n){return ur(e,t,n).callbackRef}function ur(e,t,n){const r=h.useRef(null);let o=i=>{};const s=h.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const c=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?c():requestAnimationFrame(c)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function li(e,t,n,r,o,s,i,c,l){const a=h.useCallback(d=>{const x=ai(d.children,t,c?"offsetWidth":"offsetHeight",o);let m=d.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const S=m.lastElementChild.dataset.viewportType==="window";let v;S&&(v=m.ownerDocument.defaultView);const w=i?c?i.scrollLeft:i.scrollTop:S?c?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:c?m.scrollLeft:m.scrollTop,u=i?c?i.scrollWidth:i.scrollHeight:S?c?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:c?m.scrollWidth:m.scrollHeight,f=i?c?i.offsetWidth:i.offsetHeight:S?c?v.innerWidth:v.innerHeight:c?m.offsetWidth:m.offsetHeight;r({scrollHeight:u,scrollTop:Math.max(w,0),viewportHeight:f}),s==null||s(c?Br("column-gap",getComputedStyle(d).columnGap,o):Br("row-gap",getComputedStyle(d).rowGap,o)),x!==null&&e(x)},[e,t,o,s,i,r,c]);return ur(a,n,l)}function ai(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const c=e.item(i);if(c.dataset.index===void 0)continue;const l=parseInt(c.dataset.index),a=parseFloat(c.dataset.knownSize),d=t(c,n);if(d===0&&r("Zero-sized element, this should not happen",{child:c},Ve.ERROR),d===a)continue;const x=s[s.length-1];s.length===0||x.size!==d||x.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Br(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ve.WARN),t==="normal"?0:parseInt(t??"0",10)}function Fo(e,t,n){const r=h.useRef(null),o=h.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const a=l.getBoundingClientRect(),d=a.width;let x,m;if(t){const S=t.getBoundingClientRect(),v=a.top-S.top;m=S.height-Math.max(0,v),x=v+t.scrollTop}else{const S=i.current.ownerDocument.defaultView;m=S.innerHeight-Math.max(0,a.top),x=a.top+S.scrollY}r.current={offsetTop:x,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=ur(o,!0,n),c=h.useCallback(()=>{o(i.current)},[o,i]);return h.useEffect(()=>{var l;if(t){t.addEventListener("scroll",c);const a=new ResizeObserver(()=>{requestAnimationFrame(c)});return a.observe(t),()=>{t.removeEventListener("scroll",c),a.unobserve(t)}}else{const a=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return a==null||a.addEventListener("scroll",c),a==null||a.addEventListener("resize",c),()=>{a==null||a.removeEventListener("scroll",c),a==null||a.removeEventListener("resize",c)}}},[c,t,i]),s}const We=he(()=>{const e=pe(),t=pe(),n=W(0),r=pe(),o=W(0),s=pe(),i=pe(),c=W(0),l=W(0),a=W(0),d=W(0),x=pe(),m=pe(),S=W(!1),v=W(!1),w=W(!1);return ne(H(e,Y(({scrollTop:u})=>u)),t),ne(H(e,Y(({scrollHeight:u})=>u)),i),ne(t,o),{deviation:n,fixedFooterHeight:a,fixedHeaderHeight:l,footerHeight:d,headerHeight:c,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:S,scrollTo:x,scrollTop:t,skipAnimationFrameInResizeObserver:w,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Lt={lvl:0};function Wo(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:c,value:l}=t(e[i]);s.push({end:c-1,start:r,value:o}),r=c,o=l}return s.push({end:1/0,start:r,value:o}),s}function Se(e){return e===Lt}function Ht(e,t){if(!Se(e))return t===e.k?e.v:t<e.k?Ht(e.l,t):Ht(e.r,t)}function rt(e,t,n="k"){if(Se(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=rt(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return rt(e.l,t,n)}function Ue(e,t,n){return Se(e)?Vo(t,n,1):t===e.k?Ae(e,{k:t,v:n}):t<e.k?Gr(Ae(e,{l:Ue(e.l,t,n)})):Gr(Ae(e,{r:Ue(e.r,t,n)}))}function _t(){return Lt}function Mt(e,t,n){if(Se(e))return[];const r=rt(e,t)[0];return ci(tr(e,r,n))}function er(e,t){if(Se(e))return Lt;const{k:n,l:r,r:o}=e;if(t===n){if(Se(r))return o;if(Se(o))return r;{const[s,i]=$o(r);return nn(Ae(e,{k:s,l:Do(r),v:i}))}}else return t<n?nn(Ae(e,{l:er(r,t)})):nn(Ae(e,{r:er(o,t)}))}function xt(e){return Se(e)?[]:[...xt(e.l),{k:e.k,v:e.v},...xt(e.r)]}function tr(e,t,n){if(Se(e))return[];const{k:r,l:o,r:s,v:i}=e;let c=[];return r>t&&(c=c.concat(tr(o,t,n))),r>=t&&r<=n&&c.push({k:r,v:i}),r<=n&&(c=c.concat(tr(s,t,n))),c}function nn(e){const{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(_n(t))return qo(Ae(e,{lvl:n-1}));if(!Se(t)&&!Se(t.r))return Ae(t.r,{l:Ae(t,{r:t.r.l}),lvl:n,r:Ae(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(_n(e))return nr(Ae(e,{lvl:n-1}));if(!Se(r)&&!Se(r.l)){const o=r.l,s=_n(o)?r.lvl-1:r.lvl;return Ae(o,{l:Ae(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:nr(Ae(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Ae(e,t){return Vo(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function Do(e){return Se(e.r)?e.l:nn(Ae(e,{r:Do(e.r)}))}function _n(e){return Se(e)||e.lvl>e.r.lvl}function $o(e){return Se(e.r)?[e.k,e.v]:$o(e.r)}function Vo(e,t,n,r=Lt,o=Lt){return{k:e,l:r,lvl:n,r:o,v:t}}function Gr(e){return nr(qo(e))}function qo(e){const{l:t}=e;return!Se(t)&&t.lvl===e.lvl?Ae(t,{r:Ae(e,{l:t.r})}):e}function nr(e){const{lvl:t,r:n}=e;return!Se(n)&&!Se(n.r)&&n.lvl===t&&n.r.lvl===t?Ae(n,{l:Ae(e,{r:n.l}),lvl:t+1}):e}function ci(e){return Wo(e,({k:t,v:n})=>({index:t,value:n}))}function Uo(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Nt(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const dr=he(()=>({recalcInProgress:W(!1)}),[],{singleton:!0});function Ko(e,t,n){return e[sn(e,t,n)]}function sn(e,t,n,r=0){let o=e.length-1;for(;r<=o;){const s=Math.floor((r+o)/2),i=e[s],c=n(i,t);if(c===0)return s;if(c===-1){if(o-r<2)return s-1;o=s-1}else{if(o===r)return s;r=s+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function ui(e,t,n,r){const o=sn(e,t,r),s=sn(e,n,r,o);return e.slice(o,s+1)}function pt(e,t){return Math.round(e.getBoundingClientRect()[t])}function bn(e){return!Se(e.groupOffsetTree)}function fr({index:e},t){return t===e?0:t<e?-1:1}function di(){return{groupIndices:[],groupOffsetTree:_t(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:_t()}}function fi(e,t){let n=Se(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Se(e)){e=Ue(e,0,s);continue}const c=Mt(e,i-1,o+1);if(c.some(vi(r)))continue;let l=!1,a=!1;for(const{end:d,start:x,value:m}of c)l?(o>=x||s===m)&&(e=er(e,x)):(a=m!==s,l=!0),d>o&&o>=x&&m!==s&&(e=Ue(e,o+1,m));a&&(e=Ue(e,i,s))}return[e,n]}function pi(e){return typeof e.groupIndex<"u"}function gi({offset:e},t){return t===e?0:t<e?-1:1}function Ft(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=Ko(t,e,fr),i=e-r,c=s*i+(i-1)*n+o;return c>0?c+n:c}function Xo(e,t){if(!bn(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Yo(e,t,n){if(pi(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Xo(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function hi(e,t,n,r=0){return r>0&&(t=Math.max(t,Ko(e,r,fr).offset)),Wo(ui(e,t,n,gi),xi)}function mi(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Ve.DEBUG);const s=e.sizeTree;let i=s,c=0;if(n.length>0&&Se(s)&&t.length===2){const m=t[0].size,S=t[1].size;i=n.reduce((v,w)=>Ue(Ue(v,w,m),w+1,S),i)}else[i,c]=fi(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:a,lastSize:d,offsetTree:x}=rr(e.offsetTree,c,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,S)=>Ue(m,S,Ft(S,x,o)),_t()),lastIndex:l,lastOffset:a,lastSize:d,offsetTree:x,sizeTree:i}}function bi(e){return xt(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function Ar(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function rr(e,t,n,r){let o=e,s=0,i=0,c=0,l=0;if(t!==0){l=sn(o,t-1,fr),c=o[l].offset;const a=rt(n,t-1);s=a[0],i=a[1],o.length&&o[l].size===rt(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:a,value:d}of Mt(n,t,1/0)){const x=a-s,m=x*i+c+x*r;o.push({index:a,offset:m,size:d}),s=a,c=m,i=d}return{lastIndex:s,lastOffset:c,lastSize:i,offsetTree:o}}function xi(e){return{index:e.index,value:e}}function vi(e){const{endIndex:t,size:n,startIndex:r}=e;return o=>o.start===r&&(o.end===t||o.end===1/0)&&o.value===n}const Si={offsetHeight:"height",offsetWidth:"width"},at=he(([{log:e},{recalcInProgress:t}])=>{const n=pe(),r=pe(),o=Fe(r,0),s=pe(),i=pe(),c=W(0),l=W([]),a=W(void 0),d=W(void 0),x=W(void 0),m=W(void 0),S=W((g,y)=>pt(g,Si[y])),v=W(void 0),w=W(0),u=di(),f=Fe(H(n,de(l,e,w),lt(mi,u),Ie()),u),p=Fe(H(l,Ie(),lt((g,y)=>({current:y,prev:g.current}),{current:[],prev:[]}),Y(({prev:g})=>g)),[]);ne(H(l,se(g=>g.length>0),de(f,w),Y(([g,y,R])=>{const k=g.reduce((O,z,I)=>Ue(O,z,Ft(z,y.offsetTree,R)||I),_t());return{...y,groupIndices:g,groupOffsetTree:k}})),f),ne(H(r,de(f),se(([g,{lastIndex:y}])=>g<y),Y(([g,{lastIndex:y,lastSize:R}])=>[{endIndex:y,size:R,startIndex:g}])),n),ne(a,d);const C=Fe(H(a,Y(g=>g===void 0)),!0);ne(H(d,se(g=>g!==void 0&&Se(_e(f).sizeTree)),Y(g=>{const y=_e(x),R=_e(l).length>0;return y?R?[{endIndex:0,size:y,startIndex:0},{endIndex:1,size:g,startIndex:1}]:[]:[{endIndex:0,size:g,startIndex:0}]})),n),ne(H(m,se(g=>g!==void 0&&g.length>0&&Se(_e(f).sizeTree)),Y(g=>{const y=[];let R=g[0],k=0;for(let O=1;O<g.length;O++){const z=g[O];z!==R&&(y.push({endIndex:O-1,size:R,startIndex:k}),R=z,k=O)}return y.push({endIndex:g.length-1,size:R,startIndex:k}),y})),n),ne(H(l,de(x,d),se(([,g,y])=>g!==void 0&&y!==void 0),Y(([g,y,R])=>{const k=[];for(let O=0;O<g.length;O++){const z=g[O],I=g[O+1];k.push({startIndex:z,endIndex:z,size:y}),I!==void 0&&k.push({startIndex:z+1,endIndex:I-1,size:R})}return k})),n);const T=Ke(H(n,de(f),lt(({sizes:g},[y,R])=>({changed:R!==g,sizes:R}),{changed:!1,sizes:u}),Y(g=>g.changed)));xe(H(c,lt((g,y)=>({diff:g.prev-y,prev:y}),{diff:0,prev:0}),Y(g=>g.diff)),g=>{const{groupIndices:y}=_e(f);if(g>0)ce(t,!0),ce(s,g+Ar(g,y));else if(g<0){const R=_e(p);R.length>0&&(g-=Ar(-g,R)),ce(i,g)}}),xe(H(c,de(e)),([g,y])=>{g<0&&y("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:c},Ve.ERROR)});const M=Ke(s);ne(H(s,de(f),Y(([g,y])=>{const R=y.groupIndices.length>0,k=[],O=y.lastSize;if(R){const z=Ht(y.sizeTree,0);let I=0,_=0;for(;I<g;){const N=y.groupIndices[_],B=y.groupIndices.length===_+1?1/0:y.groupIndices[_+1]-N-1;k.push({endIndex:N,size:z,startIndex:N}),k.push({endIndex:N+1+B-1,size:O,startIndex:N+1}),_++,I+=B+1}const P=xt(y.sizeTree);return I!==g&&P.shift(),P.reduce((N,{k:B,v:$})=>{let te=N.ranges;return N.prevSize!==0&&(te=[...N.ranges,{endIndex:B+g-1,size:N.prevSize,startIndex:N.prevIndex}]),{prevIndex:B+g,prevSize:$,ranges:te}},{prevIndex:g,prevSize:0,ranges:k}).ranges}return xt(y.sizeTree).reduce((z,{k:I,v:_})=>({prevIndex:I+g,prevSize:_,ranges:[...z.ranges,{endIndex:I+g-1,size:z.prevSize,startIndex:z.prevIndex}]}),{prevIndex:0,prevSize:O,ranges:[]}).ranges})),n);const E=Ke(H(i,de(f,w),Y(([g,{offsetTree:y},R])=>{const k=-g;return Ft(k,y,R)})));return ne(H(i,de(f,w),Y(([g,y,R])=>{if(y.groupIndices.length>0){if(Se(y.sizeTree))return y;let k=_t();const O=_e(p);let z=0,I=0,_=0;for(;z<-g;){_=O[I];const P=O[I+1]-_-1;I++,z+=P+1}if(k=xt(y.sizeTree).reduce((P,{k:N,v:B})=>Ue(P,Math.max(0,N+g),B),k),z!==-g){const P=Ht(y.sizeTree,_);k=Ue(k,0,P);const N=rt(y.sizeTree,-g+1)[1];k=Ue(k,1,N)}return{...y,sizeTree:k,...rr(y.offsetTree,0,k,R)}}else{const k=xt(y.sizeTree).reduce((O,{k:z,v:I})=>Ue(O,Math.max(0,z+g),I),_t());return{...y,sizeTree:k,...rr(y.offsetTree,0,k,R)}}})),f),{beforeUnshiftWith:M,data:v,defaultItemSize:d,firstItemIndex:c,fixedItemSize:a,fixedGroupSize:x,gap:w,groupIndices:l,heightEstimates:m,itemSize:S,listRefresh:T,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:f,statefulTotalCount:o,totalCount:r,trackItemSizes:C,unshiftWith:s}},Te(ht,dr),{singleton:!0});function yi(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Qo=he(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=pe(),i=pe(),c=Ke(H(s,Y(yi)));return ne(H(c,Y(l=>l.totalCount)),n),ne(H(c,Y(l=>l.groupIndices)),e),ne(H(ze(o,t,r),se(([l,a])=>bn(a)),Y(([l,a,d])=>rt(a.groupOffsetTree,Math.max(l-d,0),"v")[0]),Ie(),Y(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},Te(at,We)),mt=he(([{log:e}])=>{const t=W(!1),n=Ke(H(t,se(r=>r),Ie()));return xe(t,r=>{r&&_e(e)("props updated",{},Ve.DEBUG)}),{didMount:n,propsReady:t}},Te(ht),{singleton:!0}),wi=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Zo(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!wi)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Ut=he(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:c,scrollingInProgress:l,scrollTo:a,smoothScrollTargetReached:d,viewportHeight:x},{log:m}])=>{const S=pe(),v=pe(),w=W(0);let u=null,f=null,p=null;function C(){u&&(u(),u=null),p&&(p(),p=null),f&&(clearTimeout(f),f=null),ce(l,!1)}return ne(H(S,de(n,x,r,w,c,i,m),de(e,s,o),Y(([[T,M,E,g,y,R,k,O],z,I,_])=>{const P=Zo(T),{align:N,behavior:B,offset:$}=P,te=g-1,fe=Yo(P,M,te);let ge=Ft(fe,M.offsetTree,z)+R;N==="end"?(ge+=I+rt(M.sizeTree,fe)[1]-E+_,fe===te&&(ge+=k)):N==="center"?ge+=(I+rt(M.sizeTree,fe)[1]-E+_)/2:ge-=y,$&&(ge+=$);const ve=me=>{C(),me?(O("retrying to scroll to",{location:T},Ve.DEBUG),ce(S,T)):(ce(v,!0),O("list did not change, scroll successful",{},Ve.DEBUG))};if(C(),B==="smooth"){let me=!1;p=xe(t,Be=>{me=me||Be}),u=nt(d,()=>{ve(me)})}else u=nt(H(t,Ci(150)),ve);return f=setTimeout(()=>{C()},1200),ce(l,!0),O("scrolling from index to",{behavior:B,index:fe,top:ge},Ve.DEBUG),{behavior:B,top:ge}})),a),{scrollTargetReached:v,scrollToIndex:S,topListHeight:w}},Te(at,We,ht),{singleton:!0});function Ci(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function pr(e,t){e==0?t():requestAnimationFrame(()=>{pr(e-1,t)})}function gr(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Kt=he(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const c=W(!0),l=W(0),a=W(!0);return ne(H(i,de(l),se(([d,x])=>!!x),it(!1)),c),ne(H(i,de(l),se(([d,x])=>!!x),it(!1)),a),xe(H(ze(t,i),de(c,n,e,a),se(([[,d],x,{sizeTree:m},S,v])=>d&&(!Se(m)||ar(S))&&!x&&!v),de(l)),([,d])=>{nt(o,()=>{ce(a,!0)}),pr(4,()=>{nt(r,()=>{ce(c,!0)}),ce(s,d)})}),{initialItemFinalLocationReached:a,initialTopMostItemIndex:l,scrolledToInitialItem:c}},Te(at,We,Ut,mt),{singleton:!0});function Jo(e,t){return Math.abs(e-t)<1.01}const Wt="up",Gt="down",Ii="none",Ti={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},ki=0,Xt=he(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=W(!1),c=W(!0),l=pe(),a=pe(),d=W(4),x=W(ki),m=Fe(H(Jn(H(oe(o),St(1),it(!0)),H(oe(o),St(1),it(!1),zr(100))),Ie()),!1),S=Fe(H(Jn(H(n,it(!0)),H(n,it(!1),zr(200))),Ie()),!1);ne(H(ze(oe(o),oe(x)),Y(([p,C])=>p<=C),Ie()),c),ne(H(c,ct(50)),a);const v=Ke(H(ze(r,oe(s),oe(t),oe(e),oe(d)),lt((p,[{scrollHeight:C,scrollTop:T},M,E,g,y])=>{const R=T+M-C>-y,k={scrollHeight:C,scrollTop:T,viewportHeight:M};if(R){let z,I;return T>p.state.scrollTop?(z="SCROLLED_DOWN",I=p.state.scrollTop-T):(z="SIZE_DECREASED",I=p.state.scrollTop-T||p.scrollTopDelta),{atBottom:!0,atBottomBecause:z,scrollTopDelta:I,state:k}}let O;return k.scrollHeight>p.state.scrollHeight?O="SIZE_INCREASED":M<p.state.viewportHeight?O="VIEWPORT_HEIGHT_DECREASING":T<p.state.scrollTop?O="SCROLLING_UPWARDS":O="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:O,state:k}},Ti),Ie((p,C)=>p&&p.atBottom===C.atBottom))),w=Fe(H(r,lt((p,{scrollHeight:C,scrollTop:T,viewportHeight:M})=>{if(Jo(p.scrollHeight,C))return{changed:!1,jump:0,scrollHeight:C,scrollTop:T};{const E=C-(T+M)<1;return p.scrollTop!==T&&E?{changed:!0,jump:p.scrollTop-T,scrollHeight:C,scrollTop:T}:{changed:!0,jump:0,scrollHeight:C,scrollTop:T}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),se(p=>p.changed),Y(p=>p.jump)),0);ne(H(v,Y(p=>p.atBottom)),i),ne(H(i,ct(50)),l);const u=W(Gt);ne(H(r,Y(({scrollTop:p})=>p),Ie(),lt((p,C)=>_e(S)?{direction:p.direction,prevScrollTop:C}:{direction:C<p.prevScrollTop?Wt:Gt,prevScrollTop:C},{direction:Gt,prevScrollTop:0}),Y(p=>p.direction)),u),ne(H(r,ct(50),it(Ii)),u);const f=W(0);return ne(H(m,se(p=>!p),it(0)),f),ne(H(o,ct(100),de(m),se(([p,C])=>C),lt(([p,C],[T])=>[C,T],[0,0]),Y(([p,C])=>C-p)),f),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:a,atTopThreshold:x,isAtBottom:i,isAtTop:c,isScrolling:m,lastJumpDueToItemResize:w,scrollDirection:u,scrollVelocity:f}},Te(We)),Dt="top",$t="bottom",Lr="none";function Hr(e,t,n){return typeof e=="number"?n===Wt&&t===Dt||n===Gt&&t===$t?e:0:n===Wt?t===Dt?e.main:e.reverse:t===$t?e.main:e.reverse}function Nr(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const hr=he(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=pe(),i=W(0),c=W(0),l=W(0),a=Fe(H(ze(oe(r),oe(o),oe(n),oe(s,Nt),oe(l),oe(i),oe(t),oe(e),oe(c)),Y(([d,x,m,[S,v],w,u,f,p,C])=>{const T=d-p,M=u+f,E=Math.max(m-T,0);let g=Lr;const y=Nr(C,Dt),R=Nr(C,$t);return S-=p,S+=m+f,v+=m+f,v-=p,S>d+M-y&&(g=Wt),v<d-E+x+R&&(g=Gt),g!==Lr?[Math.max(T-m-Hr(w,Dt,g)-y,0),T-E-f+x+Hr(w,$t,g)+R]:null}),se(d=>d!=null),Ie(Nt)),[0,0]);return{increaseViewportBy:c,listBoundary:s,overscan:l,topListHeight:i,visibleRange:a}},Te(We),{singleton:!0});function Ri(e,t,n){if(bn(t)){const r=Xo(e,t);return[{index:rt(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const Mn={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function rn(e,t,n,r,o,s){const{lastIndex:i,lastOffset:c,lastSize:l}=o;let a=0,d=0;if(e.length>0){a=e[0].offset;const w=e[e.length-1];d=w.offset+w.size}const x=n-i,m=c+x*l+(x-1)*r,S=a,v=m-d;return{bottom:d,firstItemIndex:s,items:Fr(e,o,s),offsetBottom:v,offsetTop:a,top:S,topItems:Fr(t,o,s),topListHeight:t.reduce((w,u)=>u.size+w,0),totalCount:n}}function es(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const c=e+i,l=gr(t,c),a=Array.from({length:c}).map((d,x)=>({data:s[x+l],index:x+l,offset:0,size:0}));return rn(a,[],c,o,n,r)}function Fr(e,t,n){if(e.length===0)return[];if(!bn(t))return e.map(a=>({...a,index:a.index+n,originalIndex:a.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=Mt(t.groupOffsetTree,r,o);let c,l=0;for(const a of e){(!c||c.end<a.index)&&(c=i.shift(),l=t.groupIndices.indexOf(c.start));let d;a.index===c.start?d={index:l,type:"group"}:d={groupIndex:l,index:a.index-(l+1)+n},s.push({...d,data:a.data,offset:a.offset,originalIndex:a.index,size:a.size})}return s}function Wr(e,t){var n;return e===void 0?0:typeof e=="number"?e:(n=e[t])!=null?n:0}const It=he(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:c,visibleRange:l},{initialTopMostItemIndex:a,scrolledToInitialItem:d},{topListHeight:x},m,{didMount:S},{recalcInProgress:v}])=>{const w=W([]),u=W(0),f=pe(),p=W(0);ne(s.topItemsIndexes,w);const C=Fe(H(ze(S,v,oe(l,Nt),oe(o),oe(r),oe(a),d,oe(w),oe(t),oe(n),oe(p),e),se(([g,y,,R,,,,,,,,k])=>{const O=k&&k.length!==R;return g&&!y&&!O}),Y(([,,[g,y],R,k,O,z,I,_,P,N,B])=>{var $,te,fe,ge;const ve=k,{offsetTree:me,sizeTree:Be}=ve,K=_e(u);if(R===0)return{...Mn,totalCount:R};if(g===0&&y===0)return K===0?{...Mn,totalCount:R}:es(K,O,k,_,P,B||[]);if(Se(Be))return K>0?null:rn(Ri(gr(O,R),ve,B),[],R,P,ve,_);const D=[];if(I.length>0){const F=I[0],X=I[I.length-1];let ee=0;for(const Z of Mt(Be,F,X)){const ie=Z.value,re=Math.max(Z.start,F),be=Math.min(Z.end,X);for(let ue=re;ue<=be;ue++)D.push({data:B==null?void 0:B[ue],index:ue,offset:ee,size:ie}),ee+=ie}}if(!z)return rn([],D,R,P,ve,_);const A=I.length>0?I[I.length-1]+1:0,j=hi(me,g,y,A);if(j.length===0)return null;const L=R-1,V=mn([],F=>{for(const X of j){const ee=X.value;let Z=ee.offset,ie=X.start;const re=ee.size;if(ee.offset<g){ie+=Math.floor((g-ee.offset+P)/(re+P));const ue=ie-X.start;Z+=ue*re+ue*P}ie<A&&(Z+=(A-ie)*re,ie=A);const be=Math.min(X.end,L);for(let ue=ie;ue<=be&&!(Z>=y);ue++)F.push({data:B==null?void 0:B[ue],index:ue,offset:Z,size:re}),Z+=re+P}}),G=Wr(N,Dt),Q=Wr(N,$t);if(V.length>0&&(G>0||Q>0)){const F=V[0],X=V[V.length-1];if(G>0&&F.index>A){const ee=Math.min(G,F.index-A),Z=[];let ie=F.offset;for(let re=F.index-1;re>=F.index-ee;re--){const be=(te=($=Mt(Be,re,re)[0])==null?void 0:$.value)!=null?te:F.size;ie-=be+P,Z.unshift({data:B==null?void 0:B[re],index:re,offset:ie,size:be})}V.unshift(...Z)}if(Q>0&&X.index<L){const ee=Math.min(Q,L-X.index);let Z=X.offset+X.size+P;for(let ie=X.index+1;ie<=X.index+ee;ie++){const re=(ge=(fe=Mt(Be,ie,ie)[0])==null?void 0:fe.value)!=null?ge:X.size;V.push({data:B==null?void 0:B[ie],index:ie,offset:Z,size:re}),Z+=re+P}}}return rn(V,D,R,P,ve,_)}),se(g=>g!==null),Ie()),Mn);ne(H(e,se(ar),Y(g=>g==null?void 0:g.length)),o),ne(H(C,Y(g=>g.topListHeight)),x),ne(x,c),ne(H(C,Y(g=>[g.top,g.bottom])),i),ne(H(C,Y(g=>g.items)),f);const T=Ke(H(C,se(({items:g})=>g.length>0),de(o,e),se(([{items:g},y])=>g[g.length-1].originalIndex===y-1),Y(([,g,y])=>[g-1,y]),Ie(Nt),Y(([g])=>g))),M=Ke(H(C,ct(200),se(({items:g,topItems:y})=>g.length>0&&g[0].originalIndex===y.length),Y(({items:g})=>g[0].index),Ie())),E=Ke(H(C,se(({items:g})=>g.length>0),Y(({items:g})=>{let y=0,R=g.length-1;for(;g[y].type==="group"&&y<R;)y++;for(;g[R].type==="group"&&R>y;)R--;return{endIndex:g[R].index,startIndex:g[y].index}}),Ie(Uo)));return{endReached:T,initialItemCount:u,itemsRendered:f,listState:C,minOverscanItemCount:p,rangeChanged:E,startReached:M,topItemsIndexes:w,...m}},Te(at,Qo,hr,Kt,Ut,Xt,mt,dr),{singleton:!0}),ts=he(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=pe(),i=Fe(H(ze(n,e,r,t,o),Y(([c,l,a,d,x])=>c+l+a+d+x.offsetBottom+x.bottom)),0);return ne(oe(i),s),{totalListHeight:i,totalListHeightChanged:s}},Te(We,It),{singleton:!0}),_i=he(([{viewportHeight:e},{totalListHeight:t}])=>{const n=W(!1),r=Fe(H(ze(n,e,t),se(([o])=>o),Y(([,o,s])=>Math.max(0,o-s)),ct(0),Ie()),0);return{alignToBottom:n,paddingTopAddition:r}},Te(We,ts),{singleton:!0}),ns=he(()=>({context:W(null)})),Mi=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...o},viewportBottom:s,viewportTop:i})=>t<i?{...o,align:n??"start",behavior:r}:e>s?{...o,align:n??"end",behavior:r}:null,rs=he(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:c,viewportHeight:l},{scrollToIndex:a}])=>{const d=pe();return ne(H(d,de(t,l,n,s,o,r,c),de(e),Y(([[x,m,S,v,w,u,f,p],C])=>{const{align:T,behavior:M,calculateViewLocation:E=Mi,done:g,...y}=x,R=Yo(x,m,v-1),k=Ft(R,m.offsetTree,C)+w+u,O=k+rt(m.sizeTree,R)[1],z=p+u,I=p+S-f,_=E({itemBottom:O,itemTop:k,locationParams:{align:T,behavior:M,...y},viewportBottom:I,viewportTop:z});return _?g&&nt(H(i,se(P=>!P),St(_e(i)?1:2)),g):g==null||g(),_}),se(x=>x!==null)),a),{scrollIntoView:d}},Te(at,We,Ut,It,ht),{singleton:!0});function Dr(e){return e?e==="smooth"?"smooth":"auto":!1}const Ei=(e,t)=>typeof e=="function"?Dr(e(t)):t&&Dr(e),ji=he(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:c},{didMount:l,propsReady:a},{log:d},{scrollingInProgress:x},{context:m},{scrollIntoView:S}])=>{const v=W(!1),w=pe();let u=null;function f(M){ce(i,{align:"end",behavior:M,index:"LAST"})}xe(H(ze(H(oe(t),St(1)),l),de(oe(v),s,c,x),Y(([[M,E],g,y,R,k])=>{let O=E&&R,z="auto";return O&&(z=Ei(g,y||k),O=O&&!!z),{followOutputBehavior:z,shouldFollow:O,totalCount:M}}),se(({shouldFollow:M})=>M)),({followOutputBehavior:M,totalCount:E})=>{u&&(u(),u=null),_e(n)?requestAnimationFrame(()=>{_e(d)("following output to ",{totalCount:E},Ve.DEBUG),f(M)}):u=nt(e,()=>{_e(d)("following output to ",{totalCount:E},Ve.DEBUG),f(M),u=null})});function p(M){const E=nt(o,g=>{M&&!g.atBottom&&g.notAtBottomBecause==="SIZE_INCREASED"&&!u&&(_e(d)("scrolling to bottom due to increased size",{},Ve.DEBUG),f("auto"))});setTimeout(E,100)}xe(H(ze(oe(v),t,a),se(([M,,E])=>M&&E),lt(({value:M},[,E])=>({refreshed:M===E,value:E}),{refreshed:!1,value:0}),se(({refreshed:M})=>M),de(v,t)),([,M])=>{_e(c)&&p(M!==!1)}),xe(w,()=>{p(_e(v)!==!1)}),xe(ze(oe(v),o),([M,E])=>{M&&!E.atBottom&&E.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&f("auto")});const C=W(null),T=pe();return ne(Jn(H(oe(r),Y(M=>{var E;return(E=M==null?void 0:M.length)!=null?E:0})),H(oe(t))),T),xe(H(ze(H(T,St(1)),l),de(oe(C),c,x,m),Y(([[M,E],g,y,R,k])=>E&&y&&(g==null?void 0:g({context:k,totalCount:M,scrollingInProgress:R}))),se(M=>!!M),ct(0)),M=>{u&&(u(),u=null),_e(n)?requestAnimationFrame(()=>{_e(d)("scrolling into view",{}),ce(S,M)}):u=nt(e,()=>{_e(d)("scrolling into view",{}),ce(S,M),u=null})}),{autoscrollToBottom:w,followOutput:v,scrollIntoViewOnChange:C}},Te(at,Xt,Ut,Kt,mt,ht,We,ns,rs)),Oi=he(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:c}])=>(ne(H(c,de(s),se(([,l])=>l!==0),de(o,r,t,n,e),Y(([[,l],a,d,x,m,S=[]])=>es(l,a,d,x,m,S))),i),{}),Te(at,Kt,It,mt),{singleton:!0}),Pi=he(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=W(0);return xe(H(e,de(r),se(([,o])=>o!==0),Y(([,o])=>({top:o}))),o=>{nt(H(n,St(1),se(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{ce(t,o)})})}),{initialScrollTop:r}},Te(mt,We,It),{singleton:!0}),os=he(([{scrollVelocity:e}])=>{const t=W(!1),n=pe(),r=W(!1);return ne(H(e,de(r,t,n),se(([o,s])=>!!s),Y(([o,s,i,c])=>{const{enter:l,exit:a}=s;if(i){if(a(o,c))return!1}else if(l(o,c))return!0;return i}),Ie()),t),xe(H(ze(t,e,n),de(r)),([[o,s,i],c])=>{o&&c&&c.change&&c.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},Te(Xt),{singleton:!0}),mr=he(([{scrollContainerState:e,scrollTo:t}])=>{const n=pe(),r=pe(),o=pe(),s=W(!1),i=W(void 0);return ne(H(ze(n,r),Y(([{scrollHeight:c,scrollTop:l,viewportHeight:a},{offsetTop:d}])=>({scrollHeight:c,scrollTop:Math.max(0,l-d),viewportHeight:a}))),e),ne(H(t,de(r),Y(([c,{offsetTop:l}])=>({...c,top:c.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},Te(We)),zi=he(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:c,windowViewportRect:l}])=>{const a=pe(),d=W(void 0),x=W(null),m=W(null);return ne(c,x),ne(l,m),xe(H(a,de(t,r,i,x,m,n)),([S,v,w,u,f,p,C])=>{const T=bi(v.sizeTree);u&&f!==null&&p!==null&&(w=f.scrollTop-p.offsetTop),w-=C,S({ranges:T,scrollTop:w})}),ne(H(d,se(ar),Y(Bi)),o),ne(H(s,de(d),se(([,S])=>S!==void 0),Ie(),Y(([,S])=>S.ranges)),e),{getState:a,restoreStateFrom:d}},Te(at,We,Kt,mt,mr));function Bi(e){return{align:"start",index:0,offset:e.scrollTop}}const Gi=he(([{topItemsIndexes:e}])=>{const t=W(0);return ne(H(t,se(n=>n>=0),Y(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},Te(It));function ss(e){let t=!1,n;return(()=>(t||(t=!0,n=e()),n))}const Ai=ss(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Li=he(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:c},{listState:l},{beforeUnshiftWith:a,gap:d,shiftWithOffset:x,sizes:m},{log:S},{recalcInProgress:v}])=>{const w=Ke(H(l,de(i),lt(([,f,p,C],[{bottom:T,items:M,offsetBottom:E,totalCount:g},y])=>{const R=T+E;let k=0;return p===g&&f.length>0&&M.length>0&&(M[0].originalIndex===0&&f[0].originalIndex===0||(k=R-C,k!==0&&(k+=y))),[k,M,g,R]},[0,[],0,0]),se(([f])=>f!==0),de(r,c,n,o,S,v),se(([,f,p,C,,,T])=>!T&&!C&&f!==0&&p===Wt),Y(([[f],,,,,p])=>(p("Upward scrolling compensation",{amount:f},Ve.DEBUG),f))));function u(f){f>0?(ce(t,{behavior:"auto",top:-f}),ce(e,0)):(ce(e,0),ce(t,{behavior:"auto",top:-f}))}return xe(H(w,de(e,s)),([f,p,C])=>{C&&Ai()?ce(e,p-f):u(-f)}),xe(H(ze(Fe(s,!1),e,v),se(([f,p,C])=>!f&&!C&&p!==0),Y(([f,p])=>p),ct(1)),u),ne(H(x,Y(f=>({top:-f}))),t),xe(H(a,de(m,d),Y(([f,{groupIndices:p,lastSize:C,sizeTree:T},M])=>{function E(g){return g*(C+M)}if(p.length===0)return E(f);{let g=0;const y=Ht(T,0);let R=0,k=0;for(;R<f;){R++,g+=y;let O=p.length===k+1?1/0:p[k+1]-p[k]-1;R+O>f&&(g-=y,O=f-R+1),R+=O,g+=E(O),k++}return g}})),f=>{ce(e,f),requestAnimationFrame(()=>{ce(t,{top:f}),requestAnimationFrame(()=>{ce(e,0),ce(v,!1)})})}),{deviation:e}},Te(We,Xt,It,at,ht,dr)),Hi=he(([e,t,n,r,o,s,i,c,l,a,d])=>({...e,...t,...n,...r,...o,...s,...i,...c,...l,...a,...d}),Te(hr,Oi,mt,os,ts,Pi,_i,mr,rs,ht,ns)),is=he(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,fixedGroupSize:o,gap:s,groupIndices:i,heightEstimates:c,itemSize:l,sizeRanges:a,sizes:d,statefulTotalCount:x,totalCount:m,trackItemSizes:S},{initialItemFinalLocationReached:v,initialTopMostItemIndex:w,scrolledToInitialItem:u},f,p,C,T,{scrollToIndex:M},E,{topItemCount:g},{groupCounts:y},R])=>{const{listState:k,minOverscanItemCount:O,topItemsIndexes:z,rangeChanged:I,..._}=T;return ne(I,R.scrollSeekRangeChanged),ne(H(R.windowViewportRect,Y(P=>P.visibleHeight)),f.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,fixedGroupHeight:o,gap:s,groupCounts:y,heightEstimates:c,initialItemFinalLocationReached:v,initialTopMostItemIndex:w,scrolledToInitialItem:u,sizeRanges:a,topItemCount:g,topItemsIndexes:z,totalCount:m,...C,groupIndices:i,itemSize:l,listState:k,minOverscanItemCount:O,scrollToIndex:M,statefulTotalCount:x,trackItemSizes:S,rangeChanged:I,..._,...R,...f,sizes:d,...p}},Te(at,Kt,We,zi,ji,It,Ut,Li,Gi,Qo,Hi));function Ni(e,t){const n={},r={};let o=0;const s=e.length;for(;o<s;)r[e[o]]=1,o+=1;for(const i in t)Object.hasOwn(r,i)||(n[i]=t[i]);return n}const Jt=typeof document<"u"?h.useLayoutEffect:h.useEffect;function ls(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),c=h.createContext({});function l(u,f){u.propsReady&&ce(u.propsReady,!1);for(const p of r){const C=u[t.required[p]];ce(C,f[p])}for(const p of o)if(p in f){const C=u[t.optional[p]];ce(C,f[p])}u.propsReady&&ce(u.propsReady,!0)}function a(u){return s.reduce((f,p)=>(f[p]=C=>{const T=u[t.methods[p]];ce(T,C)},f),{})}function d(u){return i.reduce((f,p)=>(f[p]=ni(u[t.events[p]]),f),{})}const x=h.forwardRef((u,f)=>{const{children:p,...C}=u,[T]=h.useState(()=>mn(oi(e),g=>{l(g,C)})),[M]=h.useState(Pr(d,T));Jt(()=>{for(const g of i)g in C&&xe(M[g],C[g]);return()=>{Object.values(M).map(cr)}},[C,M,T]),Jt(()=>{l(T,C)}),h.useImperativeHandle(f,Or(a(T)));const E=n;return b.jsx(c.Provider,{value:T,children:n?b.jsx(E,{...Ni([...r,...o,...i],C),children:p}):p})}),m=u=>{const f=h.useContext(c);return h.useCallback(p=>{ce(f[u],p)},[f,u])},S=u=>{const f=h.useContext(c)[u],p=h.useCallback(C=>xe(f,C),[f]);return h.useSyncExternalStore(p,()=>_e(f),()=>_e(f))},v=u=>{const f=h.useContext(c)[u],[p,C]=h.useState(Pr(_e,f));return Jt(()=>xe(f,T=>{T!==p&&C(Or(T))}),[f,p]),p},w=h.version.startsWith("18")?S:v;return{Component:x,useEmitter:(u,f)=>{const p=h.useContext(c)[u];Jt(()=>xe(p,f),[f,p])},useEmitterValue:w,usePublisher:m}}const as=h.createContext(void 0),cs=h.createContext(void 0),us=typeof document<"u"?h.useLayoutEffect:h.useEffect;function En(e){return"self"in e}function Fi(e){return"body"in e}function ds(e,t,n,r=Ot,o,s){const i=h.useRef(null),c=h.useRef(null),l=h.useRef(null),a=h.useCallback(m=>{let S,v,w;const u=m.target;if(Fi(u)||En(u)){const p=En(u)?u:u.defaultView;w=s?p.scrollX:p.scrollY,S=s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight,v=s?p.innerWidth:p.innerHeight}else w=s?u.scrollLeft:u.scrollTop,S=s?u.scrollWidth:u.scrollHeight,v=s?u.offsetWidth:u.offsetHeight;const f=()=>{e({scrollHeight:S,scrollTop:Math.max(w,0),viewportHeight:v})};m.suppressFlushSync?f():Bs.flushSync(f),c.current!==null&&(w===c.current||w<=0||w===S-v)&&(c.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);h.useEffect(()=>{const m=o||i.current;return r(o||i.current),a({suppressFlushSync:!0,target:m}),m.addEventListener("scroll",a,{passive:!0}),()=>{r(null),m.removeEventListener("scroll",a)}},[i,a,n,r,o]);function d(m){const S=i.current;if(!S||(s?"offsetWidth"in S&&S.offsetWidth===0:"offsetHeight"in S&&S.offsetHeight===0))return;const v=m.behavior==="smooth";let w,u,f;En(S)?(u=Math.max(pt(S.document.documentElement,s?"width":"height"),s?S.document.documentElement.scrollWidth:S.document.documentElement.scrollHeight),w=s?S.innerWidth:S.innerHeight,f=s?window.scrollX:window.scrollY):(u=S[s?"scrollWidth":"scrollHeight"],w=pt(S,s?"width":"height"),f=S[s?"scrollLeft":"scrollTop"]);const p=u-w;if(m.top=Math.ceil(Math.max(Math.min(p,m.top),0)),Jo(w,u)||m.top===f){e({scrollHeight:u,scrollTop:f,viewportHeight:w}),v&&t(!0);return}v?(c.current=m.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,c.current=null,t(!0)},1e3)):c.current=null,s&&(m={behavior:m.behavior,left:m.top}),S.scrollTo(m)}function x(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:x,scrollerRef:i,scrollToCallback:d}}const jn="-webkit-sticky",$r="sticky",br=ss(()=>{if(typeof document>"u")return $r;const e=document.createElement("div");return e.style.position=jn,e.style.position===jn?jn:$r});function xr(e){return e}const Wi=he(()=>{const e=W(c=>`Item ${c}`),t=W(c=>`Group ${c}`),n=W({}),r=W(xr),o=W("div"),s=W(Ot),i=(c,l=null)=>Fe(H(n,Y(a=>a[c]),Ie()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),Di=he(([e,t])=>({...e,...t}),Te(is,Wi)),$i=({height:e})=>b.jsx("div",{style:{height:e}}),Vi={overflowAnchor:"none",position:br(),zIndex:1},fs={overflowAnchor:"none"},qi={...fs,display:"inline-block",height:"100%"},Vr=h.memo(function({showTopList:e=!1}){const t=le("listState"),n=Qe("sizeRanges"),r=le("useWindowScroll"),o=le("customScrollParent"),s=Qe("windowScrollContainerState"),i=Qe("scrollContainerState"),c=o||r?s:i,l=le("itemContent"),a=le("context"),d=le("groupContent"),x=le("trackItemSizes"),m=le("itemSize"),S=le("log"),v=Qe("gap"),w=le("horizontalDirection"),{callbackRef:u}=li(n,m,x,e?Ot:c,S,v,o,w,le("skipAnimationFrameInResizeObserver")),[f,p]=h.useState(0);vr("deviation",_=>{f!==_&&p(_)});const C=le("EmptyPlaceholder"),T=le("ScrollSeekPlaceholder")||$i,M=le("ListComponent"),E=le("ItemComponent"),g=le("GroupComponent"),y=le("computeItemKey"),R=le("isSeeking"),k=le("groupIndices").length>0,O=le("alignToBottom"),z=le("initialItemFinalLocationReached"),I=e?{}:{boxSizing:"border-box",...w?{display:"inline-block",height:"100%",marginLeft:f!==0?f:O?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:f!==0?f:O?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...z?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?b.jsx(C,{...Ne(C,a)}):b.jsx(M,{...Ne(M,a),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:u,style:I,children:(e?t.topItems:t.items).map(_=>{const P=_.originalIndex,N=y(P+t.firstItemIndex,_.data,a);return R?h.createElement(T,{...Ne(T,a),height:_.size,index:_.index,key:N,type:_.type||"item",..._.type==="group"?{}:{groupIndex:_.groupIndex}}):_.type==="group"?h.createElement(g,{...Ne(g,a),"data-index":P,"data-item-index":_.index,"data-known-size":_.size,key:N,style:Vi},d(_.index,a)):h.createElement(E,{...Ne(E,a),...Yi(E,_.data),"data-index":P,"data-item-group-index":_.groupIndex,"data-item-index":_.index,"data-known-size":_.size,key:N,style:w?qi:fs},k?l(_.index,_.groupIndex,_.data,a):l(_.index,_.data,a))})})}),Ui={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Ki={outline:"none",overflowX:"auto",position:"relative"},xn=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Xi={position:br(),top:0,width:"100%",zIndex:1};function Ne(e,t){if(typeof e!="string")return{context:t}}function Yi(e,t){return{item:typeof e=="string"?void 0:t}}const Qi=h.memo(function(){const e=le("HeaderComponent"),t=Qe("headerHeight"),n=le("HeaderFooterTag"),r=Ct(h.useMemo(()=>s=>{t(pt(s,"height"))},[t]),!0,le("skipAnimationFrameInResizeObserver")),o=le("context");return e?b.jsx(n,{ref:r,children:b.jsx(e,{...Ne(e,o)})}):null}),Zi=h.memo(function(){const e=le("FooterComponent"),t=Qe("footerHeight"),n=le("HeaderFooterTag"),r=Ct(h.useMemo(()=>s=>{t(pt(s,"height"))},[t]),!0,le("skipAnimationFrameInResizeObserver")),o=le("context");return e?b.jsx(n,{ref:r,children:b.jsx(e,{...Ne(e,o)})}):null});function ps({useEmitter:e,useEmitterValue:t,usePublisher:n}){return h.memo(function({children:r,style:o,context:s,...i}){const c=n("scrollContainerState"),l=t("ScrollerComponent"),a=n("smoothScrollTargetReached"),d=t("scrollerRef"),x=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:S,scrollToCallback:v}=ds(c,a,l,d,void 0,x);return e("scrollTo",v),e("scrollBy",m),b.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:S,style:{...x?Ki:Ui,...o},tabIndex:0,...i,...Ne(l,s),children:r})})}function gs({useEmitter:e,useEmitterValue:t,usePublisher:n}){return h.memo(function({children:r,style:o,context:s,...i}){const c=n("windowScrollContainerState"),l=t("ScrollerComponent"),a=n("smoothScrollTargetReached"),d=t("totalListHeight"),x=t("deviation"),m=t("customScrollParent"),S=h.useRef(null),v=t("scrollerRef"),{scrollByCallback:w,scrollerRef:u,scrollToCallback:f}=ds(c,a,l,v,m);return us(()=>{var p;return u.current=m||((p=S.current)==null?void 0:p.ownerDocument.defaultView),()=>{u.current=null}},[u,m]),e("windowScrollTo",f),e("scrollBy",w),b.jsx(l,{ref:S,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+x}:{}},...i,...Ne(l,s),children:r})})}const Ji=({children:e})=>{const t=h.useContext(as),n=Qe("viewportHeight"),r=Qe("fixedItemHeight"),o=le("alignToBottom"),s=le("horizontalDirection"),i=h.useMemo(()=>Ho(n,l=>pt(l,s?"width":"height")),[n,s]),c=Ct(i,!0,le("skipAnimationFrameInResizeObserver"));return h.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),b.jsx("div",{"data-viewport-type":"element",ref:c,style:xn(o),children:e})},el=({children:e})=>{const t=h.useContext(as),n=Qe("windowViewportRect"),r=Qe("fixedItemHeight"),o=le("customScrollParent"),s=Fo(n,o,le("skipAnimationFrameInResizeObserver")),i=le("alignToBottom");return h.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),b.jsx("div",{"data-viewport-type":"window",ref:s,style:xn(i),children:e})},tl=({children:e})=>{const t=le("TopItemListComponent")||"div",n=le("headerHeight"),r={...Xi,marginTop:`${n}px`},o=le("context");return b.jsx(t,{style:r,...Ne(t,o),children:e})},nl=h.memo(function(e){const t=le("useWindowScroll"),n=le("topItemsIndexes").length>0,r=le("customScrollParent"),o=le("context");return b.jsxs(r||t?sl:ol,{...e,context:o,children:[n&&b.jsx(tl,{children:b.jsx(Vr,{showTopList:!0})}),b.jsxs(r||t?el:Ji,{children:[b.jsx(Qi,{}),b.jsx(Vr,{}),b.jsx(Zi,{})]})]})}),{Component:rl,useEmitter:vr,useEmitterValue:le,usePublisher:Qe}=ls(Di,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},nl),ol=ps({useEmitter:vr,useEmitterValue:le,usePublisher:Qe}),sl=gs({useEmitter:vr,useEmitterValue:le,usePublisher:Qe}),il=rl,ll=he(()=>{const e=W(a=>b.jsxs("td",{children:["Item $",a]})),t=W(null),n=W(a=>b.jsxs("td",{colSpan:1e3,children:["Group ",a]})),r=W(null),o=W(null),s=W({}),i=W(xr),c=W(Ot),l=(a,d=null)=>Fe(H(s,Y(x=>x[a]),Ie()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:c,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}});Te(is,ll);br();const qr={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},al={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Ur,floor:ln,max:At,min:On,round:Kr}=Math;function Xr(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function cl(e){return{...al,items:e}}function en(e,t){return e&&e.width===t.width&&e.height===t.height}function ul(e,t){return e&&e.column===t.column&&e.row===t.row}const dl=he(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:c,scrollTo:l,scrollTop:a,smoothScrollTargetReached:d,viewportHeight:x},m,S,{didMount:v,propsReady:w},{customScrollParent:u,useWindowScroll:f,windowScrollContainerState:p,windowScrollTo:C,windowViewportRect:T},M])=>{const E=W(0),g=W(0),y=W(qr),R=W({height:0,width:0}),k=W({height:0,width:0}),O=pe(),z=pe(),I=W(0),_=W(null),P=W({column:0,row:0}),N=pe(),B=pe(),$=W(!1),te=W(0),fe=W(!0),ge=W(!1),ve=W(!1);xe(H(v,de(te),se(([j,L])=>!!L)),()=>{ce(fe,!1)}),xe(H(ze(v,fe,k,R,te,ge),se(([j,L,V,G,,Q])=>j&&!L&&V.height!==0&&G.height!==0&&!Q)),([,,,,j])=>{ce(ge,!0),pr(1,()=>{ce(O,j)}),nt(H(a),()=>{ce(t,[0,0]),ce(fe,!0)})}),ne(H(B,se(j=>j!=null&&j.scrollTop>0),it(0)),g),xe(H(v,de(B),se(([,j])=>j!=null)),([,j])=>{j&&(ce(R,j.viewport),ce(k,j.item),ce(P,j.gap),j.scrollTop>0&&(ce($,!0),nt(H(a,St(1)),L=>{ce($,!1)}),ce(l,{top:j.scrollTop})))}),ne(H(R,Y(({height:j})=>j)),x),ne(H(ze(oe(R,en),oe(k,en),oe(P,(j,L)=>j&&j.column===L.column&&j.row===L.row),oe(a)),Y(([j,L,V,G])=>({gap:V,item:L,scrollTop:G,viewport:j}))),N),ne(H(ze(oe(E),r,oe(P,ul),oe(k,en),oe(R,en),oe(_),oe(g),oe($),oe(fe),oe(te)),se(([,,,,,,,j])=>!j),Y(([j,[L,V],G,Q,F,X,ee,,Z,ie])=>{const{column:re,row:be}=G,{height:ue,width:ye}=Q,{width:ke}=F;if(ee===0&&(j===0||ke===0))return qr;if(ye===0){const ut=gr(ie,j),Pt=ut+Math.max(ee-1,0);return cl(Xr(ut,Pt,X))}const Pe=hs(ke,ye,re);let Ee,Le;Z?L===0&&V===0&&ee>0?(Ee=0,Le=ee-1):(Ee=Pe*ln((L+be)/(ue+be)),Le=Pe*Ur((V+be)/(ue+be))-1,Le=On(j-1,At(Le,Pe-1)),Ee=On(Le,At(0,Ee))):(Ee=0,Le=-1);const ot=Xr(Ee,Le,X),{bottom:De,top:je}=Yr(F,G,Q,ot),Je=Ur(j/Pe),Xe=Je*ue+(Je-1)*be-De;return{bottom:De,itemHeight:ue,items:ot,itemWidth:ye,offsetBottom:Xe,offsetTop:je,top:je}})),y),ne(H(_,se(j=>j!==null),Y(j=>j.length)),E),ne(H(ze(R,k,y,P),se(([j,L,{items:V}])=>V.length>0&&L.height!==0&&j.height!==0),Y(([j,L,{items:V},G])=>{const{bottom:Q,top:F}=Yr(j,G,L,V);return[F,Q]}),Ie(Nt)),t);const me=W(!1);ne(H(a,de(me),Y(([j,L])=>L||j!==0)),me);const Be=Ke(H(ze(y,E),se(([{items:j}])=>j.length>0),de(me),se(([[j,L],V])=>{const G=j.items[j.items.length-1].index===L-1;return(V||j.bottom>0&&j.itemHeight>0&&j.offsetBottom===0&&j.items.length===L)&&G}),Y(([[,j]])=>j-1),Ie())),K=Ke(H(oe(y),se(({items:j})=>j.length>0&&j[0].index===0),it(0),Ie())),D=Ke(H(oe(y),de($),se(([{items:j},L])=>j.length>0&&!L),Y(([{items:j}])=>({endIndex:j[j.length-1].index,startIndex:j[0].index})),Ie(Uo),ct(0)));ne(D,S.scrollSeekRangeChanged),ne(H(O,de(R,k,E,P),Y(([j,L,V,G,Q])=>{const F=Zo(j),{align:X,behavior:ee,offset:Z}=F;let ie=F.index;ie==="LAST"&&(ie=G-1),ie=At(0,ie,On(G-1,ie));let re=or(L,Q,V,ie);return X==="end"?re=Kr(re-L.height+V.height):X==="center"&&(re=Kr(re-L.height/2+V.height/2)),Z&&(re+=Z),{behavior:ee,top:re}})),l);const A=Fe(H(y,Y(j=>j.offsetBottom+j.bottom)),0);return ne(H(T,Y(j=>({height:j.visibleHeight,width:j.visibleWidth}))),R),{customScrollParent:u,data:_,deviation:I,footerHeight:o,gap:P,headerHeight:s,increaseViewportBy:e,initialItemCount:g,itemDimensions:k,overscan:n,restoreStateFrom:B,scrollBy:i,scrollContainerState:c,scrollHeight:z,scrollTo:l,scrollToIndex:O,scrollTop:a,smoothScrollTargetReached:d,totalCount:E,useWindowScroll:f,viewportDimensions:R,windowScrollContainerState:p,windowScrollTo:C,windowViewportRect:T,...S,gridState:y,horizontalDirection:ve,initialTopMostItemIndex:te,totalListHeight:A,...m,endReached:Be,propsReady:w,rangeChanged:D,startReached:K,stateChanged:N,stateRestoreInProgress:$,...M}},Te(hr,We,Xt,os,mt,mr,ht));function hs(e,t,n){return At(1,ln((e+n)/(ln(t)+n)))}function Yr(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=or(e,t,n,r[0].index);return{bottom:or(e,t,n,r[r.length-1].index)+o,top:s}}function or(e,t,n,r){const o=hs(e.width,n.width,t.column),s=ln(r/o),i=s*n.height+At(0,s-1)*t.row;return i>0?i+t.row:i}const fl=he(()=>{const e=W(x=>`Item ${x}`),t=W({}),n=W(null),r=W("virtuoso-grid-item"),o=W("virtuoso-grid-list"),s=W(xr),i=W("div"),c=W(Ot),l=(x,m=null)=>Fe(H(t,Y(S=>S[x]),Ie()),m),a=W(!1),d=W(!1);return ne(oe(d),a),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:a,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:c,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),pl=he(([e,t])=>({...e,...t}),Te(dl,fl)),gl=h.memo(function(){const e=Re("gridState"),t=Re("listClassName"),n=Re("itemClassName"),r=Re("itemContent"),o=Re("computeItemKey"),s=Re("isSeeking"),i=Ze("scrollHeight"),c=Re("ItemComponent"),l=Re("ListComponent"),a=Re("ScrollSeekPlaceholder"),d=Re("context"),x=Ze("itemDimensions"),m=Ze("gap"),S=Re("log"),v=Re("stateRestoreInProgress"),w=Ze("reportReadyState"),u=Ct(h.useMemo(()=>f=>{const p=f.parentElement.parentElement.scrollHeight;i(p);const C=f.firstChild;if(C){const{height:T,width:M}=C.getBoundingClientRect();x({height:T,width:M})}m({column:Qr("column-gap",getComputedStyle(f).columnGap,S),row:Qr("row-gap",getComputedStyle(f).rowGap,S)})},[i,x,m,S]),!0,!1);return us(()=>{e.itemHeight>0&&e.itemWidth>0&&w(!0)},[e]),v?null:b.jsx(l,{className:t,ref:u,...Ne(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(f=>{const p=o(f.index,f.data,d);return s?b.jsx(a,{...Ne(a,d),height:e.itemHeight,index:f.index,width:e.itemWidth},p):h.createElement(c,{...Ne(c,d),className:n,"data-index":f.index,key:p},r(f.index,f.data,d))})})}),hl=h.memo(function(){const e=Re("HeaderComponent"),t=Ze("headerHeight"),n=Re("headerFooterTag"),r=Ct(h.useMemo(()=>s=>{t(pt(s,"height"))},[t]),!0,!1),o=Re("context");return e?b.jsx(n,{ref:r,children:b.jsx(e,{...Ne(e,o)})}):null}),ml=h.memo(function(){const e=Re("FooterComponent"),t=Ze("footerHeight"),n=Re("headerFooterTag"),r=Ct(h.useMemo(()=>s=>{t(pt(s,"height"))},[t]),!0,!1),o=Re("context");return e?b.jsx(n,{ref:r,children:b.jsx(e,{...Ne(e,o)})}):null}),bl=({children:e})=>{const t=h.useContext(cs),n=Ze("itemDimensions"),r=Ze("viewportDimensions"),o=Ct(h.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return h.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),b.jsx("div",{ref:o,style:xn(!1),children:e})},xl=({children:e})=>{const t=h.useContext(cs),n=Ze("windowViewportRect"),r=Ze("itemDimensions"),o=Re("customScrollParent"),s=Fo(n,o,!1);return h.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),b.jsx("div",{ref:s,style:xn(!1),children:e})},vl=h.memo(function({...e}){const t=Re("useWindowScroll"),n=Re("customScrollParent"),r=n||t?yl:Sl,o=n||t?xl:bl,s=Re("context");return b.jsx(r,{...e,...Ne(r,s),children:b.jsxs(o,{children:[b.jsx(hl,{}),b.jsx(gl,{}),b.jsx(ml,{})]})})}),{useEmitter:ms,useEmitterValue:Re,usePublisher:Ze}=ls(pl,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},vl),Sl=ps({useEmitter:ms,useEmitterValue:Re,usePublisher:Ze}),yl=gs({useEmitter:ms,useEmitterValue:Re,usePublisher:Ze});function Qr(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ve.WARN),t==="normal"?0:parseInt(t??"0",10)}const vn=h.createContext(void 0);function Ce(e,t){const n=h.useContext(vn);if(!n)throw new Error("useAudioStore must be used within CRAudioProvider");return pn(n,e,t)}function an(){const e=h.useContext(vn);if(!e)throw new Error("useAudioStoreApi must be used within CRAudioProvider");return e}const wl="_run_zzb61_3",Cl="_runWrap_zzb61_7",Il="_highlight_zzb61_13",Tl="_highlightleft_zzb61_14",kl="_highlightright_zzb61_15",Rl="_highlightcenter_zzb61_16",_l="_underline_zzb61_48",Ml="_underlineleft_zzb61_49",El="_underlineright_zzb61_50",jl="_underlinecenter_zzb61_51",st={run:wl,runWrap:Cl,highlight:Il,highlightleft:Tl,highlightright:kl,highlightcenter:Rl,underline:_l,underlineleft:Ml,underlineright:El,underlinecenter:jl},Zr=e=>Symbol.iterator in e,Jr=e=>"entries"in e,eo=(e,t)=>{const n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(const[o,s]of n)if(!r.has(o)||!Object.is(s,r.get(o)))return!1;return!0},Ol=(e,t)=>{const n=e[Symbol.iterator](),r=t[Symbol.iterator]();let o=n.next(),s=r.next();for(;!o.done&&!s.done;){if(!Object.is(o.value,s.value))return!1;o=n.next(),s=r.next()}return!!o.done&&!!s.done};function Pl(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:Zr(e)&&Zr(t)?Jr(e)&&Jr(t)?eo(e,t):Ol(e,t):eo({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function Vt(e){const t=h.useRef(void 0);return n=>{const r=e(n);return Pl(t.current,r)?t.current:t.current=r}}function zl(e){const t=e.replace("#",""),n=parseInt(t.length===3?t.repeat(2):t,16),r=n>>16&255,o=n>>8&255,s=n&255;return{r,g:o,b:s}}function Bl(e){const t=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);return t?{r:+t[1],g:+t[2],b:+t[3]}:null}const Gl=Object.freeze({showPointer:void 0,pointerStyle:void 0,pointerColor:void 0}),bs=h.memo(function({runs:t,ns:n,baseIndex:r,preGroups:o}){const s=Ce(O=>O.setClipIndex),i=Ce(O=>O.seek),c=U(O=>O.setCurrentGlobalRunIndex),l=an(),a=U(O=>O.rangeStartGI),d=U(O=>O.rangeEndGI),x=U(O=>O.setRange),m=a!=null&&d!=null,S=h.useCallback(O=>{var te;const z=(te=O.target)==null?void 0:te.closest("[data-g]");if(!z)return;const I=Number(z.dataset.g),_=I-r;if(_<0||_>=t.length)return;const P=t[_],N=P.text??"";if(!N.trim()||!/[가-힣a-zA-Z0-9]/.test(N))return;c(I,"program");const B=P.audioChunkIndex,$=P.audioTimeMs;B!=null&&$!=null&&(s(B),i($))},[t,r,i,s,c]),v=h.useRef(null),w=h.useRef(!1),u=h.useRef({x:0,y:0}),f=h.useCallback(O=>{var P;const z=(P=O.target)==null?void 0:P.closest("[data-g]");if(!z)return;const I=Number(z.dataset.g),_=I-r;_<0||_>=t.length||(w.current=!1,u.current={x:O.clientX,y:O.clientY},v.current&&(window.clearTimeout(v.current),v.current=null),v.current=window.setTimeout(()=>{l.getState().status!=="playing"&&(x(I,I),w.current=!0,v.current=null)},800))},[t,r,x,l]),p=h.useCallback(()=>{v.current&&(window.clearTimeout(v.current),v.current=null)},[]),C=h.useCallback(O=>{if(!v.current)return;const z=O.clientX-u.current.x,I=O.clientY-u.current.y;(Math.abs(z)>5||Math.abs(I)>5)&&p()},[p]),T=h.useCallback(()=>{p()},[p]),M=p,E=p,g=U(O=>O.clearRange),y=h.useCallback(O=>{var _;if(w.current){w.current=!1;return}const z=(_=O.target)==null?void 0:_.closest("[data-g]");if(!z)return;const I=Number(z.dataset.g);isNaN(I)||m&&a!=null&&d!=null&&(g(),O.stopPropagation())},[m,a,d,g]),R=o,k=r+t.length-1;return b.jsx("span",{onClick:y,onDoubleClick:S,onPointerDown:f,onPointerMove:C,onPointerUp:T,onPointerCancel:M,onPointerLeave:E,children:R.map((O,z)=>b.jsx(Ll,{ns:n,group:O,runs:t,paraLastG:k,rangeStartGI:a,rangeEndGI:d},`${n}/grp:${z}-${O.startG}`))})},(e,t)=>e.ns===t.ns&&e.baseIndex===t.baseIndex&&e.runs===t.runs&&e.sectionId===t.sectionId),Al=h.memo(function(){const t=h.useCallback(r=>({showSplit:r.showSplit,slash:r.breakMarks.slash,breakGapPx:r.breakGapPx}),[]),n=J(Vt(t));return n.showSplit?b.jsxs(b.Fragment,{children:[b.jsx("span",{style:{display:"inline-block",width:n.breakGapPx/2}}),n.slash&&b.jsx("span",{children:" / "}),b.jsx("span",{style:{display:"inline-block",width:n.breakGapPx/2}})]}):null}),Ll=h.memo(function({ns:t,group:n,runs:r,paraLastG:o,rangeStartGI:s,rangeEndGI:i}){const c=h.useCallback(u=>{const f=u.currentGlobalRunIndex;return f!=null&&f>=n.startG&&f<=n.endG},[n]),l=U(Vt(c)),a=h.useCallback(u=>l?{showPointer:u.showPointer,pointerStyle:u.pointerStyle,pointerColor:u.pointerColor}:Gl,[l]),d=J(Vt(a)),x=n.r0??0,m=n.len??Math.max(0,n.endG-n.startG+1),S=l&&d.showPointer&&d.pointerStyle!=="underline",v=l&&d.showPointer&&d.pointerStyle==="underline",w=S||v?{"--hl-color":d.pointerColor,"--ul-color":d.pointerColor,"--ul-thickness":"0.3em","--ul-offset":"0.35em"}:void 0;return b.jsx(b.Fragment,{children:Array.from({length:m}).map((u,f)=>{const C=r[x+f],T=n.startG+f,M=`${t}/run:${T}`,E=!!C.split&&T!==o;let g=`${st.runWrap}`;return S&&(m===1?g+=` ${st.highlight}`:f===0?g+=` ${st.highlightleft}`:f+1===m?g+=` ${st.highlightright}`:g+=` ${st.highlightcenter}`),v&&(m===1?g+=` ${st.underline}`:f===0?g+=` ${st.underlineleft}`:f+1===m?g+=` ${st.underlineright}`:g+=` ${st.underlinecenter}`),b.jsxs(h.Fragment,{children:[b.jsx("span",{className:g,style:w,children:b.jsx(Hl,{gi:n.startG,g:T,run:C,active:l,pointerCfg:d,isInRange:s!=null&&i!=null&&T>=s&&T<=i})}),E&&b.jsx(Al,{})]},M)})})},(e,t)=>e.group===t.group&&e.runs===t.runs&&e.ns===t.ns&&e.rangeStartGI===t.rangeStartGI&&e.rangeEndGI===t.rangeEndGI),Hl=h.memo(function({gi:t,g:n,run:r,active:o,pointerCfg:s,isInRange:i}){const c=h.useMemo(()=>{const l={whiteSpace:"pre-wrap"};if(r.bold&&(l.fontWeight=700),r.italic&&(l.fontStyle="italic"),r.underline&&(l.textDecoration="underline"),o&&s.showPointer){const a=s.pointerColor;if(s.pointerStyle!=="underline"){l.backgroundColor=a;const d=a.startsWith("#")?zl(a):Bl(a);d&&(.299*d.r+.587*d.g+.114*d.b)/255<.6&&(l.color="#fff")}}return i&&(l.boxShadow="inset 0 0 0 100px rgba(59, 130, 246, 0.3)"),l},[r.bold,r.italic,r.underline,o,s,i]);return b.jsx("span",{className:st.run,style:c,"data-g":n,"data-gi":t,"data-test":(r==null?void 0:r.audioChunkIndex)||-1,children:r.text||""})},(e,t)=>e.g===t.g&&e.run===t.run&&e.active===t.active&&e.pointerCfg===t.pointerCfg&&e.isInRange===t.isInRange);function Nl({block:e,computedMarker:t,ns:n,baseIndex:r,sectionId:o,preGroups:s}){var a;const i=e.list?e.list.level*24:0,c=((a=e.list)==null?void 0:a.kind)==="bullet"?e.list.glyph??"•":void 0,l=t??c;return b.jsxs("p",{style:{width:"100%",margin:"8px 0",paddingLeft:i,textAlign:e.textAlign,boxSizing:"border-box"},children:[e.list?b.jsx("span",{style:{minWidth:16,display:"inline-block",whiteSpace:"nowrap",userSelect:"none"},children:l||""}):null,b.jsx(bs,{preGroups:s,runs:e.runs,ns:n,baseIndex:r,sectionId:o})]})}const Fl=h.memo(Nl,(e,t)=>e.block===t.block&&e.computedMarker===t.computedMarker&&e.baseIndex===t.baseIndex&&e.ns===t.ns);function Wl(e,t){switch((t||"decimal").toLowerCase().replace(/[\s_-]+/g,"")){case"decimal":return String(e);case"decimalleadingzero":return e<10?`0${e}`:String(e);case"loweralpha":case"lowerlatin":return no(e,!1);case"upperalpha":case"upperlatin":return no(e,!0);case"lowerroman":return to(e,!1);case"upperroman":return to(e,!0);case"decimalenclosedcircle":return Dl(e);default:return String(e)}}function Dl(e){return e>=1&&e<=20?String.fromCharCode(9312+(e-1)):`(${e})`}function to(e,t=!0){if(e<=0)return"";const n=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];let r=e,o="";for(const[s,i]of n)for(;r>=s;)o+=i,r-=s;return t?o:o.toLowerCase()}function no(e,t=!1){let n=e,r="";for(;n>0;)n--,r=String.fromCharCode(97+n%26)+r,n=Math.floor(n/26);return t?r.toUpperCase():r}function Sr(e){const t=new Map;return{next(n,r){const o=`${n}-${r}`,s=(t.get(o)??0)+1;return t.set(o,s),s},reset(){t.clear()}}}function yr(e,t){const n=e.list;if(!n||n.kind!=="ordered")return;const r=t.next(n.numId??0,n.level),o=Wl(r,n.format),s=(n.format||"").toLowerCase();return!/enclosed|paren/.test(s)&&s!=="decimalleadingzero"?`${o}.`:o}function $l(e){return e.map(t=>t.type==="image"?0:t.runs.length)}function Vl(e){const t=new Array(e.length+1).fill(0);for(let n=0;n<e.length;n++)t[n+1]=t[n]+e[n];return t}function ql(e,t){const n=[];if(!e.length)return n;const r=(o,s,i)=>{n.push({splitIndex:i??o,runs:e.slice(o,s+1),startG:t+o,endG:t+s})};for(let o=0;o<e.length;o++){const s=e[o].splitIndex;if(s===void 0){r(o,o,void 0);continue}let i=o+1;for(;i<e.length&&e[i].splitIndex===s;)i++;r(o,i-1,s),o=i-1}return n}const Ul="_scroller_kqkmq_3",Kl={scroller:Ul},Xl=h.forwardRef(function({className:t,style:n,...r},o){return b.jsx("div",{ref:o,className:`${Kl.scroller}${t?" "+t:""}`,style:n,...r})}),sr=e=>/[가-힣a-zA-Z0-9]/.test(e),Yl=e=>((e==null?void 0:e.textContent)??"").trim(),cn=(e,t)=>e.querySelector(`[data-g="${t}"]`);function Ql(e,t=12,n=1.5,r=.5){if(!e)return-1;const o=e.getBoundingClientRect(),s=o.top+t;let i=-1,c=1/0,l=1/0,a=-1,d=1/0,x=1/0;const m=e.querySelectorAll("[data-g]");for(let S=0;S<m.length;S++){const v=m[S];if(!v||!v.isConnected)continue;const w=Yl(v);if(!w||!sr(w))continue;const u=v.getBoundingClientRect();if(u.height<=r||u.width<=r||u.bottom<=o.top||u.top>=o.bottom)continue;if(u.top<s){const C=Math.abs(u.top-s);(C<d||C===d&&(u.top<x||a!==-1&&Number(v.dataset.g)<a))&&(d=C,a=Number(v.dataset.g),x=u.top);continue}const f=Number(v.dataset.g);if(Number.isNaN(f))continue;u.top<l-n?(l=u.top,c=u.top,i=f):u.top<=l+n&&(u.top<c||u.top===c&&(i===-1||f<i))&&(c=u.top,i=f);const p=Math.abs(u.top-s);(p<d||p===d&&(u.top<x||a!==-1&&f<a))&&(d=p,a=f,x=u.top)}return i!==-1?i:a}const xs=async(e,t,{timeoutMs:n=1200,intervalMs:r=16}={})=>{const o=performance.now();let s=cn(e,t);for(;!s;){if(performance.now()-o>n)return null;await new Promise(i=>setTimeout(i,r)),s=cn(e,t)}return s},ro=e=>{const t=e.getBoundingClientRect(),n=t.top+t.height*.15,r=t.top+t.height*.8,o=Array.from(e.querySelectorAll("[data-g]"));let s=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;for(const c of o){const l=c.getBoundingClientRect();if(l.bottom<n||l.top>r||l.height<=0)continue;const a=Number(c.dataset.g);Number.isNaN(a)||(a<s&&(s=a),a>i&&(i=a))}return!Number.isFinite(s)||!Number.isFinite(i)?null:{first:s,last:i}},Zl=(e,t,{topPaddingRatio:n=.15,behavior:r="auto"}={})=>{const o=cn(e,t);if(!o)return!1;const s=e.getBoundingClientRect(),i=o.getBoundingClientRect(),c=s.height*n,l=i.top-(s.top+c);return e.scrollTo({top:e.scrollTop+l,behavior:r}),!0};function Jl(e,t=120){return new Promise(n=>{let r=null;const o=()=>{r!=null&&window.clearTimeout(r),r=window.setTimeout(()=>{e.removeEventListener("scroll",o,{capture:!0}),n()},t)};e.addEventListener("scroll",o,{passive:!0,capture:!0}),o()})}const Pn=async(e,t,{topPaddingRatio:n=.15,behavior:r="smooth",quietMs:o=120}={})=>{if(!Zl(e,t,{topPaddingRatio:n,behavior:r}))return!1;await Jl(e,o);const i=cn(e,t);if(!i)return!1;const c=e.getBoundingClientRect(),l=i.getBoundingClientRect(),a=c.height*n,d=c.top+a,x=l.top-d;return Math.abs(x)<=1},ft=()=>new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>e())})}),wr=h.createContext(null);function vs(){const e=h.useContext(wr);if(!e)throw new Error("useQuizStoreApi must be used within QuizProgressProvider");return e}function tt(e,t){const n=h.useContext(wr);if(!n)throw new Error("useQuizStore must be used within QuizProgressProvider");return pn(n,e,t)}const Ss=()=>{const e=U(r=>r.section),t=vs(),n=e.quizzes;return!n||!n.length?null:b.jsxs("button",{onClick:()=>{t.getState().openFromSection(e)},style:{width:300,background:"#2563eb",color:"white",border:"none",borderRadius:"10px",padding:"14px 28px",fontSize:"16px",fontWeight:600,cursor:"pointer",boxShadow:"0 6px 16px rgba(37,99,235,0.3)",transition:"all 0.15s ease"},children:["퀴즈 풀기 (",n.length,")"]})},ea="_navBtn_1fciy_2",ta="_disabled_1fciy_26",na="_label_1fciy_32",Et={navBtn:ea,disabled:ta,label:na};var ys={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},oo=h.createContext&&h.createContext(ys),ra=["attr","size","title"];function oa(e,t){if(e==null)return{};var n=sa(e,t),r,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(o=0;o<s.length;o++)r=s[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function sa(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function un(){return un=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},un.apply(this,arguments)}function so(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function dn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?so(Object(n),!0).forEach(function(r){ia(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):so(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function ia(e,t,n){return t=la(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function la(e){var t=aa(e,"string");return typeof t=="symbol"?t:t+""}function aa(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function ws(e){return e&&e.map((t,n)=>h.createElement(t.tag,dn({key:n},t.attr),ws(t.child)))}function qe(e){return t=>h.createElement(ca,un({attr:dn({},e.attr)},t),ws(e.child))}function ca(e){var t=n=>{var{attr:r,size:o,title:s}=e,i=oa(e,ra),c=o||n.size||"1em",l;return n.className&&(l=n.className),e.className&&(l=(l?l+" ":"")+e.className),h.createElement("svg",un({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,r,i,{className:l,style:dn(dn({color:e.color||n.color},n.style),e.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),s&&h.createElement("title",null,s),e.children)};return oo!==void 0?h.createElement(oo.Consumer,null,n=>t(n)):t(ys)}function io(e){return qe({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M18.464 2.114a.998.998 0 0 0-1.033.063l-13 9a1.003 1.003 0 0 0 0 1.645l13 9A1 1 0 0 0 19 21V3a1 1 0 0 0-.536-.886zM17 19.091 6.757 12 17 4.909v14.182z"},child:[]}]})(e)}function lo(e){return qe({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M5.536 21.886a1.004 1.004 0 0 0 1.033-.064l13-9a1 1 0 0 0 0-1.644l-13-9A.998.998 0 0 0 5 3v18a1 1 0 0 0 .536.886zM7 4.909 17.243 12 7 19.091V4.909z"},child:[]}]})(e)}const ua=({isIcon:e=!0})=>{const t=U(i=>i.isCanPrev),n=U(i=>i.onSectionNav),r=!t,o=h.useCallback(i=>{i.stopPropagation(),i.preventDefault(),t&&(n==null||n("prev"))},[t,n]),s=t?"이전 섹션으로":"이전 섹션 없음";return e?b.jsxs("button",{type:"button",className:`${Et.navBtn} ${r?Et.disabled:""}`,disabled:r,title:s,onMouseDown:o,onClick:i=>i.stopPropagation(),onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&o(i)},children:[b.jsx(io,{size:18}),b.jsx("span",{className:Et.label,children:"이전"})]}):b.jsx("button",{type:"button",disabled:r,title:s,onClick:o,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&o(i)},style:{width:300,background:r?"#9ca3af":"#2563eb",color:"white",border:"none",borderRadius:"10px",padding:"14px 28px",fontSize:"16px",fontWeight:600,cursor:r?"not-allowed":"pointer",boxShadow:r?"none":"0 6px 16px rgba(37,99,235,0.3)",transition:"all 0.15s ease",opacity:r?.5:1},children:r?"첫섹션입니다":b.jsxs(b.Fragment,{children:[b.jsx(io,{size:18,style:{display:"inline",marginRight:"8px",verticalAlign:"middle"}}),"PrevSection"]})})},fn=({isIcon:e=!0})=>{const t=U(i=>i.isCanNext),n=U(i=>i.onSectionNav),r=!t,o=h.useCallback(i=>{i.stopPropagation(),i.preventDefault(),t&&(n==null||n("next"))},[t,n]),s=t?"다음 섹션으로":"다음 섹션 없음";return e?b.jsxs("button",{type:"button",className:`${Et.navBtn} ${r?Et.disabled:""}`,disabled:r,title:s,onMouseDown:o,onClick:i=>i.stopPropagation(),onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&o(i)},children:[b.jsx(lo,{size:18}),b.jsx("span",{className:Et.label,children:"다음"})]}):b.jsx("button",{type:"button",disabled:r,title:s,onClick:o,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&o(i)},style:{width:300,background:r?"#9ca3af":"#2563eb",color:"white",border:"none",borderRadius:"10px",padding:"14px 28px",fontSize:"16px",fontWeight:600,cursor:r?"not-allowed":"pointer",boxShadow:r?"none":"0 6px 16px rgba(37,99,235,0.3)",transition:"all 0.15s ease",opacity:r?.5:1},children:r?"마지막섹션입니다":b.jsxs(b.Fragment,{children:["NextSection",b.jsx(lo,{size:18,style:{display:"inline",marginLeft:"8px",verticalAlign:"middle"}})]})})};function Cs(e,t){let n=0,r=e.length-1;for(;n<r;){const o=Math.floor((n+r+1)/2);e[o]<=t?n=o:r=o-1}return n}function da({section:e,blocks:t,nsPrefix:n}){const r=h.useMemo(()=>{const R=[],k=Sr();return t.forEach((O,z)=>{O.type==="paragraph"&&(R[z]=yr(O,k))}),R},[t]),o=U(R=>{var k;return((k=R.layout)==null?void 0:k.prefix)??[]}),s=U(R=>{var k;return((k=R.derivedNav)==null?void 0:k.splitGroupsPerBlock)??[]}),i=J(R=>R.marginX),c=J(R=>R.viewportHeight),l=h.useRef({start:0,end:0}),a=h.useCallback(R=>{const k=t[R],O=`${n}blk-${k.id}`;if(k.type==="image"){const{src:_,alt:P,width:N,height:B}=k,$=N&&B?`${N} / ${B}`:"4 / 3",te=R>=l.current.start&&R<=l.current.end,fe=c>80?Math.floor((c-80)*.6):void 0;return b.jsxs("div",{style:{margin:"12px 0",textAlign:"center",width:"100%"},children:[b.jsx("div",{style:{position:"relative",width:"100%",maxHeight:fe,aspectRatio:$},children:b.jsx("img",{src:_,alt:P||"",loading:te?"eager":"lazy",style:{pointerEvents:"none",position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"contain",display:"block"}})}),P&&b.jsx("div",{style:{fontSize:12,color:"#6b7280",marginTop:4},children:P})]})}const z=r[R]??void 0,I=s[R];return b.jsx("div",{style:{maxWidth:860,display:"flex"},children:b.jsx(Fl,{block:k,computedMarker:z,ns:O,baseIndex:o[R],sectionId:e.section_id,preGroups:I})})},[t,r,o,n,e,s,c]),d=h.useRef(null),x=h.useCallback(R=>{d.current=R},[]),m=h.useMemo(()=>h.memo(R=>{const{style:k,children:O,...z}=R;return b.jsx("div",{...z,style:k,children:b.jsx("div",{style:{boxSizing:"border-box",paddingRight:`${i}px`,paddingLeft:`${i}px`,maxWidth:860,margin:"0 auto",width:"100%",height:"100%"},children:O})})}),[i]),S=h.useRef(null),v=h.useMemo(()=>t.map(R=>R.id),[t]),[w,u]=h.useState(!1);h.useEffect(()=>{u(!1)},[t]);const f=h.useCallback(()=>{u(!0)},[]),p=h.useCallback(()=>{if(!w)return b.jsx("div",{style:{height:40}});const R=e.quizzes,k=Math.max(80,Math.floor(c*.5));return R&&R.length?b.jsxs("div",{style:{display:"block"},children:[b.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:20},children:b.jsx(Ss,{})}),b.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:20},children:b.jsx(fn,{isIcon:!1})}),b.jsx("div",{style:{height:k,width:"100%"}})]}):b.jsxs("div",{children:[b.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:20},children:b.jsx(fn,{isIcon:!1})}),b.jsx("div",{style:{height:40}})]})},[w,e,c]),C=h.useMemo(()=>({Item:m,Header:()=>b.jsx("div",{style:{height:40}}),Footer:p,Scroller:Xl}),[p,m]),T=h.useCallback(R=>v[R],[v]),M=vt(),[E]=h.useState(()=>M.getState().progress.currentGlobalRunIndex??0),g=h.useMemo(()=>{if(!o.length)return 0;const R=o[o.length-1],k=Math.max(0,Math.min(E,R));return Cs(o,k)},[o,E]);console.log("SectionRenderVirtuoso확인");const y=vt();return h.useEffect(()=>{let R=!1;return(async()=>{let k=d.current;if(!k){for(let _=0;_<20;_++){if(await new Promise(P=>setTimeout(P,50)),R)return;if(k=d.current,k)break}if(!k)return}const O=y.getState().progress.currentGlobalRunIndex,z=y.getState().progress.setSectionLoading,I=O!=null&&O>=0?O:0;await xs(k,I),!R&&(await ft(),await ft(),await ft(),await ft(),!R&&z(!1))})(),()=>{R=!0}},[d,y]),b.jsxs(b.Fragment,{children:[b.jsx(il,{ref:S,style:{height:"100%",width:"100%",boxSizing:"border-box"},defaultItemHeight:99,computeItemKey:T,totalCount:t.length,itemContent:a,initialTopMostItemIndex:g,increaseViewportBy:{top:200,bottom:200},endReached:f,components:C,scrollerRef:x}),b.jsx(fa,{scrollContainerRef:d,virtRef:S,prefix:o})]})}const fa=({scrollContainerRef:e,virtRef:t,prefix:n})=>{const r=U(I=>I.setCurrentGlobalRunIndex),o=U(I=>I.registerSectionScrollApi),s=U(I=>I.currentGlobalRunIndex),i=Ce(I=>I.scrollLock),c=Ce(I=>I.syncToGI),l=wt(),a=h.useRef(!1),d=h.useRef(null),x=h.useRef(null),m=h.useRef(null),S=h.useRef(-1),v=h.useCallback(()=>{if(i)return;d.current=null;const I=x.current;if(!I)return;const _=Ql(I,5);_!==-1&&_!==S.current&&(S.current=_,c(_),r(_,"scroll"))},[i,c,r]),w=h.useCallback(I=>{x.current=I,d.current==null&&(d.current=requestAnimationFrame(v))},[v]),u=h.useCallback(I=>{x.current=I,m.current!=null&&(window.clearTimeout(m.current),m.current=null),m.current=window.setTimeout(()=>{m.current=null,v();const _=S.current;if(_===-1)return;const P=I.scrollTop,N=I.scrollHeight-I.clientHeight,B=N>0?P/N:0;let $=0;const te=I.querySelector(`[data-g="${_}"]`);if(te){const fe=I.getBoundingClientRect();$=(te.getBoundingClientRect().top-fe.top)/fe.height}l.getState().emit({type:"scroll",payload:{scrollTop:P,scrollRatio:B,anchorGI:_,anchorOffsetRatio:$}})},100)},[v,l]),f=h.useRef(!1),p=h.useCallback(I=>{i||a.current&&(f.current||(w(I),u(I)))},[i,w,u]),C=h.useRef(void 0),T=h.useRef(void 0),M=h.useRef(void 0),E=h.useRef(void 0);h.useEffect(()=>{const I=e.current;if(I)return C.current=()=>{a.current=!0},T.current=()=>{a.current=!0},M.current=()=>{a.current=!0},E.current=()=>p(I),I.addEventListener("wheel",C.current,{passive:!0}),I.addEventListener("touchmove",T.current,{passive:!0}),window.addEventListener("keydown",M.current,{passive:!0}),I.addEventListener("scroll",E.current,{passive:!0}),()=>{I.removeEventListener("wheel",C.current),I.removeEventListener("touchmove",T.current),window.removeEventListener("keydown",M.current),I.removeEventListener("scroll",E.current),d.current!=null&&cancelAnimationFrame(d.current),m.current!=null&&(clearTimeout(m.current),m.current=null)}},[p,e]),h.useEffect(()=>{const I=e.current;if(!I||!i)return;const _=$=>{$.preventDefault(),$.stopPropagation(),a.current=!1},P=$=>{$.preventDefault(),$.stopPropagation(),a.current=!1},N=$=>{["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes($.key)&&($.preventDefault(),$.stopPropagation(),a.current=!1)},B={overscrollBehavior:I.style.overscrollBehavior,touchAction:I.style.touchAction};return I.style.overscrollBehavior="contain",I.style.touchAction="none",I.addEventListener("wheel",_,{passive:!1}),I.addEventListener("touchmove",P,{passive:!1}),window.addEventListener("keydown",N,{passive:!1}),()=>{I.removeEventListener("wheel",_),I.removeEventListener("touchmove",P),window.removeEventListener("keydown",N),I.style.overscrollBehavior=B.overscrollBehavior,I.style.touchAction=B.touchAction}},[i,e]);const g=h.useRef({first:-1,last:-1}),y=h.useRef(!1),R=h.useCallback(()=>{const I=e.current;if(!I)return;const _=ro(I),P=(_==null?void 0:_.first)??-1,N=(_==null?void 0:_.last)??-1;g.current={first:P,last:N}},[e]),k=h.useRef(!1),O=h.useCallback(()=>{const I=e.current;if(!I||k.current)return;k.current=!0;const _=Math.min(I.scrollTop+Math.floor(I.clientHeight*.6),I.scrollHeight-I.clientHeight);requestAnimationFrame(()=>{I.scrollTo({top:_,behavior:"instant"})})},[e]);h.useEffect(()=>{!y.current&&i&&(k.current=!1,R()),y.current=i},[i,R]),h.useEffect(()=>{if(i!==!0)return;const I=e.current;if(!I)return;const{first:_,last:P}=g.current;if(_===-1||P===-1){O();return}if(I.scrollTop<=1){(async()=>{try{f.current=!0,await Pn(I,s,{behavior:"smooth",topPaddingRatio:.2})}finally{f.current=!1}R()})();return}if(s<_||s>P){async function B(){if(!I)return;const $=I.scrollTop<=1?0:.2;return await Pn(I,s,{behavior:"smooth",topPaddingRatio:$})}B().then($=>{$?R():O()})}},[i,s,O,R,e]);const z=h.useCallback(()=>{const I=e.current;if(!I)return;function _(A,j,L=.2,V=.8){const G=A.querySelector(`[data-g="${j}"]`);if(!G)return!1;const Q=A.getBoundingClientRect(),F=G.getBoundingClientRect();if(F.height<=0||Q.height<=0)return!1;const X=(F.top+F.height/2-Q.top)/Q.height;return X>=L&&X<=V}const P=A=>A==="instant"?"auto":A,N=A=>{const j=I.scrollTop,L=I.scrollHeight-I.clientHeight,V=L>0?j/L:0;let G=0;const Q=I.querySelector(`[data-g="${A}"]`);if(Q){const F=I.getBoundingClientRect();G=(Q.getBoundingClientRect().top-F.top)/F.height}l.getState().emit({type:"scroll",payload:{scrollTop:j,scrollRatio:V,anchorGI:A,anchorOffsetRatio:G}})},B=async(A,j="smooth")=>{var V;const L=Cs(n,A);(V=t.current)==null||V.scrollToIndex({index:L,align:"start",behavior:P(j)}),await xs(I,A)},$=()=>new Promise(A=>requestAnimationFrame(()=>A())),te=async A=>{if(_(I,A,.1,.7))return N(A),!0;f.current=!0;const j=I.querySelector(`[data-g="${A}"]`),L=I.getBoundingClientRect();let V=I.scrollTop<=1?0:.1;if(j){const Q=j.getBoundingClientRect();V=((Q.top+Q.height/2-L.top)/L.height>.5,.15)}const G=!!j;return G?(await Pn(I,A,{behavior:"smooth",topPaddingRatio:V}),await $()):G||await B(A,"auto"),f.current=!1,N(A),_(I,A,.1,.7)},fe=async A=>te(A);return{ensureVisibleGI:te,scrollToGI:fe,getVisibleRange:()=>ro(I),getScrollTop:()=>I.scrollTop,setScrollTop:A=>{I.scrollTop=A},getAnchorOffsetRatio:A=>{const j=I.querySelector(`[data-g="${A}"]`);if(!j)return 0;const L=j.getBoundingClientRect(),V=I.getBoundingClientRect();return(L.top-V.top)/V.height},scrollToGIAtOffset:async(A,j)=>{await fe(A),await new Promise(Z=>requestAnimationFrame(()=>requestAnimationFrame(Z)));const L=I.querySelector(`[data-g="${A}"]`);if(!L)return;const V=L.getBoundingClientRect(),G=I.getBoundingClientRect(),Q=G.height>0?G.height/I.clientHeight:1,F=(V.top-G.top)/Q,X=j*I.clientHeight,ee=F-X;I.scrollTop=I.scrollTop+ee},getScrollRatio:()=>{const A=I.scrollHeight-I.clientHeight;return A>0?I.scrollTop/A:0}}},[e,t,n,l]);return h.useEffect(()=>(console.log("@@@@@빌드스크롤api"),o(z()),()=>o(void 0)),[z,o]),null};function pa(e){var r,o;const t=e;if(!t)return!1;const n=((o=(r=t.tagName)==null?void 0:r.toLowerCase)==null?void 0:o.call(r))??"";return!!(["a","button","input","textarea","select","label"].includes(n)||t.isContentEditable)}function ga(){const e=U(v=>v.section),t=J(v=>v.theme),n=J(v=>v.fontFamily),r=J(v=>v.fontSizePx),o=J(v=>v.lineHeight),s=on[t],{blocks:i,nsPrefix:c}=h.useMemo(()=>({sectionId:e.section_id,blocks:e.ast.blocks,nsPrefix:`sec-${e.section_id??"0"}/`}),[e]),l=gn(),a=h.useCallback(()=>{const{isSettingsOpen:v,setSettingsOpen:w,toggleOverlays:u}=l.getState();v?w(!1):u()},[l]),{onClick:d,onDoubleClick:x}=Ks({onSingle:a,onDouble:()=>{},delay:250,shouldIgnoreTarget:pa}),m=h.useMemo(()=>({flex:1,fontFamily:n,background:s.bg,color:s.fg,fontSize:r,lineHeight:o,overflow:"hidden",WebkitTextSizeAdjust:"none",MozTextSizeAdjust:"none",textSizeAdjust:"none"}),[n,s.bg,s.fg,r,o]),S=h.useMemo(()=>({margin:"0 auto",width:"100%",height:"100%"}),[]);return console.log("ScrollSectionWrap render"),b.jsx("div",{onClick:d,onDoubleClick:x,style:m,children:b.jsx("div",{style:S,children:b.jsx(da,{section:e,blocks:i,nsPrefix:c})})})}function ha(e){return qe({attr:{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM12.293 7.293a1 1 0 011.414 0L15 8.586l1.293-1.293a1 1 0 111.414 1.414L16.414 10l1.293 1.293a1 1 0 01-1.414 1.414L15 11.414l-1.293 1.293a1 1 0 01-1.414-1.414L13.586 10l-1.293-1.293a1 1 0 010-1.414z",clipRule:"evenodd"},child:[]}]})(e)}function ma(e){return qe({attr:{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM14.657 2.929a1 1 0 011.414 0A9.972 9.972 0 0119 10a9.972 9.972 0 01-2.929 7.071 1 1 0 01-1.414-1.414A7.971 7.971 0 0017 10c0-2.21-.894-4.208-2.343-5.657a1 1 0 010-1.414zm-2.829 2.828a1 1 0 011.415 0A5.983 5.983 0 0115 10a5.984 5.984 0 01-1.757 4.243 1 1 0 01-1.415-1.415A3.984 3.984 0 0013 10a3.983 3.983 0 00-1.172-2.828 1 1 0 010-1.415z",clipRule:"evenodd"},child:[]}]})(e)}function ba(e){return qe({attr:{viewBox:"0 0 544 512"},child:[{tag:"path",attr:{d:"M0 479.98L99.92 512l35.45-35.45-67.04-67.04L0 479.98zm124.61-240.01a36.592 36.592 0 0 0-10.79 38.1l13.05 42.83-50.93 50.94 96.23 96.23 50.86-50.86 42.74 13.08c13.73 4.2 28.65-.01 38.15-10.78l35.55-41.64-173.34-173.34-41.52 35.44zm403.31-160.7l-63.2-63.2c-20.49-20.49-53.38-21.52-75.12-2.35L190.55 183.68l169.77 169.78L530.27 154.4c19.18-21.74 18.15-54.63-2.35-75.13z"},child:[]}]})(e)}function xa(e){return qe({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M9.64 7.64c.23-.5.36-1.05.36-1.64 0-2.21-1.79-4-4-4S2 3.79 2 6s1.79 4 4 4c.59 0 1.14-.13 1.64-.36L10 12l-2.36 2.36C7.14 14.13 6.59 14 6 14c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4c0-.59-.13-1.14-.36-1.64L12 14l7 7h3v-1L9.64 7.64zM6 8c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2zm0 12c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2zm6-7.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.22.5-.5.5zM19 3l-6 6 2 2 7-7V3h-3z"},child:[]}]})(e)}function va(e){return qe({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z",opacity:".87"},child:[]},{tag:"path",attr:{d:"M17.51 3.87 15.73 2.1 5.84 12l9.9 9.9 1.77-1.77L9.38 12l8.13-8.13z"},child:[]}]})(e)}function Sa(e){return qe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"},child:[]},{tag:"path",attr:{d:"M12 18c-.328 0 -.652 -.017 -.97 -.05c-3.172 -.332 -5.85 -2.315 -8.03 -5.95c2.4 -4 5.4 -6 9 -6c3.465 0 6.374 1.853 8.727 5.558"},child:[]},{tag:"path",attr:{d:"M18 18m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"},child:[]},{tag:"path",attr:{d:"M20.2 20.2l1.8 1.8"},child:[]}]})(e)}function ya(e){return qe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},child:[]},{tag:"path",attr:{d:"M4 8v-2a2 2 0 0 1 2 -2h2"},child:[]},{tag:"path",attr:{d:"M4 16v2a2 2 0 0 0 2 2h2"},child:[]},{tag:"path",attr:{d:"M16 4h2a2 2 0 0 1 2 2v2"},child:[]},{tag:"path",attr:{d:"M16 20h2a2 2 0 0 0 2 -2v-2"},child:[]}]})(e)}const wa="_wrap_1hfub_4",Ca="_visible_1hfub_25",Ia="_compact_1hfub_31",Ta="_row2_1hfub_34",ka="_controls_1hfub_44",Ra="_row1_1hfub_52",_a="_groupExpand_1hfub_80",Ma="_groupPlayback_1hfub_81",Ea="_groupSpeed_1hfub_82",ja="_groupFeatures_1hfub_83",Oa="_groupNav_1hfub_84",Pa="_btn_1hfub_116",za="_btnForbidden_1hfub_141",Ba="_btnActive_1hfub_147",Ga="_label_1hfub_158",Aa="_compactBtn_1hfub_168",we={wrap:wa,visible:Ca,compact:Ia,row2:Ta,controls:ka,row1:Ra,groupExpand:_a,groupPlayback:Ma,groupSpeed:Ea,groupFeatures:ja,groupNav:Oa,btn:Pa,btnForbidden:za,btnActive:Ba,label:Ga,compactBtn:Aa},La=h.memo(function(){const t=h.useRef(null),n=h.useContext(yt),r=(n==null?void 0:n.getState().isPlaybackMode)??!1,o=Ce(y=>y.status),s=Ce(y=>y.currentTimeMs),i=Ce(y=>y.currentClip),c=Ce(y=>y.playbackKind),l=J(y=>y.muteAudio),a=J(y=>y.audioSpeed),d=Ce(y=>y.getClipSrc),x=Ce(y=>y._onTime),m=Ce(y=>y._onEnded),S=Ce(y=>y._onError),v=U(y=>y.setCurrentGlobalRunIndex),w=U(y=>y.getSectionScrollApi),u=U(y=>y.snapToReadable),f=U(y=>y.edgeReadable),p=h.useRef(null),C=h.useRef(null),T=h.useRef(!1),M=h.useRef(null);h.useEffect(()=>{c==="real"&&(T.current=!0)},[c]);const E=h.useMemo(()=>{const y=d(i);if(!y)return null;try{return new URL(y,window.location.href).href}catch{return y}},[i,d]);h.useEffect(()=>{T.current=!0},[E]),h.useEffect(()=>{const y=t.current;if(!y)return;const R=()=>{if(y.paused||y.ended)return;const z=y.currentTime*1e3;T.current&&z===0||(z>0&&(T.current=!1),x(z))},k=()=>{var I,_;m();const z=f(1);typeof z=="number"&&z>=0&&(v(z,"audio"),(_=(I=w())==null?void 0:I.ensureVisibleGI)==null||_.call(I,z))},O=z=>{const I=z.currentTarget;console.warn("Audio error",{networkState:I.networkState,readyState:I.readyState}),S()};return y.addEventListener("timeupdate",R),y.addEventListener("ended",k),y.addEventListener("error",O),()=>{y.removeEventListener("timeupdate",R),y.removeEventListener("ended",k),y.removeEventListener("error",O)}},[x,m,S,f,v,w]),h.useEffect(()=>{if(r)return;const y=t.current;if(!y)return;if(!E){try{y.pause()}catch(z){console.log("pause error",z)}C.current=null;return}const R=y.currentSrc||y.src||null,k=!R||R!==E;if(k){try{y.pause()}catch(z){console.log("pause error",z)}y.src=E;try{y.load()}catch(z){console.log("load error",z)}C.current=E}y.muted=!!l,y.volume=1,y.playbackRate=typeof a=="number"?a:1;const O=async()=>{k&&await new Promise(z=>{let I=!1;const _=()=>{I||(I=!0,y.removeEventListener("loadedmetadata",_),y.removeEventListener("canplay",_),z())};y.addEventListener("loadedmetadata",_),y.addEventListener("canplay",_),y.readyState>=1&&_()});try{await y.play()}catch(z){console.warn("el.play() failed",z)}};if(o==="loading"||o==="playing")O();else try{y.pause()}catch(z){console.log("pause error",z)}},[E,l,o,a,r]),h.useEffect(()=>{if(r)return;const y=t.current;if(!y||c!=="real")return;const R=s/1e3;if(Number.isFinite(R)){if(y.readyState<1){p.current=s;const k=()=>{if(p.current!=null){const O=p.current/1e3;try{y.currentTime=O}catch(z){console.log("currentTime보정 오류",z)}p.current=null}y.removeEventListener("loadedmetadata",k),y.removeEventListener("canplay",k)};y.addEventListener("loadedmetadata",k),y.addEventListener("canplay",k);return}if(Math.abs(y.currentTime-R)>.2)try{y.currentTime=R}catch(k){console.log("currentTime보정오류",k)}}},[s,c,r]);const g=Ce(y=>y.getGIFromCT);return h.useEffect(()=>{var k,O;if(r||c!=="real"||o!=="playing"&&o!=="loading")return;const y=g(i,s);if(y<0)return;const R=u(y);R!==M.current&&(M.current=R,v(R,"audio"),R%5===0&&((O=(k=w())==null?void 0:k.ensureVisibleGI)==null||O.call(k,R)))},[o,i,s,c,g,u,v,w,r]),b.jsx("audio",{ref:t,preload:"auto",style:{display:"none"}})});function Ha(){return b.jsx(La,{})}const Na="_scrubberWrap_uw0cd_2",Fa="_labels_uw0cd_9",Wa="_index_uw0cd_15",Da="_controls_uw0cd_19",$a="_percent_uw0cd_25",Va="_range_uw0cd_46",kt={scrubberWrap:Na,labels:Fa,index:Wa,controls:Da,percent:$a,range:Va};function qa(){const e=J(M=>M.isDev),t=U(M=>M.currentGlobalRunIndex),n=U(M=>M.totalRuns),r=U(M=>M.setCurrentGlobalRunIndex),o=U(M=>M.getSectionScrollApi),s=U(M=>M.giToPercentTotal),i=U(M=>M.percentToGITotal),c=U(M=>M.snapToReadable),l=Ce(M=>M.scrollLock),a=Ce(M=>M.pause),d=Ce(M=>M.play),x=Ce(M=>M.syncToGI),[m,S]=h.useState(()=>s(t||0));h.useEffect(()=>{S(s(t||0))},[t,s]);const v=h.useRef(!1),w=h.useMemo(()=>Math.max(0,Math.min(t??0,Math.max(0,(n??1)-1)))+1,[t,n]),u=h.useCallback(()=>{l&&(a(),v.current=!0)},[l,a]),f=h.useCallback(M=>{S(Number(M.currentTarget.value))},[]),p=h.useCallback(async()=>{const M=i(m),E=c(M);a(),r(E,"scrubber-commit"),x(E);const g=o();g!=null&&g.ensureVisibleGI&&await g.ensureVisibleGI(E),v.current&&(v.current=!1,d())},[m,i,c,a,r,x,o,d]),C=h.useMemo(()=>({"--pct":`${m}%`}),[m]),T=h.useMemo(()=>Math.round(m),[m]);return b.jsxs("div",{className:kt.scrubberWrap,children:[e&&b.jsx("div",{className:kt.labels,children:b.jsxs("span",{className:kt.index,children:[w," / ",n||0]})}),b.jsxs("div",{className:kt.controls,children:[b.jsx("input",{type:"range",className:kt.range,min:0,max:100,step:.5,value:m,style:C,onMouseDown:u,onTouchStart:u,onChange:f,onMouseUp:()=>{p()},onTouchEnd:()=>{p()},onKeyUp:M=>M.key==="Enter"||M.key===" "?void p():void 0,"aria-label":"진행률"}),b.jsxs("span",{className:kt.percent,children:[T,"%"]})]})]})}const Ua=h.memo(qa),Ka=h.memo(function(){const t=h.useContext(yt),n=(t==null?void 0:t.getState().isPlaybackMode)??!1,r=Ce(y=>y.playbackKind),o=Ce(y=>y.status),s=Ce(y=>y.fake),i=J(y=>y.audioSpeed),c=Ce(y=>y.pause),l=U(y=>y.totalRuns),a=U(y=>y.currentGlobalRunIndex),d=U(y=>y.setCurrentGlobalRunIndex),x=U(y=>y.getSectionScrollApi),m=U(y=>y.nextReadableFrom),S=U(y=>y.edgeReadable),v=h.useRef(null),w=h.useRef(null),u=h.useRef(0),f=h.useRef(-1),p=!n&&r==="fake"&&o==="playing",C=Math.max(1,(s==null?void 0:s.totalWords)??1),T=h.useMemo(()=>{const y=200*i;return C/y*6e4},[C,i]),M=h.useMemo(()=>!l||l<=1||T<=0?0:(l-1)/T,[l,T]);h.useEffect(()=>{if(!p)return;const y=Math.max(0,Math.min(a??0,Math.max(0,(l??1)-1)));u.current=y,f.current=y,w.current=null},[p,a,l]);const E=h.useRef(-1);h.useEffect(()=>{if(!l){E.current=-1;return}const y=S(1);E.current=y??-1},[S,l]);const g=h.useCallback(y=>{(async()=>{var N,B;if(!p){v.current=null;return}if(!l||l<=1||M<=0){v.current=null;return}const R=w.current;w.current=y;const k=R==null?0:Math.max(0,y-R),O=l-1;u.current=Math.min(O,u.current+M*k);const z=Math.floor(u.current),I=x(),_=m(z,1);if(_==null){const $=E.current>=0?E.current:z;$!==f.current&&(f.current=$,d($,"audio"),await((N=I==null?void 0:I.ensureVisibleGI)==null?void 0:N.call(I,$))),c(),v.current=null;return}const P=_;P!==f.current&&(f.current=P,d(P,"audio"),P%5===0&&await((B=I==null?void 0:I.ensureVisibleGI)==null?void 0:B.call(I,P))),v.current=requestAnimationFrame(g)})().catch(console.error)},[p,l,M,m,d,x,c]);return h.useEffect(()=>(p?v.current==null&&(v.current=requestAnimationFrame(g)):(v.current&&(cancelAnimationFrame(v.current),v.current=null),w.current=null),()=>{v.current&&(cancelAnimationFrame(v.current),v.current=null)}),[p,g]),null}),Xa=h.memo(function(){return b.jsx(Ka,{})}),Ya="data:image/svg+xml,%3csvg%20width='111'%20height='111'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20xml:space='preserve'%20overflow='hidden'%3e%3cg%20transform='translate(-435%2011)'%3e%3cpath%20d='M532.723%2046.8125C530.242%2046.8292%20527.8%2047.4292%20525.593%2048.5642%20523.298%2049.7713%20520.952%2050.8767%20518.608%2051.8815%20517.451%2031.9953%20500.391%2016.8128%20480.505%2017.9704%20462.359%2019.0268%20447.834%2033.4215%20446.615%2051.5578L438.476%2048.1353%20438.476%2049.9344C438.473%2054.7251%20441.432%2059.0185%20445.91%2060.721%20446.509%2060.9604%20447.138%2061.1708%20447.767%2061.3801%20448.053%2061.4761%20448.339%2061.5709%20448.622%2061.6692L447.745%2066.7254C447.463%2068.2415%20447.818%2069.8071%20448.728%2071.0521%20449.635%2072.2874%20450.984%2073.1242%20452.493%2073.3877L452.768%2073.4282C453.011%2073.488%20453.259%2073.5198%20453.509%2073.523%20456.31%2073.5182%20458.699%2071.4953%20459.166%2068.7338L459.781%2064.8673C468.886%2066.8727%20478.184%2067.875%20487.508%2067.8562%20493.267%2067.8674%20499.021%2067.5125%20504.736%2066.7937%20504.893%2066.7613%20505.041%2066.7405%20505.184%2066.7231L505.562%2068.8379C505.986%2071.6231%20508.396%2073.6706%20511.213%2073.6375%20511.583%2073.648%20511.953%2073.5977%20512.307%2073.4883%20515.422%2072.958%20517.518%2070.0024%20516.988%2066.8869%20516.984%2066.8688%20516.981%2066.8509%20516.978%2066.833L516.758%2065.6767C522.066%2065.3125%20527.42%2065.3125%20532.607%2065.3125L532.723%2065.3125C537.831%2065.6255%20542.226%2061.7378%20542.539%2056.6292%20542.852%2051.5205%20538.965%2047.1255%20533.856%2046.8125%20533.479%2046.7894%20533.1%2046.7894%20532.723%2046.8125ZM516.326%2052.7256C511.914%2054.5082%20507.352%2055.8913%20502.693%2056.858L492.697%2041.007%20501.916%2026.3469C510.579%2032.4029%20515.911%2042.1631%20516.326%2052.7256ZM500.254%2057.3217C497.133%2057.8531%20493.977%2058.1542%20490.811%2058.2224L487.449%2058.2224C480.061%2058.2766%20472.682%2057.6921%20465.394%2056.4753L474.504%2042.1644%20490.692%2042.1644ZM482.602%2020.2188C488.73%2020.2155%20494.742%2021.8953%20499.981%2025.075L490.693%2039.8507%20474.491%2039.8195%20465.194%2025.0415C470.449%2021.8782%20476.468%2020.2107%20482.602%2020.2188ZM463.254%2026.2995%20472.504%2041.0023%20462.938%2056.0267C458.169%2055.1133%20453.47%2053.8672%20448.875%2052.2977%20449.378%2041.8709%20454.689%2032.2672%20463.254%2026.2995ZM456.876%2068.3719C456.595%2070.0115%20455.173%2071.2097%20453.509%2071.2094%20453.431%2071.2042%20453.354%2071.191%20453.278%2071.1701%20453.133%2071.1343%20452.984%2071.1101%20452.835%2071.0972%20451.94%2070.9264%20451.142%2070.4243%20450.601%2069.6912%20450.063%2068.9533%20449.853%2068.0254%20450.023%2067.1278L450.844%2062.3872%20457.525%2064.2962ZM514.123%2069.8103C513.566%2070.5637%20512.74%2071.0728%20511.817%2071.2313L511.657%2071.2718C511.514%2071.32%20511.363%2071.3392%20511.213%2071.3285%20509.525%2071.3698%20508.075%2070.1378%20507.844%2068.4656L507.486%2066.4688%20514.501%2065.8548%20514.701%2067.2527C514.87%2068.1485%20514.661%2069.0742%20514.123%2069.8103ZM532.723%2063%20532.607%2063C526.955%2063%20521.113%2063%20515.284%2063.4625L515.276%2063.4625%20515.276%2063.4625%20505.9%2064.2904%20504.36%2064.5078C498.77%2065.2064%20493.141%2065.5509%20487.508%2065.5391%20477.952%2065.5601%20468.425%2064.4858%20459.114%2062.3375L450.263%2059.8168%20446.738%2058.5658C443.792%2057.4525%20441.62%2054.9086%20440.982%2051.8237%20454.33%2057.5309%20470.023%2060.5383%20486.577%2060.5383%20486.868%2060.5383%20487.161%2060.5383%20487.452%2060.5383L490.828%2060.5383C500.421%2060.2575%20509.874%2058.1665%20518.689%2054.3755L518.797%2054.3304C521.437%2053.2216%20524.086%2051.9728%20526.649%2050.6235%20528.526%2049.6491%20530.608%2049.1354%20532.723%2049.125%20536.554%2048.8199%20539.908%2051.6785%20540.213%2055.5099%20540.518%2059.3414%20537.659%2062.6949%20533.828%2063%20533.46%2063.0293%20533.091%2063.0293%20532.723%2063Z'/%3e%3cpath%20d='M534.442%2053.75C534.442%2055.0272%20533.407%2056.0625%20532.13%2056.0625%20530.852%2056.0625%20529.817%2055.0272%20529.817%2053.75%20529.817%2052.4728%20530.852%2051.4375%20532.13%2051.4375%20533.407%2051.4375%20534.442%2052.4728%20534.442%2053.75Z'/%3e%3c/g%3e%3c/svg%3e",Qa="data:image/svg+xml,%3csvg%20width='159'%20height='159'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20xml:space='preserve'%20overflow='hidden'%3e%3cg%20transform='translate(-392%20-84)'%3e%3cpath%20d='M496.776%20189.601C496.122%20189.934%20495.77%20190.663%20495.916%20191.383L499.911%20210.219C500.074%20210.985%20500.75%20211.532%20501.533%20211.531L501.929%20211.531C503.729%20211.515%20505.222%20212.919%20505.319%20214.716%20505.389%20216.544%20503.964%20218.083%20502.136%20218.154%20502.093%20218.155%20502.05%20218.156%20502.006%20218.156L497.503%20218.156C495.941%20218.15%20494.594%20217.058%20494.263%20215.531L490.363%20197.147C490.174%20196.252%20489.294%20195.68%20488.4%20195.87%20488.399%20195.87%20488.399%20195.87%20488.399%20195.87%20488.174%20195.918%20487.962%20196.014%20487.776%20196.15L481.184%20200.898C479.925%20201.758%20478.809%20202.45%20477.776%20203.015%20476.998%20203.429%20476.669%20204.372%20477.022%20205.18%20477.402%20206.011%20478.385%20206.378%20479.217%20205.998%20479.253%20205.981%20479.288%20205.964%20479.322%20205.945%20480.618%20205.229%20481.877%20204.447%20483.094%20203.604L487.657%20200.313%20491.031%20216.213C491.677%20219.273%20494.376%20221.464%20497.503%20221.469L501.882%20221.469C505.577%20221.473%20508.587%20218.502%20508.631%20214.807%20508.608%20211.503%20506.158%20208.719%20502.883%20208.277L499.416%20191.93C502.051%20190.581%20506.719%20188.344%20509.619%20188.344%20515.225%20188.346%20520.812%20187.662%20526.252%20186.307%20530.081%20185.36%20533.152%20182.51%20534.381%20178.762L534.535%20178.295C535.676%20175.09%20535.323%20171.542%20533.573%20168.624L525.126%20154.2C522.254%20149.369%20517.625%20145.835%20512.207%20144.337%20512.364%20138.624%20511.516%20132.927%20509.7%20127.508%20504.714%20113.244%20488.452%20105.977%20487.761%20105.669%20487.336%20105.48%20486.851%20105.48%20486.426%20105.669%20485.959%20105.876%20484.987%20106.308%20483.1%20111.962%20482.811%20112.832%20483.281%20113.77%20484.15%20114.059%20485.019%20114.348%20485.958%20113.878%20486.247%20113.009%20486.649%20111.744%20487.129%20110.505%20487.685%20109.299%20491.474%20111.245%20502.818%20117.831%20506.566%20128.543%20508.418%20133.972%20509.183%20139.713%20508.815%20145.437%20508.734%20146.277%20509.297%20147.043%20510.122%20147.217%20515.212%20148.269%20519.626%20151.41%20522.287%20155.875L530.744%20170.299C532.007%20172.379%20532.256%20174.921%20531.42%20177.207L531.254%20177.727C530.378%20180.388%20528.194%20182.41%20525.474%20183.079%20520.288%20184.375%20514.964%20185.031%20509.619%20185.031%20505.93%20185.031%20501.061%20187.35%20496.776%20189.601Z'/%3e%3cpath%20d='M422.439%20192.966C421.946%20190.791%20421.681%20188.571%20421.649%20186.341%20421.7%20185.427%20421.001%20184.643%20420.086%20184.592%20419.171%20184.54%20418.388%20185.239%20418.336%20186.154%20418.324%20187.879%20418.47%20189.602%20418.772%20191.3%20412.577%20189.633%20408.907%20183.26%20410.574%20177.065%20411.942%20171.981%20416.559%20168.453%20421.824%20168.469%20422.661%20168.473%20423.491%20168.611%20424.284%20168.88%20425.056%20169.133%20425.898%20168.787%20426.271%20168.065%20435.26%20150.783%20455.639%20142.806%20473.971%20149.392%20474.837%20150.636%20475.5%20151.557%20475.559%20151.638%20476.094%20152.38%20477.129%20152.549%20477.872%20152.014%20478.614%20151.479%20478.782%20150.444%20478.248%20149.702%20478.216%20149.657%20475.101%20145.338%20473.444%20142.62%20467.845%20132.798%20470.283%20120.115%20471.358%20115.817%20475.617%20117.014%20487.816%20121.194%20493.442%20131.039%20496.082%20135.531%20497.921%20140.449%20498.876%20145.571%20499.017%20146.361%20499.705%20146.936%20500.508%20146.936L503.929%20146.936C504.816%20146.948%20505.561%20146.274%20505.639%20145.391%20505.7%20144.478%20505.01%20143.688%20504.097%20143.627%20504.059%20143.624%20504.021%20143.623%20503.982%20143.623L501.871%20143.623C500.778%20138.613%20498.902%20133.806%20496.312%20129.38%20488.742%20116.13%20471.271%20112.337%20470.533%20112.183%20469.704%20112.01%20468.879%20112.489%20468.618%20113.294%20468.385%20114.011%20463.013%20131.036%20470.568%20144.256%20470.579%20144.276%20470.745%20144.576%20470.978%20144.973%20470.99%20144.991%20470.978%20145.003%20470.96%20144.998%20452.498%20140.481%20433.287%20148.811%20423.966%20165.375%20423.261%20165.231%20422.543%20165.158%20421.824%20165.156%20413.582%20165.183%20406.923%20171.886%20406.95%20180.128%20406.974%20187.414%20412.256%20193.618%20419.446%20194.803L419.446%20194.803C419.532%20195.194%20419.611%20195.585%20419.706%20195.972L419.8%20196.329C422.428%20206.56%20428.796%20215.436%20437.646%20221.204%20437.917%20221.379%20438.232%20221.473%20438.554%20221.474L473.068%20221.474C476.748%20221.495%20479.756%20218.542%20479.801%20214.862%20479.847%20211.242%20476.95%20208.27%20473.329%20208.224%20473.278%20208.223%20473.227%20208.223%20473.176%20208.224L465.158%20208.224C474.765%20201.216%20476.873%20187.747%20469.866%20178.14%20465.812%20172.583%20459.348%20169.297%20452.47%20169.297%20450.573%20169.261%20448.682%20169.507%20446.858%20170.029%20445.981%20170.293%20445.484%20171.219%20445.749%20172.096%20446.013%20172.973%20446.938%20173.47%20447.816%20173.206%20449.328%20172.775%20450.897%20172.574%20452.47%20172.609%20462.532%20172.632%20470.67%20180.807%20470.648%20190.869%20470.63%20198.914%20465.337%20205.995%20457.626%20208.29%20456.784%20208.543%20456.286%20209.408%20456.491%20210.263%20456.686%20211.016%20457.369%20211.54%20458.147%20211.533L473.107%20211.533C474.951%20211.521%20476.458%20213.001%20476.48%20214.845%20476.52%20216.635%20475.102%20218.118%20473.312%20218.158%20473.264%20218.159%20473.216%20218.159%20473.168%20218.158L439.054%20218.158C431.004%20212.776%20425.251%20204.584%20422.922%20195.184%20422.853%20194.889%20422.795%20194.619%20422.733%20194.339Z'/%3e%3cpath%20d='M519.521%20163.831C519.708%20162.011%20518.383%20160.385%20516.563%20160.199%20514.743%20160.012%20513.117%20161.337%20512.931%20163.157%20512.744%20164.977%20514.069%20166.603%20515.889%20166.789%20516.113%20166.812%20516.339%20166.812%20516.563%20166.789%20518.126%20166.629%20519.361%20165.394%20519.521%20163.831Z'/%3e%3c/g%3e%3c/svg%3e",Za="_WPMSpeedButtonsWrap_r3byt_1",Ja="_btnWrap_r3byt_7",ec="_label_r3byt_14",tc="_iconBtn_r3byt_22",zt={WPMSpeedButtonsWrap:Za,btnWrap:Ja,label:ec,iconBtn:tc},ao=350,nc=40,rc=.85,oc=h.memo(function(){const t=J(m=>m.audioSpeed),n=J(m=>m.incAudioSpeed),r=J(m=>m.decAudioSpeed),o=h.useRef(null),s=h.useRef(ao),i=h.useRef(null),c=h.useCallback(m=>{const S=t;if(m==="inc"){if(S>=2)return!1;n()}else{if(S<=.3)return!1;r()}return!0},[t,n,r]),l=h.useCallback(()=>{i.current=null,o.current&&(clearTimeout(o.current),o.current=null)},[]),a=h.useCallback(()=>{i.current&&(s.current=Math.max(nc,Math.floor(s.current*rc)),o.current=window.setTimeout(()=>{c(i.current)?a():l()},s.current))},[c,l]),d=h.useCallback(m=>{if(i.current)return;i.current=m,s.current=ao,c(m)&&a();const v=()=>l();window.addEventListener("mouseup",v,{once:!0}),window.addEventListener("touchend",v,{once:!0})},[a,c,l]);h.useEffect(()=>l,[l]);const x=`${(t*100).toFixed(0)}%`;return b.jsx("div",{onMouseLeave:l,className:zt.WPMSpeedButtonsWrap,children:b.jsxs("div",{className:zt.btnWrap,children:[b.jsx("button",{className:zt.iconBtn,type:"button",title:"속도 느리게",onMouseDown:()=>d("dec"),onTouchStart:m=>{m.preventDefault(),d("dec")},onMouseUp:l,children:b.jsx("img",{src:Ya,alt:"느리게"})}),b.jsx("div",{className:zt.label,style:{minWidth:"44px",textAlign:"center"},children:b.jsx("div",{children:x})}),b.jsx("button",{className:zt.iconBtn,type:"button",title:"속도 빠르게",onMouseDown:()=>d("inc"),onTouchStart:m=>{m.preventDefault(),d("inc")},onMouseUp:l,children:b.jsx("img",{src:Qa,alt:"빠르게"})})]})})}),sc="_StepBtn_15t0r_1",ic={StepBtn:sc};function lc(e){return qe({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M208,48V208a8,8,0,0,1-13.66,5.66L128,147.31V208a8,8,0,0,1-13.66,5.66l-80-80a8,8,0,0,1,0-11.32l80-80A8,8,0,0,1,128,48v60.69l66.34-66.35A8,8,0,0,1,208,48Z"},child:[]}]})(e)}function ac(e){return qe({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M221.66,133.66l-80,80A8,8,0,0,1,128,208V147.31L61.66,213.66A8,8,0,0,1,48,208V48a8,8,0,0,1,13.66-5.66L128,108.69V48a8,8,0,0,1,13.66-5.66l80,80A8,8,0,0,1,221.66,133.66Z"},child:[]}]})(e)}function co({direction:e}){const t=U(x=>x.currentGlobalRunIndex),n=U(x=>x.totalRuns),r=U(x=>x.hasReadableInDir),o=U(x=>x.computeStepTarget),s=U(x=>x.setCurrentGlobalRunIndex),i=Ce(x=>x.syncToGI),c=U(x=>x.getSectionScrollApi),l=h.useCallback(async x=>{var v,w;const m=Math.max(t,Math.min(0,Math.max(0,(n??1)-1))),S=o(m,x);s(S,"scrubber-step"),i(S),await((w=(v=c())==null?void 0:v.ensureVisibleGI)==null?void 0:w.call(v,S))},[t,n,o,s,i,c]),a=h.useMemo(()=>{const x=Math.max(t,Math.min(0,Math.max(0,(n??1)-1))),m=!n||!r(x,1),S=!n||!r(x,-1);return e==="left"?S:m},[e,n,t,r]),d=h.useCallback(()=>{l(e==="left"?-1:1)},[e,l]);return b.jsx("button",{className:ic.StepBtn,type:"button",onClick:d,disabled:a,title:e==="left"?"이전":"다음",children:e==="left"?b.jsx(lc,{}):b.jsx(ac,{})})}const cc="_GCPlayBtn_n54mc_1",uc="_playing_n54mc_34",uo={GCPlayBtn:cc,playing:uc},dc=({size:e=60,color:t="#333",bgColor:n="#fff",isPlaying:r,onClick:o,tooltip:s="재생",title:i=""})=>b.jsx("button",{className:`${uo.GCPlayBtn} ${r?uo.playing:""}`,onClick:o,"data-tip":s,title:i,style:{"--btn-size":`${e}px`,"--icon-color":t,"--btn-bg":n}});function fc(e){return qe({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 294.1L383 167c9.4-9.4 24.6-9.4 33.9 0s9.3 24.6 0 34L273 345c-9.1 9.1-23.7 9.3-33.1.7L95 201.1c-4.7-4.7-7-10.9-7-17s2.3-12.3 7-17c9.4-9.4 24.6-9.4 33.9 0l127.1 127z"},child:[]}]})(e)}function pc(e){return qe({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 217.9L383 345c9.4 9.4 24.6 9.4 33.9 0 9.4-9.4 9.3-24.6 0-34L273 167c-9.1-9.1-23.7-9.3-33.1-.7L95 310.9c-4.7 4.7-7 10.9-7 17s2.3 12.3 7 17c9.4 9.4 24.6 9.4 33.9 0l127.1-127z"},child:[]}]})(e)}function gc(){var R;const e=J(k=>k.showOverlays),t=U(k=>k.section),n=!!t.ast.isAddedSplit,r=!!((R=t.audios)!=null&&R.length),o=U(k=>k.canTracking),s=U(k=>k.canToggleShowGaze),i=U(k=>k.showGaze),c=U(k=>k.onToggleShowGaze),l=J(k=>k.muteAudio),a=J(k=>k.showPointer),d=J(k=>k.showSplit),x=J(k=>k.toggleMuteAudio),m=J(k=>k.toggleShowPointer),S=J(k=>k.toggleShowSplit),v=J(k=>k.overlayCompactMode),w=J(k=>k.toggleOverlayCompactMode),u=an(),f=vt();h.useEffect(()=>{const k=u.getState(),{syncToGI:O,useFake:z,useReal:I}=k,_=k.playbackKind,P=f.getState().progress.currentGlobalRunIndex??0;if(!r){_!=="fake"&&z();return}l?_!=="fake"&&(console.log("이부분일까?"),z()):_!=="real"&&(O(P),I())},[r,l,f,u]);const p=Ce(k=>k.play),C=Ce(k=>k.pause),T=Ce(k=>k.status),M=h.useCallback(k=>{k.stopPropagation(),T==="playing"||T==="loading"?C():p()},[T,p,C]),E=an(),g=vt(),y=h.useCallback(async k=>{var me,Be;if(k.stopPropagation(),T==="playing"||T==="loading"){C();return}const{progress:O}=g.getState(),{currentGlobalRunIndex:z,snapToReadable:I,edgeReadable:_,setCurrentGlobalRunIndex:P,getSectionScrollApi:N}=O,B=E.getState(),$=B.currentClip,te=N==null?void 0:N(),fe=typeof z=="number"?z:0,ge=typeof I=="function"?I(fe):fe,ve=typeof _=="function"?_(1):null;if(ve!=null&&ge>=ve){P==null||P(ve,"audio"),await((me=te==null?void 0:te.ensureVisibleGI)==null?void 0:me.call(te,ve)),B.syncToGI(ve);return}P==null||P(ge,"audio"),await((Be=te==null?void 0:te.ensureVisibleGI)==null?void 0:Be.call(te,ge)),B.syncToGI(ge),p($)},[T,C,p,E,g]);return b.jsxs("div",{className:`${we.wrap} ${e?we.visible:""} ${v?we.compact:""}`,onClick:k=>{k.stopPropagation()},onTouchStart:k=>{k.stopPropagation()},children:[!v&&b.jsx(Ua,{}),b.jsx("div",{style:v?{display:"none"}:void 0,children:r&&!l?b.jsx(Ha,{}):b.jsx(Xa,{})}),b.jsxs("div",{className:we.controls,children:[b.jsxs("div",{className:we.row1,children:[b.jsx("div",{className:we.groupExpand,children:b.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),w()},className:we.compactBtn,title:v?"오버레이 확대":"오버레이 축소",children:v?b.jsx(pc,{size:24}):b.jsx(fc,{size:24})})}),b.jsxs("div",{className:we.groupPlayback,children:[b.jsx(co,{direction:"left"}),b.jsx(dc,{size:34,isPlaying:T==="playing",onClick:l?y:M,title:T==="playing"?"일시정지":"재생"}),b.jsx(co,{direction:"right"})]}),b.jsx("div",{className:we.groupSpeed,children:b.jsx(oc,{})})]}),b.jsxs("div",{className:we.row2,children:[b.jsxs("div",{className:we.groupFeatures,children:[r&&b.jsxs("button",{type:"button",onClick:k=>{k.stopPropagation(),x()},className:`${we.btn} ${l?"":we.btnActive}`,title:"오디오북 음소거 전환",children:[l?b.jsx(ha,{size:18}):b.jsx(ma,{size:18}),b.jsx("span",{className:we.label,children:"오디오북"})]}),b.jsxs("button",{type:"button",onClick:k=>{k.stopPropagation(),m()},className:`${we.btn} ${a?we.btnActive:""}`,title:"포인터 표시",children:[b.jsx(ba,{size:18}),b.jsx("span",{className:we.label,children:"포인터"})]}),n&&b.jsxs("button",{type:"button",onClick:k=>{k.stopPropagation(),S()},disabled:!n,className:`${we.btn} ${d?we.btnActive:""} ${n?"":we.btnForbidden}`,title:"끊어읽기 표시",children:[b.jsx(xa,{size:18}),b.jsx("span",{className:we.label,children:"끊어읽기"})]}),b.jsxs("button",{type:"button",onClick:k=>{k.stopPropagation(),c==null||c()},disabled:!o||!s,className:`${we.btn} ${o&&i?we.btnActive:""} ${o?"":we.btnForbidden}`,title:"시선 표시",children:[b.jsx(Sa,{size:18}),b.jsx("span",{className:we.label,children:"시선"})]})]}),b.jsxs("div",{className:we.groupNav,children:[b.jsx(ua,{}),b.jsx(fn,{})]})]})]})]})}const hc=h.memo(gc);function mc(e){return qe({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"32",d:"M262.29 192.31a64 64 0 1 0 57.4 57.4 64.13 64.13 0 0 0-57.4-57.4zM416.39 256a154.34 154.34 0 0 1-1.53 20.79l45.21 35.46a10.81 10.81 0 0 1 2.45 13.75l-42.77 74a10.81 10.81 0 0 1-13.14 4.59l-44.9-18.08a16.11 16.11 0 0 0-15.17 1.75A164.48 164.48 0 0 1 325 400.8a15.94 15.94 0 0 0-8.82 12.14l-6.73 47.89a11.08 11.08 0 0 1-10.68 9.17h-85.54a11.11 11.11 0 0 1-10.69-8.87l-6.72-47.82a16.07 16.07 0 0 0-9-12.22 155.3 155.3 0 0 1-21.46-12.57 16 16 0 0 0-15.11-1.71l-44.89 18.07a10.81 10.81 0 0 1-13.14-4.58l-42.77-74a10.8 10.8 0 0 1 2.45-13.75l38.21-30a16.05 16.05 0 0 0 6-14.08c-.36-4.17-.58-8.33-.58-12.5s.21-8.27.58-12.35a16 16 0 0 0-6.07-13.94l-38.19-30A10.81 10.81 0 0 1 49.48 186l42.77-74a10.81 10.81 0 0 1 13.14-4.59l44.9 18.08a16.11 16.11 0 0 0 15.17-1.75A164.48 164.48 0 0 1 187 111.2a15.94 15.94 0 0 0 8.82-12.14l6.73-47.89A11.08 11.08 0 0 1 213.23 42h85.54a11.11 11.11 0 0 1 10.69 8.87l6.72 47.82a16.07 16.07 0 0 0 9 12.22 155.3 155.3 0 0 1 21.46 12.57 16 16 0 0 0 15.11 1.71l44.89-18.07a10.81 10.81 0 0 1 13.14 4.58l42.77 74a10.8 10.8 0 0 1-2.45 13.75l-38.21 30a16.05 16.05 0 0 0-6.05 14.08c.33 4.14.55 8.3.55 12.47z"},child:[]}]})(e)}const bc="_host_gafql_3",xc="_topbar_gafql_11",vc="_visible_gafql_32",Sc="_backBtn_gafql_37",yc="_title_gafql_58",wc="_calibrationBtn_gafql_67",Cc="_disabled_gafql_87",Ic="_settingsBtn_gafql_95",dt={host:bc,topbar:xc,visible:vc,backBtn:Sc,title:yc,calibrationBtn:wc,disabled:Cc,settingsBtn:Ic};function Tc(){const e=J(x=>x.showOverlays),t=J(x=>x.overlayCompactMode),n=U(x=>x.onViewerClose),o=U(x=>x.section).ast.title,s=U(x=>x.canTracking),i=U(x=>x.handleAskCalibration),c=J(x=>x.setSettingsOpen),l=J(x=>x.setShowOverlays),a=h.useCallback(()=>{n==null||n()},[n]),d=h.useCallback(()=>{c(!0),l(!1)},[c,l]);return b.jsx("div",{className:dt.host,children:b.jsxs("div",{className:`${dt.topbar} ${e&&!t?dt.visible:""}`,children:[b.jsx("button",{type:"button",className:dt.backBtn,onClick:a,"aria-label":"뒤로가기",children:b.jsx(va,{size:28})}),b.jsx("div",{className:dt.title,children:b.jsx("span",{className:"truncate",children:o||"섹션 없음"})}),b.jsx("button",{type:"button",className:`${dt.calibrationBtn} ${s?"":dt.disabled}`,onClick:i,disabled:!s,"aria-label":"시선보정",title:"시선보정",children:b.jsx(ya,{size:24})}),b.jsx("button",{type:"button",className:dt.settingsBtn,onClick:d,"aria-label":"뷰어 설정",children:b.jsx(mc,{size:28})})]})})}const kc=h.memo(Tc),Rc="_wrap_62su0_7",_c="_wrapHidden_62su0_29",Mc="_wrapVisible_62su0_35",Ec="_scrollArea_62su0_71",jc="_row_62su0_81",Oc="_label_62su0_89",Pc="_btn_62su0_95",zc="_btnActive_62su0_106",Bc="_btnSmall_62su0_110",Gc="_pill_62su0_122",Ac="_themeCircle_62su0_133",Lc="_themeCircleActive_62su0_146",Hc="_stepRow_62su0_151",Nc="_stepLabel_62su0_159",Fc="_levelBox_62su0_172",Wc="_inlineFlex_62su0_177",Me={wrap:Rc,wrapHidden:_c,wrapVisible:Mc,scrollArea:Ec,row:jc,label:Oc,btn:Pc,btnActive:zc,btnSmall:Bc,pill:Gc,themeCircle:Ac,themeCircleActive:Lc,stepRow:Hc,stepLabel:Nc,levelBox:Fc,inlineFlex:Wc};function Dc({visible:e}){const t=J(g=>g.mode),n=J(g=>g.setMode),r=J(g=>g.theme),o=J(g=>g.setTheme),s=J(g=>g.fontFamily),i=J(g=>g.setFontFamily),c=J(g=>g.resetToDefaults),l=J(g=>g.getFontLevel()),a=J(g=>g.getLineLevel()),d=J(g=>g.getMarginLevel()),x=J(g=>g.setFontLevel),m=J(g=>g.setLineLevel),S=J(g=>g.setMarginLevel),v=J(g=>g.pointerStyle),w=J(g=>g.setPointerStyle),u=J(g=>g.pointerColor),f=J(g=>g.setPointerColor),p=J(g=>g.breakMarks),C=J(g=>g.toggleBreakMark),T=J(g=>g.getBreakGapLevel()),M=J(g=>g.setBreakGapLevel),E=`${Me.wrap} ${e?Me.wrapVisible:Me.wrapHidden}`;return b.jsxs("div",{className:E,role:"dialog","aria-modal":"true","aria-label":"뷰어 설정",children:[b.jsxs("div",{className:Me.scrollArea,children:[b.jsx(Bt,{label:"열람방식",children:b.jsxs("div",{className:Me.inlineFlex,children:[b.jsx(Rt,{active:t==="page",onClick:()=>n("page"),children:"페이지"}),b.jsx(Rt,{active:t==="scroll",onClick:()=>n("scroll"),children:"스크롤"})]})}),b.jsx(Bt,{label:"테마",children:b.jsx("div",{className:Me.inlineFlex,children:Object.keys(on).map(g=>{const y=g,R=on[y];return b.jsx("button",{type:"button",onClick:()=>o(y),className:`${Me.themeCircle} ${r===g?Me.themeCircleActive:""}`,style:{background:R.bg,color:R.fg,fontFamily:s},title:String(g),"aria-label":`테마: ${String(g)}`,children:"A"},`${g}_tc_button`)})})}),b.jsx(Bt,{label:"글꼴",children:b.jsx("div",{className:Me.inlineFlex,children:Ao.map(g=>b.jsx(Rt,{active:s===g.value,onClick:()=>i(g.value),title:g.value,children:g.label},g.label))})}),b.jsx(tn,{label:"글자 크기",level:l,min:1,max:12,onDec:()=>x(Math.max(1,l-1)),onInc:()=>x(Math.min(12,l+1))}),b.jsx(tn,{label:"줄 간격",level:a,min:1,max:7,onDec:()=>m(Math.max(1,a-1)),onInc:()=>m(Math.min(7,a+1))}),b.jsx(tn,{label:"여백",level:d,min:1,max:5,onDec:()=>S(Math.max(1,d-1)),onInc:()=>S(Math.min(5,d+1))}),b.jsx(Bt,{label:"포인터",children:b.jsxs("div",{className:Me.inlineFlex,children:[b.jsx(Rt,{active:v==="highlight",onClick:()=>w("highlight"),children:"형광펜"}),b.jsx(Rt,{active:v==="underline",onClick:()=>w("underline"),children:"밑줄"}),b.jsx("input",{type:"color",value:u,onChange:g=>f(g.target.value),"aria-label":"포인터 색상",style:{width:36,height:28,padding:0,border:"none",background:"transparent"}})]})}),b.jsx(Bt,{label:"끊기표시",children:b.jsx("div",{className:Me.inlineFlex,children:b.jsx(Rt,{active:p.slash,onClick:()=>C("slash"),children:"슬래쉬"})})}),b.jsx(tn,{label:"끊기간격",level:T,min:1,max:5,onDec:()=>M(Math.max(1,T-1)),onInc:()=>M(Math.min(5,T+1))})]}),b.jsx("div",{className:Me.inlineFlex,style:{justifyContent:"center"},children:b.jsx("button",{type:"button",onClick:c,className:Me.pill,children:"보기 설정 초기화"})})]})}function Bt({label:e,children:t}){return b.jsxs("div",{className:Me.row,children:[b.jsx("label",{className:Me.label,children:e}),t]})}function Rt({active:e,onClick:t,title:n,children:r}){return b.jsx("button",{type:"button",onClick:t,title:n,className:`${Me.btn} ${e?Me.btnActive:""}`,children:r})}function tn({label:e,level:t,min:n,max:r,onDec:o,onInc:s}){const i=t<=n,c=t>=r;return b.jsxs("div",{className:Me.stepRow,children:[b.jsx("label",{className:Me.stepLabel,children:e}),b.jsxs("div",{className:Me.inlineFlex,children:[b.jsx("button",{type:"button",onClick:o,disabled:i,className:Me.btnSmall,"aria-label":"감소",children:"−"}),b.jsx("div",{className:Me.levelBox,children:t}),b.jsx("button",{type:"button",onClick:s,disabled:c,className:Me.btnSmall,"aria-label":"증가",children:"+"})]})]})}const $c=h.memo(function(){const t=J(i=>i.showOverlays),n=J(i=>i.isSettingsOpen),r=U(i=>i.rangeStartGI),o=U(i=>i.rangeEndGI);return r!=null&&o!=null?null:b.jsxs("div",{"aria-hidden":!0,style:{pointerEvents:"none",position:"absolute",inset:0,containerType:"size",containerName:"viewer"},children:[b.jsx(kc,{}),b.jsx(hc,{}),b.jsx("div",{style:{pointerEvents:"auto"},children:b.jsx(Dc,{visible:!t&&n})})]})}),Vc=e=>(t,n,r)=>{const o=r.subscribe;return r.subscribe=((i,c,l)=>{let a=i;if(c){const d=(l==null?void 0:l.equalityFn)||Object.is;let x=i(r.getState());a=m=>{const S=i(m);if(!d(x,S)){const v=x;c(x=S,v)}},l!=null&&l.fireImmediately&&c(x,x)}return o(a)}),e(t,n,r)},qc=Vc;function Uc(e){return e?e.kind==="saved"?e.cdnUrl:e.blobUrl:null}function Kc(e){var o,s,i;if(!e||!/\S/.test(e))return 0;const t=((o=e.match(/[A-Za-z0-9]+(?:['’-][A-Za-z0-9]+)*/g))==null?void 0:o.length)??0,n=((s=e.match(/[\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A]+/g))==null?void 0:s.length)??0,r=((i=e.match(/[\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\u3040-\u30FF\u31FF\uAC00-\uD7AF\u1100-\u11FF\u3130-\u318F]/g))==null?void 0:i.length)??0;return t+n+Math.floor(r/2)}function Xc(e){let t=0;for(const n of e.ast.blocks??[])if(n.type==="paragraph")for(const r of n.runs??[])t+=Kc((r==null?void 0:r.text)??"");return t}function Yc(e){const t=e==null?void 0:e.recorderStore;let n=e==null?void 0:e.map,r=e==null?void 0:e.initialIndex;const o=S=>{if(!n)return null;const{g2ct:v}=n;if(!v)return null;const w=v[S];if(w)return{clip:w.clip,t:w.t};for(let u=1;u<=100&&S-u>=0;u++){const f=v[S-u];if(f)return{clip:f.clip,t:f.t}}for(let u=1;u<=100;u++){const f=v[S+u];if(f)return{clip:f.clip,t:f.t}}return null},s=(e==null?void 0:e.clips)??[];let i=0,c=0;const l=Math.max(1,Xc(e.section)||150);if(typeof(e==null?void 0:e.initialIndex)=="number"&&n){const S=o(e.initialIndex);S&&(i=S.clip,c=S.t,r=void 0)}const a=s.length>0,d=a?"paused":"idle",x=a?"real":"fake",m=a?null:{totalWords:l};return qt(qc((S,v)=>({clips:s,currentClip:Math.max(0,Math.min(i,Math.max(0,s.length-1))),currentTimeMs:Math.max(0,c),status:d,scrollLock:!1,playbackKind:x,fake:m,useFake:()=>S(w=>({playbackKind:"fake",fake:{totalWords:l},scrollLock:w.status==="playing"})),useReal:()=>S(w=>({playbackKind:"real",fake:{totalWords:l},scrollLock:w.status==="playing"})),injectMap:w=>{if(n=w,typeof r=="number"){const u=o(r);u&&S(f=>({currentClip:Math.max(0,Math.min(u.clip,Math.max(0,f.clips.length-1))),currentTimeMs:Math.max(0,u.t)})),r=void 0}},setClipAndMs:(w,u)=>S(f=>{const p=Math.max(0,f.clips.length-1);return{currentClip:Math.max(0,Math.min(w,p)),currentTimeMs:Math.max(0,u),status:f.status,scrollLock:f.scrollLock}}),setClips:w=>S(u=>{const f=Array.isArray(w)?w:[],p=f.length>0;return{clips:f,currentClip:0,currentTimeMs:0,status:p?"paused":"idle",playbackKind:p?"real":"fake",fake:p?null:u.fake??{totalWords:l},scrollLock:!1}}),clear:()=>S(w=>({clips:[],currentClip:0,currentTimeMs:0,status:"idle",playbackKind:"fake",fake:w.fake??{totalWords:l},scrollLock:!1})),play:(w,u)=>{t==null||t.getState().emit({type:"audio_control",payload:{action:"play"}}),S(f=>{if(f.playbackKind==="fake")return{status:"playing",scrollLock:!0};const p=typeof w=="number"?w:f.currentClip,C=typeof u=="number"?u:f.currentTimeMs;return{status:"loading",currentClip:Math.max(0,Math.min(p,Math.max(0,f.clips.length-1))),currentTimeMs:C,scrollLock:!0}})},pause:()=>{t==null||t.getState().emit({type:"audio_control",payload:{action:"pause"}}),S({status:"paused",scrollLock:!1})},seek:w=>S(u=>({currentTimeMs:Math.max(0,w),status:u.status})),stop:()=>S({status:"idle",currentTimeMs:0,scrollLock:!1}),nextClip:()=>S(w=>{if(w.playbackKind==="fake")return w;const u=Math.max(0,w.clips.length-1);return{currentClip:Math.min(w.currentClip+1,u),currentTimeMs:0,status:"loading",scrollLock:!0}}),prevClip:()=>S(w=>w.playbackKind==="fake"?w:{currentClip:Math.max(0,w.currentClip-1),currentTimeMs:0,status:"loading",scrollLock:!0}),setClipIndex:w=>S(u=>u.playbackKind==="fake"||w<0||w>=u.clips.length?u:{currentClip:w,currentTimeMs:0}),getClipSrc:w=>{const u=v();if(!u.clips.length)return null;const f=typeof w=="number"?w:u.currentClip;return Uc(u.clips[f])},getGIFromCT:(w,u)=>{if(!n)return-1;const f=n.byClip[w];if(!f||f.length===0)return-1;let p=0,C=f.length-1,T=0;for(;p<=C;){const M=p+C>>1;f[M].t<=u?(T=M,p=M+1):C=M-1}return f[Math.max(0,Math.min(T,f.length-1))].g},getCTFromGI:w=>{if(!n)return null;const{g2ct:u}=n;if(!u)return null;let f=u[w];if(!f){let p=w-1;const C=Math.max(0,w-100);for(;p>=C;){if(u[p]){f=u[p];break}p--}if(!f){let T=w+1;const M=w+100;for(;u[T]==null&&T<=M;)T++;u[T]&&(f=u[T])}}return f?{clip:f.clip,timeMs:f.t}:null},getMetaByGI:w=>{const u=v().getCTFromGI(w);return u?{clipIndex:u.clip,timeMs:u.timeMs}:null},syncToGI:w=>{const u=v().getMetaByGI(w);u&&v().setClipAndMs(u.clipIndex,u.timeMs)},_onTime:w=>S({currentTimeMs:w,status:"playing",scrollLock:!0}),_onEnded:()=>S(w=>{if(w.playbackKind==="fake")return{status:"ended",scrollLock:!1};const u=Math.max(0,w.clips.length-1);return w.currentClip>=u?{status:"ended",scrollLock:!1}:{currentClip:Math.min(w.currentClip+1,u),currentTimeMs:0,status:"loading",scrollLock:!0}}),_onError:()=>S({status:"error",scrollLock:!1}),_setStatusOnly:w=>S({status:w})})))}function Qc({children:e,initialState:t}){const n=h.useContext(yt)??void 0,r=h.useMemo(()=>Yc({...t,recorderStore:n}),[t,n]);return b.jsx(vn.Provider,{value:r,children:e})}function Zc(e){var s,i;const t={},n=[],r=((s=e==null?void 0:e.ast)==null?void 0:s.blocks)??[];let o=0;for(const c of r){if((c==null?void 0:c.type)==="image")continue;const l=(c==null?void 0:c.runs)??[];for(let a=0;a<l.length;a++){const d=l[a],x=o+a;d.audioChunkIndex!=null&&d.audioTimeMs!=null&&((t[i=d.audioChunkIndex]||(t[i]=[])).push({t:d.audioTimeMs,g:x}),n[x]={clip:d.audioChunkIndex,t:d.audioTimeMs})}o+=l.length}return Object.values(t).forEach(c=>c.sort((l,a)=>l.t-a.t)),{byClip:t,g2ct:n}}function Jc(e,t,n){if(n<=0)return-1;const r=Math.max(0,Math.min(t,n-1));if(e[r]===1)return r;for(let o=1;o<n;o++){const s=r-o;if(s>=0&&e[s]===1)return s;const i=r+o;return i<n&&e[i]===1?i:-1}return-1}function eu(e){const t=$l(e),n=Vl(t),r=t.reduce((d,x)=>d+(x||0),0),o=new Int32Array(Math.max(1,r)).fill(-1),s=new Uint8Array(Math.max(1,r)).fill(0),i=[],c=[];return e.forEach((d,x)=>{var u;if(d.type!=="paragraph")return;const m=n[x]??0,S=d.runs??[];for(let f=0;f<S.length;f++){const p=((u=S[f])==null?void 0:u.text)||"";sr(p)&&(s[m+f]=1)}const w=ql(S,m).map(f=>{var M;const p=f.startG-m,C=f.endG-f.startG+1;let T=-1;for(let E=0;E<C;E++){const g=((M=S[p+E])==null?void 0:M.text)??"";if(sr(g)){T=f.startG+E;break}}return{startG:f.startG,endG:f.endG,r0:p,len:C,firstReadableGI:T,splitIndex:f.splitIndex}});c[x]=w;for(const f of w){const p=i.length;for(let C=f.startG;C<=f.endG;C++)o[C]=p;i.push(f)}}),{nav:{groups:i,giToGroupIdx:o,readableGi:s,splitGroupsPerBlock:c},layout:{prefix:n,totalRuns:r}}}function tu(e){const{section:t,onViewerClose:n,onSectionNav:r,isCanPrev:o,isCanNext:s,canTracking:i,canToggleShowGaze:c,showGaze:l,onToggleShowGaze:a,handleAskCalibration:d,nav:x,layout:m,initialIndex:S,mountTime:v}=e,w=m.totalRuns??0,u=typeof S=="number"?S:w>0?0:-1,f=u>=0?Jc(x.readableGi,u,w):-1;return{section:t,sectionId:t.section_id,onViewerClose:n,onSectionNav:r,isCanPrev:o??!1,isCanNext:s??!1,canTracking:i??!1,canToggleShowGaze:c??!1,showGaze:l??!1,onToggleShowGaze:a,handleAskCalibration:d,currentGlobalRunIndex:f,lastUpdateBy:"program",totalRuns:w,pageIndex:0,totalPages:0,sectionLoading:!0,_loadingStartTime:v,_scrollApi:void 0,derivedNav:x,layout:m,rangeStartGI:null,rangeEndGI:null,translateOpen:!1,translateLoading:!1,translateText:void 0,translatedText:void 0,translateStartGI:void 0,translateEndGI:void 0}}function nu(e){const{section:t,initialIndex:n,onViewerClose:r,onSectionNav:o,isCanPrev:s,isCanNext:i,canTracking:c,canToggleShowGaze:l,showGaze:a,onToggleShowGaze:d,handleAskCalibration:x,eventBridgeStore:m}=e,S=t.ast.blocks,{nav:v,layout:w}=eu(S),u=Date.now(),f=tu({section:t,onViewerClose:r,onSectionNav:o,isCanPrev:s,isCanNext:i,canTracking:c,canToggleShowGaze:l,showGaze:a,onToggleShowGaze:d,handleAskCalibration:x,nav:v,layout:w,initialIndex:n,mountTime:u});return m&&queueMicrotask(()=>{m.getState().emit({type:"render_start",payload:{sectionId:t.section_id}},u),m.getState().emit({type:"loading_start",payload:{}},u)}),qt((p,C)=>{const T=K=>{p(D=>D.progress._scrollApi===K?D:{progress:{...D.progress,_scrollApi:K}})},M=()=>C().progress._scrollApi,E=K=>{p(D=>{const A=D.progress;if(A.totalRuns===K)return D;const j=A.currentGlobalRunIndex<0&&K>0;return{progress:{...A,totalRuns:K,currentGlobalRunIndex:j?0:A.currentGlobalRunIndex,lastUpdateBy:j?"program":A.lastUpdateBy}}})},g=(K,D="program")=>{const A=C().progress.currentGlobalRunIndex,j=C().progress,L=j.totalRuns>0?Math.max(-1,Math.min(K,j.totalRuns-1)):K;A===L&&j.lastUpdateBy===D||(p(V=>({progress:{...V.progress,currentGlobalRunIndex:L,lastUpdateBy:D}})),A!==L&&m&&m.getState().emit({type:"global_index_change",payload:{globalIndex:L}}))},y=K=>{const{sectionLoading:D,_loadingStartTime:A}=C().progress;if(D===K)return;const j=Date.now();if(K)p(L=>({progress:{...L.progress,sectionLoading:!0,_loadingStartTime:j}})),m&&m.getState().emit({type:"loading_start",payload:{}});else{const V=(A?j-A:0)/1e3;p(G=>({progress:{...G.progress,sectionLoading:!1,_loadingStartTime:null}})),m&&m.getState().emit({type:"loading_end",payload:{duration:V}})}},R=K=>{p(D=>({progress:{...D.progress,pageIndex:K}}))},k=K=>{p(D=>({progress:{...D.progress,totalPages:K}}))},O=(K,D)=>{const j=C().progress.rangeStartGI==null;if(p(L=>({progress:{...L.progress,rangeStartGI:Math.min(K,D),rangeEndGI:Math.max(K,D)}})),m){const L=_();m.getState().emit({type:j?"range_select":"range_change",payload:{startGI:Math.min(K,D),endGI:Math.max(K,D),text:L}})}},z=()=>{p(K=>({progress:{...K.progress,rangeStartGI:null,rangeEndGI:null}})),m&&m.getState().emit({type:"range_clear",payload:{}})},I=K=>{const{rangeStartGI:D,rangeEndGI:A}=C().progress;D==null||A==null||(K<D?p(j=>({progress:{...j.progress,rangeStartGI:K}})):K>A?p(j=>({progress:{...j.progress,rangeEndGI:K}})):z())},_=()=>{var Q;const{rangeStartGI:K,rangeEndGI:D,section:A,layout:j}=C().progress;if(K==null||D==null||!j)return"";const L=((Q=A.ast)==null?void 0:Q.blocks)??[],V=j.prefix,G=[];for(let F=0;F<L.length;F++){const X=L[F];if(X.type!=="paragraph")continue;const ee=X.runs??[],Z=V[F]??0;for(let ie=0;ie<ee.length;ie++){const re=Z+ie;re>=K&&re<=D&&G.push(ee[ie].text??"")}}return G.join("")},P=K=>{p(D=>({progress:{...D.progress,translateOpen:K.isOpen,translateLoading:K.isLoading??!1,translateText:K.text,translatedText:K.translatedText,translateStartGI:K.startGI,translateEndGI:K.endGI}}))},N=()=>{p(K=>({progress:{...K.progress,translateOpen:!1,translateLoading:!1,translateText:void 0,translatedText:void 0,translateStartGI:void 0,translateEndGI:void 0}}))},B=K=>{const{totalRuns:D,derivedNav:A}=C().progress,j=A==null?void 0:A.readableGi;if(!j||D<=0)return K;const L=D,V=Math.max(0,Math.min(K,L-1));if(j[V])return V;let G=V-1,Q=V+1;for(;G>=0||Q<L;){if(Q<L&&j[Q])return Q;if(G>=0&&j[G])return G;Q+=1,G-=1}return V},$=(K,D)=>{const{totalRuns:A,derivedNav:j}=C().progress,L=j==null?void 0:j.readableGi;if(!L||A<=0)return null;if(D>0){for(let V=Math.min(Math.max(K,0),A-1);V<A;V+=1)if(L[V])return V}else for(let V=Math.min(Math.max(K,0),A-1);V>=0;V-=1)if(L[V])return V;return null},te=K=>{const{totalRuns:D,derivedNav:A}=C().progress,j=A==null?void 0:A.readableGi;if(!j||D<=0)return null;if(K>0){for(let L=D-1;L>=0;L-=1)if(j[L])return L}else for(let L=0;L<D;L+=1)if(j[L])return L;return null};return{progress:{...f,registerSectionScrollApi:T,getSectionScrollApi:M,setTotalRuns:E,setCurrentGlobalRunIndex:g,setSectionLoading:y,setPageIndex:R,setTotalPages:k,setTranslateState:P,clearTranslate:N,setRange:O,clearRange:z,extendRange:I,getRangeText:_,snapToReadable:B,nextReadableFrom:$,edgeReadable:te,hasReadableInDir:(K,D)=>$(K+(D>0?1:-1),D)!=null,computeStepTarget:(K,D)=>{const{totalRuns:A,derivedNav:j}=C().progress;if(!A||A<=0)return K;const L=(j==null?void 0:j.groups)??[],V=j==null?void 0:j.giToGroupIdx;if(!L.length||!V){const Z=A-1;return B(Math.max(0,Math.min(K+D,Z)))}let G=V[K]??-1;if(G<0||G>=L.length)for(let ee=0;ee<L.length;ee+=1){const Z=L[ee];if(K>=Z.startG&&K<=Z.endG){G=ee;break}}if(G<0||G>=L.length)return te(D)??B(K);const Q=ee=>ee>=0&&ee<L.length&&(L[ee].firstReadableGI??-1)>=0;let F=G+D;for(;F>=0&&F<L.length&&!Q(F);)F+=D;if(F<0||F>=L.length)return te(D)??B(K+D);const X=L[F].firstReadableGI;return X>=0?X:B(K+D)},giToPercentTotal:K=>{const D=C().progress.totalRuns;return!D||D<=1?0:Math.max(0,Math.min(K,D-1))/(D-1)*100},percentToGITotal:K=>{const D=C().progress.totalRuns;if(!D||D<=1)return 0;const A=Math.max(0,Math.min(K,100)),j=Math.round(A/100*(D-1));return Math.max(0,Math.min(j,D-1))}}}})}function ru({children:e,initialState:t,gazeSync:n}){const r=h.useContext(yt),o=h.useMemo(()=>nu({...t,...n?n.getSnapshot():{},eventBridgeStore:r}),[t,r]);return h.useEffect(()=>{if(!n)return;const s=()=>{const i=n.getSnapshot(),c=o.getState().progress;c.canTracking===i.canTracking&&c.canToggleShowGaze===i.canToggleShowGaze&&c.showGaze===i.showGaze&&c.onToggleShowGaze===i.onToggleShowGaze&&c.handleAskCalibration===i.handleAskCalibration||o.setState(l=>({progress:{...l.progress,canTracking:i.canTracking,canToggleShowGaze:i.canToggleShowGaze,showGaze:i.showGaze,onToggleShowGaze:i.onToggleShowGaze,handleAskCalibration:i.handleAskCalibration}}))};return s(),n.subscribe(s)},[o,n]),b.jsx(lr.Provider,{value:o,children:e})}function ou({children:e,initialState:t}){const n=h.useContext(yt)??void 0,r=h.useRef(Ys({init:t,recorderStore:n}));return b.jsx(ir.Provider,{value:r.current,children:e})}const su=({pages:e,pageIndex:t,maxWidth:n})=>{const r=U(p=>p.section),o=h.useMemo(()=>{var p;return((p=r.ast)==null?void 0:p.blocks)??[]},[r]),s=J(p=>p.marginX),i=J(p=>p.lineHeight),c=J(p=>p.fontSizePx),l=J(p=>p.fontFamily),a=J(p=>p.viewportHeight),d=U(p=>{var C;return((C=p.layout)==null?void 0:C.prefix)??[]}),x=U(p=>{var C;return((C=p.derivedNav)==null?void 0:C.splitGroupsPerBlock)??[]}),m=e[t],S=h.useMemo(()=>{const p=[];return o.forEach((C,T)=>{(C.type==="paragraph"||C.type==="image")&&p.push(T)}),p},[o]),v=h.useMemo(()=>{if(!m)return[];const p=[];for(let C=m.startBlock;C<=m.endBlock;C++){const T=S[C];T!=null&&p.push(T)}return p},[m,S]),w=h.useMemo(()=>{const p=[];for(const C of v){const T=o[C];(T==null?void 0:T.type)==="paragraph"&&p.push({b:T,originalBlockIndex:C})}return p},[v,o]),u=h.useMemo(()=>{const p=[],C=Sr();return w.forEach((T,M)=>{p[M]=yr(T.b,C)}),p},[w]),f=(p,C,T)=>{if(!p||p.length===0)return[];const M=[];for(const E of p){const g=E.startG,y=E.endG;if(y<C||g>T)continue;const R=Math.max(g,C),k=Math.min(y,T),O=R-g|0,z=Math.max(0,k-R+1);if(z<=0)continue;const I=(E.r0??0)+O;M.push({...E,startG:R,endG:k,r0:I,len:z})}return M};return b.jsx("div",{style:{position:"relative",width:"100%",height:"100%",minHeight:0,display:"flex",alignItems:"stretch",justifyContent:"center",fontFamily:l,fontSize:c,lineHeight:i,boxSizing:"border-box"},children:b.jsxs("div",{style:{width:"100%",maxWidth:n,height:"100%",boxSizing:"border-box",overflow:"hidden",display:"flex",flexDirection:"column",margin:"0 auto"},children:[b.jsx("div",{style:{height:40}}),b.jsx("div",{style:{flex:1,overflow:"hidden"},children:v.map((p,C)=>{var A;const T=o[p],M=C===0,E=C===v.length-1,g={boxSizing:"border-box",paddingRight:`${s}px`,paddingLeft:`${s}px`,maxWidth:n,margin:"0 auto",display:"flex",width:"100%",height:"auto"},y=`sec-${r.section_id}/blk-${T.id??p}`;if(T.type==="image"){const{src:j,alt:L,width:V,height:G}=T,Q=V&&G?`${V} / ${G}`:"4 / 3",F=a>80?Math.floor((a-80)*.6):void 0;return b.jsx("div",{style:g,children:b.jsxs("div",{style:{margin:"12px 0",textAlign:"center",width:"100%"},children:[b.jsx("div",{style:{position:"relative",width:"100%",maxHeight:F,aspectRatio:Q},children:b.jsx("img",{src:j,alt:L||"",loading:"eager",style:{pointerEvents:"none",position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"contain",display:"block"}})}),L&&b.jsx("div",{style:{fontSize:12,color:"#6b7280",marginTop:4},children:L})]})},y)}const R=T,k=w.findIndex(j=>j.originalBlockIndex===p),O=k>=0?u[k]:void 0,z=R.runs??[],I=z.length;let _=0,P=Math.max(0,I-1);M&&m.startOffsetInBlock!=null&&(_=Math.min(Math.max(0,m.startOffsetInBlock),P)),E&&m.endOffsetInBlock!=null&&(P=Math.max(_,Math.min(m.endOffsetInBlock,P)));const N=_>0,B=d[p]??0,$=x[p]??[],te=B+_,fe=B+P;let ge=f($,te,fe);const ve=B+_;ge=ge.map(j=>{const L=Math.max(0,(j.startG??te)-ve),V=j.len??Math.max(1,(j.endG??fe)-(j.startG??te)+1);return{...j,r0:L,len:V}});const me=_<=P?z.slice(_,P+1):[],Be=R.list?R.list.level*24:0,K=((A=R.list)==null?void 0:A.kind)==="bullet"?R.list.glyph??"•":void 0,D=N?void 0:O??K;return b.jsx("div",{style:g,children:b.jsxs("p",{style:{width:"100%",margin:"8px 0",paddingLeft:Be,textAlign:R.textAlign,whiteSpace:"pre-wrap",boxSizing:"border-box"},children:[R.list&&D?b.jsx("span",{"aria-hidden":!0,style:{minWidth:16,display:"inline-block",whiteSpace:"nowrap",userSelect:"none"},children:D||""}):null,b.jsx(bs,{preGroups:ge,runs:me,ns:y,baseIndex:ve,sectionId:String(r.section_id)})]})},y)})})]})})},fo=.5;function iu(e,t){const n=h.useRef(null),r=h.useRef(null),o=h.useRef(!1);h.useEffect(()=>{const s=()=>{n.current==null&&(n.current=requestAnimationFrame(()=>{n.current=null,t(),o.current=!0,requestAnimationFrame(()=>{o.current=!1})}))},i=new ResizeObserver(l=>{if(o.current)return;const a=l[0],{width:d,height:x}=a.contentRect,m=r.current;if(!m){r.current={w:d,h:x};return}Math.abs(m.w-d)<fo&&Math.abs(m.h-x)<fo||(r.current={w:d,h:x},s())});e.forEach(l=>{l.current&&i.observe(l.current)});const c=()=>s();return window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c),i.disconnect(),n.current!=null&&cancelAnimationFrame(n.current),n.current=null}},[e,t])}function lu(e){const{onPrev:t,onNext:n,onSingle:r,onDouble:o,shouldIgnoreTarget:s,shouldIgnoreSwipe:i,horizontalThreshold:c=120,velocityThreshold:l=.6,singleDelayMs:a=250,doubleClickWindowMs:d=300,onDragMove:x,onDragEnd:m,pageTransitionThreshold:S}=e,v=S??c,w=10,u=$e.useRef({touchId:null,startX:0,startY:0,startT:0,swiping:!1,mouseDown:!1,mouseSwiping:!1,mStartX:0,mStartY:0,mStartT:0,capturedEl:null,prevUserSelect:"",lastTapT:0,singleTimer:null,suppressClick:!1}),f=()=>{u.current.singleTimer!=null&&(clearTimeout(u.current.singleTimer),u.current.singleTimer=null)},p=$e.useCallback(_=>{if(s!=null&&s(_))return;const P=performance.now();P-u.current.lastTapT<=d&&u.current.lastTapT>0?(f(),u.current.lastTapT=0,o==null||o()):(f(),r&&(u.current.singleTimer=window.setTimeout(()=>{u.current.singleTimer=null,r()},a)),u.current.lastTapT=P)},[s,d,o,r,a]),C=$e.useCallback((_,P)=>{const N=Math.abs(_)/Math.max(1,P);Math.abs(_)>=v||N>=l?_<0?n():t():m==null||m()},[v,l,n,t,m]),T=$e.useCallback(_=>{if(_.touches.length!==1)return;const P=i??s;if(P!=null&&P(_.target))return;const N=_.touches[0];u.current.touchId=N.identifier,u.current.startX=N.clientX,u.current.startY=N.clientY,u.current.startT=_.timeStamp,u.current.swiping=!1},[i,s]),M=$e.useCallback(_=>{if(u.current.touchId==null)return;const P=Array.from(_.touches).find(te=>te.identifier===u.current.touchId);if(!P)return;const N=P.clientX-u.current.startX,B=Math.abs(N),$=Math.abs(P.clientY-u.current.startY);if(!u.current.swiping)if(B>=w&&B>$)u.current.swiping=!0;else return;x==null||x(N)},[x]),E=$e.useCallback(_=>{if(u.current.touchId==null)return;const P=Array.from(_.changedTouches).find(te=>te.identifier===u.current.touchId);if(!P)return;const N=P.clientX-u.current.startX,B=P.clientY-u.current.startY,$=_.timeStamp-u.current.startT;u.current.swiping?C(N,$):Math.abs(N)<10&&Math.abs(B)<10&&p(_.target),u.current.suppressClick=!0,u.current.touchId=null,u.current.swiping=!1},[C,p]),g=$e.useCallback(()=>{u.current.swiping&&(m==null||m()),u.current.touchId=null,u.current.swiping=!1},[m]),y=$e.useCallback(_=>{if(_.pointerType==="touch"||u.current.mouseDown)return;const P=i??s;P!=null&&P(_.target)||(u.current.mouseDown=!0,u.current.mouseSwiping=!1,u.current.mStartX=_.clientX,u.current.mStartY=_.clientY,u.current.mStartT=_.timeStamp,u.current.suppressClick=!1,u.current.capturedEl=_.currentTarget)},[i,s]),R=$e.useCallback(_=>{if(_.pointerType==="touch"||!u.current.mouseDown)return;const P=_.clientX-u.current.mStartX,N=Math.abs(P),B=Math.abs(_.clientY-u.current.mStartY);if(!u.current.mouseSwiping)if(N>=w&&N>B){u.current.mouseSwiping=!0,u.current.suppressClick=!0;const $=u.current.capturedEl;if($!=null&&$.setPointerCapture)try{$.setPointerCapture(_.pointerId)}catch{}u.current.prevUserSelect=document.body.style.userSelect,document.body.style.userSelect="none",_.preventDefault()}else return;x==null||x(P),_.preventDefault()},[x]),k=$e.useCallback(_=>{var N;if(_.pointerType==="touch"||!u.current.mouseDown)return;if(u.current.mouseSwiping){const B=_.clientX-u.current.mStartX,$=_.timeStamp-u.current.mStartT;C(B,$),document.body.style.userSelect=u.current.prevUserSelect}const P=u.current.capturedEl;if((N=P==null?void 0:P.hasPointerCapture)!=null&&N.call(P,_.pointerId))try{P.releasePointerCapture(_.pointerId)}catch{}u.current.mouseDown=!1,u.current.mouseSwiping=!1,u.current.capturedEl=null},[C]),O=$e.useCallback(_=>{_.pointerType!=="touch"&&(u.current.mouseSwiping&&(m==null||m(),document.body.style.userSelect=u.current.prevUserSelect),u.current.mouseDown=!1,u.current.mouseSwiping=!1,u.current.capturedEl=null)},[m]),z=$e.useCallback(()=>{u.current.mouseSwiping&&(m==null||m(),document.body.style.userSelect=u.current.prevUserSelect),u.current.mouseDown=!1,u.current.mouseSwiping=!1,u.current.capturedEl=null},[m]),I=$e.useCallback(_=>{if(u.current.suppressClick){u.current.suppressClick=!1;return}p(_.target)},[p]);return $e.useEffect(()=>()=>{f(),document.body.style.userSelect=""},[]),{onTouchStart:T,onTouchMove:M,onTouchEnd:E,onTouchCancel:g,onPointerDown:y,onPointerMove:R,onPointerUp:k,onPointerCancel:O,onLostPointerCapture:z,onClick:I}}var zn,po;function Is(){if(po)return zn;po=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return zn=e,zn}var Bn,go;function au(){if(go)return Bn;go=1;var e=typeof Yt=="object"&&Yt&&Yt.Object===Object&&Yt;return Bn=e,Bn}var Gn,ho;function Ts(){if(ho)return Gn;ho=1;var e=au(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Gn=n,Gn}var An,mo;function cu(){if(mo)return An;mo=1;var e=Ts(),t=function(){return e.Date.now()};return An=t,An}var Ln,bo;function uu(){if(bo)return Ln;bo=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return Ln=t,Ln}var Hn,xo;function du(){if(xo)return Hn;xo=1;var e=uu(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return Hn=n,Hn}var Nn,vo;function ks(){if(vo)return Nn;vo=1;var e=Ts(),t=e.Symbol;return Nn=t,Nn}var Fn,So;function fu(){if(So)return Fn;So=1;var e=ks(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,o=e?e.toStringTag:void 0;function s(i){var c=n.call(i,o),l=i[o];try{i[o]=void 0;var a=!0}catch{}var d=r.call(i);return a&&(c?i[o]=l:delete i[o]),d}return Fn=s,Fn}var Wn,yo;function pu(){if(yo)return Wn;yo=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return Wn=n,Wn}var Dn,wo;function gu(){if(wo)return Dn;wo=1;var e=ks(),t=fu(),n=pu(),r="[object Null]",o="[object Undefined]",s=e?e.toStringTag:void 0;function i(c){return c==null?c===void 0?o:r:s&&s in Object(c)?t(c):n(c)}return Dn=i,Dn}var $n,Co;function hu(){if(Co)return $n;Co=1;function e(t){return t!=null&&typeof t=="object"}return $n=e,$n}var Vn,Io;function mu(){if(Io)return Vn;Io=1;var e=gu(),t=hu(),n="[object Symbol]";function r(o){return typeof o=="symbol"||t(o)&&e(o)==n}return Vn=r,Vn}var qn,To;function bu(){if(To)return qn;To=1;var e=du(),t=Is(),n=mu(),r=NaN,o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,i=/^0o[0-7]+$/i,c=parseInt;function l(a){if(typeof a=="number")return a;if(n(a))return r;if(t(a)){var d=typeof a.valueOf=="function"?a.valueOf():a;a=t(d)?d+"":d}if(typeof a!="string")return a===0?a:+a;a=e(a);var x=s.test(a);return x||i.test(a)?c(a.slice(2),x?2:8):o.test(a)?r:+a}return qn=l,qn}var Un,ko;function xu(){if(ko)return Un;ko=1;var e=Is(),t=cu(),n=bu(),r="Expected a function",o=Math.max,s=Math.min;function i(c,l,a){var d,x,m,S,v,w,u=0,f=!1,p=!1,C=!0;if(typeof c!="function")throw new TypeError(r);l=n(l)||0,e(a)&&(f=!!a.leading,p="maxWait"in a,m=p?o(n(a.maxWait)||0,l):m,C="trailing"in a?!!a.trailing:C);function T(I){var _=d,P=x;return d=x=void 0,u=I,S=c.apply(P,_),S}function M(I){return u=I,v=setTimeout(y,l),f?T(I):S}function E(I){var _=I-w,P=I-u,N=l-_;return p?s(N,m-P):N}function g(I){var _=I-w,P=I-u;return w===void 0||_>=l||_<0||p&&P>=m}function y(){var I=t();if(g(I))return R(I);v=setTimeout(y,E(I))}function R(I){return v=void 0,C&&d?T(I):(d=x=void 0,S)}function k(){v!==void 0&&clearTimeout(v),u=0,d=w=x=v=void 0}function O(){return v===void 0?S:R(t())}function z(){var I=t(),_=g(I);if(d=arguments,x=this,w=I,_){if(v===void 0)return M(w);if(p)return clearTimeout(v),v=setTimeout(y,l),T(w)}return v===void 0&&(v=setTimeout(y,l)),S}return z.cancel=k,z.flush=O,z}return Un=i,Un}var vu=xu();const Su=zo(vu);function yu(e,t=200,n,r){const o=h.useRef(e),s=h.useRef(n);h.useEffect(()=>{o.current=e},[e]),h.useEffect(()=>{s.current=n},[n]);const i=h.useMemo(()=>{const c=Su((...a)=>{o.current(...a)},t,r),l=((...a)=>{var d;(d=s.current)==null||d.call(s),c(...a)});return l.cancel=c.cancel.bind(c),l.flush=c.flush.bind(c),l},[t,r]);return h.useEffect(()=>()=>i.cancel(),[i]),i}const wu="https://fonts.googleapis.com/css2?family=Nanum+Myeongjo:wght@400;700&family=Noto+Sans+KR:wght@300;400;500;700&family=Noto+Serif+KR:wght@400;700&display=swap";let Kn=!1;function Cu(){if(Kn||typeof document>"u")return;if(document.querySelector('link[href*="fonts.googleapis.com"][href*="Noto"]')){Kn=!0;return}const t=document.createElement("link");t.rel="stylesheet",t.href=wu,document.head.appendChild(t),Kn=!0}const Rs=new Map,_s=e=>Rs.get(e)??0,Iu=e=>{const t=_s(e)+1;return Rs.set(e,t),t};class Ms extends Error{constructor(){super("calcPages canceled due to a newer invocation");Ir(this,"code","CALC_PAGES_CANCELED");this.name="CalcPagesCanceled"}}const Ye=(e,t)=>{if(e!==_s(t))throw new Ms},Xn=e=>{const t=getComputedStyle(e),n=parseFloat(t.marginTop||"0")||0,r=parseFloat(t.marginBottom||"0")||0;return{mt:n,mb:r}},Ro=e=>{const t=e.getClientRects(),n=t.length?t[0].top:e.getBoundingClientRect().top,r=e.querySelectorAll("[data-runbox]"),o=[];return r.forEach((s,i)=>{const c=s.getClientRects(),l=c.length?c[c.length-1].bottom:n;o[i]=Math.max(0,l-n)}),o},Tu=(e,t,n)=>{if(n<16)return async(o=24)=>{Ye(e,t)};let r=0;return async(o=24)=>{r++,r%o===0&&(Ye(e,t),await new Promise(s=>requestAnimationFrame(()=>s())),Ye(e,t))}};async function ku({viewHost:e,measureRoot:t,contentArea:n,items:r,cfgMaxWidth:o,marginX:s,fontFamily:i,fontSizePx:c,lineHeight:l,showSplit:a,breakGapPx:d=0,showSlash:x,paragraphMarkers:m,playbackScale:S=1,viewportHeight:v=0,instanceId:w="default"}){var f,p,C;const u=Iu(w);if(Ye(u,w),i&&typeof document<"u"&&document.fonts){Cu();try{const T=`${c}px ${i}`;await document.fonts.load(T),document.fonts.check(T)||await document.fonts.ready}catch{}}Ye(u,w);try{const T=Math.abs(S-1)>.001,M=1/S;T&&(t.style.transform=`scale(${M})`,t.style.transformOrigin="top left");const E=Math.max(0,e.offsetWidth||0),g=Math.max(0,Math.min(E,o));t.style.maxWidth=`${g}px`,Ye(u,w);let y=Math.round(n.offsetHeight||0);y||(y=Math.max(0,n.clientHeight|0)),console.log("[calcPages] playbackScale:",S.toFixed(4),T?"(scaled, applying inverse)":"(no scale)"),console.log("[calcPages] viewWidth:",E),console.log("[calcPages] pageBoxWidth:",g),console.log("[calcPages] maxPageHeight:",y),console.log("[calcPages] contentArea rect:",n.getBoundingClientRect()),console.log("[calcPages] measureRoot rect:",t.getBoundingClientRect());const R=1.5,k=(G,Q)=>Q+G<=y-R,O=getComputedStyle(e),z={letterSpacing:O.letterSpacing,wordSpacing:O.wordSpacing,fontKerning:O.fontKerning||"normal",fontVariantLigatures:O.fontVariantLigatures||"normal",textTransform:O.textTransform||"none",direction:O.direction||"ltr",wordBreak:O.wordBreak||"keep-all",overflowWrap:O.overflowWrap||O.wordWrap||"break-word",hyphens:O.hyphens||"manual"},I=G=>{G.style.letterSpacing=z.letterSpacing||"",G.style.wordSpacing=z.wordSpacing||"",G.style.fontKerning=z.fontKerning||"",G.style.fontVariantLigatures=z.fontVariantLigatures||"",G.style.textTransform=z.textTransform||"",G.style.direction=z.direction||"",G.style.wordBreak=z.wordBreak||"",G.style.wordWrap=z.overflowWrap||"",G.style.overflowWrap=z.overflowWrap||"",G.style.hyphens=z.hyphens||""},_=g,P=Math.max(0,_-2*(s||0));n.innerHTML="";const N=document.createElement("div");N.style.boxSizing="border-box",N.style.width=`${_}px`,N.style.maxWidth=`${_}px`,N.style.margin="0 auto",N.style.display="flex",n.appendChild(N);const B=document.createElement("div");B.style.boxSizing="border-box",B.style.paddingRight=`${s}px`,B.style.paddingLeft=`${s}px`,B.style.width=`${_}px`,B.style.maxWidth=`${_}px`,B.style.margin="0 auto",B.style.display="flex",B.style.justifyContent="center",B.style.height="auto",N.appendChild(B);const $=new Map,te={},fe=Tu(u,w,r.length),ge=(G,Q)=>{const F=document.createElement("p");return F.style.margin="8px 0",F.style.paddingLeft=Q?`${Q}px`:"0",F.style.textAlign=G.textAlign??"start",F.style.whiteSpace="pre-wrap",F.style.lineHeight=String(l),F.style.fontSize=`${c}px`,F.style.boxSizing="border-box",F.style.fontFamily=i??"",F.style.width="100%",I(F),F},ve=(G,Q)=>{const F=Q??[],X=document.createDocumentFragment();for(let ee=0;ee<F.length;ee++){const Z=F[ee],ie=document.createElement("span");ie.dataset.runbox=String(ee),ie.style.whiteSpace="pre-wrap";const re=document.createElement("span");if(re.dataset.run=String(ee),re.textContent=(Z==null?void 0:Z.text)??"",re.style.whiteSpace="pre-wrap",Z!=null&&Z.bold&&(re.style.fontWeight="700"),Z!=null&&Z.italic&&(re.style.fontStyle="italic"),Z!=null&&Z.underline&&(re.style.textDecoration="underline"),ie.appendChild(re),a&&(Z!=null&&Z.split)&&ee!==F.length-1){const be=Math.max(0,(d??0)/2),ue=document.createElement("span");ue.style.display="inline-block",ue.style.width=`${be}px`;const ye=document.createElement("span");if(ye.style.display="inline-block",ye.style.width=`${be}px`,ie.appendChild(ue),x){const ke=document.createElement("span");ke.textContent=" / ",ie.appendChild(ke)}ie.appendChild(ye)}X.appendChild(ie)}G.appendChild(X)},me=v>80?Math.floor((v-80)*.6):void 0,Be=G=>{const Q=G!=null&&G.width&&(G!=null&&G.height)?`${G.width} / ${G.height}`:"4 / 3",F=document.createElement("div");F.style.margin="12px 0",F.style.textAlign="center",F.style.width=`${P}px`;const X=document.createElement("div");X.style.position="relative",X.style.width="100%",me&&(X.style.maxHeight=`${me}px`),X.style.aspectRatio=Q;const ee=document.createElement("div");if(ee.style.position="absolute",ee.style.inset="0",ee.style.width="100%",ee.style.height="100%",X.appendChild(ee),F.appendChild(X),G!=null&&G.alt){const Z=document.createElement("div");Z.style.fontSize="12px",Z.style.color="#6B7280",Z.style.marginTop="4px",Z.textContent=String(G.alt),I(Z),F.appendChild(Z)}return F};for(let G=0;G<r.length;G++){Ye(u,w);const Q=r[G];if(B.dataset.block=String(G),B.innerHTML="",Q.kind==="image"){const ye=Q.block,ke=Be(ye);B.appendChild(ke);const Pe=ke.getBoundingClientRect(),{mt:Ee,mb:Le}=Xn(ke);te[G]={contentH:Math.ceil(Pe.height),mt:Ee,mb:Le},await fe(24);continue}const F=Q.block,X=F.list?(F.list.level??0)*24:0,ee=Q.paraIndex??0,Z=m[ee]??(((f=F.list)==null?void 0:f.kind)==="bullet"?((p=F.list)==null?void 0:p.glyph)??"•":void 0);if(!!(F.list&&Z)){const ye=ge(F,X);ye.dataset.variant="with";const ke=ge(F,X);ke.dataset.variant="no";const Pe=document.createElement("span");Pe.textContent=`${Z} `,Pe.style.minWidth="16px",Pe.style.display="inline-block",Pe.style.whiteSpace="nowrap",Pe.style.userSelect="none",ye.appendChild(Pe),ve(ye,F.runs),ve(ke,F.runs);const Ee=document.createDocumentFragment();Ee.appendChild(ye),Ee.appendChild(ke),B.appendChild(Ee)}else{const ye=ge(F,X);ye.dataset.variant="with",ve(ye,F.runs),B.appendChild(ye)}const re=B.querySelector('p[data-variant="with"]'),be=B.querySelector('p[data-variant="no"]'),ue=be??re;if(re&&ue){const ye=Ro(re),ke=Ro(ue),{mt:Pe,mb:Ee}=Xn(re),{mt:Le,mb:ot}=Xn(ue),De=((C=F.runs)==null?void 0:C.length)??0,je=be?ke:ye,Je=be?Le:Pe,Xe=be?ot:Ee;if(G<3){const ut=re.getBoundingClientRect().height;console.log(`[calcPages] para ${G}: height=${ut.toFixed(2)}, lastBottom=[${ye.slice(-3).map(Pt=>Pt.toFixed(1)).join(",")}], runs=${De}`)}$.set(G,{runsLen:De,lastBottomWith:ye,lastBottomNo:je,mtWith:Pe,mbWith:Ee,mtNo:Je,mbNo:Xe})}await fe(24)}Ye(u,w),B.innerHTML="";const K=(G,Q,F,X)=>{if(Q>F)return{top:0,content:0,mb:0};const ee=X?G.lastBottomNo:G.lastBottomWith,Z=X?G.mtNo:G.mtWith,ie=X?G.mbNo:G.mbWith,re=X?0:Z,be=Q>0?ee[Q-1]??0:0,ue=Math.max(0,(ee[F]??0)-be);return{top:re,content:ue,mb:ie}},D=[];let A=0,j,L=null,V=null;for(;A<r.length;){Ye(u,w);const G=A;let Q=0,F=0,X=j;X!=null&&L===A&&V!=null&&(X=Math.max(X,V+1));let ee=-1,Z;for(;A<r.length;){if(Ye(u,w),r[A].kind==="image"){const je=te[A]??{contentH:0,mt:0,mb:0},Xe=(Q===0?je.mt:F+je.mt)+je.contentH;if(k(Xe,Q)){Q+=Xe,ee=A,Z=void 0,F=je.mb,A+=1,j=void 0,L=null,V=null;continue}if(Q===0){D.push({startBlock:G,endBlock:A,...X!=null?{startOffsetInBlock:X}:{}}),A+=1,j=void 0,L=null,V=null,F=0;break}break}const re=$.get(A),be=re.runsLen,ue=A===G&&X!=null?X:0;if(ue>=be){A+=1,j=void 0,L=null,V=null;continue}const ye=ue>0,ke=K(re,ue,be-1,ye),Ee=(Q===0?ke.top:F+ke.top)+ke.content;if(k(Ee,Q)){Q+=Ee,ee=A,Z=be-1,F=ke.mb,A+=1,j=void 0,L=null,V=null;continue}let Le=ue,ot=be-1,De=ue-1;for(;Le<=ot;){Ye(u,w);const je=Le+ot>>1,Je=K(re,ue,je,ye),Xe=(Q===0?Je.top:F+Je.top)+Je.content;k(Xe,Q)?(De=je,Le=je+1):ot=je-1}if(De>=ue){D.push({startBlock:G,endBlock:A,...X!=null?{startOffsetInBlock:X}:{},endOffsetInBlock:De}),j=De+1,L=A,V=De,F=0;break}if(Q>0){D.push({startBlock:G,endBlock:ee>=0?ee:Math.min(A-1,r.length-1),...X!=null?{startOffsetInBlock:X}:{},...Z!=null?{endOffsetInBlock:Z}:{}}),F=0;break}else{const je=ue;D.push({startBlock:G,endBlock:A,...X!=null?{startOffsetInBlock:X}:{},endOffsetInBlock:je}),j=je+1,L=A,V=je,F=0;break}}(D.length===0||D[D.length-1].startBlock!==G)&&D.push({startBlock:G,endBlock:ee>=0?ee:Math.min(A-1,r.length-1),...X!=null?{startOffsetInBlock:X}:{},...Z!=null?{endOffsetInBlock:Z}:{}})}return N.remove(),T&&(t.style.transform="",t.style.transformOrigin=""),Ye(u,w),{pages:D,pageByRunIndex:null}}catch(T){throw console.error(T),T}}function _o(e,t,n){var r;if(!e)return null;for(let o=e.startBlock;o<=e.endBlock;o++){const s=t[o];if(!s||s.kind!=="paragraph")continue;const i=((r=s.block.runs)==null?void 0:r.length)??0;if(!i)continue;const c=o===e.startBlock&&e.startOffsetInBlock!=null?Math.min(Math.max(0,e.startOffsetInBlock),i-1):0;return(n[s.originalIndex]??0)+c}return null}function Ru(e,t,n,r){var o;for(let s=0;s<t.length;s++){const i=t[s];for(let c=i.startBlock;c<=i.endBlock;c++){const l=n[c];if(!l||l.kind!=="paragraph")continue;const a=((o=l.block.runs)==null?void 0:o.length)??0;if(!a)continue;let d=0,x=a-1;c===i.startBlock&&i.startOffsetInBlock!=null&&(d=Math.max(0,Math.min(i.startOffsetInBlock,x))),c===i.endBlock&&i.endOffsetInBlock!=null&&(x=Math.max(d,Math.min(i.endOffsetInBlock,x)));const m=r[l.originalIndex]??0,S=m+d,v=m+x;if(e>=S&&e<=v)return s}}return-1}function _u(e){var r,o;const t=e;if(!t)return!1;const n=((o=(r=t.tagName)==null?void 0:r.toLowerCase)==null?void 0:o.call(r))??"";return!!(["a","button","input","textarea","select","label"].includes(n)||t.isContentEditable)}function Mu(e){var n,r;const t=e;return t?((n=t.style)==null?void 0:n.cursor)==="grab"||((r=t.closest)==null?void 0:r.call(t,"[data-range-handle]"))!=null:!1}function Eu(e){const t=[],n=[];let r=0;return e.forEach((o,s)=>{o.type==="paragraph"?(t.push({kind:"paragraph",block:o,originalIndex:s,paraIndex:r}),n.push(s),r+=1):o.type==="image"&&t.push({kind:"image",block:o,originalIndex:s})}),{items:t,paraIndexMap:n}}function ju(){var Cr;const e=h.useId(),t=U(q=>q.section),n=U(q=>q.sectionLoading),r=U(q=>q.rangeStartGI),o=U(q=>q.rangeEndGI),s=r!=null&&o!=null,i=wt(),c=J(q=>q.theme),l=on[c],a=J(q=>q.fontFamily),d=J(q=>q.fontSizePx),x=J(q=>q.lineHeight),m=J(q=>q.marginX),S=J(q=>q.viewportHeight),v=860,w=h.useRef(null),{items:u}=h.useMemo(()=>{var q;return Eu(((q=t==null?void 0:t.ast)==null?void 0:q.blocks)??[])},[t]),f=h.useMemo(()=>{const q=[],Oe=Sr();return u.forEach(Ge=>{if(Ge.kind==="paragraph"){const bt=Ge.paraIndex;q[bt]=yr(Ge.block,Oe)}}),q},[u]),[p,C]=h.useState({pages:[],pageByRunIndex:null}),T=U(q=>q.pageIndex),M=U(q=>q.setPageIndex),E=h.useRef(0),g=h.useRef(null),[y,R]=h.useState(!1),[k,O]=h.useState(null),[z,I]=h.useState(!1),_=h.useMemo(()=>({flex:1,fontFamily:a,background:l.bg,color:l.fg,fontSize:d,lineHeight:x,overflow:"hidden",width:"100%",height:"100%",position:"relative",boxSizing:"border-box",WebkitTextSizeAdjust:"none",MozTextSizeAdjust:"none",textSizeAdjust:"none"}),[a,l.bg,l.fg,d,x]),{showSplit:P,breakGapPx:N,slash:B}=J(Vt(q=>{var Oe;return{showSplit:q.showSplit,breakGapPx:q.breakGapPx??0,slash:((Oe=q.breakMarks)==null?void 0:Oe.slash)??!1}})),$=vt();h.useEffect(()=>{p&&p.pages.length&&(console.log("그래서 총 페이지",p.pages.length),$.getState().progress.setTotalPages(p.pages.length+1),(async()=>{const q=$.getState().progress.setSectionLoading;await ft(),await ft(),await ft(),await ft(),console.log("recalc종료"),q(!1)})())},[p,$]);const te=h.useCallback(()=>{console.log("@@@@@@recalc호출");const q=w.current,Oe=re.current,Ge=be.current;if(console.log("showSplit",P),!q||!Oe||!Ge||u.length===0){C({pages:[],pageByRunIndex:null}),M(0),$.getState().progress.setTotalPages(0);return}(async()=>{const bt=performance.now();try{const et=i.getState().playbackScale,{pages:Tt,pageByRunIndex:js}=await ku({viewHost:q,measureRoot:Oe,contentArea:Ge,items:u,cfgMaxWidth:v,marginX:m,fontFamily:a,fontSizePx:d,lineHeight:x,showSplit:P,breakGapPx:N,showSlash:B,paragraphMarkers:f,playbackScale:et,viewportHeight:S,instanceId:e}),Os=performance.now();console.log(`✅ calcPages 완료: ${(Os-bt).toFixed(1)} ms (${Tt.length} pages)`),C({pages:Tt,pageByRunIndex:js}),M(0)}catch(et){if(et instanceof Ms){console.log("이젠실행 취소 들어옴!");return}console.log("에러발생",et)}})()},[M,u,v,m,a,d,x,P,N,B,f,i,S,e]),fe=U(q=>q.setCurrentGlobalRunIndex),ge=U(q=>{var Oe;return((Oe=q.layout)==null?void 0:Oe.prefix)??[]}),ve=Ce(q=>q.syncToGI),me=h.useCallback(q=>{const Oe=p.pages.length+1,Ge=T+q;if(Ge<0||Ge>=Oe)return;const bt=T===p.pages.length;if(Ge===p.pages.length){M(Ge);return}if(bt&&q===-1){const Tt=_o(p.pages[Ge],u,ge);Tt!=null&&(fe(Tt,"scrubber-step"),ve(Tt)),M(Ge);return}const et=_o(p.pages[Ge],u,ge);et!=null?(fe(et,"scrubber-step"),ve(et)):M(Ge)},[T,p.pages,u,ge,fe,M,ve]),Be=h.useCallback(()=>{y||E.current!==0?(O("prev"),R(!1)):me(-1)},[y,me]),K=h.useCallback(()=>{y||E.current!==0?(O("next"),R(!1)):me(1)},[y,me]),D=gn(),A=h.useCallback(()=>{const{isSettingsOpen:q,setSettingsOpen:Oe,toggleOverlays:Ge}=D.getState();q?Oe(!1):Ge()},[D]),j=p.pages.length+1,L=((Cr=w.current)==null?void 0:Cr.clientWidth)||400,V=h.useCallback(q=>{var et;const Oe=g.current;if(!Oe)return;const Ge=((et=w.current)==null?void 0:et.clientWidth)||1,bt=q/Ge*33.333;Oe.style.transform=`translate3d(${-33.333+bt}%, 0, 0)`},[]),G=h.useCallback(q=>{T===0&&q>0||T>=j-1&&q<0||(E.current=q,V(q),y||R(!0))},[T,j,V,y]),Q=h.useCallback(()=>{E.current=0,R(!1);const q=g.current;q&&(q.style.transition="transform 250ms ease-out",q.style.transform="translate3d(-33.333%, 0, 0)")},[]),F=h.useCallback(q=>{if(q.target!==q.currentTarget||q.propertyName!=="transform")return;const Oe=k;I(!0),O(null),E.current=0,Oe==="prev"?me(-1):Oe==="next"&&me(1)},[k,me]);h.useLayoutEffect(()=>{z&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{I(!1)})})},[z]);const X=an(),ee=h.useCallback(q=>s||Mu(q)?!0:_u(q),[s]),Z=h.useCallback(q=>X.getState().status==="playing"?!0:ee(q),[X,ee]),ie=lu({onPrev:Be,onNext:K,onSingle:A,onDouble:()=>{},shouldIgnoreTarget:ee,shouldIgnoreSwipe:Z,horizontalThreshold:120,velocityThreshold:.6,singleDelayMs:250,doubleClickWindowMs:300,onDragMove:G,onDragEnd:Q,pageTransitionThreshold:L*.5}),re=h.useRef(null),be=h.useRef(null),ue=h.useCallback(()=>{const q=$.getState().progress.setSectionLoading;q(!0)},[$]),ye=h.useMemo(()=>({trailing:!0,leading:!1,maxWait:1e3}),[]),ke=yu(te,200,ue,ye),Pe=h.useRef("");h.useEffect(()=>{if(S<=0)return;const q=`${a}|${d}|${x}|${m}|${P}|${N}|${B}|${S}|${t==null?void 0:t.section_id}`;Pe.current!==q&&(Pe.current=q,console.log("debounceRecalc 취소"),ke.cancel(),ue(),te())},[ke,te,ue,a,d,x,m,P,N,B,S,t==null?void 0:t.section_id]),iu([w],ke);const Ee=U(q=>q.registerSectionScrollApi);h.useEffect(()=>(Ee({ensureVisibleGI:()=>Promise.resolve(!0),scrollToGI:()=>Promise.resolve(!0),getVisibleRange:()=>null,getScrollTop:()=>0,setScrollTop:()=>{},getAnchorOffsetRatio:()=>0,scrollToGIAtOffset:()=>Promise.resolve(),stepPage:me}),()=>Ee(void 0)),[Ee,me]);const Le=t.quizzes&&t.quizzes.length>0,ot=p.pages.length>0&&T===p.pages.length,De=T>0?T-1:null,je=T<j-1?T+1:null,Je=h.useMemo(()=>k==="prev"?"translate3d(0%, 0, 0)":k==="next"?"translate3d(-66.666%, 0, 0)":"translate3d(-33.333%, 0, 0)",[k]),Xe=q=>n?null:q===p.pages.length?b.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,width:"100%",height:"100%"},children:[Le&&b.jsx(Ss,{}),b.jsx(fn,{isIcon:!1})]}):b.jsx(su,{pages:p.pages,pageIndex:q,maxWidth:v}),ut={width:"33.333%",height:"100%",flexShrink:0,display:"flex",alignItems:"stretch",justifyContent:"center",overflow:"hidden",boxSizing:"border-box",backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden"},Pt=!z&&(!y||k!==null);return console.log("여기리랜더"),b.jsxs("div",{ref:w,style:{..._,touchAction:"none"},...ie,children:[b.jsxs("div",{ref:g,style:{display:"flex",width:"300%",height:"100%",transform:Je,transition:Pt?"transform 250ms ease-out":"none",willChange:"transform",boxSizing:"border-box",backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden"},onTransitionEnd:k?F:void 0,children:[b.jsx("div",{style:ut,children:De!==null&&Xe(De)}),b.jsx("div",{style:ut,children:Xe(T)}),b.jsx("div",{style:ut,children:je!==null&&Xe(je)})]}),b.jsx("div",{ref:re,"aria-hidden":!0,style:{position:"absolute",contain:"layout style paint",left:-999999,top:-999999,zIndex:-999999,opacity:0,width:"100%",maxWidth:v,height:"100%",minHeight:0,boxSizing:"border-box",overflow:"hidden",fontFamily:a,fontSize:d,lineHeight:x,pointerEvents:"none",background:"pink"},children:b.jsxs("div",{style:{width:"100%",maxWidth:v,height:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",margin:"0 auto",overflow:"hidden"},children:[b.jsx("div",{style:{height:40,background:"blue"}}),b.jsx("div",{ref:be,style:{height:"calc(100% - 110px)",overflow:"hidden",boxSizing:"border-box",width:"100%"}})]})}),b.jsx(Ou,{pages:p.pages,items:u,onGotoPage:M,currentPageIndex:T,isOnExtraPage:ot})]})}const Ou=({pages:e,items:t,onGotoPage:n,currentPageIndex:r,isOnExtraPage:o})=>{const s=U(a=>a.currentGlobalRunIndex),i=U(a=>a.lastUpdateBy),c=U(a=>{var d;return((d=a.layout)==null?void 0:d.prefix)??[]}),l=h.useRef(null);return h.useEffect(()=>{if(s==null||e.length===0||o&&!(i==="scrubber-live"||i==="scrubber-commit")||l.current===s)return;l.current=s;const a=Ru(s,e,t,c);a>=0&&a!==r&&n(a)},[s,e,t,c,n,r,o,i]),b.jsx(b.Fragment,{})},Pu="_wrapper_dbk3n_1",zu="_spinner_dbk3n_10",Mo={wrapper:Pu,spinner:zu};function Bu({size:e=28,speed:t=.8}){return b.jsx("div",{className:`${Mo.wrapper}`,children:b.jsx("div",{className:Mo.spinner,style:{width:e,height:e,borderWidth:3,animationDuration:`${t}s`}})})}function Gu(){const e=U(Vt(t=>t.sectionLoading===!0));return b.jsx(b.Fragment,{children:e===!0&&b.jsx(Bu,{})})}const Au="_Overlay_ybic8_3",Lu="_Dialog_ybic8_15",Hu="_Body_ybic8_25",Nu="_Header_ybic8_32",Fu="_Paging_ybic8_39",Wu="_Remaining_ybic8_48",Du="_RemainingDanger_ybic8_55",$u="_NextBtn_ybic8_59",Vu="_CloseBtn_ybic8_96",qu="_Question_ybic8_113",Uu="_Score_ybic8_123",Ku="_Image_ybic8_130",Xu="_Options_ybic8_140",Yu="_OptionBtn_ybic8_145",Qu="_OptionBtnActive_ybic8_165",Zu="_Footer_ybic8_172",Ju="_OptionBtnCorrect_ybic8_195",ed="_Judge_ybic8_201",td="_Correct_ybic8_212",nd="_Incorrect_ybic8_215",rd="_ResultHeader_ybic8_220",od="_ResultActions_ybic8_233",sd="_CloseBtnSoft_ybic8_239",id="_SummaryGrid_ybic8_249",ld="_StatCard_ybic8_257",ad="_StatLabel_ybic8_265",cd="_StatValue_ybic8_270",ud="_StatSub_ybic8_277",ae={Overlay:Au,Dialog:Lu,Body:Hu,Header:Nu,Paging:Fu,Remaining:Wu,RemainingDanger:Du,NextBtn:$u,CloseBtn:Vu,Question:qu,Score:Uu,Image:Ku,Options:Xu,OptionBtn:Yu,OptionBtnActive:Qu,Footer:Zu,OptionBtnCorrect:Ju,Judge:ed,Correct:td,Incorrect:nd,ResultHeader:rd,ResultActions:od,CloseBtnSoft:sd,SummaryGrid:id,StatCard:ld,StatLabel:ad,StatValue:cd,StatSub:ud};function dd(e){return e?e.kind==="temp"?e.image_blob_url:e.image_cdn_url:null}function Es(e){var t;return(((t=e.answers)==null?void 0:t.length)??0)>1}function fd(e){const t=e.answers??[],n=[];return t.forEach(r=>{const o=e.options.findIndex(s=>s===r);o>=0&&n.push(o)}),n.sort((r,o)=>r-o)}const pd=h.memo(function(){const t=tt(u=>u.phase),n=tt(u=>u.quizzes),r=tt(u=>u.order),o=tt(u=>u.currentIndex),s=tt(u=>u.answers),i=tt(u=>u.correctCount),c=tt(u=>u.remainingSec),l=tt(u=>u.uiReveal),a=tt(u=>u.startedAt),d=tt(u=>u.finishedAt),x=tt(u=>u.perQ),m=vs();h.useEffect(()=>{if(t==="idle"||t!=="doing"||c==null)return;const u=window.setInterval(()=>m.getState().tick(),1e3);return()=>window.clearInterval(u)},[t,c,m]);const S=t==="doing"?n[r[o]]:void 0,v=t==="doing"&&S?s[S.qid]??[]:[],w=h.useMemo(()=>{if(t==="idle"||t!=="finished")return;const u=r.map(B=>n[B]),f=u.length,p=u.reduce((B,$)=>B+($.score??0),0),C=u.reduce((B,$)=>{const te=x[$.qid];return B+(te!=null&&te.isCorrect?$.score??0:0)},0),T=u.map(B=>x[B.qid]).filter(B=>!!B),M=typeof a=="number"&&typeof d=="number"?Math.max(0,d-a):T.reduce((B,$)=>B+($.ms??0),0),E=f>0?Math.round(M/f):0,g=[...T].sort((B,$)=>B.ms-$.ms),y=g[0],R=g[g.length-1],k=T.filter(B=>!B.multi),O=T.filter(B=>B.multi),z=k.filter(B=>B.isCorrect).length,I=O.filter(B=>B.isCorrect).length,_=T.filter(B=>B.timedOut).length,P=T.filter(B=>B.revealed).length,N=T.filter(B=>!B.isCorrect).sort((B,$)=>$.ms-B.ms).slice(0,3);return{total:f,correct:i,rate:f?Math.round(i/f*100):0,timeMsTotal:M,avgMs:E,totalScore:p,gainedScore:C,fastest:y,slowest:R,singles:{total:k.length,correct:z},multis:{total:O.length,correct:I},timedOut:_,revealed:P,wrongTop3:N}},[t,r,n,x,a,d,i]);return t==="idle"?null:b.jsx("div",{className:ae.Overlay,role:"dialog","aria-modal":"true",children:b.jsx("div",{className:ae.Dialog,children:t==="doing"&&S?b.jsx(gd,{q:S,index:o,total:r.length,selected:v,uiReveal:l,onSelect:u=>{if(l)return;const f=m.getState();Es(S)?f.selectToggle(u):f.selectSingle(u)},onBeforeNext:()=>m.getState().setReveal(!0),onNext:()=>m.getState().afterRevealNext(),remainingSec:c,onClose:()=>m.getState().close()}):b.jsx(hd,{total:r.length,correct:i,summary:w,onClose:()=>m.getState().close()})})})});function gd(e){const{q:t,index:n,total:r,selected:o,uiReveal:s,onSelect:i,onBeforeNext:c,onNext:l,remainingSec:a,onClose:d}=e,x=Es(t),m=h.useMemo(()=>{const u=t.options.map((f,p)=>({opt:f,i:p}));for(let f=u.length-1;f>0;f--){const p=Math.floor(Math.random()*(f+1));[u[f],u[p]]=[u[p],u[f]]}return u},[t.options]),S=h.useMemo(()=>dd(t),[t]),v=h.useMemo(()=>fd(t),[t]),w=h.useMemo(()=>{const u=[...o].sort((f,p)=>f-p);if(u.length!==v.length)return!1;for(let f=0;f<u.length;f++)if(u[f]!==v[f])return!1;return!0},[o,v]);return b.jsxs("div",{className:ae.Body,children:[b.jsxs("div",{className:ae.Header,children:[b.jsx("div",{className:ae.Paging,children:`Quiz (${n+1}/${r})`}),b.jsx("button",{type:"button",onClick:d,className:ae.CloseBtn,children:"X"})]}),b.jsx("div",{className:ae.Question,children:t.question}),b.jsx("div",{className:ae.Score,children:` (${t.score}점${x?" ,모두선택":""})`}),b.jsx("div",{className:`${ae.Judge}${s?w?` ${ae.Correct}`:` ${ae.Incorrect}`:""}`,"aria-live":"polite",children:s?w?`Correct : +${t.score} point`:"Incorrect : 0 point":"a"}),b.jsx("div",{className:ae.Image,children:S&&b.jsx("img",{src:S,alt:""})}),b.jsx("div",{className:ae.Options,children:m.map(({opt:u,i:f})=>{const p=o.includes(f),C=v.includes(f),T=[ae.OptionBtn,p?ae.OptionBtnActive:"",s&&C?ae.OptionBtnCorrect:""].filter(Boolean).join(" ");return b.jsx("button",{type:"button",onClick:()=>i(f),className:T,disabled:s,children:u},f)})}),b.jsx("div",{className:ae.Footer,children:s?b.jsx("button",{type:"button",onClick:l,className:ae.NextBtn,children:n+1>=r?"Complete":"Next Quiz"}):b.jsxs("button",{type:"button",onClick:c,className:`${ae.NextBtn}`,children:["Submit",typeof a=="number"&&b.jsx("span",{className:`${ae.Remaining} ${a<=5?ae.RemainingDanger:""}`,children:` (${a} s )`})]})})]})}function Eo(e){return e==null?"-":`${Math.round(e/1e3)}s`}function hd(e){const{total:t,correct:n,summary:r,onClose:o}=e,s=(r==null?void 0:r.rate)??(t>0?Math.round(n/t*100):0);return b.jsxs("div",{className:ae.Body,children:[b.jsx("div",{className:ae.ResultHeader,children:"결과 요약"}),b.jsxs("div",{className:ae.SummaryGrid,role:"list",children:[b.jsxs("div",{className:ae.StatCard,role:"listitem",children:[b.jsx("div",{className:ae.StatLabel,children:"정답률"}),b.jsxs("div",{className:ae.StatValue,children:[s,"%"]}),b.jsx("div",{className:ae.StatSub,children:`정답수 ${n}/문제수${t}`})]}),b.jsxs("div",{className:ae.StatCard,role:"listitem",children:[b.jsx("div",{className:ae.StatLabel,children:"총 점수"}),b.jsx("div",{className:ae.StatValue,children:r?`${r.gainedScore}/${r.totalScore}`:"-"}),b.jsx("div",{className:ae.StatSub,children:"획득점수/최대점수"})]}),b.jsxs("div",{className:ae.StatCard,role:"listitem",children:[b.jsx("div",{className:ae.StatLabel,children:"총 소요 시간"}),b.jsx("div",{className:ae.StatValue,children:Eo(r==null?void 0:r.timeMsTotal)}),b.jsx("div",{className:ae.StatSub,children:`평균 ${Eo(r==null?void 0:r.avgMs)}`})]}),b.jsxs("div",{className:ae.StatCard,role:"listitem",children:[b.jsx("div",{className:ae.StatLabel,children:"타입오버 퀴즈수"}),b.jsx("div",{className:ae.StatValue,children:r?`${r.timedOut}`:"-"}),b.jsx("div",{className:ae.StatSub,children:"timeout"})]})]}),b.jsx("div",{className:ae.ResultActions,children:b.jsx("button",{type:"button",onClick:o,className:ae.CloseBtnSoft,children:"닫기"})})]})}function md(e){return e.map((t,n)=>n)}function bd(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Yn(e){var t;return(((t=e.answers)==null?void 0:t.length)??0)>1}function Qn(e){const t=e.answers??[],n=[];return t.forEach(r=>{const o=e.options.findIndex(s=>s===r);o>=0&&n.push(o)}),n.sort((r,o)=>r-o)}function jo(e){if(!e)return{};const t=(e.quizzes??[]).slice().sort((n,r)=>n.index-r.index);return{sectionId:e.section_id,quizzes:t,order:md(t),currentIndex:0,answers:{},correctCount:0,startedAt:void 0,finishedAt:void 0,questionStartedAt:void 0,remainingSec:void 0,uiReveal:!1,perQ:{}}}function xd(e){const t={phase:"idle",sectionId:void 0,quizzes:[],order:[],currentIndex:0,answers:{},correctCount:0,startedAt:void 0,finishedAt:void 0,questionStartedAt:void 0,remainingSec:void 0,uiReveal:!1,perQ:{}},n=jo(e);return qt()((o,s)=>({...t,...n,hydrateFromSection:i=>{if(!i)return;const c=jo(i);o(c)},openFromSection:i=>{i&&s().hydrateFromSection(i);const c=s();if(!c.quizzes.length)return;const l=c.quizzes[0];o({phase:"doing",startedAt:Date.now(),finishedAt:void 0,questionStartedAt:Date.now(),remainingSec:l.limit_sec||void 0,currentIndex:0,uiReveal:!1})},close:()=>{o({phase:"idle",sectionId:void 0,quizzes:[],order:[],currentIndex:0,answers:{},correctCount:0,startedAt:void 0,finishedAt:void 0,questionStartedAt:void 0,remainingSec:void 0,uiReveal:!1,perQ:{}})},selectToggle:i=>{const c=s();if(c.phase!=="doing"||c.uiReveal)return;const a=c.quizzes[c.order[c.currentIndex]].qid,d=c.answers[a]??[],x=d.includes(i)?d.filter(m=>m!==i):[...d,i].sort((m,S)=>m-S);o({answers:{...c.answers,[a]:x}})},selectSingle:i=>{const c=s();if(c.phase!=="doing"||c.uiReveal)return;const a=c.quizzes[c.order[c.currentIndex]].qid;o({answers:{...c.answers,[a]:[i]}})},submitCurrent:()=>{const i=s();if(i.phase!=="doing")return;const c=i.order[i.currentIndex],l=i.quizzes[c],a=l.qid,d=(i.answers[a]??[]).slice().sort((u,f)=>u-f),x=Qn(l),m=bd(d,x),S=i.questionStartedAt?Date.now()-i.questionStartedAt:0,v=i.perQ[a],w={qid:a,index:l.index,question:l.question,score:l.score??0,multi:Yn(l),selected:d,correctIdxes:x,isCorrect:m,ms:S,revealed:(v==null?void 0:v.revealed)??!1,timedOut:(v==null?void 0:v.timedOut)??!1};if(o({correctCount:i.correctCount+(m?1:0),perQ:{...i.perQ,[a]:w}}),i.currentIndex+1>=i.order.length)o({uiReveal:!1,remainingSec:void 0}),s().finish();else{const u=i.currentIndex+1;o({currentIndex:u,questionStartedAt:Date.now(),remainingSec:i.quizzes[i.order[u]].limit_sec||void 0,uiReveal:!1})}},setReveal:i=>{const c=s();if(c.phase==="doing"){if(i){const l=c.quizzes[c.order[c.currentIndex]],a=l.qid,d=c.perQ[a],x={qid:a,index:l.index,question:l.question,score:l.score??0,multi:Yn(l),selected:(d==null?void 0:d.selected)??[],correctIdxes:(d==null?void 0:d.correctIdxes)??Qn(l),isCorrect:(d==null?void 0:d.isCorrect)??!1,ms:(d==null?void 0:d.ms)??0,revealed:!0,timedOut:(d==null?void 0:d.timedOut)??!1};o({perQ:{...c.perQ,[a]:x}})}o({uiReveal:i})}},afterRevealNext:()=>{s().phase==="doing"&&s().submitCurrent()},next:()=>{const i=s();if(i.phase!=="doing"||i.currentIndex+1>=i.order.length)return;const c=i.currentIndex+1;o({currentIndex:c,questionStartedAt:Date.now(),remainingSec:i.quizzes[i.order[c]].limit_sec||void 0,uiReveal:!1})},prev:()=>{const i=s();if(i.phase!=="doing"||i.currentIndex<=0)return;const c=i.currentIndex-1;o({currentIndex:c,questionStartedAt:Date.now(),remainingSec:i.quizzes[i.order[c]].limit_sec||void 0,uiReveal:!1})},finish:()=>{o({phase:"finished",remainingSec:void 0,uiReveal:!1,finishedAt:Date.now()})},tick:()=>{const i=s();if(i.phase!=="doing"||i.remainingSec==null)return;const c=i.remainingSec-1;if(c<=0){const l=i.quizzes[i.order[i.currentIndex]],a=l.qid,d=i.perQ[a],x={qid:a,index:l.index,question:l.question,score:l.score??0,multi:Yn(l),selected:(d==null?void 0:d.selected)??[],correctIdxes:(d==null?void 0:d.correctIdxes)??Qn(l),isCorrect:(d==null?void 0:d.isCorrect)??!1,ms:(d==null?void 0:d.ms)??0,revealed:!0,timedOut:!0};o({remainingSec:0,uiReveal:!0,perQ:{...i.perQ,[a]:x}})}else o({remainingSec:c})}}))}function vd({children:e,initialState:t}){const n=h.useMemo(()=>xd(t.section),[t]),r=h.useRef(t.onQuizComplete);return h.useEffect(()=>{r.current=t.onQuizComplete},[t.onQuizComplete]),h.useEffect(()=>{const o=n.subscribe((s,i)=>{if(i.phase!=="finished"&&s.phase==="finished"){const c=r.current;if(!c)return;const{sectionId:l,quizzes:a,order:d,perQ:x,startedAt:m,finishedAt:S}=s,v=d.map(E=>a[E]),w=v.length,u=v.filter(E=>{var g;return(g=x[E.qid])==null?void 0:g.isCorrect}).length,f=v.reduce((E,g)=>E+(g.score??0),0),p=v.reduce((E,g)=>{const y=x[g.qid];return E+(y!=null&&y.isCorrect?g.score??0:0)},0),C=typeof m=="number"&&typeof S=="number"?Math.max(0,S-m):0,T=v.map(E=>{const g=x[E.qid];return{qid:E.qid,index:E.index,question:E.question,score:E.score??0,isCorrect:(g==null?void 0:g.isCorrect)??!1,selected:(g==null?void 0:g.selected)??[],correctIdxes:(g==null?void 0:g.correctIdxes)??[],ms:(g==null?void 0:g.ms)??0,timedOut:(g==null?void 0:g.timedOut)??!1}}),M={sectionId:l??"",total:w,correct:u,rate:w>0?Math.round(u/w*100):0,totalScore:f,gainedScore:p,timeMsTotal:C,perQuestion:T};c(M)}});return()=>o()},[n]),b.jsx(wr.Provider,{value:n,children:e})}const Oo=["mode","theme","fontFamily","fontSizePx","lineHeight","marginX","marginY","pointerStyle","pointerColor","breakMarks","breakGapPx","muteAudio","audioSpeed","showPointer","showSplit","showOverlays","overlayCompactMode","isSettingsOpen"];function Sd({containerRef:e}){const t=wt(),n=gn(),r=h.useRef(null);return h.useEffect(()=>{const o=e.current;if(!o)return;let s=o.clientWidth,i=o.clientHeight;n.getState().setViewportSize(s,i);const c=new ResizeObserver(()=>{const l=o.clientWidth,a=o.clientHeight;(l!==s||a!==i)&&(s=l,i=a,n.getState().setViewportSize(l,a),t.getState().emit({type:"viewport_resize",payload:{width:l,height:a}}))});return c.observe(o),()=>c.disconnect()},[t,n,e]),h.useEffect(()=>{const o=n.getState();r.current={};for(const i of Oo)r.current[i]=o[i];const s=n.subscribe(i=>{const c=r.current;if(c)for(const l of Oo){const a=c[l],d=i[l];a!==d&&(l==="mode"?t.getState().emit({type:"mode_change",payload:{mode:d}}):t.getState().emit({type:"settings_change",payload:{key:l,value:d}}),c[l]=d)}});return()=>{s(),r.current=null}},[t,n]),null}function yd(){const e=wt(),t=gn(),n=vt(),r=h.useContext(Go),o=h.useContext(vn),s=h.useCallback(l=>{const{viewerState:a}=l;if(a){a.mode&&t.getState().setMode(a.mode);const{...m}=a;t.setState(m)}if(typeof l.globalIndex=="number"&&n.getState().progress.setCurrentGlobalRunIndex(l.globalIndex,"playback"),(a==null?void 0:a.mode)==="scroll"||!(a!=null&&a.mode)){const m=()=>{const S=n.getState().progress.getSectionScrollApi();if(!S)return!1;if(l.scrollY===0)S.setScrollTop(0);else if(S.scrollToGIAtOffset){const v=l.anchorGI??l.globalIndex;if(typeof v=="number"){const w=l.anchorOffsetRatio??0;S.scrollToGIAtOffset(v,w)}}return!0};if(!m()){let S=0;const v=setInterval(()=>{(m()||++S>=10)&&clearInterval(v)},50)}}l.audio&&o&&o.getState()._setStatusOnly(l.audio.status);const x=n.getState().progress;l.range?x.setRange(l.range.startGI,l.range.endGI):x.clearRange(),l.translate&&l.translate.isOpen?x.setTranslateState({isOpen:!0,isLoading:l.translate.isLoading,text:l.translate.text,translatedText:l.translate.translatedText,startGI:l.translate.startGI,endGI:l.translate.endGI}):x.clearTranslate()},[t,n,o]),i=h.useCallback(()=>{var M,E,g,y;const l=t.getState(),a=n.getState().progress,d=(M=a.getSectionScrollApi)==null?void 0:M.call(a),x=a.currentGlobalRunIndex??0,m=((E=d==null?void 0:d.getScrollTop)==null?void 0:E.call(d))??0,S=((g=d==null?void 0:d.getAnchorOffsetRatio)==null?void 0:g.call(d,x))??0,v=o==null?void 0:o.getState(),w=v?{status:v.status,currentClip:v.currentClip,currentTimeMs:v.currentTimeMs}:void 0,{rangeStartGI:u,rangeEndGI:f}=a,p=u!=null&&f!=null?{startGI:u,endGI:f,text:a.getRangeText()}:null,C=((y=d==null?void 0:d.getScrollRatio)==null?void 0:y.call(d))??0,T=a.translateOpen?{isOpen:!0,isLoading:a.translateLoading,text:a.translateText,translatedText:a.translatedText,startGI:a.translateStartGI,endGI:a.translateEndGI}:null;return{viewerState:{mode:l.mode,theme:l.theme,fontFamily:l.fontFamily,fontSizePx:l.fontSizePx,lineHeight:l.lineHeight,marginX:l.marginX,marginY:l.marginY,showOverlays:l.showOverlays,isSettingsOpen:l.isSettingsOpen,pointerStyle:l.pointerStyle,pointerColor:l.pointerColor,breakMarks:l.breakMarks,breakGapPx:l.breakGapPx,muteAudio:l.muteAudio,audioSpeed:l.audioSpeed,showPointer:l.showPointer,showSplit:l.showSplit,overlayCompactMode:l.overlayCompactMode,viewportWidth:l.viewportWidth,viewportHeight:l.viewportHeight},globalIndex:x,scrollY:m,scrollRatio:C,anchorGI:x,anchorOffsetRatio:S,currentPage:a.pageIndex??0,totalPages:a.totalPages,sectionId:a.sectionId??"",viewportWidth:l.viewportWidth,viewportHeight:l.viewportHeight,audio:w,range:p,translate:T}},[t,n,o]),c=h.useCallback(l=>{switch(l.type){case"global_index_change":{const{globalIndex:a}=l.payload;n.getState().progress.setCurrentGlobalRunIndex(a,"playback");break}case"scroll":{if(t.getState().mode==="page")break;const{scrollTop:d,anchorGI:x,anchorOffsetRatio:m}=l.payload,S=n.getState().progress.getSectionScrollApi();S&&(d===0?S.setScrollTop(0):S.scrollToGIAtOffset&&typeof x=="number"&&S.scrollToGIAtOffset(x,m));break}case"settings_change":{const{key:a,value:d}=l.payload,x=t.getState();a in x&&typeof x[a]!="function"&&t.setState({[a]:d});break}case"mode_change":{const{mode:a}=l.payload;t.getState().setMode(a);break}case"audio_control":{if(!o)break;const{action:a}=l.payload;switch(a){case"play":o.getState()._setStatusOnly("playing");break;case"pause":o.getState()._setStatusOnly("paused");break;case"stop":o.getState()._setStatusOnly("idle");break}break}case"page_change":{const{pageIndex:a}=l.payload;n.getState().progress.setPageIndex(a);break}case"range_select":case"range_change":{const{startGI:a,endGI:d}=l.payload;console.log(`[DirectPlayback] ${l.type}: GI ${a}~${d}`),n.getState().progress.setRange(a,d);const x=n.getState().progress;console.log(`[DirectPlayback] after setRange: rangeStartGI=${x.rangeStartGI}, rangeEndGI=${x.rangeEndGI}`);break}case"range_clear":{console.log("[DirectPlayback] range_clear"),n.getState().progress.clearRange();break}case"translate_request":{const{text:a,startGI:d,endGI:x}=l.payload;n.getState().progress.setTranslateState({isOpen:!0,text:a,startGI:d,endGI:x});break}case"translate_loading_start":{n.getState().progress.setTranslateState({isOpen:!0,isLoading:!0});break}case"translate_loading_end":{const{translatedText:a}=l.payload;n.getState().progress.setTranslateState({isOpen:!0,isLoading:!1,translatedText:a});break}case"translate_modal_close":{n.getState().progress.clearTranslate();break}case"render_start":case"loading_start":case"loading_end":case"viewport_resize":break;default:console.log("[DirectPlaybackController] 미처리 이벤트:",l.type)}},[n,t,o]);return h.useLayoutEffect(()=>r?(r.current={dispatch:c,applySnapshot:s,getSnapshot:i,isReady:()=>!n.getState().progress.sectionLoading,waitUntilReady:()=>new Promise(a=>{if(!n.getState().progress.sectionLoading){a();return}const d=n.subscribe(x=>{x.progress.sectionLoading||(d(),a())})})},e.getState().isPlaybackMode&&(e.getState().setDispatchHandler(c),e.getState().setApplySnapshotHandler(s)),()=>{e.getState().setDispatchHandler(null),e.getState().setApplySnapshotHandler(null)}):void 0,[r,e,c,s,i,n]),h.useLayoutEffect(()=>e.subscribe((a,d)=>{a.isPlaybackMode&&!d.isPlaybackMode?(e.getState().setDispatchHandler(c),e.getState().setApplySnapshotHandler(s)):!a.isPlaybackMode&&d.isPlaybackMode&&(e.getState().setDispatchHandler(null),e.getState().setApplySnapshotHandler(null))}),[e,c,s]),null}const wd=({containerRef:e,onTranslate:t})=>{const n=U(m=>m.rangeStartGI),r=U(m=>m.rangeEndGI),o=U(m=>m.getRangeText),s=U(m=>m.clearRange),i=wt(),c=n!=null&&r!=null,[l,a]=h.useState(null);h.useEffect(()=>{if(!c)return;const m=e.current;if(!m)return;let S=!0;const v=new ResizeObserver(()=>{if(S){S=!1;return}s()});return v.observe(m),()=>v.disconnect()},[c,s,e]),h.useEffect(()=>{if(!c||n==null||r==null){a(null);return}const m=()=>{const v=e.current;if(!v)return;const w=v.getBoundingClientRect(),f=1/(i.getState().playbackScale||1),p=v.querySelector(`[data-g="${r}"]`);if(!p){a({x:w.width*f/2,y:80});return}const C=p.getBoundingClientRect(),T=v.querySelector(`[data-g="${n}"]`),M=T==null?void 0:T.getBoundingClientRect();let E=(C.left+C.width/2-w.left)*f;M&&(E=((M.left+C.right)/2-w.left)*f);const g=160,y=50,R=16,k=12,O=w.width*f,z=Math.max(R+g/2,Math.min(E,O-R-g/2)),I=(((M==null?void 0:M.top)??C.top)-w.top)*f-y-k;let _=I;I<R&&(_=(C.bottom-w.top)*f+k),a({x:z,y:_})};m();const S=e.current;return S&&S.addEventListener("scroll",m,!0),()=>{S&&S.removeEventListener("scroll",m,!0)}},[c,n,r,e,i]);const d=h.useCallback(()=>{const m=o();m&&navigator.clipboard.writeText(m).catch(S=>{console.error("복사 실패:",S)}),s()},[o,s]),x=h.useCallback(()=>{const m=o();m&&t&&t(m)},[o,t]);return!c||!l?null:b.jsxs("div",{"data-range-menu":!0,style:{position:"absolute",left:l.x,top:l.y,transform:"translateX(-50%)",display:"flex",gap:8,padding:"8px 12px",backgroundColor:"#fff",borderRadius:8,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.3)",zIndex:1e4},children:[b.jsx("button",{onClick:d,style:{padding:"8px 16px",backgroundColor:"#3b82f6",color:"#fff",border:"none",borderRadius:6,fontSize:14,fontWeight:500,cursor:"pointer"},children:"복사"}),b.jsx("button",{onClick:x,style:{padding:"8px 16px",backgroundColor:"#10b981",color:"#fff",border:"none",borderRadius:6,fontSize:14,fontWeight:500,cursor:"pointer"},children:"번역"})]})},Cd="_handleStart_1ihf3_16 _handle_1ihf3_1",Id="_handleEnd_1ihf3_21 _handle_1ihf3_1",Po={handleStart:Cd,handleEnd:Id},Td=({containerRef:e})=>{const t=U(f=>f.rangeStartGI),n=U(f=>f.rangeEndGI),r=U(f=>f.setRange),o=wt(),s=t!=null&&n!=null,[i,c]=h.useState(null),[l,a]=h.useState(null),d=h.useRef(null),x=h.useRef(null);h.useEffect(()=>{if(!s||t==null||n==null){c(null),a(null);return}const f=()=>{const C=e.current;if(!C)return;const T=C.getBoundingClientRect(),E=1/(o.getState().playbackScale||1),g=C.querySelector(`[data-g="${t}"]`),y=C.querySelector(`[data-g="${n}"]`);if(g){const R=g.getBoundingClientRect();c({x:(R.left-T.left)*E,y:(R.bottom-T.top)*E})}else c(null);if(y){const R=y.getBoundingClientRect();a({x:(R.right-T.left)*E,y:(R.bottom-T.top)*E})}else a(null)};f();const p=e.current;return p&&p.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{p&&p.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[s,t,n,e,o]);const m=h.useCallback((f,p)=>{var T;const C=document.elementsFromPoint(f,p);for(const M of C){const E=(T=M.getAttribute)==null?void 0:T.call(M,"data-g");if(E!=null)return parseInt(E,10)}return null},[]),S=h.useCallback(f=>p=>{p.preventDefault(),p.stopPropagation(),d.current=f,x.current=f==="start"?t:n,p.target.setPointerCapture(p.pointerId)},[t,n]),v=h.useCallback(f=>{if(!d.current||t==null||n==null)return;const p=m(f.clientX,f.clientY);p!=null&&(d.current==="start"?p<=n?r(p,n):(r(n,p),d.current="end"):p>=t?r(t,p):(r(p,t),d.current="start"))},[t,n,r,m]),w=h.useCallback(f=>{d.current=null,x.current=null,f.target.releasePointerCapture(f.pointerId)},[]);return s?b.jsxs(b.Fragment,{children:[i&&b.jsx("div",{className:Po.handleStart,"data-range-handle":"start",style:{left:i.x-26,top:i.y},onPointerDown:S("start"),onPointerMove:v,onPointerUp:w,onPointerCancel:w}),l&&b.jsx("div",{className:Po.handleEnd,"data-range-handle":"end",style:{left:l.x,top:l.y},onPointerDown:S("end"),onPointerMove:v,onPointerUp:w,onPointerCancel:w})]}):null};function kd(){const e=U(o=>o.rangeStartGI),t=U(o=>o.rangeEndGI),n=U(o=>o.clearRange),r=e!=null&&t!=null;return h.useEffect(()=>{if(!r)return;const o=s=>{var c;const i=s.target;if(!(i.closest("[data-range-menu]")||i.closest("[data-range-handle]"))){if(i.closest("[data-g]")){const l=(c=i.closest("[data-g]"))==null?void 0:c.getAttribute("data-g");if(l){const a=parseInt(l,10),d=Math.min(e,t),x=Math.max(e,t);if(a>=d&&a<=x)return}}n()}};return document.addEventListener("click",o,!0),()=>document.removeEventListener("click",o,!0)},[r,e,t,n]),null}const Rd=({isOpen:e,onClose:t,text:n})=>e?b.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:10001},onClick:t,children:b.jsxs("div",{style:{position:"relative",backgroundColor:"#fff",borderRadius:12,padding:"24px 32px",minWidth:280,maxWidth:"80%",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.2)"},onClick:r=>r.stopPropagation(),children:[b.jsx("button",{onClick:t,style:{position:"absolute",top:12,right:12,width:28,height:28,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"transparent",border:"none",borderRadius:"50%",cursor:"pointer",fontSize:20,color:"#666"},"aria-label":"닫기",children:"✕"}),b.jsx("h3",{style:{margin:"0 0 16px 0",fontSize:18,fontWeight:600,color:"#333"},children:"번역"}),b.jsx("p",{style:{margin:0,fontSize:16,color:"#666",textAlign:"center",padding:"16px 0"},children:"준비중입니다"}),n&&b.jsxs("div",{style:{marginTop:16,padding:12,backgroundColor:"#f5f5f5",borderRadius:8,fontSize:14,color:"#888",maxHeight:100,overflow:"auto"},children:[b.jsx("span",{style:{fontWeight:500},children:"선택된 텍스트: "}),n]})]})}):null,_d=(e,t,n)=>Math.min(n,Math.max(t,e));function Md({section:e,initialViewerState:t,initialProgressRunIndex:n,onViewerClose:r,onSectionNav:o,isCanPrev:s=!1,isCanNext:i=!1,onQuizComplete:c,onViewerEvent:l,viewerRef:a,gazeSync:d,isPlaybackMode:x=!1,playbackScale:m,isDev:S=!1}){const v=String((e==null?void 0:e.section_id)??"0"),w=h.useMemo(()=>{var M,E;const C=((M=e==null?void 0:e.ast)==null?void 0:M.blocks)??[];let T=0;for(const g of C)(g==null?void 0:g.type)!=="image"&&(T+=((E=g==null?void 0:g.runs)==null?void 0:E.length)??0);return T},[e]),u=h.useMemo(()=>typeof n=="number"?_d(n,w>0?0:-1,Math.max(w-1,-1)):(w>0,0),[n,w]),f=h.useMemo(()=>({section:e,initialIndex:u,onViewerClose:r,onSectionNav:o,isCanPrev:s,isCanNext:i}),[e,u,r,o,s,i]),p=h.useMemo(()=>{const C=(e==null?void 0:e.audios)??[],T=C.length>0?Zc(e):void 0;return{clips:C,map:T,initialIndex:u,section:e}},[e,u]);return b.jsx(Us,{onViewerEvent:l,isPlaybackMode:x,playbackScale:m,viewerRef:a,children:b.jsx(ou,{initialState:{...t,isDev:S},children:b.jsx(ru,{initialState:f,gazeSync:d,children:b.jsx(Qc,{initialState:p,children:b.jsx(vd,{initialState:{section:e,onQuizComplete:c},children:b.jsx(Ed,{})},v)},v)},v)})})}function Ed(){const e=J(d=>d.mode),t=h.useRef(null),n=wt(),r=vt(),o=U(d=>d.translateOpen),s=U(d=>d.translateText),i=h.useCallback(d=>{const{rangeStartGI:x,rangeEndGI:m}=r.getState().progress;r.getState().progress.setTranslateState({isOpen:!0,text:d,startGI:x??0,endGI:m??0}),n.getState().emit({type:"translate_request",payload:{text:d,startGI:x??0,endGI:m??0}})},[n,r]),c=h.useCallback(()=>{r.getState().progress.clearTranslate(),n.getState().emit({type:"translate_modal_close",payload:{}})},[n,r]),l=d=>{d.preventDefault()},a=d=>{d.preventDefault()};return b.jsxs("div",{ref:t,onContextMenu:l,onDragStart:a,style:{position:"relative",display:"flex",flexDirection:"column",height:"100%",width:"100%",userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"none"},children:[e==="scroll"?b.jsx(ga,{}):b.jsx(ju,{}),b.jsx(wd,{containerRef:t,onTranslate:i}),b.jsx(Td,{containerRef:t}),b.jsx($c,{}),b.jsx(pd,{}),b.jsx(Gu,{}),b.jsx(kd,{}),b.jsx(Rd,{isOpen:o,onClose:c,text:s}),b.jsx(Sd,{containerRef:t}),b.jsx(yd,{})]})}exports.CRViewer=Md;
|
|
34
|
+
*/var Mr;function Ns(){return Mr||(Mr=1,process.env.NODE_ENV!=="production"&&(function(){function e(l,d){return l===d&&(l!==0||1/l===1/d)||l!==l&&d!==d}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=h,n=Bo(),r=typeof Object.is=="function"?Object.is:e,o=n.useSyncExternalStore,s=t.useRef,i=t.useEffect,u=t.useMemo,a=t.useDebugValue;Cn.useSyncExternalStoreWithSelector=function(l,d,m,p,b){var S=s(null);if(S.current===null){var w={hasValue:!1,value:null};S.current=w}else w=S.current;S=u(function(){function f(E){if(!g){if(g=!0,C=E,E=p(E),b!==void 0&&w.hasValue){var x=w.value;if(b(x,E))return T=x}return T=E}if(x=T,r(C,E))return x;var y=p(E);return b!==void 0&&b(x,y)?(C=E,x):(C=E,T=y)}var g=!1,C,T,M=m===void 0?null:m;return[function(){return f(d())},M===null?void 0:function(){return f(M())}]},[d,m,p,b]);var c=o(l,S[0],S[1]);return i(function(){w.hasValue=!0,w.value=c},[c]),a(c),c},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Cn}var Er;function Fs(){return Er||(Er=1,process.env.NODE_ENV==="production"?Qt.exports=Hs():Qt.exports=Ns()),Qt.exports}var Ws=Fs();const Ds=Po(Ws),jr=e=>{let t;const n=new Set,r=(l,d)=>{const m=typeof l=="function"?l(t):l;if(!Object.is(m,t)){const p=t;t=d??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(b=>b(t,p))}},o=()=>t,u={setState:r,getState:o,getInitialState:()=>a,subscribe:l=>(n.add(l),()=>n.delete(l))},a=t=e(r,o,u);return u},qt=(e=>e?jr(e):jr),{useSyncExternalStoreWithSelector:$s}=Ds,Vs=e=>e;function pn(e,t=Vs,n){const r=$s(e.subscribe,e.getState,e.getInitialState,t,n);return h.useDebugValue(r),r}function J(e,t){const n=h.useContext(ir);if(!n)throw new Error("useCRViewerScopedStore must be used inside <InternalCRViewerProvider>");return pn(n,e,t)}function gn(){const e=h.useContext(ir);if(!e)throw new Error("useCRViewerStoreApi must be used inside <InternalCRViewerProvider>");return e}const yt=h.createContext(void 0),Ao=h.createContext(void 0);function qs(){return qt((e,t)=>({emitCallback:null,isPlaybackMode:!1,playbackScale:1,dispatchHandler:null,applySnapshotHandler:null,setEmitCallback:n=>e({emitCallback:n}),emit:(n,r)=>{const{emitCallback:o,isPlaybackMode:s}=t();s||o&&o({...n,timestamp:r??Date.now()})},setPlaybackMode:n=>e({isPlaybackMode:n}),setPlaybackScale:n=>e({playbackScale:n}),setDispatchHandler:n=>e({dispatchHandler:n}),dispatch:n=>{const{dispatchHandler:r,isPlaybackMode:o}=t();if(!o){console.warn("[ViewerEventBridge] dispatch called but not in playback mode");return}r?r(n):console.warn("[ViewerEventBridge] dispatch called but no handler registered")},setApplySnapshotHandler:n=>e({applySnapshotHandler:n}),applySnapshot:n=>{const{applySnapshotHandler:r,isPlaybackMode:o}=t();if(!o){console.warn("[ViewerEventBridge] applySnapshot called but not in playback mode");return}r?r(n):console.warn("[ViewerEventBridge] applySnapshot called but no handler registered")}}))}function Us({children:e,onViewerEvent:t,isPlaybackMode:n=!1,playbackScale:r=1,viewerRef:o}){const s=h.useMemo(()=>qs(),[]);return h.useLayoutEffect(()=>(s.getState().setEmitCallback(t??null),()=>s.getState().setEmitCallback(null)),[t,s]),h.useLayoutEffect(()=>{s.getState().setPlaybackMode(n)},[n,s]),h.useLayoutEffect(()=>{s.getState().setPlaybackScale(r)},[r,s]),h.useLayoutEffect(()=>()=>{o&&(o.current=null)},[o]),v.jsx(yt.Provider,{value:s,children:v.jsx(Ao.Provider,{value:o,children:e})})}function wt(){const e=h.useContext(yt);if(!e)throw new Error("useViewerEventBridgeStoreApi must be used inside <ViewerEventBridgeProvider>");return e}const lr=h.createContext(void 0);function vt(){const e=h.useContext(lr);if(!e)throw new Error("useProgressStoreApi must be used within InternalCRViewerProgressProvider");return e}function U(e,t){const n=h.useContext(lr);if(!n)throw new Error("useProgressStore must be used within InternalCRViewerProgressProvider");return pn(n,o=>e(o.progress),t)}function Ks({onSingle:e,onDouble:t,delay:n=250,shouldIgnoreTarget:r}){const o=h.useRef(null);h.useEffect(()=>()=>{o.current!=null&&(clearTimeout(o.current),o.current=null)},[]);const s=h.useCallback(u=>{if(!(r!=null&&r(u.target))&&u.detail===1){if(o.current!=null)return;o.current=window.setTimeout(()=>{o.current=null,e==null||e(u)},n)}},[n,e,r]),i=h.useCallback(u=>{r!=null&&r(u.target)||o.current!=null&&(clearTimeout(o.current),o.current=null)},[t,r]);return{onClick:s,onDoubleClick:i}}const on={light:{bg:"#ffffff",fg:"#111827",overlayBg:"#ffffff",overlayFg:"#111827",borderColor:"#333333"},dark:{bg:"#0b0b0b",fg:"#e5e7eb",overlayBg:"#0b0b0b",overlayFg:"#e5e7eb",borderColor:"#ffffff"},sepia:{bg:"#f4ecd8",fg:"#3e2f1c",overlayBg:"#f4ecd8",overlayFg:"#3e2f1c",borderColor:"#bfa87a"},green:{bg:"#e9f5e1",fg:"#1b3d1f",overlayBg:"#e9f5e1",overlayFg:"#1b3d1f",borderColor:"#93b48b"}},In=[8,16,24,40,64],Tn=[1.2,1.4,1.6,1.8,2,2.2,2.4],kn=[4,8,12,16,24],Zn=e=>Math.round(12+(e-1)*(16/11)),Xs=e=>{let t=1,n=1/0;for(let r=1;r<=12;r++){const o=Zn(r),s=Math.abs(o-e);s<n&&(t=r,n=s)}return t},Rn=(e,t)=>{let n=0,r=1/0;return t.forEach((o,s)=>{const i=Math.abs(o-e);i<r&&(r=i,n=s)}),n+1},Go=[{label:"고딕체",value:"'Noto Sans KR', sans-serif"},{label:"명조체",value:"'Noto Serif KR', serif"},{label:"바탕체",value:"'Nanum Myeongjo', serif"}],He={mode:"page",theme:"light",fontFamily:Go.find(e=>e.label==="명조체").value,fontSizePx:18,lineHeight:1.8,marginX:20,marginY:24,showOverlays:!0,overlayCompactMode:!0,isSettingsOpen:!1,pointerStyle:"highlight",pointerColor:"#fff59d",breakMarks:{slash:!0},breakGapPx:8,muteAudio:!1,audioSpeed:1,showPointer:!0,showSplit:!0,viewportWidth:0,viewportHeight:0,isDev:!1};function Ys(e){const{init:t,recorderStore:n}=e??{};return qt((r,o)=>({...He,...t,setMode:s=>r({mode:s}),setTheme:s=>r({theme:s}),setFontFamily:s=>r({fontFamily:s}),setFontSizePx:s=>r({fontSizePx:s}),setLineHeight:s=>r({lineHeight:s}),setMarginX:s=>r({marginX:s}),setMarginY:s=>r({marginY:s}),setShowOverlays:s=>r({showOverlays:s}),toggleOverlays:()=>{const s=!o().showOverlays;r({showOverlays:s,...s&&{overlayCompactMode:!0}})},setOverlayCompactMode:s=>r({overlayCompactMode:s}),toggleOverlayCompactMode:()=>r({overlayCompactMode:!o().overlayCompactMode}),setSettingsOpen:s=>r({isSettingsOpen:s}),resetToDefaults:()=>r(s=>({mode:He.mode,theme:He.theme,fontFamily:He.fontFamily,fontSizePx:He.fontSizePx,lineHeight:He.lineHeight,marginX:He.marginX,marginY:He.marginY,showOverlays:!1,isSettingsOpen:!0,pointerStyle:He.pointerStyle,pointerColor:He.pointerColor,breakMarks:He.breakMarks,breakGapPx:He.breakGapPx,muteAudio:He.muteAudio,audioSpeed:He.audioSpeed,showPointer:He.showPointer,showSplit:He.showSplit})),maps:{MARGIN_MAP:In,LINEHEIGHT_MAP:Tn,BREAK_GAP_MAP:kn,fontSizeFromLevel:Zn},setPointerStyle:s=>r({pointerStyle:s}),setPointerColor:s=>r({pointerColor:s}),toggleBreakMark:s=>{const i=o().breakMarks;r({breakMarks:{...i,[s]:!i[s]}})},setBreakMarks:s=>{r({breakMarks:{...o().breakMarks,...s}})},setBreakGapPx:s=>r({breakGapPx:s}),setBreakGapLevel:s=>{const i=kn[Math.max(1,Math.min(5,s))-1];r({breakGapPx:i})},getBreakGapLevel:()=>Rn(o().breakGapPx,kn),getFontLevel:()=>Xs(o().fontSizePx),getLineLevel:()=>Rn(o().lineHeight,Tn),getMarginLevel:()=>Rn(o().marginX,In),setFontLevel:s=>r({fontSizePx:Zn(Math.max(1,Math.min(12,s)))}),setLineLevel:s=>r({lineHeight:Tn[Math.max(1,Math.min(7,s))-1]}),setMarginLevel:s=>{const i=In[Math.max(1,Math.min(5,s))-1];r({marginX:i,marginY:i})},setMuteAudio:s=>{r({muteAudio:s}),n==null||n.getState().emit({type:"settings_change",payload:{key:"muteAudio",value:s}})},toggleMuteAudio:()=>{const s=!o().muteAudio;r({muteAudio:s}),n==null||n.getState().emit({type:"settings_change",payload:{key:"muteAudio",value:s}})},setAudioSpeed:s=>{const i=Math.max(.3,Math.min(2,s));r({audioSpeed:i}),n==null||n.getState().emit({type:"settings_change",payload:{key:"audioSpeed",value:i}})},incAudioSpeed:()=>{const s=Math.min(2,Math.round((o().audioSpeed+.05)*100)/100);r({audioSpeed:s}),n==null||n.getState().emit({type:"settings_change",payload:{key:"audioSpeed",value:s}})},decAudioSpeed:()=>{const s=Math.max(.3,Math.round((o().audioSpeed-.05)*100)/100);r({audioSpeed:s}),n==null||n.getState().emit({type:"settings_change",payload:{key:"audioSpeed",value:s}})},setShowPointer:s=>r({showPointer:s}),toggleShowPointer:()=>r({showPointer:!o().showPointer}),setShowSplit:s=>r({showSplit:s}),toggleShowSplit:()=>r({showSplit:!o().showSplit}),setViewportSize:(s,i)=>r({viewportWidth:s,viewportHeight:i})}))}const hn=0,gt=1,jt=2,Lo=4;function Or(e){return()=>e}function Qs(e){e()}function Ho(e,t){return n=>e(t(n))}function zr(e,t){return()=>e(t)}function Zs(e,t){return n=>e(t,n)}function ar(e){return e!==void 0}function Js(...e){return()=>{e.map(Qs)}}function Ot(){}function mn(e,t){return t(e),e}function ei(e,t){return t(e)}function Te(...e){return e}function xe(e,t){return e(gt,t)}function ce(e,t){e(hn,t)}function cr(e){e(jt)}function _e(e){return e(Lo)}function ne(e,t){return xe(e,Zs(t,hn))}function nt(e,t){const n=e(gt,r=>{n(),t(r)});return n}function Pr(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function No(e,t){return e===t}function Ie(e=No){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function se(e){return t=>n=>{e(n)&&t(n)}}function Y(e){return t=>Ho(t,e)}function it(e){return t=>()=>{t(e)}}function H(e,...t){const n=ti(...t);return((r,o)=>{switch(r){case jt:cr(e);return;case gt:return xe(e,n(o))}})}function lt(e,t){return n=>r=>{n(t=e(t,r))}}function St(e){return t=>n=>{e>0?e--:t(n)}}function ct(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function de(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const u=Math.pow(2,i);xe(s,a=>{const l=n;n=n|u,t[i]=a,l!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const u=()=>{s([i].concat(t))};n===o?u():r=u}}function ti(...e){return t=>e.reduceRight(ei,t)}function ni(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case gt:return s?n===s?void 0:(r(),n=s,t=xe(e,s),t):(r(),Ot);case jt:r(),n=null;return}}}function W(e){let t=e;const n=pe();return((r,o)=>{switch(r){case hn:t=o;break;case gt:{o(t);break}case Lo:return t}return n(r,o)})}function Fe(e,t){return mn(W(t),n=>ne(e,n))}function pe(){const e=[];return((t,n)=>{switch(t){case hn:e.slice().forEach(r=>{r(n)});return;case jt:e.splice(0,e.length);return;case gt:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}})}function Xe(e){return mn(pe(),t=>ne(e,t))}function he(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:ri(),singleton:n}}const ri=()=>Symbol();function oi(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const u=r(o.map(a=>n(a)));return i&&t.set(s,u),u};return n(e)}function Pe(...e){const t=pe(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const u=Math.pow(2,i);xe(s,a=>{n[i]=a,r=r|u,r===o&&ce(t,n)})}),function(s,i){switch(s){case jt:{cr(t);return}case gt:return r===o&&i(n),xe(t,i)}}}function oe(e,t=No){return H(e,Ie(t))}function Jn(...e){return function(t,n){switch(t){case jt:return;case gt:return Js(...e.map(r=>xe(r,n)))}}}var Ve=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ve||{});const si={0:"debug",3:"error",1:"log",2:"warn"},ii=()=>typeof globalThis>"u"?window:globalThis,ht=he(()=>{const e=W(3);return{log:W((t,n,r=1)=>{var o;const s=(o=ii().VIRTUOSO_LOG_LEVEL)!=null?o:_e(e);r>=s&&console[si[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Ct(e,t,n){return ur(e,t,n).callbackRef}function ur(e,t,n){const r=h.useRef(null);let o=i=>{};const s=h.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const u=()=>{const a=i[0].target;a.offsetParent!==null&&e(a)};n?u():requestAnimationFrame(u)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function li(e,t,n,r,o,s,i,u,a){const l=h.useCallback(d=>{const m=ai(d.children,t,u?"offsetWidth":"offsetHeight",o);let p=d.parentElement;for(;!p.dataset.virtuosoScroller;)p=p.parentElement;const b=p.lastElementChild.dataset.viewportType==="window";let S;b&&(S=p.ownerDocument.defaultView);const w=i?u?i.scrollLeft:i.scrollTop:b?u?S.scrollX||S.document.documentElement.scrollLeft:S.scrollY||S.document.documentElement.scrollTop:u?p.scrollLeft:p.scrollTop,c=i?u?i.scrollWidth:i.scrollHeight:b?u?S.document.documentElement.scrollWidth:S.document.documentElement.scrollHeight:u?p.scrollWidth:p.scrollHeight,f=i?u?i.offsetWidth:i.offsetHeight:b?u?S.innerWidth:S.innerHeight:u?p.offsetWidth:p.offsetHeight;r({scrollHeight:c,scrollTop:Math.max(w,0),viewportHeight:f}),s==null||s(u?Br("column-gap",getComputedStyle(d).columnGap,o):Br("row-gap",getComputedStyle(d).rowGap,o)),m!==null&&e(m)},[e,t,o,s,i,r,u]);return ur(l,n,a)}function ai(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const u=e.item(i);if(u.dataset.index===void 0)continue;const a=parseInt(u.dataset.index),l=parseFloat(u.dataset.knownSize),d=t(u,n);if(d===0&&r("Zero-sized element, this should not happen",{child:u},Ve.ERROR),d===l)continue;const m=s[s.length-1];s.length===0||m.size!==d||m.endIndex!==a-1?s.push({endIndex:a,size:d,startIndex:a}):s[s.length-1].endIndex++}return s}function Br(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ve.WARN),t==="normal"?0:parseInt(t??"0",10)}function Fo(e,t,n){const r=h.useRef(null),o=h.useCallback(a=>{if(!(a!=null&&a.offsetParent))return;const l=a.getBoundingClientRect(),d=l.width;let m,p;if(t){const b=t.getBoundingClientRect(),S=l.top-b.top;p=b.height-Math.max(0,S),m=S+t.scrollTop}else{const b=i.current.ownerDocument.defaultView;p=b.innerHeight-Math.max(0,l.top),m=l.top+b.scrollY}r.current={offsetTop:m,visibleHeight:p,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=ur(o,!0,n),u=h.useCallback(()=>{o(i.current)},[o,i]);return h.useEffect(()=>{var a;if(t){t.addEventListener("scroll",u);const l=new ResizeObserver(()=>{requestAnimationFrame(u)});return l.observe(t),()=>{t.removeEventListener("scroll",u),l.unobserve(t)}}else{const l=(a=i.current)==null?void 0:a.ownerDocument.defaultView;return l==null||l.addEventListener("scroll",u),l==null||l.addEventListener("resize",u),()=>{l==null||l.removeEventListener("scroll",u),l==null||l.removeEventListener("resize",u)}}},[u,t,i]),s}const We=he(()=>{const e=pe(),t=pe(),n=W(0),r=pe(),o=W(0),s=pe(),i=pe(),u=W(0),a=W(0),l=W(0),d=W(0),m=pe(),p=pe(),b=W(!1),S=W(!1),w=W(!1);return ne(H(e,Y(({scrollTop:c})=>c)),t),ne(H(e,Y(({scrollHeight:c})=>c)),i),ne(t,o),{deviation:n,fixedFooterHeight:l,fixedHeaderHeight:a,footerHeight:d,headerHeight:u,horizontalDirection:S,scrollBy:p,scrollContainerState:e,scrollHeight:i,scrollingInProgress:b,scrollTo:m,scrollTop:t,skipAnimationFrameInResizeObserver:w,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Lt={lvl:0};function Wo(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:u,value:a}=t(e[i]);s.push({end:u-1,start:r,value:o}),r=u,o=a}return s.push({end:1/0,start:r,value:o}),s}function Se(e){return e===Lt}function Ht(e,t){if(!Se(e))return t===e.k?e.v:t<e.k?Ht(e.l,t):Ht(e.r,t)}function rt(e,t,n="k"){if(Se(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=rt(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return rt(e.l,t,n)}function Ke(e,t,n){return Se(e)?Vo(t,n,1):t===e.k?Ge(e,{k:t,v:n}):t<e.k?Ar(Ge(e,{l:Ke(e.l,t,n)})):Ar(Ge(e,{r:Ke(e.r,t,n)}))}function _t(){return Lt}function Mt(e,t,n){if(Se(e))return[];const r=rt(e,t)[0];return ci(tr(e,r,n))}function er(e,t){if(Se(e))return Lt;const{k:n,l:r,r:o}=e;if(t===n){if(Se(r))return o;if(Se(o))return r;{const[s,i]=$o(r);return nn(Ge(e,{k:s,l:Do(r),v:i}))}}else return t<n?nn(Ge(e,{l:er(r,t)})):nn(Ge(e,{r:er(o,t)}))}function xt(e){return Se(e)?[]:[...xt(e.l),{k:e.k,v:e.v},...xt(e.r)]}function tr(e,t,n){if(Se(e))return[];const{k:r,l:o,r:s,v:i}=e;let u=[];return r>t&&(u=u.concat(tr(o,t,n))),r>=t&&r<=n&&u.push({k:r,v:i}),r<=n&&(u=u.concat(tr(s,t,n))),u}function nn(e){const{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(_n(t))return qo(Ge(e,{lvl:n-1}));if(!Se(t)&&!Se(t.r))return Ge(t.r,{l:Ge(t,{r:t.r.l}),lvl:n,r:Ge(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(_n(e))return nr(Ge(e,{lvl:n-1}));if(!Se(r)&&!Se(r.l)){const o=r.l,s=_n(o)?r.lvl-1:r.lvl;return Ge(o,{l:Ge(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:nr(Ge(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Ge(e,t){return Vo(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function Do(e){return Se(e.r)?e.l:nn(Ge(e,{r:Do(e.r)}))}function _n(e){return Se(e)||e.lvl>e.r.lvl}function $o(e){return Se(e.r)?[e.k,e.v]:$o(e.r)}function Vo(e,t,n,r=Lt,o=Lt){return{k:e,l:r,lvl:n,r:o,v:t}}function Ar(e){return nr(qo(e))}function qo(e){const{l:t}=e;return!Se(t)&&t.lvl===e.lvl?Ge(t,{r:Ge(e,{l:t.r})}):e}function nr(e){const{lvl:t,r:n}=e;return!Se(n)&&!Se(n.r)&&n.lvl===t&&n.r.lvl===t?Ge(n,{l:Ge(e,{r:n.l}),lvl:t+1}):e}function ci(e){return Wo(e,({k:t,v:n})=>({index:t,value:n}))}function Uo(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Nt(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const dr=he(()=>({recalcInProgress:W(!1)}),[],{singleton:!0});function Ko(e,t,n){return e[sn(e,t,n)]}function sn(e,t,n,r=0){let o=e.length-1;for(;r<=o;){const s=Math.floor((r+o)/2),i=e[s],u=n(i,t);if(u===0)return s;if(u===-1){if(o-r<2)return s-1;o=s-1}else{if(o===r)return s;r=s+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function ui(e,t,n,r){const o=sn(e,t,r),s=sn(e,n,r,o);return e.slice(o,s+1)}function pt(e,t){return Math.round(e.getBoundingClientRect()[t])}function bn(e){return!Se(e.groupOffsetTree)}function fr({index:e},t){return t===e?0:t<e?-1:1}function di(){return{groupIndices:[],groupOffsetTree:_t(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:_t()}}function fi(e,t){let n=Se(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Se(e)){e=Ke(e,0,s);continue}const u=Mt(e,i-1,o+1);if(u.some(vi(r)))continue;let a=!1,l=!1;for(const{end:d,start:m,value:p}of u)a?(o>=m||s===p)&&(e=er(e,m)):(l=p!==s,a=!0),d>o&&o>=m&&p!==s&&(e=Ke(e,o+1,p));l&&(e=Ke(e,i,s))}return[e,n]}function pi(e){return typeof e.groupIndex<"u"}function gi({offset:e},t){return t===e?0:t<e?-1:1}function Ft(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=Ko(t,e,fr),i=e-r,u=s*i+(i-1)*n+o;return u>0?u+n:u}function Xo(e,t){if(!bn(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Yo(e,t,n){if(pi(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Xo(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function hi(e,t,n,r=0){return r>0&&(t=Math.max(t,Ko(e,r,fr).offset)),Wo(ui(e,t,n,gi),xi)}function mi(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Ve.DEBUG);const s=e.sizeTree;let i=s,u=0;if(n.length>0&&Se(s)&&t.length===2){const p=t[0].size,b=t[1].size;i=n.reduce((S,w)=>Ke(Ke(S,w,p),w+1,b),i)}else[i,u]=fi(i,t);if(i===s)return e;const{lastIndex:a,lastOffset:l,lastSize:d,offsetTree:m}=rr(e.offsetTree,u,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((p,b)=>Ke(p,b,Ft(b,m,o)),_t()),lastIndex:a,lastOffset:l,lastSize:d,offsetTree:m,sizeTree:i}}function bi(e){return xt(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function Gr(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function rr(e,t,n,r){let o=e,s=0,i=0,u=0,a=0;if(t!==0){a=sn(o,t-1,fr),u=o[a].offset;const l=rt(n,t-1);s=l[0],i=l[1],o.length&&o[a].size===rt(n,t)[1]&&(a-=1),o=o.slice(0,a+1)}else o=[];for(const{start:l,value:d}of Mt(n,t,1/0)){const m=l-s,p=m*i+u+m*r;o.push({index:l,offset:p,size:d}),s=l,u=p,i=d}return{lastIndex:s,lastOffset:u,lastSize:i,offsetTree:o}}function xi(e){return{index:e.index,value:e}}function vi(e){const{endIndex:t,size:n,startIndex:r}=e;return o=>o.start===r&&(o.end===t||o.end===1/0)&&o.value===n}const Si={offsetHeight:"height",offsetWidth:"width"},at=he(([{log:e},{recalcInProgress:t}])=>{const n=pe(),r=pe(),o=Fe(r,0),s=pe(),i=pe(),u=W(0),a=W([]),l=W(void 0),d=W(void 0),m=W(void 0),p=W(void 0),b=W((x,y)=>pt(x,Si[y])),S=W(void 0),w=W(0),c=di(),f=Fe(H(n,de(a,e,w),lt(mi,c),Ie()),c),g=Fe(H(a,Ie(),lt((x,y)=>({current:y,prev:x.current}),{current:[],prev:[]}),Y(({prev:x})=>x)),[]);ne(H(a,se(x=>x.length>0),de(f,w),Y(([x,y,R])=>{const k=x.reduce((O,P,I)=>Ke(O,P,Ft(P,y.offsetTree,R)||I),_t());return{...y,groupIndices:x,groupOffsetTree:k}})),f),ne(H(r,de(f),se(([x,{lastIndex:y}])=>x<y),Y(([x,{lastIndex:y,lastSize:R}])=>[{endIndex:y,size:R,startIndex:x}])),n),ne(l,d);const C=Fe(H(l,Y(x=>x===void 0)),!0);ne(H(d,se(x=>x!==void 0&&Se(_e(f).sizeTree)),Y(x=>{const y=_e(m),R=_e(a).length>0;return y?R?[{endIndex:0,size:y,startIndex:0},{endIndex:1,size:x,startIndex:1}]:[]:[{endIndex:0,size:x,startIndex:0}]})),n),ne(H(p,se(x=>x!==void 0&&x.length>0&&Se(_e(f).sizeTree)),Y(x=>{const y=[];let R=x[0],k=0;for(let O=1;O<x.length;O++){const P=x[O];P!==R&&(y.push({endIndex:O-1,size:R,startIndex:k}),R=P,k=O)}return y.push({endIndex:x.length-1,size:R,startIndex:k}),y})),n),ne(H(a,de(m,d),se(([,x,y])=>x!==void 0&&y!==void 0),Y(([x,y,R])=>{const k=[];for(let O=0;O<x.length;O++){const P=x[O],I=x[O+1];k.push({startIndex:P,endIndex:P,size:y}),I!==void 0&&k.push({startIndex:P+1,endIndex:I-1,size:R})}return k})),n);const T=Xe(H(n,de(f),lt(({sizes:x},[y,R])=>({changed:R!==x,sizes:R}),{changed:!1,sizes:c}),Y(x=>x.changed)));xe(H(u,lt((x,y)=>({diff:x.prev-y,prev:y}),{diff:0,prev:0}),Y(x=>x.diff)),x=>{const{groupIndices:y}=_e(f);if(x>0)ce(t,!0),ce(s,x+Gr(x,y));else if(x<0){const R=_e(g);R.length>0&&(x-=Gr(-x,R)),ce(i,x)}}),xe(H(u,de(e)),([x,y])=>{x<0&&y("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:u},Ve.ERROR)});const M=Xe(s);ne(H(s,de(f),Y(([x,y])=>{const R=y.groupIndices.length>0,k=[],O=y.lastSize;if(R){const P=Ht(y.sizeTree,0);let I=0,_=0;for(;I<x;){const N=y.groupIndices[_],B=y.groupIndices.length===_+1?1/0:y.groupIndices[_+1]-N-1;k.push({endIndex:N,size:P,startIndex:N}),k.push({endIndex:N+1+B-1,size:O,startIndex:N+1}),_++,I+=B+1}const z=xt(y.sizeTree);return I!==x&&z.shift(),z.reduce((N,{k:B,v:$})=>{let te=N.ranges;return N.prevSize!==0&&(te=[...N.ranges,{endIndex:B+x-1,size:N.prevSize,startIndex:N.prevIndex}]),{prevIndex:B+x,prevSize:$,ranges:te}},{prevIndex:x,prevSize:0,ranges:k}).ranges}return xt(y.sizeTree).reduce((P,{k:I,v:_})=>({prevIndex:I+x,prevSize:_,ranges:[...P.ranges,{endIndex:I+x-1,size:P.prevSize,startIndex:P.prevIndex}]}),{prevIndex:0,prevSize:O,ranges:[]}).ranges})),n);const E=Xe(H(i,de(f,w),Y(([x,{offsetTree:y},R])=>{const k=-x;return Ft(k,y,R)})));return ne(H(i,de(f,w),Y(([x,y,R])=>{if(y.groupIndices.length>0){if(Se(y.sizeTree))return y;let k=_t();const O=_e(g);let P=0,I=0,_=0;for(;P<-x;){_=O[I];const z=O[I+1]-_-1;I++,P+=z+1}if(k=xt(y.sizeTree).reduce((z,{k:N,v:B})=>Ke(z,Math.max(0,N+x),B),k),P!==-x){const z=Ht(y.sizeTree,_);k=Ke(k,0,z);const N=rt(y.sizeTree,-x+1)[1];k=Ke(k,1,N)}return{...y,sizeTree:k,...rr(y.offsetTree,0,k,R)}}else{const k=xt(y.sizeTree).reduce((O,{k:P,v:I})=>Ke(O,Math.max(0,P+x),I),_t());return{...y,sizeTree:k,...rr(y.offsetTree,0,k,R)}}})),f),{beforeUnshiftWith:M,data:S,defaultItemSize:d,firstItemIndex:u,fixedItemSize:l,fixedGroupSize:m,gap:w,groupIndices:a,heightEstimates:p,itemSize:b,listRefresh:T,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:f,statefulTotalCount:o,totalCount:r,trackItemSizes:C,unshiftWith:s}},Te(ht,dr),{singleton:!0});function yi(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Qo=he(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=pe(),i=pe(),u=Xe(H(s,Y(yi)));return ne(H(u,Y(a=>a.totalCount)),n),ne(H(u,Y(a=>a.groupIndices)),e),ne(H(Pe(o,t,r),se(([a,l])=>bn(l)),Y(([a,l,d])=>rt(l.groupOffsetTree,Math.max(a-d,0),"v")[0]),Ie(),Y(a=>[a])),i),{groupCounts:s,topItemsIndexes:i}},Te(at,We)),mt=he(([{log:e}])=>{const t=W(!1),n=Xe(H(t,se(r=>r),Ie()));return xe(t,r=>{r&&_e(e)("props updated",{},Ve.DEBUG)}),{didMount:n,propsReady:t}},Te(ht),{singleton:!0}),wi=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Zo(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!wi)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Ut=he(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:u,scrollingInProgress:a,scrollTo:l,smoothScrollTargetReached:d,viewportHeight:m},{log:p}])=>{const b=pe(),S=pe(),w=W(0);let c=null,f=null,g=null;function C(){c&&(c(),c=null),g&&(g(),g=null),f&&(clearTimeout(f),f=null),ce(a,!1)}return ne(H(b,de(n,m,r,w,u,i,p),de(e,s,o),Y(([[T,M,E,x,y,R,k,O],P,I,_])=>{const z=Zo(T),{align:N,behavior:B,offset:$}=z,te=x-1,fe=Yo(z,M,te);let ge=Ft(fe,M.offsetTree,P)+R;N==="end"?(ge+=I+rt(M.sizeTree,fe)[1]-E+_,fe===te&&(ge+=k)):N==="center"?ge+=(I+rt(M.sizeTree,fe)[1]-E+_)/2:ge-=y,$&&(ge+=$);const ve=me=>{C(),me?(O("retrying to scroll to",{location:T},Ve.DEBUG),ce(b,T)):(ce(S,!0),O("list did not change, scroll successful",{},Ve.DEBUG))};if(C(),B==="smooth"){let me=!1;g=xe(t,Be=>{me=me||Be}),c=nt(d,()=>{ve(me)})}else c=nt(H(t,Ci(150)),ve);return f=setTimeout(()=>{C()},1200),ce(a,!0),O("scrolling from index to",{behavior:B,index:fe,top:ge},Ve.DEBUG),{behavior:B,top:ge}})),l),{scrollTargetReached:S,scrollToIndex:b,topListHeight:w}},Te(at,We,ht),{singleton:!0});function Ci(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function pr(e,t){e==0?t():requestAnimationFrame(()=>{pr(e-1,t)})}function gr(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Kt=he(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const u=W(!0),a=W(0),l=W(!0);return ne(H(i,de(a),se(([d,m])=>!!m),it(!1)),u),ne(H(i,de(a),se(([d,m])=>!!m),it(!1)),l),xe(H(Pe(t,i),de(u,n,e,l),se(([[,d],m,{sizeTree:p},b,S])=>d&&(!Se(p)||ar(b))&&!m&&!S),de(a)),([,d])=>{nt(o,()=>{ce(l,!0)}),pr(4,()=>{nt(r,()=>{ce(u,!0)}),ce(s,d)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:a,scrolledToInitialItem:u}},Te(at,We,Ut,mt),{singleton:!0});function Jo(e,t){return Math.abs(e-t)<1.01}const Wt="up",At="down",Ii="none",Ti={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},ki=0,Xt=he(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=W(!1),u=W(!0),a=pe(),l=pe(),d=W(4),m=W(ki),p=Fe(H(Jn(H(oe(o),St(1),it(!0)),H(oe(o),St(1),it(!1),Pr(100))),Ie()),!1),b=Fe(H(Jn(H(n,it(!0)),H(n,it(!1),Pr(200))),Ie()),!1);ne(H(Pe(oe(o),oe(m)),Y(([g,C])=>g<=C),Ie()),u),ne(H(u,ct(50)),l);const S=Xe(H(Pe(r,oe(s),oe(t),oe(e),oe(d)),lt((g,[{scrollHeight:C,scrollTop:T},M,E,x,y])=>{const R=T+M-C>-y,k={scrollHeight:C,scrollTop:T,viewportHeight:M};if(R){let P,I;return T>g.state.scrollTop?(P="SCROLLED_DOWN",I=g.state.scrollTop-T):(P="SIZE_DECREASED",I=g.state.scrollTop-T||g.scrollTopDelta),{atBottom:!0,atBottomBecause:P,scrollTopDelta:I,state:k}}let O;return k.scrollHeight>g.state.scrollHeight?O="SIZE_INCREASED":M<g.state.viewportHeight?O="VIEWPORT_HEIGHT_DECREASING":T<g.state.scrollTop?O="SCROLLING_UPWARDS":O="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:O,state:k}},Ti),Ie((g,C)=>g&&g.atBottom===C.atBottom))),w=Fe(H(r,lt((g,{scrollHeight:C,scrollTop:T,viewportHeight:M})=>{if(Jo(g.scrollHeight,C))return{changed:!1,jump:0,scrollHeight:C,scrollTop:T};{const E=C-(T+M)<1;return g.scrollTop!==T&&E?{changed:!0,jump:g.scrollTop-T,scrollHeight:C,scrollTop:T}:{changed:!0,jump:0,scrollHeight:C,scrollTop:T}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),se(g=>g.changed),Y(g=>g.jump)),0);ne(H(S,Y(g=>g.atBottom)),i),ne(H(i,ct(50)),a);const c=W(At);ne(H(r,Y(({scrollTop:g})=>g),Ie(),lt((g,C)=>_e(b)?{direction:g.direction,prevScrollTop:C}:{direction:C<g.prevScrollTop?Wt:At,prevScrollTop:C},{direction:At,prevScrollTop:0}),Y(g=>g.direction)),c),ne(H(r,ct(50),it(Ii)),c);const f=W(0);return ne(H(p,se(g=>!g),it(0)),f),ne(H(o,ct(100),de(p),se(([g,C])=>C),lt(([g,C],[T])=>[C,T],[0,0]),Y(([g,C])=>C-g)),f),{atBottomState:S,atBottomStateChange:a,atBottomThreshold:d,atTopStateChange:l,atTopThreshold:m,isAtBottom:i,isAtTop:u,isScrolling:p,lastJumpDueToItemResize:w,scrollDirection:c,scrollVelocity:f}},Te(We)),Dt="top",$t="bottom",Lr="none";function Hr(e,t,n){return typeof e=="number"?n===Wt&&t===Dt||n===At&&t===$t?e:0:n===Wt?t===Dt?e.main:e.reverse:t===$t?e.main:e.reverse}function Nr(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const hr=he(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=pe(),i=W(0),u=W(0),a=W(0),l=Fe(H(Pe(oe(r),oe(o),oe(n),oe(s,Nt),oe(a),oe(i),oe(t),oe(e),oe(u)),Y(([d,m,p,[b,S],w,c,f,g,C])=>{const T=d-g,M=c+f,E=Math.max(p-T,0);let x=Lr;const y=Nr(C,Dt),R=Nr(C,$t);return b-=g,b+=p+f,S+=p+f,S-=g,b>d+M-y&&(x=Wt),S<d-E+m+R&&(x=At),x!==Lr?[Math.max(T-p-Hr(w,Dt,x)-y,0),T-E-f+m+Hr(w,$t,x)+R]:null}),se(d=>d!=null),Ie(Nt)),[0,0]);return{increaseViewportBy:u,listBoundary:s,overscan:a,topListHeight:i,visibleRange:l}},Te(We),{singleton:!0});function Ri(e,t,n){if(bn(t)){const r=Xo(e,t);return[{index:rt(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const Mn={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function rn(e,t,n,r,o,s){const{lastIndex:i,lastOffset:u,lastSize:a}=o;let l=0,d=0;if(e.length>0){l=e[0].offset;const w=e[e.length-1];d=w.offset+w.size}const m=n-i,p=u+m*a+(m-1)*r,b=l,S=p-d;return{bottom:d,firstItemIndex:s,items:Fr(e,o,s),offsetBottom:S,offsetTop:l,top:b,topItems:Fr(t,o,s),topListHeight:t.reduce((w,c)=>c.size+w,0),totalCount:n}}function es(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const u=e+i,a=gr(t,u),l=Array.from({length:u}).map((d,m)=>({data:s[m+a],index:m+a,offset:0,size:0}));return rn(l,[],u,o,n,r)}function Fr(e,t,n){if(e.length===0)return[];if(!bn(t))return e.map(l=>({...l,index:l.index+n,originalIndex:l.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=Mt(t.groupOffsetTree,r,o);let u,a=0;for(const l of e){(!u||u.end<l.index)&&(u=i.shift(),a=t.groupIndices.indexOf(u.start));let d;l.index===u.start?d={index:a,type:"group"}:d={groupIndex:a,index:l.index-(a+1)+n},s.push({...d,data:l.data,offset:l.offset,originalIndex:l.index,size:l.size})}return s}function Wr(e,t){var n;return e===void 0?0:typeof e=="number"?e:(n=e[t])!=null?n:0}const It=he(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:u,visibleRange:a},{initialTopMostItemIndex:l,scrolledToInitialItem:d},{topListHeight:m},p,{didMount:b},{recalcInProgress:S}])=>{const w=W([]),c=W(0),f=pe(),g=W(0);ne(s.topItemsIndexes,w);const C=Fe(H(Pe(b,S,oe(a,Nt),oe(o),oe(r),oe(l),d,oe(w),oe(t),oe(n),oe(g),e),se(([x,y,,R,,,,,,,,k])=>{const O=k&&k.length!==R;return x&&!y&&!O}),Y(([,,[x,y],R,k,O,P,I,_,z,N,B])=>{var $,te,fe,ge;const ve=k,{offsetTree:me,sizeTree:Be}=ve,K=_e(c);if(R===0)return{...Mn,totalCount:R};if(x===0&&y===0)return K===0?{...Mn,totalCount:R}:es(K,O,k,_,z,B||[]);if(Se(Be))return K>0?null:rn(Ri(gr(O,R),ve,B),[],R,z,ve,_);const D=[];if(I.length>0){const F=I[0],X=I[I.length-1];let ee=0;for(const Z of Mt(Be,F,X)){const ie=Z.value,re=Math.max(Z.start,F),be=Math.min(Z.end,X);for(let ue=re;ue<=be;ue++)D.push({data:B==null?void 0:B[ue],index:ue,offset:ee,size:ie}),ee+=ie}}if(!P)return rn([],D,R,z,ve,_);const G=I.length>0?I[I.length-1]+1:0,j=hi(me,x,y,G);if(j.length===0)return null;const L=R-1,V=mn([],F=>{for(const X of j){const ee=X.value;let Z=ee.offset,ie=X.start;const re=ee.size;if(ee.offset<x){ie+=Math.floor((x-ee.offset+z)/(re+z));const ue=ie-X.start;Z+=ue*re+ue*z}ie<G&&(Z+=(G-ie)*re,ie=G);const be=Math.min(X.end,L);for(let ue=ie;ue<=be&&!(Z>=y);ue++)F.push({data:B==null?void 0:B[ue],index:ue,offset:Z,size:re}),Z+=re+z}}),A=Wr(N,Dt),Q=Wr(N,$t);if(V.length>0&&(A>0||Q>0)){const F=V[0],X=V[V.length-1];if(A>0&&F.index>G){const ee=Math.min(A,F.index-G),Z=[];let ie=F.offset;for(let re=F.index-1;re>=F.index-ee;re--){const be=(te=($=Mt(Be,re,re)[0])==null?void 0:$.value)!=null?te:F.size;ie-=be+z,Z.unshift({data:B==null?void 0:B[re],index:re,offset:ie,size:be})}V.unshift(...Z)}if(Q>0&&X.index<L){const ee=Math.min(Q,L-X.index);let Z=X.offset+X.size+z;for(let ie=X.index+1;ie<=X.index+ee;ie++){const re=(ge=(fe=Mt(Be,ie,ie)[0])==null?void 0:fe.value)!=null?ge:X.size;V.push({data:B==null?void 0:B[ie],index:ie,offset:Z,size:re}),Z+=re+z}}}return rn(V,D,R,z,ve,_)}),se(x=>x!==null),Ie()),Mn);ne(H(e,se(ar),Y(x=>x==null?void 0:x.length)),o),ne(H(C,Y(x=>x.topListHeight)),m),ne(m,u),ne(H(C,Y(x=>[x.top,x.bottom])),i),ne(H(C,Y(x=>x.items)),f);const T=Xe(H(C,se(({items:x})=>x.length>0),de(o,e),se(([{items:x},y])=>x[x.length-1].originalIndex===y-1),Y(([,x,y])=>[x-1,y]),Ie(Nt),Y(([x])=>x))),M=Xe(H(C,ct(200),se(({items:x,topItems:y})=>x.length>0&&x[0].originalIndex===y.length),Y(({items:x})=>x[0].index),Ie())),E=Xe(H(C,se(({items:x})=>x.length>0),Y(({items:x})=>{let y=0,R=x.length-1;for(;x[y].type==="group"&&y<R;)y++;for(;x[R].type==="group"&&R>y;)R--;return{endIndex:x[R].index,startIndex:x[y].index}}),Ie(Uo)));return{endReached:T,initialItemCount:c,itemsRendered:f,listState:C,minOverscanItemCount:g,rangeChanged:E,startReached:M,topItemsIndexes:w,...p}},Te(at,Qo,hr,Kt,Ut,Xt,mt,dr),{singleton:!0}),ts=he(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=pe(),i=Fe(H(Pe(n,e,r,t,o),Y(([u,a,l,d,m])=>u+a+l+d+m.offsetBottom+m.bottom)),0);return ne(oe(i),s),{totalListHeight:i,totalListHeightChanged:s}},Te(We,It),{singleton:!0}),_i=he(([{viewportHeight:e},{totalListHeight:t}])=>{const n=W(!1),r=Fe(H(Pe(n,e,t),se(([o])=>o),Y(([,o,s])=>Math.max(0,o-s)),ct(0),Ie()),0);return{alignToBottom:n,paddingTopAddition:r}},Te(We,ts),{singleton:!0}),ns=he(()=>({context:W(null)})),Mi=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...o},viewportBottom:s,viewportTop:i})=>t<i?{...o,align:n??"start",behavior:r}:e>s?{...o,align:n??"end",behavior:r}:null,rs=he(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:u,viewportHeight:a},{scrollToIndex:l}])=>{const d=pe();return ne(H(d,de(t,a,n,s,o,r,u),de(e),Y(([[m,p,b,S,w,c,f,g],C])=>{const{align:T,behavior:M,calculateViewLocation:E=Mi,done:x,...y}=m,R=Yo(m,p,S-1),k=Ft(R,p.offsetTree,C)+w+c,O=k+rt(p.sizeTree,R)[1],P=g+c,I=g+b-f,_=E({itemBottom:O,itemTop:k,locationParams:{align:T,behavior:M,...y},viewportBottom:I,viewportTop:P});return _?x&&nt(H(i,se(z=>!z),St(_e(i)?1:2)),x):x==null||x(),_}),se(m=>m!==null)),l),{scrollIntoView:d}},Te(at,We,Ut,It,ht),{singleton:!0});function Dr(e){return e?e==="smooth"?"smooth":"auto":!1}const Ei=(e,t)=>typeof e=="function"?Dr(e(t)):t&&Dr(e),ji=he(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:u},{didMount:a,propsReady:l},{log:d},{scrollingInProgress:m},{context:p},{scrollIntoView:b}])=>{const S=W(!1),w=pe();let c=null;function f(M){ce(i,{align:"end",behavior:M,index:"LAST"})}xe(H(Pe(H(oe(t),St(1)),a),de(oe(S),s,u,m),Y(([[M,E],x,y,R,k])=>{let O=E&&R,P="auto";return O&&(P=Ei(x,y||k),O=O&&!!P),{followOutputBehavior:P,shouldFollow:O,totalCount:M}}),se(({shouldFollow:M})=>M)),({followOutputBehavior:M,totalCount:E})=>{c&&(c(),c=null),_e(n)?requestAnimationFrame(()=>{_e(d)("following output to ",{totalCount:E},Ve.DEBUG),f(M)}):c=nt(e,()=>{_e(d)("following output to ",{totalCount:E},Ve.DEBUG),f(M),c=null})});function g(M){const E=nt(o,x=>{M&&!x.atBottom&&x.notAtBottomBecause==="SIZE_INCREASED"&&!c&&(_e(d)("scrolling to bottom due to increased size",{},Ve.DEBUG),f("auto"))});setTimeout(E,100)}xe(H(Pe(oe(S),t,l),se(([M,,E])=>M&&E),lt(({value:M},[,E])=>({refreshed:M===E,value:E}),{refreshed:!1,value:0}),se(({refreshed:M})=>M),de(S,t)),([,M])=>{_e(u)&&g(M!==!1)}),xe(w,()=>{g(_e(S)!==!1)}),xe(Pe(oe(S),o),([M,E])=>{M&&!E.atBottom&&E.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&f("auto")});const C=W(null),T=pe();return ne(Jn(H(oe(r),Y(M=>{var E;return(E=M==null?void 0:M.length)!=null?E:0})),H(oe(t))),T),xe(H(Pe(H(T,St(1)),a),de(oe(C),u,m,p),Y(([[M,E],x,y,R,k])=>E&&y&&(x==null?void 0:x({context:k,totalCount:M,scrollingInProgress:R}))),se(M=>!!M),ct(0)),M=>{c&&(c(),c=null),_e(n)?requestAnimationFrame(()=>{_e(d)("scrolling into view",{}),ce(b,M)}):c=nt(e,()=>{_e(d)("scrolling into view",{}),ce(b,M),c=null})}),{autoscrollToBottom:w,followOutput:S,scrollIntoViewOnChange:C}},Te(at,Xt,Ut,Kt,mt,ht,We,ns,rs)),Oi=he(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:u}])=>(ne(H(u,de(s),se(([,a])=>a!==0),de(o,r,t,n,e),Y(([[,a],l,d,m,p,b=[]])=>es(a,l,d,m,p,b))),i),{}),Te(at,Kt,It,mt),{singleton:!0}),zi=he(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=W(0);return xe(H(e,de(r),se(([,o])=>o!==0),Y(([,o])=>({top:o}))),o=>{nt(H(n,St(1),se(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{ce(t,o)})})}),{initialScrollTop:r}},Te(mt,We,It),{singleton:!0}),os=he(([{scrollVelocity:e}])=>{const t=W(!1),n=pe(),r=W(!1);return ne(H(e,de(r,t,n),se(([o,s])=>!!s),Y(([o,s,i,u])=>{const{enter:a,exit:l}=s;if(i){if(l(o,u))return!1}else if(a(o,u))return!0;return i}),Ie()),t),xe(H(Pe(t,e,n),de(r)),([[o,s,i],u])=>{o&&u&&u.change&&u.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},Te(Xt),{singleton:!0}),mr=he(([{scrollContainerState:e,scrollTo:t}])=>{const n=pe(),r=pe(),o=pe(),s=W(!1),i=W(void 0);return ne(H(Pe(n,r),Y(([{scrollHeight:u,scrollTop:a,viewportHeight:l},{offsetTop:d}])=>({scrollHeight:u,scrollTop:Math.max(0,a-d),viewportHeight:l}))),e),ne(H(t,de(r),Y(([u,{offsetTop:a}])=>({...u,top:u.top+a}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},Te(We)),Pi=he(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:u,windowViewportRect:a}])=>{const l=pe(),d=W(void 0),m=W(null),p=W(null);return ne(u,m),ne(a,p),xe(H(l,de(t,r,i,m,p,n)),([b,S,w,c,f,g,C])=>{const T=bi(S.sizeTree);c&&f!==null&&g!==null&&(w=f.scrollTop-g.offsetTop),w-=C,b({ranges:T,scrollTop:w})}),ne(H(d,se(ar),Y(Bi)),o),ne(H(s,de(d),se(([,b])=>b!==void 0),Ie(),Y(([,b])=>b.ranges)),e),{getState:l,restoreStateFrom:d}},Te(at,We,Kt,mt,mr));function Bi(e){return{align:"start",index:0,offset:e.scrollTop}}const Ai=he(([{topItemsIndexes:e}])=>{const t=W(0);return ne(H(t,se(n=>n>=0),Y(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},Te(It));function ss(e){let t=!1,n;return(()=>(t||(t=!0,n=e()),n))}const Gi=ss(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Li=he(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:u},{listState:a},{beforeUnshiftWith:l,gap:d,shiftWithOffset:m,sizes:p},{log:b},{recalcInProgress:S}])=>{const w=Xe(H(a,de(i),lt(([,f,g,C],[{bottom:T,items:M,offsetBottom:E,totalCount:x},y])=>{const R=T+E;let k=0;return g===x&&f.length>0&&M.length>0&&(M[0].originalIndex===0&&f[0].originalIndex===0||(k=R-C,k!==0&&(k+=y))),[k,M,x,R]},[0,[],0,0]),se(([f])=>f!==0),de(r,u,n,o,b,S),se(([,f,g,C,,,T])=>!T&&!C&&f!==0&&g===Wt),Y(([[f],,,,,g])=>(g("Upward scrolling compensation",{amount:f},Ve.DEBUG),f))));function c(f){f>0?(ce(t,{behavior:"auto",top:-f}),ce(e,0)):(ce(e,0),ce(t,{behavior:"auto",top:-f}))}return xe(H(w,de(e,s)),([f,g,C])=>{C&&Gi()?ce(e,g-f):c(-f)}),xe(H(Pe(Fe(s,!1),e,S),se(([f,g,C])=>!f&&!C&&g!==0),Y(([f,g])=>g),ct(1)),c),ne(H(m,Y(f=>({top:-f}))),t),xe(H(l,de(p,d),Y(([f,{groupIndices:g,lastSize:C,sizeTree:T},M])=>{function E(x){return x*(C+M)}if(g.length===0)return E(f);{let x=0;const y=Ht(T,0);let R=0,k=0;for(;R<f;){R++,x+=y;let O=g.length===k+1?1/0:g[k+1]-g[k]-1;R+O>f&&(x-=y,O=f-R+1),R+=O,x+=E(O),k++}return x}})),f=>{ce(e,f),requestAnimationFrame(()=>{ce(t,{top:f}),requestAnimationFrame(()=>{ce(e,0),ce(S,!1)})})}),{deviation:e}},Te(We,Xt,It,at,ht,dr)),Hi=he(([e,t,n,r,o,s,i,u,a,l,d])=>({...e,...t,...n,...r,...o,...s,...i,...u,...a,...l,...d}),Te(hr,Oi,mt,os,ts,zi,_i,mr,rs,ht,ns)),is=he(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,fixedGroupSize:o,gap:s,groupIndices:i,heightEstimates:u,itemSize:a,sizeRanges:l,sizes:d,statefulTotalCount:m,totalCount:p,trackItemSizes:b},{initialItemFinalLocationReached:S,initialTopMostItemIndex:w,scrolledToInitialItem:c},f,g,C,T,{scrollToIndex:M},E,{topItemCount:x},{groupCounts:y},R])=>{const{listState:k,minOverscanItemCount:O,topItemsIndexes:P,rangeChanged:I,..._}=T;return ne(I,R.scrollSeekRangeChanged),ne(H(R.windowViewportRect,Y(z=>z.visibleHeight)),f.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,fixedGroupHeight:o,gap:s,groupCounts:y,heightEstimates:u,initialItemFinalLocationReached:S,initialTopMostItemIndex:w,scrolledToInitialItem:c,sizeRanges:l,topItemCount:x,topItemsIndexes:P,totalCount:p,...C,groupIndices:i,itemSize:a,listState:k,minOverscanItemCount:O,scrollToIndex:M,statefulTotalCount:m,trackItemSizes:b,rangeChanged:I,..._,...R,...f,sizes:d,...g}},Te(at,Kt,We,Pi,ji,It,Ut,Li,Ai,Qo,Hi));function Ni(e,t){const n={},r={};let o=0;const s=e.length;for(;o<s;)r[e[o]]=1,o+=1;for(const i in t)Object.hasOwn(r,i)||(n[i]=t[i]);return n}const Jt=typeof document<"u"?h.useLayoutEffect:h.useEffect;function ls(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),u=h.createContext({});function a(c,f){c.propsReady&&ce(c.propsReady,!1);for(const g of r){const C=c[t.required[g]];ce(C,f[g])}for(const g of o)if(g in f){const C=c[t.optional[g]];ce(C,f[g])}c.propsReady&&ce(c.propsReady,!0)}function l(c){return s.reduce((f,g)=>(f[g]=C=>{const T=c[t.methods[g]];ce(T,C)},f),{})}function d(c){return i.reduce((f,g)=>(f[g]=ni(c[t.events[g]]),f),{})}const m=h.forwardRef((c,f)=>{const{children:g,...C}=c,[T]=h.useState(()=>mn(oi(e),x=>{a(x,C)})),[M]=h.useState(zr(d,T));Jt(()=>{for(const x of i)x in C&&xe(M[x],C[x]);return()=>{Object.values(M).map(cr)}},[C,M,T]),Jt(()=>{a(T,C)}),h.useImperativeHandle(f,Or(l(T)));const E=n;return v.jsx(u.Provider,{value:T,children:n?v.jsx(E,{...Ni([...r,...o,...i],C),children:g}):g})}),p=c=>{const f=h.useContext(u);return h.useCallback(g=>{ce(f[c],g)},[f,c])},b=c=>{const f=h.useContext(u)[c],g=h.useCallback(C=>xe(f,C),[f]);return h.useSyncExternalStore(g,()=>_e(f),()=>_e(f))},S=c=>{const f=h.useContext(u)[c],[g,C]=h.useState(zr(_e,f));return Jt(()=>xe(f,T=>{T!==g&&C(Or(T))}),[f,g]),g},w=h.version.startsWith("18")?b:S;return{Component:m,useEmitter:(c,f)=>{const g=h.useContext(u)[c];Jt(()=>xe(g,f),[f,g])},useEmitterValue:w,usePublisher:p}}const as=h.createContext(void 0),cs=h.createContext(void 0),us=typeof document<"u"?h.useLayoutEffect:h.useEffect;function En(e){return"self"in e}function Fi(e){return"body"in e}function ds(e,t,n,r=Ot,o,s){const i=h.useRef(null),u=h.useRef(null),a=h.useRef(null),l=h.useCallback(p=>{let b,S,w;const c=p.target;if(Fi(c)||En(c)){const g=En(c)?c:c.defaultView;w=s?g.scrollX:g.scrollY,b=s?g.document.documentElement.scrollWidth:g.document.documentElement.scrollHeight,S=s?g.innerWidth:g.innerHeight}else w=s?c.scrollLeft:c.scrollTop,b=s?c.scrollWidth:c.scrollHeight,S=s?c.offsetWidth:c.offsetHeight;const f=()=>{e({scrollHeight:b,scrollTop:Math.max(w,0),viewportHeight:S})};p.suppressFlushSync?f():Bs.flushSync(f),u.current!==null&&(w===u.current||w<=0||w===b-S)&&(u.current=null,t(!0),a.current&&(clearTimeout(a.current),a.current=null))},[e,t,s]);h.useEffect(()=>{const p=o||i.current;return r(o||i.current),l({suppressFlushSync:!0,target:p}),p.addEventListener("scroll",l,{passive:!0}),()=>{r(null),p.removeEventListener("scroll",l)}},[i,l,n,r,o]);function d(p){const b=i.current;if(!b||(s?"offsetWidth"in b&&b.offsetWidth===0:"offsetHeight"in b&&b.offsetHeight===0))return;const S=p.behavior==="smooth";let w,c,f;En(b)?(c=Math.max(pt(b.document.documentElement,s?"width":"height"),s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight),w=s?b.innerWidth:b.innerHeight,f=s?window.scrollX:window.scrollY):(c=b[s?"scrollWidth":"scrollHeight"],w=pt(b,s?"width":"height"),f=b[s?"scrollLeft":"scrollTop"]);const g=c-w;if(p.top=Math.ceil(Math.max(Math.min(g,p.top),0)),Jo(w,c)||p.top===f){e({scrollHeight:c,scrollTop:f,viewportHeight:w}),S&&t(!0);return}S?(u.current=p.top,a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{a.current=null,u.current=null,t(!0)},1e3)):u.current=null,s&&(p={behavior:p.behavior,left:p.top}),b.scrollTo(p)}function m(p){s&&(p={behavior:p.behavior,left:p.top}),i.current.scrollBy(p)}return{scrollByCallback:m,scrollerRef:i,scrollToCallback:d}}const jn="-webkit-sticky",$r="sticky",br=ss(()=>{if(typeof document>"u")return $r;const e=document.createElement("div");return e.style.position=jn,e.style.position===jn?jn:$r});function xr(e){return e}const Wi=he(()=>{const e=W(u=>`Item ${u}`),t=W(u=>`Group ${u}`),n=W({}),r=W(xr),o=W("div"),s=W(Ot),i=(u,a=null)=>Fe(H(n,Y(l=>l[u]),Ie()),a);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),Di=he(([e,t])=>({...e,...t}),Te(is,Wi)),$i=({height:e})=>v.jsx("div",{style:{height:e}}),Vi={overflowAnchor:"none",position:br(),zIndex:1},fs={overflowAnchor:"none"},qi={...fs,display:"inline-block",height:"100%"},Vr=h.memo(function({showTopList:e=!1}){const t=le("listState"),n=Ze("sizeRanges"),r=le("useWindowScroll"),o=le("customScrollParent"),s=Ze("windowScrollContainerState"),i=Ze("scrollContainerState"),u=o||r?s:i,a=le("itemContent"),l=le("context"),d=le("groupContent"),m=le("trackItemSizes"),p=le("itemSize"),b=le("log"),S=Ze("gap"),w=le("horizontalDirection"),{callbackRef:c}=li(n,p,m,e?Ot:u,b,S,o,w,le("skipAnimationFrameInResizeObserver")),[f,g]=h.useState(0);vr("deviation",_=>{f!==_&&g(_)});const C=le("EmptyPlaceholder"),T=le("ScrollSeekPlaceholder")||$i,M=le("ListComponent"),E=le("ItemComponent"),x=le("GroupComponent"),y=le("computeItemKey"),R=le("isSeeking"),k=le("groupIndices").length>0,O=le("alignToBottom"),P=le("initialItemFinalLocationReached"),I=e?{}:{boxSizing:"border-box",...w?{display:"inline-block",height:"100%",marginLeft:f!==0?f:O?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:f!==0?f:O?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...P?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?v.jsx(C,{...Ne(C,l)}):v.jsx(M,{...Ne(M,l),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:c,style:I,children:(e?t.topItems:t.items).map(_=>{const z=_.originalIndex,N=y(z+t.firstItemIndex,_.data,l);return R?h.createElement(T,{...Ne(T,l),height:_.size,index:_.index,key:N,type:_.type||"item",..._.type==="group"?{}:{groupIndex:_.groupIndex}}):_.type==="group"?h.createElement(x,{...Ne(x,l),"data-index":z,"data-item-index":_.index,"data-known-size":_.size,key:N,style:Vi},d(_.index,l)):h.createElement(E,{...Ne(E,l),...Yi(E,_.data),"data-index":z,"data-item-group-index":_.groupIndex,"data-item-index":_.index,"data-known-size":_.size,key:N,style:w?qi:fs},k?a(_.index,_.groupIndex,_.data,l):a(_.index,_.data,l))})})}),Ui={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Ki={outline:"none",overflowX:"auto",position:"relative"},xn=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Xi={position:br(),top:0,width:"100%",zIndex:1};function Ne(e,t){if(typeof e!="string")return{context:t}}function Yi(e,t){return{item:typeof e=="string"?void 0:t}}const Qi=h.memo(function(){const e=le("HeaderComponent"),t=Ze("headerHeight"),n=le("HeaderFooterTag"),r=Ct(h.useMemo(()=>s=>{t(pt(s,"height"))},[t]),!0,le("skipAnimationFrameInResizeObserver")),o=le("context");return e?v.jsx(n,{ref:r,children:v.jsx(e,{...Ne(e,o)})}):null}),Zi=h.memo(function(){const e=le("FooterComponent"),t=Ze("footerHeight"),n=le("HeaderFooterTag"),r=Ct(h.useMemo(()=>s=>{t(pt(s,"height"))},[t]),!0,le("skipAnimationFrameInResizeObserver")),o=le("context");return e?v.jsx(n,{ref:r,children:v.jsx(e,{...Ne(e,o)})}):null});function ps({useEmitter:e,useEmitterValue:t,usePublisher:n}){return h.memo(function({children:r,style:o,context:s,...i}){const u=n("scrollContainerState"),a=t("ScrollerComponent"),l=n("smoothScrollTargetReached"),d=t("scrollerRef"),m=t("horizontalDirection")||!1,{scrollByCallback:p,scrollerRef:b,scrollToCallback:S}=ds(u,l,a,d,void 0,m);return e("scrollTo",S),e("scrollBy",p),v.jsx(a,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:b,style:{...m?Ki:Ui,...o},tabIndex:0,...i,...Ne(a,s),children:r})})}function gs({useEmitter:e,useEmitterValue:t,usePublisher:n}){return h.memo(function({children:r,style:o,context:s,...i}){const u=n("windowScrollContainerState"),a=t("ScrollerComponent"),l=n("smoothScrollTargetReached"),d=t("totalListHeight"),m=t("deviation"),p=t("customScrollParent"),b=h.useRef(null),S=t("scrollerRef"),{scrollByCallback:w,scrollerRef:c,scrollToCallback:f}=ds(u,l,a,S,p);return us(()=>{var g;return c.current=p||((g=b.current)==null?void 0:g.ownerDocument.defaultView),()=>{c.current=null}},[c,p]),e("windowScrollTo",f),e("scrollBy",w),v.jsx(a,{ref:b,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+m}:{}},...i,...Ne(a,s),children:r})})}const Ji=({children:e})=>{const t=h.useContext(as),n=Ze("viewportHeight"),r=Ze("fixedItemHeight"),o=le("alignToBottom"),s=le("horizontalDirection"),i=h.useMemo(()=>Ho(n,a=>pt(a,s?"width":"height")),[n,s]),u=Ct(i,!0,le("skipAnimationFrameInResizeObserver"));return h.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),v.jsx("div",{"data-viewport-type":"element",ref:u,style:xn(o),children:e})},el=({children:e})=>{const t=h.useContext(as),n=Ze("windowViewportRect"),r=Ze("fixedItemHeight"),o=le("customScrollParent"),s=Fo(n,o,le("skipAnimationFrameInResizeObserver")),i=le("alignToBottom");return h.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),v.jsx("div",{"data-viewport-type":"window",ref:s,style:xn(i),children:e})},tl=({children:e})=>{const t=le("TopItemListComponent")||"div",n=le("headerHeight"),r={...Xi,marginTop:`${n}px`},o=le("context");return v.jsx(t,{style:r,...Ne(t,o),children:e})},nl=h.memo(function(e){const t=le("useWindowScroll"),n=le("topItemsIndexes").length>0,r=le("customScrollParent"),o=le("context");return v.jsxs(r||t?sl:ol,{...e,context:o,children:[n&&v.jsx(tl,{children:v.jsx(Vr,{showTopList:!0})}),v.jsxs(r||t?el:Ji,{children:[v.jsx(Qi,{}),v.jsx(Vr,{}),v.jsx(Zi,{})]})]})}),{Component:rl,useEmitter:vr,useEmitterValue:le,usePublisher:Ze}=ls(Di,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},nl),ol=ps({useEmitter:vr,useEmitterValue:le,usePublisher:Ze}),sl=gs({useEmitter:vr,useEmitterValue:le,usePublisher:Ze}),il=rl,ll=he(()=>{const e=W(l=>v.jsxs("td",{children:["Item $",l]})),t=W(null),n=W(l=>v.jsxs("td",{colSpan:1e3,children:["Group ",l]})),r=W(null),o=W(null),s=W({}),i=W(xr),u=W(Ot),a=(l,d=null)=>Fe(H(s,Y(m=>m[l]),Ie()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:a("EmptyPlaceholder"),FillerRow:a("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:a("Scroller","div"),scrollerRef:u,ScrollSeekPlaceholder:a("ScrollSeekPlaceholder"),TableBodyComponent:a("TableBody","tbody"),TableComponent:a("Table","table"),TableFooterComponent:a("TableFoot","tfoot"),TableHeadComponent:a("TableHead","thead"),TableRowComponent:a("TableRow","tr"),GroupComponent:a("Group","tr")}});Te(is,ll);br();const qr={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},al={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Ur,floor:ln,max:Gt,min:On,round:Kr}=Math;function Xr(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function cl(e){return{...al,items:e}}function en(e,t){return e&&e.width===t.width&&e.height===t.height}function ul(e,t){return e&&e.column===t.column&&e.row===t.row}const dl=he(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:u,scrollTo:a,scrollTop:l,smoothScrollTargetReached:d,viewportHeight:m},p,b,{didMount:S,propsReady:w},{customScrollParent:c,useWindowScroll:f,windowScrollContainerState:g,windowScrollTo:C,windowViewportRect:T},M])=>{const E=W(0),x=W(0),y=W(qr),R=W({height:0,width:0}),k=W({height:0,width:0}),O=pe(),P=pe(),I=W(0),_=W(null),z=W({column:0,row:0}),N=pe(),B=pe(),$=W(!1),te=W(0),fe=W(!0),ge=W(!1),ve=W(!1);xe(H(S,de(te),se(([j,L])=>!!L)),()=>{ce(fe,!1)}),xe(H(Pe(S,fe,k,R,te,ge),se(([j,L,V,A,,Q])=>j&&!L&&V.height!==0&&A.height!==0&&!Q)),([,,,,j])=>{ce(ge,!0),pr(1,()=>{ce(O,j)}),nt(H(l),()=>{ce(t,[0,0]),ce(fe,!0)})}),ne(H(B,se(j=>j!=null&&j.scrollTop>0),it(0)),x),xe(H(S,de(B),se(([,j])=>j!=null)),([,j])=>{j&&(ce(R,j.viewport),ce(k,j.item),ce(z,j.gap),j.scrollTop>0&&(ce($,!0),nt(H(l,St(1)),L=>{ce($,!1)}),ce(a,{top:j.scrollTop})))}),ne(H(R,Y(({height:j})=>j)),m),ne(H(Pe(oe(R,en),oe(k,en),oe(z,(j,L)=>j&&j.column===L.column&&j.row===L.row),oe(l)),Y(([j,L,V,A])=>({gap:V,item:L,scrollTop:A,viewport:j}))),N),ne(H(Pe(oe(E),r,oe(z,ul),oe(k,en),oe(R,en),oe(_),oe(x),oe($),oe(fe),oe(te)),se(([,,,,,,,j])=>!j),Y(([j,[L,V],A,Q,F,X,ee,,Z,ie])=>{const{column:re,row:be}=A,{height:ue,width:ye}=Q,{width:ke}=F;if(ee===0&&(j===0||ke===0))return qr;if(ye===0){const ut=gr(ie,j),zt=ut+Math.max(ee-1,0);return cl(Xr(ut,zt,X))}const ze=hs(ke,ye,re);let Ee,Le;Z?L===0&&V===0&&ee>0?(Ee=0,Le=ee-1):(Ee=ze*ln((L+be)/(ue+be)),Le=ze*Ur((V+be)/(ue+be))-1,Le=On(j-1,Gt(Le,ze-1)),Ee=On(Le,Gt(0,Ee))):(Ee=0,Le=-1);const ot=Xr(Ee,Le,X),{bottom:De,top:je}=Yr(F,A,Q,ot),et=Ur(j/ze),Ye=et*ue+(et-1)*be-De;return{bottom:De,itemHeight:ue,items:ot,itemWidth:ye,offsetBottom:Ye,offsetTop:je,top:je}})),y),ne(H(_,se(j=>j!==null),Y(j=>j.length)),E),ne(H(Pe(R,k,y,z),se(([j,L,{items:V}])=>V.length>0&&L.height!==0&&j.height!==0),Y(([j,L,{items:V},A])=>{const{bottom:Q,top:F}=Yr(j,A,L,V);return[F,Q]}),Ie(Nt)),t);const me=W(!1);ne(H(l,de(me),Y(([j,L])=>L||j!==0)),me);const Be=Xe(H(Pe(y,E),se(([{items:j}])=>j.length>0),de(me),se(([[j,L],V])=>{const A=j.items[j.items.length-1].index===L-1;return(V||j.bottom>0&&j.itemHeight>0&&j.offsetBottom===0&&j.items.length===L)&&A}),Y(([[,j]])=>j-1),Ie())),K=Xe(H(oe(y),se(({items:j})=>j.length>0&&j[0].index===0),it(0),Ie())),D=Xe(H(oe(y),de($),se(([{items:j},L])=>j.length>0&&!L),Y(([{items:j}])=>({endIndex:j[j.length-1].index,startIndex:j[0].index})),Ie(Uo),ct(0)));ne(D,b.scrollSeekRangeChanged),ne(H(O,de(R,k,E,z),Y(([j,L,V,A,Q])=>{const F=Zo(j),{align:X,behavior:ee,offset:Z}=F;let ie=F.index;ie==="LAST"&&(ie=A-1),ie=Gt(0,ie,On(A-1,ie));let re=or(L,Q,V,ie);return X==="end"?re=Kr(re-L.height+V.height):X==="center"&&(re=Kr(re-L.height/2+V.height/2)),Z&&(re+=Z),{behavior:ee,top:re}})),a);const G=Fe(H(y,Y(j=>j.offsetBottom+j.bottom)),0);return ne(H(T,Y(j=>({height:j.visibleHeight,width:j.visibleWidth}))),R),{customScrollParent:c,data:_,deviation:I,footerHeight:o,gap:z,headerHeight:s,increaseViewportBy:e,initialItemCount:x,itemDimensions:k,overscan:n,restoreStateFrom:B,scrollBy:i,scrollContainerState:u,scrollHeight:P,scrollTo:a,scrollToIndex:O,scrollTop:l,smoothScrollTargetReached:d,totalCount:E,useWindowScroll:f,viewportDimensions:R,windowScrollContainerState:g,windowScrollTo:C,windowViewportRect:T,...b,gridState:y,horizontalDirection:ve,initialTopMostItemIndex:te,totalListHeight:G,...p,endReached:Be,propsReady:w,rangeChanged:D,startReached:K,stateChanged:N,stateRestoreInProgress:$,...M}},Te(hr,We,Xt,os,mt,mr,ht));function hs(e,t,n){return Gt(1,ln((e+n)/(ln(t)+n)))}function Yr(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=or(e,t,n,r[0].index);return{bottom:or(e,t,n,r[r.length-1].index)+o,top:s}}function or(e,t,n,r){const o=hs(e.width,n.width,t.column),s=ln(r/o),i=s*n.height+Gt(0,s-1)*t.row;return i>0?i+t.row:i}const fl=he(()=>{const e=W(m=>`Item ${m}`),t=W({}),n=W(null),r=W("virtuoso-grid-item"),o=W("virtuoso-grid-list"),s=W(xr),i=W("div"),u=W(Ot),a=(m,p=null)=>Fe(H(t,Y(b=>b[m]),Ie()),p),l=W(!1),d=W(!1);return ne(oe(d),l),{components:t,computeItemKey:s,context:n,FooterComponent:a("Footer"),HeaderComponent:a("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:a("Item","div"),itemContent:e,listClassName:o,ListComponent:a("List","div"),readyStateChanged:l,reportReadyState:d,ScrollerComponent:a("Scroller","div"),scrollerRef:u,ScrollSeekPlaceholder:a("ScrollSeekPlaceholder","div")}}),pl=he(([e,t])=>({...e,...t}),Te(dl,fl)),gl=h.memo(function(){const e=Re("gridState"),t=Re("listClassName"),n=Re("itemClassName"),r=Re("itemContent"),o=Re("computeItemKey"),s=Re("isSeeking"),i=Je("scrollHeight"),u=Re("ItemComponent"),a=Re("ListComponent"),l=Re("ScrollSeekPlaceholder"),d=Re("context"),m=Je("itemDimensions"),p=Je("gap"),b=Re("log"),S=Re("stateRestoreInProgress"),w=Je("reportReadyState"),c=Ct(h.useMemo(()=>f=>{const g=f.parentElement.parentElement.scrollHeight;i(g);const C=f.firstChild;if(C){const{height:T,width:M}=C.getBoundingClientRect();m({height:T,width:M})}p({column:Qr("column-gap",getComputedStyle(f).columnGap,b),row:Qr("row-gap",getComputedStyle(f).rowGap,b)})},[i,m,p,b]),!0,!1);return us(()=>{e.itemHeight>0&&e.itemWidth>0&&w(!0)},[e]),S?null:v.jsx(a,{className:t,ref:c,...Ne(a,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(f=>{const g=o(f.index,f.data,d);return s?v.jsx(l,{...Ne(l,d),height:e.itemHeight,index:f.index,width:e.itemWidth},g):h.createElement(u,{...Ne(u,d),className:n,"data-index":f.index,key:g},r(f.index,f.data,d))})})}),hl=h.memo(function(){const e=Re("HeaderComponent"),t=Je("headerHeight"),n=Re("headerFooterTag"),r=Ct(h.useMemo(()=>s=>{t(pt(s,"height"))},[t]),!0,!1),o=Re("context");return e?v.jsx(n,{ref:r,children:v.jsx(e,{...Ne(e,o)})}):null}),ml=h.memo(function(){const e=Re("FooterComponent"),t=Je("footerHeight"),n=Re("headerFooterTag"),r=Ct(h.useMemo(()=>s=>{t(pt(s,"height"))},[t]),!0,!1),o=Re("context");return e?v.jsx(n,{ref:r,children:v.jsx(e,{...Ne(e,o)})}):null}),bl=({children:e})=>{const t=h.useContext(cs),n=Je("itemDimensions"),r=Je("viewportDimensions"),o=Ct(h.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return h.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),v.jsx("div",{ref:o,style:xn(!1),children:e})},xl=({children:e})=>{const t=h.useContext(cs),n=Je("windowViewportRect"),r=Je("itemDimensions"),o=Re("customScrollParent"),s=Fo(n,o,!1);return h.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),v.jsx("div",{ref:s,style:xn(!1),children:e})},vl=h.memo(function({...e}){const t=Re("useWindowScroll"),n=Re("customScrollParent"),r=n||t?yl:Sl,o=n||t?xl:bl,s=Re("context");return v.jsx(r,{...e,...Ne(r,s),children:v.jsxs(o,{children:[v.jsx(hl,{}),v.jsx(gl,{}),v.jsx(ml,{})]})})}),{useEmitter:ms,useEmitterValue:Re,usePublisher:Je}=ls(pl,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},vl),Sl=ps({useEmitter:ms,useEmitterValue:Re,usePublisher:Je}),yl=gs({useEmitter:ms,useEmitterValue:Re,usePublisher:Je});function Qr(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ve.WARN),t==="normal"?0:parseInt(t??"0",10)}const vn=h.createContext(void 0);function Ce(e,t){const n=h.useContext(vn);if(!n)throw new Error("useAudioStore must be used within CRAudioProvider");return pn(n,e,t)}function an(){const e=h.useContext(vn);if(!e)throw new Error("useAudioStoreApi must be used within CRAudioProvider");return e}const wl="_run_zzb61_3",Cl="_runWrap_zzb61_7",Il="_highlight_zzb61_13",Tl="_highlightleft_zzb61_14",kl="_highlightright_zzb61_15",Rl="_highlightcenter_zzb61_16",_l="_underline_zzb61_48",Ml="_underlineleft_zzb61_49",El="_underlineright_zzb61_50",jl="_underlinecenter_zzb61_51",st={run:wl,runWrap:Cl,highlight:Il,highlightleft:Tl,highlightright:kl,highlightcenter:Rl,underline:_l,underlineleft:Ml,underlineright:El,underlinecenter:jl},Zr=e=>Symbol.iterator in e,Jr=e=>"entries"in e,eo=(e,t)=>{const n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(const[o,s]of n)if(!r.has(o)||!Object.is(s,r.get(o)))return!1;return!0},Ol=(e,t)=>{const n=e[Symbol.iterator](),r=t[Symbol.iterator]();let o=n.next(),s=r.next();for(;!o.done&&!s.done;){if(!Object.is(o.value,s.value))return!1;o=n.next(),s=r.next()}return!!o.done&&!!s.done};function zl(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:Zr(e)&&Zr(t)?Jr(e)&&Jr(t)?eo(e,t):Ol(e,t):eo({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function Vt(e){const t=h.useRef(void 0);return n=>{const r=e(n);return zl(t.current,r)?t.current:t.current=r}}function Pl(e){const t=e.replace("#",""),n=parseInt(t.length===3?t.repeat(2):t,16),r=n>>16&255,o=n>>8&255,s=n&255;return{r,g:o,b:s}}function Bl(e){const t=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);return t?{r:+t[1],g:+t[2],b:+t[3]}:null}const Al=Object.freeze({showPointer:void 0,pointerStyle:void 0,pointerColor:void 0}),bs=h.memo(function({runs:t,ns:n,baseIndex:r,preGroups:o}){const s=Ce(O=>O.setClipIndex),i=Ce(O=>O.seek),u=U(O=>O.setCurrentGlobalRunIndex),a=an(),l=U(O=>O.rangeStartGI),d=U(O=>O.rangeEndGI),m=U(O=>O.setRange),p=l!=null&&d!=null,b=h.useCallback(O=>{var te;const P=(te=O.target)==null?void 0:te.closest("[data-g]");if(!P)return;const I=Number(P.dataset.g),_=I-r;if(_<0||_>=t.length)return;const z=t[_],N=z.text??"";if(!N.trim()||!/[가-힣a-zA-Z0-9]/.test(N))return;u(I,"program");const B=z.audioChunkIndex,$=z.audioTimeMs;B!=null&&$!=null&&(s(B),i($))},[t,r,i,s,u]),S=h.useRef(null),w=h.useRef(!1),c=h.useRef({x:0,y:0}),f=h.useCallback(O=>{var z;const P=(z=O.target)==null?void 0:z.closest("[data-g]");if(!P)return;const I=Number(P.dataset.g),_=I-r;_<0||_>=t.length||(w.current=!1,c.current={x:O.clientX,y:O.clientY},S.current&&(window.clearTimeout(S.current),S.current=null),S.current=window.setTimeout(()=>{a.getState().status!=="playing"&&(m(I,I),w.current=!0,S.current=null)},800))},[t,r,m,a]),g=h.useCallback(()=>{S.current&&(window.clearTimeout(S.current),S.current=null)},[]),C=h.useCallback(O=>{if(!S.current)return;const P=O.clientX-c.current.x,I=O.clientY-c.current.y;(Math.abs(P)>5||Math.abs(I)>5)&&g()},[g]),T=h.useCallback(()=>{g()},[g]),M=g,E=g,x=U(O=>O.clearRange),y=h.useCallback(O=>{var _;if(w.current){w.current=!1;return}const P=(_=O.target)==null?void 0:_.closest("[data-g]");if(!P)return;const I=Number(P.dataset.g);isNaN(I)||p&&l!=null&&d!=null&&(x(),O.stopPropagation())},[p,l,d,x]),R=o,k=r+t.length-1;return v.jsx("span",{onClick:y,onDoubleClick:b,onPointerDown:f,onPointerMove:C,onPointerUp:T,onPointerCancel:M,onPointerLeave:E,children:R.map((O,P)=>v.jsx(Ll,{ns:n,group:O,runs:t,paraLastG:k,rangeStartGI:l,rangeEndGI:d},`${n}/grp:${P}-${O.startG}`))})},(e,t)=>e.ns===t.ns&&e.baseIndex===t.baseIndex&&e.runs===t.runs&&e.sectionId===t.sectionId),Gl=h.memo(function(){const t=h.useCallback(r=>({showSplit:r.showSplit,slash:r.breakMarks.slash,breakGapPx:r.breakGapPx}),[]),n=J(Vt(t));return n.showSplit?v.jsxs(v.Fragment,{children:[v.jsx("span",{style:{display:"inline-block",width:n.breakGapPx/2}}),n.slash&&v.jsx("span",{children:" / "}),v.jsx("span",{style:{display:"inline-block",width:n.breakGapPx/2}})]}):null}),Ll=h.memo(function({ns:t,group:n,runs:r,paraLastG:o,rangeStartGI:s,rangeEndGI:i}){const u=h.useCallback(c=>{const f=c.currentGlobalRunIndex;return f!=null&&f>=n.startG&&f<=n.endG},[n]),a=U(Vt(u)),l=h.useCallback(c=>a?{showPointer:c.showPointer,pointerStyle:c.pointerStyle,pointerColor:c.pointerColor}:Al,[a]),d=J(Vt(l)),m=n.r0??0,p=n.len??Math.max(0,n.endG-n.startG+1),b=a&&d.showPointer&&d.pointerStyle!=="underline",S=a&&d.showPointer&&d.pointerStyle==="underline",w=b||S?{"--hl-color":d.pointerColor,"--ul-color":d.pointerColor,"--ul-thickness":"0.3em","--ul-offset":"0.35em"}:void 0;return v.jsx(v.Fragment,{children:Array.from({length:p}).map((c,f)=>{const C=r[m+f],T=n.startG+f,M=`${t}/run:${T}`,E=!!C.split&&T!==o;let x=`${st.runWrap}`;return b&&(p===1?x+=` ${st.highlight}`:f===0?x+=` ${st.highlightleft}`:f+1===p?x+=` ${st.highlightright}`:x+=` ${st.highlightcenter}`),S&&(p===1?x+=` ${st.underline}`:f===0?x+=` ${st.underlineleft}`:f+1===p?x+=` ${st.underlineright}`:x+=` ${st.underlinecenter}`),v.jsxs(h.Fragment,{children:[v.jsx("span",{className:x,style:w,children:v.jsx(Hl,{gi:n.startG,g:T,run:C,active:a,pointerCfg:d,isInRange:s!=null&&i!=null&&T>=s&&T<=i})}),E&&v.jsx(Gl,{})]},M)})})},(e,t)=>e.group===t.group&&e.runs===t.runs&&e.ns===t.ns&&e.rangeStartGI===t.rangeStartGI&&e.rangeEndGI===t.rangeEndGI),Hl=h.memo(function({gi:t,g:n,run:r,active:o,pointerCfg:s,isInRange:i}){const u=h.useMemo(()=>{const a={whiteSpace:"pre-wrap"};if(r.bold&&(a.fontWeight=700),r.italic&&(a.fontStyle="italic"),r.underline&&(a.textDecoration="underline"),o&&s.showPointer){const l=s.pointerColor;if(s.pointerStyle!=="underline"){a.backgroundColor=l;const d=l.startsWith("#")?Pl(l):Bl(l);d&&(.299*d.r+.587*d.g+.114*d.b)/255<.6&&(a.color="#fff")}}return i&&(a.boxShadow="inset 0 0 0 100px rgba(59, 130, 246, 0.3)"),a},[r.bold,r.italic,r.underline,o,s,i]);return v.jsx("span",{className:st.run,style:u,"data-g":n,"data-gi":t,"data-test":(r==null?void 0:r.audioChunkIndex)||-1,children:r.text||""})},(e,t)=>e.g===t.g&&e.run===t.run&&e.active===t.active&&e.pointerCfg===t.pointerCfg&&e.isInRange===t.isInRange);function Nl({block:e,computedMarker:t,ns:n,baseIndex:r,sectionId:o,preGroups:s}){var l;const i=e.list?e.list.level*24:0,u=((l=e.list)==null?void 0:l.kind)==="bullet"?e.list.glyph??"•":void 0,a=t??u;return v.jsxs("p",{style:{width:"100%",margin:"8px 0",paddingLeft:i,textAlign:e.textAlign,boxSizing:"border-box"},children:[e.list?v.jsx("span",{style:{minWidth:16,display:"inline-block",whiteSpace:"nowrap",userSelect:"none"},children:a||""}):null,v.jsx(bs,{preGroups:s,runs:e.runs,ns:n,baseIndex:r,sectionId:o})]})}const Fl=h.memo(Nl,(e,t)=>e.block===t.block&&e.computedMarker===t.computedMarker&&e.baseIndex===t.baseIndex&&e.ns===t.ns);function Wl(e,t){switch((t||"decimal").toLowerCase().replace(/[\s_-]+/g,"")){case"decimal":return String(e);case"decimalleadingzero":return e<10?`0${e}`:String(e);case"loweralpha":case"lowerlatin":return no(e,!1);case"upperalpha":case"upperlatin":return no(e,!0);case"lowerroman":return to(e,!1);case"upperroman":return to(e,!0);case"decimalenclosedcircle":return Dl(e);default:return String(e)}}function Dl(e){return e>=1&&e<=20?String.fromCharCode(9312+(e-1)):`(${e})`}function to(e,t=!0){if(e<=0)return"";const n=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];let r=e,o="";for(const[s,i]of n)for(;r>=s;)o+=i,r-=s;return t?o:o.toLowerCase()}function no(e,t=!1){let n=e,r="";for(;n>0;)n--,r=String.fromCharCode(97+n%26)+r,n=Math.floor(n/26);return t?r.toUpperCase():r}function Sr(e){const t=new Map;return{next(n,r){const o=`${n}-${r}`,s=(t.get(o)??0)+1;return t.set(o,s),s},reset(){t.clear()}}}function yr(e,t){const n=e.list;if(!n||n.kind!=="ordered")return;const r=t.next(n.numId??0,n.level),o=Wl(r,n.format),s=(n.format||"").toLowerCase();return!/enclosed|paren/.test(s)&&s!=="decimalleadingzero"?`${o}.`:o}function $l(e){return e.map(t=>t.type==="image"?0:t.runs.length)}function Vl(e){const t=new Array(e.length+1).fill(0);for(let n=0;n<e.length;n++)t[n+1]=t[n]+e[n];return t}function ql(e,t){const n=[];if(!e.length)return n;const r=(o,s,i)=>{n.push({splitIndex:i??o,runs:e.slice(o,s+1),startG:t+o,endG:t+s})};for(let o=0;o<e.length;o++){const s=e[o].splitIndex;if(s===void 0){r(o,o,void 0);continue}let i=o+1;for(;i<e.length&&e[i].splitIndex===s;)i++;r(o,i-1,s),o=i-1}return n}const Ul="_scroller_kqkmq_3",Kl={scroller:Ul},Xl=h.forwardRef(function({className:t,style:n,...r},o){return v.jsx("div",{ref:o,className:`${Kl.scroller}${t?" "+t:""}`,style:n,...r})}),sr=e=>/[가-힣a-zA-Z0-9]/.test(e),Yl=e=>((e==null?void 0:e.textContent)??"").trim(),cn=(e,t)=>e.querySelector(`[data-g="${t}"]`);function Ql(e,t=12,n=1.5,r=.5){if(!e)return-1;const o=e.getBoundingClientRect(),s=o.top+t;let i=-1,u=1/0,a=1/0,l=-1,d=1/0,m=1/0;const p=e.querySelectorAll("[data-g]");for(let b=0;b<p.length;b++){const S=p[b];if(!S||!S.isConnected)continue;const w=Yl(S);if(!w||!sr(w))continue;const c=S.getBoundingClientRect();if(c.height<=r||c.width<=r||c.bottom<=o.top||c.top>=o.bottom)continue;if(c.top<s){const C=Math.abs(c.top-s);(C<d||C===d&&(c.top<m||l!==-1&&Number(S.dataset.g)<l))&&(d=C,l=Number(S.dataset.g),m=c.top);continue}const f=Number(S.dataset.g);if(Number.isNaN(f))continue;c.top<a-n?(a=c.top,u=c.top,i=f):c.top<=a+n&&(c.top<u||c.top===u&&(i===-1||f<i))&&(u=c.top,i=f);const g=Math.abs(c.top-s);(g<d||g===d&&(c.top<m||l!==-1&&f<l))&&(d=g,l=f,m=c.top)}return i!==-1?i:l}const xs=async(e,t,{timeoutMs:n=1200,intervalMs:r=16}={})=>{const o=performance.now();let s=cn(e,t);for(;!s;){if(performance.now()-o>n)return null;await new Promise(i=>setTimeout(i,r)),s=cn(e,t)}return s},ro=e=>{const t=e.getBoundingClientRect(),n=t.top+t.height*.15,r=t.top+t.height*.8,o=Array.from(e.querySelectorAll("[data-g]"));let s=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;for(const u of o){const a=u.getBoundingClientRect();if(a.bottom<n||a.top>r||a.height<=0)continue;const l=Number(u.dataset.g);Number.isNaN(l)||(l<s&&(s=l),l>i&&(i=l))}return!Number.isFinite(s)||!Number.isFinite(i)?null:{first:s,last:i}},Zl=(e,t,{topPaddingRatio:n=.15,behavior:r="auto"}={})=>{const o=cn(e,t);if(!o)return!1;const s=e.getBoundingClientRect(),i=o.getBoundingClientRect(),u=s.height*n,a=i.top-(s.top+u);return e.scrollTo({top:e.scrollTop+a,behavior:r}),!0};function Jl(e,t=120){return new Promise(n=>{let r=null;const o=()=>{r!=null&&window.clearTimeout(r),r=window.setTimeout(()=>{e.removeEventListener("scroll",o,{capture:!0}),n()},t)};e.addEventListener("scroll",o,{passive:!0,capture:!0}),o()})}const zn=async(e,t,{topPaddingRatio:n=.15,behavior:r="smooth",quietMs:o=120}={})=>{if(!Zl(e,t,{topPaddingRatio:n,behavior:r}))return!1;await Jl(e,o);const i=cn(e,t);if(!i)return!1;const u=e.getBoundingClientRect(),a=i.getBoundingClientRect(),l=u.height*n,d=u.top+l,m=a.top-d;return Math.abs(m)<=1},ft=()=>new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>e())})}),wr=h.createContext(null);function vs(){const e=h.useContext(wr);if(!e)throw new Error("useQuizStoreApi must be used within QuizProgressProvider");return e}function Ue(e,t){const n=h.useContext(wr);if(!n)throw new Error("useQuizStore must be used within QuizProgressProvider");return pn(n,e,t)}const Ss=()=>{const e=U(l=>l.section),t=vs(),n=Ue(l=>l.retryAllowed),r=Ue(l=>l.previousResult),o=r!=null,s=e.quizzes;if(!s||!s.length)return null;const i=o?n?`퀴즈 다시 풀기 (${s.length})`:"퀴즈 결과 보기":`퀴즈 풀기 (${s.length})`,u=o&&!n?"#64748b":"#2563eb",a=o&&!n?"0 6px 16px rgba(100,116,139,0.3)":"0 6px 16px rgba(37,99,235,0.3)";return v.jsxs("button",{onClick:()=>{t.getState().openFromSection(e)},style:{width:300,background:u,color:"white",border:"none",borderRadius:"10px",padding:"14px 28px",fontSize:"16px",fontWeight:600,cursor:"pointer",boxShadow:a,transition:"all 0.15s ease"},children:[i,o&&!n&&v.jsxs("div",{style:{fontSize:"12px",fontWeight:400,marginTop:"4px",opacity:.8},children:["이미 풀었습니다 (",r.rate,"%)"]})]})},ea="_navBtn_1fciy_2",ta="_disabled_1fciy_26",na="_label_1fciy_32",Et={navBtn:ea,disabled:ta,label:na};var ys={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},oo=h.createContext&&h.createContext(ys),ra=["attr","size","title"];function oa(e,t){if(e==null)return{};var n=sa(e,t),r,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(o=0;o<s.length;o++)r=s[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function sa(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function un(){return un=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},un.apply(this,arguments)}function so(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function dn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?so(Object(n),!0).forEach(function(r){ia(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):so(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function ia(e,t,n){return t=la(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function la(e){var t=aa(e,"string");return typeof t=="symbol"?t:t+""}function aa(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function ws(e){return e&&e.map((t,n)=>h.createElement(t.tag,dn({key:n},t.attr),ws(t.child)))}function qe(e){return t=>h.createElement(ca,un({attr:dn({},e.attr)},t),ws(e.child))}function ca(e){var t=n=>{var{attr:r,size:o,title:s}=e,i=oa(e,ra),u=o||n.size||"1em",a;return n.className&&(a=n.className),e.className&&(a=(a?a+" ":"")+e.className),h.createElement("svg",un({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,r,i,{className:a,style:dn(dn({color:e.color||n.color},n.style),e.style),height:u,width:u,xmlns:"http://www.w3.org/2000/svg"}),s&&h.createElement("title",null,s),e.children)};return oo!==void 0?h.createElement(oo.Consumer,null,n=>t(n)):t(ys)}function io(e){return qe({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M18.464 2.114a.998.998 0 0 0-1.033.063l-13 9a1.003 1.003 0 0 0 0 1.645l13 9A1 1 0 0 0 19 21V3a1 1 0 0 0-.536-.886zM17 19.091 6.757 12 17 4.909v14.182z"},child:[]}]})(e)}function lo(e){return qe({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M5.536 21.886a1.004 1.004 0 0 0 1.033-.064l13-9a1 1 0 0 0 0-1.644l-13-9A.998.998 0 0 0 5 3v18a1 1 0 0 0 .536.886zM7 4.909 17.243 12 7 19.091V4.909z"},child:[]}]})(e)}const ua=({isIcon:e=!0})=>{const t=U(i=>i.isCanPrev),n=U(i=>i.onSectionNav),r=!t,o=h.useCallback(i=>{i.stopPropagation(),i.preventDefault(),t&&(n==null||n("prev"))},[t,n]),s=t?"이전 섹션으로":"이전 섹션 없음";return e?v.jsxs("button",{type:"button",className:`${Et.navBtn} ${r?Et.disabled:""}`,disabled:r,title:s,onMouseDown:o,onClick:i=>i.stopPropagation(),onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&o(i)},children:[v.jsx(io,{size:18}),v.jsx("span",{className:Et.label,children:"이전"})]}):v.jsx("button",{type:"button",disabled:r,title:s,onClick:o,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&o(i)},style:{width:300,background:r?"#9ca3af":"#2563eb",color:"white",border:"none",borderRadius:"10px",padding:"14px 28px",fontSize:"16px",fontWeight:600,cursor:r?"not-allowed":"pointer",boxShadow:r?"none":"0 6px 16px rgba(37,99,235,0.3)",transition:"all 0.15s ease",opacity:r?.5:1},children:r?"첫섹션입니다":v.jsxs(v.Fragment,{children:[v.jsx(io,{size:18,style:{display:"inline",marginRight:"8px",verticalAlign:"middle"}}),"PrevSection"]})})},fn=({isIcon:e=!0})=>{const t=U(i=>i.isCanNext),n=U(i=>i.onSectionNav),r=!t,o=h.useCallback(i=>{i.stopPropagation(),i.preventDefault(),t&&(n==null||n("next"))},[t,n]),s=t?"다음 섹션으로":"다음 섹션 없음";return e?v.jsxs("button",{type:"button",className:`${Et.navBtn} ${r?Et.disabled:""}`,disabled:r,title:s,onMouseDown:o,onClick:i=>i.stopPropagation(),onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&o(i)},children:[v.jsx(lo,{size:18}),v.jsx("span",{className:Et.label,children:"다음"})]}):v.jsx("button",{type:"button",disabled:r,title:s,onClick:o,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&o(i)},style:{width:300,background:r?"#9ca3af":"#2563eb",color:"white",border:"none",borderRadius:"10px",padding:"14px 28px",fontSize:"16px",fontWeight:600,cursor:r?"not-allowed":"pointer",boxShadow:r?"none":"0 6px 16px rgba(37,99,235,0.3)",transition:"all 0.15s ease",opacity:r?.5:1},children:r?"마지막섹션입니다":v.jsxs(v.Fragment,{children:["NextSection",v.jsx(lo,{size:18,style:{display:"inline",marginLeft:"8px",verticalAlign:"middle"}})]})})};function Cs(e,t){let n=0,r=e.length-1;for(;n<r;){const o=Math.floor((n+r+1)/2);e[o]<=t?n=o:r=o-1}return n}function da({section:e,blocks:t,nsPrefix:n}){const r=h.useMemo(()=>{const R=[],k=Sr();return t.forEach((O,P)=>{O.type==="paragraph"&&(R[P]=yr(O,k))}),R},[t]),o=U(R=>{var k;return((k=R.layout)==null?void 0:k.prefix)??[]}),s=U(R=>{var k;return((k=R.derivedNav)==null?void 0:k.splitGroupsPerBlock)??[]}),i=J(R=>R.marginX),u=J(R=>R.viewportHeight),a=h.useRef({start:0,end:0}),l=h.useCallback(R=>{const k=t[R],O=`${n}blk-${k.id}`;if(k.type==="image"){const{src:_,alt:z,width:N,height:B}=k,$=N&&B?`${N} / ${B}`:"4 / 3",te=R>=a.current.start&&R<=a.current.end,fe=u>80?Math.floor((u-80)*.6):void 0;return v.jsxs("div",{style:{margin:"12px 0",textAlign:"center",width:"100%"},children:[v.jsx("div",{style:{position:"relative",width:"100%",maxHeight:fe,aspectRatio:$},children:v.jsx("img",{src:_,alt:z||"",loading:te?"eager":"lazy",style:{pointerEvents:"none",position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"contain",display:"block"}})}),z&&v.jsx("div",{style:{fontSize:12,color:"#6b7280",marginTop:4},children:z})]})}const P=r[R]??void 0,I=s[R];return v.jsx("div",{style:{maxWidth:860,display:"flex"},children:v.jsx(Fl,{block:k,computedMarker:P,ns:O,baseIndex:o[R],sectionId:e.section_id,preGroups:I})})},[t,r,o,n,e,s,u]),d=h.useRef(null),m=h.useCallback(R=>{d.current=R},[]),p=h.useMemo(()=>h.memo(R=>{const{style:k,children:O,...P}=R;return v.jsx("div",{...P,style:k,children:v.jsx("div",{style:{boxSizing:"border-box",paddingRight:`${i}px`,paddingLeft:`${i}px`,maxWidth:860,margin:"0 auto",width:"100%",height:"100%"},children:O})})}),[i]),b=h.useRef(null),S=h.useMemo(()=>t.map(R=>R.id),[t]),[w,c]=h.useState(!1);h.useEffect(()=>{c(!1)},[t]);const f=h.useCallback(()=>{c(!0)},[]),g=h.useCallback(()=>{if(!w)return v.jsx("div",{style:{height:40}});const R=e.quizzes,k=Math.max(80,Math.floor(u*.5));return R&&R.length?v.jsxs("div",{style:{display:"block"},children:[v.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:20},children:v.jsx(Ss,{})}),v.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:20},children:v.jsx(fn,{isIcon:!1})}),v.jsx("div",{style:{height:k,width:"100%"}})]}):v.jsxs("div",{children:[v.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:20},children:v.jsx(fn,{isIcon:!1})}),v.jsx("div",{style:{height:40}})]})},[w,e,u]),C=h.useMemo(()=>({Item:p,Header:()=>v.jsx("div",{style:{height:40}}),Footer:g,Scroller:Xl}),[g,p]),T=h.useCallback(R=>S[R],[S]),M=vt(),[E]=h.useState(()=>M.getState().progress.currentGlobalRunIndex??0),x=h.useMemo(()=>{if(!o.length)return 0;const R=o[o.length-1],k=Math.max(0,Math.min(E,R));return Cs(o,k)},[o,E]);console.log("SectionRenderVirtuoso확인");const y=vt();return h.useEffect(()=>{let R=!1;return(async()=>{let k=d.current;if(!k){for(let _=0;_<20;_++){if(await new Promise(z=>setTimeout(z,50)),R)return;if(k=d.current,k)break}if(!k)return}const O=y.getState().progress.currentGlobalRunIndex,P=y.getState().progress.setSectionLoading,I=O!=null&&O>=0?O:0;await xs(k,I),!R&&(await ft(),await ft(),await ft(),await ft(),!R&&P(!1))})(),()=>{R=!0}},[d,y]),v.jsxs(v.Fragment,{children:[v.jsx(il,{ref:b,style:{height:"100%",width:"100%",boxSizing:"border-box"},defaultItemHeight:99,computeItemKey:T,totalCount:t.length,itemContent:l,initialTopMostItemIndex:x,increaseViewportBy:{top:200,bottom:200},endReached:f,components:C,scrollerRef:m}),v.jsx(fa,{scrollContainerRef:d,virtRef:b,prefix:o})]})}const fa=({scrollContainerRef:e,virtRef:t,prefix:n})=>{const r=U(I=>I.setCurrentGlobalRunIndex),o=U(I=>I.registerSectionScrollApi),s=U(I=>I.currentGlobalRunIndex),i=Ce(I=>I.scrollLock),u=Ce(I=>I.syncToGI),a=wt(),l=h.useRef(!1),d=h.useRef(null),m=h.useRef(null),p=h.useRef(null),b=h.useRef(-1),S=h.useCallback(()=>{if(i)return;d.current=null;const I=m.current;if(!I)return;const _=Ql(I,5);_!==-1&&_!==b.current&&(b.current=_,u(_),r(_,"scroll"))},[i,u,r]),w=h.useCallback(I=>{m.current=I,d.current==null&&(d.current=requestAnimationFrame(S))},[S]),c=h.useCallback(I=>{m.current=I,p.current!=null&&(window.clearTimeout(p.current),p.current=null),p.current=window.setTimeout(()=>{p.current=null,S();const _=b.current;if(_===-1)return;const z=I.scrollTop,N=I.scrollHeight-I.clientHeight,B=N>0?z/N:0;let $=0;const te=I.querySelector(`[data-g="${_}"]`);if(te){const fe=I.getBoundingClientRect();$=(te.getBoundingClientRect().top-fe.top)/fe.height}a.getState().emit({type:"scroll",payload:{scrollTop:z,scrollRatio:B,anchorGI:_,anchorOffsetRatio:$}})},100)},[S,a]),f=h.useRef(!1),g=h.useCallback(I=>{i||l.current&&(f.current||(w(I),c(I)))},[i,w,c]),C=h.useRef(void 0),T=h.useRef(void 0),M=h.useRef(void 0),E=h.useRef(void 0);h.useEffect(()=>{const I=e.current;if(I)return C.current=()=>{l.current=!0},T.current=()=>{l.current=!0},M.current=()=>{l.current=!0},E.current=()=>g(I),I.addEventListener("wheel",C.current,{passive:!0}),I.addEventListener("touchmove",T.current,{passive:!0}),window.addEventListener("keydown",M.current,{passive:!0}),I.addEventListener("scroll",E.current,{passive:!0}),()=>{I.removeEventListener("wheel",C.current),I.removeEventListener("touchmove",T.current),window.removeEventListener("keydown",M.current),I.removeEventListener("scroll",E.current),d.current!=null&&cancelAnimationFrame(d.current),p.current!=null&&(clearTimeout(p.current),p.current=null)}},[g,e]),h.useEffect(()=>{const I=e.current;if(!I||!i)return;const _=$=>{$.preventDefault(),$.stopPropagation(),l.current=!1},z=$=>{$.preventDefault(),$.stopPropagation(),l.current=!1},N=$=>{["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes($.key)&&($.preventDefault(),$.stopPropagation(),l.current=!1)},B={overscrollBehavior:I.style.overscrollBehavior,touchAction:I.style.touchAction};return I.style.overscrollBehavior="contain",I.style.touchAction="none",I.addEventListener("wheel",_,{passive:!1}),I.addEventListener("touchmove",z,{passive:!1}),window.addEventListener("keydown",N,{passive:!1}),()=>{I.removeEventListener("wheel",_),I.removeEventListener("touchmove",z),window.removeEventListener("keydown",N),I.style.overscrollBehavior=B.overscrollBehavior,I.style.touchAction=B.touchAction}},[i,e]);const x=h.useRef({first:-1,last:-1}),y=h.useRef(!1),R=h.useCallback(()=>{const I=e.current;if(!I)return;const _=ro(I),z=(_==null?void 0:_.first)??-1,N=(_==null?void 0:_.last)??-1;x.current={first:z,last:N}},[e]),k=h.useRef(!1),O=h.useCallback(()=>{const I=e.current;if(!I||k.current)return;k.current=!0;const _=Math.min(I.scrollTop+Math.floor(I.clientHeight*.6),I.scrollHeight-I.clientHeight);requestAnimationFrame(()=>{I.scrollTo({top:_,behavior:"instant"})})},[e]);h.useEffect(()=>{!y.current&&i&&(k.current=!1,R()),y.current=i},[i,R]),h.useEffect(()=>{if(i!==!0)return;const I=e.current;if(!I)return;const{first:_,last:z}=x.current;if(_===-1||z===-1){O();return}if(I.scrollTop<=1){(async()=>{try{f.current=!0,await zn(I,s,{behavior:"smooth",topPaddingRatio:.2})}finally{f.current=!1}R()})();return}if(s<_||s>z){async function B(){if(!I)return;const $=I.scrollTop<=1?0:.2;return await zn(I,s,{behavior:"smooth",topPaddingRatio:$})}B().then($=>{$?R():O()})}},[i,s,O,R,e]);const P=h.useCallback(()=>{const I=e.current;if(!I)return;function _(G,j,L=.2,V=.8){const A=G.querySelector(`[data-g="${j}"]`);if(!A)return!1;const Q=G.getBoundingClientRect(),F=A.getBoundingClientRect();if(F.height<=0||Q.height<=0)return!1;const X=(F.top+F.height/2-Q.top)/Q.height;return X>=L&&X<=V}const z=G=>G==="instant"?"auto":G,N=G=>{const j=I.scrollTop,L=I.scrollHeight-I.clientHeight,V=L>0?j/L:0;let A=0;const Q=I.querySelector(`[data-g="${G}"]`);if(Q){const F=I.getBoundingClientRect();A=(Q.getBoundingClientRect().top-F.top)/F.height}a.getState().emit({type:"scroll",payload:{scrollTop:j,scrollRatio:V,anchorGI:G,anchorOffsetRatio:A}})},B=async(G,j="smooth")=>{var V;const L=Cs(n,G);(V=t.current)==null||V.scrollToIndex({index:L,align:"start",behavior:z(j)}),await xs(I,G)},$=()=>new Promise(G=>requestAnimationFrame(()=>G())),te=async G=>{if(_(I,G,.1,.7))return N(G),!0;f.current=!0;const j=I.querySelector(`[data-g="${G}"]`),L=I.getBoundingClientRect();let V=I.scrollTop<=1?0:.1;if(j){const Q=j.getBoundingClientRect();V=((Q.top+Q.height/2-L.top)/L.height>.5,.15)}const A=!!j;return A?(await zn(I,G,{behavior:"smooth",topPaddingRatio:V}),await $()):A||await B(G,"auto"),f.current=!1,N(G),_(I,G,.1,.7)},fe=async G=>te(G);return{ensureVisibleGI:te,scrollToGI:fe,getVisibleRange:()=>ro(I),getScrollTop:()=>I.scrollTop,setScrollTop:G=>{I.scrollTop=G},getAnchorOffsetRatio:G=>{const j=I.querySelector(`[data-g="${G}"]`);if(!j)return 0;const L=j.getBoundingClientRect(),V=I.getBoundingClientRect();return(L.top-V.top)/V.height},scrollToGIAtOffset:async(G,j)=>{await fe(G),await new Promise(Z=>requestAnimationFrame(()=>requestAnimationFrame(Z)));const L=I.querySelector(`[data-g="${G}"]`);if(!L)return;const V=L.getBoundingClientRect(),A=I.getBoundingClientRect(),Q=A.height>0?A.height/I.clientHeight:1,F=(V.top-A.top)/Q,X=j*I.clientHeight,ee=F-X;I.scrollTop=I.scrollTop+ee},getScrollRatio:()=>{const G=I.scrollHeight-I.clientHeight;return G>0?I.scrollTop/G:0}}},[e,t,n,a]);return h.useEffect(()=>(console.log("@@@@@빌드스크롤api"),o(P()),()=>o(void 0)),[P,o]),null};function pa(e){var r,o;const t=e;if(!t)return!1;const n=((o=(r=t.tagName)==null?void 0:r.toLowerCase)==null?void 0:o.call(r))??"";return!!(["a","button","input","textarea","select","label"].includes(n)||t.isContentEditable)}function ga(){const e=U(S=>S.section),t=J(S=>S.theme),n=J(S=>S.fontFamily),r=J(S=>S.fontSizePx),o=J(S=>S.lineHeight),s=on[t],{blocks:i,nsPrefix:u}=h.useMemo(()=>({sectionId:e.section_id,blocks:e.ast.blocks,nsPrefix:`sec-${e.section_id??"0"}/`}),[e]),a=gn(),l=h.useCallback(()=>{const{isSettingsOpen:S,setSettingsOpen:w,toggleOverlays:c}=a.getState();S?w(!1):c()},[a]),{onClick:d,onDoubleClick:m}=Ks({onSingle:l,onDouble:()=>{},delay:250,shouldIgnoreTarget:pa}),p=h.useMemo(()=>({flex:1,fontFamily:n,background:s.bg,color:s.fg,fontSize:r,lineHeight:o,overflow:"hidden",WebkitTextSizeAdjust:"none",MozTextSizeAdjust:"none",textSizeAdjust:"none"}),[n,s.bg,s.fg,r,o]),b=h.useMemo(()=>({margin:"0 auto",width:"100%",height:"100%"}),[]);return console.log("ScrollSectionWrap render"),v.jsx("div",{onClick:d,onDoubleClick:m,style:p,children:v.jsx("div",{style:b,children:v.jsx(da,{section:e,blocks:i,nsPrefix:u})})})}function ha(e){return qe({attr:{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM12.293 7.293a1 1 0 011.414 0L15 8.586l1.293-1.293a1 1 0 111.414 1.414L16.414 10l1.293 1.293a1 1 0 01-1.414 1.414L15 11.414l-1.293 1.293a1 1 0 01-1.414-1.414L13.586 10l-1.293-1.293a1 1 0 010-1.414z",clipRule:"evenodd"},child:[]}]})(e)}function ma(e){return qe({attr:{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM14.657 2.929a1 1 0 011.414 0A9.972 9.972 0 0119 10a9.972 9.972 0 01-2.929 7.071 1 1 0 01-1.414-1.414A7.971 7.971 0 0017 10c0-2.21-.894-4.208-2.343-5.657a1 1 0 010-1.414zm-2.829 2.828a1 1 0 011.415 0A5.983 5.983 0 0115 10a5.984 5.984 0 01-1.757 4.243 1 1 0 01-1.415-1.415A3.984 3.984 0 0013 10a3.983 3.983 0 00-1.172-2.828 1 1 0 010-1.415z",clipRule:"evenodd"},child:[]}]})(e)}function ba(e){return qe({attr:{viewBox:"0 0 544 512"},child:[{tag:"path",attr:{d:"M0 479.98L99.92 512l35.45-35.45-67.04-67.04L0 479.98zm124.61-240.01a36.592 36.592 0 0 0-10.79 38.1l13.05 42.83-50.93 50.94 96.23 96.23 50.86-50.86 42.74 13.08c13.73 4.2 28.65-.01 38.15-10.78l35.55-41.64-173.34-173.34-41.52 35.44zm403.31-160.7l-63.2-63.2c-20.49-20.49-53.38-21.52-75.12-2.35L190.55 183.68l169.77 169.78L530.27 154.4c19.18-21.74 18.15-54.63-2.35-75.13z"},child:[]}]})(e)}function xa(e){return qe({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M9.64 7.64c.23-.5.36-1.05.36-1.64 0-2.21-1.79-4-4-4S2 3.79 2 6s1.79 4 4 4c.59 0 1.14-.13 1.64-.36L10 12l-2.36 2.36C7.14 14.13 6.59 14 6 14c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4c0-.59-.13-1.14-.36-1.64L12 14l7 7h3v-1L9.64 7.64zM6 8c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2zm0 12c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2zm6-7.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.22.5-.5.5zM19 3l-6 6 2 2 7-7V3h-3z"},child:[]}]})(e)}function va(e){return qe({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z",opacity:".87"},child:[]},{tag:"path",attr:{d:"M17.51 3.87 15.73 2.1 5.84 12l9.9 9.9 1.77-1.77L9.38 12l8.13-8.13z"},child:[]}]})(e)}function Sa(e){return qe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"},child:[]},{tag:"path",attr:{d:"M12 18c-.328 0 -.652 -.017 -.97 -.05c-3.172 -.332 -5.85 -2.315 -8.03 -5.95c2.4 -4 5.4 -6 9 -6c3.465 0 6.374 1.853 8.727 5.558"},child:[]},{tag:"path",attr:{d:"M18 18m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"},child:[]},{tag:"path",attr:{d:"M20.2 20.2l1.8 1.8"},child:[]}]})(e)}function ya(e){return qe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},child:[]},{tag:"path",attr:{d:"M4 8v-2a2 2 0 0 1 2 -2h2"},child:[]},{tag:"path",attr:{d:"M4 16v2a2 2 0 0 0 2 2h2"},child:[]},{tag:"path",attr:{d:"M16 4h2a2 2 0 0 1 2 2v2"},child:[]},{tag:"path",attr:{d:"M16 20h2a2 2 0 0 0 2 -2v-2"},child:[]}]})(e)}const wa="_wrap_1hfub_4",Ca="_visible_1hfub_25",Ia="_compact_1hfub_31",Ta="_row2_1hfub_34",ka="_controls_1hfub_44",Ra="_row1_1hfub_52",_a="_groupExpand_1hfub_80",Ma="_groupPlayback_1hfub_81",Ea="_groupSpeed_1hfub_82",ja="_groupFeatures_1hfub_83",Oa="_groupNav_1hfub_84",za="_btn_1hfub_116",Pa="_btnForbidden_1hfub_141",Ba="_btnActive_1hfub_147",Aa="_label_1hfub_158",Ga="_compactBtn_1hfub_168",we={wrap:wa,visible:Ca,compact:Ia,row2:Ta,controls:ka,row1:Ra,groupExpand:_a,groupPlayback:Ma,groupSpeed:Ea,groupFeatures:ja,groupNav:Oa,btn:za,btnForbidden:Pa,btnActive:Ba,label:Aa,compactBtn:Ga},La=h.memo(function(){const t=h.useRef(null),n=h.useContext(yt),r=(n==null?void 0:n.getState().isPlaybackMode)??!1,o=Ce(y=>y.status),s=Ce(y=>y.currentTimeMs),i=Ce(y=>y.currentClip),u=Ce(y=>y.playbackKind),a=J(y=>y.muteAudio),l=J(y=>y.audioSpeed),d=Ce(y=>y.getClipSrc),m=Ce(y=>y._onTime),p=Ce(y=>y._onEnded),b=Ce(y=>y._onError),S=U(y=>y.setCurrentGlobalRunIndex),w=U(y=>y.getSectionScrollApi),c=U(y=>y.snapToReadable),f=U(y=>y.edgeReadable),g=h.useRef(null),C=h.useRef(null),T=h.useRef(!1),M=h.useRef(null);h.useEffect(()=>{u==="real"&&(T.current=!0)},[u]);const E=h.useMemo(()=>{const y=d(i);if(!y)return null;try{return new URL(y,window.location.href).href}catch{return y}},[i,d]);h.useEffect(()=>{T.current=!0},[E]),h.useEffect(()=>{const y=t.current;if(!y)return;const R=()=>{if(y.paused||y.ended)return;const P=y.currentTime*1e3;T.current&&P===0||(P>0&&(T.current=!1),m(P))},k=()=>{var I,_;p();const P=f(1);typeof P=="number"&&P>=0&&(S(P,"audio"),(_=(I=w())==null?void 0:I.ensureVisibleGI)==null||_.call(I,P))},O=P=>{const I=P.currentTarget;console.warn("Audio error",{networkState:I.networkState,readyState:I.readyState}),b()};return y.addEventListener("timeupdate",R),y.addEventListener("ended",k),y.addEventListener("error",O),()=>{y.removeEventListener("timeupdate",R),y.removeEventListener("ended",k),y.removeEventListener("error",O)}},[m,p,b,f,S,w]),h.useEffect(()=>{if(r)return;const y=t.current;if(!y)return;if(!E){try{y.pause()}catch(P){console.log("pause error",P)}C.current=null;return}const R=y.currentSrc||y.src||null,k=!R||R!==E;if(k){try{y.pause()}catch(P){console.log("pause error",P)}y.src=E;try{y.load()}catch(P){console.log("load error",P)}C.current=E}y.muted=!!a,y.volume=1,y.playbackRate=typeof l=="number"?l:1;const O=async()=>{k&&await new Promise(P=>{let I=!1;const _=()=>{I||(I=!0,y.removeEventListener("loadedmetadata",_),y.removeEventListener("canplay",_),P())};y.addEventListener("loadedmetadata",_),y.addEventListener("canplay",_),y.readyState>=1&&_()});try{await y.play()}catch(P){console.warn("el.play() failed",P)}};if(o==="loading"||o==="playing")O();else try{y.pause()}catch(P){console.log("pause error",P)}},[E,a,o,l,r]),h.useEffect(()=>{if(r)return;const y=t.current;if(!y||u!=="real")return;const R=s/1e3;if(Number.isFinite(R)){if(y.readyState<1){g.current=s;const k=()=>{if(g.current!=null){const O=g.current/1e3;try{y.currentTime=O}catch(P){console.log("currentTime보정 오류",P)}g.current=null}y.removeEventListener("loadedmetadata",k),y.removeEventListener("canplay",k)};y.addEventListener("loadedmetadata",k),y.addEventListener("canplay",k);return}if(Math.abs(y.currentTime-R)>.2)try{y.currentTime=R}catch(k){console.log("currentTime보정오류",k)}}},[s,u,r]);const x=Ce(y=>y.getGIFromCT);return h.useEffect(()=>{var k,O;if(r||u!=="real"||o!=="playing"&&o!=="loading")return;const y=x(i,s);if(y<0)return;const R=c(y);R!==M.current&&(M.current=R,S(R,"audio"),R%5===0&&((O=(k=w())==null?void 0:k.ensureVisibleGI)==null||O.call(k,R)))},[o,i,s,u,x,c,S,w,r]),v.jsx("audio",{ref:t,preload:"auto",style:{display:"none"}})});function Ha(){return v.jsx(La,{})}const Na="_scrubberWrap_uw0cd_2",Fa="_labels_uw0cd_9",Wa="_index_uw0cd_15",Da="_controls_uw0cd_19",$a="_percent_uw0cd_25",Va="_range_uw0cd_46",kt={scrubberWrap:Na,labels:Fa,index:Wa,controls:Da,percent:$a,range:Va};function qa(){const e=J(M=>M.isDev),t=U(M=>M.currentGlobalRunIndex),n=U(M=>M.totalRuns),r=U(M=>M.setCurrentGlobalRunIndex),o=U(M=>M.getSectionScrollApi),s=U(M=>M.giToPercentTotal),i=U(M=>M.percentToGITotal),u=U(M=>M.snapToReadable),a=Ce(M=>M.scrollLock),l=Ce(M=>M.pause),d=Ce(M=>M.play),m=Ce(M=>M.syncToGI),[p,b]=h.useState(()=>s(t||0));h.useEffect(()=>{b(s(t||0))},[t,s]);const S=h.useRef(!1),w=h.useMemo(()=>Math.max(0,Math.min(t??0,Math.max(0,(n??1)-1)))+1,[t,n]),c=h.useCallback(()=>{a&&(l(),S.current=!0)},[a,l]),f=h.useCallback(M=>{b(Number(M.currentTarget.value))},[]),g=h.useCallback(async()=>{const M=i(p),E=u(M);l(),r(E,"scrubber-commit"),m(E);const x=o();x!=null&&x.ensureVisibleGI&&await x.ensureVisibleGI(E),S.current&&(S.current=!1,d())},[p,i,u,l,r,m,o,d]),C=h.useMemo(()=>({"--pct":`${p}%`}),[p]),T=h.useMemo(()=>Math.round(p),[p]);return v.jsxs("div",{className:kt.scrubberWrap,children:[e&&v.jsx("div",{className:kt.labels,children:v.jsxs("span",{className:kt.index,children:[w," / ",n||0]})}),v.jsxs("div",{className:kt.controls,children:[v.jsx("input",{type:"range",className:kt.range,min:0,max:100,step:.5,value:p,style:C,onMouseDown:c,onTouchStart:c,onChange:f,onMouseUp:()=>{g()},onTouchEnd:()=>{g()},onKeyUp:M=>M.key==="Enter"||M.key===" "?void g():void 0,"aria-label":"진행률"}),v.jsxs("span",{className:kt.percent,children:[T,"%"]})]})]})}const Ua=h.memo(qa),Ka=h.memo(function(){const t=h.useContext(yt),n=(t==null?void 0:t.getState().isPlaybackMode)??!1,r=Ce(y=>y.playbackKind),o=Ce(y=>y.status),s=Ce(y=>y.fake),i=J(y=>y.audioSpeed),u=Ce(y=>y.pause),a=U(y=>y.totalRuns),l=U(y=>y.currentGlobalRunIndex),d=U(y=>y.setCurrentGlobalRunIndex),m=U(y=>y.getSectionScrollApi),p=U(y=>y.nextReadableFrom),b=U(y=>y.edgeReadable),S=h.useRef(null),w=h.useRef(null),c=h.useRef(0),f=h.useRef(-1),g=!n&&r==="fake"&&o==="playing",C=Math.max(1,(s==null?void 0:s.totalWords)??1),T=h.useMemo(()=>{const y=200*i;return C/y*6e4},[C,i]),M=h.useMemo(()=>!a||a<=1||T<=0?0:(a-1)/T,[a,T]);h.useEffect(()=>{if(!g)return;const y=Math.max(0,Math.min(l??0,Math.max(0,(a??1)-1)));c.current=y,f.current=y,w.current=null},[g,l,a]);const E=h.useRef(-1);h.useEffect(()=>{if(!a){E.current=-1;return}const y=b(1);E.current=y??-1},[b,a]);const x=h.useCallback(y=>{(async()=>{var N,B;if(!g){S.current=null;return}if(!a||a<=1||M<=0){S.current=null;return}const R=w.current;w.current=y;const k=R==null?0:Math.max(0,y-R),O=a-1;c.current=Math.min(O,c.current+M*k);const P=Math.floor(c.current),I=m(),_=p(P,1);if(_==null){const $=E.current>=0?E.current:P;$!==f.current&&(f.current=$,d($,"audio"),await((N=I==null?void 0:I.ensureVisibleGI)==null?void 0:N.call(I,$))),u(),S.current=null;return}const z=_;z!==f.current&&(f.current=z,d(z,"audio"),z%5===0&&await((B=I==null?void 0:I.ensureVisibleGI)==null?void 0:B.call(I,z))),S.current=requestAnimationFrame(x)})().catch(console.error)},[g,a,M,p,d,m,u]);return h.useEffect(()=>(g?S.current==null&&(S.current=requestAnimationFrame(x)):(S.current&&(cancelAnimationFrame(S.current),S.current=null),w.current=null),()=>{S.current&&(cancelAnimationFrame(S.current),S.current=null)}),[g,x]),null}),Xa=h.memo(function(){return v.jsx(Ka,{})}),Ya="data:image/svg+xml,%3csvg%20width='111'%20height='111'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20xml:space='preserve'%20overflow='hidden'%3e%3cg%20transform='translate(-435%2011)'%3e%3cpath%20d='M532.723%2046.8125C530.242%2046.8292%20527.8%2047.4292%20525.593%2048.5642%20523.298%2049.7713%20520.952%2050.8767%20518.608%2051.8815%20517.451%2031.9953%20500.391%2016.8128%20480.505%2017.9704%20462.359%2019.0268%20447.834%2033.4215%20446.615%2051.5578L438.476%2048.1353%20438.476%2049.9344C438.473%2054.7251%20441.432%2059.0185%20445.91%2060.721%20446.509%2060.9604%20447.138%2061.1708%20447.767%2061.3801%20448.053%2061.4761%20448.339%2061.5709%20448.622%2061.6692L447.745%2066.7254C447.463%2068.2415%20447.818%2069.8071%20448.728%2071.0521%20449.635%2072.2874%20450.984%2073.1242%20452.493%2073.3877L452.768%2073.4282C453.011%2073.488%20453.259%2073.5198%20453.509%2073.523%20456.31%2073.5182%20458.699%2071.4953%20459.166%2068.7338L459.781%2064.8673C468.886%2066.8727%20478.184%2067.875%20487.508%2067.8562%20493.267%2067.8674%20499.021%2067.5125%20504.736%2066.7937%20504.893%2066.7613%20505.041%2066.7405%20505.184%2066.7231L505.562%2068.8379C505.986%2071.6231%20508.396%2073.6706%20511.213%2073.6375%20511.583%2073.648%20511.953%2073.5977%20512.307%2073.4883%20515.422%2072.958%20517.518%2070.0024%20516.988%2066.8869%20516.984%2066.8688%20516.981%2066.8509%20516.978%2066.833L516.758%2065.6767C522.066%2065.3125%20527.42%2065.3125%20532.607%2065.3125L532.723%2065.3125C537.831%2065.6255%20542.226%2061.7378%20542.539%2056.6292%20542.852%2051.5205%20538.965%2047.1255%20533.856%2046.8125%20533.479%2046.7894%20533.1%2046.7894%20532.723%2046.8125ZM516.326%2052.7256C511.914%2054.5082%20507.352%2055.8913%20502.693%2056.858L492.697%2041.007%20501.916%2026.3469C510.579%2032.4029%20515.911%2042.1631%20516.326%2052.7256ZM500.254%2057.3217C497.133%2057.8531%20493.977%2058.1542%20490.811%2058.2224L487.449%2058.2224C480.061%2058.2766%20472.682%2057.6921%20465.394%2056.4753L474.504%2042.1644%20490.692%2042.1644ZM482.602%2020.2188C488.73%2020.2155%20494.742%2021.8953%20499.981%2025.075L490.693%2039.8507%20474.491%2039.8195%20465.194%2025.0415C470.449%2021.8782%20476.468%2020.2107%20482.602%2020.2188ZM463.254%2026.2995%20472.504%2041.0023%20462.938%2056.0267C458.169%2055.1133%20453.47%2053.8672%20448.875%2052.2977%20449.378%2041.8709%20454.689%2032.2672%20463.254%2026.2995ZM456.876%2068.3719C456.595%2070.0115%20455.173%2071.2097%20453.509%2071.2094%20453.431%2071.2042%20453.354%2071.191%20453.278%2071.1701%20453.133%2071.1343%20452.984%2071.1101%20452.835%2071.0972%20451.94%2070.9264%20451.142%2070.4243%20450.601%2069.6912%20450.063%2068.9533%20449.853%2068.0254%20450.023%2067.1278L450.844%2062.3872%20457.525%2064.2962ZM514.123%2069.8103C513.566%2070.5637%20512.74%2071.0728%20511.817%2071.2313L511.657%2071.2718C511.514%2071.32%20511.363%2071.3392%20511.213%2071.3285%20509.525%2071.3698%20508.075%2070.1378%20507.844%2068.4656L507.486%2066.4688%20514.501%2065.8548%20514.701%2067.2527C514.87%2068.1485%20514.661%2069.0742%20514.123%2069.8103ZM532.723%2063%20532.607%2063C526.955%2063%20521.113%2063%20515.284%2063.4625L515.276%2063.4625%20515.276%2063.4625%20505.9%2064.2904%20504.36%2064.5078C498.77%2065.2064%20493.141%2065.5509%20487.508%2065.5391%20477.952%2065.5601%20468.425%2064.4858%20459.114%2062.3375L450.263%2059.8168%20446.738%2058.5658C443.792%2057.4525%20441.62%2054.9086%20440.982%2051.8237%20454.33%2057.5309%20470.023%2060.5383%20486.577%2060.5383%20486.868%2060.5383%20487.161%2060.5383%20487.452%2060.5383L490.828%2060.5383C500.421%2060.2575%20509.874%2058.1665%20518.689%2054.3755L518.797%2054.3304C521.437%2053.2216%20524.086%2051.9728%20526.649%2050.6235%20528.526%2049.6491%20530.608%2049.1354%20532.723%2049.125%20536.554%2048.8199%20539.908%2051.6785%20540.213%2055.5099%20540.518%2059.3414%20537.659%2062.6949%20533.828%2063%20533.46%2063.0293%20533.091%2063.0293%20532.723%2063Z'/%3e%3cpath%20d='M534.442%2053.75C534.442%2055.0272%20533.407%2056.0625%20532.13%2056.0625%20530.852%2056.0625%20529.817%2055.0272%20529.817%2053.75%20529.817%2052.4728%20530.852%2051.4375%20532.13%2051.4375%20533.407%2051.4375%20534.442%2052.4728%20534.442%2053.75Z'/%3e%3c/g%3e%3c/svg%3e",Qa="data:image/svg+xml,%3csvg%20width='159'%20height='159'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20xml:space='preserve'%20overflow='hidden'%3e%3cg%20transform='translate(-392%20-84)'%3e%3cpath%20d='M496.776%20189.601C496.122%20189.934%20495.77%20190.663%20495.916%20191.383L499.911%20210.219C500.074%20210.985%20500.75%20211.532%20501.533%20211.531L501.929%20211.531C503.729%20211.515%20505.222%20212.919%20505.319%20214.716%20505.389%20216.544%20503.964%20218.083%20502.136%20218.154%20502.093%20218.155%20502.05%20218.156%20502.006%20218.156L497.503%20218.156C495.941%20218.15%20494.594%20217.058%20494.263%20215.531L490.363%20197.147C490.174%20196.252%20489.294%20195.68%20488.4%20195.87%20488.399%20195.87%20488.399%20195.87%20488.399%20195.87%20488.174%20195.918%20487.962%20196.014%20487.776%20196.15L481.184%20200.898C479.925%20201.758%20478.809%20202.45%20477.776%20203.015%20476.998%20203.429%20476.669%20204.372%20477.022%20205.18%20477.402%20206.011%20478.385%20206.378%20479.217%20205.998%20479.253%20205.981%20479.288%20205.964%20479.322%20205.945%20480.618%20205.229%20481.877%20204.447%20483.094%20203.604L487.657%20200.313%20491.031%20216.213C491.677%20219.273%20494.376%20221.464%20497.503%20221.469L501.882%20221.469C505.577%20221.473%20508.587%20218.502%20508.631%20214.807%20508.608%20211.503%20506.158%20208.719%20502.883%20208.277L499.416%20191.93C502.051%20190.581%20506.719%20188.344%20509.619%20188.344%20515.225%20188.346%20520.812%20187.662%20526.252%20186.307%20530.081%20185.36%20533.152%20182.51%20534.381%20178.762L534.535%20178.295C535.676%20175.09%20535.323%20171.542%20533.573%20168.624L525.126%20154.2C522.254%20149.369%20517.625%20145.835%20512.207%20144.337%20512.364%20138.624%20511.516%20132.927%20509.7%20127.508%20504.714%20113.244%20488.452%20105.977%20487.761%20105.669%20487.336%20105.48%20486.851%20105.48%20486.426%20105.669%20485.959%20105.876%20484.987%20106.308%20483.1%20111.962%20482.811%20112.832%20483.281%20113.77%20484.15%20114.059%20485.019%20114.348%20485.958%20113.878%20486.247%20113.009%20486.649%20111.744%20487.129%20110.505%20487.685%20109.299%20491.474%20111.245%20502.818%20117.831%20506.566%20128.543%20508.418%20133.972%20509.183%20139.713%20508.815%20145.437%20508.734%20146.277%20509.297%20147.043%20510.122%20147.217%20515.212%20148.269%20519.626%20151.41%20522.287%20155.875L530.744%20170.299C532.007%20172.379%20532.256%20174.921%20531.42%20177.207L531.254%20177.727C530.378%20180.388%20528.194%20182.41%20525.474%20183.079%20520.288%20184.375%20514.964%20185.031%20509.619%20185.031%20505.93%20185.031%20501.061%20187.35%20496.776%20189.601Z'/%3e%3cpath%20d='M422.439%20192.966C421.946%20190.791%20421.681%20188.571%20421.649%20186.341%20421.7%20185.427%20421.001%20184.643%20420.086%20184.592%20419.171%20184.54%20418.388%20185.239%20418.336%20186.154%20418.324%20187.879%20418.47%20189.602%20418.772%20191.3%20412.577%20189.633%20408.907%20183.26%20410.574%20177.065%20411.942%20171.981%20416.559%20168.453%20421.824%20168.469%20422.661%20168.473%20423.491%20168.611%20424.284%20168.88%20425.056%20169.133%20425.898%20168.787%20426.271%20168.065%20435.26%20150.783%20455.639%20142.806%20473.971%20149.392%20474.837%20150.636%20475.5%20151.557%20475.559%20151.638%20476.094%20152.38%20477.129%20152.549%20477.872%20152.014%20478.614%20151.479%20478.782%20150.444%20478.248%20149.702%20478.216%20149.657%20475.101%20145.338%20473.444%20142.62%20467.845%20132.798%20470.283%20120.115%20471.358%20115.817%20475.617%20117.014%20487.816%20121.194%20493.442%20131.039%20496.082%20135.531%20497.921%20140.449%20498.876%20145.571%20499.017%20146.361%20499.705%20146.936%20500.508%20146.936L503.929%20146.936C504.816%20146.948%20505.561%20146.274%20505.639%20145.391%20505.7%20144.478%20505.01%20143.688%20504.097%20143.627%20504.059%20143.624%20504.021%20143.623%20503.982%20143.623L501.871%20143.623C500.778%20138.613%20498.902%20133.806%20496.312%20129.38%20488.742%20116.13%20471.271%20112.337%20470.533%20112.183%20469.704%20112.01%20468.879%20112.489%20468.618%20113.294%20468.385%20114.011%20463.013%20131.036%20470.568%20144.256%20470.579%20144.276%20470.745%20144.576%20470.978%20144.973%20470.99%20144.991%20470.978%20145.003%20470.96%20144.998%20452.498%20140.481%20433.287%20148.811%20423.966%20165.375%20423.261%20165.231%20422.543%20165.158%20421.824%20165.156%20413.582%20165.183%20406.923%20171.886%20406.95%20180.128%20406.974%20187.414%20412.256%20193.618%20419.446%20194.803L419.446%20194.803C419.532%20195.194%20419.611%20195.585%20419.706%20195.972L419.8%20196.329C422.428%20206.56%20428.796%20215.436%20437.646%20221.204%20437.917%20221.379%20438.232%20221.473%20438.554%20221.474L473.068%20221.474C476.748%20221.495%20479.756%20218.542%20479.801%20214.862%20479.847%20211.242%20476.95%20208.27%20473.329%20208.224%20473.278%20208.223%20473.227%20208.223%20473.176%20208.224L465.158%20208.224C474.765%20201.216%20476.873%20187.747%20469.866%20178.14%20465.812%20172.583%20459.348%20169.297%20452.47%20169.297%20450.573%20169.261%20448.682%20169.507%20446.858%20170.029%20445.981%20170.293%20445.484%20171.219%20445.749%20172.096%20446.013%20172.973%20446.938%20173.47%20447.816%20173.206%20449.328%20172.775%20450.897%20172.574%20452.47%20172.609%20462.532%20172.632%20470.67%20180.807%20470.648%20190.869%20470.63%20198.914%20465.337%20205.995%20457.626%20208.29%20456.784%20208.543%20456.286%20209.408%20456.491%20210.263%20456.686%20211.016%20457.369%20211.54%20458.147%20211.533L473.107%20211.533C474.951%20211.521%20476.458%20213.001%20476.48%20214.845%20476.52%20216.635%20475.102%20218.118%20473.312%20218.158%20473.264%20218.159%20473.216%20218.159%20473.168%20218.158L439.054%20218.158C431.004%20212.776%20425.251%20204.584%20422.922%20195.184%20422.853%20194.889%20422.795%20194.619%20422.733%20194.339Z'/%3e%3cpath%20d='M519.521%20163.831C519.708%20162.011%20518.383%20160.385%20516.563%20160.199%20514.743%20160.012%20513.117%20161.337%20512.931%20163.157%20512.744%20164.977%20514.069%20166.603%20515.889%20166.789%20516.113%20166.812%20516.339%20166.812%20516.563%20166.789%20518.126%20166.629%20519.361%20165.394%20519.521%20163.831Z'/%3e%3c/g%3e%3c/svg%3e",Za="_WPMSpeedButtonsWrap_r3byt_1",Ja="_btnWrap_r3byt_7",ec="_label_r3byt_14",tc="_iconBtn_r3byt_22",Pt={WPMSpeedButtonsWrap:Za,btnWrap:Ja,label:ec,iconBtn:tc},ao=350,nc=40,rc=.85,oc=h.memo(function(){const t=J(p=>p.audioSpeed),n=J(p=>p.incAudioSpeed),r=J(p=>p.decAudioSpeed),o=h.useRef(null),s=h.useRef(ao),i=h.useRef(null),u=h.useCallback(p=>{const b=t;if(p==="inc"){if(b>=2)return!1;n()}else{if(b<=.3)return!1;r()}return!0},[t,n,r]),a=h.useCallback(()=>{i.current=null,o.current&&(clearTimeout(o.current),o.current=null)},[]),l=h.useCallback(()=>{i.current&&(s.current=Math.max(nc,Math.floor(s.current*rc)),o.current=window.setTimeout(()=>{u(i.current)?l():a()},s.current))},[u,a]),d=h.useCallback(p=>{if(i.current)return;i.current=p,s.current=ao,u(p)&&l();const S=()=>a();window.addEventListener("mouseup",S,{once:!0}),window.addEventListener("touchend",S,{once:!0})},[l,u,a]);h.useEffect(()=>a,[a]);const m=`${(t*100).toFixed(0)}%`;return v.jsx("div",{onMouseLeave:a,className:Pt.WPMSpeedButtonsWrap,children:v.jsxs("div",{className:Pt.btnWrap,children:[v.jsx("button",{className:Pt.iconBtn,type:"button",title:"속도 느리게",onMouseDown:()=>d("dec"),onTouchStart:p=>{p.preventDefault(),d("dec")},onMouseUp:a,children:v.jsx("img",{src:Ya,alt:"느리게"})}),v.jsx("div",{className:Pt.label,style:{minWidth:"44px",textAlign:"center"},children:v.jsx("div",{children:m})}),v.jsx("button",{className:Pt.iconBtn,type:"button",title:"속도 빠르게",onMouseDown:()=>d("inc"),onTouchStart:p=>{p.preventDefault(),d("inc")},onMouseUp:a,children:v.jsx("img",{src:Qa,alt:"빠르게"})})]})})}),sc="_StepBtn_15t0r_1",ic={StepBtn:sc};function lc(e){return qe({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M208,48V208a8,8,0,0,1-13.66,5.66L128,147.31V208a8,8,0,0,1-13.66,5.66l-80-80a8,8,0,0,1,0-11.32l80-80A8,8,0,0,1,128,48v60.69l66.34-66.35A8,8,0,0,1,208,48Z"},child:[]}]})(e)}function ac(e){return qe({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M221.66,133.66l-80,80A8,8,0,0,1,128,208V147.31L61.66,213.66A8,8,0,0,1,48,208V48a8,8,0,0,1,13.66-5.66L128,108.69V48a8,8,0,0,1,13.66-5.66l80,80A8,8,0,0,1,221.66,133.66Z"},child:[]}]})(e)}function co({direction:e}){const t=U(m=>m.currentGlobalRunIndex),n=U(m=>m.totalRuns),r=U(m=>m.hasReadableInDir),o=U(m=>m.computeStepTarget),s=U(m=>m.setCurrentGlobalRunIndex),i=Ce(m=>m.syncToGI),u=U(m=>m.getSectionScrollApi),a=h.useCallback(async m=>{var S,w;const p=Math.max(t,Math.min(0,Math.max(0,(n??1)-1))),b=o(p,m);s(b,"scrubber-step"),i(b),await((w=(S=u())==null?void 0:S.ensureVisibleGI)==null?void 0:w.call(S,b))},[t,n,o,s,i,u]),l=h.useMemo(()=>{const m=Math.max(t,Math.min(0,Math.max(0,(n??1)-1))),p=!n||!r(m,1),b=!n||!r(m,-1);return e==="left"?b:p},[e,n,t,r]),d=h.useCallback(()=>{a(e==="left"?-1:1)},[e,a]);return v.jsx("button",{className:ic.StepBtn,type:"button",onClick:d,disabled:l,title:e==="left"?"이전":"다음",children:e==="left"?v.jsx(lc,{}):v.jsx(ac,{})})}const cc="_GCPlayBtn_n54mc_1",uc="_playing_n54mc_34",uo={GCPlayBtn:cc,playing:uc},dc=({size:e=60,color:t="#333",bgColor:n="#fff",isPlaying:r,onClick:o,tooltip:s="재생",title:i=""})=>v.jsx("button",{className:`${uo.GCPlayBtn} ${r?uo.playing:""}`,onClick:o,"data-tip":s,title:i,style:{"--btn-size":`${e}px`,"--icon-color":t,"--btn-bg":n}});function fc(e){return qe({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 294.1L383 167c9.4-9.4 24.6-9.4 33.9 0s9.3 24.6 0 34L273 345c-9.1 9.1-23.7 9.3-33.1.7L95 201.1c-4.7-4.7-7-10.9-7-17s2.3-12.3 7-17c9.4-9.4 24.6-9.4 33.9 0l127.1 127z"},child:[]}]})(e)}function pc(e){return qe({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 217.9L383 345c9.4 9.4 24.6 9.4 33.9 0 9.4-9.4 9.3-24.6 0-34L273 167c-9.1-9.1-23.7-9.3-33.1-.7L95 310.9c-4.7 4.7-7 10.9-7 17s2.3 12.3 7 17c9.4 9.4 24.6 9.4 33.9 0l127.1-127z"},child:[]}]})(e)}function gc(){var R;const e=J(k=>k.showOverlays),t=U(k=>k.section),n=!!t.ast.isAddedSplit,r=!!((R=t.audios)!=null&&R.length),o=U(k=>k.canTracking),s=U(k=>k.canToggleShowGaze),i=U(k=>k.showGaze),u=U(k=>k.onToggleShowGaze),a=J(k=>k.muteAudio),l=J(k=>k.showPointer),d=J(k=>k.showSplit),m=J(k=>k.toggleMuteAudio),p=J(k=>k.toggleShowPointer),b=J(k=>k.toggleShowSplit),S=J(k=>k.overlayCompactMode),w=J(k=>k.toggleOverlayCompactMode),c=an(),f=vt();h.useEffect(()=>{const k=c.getState(),{syncToGI:O,useFake:P,useReal:I}=k,_=k.playbackKind,z=f.getState().progress.currentGlobalRunIndex??0;if(!r){_!=="fake"&&P();return}a?_!=="fake"&&(console.log("이부분일까?"),P()):_!=="real"&&(O(z),I())},[r,a,f,c]);const g=Ce(k=>k.play),C=Ce(k=>k.pause),T=Ce(k=>k.status),M=h.useCallback(k=>{k.stopPropagation(),T==="playing"||T==="loading"?C():g()},[T,g,C]),E=an(),x=vt(),y=h.useCallback(async k=>{var me,Be;if(k.stopPropagation(),T==="playing"||T==="loading"){C();return}const{progress:O}=x.getState(),{currentGlobalRunIndex:P,snapToReadable:I,edgeReadable:_,setCurrentGlobalRunIndex:z,getSectionScrollApi:N}=O,B=E.getState(),$=B.currentClip,te=N==null?void 0:N(),fe=typeof P=="number"?P:0,ge=typeof I=="function"?I(fe):fe,ve=typeof _=="function"?_(1):null;if(ve!=null&&ge>=ve){z==null||z(ve,"audio"),await((me=te==null?void 0:te.ensureVisibleGI)==null?void 0:me.call(te,ve)),B.syncToGI(ve);return}z==null||z(ge,"audio"),await((Be=te==null?void 0:te.ensureVisibleGI)==null?void 0:Be.call(te,ge)),B.syncToGI(ge),g($)},[T,C,g,E,x]);return v.jsxs("div",{className:`${we.wrap} ${e?we.visible:""} ${S?we.compact:""}`,onClick:k=>{k.stopPropagation()},onTouchStart:k=>{k.stopPropagation()},children:[!S&&v.jsx(Ua,{}),v.jsx("div",{style:S?{display:"none"}:void 0,children:r&&!a?v.jsx(Ha,{}):v.jsx(Xa,{})}),v.jsxs("div",{className:we.controls,children:[v.jsxs("div",{className:we.row1,children:[v.jsx("div",{className:we.groupExpand,children:v.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),w()},className:we.compactBtn,title:S?"오버레이 확대":"오버레이 축소",children:S?v.jsx(pc,{size:24}):v.jsx(fc,{size:24})})}),v.jsxs("div",{className:we.groupPlayback,children:[v.jsx(co,{direction:"left"}),v.jsx(dc,{size:34,isPlaying:T==="playing",onClick:a?y:M,title:T==="playing"?"일시정지":"재생"}),v.jsx(co,{direction:"right"})]}),v.jsx("div",{className:we.groupSpeed,children:v.jsx(oc,{})})]}),v.jsxs("div",{className:we.row2,children:[v.jsxs("div",{className:we.groupFeatures,children:[r&&v.jsxs("button",{type:"button",onClick:k=>{k.stopPropagation(),m()},className:`${we.btn} ${a?"":we.btnActive}`,title:"오디오북 음소거 전환",children:[a?v.jsx(ha,{size:18}):v.jsx(ma,{size:18}),v.jsx("span",{className:we.label,children:"오디오북"})]}),v.jsxs("button",{type:"button",onClick:k=>{k.stopPropagation(),p()},className:`${we.btn} ${l?we.btnActive:""}`,title:"포인터 표시",children:[v.jsx(ba,{size:18}),v.jsx("span",{className:we.label,children:"포인터"})]}),n&&v.jsxs("button",{type:"button",onClick:k=>{k.stopPropagation(),b()},disabled:!n,className:`${we.btn} ${d?we.btnActive:""} ${n?"":we.btnForbidden}`,title:"끊어읽기 표시",children:[v.jsx(xa,{size:18}),v.jsx("span",{className:we.label,children:"끊어읽기"})]}),v.jsxs("button",{type:"button",onClick:k=>{k.stopPropagation(),u==null||u()},disabled:!o||!s,className:`${we.btn} ${o&&i?we.btnActive:""} ${o?"":we.btnForbidden}`,title:"시선 표시",children:[v.jsx(Sa,{size:18}),v.jsx("span",{className:we.label,children:"시선"})]})]}),v.jsxs("div",{className:we.groupNav,children:[v.jsx(ua,{}),v.jsx(fn,{})]})]})]})]})}const hc=h.memo(gc);function mc(e){return qe({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"32",d:"M262.29 192.31a64 64 0 1 0 57.4 57.4 64.13 64.13 0 0 0-57.4-57.4zM416.39 256a154.34 154.34 0 0 1-1.53 20.79l45.21 35.46a10.81 10.81 0 0 1 2.45 13.75l-42.77 74a10.81 10.81 0 0 1-13.14 4.59l-44.9-18.08a16.11 16.11 0 0 0-15.17 1.75A164.48 164.48 0 0 1 325 400.8a15.94 15.94 0 0 0-8.82 12.14l-6.73 47.89a11.08 11.08 0 0 1-10.68 9.17h-85.54a11.11 11.11 0 0 1-10.69-8.87l-6.72-47.82a16.07 16.07 0 0 0-9-12.22 155.3 155.3 0 0 1-21.46-12.57 16 16 0 0 0-15.11-1.71l-44.89 18.07a10.81 10.81 0 0 1-13.14-4.58l-42.77-74a10.8 10.8 0 0 1 2.45-13.75l38.21-30a16.05 16.05 0 0 0 6-14.08c-.36-4.17-.58-8.33-.58-12.5s.21-8.27.58-12.35a16 16 0 0 0-6.07-13.94l-38.19-30A10.81 10.81 0 0 1 49.48 186l42.77-74a10.81 10.81 0 0 1 13.14-4.59l44.9 18.08a16.11 16.11 0 0 0 15.17-1.75A164.48 164.48 0 0 1 187 111.2a15.94 15.94 0 0 0 8.82-12.14l6.73-47.89A11.08 11.08 0 0 1 213.23 42h85.54a11.11 11.11 0 0 1 10.69 8.87l6.72 47.82a16.07 16.07 0 0 0 9 12.22 155.3 155.3 0 0 1 21.46 12.57 16 16 0 0 0 15.11 1.71l44.89-18.07a10.81 10.81 0 0 1 13.14 4.58l42.77 74a10.8 10.8 0 0 1-2.45 13.75l-38.21 30a16.05 16.05 0 0 0-6.05 14.08c.33 4.14.55 8.3.55 12.47z"},child:[]}]})(e)}const bc="_host_gafql_3",xc="_topbar_gafql_11",vc="_visible_gafql_32",Sc="_backBtn_gafql_37",yc="_title_gafql_58",wc="_calibrationBtn_gafql_67",Cc="_disabled_gafql_87",Ic="_settingsBtn_gafql_95",dt={host:bc,topbar:xc,visible:vc,backBtn:Sc,title:yc,calibrationBtn:wc,disabled:Cc,settingsBtn:Ic};function Tc(){const e=J(m=>m.showOverlays),t=J(m=>m.overlayCompactMode),n=U(m=>m.onViewerClose),o=U(m=>m.section).ast.title,s=U(m=>m.canTracking),i=U(m=>m.handleAskCalibration),u=J(m=>m.setSettingsOpen),a=J(m=>m.setShowOverlays),l=h.useCallback(()=>{n==null||n()},[n]),d=h.useCallback(()=>{u(!0),a(!1)},[u,a]);return v.jsx("div",{className:dt.host,children:v.jsxs("div",{className:`${dt.topbar} ${e&&!t?dt.visible:""}`,children:[v.jsx("button",{type:"button",className:dt.backBtn,onClick:l,"aria-label":"뒤로가기",children:v.jsx(va,{size:28})}),v.jsx("div",{className:dt.title,children:v.jsx("span",{className:"truncate",children:o||"섹션 없음"})}),v.jsx("button",{type:"button",className:`${dt.calibrationBtn} ${s?"":dt.disabled}`,onClick:i,disabled:!s,"aria-label":"시선보정",title:"시선보정",children:v.jsx(ya,{size:24})}),v.jsx("button",{type:"button",className:dt.settingsBtn,onClick:d,"aria-label":"뷰어 설정",children:v.jsx(mc,{size:28})})]})})}const kc=h.memo(Tc),Rc="_wrap_62su0_7",_c="_wrapHidden_62su0_29",Mc="_wrapVisible_62su0_35",Ec="_scrollArea_62su0_71",jc="_row_62su0_81",Oc="_label_62su0_89",zc="_btn_62su0_95",Pc="_btnActive_62su0_106",Bc="_btnSmall_62su0_110",Ac="_pill_62su0_122",Gc="_themeCircle_62su0_133",Lc="_themeCircleActive_62su0_146",Hc="_stepRow_62su0_151",Nc="_stepLabel_62su0_159",Fc="_levelBox_62su0_172",Wc="_inlineFlex_62su0_177",Me={wrap:Rc,wrapHidden:_c,wrapVisible:Mc,scrollArea:Ec,row:jc,label:Oc,btn:zc,btnActive:Pc,btnSmall:Bc,pill:Ac,themeCircle:Gc,themeCircleActive:Lc,stepRow:Hc,stepLabel:Nc,levelBox:Fc,inlineFlex:Wc};function Dc({visible:e}){const t=J(x=>x.mode),n=J(x=>x.setMode),r=J(x=>x.theme),o=J(x=>x.setTheme),s=J(x=>x.fontFamily),i=J(x=>x.setFontFamily),u=J(x=>x.resetToDefaults),a=J(x=>x.getFontLevel()),l=J(x=>x.getLineLevel()),d=J(x=>x.getMarginLevel()),m=J(x=>x.setFontLevel),p=J(x=>x.setLineLevel),b=J(x=>x.setMarginLevel),S=J(x=>x.pointerStyle),w=J(x=>x.setPointerStyle),c=J(x=>x.pointerColor),f=J(x=>x.setPointerColor),g=J(x=>x.breakMarks),C=J(x=>x.toggleBreakMark),T=J(x=>x.getBreakGapLevel()),M=J(x=>x.setBreakGapLevel),E=`${Me.wrap} ${e?Me.wrapVisible:Me.wrapHidden}`;return v.jsxs("div",{className:E,role:"dialog","aria-modal":"true","aria-label":"뷰어 설정",children:[v.jsxs("div",{className:Me.scrollArea,children:[v.jsx(Bt,{label:"열람방식",children:v.jsxs("div",{className:Me.inlineFlex,children:[v.jsx(Rt,{active:t==="page",onClick:()=>n("page"),children:"페이지"}),v.jsx(Rt,{active:t==="scroll",onClick:()=>n("scroll"),children:"스크롤"})]})}),v.jsx(Bt,{label:"테마",children:v.jsx("div",{className:Me.inlineFlex,children:Object.keys(on).map(x=>{const y=x,R=on[y];return v.jsx("button",{type:"button",onClick:()=>o(y),className:`${Me.themeCircle} ${r===x?Me.themeCircleActive:""}`,style:{background:R.bg,color:R.fg,fontFamily:s},title:String(x),"aria-label":`테마: ${String(x)}`,children:"A"},`${x}_tc_button`)})})}),v.jsx(Bt,{label:"글꼴",children:v.jsx("div",{className:Me.inlineFlex,children:Go.map(x=>v.jsx(Rt,{active:s===x.value,onClick:()=>i(x.value),title:x.value,children:x.label},x.label))})}),v.jsx(tn,{label:"글자 크기",level:a,min:1,max:12,onDec:()=>m(Math.max(1,a-1)),onInc:()=>m(Math.min(12,a+1))}),v.jsx(tn,{label:"줄 간격",level:l,min:1,max:7,onDec:()=>p(Math.max(1,l-1)),onInc:()=>p(Math.min(7,l+1))}),v.jsx(tn,{label:"여백",level:d,min:1,max:5,onDec:()=>b(Math.max(1,d-1)),onInc:()=>b(Math.min(5,d+1))}),v.jsx(Bt,{label:"포인터",children:v.jsxs("div",{className:Me.inlineFlex,children:[v.jsx(Rt,{active:S==="highlight",onClick:()=>w("highlight"),children:"형광펜"}),v.jsx(Rt,{active:S==="underline",onClick:()=>w("underline"),children:"밑줄"}),v.jsx("input",{type:"color",value:c,onChange:x=>f(x.target.value),"aria-label":"포인터 색상",style:{width:36,height:28,padding:0,border:"none",background:"transparent"}})]})}),v.jsx(Bt,{label:"끊기표시",children:v.jsx("div",{className:Me.inlineFlex,children:v.jsx(Rt,{active:g.slash,onClick:()=>C("slash"),children:"슬래쉬"})})}),v.jsx(tn,{label:"끊기간격",level:T,min:1,max:5,onDec:()=>M(Math.max(1,T-1)),onInc:()=>M(Math.min(5,T+1))})]}),v.jsx("div",{className:Me.inlineFlex,style:{justifyContent:"center"},children:v.jsx("button",{type:"button",onClick:u,className:Me.pill,children:"보기 설정 초기화"})})]})}function Bt({label:e,children:t}){return v.jsxs("div",{className:Me.row,children:[v.jsx("label",{className:Me.label,children:e}),t]})}function Rt({active:e,onClick:t,title:n,children:r}){return v.jsx("button",{type:"button",onClick:t,title:n,className:`${Me.btn} ${e?Me.btnActive:""}`,children:r})}function tn({label:e,level:t,min:n,max:r,onDec:o,onInc:s}){const i=t<=n,u=t>=r;return v.jsxs("div",{className:Me.stepRow,children:[v.jsx("label",{className:Me.stepLabel,children:e}),v.jsxs("div",{className:Me.inlineFlex,children:[v.jsx("button",{type:"button",onClick:o,disabled:i,className:Me.btnSmall,"aria-label":"감소",children:"−"}),v.jsx("div",{className:Me.levelBox,children:t}),v.jsx("button",{type:"button",onClick:s,disabled:u,className:Me.btnSmall,"aria-label":"증가",children:"+"})]})]})}const $c=h.memo(function(){const t=J(i=>i.showOverlays),n=J(i=>i.isSettingsOpen),r=U(i=>i.rangeStartGI),o=U(i=>i.rangeEndGI);return r!=null&&o!=null?null:v.jsxs("div",{"aria-hidden":!0,style:{pointerEvents:"none",position:"absolute",inset:0,containerType:"size",containerName:"viewer"},children:[v.jsx(kc,{}),v.jsx(hc,{}),v.jsx("div",{style:{pointerEvents:"auto"},children:v.jsx(Dc,{visible:!t&&n})})]})}),Vc=e=>(t,n,r)=>{const o=r.subscribe;return r.subscribe=((i,u,a)=>{let l=i;if(u){const d=(a==null?void 0:a.equalityFn)||Object.is;let m=i(r.getState());l=p=>{const b=i(p);if(!d(m,b)){const S=m;u(m=b,S)}},a!=null&&a.fireImmediately&&u(m,m)}return o(l)}),e(t,n,r)},qc=Vc;function Uc(e){return e?e.kind==="saved"?e.cdnUrl:e.blobUrl:null}function Kc(e){var o,s,i;if(!e||!/\S/.test(e))return 0;const t=((o=e.match(/[A-Za-z0-9]+(?:['’-][A-Za-z0-9]+)*/g))==null?void 0:o.length)??0,n=((s=e.match(/[\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A]+/g))==null?void 0:s.length)??0,r=((i=e.match(/[\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\u3040-\u30FF\u31FF\uAC00-\uD7AF\u1100-\u11FF\u3130-\u318F]/g))==null?void 0:i.length)??0;return t+n+Math.floor(r/2)}function Xc(e){let t=0;for(const n of e.ast.blocks??[])if(n.type==="paragraph")for(const r of n.runs??[])t+=Kc((r==null?void 0:r.text)??"");return t}function Yc(e){const t=e==null?void 0:e.recorderStore;let n=e==null?void 0:e.map,r=e==null?void 0:e.initialIndex;const o=b=>{if(!n)return null;const{g2ct:S}=n;if(!S)return null;const w=S[b];if(w)return{clip:w.clip,t:w.t};for(let c=1;c<=100&&b-c>=0;c++){const f=S[b-c];if(f)return{clip:f.clip,t:f.t}}for(let c=1;c<=100;c++){const f=S[b+c];if(f)return{clip:f.clip,t:f.t}}return null},s=(e==null?void 0:e.clips)??[];let i=0,u=0;const a=Math.max(1,Xc(e.section)||150);if(typeof(e==null?void 0:e.initialIndex)=="number"&&n){const b=o(e.initialIndex);b&&(i=b.clip,u=b.t,r=void 0)}const l=s.length>0,d=l?"paused":"idle",m=l?"real":"fake",p=l?null:{totalWords:a};return qt(qc((b,S)=>({clips:s,currentClip:Math.max(0,Math.min(i,Math.max(0,s.length-1))),currentTimeMs:Math.max(0,u),status:d,scrollLock:!1,playbackKind:m,fake:p,useFake:()=>b(w=>({playbackKind:"fake",fake:{totalWords:a},scrollLock:w.status==="playing"})),useReal:()=>b(w=>({playbackKind:"real",fake:{totalWords:a},scrollLock:w.status==="playing"})),injectMap:w=>{if(n=w,typeof r=="number"){const c=o(r);c&&b(f=>({currentClip:Math.max(0,Math.min(c.clip,Math.max(0,f.clips.length-1))),currentTimeMs:Math.max(0,c.t)})),r=void 0}},setClipAndMs:(w,c)=>b(f=>{const g=Math.max(0,f.clips.length-1);return{currentClip:Math.max(0,Math.min(w,g)),currentTimeMs:Math.max(0,c),status:f.status,scrollLock:f.scrollLock}}),setClips:w=>b(c=>{const f=Array.isArray(w)?w:[],g=f.length>0;return{clips:f,currentClip:0,currentTimeMs:0,status:g?"paused":"idle",playbackKind:g?"real":"fake",fake:g?null:c.fake??{totalWords:a},scrollLock:!1}}),clear:()=>b(w=>({clips:[],currentClip:0,currentTimeMs:0,status:"idle",playbackKind:"fake",fake:w.fake??{totalWords:a},scrollLock:!1})),play:(w,c)=>{t==null||t.getState().emit({type:"audio_control",payload:{action:"play"}}),b(f=>{if(f.playbackKind==="fake")return{status:"playing",scrollLock:!0};const g=typeof w=="number"?w:f.currentClip,C=typeof c=="number"?c:f.currentTimeMs;return{status:"loading",currentClip:Math.max(0,Math.min(g,Math.max(0,f.clips.length-1))),currentTimeMs:C,scrollLock:!0}})},pause:()=>{t==null||t.getState().emit({type:"audio_control",payload:{action:"pause"}}),b({status:"paused",scrollLock:!1})},seek:w=>b(c=>({currentTimeMs:Math.max(0,w),status:c.status})),stop:()=>b({status:"idle",currentTimeMs:0,scrollLock:!1}),nextClip:()=>b(w=>{if(w.playbackKind==="fake")return w;const c=Math.max(0,w.clips.length-1);return{currentClip:Math.min(w.currentClip+1,c),currentTimeMs:0,status:"loading",scrollLock:!0}}),prevClip:()=>b(w=>w.playbackKind==="fake"?w:{currentClip:Math.max(0,w.currentClip-1),currentTimeMs:0,status:"loading",scrollLock:!0}),setClipIndex:w=>b(c=>c.playbackKind==="fake"||w<0||w>=c.clips.length?c:{currentClip:w,currentTimeMs:0}),getClipSrc:w=>{const c=S();if(!c.clips.length)return null;const f=typeof w=="number"?w:c.currentClip;return Uc(c.clips[f])},getGIFromCT:(w,c)=>{if(!n)return-1;const f=n.byClip[w];if(!f||f.length===0)return-1;let g=0,C=f.length-1,T=0;for(;g<=C;){const M=g+C>>1;f[M].t<=c?(T=M,g=M+1):C=M-1}return f[Math.max(0,Math.min(T,f.length-1))].g},getCTFromGI:w=>{if(!n)return null;const{g2ct:c}=n;if(!c)return null;let f=c[w];if(!f){let g=w-1;const C=Math.max(0,w-100);for(;g>=C;){if(c[g]){f=c[g];break}g--}if(!f){let T=w+1;const M=w+100;for(;c[T]==null&&T<=M;)T++;c[T]&&(f=c[T])}}return f?{clip:f.clip,timeMs:f.t}:null},getMetaByGI:w=>{const c=S().getCTFromGI(w);return c?{clipIndex:c.clip,timeMs:c.timeMs}:null},syncToGI:w=>{const c=S().getMetaByGI(w);c&&S().setClipAndMs(c.clipIndex,c.timeMs)},_onTime:w=>b({currentTimeMs:w,status:"playing",scrollLock:!0}),_onEnded:()=>b(w=>{if(w.playbackKind==="fake")return{status:"ended",scrollLock:!1};const c=Math.max(0,w.clips.length-1);return w.currentClip>=c?{status:"ended",scrollLock:!1}:{currentClip:Math.min(w.currentClip+1,c),currentTimeMs:0,status:"loading",scrollLock:!0}}),_onError:()=>b({status:"error",scrollLock:!1}),_setStatusOnly:w=>b({status:w})})))}function Qc({children:e,initialState:t}){const n=h.useContext(yt)??void 0,r=h.useMemo(()=>Yc({...t,recorderStore:n}),[t,n]);return v.jsx(vn.Provider,{value:r,children:e})}function Zc(e){var s,i;const t={},n=[],r=((s=e==null?void 0:e.ast)==null?void 0:s.blocks)??[];let o=0;for(const u of r){if((u==null?void 0:u.type)==="image")continue;const a=(u==null?void 0:u.runs)??[];for(let l=0;l<a.length;l++){const d=a[l],m=o+l;d.audioChunkIndex!=null&&d.audioTimeMs!=null&&((t[i=d.audioChunkIndex]||(t[i]=[])).push({t:d.audioTimeMs,g:m}),n[m]={clip:d.audioChunkIndex,t:d.audioTimeMs})}o+=a.length}return Object.values(t).forEach(u=>u.sort((a,l)=>a.t-l.t)),{byClip:t,g2ct:n}}function Jc(e,t,n){if(n<=0)return-1;const r=Math.max(0,Math.min(t,n-1));if(e[r]===1)return r;for(let o=1;o<n;o++){const s=r-o;if(s>=0&&e[s]===1)return s;const i=r+o;return i<n&&e[i]===1?i:-1}return-1}function eu(e){const t=$l(e),n=Vl(t),r=t.reduce((d,m)=>d+(m||0),0),o=new Int32Array(Math.max(1,r)).fill(-1),s=new Uint8Array(Math.max(1,r)).fill(0),i=[],u=[];return e.forEach((d,m)=>{var c;if(d.type!=="paragraph")return;const p=n[m]??0,b=d.runs??[];for(let f=0;f<b.length;f++){const g=((c=b[f])==null?void 0:c.text)||"";sr(g)&&(s[p+f]=1)}const w=ql(b,p).map(f=>{var M;const g=f.startG-p,C=f.endG-f.startG+1;let T=-1;for(let E=0;E<C;E++){const x=((M=b[g+E])==null?void 0:M.text)??"";if(sr(x)){T=f.startG+E;break}}return{startG:f.startG,endG:f.endG,r0:g,len:C,firstReadableGI:T,splitIndex:f.splitIndex}});u[m]=w;for(const f of w){const g=i.length;for(let C=f.startG;C<=f.endG;C++)o[C]=g;i.push(f)}}),{nav:{groups:i,giToGroupIdx:o,readableGi:s,splitGroupsPerBlock:u},layout:{prefix:n,totalRuns:r}}}function tu(e){const{section:t,onViewerClose:n,onSectionNav:r,isCanPrev:o,isCanNext:s,canTracking:i,canToggleShowGaze:u,showGaze:a,onToggleShowGaze:l,handleAskCalibration:d,nav:m,layout:p,initialIndex:b,mountTime:S}=e,w=p.totalRuns??0,c=typeof b=="number"?b:w>0?0:-1,f=c>=0?Jc(m.readableGi,c,w):-1;return{section:t,sectionId:t.section_id,onViewerClose:n,onSectionNav:r,isCanPrev:o??!1,isCanNext:s??!1,canTracking:i??!1,canToggleShowGaze:u??!1,showGaze:a??!1,onToggleShowGaze:l,handleAskCalibration:d,currentGlobalRunIndex:f,lastUpdateBy:"program",totalRuns:w,pageIndex:0,totalPages:0,sectionLoading:!0,_loadingStartTime:S,_scrollApi:void 0,derivedNav:m,layout:p,rangeStartGI:null,rangeEndGI:null,translateOpen:!1,translateLoading:!1,translateText:void 0,translatedText:void 0,translateStartGI:void 0,translateEndGI:void 0}}function nu(e){const{section:t,initialIndex:n,onViewerClose:r,onSectionNav:o,isCanPrev:s,isCanNext:i,canTracking:u,canToggleShowGaze:a,showGaze:l,onToggleShowGaze:d,handleAskCalibration:m,eventBridgeStore:p}=e,b=t.ast.blocks,{nav:S,layout:w}=eu(b),c=Date.now(),f=tu({section:t,onViewerClose:r,onSectionNav:o,isCanPrev:s,isCanNext:i,canTracking:u,canToggleShowGaze:a,showGaze:l,onToggleShowGaze:d,handleAskCalibration:m,nav:S,layout:w,initialIndex:n,mountTime:c});return p&&queueMicrotask(()=>{p.getState().emit({type:"render_start",payload:{sectionId:t.section_id}},c),p.getState().emit({type:"loading_start",payload:{}},c)}),qt((g,C)=>{const T=K=>{g(D=>D.progress._scrollApi===K?D:{progress:{...D.progress,_scrollApi:K}})},M=()=>C().progress._scrollApi,E=K=>{g(D=>{const G=D.progress;if(G.totalRuns===K)return D;const j=G.currentGlobalRunIndex<0&&K>0;return{progress:{...G,totalRuns:K,currentGlobalRunIndex:j?0:G.currentGlobalRunIndex,lastUpdateBy:j?"program":G.lastUpdateBy}}})},x=(K,D="program")=>{const G=C().progress.currentGlobalRunIndex,j=C().progress,L=j.totalRuns>0?Math.max(-1,Math.min(K,j.totalRuns-1)):K;G===L&&j.lastUpdateBy===D||(g(V=>({progress:{...V.progress,currentGlobalRunIndex:L,lastUpdateBy:D}})),G!==L&&p&&p.getState().emit({type:"global_index_change",payload:{globalIndex:L}}))},y=K=>{const{sectionLoading:D,_loadingStartTime:G}=C().progress;if(D===K)return;const j=Date.now();if(K)g(L=>({progress:{...L.progress,sectionLoading:!0,_loadingStartTime:j}})),p&&p.getState().emit({type:"loading_start",payload:{}});else{const V=(G?j-G:0)/1e3;g(A=>({progress:{...A.progress,sectionLoading:!1,_loadingStartTime:null}})),p&&p.getState().emit({type:"loading_end",payload:{duration:V}})}},R=K=>{g(D=>({progress:{...D.progress,pageIndex:K}}))},k=K=>{g(D=>({progress:{...D.progress,totalPages:K}}))},O=(K,D)=>{const j=C().progress.rangeStartGI==null;if(g(L=>({progress:{...L.progress,rangeStartGI:Math.min(K,D),rangeEndGI:Math.max(K,D)}})),p){const L=_();p.getState().emit({type:j?"range_select":"range_change",payload:{startGI:Math.min(K,D),endGI:Math.max(K,D),text:L}})}},P=()=>{g(K=>({progress:{...K.progress,rangeStartGI:null,rangeEndGI:null}})),p&&p.getState().emit({type:"range_clear",payload:{}})},I=K=>{const{rangeStartGI:D,rangeEndGI:G}=C().progress;D==null||G==null||(K<D?g(j=>({progress:{...j.progress,rangeStartGI:K}})):K>G?g(j=>({progress:{...j.progress,rangeEndGI:K}})):P())},_=()=>{var Q;const{rangeStartGI:K,rangeEndGI:D,section:G,layout:j}=C().progress;if(K==null||D==null||!j)return"";const L=((Q=G.ast)==null?void 0:Q.blocks)??[],V=j.prefix,A=[];for(let F=0;F<L.length;F++){const X=L[F];if(X.type!=="paragraph")continue;const ee=X.runs??[],Z=V[F]??0;for(let ie=0;ie<ee.length;ie++){const re=Z+ie;re>=K&&re<=D&&A.push(ee[ie].text??"")}}return A.join("")},z=K=>{g(D=>({progress:{...D.progress,translateOpen:K.isOpen,translateLoading:K.isLoading??!1,translateText:K.text,translatedText:K.translatedText,translateStartGI:K.startGI,translateEndGI:K.endGI}}))},N=()=>{g(K=>({progress:{...K.progress,translateOpen:!1,translateLoading:!1,translateText:void 0,translatedText:void 0,translateStartGI:void 0,translateEndGI:void 0}}))},B=K=>{const{totalRuns:D,derivedNav:G}=C().progress,j=G==null?void 0:G.readableGi;if(!j||D<=0)return K;const L=D,V=Math.max(0,Math.min(K,L-1));if(j[V])return V;let A=V-1,Q=V+1;for(;A>=0||Q<L;){if(Q<L&&j[Q])return Q;if(A>=0&&j[A])return A;Q+=1,A-=1}return V},$=(K,D)=>{const{totalRuns:G,derivedNav:j}=C().progress,L=j==null?void 0:j.readableGi;if(!L||G<=0)return null;if(D>0){for(let V=Math.min(Math.max(K,0),G-1);V<G;V+=1)if(L[V])return V}else for(let V=Math.min(Math.max(K,0),G-1);V>=0;V-=1)if(L[V])return V;return null},te=K=>{const{totalRuns:D,derivedNav:G}=C().progress,j=G==null?void 0:G.readableGi;if(!j||D<=0)return null;if(K>0){for(let L=D-1;L>=0;L-=1)if(j[L])return L}else for(let L=0;L<D;L+=1)if(j[L])return L;return null};return{progress:{...f,registerSectionScrollApi:T,getSectionScrollApi:M,setTotalRuns:E,setCurrentGlobalRunIndex:x,setSectionLoading:y,setPageIndex:R,setTotalPages:k,setTranslateState:z,clearTranslate:N,setRange:O,clearRange:P,extendRange:I,getRangeText:_,snapToReadable:B,nextReadableFrom:$,edgeReadable:te,hasReadableInDir:(K,D)=>$(K+(D>0?1:-1),D)!=null,computeStepTarget:(K,D)=>{const{totalRuns:G,derivedNav:j}=C().progress;if(!G||G<=0)return K;const L=(j==null?void 0:j.groups)??[],V=j==null?void 0:j.giToGroupIdx;if(!L.length||!V){const Z=G-1;return B(Math.max(0,Math.min(K+D,Z)))}let A=V[K]??-1;if(A<0||A>=L.length)for(let ee=0;ee<L.length;ee+=1){const Z=L[ee];if(K>=Z.startG&&K<=Z.endG){A=ee;break}}if(A<0||A>=L.length)return te(D)??B(K);const Q=ee=>ee>=0&&ee<L.length&&(L[ee].firstReadableGI??-1)>=0;let F=A+D;for(;F>=0&&F<L.length&&!Q(F);)F+=D;if(F<0||F>=L.length)return te(D)??B(K+D);const X=L[F].firstReadableGI;return X>=0?X:B(K+D)},giToPercentTotal:K=>{const D=C().progress.totalRuns;return!D||D<=1?0:Math.max(0,Math.min(K,D-1))/(D-1)*100},percentToGITotal:K=>{const D=C().progress.totalRuns;if(!D||D<=1)return 0;const G=Math.max(0,Math.min(K,100)),j=Math.round(G/100*(D-1));return Math.max(0,Math.min(j,D-1))}}}})}function ru({children:e,initialState:t,gazeSync:n}){const r=h.useContext(yt),o=h.useMemo(()=>nu({...t,...n?n.getSnapshot():{},eventBridgeStore:r}),[t,r]);return h.useEffect(()=>{if(!n)return;const s=()=>{const i=n.getSnapshot(),u=o.getState().progress;u.canTracking===i.canTracking&&u.canToggleShowGaze===i.canToggleShowGaze&&u.showGaze===i.showGaze&&u.onToggleShowGaze===i.onToggleShowGaze&&u.handleAskCalibration===i.handleAskCalibration||o.setState(a=>({progress:{...a.progress,canTracking:i.canTracking,canToggleShowGaze:i.canToggleShowGaze,showGaze:i.showGaze,onToggleShowGaze:i.onToggleShowGaze,handleAskCalibration:i.handleAskCalibration}}))};return s(),n.subscribe(s)},[o,n]),v.jsx(lr.Provider,{value:o,children:e})}function ou({children:e,initialState:t}){const n=h.useContext(yt)??void 0,r=h.useRef(Ys({init:t,recorderStore:n}));return v.jsx(ir.Provider,{value:r.current,children:e})}const su=({pages:e,pageIndex:t,maxWidth:n})=>{const r=U(g=>g.section),o=h.useMemo(()=>{var g;return((g=r.ast)==null?void 0:g.blocks)??[]},[r]),s=J(g=>g.marginX),i=J(g=>g.lineHeight),u=J(g=>g.fontSizePx),a=J(g=>g.fontFamily),l=J(g=>g.viewportHeight),d=U(g=>{var C;return((C=g.layout)==null?void 0:C.prefix)??[]}),m=U(g=>{var C;return((C=g.derivedNav)==null?void 0:C.splitGroupsPerBlock)??[]}),p=e[t],b=h.useMemo(()=>{const g=[];return o.forEach((C,T)=>{(C.type==="paragraph"||C.type==="image")&&g.push(T)}),g},[o]),S=h.useMemo(()=>{if(!p)return[];const g=[];for(let C=p.startBlock;C<=p.endBlock;C++){const T=b[C];T!=null&&g.push(T)}return g},[p,b]),w=h.useMemo(()=>{const g=[];for(const C of S){const T=o[C];(T==null?void 0:T.type)==="paragraph"&&g.push({b:T,originalBlockIndex:C})}return g},[S,o]),c=h.useMemo(()=>{const g=[],C=Sr();return w.forEach((T,M)=>{g[M]=yr(T.b,C)}),g},[w]),f=(g,C,T)=>{if(!g||g.length===0)return[];const M=[];for(const E of g){const x=E.startG,y=E.endG;if(y<C||x>T)continue;const R=Math.max(x,C),k=Math.min(y,T),O=R-x|0,P=Math.max(0,k-R+1);if(P<=0)continue;const I=(E.r0??0)+O;M.push({...E,startG:R,endG:k,r0:I,len:P})}return M};return v.jsx("div",{style:{position:"relative",width:"100%",height:"100%",minHeight:0,display:"flex",alignItems:"stretch",justifyContent:"center",fontFamily:a,fontSize:u,lineHeight:i,boxSizing:"border-box"},children:v.jsxs("div",{style:{width:"100%",maxWidth:n,height:"100%",boxSizing:"border-box",overflow:"hidden",display:"flex",flexDirection:"column",margin:"0 auto"},children:[v.jsx("div",{style:{height:40}}),v.jsx("div",{style:{flex:1,overflow:"hidden"},children:S.map((g,C)=>{var G;const T=o[g],M=C===0,E=C===S.length-1,x={boxSizing:"border-box",paddingRight:`${s}px`,paddingLeft:`${s}px`,maxWidth:n,margin:"0 auto",display:"flex",width:"100%",height:"auto"},y=`sec-${r.section_id}/blk-${T.id??g}`;if(T.type==="image"){const{src:j,alt:L,width:V,height:A}=T,Q=V&&A?`${V} / ${A}`:"4 / 3",F=l>80?Math.floor((l-80)*.6):void 0;return v.jsx("div",{style:x,children:v.jsxs("div",{style:{margin:"12px 0",textAlign:"center",width:"100%"},children:[v.jsx("div",{style:{position:"relative",width:"100%",maxHeight:F,aspectRatio:Q},children:v.jsx("img",{src:j,alt:L||"",loading:"eager",style:{pointerEvents:"none",position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"contain",display:"block"}})}),L&&v.jsx("div",{style:{fontSize:12,color:"#6b7280",marginTop:4},children:L})]})},y)}const R=T,k=w.findIndex(j=>j.originalBlockIndex===g),O=k>=0?c[k]:void 0,P=R.runs??[],I=P.length;let _=0,z=Math.max(0,I-1);M&&p.startOffsetInBlock!=null&&(_=Math.min(Math.max(0,p.startOffsetInBlock),z)),E&&p.endOffsetInBlock!=null&&(z=Math.max(_,Math.min(p.endOffsetInBlock,z)));const N=_>0,B=d[g]??0,$=m[g]??[],te=B+_,fe=B+z;let ge=f($,te,fe);const ve=B+_;ge=ge.map(j=>{const L=Math.max(0,(j.startG??te)-ve),V=j.len??Math.max(1,(j.endG??fe)-(j.startG??te)+1);return{...j,r0:L,len:V}});const me=_<=z?P.slice(_,z+1):[],Be=R.list?R.list.level*24:0,K=((G=R.list)==null?void 0:G.kind)==="bullet"?R.list.glyph??"•":void 0,D=N?void 0:O??K;return v.jsx("div",{style:x,children:v.jsxs("p",{style:{width:"100%",margin:"8px 0",paddingLeft:Be,textAlign:R.textAlign,whiteSpace:"pre-wrap",boxSizing:"border-box"},children:[R.list&&D?v.jsx("span",{"aria-hidden":!0,style:{minWidth:16,display:"inline-block",whiteSpace:"nowrap",userSelect:"none"},children:D||""}):null,v.jsx(bs,{preGroups:ge,runs:me,ns:y,baseIndex:ve,sectionId:String(r.section_id)})]})},y)})})]})})},fo=.5;function iu(e,t){const n=h.useRef(null),r=h.useRef(null),o=h.useRef(!1);h.useEffect(()=>{const s=()=>{n.current==null&&(n.current=requestAnimationFrame(()=>{n.current=null,t(),o.current=!0,requestAnimationFrame(()=>{o.current=!1})}))},i=new ResizeObserver(a=>{if(o.current)return;const l=a[0],{width:d,height:m}=l.contentRect,p=r.current;if(!p){r.current={w:d,h:m};return}Math.abs(p.w-d)<fo&&Math.abs(p.h-m)<fo||(r.current={w:d,h:m},s())});e.forEach(a=>{a.current&&i.observe(a.current)});const u=()=>s();return window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u),i.disconnect(),n.current!=null&&cancelAnimationFrame(n.current),n.current=null}},[e,t])}function lu(e){const{onPrev:t,onNext:n,onSingle:r,onDouble:o,shouldIgnoreTarget:s,shouldIgnoreSwipe:i,horizontalThreshold:u=120,velocityThreshold:a=.6,singleDelayMs:l=250,doubleClickWindowMs:d=300,onDragMove:m,onDragEnd:p,pageTransitionThreshold:b}=e,S=b??u,w=10,c=$e.useRef({touchId:null,startX:0,startY:0,startT:0,swiping:!1,mouseDown:!1,mouseSwiping:!1,mStartX:0,mStartY:0,mStartT:0,capturedEl:null,prevUserSelect:"",lastTapT:0,singleTimer:null,suppressClick:!1}),f=()=>{c.current.singleTimer!=null&&(clearTimeout(c.current.singleTimer),c.current.singleTimer=null)},g=$e.useCallback(_=>{if(s!=null&&s(_))return;const z=performance.now();z-c.current.lastTapT<=d&&c.current.lastTapT>0?(f(),c.current.lastTapT=0,o==null||o()):(f(),r&&(c.current.singleTimer=window.setTimeout(()=>{c.current.singleTimer=null,r()},l)),c.current.lastTapT=z)},[s,d,o,r,l]),C=$e.useCallback((_,z)=>{const N=Math.abs(_)/Math.max(1,z);Math.abs(_)>=S||N>=a?_<0?n():t():p==null||p()},[S,a,n,t,p]),T=$e.useCallback(_=>{if(_.touches.length!==1)return;const z=i??s;if(z!=null&&z(_.target))return;const N=_.touches[0];c.current.touchId=N.identifier,c.current.startX=N.clientX,c.current.startY=N.clientY,c.current.startT=_.timeStamp,c.current.swiping=!1},[i,s]),M=$e.useCallback(_=>{if(c.current.touchId==null)return;const z=Array.from(_.touches).find(te=>te.identifier===c.current.touchId);if(!z)return;const N=z.clientX-c.current.startX,B=Math.abs(N),$=Math.abs(z.clientY-c.current.startY);if(!c.current.swiping)if(B>=w&&B>$)c.current.swiping=!0;else return;m==null||m(N)},[m]),E=$e.useCallback(_=>{if(c.current.touchId==null)return;const z=Array.from(_.changedTouches).find(te=>te.identifier===c.current.touchId);if(!z)return;const N=z.clientX-c.current.startX,B=z.clientY-c.current.startY,$=_.timeStamp-c.current.startT;c.current.swiping?C(N,$):Math.abs(N)<10&&Math.abs(B)<10&&g(_.target),c.current.suppressClick=!0,c.current.touchId=null,c.current.swiping=!1},[C,g]),x=$e.useCallback(()=>{c.current.swiping&&(p==null||p()),c.current.touchId=null,c.current.swiping=!1},[p]),y=$e.useCallback(_=>{if(_.pointerType==="touch"||c.current.mouseDown)return;const z=i??s;z!=null&&z(_.target)||(c.current.mouseDown=!0,c.current.mouseSwiping=!1,c.current.mStartX=_.clientX,c.current.mStartY=_.clientY,c.current.mStartT=_.timeStamp,c.current.suppressClick=!1,c.current.capturedEl=_.currentTarget)},[i,s]),R=$e.useCallback(_=>{if(_.pointerType==="touch"||!c.current.mouseDown)return;const z=_.clientX-c.current.mStartX,N=Math.abs(z),B=Math.abs(_.clientY-c.current.mStartY);if(!c.current.mouseSwiping)if(N>=w&&N>B){c.current.mouseSwiping=!0,c.current.suppressClick=!0;const $=c.current.capturedEl;if($!=null&&$.setPointerCapture)try{$.setPointerCapture(_.pointerId)}catch{}c.current.prevUserSelect=document.body.style.userSelect,document.body.style.userSelect="none",_.preventDefault()}else return;m==null||m(z),_.preventDefault()},[m]),k=$e.useCallback(_=>{var N;if(_.pointerType==="touch"||!c.current.mouseDown)return;if(c.current.mouseSwiping){const B=_.clientX-c.current.mStartX,$=_.timeStamp-c.current.mStartT;C(B,$),document.body.style.userSelect=c.current.prevUserSelect}const z=c.current.capturedEl;if((N=z==null?void 0:z.hasPointerCapture)!=null&&N.call(z,_.pointerId))try{z.releasePointerCapture(_.pointerId)}catch{}c.current.mouseDown=!1,c.current.mouseSwiping=!1,c.current.capturedEl=null},[C]),O=$e.useCallback(_=>{_.pointerType!=="touch"&&(c.current.mouseSwiping&&(p==null||p(),document.body.style.userSelect=c.current.prevUserSelect),c.current.mouseDown=!1,c.current.mouseSwiping=!1,c.current.capturedEl=null)},[p]),P=$e.useCallback(()=>{c.current.mouseSwiping&&(p==null||p(),document.body.style.userSelect=c.current.prevUserSelect),c.current.mouseDown=!1,c.current.mouseSwiping=!1,c.current.capturedEl=null},[p]),I=$e.useCallback(_=>{if(c.current.suppressClick){c.current.suppressClick=!1;return}g(_.target)},[g]);return $e.useEffect(()=>()=>{f(),document.body.style.userSelect=""},[]),{onTouchStart:T,onTouchMove:M,onTouchEnd:E,onTouchCancel:x,onPointerDown:y,onPointerMove:R,onPointerUp:k,onPointerCancel:O,onLostPointerCapture:P,onClick:I}}var Pn,po;function Is(){if(po)return Pn;po=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return Pn=e,Pn}var Bn,go;function au(){if(go)return Bn;go=1;var e=typeof Yt=="object"&&Yt&&Yt.Object===Object&&Yt;return Bn=e,Bn}var An,ho;function Ts(){if(ho)return An;ho=1;var e=au(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return An=n,An}var Gn,mo;function cu(){if(mo)return Gn;mo=1;var e=Ts(),t=function(){return e.Date.now()};return Gn=t,Gn}var Ln,bo;function uu(){if(bo)return Ln;bo=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return Ln=t,Ln}var Hn,xo;function du(){if(xo)return Hn;xo=1;var e=uu(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return Hn=n,Hn}var Nn,vo;function ks(){if(vo)return Nn;vo=1;var e=Ts(),t=e.Symbol;return Nn=t,Nn}var Fn,So;function fu(){if(So)return Fn;So=1;var e=ks(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,o=e?e.toStringTag:void 0;function s(i){var u=n.call(i,o),a=i[o];try{i[o]=void 0;var l=!0}catch{}var d=r.call(i);return l&&(u?i[o]=a:delete i[o]),d}return Fn=s,Fn}var Wn,yo;function pu(){if(yo)return Wn;yo=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return Wn=n,Wn}var Dn,wo;function gu(){if(wo)return Dn;wo=1;var e=ks(),t=fu(),n=pu(),r="[object Null]",o="[object Undefined]",s=e?e.toStringTag:void 0;function i(u){return u==null?u===void 0?o:r:s&&s in Object(u)?t(u):n(u)}return Dn=i,Dn}var $n,Co;function hu(){if(Co)return $n;Co=1;function e(t){return t!=null&&typeof t=="object"}return $n=e,$n}var Vn,Io;function mu(){if(Io)return Vn;Io=1;var e=gu(),t=hu(),n="[object Symbol]";function r(o){return typeof o=="symbol"||t(o)&&e(o)==n}return Vn=r,Vn}var qn,To;function bu(){if(To)return qn;To=1;var e=du(),t=Is(),n=mu(),r=NaN,o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,i=/^0o[0-7]+$/i,u=parseInt;function a(l){if(typeof l=="number")return l;if(n(l))return r;if(t(l)){var d=typeof l.valueOf=="function"?l.valueOf():l;l=t(d)?d+"":d}if(typeof l!="string")return l===0?l:+l;l=e(l);var m=s.test(l);return m||i.test(l)?u(l.slice(2),m?2:8):o.test(l)?r:+l}return qn=a,qn}var Un,ko;function xu(){if(ko)return Un;ko=1;var e=Is(),t=cu(),n=bu(),r="Expected a function",o=Math.max,s=Math.min;function i(u,a,l){var d,m,p,b,S,w,c=0,f=!1,g=!1,C=!0;if(typeof u!="function")throw new TypeError(r);a=n(a)||0,e(l)&&(f=!!l.leading,g="maxWait"in l,p=g?o(n(l.maxWait)||0,a):p,C="trailing"in l?!!l.trailing:C);function T(I){var _=d,z=m;return d=m=void 0,c=I,b=u.apply(z,_),b}function M(I){return c=I,S=setTimeout(y,a),f?T(I):b}function E(I){var _=I-w,z=I-c,N=a-_;return g?s(N,p-z):N}function x(I){var _=I-w,z=I-c;return w===void 0||_>=a||_<0||g&&z>=p}function y(){var I=t();if(x(I))return R(I);S=setTimeout(y,E(I))}function R(I){return S=void 0,C&&d?T(I):(d=m=void 0,b)}function k(){S!==void 0&&clearTimeout(S),c=0,d=w=m=S=void 0}function O(){return S===void 0?b:R(t())}function P(){var I=t(),_=x(I);if(d=arguments,m=this,w=I,_){if(S===void 0)return M(w);if(g)return clearTimeout(S),S=setTimeout(y,a),T(w)}return S===void 0&&(S=setTimeout(y,a)),b}return P.cancel=k,P.flush=O,P}return Un=i,Un}var vu=xu();const Su=Po(vu);function yu(e,t=200,n,r){const o=h.useRef(e),s=h.useRef(n);h.useEffect(()=>{o.current=e},[e]),h.useEffect(()=>{s.current=n},[n]);const i=h.useMemo(()=>{const u=Su((...l)=>{o.current(...l)},t,r),a=((...l)=>{var d;(d=s.current)==null||d.call(s),u(...l)});return a.cancel=u.cancel.bind(u),a.flush=u.flush.bind(u),a},[t,r]);return h.useEffect(()=>()=>i.cancel(),[i]),i}const wu="https://fonts.googleapis.com/css2?family=Nanum+Myeongjo:wght@400;700&family=Noto+Sans+KR:wght@300;400;500;700&family=Noto+Serif+KR:wght@400;700&display=swap";let Kn=!1;function Cu(){if(Kn||typeof document>"u")return;if(document.querySelector('link[href*="fonts.googleapis.com"][href*="Noto"]')){Kn=!0;return}const t=document.createElement("link");t.rel="stylesheet",t.href=wu,document.head.appendChild(t),Kn=!0}const Rs=new Map,_s=e=>Rs.get(e)??0,Iu=e=>{const t=_s(e)+1;return Rs.set(e,t),t};class Ms extends Error{constructor(){super("calcPages canceled due to a newer invocation");Ir(this,"code","CALC_PAGES_CANCELED");this.name="CalcPagesCanceled"}}const Qe=(e,t)=>{if(e!==_s(t))throw new Ms},Xn=e=>{const t=getComputedStyle(e),n=parseFloat(t.marginTop||"0")||0,r=parseFloat(t.marginBottom||"0")||0;return{mt:n,mb:r}},Ro=e=>{const t=e.getClientRects(),n=t.length?t[0].top:e.getBoundingClientRect().top,r=e.querySelectorAll("[data-runbox]"),o=[];return r.forEach((s,i)=>{const u=s.getClientRects(),a=u.length?u[u.length-1].bottom:n;o[i]=Math.max(0,a-n)}),o},Tu=(e,t,n)=>{if(n<16)return async(o=24)=>{Qe(e,t)};let r=0;return async(o=24)=>{r++,r%o===0&&(Qe(e,t),await new Promise(s=>requestAnimationFrame(()=>s())),Qe(e,t))}};async function ku({viewHost:e,measureRoot:t,contentArea:n,items:r,cfgMaxWidth:o,marginX:s,fontFamily:i,fontSizePx:u,lineHeight:a,showSplit:l,breakGapPx:d=0,showSlash:m,paragraphMarkers:p,playbackScale:b=1,viewportHeight:S=0,instanceId:w="default"}){var f,g,C;const c=Iu(w);if(Qe(c,w),i&&typeof document<"u"&&document.fonts){Cu();try{const T=`${u}px ${i}`;await document.fonts.load(T),document.fonts.check(T)||await document.fonts.ready}catch{}}Qe(c,w);try{const T=Math.abs(b-1)>.001,M=1/b;T&&(t.style.transform=`scale(${M})`,t.style.transformOrigin="top left");const E=Math.max(0,e.offsetWidth||0),x=Math.max(0,Math.min(E,o));t.style.maxWidth=`${x}px`,Qe(c,w);let y=Math.round(n.offsetHeight||0);y||(y=Math.max(0,n.clientHeight|0)),console.log("[calcPages] playbackScale:",b.toFixed(4),T?"(scaled, applying inverse)":"(no scale)"),console.log("[calcPages] viewWidth:",E),console.log("[calcPages] pageBoxWidth:",x),console.log("[calcPages] maxPageHeight:",y),console.log("[calcPages] contentArea rect:",n.getBoundingClientRect()),console.log("[calcPages] measureRoot rect:",t.getBoundingClientRect());const R=1.5,k=(A,Q)=>Q+A<=y-R,O=getComputedStyle(e),P={letterSpacing:O.letterSpacing,wordSpacing:O.wordSpacing,fontKerning:O.fontKerning||"normal",fontVariantLigatures:O.fontVariantLigatures||"normal",textTransform:O.textTransform||"none",direction:O.direction||"ltr",wordBreak:O.wordBreak||"keep-all",overflowWrap:O.overflowWrap||O.wordWrap||"break-word",hyphens:O.hyphens||"manual"},I=A=>{A.style.letterSpacing=P.letterSpacing||"",A.style.wordSpacing=P.wordSpacing||"",A.style.fontKerning=P.fontKerning||"",A.style.fontVariantLigatures=P.fontVariantLigatures||"",A.style.textTransform=P.textTransform||"",A.style.direction=P.direction||"",A.style.wordBreak=P.wordBreak||"",A.style.wordWrap=P.overflowWrap||"",A.style.overflowWrap=P.overflowWrap||"",A.style.hyphens=P.hyphens||""},_=x,z=Math.max(0,_-2*(s||0));n.innerHTML="";const N=document.createElement("div");N.style.boxSizing="border-box",N.style.width=`${_}px`,N.style.maxWidth=`${_}px`,N.style.margin="0 auto",N.style.display="flex",n.appendChild(N);const B=document.createElement("div");B.style.boxSizing="border-box",B.style.paddingRight=`${s}px`,B.style.paddingLeft=`${s}px`,B.style.width=`${_}px`,B.style.maxWidth=`${_}px`,B.style.margin="0 auto",B.style.display="flex",B.style.justifyContent="center",B.style.height="auto",N.appendChild(B);const $=new Map,te={},fe=Tu(c,w,r.length),ge=(A,Q)=>{const F=document.createElement("p");return F.style.margin="8px 0",F.style.paddingLeft=Q?`${Q}px`:"0",F.style.textAlign=A.textAlign??"start",F.style.whiteSpace="pre-wrap",F.style.lineHeight=String(a),F.style.fontSize=`${u}px`,F.style.boxSizing="border-box",F.style.fontFamily=i??"",F.style.width="100%",I(F),F},ve=(A,Q)=>{const F=Q??[],X=document.createDocumentFragment();for(let ee=0;ee<F.length;ee++){const Z=F[ee],ie=document.createElement("span");ie.dataset.runbox=String(ee),ie.style.whiteSpace="pre-wrap";const re=document.createElement("span");if(re.dataset.run=String(ee),re.textContent=(Z==null?void 0:Z.text)??"",re.style.whiteSpace="pre-wrap",Z!=null&&Z.bold&&(re.style.fontWeight="700"),Z!=null&&Z.italic&&(re.style.fontStyle="italic"),Z!=null&&Z.underline&&(re.style.textDecoration="underline"),ie.appendChild(re),l&&(Z!=null&&Z.split)&&ee!==F.length-1){const be=Math.max(0,(d??0)/2),ue=document.createElement("span");ue.style.display="inline-block",ue.style.width=`${be}px`;const ye=document.createElement("span");if(ye.style.display="inline-block",ye.style.width=`${be}px`,ie.appendChild(ue),m){const ke=document.createElement("span");ke.textContent=" / ",ie.appendChild(ke)}ie.appendChild(ye)}X.appendChild(ie)}A.appendChild(X)},me=S>80?Math.floor((S-80)*.6):void 0,Be=A=>{const Q=A!=null&&A.width&&(A!=null&&A.height)?`${A.width} / ${A.height}`:"4 / 3",F=document.createElement("div");F.style.margin="12px 0",F.style.textAlign="center",F.style.width=`${z}px`;const X=document.createElement("div");X.style.position="relative",X.style.width="100%",me&&(X.style.maxHeight=`${me}px`),X.style.aspectRatio=Q;const ee=document.createElement("div");if(ee.style.position="absolute",ee.style.inset="0",ee.style.width="100%",ee.style.height="100%",X.appendChild(ee),F.appendChild(X),A!=null&&A.alt){const Z=document.createElement("div");Z.style.fontSize="12px",Z.style.color="#6B7280",Z.style.marginTop="4px",Z.textContent=String(A.alt),I(Z),F.appendChild(Z)}return F};for(let A=0;A<r.length;A++){Qe(c,w);const Q=r[A];if(B.dataset.block=String(A),B.innerHTML="",Q.kind==="image"){const ye=Q.block,ke=Be(ye);B.appendChild(ke);const ze=ke.getBoundingClientRect(),{mt:Ee,mb:Le}=Xn(ke);te[A]={contentH:Math.ceil(ze.height),mt:Ee,mb:Le},await fe(24);continue}const F=Q.block,X=F.list?(F.list.level??0)*24:0,ee=Q.paraIndex??0,Z=p[ee]??(((f=F.list)==null?void 0:f.kind)==="bullet"?((g=F.list)==null?void 0:g.glyph)??"•":void 0);if(!!(F.list&&Z)){const ye=ge(F,X);ye.dataset.variant="with";const ke=ge(F,X);ke.dataset.variant="no";const ze=document.createElement("span");ze.textContent=`${Z} `,ze.style.minWidth="16px",ze.style.display="inline-block",ze.style.whiteSpace="nowrap",ze.style.userSelect="none",ye.appendChild(ze),ve(ye,F.runs),ve(ke,F.runs);const Ee=document.createDocumentFragment();Ee.appendChild(ye),Ee.appendChild(ke),B.appendChild(Ee)}else{const ye=ge(F,X);ye.dataset.variant="with",ve(ye,F.runs),B.appendChild(ye)}const re=B.querySelector('p[data-variant="with"]'),be=B.querySelector('p[data-variant="no"]'),ue=be??re;if(re&&ue){const ye=Ro(re),ke=Ro(ue),{mt:ze,mb:Ee}=Xn(re),{mt:Le,mb:ot}=Xn(ue),De=((C=F.runs)==null?void 0:C.length)??0,je=be?ke:ye,et=be?Le:ze,Ye=be?ot:Ee;if(A<3){const ut=re.getBoundingClientRect().height;console.log(`[calcPages] para ${A}: height=${ut.toFixed(2)}, lastBottom=[${ye.slice(-3).map(zt=>zt.toFixed(1)).join(",")}], runs=${De}`)}$.set(A,{runsLen:De,lastBottomWith:ye,lastBottomNo:je,mtWith:ze,mbWith:Ee,mtNo:et,mbNo:Ye})}await fe(24)}Qe(c,w),B.innerHTML="";const K=(A,Q,F,X)=>{if(Q>F)return{top:0,content:0,mb:0};const ee=X?A.lastBottomNo:A.lastBottomWith,Z=X?A.mtNo:A.mtWith,ie=X?A.mbNo:A.mbWith,re=X?0:Z,be=Q>0?ee[Q-1]??0:0,ue=Math.max(0,(ee[F]??0)-be);return{top:re,content:ue,mb:ie}},D=[];let G=0,j,L=null,V=null;for(;G<r.length;){Qe(c,w);const A=G;let Q=0,F=0,X=j;X!=null&&L===G&&V!=null&&(X=Math.max(X,V+1));let ee=-1,Z;for(;G<r.length;){if(Qe(c,w),r[G].kind==="image"){const je=te[G]??{contentH:0,mt:0,mb:0},Ye=(Q===0?je.mt:F+je.mt)+je.contentH;if(k(Ye,Q)){Q+=Ye,ee=G,Z=void 0,F=je.mb,G+=1,j=void 0,L=null,V=null;continue}if(Q===0){D.push({startBlock:A,endBlock:G,...X!=null?{startOffsetInBlock:X}:{}}),G+=1,j=void 0,L=null,V=null,F=0;break}break}const re=$.get(G),be=re.runsLen,ue=G===A&&X!=null?X:0;if(ue>=be){G+=1,j=void 0,L=null,V=null;continue}const ye=ue>0,ke=K(re,ue,be-1,ye),Ee=(Q===0?ke.top:F+ke.top)+ke.content;if(k(Ee,Q)){Q+=Ee,ee=G,Z=be-1,F=ke.mb,G+=1,j=void 0,L=null,V=null;continue}let Le=ue,ot=be-1,De=ue-1;for(;Le<=ot;){Qe(c,w);const je=Le+ot>>1,et=K(re,ue,je,ye),Ye=(Q===0?et.top:F+et.top)+et.content;k(Ye,Q)?(De=je,Le=je+1):ot=je-1}if(De>=ue){D.push({startBlock:A,endBlock:G,...X!=null?{startOffsetInBlock:X}:{},endOffsetInBlock:De}),j=De+1,L=G,V=De,F=0;break}if(Q>0){D.push({startBlock:A,endBlock:ee>=0?ee:Math.min(G-1,r.length-1),...X!=null?{startOffsetInBlock:X}:{},...Z!=null?{endOffsetInBlock:Z}:{}}),F=0;break}else{const je=ue;D.push({startBlock:A,endBlock:G,...X!=null?{startOffsetInBlock:X}:{},endOffsetInBlock:je}),j=je+1,L=G,V=je,F=0;break}}(D.length===0||D[D.length-1].startBlock!==A)&&D.push({startBlock:A,endBlock:ee>=0?ee:Math.min(G-1,r.length-1),...X!=null?{startOffsetInBlock:X}:{},...Z!=null?{endOffsetInBlock:Z}:{}})}return N.remove(),T&&(t.style.transform="",t.style.transformOrigin=""),Qe(c,w),{pages:D,pageByRunIndex:null}}catch(T){throw console.error(T),T}}function _o(e,t,n){var r;if(!e)return null;for(let o=e.startBlock;o<=e.endBlock;o++){const s=t[o];if(!s||s.kind!=="paragraph")continue;const i=((r=s.block.runs)==null?void 0:r.length)??0;if(!i)continue;const u=o===e.startBlock&&e.startOffsetInBlock!=null?Math.min(Math.max(0,e.startOffsetInBlock),i-1):0;return(n[s.originalIndex]??0)+u}return null}function Ru(e,t,n,r){var o;for(let s=0;s<t.length;s++){const i=t[s];for(let u=i.startBlock;u<=i.endBlock;u++){const a=n[u];if(!a||a.kind!=="paragraph")continue;const l=((o=a.block.runs)==null?void 0:o.length)??0;if(!l)continue;let d=0,m=l-1;u===i.startBlock&&i.startOffsetInBlock!=null&&(d=Math.max(0,Math.min(i.startOffsetInBlock,m))),u===i.endBlock&&i.endOffsetInBlock!=null&&(m=Math.max(d,Math.min(i.endOffsetInBlock,m)));const p=r[a.originalIndex]??0,b=p+d,S=p+m;if(e>=b&&e<=S)return s}}return-1}function _u(e){var r,o;const t=e;if(!t)return!1;const n=((o=(r=t.tagName)==null?void 0:r.toLowerCase)==null?void 0:o.call(r))??"";return!!(["a","button","input","textarea","select","label"].includes(n)||t.isContentEditable)}function Mu(e){var n,r;const t=e;return t?((n=t.style)==null?void 0:n.cursor)==="grab"||((r=t.closest)==null?void 0:r.call(t,"[data-range-handle]"))!=null:!1}function Eu(e){const t=[],n=[];let r=0;return e.forEach((o,s)=>{o.type==="paragraph"?(t.push({kind:"paragraph",block:o,originalIndex:s,paraIndex:r}),n.push(s),r+=1):o.type==="image"&&t.push({kind:"image",block:o,originalIndex:s})}),{items:t,paraIndexMap:n}}function ju(){var Cr;const e=h.useId(),t=U(q=>q.section),n=U(q=>q.sectionLoading),r=U(q=>q.rangeStartGI),o=U(q=>q.rangeEndGI),s=r!=null&&o!=null,i=wt(),u=J(q=>q.theme),a=on[u],l=J(q=>q.fontFamily),d=J(q=>q.fontSizePx),m=J(q=>q.lineHeight),p=J(q=>q.marginX),b=J(q=>q.viewportHeight),S=860,w=h.useRef(null),{items:c}=h.useMemo(()=>{var q;return Eu(((q=t==null?void 0:t.ast)==null?void 0:q.blocks)??[])},[t]),f=h.useMemo(()=>{const q=[],Oe=Sr();return c.forEach(Ae=>{if(Ae.kind==="paragraph"){const bt=Ae.paraIndex;q[bt]=yr(Ae.block,Oe)}}),q},[c]),[g,C]=h.useState({pages:[],pageByRunIndex:null}),T=U(q=>q.pageIndex),M=U(q=>q.setPageIndex),E=h.useRef(0),x=h.useRef(null),[y,R]=h.useState(!1),[k,O]=h.useState(null),[P,I]=h.useState(!1),_=h.useMemo(()=>({flex:1,fontFamily:l,background:a.bg,color:a.fg,fontSize:d,lineHeight:m,overflow:"hidden",width:"100%",height:"100%",position:"relative",boxSizing:"border-box",WebkitTextSizeAdjust:"none",MozTextSizeAdjust:"none",textSizeAdjust:"none"}),[l,a.bg,a.fg,d,m]),{showSplit:z,breakGapPx:N,slash:B}=J(Vt(q=>{var Oe;return{showSplit:q.showSplit,breakGapPx:q.breakGapPx??0,slash:((Oe=q.breakMarks)==null?void 0:Oe.slash)??!1}})),$=vt();h.useEffect(()=>{g&&g.pages.length&&(console.log("그래서 총 페이지",g.pages.length),$.getState().progress.setTotalPages(g.pages.length+1),(async()=>{const q=$.getState().progress.setSectionLoading;await ft(),await ft(),await ft(),await ft(),console.log("recalc종료"),q(!1)})())},[g,$]);const te=h.useCallback(()=>{console.log("@@@@@@recalc호출");const q=w.current,Oe=re.current,Ae=be.current;if(console.log("showSplit",z),!q||!Oe||!Ae||c.length===0){C({pages:[],pageByRunIndex:null}),M(0),$.getState().progress.setTotalPages(0);return}(async()=>{const bt=performance.now();try{const tt=i.getState().playbackScale,{pages:Tt,pageByRunIndex:js}=await ku({viewHost:q,measureRoot:Oe,contentArea:Ae,items:c,cfgMaxWidth:S,marginX:p,fontFamily:l,fontSizePx:d,lineHeight:m,showSplit:z,breakGapPx:N,showSlash:B,paragraphMarkers:f,playbackScale:tt,viewportHeight:b,instanceId:e}),Os=performance.now();console.log(`✅ calcPages 완료: ${(Os-bt).toFixed(1)} ms (${Tt.length} pages)`),C({pages:Tt,pageByRunIndex:js}),M(0)}catch(tt){if(tt instanceof Ms){console.log("이젠실행 취소 들어옴!");return}console.log("에러발생",tt)}})()},[M,c,S,p,l,d,m,z,N,B,f,i,b,e]),fe=U(q=>q.setCurrentGlobalRunIndex),ge=U(q=>{var Oe;return((Oe=q.layout)==null?void 0:Oe.prefix)??[]}),ve=Ce(q=>q.syncToGI),me=h.useCallback(q=>{const Oe=g.pages.length+1,Ae=T+q;if(Ae<0||Ae>=Oe)return;const bt=T===g.pages.length;if(Ae===g.pages.length){M(Ae);return}if(bt&&q===-1){const Tt=_o(g.pages[Ae],c,ge);Tt!=null&&(fe(Tt,"scrubber-step"),ve(Tt)),M(Ae);return}const tt=_o(g.pages[Ae],c,ge);tt!=null?(fe(tt,"scrubber-step"),ve(tt)):M(Ae)},[T,g.pages,c,ge,fe,M,ve]),Be=h.useCallback(()=>{y||E.current!==0?(O("prev"),R(!1)):me(-1)},[y,me]),K=h.useCallback(()=>{y||E.current!==0?(O("next"),R(!1)):me(1)},[y,me]),D=gn(),G=h.useCallback(()=>{const{isSettingsOpen:q,setSettingsOpen:Oe,toggleOverlays:Ae}=D.getState();q?Oe(!1):Ae()},[D]),j=g.pages.length+1,L=((Cr=w.current)==null?void 0:Cr.clientWidth)||400,V=h.useCallback(q=>{var tt;const Oe=x.current;if(!Oe)return;const Ae=((tt=w.current)==null?void 0:tt.clientWidth)||1,bt=q/Ae*33.333;Oe.style.transform=`translate3d(${-33.333+bt}%, 0, 0)`},[]),A=h.useCallback(q=>{T===0&&q>0||T>=j-1&&q<0||(E.current=q,V(q),y||R(!0))},[T,j,V,y]),Q=h.useCallback(()=>{E.current=0,R(!1);const q=x.current;q&&(q.style.transition="transform 250ms ease-out",q.style.transform="translate3d(-33.333%, 0, 0)")},[]),F=h.useCallback(q=>{if(q.target!==q.currentTarget||q.propertyName!=="transform")return;const Oe=k;I(!0),O(null),E.current=0,Oe==="prev"?me(-1):Oe==="next"&&me(1)},[k,me]);h.useLayoutEffect(()=>{P&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{I(!1)})})},[P]);const X=an(),ee=h.useCallback(q=>s||Mu(q)?!0:_u(q),[s]),Z=h.useCallback(q=>X.getState().status==="playing"?!0:ee(q),[X,ee]),ie=lu({onPrev:Be,onNext:K,onSingle:G,onDouble:()=>{},shouldIgnoreTarget:ee,shouldIgnoreSwipe:Z,horizontalThreshold:120,velocityThreshold:.6,singleDelayMs:250,doubleClickWindowMs:300,onDragMove:A,onDragEnd:Q,pageTransitionThreshold:L*.5}),re=h.useRef(null),be=h.useRef(null),ue=h.useCallback(()=>{const q=$.getState().progress.setSectionLoading;q(!0)},[$]),ye=h.useMemo(()=>({trailing:!0,leading:!1,maxWait:1e3}),[]),ke=yu(te,200,ue,ye),ze=h.useRef("");h.useEffect(()=>{if(b<=0)return;const q=`${l}|${d}|${m}|${p}|${z}|${N}|${B}|${b}|${t==null?void 0:t.section_id}`;ze.current!==q&&(ze.current=q,console.log("debounceRecalc 취소"),ke.cancel(),ue(),te())},[ke,te,ue,l,d,m,p,z,N,B,b,t==null?void 0:t.section_id]),iu([w],ke);const Ee=U(q=>q.registerSectionScrollApi);h.useEffect(()=>(Ee({ensureVisibleGI:()=>Promise.resolve(!0),scrollToGI:()=>Promise.resolve(!0),getVisibleRange:()=>null,getScrollTop:()=>0,setScrollTop:()=>{},getAnchorOffsetRatio:()=>0,scrollToGIAtOffset:()=>Promise.resolve(),stepPage:me}),()=>Ee(void 0)),[Ee,me]);const Le=t.quizzes&&t.quizzes.length>0,ot=g.pages.length>0&&T===g.pages.length,De=T>0?T-1:null,je=T<j-1?T+1:null,et=h.useMemo(()=>k==="prev"?"translate3d(0%, 0, 0)":k==="next"?"translate3d(-66.666%, 0, 0)":"translate3d(-33.333%, 0, 0)",[k]),Ye=q=>n?null:q===g.pages.length?v.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,width:"100%",height:"100%"},children:[Le&&v.jsx(Ss,{}),v.jsx(fn,{isIcon:!1})]}):v.jsx(su,{pages:g.pages,pageIndex:q,maxWidth:S}),ut={width:"33.333%",height:"100%",flexShrink:0,display:"flex",alignItems:"stretch",justifyContent:"center",overflow:"hidden",boxSizing:"border-box",backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden"},zt=!P&&(!y||k!==null);return console.log("여기리랜더"),v.jsxs("div",{ref:w,style:{..._,touchAction:"none"},...ie,children:[v.jsxs("div",{ref:x,style:{display:"flex",width:"300%",height:"100%",transform:et,transition:zt?"transform 250ms ease-out":"none",willChange:"transform",boxSizing:"border-box",backfaceVisibility:"hidden",WebkitBackfaceVisibility:"hidden"},onTransitionEnd:k?F:void 0,children:[v.jsx("div",{style:ut,children:De!==null&&Ye(De)}),v.jsx("div",{style:ut,children:Ye(T)}),v.jsx("div",{style:ut,children:je!==null&&Ye(je)})]}),v.jsx("div",{ref:re,"aria-hidden":!0,style:{position:"absolute",contain:"layout style paint",left:-999999,top:-999999,zIndex:-999999,opacity:0,width:"100%",maxWidth:S,height:"100%",minHeight:0,boxSizing:"border-box",overflow:"hidden",fontFamily:l,fontSize:d,lineHeight:m,pointerEvents:"none",background:"pink"},children:v.jsxs("div",{style:{width:"100%",maxWidth:S,height:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",margin:"0 auto",overflow:"hidden"},children:[v.jsx("div",{style:{height:40,background:"blue"}}),v.jsx("div",{ref:be,style:{height:"calc(100% - 110px)",overflow:"hidden",boxSizing:"border-box",width:"100%"}})]})}),v.jsx(Ou,{pages:g.pages,items:c,onGotoPage:M,currentPageIndex:T,isOnExtraPage:ot})]})}const Ou=({pages:e,items:t,onGotoPage:n,currentPageIndex:r,isOnExtraPage:o})=>{const s=U(l=>l.currentGlobalRunIndex),i=U(l=>l.lastUpdateBy),u=U(l=>{var d;return((d=l.layout)==null?void 0:d.prefix)??[]}),a=h.useRef(null);return h.useEffect(()=>{if(s==null||e.length===0||o&&!(i==="scrubber-live"||i==="scrubber-commit")||a.current===s)return;a.current=s;const l=Ru(s,e,t,u);l>=0&&l!==r&&n(l)},[s,e,t,u,n,r,o,i]),v.jsx(v.Fragment,{})},zu="_wrapper_dbk3n_1",Pu="_spinner_dbk3n_10",Mo={wrapper:zu,spinner:Pu};function Bu({size:e=28,speed:t=.8}){return v.jsx("div",{className:`${Mo.wrapper}`,children:v.jsx("div",{className:Mo.spinner,style:{width:e,height:e,borderWidth:3,animationDuration:`${t}s`}})})}function Au(){const e=U(Vt(t=>t.sectionLoading===!0));return v.jsx(v.Fragment,{children:e===!0&&v.jsx(Bu,{})})}const Gu="_Overlay_ybic8_3",Lu="_Dialog_ybic8_15",Hu="_Body_ybic8_25",Nu="_Header_ybic8_32",Fu="_Paging_ybic8_39",Wu="_Remaining_ybic8_48",Du="_RemainingDanger_ybic8_55",$u="_NextBtn_ybic8_59",Vu="_CloseBtn_ybic8_96",qu="_Question_ybic8_113",Uu="_Score_ybic8_123",Ku="_Image_ybic8_130",Xu="_Options_ybic8_140",Yu="_OptionBtn_ybic8_145",Qu="_OptionBtnActive_ybic8_165",Zu="_Footer_ybic8_172",Ju="_OptionBtnCorrect_ybic8_195",ed="_Judge_ybic8_201",td="_Correct_ybic8_212",nd="_Incorrect_ybic8_215",rd="_ResultHeader_ybic8_220",od="_ResultActions_ybic8_233",sd="_CloseBtnSoft_ybic8_239",id="_SummaryGrid_ybic8_249",ld="_StatCard_ybic8_257",ad="_StatLabel_ybic8_265",cd="_StatValue_ybic8_270",ud="_StatSub_ybic8_277",ae={Overlay:Gu,Dialog:Lu,Body:Hu,Header:Nu,Paging:Fu,Remaining:Wu,RemainingDanger:Du,NextBtn:$u,CloseBtn:Vu,Question:qu,Score:Uu,Image:Ku,Options:Xu,OptionBtn:Yu,OptionBtnActive:Qu,Footer:Zu,OptionBtnCorrect:Ju,Judge:ed,Correct:td,Incorrect:nd,ResultHeader:rd,ResultActions:od,CloseBtnSoft:sd,SummaryGrid:id,StatCard:ld,StatLabel:ad,StatValue:cd,StatSub:ud};function dd(e){return e?e.kind==="temp"?e.image_blob_url:e.image_cdn_url:null}function Es(e){var t;return(((t=e.answers)==null?void 0:t.length)??0)>1}function fd(e){const t=e.answers??[],n=[];return t.forEach(r=>{const o=e.options.findIndex(s=>s===r);o>=0&&n.push(o)}),n.sort((r,o)=>r-o)}const pd=h.memo(function(){const t=Ue(c=>c.phase),n=Ue(c=>c.quizzes),r=Ue(c=>c.order),o=Ue(c=>c.currentIndex),s=Ue(c=>c.answers),i=Ue(c=>c.correctCount),u=Ue(c=>c.remainingSec),a=Ue(c=>c.uiReveal),l=Ue(c=>c.startedAt),d=Ue(c=>c.finishedAt),m=Ue(c=>c.perQ),p=vs();h.useEffect(()=>{if(t==="idle"||t!=="doing"||u==null)return;const c=window.setInterval(()=>p.getState().tick(),1e3);return()=>window.clearInterval(c)},[t,u,p]);const b=t==="doing"?n[r[o]]:void 0,S=t==="doing"&&b?s[b.qid]??[]:[],w=h.useMemo(()=>{if(t==="idle"||t!=="finished")return;const c=r.map(B=>n[B]),f=c.length,g=c.reduce((B,$)=>B+($.score??0),0),C=c.reduce((B,$)=>{const te=m[$.qid];return B+(te!=null&&te.isCorrect?$.score??0:0)},0),T=c.map(B=>m[B.qid]).filter(B=>!!B),M=typeof l=="number"&&typeof d=="number"?Math.max(0,d-l):T.reduce((B,$)=>B+($.ms??0),0),E=f>0?Math.round(M/f):0,x=[...T].sort((B,$)=>B.ms-$.ms),y=x[0],R=x[x.length-1],k=T.filter(B=>!B.multi),O=T.filter(B=>B.multi),P=k.filter(B=>B.isCorrect).length,I=O.filter(B=>B.isCorrect).length,_=T.filter(B=>B.timedOut).length,z=T.filter(B=>B.revealed).length,N=T.filter(B=>!B.isCorrect).sort((B,$)=>$.ms-B.ms).slice(0,3);return{total:f,correct:i,rate:f?Math.round(i/f*100):0,timeMsTotal:M,avgMs:E,totalScore:g,gainedScore:C,fastest:y,slowest:R,singles:{total:k.length,correct:P},multis:{total:O.length,correct:I},timedOut:_,revealed:z,wrongTop3:N}},[t,r,n,m,l,d,i]);return t==="idle"?null:v.jsx("div",{className:ae.Overlay,role:"dialog","aria-modal":"true",children:v.jsx("div",{className:ae.Dialog,children:t==="doing"&&b?v.jsx(gd,{q:b,index:o,total:r.length,selected:S,uiReveal:a,onSelect:c=>{if(a)return;const f=p.getState();Es(b)?f.selectToggle(c):f.selectSingle(c)},onBeforeNext:()=>p.getState().setReveal(!0),onNext:()=>p.getState().afterRevealNext(),remainingSec:u,onClose:()=>p.getState().close()}):v.jsx(hd,{total:r.length,correct:i,summary:w,retryAllowed:p.getState().retryAllowed,onClose:()=>p.getState().close(),onRetry:()=>{const f=p.getState().quizzes;if(!f.length)return;const g=f[0];p.setState({phase:"doing",currentIndex:0,answers:{},correctCount:0,startedAt:Date.now(),finishedAt:void 0,questionStartedAt:Date.now(),remainingSec:g.limit_sec||void 0,uiReveal:!1,perQ:{}})}})})})});function gd(e){const{q:t,index:n,total:r,selected:o,uiReveal:s,onSelect:i,onBeforeNext:u,onNext:a,remainingSec:l,onClose:d}=e,m=Es(t),p=h.useMemo(()=>{const c=t.options.map((f,g)=>({opt:f,i:g}));for(let f=c.length-1;f>0;f--){const g=Math.floor(Math.random()*(f+1));[c[f],c[g]]=[c[g],c[f]]}return c},[t.options]),b=h.useMemo(()=>dd(t),[t]),S=h.useMemo(()=>fd(t),[t]),w=h.useMemo(()=>{const c=[...o].sort((f,g)=>f-g);if(c.length!==S.length)return!1;for(let f=0;f<c.length;f++)if(c[f]!==S[f])return!1;return!0},[o,S]);return v.jsxs("div",{className:ae.Body,children:[v.jsxs("div",{className:ae.Header,children:[v.jsx("div",{className:ae.Paging,children:`Quiz (${n+1}/${r})`}),v.jsx("button",{type:"button",onClick:d,className:ae.CloseBtn,children:"X"})]}),v.jsx("div",{className:ae.Question,children:t.question}),v.jsx("div",{className:ae.Score,children:` (${t.score}점${m?" ,모두선택":""})`}),v.jsx("div",{className:`${ae.Judge}${s?w?` ${ae.Correct}`:` ${ae.Incorrect}`:""}`,"aria-live":"polite",children:s?w?`Correct : +${t.score} point`:"Incorrect : 0 point":"a"}),v.jsx("div",{className:ae.Image,children:b&&v.jsx("img",{src:b,alt:""})}),v.jsx("div",{className:ae.Options,children:p.map(({opt:c,i:f})=>{const g=o.includes(f),C=S.includes(f),T=[ae.OptionBtn,g?ae.OptionBtnActive:"",s&&C?ae.OptionBtnCorrect:""].filter(Boolean).join(" ");return v.jsx("button",{type:"button",onClick:()=>i(f),className:T,disabled:s,children:c},f)})}),v.jsx("div",{className:ae.Footer,children:s?v.jsx("button",{type:"button",onClick:a,className:ae.NextBtn,children:n+1>=r?"Complete":"Next Quiz"}):v.jsxs("button",{type:"button",onClick:u,className:`${ae.NextBtn}`,children:["Submit",typeof l=="number"&&v.jsx("span",{className:`${ae.Remaining} ${l<=5?ae.RemainingDanger:""}`,children:` (${l} s )`})]})})]})}function Eo(e){return e==null?"-":`${Math.round(e/1e3)}s`}function hd(e){const{total:t,correct:n,summary:r,retryAllowed:o,onClose:s,onRetry:i}=e,u=(r==null?void 0:r.rate)??(t>0?Math.round(n/t*100):0);return v.jsxs("div",{className:ae.Body,children:[v.jsx("div",{className:ae.ResultHeader,children:"결과 요약"}),v.jsxs("div",{className:ae.SummaryGrid,role:"list",children:[v.jsxs("div",{className:ae.StatCard,role:"listitem",children:[v.jsx("div",{className:ae.StatLabel,children:"정답률"}),v.jsxs("div",{className:ae.StatValue,children:[u,"%"]}),v.jsx("div",{className:ae.StatSub,children:`정답수 ${n}/문제수${t}`})]}),v.jsxs("div",{className:ae.StatCard,role:"listitem",children:[v.jsx("div",{className:ae.StatLabel,children:"총 점수"}),v.jsx("div",{className:ae.StatValue,children:r?`${r.gainedScore}/${r.totalScore}`:"-"}),v.jsx("div",{className:ae.StatSub,children:"획득점수/최대점수"})]}),v.jsxs("div",{className:ae.StatCard,role:"listitem",children:[v.jsx("div",{className:ae.StatLabel,children:"총 소요 시간"}),v.jsx("div",{className:ae.StatValue,children:Eo(r==null?void 0:r.timeMsTotal)}),v.jsx("div",{className:ae.StatSub,children:`평균 ${Eo(r==null?void 0:r.avgMs)}`})]}),v.jsxs("div",{className:ae.StatCard,role:"listitem",children:[v.jsx("div",{className:ae.StatLabel,children:"타입오버 퀴즈수"}),v.jsx("div",{className:ae.StatValue,children:r?`${r.timedOut}`:"-"}),v.jsx("div",{className:ae.StatSub,children:"timeout"})]})]}),v.jsxs("div",{className:ae.ResultActions,children:[o&&v.jsx("button",{type:"button",onClick:i,className:ae.CloseBtnSoft,children:"다시 풀기"}),v.jsx("button",{type:"button",onClick:s,className:ae.CloseBtnSoft,children:"닫기"})]})]})}function md(e){return e.map((t,n)=>n)}function bd(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Yn(e){var t;return(((t=e.answers)==null?void 0:t.length)??0)>1}function Qn(e){const t=e.answers??[],n=[];return t.forEach(r=>{const o=e.options.findIndex(s=>s===r);o>=0&&n.push(o)}),n.sort((r,o)=>r-o)}function jo(e){if(!e)return{};const t=(e.quizzes??[]).slice().sort((n,r)=>n.index-r.index);return{sectionId:e.section_id,quizzes:t,order:md(t),currentIndex:0,answers:{},correctCount:0,startedAt:void 0,finishedAt:void 0,questionStartedAt:void 0,remainingSec:void 0,uiReveal:!1,perQ:{}}}function xd(e,t){const n=(t==null?void 0:t.retryAllowed)??!0,r=(t==null?void 0:t.previousResult)??null,o={phase:"idle",sectionId:void 0,quizzes:[],order:[],currentIndex:0,answers:{},correctCount:0,startedAt:void 0,finishedAt:void 0,questionStartedAt:void 0,remainingSec:void 0,uiReveal:!1,perQ:{},retryAllowed:n,previousResult:r},s=jo(e);return qt()((u,a)=>({...o,...s,hydrateFromSection:l=>{if(!l)return;const d=jo(l);u(d)},openFromSection:l=>{l&&a().hydrateFromSection(l);const d=a();if(!d.quizzes.length)return;if(!d.retryAllowed&&d.previousResult){const p={};for(const b of d.previousResult.perQuestion)p[b.qid]={qid:b.qid,index:b.index,question:b.question,score:b.score,multi:b.correctIdxes.length>1,selected:b.selected,correctIdxes:b.correctIdxes,isCorrect:b.isCorrect,ms:b.ms,revealed:!0,timedOut:b.timedOut};u({phase:"finished",correctCount:d.previousResult.correct,perQ:p,startedAt:void 0,finishedAt:void 0});return}const m=d.quizzes[0];u({phase:"doing",startedAt:Date.now(),finishedAt:void 0,questionStartedAt:Date.now(),remainingSec:m.limit_sec||void 0,currentIndex:0,uiReveal:!1})},close:()=>{u({phase:"idle",sectionId:void 0,quizzes:[],order:[],currentIndex:0,answers:{},correctCount:0,startedAt:void 0,finishedAt:void 0,questionStartedAt:void 0,remainingSec:void 0,uiReveal:!1,perQ:{}})},selectToggle:l=>{const d=a();if(d.phase!=="doing"||d.uiReveal)return;const p=d.quizzes[d.order[d.currentIndex]].qid,b=d.answers[p]??[],S=b.includes(l)?b.filter(w=>w!==l):[...b,l].sort((w,c)=>w-c);u({answers:{...d.answers,[p]:S}})},selectSingle:l=>{const d=a();if(d.phase!=="doing"||d.uiReveal)return;const p=d.quizzes[d.order[d.currentIndex]].qid;u({answers:{...d.answers,[p]:[l]}})},submitCurrent:()=>{const l=a();if(l.phase!=="doing")return;const d=l.order[l.currentIndex],m=l.quizzes[d],p=m.qid,b=(l.answers[p]??[]).slice().sort((C,T)=>C-T),S=Qn(m),w=bd(b,S),c=l.questionStartedAt?Date.now()-l.questionStartedAt:0,f=l.perQ[p],g={qid:p,index:m.index,question:m.question,score:m.score??0,multi:Yn(m),selected:b,correctIdxes:S,isCorrect:w,ms:c,revealed:(f==null?void 0:f.revealed)??!1,timedOut:(f==null?void 0:f.timedOut)??!1};if(u({correctCount:l.correctCount+(w?1:0),perQ:{...l.perQ,[p]:g}}),l.currentIndex+1>=l.order.length)u({uiReveal:!1,remainingSec:void 0}),a().finish();else{const C=l.currentIndex+1;u({currentIndex:C,questionStartedAt:Date.now(),remainingSec:l.quizzes[l.order[C]].limit_sec||void 0,uiReveal:!1})}},setReveal:l=>{const d=a();if(d.phase==="doing"){if(l){const m=d.quizzes[d.order[d.currentIndex]],p=m.qid,b=d.perQ[p],S={qid:p,index:m.index,question:m.question,score:m.score??0,multi:Yn(m),selected:(b==null?void 0:b.selected)??[],correctIdxes:(b==null?void 0:b.correctIdxes)??Qn(m),isCorrect:(b==null?void 0:b.isCorrect)??!1,ms:(b==null?void 0:b.ms)??0,revealed:!0,timedOut:(b==null?void 0:b.timedOut)??!1};u({perQ:{...d.perQ,[p]:S}})}u({uiReveal:l})}},afterRevealNext:()=>{a().phase==="doing"&&a().submitCurrent()},next:()=>{const l=a();if(l.phase!=="doing"||l.currentIndex+1>=l.order.length)return;const d=l.currentIndex+1;u({currentIndex:d,questionStartedAt:Date.now(),remainingSec:l.quizzes[l.order[d]].limit_sec||void 0,uiReveal:!1})},prev:()=>{const l=a();if(l.phase!=="doing"||l.currentIndex<=0)return;const d=l.currentIndex-1;u({currentIndex:d,questionStartedAt:Date.now(),remainingSec:l.quizzes[l.order[d]].limit_sec||void 0,uiReveal:!1})},finish:()=>{u({phase:"finished",remainingSec:void 0,uiReveal:!1,finishedAt:Date.now()})},tick:()=>{const l=a();if(l.phase!=="doing"||l.remainingSec==null)return;const d=l.remainingSec-1;if(d<=0){const m=l.quizzes[l.order[l.currentIndex]],p=m.qid,b=l.perQ[p],S={qid:p,index:m.index,question:m.question,score:m.score??0,multi:Yn(m),selected:(b==null?void 0:b.selected)??[],correctIdxes:(b==null?void 0:b.correctIdxes)??Qn(m),isCorrect:(b==null?void 0:b.isCorrect)??!1,ms:(b==null?void 0:b.ms)??0,revealed:!0,timedOut:!0};u({remainingSec:0,uiReveal:!0,perQ:{...l.perQ,[p]:S}})}else u({remainingSec:d})}}))}function vd({children:e,initialState:t}){const n=h.useMemo(()=>xd(t.section,{retryAllowed:t.quizRetryAllowed??!0,previousResult:t.previousQuizResult??null}),[t]),r=h.useRef(t.onQuizComplete);return h.useEffect(()=>{r.current=t.onQuizComplete},[t.onQuizComplete]),h.useEffect(()=>{const o=n.subscribe((s,i)=>{if(i.phase!=="finished"&&s.phase==="finished"){const u=r.current;if(!u||!s.retryAllowed&&s.previousResult&&!s.startedAt)return;const{sectionId:a,quizzes:l,order:d,perQ:m,startedAt:p,finishedAt:b}=s,S=d.map(E=>l[E]),w=S.length,c=S.filter(E=>{var x;return(x=m[E.qid])==null?void 0:x.isCorrect}).length,f=S.reduce((E,x)=>E+(x.score??0),0),g=S.reduce((E,x)=>{const y=m[x.qid];return E+(y!=null&&y.isCorrect?x.score??0:0)},0),C=typeof p=="number"&&typeof b=="number"?Math.max(0,b-p):0,T=S.map(E=>{const x=m[E.qid];return{qid:E.qid,index:E.index,question:E.question,score:E.score??0,isCorrect:(x==null?void 0:x.isCorrect)??!1,selected:(x==null?void 0:x.selected)??[],correctIdxes:(x==null?void 0:x.correctIdxes)??[],ms:(x==null?void 0:x.ms)??0,timedOut:(x==null?void 0:x.timedOut)??!1}}),M={sectionId:a??"",total:w,correct:c,rate:w>0?Math.round(c/w*100):0,totalScore:f,gainedScore:g,timeMsTotal:C,perQuestion:T};u(M)}});return()=>o()},[n]),v.jsx(wr.Provider,{value:n,children:e})}const Oo=["mode","theme","fontFamily","fontSizePx","lineHeight","marginX","marginY","pointerStyle","pointerColor","breakMarks","breakGapPx","muteAudio","audioSpeed","showPointer","showSplit","showOverlays","overlayCompactMode","isSettingsOpen"];function Sd({containerRef:e}){const t=wt(),n=gn(),r=h.useRef(null);return h.useEffect(()=>{const o=e.current;if(!o)return;let s=o.clientWidth,i=o.clientHeight;n.getState().setViewportSize(s,i);const u=new ResizeObserver(()=>{const a=o.clientWidth,l=o.clientHeight;(a!==s||l!==i)&&(s=a,i=l,n.getState().setViewportSize(a,l),t.getState().emit({type:"viewport_resize",payload:{width:a,height:l}}))});return u.observe(o),()=>u.disconnect()},[t,n,e]),h.useEffect(()=>{const o=n.getState();r.current={};for(const i of Oo)r.current[i]=o[i];const s=n.subscribe(i=>{const u=r.current;if(u)for(const a of Oo){const l=u[a],d=i[a];l!==d&&(a==="mode"?t.getState().emit({type:"mode_change",payload:{mode:d}}):t.getState().emit({type:"settings_change",payload:{key:a,value:d}}),u[a]=d)}});return()=>{s(),r.current=null}},[t,n]),null}function yd(){const e=wt(),t=gn(),n=vt(),r=h.useContext(Ao),o=h.useContext(vn),s=h.useCallback(a=>{const{viewerState:l}=a;if(l){l.mode&&t.getState().setMode(l.mode);const{...p}=l;t.setState(p)}if(typeof a.globalIndex=="number"&&n.getState().progress.setCurrentGlobalRunIndex(a.globalIndex,"playback"),(l==null?void 0:l.mode)==="scroll"||!(l!=null&&l.mode)){const p=()=>{const b=n.getState().progress.getSectionScrollApi();if(!b)return!1;if(a.scrollY===0)b.setScrollTop(0);else if(b.scrollToGIAtOffset){const S=a.anchorGI??a.globalIndex;if(typeof S=="number"){const w=a.anchorOffsetRatio??0;b.scrollToGIAtOffset(S,w)}}return!0};if(!p()){let b=0;const S=setInterval(()=>{(p()||++b>=10)&&clearInterval(S)},50)}}a.audio&&o&&o.getState()._setStatusOnly(a.audio.status);const m=n.getState().progress;a.range?m.setRange(a.range.startGI,a.range.endGI):m.clearRange(),a.translate&&a.translate.isOpen?m.setTranslateState({isOpen:!0,isLoading:a.translate.isLoading,text:a.translate.text,translatedText:a.translate.translatedText,startGI:a.translate.startGI,endGI:a.translate.endGI}):m.clearTranslate()},[t,n,o]),i=h.useCallback(()=>{var M,E,x,y;const a=t.getState(),l=n.getState().progress,d=(M=l.getSectionScrollApi)==null?void 0:M.call(l),m=l.currentGlobalRunIndex??0,p=((E=d==null?void 0:d.getScrollTop)==null?void 0:E.call(d))??0,b=((x=d==null?void 0:d.getAnchorOffsetRatio)==null?void 0:x.call(d,m))??0,S=o==null?void 0:o.getState(),w=S?{status:S.status,currentClip:S.currentClip,currentTimeMs:S.currentTimeMs}:void 0,{rangeStartGI:c,rangeEndGI:f}=l,g=c!=null&&f!=null?{startGI:c,endGI:f,text:l.getRangeText()}:null,C=((y=d==null?void 0:d.getScrollRatio)==null?void 0:y.call(d))??0,T=l.translateOpen?{isOpen:!0,isLoading:l.translateLoading,text:l.translateText,translatedText:l.translatedText,startGI:l.translateStartGI,endGI:l.translateEndGI}:null;return{viewerState:{mode:a.mode,theme:a.theme,fontFamily:a.fontFamily,fontSizePx:a.fontSizePx,lineHeight:a.lineHeight,marginX:a.marginX,marginY:a.marginY,showOverlays:a.showOverlays,isSettingsOpen:a.isSettingsOpen,pointerStyle:a.pointerStyle,pointerColor:a.pointerColor,breakMarks:a.breakMarks,breakGapPx:a.breakGapPx,muteAudio:a.muteAudio,audioSpeed:a.audioSpeed,showPointer:a.showPointer,showSplit:a.showSplit,overlayCompactMode:a.overlayCompactMode,viewportWidth:a.viewportWidth,viewportHeight:a.viewportHeight},globalIndex:m,scrollY:p,scrollRatio:C,anchorGI:m,anchorOffsetRatio:b,currentPage:l.pageIndex??0,totalPages:l.totalPages,sectionId:l.sectionId??"",viewportWidth:a.viewportWidth,viewportHeight:a.viewportHeight,audio:w,range:g,translate:T}},[t,n,o]),u=h.useCallback(a=>{switch(a.type){case"global_index_change":{const{globalIndex:l}=a.payload;n.getState().progress.setCurrentGlobalRunIndex(l,"playback");break}case"scroll":{if(t.getState().mode==="page")break;const{scrollTop:d,anchorGI:m,anchorOffsetRatio:p}=a.payload,b=n.getState().progress.getSectionScrollApi();b&&(d===0?b.setScrollTop(0):b.scrollToGIAtOffset&&typeof m=="number"&&b.scrollToGIAtOffset(m,p));break}case"settings_change":{const{key:l,value:d}=a.payload,m=t.getState();l in m&&typeof m[l]!="function"&&t.setState({[l]:d});break}case"mode_change":{const{mode:l}=a.payload;t.getState().setMode(l);break}case"audio_control":{if(!o)break;const{action:l}=a.payload;switch(l){case"play":o.getState()._setStatusOnly("playing");break;case"pause":o.getState()._setStatusOnly("paused");break;case"stop":o.getState()._setStatusOnly("idle");break}break}case"page_change":{const{pageIndex:l}=a.payload;n.getState().progress.setPageIndex(l);break}case"range_select":case"range_change":{const{startGI:l,endGI:d}=a.payload;console.log(`[DirectPlayback] ${a.type}: GI ${l}~${d}`),n.getState().progress.setRange(l,d);const m=n.getState().progress;console.log(`[DirectPlayback] after setRange: rangeStartGI=${m.rangeStartGI}, rangeEndGI=${m.rangeEndGI}`);break}case"range_clear":{console.log("[DirectPlayback] range_clear"),n.getState().progress.clearRange();break}case"translate_request":{const{text:l,startGI:d,endGI:m}=a.payload;n.getState().progress.setTranslateState({isOpen:!0,text:l,startGI:d,endGI:m});break}case"translate_loading_start":{n.getState().progress.setTranslateState({isOpen:!0,isLoading:!0});break}case"translate_loading_end":{const{translatedText:l}=a.payload;n.getState().progress.setTranslateState({isOpen:!0,isLoading:!1,translatedText:l});break}case"translate_modal_close":{n.getState().progress.clearTranslate();break}case"render_start":case"loading_start":case"loading_end":case"viewport_resize":break;default:console.log("[DirectPlaybackController] 미처리 이벤트:",a.type)}},[n,t,o]);return h.useLayoutEffect(()=>r?(r.current={dispatch:u,applySnapshot:s,getSnapshot:i,isReady:()=>!n.getState().progress.sectionLoading,waitUntilReady:()=>new Promise(l=>{if(!n.getState().progress.sectionLoading){l();return}const d=n.subscribe(m=>{m.progress.sectionLoading||(d(),l())})})},e.getState().isPlaybackMode&&(e.getState().setDispatchHandler(u),e.getState().setApplySnapshotHandler(s)),()=>{e.getState().setDispatchHandler(null),e.getState().setApplySnapshotHandler(null)}):void 0,[r,e,u,s,i,n]),h.useLayoutEffect(()=>e.subscribe((l,d)=>{l.isPlaybackMode&&!d.isPlaybackMode?(e.getState().setDispatchHandler(u),e.getState().setApplySnapshotHandler(s)):!l.isPlaybackMode&&d.isPlaybackMode&&(e.getState().setDispatchHandler(null),e.getState().setApplySnapshotHandler(null))}),[e,u,s]),null}const wd=({containerRef:e,onTranslate:t})=>{const n=U(p=>p.rangeStartGI),r=U(p=>p.rangeEndGI),o=U(p=>p.getRangeText),s=U(p=>p.clearRange),i=wt(),u=n!=null&&r!=null,[a,l]=h.useState(null);h.useEffect(()=>{if(!u)return;const p=e.current;if(!p)return;let b=!0;const S=new ResizeObserver(()=>{if(b){b=!1;return}s()});return S.observe(p),()=>S.disconnect()},[u,s,e]),h.useEffect(()=>{if(!u||n==null||r==null){l(null);return}const p=()=>{const S=e.current;if(!S)return;const w=S.getBoundingClientRect(),f=1/(i.getState().playbackScale||1),g=S.querySelector(`[data-g="${r}"]`);if(!g){l({x:w.width*f/2,y:80});return}const C=g.getBoundingClientRect(),T=S.querySelector(`[data-g="${n}"]`),M=T==null?void 0:T.getBoundingClientRect();let E=(C.left+C.width/2-w.left)*f;M&&(E=((M.left+C.right)/2-w.left)*f);const x=160,y=50,R=16,k=12,O=w.width*f,P=Math.max(R+x/2,Math.min(E,O-R-x/2)),I=(((M==null?void 0:M.top)??C.top)-w.top)*f-y-k;let _=I;I<R&&(_=(C.bottom-w.top)*f+k),l({x:P,y:_})};p();const b=e.current;return b&&b.addEventListener("scroll",p,!0),()=>{b&&b.removeEventListener("scroll",p,!0)}},[u,n,r,e,i]);const d=h.useCallback(()=>{const p=o();p&&navigator.clipboard.writeText(p).catch(b=>{console.error("복사 실패:",b)}),s()},[o,s]),m=h.useCallback(()=>{const p=o();p&&t&&t(p)},[o,t]);return!u||!a?null:v.jsxs("div",{"data-range-menu":!0,style:{position:"absolute",left:a.x,top:a.y,transform:"translateX(-50%)",display:"flex",gap:8,padding:"8px 12px",backgroundColor:"#fff",borderRadius:8,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.3)",zIndex:1e4},children:[v.jsx("button",{onClick:d,style:{padding:"8px 16px",backgroundColor:"#3b82f6",color:"#fff",border:"none",borderRadius:6,fontSize:14,fontWeight:500,cursor:"pointer"},children:"복사"}),v.jsx("button",{onClick:m,style:{padding:"8px 16px",backgroundColor:"#10b981",color:"#fff",border:"none",borderRadius:6,fontSize:14,fontWeight:500,cursor:"pointer"},children:"번역"})]})},Cd="_handleStart_1ihf3_16 _handle_1ihf3_1",Id="_handleEnd_1ihf3_21 _handle_1ihf3_1",zo={handleStart:Cd,handleEnd:Id},Td=({containerRef:e})=>{const t=U(f=>f.rangeStartGI),n=U(f=>f.rangeEndGI),r=U(f=>f.setRange),o=wt(),s=t!=null&&n!=null,[i,u]=h.useState(null),[a,l]=h.useState(null),d=h.useRef(null),m=h.useRef(null);h.useEffect(()=>{if(!s||t==null||n==null){u(null),l(null);return}const f=()=>{const C=e.current;if(!C)return;const T=C.getBoundingClientRect(),E=1/(o.getState().playbackScale||1),x=C.querySelector(`[data-g="${t}"]`),y=C.querySelector(`[data-g="${n}"]`);if(x){const R=x.getBoundingClientRect();u({x:(R.left-T.left)*E,y:(R.bottom-T.top)*E})}else u(null);if(y){const R=y.getBoundingClientRect();l({x:(R.right-T.left)*E,y:(R.bottom-T.top)*E})}else l(null)};f();const g=e.current;return g&&g.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{g&&g.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[s,t,n,e,o]);const p=h.useCallback((f,g)=>{var T;const C=document.elementsFromPoint(f,g);for(const M of C){const E=(T=M.getAttribute)==null?void 0:T.call(M,"data-g");if(E!=null)return parseInt(E,10)}return null},[]),b=h.useCallback(f=>g=>{g.preventDefault(),g.stopPropagation(),d.current=f,m.current=f==="start"?t:n,g.target.setPointerCapture(g.pointerId)},[t,n]),S=h.useCallback(f=>{if(!d.current||t==null||n==null)return;const g=p(f.clientX,f.clientY);g!=null&&(d.current==="start"?g<=n?r(g,n):(r(n,g),d.current="end"):g>=t?r(t,g):(r(g,t),d.current="start"))},[t,n,r,p]),w=h.useCallback(f=>{d.current=null,m.current=null,f.target.releasePointerCapture(f.pointerId)},[]);return s?v.jsxs(v.Fragment,{children:[i&&v.jsx("div",{className:zo.handleStart,"data-range-handle":"start",style:{left:i.x-26,top:i.y},onPointerDown:b("start"),onPointerMove:S,onPointerUp:w,onPointerCancel:w}),a&&v.jsx("div",{className:zo.handleEnd,"data-range-handle":"end",style:{left:a.x,top:a.y},onPointerDown:b("end"),onPointerMove:S,onPointerUp:w,onPointerCancel:w})]}):null};function kd(){const e=U(o=>o.rangeStartGI),t=U(o=>o.rangeEndGI),n=U(o=>o.clearRange),r=e!=null&&t!=null;return h.useEffect(()=>{if(!r)return;const o=s=>{var u;const i=s.target;if(!(i.closest("[data-range-menu]")||i.closest("[data-range-handle]"))){if(i.closest("[data-g]")){const a=(u=i.closest("[data-g]"))==null?void 0:u.getAttribute("data-g");if(a){const l=parseInt(a,10),d=Math.min(e,t),m=Math.max(e,t);if(l>=d&&l<=m)return}}n()}};return document.addEventListener("click",o,!0),()=>document.removeEventListener("click",o,!0)},[r,e,t,n]),null}const Rd=({isOpen:e,onClose:t,text:n})=>e?v.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:10001},onClick:t,children:v.jsxs("div",{style:{position:"relative",backgroundColor:"#fff",borderRadius:12,padding:"24px 32px",minWidth:280,maxWidth:"80%",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.2)"},onClick:r=>r.stopPropagation(),children:[v.jsx("button",{onClick:t,style:{position:"absolute",top:12,right:12,width:28,height:28,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"transparent",border:"none",borderRadius:"50%",cursor:"pointer",fontSize:20,color:"#666"},"aria-label":"닫기",children:"✕"}),v.jsx("h3",{style:{margin:"0 0 16px 0",fontSize:18,fontWeight:600,color:"#333"},children:"번역"}),v.jsx("p",{style:{margin:0,fontSize:16,color:"#666",textAlign:"center",padding:"16px 0"},children:"준비중입니다"}),n&&v.jsxs("div",{style:{marginTop:16,padding:12,backgroundColor:"#f5f5f5",borderRadius:8,fontSize:14,color:"#888",maxHeight:100,overflow:"auto"},children:[v.jsx("span",{style:{fontWeight:500},children:"선택된 텍스트: "}),n]})]})}):null,_d=(e,t,n)=>Math.min(n,Math.max(t,e));function Md({section:e,initialViewerState:t,initialProgressRunIndex:n,onViewerClose:r,onSectionNav:o,isCanPrev:s=!1,isCanNext:i=!1,onQuizComplete:u,quizRetryAllowed:a,previousQuizResult:l,onViewerEvent:d,viewerRef:m,gazeSync:p,isPlaybackMode:b=!1,playbackScale:S,isDev:w=!1}){const c=String((e==null?void 0:e.section_id)??"0"),f=h.useMemo(()=>{var x,y;const M=((x=e==null?void 0:e.ast)==null?void 0:x.blocks)??[];let E=0;for(const R of M)(R==null?void 0:R.type)!=="image"&&(E+=((y=R==null?void 0:R.runs)==null?void 0:y.length)??0);return E},[e]),g=h.useMemo(()=>typeof n=="number"?_d(n,f>0?0:-1,Math.max(f-1,-1)):(f>0,0),[n,f]),C=h.useMemo(()=>({section:e,initialIndex:g,onViewerClose:r,onSectionNav:o,isCanPrev:s,isCanNext:i}),[e,g,r,o,s,i]),T=h.useMemo(()=>{const M=(e==null?void 0:e.audios)??[],E=M.length>0?Zc(e):void 0;return{clips:M,map:E,initialIndex:g,section:e}},[e,g]);return v.jsx(Us,{onViewerEvent:d,isPlaybackMode:b,playbackScale:S,viewerRef:m,children:v.jsx(ou,{initialState:{...t,isDev:w},children:v.jsx(ru,{initialState:C,gazeSync:p,children:v.jsx(Qc,{initialState:T,children:v.jsx(vd,{initialState:{section:e,onQuizComplete:u,quizRetryAllowed:a,previousQuizResult:l},children:v.jsx(Ed,{})},c)},c)},c)})})}function Ed(){const e=J(d=>d.mode),t=h.useRef(null),n=wt(),r=vt(),o=U(d=>d.translateOpen),s=U(d=>d.translateText),i=h.useCallback(d=>{const{rangeStartGI:m,rangeEndGI:p}=r.getState().progress;r.getState().progress.setTranslateState({isOpen:!0,text:d,startGI:m??0,endGI:p??0}),n.getState().emit({type:"translate_request",payload:{text:d,startGI:m??0,endGI:p??0}})},[n,r]),u=h.useCallback(()=>{r.getState().progress.clearTranslate(),n.getState().emit({type:"translate_modal_close",payload:{}})},[n,r]),a=d=>{d.preventDefault()},l=d=>{d.preventDefault()};return v.jsxs("div",{ref:t,onContextMenu:a,onDragStart:l,style:{position:"relative",display:"flex",flexDirection:"column",height:"100%",width:"100%",userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"none"},children:[e==="scroll"?v.jsx(ga,{}):v.jsx(ju,{}),v.jsx(wd,{containerRef:t,onTranslate:i}),v.jsx(Td,{containerRef:t}),v.jsx($c,{}),v.jsx(pd,{}),v.jsx(Au,{}),v.jsx(kd,{}),v.jsx(Rd,{isOpen:o,onClose:u,text:s}),v.jsx(Sd,{containerRef:t}),v.jsx(yd,{})]})}exports.CRViewer=Md;
|