From a891f64ba9f694f28546993be79f79f3157982b8 Mon Sep 17 00:00:00 2001 From: Yiannis Christodoulou Date: Mon, 13 Oct 2025 00:34:13 +0300 Subject: [PATCH] build assets --- static/chapters_editor/chapters-editor.js | 2 +- static/chapters_editor/chapters-editor.js.map | 2 +- static/video_js/video-js.css | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/static/chapters_editor/chapters-editor.js b/static/chapters_editor/chapters-editor.js index f8d05855..e5aa78d8 100644 --- a/static/chapters_editor/chapters-editor.js +++ b/static/chapters_editor/chapters-editor.js @@ -199,5 +199,5 @@ Check the render method of %s.`,Ge(ta)||"Unknown"));var u=Yr(i,o);u.payload={ele let root = createRoot(domContainer); root.render();`),t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(i=t.onRecoverableError),t.transitionCallbacks!==void 0&&t.transitionCallbacks);var o=oS(e,Ys,null,n,a,r,i);Hs(o.current,e);var l=e.nodeType===vn?e.parentNode:e;return Xl(l),new lm(o)}function Xc(e){this._internalRoot=e}function QD(e){e&&fE(e)}Xc.prototype.unstable_scheduleHydration=QD;function KD(e,t,n){if(!Qc(e))throw new Error("hydrateRoot(...): Target container is not a DOM element.");_S(e),t===void 0&&c("Must provide initial children as second argument to hydrateRoot. Example usage: hydrateRoot(domContainer, )");var a=n??null,r=n!=null&&n.hydratedSources||null,i=!1,o=!1,l="",u=DS;n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(l=n.identifierPrefix),n.onRecoverableError!==void 0&&(u=n.onRecoverableError));var f=lS(t,null,e,Ys,a,i,o,l,u);if(Hs(f.current,e),Xl(e),r)for(var d=0;d2&&arguments[2]!==void 0?arguments[2]:null;if(!Qc(t))throw new Error("Target container is not a DOM element.");return zD(e,t,null,n)}function l_(e,t,n,a){return r_(e,t,n,a)}var sm={usingClientEntryPoint:!1,Events:[ci,Uo,zs,Pm,Ym,Fp]};function u_(e,t){return sm.usingClientEntryPoint||c('You are importing createRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client".'),XD(e,t)}function s_(e,t,n){return sm.usingClientEntryPoint||c('You are importing hydrateRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client".'),KD(e,t,n)}function c_(e){return Fb()&&c("flushSync was called from inside a lifecycle method. React cannot flush when React is already rendering. Consider moving this call to a scheduler task or micro task."),Gr(e)}var f_=GD({findFiberByHostInstance:Ii,bundleType:1,version:nm,rendererPackageName:"react-dom"});if(!f_&&Xe&&window.top===window.self&&(navigator.userAgent.indexOf("Chrome")>-1&&navigator.userAgent.indexOf("Edge")===-1||navigator.userAgent.indexOf("Firefox")>-1)){var AS=window.location.protocol;/^(https?|file):$/.test(AS)&&console.info("%cDownload the React DevTools for a better development experience: https://reactjs.org/link/react-devtools"+(AS==="file:"?` -You might need to use a local HTTP server (instead of file://): https://reactjs.org/link/react-devtools-faq`:""),"font-weight:bold")}ca.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=sm,ca.createPortal=o_,ca.createRoot=u_,ca.findDOMNode=t_,ca.flushSync=c_,ca.hydrate=n_,ca.hydrateRoot=s_,ca.render=a_,ca.unmountComponentAtNode=i_,ca.unstable_batchedUpdates=Fp,ca.unstable_renderSubtreeIntoContainer=l_,ca.version=nm,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}(),ca}pm.exports=zS();var FS=pm.exports,gm,bm=FS;{var Sm=bm.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;gm=function(L,D){Sm.usingClientEntryPoint=!0;try{return bm.createRoot(L,D)}finally{Sm.usingClientEntryPoint=!1}}}const Y=L=>{if(isNaN(L))return"00:00:00.000";const D=Math.floor(L/3600),ge=Math.floor(L%3600/60),Ne=Math.floor(L%60),Me=Math.round(L%1*1e3),X=String(D).padStart(2,"0"),c=String(ge).padStart(2,"0"),yt=String(Ne).padStart(2,"0"),me=String(Me).padStart(3,"0");return`${X}:${c}:${yt}.${me}`},wi=L=>Y(L),VS=L=>Y(L),ve={debug:(...L)=>{},error:(...L)=>console.error(...L),warn:(...L)=>console.warn(...L),info:(...L)=>console.info(...L)};var q=Zc();const BS=({videoRef:L,currentTime:D,duration:ge,isPlaying:Ne,isMuted:Me=!1,onPlayPause:X,onSeek:c,onToggleMute:yt})=>{var pt;const me=q.useRef(null),[ne,tt]=q.useState(!1),[oe,ze]=q.useState(!1),[Q,he]=q.useState(null),[W,cn]=q.useState(!1),gt=q.useRef(!1),[De,Oe]=q.useState({x:0}),[Lt,O]=q.useState(0),J=typeof window<"u"&&((pt=window.MEDIA_DATA)==null?void 0:pt.videoUrl)||"/videos/sample-video.mp4";q.useEffect(()=>{if(tt((()=>{const A=navigator.userAgent||navigator.vendor||window.opera;return/iPad|iPhone|iPod/.test(A)&&!window.MSStream})()),typeof window<"u"){const A=localStorage.getItem("video_initialized")==="true";ze(A)}},[]),q.useEffect(()=>{Ne&&!oe&&(ze(!0),typeof window<"u"&&localStorage.setItem("video_initialized","true"))},[Ne,oe]),q.useEffect(()=>{const le=L.current;if(!le)return;le.setAttribute("playsinline","true"),le.setAttribute("webkit-playsinline","true"),le.setAttribute("x-webkit-airplay","allow");const A=()=>{gt.current||(he(le.currentTime),typeof window<"u"&&(window.lastSeekedPosition=le.currentTime))},ye=()=>{ne&&(ze(!0),localStorage.setItem("video_initialized","true"))},Be=()=>{};return le.addEventListener("timeupdate",A),le.addEventListener("play",ye),le.addEventListener("pause",Be),()=>{le.removeEventListener("timeupdate",A),le.removeEventListener("play",ye),le.removeEventListener("pause",Be)}},[L,ne,gt]),q.useEffect(()=>{he(D)},[D]);const $e=ge>0?D/ge*100:0,dt=le=>{le.preventDefault(),cn(!0),gt.current=!0,vt(le);const A=Be=>{gt.current&&vt(Be)},ye=()=>{cn(!1),gt.current=!1,document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",ye)};document.addEventListener("mousemove",A),document.addEventListener("mouseup",ye)},vt=le=>{if(!me.current)return;const A=me.current.getBoundingClientRect(),ye=Math.max(0,Math.min(1,(le.clientX-A.left)/A.width)),Be=ge*ye;Oe({x:le.clientX}),O(Be),he(Be),typeof window<"u"&&(window.lastSeekedPosition=Be),c(Be)},Yt=le=>{if(!me.current||!le.touches[0])return;le.preventDefault(),cn(!0),gt.current=!0,_e(le);const A=Be=>{gt.current&&_e(Be)},ye=()=>{cn(!1),gt.current=!1,document.removeEventListener("touchmove",A),document.removeEventListener("touchend",ye),document.removeEventListener("touchcancel",ye)};document.addEventListener("touchmove",A,{passive:!1}),document.addEventListener("touchend",ye),document.addEventListener("touchcancel",ye)},_e=le=>{if(!me.current)return;const A="touches"in le?le.touches[0]:null;if(!A)return;le.preventDefault();const ye=me.current.getBoundingClientRect(),Be=Math.max(0,Math.min(1,(A.clientX-ye.left)/ye.width)),ot=ge*Be;Oe({x:A.clientX}),O(ot),he(ot),typeof window<"u"&&(window.lastSeekedPosition=ot),c(ot)},re=le=>{if(!W&&me.current){const A=me.current.getBoundingClientRect(),ye=(le.clientX-A.left)/A.width,Be=ge*ye;he(Be),typeof window<"u"&&(window.lastSeekedPosition=Be),c(Be)}},Ce=()=>{L.current&&(document.fullscreenElement?document.exitFullscreen():L.current.requestFullscreen())},ue=()=>{const le=L.current;le&&(le.paused?ne&&Q!==null&&Q>0?(le.currentTime=Q,setTimeout(()=>{L.current&&L.current.play().then(()=>{var A;ve.debug("iOS: Play started successfully at position:",(A=L.current)==null?void 0:A.currentTime),X()}).catch(A=>{console.error("iOS: Error playing video:",A)})},50)):le.play().then(()=>{X()}).catch(A=>{console.error("Error playing video:",A)}):(le.pause(),X()))};return v.jsxs("div",{className:"video-player-container",children:[v.jsxs("video",{ref:L,preload:"auto",crossOrigin:"anonymous",onClick:ue,playsInline:!0,"webkit-playsinline":"true","x-webkit-airplay":"allow",controls:!1,muted:Me,children:[v.jsx("source",{src:J,type:"video/mp4"}),v.jsx("p",{children:"Your browser doesn't support HTML5 video."})]}),ne&&!oe&&!Ne&&v.jsx("div",{className:"ios-first-play-indicator",children:v.jsx("div",{className:"ios-play-message",children:"Tap Play to initialize video controls"})}),v.jsx("div",{className:`play-pause-indicator ${Ne?"pause-icon":"play-icon"}`}),v.jsxs("div",{className:"video-controls",children:[v.jsxs("div",{className:"video-time-display",children:[v.jsx("span",{className:"video-current-time",children:wi(D)}),v.jsxs("span",{className:"video-duration",children:["/ ",wi(ge)]})]}),v.jsxs("div",{ref:me,className:`video-progress ${W?"dragging":""}`,onClick:re,onMouseDown:dt,onTouchStart:Yt,children:[v.jsx("div",{className:"video-progress-fill",style:{width:`${$e}%`}}),v.jsx("div",{className:"video-scrubber",style:{left:`${$e}%`}}),W&&v.jsx("div",{className:"video-time-tooltip",style:{left:`${De.x}px`,transform:"translateX(-50%)"},children:Y(Lt)})]}),v.jsxs("div",{className:"video-controls-buttons",children:[yt&&v.jsx("button",{className:"mute-button","aria-label":Me?"Unmute":"Mute",onClick:yt,"data-tooltip":Me?"Unmute":"Mute",children:Me?v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"}),v.jsx("path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12M15 9.34V4a3 3 0 0 0-5.94-.6"}),v.jsx("path",{d:"M17 16.95A7 7 0 0 1 5 12v-2m14 0v2a7 7 0 0 1-.11 1.23"}),v.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),v.jsx("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]}):v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),v.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"})]})}),v.jsx("button",{className:"fullscreen-button","aria-label":"Fullscreen",onClick:Ce,"data-tooltip":"Toggle fullscreen",children:v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:v.jsx("path",{fillRule:"evenodd",d:"M3 4a1 1 0 011-1h4a1 1 0 010 2H6.414l2.293 2.293a1 1 0 01-1.414 1.414L5 6.414V8a1 1 0 01-2 0V4zm9 1a1 1 0 010-2h4a1 1 0 011 1v4a1 1 0 01-2 0V6.414l-2.293 2.293a1 1 0 11-1.414-1.414L13.586 5H12zm-9 7a1 1 0 012 0v1.586l2.293-2.293a1 1 0 011.414 1.414L6.414 15H8a1 1 0 010 2H4a1 1 0 01-1-1v-4zm13-1a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 010-2h1.586l-2.293-2.293a1 1 0 011.414-1.414L15 13.586V12a1 1 0 011-1z",clipRule:"evenodd"})})})]})]})]})},$S=(L,D)=>{const ge=Math.min(Math.max(L/(D||1),0),1),Ne=210,Me=40+Math.floor(ge*20),X=85+Math.floor(ge*8);return`hsl(${Ne}, ${Me}%, ${X}%)`},Wu=({isOpen:L,onClose:D,title:ge,children:Ne,actions:Me})=>{if(q.useEffect(()=>{const c=yt=>{yt.key==="Escape"&&L&&D()};return document.addEventListener("keydown",c),L&&(document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",c),document.body.style.overflow=""}},[L,D]),!L)return null;const X=c=>{c.target===c.currentTarget&&D()};return v.jsx("div",{className:"modal-overlay",onClick:X,children:v.jsxs("div",{className:"modal-container",onClick:c=>c.stopPropagation(),children:[v.jsxs("div",{className:"modal-header",children:[v.jsx("h2",{className:"modal-title",children:ge}),v.jsx("button",{className:"modal-close-button",onClick:D,"aria-label":"Close modal",style:{minWidth:"24px",minHeight:"24px"},children:v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),v.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),v.jsx("div",{className:"modal-content",children:Ne}),Me&&v.jsx("div",{className:"modal-actions",children:Me})]})})},PS=async(L,D)=>{try{const ge=await fetch(`/api/v1/media/${L}/chapters`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)});if(ve.debug("response",ge),!ge.ok){if(ge.status===404)return{success:!0,timestamp:new Date().toISOString()};try{const Me=await ge.json();return{success:!1,timestamp:new Date().toISOString(),error:Me.error||"Auto-save failed (videoApi.ts)"}}catch{return{success:!1,timestamp:new Date().toISOString(),error:"Auto-save failed (videoApi.ts)"}}}const Ne=await ge.json();return{success:!0,timestamp:Ne.updated_at||new Date().toISOString(),...Ne}}catch{return{success:!0,timestamp:new Date().toISOString()}}},Tm="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20style='enable-background:new%200%200%20512%20512;'%20version='1.1'%20viewBox='0%200%20512%20512'%20xml:space='preserve'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cstyle%20type='text/css'%3e%20.st0{fill:%23333333;}%20.st1{fill:none;stroke:%23333333;stroke-width:32;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;}%20%3c/style%3e%3cg%20id='Layer_1'/%3e%3cg%20id='Layer_2'%3e%3cg%3e%3cpath%20class='st0'%20d='M350.45,277.5l-164.08,94.73c-16.55,9.56-37.24-2.39-37.24-21.5V161.27c0-19.11,20.69-31.06,37.24-21.5%20l164.08,94.73C367,244.06,367,267.94,350.45,277.5z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",Em="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20style='enable-background:new%200%200%20512%20512;'%20version='1.1'%20viewBox='0%200%20512%20512'%20xml:space='preserve'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cstyle%20type='text/css'%3e.st0{fill:%23333333;}.st1{fill:none;stroke:%23333333;stroke-width:32;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;}%3c/style%3e%3cg%20id='Layer_1'/%3e%3cg%20id='Layer_2'%3e%3cg%3e%3cg%3e%3cpath%20class='st0'%20d='M208.15,380.19h-91.19c-5.7,0-10.32-4.62-10.32-10.32V142.13c0-5.7,4.62-10.32,10.32-10.32h91.19%20c5.7,0,10.32,4.62,10.32,10.32v227.74C218.47,375.57,213.85,380.19,208.15,380.19z'/%3e%3c/g%3e%3cg%3e%3cpath%20class='st0'%20d='M395.04,380.19h-91.19c-5.7,0-10.32-4.62-10.32-10.32V142.13c0-5.7,4.62-10.32,10.32-10.32h91.19%20c5.7,0,10.32,4.62,10.32,10.32v227.74C405.36,375.57,400.74,380.19,395.04,380.19z'/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",Cm="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20style='enable-background:new%200%200%20512%20512;'%20version='1.1'%20viewBox='0%200%20512%20512'%20xml:space='preserve'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cstyle%20type='text/css'%3e.st0{fill:%23333333;}.st1{fill:none;stroke:%23333333;stroke-width:32;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;}%3c/style%3e%3cg%20id='Layer_1'/%3e%3cg%20id='Layer_2'%3e%3cg%3e%3cg%3e%3cpath%20class='st0'%20d='M85.26,277.5l164.08,94.73c16.55,9.56,37.24-2.39,37.24-21.5V161.27c0-19.11-20.69-31.06-37.24-21.5%20L85.26,234.5C68.71,244.06,68.71,267.94,85.26,277.5z'/%3e%3c/g%3e%3cg%3e%3cpath%20class='st0'%20d='M377.47,375.59h41.42c11.19,0,20.26-9.07,20.26-20.26V156.67c0-11.19-9.07-20.26-20.26-20.26h-41.42%20c-11.19,0-20.26,9.07-20.26,20.26v198.67C357.21,366.52,366.28,375.59,377.47,375.59z'/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",YS="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20height='32'%20viewBox='0%200%2032%2032'%20width='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle/%3e%3cg%20data-name='1'%20id='_1'%3e%3cpath%20d='M27,3V29a1,1,0,0,1-1,1H6a1,1,0,0,1-1-1V27H7v1H25V4H7V7H5V3A1,1,0,0,1,6,2H26A1,1,0,0,1,27,3Z'/%3e%3cg%20transform='translate(2,%200)'%3e%3cpath%20d='M10.71,20.29,7.41,17H18V15H7.41l3.3-3.29L9.29,10.29l-5,5a1,1,0,0,0,0,1.42l5,5Z'%20id='logout_account_exit_door'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",IS="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20height='32'%20viewBox='0%200%2032%2032'%20width='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20data-name='1'%20id='_1'%3e%3cpath%20d='M5,3V29a1,1,0,0,0,1,1H26a1,1,0,0,0,1-1V25H25v3H7V4H25V7h2V3a1,1,0,0,0-1-1H6A1,1,0,0,0,5,3Z'/%3e%3cg%20transform='translate(28,%200)%20scale(-1,%201)'%3e%3cpath%20d='M10.71,20.29,7.41,17H18V15H7.41l3.3-3.29L9.29,10.29l-5,5a1,1,0,0,0,0,1.42l5,5Z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",WS="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20height='32'%20viewBox='0%200%2032%2032'%20width='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20data-name='1'%20id='_1'%3e%3cpath%20d='M5,3V29a1,1,0,0,0,1,1H26a1,1,0,0,0,1-1V25H25v3H7V4H25V7h2V3a1,1,0,0,0-1-1H6A1,1,0,0,0,5,3Z'/%3e%3cg%20transform='translate(30,%200)%20scale(-1,%201)'%3e%3cpath%20d='M10.71,20.29,7.41,17H18V15H7.41l3.3-3.29L9.29,10.29l-5,5a1,1,0,0,0,0,1.42l5,5Z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",qS="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20height='32'%20viewBox='0%200%2032%2032'%20width='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle/%3e%3cg%20data-name='1'%20id='_1'%3e%3cpath%20d='M27,3V29a1,1,0,0,1-1,1H6a1,1,0,0,1-1-1V27H7v1H25V4H7V7H5V3A1,1,0,0,1,6,2H26A1,1,0,0,1,27,3Z'/%3e%3cg%20transform='translate(2,%200)'%3e%3cpath%20d='M10.71,20.29,7.41,17H18V15H7.41l3.3-3.29L9.29,10.29l-5,5a1,1,0,0,0,0,1.42l5,5Z'%20id='logout_account_exit_door'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",GS={color:"#007bff",textDecoration:"none",fontWeight:"bold","&:hover":{textDecoration:"underline",color:"#0056b3"}},xm=L=>{let X,c;if(L<=15)if(L<=0)X="0%",c="none";else{const me=-50*((L-0)/15);X=`${L}%`,c=`translateX(${me}%)`}else if(L>=75)if(L>=100)X="100%",c="translateX(-100%)";else{const me=-50-50*((L-75)/25);X=`${L}%`,c=`translateX(${me}%)`}else X=`${L}%`,c="translateX(-50%)";return{left:X,transform:c}},XS=({currentTime:L,duration:D,trimStart:ge,trimEnd:Ne,splitPoints:Me,zoomLevel:X,clipSegments:c,selectedSegmentId:yt,onSelectedSegmentChange:me,onSegmentUpdate:ne,onChapterSave:tt,onTrimStartChange:oe,onTrimEndChange:ze,onZoomChange:Q,onSeek:he,videoRef:W,hasUnsavedChanges:cn=!1,isIOSUninitialized:gt=!1,isPlaying:De,setIsPlaying:Oe,onPlayPause:Lt,isPlayingSegments:O=!1})=>{const J=q.useRef(null),$e=q.useRef(null),dt=q.useRef(null),[vt,Yt]=q.useState(null),_e=yt!==void 0?yt:vt,re=p=>{me?me(p):Yt(p)},[Ce,ue]=q.useState(!1),[pt,le]=q.useState({x:0,y:0}),[A,ye]=q.useState(0),[Be,ot]=q.useState(!1),[Et,Ot]=q.useState(30),[Vt,je]=q.useState(!1),[Ve,Je]=q.useState(null),[en,nt]=q.useState(0),[It,mt]=q.useState(!1),Xe=q.useRef(null),[hn,Kt]=q.useState(""),[Nn,z]=q.useState(!1),Ee=[...c].sort((p,R)=>p.startTime-R.startTime).find(p=>p.id===_e),[Te,Pe]=q.useState(""),[at,Ze]=q.useState(!1),we=q.useRef(null),lt=q.useRef(c);q.useEffect(()=>{lt.current=c},[c]);const _t=q.useCallback(async()=>{var p;try{Ze(!0);const R=lt.current.map(_=>({startTime:Y(_.startTime),endTime:Y(_.endTime),chapterTitle:_.chapterTitle}));ve.debug("chapters",R);const y=typeof window<"u"&&((p=window.MEDIA_DATA)==null?void 0:p.mediaId)||null||"1234";if(ve.debug("mediaId",y),!y||R.length===0){ve.debug("No mediaId or segments, skipping auto-save"),Ze(!1);return}ve.debug("Auto-saving segments:",{mediaId:y,chapters:R});const E=await PS(y,{chapters:R});if(E.success===!0){ve.debug("Auto-save successful");const S=new Date(E.updated_at||new Date().toISOString()).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).replace(",","");Pe(S),ve.debug("Auto-save successful:",S)}else ve.error("Auto-save failed: (TimelineControls.tsx)")}catch(R){ve.error("Auto-save error: (TimelineControls.tsx)",R)}finally{Ze(!1)}},[]),ht=q.useCallback(()=>{we.current&&clearTimeout(we.current);const p=setTimeout(()=>{_t()},1e3);we.current=p},[_t]);q.useEffect(()=>{Kt(Ee&&Ee.chapterTitle||"")},[_e,Ee]);const Jt=p=>{Kt(p),z(!0),_e&&ne&&ne(_e,{chapterTitle:p})},Wt=p=>{const R=p;let T=null,y=null,E=A;const _=()=>{const S=R<0?Math.max(0,E+R):Math.min(D,E+R);E=S;const V=Vt;if(he(S),ye(S),nt(S),J.current){const B=J.current.getBoundingClientRect(),K=S/D*100,Le=B.left+B.width*(K/100);le({x:Le,y:B.top-10});const F=c.find(Ke=>S>=Ke.startTime&&S<=Ke.endTime);if(F)re(F.id),ue(!1);else{re(null);const Ke=va(S);Ot(Ke),ue(!0)}}V&&W.current&&(W.current.play(),je(!0))};return{onMouseDown:S=>{S.stopPropagation(),S.preventDefault(),E=A,_(),T=setTimeout(()=>{y=setInterval(_,200)},750);const V=()=>{T&&(clearTimeout(T),T=null),y&&(clearInterval(y),y=null),document.removeEventListener("mouseup",V),document.removeEventListener("mouseleave",V)};document.addEventListener("mouseup",V),document.addEventListener("mouseleave",V)},onTouchStart:S=>{S.stopPropagation(),S.preventDefault(),E=A,_(),T=setTimeout(()=>{y=setInterval(_,200)},750);const V=()=>{T&&(clearTimeout(T),T=null),y&&(clearInterval(y),y=null),document.removeEventListener("touchend",V),document.removeEventListener("touchcancel",V)};document.addEventListener("touchend",V),document.addEventListener("touchcancel",V)},onClick:S=>{S.stopPropagation()}}},[fa,In]=q.useState(!1),[Z,xe]=q.useState(!1),[Qe,Ct]=q.useState(!1),[Bt,zt]=q.useState(!1),[tn,Rn]=q.useState(""),[qt,At]=q.useState(""),[Ft,ir]=q.useState(""),[Sa,Ta]=q.useState("chapters"),da=D>0?L/D*100:0,Kr=D>0?ge/D*100:0,Jr=D>0?Ne/D*100:0,Sr=async()=>{var p;In(!1),xe(!0),Ta("chapters");try{const R=c.filter(T=>T.chapterTitle&&T.chapterTitle.trim()).map(T=>({chapterTitle:T.chapterTitle||`Chapter ${T.id}`,from:Y(T.startTime),to:Y(T.endTime)}));if(R.length===0){At("No chapters with titles found"),zt(!0),xe(!1);return}if(tt){await tt(R),xe(!1),Rn("Chapters saved successfully!");const T=typeof window<"u"&&((p=window.MEDIA_DATA)==null?void 0:p.mediaId)||null;T&&ir(`/view?m=${T}`),Ct(!0)}else At("Chapter save function not available"),zt(!0),xe(!1)}catch(R){ve.error("Error saving chapters:",R),xe(!1);const T=R instanceof Error?R.message:"An error occurred while saving chapters";At(T),zt(!0)}};q.useEffect(()=>{if(Xe.current&&J.current&&X>1){const p=Xe.current.clientWidth,R=J.current.clientWidth,T=L/D*R,y=Math.max(0,T-p/2);Xe.current.scrollTo({left:y,behavior:"smooth"});const E=J.current.getBoundingClientRect();Xe.current.getBoundingClientRect();const S=E.left-Xe.current.scrollLeft+da/100*E.width;(_e!==null||Ce)&&(le({x:S,y:E.top-10}),ye(L))}},[L,X,D,_e,Ce,da]),q.useEffect(()=>{const p=W.current;if(!p||!Ve||!Vt||O)return;ve.debug("Segment boundary check ACTIVATED for segment:",Ve.id,"Start:",Y(Ve.startTime),"End:",Y(Ve.endTime));const R=()=>{const T=Ve.endTime-p.currentTime;if(Math.round(T*10)%10===0&&ve.debug("Segment playback - time remaining:",Y(T),"Current:",Y(p.currentTime),"End:",Y(Ve.endTime),"ContinuePastBoundary:",It),p.currentTime>Ve.endTime){p.pause(),p.currentTime=Ve.endTime,je(!1),mt(!1),ve.debug("Passed segment end - setting back to exact boundary:",Y(Ve.endTime));return}if(Ve.endTime-p.currentTime<.05)if(It)ve.debug("Continuing past segment boundary:",Y(Ve.endTime)),p.currentTime>Ve.endTime&&(mt(!1),Je(null),sessionStorage.removeItem("continuingPastSegment"));else{p.pause(),p.currentTime=Ve.endTime,je(!1),ve.debug("Paused at segment end boundary:",Y(Ve.endTime));const E=[...c].sort((_,S)=>_.startTime-S.startTime).find(_=>_.startTime>Ve.endTime);E&&Math.abs(E.startTime-Ve.endTime)<.1&&(ve.debug("Found adjacent next segment:",E.id),re(E.id),Je(E),nt(E.startTime),ye(E.startTime),p.currentTime=E.startTime)}};return p.addEventListener("timeupdate",R),()=>{p.removeEventListener("timeupdate",R)}},[Ve,Vt,It,c]),q.useEffect(()=>{if(W.current)if(W.current.paused)W.current.paused&&Vt&&(nt(L),ye(L),je(!1),ve.debug("Video paused at:",Y(L)));else{nt(L),ye(L),_e!==null&&je(!0);const p=c.find(y=>L>=y.startTime&&L<=y.endTime),R=L/D*100;if(J.current){const y=J.current.offsetWidth,E=R/100*y;le({x:E,y:J.current.getBoundingClientRect().top-10})}const T=sessionStorage.getItem("continuingPastSegment")==="true";if(p){const y=W.current,E=Ve&&Ve.id<0&&Vt;if((Ve==null?void 0:Ve.id)!==p.id&&!E&&!T&&!It&&(ve.debug(`Entered a new segment during playback: ${p.id}, setting as active`),Je(p),re(p.id),ue(!1),mt(!1),sessionStorage.removeItem("continuingPastSegment")),E&&y&&p){ve.debug(`CUTAWAY BOUNDARY REACHED: Current position ${Y(y.currentTime)} at segment ${p.id} - STOPPING at boundary ${Y(p.startTime)}`),y.pause(),setTimeout(()=>{if(W.current){W.current.currentTime=p.startTime,he(p.startTime),nt(p.startTime),ye(p.startTime),mt(!1),re(p.id),ue(!1);const S=()=>{W.current&&(W.current.currentTime=p.startTime,he(p.startTime),nt(p.startTime),ye(p.startTime),ve.debug(`Position corrected to exact segment boundary: ${Y(W.current.currentTime)} (target: ${Y(p.startTime)})`))};setTimeout(S,10),setTimeout(S,20),setTimeout(S,50),setTimeout(S,100),setTimeout(S,200),W.current.addEventListener("seeked",S),W.current.addEventListener("canplay",S),W.current.addEventListener("waiting",S),setTimeout(()=>{W.current&&(W.current.removeEventListener("seeked",S),W.current.removeEventListener("canplay",S),W.current.removeEventListener("waiting",S))},300)}},10),je(!1),Je(null);return}Ve===null&&Vt===!0||T||E?(_e!==p.id||Ce)&&(ve.debug("Tooltip updated for segment during continued playback:",p.id,E?"(cutaway playback - keeping virtual segment)":""),re(p.id),ue(!1),!E&&sessionStorage.getItem("lastSegmentId")!==p.id.toString()&&sessionStorage.removeItem("continuingPastSegment")):((Ve==null?void 0:Ve.id)!==p.id||Ce)&&(ve.debug("Playback moved into segment:",p.id),re(p.id),Je(p),ue(!1),sessionStorage.setItem("lastSegmentId",p.id.toString()))}else if(Ve!==null||!Ce){re(null),Je(null);const y=va(L);Ot(y),y>=.5?ue(!0):ue(!1)}}},[L,Vt,Ve,_e,c]),q.useEffect(()=>{const p=R=>{const T=R.target;Be&&!T.closest(".zoom-dropdown-container")&&ot(!1)};return document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p)}},[Be]),q.useEffect(()=>{const p=y=>{const{recordHistory:E,fromAutoSave:_}=y.detail;E&&!_&&ht()},R=()=>{ht()},T=y=>{const{recordHistory:E}=y.detail;E&&ht()};return document.addEventListener("update-segments",p),document.addEventListener("segment-drag-end",R),document.addEventListener("update-trim",T),document.addEventListener("delete-segment",ht),document.addEventListener("split-segment",ht),()=>{document.removeEventListener("update-segments",p),document.removeEventListener("segment-drag-end",R),document.removeEventListener("update-trim",T),document.removeEventListener("delete-segment",ht),document.removeEventListener("split-segment",ht),we.current&&(ve.debug("Clearing auto-save timer in cleanup:",we.current),clearTimeout(we.current))}},[ht]),q.useEffect(()=>{c.length>0&&!Te&&setTimeout(()=>{_t()},500)},[Te,_t]),q.useEffect(()=>{const p=()=>{var y;let T=typeof window<"u"&&((y=window.MEDIA_DATA)==null?void 0:y.chapters)||null;try{if(T&&T.chapters&&T.chapters.length>0){ve.debug("Found saved segments:",T);const E=T.chapters.map((S,V)=>({id:Date.now()+V,chapterTitle:S.chapterTitle||`Chapter ${V+1}`,startTime:R(S.startTime),endTime:R(S.endTime)})),_=new CustomEvent("update-segments",{detail:{segments:E,recordHistory:!1,fromAutoSave:!0}});if(document.dispatchEvent(_),T.updated_at){const V=new Date(T.updated_at).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).replace(",","");Pe(V)}}else ve.debug("No saved segments found")}catch(E){console.error("Error loading saved segments:",E)}},R=T=>{const y=T.split(":");if(y.length!==3)return 0;const E=parseInt(y[0])||0,_=parseInt(y[1])||0,S=y[2].split("."),V=parseInt(S[0])||0,B=parseInt(S[1])||0;return E*3600+_*60+V+B/1e3};setTimeout(p,100)},[]),q.useEffect(()=>()=>{},[_e,Ce,Vt]),q.useEffect(()=>{const p=$e.current,R=dt.current,T=J.current;if(!p||!R||!T)return;const y=E=>_=>{_.preventDefault();const S=T.getBoundingClientRect();let V=!0,B=E?ge:Ne;const K=Ke=>new CustomEvent("trim-handle-event",{detail:{type:Ke,isStart:E}});document.dispatchEvent(K("drag-start"));const Le=Ke=>{if(!V)return;const kt=S.width,rn=Math.max(0,Math.min(1,(Ke.clientX-S.left)/kt))*D;typeof window<"u"&&(window.lastSeekedPosition=rn),E?rnge&&(document.dispatchEvent(new CustomEvent("update-trim",{detail:{time:rn,isStart:!1,recordHistory:!1}})),B=rn)},F=()=>{V=!1,document.removeEventListener("mousemove",Le),document.removeEventListener("mouseup",F),E?document.dispatchEvent(new CustomEvent("update-trim",{detail:{time:B,isStart:!0,recordHistory:!0,action:"adjust_trim_start"}})):document.dispatchEvent(new CustomEvent("update-trim",{detail:{time:B,isStart:!1,recordHistory:!0,action:"adjust_trim_end"}})),document.dispatchEvent(K("drag-end"))};document.addEventListener("mousemove",Le),document.addEventListener("mouseup",F)};return p.addEventListener("mousedown",y(!0)),R.addEventListener("mousedown",y(!1)),()=>{p.removeEventListener("mousedown",y(!0)),R.removeEventListener("mousedown",y(!1))}},[D,ge,Ne,oe,ze]);const Zr=()=>Me.map((p,R)=>{const T=p/D*100;return v.jsx("div",{className:"split-point",style:{left:`${T}%`}},R)}),va=p=>{const T=[...c].sort((S,V)=>S.startTime-V.startTime),y=T.find(S=>S.startTime>p),E=[...T].reverse().find(S=>S.endTime{if(!J.current)return;const R=c.find(B=>{const K=p>=B.startTime&&p<=B.endTime,Le=Math.abs(p-B.startTime)<.001,F=Math.abs(p-B.endTime)<.001;return K||Le||F}),T=[...c].sort((B,K)=>B.startTime-K.startTime),y=T.find(B=>B.startTime>p),E=[...T].reverse().find(B=>B.endTime1&&Xe.current?V=_.left-Xe.current.scrollLeft+_.width*(S/100):V=_.left+_.width*(S/100),le({x:V,y:_.top-10})},Zn=p=>{if(!J.current||!Xe.current||gt)return;const R=W.current&&!W.current.paused;mt(!1);const T=J.current.getBoundingClientRect();let y;if(X>1){const S=Xe.current.scrollLeft,V=J.current.clientWidth;y=(p.clientX-T.left+S)/V}else y=(p.clientX-T.left)/T.width;const E=y*D;ve.debug("Timeline clicked at:",Y(E),"distance from end:",Y(D-E)),typeof window<"u"&&(window.lastSeekedPosition=E),he(E),ye(E),nt(E);const _=c.find(S=>{const V=E>=S.startTime&&E<=S.endTime,B=Math.abs(E-S.startTime)<.01,K=Math.abs(E-S.endTime)<.01;return V||B||K});if(_&&Je(_),W.current)if(O&&R){if(_){const V=[...c].sort((B,K)=>B.startTime-K.startTime).findIndex(B=>B.id===_.id);if(V!==-1){const B=new CustomEvent("update-segment-index",{detail:{segmentIndex:V}});document.dispatchEvent(B),ve.debug(`Segments playback mode: updating segment index to ${V} for timeline click in segment ${_.id}`)}}W.current.play().then(()=>{je(!0)}).catch(S=>{console.error("Error resuming segments playback:",S),je(!1)})}else R&&!O&&W.current.play().then(()=>{je(!0)}).catch(S=>{console.error("Error resuming playback:",S),je(!1)});if(p.target===J.current)if(_)re(_.id),ue(!1);else{re(null);const S=va(E);Ot(S);let V;if(X>1){const F=T.left-Xe.current.scrollLeft,Ke=E/D;V=F+Ke*T.width}else V=p.clientX;le({x:V,y:T.top-10}),ue(!0);const B=[...c].sort((F,Ke)=>F.startTime-Ke.startTime),K=[...B].reverse().find(F=>F.endTimeF.startTime>E);ve.debug("Clicked in cutaway area:",{position:Y(E),availableSpace:Y(S),prevSegmentEnd:K?Y(K.endTime):"none",nextSegmentStart:Le?Y(Le.startTime):"none"})}},wn=(p,R)=>T=>{if(T.preventDefault(),T.stopPropagation(),!J.current)return;J.current.getBoundingClientRect().width;const E=c.find(Dn=>Dn.id===p);if(!E)return;const _=E.startTime,S=E.endTime,V={...E};document.body.style.cursor="ew-resize";const B=document.createElement("div");B.style.position="fixed",B.style.top="0",B.style.left="0",B.style.width="100vw",B.style.height="100vh",B.style.zIndex="1000",B.style.cursor="ew-resize",document.body.appendChild(B);let K=!0,Le=_,F=S;document.dispatchEvent(new CustomEvent("segment-drag-start",{detail:{segmentId:p}}));const Ke=Dn=>{if(!K||!J.current)return;const or=J.current.getBoundingClientRect(),$t=Math.max(0,Math.min(1,(Dn-or.left)/or.width))*D,Ea=R?$t:_,Pa=R?S:$t;if(L>=Ea&&L<=Pa)re(p),ue(!1);else{re(null);const ln=va(L);Ot(ln),ue(!0)}const Ca=c.filter(ln=>ln.id!==p);let ea=_,Wn=S;if(R){ea=Math.min($t,S-.5);const xt=Ca.filter(xa=>xa.endTime<=_).sort((xa,Di)=>Di.endTime-xa.endTime)[0];xt&&eaxa.startTime>=S).sort((xa,Di)=>xa.startTime-Di.startTime)[0];xt&&Wn>xt.startTime&&(Wn=xt.startTime),xt&&Math.abs(Wn-xt.startTime)<.3&&(Wn=xt.startTime),F=Wn}const Rr=c.map(ln=>ln.id===p?{...ln,startTime:ea,endTime:Wn}:ln),wr=new CustomEvent("update-segments",{detail:{segments:Rr,recordHistory:!1}});if(document.dispatchEvent(wr),_e===p&&W.current){const ln=W.current.currentTime,xt=Rr.find(Ya=>Ya.id===p);if(xt){const Ya=ln>=xt.startTime&&ln<=xt.endTime;ve.debug(`During drag - playhead at ${Y(ln)} is ${Ya?"inside":"outside"} segment (${Y(xt.startTime)} - ${Y(xt.endTime)})`),!Ya&&Vt&&(W.current.pause(),je(!1),Je(null)),lnxt.endTime&&(ve.debug(`Adjusting display time to segment end: ${Y(xt.endTime)}`),nt(xt.endTime),ye(xt.endTime))}}},kt=()=>{if(!K)return;K=!1,document.removeEventListener("mousemove",bt),document.removeEventListener("mouseup",rn),document.removeEventListener("touchmove",xr),document.removeEventListener("touchend",Na),document.removeEventListener("touchcancel",Na),document.body.style.cursor="",document.body.contains(B)&&document.body.removeChild(B);const Dn=c.map(_n=>_n.id===p?{..._n,startTime:Le,endTime:F}:_n),or=R?"adjust_segment_start":"adjust_segment_end";if(document.dispatchEvent(new CustomEvent("update-segments",{detail:{segments:Dn,recordHistory:!0,action:or}})),_e===p&&W.current){const _n=W.current.currentTime,$t=Dn.find(Ea=>Ea.id===p);if($t){const Ea=_n>=$t.startTime&&_n<=$t.endTime;ve.debug(`Drag complete - playhead at ${Y(_n)} is ${Ea?"inside":"outside"} segment (${Y($t.startTime)} - ${Y($t.endTime)})`);const Pa=_n>=V.startTime&&_n<=V.endTime;Ea?(!Pa&&Ea||Pa&&Ea&&($t.startTime!==V.startTime||$t.endTime!==V.endTime))&&Je($t):(Vt&&(W.current.pause(),je(!1),Je(null),mt(!1)),_n<$t.startTime?(ve.debug(`Final adjustment - setting display time to segment start: ${Y($t.startTime)}`),nt($t.startTime),ye($t.startTime)):_n>$t.endTime&&(ve.debug(`Final adjustment - setting display time to segment end: ${Y($t.endTime)}`),nt($t.endTime),ye($t.endTime)))}}},bt=Dn=>{Ke(Dn.clientX)},rn=()=>{kt()},xr=Dn=>{Dn.touches.length>0&&(Dn.preventDefault(),Ke(Dn.touches[0].clientX))},Na=()=>{kt()};document.addEventListener("mousemove",bt,{passive:!1}),document.addEventListener("mouseup",rn),document.addEventListener("touchmove",xr,{passive:!1}),document.addEventListener("touchend",Na),document.addEventListener("touchcancel",Na)},Aa=p=>R=>{if(R.target.classList.contains("clip-segment-handle"))return;R.preventDefault(),R.stopPropagation(),mt(!1);const T=W.current&&!W.current.paused;re(p);const y=c.find(F=>F.id===p);if(!y)return;const _=R.currentTarget.getBoundingClientRect(),S=(R.clientX-_.left)/_.width,V=y.startTime+S*(y.endTime-y.startTime),B=Math.max(y.startTime,Math.min(y.endTime,V));if(ye(B),nt(B),W.current){const F=W.current.currentTime,Ke=F>=y.startTime&&F<=y.endTime;ve.debug(`Segment click - playhead at ${Y(F)} is ${Ke?"inside":"outside"} segment (${Y(y.startTime)} - ${Y(y.endTime)})`),Ke||(Math.abs(F-y.startTime)kt.startTime-bt.startTime).findIndex(kt=>kt.id===p);if(Ke!==-1){const kt=new CustomEvent("update-segment-index",{detail:{segmentIndex:Ke}});document.dispatchEvent(kt)}W.current.play().then(()=>{je(!0)}).catch(kt=>{console.error("Error continuing segments playback after segment click:",kt)})}else T&&!O&&(Je(y),mt(!1),W.current.play().then(()=>{je(!0)}).catch(F=>{console.error("Error resuming playback after segment click:",F)}));const K=R.clientX,Le=_.top-10;if(le({x:K,y:Le}),X>1&&J.current&&Xe.current){J.current.getBoundingClientRect();const F=J.current.clientWidth,Ke=Xe.current.clientWidth,kt=B/D*F,bt=Math.max(0,kt-Ke/2);Xe.current.scrollTo({left:bt,behavior:"smooth"}),setTimeout(()=>{if(J.current&&Xe.current){const rn=J.current.getBoundingClientRect(),Na=B/D*F-Xe.current.scrollLeft+rn.left;le({x:Na,y:Le})}},300)}},Tr=()=>c.map((p,R)=>{const T=p.startTime/D*100,y=(p.endTime-p.startTime)/D*100,E=$S((p.startTime+p.endTime)/2,D);return v.jsxs("div",{className:`clip-segment ${_e===p.id?"selected":""}`,style:{left:`${T}%`,width:`${y}%`,backgroundColor:E,borderWidth:"2px",borderStyle:"solid",borderColor:"rgba(0, 0, 0, 0.5)"},onClick:Aa(p.id),children:[v.jsxs("div",{className:"clip-segment-info",children:[v.jsxs("div",{className:"clip-segment-name",children:["Chapter ",R+1]}),v.jsxs("div",{className:"clip-segment-time",children:[wi(p.startTime)," - ",wi(p.endTime)]}),v.jsxs("div",{className:"clip-segment-duration",children:["Duration: ",wi(p.endTime-p.startTime)]})]}),O?null:v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"clip-segment-handle left",title:"Resize segment start",onMouseDown:_=>{_.stopPropagation(),wn(p.id,!0)(_)},onTouchStart:_=>{_.stopPropagation(),wn(p.id,!0)(_)}}),v.jsx("div",{className:"clip-segment-handle right",title:"Resize segment end",onMouseDown:_=>{_.stopPropagation(),wn(p.id,!1)(_)},onTouchStart:_=>{_.stopPropagation(),wn(p.id,!1)(_)}})]})]},p.id)});q.useEffect(()=>{const p=R=>{const{segmentId:T}=R.detail;if(c.filter(E=>E.id!==T).length===0){const E={id:Date.now(),chapterTitle:"Full Video",startTime:0,endTime:D},_=new CustomEvent("update-segments",{detail:{segments:[E],recordHistory:!0,action:"create_full_video_segment"}});if(document.dispatchEvent(_),re(E.id),ue(!1),ye(L),nt(L),Je(E),J.current){const S=J.current.getBoundingClientRect(),V=L/D*100,B=S.left+S.width*(V/100);le({x:B,y:S.top-10}),ve.debug("Created full video segment:",{id:E.id,duration:Y(D),currentPosition:Y(L)})}}else if(_e===T){if(!c.find(S=>S.id===T))return;const _=va(L);if(re(null),ue(!0),Ot(_),J.current){const S=J.current.getBoundingClientRect(),V=L/D*100,B=S.left+S.width*(V/100);le({x:B,y:S.top-10}),ve.debug("Segment deleted, showing cutaway tooltip:",{position:Y(L),availableSpace:Y(_)})}}};return document.addEventListener("delete-segment",p),()=>{document.removeEventListener("delete-segment",p)}},[_e,c,L,D,J]),q.useEffect(()=>{const p=W.current;if(!p)return;const R=()=>{if(!W.current)return;const y=W.current,E=y.currentTime;mt(!1);let _=D,S=null,V=null;S=c.find(K=>{const Le=E>=K.startTime&&E<=K.endTime,F=Math.abs(E-K.startTime)<.001,Ke=Math.abs(E-K.endTime)<.001;return Le||F||Ke}),V=c.filter(K=>{const Le=K.startTime>E,F=Math.abs(K.startTime-E)>.001;return Le&&F}).sort((K,Le)=>K.startTime-Le.startTime)[0],S?(_=S.endTime,Je(S)):V&&(_=V.startTime);const B=()=>{if(!y)return;const K=y.currentTime;if(_-K<=.001||K>=_){y.pause();const F=()=>{y&&(y.currentTime=_,he(_),nt(_),ye(_),ve.debug("Position verification:",{target:Y(_),actual:Y(y.currentTime),difference:Math.abs(y.currentTime-_).toFixed(3)}))};F(),setTimeout(F,10),setTimeout(F,20),setTimeout(F,50),S?(re(S.id),ue(!1)):V?(re(V.id),ue(!1),Je(V)):(re(null),ue(!0),Je(null)),y.removeEventListener("timeupdate",B),Oe(!1),je(!1),mt(!1);return}};y.addEventListener("timeupdate",B),y.play().then(()=>{Oe(!0),je(!0),ve.debug("Playback started:",{from:Y(E),to:Y(_),currentSegment:S?`Segment ${S.id}`:"None",nextSegment:V?`Segment ${V.id}`:"None"})}).catch(K=>{console.error("Error playing video:",K)})},T=()=>{je(!1)};return p.addEventListener("play",R),p.addEventListener("pause",T),()=>{p.removeEventListener("play",R),p.removeEventListener("pause",T)}},[c,D,he]);const Er=p=>{if(!J.current)return;const R=J.current.getBoundingClientRect(),y=(p.clientX-R.left)/R.width*D,E=Math.max(0,Math.min(D,y));typeof window<"u"&&(window.lastSeekedPosition=E)},[Cr,h]=q.useState(!1),$=q.useRef(!1),ae=p=>{if(gt)return;p.stopPropagation(),p.preventDefault(),h(!0),$.current=!0,jn(L);const R=y=>{if(!J.current||!Xe.current)return;const E=J.current.getBoundingClientRect();let _;if(X>1){const V=Xe.current.scrollLeft,B=J.current.clientWidth;_=(y.clientX-E.left+V)/B}else _=(y.clientX-E.left)/E.width;_=Math.max(0,Math.min(1,_));const S=_*D;ye(S),nt(S),jn(S),typeof window<"u"&&(window.lastSeekedPosition=S),he(S)},T=()=>{h(!1),$.current=!1,document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",T)};document.addEventListener("mousemove",R),document.addEventListener("mouseup",T)},pe=p=>{if(gt)return;p.stopPropagation(),p.preventDefault(),h(!0),$.current=!0,jn(L);const R=y=>{if(!J.current||!Xe.current||!y.touches[0])return;const E=J.current.getBoundingClientRect();let _;if(X>1){const V=Xe.current.scrollLeft,B=J.current.clientWidth;_=(y.touches[0].clientX-E.left+V)/B}else _=(y.touches[0].clientX-E.left)/E.width;_=Math.max(0,Math.min(1,_));const S=_*D;ye(S),nt(S),jn(S),typeof window<"u"&&(window.lastSeekedPosition=S),he(S)},T=()=>{h(!1),$.current=!1,document.removeEventListener("touchmove",R),document.removeEventListener("touchend",T),document.removeEventListener("touchcancel",T)};document.addEventListener("touchmove",R,{passive:!1}),document.addEventListener("touchend",T),document.addEventListener("touchcancel",T)};return q.useEffect(()=>{},[Ft,Sa,Qe]),v.jsxs("div",{className:`timeline-container-card ${O?"segments-playback-mode":""}`,children:[v.jsxs("div",{className:"timeline-header",children:[v.jsx("div",{className:"timeline-title",children:v.jsx("span",{className:"timeline-title-text",children:"Timeline"})}),v.jsxs("div",{className:"duration-time",children:["Total Chapters:"," ",v.jsx("span",{children:Y(c.reduce((p,R)=>p+(R.endTime-R.startTime),0))})]})]}),v.jsx("div",{ref:Xe,className:`timeline-scroll-container ${O?"segments-playback-mode":""}`,style:{overflow:X>1?"auto":"hidden"},children:v.jsxs("div",{ref:J,className:"timeline-container",onClick:Zn,onMouseMove:Er,style:{width:`${X*100}%`,cursor:"pointer"},children:[v.jsxs("div",{className:"timeline-marker",style:{left:`${da}%`},children:[v.jsx("div",{className:"timeline-marker-head",onClick:p=>{if(p.stopPropagation(),c.find(R=>L>=R.startTime&&L<=R.endTime),_e||Ce){re(null),ue(!1);return}else jn(L),ve.debug("Opening tooltip at:",Y(L))},children:v.jsx("span",{className:"timeline-marker-head-icon",children:_e||Ce?"-":"+"})}),O?null:v.jsx("div",{className:`timeline-marker-drag ${Cr?"dragging":""}`,onMouseDown:ae,onTouchStart:pe,children:v.jsx("span",{className:"timeline-marker-drag-icon",children:"⋮"})})]}),c.length===0&&v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"trim-line-marker",style:{left:`${Kr}%`},children:v.jsx("div",{ref:$e,className:"trim-handle left"})}),v.jsx("div",{className:"trim-line-marker",style:{left:`${Jr}%`},children:v.jsx("div",{ref:dt,className:"trim-handle right"})})]}),Tr(),Zr(),_e!==null&&v.jsxs("div",{className:`segment-tooltip two-row-tooltip ${O?"segments-playback-mode":""}`,style:{position:"absolute",...xm(da)},onClick:p=>{O&&(p.stopPropagation(),p.preventDefault())},children:[_e&&v.jsx("div",{className:"tooltip-chapter-editor",children:v.jsx("textarea",{className:"tooltip-chapter-input",placeholder:"Chapter Title",value:hn,onChange:p=>Jt(p.target.value),onBlur:_t,onMouseLeave:_t,rows:2,maxLength:200,onClick:p=>p.stopPropagation(),onMouseDown:p=>p.stopPropagation(),onMouseUp:p=>p.stopPropagation()})}),v.jsxs("div",{className:"tooltip-row",children:[v.jsx("button",{className:`tooltip-time-btn ${O?"disabled":""}`,"data-tooltip":O?"Disabled during preview":"Seek -50ms (click or hold)",disabled:O,...O?{}:Wt(-.05),style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},children:"-50ms"}),v.jsx("div",{className:`tooltip-time-display ${O?"disabled":""}`,style:{pointerEvents:O?"none":"auto",cursor:O?"not-allowed":"default",opacity:O?.6:1,userSelect:"none",WebkitUserSelect:"none"},onClick:p=>{O&&(p.stopPropagation(),p.preventDefault())},children:Y(en)}),v.jsx("button",{className:`tooltip-time-btn ${O?"disabled":""}`,"data-tooltip":O?"Disabled during preview":"Seek +50ms (click or hold)",disabled:O,...O?{}:Wt(.05),style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},children:"+50ms"})]}),v.jsxs("div",{className:"tooltip-row tooltip-actions",children:[v.jsx("button",{className:`tooltip-action-btn delete ${O?"disabled":""}`,"data-tooltip":O?"Disabled during preview":"Delete segment",disabled:O,style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},onClick:p=>{p.stopPropagation();const R=new CustomEvent("delete-segment",{detail:{segmentId:_e}});document.dispatchEvent(R)},children:v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("path",{d:"M3 6h18"}),v.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),v.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),v.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}),v.jsx("button",{className:`tooltip-action-btn scissors ${O?"disabled":""}`,"data-tooltip":O?"Disabled during preview":"Split segment at current position",style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},disabled:O,onClick:p=>{p.stopPropagation();const R=new CustomEvent("split-segment",{detail:{segmentId:_e,time:A}});document.dispatchEvent(R)},children:v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("circle",{cx:"6",cy:"6",r:"3"}),v.jsx("circle",{cx:"6",cy:"18",r:"3"}),v.jsx("line",{x1:"20",y1:"4",x2:"8.12",y2:"15.88"}),v.jsx("line",{x1:"14.47",y1:"14.48",x2:"20",y2:"20"}),v.jsx("line",{x1:"8.12",y1:"8.12",x2:"12",y2:"12"})]})}),v.jsx("button",{className:`tooltip-action-btn play-from-start ${O?"disabled":""}`,"data-tooltip":O?"Disabled during preview":"Play segment from beginning",style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},disabled:O,onClick:p=>{p.stopPropagation();const R=c.find(T=>T.id===_e);if(R&&W.current){if(mt(!0),Math.abs(W.current.currentTime-R.endTime)<.05){ve.debug(`Already at end boundary (${Y(W.current.currentTime)}), nudging position back slightly`);const T=Math.max(R.startTime,R.endTime-.1);W.current.currentTime=T,he(T),ye(T),ve.debug(`Position adjusted to ${Y(T)}`)}else he(R.startTime),ye(R.startTime);Je(R),W.current.play().then(()=>{je(!0)}).catch(T=>{console.error("Error playing from beginning:",T)})}},children:v.jsx("img",{src:Cm,alt:"Play from beginning",style:{width:"24px",height:"24px"}})}),v.jsx("button",{className:`tooltip-action-btn ${De?"pause":"play"} ${O?"disabled":""}`,"data-tooltip":O?"Disabled during preview":De?"Pause playback":"Play from current position",style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},disabled:O,onClick:p=>{p.stopPropagation(),De?W.current&&(W.current.pause(),je(!1),mt(!1)):Lt()},children:De?v.jsx("img",{src:Em,alt:"Pause",style:{width:"24px",height:"24px"}}):v.jsx("img",{src:Tm,alt:"Play",style:{width:"24px",height:"24px"}})}),v.jsx("button",{className:`tooltip-action-btn set-in ${O?"disabled":""}`,style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},"data-tooltip":O?"Disabled during preview":"Set start point at current position",disabled:O,onClick:p=>{if(p.stopPropagation(),c.find(T=>T.id===_e)){const T=c.map(E=>E.id===_e?{...E,startTime:A{if(p.stopPropagation(),c.find(T=>T.id===_e)){const T=c.map(E=>E.id===_e?{...E,endTime:A>E.startTime+.5?A:E.startTime+.5}:E),y=new CustomEvent("update-segments",{detail:{segments:T,recordHistory:!0,action:"adjust_end_time"}});document.dispatchEvent(y)}},children:v.jsx("img",{src:YS,alt:"Set end point",style:{width:"24px",height:"24px"}})})]})]}),Ce&&_e===null&&v.jsxs("div",{className:`empty-space-tooltip two-row-tooltip ${O?"segments-playback-mode":""}`,style:{position:"absolute",...xm(da)},onClick:p=>{O&&(p.stopPropagation(),p.preventDefault())},children:[v.jsxs("div",{className:"tooltip-row",children:[v.jsx("button",{className:`tooltip-time-btn ${O?"disabled":""}`,"data-tooltip":O?"Disabled during preview":"Seek -50ms (click or hold)",disabled:O,...O?{}:Wt(-.05),style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},children:"-50ms"}),v.jsx("div",{className:`tooltip-time-display ${O?"disabled":""}`,style:{pointerEvents:O?"none":"auto",cursor:O?"not-allowed":"default",opacity:O?.6:1,userSelect:"none",WebkitUserSelect:"none"},onClick:p=>{O&&(p.stopPropagation(),p.preventDefault())},children:Y(A)}),v.jsx("button",{className:`tooltip-time-btn ${O?"disabled":""}`,style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},"data-tooltip":O?"Disabled during preview":"Seek +50ms (click or hold)",disabled:O,...O?{}:Wt(.05),children:"+50ms"})]}),v.jsxs("div",{className:"tooltip-row tooltip-actions",children:[v.jsxs("button",{className:`tooltip-action-btn new-segment ${Et<.5||O?"disabled":""}`,style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},"data-tooltip":O?"Disabled during preview":Et<.5?"Not enough space for new segment":"Create new segment",disabled:Et<.5||O,onClick:async p=>{if(p.stopPropagation(),Et<.5)return;const R=A,T=R+Et,y={id:Date.now(),chapterTitle:"segment",startTime:R,endTime:T},E=[...c,y],_=new CustomEvent("update-segments",{detail:{segments:E,recordHistory:!0,action:"create_segment"}});document.dispatchEvent(_),ue(!1),setTimeout(()=>{const S=E[E.length-1];S&&(re(S.id),ve.debug("Created and selected new segment:",S.id))},100)},children:[v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),v.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"16"}),v.jsx("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]}),v.jsx("span",{className:"tooltip-btn-text",children:"New"})]}),v.jsx("button",{className:`tooltip-action-btn play-from-start ${O?"disabled":""}`,"data-tooltip":O?"Disabled during preview":"Play from beginning of cutaway",style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},disabled:O,onClick:p=>{if(p.stopPropagation(),W.current){const R=A;mt(!0);const T=[...c].sort((K,Le)=>K.startTime-Le.startTime),y=[...T].reverse().find(K=>K.endTimeK.startTime>R),S=_?_.startTime:D,V={id:-999,chapterTitle:"Cutaway",startTime:E,endTime:S};he(E),ye(E),je(!1),setTimeout(()=>{Je(V)},0);const B=()=>{if(!W.current)return;const K=W.current.currentTime,Le=[...c].sort((bt,rn)=>bt.startTime-rn.startTime),F=Le.find(bt=>bt.startTime>K-.3),Ke=F&&K>=F.startTime-.25&&K<=F.startTime+.1&&!It;F&&K>=F.startTime-.25&&K<=F.startTime+.1&&ve.debug(`Approaching boundary at ${Y(F.startTime)}, continuePastBoundary=${It}, willStop=${Ke}`);const kt=Le.find(bt=>K>=bt.startTime&&K<=bt.endTime);if(kt&&(Ve==null?void 0:Ve.id)!==kt.id){ve.debug(`Entered segment ${kt.id} during cutaway playback`),Je(kt),re(kt.id),ue(!1),W.current.removeEventListener("timeupdate",B),mt(!1),sessionStorage.removeItem("continuingPastSegment");return}if(Ke&&F){ve.debug(`CUTAWAY MANUAL BOUNDARY CHECK: Current position ${Y(K)} approaching segment at ${Y(F.startTime)} (distance: ${Math.abs(K-F.startTime).toFixed(3)}s) - STOPPING`),W.current.pause(),setTimeout(()=>{if(W.current){W.current.currentTime=F.startTime,he(F.startTime),nt(F.startTime),ye(F.startTime),mt(!1),re(F.id),ue(!1),Je(F);const bt=()=>{W.current&&(W.current.currentTime=F.startTime,he(F.startTime),nt(F.startTime),ye(F.startTime),ve.debug(`Position corrected to exact segment boundary: ${Y(W.current.currentTime)} (target: ${Y(F.startTime)})`))};setTimeout(bt,10),setTimeout(bt,20),setTimeout(bt,50),setTimeout(bt,100),setTimeout(bt,200),W.current.addEventListener("seeked",bt),W.current.addEventListener("canplay",bt),W.current.addEventListener("waiting",bt),setTimeout(()=>{W.current&&(W.current.removeEventListener("seeked",bt),W.current.removeEventListener("canplay",bt),W.current.removeEventListener("waiting",bt))},300)}},10),je(!1),Je(null),W.current.removeEventListener("timeupdate",B);return}};W.current.addEventListener("timeupdate",B),setTimeout(()=>{W.current&&W.current.play().then(()=>{je(!0),ve.debug("CUTAWAY PLAYBACK STARTED:",Y(E),"to",Y(S),y?`(after segment ${y.id}, offset +25ms from ${Y(y.endTime)})`:"(from video start)",_?`(will stop at segment ${_.id})`:"(will play to end)")}).catch(K=>{console.error("Error playing cutaway:",K)})},50)}},children:v.jsx("img",{src:Cm,alt:"Play from beginning",style:{width:"24px",height:"24px"}})}),v.jsx("button",{className:`tooltip-action-btn ${De?"pause":"play"} ${O?"disabled":""}`,"data-tooltip":O?"Disabled during preview":De?"Pause playback":"Play from here until next segment",style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},disabled:O,onClick:p=>{p.stopPropagation(),De?W.current&&(W.current.pause(),je(!1),mt(!1)):Lt()},children:De?v.jsx("img",{src:Em,alt:"Pause",style:{width:"24px",height:"24px"}}):v.jsx("img",{src:Tm,alt:"Play",style:{width:"24px",height:"24px"}})}),v.jsx("button",{className:`tooltip-action-btn segment-end ${O?"disabled":""}`,style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},"data-tooltip":O?"Disabled during preview":"Adjust end of previous segment",disabled:O,onClick:p=>{p.stopPropagation();const T=[...c].sort((y,E)=>y.startTime-E.startTime).filter(y=>y.endTime<=A).sort((y,E)=>E.endTime-y.endTime)[0];if(T){const y=c.map(_=>_.id===T.id?{..._,endTime:A}:_),E=new CustomEvent("update-segments",{detail:{segments:y,recordHistory:!0,action:"adjust_previous_end_time"}});document.dispatchEvent(E),ve.debug("Adjusted end of previous segment to:",Y(A)),re(T.id),ue(!1)}else if(c.length>0){const y=[...c].sort((S,V)=>S.startTime-V.startTime);let E=!1,_=0;for(let S=0;SV&&AB.endTime-V.endTime)[0];if(S&&S.endTimeK.id===S.id?{...K,endTime:D}:K),B=new CustomEvent("update-segments",{detail:{segments:V,recordHistory:!0,action:"extend_last_segment"}});document.dispatchEvent(B),re(S.id),ue(!1)}}}else if(A>0){const y={id:Date.now(),chapterTitle:"segment",startTime:0,endTime:A},E=new CustomEvent("update-segments",{detail:{segments:[y],recordHistory:!0,action:"create_segment_from_start"}});document.dispatchEvent(E),ve.debug("Created new segment from start to:",Y(A)),re(y.id),ue(!1)}},children:v.jsx("img",{src:qS,alt:"Set end point",style:{width:"24px",height:"24px"}})}),v.jsx("button",{className:`tooltip-action-btn segment-start ${O?"disabled":""}`,"data-tooltip":O?"Disabled during preview":"Adjust start of next segment",style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},disabled:O,onClick:p=>{p.stopPropagation();const T=[...c].sort((y,E)=>y.startTime-E.startTime).filter(y=>y.startTime>=A).sort((y,E)=>y.startTime-E.startTime)[0];if(T){const y=c.map(_=>_.id===T.id?{..._,startTime:A}:_),E=new CustomEvent("update-segments",{detail:{segments:y,recordHistory:!0,action:"adjust_next_start_time"}});document.dispatchEvent(E),ve.debug("Adjusted start of next segment to:",Y(A)),re(T.id),ue(!1)}else if(c.length>0){const y=[...c].sort((S,V)=>S.startTime-V.startTime);let E=!1,_=0;for(let S=0;SV&&Ay[y.length-1].endTime){const S={id:Date.now(),chapterTitle:"segment",startTime:A,endTime:D},V=[...c,S],B=new CustomEvent("update-segments",{detail:{segments:V,recordHistory:!0,action:"create_segment_to_end"}});document.dispatchEvent(B),ve.debug("Created new segment from",Y(A),"to end"),re(S.id),ue(!1)}else{const S=y[0];if(S&&S.startTime>0){const V=c.map(K=>K.id===S.id?{...K,startTime:0}:K),B=new CustomEvent("update-segments",{detail:{segments:V,recordHistory:!0,action:"extend_first_segment"}});document.dispatchEvent(B),re(S.id),ue(!1)}}}else if(A{if(p.key==="Enter"){const R=p.currentTarget.value;try{const T=R.split(":");let y=0,E=0,_=0,S=0;if(T.length===3){y=parseInt(T[0]),E=parseInt(T[1]);const B=T[2].split(".");_=parseInt(B[0]),B.length>1&&(S=parseInt(B[1].padEnd(3,"0").substring(0,3)))}else if(T.length===2){E=parseInt(T[0]);const B=T[1].split(".");_=parseInt(B[0]),B.length>1&&(S=parseInt(B[1].padEnd(3,"0").substring(0,3)))}const V=y*3600+E*60+_+S/1e3;if(!isNaN(V)&&V>=0&&V<=D){he(V);const B=K=>{const Le=c.find(F=>{const Ke=K>=F.startTime&&K<=F.endTime,kt=Math.abs(K-F.startTime)<.001,bt=Math.abs(K-F.endTime)<.001;return Ke||kt||bt});if(J.current&&Xe.current){const F=J.current.getBoundingClientRect();let Ke;if(X>1)Ke=F.left-Xe.current.scrollLeft+K/D*F.width;else{const kt=K/D;Ke=F.left+F.width*kt}le({x:Ke,y:F.top-10}),ye(K),Le?(re(Le.id),ue(!1)):(re(null),ue(!0))}};setTimeout(()=>B(V),10)}}catch(T){console.error("Invalid time format:",T)}}}}),v.jsx("div",{className:"time-button-group",children:(()=>{const p=()=>{const R=c.find(T=>{const y=L>=T.startTime&&L<=T.endTime,E=Math.abs(L-T.startTime)<.001,_=Math.abs(L-T.endTime)<.001;return y||E||_});if(J.current&&Xe.current){const T=J.current.getBoundingClientRect();let y;if(X>1)y=T.left-Xe.current.scrollLeft+L/D*T.width;else{const E=L/D;y=T.left+T.width*E}if(le({x:y,y:T.top-10}),ye(L),R)re(R.id),ue(!1);else{const E=va(L);Ot(E),E>=.5?(re(null),ue(!0)):(re(null),ue(!1))}}};return v.jsxs(v.Fragment,{children:[v.jsx("button",{className:"time-button",onClick:()=>{he(L-.01),setTimeout(p,10)},"data-tooltip":"Move back 10ms",children:"-10ms"}),v.jsx("button",{className:"time-button",onClick:()=>{he(L-.001),setTimeout(p,10)},"data-tooltip":"Move back 1ms",children:"-1ms"}),v.jsx("button",{className:"time-button",onClick:()=>{he(L+.001),setTimeout(p,10)},"data-tooltip":"Move forward 1ms",children:"+1ms"}),v.jsx("button",{className:"time-button",onClick:()=>{he(L+.01),setTimeout(p,10)},"data-tooltip":"Move forward 10ms",children:"+10ms"})]})})()})]}),v.jsxs("div",{className:"controls-right",children:[v.jsxs("div",{className:"zoom-dropdown-container",children:[v.jsxs("button",{className:"zoom-button","data-tooltip":"Select zoom level",onClick:()=>ot(!Be),children:["Zoom ",X,"x",v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:v.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),Be&&v.jsx("div",{className:"zoom-dropdown",style:{position:"absolute",top:"100%",left:0,zIndex:1e3},children:[1,2,4,8,16,32,64,128,256,512,1024,2048,4096].map(p=>v.jsxs("div",{className:`zoom-option ${X===p?"selected":""}`,onClick:()=>{Q(p),ot(!1)},children:[X===p&&v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:v.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Zoom ",p,"x"]},p))})]}),v.jsx("div",{className:"auto-saved-time",style:{color:at?"#1976d2":"gray",fontSize:"12px",marginLeft:"10px",display:"flex",alignItems:"center",gap:"5px"},children:at?v.jsxs(v.Fragment,{children:[v.jsx("span",{className:"auto-save-spinner",style:{display:"inline-block",width:"12px",height:"12px",border:"2px solid #f3f3f3",borderTop:"2px solid #1976d2",borderRadius:"50%",animation:"spin 1s linear infinite"}}),"Auto saving..."]}):Te?`Auto saved: ${Te}`:"Not saved yet"}),v.jsx("div",{className:"save-buttons-row",children:v.jsx("button",{onClick:()=>In(!0),className:"save-chapters-button","data-tooltip":"Save chapters",disabled:c.filter(p=>p.chapterTitle&&p.chapterTitle.trim()).length===0,children:"Save Chapters"})}),v.jsx(Wu,{isOpen:fa,onClose:()=>In(!1),title:"Save Chapters",actions:v.jsxs(v.Fragment,{children:[v.jsx("button",{className:"modal-button modal-button-secondary",onClick:()=>In(!1),children:"Cancel"}),v.jsx("button",{className:"modal-button modal-button-primary",onClick:Sr,children:"Save Chapters"})]}),children:v.jsxs("p",{className:"modal-message",children:["Are you sure you want to save the chapters? This will save"," ",c.filter(p=>p.chapterTitle&&p.chapterTitle.trim()).length," chapters to the database."]})}),v.jsxs(Wu,{isOpen:Z,onClose:()=>{},title:"Processing Video",children:[v.jsx("div",{className:"modal-spinner",children:v.jsx("div",{className:"spinner"})}),v.jsx("p",{className:"modal-message text-center",children:"Please wait while your video is being processed..."})]}),v.jsx(Wu,{isOpen:Qe,onClose:()=>{Ct(!1)},title:"Video Edited Successfully",children:v.jsx("div",{className:"modal-success-content",children:v.jsxs("p",{className:"modal-message text-center redirect-message",children:[v.jsx("span",{style:{fontWeight:"bold"},children:"Your chapters have been saved successfully!"}),v.jsx("br",{}),v.jsx("a",{href:Ft,className:"media-page-link",style:GS,children:"Click here to navigate to the media page"})," ","or close this window to continue editing the chapters."]})})}),v.jsxs(Wu,{isOpen:Bt,onClose:()=>zt(!1),title:"Video Processing Error",children:[v.jsxs("div",{className:"modal-error-content",children:[v.jsx("div",{className:"modal-error-icon",children:v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"#F44336",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("circle",{cx:"12",cy:"12",r:"10"}),v.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),v.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}),v.jsx("p",{className:"modal-message text-center error-message",children:qt})]}),v.jsx("div",{className:"modal-choices",children:v.jsxs("button",{onClick:()=>zt(!1),className:"modal-choice-button centered-choice",children:[v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),v.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),"Close"]})})]})]})]}),gt&&v.jsx("div",{className:"mobile-timeline-overlay",children:v.jsxs("div",{className:"mobile-timeline-message",children:[v.jsx("p",{children:"Please play the video first to enable timeline controls"}),v.jsx("div",{className:"mobile-play-icon"})]})})]})},QS=({onSplit:L,onReset:D,onUndo:ge,onRedo:Ne,onPlaySegments:Me,onPlay:X,canUndo:c,canRedo:yt,isPlaying:me=!1,isPlayingSegments:ne=!1})=>{const[tt,oe]=q.useState(!1);q.useEffect(()=>{const Q=()=>{oe(window.innerWidth<=640)};return Q(),window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[]);const ze=()=>{X()};return v.jsx("div",{className:"editing-tools-container",children:v.jsxs("div",{className:"flex-container single-row",children:[v.jsxs("div",{className:"button-group play-buttons-group",children:[v.jsx("button",{className:"button segments-button",onClick:Me,"data-tooltip":ne?"Stop chapters playback":"Play chapters in one continuous flow",style:{fontSize:"0.875rem"},children:ne?v.jsxs(v.Fragment,{children:[v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("circle",{cx:"12",cy:"12",r:"10"}),v.jsx("line",{x1:"10",y1:"15",x2:"10",y2:"9"}),v.jsx("line",{x1:"14",y1:"15",x2:"14",y2:"9"})]}),v.jsx("span",{className:"full-text",children:"Stop Preview"}),v.jsx("span",{className:"short-text",children:"Stop Preview"})]}):v.jsxs(v.Fragment,{children:[v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("circle",{cx:"12",cy:"12",r:"10"}),v.jsx("polygon",{points:"10 8 16 12 10 16 10 8"})]}),v.jsx("span",{className:"full-text",children:"Play Preview"}),v.jsx("span",{className:"short-text",children:"Play Preview"})]})}),(!ne||!tt)&&v.jsx("button",{className:`button play-button ${ne?"greyed-out":""}`,onClick:ze,"data-tooltip":me?"Pause video":"Play full video",style:{fontSize:"0.875rem"},disabled:ne,children:me&&!ne?v.jsxs(v.Fragment,{children:[v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("circle",{cx:"12",cy:"12",r:"10"}),v.jsx("line",{x1:"10",y1:"15",x2:"10",y2:"9"}),v.jsx("line",{x1:"14",y1:"15",x2:"14",y2:"9"})]}),v.jsx("span",{className:"full-text",children:"Pause"}),v.jsx("span",{className:"short-text",children:"Pause"})]}):v.jsxs(v.Fragment,{children:[v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("circle",{cx:"12",cy:"12",r:"10"}),v.jsx("polygon",{points:"10 8 16 12 10 16 10 8"})]}),v.jsx("span",{className:"full-text",children:"Play"}),v.jsx("span",{className:"short-text",children:"Play"})]})})]}),v.jsxs("div",{className:"button-group secondary",children:[v.jsxs("button",{className:"button","aria-label":"Undo","data-tooltip":ne?"Disabled during preview":"Undo last action",disabled:!c||ne,onClick:ge,children:[v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("path",{d:"M9 14 4 9l5-5"}),v.jsx("path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5v0a5.5 5.5 0 0 1-5.5 5.5H11"})]}),v.jsx("span",{className:"button-text",children:"Undo"})]}),v.jsxs("button",{className:"button","aria-label":"Redo","data-tooltip":ne?"Disabled during preview":"Redo last undone action",disabled:!yt||ne,onClick:Ne,children:[v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("path",{d:"m15 14 5-5-5-5"}),v.jsx("path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5v0A5.5 5.5 0 0 0 9.5 20H13"})]}),v.jsx("span",{className:"button-text",children:"Redo"})]}),v.jsx("div",{className:"divider"}),v.jsxs("button",{className:"button",onClick:D,"data-tooltip":ne?"Disabled during preview":"Reset to full video",disabled:ne,children:[v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:v.jsx("path",{fillRule:"evenodd",d:"M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z",clipRule:"evenodd"})}),v.jsx("span",{className:"reset-text",children:"Reset"})]})]})]})})},KS=({segments:L,selectedSegmentId:D})=>{const ge=[...L].sort((X,c)=>X.startTime-c.startTime),Ne=X=>{const c=new CustomEvent("delete-segment",{detail:{segmentId:X}});document.dispatchEvent(c)},Me=X=>`segment-default-color segment-color-${X%8+1}`;return ge.find(X=>X.id===D),v.jsxs("div",{className:"clip-segments-container",children:[v.jsx("h3",{className:"clip-segments-title",children:"Chapters"}),ge.map((X,c)=>v.jsxs("div",{className:`segment-item ${Me(c)} ${D===X.id?"selected":""}`,children:[v.jsx("div",{className:"segment-content",children:v.jsxs("div",{className:"segment-info",children:[v.jsx("div",{className:"segment-title",children:X.chapterTitle?v.jsx("span",{className:"chapter-title",children:X.chapterTitle}):v.jsxs("span",{className:"default-title",children:["Chapter ",c+1]})}),v.jsxs("div",{className:"segment-time",children:[wi(X.startTime)," - ",wi(X.endTime)]}),v.jsxs("div",{className:"segment-duration",children:["Duration: ",VS(X.endTime-X.startTime)]})]})}),v.jsx("div",{className:"segment-actions",children:v.jsx("button",{className:"delete-button","aria-label":"Delete Segment","data-tooltip":"Delete this segment",onClick:()=>Ne(X.id),children:v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:v.jsx("path",{fillRule:"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z",clipRule:"evenodd"})})})})]},X.id)),ge.length===0&&v.jsx("div",{className:"empty-message",children:"No chapters created yet. Use the split button to create chapter segments."})]})},JS=({videoRef:L,onPlay:D})=>{const[ge,Ne]=q.useState(!1);q.useEffect(()=>{const c=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(navigator.userAgent);Ne(c)},[]),q.useEffect(()=>{const X=L.current;if(!X)return;const c=()=>{Ne(!1)};return X.addEventListener("play",c),()=>{X.removeEventListener("play",c)}},[L]);const Me=()=>{D()};return ge?v.jsx("div",{className:"mobile-play-prompt-overlay",children:v.jsx("div",{className:"mobile-play-prompt",children:v.jsx("button",{className:"mobile-play-button",onClick:Me,children:"Click to start editing..."})})}):null},ZS=()=>{const L=z=>{const te=z.split(":");if(te.length!==3)return 0;const Ee=parseInt(te[0],10)||0,Te=parseInt(te[1],10)||0,Pe=parseFloat(te[2])||0;return Ee*3600+Te*60+Pe},D=q.useRef(null),[ge,Ne]=q.useState(0),[Me,X]=q.useState(0),[c,yt]=q.useState(!1),[me,ne]=q.useState(!1),[tt,oe]=q.useState(0),[ze,Q]=q.useState(0),[he,W]=q.useState([]),[cn,gt]=q.useState(1),[De,Oe]=q.useState([]),[Lt,O]=q.useState(null),[J,$e]=q.useState([]),[dt,vt]=q.useState(-1),[Yt,_e]=q.useState(!1),[re,Ce]=q.useState(!1),[ue,pt]=q.useState(0);q.useEffect(()=>{var z;if(J.length>0){const te=((z=J[dt])==null?void 0:z.action)||"";te!=="save"&&te!=="save_copy"&&te!=="save_segments"&&_e(!0)}},[J,dt]),q.useEffect(()=>{const z=D.current;if(!z)return;const te=()=>{X(z.duration),Q(z.duration),(async()=>{var ht;let we=[];const lt=typeof window<"u"&&((ht=window.MEDIA_DATA)==null?void 0:ht.chapters)||[];if(lt.length>0)for(let Jt=0;Jt{Ne(z.currentTime)},Te=()=>{yt(!0),Kt(!0)},Pe=()=>{yt(!1)},at=()=>{yt(!1),z.currentTime=tt};return z.addEventListener("loadedmetadata",te),z.addEventListener("timeupdate",Ee),z.addEventListener("play",Te),z.addEventListener("pause",Pe),z.addEventListener("ended",at),()=>{z.removeEventListener("loadedmetadata",te),z.removeEventListener("timeupdate",Ee),z.removeEventListener("play",Te),z.removeEventListener("pause",Pe),z.removeEventListener("ended",at)}},[]);const le=z=>{const te=D.current;if(!te)return;const Ee=!te.paused;te.currentTime=z,Ne(z),typeof window<"u"&&(window.lastSeekedPosition=z),Ee&&te.play().then(()=>{yt(!0)}).catch(Te=>{console.error("Error resuming playback:",Te),yt(!1)})},A=z=>{const te={trimStart:tt,trimEnd:ze,splitPoints:[...he],clipSegments:JSON.parse(JSON.stringify(De)),action:z||"manual_save"},Ee=J[dt],Te=()=>{if(!Ee||Ee.clipSegments.length!==te.clipSegments.length)return!0;for(let Ze=0;Ze.001||Math.abs(we.endTime-lt.endTime)>.001)return!0}return!1},Pe=!Ee||Ee.trimStart!==te.trimStart||Ee.trimEnd!==te.trimEnd||Ee.splitPoints.length!==te.splitPoints.length||Te(),at=te.action!==void 0;if(Pe||at){const Ze=dt;$e(we=>Zewe+1)}};q.useEffect(()=>{const z=te=>{if(te.detail){const{time:Ee,isStart:Te,recordHistory:Pe,action:at}=te.detail;Te?oe(Ee):Q(Ee),Pe&&setTimeout(()=>{A(at||(Te?"adjust_trim_start":"adjust_trim_end"))},10)}};return document.addEventListener("update-trim",z),()=>{document.removeEventListener("update-trim",z)}},[]),q.useEffect(()=>{const z=Te=>{if(Te.detail&&Te.detail.segments){const Pe=Te.detail.recordHistory!==!1,at=Te.detail.action||"update_segments";Oe(Te.detail.segments),Pe&&setTimeout(()=>{const Ze=JSON.parse(JSON.stringify(Te.detail.segments)),we={trimStart:tt,trimEnd:ze,splitPoints:[...he],clipSegments:Ze,action:at},lt=dt;$e(_t=>lt<_t.length-1?[..._t.slice(0,lt+1),we]:[..._t,we]),vt(_t=>_t+1)},20)}},te=async Te=>{const Pe=Te;if(Pe.detail&&typeof Pe.detail.time=="number"&&typeof Pe.detail.segmentId=="number"){const at=Pe.detail.time,Ze=Pe.detail.segmentId;le(at);const we=De.find(Wt=>Wt.id===Ze);if(!we||at<=we.startTime||at>=we.endTime)return;const lt=[...De],_t=lt.findIndex(Wt=>Wt.id===Ze);if(_t===-1)return;lt.splice(_t,1);const ht={id:Date.now(),chapterTitle:`${we.chapterTitle}-A`,startTime:we.startTime,endTime:at},Jt={id:Date.now()+1,chapterTitle:`${we.chapterTitle}-B`,startTime:at,endTime:we.endTime};lt.push(ht,Jt),lt.sort((Wt,fa)=>Wt.startTime-fa.startTime),Oe(lt),A("split_segment")}},Ee=async Te=>{const Pe=Te;if(Pe.detail&&typeof Pe.detail.segmentId=="number"){const at=Pe.detail.segmentId,Ze=De.filter(we=>we.id!==at);if(Ze.length!==De.length){if(Ze.length===0&&D.current){const we={id:Date.now(),chapterTitle:"segment",startTime:0,endTime:D.current.duration};oe(0),Q(D.current.duration),W([]),Oe([we])}else Oe(Ze);A("delete_segment")}}};return document.addEventListener("update-segments",z),document.addEventListener("split-segment",te),document.addEventListener("delete-segment",Ee),()=>{document.removeEventListener("update-segments",z),document.removeEventListener("split-segment",te),document.removeEventListener("delete-segment",Ee)}},[De,Me]);const ye=z=>{oe(z),A("adjust_trim_start")},Be=z=>{Q(z),A("adjust_trim_end")},ot=async()=>{if(D.current&&!he.includes(ge)){const z=[...he,ge].sort((Te,Pe)=>Te-Pe);W(z);const te=[];let Ee=0;for(let Te=0;Te<=z.length;Te++){const Pe=Te{if(oe(0),Q(Me),W([]),!D.current)return;const z={id:Date.now(),chapterTitle:"segment",startTime:0,endTime:Me};Oe([z]),A("reset_all")},Ot=()=>{if(dt>0){const z=J[dt-1];ve.debug(`** UNDO ** to position ${dt-1}, action: ${z.action}, segments: ${z.clipSegments.length}`),ve.debug("Segment details after undo:",z.clipSegments.map(te=>`ID: ${te.id}, Time: ${Y(te.startTime)} - ${Y(te.endTime)}`)),oe(z.trimStart),Q(z.trimEnd),W([...z.splitPoints]),Oe(JSON.parse(JSON.stringify(z.clipSegments))),vt(dt-1)}},Vt=()=>{if(dt`ID: ${te.id}, Time: ${Y(te.startTime)} - ${Y(te.endTime)}`)),oe(z.trimStart),Q(z.trimEnd),W([...z.splitPoints]),Oe(JSON.parse(JSON.stringify(z.clipSegments))),vt(dt+1)}},je=z=>{gt(z)},Ve=()=>{const z=D.current;z&&(z.muted=!z.muted,ne(!me))},Je=(z,te)=>{Oe(Ee=>Ee.map(Te=>Te.id===z?{...Te,...te}:Te)),_e(!0)},en=async z=>{var te;try{const Ee=(te=window.MEDIA_DATA)==null?void 0:te.mediaId;if(!Ee){console.error("No media ID found");return}const Pe={chapters:z.map(_t=>({startTime:_t.from,endTime:_t.to,chapterTitle:_t.chapterTitle}))},at=nt(),Ze={"Content-Type":"application/json"};at&&(Ze["X-CSRFToken"]=at);const we=await fetch(`/api/v1/media/${Ee}/chapters`,{method:"POST",headers:Ze,body:JSON.stringify(Pe)});if(!we.ok)throw new Error(`Failed to save chapters: ${we.status}`);const lt=await we.json();_e(!1)}catch(Ee){console.error("Error saving chapters:",Ee)}},nt=()=>{var Te;const Ee=`; ${document.cookie}`.split("; csrftoken=");return Ee.length===2&&((Te=Ee.pop())==null?void 0:Te.split(";").shift())||""},It=z=>{O(z)},mt=z=>{(!Xe||hn)&&le(z)},Xe=typeof window<"u"&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(navigator.userAgent),[hn,Kt]=q.useState(!1);return q.useEffect(()=>{if(!re||!D.current)return;const z=D.current,te=[...De].sort((Te,Pe)=>Te.startTime-Pe.startTime),Ee=()=>{const Te=te[ue];if(!Te)return;const Pe=z.currentTime;if(Pe=Te.endTime-.01)if(ue{console.error("Error continuing segment playback:",Ze)})}else z.pause(),Ce(!1),pt(0),z.removeEventListener("timeupdate",Ee)};return z.addEventListener("timeupdate",Ee),z.paused&&te.length>0&&(z.currentTime=te[0].startTime,z.play().catch(console.error)),()=>{z.removeEventListener("timeupdate",Ee)}},[re,ue,De]),q.useEffect(()=>{const z=te=>{const{segmentIndex:Ee}=te.detail;re&&Ee!==ue&&pt(Ee)};return document.addEventListener("update-segment-index",z),()=>{document.removeEventListener("update-segment-index",z)}},[re,ue]),{videoRef:D,currentTime:ge,duration:Me,isPlaying:c,setIsPlaying:yt,isMuted:me,isPlayingSegments:re,trimStart:tt,trimEnd:ze,splitPoints:he,zoomLevel:cn,clipSegments:De,selectedSegmentId:Lt,hasUnsavedChanges:Yt,historyPosition:dt,history:J,handleTrimStartChange:ye,handleTrimEndChange:Be,handleZoomChange:je,handleMobileSafeSeek:mt,handleSplit:ot,handleReset:Et,handleUndo:Ot,handleRedo:Vt,handlePlaySegments:()=>{const z=D.current;if(!(!z||De.length===0))if(re)z.pause(),Ce(!1),pt(0);else{Ce(!0),pt(0);const te=[...De].sort((Ee,Te)=>Ee.startTime-Te.startTime);z.currentTime=te[0].startTime,z.play().catch(Ee=>{console.error("Error starting segments playback:",Ee),Ce(!1)})}},toggleMute:Ve,handleSegmentUpdate:Je,handleChapterSave:en,handleSelectedSegmentChange:It,isMobile:Xe,videoInitialized:hn,setVideoInitialized:Kt}},eT=()=>{const{videoRef:L,currentTime:D,duration:ge,isPlaying:Ne,setIsPlaying:Me,isMuted:X,trimStart:c,trimEnd:yt,splitPoints:me,zoomLevel:ne,clipSegments:tt,selectedSegmentId:oe,hasUnsavedChanges:ze,historyPosition:Q,history:he,handleTrimStartChange:W,handleTrimEndChange:cn,handleZoomChange:gt,handleMobileSafeSeek:De,handleSplit:Oe,handleReset:Lt,handleUndo:O,handleRedo:J,toggleMute:$e,handleSegmentUpdate:dt,handleChapterSave:vt,handleSelectedSegmentChange:Yt,isMobile:_e,videoInitialized:re,setVideoInitialized:Ce,isPlayingSegments:ue,handlePlaySegments:pt}=ZS(),le=()=>{if(!L.current)return;const A=L.current;if(Ne){A.pause(),Me(!1);return}const ye=Number(A.currentTime.toFixed(6));let Be=ge,ot=null,Et=null;const Ot=[...tt].sort((je,Ve)=>je.startTime-Ve.startTime);ot=Ot.find(je=>{const Ve=Number(je.startTime.toFixed(6)),Je=Number(je.endTime.toFixed(6));return ye>Ve&&yeNumber(je.startTime.toFixed(6))>ye)),ot?Be=Number(ot.endTime.toFixed(6)):Et&&(Be=Number(Et.startTime.toFixed(6)));const Vt=()=>{if(!A)return;const je=Number(A.currentTime.toFixed(6));if(Number((Be-je).toFixed(6))<=0||je>=Be){A.pause();const Je=()=>{if(!A)return;A.currentTime=Be,De(Be);const en=Number(A.currentTime.toFixed(6)),nt=Number(Math.abs(en-Be).toFixed(6));ve.debug("Position verification:",{target:Y(Be),actual:Y(en),difference:nt}),nt>0&&(A.currentTime=Be,De(Be))};Je(),setTimeout(Je,5),setTimeout(Je,10),setTimeout(Je,20),setTimeout(Je,50),A.removeEventListener("timeupdate",Vt),Me(!1),ve.debug("Stopped at position:",{target:Y(Be),actual:Y(A.currentTime),type:ot?"segment end":Et?"next segment start":"end of video",segment:ot?{id:ot.id,start:Y(ot.startTime),end:Y(ot.endTime)}:null,nextSegment:Et?{id:Et.id,start:Y(Et.startTime),end:Y(Et.endTime)}:null});return}};A.addEventListener("timeupdate",Vt),A.play().then(()=>{Me(!0),Ce(!0),ve.debug("Playback started:",{from:Y(ye),to:Y(Be),currentSegment:ot?{id:ot.id,start:Y(ot.startTime),end:Y(ot.endTime)}:"None",nextSegment:Et?{id:Et.id,start:Y(Et.startTime),end:Y(Et.endTime)}:"None"})}).catch(je=>{console.error("Error playing video:",je)})};return v.jsxs("div",{className:"bg-background min-h-screen",children:[v.jsx(JS,{videoRef:L,onPlay:le}),v.jsxs("div",{className:"container mx-auto px-4 py-6 max-w-6xl",children:[v.jsx(BS,{videoRef:L,currentTime:D,duration:ge,isPlaying:Ne,isMuted:X,onPlayPause:le,onSeek:De,onToggleMute:$e}),v.jsx(QS,{onSplit:Oe,onReset:Lt,onUndo:O,onRedo:J,onPlaySegments:pt,onPlay:le,isPlaying:Ne,isPlayingSegments:ue,canUndo:Q>0,canRedo:Q{const L=document.getElementById("chapters-editor-root");L&&gm(L).render(v.jsx(eT,{}))};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Rm):Rm()})(); +You might need to use a local HTTP server (instead of file://): https://reactjs.org/link/react-devtools-faq`:""),"font-weight:bold")}ca.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=sm,ca.createPortal=o_,ca.createRoot=u_,ca.findDOMNode=t_,ca.flushSync=c_,ca.hydrate=n_,ca.hydrateRoot=s_,ca.render=a_,ca.unmountComponentAtNode=i_,ca.unstable_batchedUpdates=Fp,ca.unstable_renderSubtreeIntoContainer=l_,ca.version=nm,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}(),ca}pm.exports=zS();var FS=pm.exports,gm,bm=FS;{var Sm=bm.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;gm=function(L,D){Sm.usingClientEntryPoint=!0;try{return bm.createRoot(L,D)}finally{Sm.usingClientEntryPoint=!1}}}const Y=L=>{if(isNaN(L))return"00:00:00.000";const D=Math.floor(L/3600),ge=Math.floor(L%3600/60),Ne=Math.floor(L%60),Me=Math.round(L%1*1e3),X=String(D).padStart(2,"0"),c=String(ge).padStart(2,"0"),yt=String(Ne).padStart(2,"0"),me=String(Me).padStart(3,"0");return`${X}:${c}:${yt}.${me}`},wi=L=>Y(L),VS=L=>Y(L),ve={debug:(...L)=>{},error:(...L)=>console.error(...L),warn:(...L)=>console.warn(...L),info:(...L)=>console.info(...L)};var q=Zc();const BS=({videoRef:L,currentTime:D,duration:ge,isPlaying:Ne,isMuted:Me=!1,onPlayPause:X,onSeek:c,onToggleMute:yt})=>{var pt;const me=q.useRef(null),[ne,tt]=q.useState(!1),[oe,ze]=q.useState(!1),[Q,he]=q.useState(null),[W,cn]=q.useState(!1),gt=q.useRef(!1),[De,Oe]=q.useState({x:0}),[Lt,O]=q.useState(0),J=typeof window<"u"&&((pt=window.MEDIA_DATA)==null?void 0:pt.videoUrl)||"/videos/sample-video.mp4";q.useEffect(()=>{if(tt((()=>{const A=navigator.userAgent||navigator.vendor||window.opera;return/iPad|iPhone|iPod/.test(A)&&!window.MSStream})()),typeof window<"u"){const A=localStorage.getItem("video_initialized")==="true";ze(A)}},[]),q.useEffect(()=>{Ne&&!oe&&(ze(!0),typeof window<"u"&&localStorage.setItem("video_initialized","true"))},[Ne,oe]),q.useEffect(()=>{const le=L.current;if(!le)return;le.setAttribute("playsinline","true"),le.setAttribute("webkit-playsinline","true"),le.setAttribute("x-webkit-airplay","allow");const A=()=>{gt.current||(he(le.currentTime),typeof window<"u"&&(window.lastSeekedPosition=le.currentTime))},ye=()=>{ne&&(ze(!0),localStorage.setItem("video_initialized","true"))},Be=()=>{};return le.addEventListener("timeupdate",A),le.addEventListener("play",ye),le.addEventListener("pause",Be),()=>{le.removeEventListener("timeupdate",A),le.removeEventListener("play",ye),le.removeEventListener("pause",Be)}},[L,ne,gt]),q.useEffect(()=>{he(D)},[D]);const $e=ge>0?D/ge*100:0,dt=le=>{le.preventDefault(),cn(!0),gt.current=!0,vt(le);const A=Be=>{gt.current&&vt(Be)},ye=()=>{cn(!1),gt.current=!1,document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",ye)};document.addEventListener("mousemove",A),document.addEventListener("mouseup",ye)},vt=le=>{if(!me.current)return;const A=me.current.getBoundingClientRect(),ye=Math.max(0,Math.min(1,(le.clientX-A.left)/A.width)),Be=ge*ye;Oe({x:le.clientX}),O(Be),he(Be),typeof window<"u"&&(window.lastSeekedPosition=Be),c(Be)},Yt=le=>{if(!me.current||!le.touches[0])return;le.preventDefault(),cn(!0),gt.current=!0,_e(le);const A=Be=>{gt.current&&_e(Be)},ye=()=>{cn(!1),gt.current=!1,document.removeEventListener("touchmove",A),document.removeEventListener("touchend",ye),document.removeEventListener("touchcancel",ye)};document.addEventListener("touchmove",A,{passive:!1}),document.addEventListener("touchend",ye),document.addEventListener("touchcancel",ye)},_e=le=>{if(!me.current)return;const A="touches"in le?le.touches[0]:null;if(!A)return;le.preventDefault();const ye=me.current.getBoundingClientRect(),Be=Math.max(0,Math.min(1,(A.clientX-ye.left)/ye.width)),ot=ge*Be;Oe({x:A.clientX}),O(ot),he(ot),typeof window<"u"&&(window.lastSeekedPosition=ot),c(ot)},re=le=>{if(!W&&me.current){const A=me.current.getBoundingClientRect(),ye=(le.clientX-A.left)/A.width,Be=ge*ye;he(Be),typeof window<"u"&&(window.lastSeekedPosition=Be),c(Be)}},Ce=()=>{L.current&&(document.fullscreenElement?document.exitFullscreen():L.current.requestFullscreen())},ue=()=>{const le=L.current;le&&(le.paused?ne&&Q!==null&&Q>0?(le.currentTime=Q,setTimeout(()=>{L.current&&L.current.play().then(()=>{var A;ve.debug("iOS: Play started successfully at position:",(A=L.current)==null?void 0:A.currentTime),X()}).catch(A=>{console.error("iOS: Error playing video:",A)})},50)):le.play().then(()=>{X()}).catch(A=>{console.error("Error playing video:",A)}):(le.pause(),X()))};return v.jsxs("div",{className:"video-player-container",children:[v.jsxs("video",{ref:L,preload:"auto",crossOrigin:"anonymous",onClick:ue,playsInline:!0,"webkit-playsinline":"true","x-webkit-airplay":"allow",controls:!1,muted:Me,children:[v.jsx("source",{src:J,type:"video/mp4"}),v.jsx("p",{children:"Your browser doesn't support HTML5 video."})]}),ne&&!oe&&!Ne&&v.jsx("div",{className:"ios-first-play-indicator",children:v.jsx("div",{className:"ios-play-message",children:"Tap Play to initialize video controls"})}),v.jsx("div",{className:`play-pause-indicator ${Ne?"pause-icon":"play-icon"}`}),v.jsxs("div",{className:"video-controls",children:[v.jsxs("div",{className:"video-time-display",children:[v.jsx("span",{className:"video-current-time",children:wi(D)}),v.jsxs("span",{className:"video-duration",children:["/ ",wi(ge)]})]}),v.jsxs("div",{ref:me,className:`video-progress ${W?"dragging":""}`,onClick:re,onMouseDown:dt,onTouchStart:Yt,children:[v.jsx("div",{className:"video-progress-fill",style:{width:`${$e}%`}}),v.jsx("div",{className:"video-scrubber",style:{left:`${$e}%`}}),W&&v.jsx("div",{className:"video-time-tooltip",style:{left:`${De.x}px`,transform:"translateX(-50%)"},children:Y(Lt)})]}),v.jsxs("div",{className:"video-controls-buttons",children:[yt&&v.jsx("button",{className:"mute-button","aria-label":Me?"Unmute":"Mute",onClick:yt,"data-tooltip":Me?"Unmute":"Mute",children:Me?v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"}),v.jsx("path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12M15 9.34V4a3 3 0 0 0-5.94-.6"}),v.jsx("path",{d:"M17 16.95A7 7 0 0 1 5 12v-2m14 0v2a7 7 0 0 1-.11 1.23"}),v.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),v.jsx("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]}):v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),v.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"})]})}),v.jsx("button",{className:"fullscreen-button","aria-label":"Fullscreen",onClick:Ce,"data-tooltip":"Toggle fullscreen",children:v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:v.jsx("path",{fillRule:"evenodd",d:"M3 4a1 1 0 011-1h4a1 1 0 010 2H6.414l2.293 2.293a1 1 0 01-1.414 1.414L5 6.414V8a1 1 0 01-2 0V4zm9 1a1 1 0 010-2h4a1 1 0 011 1v4a1 1 0 01-2 0V6.414l-2.293 2.293a1 1 0 11-1.414-1.414L13.586 5H12zm-9 7a1 1 0 012 0v1.586l2.293-2.293a1 1 0 011.414 1.414L6.414 15H8a1 1 0 010 2H4a1 1 0 01-1-1v-4zm13-1a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 010-2h1.586l-2.293-2.293a1 1 0 011.414-1.414L15 13.586V12a1 1 0 011-1z",clipRule:"evenodd"})})})]})]})]})},$S=(L,D)=>{const ge=Math.min(Math.max(L/(D||1),0),1),Ne=210,Me=40+Math.floor(ge*20),X=85+Math.floor(ge*8);return`hsl(${Ne}, ${Me}%, ${X}%)`},Wu=({isOpen:L,onClose:D,title:ge,children:Ne,actions:Me})=>{if(q.useEffect(()=>{const c=yt=>{yt.key==="Escape"&&L&&D()};return document.addEventListener("keydown",c),L&&(document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",c),document.body.style.overflow=""}},[L,D]),!L)return null;const X=c=>{c.target===c.currentTarget&&D()};return v.jsx("div",{className:"modal-overlay",onClick:X,children:v.jsxs("div",{className:"modal-container",onClick:c=>c.stopPropagation(),children:[v.jsxs("div",{className:"modal-header",children:[v.jsx("h2",{className:"modal-title",children:ge}),v.jsx("button",{className:"modal-close-button",onClick:D,"aria-label":"Close modal",style:{minWidth:"24px",minHeight:"24px"},children:v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),v.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),v.jsx("div",{className:"modal-content",children:Ne}),Me&&v.jsx("div",{className:"modal-actions",children:Me})]})})},PS=async(L,D)=>{try{const ge=await fetch(`/api/v1/media/${L}/chapters`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)});if(ve.debug("response",ge),!ge.ok){if(ge.status===404)return{success:!0,timestamp:new Date().toISOString()};try{const Me=await ge.json();return{success:!1,timestamp:new Date().toISOString(),error:Me.error||"Auto-save failed (videoApi.ts)"}}catch{return{success:!1,timestamp:new Date().toISOString(),error:"Auto-save failed (videoApi.ts)"}}}const Ne=await ge.json();return{success:!0,timestamp:Ne.updated_at||new Date().toISOString(),...Ne}}catch{return{success:!0,timestamp:new Date().toISOString()}}},Tm="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20style='enable-background:new%200%200%20512%20512;'%20version='1.1'%20viewBox='0%200%20512%20512'%20xml:space='preserve'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cstyle%20type='text/css'%3e%20.st0{fill:%23333333;}%20.st1{fill:none;stroke:%23333333;stroke-width:32;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;}%20%3c/style%3e%3cg%20id='Layer_1'/%3e%3cg%20id='Layer_2'%3e%3cg%3e%3cpath%20class='st0'%20d='M350.45,277.5l-164.08,94.73c-16.55,9.56-37.24-2.39-37.24-21.5V161.27c0-19.11,20.69-31.06,37.24-21.5%20l164.08,94.73C367,244.06,367,267.94,350.45,277.5z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",Em="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20style='enable-background:new%200%200%20512%20512;'%20version='1.1'%20viewBox='0%200%20512%20512'%20xml:space='preserve'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cstyle%20type='text/css'%3e.st0{fill:%23333333;}.st1{fill:none;stroke:%23333333;stroke-width:32;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;}%3c/style%3e%3cg%20id='Layer_1'/%3e%3cg%20id='Layer_2'%3e%3cg%3e%3cg%3e%3cpath%20class='st0'%20d='M208.15,380.19h-91.19c-5.7,0-10.32-4.62-10.32-10.32V142.13c0-5.7,4.62-10.32,10.32-10.32h91.19%20c5.7,0,10.32,4.62,10.32,10.32v227.74C218.47,375.57,213.85,380.19,208.15,380.19z'/%3e%3c/g%3e%3cg%3e%3cpath%20class='st0'%20d='M395.04,380.19h-91.19c-5.7,0-10.32-4.62-10.32-10.32V142.13c0-5.7,4.62-10.32,10.32-10.32h91.19%20c5.7,0,10.32,4.62,10.32,10.32v227.74C405.36,375.57,400.74,380.19,395.04,380.19z'/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",Cm="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20style='enable-background:new%200%200%20512%20512;'%20version='1.1'%20viewBox='0%200%20512%20512'%20xml:space='preserve'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cstyle%20type='text/css'%3e.st0{fill:%23333333;}.st1{fill:none;stroke:%23333333;stroke-width:32;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;}%3c/style%3e%3cg%20id='Layer_1'/%3e%3cg%20id='Layer_2'%3e%3cg%3e%3cg%3e%3cpath%20class='st0'%20d='M85.26,277.5l164.08,94.73c16.55,9.56,37.24-2.39,37.24-21.5V161.27c0-19.11-20.69-31.06-37.24-21.5%20L85.26,234.5C68.71,244.06,68.71,267.94,85.26,277.5z'/%3e%3c/g%3e%3cg%3e%3cpath%20class='st0'%20d='M377.47,375.59h41.42c11.19,0,20.26-9.07,20.26-20.26V156.67c0-11.19-9.07-20.26-20.26-20.26h-41.42%20c-11.19,0-20.26,9.07-20.26,20.26v198.67C357.21,366.52,366.28,375.59,377.47,375.59z'/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",YS="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20height='32'%20viewBox='0%200%2032%2032'%20width='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle/%3e%3cg%20data-name='1'%20id='_1'%3e%3cpath%20d='M27,3V29a1,1,0,0,1-1,1H6a1,1,0,0,1-1-1V27H7v1H25V4H7V7H5V3A1,1,0,0,1,6,2H26A1,1,0,0,1,27,3Z'/%3e%3cg%20transform='translate(2,%200)'%3e%3cpath%20d='M10.71,20.29,7.41,17H18V15H7.41l3.3-3.29L9.29,10.29l-5,5a1,1,0,0,0,0,1.42l5,5Z'%20id='logout_account_exit_door'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",IS="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20height='32'%20viewBox='0%200%2032%2032'%20width='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20data-name='1'%20id='_1'%3e%3cpath%20d='M5,3V29a1,1,0,0,0,1,1H26a1,1,0,0,0,1-1V25H25v3H7V4H25V7h2V3a1,1,0,0,0-1-1H6A1,1,0,0,0,5,3Z'/%3e%3cg%20transform='translate(28,%200)%20scale(-1,%201)'%3e%3cpath%20d='M10.71,20.29,7.41,17H18V15H7.41l3.3-3.29L9.29,10.29l-5,5a1,1,0,0,0,0,1.42l5,5Z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",WS="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20height='32'%20viewBox='0%200%2032%2032'%20width='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20data-name='1'%20id='_1'%3e%3cpath%20d='M5,3V29a1,1,0,0,0,1,1H26a1,1,0,0,0,1-1V25H25v3H7V4H25V7h2V3a1,1,0,0,0-1-1H6A1,1,0,0,0,5,3Z'/%3e%3cg%20transform='translate(30,%200)%20scale(-1,%201)'%3e%3cpath%20d='M10.71,20.29,7.41,17H18V15H7.41l3.3-3.29L9.29,10.29l-5,5a1,1,0,0,0,0,1.42l5,5Z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",qS="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20height='32'%20viewBox='0%200%2032%2032'%20width='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle/%3e%3cg%20data-name='1'%20id='_1'%3e%3cpath%20d='M27,3V29a1,1,0,0,1-1,1H6a1,1,0,0,1-1-1V27H7v1H25V4H7V7H5V3A1,1,0,0,1,6,2H26A1,1,0,0,1,27,3Z'/%3e%3cg%20transform='translate(2,%200)'%3e%3cpath%20d='M10.71,20.29,7.41,17H18V15H7.41l3.3-3.29L9.29,10.29l-5,5a1,1,0,0,0,0,1.42l5,5Z'%20id='logout_account_exit_door'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",GS={color:"#007bff",textDecoration:"none",fontWeight:"bold","&:hover":{textDecoration:"underline",color:"#0056b3"}},xm=L=>{let X,c;if(L<=15)if(L<=0)X="0%",c="none";else{const me=-50*((L-0)/15);X=`${L}%`,c=`translateX(${me}%)`}else if(L>=75)if(L>=100)X="100%",c="translateX(-100%)";else{const me=-50-50*((L-75)/25);X=`${L}%`,c=`translateX(${me}%)`}else X=`${L}%`,c="translateX(-50%)";return{left:X,transform:c}},XS=({currentTime:L,duration:D,trimStart:ge,trimEnd:Ne,splitPoints:Me,zoomLevel:X,clipSegments:c,selectedSegmentId:yt,onSelectedSegmentChange:me,onSegmentUpdate:ne,onChapterSave:tt,onTrimStartChange:oe,onTrimEndChange:ze,onZoomChange:Q,onSeek:he,videoRef:W,hasUnsavedChanges:cn=!1,isIOSUninitialized:gt=!1,isPlaying:De,setIsPlaying:Oe,onPlayPause:Lt,isPlayingSegments:O=!1})=>{const J=q.useRef(null),$e=q.useRef(null),dt=q.useRef(null),[vt,Yt]=q.useState(null),_e=yt!==void 0?yt:vt,re=p=>{me?me(p):Yt(p)},[Ce,ue]=q.useState(!1),[pt,le]=q.useState({x:0,y:0}),[A,ye]=q.useState(0),[Be,ot]=q.useState(!1),[Et,Ot]=q.useState(30),[Vt,je]=q.useState(!1),[Ve,Je]=q.useState(null),[en,nt]=q.useState(0),[It,mt]=q.useState(!1),Xe=q.useRef(null),[hn,Kt]=q.useState(""),[Nn,z]=q.useState(!1),Ee=[...c].sort((p,R)=>p.startTime-R.startTime).find(p=>p.id===_e),[Te,Pe]=q.useState(""),[at,Ze]=q.useState(!1),we=q.useRef(null),lt=q.useRef(c);q.useEffect(()=>{lt.current=c},[c]);const _t=q.useCallback(async()=>{var p;try{Ze(!0);const R=lt.current.map(_=>({startTime:Y(_.startTime),endTime:Y(_.endTime),chapterTitle:_.chapterTitle}));ve.debug("chapters",R);const y=typeof window<"u"&&((p=window.MEDIA_DATA)==null?void 0:p.mediaId)||null||"1234";if(ve.debug("mediaId",y),!y||R.length===0){ve.debug("No mediaId or segments, skipping auto-save"),Ze(!1);return}ve.debug("Auto-saving segments:",{mediaId:y,chapters:R});const E=await PS(y,{chapters:R});if(E.success===!0){ve.debug("Auto-save successful");const S=new Date(E.updated_at||new Date().toISOString()).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).replace(",","");Pe(S),ve.debug("Auto-save successful:",S)}else ve.error("Auto-save failed: (TimelineControls.tsx)")}catch(R){ve.error("Auto-save error: (TimelineControls.tsx)",R)}finally{Ze(!1)}},[]),ht=q.useCallback(()=>{we.current&&clearTimeout(we.current);const p=setTimeout(()=>{_t()},1e3);we.current=p},[_t]);q.useEffect(()=>{Kt(Ee&&Ee.chapterTitle||"")},[_e,Ee]);const Jt=p=>{Kt(p),z(!0),_e&&ne&&ne(_e,{chapterTitle:p})},Wt=p=>{const R=p;let T=null,y=null,E=A;const _=()=>{const S=R<0?Math.max(0,E+R):Math.min(D,E+R);E=S;const V=Vt;if(he(S),ye(S),nt(S),J.current){const B=J.current.getBoundingClientRect(),K=S/D*100,Le=B.left+B.width*(K/100);le({x:Le,y:B.top-10});const F=c.find(Ke=>S>=Ke.startTime&&S<=Ke.endTime);if(F)re(F.id),ue(!1);else{re(null);const Ke=va(S);Ot(Ke),ue(!0)}}V&&W.current&&(W.current.play(),je(!0))};return{onMouseDown:S=>{S.stopPropagation(),S.preventDefault(),E=A,_(),T=setTimeout(()=>{y=setInterval(_,200)},750);const V=()=>{T&&(clearTimeout(T),T=null),y&&(clearInterval(y),y=null),document.removeEventListener("mouseup",V),document.removeEventListener("mouseleave",V)};document.addEventListener("mouseup",V),document.addEventListener("mouseleave",V)},onTouchStart:S=>{S.stopPropagation(),S.preventDefault(),E=A,_(),T=setTimeout(()=>{y=setInterval(_,200)},750);const V=()=>{T&&(clearTimeout(T),T=null),y&&(clearInterval(y),y=null),document.removeEventListener("touchend",V),document.removeEventListener("touchcancel",V)};document.addEventListener("touchend",V),document.addEventListener("touchcancel",V)},onClick:S=>{S.stopPropagation()}}},[fa,In]=q.useState(!1),[Z,xe]=q.useState(!1),[Qe,Ct]=q.useState(!1),[Bt,zt]=q.useState(!1),[tn,Rn]=q.useState(""),[qt,At]=q.useState(""),[Ft,ir]=q.useState(""),[Sa,Ta]=q.useState("chapters"),da=D>0?L/D*100:0,Kr=D>0?ge/D*100:0,Jr=D>0?Ne/D*100:0,Sr=async()=>{var p;In(!1),xe(!0),Ta("chapters");try{const R=c.filter(T=>T.chapterTitle&&T.chapterTitle.trim()).map(T=>({chapterTitle:T.chapterTitle||`Chapter ${T.id}`,from:Y(T.startTime),to:Y(T.endTime)}));if(R.length===0){At("No chapters with titles found"),zt(!0),xe(!1);return}if(tt){await tt(R),xe(!1),Rn("Chapters saved successfully!");const T=typeof window<"u"&&((p=window.MEDIA_DATA)==null?void 0:p.mediaId)||null;T&&ir(`/view?m=${T}`),Ct(!0)}else At("Chapter save function not available"),zt(!0),xe(!1)}catch(R){ve.error("Error saving chapters:",R),xe(!1);const T=R instanceof Error?R.message:"An error occurred while saving chapters";At(T),zt(!0)}};q.useEffect(()=>{if(Xe.current&&J.current&&X>1){const p=Xe.current.clientWidth,R=J.current.clientWidth,T=L/D*R,y=Math.max(0,T-p/2);Xe.current.scrollTo({left:y,behavior:"smooth"});const E=J.current.getBoundingClientRect();Xe.current.getBoundingClientRect();const S=E.left-Xe.current.scrollLeft+da/100*E.width;(_e!==null||Ce)&&(le({x:S,y:E.top-10}),ye(L))}},[L,X,D,_e,Ce,da]),q.useEffect(()=>{const p=W.current;if(!p||!Ve||!Vt||O)return;ve.debug("Segment boundary check ACTIVATED for segment:",Ve.id,"Start:",Y(Ve.startTime),"End:",Y(Ve.endTime));const R=()=>{const T=Ve.endTime-p.currentTime;if(Math.round(T*10)%10===0&&ve.debug("Segment playback - time remaining:",Y(T),"Current:",Y(p.currentTime),"End:",Y(Ve.endTime),"ContinuePastBoundary:",It),p.currentTime>Ve.endTime){p.pause(),p.currentTime=Ve.endTime,je(!1),mt(!1),ve.debug("Passed segment end - setting back to exact boundary:",Y(Ve.endTime));return}if(Ve.endTime-p.currentTime<.05)if(It)ve.debug("Continuing past segment boundary:",Y(Ve.endTime)),p.currentTime>Ve.endTime&&(mt(!1),Je(null),sessionStorage.removeItem("continuingPastSegment"));else{p.pause(),p.currentTime=Ve.endTime,je(!1),ve.debug("Paused at segment end boundary:",Y(Ve.endTime));const E=[...c].sort((_,S)=>_.startTime-S.startTime).find(_=>_.startTime>Ve.endTime);E&&Math.abs(E.startTime-Ve.endTime)<.1&&(ve.debug("Found adjacent next segment:",E.id),re(E.id),Je(E),nt(E.startTime),ye(E.startTime),p.currentTime=E.startTime)}};return p.addEventListener("timeupdate",R),()=>{p.removeEventListener("timeupdate",R)}},[Ve,Vt,It,c]),q.useEffect(()=>{if(W.current)if(W.current.paused)W.current.paused&&Vt&&(nt(L),ye(L),je(!1),ve.debug("Video paused at:",Y(L)));else{nt(L),ye(L),_e!==null&&je(!0);const p=c.find(y=>L>=y.startTime&&L<=y.endTime),R=L/D*100;if(J.current){const y=J.current.offsetWidth,E=R/100*y;le({x:E,y:J.current.getBoundingClientRect().top-10})}const T=sessionStorage.getItem("continuingPastSegment")==="true";if(p){const y=W.current,E=Ve&&Ve.id<0&&Vt;if((Ve==null?void 0:Ve.id)!==p.id&&!E&&!T&&!It&&(ve.debug(`Entered a new segment during playback: ${p.id}, setting as active`),Je(p),re(p.id),ue(!1),mt(!1),sessionStorage.removeItem("continuingPastSegment")),E&&y&&p){ve.debug(`CUTAWAY BOUNDARY REACHED: Current position ${Y(y.currentTime)} at segment ${p.id} - STOPPING at boundary ${Y(p.startTime)}`),y.pause(),setTimeout(()=>{if(W.current){W.current.currentTime=p.startTime,he(p.startTime),nt(p.startTime),ye(p.startTime),mt(!1),re(p.id),ue(!1);const S=()=>{W.current&&(W.current.currentTime=p.startTime,he(p.startTime),nt(p.startTime),ye(p.startTime),ve.debug(`Position corrected to exact segment boundary: ${Y(W.current.currentTime)} (target: ${Y(p.startTime)})`))};setTimeout(S,10),setTimeout(S,20),setTimeout(S,50),setTimeout(S,100),setTimeout(S,200),W.current.addEventListener("seeked",S),W.current.addEventListener("canplay",S),W.current.addEventListener("waiting",S),setTimeout(()=>{W.current&&(W.current.removeEventListener("seeked",S),W.current.removeEventListener("canplay",S),W.current.removeEventListener("waiting",S))},300)}},10),je(!1),Je(null);return}Ve===null&&Vt===!0||T||E?(_e!==p.id||Ce)&&(ve.debug("Tooltip updated for segment during continued playback:",p.id,E?"(cutaway playback - keeping virtual segment)":""),re(p.id),ue(!1),!E&&sessionStorage.getItem("lastSegmentId")!==p.id.toString()&&sessionStorage.removeItem("continuingPastSegment")):((Ve==null?void 0:Ve.id)!==p.id||Ce)&&(ve.debug("Playback moved into segment:",p.id),re(p.id),Je(p),ue(!1),sessionStorage.setItem("lastSegmentId",p.id.toString()))}else if(Ve!==null||!Ce){re(null),Je(null);const y=va(L);Ot(y),y>=.5?ue(!0):ue(!1)}}},[L,Vt,Ve,_e,c]),q.useEffect(()=>{const p=R=>{const T=R.target;Be&&!T.closest(".zoom-dropdown-container")&&ot(!1)};return document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p)}},[Be]),q.useEffect(()=>{const p=y=>{const{recordHistory:E,fromAutoSave:_}=y.detail;E&&!_&&ht()},R=()=>{ht()},T=y=>{const{recordHistory:E}=y.detail;E&&ht()};return document.addEventListener("update-segments",p),document.addEventListener("segment-drag-end",R),document.addEventListener("update-trim",T),document.addEventListener("delete-segment",ht),document.addEventListener("split-segment",ht),()=>{document.removeEventListener("update-segments",p),document.removeEventListener("segment-drag-end",R),document.removeEventListener("update-trim",T),document.removeEventListener("delete-segment",ht),document.removeEventListener("split-segment",ht),we.current&&(ve.debug("Clearing auto-save timer in cleanup:",we.current),clearTimeout(we.current))}},[ht]),q.useEffect(()=>{c.length>0&&!Te&&setTimeout(()=>{_t()},500)},[Te,_t]),q.useEffect(()=>{const p=()=>{var y;let T=typeof window<"u"&&((y=window.MEDIA_DATA)==null?void 0:y.chapters)||null;try{if(T&&T.chapters&&T.chapters.length>0){ve.debug("Found saved segments:",T);const E=T.chapters.map((S,V)=>({id:Date.now()+V,chapterTitle:S.chapterTitle||`Chapter ${V+1}`,startTime:R(S.startTime),endTime:R(S.endTime)})),_=new CustomEvent("update-segments",{detail:{segments:E,recordHistory:!1,fromAutoSave:!0}});if(document.dispatchEvent(_),T.updated_at){const V=new Date(T.updated_at).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).replace(",","");Pe(V)}}else ve.debug("No saved segments found")}catch(E){console.error("Error loading saved segments:",E)}},R=T=>{const y=T.split(":");if(y.length!==3)return 0;const E=parseInt(y[0])||0,_=parseInt(y[1])||0,S=y[2].split("."),V=parseInt(S[0])||0,B=parseInt(S[1])||0;return E*3600+_*60+V+B/1e3};setTimeout(p,100)},[]),q.useEffect(()=>()=>{},[_e,Ce,Vt]),q.useEffect(()=>{const p=$e.current,R=dt.current,T=J.current;if(!p||!R||!T)return;const y=E=>_=>{_.preventDefault();const S=T.getBoundingClientRect();let V=!0,B=E?ge:Ne;const K=Ke=>new CustomEvent("trim-handle-event",{detail:{type:Ke,isStart:E}});document.dispatchEvent(K("drag-start"));const Le=Ke=>{if(!V)return;const kt=S.width,rn=Math.max(0,Math.min(1,(Ke.clientX-S.left)/kt))*D;typeof window<"u"&&(window.lastSeekedPosition=rn),E?rnge&&(document.dispatchEvent(new CustomEvent("update-trim",{detail:{time:rn,isStart:!1,recordHistory:!1}})),B=rn)},F=()=>{V=!1,document.removeEventListener("mousemove",Le),document.removeEventListener("mouseup",F),E?document.dispatchEvent(new CustomEvent("update-trim",{detail:{time:B,isStart:!0,recordHistory:!0,action:"adjust_trim_start"}})):document.dispatchEvent(new CustomEvent("update-trim",{detail:{time:B,isStart:!1,recordHistory:!0,action:"adjust_trim_end"}})),document.dispatchEvent(K("drag-end"))};document.addEventListener("mousemove",Le),document.addEventListener("mouseup",F)};return p.addEventListener("mousedown",y(!0)),R.addEventListener("mousedown",y(!1)),()=>{p.removeEventListener("mousedown",y(!0)),R.removeEventListener("mousedown",y(!1))}},[D,ge,Ne,oe,ze]);const Zr=()=>Me.map((p,R)=>{const T=p/D*100;return v.jsx("div",{className:"split-point",style:{left:`${T}%`}},R)}),va=p=>{const T=[...c].sort((S,V)=>S.startTime-V.startTime),y=T.find(S=>S.startTime>p),E=[...T].reverse().find(S=>S.endTime{if(!J.current)return;const R=c.find(B=>{const K=p>=B.startTime&&p<=B.endTime,Le=Math.abs(p-B.startTime)<.001,F=Math.abs(p-B.endTime)<.001;return K||Le||F}),T=[...c].sort((B,K)=>B.startTime-K.startTime),y=T.find(B=>B.startTime>p),E=[...T].reverse().find(B=>B.endTime1&&Xe.current?V=_.left-Xe.current.scrollLeft+_.width*(S/100):V=_.left+_.width*(S/100),le({x:V,y:_.top-10})},Zn=p=>{if(!J.current||!Xe.current||gt)return;const R=W.current&&!W.current.paused;mt(!1);const T=J.current.getBoundingClientRect();let y;if(X>1){const S=Xe.current.scrollLeft,V=J.current.clientWidth;y=(p.clientX-T.left+S)/V}else y=(p.clientX-T.left)/T.width;const E=y*D;ve.debug("Timeline clicked at:",Y(E),"distance from end:",Y(D-E)),typeof window<"u"&&(window.lastSeekedPosition=E),he(E),ye(E),nt(E);const _=c.find(S=>{const V=E>=S.startTime&&E<=S.endTime,B=Math.abs(E-S.startTime)<.01,K=Math.abs(E-S.endTime)<.01;return V||B||K});if(_&&Je(_),W.current)if(O&&R){if(_){const V=[...c].sort((B,K)=>B.startTime-K.startTime).findIndex(B=>B.id===_.id);if(V!==-1){const B=new CustomEvent("update-segment-index",{detail:{segmentIndex:V}});document.dispatchEvent(B),ve.debug(`Segments playback mode: updating segment index to ${V} for timeline click in segment ${_.id}`)}}W.current.play().then(()=>{je(!0)}).catch(S=>{console.error("Error resuming segments playback:",S),je(!1)})}else R&&!O&&W.current.play().then(()=>{je(!0)}).catch(S=>{console.error("Error resuming playback:",S),je(!1)});if(p.target===J.current)if(_)re(_.id),ue(!1);else{re(null);const S=va(E);Ot(S);let V;if(X>1){const F=T.left-Xe.current.scrollLeft,Ke=E/D;V=F+Ke*T.width}else V=p.clientX;le({x:V,y:T.top-10}),ue(!0);const B=[...c].sort((F,Ke)=>F.startTime-Ke.startTime),K=[...B].reverse().find(F=>F.endTimeF.startTime>E);ve.debug("Clicked in cutaway area:",{position:Y(E),availableSpace:Y(S),prevSegmentEnd:K?Y(K.endTime):"none",nextSegmentStart:Le?Y(Le.startTime):"none"})}},wn=(p,R)=>T=>{if(T.preventDefault(),T.stopPropagation(),!J.current)return;J.current.getBoundingClientRect().width;const E=c.find(Dn=>Dn.id===p);if(!E)return;const _=E.startTime,S=E.endTime,V={...E};document.body.style.cursor="ew-resize";const B=document.createElement("div");B.style.position="fixed",B.style.top="0",B.style.left="0",B.style.width="100vw",B.style.height="100vh",B.style.zIndex="1000",B.style.cursor="ew-resize",document.body.appendChild(B);let K=!0,Le=_,F=S;document.dispatchEvent(new CustomEvent("segment-drag-start",{detail:{segmentId:p}}));const Ke=Dn=>{if(!K||!J.current)return;const or=J.current.getBoundingClientRect(),$t=Math.max(0,Math.min(1,(Dn-or.left)/or.width))*D,Ea=R?$t:_,Pa=R?S:$t;if(L>=Ea&&L<=Pa)re(p),ue(!1);else{re(null);const ln=va(L);Ot(ln),ue(!0)}const Ca=c.filter(ln=>ln.id!==p);let ea=_,Wn=S;if(R){ea=Math.min($t,S-.5);const xt=Ca.filter(xa=>xa.endTime<=_).sort((xa,Di)=>Di.endTime-xa.endTime)[0];xt&&eaxa.startTime>=S).sort((xa,Di)=>xa.startTime-Di.startTime)[0];xt&&Wn>xt.startTime&&(Wn=xt.startTime),xt&&Math.abs(Wn-xt.startTime)<.3&&(Wn=xt.startTime),F=Wn}const Rr=c.map(ln=>ln.id===p?{...ln,startTime:ea,endTime:Wn}:ln),wr=new CustomEvent("update-segments",{detail:{segments:Rr,recordHistory:!1}});if(document.dispatchEvent(wr),_e===p&&W.current){const ln=W.current.currentTime,xt=Rr.find(Ya=>Ya.id===p);if(xt){const Ya=ln>=xt.startTime&&ln<=xt.endTime;ve.debug(`During drag - playhead at ${Y(ln)} is ${Ya?"inside":"outside"} segment (${Y(xt.startTime)} - ${Y(xt.endTime)})`),!Ya&&Vt&&(W.current.pause(),je(!1),Je(null)),lnxt.endTime&&(ve.debug(`Adjusting display time to segment end: ${Y(xt.endTime)}`),nt(xt.endTime),ye(xt.endTime))}}},kt=()=>{if(!K)return;K=!1,document.removeEventListener("mousemove",bt),document.removeEventListener("mouseup",rn),document.removeEventListener("touchmove",xr),document.removeEventListener("touchend",Na),document.removeEventListener("touchcancel",Na),document.body.style.cursor="",document.body.contains(B)&&document.body.removeChild(B);const Dn=c.map(_n=>_n.id===p?{..._n,startTime:Le,endTime:F}:_n),or=R?"adjust_segment_start":"adjust_segment_end";if(document.dispatchEvent(new CustomEvent("update-segments",{detail:{segments:Dn,recordHistory:!0,action:or}})),_e===p&&W.current){const _n=W.current.currentTime,$t=Dn.find(Ea=>Ea.id===p);if($t){const Ea=_n>=$t.startTime&&_n<=$t.endTime;ve.debug(`Drag complete - playhead at ${Y(_n)} is ${Ea?"inside":"outside"} segment (${Y($t.startTime)} - ${Y($t.endTime)})`);const Pa=_n>=V.startTime&&_n<=V.endTime;Ea?(!Pa&&Ea||Pa&&Ea&&($t.startTime!==V.startTime||$t.endTime!==V.endTime))&&Je($t):(Vt&&(W.current.pause(),je(!1),Je(null),mt(!1)),_n<$t.startTime?(ve.debug(`Final adjustment - setting display time to segment start: ${Y($t.startTime)}`),nt($t.startTime),ye($t.startTime)):_n>$t.endTime&&(ve.debug(`Final adjustment - setting display time to segment end: ${Y($t.endTime)}`),nt($t.endTime),ye($t.endTime)))}}},bt=Dn=>{Ke(Dn.clientX)},rn=()=>{kt()},xr=Dn=>{Dn.touches.length>0&&(Dn.preventDefault(),Ke(Dn.touches[0].clientX))},Na=()=>{kt()};document.addEventListener("mousemove",bt,{passive:!1}),document.addEventListener("mouseup",rn),document.addEventListener("touchmove",xr,{passive:!1}),document.addEventListener("touchend",Na),document.addEventListener("touchcancel",Na)},Aa=p=>R=>{if(R.target.classList.contains("clip-segment-handle"))return;R.preventDefault(),R.stopPropagation(),mt(!1);const T=W.current&&!W.current.paused;re(p);const y=c.find(F=>F.id===p);if(!y)return;const _=R.currentTarget.getBoundingClientRect(),S=(R.clientX-_.left)/_.width,V=y.startTime+S*(y.endTime-y.startTime),B=Math.max(y.startTime,Math.min(y.endTime,V));if(ye(B),nt(B),W.current){const F=W.current.currentTime,Ke=F>=y.startTime&&F<=y.endTime;ve.debug(`Segment click - playhead at ${Y(F)} is ${Ke?"inside":"outside"} segment (${Y(y.startTime)} - ${Y(y.endTime)})`),Ke||(Math.abs(F-y.startTime)kt.startTime-bt.startTime).findIndex(kt=>kt.id===p);if(Ke!==-1){const kt=new CustomEvent("update-segment-index",{detail:{segmentIndex:Ke}});document.dispatchEvent(kt)}W.current.play().then(()=>{je(!0)}).catch(kt=>{console.error("Error continuing segments playback after segment click:",kt)})}else T&&!O&&(Je(y),mt(!1),W.current.play().then(()=>{je(!0)}).catch(F=>{console.error("Error resuming playback after segment click:",F)}));const K=R.clientX,Le=_.top-10;if(le({x:K,y:Le}),X>1&&J.current&&Xe.current){J.current.getBoundingClientRect();const F=J.current.clientWidth,Ke=Xe.current.clientWidth,kt=B/D*F,bt=Math.max(0,kt-Ke/2);Xe.current.scrollTo({left:bt,behavior:"smooth"}),setTimeout(()=>{if(J.current&&Xe.current){const rn=J.current.getBoundingClientRect(),Na=B/D*F-Xe.current.scrollLeft+rn.left;le({x:Na,y:Le})}},300)}},Tr=()=>c.map((p,R)=>{const T=p.startTime/D*100,y=(p.endTime-p.startTime)/D*100,E=$S((p.startTime+p.endTime)/2,D);return v.jsxs("div",{className:`clip-segment ${_e===p.id?"selected":""}`,style:{left:`${T}%`,width:`${y}%`,backgroundColor:E,borderWidth:"2px",borderStyle:"solid",borderColor:"rgba(0, 0, 0, 0.5)"},onClick:Aa(p.id),children:[v.jsxs("div",{className:"clip-segment-info",children:[v.jsxs("div",{className:"clip-segment-name",children:["Chapter ",R+1]}),v.jsxs("div",{className:"clip-segment-time",children:[wi(p.startTime)," - ",wi(p.endTime)]}),v.jsxs("div",{className:"clip-segment-duration",children:["Duration: ",wi(p.endTime-p.startTime)]})]}),O?null:v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"clip-segment-handle left",title:"Resize segment start",onMouseDown:_=>{_.stopPropagation(),wn(p.id,!0)(_)},onTouchStart:_=>{_.stopPropagation(),wn(p.id,!0)(_)}}),v.jsx("div",{className:"clip-segment-handle right",title:"Resize segment end",onMouseDown:_=>{_.stopPropagation(),wn(p.id,!1)(_)},onTouchStart:_=>{_.stopPropagation(),wn(p.id,!1)(_)}})]})]},p.id)});q.useEffect(()=>{const p=R=>{const{segmentId:T}=R.detail;if(c.filter(E=>E.id!==T).length===0){const E={id:Date.now(),chapterTitle:"Full Video",startTime:0,endTime:D},_=new CustomEvent("update-segments",{detail:{segments:[E],recordHistory:!0,action:"create_full_video_segment"}});if(document.dispatchEvent(_),re(E.id),ue(!1),ye(L),nt(L),Je(E),J.current){const S=J.current.getBoundingClientRect(),V=L/D*100,B=S.left+S.width*(V/100);le({x:B,y:S.top-10}),ve.debug("Created full video segment:",{id:E.id,duration:Y(D),currentPosition:Y(L)})}}else if(_e===T){if(!c.find(S=>S.id===T))return;const _=va(L);if(re(null),ue(!0),Ot(_),J.current){const S=J.current.getBoundingClientRect(),V=L/D*100,B=S.left+S.width*(V/100);le({x:B,y:S.top-10}),ve.debug("Segment deleted, showing cutaway tooltip:",{position:Y(L),availableSpace:Y(_)})}}};return document.addEventListener("delete-segment",p),()=>{document.removeEventListener("delete-segment",p)}},[_e,c,L,D,J]),q.useEffect(()=>{const p=W.current;if(!p)return;const R=()=>{if(!W.current)return;const y=W.current,E=y.currentTime;mt(!1);let _=D,S=null,V=null;S=c.find(K=>{const Le=E>=K.startTime&&E<=K.endTime,F=Math.abs(E-K.startTime)<.001,Ke=Math.abs(E-K.endTime)<.001;return Le||F||Ke}),V=c.filter(K=>{const Le=K.startTime>E,F=Math.abs(K.startTime-E)>.001;return Le&&F}).sort((K,Le)=>K.startTime-Le.startTime)[0],S?(_=S.endTime,Je(S)):V&&(_=V.startTime);const B=()=>{if(!y)return;const K=y.currentTime;if(_-K<=.001||K>=_){y.pause();const F=()=>{y&&(y.currentTime=_,he(_),nt(_),ye(_),ve.debug("Position verification:",{target:Y(_),actual:Y(y.currentTime),difference:Math.abs(y.currentTime-_).toFixed(3)}))};F(),setTimeout(F,10),setTimeout(F,20),setTimeout(F,50),S?(re(S.id),ue(!1)):V?(re(V.id),ue(!1),Je(V)):(re(null),ue(!0),Je(null)),y.removeEventListener("timeupdate",B),Oe(!1),je(!1),mt(!1);return}};y.addEventListener("timeupdate",B),y.play().then(()=>{Oe(!0),je(!0),ve.debug("Playback started:",{from:Y(E),to:Y(_),currentSegment:S?`Segment ${S.id}`:"None",nextSegment:V?`Segment ${V.id}`:"None"})}).catch(K=>{console.error("Error playing video:",K)})},T=()=>{je(!1)};return p.addEventListener("play",R),p.addEventListener("pause",T),()=>{p.removeEventListener("play",R),p.removeEventListener("pause",T)}},[c,D,he]);const Er=p=>{if(!J.current)return;const R=J.current.getBoundingClientRect(),y=(p.clientX-R.left)/R.width*D,E=Math.max(0,Math.min(D,y));typeof window<"u"&&(window.lastSeekedPosition=E)},[Cr,h]=q.useState(!1),$=q.useRef(!1),ae=p=>{if(gt)return;p.stopPropagation(),p.preventDefault(),h(!0),$.current=!0,jn(L);const R=y=>{if(!J.current||!Xe.current)return;const E=J.current.getBoundingClientRect();let _;if(X>1){const V=Xe.current.scrollLeft,B=J.current.clientWidth;_=(y.clientX-E.left+V)/B}else _=(y.clientX-E.left)/E.width;_=Math.max(0,Math.min(1,_));const S=_*D;ye(S),nt(S),jn(S),typeof window<"u"&&(window.lastSeekedPosition=S),he(S)},T=()=>{h(!1),$.current=!1,document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",T)};document.addEventListener("mousemove",R),document.addEventListener("mouseup",T)},pe=p=>{if(gt)return;p.stopPropagation(),p.preventDefault(),h(!0),$.current=!0,jn(L);const R=y=>{if(!J.current||!Xe.current||!y.touches[0])return;const E=J.current.getBoundingClientRect();let _;if(X>1){const V=Xe.current.scrollLeft,B=J.current.clientWidth;_=(y.touches[0].clientX-E.left+V)/B}else _=(y.touches[0].clientX-E.left)/E.width;_=Math.max(0,Math.min(1,_));const S=_*D;ye(S),nt(S),jn(S),typeof window<"u"&&(window.lastSeekedPosition=S),he(S)},T=()=>{h(!1),$.current=!1,document.removeEventListener("touchmove",R),document.removeEventListener("touchend",T),document.removeEventListener("touchcancel",T)};document.addEventListener("touchmove",R,{passive:!1}),document.addEventListener("touchend",T),document.addEventListener("touchcancel",T)};return q.useEffect(()=>{},[Ft,Sa,Qe]),v.jsxs("div",{className:`timeline-container-card ${O?"segments-playback-mode":""}`,children:[v.jsxs("div",{className:"timeline-header",children:[v.jsx("div",{className:"timeline-title",children:v.jsx("span",{className:"timeline-title-text",children:"Timeline"})}),v.jsxs("div",{className:"duration-time",children:["Total Chapters:"," ",v.jsx("span",{children:Y(c.reduce((p,R)=>p+(R.endTime-R.startTime),0))})]})]}),v.jsx("div",{ref:Xe,className:`timeline-scroll-container ${O?"segments-playback-mode":""}`,style:{overflow:X>1?"auto":"hidden"},children:v.jsxs("div",{ref:J,className:"timeline-container",onClick:Zn,onMouseMove:Er,style:{width:`${X*100}%`,cursor:"pointer"},children:[v.jsxs("div",{className:"timeline-marker",style:{left:`${da}%`},children:[v.jsx("div",{className:"timeline-marker-head",onClick:p=>{if(p.stopPropagation(),c.find(R=>L>=R.startTime&&L<=R.endTime),_e||Ce){re(null),ue(!1);return}else jn(L),ve.debug("Opening tooltip at:",Y(L))},children:v.jsx("span",{className:"timeline-marker-head-icon",children:_e||Ce?"-":"+"})}),O?null:v.jsx("div",{className:`timeline-marker-drag ${Cr?"dragging":""}`,onMouseDown:ae,onTouchStart:pe,children:v.jsx("span",{className:"timeline-marker-drag-icon",children:"⋮"})})]}),c.length===0&&v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"trim-line-marker",style:{left:`${Kr}%`},children:v.jsx("div",{ref:$e,className:"trim-handle left"})}),v.jsx("div",{className:"trim-line-marker",style:{left:`${Jr}%`},children:v.jsx("div",{ref:dt,className:"trim-handle right"})})]}),Tr(),Zr(),_e!==null&&v.jsxs("div",{className:`segment-tooltip two-row-tooltip ${O?"segments-playback-mode":""}`,style:{position:"absolute",...xm(da)},onClick:p=>{O&&(p.stopPropagation(),p.preventDefault())},children:[_e&&v.jsx("div",{className:"tooltip-chapter-editor",children:v.jsx("textarea",{className:"tooltip-chapter-input",placeholder:"Add Chapter Text",value:hn,onChange:p=>Jt(p.target.value),onBlur:_t,onMouseLeave:_t,rows:2,maxLength:200,onClick:p=>p.stopPropagation(),onMouseDown:p=>p.stopPropagation(),onMouseUp:p=>p.stopPropagation()})}),v.jsxs("div",{className:"tooltip-row",children:[v.jsx("button",{className:`tooltip-time-btn ${O?"disabled":""}`,"data-tooltip":O?"Disabled during preview":"Seek -50ms (click or hold)",disabled:O,...O?{}:Wt(-.05),style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},children:"-50ms"}),v.jsx("div",{className:`tooltip-time-display ${O?"disabled":""}`,style:{pointerEvents:O?"none":"auto",cursor:O?"not-allowed":"default",opacity:O?.6:1,userSelect:"none",WebkitUserSelect:"none"},onClick:p=>{O&&(p.stopPropagation(),p.preventDefault())},children:Y(en)}),v.jsx("button",{className:`tooltip-time-btn ${O?"disabled":""}`,"data-tooltip":O?"Disabled during preview":"Seek +50ms (click or hold)",disabled:O,...O?{}:Wt(.05),style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},children:"+50ms"})]}),v.jsxs("div",{className:"tooltip-row tooltip-actions",children:[v.jsx("button",{className:`tooltip-action-btn delete ${O?"disabled":""}`,"data-tooltip":O?"Disabled during preview":"Delete segment",disabled:O,style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},onClick:p=>{p.stopPropagation();const R=new CustomEvent("delete-segment",{detail:{segmentId:_e}});document.dispatchEvent(R)},children:v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("path",{d:"M3 6h18"}),v.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),v.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),v.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}),v.jsx("button",{className:`tooltip-action-btn scissors ${O?"disabled":""}`,"data-tooltip":O?"Disabled during preview":"Split segment at current position",style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},disabled:O,onClick:p=>{p.stopPropagation();const R=new CustomEvent("split-segment",{detail:{segmentId:_e,time:A}});document.dispatchEvent(R)},children:v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("circle",{cx:"6",cy:"6",r:"3"}),v.jsx("circle",{cx:"6",cy:"18",r:"3"}),v.jsx("line",{x1:"20",y1:"4",x2:"8.12",y2:"15.88"}),v.jsx("line",{x1:"14.47",y1:"14.48",x2:"20",y2:"20"}),v.jsx("line",{x1:"8.12",y1:"8.12",x2:"12",y2:"12"})]})}),v.jsx("button",{className:`tooltip-action-btn play-from-start ${O?"disabled":""}`,"data-tooltip":O?"Disabled during preview":"Play segment from beginning",style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},disabled:O,onClick:p=>{p.stopPropagation();const R=c.find(T=>T.id===_e);if(R&&W.current){if(mt(!0),Math.abs(W.current.currentTime-R.endTime)<.05){ve.debug(`Already at end boundary (${Y(W.current.currentTime)}), nudging position back slightly`);const T=Math.max(R.startTime,R.endTime-.1);W.current.currentTime=T,he(T),ye(T),ve.debug(`Position adjusted to ${Y(T)}`)}else he(R.startTime),ye(R.startTime);Je(R),W.current.play().then(()=>{je(!0)}).catch(T=>{console.error("Error playing from beginning:",T)})}},children:v.jsx("img",{src:Cm,alt:"Play from beginning",style:{width:"24px",height:"24px"}})}),v.jsx("button",{className:`tooltip-action-btn ${De?"pause":"play"} ${O?"disabled":""}`,"data-tooltip":O?"Disabled during preview":De?"Pause playback":"Play from current position",style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},disabled:O,onClick:p=>{p.stopPropagation(),De?W.current&&(W.current.pause(),je(!1),mt(!1)):Lt()},children:De?v.jsx("img",{src:Em,alt:"Pause",style:{width:"24px",height:"24px"}}):v.jsx("img",{src:Tm,alt:"Play",style:{width:"24px",height:"24px"}})}),v.jsx("button",{className:`tooltip-action-btn set-in ${O?"disabled":""}`,style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},"data-tooltip":O?"Disabled during preview":"Set start point at current position",disabled:O,onClick:p=>{if(p.stopPropagation(),c.find(T=>T.id===_e)){const T=c.map(E=>E.id===_e?{...E,startTime:A{if(p.stopPropagation(),c.find(T=>T.id===_e)){const T=c.map(E=>E.id===_e?{...E,endTime:A>E.startTime+.5?A:E.startTime+.5}:E),y=new CustomEvent("update-segments",{detail:{segments:T,recordHistory:!0,action:"adjust_end_time"}});document.dispatchEvent(y)}},children:v.jsx("img",{src:YS,alt:"Set end point",style:{width:"24px",height:"24px"}})})]})]}),Ce&&_e===null&&v.jsxs("div",{className:`empty-space-tooltip two-row-tooltip ${O?"segments-playback-mode":""}`,style:{position:"absolute",...xm(da)},onClick:p=>{O&&(p.stopPropagation(),p.preventDefault())},children:[v.jsxs("div",{className:"tooltip-row",children:[v.jsx("button",{className:`tooltip-time-btn ${O?"disabled":""}`,"data-tooltip":O?"Disabled during preview":"Seek -50ms (click or hold)",disabled:O,...O?{}:Wt(-.05),style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},children:"-50ms"}),v.jsx("div",{className:`tooltip-time-display ${O?"disabled":""}`,style:{pointerEvents:O?"none":"auto",cursor:O?"not-allowed":"default",opacity:O?.6:1,userSelect:"none",WebkitUserSelect:"none"},onClick:p=>{O&&(p.stopPropagation(),p.preventDefault())},children:Y(A)}),v.jsx("button",{className:`tooltip-time-btn ${O?"disabled":""}`,style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},"data-tooltip":O?"Disabled during preview":"Seek +50ms (click or hold)",disabled:O,...O?{}:Wt(.05),children:"+50ms"})]}),v.jsxs("div",{className:"tooltip-row tooltip-actions",children:[v.jsxs("button",{className:`tooltip-action-btn new-segment ${Et<.5||O?"disabled":""}`,style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},"data-tooltip":O?"Disabled during preview":Et<.5?"Not enough space for new segment":"Create new segment",disabled:Et<.5||O,onClick:async p=>{if(p.stopPropagation(),Et<.5)return;const R=A,T=R+Et,y={id:Date.now(),chapterTitle:"segment",startTime:R,endTime:T},E=[...c,y],_=new CustomEvent("update-segments",{detail:{segments:E,recordHistory:!0,action:"create_segment"}});document.dispatchEvent(_),ue(!1),setTimeout(()=>{const S=E[E.length-1];S&&(re(S.id),ve.debug("Created and selected new segment:",S.id))},100)},children:[v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),v.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"16"}),v.jsx("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]}),v.jsx("span",{className:"tooltip-btn-text",children:"New"})]}),v.jsx("button",{className:`tooltip-action-btn play-from-start ${O?"disabled":""}`,"data-tooltip":O?"Disabled during preview":"Play from beginning of cutaway",style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},disabled:O,onClick:p=>{if(p.stopPropagation(),W.current){const R=A;mt(!0);const T=[...c].sort((K,Le)=>K.startTime-Le.startTime),y=[...T].reverse().find(K=>K.endTimeK.startTime>R),S=_?_.startTime:D,V={id:-999,chapterTitle:"Cutaway",startTime:E,endTime:S};he(E),ye(E),je(!1),setTimeout(()=>{Je(V)},0);const B=()=>{if(!W.current)return;const K=W.current.currentTime,Le=[...c].sort((bt,rn)=>bt.startTime-rn.startTime),F=Le.find(bt=>bt.startTime>K-.3),Ke=F&&K>=F.startTime-.25&&K<=F.startTime+.1&&!It;F&&K>=F.startTime-.25&&K<=F.startTime+.1&&ve.debug(`Approaching boundary at ${Y(F.startTime)}, continuePastBoundary=${It}, willStop=${Ke}`);const kt=Le.find(bt=>K>=bt.startTime&&K<=bt.endTime);if(kt&&(Ve==null?void 0:Ve.id)!==kt.id){ve.debug(`Entered segment ${kt.id} during cutaway playback`),Je(kt),re(kt.id),ue(!1),W.current.removeEventListener("timeupdate",B),mt(!1),sessionStorage.removeItem("continuingPastSegment");return}if(Ke&&F){ve.debug(`CUTAWAY MANUAL BOUNDARY CHECK: Current position ${Y(K)} approaching segment at ${Y(F.startTime)} (distance: ${Math.abs(K-F.startTime).toFixed(3)}s) - STOPPING`),W.current.pause(),setTimeout(()=>{if(W.current){W.current.currentTime=F.startTime,he(F.startTime),nt(F.startTime),ye(F.startTime),mt(!1),re(F.id),ue(!1),Je(F);const bt=()=>{W.current&&(W.current.currentTime=F.startTime,he(F.startTime),nt(F.startTime),ye(F.startTime),ve.debug(`Position corrected to exact segment boundary: ${Y(W.current.currentTime)} (target: ${Y(F.startTime)})`))};setTimeout(bt,10),setTimeout(bt,20),setTimeout(bt,50),setTimeout(bt,100),setTimeout(bt,200),W.current.addEventListener("seeked",bt),W.current.addEventListener("canplay",bt),W.current.addEventListener("waiting",bt),setTimeout(()=>{W.current&&(W.current.removeEventListener("seeked",bt),W.current.removeEventListener("canplay",bt),W.current.removeEventListener("waiting",bt))},300)}},10),je(!1),Je(null),W.current.removeEventListener("timeupdate",B);return}};W.current.addEventListener("timeupdate",B),setTimeout(()=>{W.current&&W.current.play().then(()=>{je(!0),ve.debug("CUTAWAY PLAYBACK STARTED:",Y(E),"to",Y(S),y?`(after segment ${y.id}, offset +25ms from ${Y(y.endTime)})`:"(from video start)",_?`(will stop at segment ${_.id})`:"(will play to end)")}).catch(K=>{console.error("Error playing cutaway:",K)})},50)}},children:v.jsx("img",{src:Cm,alt:"Play from beginning",style:{width:"24px",height:"24px"}})}),v.jsx("button",{className:`tooltip-action-btn ${De?"pause":"play"} ${O?"disabled":""}`,"data-tooltip":O?"Disabled during preview":De?"Pause playback":"Play from here until next segment",style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},disabled:O,onClick:p=>{p.stopPropagation(),De?W.current&&(W.current.pause(),je(!1),mt(!1)):Lt()},children:De?v.jsx("img",{src:Em,alt:"Pause",style:{width:"24px",height:"24px"}}):v.jsx("img",{src:Tm,alt:"Play",style:{width:"24px",height:"24px"}})}),v.jsx("button",{className:`tooltip-action-btn segment-end ${O?"disabled":""}`,style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},"data-tooltip":O?"Disabled during preview":"Adjust end of previous segment",disabled:O,onClick:p=>{p.stopPropagation();const T=[...c].sort((y,E)=>y.startTime-E.startTime).filter(y=>y.endTime<=A).sort((y,E)=>E.endTime-y.endTime)[0];if(T){const y=c.map(_=>_.id===T.id?{..._,endTime:A}:_),E=new CustomEvent("update-segments",{detail:{segments:y,recordHistory:!0,action:"adjust_previous_end_time"}});document.dispatchEvent(E),ve.debug("Adjusted end of previous segment to:",Y(A)),re(T.id),ue(!1)}else if(c.length>0){const y=[...c].sort((S,V)=>S.startTime-V.startTime);let E=!1,_=0;for(let S=0;SV&&AB.endTime-V.endTime)[0];if(S&&S.endTimeK.id===S.id?{...K,endTime:D}:K),B=new CustomEvent("update-segments",{detail:{segments:V,recordHistory:!0,action:"extend_last_segment"}});document.dispatchEvent(B),re(S.id),ue(!1)}}}else if(A>0){const y={id:Date.now(),chapterTitle:"segment",startTime:0,endTime:A},E=new CustomEvent("update-segments",{detail:{segments:[y],recordHistory:!0,action:"create_segment_from_start"}});document.dispatchEvent(E),ve.debug("Created new segment from start to:",Y(A)),re(y.id),ue(!1)}},children:v.jsx("img",{src:qS,alt:"Set end point",style:{width:"24px",height:"24px"}})}),v.jsx("button",{className:`tooltip-action-btn segment-start ${O?"disabled":""}`,"data-tooltip":O?"Disabled during preview":"Adjust start of next segment",style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:O?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},disabled:O,onClick:p=>{p.stopPropagation();const T=[...c].sort((y,E)=>y.startTime-E.startTime).filter(y=>y.startTime>=A).sort((y,E)=>y.startTime-E.startTime)[0];if(T){const y=c.map(_=>_.id===T.id?{..._,startTime:A}:_),E=new CustomEvent("update-segments",{detail:{segments:y,recordHistory:!0,action:"adjust_next_start_time"}});document.dispatchEvent(E),ve.debug("Adjusted start of next segment to:",Y(A)),re(T.id),ue(!1)}else if(c.length>0){const y=[...c].sort((S,V)=>S.startTime-V.startTime);let E=!1,_=0;for(let S=0;SV&&Ay[y.length-1].endTime){const S={id:Date.now(),chapterTitle:"segment",startTime:A,endTime:D},V=[...c,S],B=new CustomEvent("update-segments",{detail:{segments:V,recordHistory:!0,action:"create_segment_to_end"}});document.dispatchEvent(B),ve.debug("Created new segment from",Y(A),"to end"),re(S.id),ue(!1)}else{const S=y[0];if(S&&S.startTime>0){const V=c.map(K=>K.id===S.id?{...K,startTime:0}:K),B=new CustomEvent("update-segments",{detail:{segments:V,recordHistory:!0,action:"extend_first_segment"}});document.dispatchEvent(B),re(S.id),ue(!1)}}}else if(A{if(p.key==="Enter"){const R=p.currentTarget.value;try{const T=R.split(":");let y=0,E=0,_=0,S=0;if(T.length===3){y=parseInt(T[0]),E=parseInt(T[1]);const B=T[2].split(".");_=parseInt(B[0]),B.length>1&&(S=parseInt(B[1].padEnd(3,"0").substring(0,3)))}else if(T.length===2){E=parseInt(T[0]);const B=T[1].split(".");_=parseInt(B[0]),B.length>1&&(S=parseInt(B[1].padEnd(3,"0").substring(0,3)))}const V=y*3600+E*60+_+S/1e3;if(!isNaN(V)&&V>=0&&V<=D){he(V);const B=K=>{const Le=c.find(F=>{const Ke=K>=F.startTime&&K<=F.endTime,kt=Math.abs(K-F.startTime)<.001,bt=Math.abs(K-F.endTime)<.001;return Ke||kt||bt});if(J.current&&Xe.current){const F=J.current.getBoundingClientRect();let Ke;if(X>1)Ke=F.left-Xe.current.scrollLeft+K/D*F.width;else{const kt=K/D;Ke=F.left+F.width*kt}le({x:Ke,y:F.top-10}),ye(K),Le?(re(Le.id),ue(!1)):(re(null),ue(!0))}};setTimeout(()=>B(V),10)}}catch(T){console.error("Invalid time format:",T)}}}}),v.jsx("div",{className:"time-button-group",children:(()=>{const p=()=>{const R=c.find(T=>{const y=L>=T.startTime&&L<=T.endTime,E=Math.abs(L-T.startTime)<.001,_=Math.abs(L-T.endTime)<.001;return y||E||_});if(J.current&&Xe.current){const T=J.current.getBoundingClientRect();let y;if(X>1)y=T.left-Xe.current.scrollLeft+L/D*T.width;else{const E=L/D;y=T.left+T.width*E}if(le({x:y,y:T.top-10}),ye(L),R)re(R.id),ue(!1);else{const E=va(L);Ot(E),E>=.5?(re(null),ue(!0)):(re(null),ue(!1))}}};return v.jsxs(v.Fragment,{children:[v.jsx("button",{className:"time-button",onClick:()=>{he(L-.01),setTimeout(p,10)},"data-tooltip":"Move back 10ms",children:"-10ms"}),v.jsx("button",{className:"time-button",onClick:()=>{he(L-.001),setTimeout(p,10)},"data-tooltip":"Move back 1ms",children:"-1ms"}),v.jsx("button",{className:"time-button",onClick:()=>{he(L+.001),setTimeout(p,10)},"data-tooltip":"Move forward 1ms",children:"+1ms"}),v.jsx("button",{className:"time-button",onClick:()=>{he(L+.01),setTimeout(p,10)},"data-tooltip":"Move forward 10ms",children:"+10ms"})]})})()})]}),v.jsxs("div",{className:"controls-right",children:[v.jsxs("div",{className:"zoom-dropdown-container",children:[v.jsxs("button",{className:"zoom-button","data-tooltip":"Select zoom level",onClick:()=>ot(!Be),children:["Zoom ",X,"x",v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:v.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),Be&&v.jsx("div",{className:"zoom-dropdown",style:{position:"absolute",top:"100%",left:0,zIndex:1e3},children:[1,2,4,8,16,32,64,128,256,512,1024,2048,4096].map(p=>v.jsxs("div",{className:`zoom-option ${X===p?"selected":""}`,onClick:()=>{Q(p),ot(!1)},children:[X===p&&v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:v.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Zoom ",p,"x"]},p))})]}),v.jsx("div",{className:"auto-saved-time",style:{color:at?"#1976d2":"gray",fontSize:"12px",marginLeft:"10px",display:"flex",alignItems:"center",gap:"5px"},children:at?v.jsxs(v.Fragment,{children:[v.jsx("span",{className:"auto-save-spinner",style:{display:"inline-block",width:"12px",height:"12px",border:"2px solid #f3f3f3",borderTop:"2px solid #1976d2",borderRadius:"50%",animation:"spin 1s linear infinite"}}),"Auto saving..."]}):Te?`Auto saved: ${Te}`:"Not saved yet"}),v.jsx("div",{className:"save-buttons-row",children:v.jsx("button",{onClick:()=>In(!0),className:"save-chapters-button","data-tooltip":"Save chapters",disabled:c.filter(p=>p.chapterTitle&&p.chapterTitle.trim()).length===0,children:"Save Chapters"})}),v.jsx(Wu,{isOpen:fa,onClose:()=>In(!1),title:"Save Chapters",actions:v.jsxs(v.Fragment,{children:[v.jsx("button",{className:"modal-button modal-button-secondary",onClick:()=>In(!1),children:"Cancel"}),v.jsx("button",{className:"modal-button modal-button-primary",onClick:Sr,children:"Save Chapters"})]}),children:v.jsxs("p",{className:"modal-message",children:["Are you sure you want to save the chapters? This will save"," ",c.filter(p=>p.chapterTitle&&p.chapterTitle.trim()).length," chapters to the database."]})}),v.jsxs(Wu,{isOpen:Z,onClose:()=>{},title:"Processing Video",children:[v.jsx("div",{className:"modal-spinner",children:v.jsx("div",{className:"spinner"})}),v.jsx("p",{className:"modal-message text-center",children:"Please wait while your video is being processed..."})]}),v.jsx(Wu,{isOpen:Qe,onClose:()=>{Ct(!1)},title:"Video Edited Successfully",children:v.jsx("div",{className:"modal-success-content",children:v.jsxs("p",{className:"modal-message text-center redirect-message",children:[v.jsx("span",{style:{fontWeight:"bold"},children:"Your chapters have been saved successfully!"}),v.jsx("br",{}),v.jsx("a",{href:Ft,className:"media-page-link",style:GS,children:"Click here to navigate to the media page"})," ","or close this window to continue editing the chapters."]})})}),v.jsxs(Wu,{isOpen:Bt,onClose:()=>zt(!1),title:"Video Processing Error",children:[v.jsxs("div",{className:"modal-error-content",children:[v.jsx("div",{className:"modal-error-icon",children:v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"#F44336",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("circle",{cx:"12",cy:"12",r:"10"}),v.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),v.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}),v.jsx("p",{className:"modal-message text-center error-message",children:qt})]}),v.jsx("div",{className:"modal-choices",children:v.jsxs("button",{onClick:()=>zt(!1),className:"modal-choice-button centered-choice",children:[v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),v.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),"Close"]})})]})]})]}),gt&&v.jsx("div",{className:"mobile-timeline-overlay",children:v.jsxs("div",{className:"mobile-timeline-message",children:[v.jsx("p",{children:"Please play the video first to enable timeline controls"}),v.jsx("div",{className:"mobile-play-icon"})]})})]})},QS=({onSplit:L,onReset:D,onUndo:ge,onRedo:Ne,onPlaySegments:Me,onPlay:X,canUndo:c,canRedo:yt,isPlaying:me=!1,isPlayingSegments:ne=!1})=>{const[tt,oe]=q.useState(!1);q.useEffect(()=>{const Q=()=>{oe(window.innerWidth<=640)};return Q(),window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[]);const ze=()=>{X()};return v.jsx("div",{className:"editing-tools-container",children:v.jsxs("div",{className:"flex-container single-row",children:[v.jsxs("div",{className:"button-group play-buttons-group",children:[v.jsx("button",{className:"button segments-button",onClick:Me,"data-tooltip":ne?"Stop chapters playback":"Play chapters in one continuous flow",style:{fontSize:"0.875rem"},children:ne?v.jsxs(v.Fragment,{children:[v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("circle",{cx:"12",cy:"12",r:"10"}),v.jsx("line",{x1:"10",y1:"15",x2:"10",y2:"9"}),v.jsx("line",{x1:"14",y1:"15",x2:"14",y2:"9"})]}),v.jsx("span",{className:"full-text",children:"Stop Preview"}),v.jsx("span",{className:"short-text",children:"Stop Preview"})]}):v.jsxs(v.Fragment,{children:[v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("circle",{cx:"12",cy:"12",r:"10"}),v.jsx("polygon",{points:"10 8 16 12 10 16 10 8"})]}),v.jsx("span",{className:"full-text",children:"Play Preview"}),v.jsx("span",{className:"short-text",children:"Play Preview"})]})}),(!ne||!tt)&&v.jsx("button",{className:`button play-button ${ne?"greyed-out":""}`,onClick:ze,"data-tooltip":me?"Pause video":"Play full video",style:{fontSize:"0.875rem"},disabled:ne,children:me&&!ne?v.jsxs(v.Fragment,{children:[v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("circle",{cx:"12",cy:"12",r:"10"}),v.jsx("line",{x1:"10",y1:"15",x2:"10",y2:"9"}),v.jsx("line",{x1:"14",y1:"15",x2:"14",y2:"9"})]}),v.jsx("span",{className:"full-text",children:"Pause"}),v.jsx("span",{className:"short-text",children:"Pause"})]}):v.jsxs(v.Fragment,{children:[v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("circle",{cx:"12",cy:"12",r:"10"}),v.jsx("polygon",{points:"10 8 16 12 10 16 10 8"})]}),v.jsx("span",{className:"full-text",children:"Play"}),v.jsx("span",{className:"short-text",children:"Play"})]})})]}),v.jsxs("div",{className:"button-group secondary",children:[v.jsxs("button",{className:"button","aria-label":"Undo","data-tooltip":ne?"Disabled during preview":"Undo last action",disabled:!c||ne,onClick:ge,children:[v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("path",{d:"M9 14 4 9l5-5"}),v.jsx("path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5v0a5.5 5.5 0 0 1-5.5 5.5H11"})]}),v.jsx("span",{className:"button-text",children:"Undo"})]}),v.jsxs("button",{className:"button","aria-label":"Redo","data-tooltip":ne?"Disabled during preview":"Redo last undone action",disabled:!yt||ne,onClick:Ne,children:[v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("path",{d:"m15 14 5-5-5-5"}),v.jsx("path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5v0A5.5 5.5 0 0 0 9.5 20H13"})]}),v.jsx("span",{className:"button-text",children:"Redo"})]}),v.jsx("div",{className:"divider"}),v.jsxs("button",{className:"button",onClick:D,"data-tooltip":ne?"Disabled during preview":"Reset to full video",disabled:ne,children:[v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:v.jsx("path",{fillRule:"evenodd",d:"M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z",clipRule:"evenodd"})}),v.jsx("span",{className:"reset-text",children:"Reset"})]})]})]})})},KS=({segments:L,selectedSegmentId:D})=>{const ge=[...L].sort((X,c)=>X.startTime-c.startTime),Ne=X=>{const c=new CustomEvent("delete-segment",{detail:{segmentId:X}});document.dispatchEvent(c)},Me=X=>`segment-default-color segment-color-${X%8+1}`;return ge.find(X=>X.id===D),v.jsxs("div",{className:"clip-segments-container",children:[v.jsx("h3",{className:"clip-segments-title",children:"Chapters"}),ge.map((X,c)=>v.jsxs("div",{className:`segment-item ${Me(c)} ${D===X.id?"selected":""}`,children:[v.jsx("div",{className:"segment-content",children:v.jsxs("div",{className:"segment-info",children:[v.jsx("div",{className:"segment-title",children:X.chapterTitle?v.jsx("span",{className:"chapter-title",children:X.chapterTitle}):v.jsxs("span",{className:"default-title",children:["Chapter ",c+1]})}),v.jsxs("div",{className:"segment-time",children:[wi(X.startTime)," - ",wi(X.endTime)]}),v.jsxs("div",{className:"segment-duration",children:["Duration: ",VS(X.endTime-X.startTime)]})]})}),v.jsx("div",{className:"segment-actions",children:v.jsx("button",{className:"delete-button","aria-label":"Delete Segment","data-tooltip":"Delete this segment",onClick:()=>Ne(X.id),children:v.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:v.jsx("path",{fillRule:"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z",clipRule:"evenodd"})})})})]},X.id)),ge.length===0&&v.jsx("div",{className:"empty-message",children:"No chapters created yet. Use the split button to create chapter segments."})]})},JS=({videoRef:L,onPlay:D})=>{const[ge,Ne]=q.useState(!1);q.useEffect(()=>{const c=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(navigator.userAgent);Ne(c)},[]),q.useEffect(()=>{const X=L.current;if(!X)return;const c=()=>{Ne(!1)};return X.addEventListener("play",c),()=>{X.removeEventListener("play",c)}},[L]);const Me=()=>{D()};return ge?v.jsx("div",{className:"mobile-play-prompt-overlay",children:v.jsx("div",{className:"mobile-play-prompt",children:v.jsx("button",{className:"mobile-play-button",onClick:Me,children:"Click to start editing..."})})}):null},ZS=()=>{const L=z=>{const te=z.split(":");if(te.length!==3)return 0;const Ee=parseInt(te[0],10)||0,Te=parseInt(te[1],10)||0,Pe=parseFloat(te[2])||0;return Ee*3600+Te*60+Pe},D=q.useRef(null),[ge,Ne]=q.useState(0),[Me,X]=q.useState(0),[c,yt]=q.useState(!1),[me,ne]=q.useState(!1),[tt,oe]=q.useState(0),[ze,Q]=q.useState(0),[he,W]=q.useState([]),[cn,gt]=q.useState(1),[De,Oe]=q.useState([]),[Lt,O]=q.useState(null),[J,$e]=q.useState([]),[dt,vt]=q.useState(-1),[Yt,_e]=q.useState(!1),[re,Ce]=q.useState(!1),[ue,pt]=q.useState(0);q.useEffect(()=>{var z;if(J.length>0){const te=((z=J[dt])==null?void 0:z.action)||"";te!=="save"&&te!=="save_copy"&&te!=="save_segments"&&_e(!0)}},[J,dt]),q.useEffect(()=>{const z=D.current;if(!z)return;const te=()=>{X(z.duration),Q(z.duration),(async()=>{var ht;let we=[];const lt=typeof window<"u"&&((ht=window.MEDIA_DATA)==null?void 0:ht.chapters)||[];if(lt.length>0)for(let Jt=0;Jt{Ne(z.currentTime)},Te=()=>{yt(!0),Kt(!0)},Pe=()=>{yt(!1)},at=()=>{yt(!1),z.currentTime=tt};return z.addEventListener("loadedmetadata",te),z.addEventListener("timeupdate",Ee),z.addEventListener("play",Te),z.addEventListener("pause",Pe),z.addEventListener("ended",at),()=>{z.removeEventListener("loadedmetadata",te),z.removeEventListener("timeupdate",Ee),z.removeEventListener("play",Te),z.removeEventListener("pause",Pe),z.removeEventListener("ended",at)}},[]);const le=z=>{const te=D.current;if(!te)return;const Ee=!te.paused;te.currentTime=z,Ne(z),typeof window<"u"&&(window.lastSeekedPosition=z),Ee&&te.play().then(()=>{yt(!0)}).catch(Te=>{console.error("Error resuming playback:",Te),yt(!1)})},A=z=>{const te={trimStart:tt,trimEnd:ze,splitPoints:[...he],clipSegments:JSON.parse(JSON.stringify(De)),action:z||"manual_save"},Ee=J[dt],Te=()=>{if(!Ee||Ee.clipSegments.length!==te.clipSegments.length)return!0;for(let Ze=0;Ze.001||Math.abs(we.endTime-lt.endTime)>.001)return!0}return!1},Pe=!Ee||Ee.trimStart!==te.trimStart||Ee.trimEnd!==te.trimEnd||Ee.splitPoints.length!==te.splitPoints.length||Te(),at=te.action!==void 0;if(Pe||at){const Ze=dt;$e(we=>Zewe+1)}};q.useEffect(()=>{const z=te=>{if(te.detail){const{time:Ee,isStart:Te,recordHistory:Pe,action:at}=te.detail;Te?oe(Ee):Q(Ee),Pe&&setTimeout(()=>{A(at||(Te?"adjust_trim_start":"adjust_trim_end"))},10)}};return document.addEventListener("update-trim",z),()=>{document.removeEventListener("update-trim",z)}},[]),q.useEffect(()=>{const z=Te=>{if(Te.detail&&Te.detail.segments){const Pe=Te.detail.recordHistory!==!1,at=Te.detail.action||"update_segments";Oe(Te.detail.segments),Pe&&setTimeout(()=>{const Ze=JSON.parse(JSON.stringify(Te.detail.segments)),we={trimStart:tt,trimEnd:ze,splitPoints:[...he],clipSegments:Ze,action:at},lt=dt;$e(_t=>lt<_t.length-1?[..._t.slice(0,lt+1),we]:[..._t,we]),vt(_t=>_t+1)},20)}},te=async Te=>{const Pe=Te;if(Pe.detail&&typeof Pe.detail.time=="number"&&typeof Pe.detail.segmentId=="number"){const at=Pe.detail.time,Ze=Pe.detail.segmentId;le(at);const we=De.find(Wt=>Wt.id===Ze);if(!we||at<=we.startTime||at>=we.endTime)return;const lt=[...De],_t=lt.findIndex(Wt=>Wt.id===Ze);if(_t===-1)return;lt.splice(_t,1);const ht={id:Date.now(),chapterTitle:`${we.chapterTitle}-A`,startTime:we.startTime,endTime:at},Jt={id:Date.now()+1,chapterTitle:`${we.chapterTitle}-B`,startTime:at,endTime:we.endTime};lt.push(ht,Jt),lt.sort((Wt,fa)=>Wt.startTime-fa.startTime),Oe(lt),A("split_segment")}},Ee=async Te=>{const Pe=Te;if(Pe.detail&&typeof Pe.detail.segmentId=="number"){const at=Pe.detail.segmentId,Ze=De.filter(we=>we.id!==at);if(Ze.length!==De.length){if(Ze.length===0&&D.current){const we={id:Date.now(),chapterTitle:"segment",startTime:0,endTime:D.current.duration};oe(0),Q(D.current.duration),W([]),Oe([we])}else Oe(Ze);A("delete_segment")}}};return document.addEventListener("update-segments",z),document.addEventListener("split-segment",te),document.addEventListener("delete-segment",Ee),()=>{document.removeEventListener("update-segments",z),document.removeEventListener("split-segment",te),document.removeEventListener("delete-segment",Ee)}},[De,Me]);const ye=z=>{oe(z),A("adjust_trim_start")},Be=z=>{Q(z),A("adjust_trim_end")},ot=async()=>{if(D.current&&!he.includes(ge)){const z=[...he,ge].sort((Te,Pe)=>Te-Pe);W(z);const te=[];let Ee=0;for(let Te=0;Te<=z.length;Te++){const Pe=Te{if(oe(0),Q(Me),W([]),!D.current)return;const z={id:Date.now(),chapterTitle:"segment",startTime:0,endTime:Me};Oe([z]),A("reset_all")},Ot=()=>{if(dt>0){const z=J[dt-1];ve.debug(`** UNDO ** to position ${dt-1}, action: ${z.action}, segments: ${z.clipSegments.length}`),ve.debug("Segment details after undo:",z.clipSegments.map(te=>`ID: ${te.id}, Time: ${Y(te.startTime)} - ${Y(te.endTime)}`)),oe(z.trimStart),Q(z.trimEnd),W([...z.splitPoints]),Oe(JSON.parse(JSON.stringify(z.clipSegments))),vt(dt-1)}},Vt=()=>{if(dt`ID: ${te.id}, Time: ${Y(te.startTime)} - ${Y(te.endTime)}`)),oe(z.trimStart),Q(z.trimEnd),W([...z.splitPoints]),Oe(JSON.parse(JSON.stringify(z.clipSegments))),vt(dt+1)}},je=z=>{gt(z)},Ve=()=>{const z=D.current;z&&(z.muted=!z.muted,ne(!me))},Je=(z,te)=>{Oe(Ee=>Ee.map(Te=>Te.id===z?{...Te,...te}:Te)),_e(!0)},en=async z=>{var te;try{const Ee=(te=window.MEDIA_DATA)==null?void 0:te.mediaId;if(!Ee){console.error("No media ID found");return}const Pe={chapters:z.map(_t=>({startTime:_t.from,endTime:_t.to,chapterTitle:_t.chapterTitle}))},at=nt(),Ze={"Content-Type":"application/json"};at&&(Ze["X-CSRFToken"]=at);const we=await fetch(`/api/v1/media/${Ee}/chapters`,{method:"POST",headers:Ze,body:JSON.stringify(Pe)});if(!we.ok)throw new Error(`Failed to save chapters: ${we.status}`);const lt=await we.json();_e(!1)}catch(Ee){console.error("Error saving chapters:",Ee)}},nt=()=>{var Te;const Ee=`; ${document.cookie}`.split("; csrftoken=");return Ee.length===2&&((Te=Ee.pop())==null?void 0:Te.split(";").shift())||""},It=z=>{O(z)},mt=z=>{(!Xe||hn)&&le(z)},Xe=typeof window<"u"&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(navigator.userAgent),[hn,Kt]=q.useState(!1);return q.useEffect(()=>{if(!re||!D.current)return;const z=D.current,te=[...De].sort((Te,Pe)=>Te.startTime-Pe.startTime),Ee=()=>{const Te=te[ue];if(!Te)return;const Pe=z.currentTime;if(Pe=Te.endTime-.01)if(ue{console.error("Error continuing segment playback:",Ze)})}else z.pause(),Ce(!1),pt(0),z.removeEventListener("timeupdate",Ee)};return z.addEventListener("timeupdate",Ee),z.paused&&te.length>0&&(z.currentTime=te[0].startTime,z.play().catch(console.error)),()=>{z.removeEventListener("timeupdate",Ee)}},[re,ue,De]),q.useEffect(()=>{const z=te=>{const{segmentIndex:Ee}=te.detail;re&&Ee!==ue&&pt(Ee)};return document.addEventListener("update-segment-index",z),()=>{document.removeEventListener("update-segment-index",z)}},[re,ue]),{videoRef:D,currentTime:ge,duration:Me,isPlaying:c,setIsPlaying:yt,isMuted:me,isPlayingSegments:re,trimStart:tt,trimEnd:ze,splitPoints:he,zoomLevel:cn,clipSegments:De,selectedSegmentId:Lt,hasUnsavedChanges:Yt,historyPosition:dt,history:J,handleTrimStartChange:ye,handleTrimEndChange:Be,handleZoomChange:je,handleMobileSafeSeek:mt,handleSplit:ot,handleReset:Et,handleUndo:Ot,handleRedo:Vt,handlePlaySegments:()=>{const z=D.current;if(!(!z||De.length===0))if(re)z.pause(),Ce(!1),pt(0);else{Ce(!0),pt(0);const te=[...De].sort((Ee,Te)=>Ee.startTime-Te.startTime);z.currentTime=te[0].startTime,z.play().catch(Ee=>{console.error("Error starting segments playback:",Ee),Ce(!1)})}},toggleMute:Ve,handleSegmentUpdate:Je,handleChapterSave:en,handleSelectedSegmentChange:It,isMobile:Xe,videoInitialized:hn,setVideoInitialized:Kt}},eT=()=>{const{videoRef:L,currentTime:D,duration:ge,isPlaying:Ne,setIsPlaying:Me,isMuted:X,trimStart:c,trimEnd:yt,splitPoints:me,zoomLevel:ne,clipSegments:tt,selectedSegmentId:oe,hasUnsavedChanges:ze,historyPosition:Q,history:he,handleTrimStartChange:W,handleTrimEndChange:cn,handleZoomChange:gt,handleMobileSafeSeek:De,handleSplit:Oe,handleReset:Lt,handleUndo:O,handleRedo:J,toggleMute:$e,handleSegmentUpdate:dt,handleChapterSave:vt,handleSelectedSegmentChange:Yt,isMobile:_e,videoInitialized:re,setVideoInitialized:Ce,isPlayingSegments:ue,handlePlaySegments:pt}=ZS(),le=()=>{if(!L.current)return;const A=L.current;if(Ne){A.pause(),Me(!1);return}const ye=Number(A.currentTime.toFixed(6));let Be=ge,ot=null,Et=null;const Ot=[...tt].sort((je,Ve)=>je.startTime-Ve.startTime);ot=Ot.find(je=>{const Ve=Number(je.startTime.toFixed(6)),Je=Number(je.endTime.toFixed(6));return ye>Ve&&yeNumber(je.startTime.toFixed(6))>ye)),ot?Be=Number(ot.endTime.toFixed(6)):Et&&(Be=Number(Et.startTime.toFixed(6)));const Vt=()=>{if(!A)return;const je=Number(A.currentTime.toFixed(6));if(Number((Be-je).toFixed(6))<=0||je>=Be){A.pause();const Je=()=>{if(!A)return;A.currentTime=Be,De(Be);const en=Number(A.currentTime.toFixed(6)),nt=Number(Math.abs(en-Be).toFixed(6));ve.debug("Position verification:",{target:Y(Be),actual:Y(en),difference:nt}),nt>0&&(A.currentTime=Be,De(Be))};Je(),setTimeout(Je,5),setTimeout(Je,10),setTimeout(Je,20),setTimeout(Je,50),A.removeEventListener("timeupdate",Vt),Me(!1),ve.debug("Stopped at position:",{target:Y(Be),actual:Y(A.currentTime),type:ot?"segment end":Et?"next segment start":"end of video",segment:ot?{id:ot.id,start:Y(ot.startTime),end:Y(ot.endTime)}:null,nextSegment:Et?{id:Et.id,start:Y(Et.startTime),end:Y(Et.endTime)}:null});return}};A.addEventListener("timeupdate",Vt),A.play().then(()=>{Me(!0),Ce(!0),ve.debug("Playback started:",{from:Y(ye),to:Y(Be),currentSegment:ot?{id:ot.id,start:Y(ot.startTime),end:Y(ot.endTime)}:"None",nextSegment:Et?{id:Et.id,start:Y(Et.startTime),end:Y(Et.endTime)}:"None"})}).catch(je=>{console.error("Error playing video:",je)})};return v.jsxs("div",{className:"bg-background min-h-screen",children:[v.jsx(JS,{videoRef:L,onPlay:le}),v.jsxs("div",{className:"container mx-auto px-4 py-6 max-w-6xl",children:[v.jsx(BS,{videoRef:L,currentTime:D,duration:ge,isPlaying:Ne,isMuted:X,onPlayPause:le,onSeek:De,onToggleMute:$e}),v.jsx(QS,{onSplit:Oe,onReset:Lt,onUndo:O,onRedo:J,onPlaySegments:pt,onPlay:le,isPlaying:Ne,isPlayingSegments:ue,canUndo:Q>0,canRedo:Q{const L=document.getElementById("chapters-editor-root");L&&gm(L).render(v.jsx(eT,{}))};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Rm):Rm()})(); //# sourceMappingURL=chapters-editor.js.map diff --git a/static/chapters_editor/chapters-editor.js.map b/static/chapters_editor/chapters-editor.js.map index e0727c10..353d7057 100644 --- a/static/chapters_editor/chapters-editor.js.map +++ b/static/chapters_editor/chapters-editor.js.map @@ -1 +1 @@ -{"version":3,"file":"chapters-editor.js","sources":["../../frontend-tools/chapters-editor/node_modules/react/cjs/react.development.js","../../frontend-tools/chapters-editor/node_modules/react/index.js","../../frontend-tools/chapters-editor/node_modules/react/cjs/react-jsx-runtime.development.js","../../frontend-tools/chapters-editor/node_modules/react/jsx-runtime.js","../../frontend-tools/chapters-editor/node_modules/scheduler/cjs/scheduler.development.js","../../frontend-tools/chapters-editor/node_modules/scheduler/index.js","../../frontend-tools/chapters-editor/node_modules/react-dom/cjs/react-dom.development.js","../../frontend-tools/chapters-editor/node_modules/react-dom/index.js","../../frontend-tools/chapters-editor/node_modules/react-dom/client.js","../../frontend-tools/chapters-editor/client/src/lib/timeUtils.ts","../../frontend-tools/chapters-editor/client/src/lib/logger.ts","../../frontend-tools/chapters-editor/client/src/components/VideoPlayer.tsx","../../frontend-tools/chapters-editor/client/src/lib/videoUtils.ts","../../frontend-tools/chapters-editor/client/src/components/Modal.tsx","../../frontend-tools/chapters-editor/client/src/services/videoApi.ts","../../frontend-tools/chapters-editor/client/src/assets/play-icon.svg","../../frontend-tools/chapters-editor/client/src/assets/pause-icon.svg","../../frontend-tools/chapters-editor/client/src/assets/play-from-beginning-icon.svg","../../frontend-tools/chapters-editor/client/src/assets/segment-end-new.svg","../../frontend-tools/chapters-editor/client/src/assets/segment-start-new.svg","../../frontend-tools/chapters-editor/client/src/assets/segment-start-new-cutaway.svg","../../frontend-tools/chapters-editor/client/src/assets/segment-end-new-cutaway.svg","../../frontend-tools/chapters-editor/client/src/components/TimelineControls.tsx","../../frontend-tools/chapters-editor/client/src/components/EditingTools.tsx","../../frontend-tools/chapters-editor/client/src/components/ClipSegments.tsx","../../frontend-tools/chapters-editor/client/src/components/IOSPlayPrompt.tsx","../../frontend-tools/chapters-editor/client/src/hooks/useVideoChapters.tsx","../../frontend-tools/chapters-editor/client/src/App.tsx","../../frontend-tools/chapters-editor/client/src/main.tsx"],"sourcesContent":["/**\n * @license React\n * react.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n\n 'use strict';\n\n/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());\n}\n var ReactVersion = '18.3.1';\n\n// ATTENTION\n// When adding new symbols to this file,\n// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'\n// The Symbol used to tag the ReactElement-like types.\nvar REACT_ELEMENT_TYPE = Symbol.for('react.element');\nvar REACT_PORTAL_TYPE = Symbol.for('react.portal');\nvar REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');\nvar REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');\nvar REACT_PROFILER_TYPE = Symbol.for('react.profiler');\nvar REACT_PROVIDER_TYPE = Symbol.for('react.provider');\nvar REACT_CONTEXT_TYPE = Symbol.for('react.context');\nvar REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');\nvar REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');\nvar REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');\nvar REACT_MEMO_TYPE = Symbol.for('react.memo');\nvar REACT_LAZY_TYPE = Symbol.for('react.lazy');\nvar REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');\nvar MAYBE_ITERATOR_SYMBOL = Symbol.iterator;\nvar FAUX_ITERATOR_SYMBOL = '@@iterator';\nfunction getIteratorFn(maybeIterable) {\n if (maybeIterable === null || typeof maybeIterable !== 'object') {\n return null;\n }\n\n var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];\n\n if (typeof maybeIterator === 'function') {\n return maybeIterator;\n }\n\n return null;\n}\n\n/**\n * Keeps track of the current dispatcher.\n */\nvar ReactCurrentDispatcher = {\n /**\n * @internal\n * @type {ReactComponent}\n */\n current: null\n};\n\n/**\n * Keeps track of the current batch's configuration such as how long an update\n * should suspend for if it needs to.\n */\nvar ReactCurrentBatchConfig = {\n transition: null\n};\n\nvar ReactCurrentActQueue = {\n current: null,\n // Used to reproduce behavior of `batchedUpdates` in legacy mode.\n isBatchingLegacy: false,\n didScheduleLegacyUpdate: false\n};\n\n/**\n * Keeps track of the current owner.\n *\n * The current owner is the component who should own any components that are\n * currently being constructed.\n */\nvar ReactCurrentOwner = {\n /**\n * @internal\n * @type {ReactComponent}\n */\n current: null\n};\n\nvar ReactDebugCurrentFrame = {};\nvar currentExtraStackFrame = null;\nfunction setExtraStackFrame(stack) {\n {\n currentExtraStackFrame = stack;\n }\n}\n\n{\n ReactDebugCurrentFrame.setExtraStackFrame = function (stack) {\n {\n currentExtraStackFrame = stack;\n }\n }; // Stack implementation injected by the current renderer.\n\n\n ReactDebugCurrentFrame.getCurrentStack = null;\n\n ReactDebugCurrentFrame.getStackAddendum = function () {\n var stack = ''; // Add an extra top frame while an element is being validated\n\n if (currentExtraStackFrame) {\n stack += currentExtraStackFrame;\n } // Delegate to the injected renderer-specific implementation\n\n\n var impl = ReactDebugCurrentFrame.getCurrentStack;\n\n if (impl) {\n stack += impl() || '';\n }\n\n return stack;\n };\n}\n\n// -----------------------------------------------------------------------------\n\nvar enableScopeAPI = false; // Experimental Create Event Handle API.\nvar enableCacheElement = false;\nvar enableTransitionTracing = false; // No known bugs, but needs performance testing\n\nvar enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber\n// stuff. Intended to enable React core members to more easily debug scheduling\n// issues in DEV builds.\n\nvar enableDebugTracing = false; // Track which Fiber(s) schedule render work.\n\nvar ReactSharedInternals = {\n ReactCurrentDispatcher: ReactCurrentDispatcher,\n ReactCurrentBatchConfig: ReactCurrentBatchConfig,\n ReactCurrentOwner: ReactCurrentOwner\n};\n\n{\n ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame;\n ReactSharedInternals.ReactCurrentActQueue = ReactCurrentActQueue;\n}\n\n// by calls to these methods by a Babel plugin.\n//\n// In PROD (or in packages without access to React internals),\n// they are left as they are instead.\n\nfunction warn(format) {\n {\n {\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n printWarning('warn', format, args);\n }\n }\n}\nfunction error(format) {\n {\n {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n\n printWarning('error', format, args);\n }\n }\n}\n\nfunction printWarning(level, format, args) {\n // When changing this logic, you might want to also\n // update consoleWithStackDev.www.js as well.\n {\n var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;\n var stack = ReactDebugCurrentFrame.getStackAddendum();\n\n if (stack !== '') {\n format += '%s';\n args = args.concat([stack]);\n } // eslint-disable-next-line react-internal/safe-string-coercion\n\n\n var argsWithFormat = args.map(function (item) {\n return String(item);\n }); // Careful: RN currently depends on this prefix\n\n argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it\n // breaks IE9: https://github.com/facebook/react/issues/13610\n // eslint-disable-next-line react-internal/no-production-logging\n\n Function.prototype.apply.call(console[level], console, argsWithFormat);\n }\n}\n\nvar didWarnStateUpdateForUnmountedComponent = {};\n\nfunction warnNoop(publicInstance, callerName) {\n {\n var _constructor = publicInstance.constructor;\n var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';\n var warningKey = componentName + \".\" + callerName;\n\n if (didWarnStateUpdateForUnmountedComponent[warningKey]) {\n return;\n }\n\n error(\"Can't call %s on a component that is not yet mounted. \" + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName);\n\n didWarnStateUpdateForUnmountedComponent[warningKey] = true;\n }\n}\n/**\n * This is the abstract API for an update queue.\n */\n\n\nvar ReactNoopUpdateQueue = {\n /**\n * Checks whether or not this composite component is mounted.\n * @param {ReactClass} publicInstance The instance we want to test.\n * @return {boolean} True if mounted, false otherwise.\n * @protected\n * @final\n */\n isMounted: function (publicInstance) {\n return false;\n },\n\n /**\n * Forces an update. This should only be invoked when it is known with\n * certainty that we are **not** in a DOM transaction.\n *\n * You may want to call this when you know that some deeper aspect of the\n * component's state has changed but `setState` was not called.\n *\n * This will not invoke `shouldComponentUpdate`, but it will invoke\n * `componentWillUpdate` and `componentDidUpdate`.\n *\n * @param {ReactClass} publicInstance The instance that should rerender.\n * @param {?function} callback Called after component is updated.\n * @param {?string} callerName name of the calling function in the public API.\n * @internal\n */\n enqueueForceUpdate: function (publicInstance, callback, callerName) {\n warnNoop(publicInstance, 'forceUpdate');\n },\n\n /**\n * Replaces all of the state. Always use this or `setState` to mutate state.\n * You should treat `this.state` as immutable.\n *\n * There is no guarantee that `this.state` will be immediately updated, so\n * accessing `this.state` after calling this method may return the old value.\n *\n * @param {ReactClass} publicInstance The instance that should rerender.\n * @param {object} completeState Next state.\n * @param {?function} callback Called after component is updated.\n * @param {?string} callerName name of the calling function in the public API.\n * @internal\n */\n enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {\n warnNoop(publicInstance, 'replaceState');\n },\n\n /**\n * Sets a subset of the state. This only exists because _pendingState is\n * internal. This provides a merging strategy that is not available to deep\n * properties which is confusing. TODO: Expose pendingState or don't use it\n * during the merge.\n *\n * @param {ReactClass} publicInstance The instance that should rerender.\n * @param {object} partialState Next partial state to be merged with state.\n * @param {?function} callback Called after component is updated.\n * @param {?string} Name of the calling function in the public API.\n * @internal\n */\n enqueueSetState: function (publicInstance, partialState, callback, callerName) {\n warnNoop(publicInstance, 'setState');\n }\n};\n\nvar assign = Object.assign;\n\nvar emptyObject = {};\n\n{\n Object.freeze(emptyObject);\n}\n/**\n * Base class helpers for the updating state of a component.\n */\n\n\nfunction Component(props, context, updater) {\n this.props = props;\n this.context = context; // If a component has string refs, we will assign a different object later.\n\n this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the\n // renderer.\n\n this.updater = updater || ReactNoopUpdateQueue;\n}\n\nComponent.prototype.isReactComponent = {};\n/**\n * Sets a subset of the state. Always use this to mutate\n * state. You should treat `this.state` as immutable.\n *\n * There is no guarantee that `this.state` will be immediately updated, so\n * accessing `this.state` after calling this method may return the old value.\n *\n * There is no guarantee that calls to `setState` will run synchronously,\n * as they may eventually be batched together. You can provide an optional\n * callback that will be executed when the call to setState is actually\n * completed.\n *\n * When a function is provided to setState, it will be called at some point in\n * the future (not synchronously). It will be called with the up to date\n * component arguments (state, props, context). These values can be different\n * from this.* because your function may be called after receiveProps but before\n * shouldComponentUpdate, and this new state, props, and context will not yet be\n * assigned to this.\n *\n * @param {object|function} partialState Next partial state or function to\n * produce next partial state to be merged with current state.\n * @param {?function} callback Called after state is updated.\n * @final\n * @protected\n */\n\nComponent.prototype.setState = function (partialState, callback) {\n if (typeof partialState !== 'object' && typeof partialState !== 'function' && partialState != null) {\n throw new Error('setState(...): takes an object of state variables to update or a ' + 'function which returns an object of state variables.');\n }\n\n this.updater.enqueueSetState(this, partialState, callback, 'setState');\n};\n/**\n * Forces an update. This should only be invoked when it is known with\n * certainty that we are **not** in a DOM transaction.\n *\n * You may want to call this when you know that some deeper aspect of the\n * component's state has changed but `setState` was not called.\n *\n * This will not invoke `shouldComponentUpdate`, but it will invoke\n * `componentWillUpdate` and `componentDidUpdate`.\n *\n * @param {?function} callback Called after update is complete.\n * @final\n * @protected\n */\n\n\nComponent.prototype.forceUpdate = function (callback) {\n this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');\n};\n/**\n * Deprecated APIs. These APIs used to exist on classic React classes but since\n * we would like to deprecate them, we're not going to move them over to this\n * modern base class. Instead, we define a getter that warns if it's accessed.\n */\n\n\n{\n var deprecatedAPIs = {\n isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],\n replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']\n };\n\n var defineDeprecationWarning = function (methodName, info) {\n Object.defineProperty(Component.prototype, methodName, {\n get: function () {\n warn('%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);\n\n return undefined;\n }\n });\n };\n\n for (var fnName in deprecatedAPIs) {\n if (deprecatedAPIs.hasOwnProperty(fnName)) {\n defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);\n }\n }\n}\n\nfunction ComponentDummy() {}\n\nComponentDummy.prototype = Component.prototype;\n/**\n * Convenience component with default shallow equality check for sCU.\n */\n\nfunction PureComponent(props, context, updater) {\n this.props = props;\n this.context = context; // If a component has string refs, we will assign a different object later.\n\n this.refs = emptyObject;\n this.updater = updater || ReactNoopUpdateQueue;\n}\n\nvar pureComponentPrototype = PureComponent.prototype = new ComponentDummy();\npureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods.\n\nassign(pureComponentPrototype, Component.prototype);\npureComponentPrototype.isPureReactComponent = true;\n\n// an immutable object with a single mutable value\nfunction createRef() {\n var refObject = {\n current: null\n };\n\n {\n Object.seal(refObject);\n }\n\n return refObject;\n}\n\nvar isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare\n\nfunction isArray(a) {\n return isArrayImpl(a);\n}\n\n/*\n * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol\n * and Temporal.* types. See https://github.com/facebook/react/pull/22064.\n *\n * The functions in this module will throw an easier-to-understand,\n * easier-to-debug exception with a clear errors message message explaining the\n * problem. (Instead of a confusing exception thrown inside the implementation\n * of the `value` object).\n */\n// $FlowFixMe only called in DEV, so void return is not possible.\nfunction typeName(value) {\n {\n // toStringTag is needed for namespaced types like Temporal.Instant\n var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;\n var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';\n return type;\n }\n} // $FlowFixMe only called in DEV, so void return is not possible.\n\n\nfunction willCoercionThrow(value) {\n {\n try {\n testStringCoercion(value);\n return false;\n } catch (e) {\n return true;\n }\n }\n}\n\nfunction testStringCoercion(value) {\n // If you ended up here by following an exception call stack, here's what's\n // happened: you supplied an object or symbol value to React (as a prop, key,\n // DOM attribute, CSS property, string ref, etc.) and when React tried to\n // coerce it to a string using `'' + value`, an exception was thrown.\n //\n // The most common types that will cause this exception are `Symbol` instances\n // and Temporal objects like `Temporal.Instant`. But any object that has a\n // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this\n // exception. (Library authors do this to prevent users from using built-in\n // numeric operators like `+` or comparison operators like `>=` because custom\n // methods are needed to perform accurate arithmetic or comparison.)\n //\n // To fix the problem, coerce this object or symbol value to a string before\n // passing it to React. The most reliable way is usually `String(value)`.\n //\n // To find which value is throwing, check the browser or debugger console.\n // Before this exception was thrown, there should be `console.error` output\n // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the\n // problem and how that type was used: key, atrribute, input value prop, etc.\n // In most cases, this console output also shows the component and its\n // ancestor components where the exception happened.\n //\n // eslint-disable-next-line react-internal/safe-string-coercion\n return '' + value;\n}\nfunction checkKeyStringCoercion(value) {\n {\n if (willCoercionThrow(value)) {\n error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));\n\n return testStringCoercion(value); // throw (to help callers find troubleshooting comments)\n }\n }\n}\n\nfunction getWrappedName(outerType, innerType, wrapperName) {\n var displayName = outerType.displayName;\n\n if (displayName) {\n return displayName;\n }\n\n var functionName = innerType.displayName || innerType.name || '';\n return functionName !== '' ? wrapperName + \"(\" + functionName + \")\" : wrapperName;\n} // Keep in sync with react-reconciler/getComponentNameFromFiber\n\n\nfunction getContextName(type) {\n return type.displayName || 'Context';\n} // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.\n\n\nfunction getComponentNameFromType(type) {\n if (type == null) {\n // Host root, text node or just invalid type.\n return null;\n }\n\n {\n if (typeof type.tag === 'number') {\n error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');\n }\n }\n\n if (typeof type === 'function') {\n return type.displayName || type.name || null;\n }\n\n if (typeof type === 'string') {\n return type;\n }\n\n switch (type) {\n case REACT_FRAGMENT_TYPE:\n return 'Fragment';\n\n case REACT_PORTAL_TYPE:\n return 'Portal';\n\n case REACT_PROFILER_TYPE:\n return 'Profiler';\n\n case REACT_STRICT_MODE_TYPE:\n return 'StrictMode';\n\n case REACT_SUSPENSE_TYPE:\n return 'Suspense';\n\n case REACT_SUSPENSE_LIST_TYPE:\n return 'SuspenseList';\n\n }\n\n if (typeof type === 'object') {\n switch (type.$$typeof) {\n case REACT_CONTEXT_TYPE:\n var context = type;\n return getContextName(context) + '.Consumer';\n\n case REACT_PROVIDER_TYPE:\n var provider = type;\n return getContextName(provider._context) + '.Provider';\n\n case REACT_FORWARD_REF_TYPE:\n return getWrappedName(type, type.render, 'ForwardRef');\n\n case REACT_MEMO_TYPE:\n var outerName = type.displayName || null;\n\n if (outerName !== null) {\n return outerName;\n }\n\n return getComponentNameFromType(type.type) || 'Memo';\n\n case REACT_LAZY_TYPE:\n {\n var lazyComponent = type;\n var payload = lazyComponent._payload;\n var init = lazyComponent._init;\n\n try {\n return getComponentNameFromType(init(payload));\n } catch (x) {\n return null;\n }\n }\n\n // eslint-disable-next-line no-fallthrough\n }\n }\n\n return null;\n}\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\nvar RESERVED_PROPS = {\n key: true,\n ref: true,\n __self: true,\n __source: true\n};\nvar specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs;\n\n{\n didWarnAboutStringRefs = {};\n}\n\nfunction hasValidRef(config) {\n {\n if (hasOwnProperty.call(config, 'ref')) {\n var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;\n\n if (getter && getter.isReactWarning) {\n return false;\n }\n }\n }\n\n return config.ref !== undefined;\n}\n\nfunction hasValidKey(config) {\n {\n if (hasOwnProperty.call(config, 'key')) {\n var getter = Object.getOwnPropertyDescriptor(config, 'key').get;\n\n if (getter && getter.isReactWarning) {\n return false;\n }\n }\n }\n\n return config.key !== undefined;\n}\n\nfunction defineKeyPropWarningGetter(props, displayName) {\n var warnAboutAccessingKey = function () {\n {\n if (!specialPropKeyWarningShown) {\n specialPropKeyWarningShown = true;\n\n error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);\n }\n }\n };\n\n warnAboutAccessingKey.isReactWarning = true;\n Object.defineProperty(props, 'key', {\n get: warnAboutAccessingKey,\n configurable: true\n });\n}\n\nfunction defineRefPropWarningGetter(props, displayName) {\n var warnAboutAccessingRef = function () {\n {\n if (!specialPropRefWarningShown) {\n specialPropRefWarningShown = true;\n\n error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);\n }\n }\n };\n\n warnAboutAccessingRef.isReactWarning = true;\n Object.defineProperty(props, 'ref', {\n get: warnAboutAccessingRef,\n configurable: true\n });\n}\n\nfunction warnIfStringRefCannotBeAutoConverted(config) {\n {\n if (typeof config.ref === 'string' && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) {\n var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);\n\n if (!didWarnAboutStringRefs[componentName]) {\n error('Component \"%s\" contains the string ref \"%s\". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', componentName, config.ref);\n\n didWarnAboutStringRefs[componentName] = true;\n }\n }\n }\n}\n/**\n * Factory method to create a new React element. This no longer adheres to\n * the class pattern, so do not use new to call it. Also, instanceof check\n * will not work. Instead test $$typeof field against Symbol.for('react.element') to check\n * if something is a React Element.\n *\n * @param {*} type\n * @param {*} props\n * @param {*} key\n * @param {string|object} ref\n * @param {*} owner\n * @param {*} self A *temporary* helper to detect places where `this` is\n * different from the `owner` when React.createElement is called, so that we\n * can warn. We want to get rid of owner and replace string `ref`s with arrow\n * functions, and as long as `this` and owner are the same, there will be no\n * change in behavior.\n * @param {*} source An annotation object (added by a transpiler or otherwise)\n * indicating filename, line number, and/or other information.\n * @internal\n */\n\n\nvar ReactElement = function (type, key, ref, self, source, owner, props) {\n var element = {\n // This tag allows us to uniquely identify this as a React Element\n $$typeof: REACT_ELEMENT_TYPE,\n // Built-in properties that belong on the element\n type: type,\n key: key,\n ref: ref,\n props: props,\n // Record the component responsible for creating this element.\n _owner: owner\n };\n\n {\n // The validation flag is currently mutative. We put it on\n // an external backing store so that we can freeze the whole object.\n // This can be replaced with a WeakMap once they are implemented in\n // commonly used development environments.\n element._store = {}; // To make comparing ReactElements easier for testing purposes, we make\n // the validation flag non-enumerable (where possible, which should\n // include every environment we run tests in), so the test framework\n // ignores it.\n\n Object.defineProperty(element._store, 'validated', {\n configurable: false,\n enumerable: false,\n writable: true,\n value: false\n }); // self and source are DEV only properties.\n\n Object.defineProperty(element, '_self', {\n configurable: false,\n enumerable: false,\n writable: false,\n value: self\n }); // Two elements created in two different places should be considered\n // equal for testing purposes and therefore we hide it from enumeration.\n\n Object.defineProperty(element, '_source', {\n configurable: false,\n enumerable: false,\n writable: false,\n value: source\n });\n\n if (Object.freeze) {\n Object.freeze(element.props);\n Object.freeze(element);\n }\n }\n\n return element;\n};\n/**\n * Create and return a new ReactElement of the given type.\n * See https://reactjs.org/docs/react-api.html#createelement\n */\n\nfunction createElement(type, config, children) {\n var propName; // Reserved names are extracted\n\n var props = {};\n var key = null;\n var ref = null;\n var self = null;\n var source = null;\n\n if (config != null) {\n if (hasValidRef(config)) {\n ref = config.ref;\n\n {\n warnIfStringRefCannotBeAutoConverted(config);\n }\n }\n\n if (hasValidKey(config)) {\n {\n checkKeyStringCoercion(config.key);\n }\n\n key = '' + config.key;\n }\n\n self = config.__self === undefined ? null : config.__self;\n source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object\n\n for (propName in config) {\n if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {\n props[propName] = config[propName];\n }\n }\n } // Children can be more than one argument, and those are transferred onto\n // the newly allocated props object.\n\n\n var childrenLength = arguments.length - 2;\n\n if (childrenLength === 1) {\n props.children = children;\n } else if (childrenLength > 1) {\n var childArray = Array(childrenLength);\n\n for (var i = 0; i < childrenLength; i++) {\n childArray[i] = arguments[i + 2];\n }\n\n {\n if (Object.freeze) {\n Object.freeze(childArray);\n }\n }\n\n props.children = childArray;\n } // Resolve default props\n\n\n if (type && type.defaultProps) {\n var defaultProps = type.defaultProps;\n\n for (propName in defaultProps) {\n if (props[propName] === undefined) {\n props[propName] = defaultProps[propName];\n }\n }\n }\n\n {\n if (key || ref) {\n var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;\n\n if (key) {\n defineKeyPropWarningGetter(props, displayName);\n }\n\n if (ref) {\n defineRefPropWarningGetter(props, displayName);\n }\n }\n }\n\n return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);\n}\nfunction cloneAndReplaceKey(oldElement, newKey) {\n var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);\n return newElement;\n}\n/**\n * Clone and return a new ReactElement using element as the starting point.\n * See https://reactjs.org/docs/react-api.html#cloneelement\n */\n\nfunction cloneElement(element, config, children) {\n if (element === null || element === undefined) {\n throw new Error(\"React.cloneElement(...): The argument must be a React element, but you passed \" + element + \".\");\n }\n\n var propName; // Original props are copied\n\n var props = assign({}, element.props); // Reserved names are extracted\n\n var key = element.key;\n var ref = element.ref; // Self is preserved since the owner is preserved.\n\n var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a\n // transpiler, and the original source is probably a better indicator of the\n // true owner.\n\n var source = element._source; // Owner will be preserved, unless ref is overridden\n\n var owner = element._owner;\n\n if (config != null) {\n if (hasValidRef(config)) {\n // Silently steal the ref from the parent.\n ref = config.ref;\n owner = ReactCurrentOwner.current;\n }\n\n if (hasValidKey(config)) {\n {\n checkKeyStringCoercion(config.key);\n }\n\n key = '' + config.key;\n } // Remaining properties override existing props\n\n\n var defaultProps;\n\n if (element.type && element.type.defaultProps) {\n defaultProps = element.type.defaultProps;\n }\n\n for (propName in config) {\n if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {\n if (config[propName] === undefined && defaultProps !== undefined) {\n // Resolve default props\n props[propName] = defaultProps[propName];\n } else {\n props[propName] = config[propName];\n }\n }\n }\n } // Children can be more than one argument, and those are transferred onto\n // the newly allocated props object.\n\n\n var childrenLength = arguments.length - 2;\n\n if (childrenLength === 1) {\n props.children = children;\n } else if (childrenLength > 1) {\n var childArray = Array(childrenLength);\n\n for (var i = 0; i < childrenLength; i++) {\n childArray[i] = arguments[i + 2];\n }\n\n props.children = childArray;\n }\n\n return ReactElement(element.type, key, ref, self, source, owner, props);\n}\n/**\n * Verifies the object is a ReactElement.\n * See https://reactjs.org/docs/react-api.html#isvalidelement\n * @param {?object} object\n * @return {boolean} True if `object` is a ReactElement.\n * @final\n */\n\nfunction isValidElement(object) {\n return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;\n}\n\nvar SEPARATOR = '.';\nvar SUBSEPARATOR = ':';\n/**\n * Escape and wrap key so it is safe to use as a reactid\n *\n * @param {string} key to be escaped.\n * @return {string} the escaped key.\n */\n\nfunction escape(key) {\n var escapeRegex = /[=:]/g;\n var escaperLookup = {\n '=': '=0',\n ':': '=2'\n };\n var escapedString = key.replace(escapeRegex, function (match) {\n return escaperLookup[match];\n });\n return '$' + escapedString;\n}\n/**\n * TODO: Test that a single child and an array with one item have the same key\n * pattern.\n */\n\n\nvar didWarnAboutMaps = false;\nvar userProvidedKeyEscapeRegex = /\\/+/g;\n\nfunction escapeUserProvidedKey(text) {\n return text.replace(userProvidedKeyEscapeRegex, '$&/');\n}\n/**\n * Generate a key string that identifies a element within a set.\n *\n * @param {*} element A element that could contain a manual key.\n * @param {number} index Index that is used if a manual key is not provided.\n * @return {string}\n */\n\n\nfunction getElementKey(element, index) {\n // Do some typechecking here since we call this blindly. We want to ensure\n // that we don't block potential future ES APIs.\n if (typeof element === 'object' && element !== null && element.key != null) {\n // Explicit key\n {\n checkKeyStringCoercion(element.key);\n }\n\n return escape('' + element.key);\n } // Implicit key determined by the index in the set\n\n\n return index.toString(36);\n}\n\nfunction mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {\n var type = typeof children;\n\n if (type === 'undefined' || type === 'boolean') {\n // All of the above are perceived as null.\n children = null;\n }\n\n var invokeCallback = false;\n\n if (children === null) {\n invokeCallback = true;\n } else {\n switch (type) {\n case 'string':\n case 'number':\n invokeCallback = true;\n break;\n\n case 'object':\n switch (children.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n invokeCallback = true;\n }\n\n }\n }\n\n if (invokeCallback) {\n var _child = children;\n var mappedChild = callback(_child); // If it's the only child, treat the name as if it was wrapped in an array\n // so that it's consistent if the number of children grows:\n\n var childKey = nameSoFar === '' ? SEPARATOR + getElementKey(_child, 0) : nameSoFar;\n\n if (isArray(mappedChild)) {\n var escapedChildKey = '';\n\n if (childKey != null) {\n escapedChildKey = escapeUserProvidedKey(childKey) + '/';\n }\n\n mapIntoArray(mappedChild, array, escapedChildKey, '', function (c) {\n return c;\n });\n } else if (mappedChild != null) {\n if (isValidElement(mappedChild)) {\n {\n // The `if` statement here prevents auto-disabling of the safe\n // coercion ESLint rule, so we must manually disable it below.\n // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key\n if (mappedChild.key && (!_child || _child.key !== mappedChild.key)) {\n checkKeyStringCoercion(mappedChild.key);\n }\n }\n\n mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as\n // traverseAllChildren used to do for objects as children\n escapedPrefix + ( // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key\n mappedChild.key && (!_child || _child.key !== mappedChild.key) ? // $FlowFixMe Flow incorrectly thinks existing element's key can be a number\n // eslint-disable-next-line react-internal/safe-string-coercion\n escapeUserProvidedKey('' + mappedChild.key) + '/' : '') + childKey);\n }\n\n array.push(mappedChild);\n }\n\n return 1;\n }\n\n var child;\n var nextName;\n var subtreeCount = 0; // Count of children found in the current subtree.\n\n var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;\n\n if (isArray(children)) {\n for (var i = 0; i < children.length; i++) {\n child = children[i];\n nextName = nextNamePrefix + getElementKey(child, i);\n subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);\n }\n } else {\n var iteratorFn = getIteratorFn(children);\n\n if (typeof iteratorFn === 'function') {\n var iterableChildren = children;\n\n {\n // Warn about using Maps as children\n if (iteratorFn === iterableChildren.entries) {\n if (!didWarnAboutMaps) {\n warn('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n }\n }\n\n var iterator = iteratorFn.call(iterableChildren);\n var step;\n var ii = 0;\n\n while (!(step = iterator.next()).done) {\n child = step.value;\n nextName = nextNamePrefix + getElementKey(child, ii++);\n subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);\n }\n } else if (type === 'object') {\n // eslint-disable-next-line react-internal/safe-string-coercion\n var childrenString = String(children);\n throw new Error(\"Objects are not valid as a React child (found: \" + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + \"). \" + 'If you meant to render a collection of children, use an array ' + 'instead.');\n }\n }\n\n return subtreeCount;\n}\n\n/**\n * Maps children that are typically specified as `props.children`.\n *\n * See https://reactjs.org/docs/react-api.html#reactchildrenmap\n *\n * The provided mapFunction(child, index) will be called for each\n * leaf child.\n *\n * @param {?*} children Children tree container.\n * @param {function(*, int)} func The map function.\n * @param {*} context Context for mapFunction.\n * @return {object} Object containing the ordered map of results.\n */\nfunction mapChildren(children, func, context) {\n if (children == null) {\n return children;\n }\n\n var result = [];\n var count = 0;\n mapIntoArray(children, result, '', '', function (child) {\n return func.call(context, child, count++);\n });\n return result;\n}\n/**\n * Count the number of children that are typically specified as\n * `props.children`.\n *\n * See https://reactjs.org/docs/react-api.html#reactchildrencount\n *\n * @param {?*} children Children tree container.\n * @return {number} The number of children.\n */\n\n\nfunction countChildren(children) {\n var n = 0;\n mapChildren(children, function () {\n n++; // Don't return anything\n });\n return n;\n}\n\n/**\n * Iterates through children that are typically specified as `props.children`.\n *\n * See https://reactjs.org/docs/react-api.html#reactchildrenforeach\n *\n * The provided forEachFunc(child, index) will be called for each\n * leaf child.\n *\n * @param {?*} children Children tree container.\n * @param {function(*, int)} forEachFunc\n * @param {*} forEachContext Context for forEachContext.\n */\nfunction forEachChildren(children, forEachFunc, forEachContext) {\n mapChildren(children, function () {\n forEachFunc.apply(this, arguments); // Don't return anything.\n }, forEachContext);\n}\n/**\n * Flatten a children object (typically specified as `props.children`) and\n * return an array with appropriately re-keyed children.\n *\n * See https://reactjs.org/docs/react-api.html#reactchildrentoarray\n */\n\n\nfunction toArray(children) {\n return mapChildren(children, function (child) {\n return child;\n }) || [];\n}\n/**\n * Returns the first child in a collection of children and verifies that there\n * is only one child in the collection.\n *\n * See https://reactjs.org/docs/react-api.html#reactchildrenonly\n *\n * The current implementation of this function assumes that a single child gets\n * passed without a wrapper, but the purpose of this helper function is to\n * abstract away the particular structure of children.\n *\n * @param {?object} children Child collection structure.\n * @return {ReactElement} The first and only `ReactElement` contained in the\n * structure.\n */\n\n\nfunction onlyChild(children) {\n if (!isValidElement(children)) {\n throw new Error('React.Children.only expected to receive a single React element child.');\n }\n\n return children;\n}\n\nfunction createContext(defaultValue) {\n // TODO: Second argument used to be an optional `calculateChangedBits`\n // function. Warn to reserve for future use?\n var context = {\n $$typeof: REACT_CONTEXT_TYPE,\n // As a workaround to support multiple concurrent renderers, we categorize\n // some renderers as primary and others as secondary. We only expect\n // there to be two concurrent renderers at most: React Native (primary) and\n // Fabric (secondary); React DOM (primary) and React ART (secondary).\n // Secondary renderers store their context values on separate fields.\n _currentValue: defaultValue,\n _currentValue2: defaultValue,\n // Used to track how many concurrent renderers this context currently\n // supports within in a single renderer. Such as parallel server rendering.\n _threadCount: 0,\n // These are circular\n Provider: null,\n Consumer: null,\n // Add these to use same hidden class in VM as ServerContext\n _defaultValue: null,\n _globalName: null\n };\n context.Provider = {\n $$typeof: REACT_PROVIDER_TYPE,\n _context: context\n };\n var hasWarnedAboutUsingNestedContextConsumers = false;\n var hasWarnedAboutUsingConsumerProvider = false;\n var hasWarnedAboutDisplayNameOnConsumer = false;\n\n {\n // A separate object, but proxies back to the original context object for\n // backwards compatibility. It has a different $$typeof, so we can properly\n // warn for the incorrect usage of Context as a Consumer.\n var Consumer = {\n $$typeof: REACT_CONTEXT_TYPE,\n _context: context\n }; // $FlowFixMe: Flow complains about not setting a value, which is intentional here\n\n Object.defineProperties(Consumer, {\n Provider: {\n get: function () {\n if (!hasWarnedAboutUsingConsumerProvider) {\n hasWarnedAboutUsingConsumerProvider = true;\n\n error('Rendering is not supported and will be removed in ' + 'a future major release. Did you mean to render instead?');\n }\n\n return context.Provider;\n },\n set: function (_Provider) {\n context.Provider = _Provider;\n }\n },\n _currentValue: {\n get: function () {\n return context._currentValue;\n },\n set: function (_currentValue) {\n context._currentValue = _currentValue;\n }\n },\n _currentValue2: {\n get: function () {\n return context._currentValue2;\n },\n set: function (_currentValue2) {\n context._currentValue2 = _currentValue2;\n }\n },\n _threadCount: {\n get: function () {\n return context._threadCount;\n },\n set: function (_threadCount) {\n context._threadCount = _threadCount;\n }\n },\n Consumer: {\n get: function () {\n if (!hasWarnedAboutUsingNestedContextConsumers) {\n hasWarnedAboutUsingNestedContextConsumers = true;\n\n error('Rendering is not supported and will be removed in ' + 'a future major release. Did you mean to render instead?');\n }\n\n return context.Consumer;\n }\n },\n displayName: {\n get: function () {\n return context.displayName;\n },\n set: function (displayName) {\n if (!hasWarnedAboutDisplayNameOnConsumer) {\n warn('Setting `displayName` on Context.Consumer has no effect. ' + \"You should set it directly on the context with Context.displayName = '%s'.\", displayName);\n\n hasWarnedAboutDisplayNameOnConsumer = true;\n }\n }\n }\n }); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty\n\n context.Consumer = Consumer;\n }\n\n {\n context._currentRenderer = null;\n context._currentRenderer2 = null;\n }\n\n return context;\n}\n\nvar Uninitialized = -1;\nvar Pending = 0;\nvar Resolved = 1;\nvar Rejected = 2;\n\nfunction lazyInitializer(payload) {\n if (payload._status === Uninitialized) {\n var ctor = payload._result;\n var thenable = ctor(); // Transition to the next state.\n // This might throw either because it's missing or throws. If so, we treat it\n // as still uninitialized and try again next time. Which is the same as what\n // happens if the ctor or any wrappers processing the ctor throws. This might\n // end up fixing it if the resolution was a concurrency bug.\n\n thenable.then(function (moduleObject) {\n if (payload._status === Pending || payload._status === Uninitialized) {\n // Transition to the next state.\n var resolved = payload;\n resolved._status = Resolved;\n resolved._result = moduleObject;\n }\n }, function (error) {\n if (payload._status === Pending || payload._status === Uninitialized) {\n // Transition to the next state.\n var rejected = payload;\n rejected._status = Rejected;\n rejected._result = error;\n }\n });\n\n if (payload._status === Uninitialized) {\n // In case, we're still uninitialized, then we're waiting for the thenable\n // to resolve. Set it as pending in the meantime.\n var pending = payload;\n pending._status = Pending;\n pending._result = thenable;\n }\n }\n\n if (payload._status === Resolved) {\n var moduleObject = payload._result;\n\n {\n if (moduleObject === undefined) {\n error('lazy: Expected the result of a dynamic imp' + 'ort() call. ' + 'Instead received: %s\\n\\nYour code should look like: \\n ' + // Break up imports to avoid accidentally parsing them as dependencies.\n 'const MyComponent = lazy(() => imp' + \"ort('./MyComponent'))\\n\\n\" + 'Did you accidentally put curly braces around the import?', moduleObject);\n }\n }\n\n {\n if (!('default' in moduleObject)) {\n error('lazy: Expected the result of a dynamic imp' + 'ort() call. ' + 'Instead received: %s\\n\\nYour code should look like: \\n ' + // Break up imports to avoid accidentally parsing them as dependencies.\n 'const MyComponent = lazy(() => imp' + \"ort('./MyComponent'))\", moduleObject);\n }\n }\n\n return moduleObject.default;\n } else {\n throw payload._result;\n }\n}\n\nfunction lazy(ctor) {\n var payload = {\n // We use these fields to store the result.\n _status: Uninitialized,\n _result: ctor\n };\n var lazyType = {\n $$typeof: REACT_LAZY_TYPE,\n _payload: payload,\n _init: lazyInitializer\n };\n\n {\n // In production, this would just set it on the object.\n var defaultProps;\n var propTypes; // $FlowFixMe\n\n Object.defineProperties(lazyType, {\n defaultProps: {\n configurable: true,\n get: function () {\n return defaultProps;\n },\n set: function (newDefaultProps) {\n error('React.lazy(...): It is not supported to assign `defaultProps` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');\n\n defaultProps = newDefaultProps; // Match production behavior more closely:\n // $FlowFixMe\n\n Object.defineProperty(lazyType, 'defaultProps', {\n enumerable: true\n });\n }\n },\n propTypes: {\n configurable: true,\n get: function () {\n return propTypes;\n },\n set: function (newPropTypes) {\n error('React.lazy(...): It is not supported to assign `propTypes` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');\n\n propTypes = newPropTypes; // Match production behavior more closely:\n // $FlowFixMe\n\n Object.defineProperty(lazyType, 'propTypes', {\n enumerable: true\n });\n }\n }\n });\n }\n\n return lazyType;\n}\n\nfunction forwardRef(render) {\n {\n if (render != null && render.$$typeof === REACT_MEMO_TYPE) {\n error('forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).');\n } else if (typeof render !== 'function') {\n error('forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);\n } else {\n if (render.length !== 0 && render.length !== 2) {\n error('forwardRef render functions accept exactly two parameters: props and ref. %s', render.length === 1 ? 'Did you forget to use the ref parameter?' : 'Any additional parameter will be undefined.');\n }\n }\n\n if (render != null) {\n if (render.defaultProps != null || render.propTypes != null) {\n error('forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?');\n }\n }\n }\n\n var elementType = {\n $$typeof: REACT_FORWARD_REF_TYPE,\n render: render\n };\n\n {\n var ownName;\n Object.defineProperty(elementType, 'displayName', {\n enumerable: false,\n configurable: true,\n get: function () {\n return ownName;\n },\n set: function (name) {\n ownName = name; // The inner component shouldn't inherit this display name in most cases,\n // because the component may be used elsewhere.\n // But it's nice for anonymous functions to inherit the name,\n // so that our component-stack generation logic will display their frames.\n // An anonymous function generally suggests a pattern like:\n // React.forwardRef((props, ref) => {...});\n // This kind of inner function is not used elsewhere so the side effect is okay.\n\n if (!render.name && !render.displayName) {\n render.displayName = name;\n }\n }\n });\n }\n\n return elementType;\n}\n\nvar REACT_MODULE_REFERENCE;\n\n{\n REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');\n}\n\nfunction isValidElementType(type) {\n if (typeof type === 'string' || typeof type === 'function') {\n return true;\n } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).\n\n\n if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) {\n return true;\n }\n\n if (typeof type === 'object' && type !== null) {\n if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object\n // types supported by any Flight configuration anywhere since\n // we don't know which Flight build this will end up being used\n // with.\n type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction memo(type, compare) {\n {\n if (!isValidElementType(type)) {\n error('memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type);\n }\n }\n\n var elementType = {\n $$typeof: REACT_MEMO_TYPE,\n type: type,\n compare: compare === undefined ? null : compare\n };\n\n {\n var ownName;\n Object.defineProperty(elementType, 'displayName', {\n enumerable: false,\n configurable: true,\n get: function () {\n return ownName;\n },\n set: function (name) {\n ownName = name; // The inner component shouldn't inherit this display name in most cases,\n // because the component may be used elsewhere.\n // But it's nice for anonymous functions to inherit the name,\n // so that our component-stack generation logic will display their frames.\n // An anonymous function generally suggests a pattern like:\n // React.memo((props) => {...});\n // This kind of inner function is not used elsewhere so the side effect is okay.\n\n if (!type.name && !type.displayName) {\n type.displayName = name;\n }\n }\n });\n }\n\n return elementType;\n}\n\nfunction resolveDispatcher() {\n var dispatcher = ReactCurrentDispatcher.current;\n\n {\n if (dispatcher === null) {\n error('Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for' + ' one of the following reasons:\\n' + '1. You might have mismatching versions of React and the renderer (such as React DOM)\\n' + '2. You might be breaking the Rules of Hooks\\n' + '3. You might have more than one copy of React in the same app\\n' + 'See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.');\n }\n } // Will result in a null access error if accessed outside render phase. We\n // intentionally don't throw our own error because this is in a hot path.\n // Also helps ensure this is inlined.\n\n\n return dispatcher;\n}\nfunction useContext(Context) {\n var dispatcher = resolveDispatcher();\n\n {\n // TODO: add a more generic warning for invalid values.\n if (Context._context !== undefined) {\n var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs\n // and nobody should be using this in existing code.\n\n if (realContext.Consumer === Context) {\n error('Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?');\n } else if (realContext.Provider === Context) {\n error('Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?');\n }\n }\n }\n\n return dispatcher.useContext(Context);\n}\nfunction useState(initialState) {\n var dispatcher = resolveDispatcher();\n return dispatcher.useState(initialState);\n}\nfunction useReducer(reducer, initialArg, init) {\n var dispatcher = resolveDispatcher();\n return dispatcher.useReducer(reducer, initialArg, init);\n}\nfunction useRef(initialValue) {\n var dispatcher = resolveDispatcher();\n return dispatcher.useRef(initialValue);\n}\nfunction useEffect(create, deps) {\n var dispatcher = resolveDispatcher();\n return dispatcher.useEffect(create, deps);\n}\nfunction useInsertionEffect(create, deps) {\n var dispatcher = resolveDispatcher();\n return dispatcher.useInsertionEffect(create, deps);\n}\nfunction useLayoutEffect(create, deps) {\n var dispatcher = resolveDispatcher();\n return dispatcher.useLayoutEffect(create, deps);\n}\nfunction useCallback(callback, deps) {\n var dispatcher = resolveDispatcher();\n return dispatcher.useCallback(callback, deps);\n}\nfunction useMemo(create, deps) {\n var dispatcher = resolveDispatcher();\n return dispatcher.useMemo(create, deps);\n}\nfunction useImperativeHandle(ref, create, deps) {\n var dispatcher = resolveDispatcher();\n return dispatcher.useImperativeHandle(ref, create, deps);\n}\nfunction useDebugValue(value, formatterFn) {\n {\n var dispatcher = resolveDispatcher();\n return dispatcher.useDebugValue(value, formatterFn);\n }\n}\nfunction useTransition() {\n var dispatcher = resolveDispatcher();\n return dispatcher.useTransition();\n}\nfunction useDeferredValue(value) {\n var dispatcher = resolveDispatcher();\n return dispatcher.useDeferredValue(value);\n}\nfunction useId() {\n var dispatcher = resolveDispatcher();\n return dispatcher.useId();\n}\nfunction useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {\n var dispatcher = resolveDispatcher();\n return dispatcher.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n\n// Helpers to patch console.logs to avoid logging during side-effect free\n// replaying on render function. This currently only patches the object\n// lazily which won't cover if the log function was extracted eagerly.\n// We could also eagerly patch the method.\nvar disabledDepth = 0;\nvar prevLog;\nvar prevInfo;\nvar prevWarn;\nvar prevError;\nvar prevGroup;\nvar prevGroupCollapsed;\nvar prevGroupEnd;\n\nfunction disabledLog() {}\n\ndisabledLog.__reactDisabledLog = true;\nfunction disableLogs() {\n {\n if (disabledDepth === 0) {\n /* eslint-disable react-internal/no-production-logging */\n prevLog = console.log;\n prevInfo = console.info;\n prevWarn = console.warn;\n prevError = console.error;\n prevGroup = console.group;\n prevGroupCollapsed = console.groupCollapsed;\n prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099\n\n var props = {\n configurable: true,\n enumerable: true,\n value: disabledLog,\n writable: true\n }; // $FlowFixMe Flow thinks console is immutable.\n\n Object.defineProperties(console, {\n info: props,\n log: props,\n warn: props,\n error: props,\n group: props,\n groupCollapsed: props,\n groupEnd: props\n });\n /* eslint-enable react-internal/no-production-logging */\n }\n\n disabledDepth++;\n }\n}\nfunction reenableLogs() {\n {\n disabledDepth--;\n\n if (disabledDepth === 0) {\n /* eslint-disable react-internal/no-production-logging */\n var props = {\n configurable: true,\n enumerable: true,\n writable: true\n }; // $FlowFixMe Flow thinks console is immutable.\n\n Object.defineProperties(console, {\n log: assign({}, props, {\n value: prevLog\n }),\n info: assign({}, props, {\n value: prevInfo\n }),\n warn: assign({}, props, {\n value: prevWarn\n }),\n error: assign({}, props, {\n value: prevError\n }),\n group: assign({}, props, {\n value: prevGroup\n }),\n groupCollapsed: assign({}, props, {\n value: prevGroupCollapsed\n }),\n groupEnd: assign({}, props, {\n value: prevGroupEnd\n })\n });\n /* eslint-enable react-internal/no-production-logging */\n }\n\n if (disabledDepth < 0) {\n error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');\n }\n }\n}\n\nvar ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher;\nvar prefix;\nfunction describeBuiltInComponentFrame(name, source, ownerFn) {\n {\n if (prefix === undefined) {\n // Extract the VM specific prefix used by each line.\n try {\n throw Error();\n } catch (x) {\n var match = x.stack.trim().match(/\\n( *(at )?)/);\n prefix = match && match[1] || '';\n }\n } // We use the prefix to ensure our stacks line up with native stack frames.\n\n\n return '\\n' + prefix + name;\n }\n}\nvar reentry = false;\nvar componentFrameCache;\n\n{\n var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;\n componentFrameCache = new PossiblyWeakMap();\n}\n\nfunction describeNativeComponentFrame(fn, construct) {\n // If something asked for a stack inside a fake render, it should get ignored.\n if ( !fn || reentry) {\n return '';\n }\n\n {\n var frame = componentFrameCache.get(fn);\n\n if (frame !== undefined) {\n return frame;\n }\n }\n\n var control;\n reentry = true;\n var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.\n\n Error.prepareStackTrace = undefined;\n var previousDispatcher;\n\n {\n previousDispatcher = ReactCurrentDispatcher$1.current; // Set the dispatcher in DEV because this might be call in the render function\n // for warnings.\n\n ReactCurrentDispatcher$1.current = null;\n disableLogs();\n }\n\n try {\n // This should throw.\n if (construct) {\n // Something should be setting the props in the constructor.\n var Fake = function () {\n throw Error();\n }; // $FlowFixMe\n\n\n Object.defineProperty(Fake.prototype, 'props', {\n set: function () {\n // We use a throwing setter instead of frozen or non-writable props\n // because that won't throw in a non-strict mode function.\n throw Error();\n }\n });\n\n if (typeof Reflect === 'object' && Reflect.construct) {\n // We construct a different control for this case to include any extra\n // frames added by the construct call.\n try {\n Reflect.construct(Fake, []);\n } catch (x) {\n control = x;\n }\n\n Reflect.construct(fn, [], Fake);\n } else {\n try {\n Fake.call();\n } catch (x) {\n control = x;\n }\n\n fn.call(Fake.prototype);\n }\n } else {\n try {\n throw Error();\n } catch (x) {\n control = x;\n }\n\n fn();\n }\n } catch (sample) {\n // This is inlined manually because closure doesn't do it for us.\n if (sample && control && typeof sample.stack === 'string') {\n // This extracts the first frame from the sample that isn't also in the control.\n // Skipping one frame that we assume is the frame that calls the two.\n var sampleLines = sample.stack.split('\\n');\n var controlLines = control.stack.split('\\n');\n var s = sampleLines.length - 1;\n var c = controlLines.length - 1;\n\n while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {\n // We expect at least one stack frame to be shared.\n // Typically this will be the root most one. However, stack frames may be\n // cut off due to maximum stack limits. In this case, one maybe cut off\n // earlier than the other. We assume that the sample is longer or the same\n // and there for cut off earlier. So we should find the root most frame in\n // the sample somewhere in the control.\n c--;\n }\n\n for (; s >= 1 && c >= 0; s--, c--) {\n // Next we find the first one that isn't the same which should be the\n // frame that called our sample function and the control.\n if (sampleLines[s] !== controlLines[c]) {\n // In V8, the first line is describing the message but other VMs don't.\n // If we're about to return the first line, and the control is also on the same\n // line, that's a pretty good indicator that our sample threw at same line as\n // the control. I.e. before we entered the sample frame. So we ignore this result.\n // This can happen if you passed a class to function component, or non-function.\n if (s !== 1 || c !== 1) {\n do {\n s--;\n c--; // We may still have similar intermediate frames from the construct call.\n // The next one that isn't the same should be our match though.\n\n if (c < 0 || sampleLines[s] !== controlLines[c]) {\n // V8 adds a \"new\" prefix for native classes. Let's remove it to make it prettier.\n var _frame = '\\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled \"\"\n // but we have a user-provided \"displayName\"\n // splice it in to make the stack more readable.\n\n\n if (fn.displayName && _frame.includes('')) {\n _frame = _frame.replace('', fn.displayName);\n }\n\n {\n if (typeof fn === 'function') {\n componentFrameCache.set(fn, _frame);\n }\n } // Return the line we found.\n\n\n return _frame;\n }\n } while (s >= 1 && c >= 0);\n }\n\n break;\n }\n }\n }\n } finally {\n reentry = false;\n\n {\n ReactCurrentDispatcher$1.current = previousDispatcher;\n reenableLogs();\n }\n\n Error.prepareStackTrace = previousPrepareStackTrace;\n } // Fallback to just using the name if we couldn't make it throw.\n\n\n var name = fn ? fn.displayName || fn.name : '';\n var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';\n\n {\n if (typeof fn === 'function') {\n componentFrameCache.set(fn, syntheticFrame);\n }\n }\n\n return syntheticFrame;\n}\nfunction describeFunctionComponentFrame(fn, source, ownerFn) {\n {\n return describeNativeComponentFrame(fn, false);\n }\n}\n\nfunction shouldConstruct(Component) {\n var prototype = Component.prototype;\n return !!(prototype && prototype.isReactComponent);\n}\n\nfunction describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {\n\n if (type == null) {\n return '';\n }\n\n if (typeof type === 'function') {\n {\n return describeNativeComponentFrame(type, shouldConstruct(type));\n }\n }\n\n if (typeof type === 'string') {\n return describeBuiltInComponentFrame(type);\n }\n\n switch (type) {\n case REACT_SUSPENSE_TYPE:\n return describeBuiltInComponentFrame('Suspense');\n\n case REACT_SUSPENSE_LIST_TYPE:\n return describeBuiltInComponentFrame('SuspenseList');\n }\n\n if (typeof type === 'object') {\n switch (type.$$typeof) {\n case REACT_FORWARD_REF_TYPE:\n return describeFunctionComponentFrame(type.render);\n\n case REACT_MEMO_TYPE:\n // Memo may contain any component type so we recursively resolve it.\n return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);\n\n case REACT_LAZY_TYPE:\n {\n var lazyComponent = type;\n var payload = lazyComponent._payload;\n var init = lazyComponent._init;\n\n try {\n // Lazy may contain any component type so we recursively resolve it.\n return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);\n } catch (x) {}\n }\n }\n }\n\n return '';\n}\n\nvar loggedTypeFailures = {};\nvar ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;\n\nfunction setCurrentlyValidatingElement(element) {\n {\n if (element) {\n var owner = element._owner;\n var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);\n ReactDebugCurrentFrame$1.setExtraStackFrame(stack);\n } else {\n ReactDebugCurrentFrame$1.setExtraStackFrame(null);\n }\n }\n}\n\nfunction checkPropTypes(typeSpecs, values, location, componentName, element) {\n {\n // $FlowFixMe This is okay but Flow doesn't know it.\n var has = Function.call.bind(hasOwnProperty);\n\n for (var typeSpecName in typeSpecs) {\n if (has(typeSpecs, typeSpecName)) {\n var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to\n // fail the render phase where it didn't fail before. So we log it.\n // After these have been cleaned up, we'll let them throw.\n\n try {\n // This is intentionally an invariant that gets caught. It's the same\n // behavior as without this statement except with a better message.\n if (typeof typeSpecs[typeSpecName] !== 'function') {\n // eslint-disable-next-line react-internal/prod-error-codes\n var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');\n err.name = 'Invariant Violation';\n throw err;\n }\n\n error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');\n } catch (ex) {\n error$1 = ex;\n }\n\n if (error$1 && !(error$1 instanceof Error)) {\n setCurrentlyValidatingElement(element);\n\n error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);\n\n setCurrentlyValidatingElement(null);\n }\n\n if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {\n // Only monitor this failure once because there tends to be a lot of the\n // same error.\n loggedTypeFailures[error$1.message] = true;\n setCurrentlyValidatingElement(element);\n\n error('Failed %s type: %s', location, error$1.message);\n\n setCurrentlyValidatingElement(null);\n }\n }\n }\n }\n}\n\nfunction setCurrentlyValidatingElement$1(element) {\n {\n if (element) {\n var owner = element._owner;\n var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);\n setExtraStackFrame(stack);\n } else {\n setExtraStackFrame(null);\n }\n }\n}\n\nvar propTypesMisspellWarningShown;\n\n{\n propTypesMisspellWarningShown = false;\n}\n\nfunction getDeclarationErrorAddendum() {\n if (ReactCurrentOwner.current) {\n var name = getComponentNameFromType(ReactCurrentOwner.current.type);\n\n if (name) {\n return '\\n\\nCheck the render method of `' + name + '`.';\n }\n }\n\n return '';\n}\n\nfunction getSourceInfoErrorAddendum(source) {\n if (source !== undefined) {\n var fileName = source.fileName.replace(/^.*[\\\\\\/]/, '');\n var lineNumber = source.lineNumber;\n return '\\n\\nCheck your code at ' + fileName + ':' + lineNumber + '.';\n }\n\n return '';\n}\n\nfunction getSourceInfoErrorAddendumForProps(elementProps) {\n if (elementProps !== null && elementProps !== undefined) {\n return getSourceInfoErrorAddendum(elementProps.__source);\n }\n\n return '';\n}\n/**\n * Warn if there's no key explicitly set on dynamic arrays of children or\n * object keys are not valid. This allows us to keep track of children between\n * updates.\n */\n\n\nvar ownerHasKeyUseWarning = {};\n\nfunction getCurrentComponentErrorInfo(parentType) {\n var info = getDeclarationErrorAddendum();\n\n if (!info) {\n var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;\n\n if (parentName) {\n info = \"\\n\\nCheck the top-level render call using <\" + parentName + \">.\";\n }\n }\n\n return info;\n}\n/**\n * Warn if the element doesn't have an explicit key assigned to it.\n * This element is in an array. The array could grow and shrink or be\n * reordered. All children that haven't already been validated are required to\n * have a \"key\" property assigned to it. Error statuses are cached so a warning\n * will only be shown once.\n *\n * @internal\n * @param {ReactElement} element Element that requires a key.\n * @param {*} parentType element's parent's type.\n */\n\n\nfunction validateExplicitKey(element, parentType) {\n if (!element._store || element._store.validated || element.key != null) {\n return;\n }\n\n element._store.validated = true;\n var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);\n\n if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {\n return;\n }\n\n ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a\n // property, it may be the creator of the child that's responsible for\n // assigning it a key.\n\n var childOwner = '';\n\n if (element && element._owner && element._owner !== ReactCurrentOwner.current) {\n // Give the component that originally created this child.\n childOwner = \" It was passed a child from \" + getComponentNameFromType(element._owner.type) + \".\";\n }\n\n {\n setCurrentlyValidatingElement$1(element);\n\n error('Each child in a list should have a unique \"key\" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);\n\n setCurrentlyValidatingElement$1(null);\n }\n}\n/**\n * Ensure that every element either is passed in a static location, in an\n * array with an explicit keys property defined, or in an object literal\n * with valid key property.\n *\n * @internal\n * @param {ReactNode} node Statically passed child of any type.\n * @param {*} parentType node's parent's type.\n */\n\n\nfunction validateChildKeys(node, parentType) {\n if (typeof node !== 'object') {\n return;\n }\n\n if (isArray(node)) {\n for (var i = 0; i < node.length; i++) {\n var child = node[i];\n\n if (isValidElement(child)) {\n validateExplicitKey(child, parentType);\n }\n }\n } else if (isValidElement(node)) {\n // This element was passed in a valid location.\n if (node._store) {\n node._store.validated = true;\n }\n } else if (node) {\n var iteratorFn = getIteratorFn(node);\n\n if (typeof iteratorFn === 'function') {\n // Entry iterators used to provide implicit keys,\n // but now we print a separate warning for them later.\n if (iteratorFn !== node.entries) {\n var iterator = iteratorFn.call(node);\n var step;\n\n while (!(step = iterator.next()).done) {\n if (isValidElement(step.value)) {\n validateExplicitKey(step.value, parentType);\n }\n }\n }\n }\n }\n}\n/**\n * Given an element, validate that its props follow the propTypes definition,\n * provided by the type.\n *\n * @param {ReactElement} element\n */\n\n\nfunction validatePropTypes(element) {\n {\n var type = element.type;\n\n if (type === null || type === undefined || typeof type === 'string') {\n return;\n }\n\n var propTypes;\n\n if (typeof type === 'function') {\n propTypes = type.propTypes;\n } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.\n // Inner props are checked in the reconciler.\n type.$$typeof === REACT_MEMO_TYPE)) {\n propTypes = type.propTypes;\n } else {\n return;\n }\n\n if (propTypes) {\n // Intentionally inside to avoid triggering lazy initializers:\n var name = getComponentNameFromType(type);\n checkPropTypes(propTypes, element.props, 'prop', name, element);\n } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {\n propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:\n\n var _name = getComponentNameFromType(type);\n\n error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');\n }\n\n if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {\n error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');\n }\n }\n}\n/**\n * Given a fragment, validate that it can only be provided with fragment props\n * @param {ReactElement} fragment\n */\n\n\nfunction validateFragmentProps(fragment) {\n {\n var keys = Object.keys(fragment.props);\n\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n\n if (key !== 'children' && key !== 'key') {\n setCurrentlyValidatingElement$1(fragment);\n\n error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);\n\n setCurrentlyValidatingElement$1(null);\n break;\n }\n }\n\n if (fragment.ref !== null) {\n setCurrentlyValidatingElement$1(fragment);\n\n error('Invalid attribute `ref` supplied to `React.Fragment`.');\n\n setCurrentlyValidatingElement$1(null);\n }\n }\n}\nfunction createElementWithValidation(type, props, children) {\n var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to\n // succeed and there will likely be errors in render.\n\n if (!validType) {\n var info = '';\n\n if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {\n info += ' You likely forgot to export your component from the file ' + \"it's defined in, or you might have mixed up default and named imports.\";\n }\n\n var sourceInfo = getSourceInfoErrorAddendumForProps(props);\n\n if (sourceInfo) {\n info += sourceInfo;\n } else {\n info += getDeclarationErrorAddendum();\n }\n\n var typeString;\n\n if (type === null) {\n typeString = 'null';\n } else if (isArray(type)) {\n typeString = 'array';\n } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {\n typeString = \"<\" + (getComponentNameFromType(type.type) || 'Unknown') + \" />\";\n info = ' Did you accidentally export a JSX literal instead of a component?';\n } else {\n typeString = typeof type;\n }\n\n {\n error('React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);\n }\n }\n\n var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used.\n // TODO: Drop this when these are no longer allowed as the type argument.\n\n if (element == null) {\n return element;\n } // Skip key warning if the type isn't valid since our key validation logic\n // doesn't expect a non-string/function type and can throw confusing errors.\n // We don't want exception behavior to differ between dev and prod.\n // (Rendering will throw with a helpful message and as soon as the type is\n // fixed, the key warnings will appear.)\n\n\n if (validType) {\n for (var i = 2; i < arguments.length; i++) {\n validateChildKeys(arguments[i], type);\n }\n }\n\n if (type === REACT_FRAGMENT_TYPE) {\n validateFragmentProps(element);\n } else {\n validatePropTypes(element);\n }\n\n return element;\n}\nvar didWarnAboutDeprecatedCreateFactory = false;\nfunction createFactoryWithValidation(type) {\n var validatedFactory = createElementWithValidation.bind(null, type);\n validatedFactory.type = type;\n\n {\n if (!didWarnAboutDeprecatedCreateFactory) {\n didWarnAboutDeprecatedCreateFactory = true;\n\n warn('React.createFactory() is deprecated and will be removed in ' + 'a future major release. Consider using JSX ' + 'or use React.createElement() directly instead.');\n } // Legacy hook: remove it\n\n\n Object.defineProperty(validatedFactory, 'type', {\n enumerable: false,\n get: function () {\n warn('Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');\n\n Object.defineProperty(this, 'type', {\n value: type\n });\n return type;\n }\n });\n }\n\n return validatedFactory;\n}\nfunction cloneElementWithValidation(element, props, children) {\n var newElement = cloneElement.apply(this, arguments);\n\n for (var i = 2; i < arguments.length; i++) {\n validateChildKeys(arguments[i], newElement.type);\n }\n\n validatePropTypes(newElement);\n return newElement;\n}\n\nfunction startTransition(scope, options) {\n var prevTransition = ReactCurrentBatchConfig.transition;\n ReactCurrentBatchConfig.transition = {};\n var currentTransition = ReactCurrentBatchConfig.transition;\n\n {\n ReactCurrentBatchConfig.transition._updatedFibers = new Set();\n }\n\n try {\n scope();\n } finally {\n ReactCurrentBatchConfig.transition = prevTransition;\n\n {\n if (prevTransition === null && currentTransition._updatedFibers) {\n var updatedFibersCount = currentTransition._updatedFibers.size;\n\n if (updatedFibersCount > 10) {\n warn('Detected a large number of updates inside startTransition. ' + 'If this is due to a subscription please re-write it to use React provided hooks. ' + 'Otherwise concurrent mode guarantees are off the table.');\n }\n\n currentTransition._updatedFibers.clear();\n }\n }\n }\n}\n\nvar didWarnAboutMessageChannel = false;\nvar enqueueTaskImpl = null;\nfunction enqueueTask(task) {\n if (enqueueTaskImpl === null) {\n try {\n // read require off the module object to get around the bundlers.\n // we don't want them to detect a require and bundle a Node polyfill.\n var requireString = ('require' + Math.random()).slice(0, 7);\n var nodeRequire = module && module[requireString]; // assuming we're in node, let's try to get node's\n // version of setImmediate, bypassing fake timers if any.\n\n enqueueTaskImpl = nodeRequire.call(module, 'timers').setImmediate;\n } catch (_err) {\n // we're in a browser\n // we can't use regular timers because they may still be faked\n // so we try MessageChannel+postMessage instead\n enqueueTaskImpl = function (callback) {\n {\n if (didWarnAboutMessageChannel === false) {\n didWarnAboutMessageChannel = true;\n\n if (typeof MessageChannel === 'undefined') {\n error('This browser does not have a MessageChannel implementation, ' + 'so enqueuing tasks via await act(async () => ...) will fail. ' + 'Please file an issue at https://github.com/facebook/react/issues ' + 'if you encounter this warning.');\n }\n }\n }\n\n var channel = new MessageChannel();\n channel.port1.onmessage = callback;\n channel.port2.postMessage(undefined);\n };\n }\n }\n\n return enqueueTaskImpl(task);\n}\n\nvar actScopeDepth = 0;\nvar didWarnNoAwaitAct = false;\nfunction act(callback) {\n {\n // `act` calls can be nested, so we track the depth. This represents the\n // number of `act` scopes on the stack.\n var prevActScopeDepth = actScopeDepth;\n actScopeDepth++;\n\n if (ReactCurrentActQueue.current === null) {\n // This is the outermost `act` scope. Initialize the queue. The reconciler\n // will detect the queue and use it instead of Scheduler.\n ReactCurrentActQueue.current = [];\n }\n\n var prevIsBatchingLegacy = ReactCurrentActQueue.isBatchingLegacy;\n var result;\n\n try {\n // Used to reproduce behavior of `batchedUpdates` in legacy mode. Only\n // set to `true` while the given callback is executed, not for updates\n // triggered during an async event, because this is how the legacy\n // implementation of `act` behaved.\n ReactCurrentActQueue.isBatchingLegacy = true;\n result = callback(); // Replicate behavior of original `act` implementation in legacy mode,\n // which flushed updates immediately after the scope function exits, even\n // if it's an async function.\n\n if (!prevIsBatchingLegacy && ReactCurrentActQueue.didScheduleLegacyUpdate) {\n var queue = ReactCurrentActQueue.current;\n\n if (queue !== null) {\n ReactCurrentActQueue.didScheduleLegacyUpdate = false;\n flushActQueue(queue);\n }\n }\n } catch (error) {\n popActScope(prevActScopeDepth);\n throw error;\n } finally {\n ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy;\n }\n\n if (result !== null && typeof result === 'object' && typeof result.then === 'function') {\n var thenableResult = result; // The callback is an async function (i.e. returned a promise). Wait\n // for it to resolve before exiting the current scope.\n\n var wasAwaited = false;\n var thenable = {\n then: function (resolve, reject) {\n wasAwaited = true;\n thenableResult.then(function (returnValue) {\n popActScope(prevActScopeDepth);\n\n if (actScopeDepth === 0) {\n // We've exited the outermost act scope. Recursively flush the\n // queue until there's no remaining work.\n recursivelyFlushAsyncActWork(returnValue, resolve, reject);\n } else {\n resolve(returnValue);\n }\n }, function (error) {\n // The callback threw an error.\n popActScope(prevActScopeDepth);\n reject(error);\n });\n }\n };\n\n {\n if (!didWarnNoAwaitAct && typeof Promise !== 'undefined') {\n // eslint-disable-next-line no-undef\n Promise.resolve().then(function () {}).then(function () {\n if (!wasAwaited) {\n didWarnNoAwaitAct = true;\n\n error('You called act(async () => ...) without await. ' + 'This could lead to unexpected testing behaviour, ' + 'interleaving multiple act calls and mixing their ' + 'scopes. ' + 'You should - await act(async () => ...);');\n }\n });\n }\n }\n\n return thenable;\n } else {\n var returnValue = result; // The callback is not an async function. Exit the current scope\n // immediately, without awaiting.\n\n popActScope(prevActScopeDepth);\n\n if (actScopeDepth === 0) {\n // Exiting the outermost act scope. Flush the queue.\n var _queue = ReactCurrentActQueue.current;\n\n if (_queue !== null) {\n flushActQueue(_queue);\n ReactCurrentActQueue.current = null;\n } // Return a thenable. If the user awaits it, we'll flush again in\n // case additional work was scheduled by a microtask.\n\n\n var _thenable = {\n then: function (resolve, reject) {\n // Confirm we haven't re-entered another `act` scope, in case\n // the user does something weird like await the thenable\n // multiple times.\n if (ReactCurrentActQueue.current === null) {\n // Recursively flush the queue until there's no remaining work.\n ReactCurrentActQueue.current = [];\n recursivelyFlushAsyncActWork(returnValue, resolve, reject);\n } else {\n resolve(returnValue);\n }\n }\n };\n return _thenable;\n } else {\n // Since we're inside a nested `act` scope, the returned thenable\n // immediately resolves. The outer scope will flush the queue.\n var _thenable2 = {\n then: function (resolve, reject) {\n resolve(returnValue);\n }\n };\n return _thenable2;\n }\n }\n }\n}\n\nfunction popActScope(prevActScopeDepth) {\n {\n if (prevActScopeDepth !== actScopeDepth - 1) {\n error('You seem to have overlapping act() calls, this is not supported. ' + 'Be sure to await previous act() calls before making a new one. ');\n }\n\n actScopeDepth = prevActScopeDepth;\n }\n}\n\nfunction recursivelyFlushAsyncActWork(returnValue, resolve, reject) {\n {\n var queue = ReactCurrentActQueue.current;\n\n if (queue !== null) {\n try {\n flushActQueue(queue);\n enqueueTask(function () {\n if (queue.length === 0) {\n // No additional work was scheduled. Finish.\n ReactCurrentActQueue.current = null;\n resolve(returnValue);\n } else {\n // Keep flushing work until there's none left.\n recursivelyFlushAsyncActWork(returnValue, resolve, reject);\n }\n });\n } catch (error) {\n reject(error);\n }\n } else {\n resolve(returnValue);\n }\n }\n}\n\nvar isFlushing = false;\n\nfunction flushActQueue(queue) {\n {\n if (!isFlushing) {\n // Prevent re-entrance.\n isFlushing = true;\n var i = 0;\n\n try {\n for (; i < queue.length; i++) {\n var callback = queue[i];\n\n do {\n callback = callback(true);\n } while (callback !== null);\n }\n\n queue.length = 0;\n } catch (error) {\n // If something throws, leave the remaining callbacks on the queue.\n queue = queue.slice(i + 1);\n throw error;\n } finally {\n isFlushing = false;\n }\n }\n }\n}\n\nvar createElement$1 = createElementWithValidation ;\nvar cloneElement$1 = cloneElementWithValidation ;\nvar createFactory = createFactoryWithValidation ;\nvar Children = {\n map: mapChildren,\n forEach: forEachChildren,\n count: countChildren,\n toArray: toArray,\n only: onlyChild\n};\n\nexports.Children = Children;\nexports.Component = Component;\nexports.Fragment = REACT_FRAGMENT_TYPE;\nexports.Profiler = REACT_PROFILER_TYPE;\nexports.PureComponent = PureComponent;\nexports.StrictMode = REACT_STRICT_MODE_TYPE;\nexports.Suspense = REACT_SUSPENSE_TYPE;\nexports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals;\nexports.act = act;\nexports.cloneElement = cloneElement$1;\nexports.createContext = createContext;\nexports.createElement = createElement$1;\nexports.createFactory = createFactory;\nexports.createRef = createRef;\nexports.forwardRef = forwardRef;\nexports.isValidElement = isValidElement;\nexports.lazy = lazy;\nexports.memo = memo;\nexports.startTransition = startTransition;\nexports.unstable_act = act;\nexports.useCallback = useCallback;\nexports.useContext = useContext;\nexports.useDebugValue = useDebugValue;\nexports.useDeferredValue = useDeferredValue;\nexports.useEffect = useEffect;\nexports.useId = useId;\nexports.useImperativeHandle = useImperativeHandle;\nexports.useInsertionEffect = useInsertionEffect;\nexports.useLayoutEffect = useLayoutEffect;\nexports.useMemo = useMemo;\nexports.useReducer = useReducer;\nexports.useRef = useRef;\nexports.useState = useState;\nexports.useSyncExternalStore = useSyncExternalStore;\nexports.useTransition = useTransition;\nexports.version = ReactVersion;\n /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());\n}\n \n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react.production.min.js');\n} else {\n module.exports = require('./cjs/react.development.js');\n}\n","/**\n * @license React\n * react-jsx-runtime.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n'use strict';\n\nvar React = require('react');\n\n// ATTENTION\n// When adding new symbols to this file,\n// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'\n// The Symbol used to tag the ReactElement-like types.\nvar REACT_ELEMENT_TYPE = Symbol.for('react.element');\nvar REACT_PORTAL_TYPE = Symbol.for('react.portal');\nvar REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');\nvar REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');\nvar REACT_PROFILER_TYPE = Symbol.for('react.profiler');\nvar REACT_PROVIDER_TYPE = Symbol.for('react.provider');\nvar REACT_CONTEXT_TYPE = Symbol.for('react.context');\nvar REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');\nvar REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');\nvar REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');\nvar REACT_MEMO_TYPE = Symbol.for('react.memo');\nvar REACT_LAZY_TYPE = Symbol.for('react.lazy');\nvar REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');\nvar MAYBE_ITERATOR_SYMBOL = Symbol.iterator;\nvar FAUX_ITERATOR_SYMBOL = '@@iterator';\nfunction getIteratorFn(maybeIterable) {\n if (maybeIterable === null || typeof maybeIterable !== 'object') {\n return null;\n }\n\n var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];\n\n if (typeof maybeIterator === 'function') {\n return maybeIterator;\n }\n\n return null;\n}\n\nvar ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n\nfunction error(format) {\n {\n {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n\n printWarning('error', format, args);\n }\n }\n}\n\nfunction printWarning(level, format, args) {\n // When changing this logic, you might want to also\n // update consoleWithStackDev.www.js as well.\n {\n var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;\n var stack = ReactDebugCurrentFrame.getStackAddendum();\n\n if (stack !== '') {\n format += '%s';\n args = args.concat([stack]);\n } // eslint-disable-next-line react-internal/safe-string-coercion\n\n\n var argsWithFormat = args.map(function (item) {\n return String(item);\n }); // Careful: RN currently depends on this prefix\n\n argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it\n // breaks IE9: https://github.com/facebook/react/issues/13610\n // eslint-disable-next-line react-internal/no-production-logging\n\n Function.prototype.apply.call(console[level], console, argsWithFormat);\n }\n}\n\n// -----------------------------------------------------------------------------\n\nvar enableScopeAPI = false; // Experimental Create Event Handle API.\nvar enableCacheElement = false;\nvar enableTransitionTracing = false; // No known bugs, but needs performance testing\n\nvar enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber\n// stuff. Intended to enable React core members to more easily debug scheduling\n// issues in DEV builds.\n\nvar enableDebugTracing = false; // Track which Fiber(s) schedule render work.\n\nvar REACT_MODULE_REFERENCE;\n\n{\n REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');\n}\n\nfunction isValidElementType(type) {\n if (typeof type === 'string' || typeof type === 'function') {\n return true;\n } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).\n\n\n if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) {\n return true;\n }\n\n if (typeof type === 'object' && type !== null) {\n if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object\n // types supported by any Flight configuration anywhere since\n // we don't know which Flight build this will end up being used\n // with.\n type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction getWrappedName(outerType, innerType, wrapperName) {\n var displayName = outerType.displayName;\n\n if (displayName) {\n return displayName;\n }\n\n var functionName = innerType.displayName || innerType.name || '';\n return functionName !== '' ? wrapperName + \"(\" + functionName + \")\" : wrapperName;\n} // Keep in sync with react-reconciler/getComponentNameFromFiber\n\n\nfunction getContextName(type) {\n return type.displayName || 'Context';\n} // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.\n\n\nfunction getComponentNameFromType(type) {\n if (type == null) {\n // Host root, text node or just invalid type.\n return null;\n }\n\n {\n if (typeof type.tag === 'number') {\n error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');\n }\n }\n\n if (typeof type === 'function') {\n return type.displayName || type.name || null;\n }\n\n if (typeof type === 'string') {\n return type;\n }\n\n switch (type) {\n case REACT_FRAGMENT_TYPE:\n return 'Fragment';\n\n case REACT_PORTAL_TYPE:\n return 'Portal';\n\n case REACT_PROFILER_TYPE:\n return 'Profiler';\n\n case REACT_STRICT_MODE_TYPE:\n return 'StrictMode';\n\n case REACT_SUSPENSE_TYPE:\n return 'Suspense';\n\n case REACT_SUSPENSE_LIST_TYPE:\n return 'SuspenseList';\n\n }\n\n if (typeof type === 'object') {\n switch (type.$$typeof) {\n case REACT_CONTEXT_TYPE:\n var context = type;\n return getContextName(context) + '.Consumer';\n\n case REACT_PROVIDER_TYPE:\n var provider = type;\n return getContextName(provider._context) + '.Provider';\n\n case REACT_FORWARD_REF_TYPE:\n return getWrappedName(type, type.render, 'ForwardRef');\n\n case REACT_MEMO_TYPE:\n var outerName = type.displayName || null;\n\n if (outerName !== null) {\n return outerName;\n }\n\n return getComponentNameFromType(type.type) || 'Memo';\n\n case REACT_LAZY_TYPE:\n {\n var lazyComponent = type;\n var payload = lazyComponent._payload;\n var init = lazyComponent._init;\n\n try {\n return getComponentNameFromType(init(payload));\n } catch (x) {\n return null;\n }\n }\n\n // eslint-disable-next-line no-fallthrough\n }\n }\n\n return null;\n}\n\nvar assign = Object.assign;\n\n// Helpers to patch console.logs to avoid logging during side-effect free\n// replaying on render function. This currently only patches the object\n// lazily which won't cover if the log function was extracted eagerly.\n// We could also eagerly patch the method.\nvar disabledDepth = 0;\nvar prevLog;\nvar prevInfo;\nvar prevWarn;\nvar prevError;\nvar prevGroup;\nvar prevGroupCollapsed;\nvar prevGroupEnd;\n\nfunction disabledLog() {}\n\ndisabledLog.__reactDisabledLog = true;\nfunction disableLogs() {\n {\n if (disabledDepth === 0) {\n /* eslint-disable react-internal/no-production-logging */\n prevLog = console.log;\n prevInfo = console.info;\n prevWarn = console.warn;\n prevError = console.error;\n prevGroup = console.group;\n prevGroupCollapsed = console.groupCollapsed;\n prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099\n\n var props = {\n configurable: true,\n enumerable: true,\n value: disabledLog,\n writable: true\n }; // $FlowFixMe Flow thinks console is immutable.\n\n Object.defineProperties(console, {\n info: props,\n log: props,\n warn: props,\n error: props,\n group: props,\n groupCollapsed: props,\n groupEnd: props\n });\n /* eslint-enable react-internal/no-production-logging */\n }\n\n disabledDepth++;\n }\n}\nfunction reenableLogs() {\n {\n disabledDepth--;\n\n if (disabledDepth === 0) {\n /* eslint-disable react-internal/no-production-logging */\n var props = {\n configurable: true,\n enumerable: true,\n writable: true\n }; // $FlowFixMe Flow thinks console is immutable.\n\n Object.defineProperties(console, {\n log: assign({}, props, {\n value: prevLog\n }),\n info: assign({}, props, {\n value: prevInfo\n }),\n warn: assign({}, props, {\n value: prevWarn\n }),\n error: assign({}, props, {\n value: prevError\n }),\n group: assign({}, props, {\n value: prevGroup\n }),\n groupCollapsed: assign({}, props, {\n value: prevGroupCollapsed\n }),\n groupEnd: assign({}, props, {\n value: prevGroupEnd\n })\n });\n /* eslint-enable react-internal/no-production-logging */\n }\n\n if (disabledDepth < 0) {\n error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');\n }\n }\n}\n\nvar ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;\nvar prefix;\nfunction describeBuiltInComponentFrame(name, source, ownerFn) {\n {\n if (prefix === undefined) {\n // Extract the VM specific prefix used by each line.\n try {\n throw Error();\n } catch (x) {\n var match = x.stack.trim().match(/\\n( *(at )?)/);\n prefix = match && match[1] || '';\n }\n } // We use the prefix to ensure our stacks line up with native stack frames.\n\n\n return '\\n' + prefix + name;\n }\n}\nvar reentry = false;\nvar componentFrameCache;\n\n{\n var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;\n componentFrameCache = new PossiblyWeakMap();\n}\n\nfunction describeNativeComponentFrame(fn, construct) {\n // If something asked for a stack inside a fake render, it should get ignored.\n if ( !fn || reentry) {\n return '';\n }\n\n {\n var frame = componentFrameCache.get(fn);\n\n if (frame !== undefined) {\n return frame;\n }\n }\n\n var control;\n reentry = true;\n var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.\n\n Error.prepareStackTrace = undefined;\n var previousDispatcher;\n\n {\n previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function\n // for warnings.\n\n ReactCurrentDispatcher.current = null;\n disableLogs();\n }\n\n try {\n // This should throw.\n if (construct) {\n // Something should be setting the props in the constructor.\n var Fake = function () {\n throw Error();\n }; // $FlowFixMe\n\n\n Object.defineProperty(Fake.prototype, 'props', {\n set: function () {\n // We use a throwing setter instead of frozen or non-writable props\n // because that won't throw in a non-strict mode function.\n throw Error();\n }\n });\n\n if (typeof Reflect === 'object' && Reflect.construct) {\n // We construct a different control for this case to include any extra\n // frames added by the construct call.\n try {\n Reflect.construct(Fake, []);\n } catch (x) {\n control = x;\n }\n\n Reflect.construct(fn, [], Fake);\n } else {\n try {\n Fake.call();\n } catch (x) {\n control = x;\n }\n\n fn.call(Fake.prototype);\n }\n } else {\n try {\n throw Error();\n } catch (x) {\n control = x;\n }\n\n fn();\n }\n } catch (sample) {\n // This is inlined manually because closure doesn't do it for us.\n if (sample && control && typeof sample.stack === 'string') {\n // This extracts the first frame from the sample that isn't also in the control.\n // Skipping one frame that we assume is the frame that calls the two.\n var sampleLines = sample.stack.split('\\n');\n var controlLines = control.stack.split('\\n');\n var s = sampleLines.length - 1;\n var c = controlLines.length - 1;\n\n while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {\n // We expect at least one stack frame to be shared.\n // Typically this will be the root most one. However, stack frames may be\n // cut off due to maximum stack limits. In this case, one maybe cut off\n // earlier than the other. We assume that the sample is longer or the same\n // and there for cut off earlier. So we should find the root most frame in\n // the sample somewhere in the control.\n c--;\n }\n\n for (; s >= 1 && c >= 0; s--, c--) {\n // Next we find the first one that isn't the same which should be the\n // frame that called our sample function and the control.\n if (sampleLines[s] !== controlLines[c]) {\n // In V8, the first line is describing the message but other VMs don't.\n // If we're about to return the first line, and the control is also on the same\n // line, that's a pretty good indicator that our sample threw at same line as\n // the control. I.e. before we entered the sample frame. So we ignore this result.\n // This can happen if you passed a class to function component, or non-function.\n if (s !== 1 || c !== 1) {\n do {\n s--;\n c--; // We may still have similar intermediate frames from the construct call.\n // The next one that isn't the same should be our match though.\n\n if (c < 0 || sampleLines[s] !== controlLines[c]) {\n // V8 adds a \"new\" prefix for native classes. Let's remove it to make it prettier.\n var _frame = '\\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled \"\"\n // but we have a user-provided \"displayName\"\n // splice it in to make the stack more readable.\n\n\n if (fn.displayName && _frame.includes('')) {\n _frame = _frame.replace('', fn.displayName);\n }\n\n {\n if (typeof fn === 'function') {\n componentFrameCache.set(fn, _frame);\n }\n } // Return the line we found.\n\n\n return _frame;\n }\n } while (s >= 1 && c >= 0);\n }\n\n break;\n }\n }\n }\n } finally {\n reentry = false;\n\n {\n ReactCurrentDispatcher.current = previousDispatcher;\n reenableLogs();\n }\n\n Error.prepareStackTrace = previousPrepareStackTrace;\n } // Fallback to just using the name if we couldn't make it throw.\n\n\n var name = fn ? fn.displayName || fn.name : '';\n var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';\n\n {\n if (typeof fn === 'function') {\n componentFrameCache.set(fn, syntheticFrame);\n }\n }\n\n return syntheticFrame;\n}\nfunction describeFunctionComponentFrame(fn, source, ownerFn) {\n {\n return describeNativeComponentFrame(fn, false);\n }\n}\n\nfunction shouldConstruct(Component) {\n var prototype = Component.prototype;\n return !!(prototype && prototype.isReactComponent);\n}\n\nfunction describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {\n\n if (type == null) {\n return '';\n }\n\n if (typeof type === 'function') {\n {\n return describeNativeComponentFrame(type, shouldConstruct(type));\n }\n }\n\n if (typeof type === 'string') {\n return describeBuiltInComponentFrame(type);\n }\n\n switch (type) {\n case REACT_SUSPENSE_TYPE:\n return describeBuiltInComponentFrame('Suspense');\n\n case REACT_SUSPENSE_LIST_TYPE:\n return describeBuiltInComponentFrame('SuspenseList');\n }\n\n if (typeof type === 'object') {\n switch (type.$$typeof) {\n case REACT_FORWARD_REF_TYPE:\n return describeFunctionComponentFrame(type.render);\n\n case REACT_MEMO_TYPE:\n // Memo may contain any component type so we recursively resolve it.\n return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);\n\n case REACT_LAZY_TYPE:\n {\n var lazyComponent = type;\n var payload = lazyComponent._payload;\n var init = lazyComponent._init;\n\n try {\n // Lazy may contain any component type so we recursively resolve it.\n return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);\n } catch (x) {}\n }\n }\n }\n\n return '';\n}\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\nvar loggedTypeFailures = {};\nvar ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;\n\nfunction setCurrentlyValidatingElement(element) {\n {\n if (element) {\n var owner = element._owner;\n var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);\n ReactDebugCurrentFrame.setExtraStackFrame(stack);\n } else {\n ReactDebugCurrentFrame.setExtraStackFrame(null);\n }\n }\n}\n\nfunction checkPropTypes(typeSpecs, values, location, componentName, element) {\n {\n // $FlowFixMe This is okay but Flow doesn't know it.\n var has = Function.call.bind(hasOwnProperty);\n\n for (var typeSpecName in typeSpecs) {\n if (has(typeSpecs, typeSpecName)) {\n var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to\n // fail the render phase where it didn't fail before. So we log it.\n // After these have been cleaned up, we'll let them throw.\n\n try {\n // This is intentionally an invariant that gets caught. It's the same\n // behavior as without this statement except with a better message.\n if (typeof typeSpecs[typeSpecName] !== 'function') {\n // eslint-disable-next-line react-internal/prod-error-codes\n var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');\n err.name = 'Invariant Violation';\n throw err;\n }\n\n error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');\n } catch (ex) {\n error$1 = ex;\n }\n\n if (error$1 && !(error$1 instanceof Error)) {\n setCurrentlyValidatingElement(element);\n\n error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);\n\n setCurrentlyValidatingElement(null);\n }\n\n if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {\n // Only monitor this failure once because there tends to be a lot of the\n // same error.\n loggedTypeFailures[error$1.message] = true;\n setCurrentlyValidatingElement(element);\n\n error('Failed %s type: %s', location, error$1.message);\n\n setCurrentlyValidatingElement(null);\n }\n }\n }\n }\n}\n\nvar isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare\n\nfunction isArray(a) {\n return isArrayImpl(a);\n}\n\n/*\n * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol\n * and Temporal.* types. See https://github.com/facebook/react/pull/22064.\n *\n * The functions in this module will throw an easier-to-understand,\n * easier-to-debug exception with a clear errors message message explaining the\n * problem. (Instead of a confusing exception thrown inside the implementation\n * of the `value` object).\n */\n// $FlowFixMe only called in DEV, so void return is not possible.\nfunction typeName(value) {\n {\n // toStringTag is needed for namespaced types like Temporal.Instant\n var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;\n var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';\n return type;\n }\n} // $FlowFixMe only called in DEV, so void return is not possible.\n\n\nfunction willCoercionThrow(value) {\n {\n try {\n testStringCoercion(value);\n return false;\n } catch (e) {\n return true;\n }\n }\n}\n\nfunction testStringCoercion(value) {\n // If you ended up here by following an exception call stack, here's what's\n // happened: you supplied an object or symbol value to React (as a prop, key,\n // DOM attribute, CSS property, string ref, etc.) and when React tried to\n // coerce it to a string using `'' + value`, an exception was thrown.\n //\n // The most common types that will cause this exception are `Symbol` instances\n // and Temporal objects like `Temporal.Instant`. But any object that has a\n // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this\n // exception. (Library authors do this to prevent users from using built-in\n // numeric operators like `+` or comparison operators like `>=` because custom\n // methods are needed to perform accurate arithmetic or comparison.)\n //\n // To fix the problem, coerce this object or symbol value to a string before\n // passing it to React. The most reliable way is usually `String(value)`.\n //\n // To find which value is throwing, check the browser or debugger console.\n // Before this exception was thrown, there should be `console.error` output\n // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the\n // problem and how that type was used: key, atrribute, input value prop, etc.\n // In most cases, this console output also shows the component and its\n // ancestor components where the exception happened.\n //\n // eslint-disable-next-line react-internal/safe-string-coercion\n return '' + value;\n}\nfunction checkKeyStringCoercion(value) {\n {\n if (willCoercionThrow(value)) {\n error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));\n\n return testStringCoercion(value); // throw (to help callers find troubleshooting comments)\n }\n }\n}\n\nvar ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;\nvar RESERVED_PROPS = {\n key: true,\n ref: true,\n __self: true,\n __source: true\n};\nvar specialPropKeyWarningShown;\nvar specialPropRefWarningShown;\nvar didWarnAboutStringRefs;\n\n{\n didWarnAboutStringRefs = {};\n}\n\nfunction hasValidRef(config) {\n {\n if (hasOwnProperty.call(config, 'ref')) {\n var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;\n\n if (getter && getter.isReactWarning) {\n return false;\n }\n }\n }\n\n return config.ref !== undefined;\n}\n\nfunction hasValidKey(config) {\n {\n if (hasOwnProperty.call(config, 'key')) {\n var getter = Object.getOwnPropertyDescriptor(config, 'key').get;\n\n if (getter && getter.isReactWarning) {\n return false;\n }\n }\n }\n\n return config.key !== undefined;\n}\n\nfunction warnIfStringRefCannotBeAutoConverted(config, self) {\n {\n if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {\n var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);\n\n if (!didWarnAboutStringRefs[componentName]) {\n error('Component \"%s\" contains the string ref \"%s\". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', getComponentNameFromType(ReactCurrentOwner.current.type), config.ref);\n\n didWarnAboutStringRefs[componentName] = true;\n }\n }\n }\n}\n\nfunction defineKeyPropWarningGetter(props, displayName) {\n {\n var warnAboutAccessingKey = function () {\n if (!specialPropKeyWarningShown) {\n specialPropKeyWarningShown = true;\n\n error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);\n }\n };\n\n warnAboutAccessingKey.isReactWarning = true;\n Object.defineProperty(props, 'key', {\n get: warnAboutAccessingKey,\n configurable: true\n });\n }\n}\n\nfunction defineRefPropWarningGetter(props, displayName) {\n {\n var warnAboutAccessingRef = function () {\n if (!specialPropRefWarningShown) {\n specialPropRefWarningShown = true;\n\n error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);\n }\n };\n\n warnAboutAccessingRef.isReactWarning = true;\n Object.defineProperty(props, 'ref', {\n get: warnAboutAccessingRef,\n configurable: true\n });\n }\n}\n/**\n * Factory method to create a new React element. This no longer adheres to\n * the class pattern, so do not use new to call it. Also, instanceof check\n * will not work. Instead test $$typeof field against Symbol.for('react.element') to check\n * if something is a React Element.\n *\n * @param {*} type\n * @param {*} props\n * @param {*} key\n * @param {string|object} ref\n * @param {*} owner\n * @param {*} self A *temporary* helper to detect places where `this` is\n * different from the `owner` when React.createElement is called, so that we\n * can warn. We want to get rid of owner and replace string `ref`s with arrow\n * functions, and as long as `this` and owner are the same, there will be no\n * change in behavior.\n * @param {*} source An annotation object (added by a transpiler or otherwise)\n * indicating filename, line number, and/or other information.\n * @internal\n */\n\n\nvar ReactElement = function (type, key, ref, self, source, owner, props) {\n var element = {\n // This tag allows us to uniquely identify this as a React Element\n $$typeof: REACT_ELEMENT_TYPE,\n // Built-in properties that belong on the element\n type: type,\n key: key,\n ref: ref,\n props: props,\n // Record the component responsible for creating this element.\n _owner: owner\n };\n\n {\n // The validation flag is currently mutative. We put it on\n // an external backing store so that we can freeze the whole object.\n // This can be replaced with a WeakMap once they are implemented in\n // commonly used development environments.\n element._store = {}; // To make comparing ReactElements easier for testing purposes, we make\n // the validation flag non-enumerable (where possible, which should\n // include every environment we run tests in), so the test framework\n // ignores it.\n\n Object.defineProperty(element._store, 'validated', {\n configurable: false,\n enumerable: false,\n writable: true,\n value: false\n }); // self and source are DEV only properties.\n\n Object.defineProperty(element, '_self', {\n configurable: false,\n enumerable: false,\n writable: false,\n value: self\n }); // Two elements created in two different places should be considered\n // equal for testing purposes and therefore we hide it from enumeration.\n\n Object.defineProperty(element, '_source', {\n configurable: false,\n enumerable: false,\n writable: false,\n value: source\n });\n\n if (Object.freeze) {\n Object.freeze(element.props);\n Object.freeze(element);\n }\n }\n\n return element;\n};\n/**\n * https://github.com/reactjs/rfcs/pull/107\n * @param {*} type\n * @param {object} props\n * @param {string} key\n */\n\nfunction jsxDEV(type, config, maybeKey, source, self) {\n {\n var propName; // Reserved names are extracted\n\n var props = {};\n var key = null;\n var ref = null; // Currently, key can be spread in as a prop. This causes a potential\n // issue if key is also explicitly declared (ie.
\n // or
). We want to deprecate key spread,\n // but as an intermediary step, we will use jsxDEV for everything except\n //
, because we aren't currently able to tell if\n // key is explicitly declared to be undefined or not.\n\n if (maybeKey !== undefined) {\n {\n checkKeyStringCoercion(maybeKey);\n }\n\n key = '' + maybeKey;\n }\n\n if (hasValidKey(config)) {\n {\n checkKeyStringCoercion(config.key);\n }\n\n key = '' + config.key;\n }\n\n if (hasValidRef(config)) {\n ref = config.ref;\n warnIfStringRefCannotBeAutoConverted(config, self);\n } // Remaining properties are added to a new props object\n\n\n for (propName in config) {\n if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {\n props[propName] = config[propName];\n }\n } // Resolve default props\n\n\n if (type && type.defaultProps) {\n var defaultProps = type.defaultProps;\n\n for (propName in defaultProps) {\n if (props[propName] === undefined) {\n props[propName] = defaultProps[propName];\n }\n }\n }\n\n if (key || ref) {\n var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;\n\n if (key) {\n defineKeyPropWarningGetter(props, displayName);\n }\n\n if (ref) {\n defineRefPropWarningGetter(props, displayName);\n }\n }\n\n return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);\n }\n}\n\nvar ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;\nvar ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;\n\nfunction setCurrentlyValidatingElement$1(element) {\n {\n if (element) {\n var owner = element._owner;\n var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);\n ReactDebugCurrentFrame$1.setExtraStackFrame(stack);\n } else {\n ReactDebugCurrentFrame$1.setExtraStackFrame(null);\n }\n }\n}\n\nvar propTypesMisspellWarningShown;\n\n{\n propTypesMisspellWarningShown = false;\n}\n/**\n * Verifies the object is a ReactElement.\n * See https://reactjs.org/docs/react-api.html#isvalidelement\n * @param {?object} object\n * @return {boolean} True if `object` is a ReactElement.\n * @final\n */\n\n\nfunction isValidElement(object) {\n {\n return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;\n }\n}\n\nfunction getDeclarationErrorAddendum() {\n {\n if (ReactCurrentOwner$1.current) {\n var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);\n\n if (name) {\n return '\\n\\nCheck the render method of `' + name + '`.';\n }\n }\n\n return '';\n }\n}\n\nfunction getSourceInfoErrorAddendum(source) {\n {\n if (source !== undefined) {\n var fileName = source.fileName.replace(/^.*[\\\\\\/]/, '');\n var lineNumber = source.lineNumber;\n return '\\n\\nCheck your code at ' + fileName + ':' + lineNumber + '.';\n }\n\n return '';\n }\n}\n/**\n * Warn if there's no key explicitly set on dynamic arrays of children or\n * object keys are not valid. This allows us to keep track of children between\n * updates.\n */\n\n\nvar ownerHasKeyUseWarning = {};\n\nfunction getCurrentComponentErrorInfo(parentType) {\n {\n var info = getDeclarationErrorAddendum();\n\n if (!info) {\n var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;\n\n if (parentName) {\n info = \"\\n\\nCheck the top-level render call using <\" + parentName + \">.\";\n }\n }\n\n return info;\n }\n}\n/**\n * Warn if the element doesn't have an explicit key assigned to it.\n * This element is in an array. The array could grow and shrink or be\n * reordered. All children that haven't already been validated are required to\n * have a \"key\" property assigned to it. Error statuses are cached so a warning\n * will only be shown once.\n *\n * @internal\n * @param {ReactElement} element Element that requires a key.\n * @param {*} parentType element's parent's type.\n */\n\n\nfunction validateExplicitKey(element, parentType) {\n {\n if (!element._store || element._store.validated || element.key != null) {\n return;\n }\n\n element._store.validated = true;\n var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);\n\n if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {\n return;\n }\n\n ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a\n // property, it may be the creator of the child that's responsible for\n // assigning it a key.\n\n var childOwner = '';\n\n if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {\n // Give the component that originally created this child.\n childOwner = \" It was passed a child from \" + getComponentNameFromType(element._owner.type) + \".\";\n }\n\n setCurrentlyValidatingElement$1(element);\n\n error('Each child in a list should have a unique \"key\" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);\n\n setCurrentlyValidatingElement$1(null);\n }\n}\n/**\n * Ensure that every element either is passed in a static location, in an\n * array with an explicit keys property defined, or in an object literal\n * with valid key property.\n *\n * @internal\n * @param {ReactNode} node Statically passed child of any type.\n * @param {*} parentType node's parent's type.\n */\n\n\nfunction validateChildKeys(node, parentType) {\n {\n if (typeof node !== 'object') {\n return;\n }\n\n if (isArray(node)) {\n for (var i = 0; i < node.length; i++) {\n var child = node[i];\n\n if (isValidElement(child)) {\n validateExplicitKey(child, parentType);\n }\n }\n } else if (isValidElement(node)) {\n // This element was passed in a valid location.\n if (node._store) {\n node._store.validated = true;\n }\n } else if (node) {\n var iteratorFn = getIteratorFn(node);\n\n if (typeof iteratorFn === 'function') {\n // Entry iterators used to provide implicit keys,\n // but now we print a separate warning for them later.\n if (iteratorFn !== node.entries) {\n var iterator = iteratorFn.call(node);\n var step;\n\n while (!(step = iterator.next()).done) {\n if (isValidElement(step.value)) {\n validateExplicitKey(step.value, parentType);\n }\n }\n }\n }\n }\n }\n}\n/**\n * Given an element, validate that its props follow the propTypes definition,\n * provided by the type.\n *\n * @param {ReactElement} element\n */\n\n\nfunction validatePropTypes(element) {\n {\n var type = element.type;\n\n if (type === null || type === undefined || typeof type === 'string') {\n return;\n }\n\n var propTypes;\n\n if (typeof type === 'function') {\n propTypes = type.propTypes;\n } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.\n // Inner props are checked in the reconciler.\n type.$$typeof === REACT_MEMO_TYPE)) {\n propTypes = type.propTypes;\n } else {\n return;\n }\n\n if (propTypes) {\n // Intentionally inside to avoid triggering lazy initializers:\n var name = getComponentNameFromType(type);\n checkPropTypes(propTypes, element.props, 'prop', name, element);\n } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {\n propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:\n\n var _name = getComponentNameFromType(type);\n\n error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');\n }\n\n if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {\n error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');\n }\n }\n}\n/**\n * Given a fragment, validate that it can only be provided with fragment props\n * @param {ReactElement} fragment\n */\n\n\nfunction validateFragmentProps(fragment) {\n {\n var keys = Object.keys(fragment.props);\n\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n\n if (key !== 'children' && key !== 'key') {\n setCurrentlyValidatingElement$1(fragment);\n\n error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);\n\n setCurrentlyValidatingElement$1(null);\n break;\n }\n }\n\n if (fragment.ref !== null) {\n setCurrentlyValidatingElement$1(fragment);\n\n error('Invalid attribute `ref` supplied to `React.Fragment`.');\n\n setCurrentlyValidatingElement$1(null);\n }\n }\n}\n\nvar didWarnAboutKeySpread = {};\nfunction jsxWithValidation(type, props, key, isStaticChildren, source, self) {\n {\n var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to\n // succeed and there will likely be errors in render.\n\n if (!validType) {\n var info = '';\n\n if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {\n info += ' You likely forgot to export your component from the file ' + \"it's defined in, or you might have mixed up default and named imports.\";\n }\n\n var sourceInfo = getSourceInfoErrorAddendum(source);\n\n if (sourceInfo) {\n info += sourceInfo;\n } else {\n info += getDeclarationErrorAddendum();\n }\n\n var typeString;\n\n if (type === null) {\n typeString = 'null';\n } else if (isArray(type)) {\n typeString = 'array';\n } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {\n typeString = \"<\" + (getComponentNameFromType(type.type) || 'Unknown') + \" />\";\n info = ' Did you accidentally export a JSX literal instead of a component?';\n } else {\n typeString = typeof type;\n }\n\n error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);\n }\n\n var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.\n // TODO: Drop this when these are no longer allowed as the type argument.\n\n if (element == null) {\n return element;\n } // Skip key warning if the type isn't valid since our key validation logic\n // doesn't expect a non-string/function type and can throw confusing errors.\n // We don't want exception behavior to differ between dev and prod.\n // (Rendering will throw with a helpful message and as soon as the type is\n // fixed, the key warnings will appear.)\n\n\n if (validType) {\n var children = props.children;\n\n if (children !== undefined) {\n if (isStaticChildren) {\n if (isArray(children)) {\n for (var i = 0; i < children.length; i++) {\n validateChildKeys(children[i], type);\n }\n\n if (Object.freeze) {\n Object.freeze(children);\n }\n } else {\n error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');\n }\n } else {\n validateChildKeys(children, type);\n }\n }\n }\n\n {\n if (hasOwnProperty.call(props, 'key')) {\n var componentName = getComponentNameFromType(type);\n var keys = Object.keys(props).filter(function (k) {\n return k !== 'key';\n });\n var beforeExample = keys.length > 0 ? '{key: someKey, ' + keys.join(': ..., ') + ': ...}' : '{key: someKey}';\n\n if (!didWarnAboutKeySpread[componentName + beforeExample]) {\n var afterExample = keys.length > 0 ? '{' + keys.join(': ..., ') + ': ...}' : '{}';\n\n error('A props object containing a \"key\" prop is being spread into JSX:\\n' + ' let props = %s;\\n' + ' <%s {...props} />\\n' + 'React keys must be passed directly to JSX without using spread:\\n' + ' let props = %s;\\n' + ' <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName);\n\n didWarnAboutKeySpread[componentName + beforeExample] = true;\n }\n }\n }\n\n if (type === REACT_FRAGMENT_TYPE) {\n validateFragmentProps(element);\n } else {\n validatePropTypes(element);\n }\n\n return element;\n }\n} // These two functions exist to still get child warnings in dev\n// even with the prod transform. This means that jsxDEV is purely\n// opt-in behavior for better messages but that we won't stop\n// giving you warnings if you use production apis.\n\nfunction jsxWithValidationStatic(type, props, key) {\n {\n return jsxWithValidation(type, props, key, true);\n }\n}\nfunction jsxWithValidationDynamic(type, props, key) {\n {\n return jsxWithValidation(type, props, key, false);\n }\n}\n\nvar jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children.\n// for now we can ship identical prod functions\n\nvar jsxs = jsxWithValidationStatic ;\n\nexports.Fragment = REACT_FRAGMENT_TYPE;\nexports.jsx = jsx;\nexports.jsxs = jsxs;\n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-jsx-runtime.production.min.js');\n} else {\n module.exports = require('./cjs/react-jsx-runtime.development.js');\n}\n","/**\n * @license React\n * scheduler.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n\n 'use strict';\n\n/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());\n}\n var enableSchedulerDebugging = false;\nvar enableProfiling = false;\nvar frameYieldMs = 5;\n\nfunction push(heap, node) {\n var index = heap.length;\n heap.push(node);\n siftUp(heap, node, index);\n}\nfunction peek(heap) {\n return heap.length === 0 ? null : heap[0];\n}\nfunction pop(heap) {\n if (heap.length === 0) {\n return null;\n }\n\n var first = heap[0];\n var last = heap.pop();\n\n if (last !== first) {\n heap[0] = last;\n siftDown(heap, last, 0);\n }\n\n return first;\n}\n\nfunction siftUp(heap, node, i) {\n var index = i;\n\n while (index > 0) {\n var parentIndex = index - 1 >>> 1;\n var parent = heap[parentIndex];\n\n if (compare(parent, node) > 0) {\n // The parent is larger. Swap positions.\n heap[parentIndex] = node;\n heap[index] = parent;\n index = parentIndex;\n } else {\n // The parent is smaller. Exit.\n return;\n }\n }\n}\n\nfunction siftDown(heap, node, i) {\n var index = i;\n var length = heap.length;\n var halfLength = length >>> 1;\n\n while (index < halfLength) {\n var leftIndex = (index + 1) * 2 - 1;\n var left = heap[leftIndex];\n var rightIndex = leftIndex + 1;\n var right = heap[rightIndex]; // If the left or right node is smaller, swap with the smaller of those.\n\n if (compare(left, node) < 0) {\n if (rightIndex < length && compare(right, left) < 0) {\n heap[index] = right;\n heap[rightIndex] = node;\n index = rightIndex;\n } else {\n heap[index] = left;\n heap[leftIndex] = node;\n index = leftIndex;\n }\n } else if (rightIndex < length && compare(right, node) < 0) {\n heap[index] = right;\n heap[rightIndex] = node;\n index = rightIndex;\n } else {\n // Neither child is smaller. Exit.\n return;\n }\n }\n}\n\nfunction compare(a, b) {\n // Compare sort index first, then task id.\n var diff = a.sortIndex - b.sortIndex;\n return diff !== 0 ? diff : a.id - b.id;\n}\n\n// TODO: Use symbols?\nvar ImmediatePriority = 1;\nvar UserBlockingPriority = 2;\nvar NormalPriority = 3;\nvar LowPriority = 4;\nvar IdlePriority = 5;\n\nfunction markTaskErrored(task, ms) {\n}\n\n/* eslint-disable no-var */\n\nvar hasPerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';\n\nif (hasPerformanceNow) {\n var localPerformance = performance;\n\n exports.unstable_now = function () {\n return localPerformance.now();\n };\n} else {\n var localDate = Date;\n var initialTime = localDate.now();\n\n exports.unstable_now = function () {\n return localDate.now() - initialTime;\n };\n} // Max 31 bit integer. The max integer size in V8 for 32-bit systems.\n// Math.pow(2, 30) - 1\n// 0b111111111111111111111111111111\n\n\nvar maxSigned31BitInt = 1073741823; // Times out immediately\n\nvar IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out\n\nvar USER_BLOCKING_PRIORITY_TIMEOUT = 250;\nvar NORMAL_PRIORITY_TIMEOUT = 5000;\nvar LOW_PRIORITY_TIMEOUT = 10000; // Never times out\n\nvar IDLE_PRIORITY_TIMEOUT = maxSigned31BitInt; // Tasks are stored on a min heap\n\nvar taskQueue = [];\nvar timerQueue = []; // Incrementing id counter. Used to maintain insertion order.\n\nvar taskIdCounter = 1; // Pausing the scheduler is useful for debugging.\nvar currentTask = null;\nvar currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrance.\n\nvar isPerformingWork = false;\nvar isHostCallbackScheduled = false;\nvar isHostTimeoutScheduled = false; // Capture local references to native APIs, in case a polyfill overrides them.\n\nvar localSetTimeout = typeof setTimeout === 'function' ? setTimeout : null;\nvar localClearTimeout = typeof clearTimeout === 'function' ? clearTimeout : null;\nvar localSetImmediate = typeof setImmediate !== 'undefined' ? setImmediate : null; // IE and Node.js + jsdom\n\nvar isInputPending = typeof navigator !== 'undefined' && navigator.scheduling !== undefined && navigator.scheduling.isInputPending !== undefined ? navigator.scheduling.isInputPending.bind(navigator.scheduling) : null;\n\nfunction advanceTimers(currentTime) {\n // Check for tasks that are no longer delayed and add them to the queue.\n var timer = peek(timerQueue);\n\n while (timer !== null) {\n if (timer.callback === null) {\n // Timer was cancelled.\n pop(timerQueue);\n } else if (timer.startTime <= currentTime) {\n // Timer fired. Transfer to the task queue.\n pop(timerQueue);\n timer.sortIndex = timer.expirationTime;\n push(taskQueue, timer);\n } else {\n // Remaining timers are pending.\n return;\n }\n\n timer = peek(timerQueue);\n }\n}\n\nfunction handleTimeout(currentTime) {\n isHostTimeoutScheduled = false;\n advanceTimers(currentTime);\n\n if (!isHostCallbackScheduled) {\n if (peek(taskQueue) !== null) {\n isHostCallbackScheduled = true;\n requestHostCallback(flushWork);\n } else {\n var firstTimer = peek(timerQueue);\n\n if (firstTimer !== null) {\n requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);\n }\n }\n }\n}\n\nfunction flushWork(hasTimeRemaining, initialTime) {\n\n\n isHostCallbackScheduled = false;\n\n if (isHostTimeoutScheduled) {\n // We scheduled a timeout but it's no longer needed. Cancel it.\n isHostTimeoutScheduled = false;\n cancelHostTimeout();\n }\n\n isPerformingWork = true;\n var previousPriorityLevel = currentPriorityLevel;\n\n try {\n if (enableProfiling) {\n try {\n return workLoop(hasTimeRemaining, initialTime);\n } catch (error) {\n if (currentTask !== null) {\n var currentTime = exports.unstable_now();\n markTaskErrored(currentTask, currentTime);\n currentTask.isQueued = false;\n }\n\n throw error;\n }\n } else {\n // No catch in prod code path.\n return workLoop(hasTimeRemaining, initialTime);\n }\n } finally {\n currentTask = null;\n currentPriorityLevel = previousPriorityLevel;\n isPerformingWork = false;\n }\n}\n\nfunction workLoop(hasTimeRemaining, initialTime) {\n var currentTime = initialTime;\n advanceTimers(currentTime);\n currentTask = peek(taskQueue);\n\n while (currentTask !== null && !(enableSchedulerDebugging )) {\n if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) {\n // This currentTask hasn't expired, and we've reached the deadline.\n break;\n }\n\n var callback = currentTask.callback;\n\n if (typeof callback === 'function') {\n currentTask.callback = null;\n currentPriorityLevel = currentTask.priorityLevel;\n var didUserCallbackTimeout = currentTask.expirationTime <= currentTime;\n\n var continuationCallback = callback(didUserCallbackTimeout);\n currentTime = exports.unstable_now();\n\n if (typeof continuationCallback === 'function') {\n currentTask.callback = continuationCallback;\n } else {\n\n if (currentTask === peek(taskQueue)) {\n pop(taskQueue);\n }\n }\n\n advanceTimers(currentTime);\n } else {\n pop(taskQueue);\n }\n\n currentTask = peek(taskQueue);\n } // Return whether there's additional work\n\n\n if (currentTask !== null) {\n return true;\n } else {\n var firstTimer = peek(timerQueue);\n\n if (firstTimer !== null) {\n requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);\n }\n\n return false;\n }\n}\n\nfunction unstable_runWithPriority(priorityLevel, eventHandler) {\n switch (priorityLevel) {\n case ImmediatePriority:\n case UserBlockingPriority:\n case NormalPriority:\n case LowPriority:\n case IdlePriority:\n break;\n\n default:\n priorityLevel = NormalPriority;\n }\n\n var previousPriorityLevel = currentPriorityLevel;\n currentPriorityLevel = priorityLevel;\n\n try {\n return eventHandler();\n } finally {\n currentPriorityLevel = previousPriorityLevel;\n }\n}\n\nfunction unstable_next(eventHandler) {\n var priorityLevel;\n\n switch (currentPriorityLevel) {\n case ImmediatePriority:\n case UserBlockingPriority:\n case NormalPriority:\n // Shift down to normal priority\n priorityLevel = NormalPriority;\n break;\n\n default:\n // Anything lower than normal priority should remain at the current level.\n priorityLevel = currentPriorityLevel;\n break;\n }\n\n var previousPriorityLevel = currentPriorityLevel;\n currentPriorityLevel = priorityLevel;\n\n try {\n return eventHandler();\n } finally {\n currentPriorityLevel = previousPriorityLevel;\n }\n}\n\nfunction unstable_wrapCallback(callback) {\n var parentPriorityLevel = currentPriorityLevel;\n return function () {\n // This is a fork of runWithPriority, inlined for performance.\n var previousPriorityLevel = currentPriorityLevel;\n currentPriorityLevel = parentPriorityLevel;\n\n try {\n return callback.apply(this, arguments);\n } finally {\n currentPriorityLevel = previousPriorityLevel;\n }\n };\n}\n\nfunction unstable_scheduleCallback(priorityLevel, callback, options) {\n var currentTime = exports.unstable_now();\n var startTime;\n\n if (typeof options === 'object' && options !== null) {\n var delay = options.delay;\n\n if (typeof delay === 'number' && delay > 0) {\n startTime = currentTime + delay;\n } else {\n startTime = currentTime;\n }\n } else {\n startTime = currentTime;\n }\n\n var timeout;\n\n switch (priorityLevel) {\n case ImmediatePriority:\n timeout = IMMEDIATE_PRIORITY_TIMEOUT;\n break;\n\n case UserBlockingPriority:\n timeout = USER_BLOCKING_PRIORITY_TIMEOUT;\n break;\n\n case IdlePriority:\n timeout = IDLE_PRIORITY_TIMEOUT;\n break;\n\n case LowPriority:\n timeout = LOW_PRIORITY_TIMEOUT;\n break;\n\n case NormalPriority:\n default:\n timeout = NORMAL_PRIORITY_TIMEOUT;\n break;\n }\n\n var expirationTime = startTime + timeout;\n var newTask = {\n id: taskIdCounter++,\n callback: callback,\n priorityLevel: priorityLevel,\n startTime: startTime,\n expirationTime: expirationTime,\n sortIndex: -1\n };\n\n if (startTime > currentTime) {\n // This is a delayed task.\n newTask.sortIndex = startTime;\n push(timerQueue, newTask);\n\n if (peek(taskQueue) === null && newTask === peek(timerQueue)) {\n // All tasks are delayed, and this is the task with the earliest delay.\n if (isHostTimeoutScheduled) {\n // Cancel an existing timeout.\n cancelHostTimeout();\n } else {\n isHostTimeoutScheduled = true;\n } // Schedule a timeout.\n\n\n requestHostTimeout(handleTimeout, startTime - currentTime);\n }\n } else {\n newTask.sortIndex = expirationTime;\n push(taskQueue, newTask);\n // wait until the next time we yield.\n\n\n if (!isHostCallbackScheduled && !isPerformingWork) {\n isHostCallbackScheduled = true;\n requestHostCallback(flushWork);\n }\n }\n\n return newTask;\n}\n\nfunction unstable_pauseExecution() {\n}\n\nfunction unstable_continueExecution() {\n\n if (!isHostCallbackScheduled && !isPerformingWork) {\n isHostCallbackScheduled = true;\n requestHostCallback(flushWork);\n }\n}\n\nfunction unstable_getFirstCallbackNode() {\n return peek(taskQueue);\n}\n\nfunction unstable_cancelCallback(task) {\n // remove from the queue because you can't remove arbitrary nodes from an\n // array based heap, only the first one.)\n\n\n task.callback = null;\n}\n\nfunction unstable_getCurrentPriorityLevel() {\n return currentPriorityLevel;\n}\n\nvar isMessageLoopRunning = false;\nvar scheduledHostCallback = null;\nvar taskTimeoutID = -1; // Scheduler periodically yields in case there is other work on the main\n// thread, like user events. By default, it yields multiple times per frame.\n// It does not attempt to align with frame boundaries, since most tasks don't\n// need to be frame aligned; for those that do, use requestAnimationFrame.\n\nvar frameInterval = frameYieldMs;\nvar startTime = -1;\n\nfunction shouldYieldToHost() {\n var timeElapsed = exports.unstable_now() - startTime;\n\n if (timeElapsed < frameInterval) {\n // The main thread has only been blocked for a really short amount of time;\n // smaller than a single frame. Don't yield yet.\n return false;\n } // The main thread has been blocked for a non-negligible amount of time. We\n\n\n return true;\n}\n\nfunction requestPaint() {\n\n}\n\nfunction forceFrameRate(fps) {\n if (fps < 0 || fps > 125) {\n // Using console['error'] to evade Babel and ESLint\n console['error']('forceFrameRate takes a positive int between 0 and 125, ' + 'forcing frame rates higher than 125 fps is not supported');\n return;\n }\n\n if (fps > 0) {\n frameInterval = Math.floor(1000 / fps);\n } else {\n // reset the framerate\n frameInterval = frameYieldMs;\n }\n}\n\nvar performWorkUntilDeadline = function () {\n if (scheduledHostCallback !== null) {\n var currentTime = exports.unstable_now(); // Keep track of the start time so we can measure how long the main thread\n // has been blocked.\n\n startTime = currentTime;\n var hasTimeRemaining = true; // If a scheduler task throws, exit the current browser task so the\n // error can be observed.\n //\n // Intentionally not using a try-catch, since that makes some debugging\n // techniques harder. Instead, if `scheduledHostCallback` errors, then\n // `hasMoreWork` will remain true, and we'll continue the work loop.\n\n var hasMoreWork = true;\n\n try {\n hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime);\n } finally {\n if (hasMoreWork) {\n // If there's more work, schedule the next message event at the end\n // of the preceding one.\n schedulePerformWorkUntilDeadline();\n } else {\n isMessageLoopRunning = false;\n scheduledHostCallback = null;\n }\n }\n } else {\n isMessageLoopRunning = false;\n } // Yielding to the browser will give it a chance to paint, so we can\n};\n\nvar schedulePerformWorkUntilDeadline;\n\nif (typeof localSetImmediate === 'function') {\n // Node.js and old IE.\n // There's a few reasons for why we prefer setImmediate.\n //\n // Unlike MessageChannel, it doesn't prevent a Node.js process from exiting.\n // (Even though this is a DOM fork of the Scheduler, you could get here\n // with a mix of Node.js 15+, which has a MessageChannel, and jsdom.)\n // https://github.com/facebook/react/issues/20756\n //\n // But also, it runs earlier which is the semantic we want.\n // If other browsers ever implement it, it's better to use it.\n // Although both of these would be inferior to native scheduling.\n schedulePerformWorkUntilDeadline = function () {\n localSetImmediate(performWorkUntilDeadline);\n };\n} else if (typeof MessageChannel !== 'undefined') {\n // DOM and Worker environments.\n // We prefer MessageChannel because of the 4ms setTimeout clamping.\n var channel = new MessageChannel();\n var port = channel.port2;\n channel.port1.onmessage = performWorkUntilDeadline;\n\n schedulePerformWorkUntilDeadline = function () {\n port.postMessage(null);\n };\n} else {\n // We should only fallback here in non-browser environments.\n schedulePerformWorkUntilDeadline = function () {\n localSetTimeout(performWorkUntilDeadline, 0);\n };\n}\n\nfunction requestHostCallback(callback) {\n scheduledHostCallback = callback;\n\n if (!isMessageLoopRunning) {\n isMessageLoopRunning = true;\n schedulePerformWorkUntilDeadline();\n }\n}\n\nfunction requestHostTimeout(callback, ms) {\n taskTimeoutID = localSetTimeout(function () {\n callback(exports.unstable_now());\n }, ms);\n}\n\nfunction cancelHostTimeout() {\n localClearTimeout(taskTimeoutID);\n taskTimeoutID = -1;\n}\n\nvar unstable_requestPaint = requestPaint;\nvar unstable_Profiling = null;\n\nexports.unstable_IdlePriority = IdlePriority;\nexports.unstable_ImmediatePriority = ImmediatePriority;\nexports.unstable_LowPriority = LowPriority;\nexports.unstable_NormalPriority = NormalPriority;\nexports.unstable_Profiling = unstable_Profiling;\nexports.unstable_UserBlockingPriority = UserBlockingPriority;\nexports.unstable_cancelCallback = unstable_cancelCallback;\nexports.unstable_continueExecution = unstable_continueExecution;\nexports.unstable_forceFrameRate = forceFrameRate;\nexports.unstable_getCurrentPriorityLevel = unstable_getCurrentPriorityLevel;\nexports.unstable_getFirstCallbackNode = unstable_getFirstCallbackNode;\nexports.unstable_next = unstable_next;\nexports.unstable_pauseExecution = unstable_pauseExecution;\nexports.unstable_requestPaint = unstable_requestPaint;\nexports.unstable_runWithPriority = unstable_runWithPriority;\nexports.unstable_scheduleCallback = unstable_scheduleCallback;\nexports.unstable_shouldYield = shouldYieldToHost;\nexports.unstable_wrapCallback = unstable_wrapCallback;\n /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());\n}\n \n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/scheduler.production.min.js');\n} else {\n module.exports = require('./cjs/scheduler.development.js');\n}\n","/**\n * @license React\n * react-dom.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n\n 'use strict';\n\n/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());\n}\n var React = require('react');\nvar Scheduler = require('scheduler');\n\nvar ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n\nvar suppressWarning = false;\nfunction setSuppressWarning(newSuppressWarning) {\n {\n suppressWarning = newSuppressWarning;\n }\n} // In DEV, calls to console.warn and console.error get replaced\n// by calls to these methods by a Babel plugin.\n//\n// In PROD (or in packages without access to React internals),\n// they are left as they are instead.\n\nfunction warn(format) {\n {\n if (!suppressWarning) {\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n printWarning('warn', format, args);\n }\n }\n}\nfunction error(format) {\n {\n if (!suppressWarning) {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n\n printWarning('error', format, args);\n }\n }\n}\n\nfunction printWarning(level, format, args) {\n // When changing this logic, you might want to also\n // update consoleWithStackDev.www.js as well.\n {\n var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;\n var stack = ReactDebugCurrentFrame.getStackAddendum();\n\n if (stack !== '') {\n format += '%s';\n args = args.concat([stack]);\n } // eslint-disable-next-line react-internal/safe-string-coercion\n\n\n var argsWithFormat = args.map(function (item) {\n return String(item);\n }); // Careful: RN currently depends on this prefix\n\n argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it\n // breaks IE9: https://github.com/facebook/react/issues/13610\n // eslint-disable-next-line react-internal/no-production-logging\n\n Function.prototype.apply.call(console[level], console, argsWithFormat);\n }\n}\n\nvar FunctionComponent = 0;\nvar ClassComponent = 1;\nvar IndeterminateComponent = 2; // Before we know whether it is function or class\n\nvar HostRoot = 3; // Root of a host tree. Could be nested inside another node.\n\nvar HostPortal = 4; // A subtree. Could be an entry point to a different renderer.\n\nvar HostComponent = 5;\nvar HostText = 6;\nvar Fragment = 7;\nvar Mode = 8;\nvar ContextConsumer = 9;\nvar ContextProvider = 10;\nvar ForwardRef = 11;\nvar Profiler = 12;\nvar SuspenseComponent = 13;\nvar MemoComponent = 14;\nvar SimpleMemoComponent = 15;\nvar LazyComponent = 16;\nvar IncompleteClassComponent = 17;\nvar DehydratedFragment = 18;\nvar SuspenseListComponent = 19;\nvar ScopeComponent = 21;\nvar OffscreenComponent = 22;\nvar LegacyHiddenComponent = 23;\nvar CacheComponent = 24;\nvar TracingMarkerComponent = 25;\n\n// -----------------------------------------------------------------------------\n\nvar enableClientRenderFallbackOnTextMismatch = true; // TODO: Need to review this code one more time before landing\n// the react-reconciler package.\n\nvar enableNewReconciler = false; // Support legacy Primer support on internal FB www\n\nvar enableLazyContextPropagation = false; // FB-only usage. The new API has different semantics.\n\nvar enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber\n\nvar enableSuspenseAvoidThisFallback = false; // Enables unstable_avoidThisFallback feature in Fizz\n// React DOM Chopping Block\n//\n// Similar to main Chopping Block but only flags related to React DOM. These are\n// grouped because we will likely batch all of them into a single major release.\n// -----------------------------------------------------------------------------\n// Disable support for comment nodes as React DOM containers. Already disabled\n// in open source, but www codebase still relies on it. Need to remove.\n\nvar disableCommentsAsDOMContainers = true; // Disable javascript: URL strings in href for XSS protection.\n// and client rendering, mostly to allow JSX attributes to apply to the custom\n// element's object properties instead of only HTML attributes.\n// https://github.com/facebook/react/issues/11347\n\nvar enableCustomElementPropertySupport = false; // Disables children for