@cyca/react-timeline-editor 0.2.4-alpha.5 → 0.2.5-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,1597 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("react"),D=require("./index-6kJWhJ-8.cjs"),gr=require("react-dom");function vr(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const v=vr(M);var Ft={exports:{}},Mt={};var mn;function br(){if(mn)return Mt;mn=1;var n=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(r,s,o){var i=null;if(o!==void 0&&(i=""+o),s.key!==void 0&&(i=""+s.key),"key"in s){o={};for(var a in s)a!=="key"&&(o[a]=s[a])}else o=s;return s=o.ref,{$$typeof:n,type:r,key:i,ref:s!==void 0?s:null,props:o}}return Mt.Fragment=e,Mt.jsx=t,Mt.jsxs=t,Mt}var It={};var pn;function Sr(){return pn||(pn=1,process.env.NODE_ENV!=="production"&&(function(){function n(d){if(d==null)return null;if(typeof d=="function")return d.$$typeof===W?null:d.displayName||d.name||null;if(typeof d=="string")return d;switch(d){case w:return"Fragment";case b:return"Profiler";case T:return"StrictMode";case _:return"Suspense";case P:return"SuspenseList";case E:return"Activity"}if(typeof d=="object")switch(typeof d.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),d.$$typeof){case y:return"Portal";case m:return d.displayName||"Context";case g:return(d._context.displayName||"Context")+".Consumer";case R:var x=d.render;return d=d.displayName,d||(d=x.displayName||x.name||"",d=d!==""?"ForwardRef("+d+")":"ForwardRef"),d;case O:return x=d.displayName||null,x!==null?x:n(d.type)||"Memo";case C:x=d._payload,d=d._init;try{return n(d(x))}catch{}}return null}function e(d){return""+d}function t(d){try{e(d);var x=!1}catch{x=!0}if(x){x=console;var L=x.error,F=typeof Symbol=="function"&&Symbol.toStringTag&&d[Symbol.toStringTag]||d.constructor.name||"Object";return L.call(x,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",F),e(d)}}function r(d){if(d===w)return"<>";if(typeof d=="object"&&d!==null&&d.$$typeof===C)return"<...>";try{var x=n(d);return x?"<"+x+">":"<...>"}catch{return"<...>"}}function s(){var d=G.A;return d===null?null:d.getOwner()}function o(){return Error("react-stack-top-frame")}function i(d){if(Z.call(d,"key")){var x=Object.getOwnPropertyDescriptor(d,"key").get;if(x&&x.isReactWarning)return!1}return d.key!==void 0}function a(d,x){function L(){k||(k=!0,console.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://react.dev/link/special-props)",x))}L.isReactWarning=!0,Object.defineProperty(d,"key",{get:L,configurable:!0})}function c(){var d=n(this.type);return K[d]||(K[d]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),d=this.props.ref,d!==void 0?d:null}function u(d,x,L,F,me,ge){var X=L.ref;return d={$$typeof:S,type:d,key:x,props:L,_owner:F},(X!==void 0?X:null)!==null?Object.defineProperty(d,"ref",{enumerable:!1,get:c}):Object.defineProperty(d,"ref",{enumerable:!1,value:null}),d._store={},Object.defineProperty(d._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(d,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(d,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:me}),Object.defineProperty(d,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:ge}),Object.freeze&&(Object.freeze(d.props),Object.freeze(d)),d}function l(d,x,L,F,me,ge){var X=x.children;if(X!==void 0)if(F)if(Y(X)){for(F=0;F<X.length;F++)h(X[F]);Object.freeze&&Object.freeze(X)}else console.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.");else h(X);if(Z.call(x,"key")){X=n(d);var te=Object.keys(x).filter(function(se){return se!=="key"});F=0<te.length?"{key: someKey, "+te.join(": ..., ")+": ...}":"{key: someKey}",I[X+F]||(te=0<te.length?"{"+te.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
- let props = %s;
3
- <%s {...props} />
4
- React keys must be passed directly to JSX without using spread:
5
- let props = %s;
6
- <%s key={someKey} {...props} />`,F,X,te,X),I[X+F]=!0)}if(X=null,L!==void 0&&(t(L),X=""+L),i(x)&&(t(x.key),X=""+x.key),"key"in x){L={};for(var U in x)U!=="key"&&(L[U]=x[U])}else L=x;return X&&a(L,typeof d=="function"?d.displayName||d.name||"Unknown":d),u(d,X,L,s(),me,ge)}function h(d){f(d)?d._store&&(d._store.validated=1):typeof d=="object"&&d!==null&&d.$$typeof===C&&(d._payload.status==="fulfilled"?f(d._payload.value)&&d._payload.value._store&&(d._payload.value._store.validated=1):d._store&&(d._store.validated=1))}function f(d){return typeof d=="object"&&d!==null&&d.$$typeof===S}var p=M,S=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),b=Symbol.for("react.profiler"),g=Symbol.for("react.consumer"),m=Symbol.for("react.context"),R=Symbol.for("react.forward_ref"),_=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),E=Symbol.for("react.activity"),W=Symbol.for("react.client.reference"),G=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z=Object.prototype.hasOwnProperty,Y=Array.isArray,ie=console.createTask?console.createTask:function(){return null};p={react_stack_bottom_frame:function(d){return d()}};var k,K={},Q=p.react_stack_bottom_frame.bind(p,o)(),j=ie(r(o)),I={};It.Fragment=w,It.jsx=function(d,x,L){var F=1e4>G.recentlyCreatedOwnerStacks++;return l(d,x,L,!1,F?Error("react-stack-top-frame"):Q,F?ie(r(d)):j)},It.jsxs=function(d,x,L){var F=1e4>G.recentlyCreatedOwnerStacks++;return l(d,x,L,!0,F?Error("react-stack-top-frame"):Q,F?ie(r(d)):j)}})()),It}var gn;function _r(){return gn||(gn=1,process.env.NODE_ENV==="production"?Ft.exports=br():Ft.exports=Sr()),Ft.exports}var A=_r();const en={trace:0,debug:1,info:2,warn:3,error:4,silent:5},wr=["trace","debug","info","warn","error"];var Er=class Vn{s;ls=new Map;lvl;def;n;r;c=console;e;trace;debug;info;warn;error;constructor(e,t,r,s){this.s=e,this.e=t,this.n=r,this.r=s,this.bindMethods()}noop=()=>{};bindMethods(){wr.forEach(e=>{const t=this.e.bind(this.c,e,this.n);Object.defineProperty(this,e,{get:()=>en[e]>=en[this.currentLevel()]?t:this.noop,configurable:!0})})}storageKey(){return this.n?`loglevel:${String(this.n)}`:"loglevel"}currentLevel(){if(this.lvl)return this.lvl;const e=this.s.get(this.storageKey());return e&&e in en?(this.lvl=e,this.lvl):this.def?this.def:this.r?this.r.currentLevel():"trace"}setLevel(e){return this.lvl=e,this.s.set(this.storageKey(),e),this}setDefaultLevel(e){return this.s.get(this.storageKey())||(this.def=e),this}resetLevel(){return this.lvl=void 0,this.s.del(this.storageKey()),this}getLogger(e){if(!e)throw new Error("Logger name required");if(!this.ls.has(e)){const t=new Vn(this.s,this.e,e,this.r||this);this.ls.set(e,$n(t))}return this.ls.get(e)}getLoggers(){const e={};return this.ls.forEach((t,r)=>{e[String(r)]=t}),e}use(e){this.c=e,this.bindMethods()}};function $n(n){return new Proxy(n,{get(e,t,r){if(t in e)return Reflect.get(e,t,r);const s=e.c[t];return typeof s=="function"?s.bind(e.c):s}})}var yr=class{get(n){return localStorage.getItem(n)}set(n,e){localStorage.setItem(n,e)}del(n){localStorage.removeItem(n)}};const Tr={trace:"#95bdb7",debug:"#ad95b8",info:"#b6bd73",warn:"#88a1bb",error:"#bf6c69"},vn={info:"⚡️",success:"✔",warn:"▲",error:"✖",log:"●",trace:"◔",debug:"◌"},Rr={bind(n,e,t){const r=t?`${vn[e]} ${String(t)}:`:`${vn[e]}`;return(n[e]||n.log).bind(n,`%c${r}%c`,`color: ${Tr[e]}; font-weight: bold;`,"color: inherit")}},tt=$n(new Er(new yr,Rr));function xr(n){let{editorData:e=[],effects:t={},scale:r=D.DEFAULT_SCALE,scaleSplitCount:s=D.DEFAULT_SCALE_SPLIT_COUNT,scaleWidth:o=D.DEFAULT_SCALE_WIDTH,startLeft:i=D.DEFAULT_START_LEFT,minScaleCount:a,maxScaleCount:c=1/0,rowHeight:u=D.DEFAULT_ROW_HEIGHT,autoScrollSpeed:l=1,autoScrollMaxSpeed:h=10}=n;r<=0&&(tt.error("Error: scale must be greater than 0!"),r=D.DEFAULT_SCALE),s<=0&&(tt.warn("Warning: scaleSplitCount cannot be less than 1!"),s=1),o<=0&&(tt.warn("Warning: scaleWidth must be greater than 0!"),o=D.DEFAULT_SCALE_WIDTH),i<0&&(tt.warn("Warning: startLeft cannot be less than 0!"),i=0),a&&typeof a=="number"&&(a<1&&(tt.warn("Warning: minScaleCount must be greater than 1!"),a=D.MIN_SCALE_COUNT),a=parseInt(a+""),c<a&&(tt.warn("Warning: maxScaleCount cannot be less than minScaleCount!"),c=a)),c=c===1/0?1/0:parseInt(c+""),u<=0&&(tt.warn("Warning: rowHeight must be greater than 0!"),u=D.DEFAULT_ROW_HEIGHT);const f={...n};return delete f.style,{...f,editorData:e,effects:t,scale:r,scaleSplitCount:s,scaleWidth:o,startLeft:i,minScaleCount:a,maxScaleCount:c,rowHeight:u,autoScrollSpeed:l,autoScrollMaxSpeed:h}}var Ut={exports:{}},tn={};var bn;function Ar(){if(bn)return tn;bn=1;var n=M.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;return tn.c=function(e){return n.H.useMemoCache(e)},tn}var nn={};var Sn;function Cr(){return Sn||(Sn=1,process.env.NODE_ENV!=="production"&&(function(){var n=M.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;nn.c=function(e){var t=n.H;return t===null&&console.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:
7
- 1. You might have mismatching versions of React and the renderer (such as React DOM)
8
- 2. You might be breaking the Rules of Hooks
9
- 3. You might have more than one copy of React in the same app
10
- See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`),t.useMemoCache(e)}})()),nn}var _n;function Dr(){return _n||(_n=1,process.env.NODE_ENV==="production"?Ut.exports=Ar():Ut.exports=Cr()),Ut.exports}var De=Dr();function Pr(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];return e.map(function(r){return r.split(" ").map(function(s){return s?""+n+s:""}).join(" ")}).join(" ")}function ve(...n){return Pr(`${D.PREFIX}-`,...n)}const Lr=n=>{const e=De.c(11),{isMoving:t,movePositions:r,assistPositions:s}=n;let o,i;if(e[0]!==t||e[1]!==r||e[2]!==s){const c=r===void 0?[]:r;let u;e[5]!==s?(u=s===void 0?[]:s,e[5]=s,e[6]=u):u=e[6];const l=u;e[7]===Symbol.for("react.memo_cache_sentinel")?(o=ve("snap-line-container"),e[7]=o):o=e[7],i=t&&c.filter(h=>l.includes(h)).map(Or),e[0]=t,e[1]=r,e[2]=s,e[3]=o,e[4]=i}else o=e[3],i=e[4];let a;return e[8]!==o||e[9]!==i?(a=A.jsx("div",{className:o,children:i}),e[8]=o,e[9]=i,e[10]=a):a=e[10],a};function Or(n,e){return A.jsx("div",{className:ve("snap-line"),style:{left:n}},e)}const Mr=1,Ir=10,wn=10;function Nr(n,e,t){const r=De.c(15),s=e===void 0?Mr:e,o=t===void 0?Ir:t,i=M.useRef(Number.MIN_SAFE_INTEGER),a=M.useRef(Number.MAX_SAFE_INTEGER),c=M.useRef(s),u=M.useRef(void 0);let l;r[0]!==n?(l=()=>{if(n?.current){const{left:g,width:m}=n.current.getBoundingClientRect();i.current=g,a.current=g+m}},r[0]=n,r[1]=l):l=r[1];const h=l;let f;r[2]!==o||r[3]!==s?(f=(g,m)=>{if(g.clientX>=a.current||g.clientX<=i.current){u.current!==void 0&&cancelAnimationFrame(u.current);const R=Math.abs(g.clientX>=a.current?g.clientX-a.current:g.clientX-i.current);c.current=Math.min(Number((R/wn).toFixed(0))*s,o);const P=(g.clientX>=a.current?1:-1)*c.current,O=()=>{m&&m(P),u.current=requestAnimationFrame(O)};return u.current=requestAnimationFrame(O),!1}else u.current!==void 0&&cancelAnimationFrame(u.current);return!0},r[2]=o,r[3]=s,r[4]=f):f=r[4];const p=f;let S;r[5]!==o||r[6]!==s?(S=(g,m,R)=>{if(g.clientX>=a.current||g.clientX<i.current){u.current!==void 0&&cancelAnimationFrame(u.current);const _=Math.abs(g.clientX>=a.current?g.clientX-a.current:g.clientX-i.current);c.current=Math.min(Number((_/wn).toFixed(0))*s,o);const O=(g.clientX>=a.current?1:-1)*c.current,C=()=>{R&&R(O),u.current=requestAnimationFrame(C)};return u.current=requestAnimationFrame(C),!1}else u.current!==void 0&&cancelAnimationFrame(u.current);return!0},r[5]=o,r[6]=s,r[7]=S):S=r[7];const y=S;let w;r[8]!==s?(w=()=>{i.current=Number.MIN_SAFE_INTEGER,a.current=Number.MAX_SAFE_INTEGER,c.current=s,u.current!==void 0&&cancelAnimationFrame(u.current)},r[8]=s,r[9]=w):w=r[9];const T=w;let b;return r[10]!==p||r[11]!==y||r[12]!==h||r[13]!==T?(b={initAutoScroll:h,dealDragAutoScroll:p,dealResizeAutoScroll:y,stopAutoScroll:T},r[10]=p,r[11]=y,r[12]=h,r[13]=T,r[14]=b):b=r[14],b}function kr(n,e,t){return Math.max(e,Math.min(n,t))}const be={toVector(n,e){return n===void 0&&(n=e),Array.isArray(n)?n:[n,n]},add(n,e){return[n[0]+e[0],n[1]+e[1]]},sub(n,e){return[n[0]-e[0],n[1]-e[1]]},addTo(n,e){n[0]+=e[0],n[1]+=e[1]},subTo(n,e){n[0]-=e[0],n[1]-=e[1]}};function En(n,e,t){return e===0||Math.abs(e)===1/0?Math.pow(n,t*5):n*e*t/(e+t*n)}function yn(n,e,t,r=.15){return r===0?kr(n,e,t):n<e?-En(e-n,t-e,r)+e:n>t?+En(n-t,t-e,r)+t:n}function Wr(n,[e,t],[r,s]){const[[o,i],[a,c]]=n;return[yn(e,o,i,r),yn(t,a,c,s)]}function zr(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function jr(n){var e=zr(n,"string");return typeof e=="symbol"?e:String(e)}function Ee(n,e,t){return e=jr(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Tn(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable})),t.push.apply(t,r)}return t}function re(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Tn(Object(t),!0).forEach(function(r){Ee(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Tn(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}const Hn={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function Rn(n){return n?n[0].toUpperCase()+n.slice(1):""}const Fr=["enter","leave"];function Ur(n=!1,e){return n&&!Fr.includes(e)}function Vr(n,e="",t=!1){const r=Hn[n],s=r&&r[e]||e;return"on"+Rn(n)+Rn(s)+(Ur(t,s)?"Capture":"")}const $r=["gotpointercapture","lostpointercapture"];function Hr(n){let e=n.substring(2).toLowerCase();const t=!!~e.indexOf("passive");t&&(e=e.replace("passive",""));const r=$r.includes(e)?"capturecapture":"capture",s=!!~e.indexOf(r);return s&&(e=e.replace("capture","")),{device:e,capture:s,passive:t}}function Br(n,e=""){const t=Hn[n],r=t&&t[e]||e;return n+r}function Gt(n){return"touches"in n}function Bn(n){return Gt(n)?"touch":"pointerType"in n?n.pointerType:"mouse"}function Xr(n){return Array.from(n.touches).filter(e=>{var t,r;return e.target===n.currentTarget||((t=n.currentTarget)===null||t===void 0||(r=t.contains)===null||r===void 0?void 0:r.call(t,e.target))})}function Yr(n){return n.type==="touchend"||n.type==="touchcancel"?n.changedTouches:n.targetTouches}function Xn(n){return Gt(n)?Yr(n)[0]:n}function Kr(n){return Xr(n).map(e=>e.identifier)}function rn(n){const e=Xn(n);return Gt(n)?e.identifier:e.pointerId}function xn(n){const e=Xn(n);return[e.clientX,e.clientY]}function qr(n){const e={};if("buttons"in n&&(e.buttons=n.buttons),"shiftKey"in n){const{shiftKey:t,altKey:r,metaKey:s,ctrlKey:o}=n;Object.assign(e,{shiftKey:t,altKey:r,metaKey:s,ctrlKey:o})}return e}function Yt(n,...e){return typeof n=="function"?n(...e):n}function Gr(){}function Jr(...n){return n.length===0?Gr:n.length===1?n[0]:function(){let e;for(const t of n)e=t.apply(this,arguments)||e;return e}}function An(n,e){return Object.assign({},e,n||{})}const Zr=32;class Qr{constructor(e,t,r){this.ctrl=e,this.args=t,this.key=r,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:t,ingKey:r,args:s}=this;t[r]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=s,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const t=this.state,r=this.config;t._active||(this.reset(),this.computeInitial(),t._active=!0,t.target=e.target,t.currentTarget=e.currentTarget,t.lastOffset=r.from?Yt(r.from,t):t.offset,t.offset=t.lastOffset,t.startTime=t.timeStamp=e.timeStamp)}computeValues(e){const t=this.state;t._values=e,t.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:t,config:r,shared:s}=this;t.args=this.args;let o=0;if(e&&(t.event=e,r.preventDefault&&e.cancelable&&t.event.preventDefault(),t.type=e.type,s.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,s.locked=!!document.pointerLockElement,Object.assign(s,qr(e)),s.down=s.pressed=s.buttons%2===1||s.touches>0,o=e.timeStamp-t.timeStamp,t.timeStamp=e.timeStamp,t.elapsedTime=t.timeStamp-t.startTime),t._active){const _=t._delta.map(Math.abs);be.addTo(t._distance,_)}this.axisIntent&&this.axisIntent(e);const[i,a]=t._movement,[c,u]=r.threshold,{_step:l,values:h}=t;if(r.hasCustomTransform?(l[0]===!1&&(l[0]=Math.abs(i)>=c&&h[0]),l[1]===!1&&(l[1]=Math.abs(a)>=u&&h[1])):(l[0]===!1&&(l[0]=Math.abs(i)>=c&&Math.sign(i)*c),l[1]===!1&&(l[1]=Math.abs(a)>=u&&Math.sign(a)*u)),t.intentional=l[0]!==!1||l[1]!==!1,!t.intentional)return;const f=[0,0];if(r.hasCustomTransform){const[_,P]=h;f[0]=l[0]!==!1?_-l[0]:0,f[1]=l[1]!==!1?P-l[1]:0}else f[0]=l[0]!==!1?i-l[0]:0,f[1]=l[1]!==!1?a-l[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(f);const p=t.offset,S=t._active&&!t._blocked||t.active;S&&(t.first=t._active&&!t.active,t.last=!t._active&&t.active,t.active=s[this.ingKey]=t._active,e&&(t.first&&("bounds"in r&&(t._bounds=Yt(r.bounds,t)),this.setup&&this.setup()),t.movement=f,this.computeOffset()));const[y,w]=t.offset,[[T,b],[g,m]]=t._bounds;t.overflow=[y<T?-1:y>b?1:0,w<g?-1:w>m?1:0],t._movementBound[0]=t.overflow[0]?t._movementBound[0]===!1?t._movement[0]:t._movementBound[0]:!1,t._movementBound[1]=t.overflow[1]?t._movementBound[1]===!1?t._movement[1]:t._movementBound[1]:!1;const R=t._active?r.rubberband||[0,0]:[0,0];if(t.offset=Wr(t._bounds,t.offset,R),t.delta=be.sub(t.offset,p),this.computeMovement(),S&&(!t.last||o>Zr)){t.delta=be.sub(t.offset,p);const _=t.delta.map(Math.abs);be.addTo(t.distance,_),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&o>0&&(t.velocity=[_[0]/o,_[1]/o],t.timeDelta=o)}}emit(){const e=this.state,t=this.shared,r=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!r.triggerAllEvents)return;const s=this.handler(re(re(re({},t),e),{},{[this.aliasKey]:e.values}));s!==void 0&&(e.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function es([n,e],t){const r=Math.abs(n),s=Math.abs(e);if(r>s&&r>t)return"x";if(s>r&&s>t)return"y"}class ts extends Qr{constructor(...e){super(...e),Ee(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=be.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=be.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const t=this.state,r=this.config;if(!t.axis&&e){const s=typeof r.axisThreshold=="object"?r.axisThreshold[Bn(e)]:r.axisThreshold;t.axis=es(t._movement,s)}t._blocked=(r.lockDirection||!!r.axis)&&!t.axis||!!r.axis&&r.axis!==t.axis}restrictToAxis(e){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":e[1]=0;break;case"y":e[0]=0;break}}}const Cn=n=>n,Dn=.15,un={enabled(n=!0){return n},eventOptions(n,e,t){return re(re({},t.shared.eventOptions),n)},preventDefault(n=!1){return n},triggerAllEvents(n=!1){return n},rubberband(n=0){switch(n){case!0:return[Dn,Dn];case!1:return[0,0];default:return be.toVector(n)}},from(n){if(typeof n=="function")return n;if(n!=null)return be.toVector(n)},transform(n,e,t){const r=n||t.shared.transform;if(this.hasCustomTransform=!!r,process.env.NODE_ENV==="development"){const s=r||Cn;return o=>{const i=s(o);return(!isFinite(i[0])||!isFinite(i[1]))&&console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${i[0]},${[1]}]`),i}}return r||Cn},threshold(n){return be.toVector(n,0)}};process.env.NODE_ENV==="development"&&Object.assign(un,{domTarget(n){if(n!==void 0)throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");return NaN},lockDirection(n){if(n!==void 0)throw Error("[@use-gesture]: `lockDirection` option has been merged with `axis`. Use it as in `{ axis: 'lock' }`");return NaN},initial(n){if(n!==void 0)throw Error("[@use-gesture]: `initial` option has been renamed to `from`.");return NaN}});const ns=0,Nt=re(re({},un),{},{axis(n,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(n=ns){return n},bounds(n={}){if(typeof n=="function")return o=>Nt.bounds(n(o));if("current"in n)return()=>n.current;if(typeof HTMLElement=="function"&&n instanceof HTMLElement)return n;const{left:e=-1/0,right:t=1/0,top:r=-1/0,bottom:s=1/0}=n;return[[e,t],[r,s]]}}),Pn={ArrowRight:(n,e=1)=>[n*e,0],ArrowLeft:(n,e=1)=>[-1*n*e,0],ArrowUp:(n,e=1)=>[0,-1*n*e],ArrowDown:(n,e=1)=>[0,n*e]};class rs extends ts{constructor(...e){super(...e),Ee(this,"ingKey","dragging")}reset(){super.reset();const e=this.state;e._pointerId=void 0,e._pointerActive=!1,e._keyboardActive=!1,e._preventScroll=!1,e._delayed=!1,e.swipe=[0,0],e.tap=!1,e.canceled=!1,e.cancel=this.cancel.bind(this)}setup(){const e=this.state;if(e._bounds instanceof HTMLElement){const t=e._bounds.getBoundingClientRect(),r=e.currentTarget.getBoundingClientRect(),s={left:t.left-r.left+e.offset[0],right:t.right-r.right+e.offset[0],top:t.top-r.top+e.offset[1],bottom:t.bottom-r.bottom+e.offset[1]};e._bounds=Nt.bounds(s)}}cancel(){const e=this.state;e.canceled||(e.canceled=!0,e._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(e){const t=this.config,r=this.state;if(e.buttons!=null&&(Array.isArray(t.pointerButtons)?!t.pointerButtons.includes(e.buttons):t.pointerButtons!==-1&&t.pointerButtons!==e.buttons))return;const s=this.ctrl.setEventIds(e);t.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(s&&s.size>1&&r._pointerActive)&&(this.start(e),this.setupPointer(e),r._pointerId=rn(e),r._pointerActive=!0,this.computeValues(xn(e)),this.computeInitial(),t.preventScrollAxis&&Bn(e)!=="mouse"?(r._active=!1,this.setupScrollPrevention(e)):t.delay>0?(this.setupDelayTrigger(e),t.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const t=this.state;t._active=!0,t._preventScroll=!0,t._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const t=this.state,r=this.config;if(!t._pointerActive)return;const s=rn(e);if(t._pointerId!==void 0&&s!==t._pointerId)return;const o=xn(e);if(document.pointerLockElement===e.target?t._delta=[e.movementX,e.movementY]:(t._delta=be.sub(o,t._values),this.computeValues(o)),be.addTo(t._movement,t._delta),this.compute(e),t._delayed&&t.intentional){this.timeoutStore.remove("dragDelay"),t.active=!1,this.startPointerDrag(e);return}if(r.preventScrollAxis&&!t._preventScroll)if(t.axis)if(t.axis===r.preventScrollAxis||r.preventScrollAxis==="xy"){t._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(e);return}else return;this.emit()}pointerUp(e){this.ctrl.setEventIds(e);try{this.config.pointerCapture&&e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId)}catch{process.env.NODE_ENV==="development"&&console.warn("[@use-gesture]: If you see this message, it's likely that you're using an outdated version of `@react-three/fiber`. \n\nPlease upgrade to the latest version.")}const t=this.state,r=this.config;if(!t._active||!t._pointerActive)return;const s=rn(e);if(t._pointerId!==void 0&&s!==t._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[o,i]=t._distance;if(t.tap=o<=r.tapsThreshold&&i<=r.tapsThreshold,t.tap&&r.filterTaps)t._force=!0;else{const[a,c]=t._delta,[u,l]=t._movement,[h,f]=r.swipe.velocity,[p,S]=r.swipe.distance,y=r.swipe.duration;if(t.elapsedTime<y){const w=Math.abs(a/t.timeDelta),T=Math.abs(c/t.timeDelta);w>h&&Math.abs(u)>p&&(t.swipe[0]=Math.sign(a)),T>f&&Math.abs(l)>S&&(t.swipe[1]=Math.sign(c))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const t=this.config,r=t.device;if(process.env.NODE_ENV==="development")try{if(r==="pointer"&&t.preventScrollDelay===void 0){const s="uv"in e?e.sourceEvent.currentTarget:e.currentTarget;window.getComputedStyle(s).touchAction==="auto"&&console.warn("[@use-gesture]: The drag target has its `touch-action` style property set to `auto`. It is recommended to add `touch-action: 'none'` so that the drag gesture behaves correctly on touch-enabled devices. For more information read this: https://use-gesture.netlify.app/docs/extras/#touch-action.\n\nThis message will only show in development mode. It won't appear in production. If this is intended, you can ignore it.",s)}}catch{}t.pointerLock&&e.currentTarget.requestPointerLock(),t.pointerCapture||(this.eventStore.add(this.sharedConfig.window,r,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,r,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,r,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(e){this.state._preventScroll&&e.cancelable&&e.preventDefault()}setupScrollPrevention(e){this.state._preventScroll=!1,ss(e);const t=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",t),this.eventStore.add(this.sharedConfig.window,"touch","cancel",t),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,e)}setupDelayTrigger(e){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(e)},this.config.delay)}keyDown(e){const t=Pn[e.key];if(t){const r=this.state,s=e.shiftKey?10:e.altKey?.1:1;this.start(e),r._delta=t(this.config.keyboardDisplacement,s),r._keyboardActive=!0,be.addTo(r._movement,r._delta),this.compute(e),this.emit()}}keyUp(e){e.key in Pn&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const t=this.config.device;e(t,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(t,"change",this.pointerMove.bind(this)),e(t,"end",this.pointerUp.bind(this)),e(t,"cancel",this.pointerUp.bind(this)),e("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(e("key","down",this.keyDown.bind(this)),e("key","up",this.keyUp.bind(this))),this.config.filterTaps&&e("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function ss(n){"persist"in n&&typeof n.persist=="function"&&n.persist()}const kt=typeof window<"u"&&window.document&&window.document.createElement;function Yn(){return kt&&"ontouchstart"in window}function os(){return Yn()||kt&&window.navigator.maxTouchPoints>1}function is(){return kt&&"onpointerdown"in window}function as(){return kt&&"exitPointerLock"in window.document}function cs(){try{return"constructor"in GestureEvent}catch{return!1}}const Re={isBrowser:kt,gesture:cs(),touch:Yn(),touchscreen:os(),pointer:is(),pointerLock:as()},ls=250,us=180,fs=.5,ds=50,hs=250,ms=10,Ln={mouse:0,touch:0,pen:8},Kn=re(re({},Nt),{},{device(n,e,{pointer:{touch:t=!1,lock:r=!1,mouse:s=!1}={}}){return this.pointerLock=r&&Re.pointerLock,Re.touch&&t?"touch":this.pointerLock?"mouse":Re.pointer&&!s?"pointer":Re.touch?"touch":"mouse"},preventScrollAxis(n,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&n?ls:void 0,!(!Re.touchscreen||t===!1))return n||(t!==void 0?"y":void 0)},pointerCapture(n,e,{pointer:{capture:t=!0,buttons:r=1,keys:s=!0}={}}){return this.pointerButtons=r,this.keys=s,!this.pointerLock&&this.device==="pointer"&&t},threshold(n,e,{filterTaps:t=!1,tapsThreshold:r=3,axis:s=void 0}){const o=be.toVector(n,t?r:s?1:0);return this.filterTaps=t,this.tapsThreshold=r,o},swipe({velocity:n=fs,distance:e=ds,duration:t=hs}={}){return{velocity:this.transform(be.toVector(n)),distance:this.transform(be.toVector(e)),duration:t}},delay(n=0){switch(n){case!0:return us;case!1:return 0;default:return n}},axisThreshold(n){return n?re(re({},Ln),n):Ln},keyboardDisplacement(n=ms){return n}});process.env.NODE_ENV==="development"&&Object.assign(Kn,{useTouch(n){if(n!==void 0)throw Error("[@use-gesture]: `useTouch` option has been renamed to `pointer.touch`. Use it as in `{ pointer: { touch: true } }`.");return NaN},experimental_preventWindowScrollY(n){if(n!==void 0)throw Error("[@use-gesture]: `experimental_preventWindowScrollY` option has been renamed to `preventScroll`.");return NaN},swipeVelocity(n){if(n!==void 0)throw Error("[@use-gesture]: `swipeVelocity` option has been renamed to `swipe.velocity`. Use it as in `{ swipe: { velocity: 0.5 } }`.");return NaN},swipeDistance(n){if(n!==void 0)throw Error("[@use-gesture]: `swipeDistance` option has been renamed to `swipe.distance`. Use it as in `{ swipe: { distance: 50 } }`.");return NaN},swipeDuration(n){if(n!==void 0)throw Error("[@use-gesture]: `swipeDuration` option has been renamed to `swipe.duration`. Use it as in `{ swipe: { duration: 250 } }`.");return NaN}});re(re({},un),{},{device(n,e,{shared:t,pointer:{touch:r=!1}={}}){if(t.target&&!Re.touch&&Re.gesture)return"gesture";if(Re.touch&&r)return"touch";if(Re.touchscreen){if(Re.pointer)return"pointer";if(Re.touch)return"touch"}},bounds(n,e,{scaleBounds:t={},angleBounds:r={}}){const s=i=>{const a=An(Yt(t,i),{min:-1/0,max:1/0});return[a.min,a.max]},o=i=>{const a=An(Yt(r,i),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof t!="function"&&typeof r!="function"?[s(),o()]:i=>[s(i),o(i)]},threshold(n,e,t){return this.lockDirection=t.axis==="lock",be.toVector(n,this.lockDirection?[.1,3]:0)},modifierKey(n){return n===void 0?"ctrlKey":n},pinchOnWheel(n=!0){return n}});re(re({},Nt),{},{mouseOnly:(n=!0)=>n});re(re({},Nt),{},{mouseOnly:(n=!0)=>n});const qn=new Map,cn=new Map;function ps(n){qn.set(n.key,n.engine),cn.set(n.key,n.resolver)}const gs={key:"drag",engine:rs,resolver:Kn};function vs(n,e){if(n==null)return{};var t={},r=Object.keys(n),s,o;for(o=0;o<r.length;o++)s=r[o],!(e.indexOf(s)>=0)&&(t[s]=n[s]);return t}function bs(n,e){if(n==null)return{};var t=vs(n,e),r,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);for(s=0;s<o.length;s++)r=o[s],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(n,r)&&(t[r]=n[r])}return t}const Ss={target(n){if(n)return()=>"current"in n?n.current:n},enabled(n=!0){return n},window(n=Re.isBrowser?window:void 0){return n},eventOptions({passive:n=!0,capture:e=!1}={}){return{passive:n,capture:e}},transform(n){return n}},_s=["target","eventOptions","window","enabled","transform"];function $t(n={},e){const t={};for(const[r,s]of Object.entries(e))switch(typeof s){case"function":if(process.env.NODE_ENV==="development"){const o=s.call(t,n[r],r,n);Number.isNaN(o)||(t[r]=o)}else t[r]=s.call(t,n[r],r,n);break;case"object":t[r]=$t(n[r],s);break;case"boolean":s&&(t[r]=n[r]);break}return t}function ws(n,e,t={}){const r=n,{target:s,eventOptions:o,window:i,enabled:a,transform:c}=r,u=bs(r,_s);if(t.shared=$t({target:s,eventOptions:o,window:i,enabled:a,transform:c},Ss),e){const l=cn.get(e);t[e]=$t(re({shared:t.shared},u),l)}else for(const l in u){const h=cn.get(l);if(h)t[l]=$t(re({shared:t.shared},u[l]),h);else if(process.env.NODE_ENV==="development"&&!["drag","pinch","scroll","wheel","move","hover"].includes(l)){if(l==="domTarget")throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");console.warn(`[@use-gesture]: Unknown config key \`${l}\` was used. Please read the documentation for further information.`)}}return t}class Gn{constructor(e,t){Ee(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,r,s,o){const i=this._listeners,a=Br(t,r),c=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},u=re(re({},c),o);e.addEventListener(a,s,u);const l=()=>{e.removeEventListener(a,s,u),i.delete(l)};return i.add(l),l}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class Es{constructor(){Ee(this,"_timeouts",new Map)}add(e,t,r=140,...s){this.remove(e),this._timeouts.set(e,window.setTimeout(t,r,...s))}remove(e){const t=this._timeouts.get(e);t&&window.clearTimeout(t)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class ys{constructor(e){Ee(this,"gestures",new Set),Ee(this,"_targetEventStore",new Gn(this)),Ee(this,"gestureEventStores",{}),Ee(this,"gestureTimeoutStores",{}),Ee(this,"handlers",{}),Ee(this,"config",{}),Ee(this,"pointerIds",new Set),Ee(this,"touchIds",new Set),Ee(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),Ts(this,e)}setEventIds(e){if(Gt(e))return this.touchIds=new Set(Kr(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,t){this.handlers=e,this.nativeHandlers=t}applyConfig(e,t){this.config=ws(e,t,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const t=this.config.shared,r={};let s;if(!(t.target&&(s=t.target(),!s))){if(t.enabled){for(const i of this.gestures){const a=this.config[i],c=On(r,a.eventOptions,!!s);if(a.enabled){const u=qn.get(i);new u(this,e,i).bind(c)}}const o=On(r,t.eventOptions,!!s);for(const i in this.nativeHandlers)o(i,"",a=>this.nativeHandlers[i](re(re({},this.state.shared),{},{event:a,args:e})),void 0,!0)}for(const o in r)r[o]=Jr(...r[o]);if(!s)return r;for(const o in r){const{device:i,capture:a,passive:c}=Hr(o);this._targetEventStore.add(s,i,"",r[o],{capture:a,passive:c})}}}}function Ct(n,e){n.gestures.add(e),n.gestureEventStores[e]=new Gn(n,e),n.gestureTimeoutStores[e]=new Es}function Ts(n,e){e.drag&&Ct(n,"drag"),e.wheel&&Ct(n,"wheel"),e.scroll&&Ct(n,"scroll"),e.move&&Ct(n,"move"),e.pinch&&Ct(n,"pinch"),e.hover&&Ct(n,"hover")}const On=(n,e,t)=>(r,s,o,i={},a=!1)=>{var c,u;const l=(c=i.capture)!==null&&c!==void 0?c:e.capture,h=(u=i.passive)!==null&&u!==void 0?u:e.passive;let f=a?r:Vr(r,s,l);t&&h&&(f+="Passive"),n[f]=n[f]||[],n[f].push(o)};function Rs(n,e={},t,r){const s=M.useMemo(()=>new ys(n),[]);if(s.applyHandlers(n,r),s.applyConfig(e,t),M.useEffect(s.effect.bind(s)),M.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function sn(n,e){return ps(gs),Rs({drag:n},e||{},"drag")}function Mn(n,e){if(typeof n=="function")return n(e);n!=null&&(n.current=e)}function Jn(...n){return e=>{let t=!1;const r=n.map(s=>{const o=Mn(s,e);return!t&&typeof o=="function"&&(t=!0),o});if(t)return()=>{for(let s=0;s<r.length;s++){const o=r[s];typeof o=="function"?o():Mn(n[s],null)}}}}function ot(...n){return v.useCallback(Jn(...n),n)}function Zn(n){const e=As(n),t=v.forwardRef((r,s)=>{const{children:o,...i}=r,a=v.Children.toArray(o),c=a.find(Ds);if(c){const u=c.props.children,l=a.map(h=>h===c?v.Children.count(u)>1?v.Children.only(null):v.isValidElement(u)?u.props.children:null:h);return A.jsx(e,{...i,ref:s,children:v.isValidElement(u)?v.cloneElement(u,void 0,l):null})}return A.jsx(e,{...i,ref:s,children:o})});return t.displayName=`${n}.Slot`,t}var xs=Zn("Slot");function As(n){const e=v.forwardRef((t,r)=>{const{children:s,...o}=t;if(v.isValidElement(s)){const i=Ls(s),a=Ps(o,s.props);return s.type!==v.Fragment&&(a.ref=r?Jn(r,i):i),v.cloneElement(s,a)}return v.Children.count(s)>1?v.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var Cs=Symbol("radix.slottable");function Ds(n){return v.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===Cs}function Ps(n,e){const t={...e};for(const r in e){const s=n[r],o=e[r];/^on[A-Z]/.test(r)?s&&o?t[r]=(...a)=>{const c=o(...a);return s(...a),c}:s&&(t[r]=s):r==="style"?t[r]={...s,...o}:r==="className"&&(t[r]=[s,o].filter(Boolean).join(" "))}return{...n,...t}}function Ls(n){let e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=Object.getOwnPropertyDescriptor(n,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var Os=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Wt=Os.reduce((n,e)=>{const t=Zn(`Primitive.${e}`),r=v.forwardRef((s,o)=>{const{asChild:i,...a}=s,c=i?t:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),A.jsx(c,{...a,ref:o})});return r.displayName=`Primitive.${e}`,{...n,[e]:r}},{});function Ms(n,e=[]){let t=[];function r(o,i){const a=v.createContext(i),c=t.length;t=[...t,i];const u=h=>{const{scope:f,children:p,...S}=h,y=f?.[n]?.[c]||a,w=v.useMemo(()=>S,Object.values(S));return A.jsx(y.Provider,{value:w,children:p})};u.displayName=o+"Provider";function l(h,f){const p=f?.[n]?.[c]||a,S=v.useContext(p);if(S)return S;if(i!==void 0)return i;throw new Error(`\`${h}\` must be used within \`${o}\``)}return[u,l]}const s=()=>{const o=t.map(i=>v.createContext(i));return function(a){const c=a?.[n]||o;return v.useMemo(()=>({[`__scope${n}`]:{...a,[n]:c}}),[a,c])}};return s.scopeName=n,[r,Is(s,...e)]}function Is(...n){const e=n[0];if(n.length===1)return e;const t=()=>{const r=n.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const i=r.reduce((a,{useScope:c,scopeName:u})=>{const h=c(o)[`__scope${u}`];return{...a,...h}},{});return v.useMemo(()=>({[`__scope${e.scopeName}`]:i}),[i])}};return t.scopeName=e.scopeName,t}function st(n,e,{checkForDefaultPrevented:t=!0}={}){return function(s){if(n?.(s),t===!1||!s.defaultPrevented)return e?.(s)}}var ln=globalThis?.document?v.useLayoutEffect:()=>{};function Ns(n,e){return v.useReducer((t,r)=>e[t][r]??t,n)}var zt=n=>{const{present:e,children:t}=n,r=ks(e),s=typeof t=="function"?t({present:r.isPresent}):v.Children.only(t),o=ot(r.ref,Ws(s));return typeof t=="function"||r.isPresent?v.cloneElement(s,{ref:o}):null};zt.displayName="Presence";function ks(n){const[e,t]=v.useState(),r=v.useRef(null),s=v.useRef(n),o=v.useRef("none"),i=n?"mounted":"unmounted",[a,c]=Ns(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const u=Vt(r.current);o.current=a==="mounted"?u:"none"},[a]),ln(()=>{const u=r.current,l=s.current;if(l!==n){const f=o.current,p=Vt(u);n?c("MOUNT"):p==="none"||u?.display==="none"?c("UNMOUNT"):c(l&&f!==p?"ANIMATION_OUT":"UNMOUNT"),s.current=n}},[n,c]),ln(()=>{if(e){let u;const l=e.ownerDocument.defaultView??window,h=p=>{const y=Vt(r.current).includes(CSS.escape(p.animationName));if(p.target===e&&y&&(c("ANIMATION_END"),!s.current)){const w=e.style.animationFillMode;e.style.animationFillMode="forwards",u=l.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=w)})}},f=p=>{p.target===e&&(o.current=Vt(r.current))};return e.addEventListener("animationstart",f),e.addEventListener("animationcancel",h),e.addEventListener("animationend",h),()=>{l.clearTimeout(u),e.removeEventListener("animationstart",f),e.removeEventListener("animationcancel",h),e.removeEventListener("animationend",h)}}else c("ANIMATION_END")},[e,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:v.useCallback(u=>{r.current=u?getComputedStyle(u):null,t(u)},[])}}function Vt(n){return n?.animationName||"none"}function Ws(n){let e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=Object.getOwnPropertyDescriptor(n,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var zs=v.createContext(void 0);function js(n){const e=v.useContext(zs);return n||e||"ltr"}function rt(n){const e=v.useRef(n);return v.useEffect(()=>{e.current=n}),v.useMemo(()=>(...t)=>e.current?.(...t),[])}function Fs(n,[e,t]){return Math.min(t,Math.max(e,n))}function Us(n,e){return v.useReducer((t,r)=>e[t][r]??t,n)}var fn="ScrollArea",[Qn]=Ms(fn),[Vs,xe]=Qn(fn),er=v.forwardRef((n,e)=>{const{__scopeScrollArea:t,type:r="hover",dir:s,scrollHideDelay:o=600,...i}=n,[a,c]=v.useState(null),[u,l]=v.useState(null),[h,f]=v.useState(null),[p,S]=v.useState(null),[y,w]=v.useState(null),[T,b]=v.useState(0),[g,m]=v.useState(0),[R,_]=v.useState(!1),[P,O]=v.useState(!1),C=ot(e,W=>c(W)),E=js(s);return A.jsx(Vs,{scope:t,type:r,dir:E,scrollHideDelay:o,scrollArea:a,viewport:u,onViewportChange:l,content:h,onContentChange:f,scrollbarX:p,onScrollbarXChange:S,scrollbarXEnabled:R,onScrollbarXEnabledChange:_,scrollbarY:y,onScrollbarYChange:w,scrollbarYEnabled:P,onScrollbarYEnabledChange:O,onCornerWidthChange:b,onCornerHeightChange:m,children:A.jsx(Wt.div,{dir:E,...i,ref:C,style:{position:"relative","--radix-scroll-area-corner-width":T+"px","--radix-scroll-area-corner-height":g+"px",...n.style}})})});er.displayName=fn;var tr="ScrollAreaViewport",nr=v.forwardRef((n,e)=>{const{__scopeScrollArea:t,children:r,nonce:s,...o}=n,i=xe(tr,t),a=v.useRef(null),c=ot(e,a,i.onViewportChange);return A.jsxs(A.Fragment,{children:[A.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),A.jsx(Wt.div,{"data-radix-scroll-area-viewport":"",...o,ref:c,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...n.style},children:A.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});nr.displayName=tr;var Me="ScrollAreaScrollbar",rr=v.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=xe(Me,n.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:i}=s,a=n.orientation==="horizontal";return v.useEffect(()=>(a?o(!0):i(!0),()=>{a?o(!1):i(!1)}),[a,o,i]),s.type==="hover"?A.jsx($s,{...r,ref:e,forceMount:t}):s.type==="scroll"?A.jsx(Hs,{...r,ref:e,forceMount:t}):s.type==="auto"?A.jsx(sr,{...r,ref:e,forceMount:t}):s.type==="always"?A.jsx(dn,{...r,ref:e}):null});rr.displayName=Me;var $s=v.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=xe(Me,n.__scopeScrollArea),[o,i]=v.useState(!1);return v.useEffect(()=>{const a=s.scrollArea;let c=0;if(a){const u=()=>{window.clearTimeout(c),i(!0)},l=()=>{c=window.setTimeout(()=>i(!1),s.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",l),()=>{window.clearTimeout(c),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",l)}}},[s.scrollArea,s.scrollHideDelay]),A.jsx(zt,{present:t||o,children:A.jsx(sr,{"data-state":o?"visible":"hidden",...r,ref:e})})}),Hs=v.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=xe(Me,n.__scopeScrollArea),o=n.orientation==="horizontal",i=Zt(()=>c("SCROLL_END"),100),[a,c]=Us("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return v.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>c("HIDE"),s.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,s.scrollHideDelay,c]),v.useEffect(()=>{const u=s.viewport,l=o?"scrollLeft":"scrollTop";if(u){let h=u[l];const f=()=>{const p=u[l];h!==p&&(c("SCROLL"),i()),h=p};return u.addEventListener("scroll",f),()=>u.removeEventListener("scroll",f)}},[s.viewport,o,c,i]),A.jsx(zt,{present:t||a!=="hidden",children:A.jsx(dn,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:e,onPointerEnter:st(n.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:st(n.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),sr=v.forwardRef((n,e)=>{const t=xe(Me,n.__scopeScrollArea),{forceMount:r,...s}=n,[o,i]=v.useState(!1),a=n.orientation==="horizontal",c=Zt(()=>{if(t.viewport){const u=t.viewport.offsetWidth<t.viewport.scrollWidth,l=t.viewport.offsetHeight<t.viewport.scrollHeight;i(a?u:l)}},10);return Lt(t.viewport,c),Lt(t.content,c),A.jsx(zt,{present:r||o,children:A.jsx(dn,{"data-state":o?"visible":"hidden",...s,ref:e})})}),dn=v.forwardRef((n,e)=>{const{orientation:t="vertical",...r}=n,s=xe(Me,n.__scopeScrollArea),o=v.useRef(null),i=v.useRef(0),[a,c]=v.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=lr(a.viewport,a.content),l={...r,sizes:a,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:f=>o.current=f,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:f=>i.current=f};function h(f,p){return Gs(f,i.current,a,p)}return t==="horizontal"?A.jsx(Bs,{...l,ref:e,onThumbPositionChange:()=>{if(s.viewport&&o.current){const f=s.viewport.scrollLeft,p=In(f,a,s.dir);o.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollLeft=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollLeft=h(f,s.dir))}}):t==="vertical"?A.jsx(Xs,{...l,ref:e,onThumbPositionChange:()=>{if(s.viewport&&o.current){const f=s.viewport.scrollTop,p=In(f,a);o.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollTop=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollTop=h(f))}}):null}),Bs=v.forwardRef((n,e)=>{const{sizes:t,onSizesChange:r,...s}=n,o=xe(Me,n.__scopeScrollArea),[i,a]=v.useState(),c=v.useRef(null),u=ot(e,c,o.onScrollbarXChange);return v.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),A.jsx(ir,{"data-orientation":"horizontal",...s,ref:u,sizes:t,style:{bottom:0,left:o.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:o.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Jt(t)+"px",...n.style},onThumbPointerDown:l=>n.onThumbPointerDown(l.x),onDragScroll:l=>n.onDragScroll(l.x),onWheelScroll:(l,h)=>{if(o.viewport){const f=o.viewport.scrollLeft+l.deltaX;n.onWheelScroll(f),fr(f,h)&&l.preventDefault()}},onResize:()=>{c.current&&o.viewport&&i&&r({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:qt(i.paddingLeft),paddingEnd:qt(i.paddingRight)}})}})}),Xs=v.forwardRef((n,e)=>{const{sizes:t,onSizesChange:r,...s}=n,o=xe(Me,n.__scopeScrollArea),[i,a]=v.useState(),c=v.useRef(null),u=ot(e,c,o.onScrollbarYChange);return v.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),A.jsx(ir,{"data-orientation":"vertical",...s,ref:u,sizes:t,style:{top:0,right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Jt(t)+"px",...n.style},onThumbPointerDown:l=>n.onThumbPointerDown(l.y),onDragScroll:l=>n.onDragScroll(l.y),onWheelScroll:(l,h)=>{if(o.viewport){const f=o.viewport.scrollTop+l.deltaY;n.onWheelScroll(f),fr(f,h)&&l.preventDefault()}},onResize:()=>{c.current&&o.viewport&&i&&r({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:qt(i.paddingTop),paddingEnd:qt(i.paddingBottom)}})}})}),[Ys,or]=Qn(Me),ir=v.forwardRef((n,e)=>{const{__scopeScrollArea:t,sizes:r,hasThumb:s,onThumbChange:o,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:l,onResize:h,...f}=n,p=xe(Me,t),[S,y]=v.useState(null),w=ot(e,C=>y(C)),T=v.useRef(null),b=v.useRef(""),g=p.viewport,m=r.content-r.viewport,R=rt(l),_=rt(c),P=Zt(h,10);function O(C){if(T.current){const E=C.clientX-T.current.left,W=C.clientY-T.current.top;u({x:E,y:W})}}return v.useEffect(()=>{const C=E=>{const W=E.target;S?.contains(W)&&R(E,m)};return document.addEventListener("wheel",C,{passive:!1}),()=>document.removeEventListener("wheel",C,{passive:!1})},[g,S,m,R]),v.useEffect(_,[r,_]),Lt(S,P),Lt(p.content,P),A.jsx(Ys,{scope:t,scrollbar:S,hasThumb:s,onThumbChange:rt(o),onThumbPointerUp:rt(i),onThumbPositionChange:_,onThumbPointerDown:rt(a),children:A.jsx(Wt.div,{...f,ref:w,style:{position:"absolute",...f.style},onPointerDown:st(n.onPointerDown,C=>{C.button===0&&(C.target.setPointerCapture(C.pointerId),T.current=S.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),O(C))}),onPointerMove:st(n.onPointerMove,O),onPointerUp:st(n.onPointerUp,C=>{const E=C.target;E.hasPointerCapture(C.pointerId)&&E.releasePointerCapture(C.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),T.current=null})})})}),Kt="ScrollAreaThumb",ar=v.forwardRef((n,e)=>{const{forceMount:t,...r}=n,s=or(Kt,n.__scopeScrollArea);return A.jsx(zt,{present:t||s.hasThumb,children:A.jsx(Ks,{ref:e,...r})})}),Ks=v.forwardRef((n,e)=>{const{__scopeScrollArea:t,style:r,...s}=n,o=xe(Kt,t),i=or(Kt,t),{onThumbPositionChange:a}=i,c=ot(e,h=>i.onThumbChange(h)),u=v.useRef(void 0),l=Zt(()=>{u.current&&(u.current(),u.current=void 0)},100);return v.useEffect(()=>{const h=o.viewport;if(h){const f=()=>{if(l(),!u.current){const p=Js(h,a);u.current=p,a()}};return a(),h.addEventListener("scroll",f),()=>h.removeEventListener("scroll",f)}},[o.viewport,l,a]),A.jsx(Wt.div,{"data-state":i.hasThumb?"visible":"hidden",...s,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:st(n.onPointerDownCapture,h=>{const p=h.target.getBoundingClientRect(),S=h.clientX-p.left,y=h.clientY-p.top;i.onThumbPointerDown({x:S,y})}),onPointerUp:st(n.onPointerUp,i.onThumbPointerUp)})});ar.displayName=Kt;var hn="ScrollAreaCorner",cr=v.forwardRef((n,e)=>{const t=xe(hn,n.__scopeScrollArea),r=!!(t.scrollbarX&&t.scrollbarY);return t.type!=="scroll"&&r?A.jsx(qs,{...n,ref:e}):null});cr.displayName=hn;var qs=v.forwardRef((n,e)=>{const{__scopeScrollArea:t,...r}=n,s=xe(hn,t),[o,i]=v.useState(0),[a,c]=v.useState(0),u=!!(o&&a);return Lt(s.scrollbarX,()=>{const l=s.scrollbarX?.offsetHeight||0;s.onCornerHeightChange(l),c(l)}),Lt(s.scrollbarY,()=>{const l=s.scrollbarY?.offsetWidth||0;s.onCornerWidthChange(l),i(l)}),u?A.jsx(Wt.div,{...r,ref:e,style:{width:o,height:a,position:"absolute",right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:0,...n.style}}):null});function qt(n){return n?parseInt(n,10):0}function lr(n,e){const t=n/e;return isNaN(t)?0:t}function Jt(n){const e=lr(n.viewport,n.content),t=n.scrollbar.paddingStart+n.scrollbar.paddingEnd,r=(n.scrollbar.size-t)*e;return Math.max(r,18)}function Gs(n,e,t,r="ltr"){const s=Jt(t),o=s/2,i=e||o,a=s-i,c=t.scrollbar.paddingStart+i,u=t.scrollbar.size-t.scrollbar.paddingEnd-a,l=t.content-t.viewport,h=r==="ltr"?[0,l]:[l*-1,0];return ur([c,u],h)(n)}function In(n,e,t="ltr"){const r=Jt(e),s=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=e.scrollbar.size-s,i=e.content-e.viewport,a=o-r,c=t==="ltr"?[0,i]:[i*-1,0],u=Fs(n,c);return ur([0,i],[0,a])(u)}function ur(n,e){return t=>{if(n[0]===n[1]||e[0]===e[1])return e[0];const r=(e[1]-e[0])/(n[1]-n[0]);return e[0]+r*(t-n[0])}}function fr(n,e){return n>0&&n<e}var Js=(n,e=()=>{})=>{let t={left:n.scrollLeft,top:n.scrollTop},r=0;return(function s(){const o={left:n.scrollLeft,top:n.scrollTop},i=t.left!==o.left,a=t.top!==o.top;(i||a)&&e(),t=o,r=window.requestAnimationFrame(s)})(),()=>window.cancelAnimationFrame(r)};function Zt(n,e){const t=rt(n),r=v.useRef(0);return v.useEffect(()=>()=>window.clearTimeout(r.current),[]),v.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(t,e)},[t,e])}function Lt(n,e){const t=rt(e);ln(()=>{let r=0;if(n){const s=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(t)});return s.observe(n),()=>{window.cancelAnimationFrame(r),s.unobserve(n)}}},[n,t])}var Zs=er,Qs=nr,eo=cr;const on=(n,e,t,r,s)=>({target:n,dx:e[0],dy:e[1],clientX:t[0],clientY:t[1],...r&&{edges:r},...s&&{deltaRect:s}}),to=(n,e,t)=>n?n===e||n===t||(e?.contains(n)??!1)||(t?.contains(n)??!1):!1,no=n=>{const e=De.c(34),{children:t,style:r,draggable:s,resizable:o,draggableOptions:i,resizableOptions:a,ref:c}=n,u=M.useRef(void 0),l=M.useRef(void 0),h=M.useRef(null),f=M.useRef(null),p=M.useRef(void 0),S=M.useRef(void 0);let y,w;e[0]!==i||e[1]!==c||e[2]!==a?(y=()=>{if(u.current=i,l.current=a,!c?.current)return;const k=a?.edges?.left,K=a?.edges?.right;k&&k!==p.current&&(p.current=k,h.current=c.current.querySelector(k)),K&&K!==S.current&&(S.current=K,f.current=c.current.querySelector(K))},w=[i,c,a],e[0]=i,e[1]=c,e[2]=a,e[3]=y,e[4]=w):(y=e[3],w=e[4]),M.useEffect(y,w);let T;e[5]!==c?(T=k=>{const{active:K,delta:Q,xy:j,event:I,first:d,last:x}=k,L=c?.current;if(!L||to(I?.target,h.current,f.current))return;const F=on(L,Q,j);d?u.current?.onstart?.(F):x?u.current?.onend?.(F):K&&u.current?.onmove?.(F)},e[5]=c,e[6]=T):T=e[6];const b=i?.lockAxis==="x"?"x":void 0;let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g={capture:!0},e[7]=g):g=e[7];let m;e[8]!==s||e[9]!==c||e[10]!==b?(m={enabled:s,axis:b,pointer:g,target:c,threshold:0},e[8]=s,e[9]=c,e[10]=b,e[11]=m):m=e[11],sn(T,m);let R;e[12]!==c?(R=k=>{const{active:K,delta:Q,xy:j,first:I,last:d}=k,x=c?.current;if(!x)return;const L=on(x,Q,j,{left:!0},{left:Q[0]});I?l.current?.onstart?.(L):d?l.current?.onend?.(L):K&&l.current?.onmove?.(L)},e[12]=c,e[13]=R):R=e[13];let _;e[14]===Symbol.for("react.memo_cache_sentinel")?(_={capture:!0},e[14]=_):_=e[14];let P;e[15]!==o?(P={enabled:o,target:h,pointer:_,threshold:0},e[15]=o,e[16]=P):P=e[16],sn(R,P);let O;e[17]!==c?(O=k=>{const{active:K,delta:Q,xy:j,first:I,last:d}=k,x=c?.current;if(!x)return;const L=on(x,Q,j,{right:!0},{right:Q[0]});I?l.current?.onstart?.(L):d?l.current?.onend?.(L):K&&l.current?.onmove?.(L)},e[17]=c,e[18]=O):O=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C={capture:!0},e[19]=C):C=e[19];let E;e[20]!==o?(E={enabled:o,target:f,pointer:C,threshold:0},e[20]=o,e[21]=E):E=e[21],sn(O,E);let W,G;e[22]!==c?(W=()=>{const k=c?.current;if(!k)return;const K=l.current?.edges?.left,Q=l.current?.edges?.right;K&&(h.current=k.querySelector(K)),Q&&(f.current=k.querySelector(Q))},G=[c],e[22]=c,e[23]=W,e[24]=G):(W=e[23],G=e[24]),M.useLayoutEffect(W,G);let Z;e[25]!==s?(Z=s?{touchAction:"none"}:{},e[25]=s,e[26]=Z):Z=e[26];let Y;e[27]!==r||e[28]!==Z?(Y={...Z,...r},e[27]=r,e[28]=Z,e[29]=Y):Y=e[29];let ie;return e[30]!==t||e[31]!==c||e[32]!==Y?(ie=A.jsx(xs,{ref:c,style:Y,draggable:!1,children:t}),e[30]=t,e[31]=c,e[32]=Y,e[33]=ie):ie=e[33],ie},Nn=tt.getLogger("[Snap Debug]").setLevel("info"),we=(n,e=0)=>n?parseFloat(n):e,an=(n,e,t,r=Number.MAX_SAFE_INTEGER)=>{let s=n,o=r;for(const i of e){const a=typeof i=="number"?i:i.value,c=Math.abs(a-n);c<t&&c<o&&(s=a,o=c,typeof i=="object"?Nn.debug(`Snapped to: ${a} (Distance: ${c}) Row: ${i.rowId??"N/A"} Action: ${i.actionId??"N/A"}`):Nn.debug(`Snapped to: ${a} (Distance: ${c})`))}return{snap:s,minDis:o}};function dr(n){const e=De.c(70),{children:t,edges:r,left:s,width:o,start:i,grid:a,getBounds:c,enableResizing:u,enableDragging:l,snapDistance:h,snapPositions:f,snapOrigin:p,onResizeStart:S,onResize:y,onResizeEnd:w,onDragStart:T,onDragEnd:b,onDrag:g,parentRef:m,autoScroll:R,autoScrollSpeed:_,autoScrollMaxSpeed:P,ref:O}=n,C=i===void 0?D.DEFAULT_START_LEFT:i,E=a===void 0?D.DEFAULT_MOVE_GRID:a,W=c===void 0?so:c,G=u===void 0?!0:u,Z=l===void 0?!0:l,Y=h===void 0?D.DEFAULT_SNAP_DISTANCE:h;let ie;e[0]!==f?(ie=f===void 0?[]:f,e[0]=f,e[1]=ie):ie=e[1];const k=ie,K=p===void 0?"leading":p,Q=R===void 0?!0:R,j=M.useRef(null),I=M.useRef(0),d=M.useRef(!1),{initAutoScroll:x,stopAutoScroll:L,dealDragAutoScroll:F,dealResizeAutoScroll:me}=Nr(m,_,P);let ge;e[2]===Symbol.for("react.memo_cache_sentinel")?(ge=(z,J)=>{const V=J===void 0?!0:J;if(!j.current)return;V&&(I.current=0);const B=j.current;B.style.setProperty("--translate-x",`${z}px`),B.dataset.left=String(z)},e[2]=ge):ge=e[2];const X=ge;let te;e[3]===Symbol.for("react.memo_cache_sentinel")?(te=(z,J)=>{const V=J===void 0?!0:J;if(!j.current)return;V&&(I.current=0);const B=j.current;B.style.width=`${z}px`,B.dataset.width=String(z)},e[3]=te):te=e[3];const U=te;let se;e[4]===Symbol.for("react.memo_cache_sentinel")?(se=()=>j.current?we(j.current.dataset.left):0,e[4]=se):se=e[4];const ee=se;let H;e[5]===Symbol.for("react.memo_cache_sentinel")?(H=()=>j.current?we(j.current.dataset.width):0,e[5]=H):H=e[5];const q=H;let it,at;e[6]!==o?(it=()=>{if(!j.current)return;const z=j.current;U(typeof o>"u"?z.offsetWidth:o,!1)},at=[o],e[6]=o,e[7]=it,e[8]=at):(it=e[7],at=e[8]),M.useEffect(it,at);let je,Ie;e[9]!==s?(je=()=>{X(s||0,!1)},Ie=[s],e[9]=s,e[10]=je,e[11]=Ie):(je=e[10],Ie=e[11]),M.useEffect(je,Ie);let Pe;e[12]===Symbol.for("react.memo_cache_sentinel")?(Pe=()=>({updateLeft:z=>X(z||0,!1),updateWidth:z=>U(z,!1),getLeft:ee,getWidth:q}),e[12]=Pe):Pe=e[12],M.useImperativeHandle(O,Pe);let Fe;e[13]!==x||e[14]!==T?(Fe=()=>{I.current=0,d.current=!1,x(),T?.()},e[13]=x,e[14]=T,e[15]=Fe):Fe=e[15];const Ue=Fe;let Le;e[16]!==W||e[17]!==E||e[18]!==g||e[19]!==Y||e[20]!==K||e[21]!==k||e[22]!==C?(Le=z=>{const{preLeft:J,preWidth:V,scrollDelta:B}=z;B&&(I.current=I.current+B);const le=d.current?Y:E;if(Math.abs(I.current)<le)return;const ae=Math.trunc(I.current/le);let $=J+ae*le;const ue=I.current>0;let N=$;K==="leading"?N=ue?$+V:$:K==="right"?N=$+V:K==="center"&&(N=$+V/2);const{snap:ne}=an(N,k,Y);if(ne!==N)d.current=!0,K==="leading"?$=ue?ne-V:ne:K==="right"?$=ne-V:K==="center"?$=ne-V/2:$=ne;else{const de=$-C;de%E!==0&&($=C+E*Math.round(de/E)),d.current=!1}I.current=I.current%le;const fe=W();$<fe.left?$=fe.left:$+V>fe.right&&($=fe.right-V),!(g&&g({lastLeft:J,left:$,lastWidth:V,width:V},B)===!1)&&X($,!1)},e[16]=W,e[17]=E,e[18]=g,e[19]=Y,e[20]=K,e[21]=k,e[22]=C,e[23]=Le):Le=e[23];const Ne=Le;let ct;e[24]!==Q||e[25]!==F||e[26]!==Ne||e[27]!==m?(ct=z=>{const J=z.target,V=we(J.dataset.left),B=we(J.dataset.width);I.current=I.current+z.dx,!(Q&&m?.current&&!F(z,$=>{if(!m?.current||!j.current)return;m.current.scrollLeft=m.current.scrollLeft+$;const ue=j.current,N=we(ue.dataset.left),ne=we(ue.dataset.width);Ne({preLeft:N,preWidth:ne,scrollDelta:$})}))&&Ne({preLeft:V,preWidth:B})},e[24]=Q,e[25]=F,e[26]=Ne,e[27]=m,e[28]=ct):ct=e[28];const Ot=ct;let ke;e[29]!==b||e[30]!==L?(ke=z=>{I.current=0,d.current=!1,L();const J=z.target;b?.({left:we(J.dataset.left),width:we(J.dataset.width)})},e[29]=b,e[30]=L,e[31]=ke):ke=e[31];const Te=ke;let We;e[32]!==x||e[33]!==S?(We=z=>{I.current=0,d.current=!1,x();const J=z.edges?.right?"right":"left";S?.(J)},e[32]=x,e[33]=S,e[34]=We):We=e[34];const Ve=We;let $e;e[35]!==W||e[36]!==E||e[37]!==y||e[38]!==Y||e[39]!==k||e[40]!==C?($e=z=>{const{dir:J,preWidth:V,preLeft:B,scrollDelta:le}=z;le&&(I.current=I.current+le);const ae=d.current?Y:E;if(Math.abs(I.current)<ae)return;const $=W();if(J==="left"){const ue=Math.trunc(I.current/ae);let N=B+ue*ae;const{snap:ne}=an(N,k,Y);if(ne!==N)d.current=!0,N=ne;else{const ye=N-C;ye%E!==0&&(N=C+E*Math.round(ye/E)),d.current=!1}I.current=I.current%ae,N<$.left&&(N=$.left);const fe=B+V,de=fe-N;if(N>=fe||y&&y("left",{lastLeft:B,lastWidth:V,left:N,width:de})===!1)return;X(N,!1),U(de,!1)}else{const ue=Math.trunc(I.current/ae);let N=V+ue*ae;const ne=B+N,{snap:fe}=an(ne,k,Y);if(fe!==ne)d.current=!0,N=fe-B;else{let de=B+N;const ye=de-C;ye%E!==0&&(de=C+E*Math.round(ye/E),N=de-B),d.current=!1}if(I.current=I.current%ae,B+N>$.right&&(N=$.right-B),N<=0||y&&y("right",{lastLeft:B,lastWidth:V,left:B,width:N})===!1)return;U(N,!1)}},e[35]=W,e[36]=E,e[37]=y,e[38]=Y,e[39]=k,e[40]=C,e[41]=$e):$e=e[41];const ze=$e;let Ae;e[42]!==Q||e[43]!==me||e[44]!==m||e[45]!==ze?(Ae=z=>{const J=z.target,V=z.edges?.left?"left":"right",B=we(J.dataset.left),le=we(J.dataset.width);I.current=I.current+(V==="left"?z.deltaRect?.left||0:z.deltaRect?.right||0),!(Q&&m?.current&&!me(z,V,ue=>{if(!m?.current||!j.current)return;m.current.scrollLeft=m.current.scrollLeft+ue;const N=j.current,ne=we(N.dataset.left),fe=we(N.dataset.width);ze({preLeft:ne,preWidth:fe,dir:V,scrollDelta:ue})}))&&ze({preLeft:B,preWidth:le,dir:V})},e[42]=Q,e[43]=me,e[44]=m,e[45]=ze,e[46]=Ae):Ae=e[46];const He=Ae;let Be;e[47]!==w||e[48]!==L?(Be=z=>{I.current=0,d.current=!1,L();const J=z.target,V=z.edges?.right?"right":"left";w?.(V,{left:we(J.dataset.left),width:we(J.dataset.width)})},e[47]=w,e[48]=L,e[49]=Be):Be=e[49];const Xe=Be,nt=s||0,Ye=`${s||0}px`;let Ke;e[50]!==Ye||e[51]!==o?(Ke={"--translate-x":Ye,transform:"translateX(var(--translate-x)) scaleX(var(--scale-x,1))",width:o},e[50]=Ye,e[51]=o,e[52]=Ke):Ke=e[52];const qe=Ke;let Oe;e[53]!==Ot||e[54]!==Ue||e[55]!==Te?(Oe={lockAxis:"x",onmove:Ot,onstart:Ue,onend:Te,cursorChecker:ro},e[53]=Ot,e[54]=Ue,e[55]=Te,e[56]=Oe):Oe=e[56];let Ce;e[57]!==r||e[58]!==He||e[59]!==Ve||e[60]!==Xe?(Ce={axis:"x",invert:"none",edges:r,onmove:He,onstart:Ve,onend:Xe},e[57]=r,e[58]=He,e[59]=Ve,e[60]=Xe,e[61]=Ce):Ce=e[61];let Ge;return e[62]!==t||e[63]!==Z||e[64]!==G||e[65]!==nt||e[66]!==qe||e[67]!==Oe||e[68]!==Ce?(Ge=A.jsx(no,{"data-left":nt,style:qe,ref:j,draggable:Z,resizable:G,draggableOptions:Oe,resizableOptions:Ce,children:t}),e[62]=t,e[63]=Z,e[64]=G,e[65]=nt,e[66]=qe,e[67]=Oe,e[68]=Ce,e[69]=Ge):Ge=e[69],Ge}function ro(){return""}function so(){return{left:Number.MIN_SAFE_INTEGER,right:Number.MAX_SAFE_INTEGER}}function oo(){let n=0,e,t="",r=arguments.length;for(;n<r;n++)(e=arguments[n])&&typeof e=="string"&&(t+=(t&&" ")+e);return t}const io=n=>{const e=De.c(200),{editorData:t,row:r,action:s,effects:o,rowHeight:i,scale:a,scaleWidth:c,scaleSplitCount:u,startLeft:l,gridSnap:h,disableDrag:f,autoScroll:p,autoScrollSpeed:S,autoScrollMaxSpeed:y,scaleCount:w,maxScaleCount:T,setScaleCount:b,onActionMoveStart:g,onActionMoving:m,onActionMoveEnd:R,onActionResizeStart:_,onActionResizeEnd:P,onActionResizing:O,snapData:C,setEditorData:E,onClickAction:W,onClickActionOnly:G,onDoubleClickAction:Z,onContextMenuAction:Y,getActionRender:ie,handleTime:k,scrollContainerRef:K}=n,Q=M.useRef(null),j=M.useRef(!1),{id:I,maxEnd:d,minStart:x,end:L,start:F,selected:me,flexible:ge,movable:X,effectId:te}=s,U=ge===void 0?!0:ge,se=X===void 0?!0:X,ee=a??D.DEFAULT_SCALE,H=c??D.DEFAULT_SCALE_WIDTH,q=l??D.DEFAULT_START_LEFT,it=u??D.DEFAULT_SCALE_SPLIT_COUNT,at=T??Number.MAX_SAFE_INTEGER,je=x||0;let Ie;e[0]!==ee||e[1]!==H||e[2]!==q||e[3]!==je?(Ie=D.parserTimeToPixel(je,{startLeft:q,scale:ee,scaleWidth:H}),e[0]=ee,e[1]=H,e[2]=q,e[3]=je,e[4]=Ie):Ie=e[4];const Pe=Ie,Fe=d||Number.MAX_VALUE;let Ue;e[5]!==ee||e[6]!==H||e[7]!==q||e[8]!==Fe?(Ue=D.parserTimeToPixel(Fe,{startLeft:q,scale:ee,scaleWidth:H}),e[5]=ee,e[6]=H,e[7]=q,e[8]=Fe,e[9]=Ue):Ue=e[9];const Le=Math.min(at*H+q,Ue);let Ne;e[10]!==L||e[11]!==ee||e[12]!==H||e[13]!==q||e[14]!==F?(Ne=D.parserTimeToTransform({start:F,end:L},{startLeft:q,scale:ee,scaleWidth:H}),e[10]=L,e[11]=ee,e[12]=H,e[13]=q,e[14]=F,e[15]=Ne):Ne=e[15];const ct=Ne,[Ot,ke]=M.useState(null),Te=Ot??ct,We=H/it;let Ve;e[16]!==te||e[17]!==o||e[18]!==U||e[19]!==se||e[20]!==me?(Ve=ve(oo("action",se&&"action-movable",me&&"action-selected",U&&"action-flexible",o[te]&&`action-effect-${te}`)),e[16]=te,e[17]=o,e[18]=U,e[19]=se,e[20]=me,e[21]=Ve):Ve=e[21];const $e=Ve;let ze;e[22]!==H||e[23]!==q||e[24]!==w||e[25]!==b?(ze=(Se,_e)=>{const oe=D.getScaleCountByPixel(Se+_e,{startLeft:q,scaleCount:w,scaleWidth:H});oe!==w&&b(oe)},e[22]=H,e[23]=q,e[24]=w,e[25]=b,e[26]=ze):ze=e[26];const Ae=ze;let He;e[27]!==s||e[28]!==g||e[29]!==r?(He=()=>{g&&g({action:s,row:r})},e[27]=s,e[28]=g,e[29]=r,e[30]=He):He=e[30];const Be=He;let Xe;e[31]!==s||e[32]!==Ae||e[33]!==m||e[34]!==r||e[35]!==ee||e[36]!==H||e[37]!==q?(Xe=Se=>{const{left:_e,width:oe}=Se;if(j.current=!0,m){const{start:pe,end:ce}=D.parserTransformToTime({left:_e,width:oe},{scaleWidth:H,scale:ee,startLeft:q});if(m({action:s,row:r,start:pe,end:ce})===!1)return!1}ke({left:_e,width:oe}),Ae(_e,oe)},e[31]=s,e[32]=Ae,e[33]=m,e[34]=r,e[35]=ee,e[36]=H,e[37]=q,e[38]=Xe):Xe=e[38];const nt=Xe;let Ye;e[39]!==t||e[40]!==I||e[41]!==R||e[42]!==r||e[43]!==ee||e[44]!==H||e[45]!==q||e[46]!==E?(Ye=Se=>{const{left:_e,width:oe}=Se,{start:pe,end:ce}=D.parserTransformToTime({left:_e,width:oe},{scaleWidth:H,scale:ee,startLeft:q}),he=t.find(et=>et.id===r.id);if(!he)return;const Qe=he.actions.find(et=>et.id===I);Qe&&(Qe.start=pe,Qe.end=ce,E([...t]),R&&R({action:Qe,row:r,start:pe,end:ce}),ke(null))},e[39]=t,e[40]=I,e[41]=R,e[42]=r,e[43]=ee,e[44]=H,e[45]=q,e[46]=E,e[47]=Ye):Ye=e[47];const Ke=Ye;let qe;e[48]!==s||e[49]!==_||e[50]!==r?(qe=Se=>{_&&_({action:s,row:r,dir:Se})},e[48]=s,e[49]=_,e[50]=r,e[51]=qe):qe=e[51];const Oe=qe;let Ce;e[52]!==s||e[53]!==Ae||e[54]!==O||e[55]!==r||e[56]!==ee||e[57]!==H||e[58]!==q?(Ce=(Se,_e)=>{const{left:oe,width:pe}=_e;if(j.current=!0,O){const{start:ce,end:he}=D.parserTransformToTime({left:oe,width:pe},{scaleWidth:H,scale:ee,startLeft:q});if(O({action:s,row:r,start:ce,end:he,dir:Se})===!1)return!1}ke({left:oe,width:pe}),Ae(oe,pe)},e[52]=s,e[53]=Ae,e[54]=O,e[55]=r,e[56]=ee,e[57]=H,e[58]=q,e[59]=Ce):Ce=e[59];const Ge=Ce;let z;e[60]!==t||e[61]!==I||e[62]!==P||e[63]!==r||e[64]!==ee||e[65]!==H||e[66]!==q||e[67]!==E?(z=(Se,_e)=>{const{left:oe,width:pe}=_e,{start:ce,end:he}=D.parserTransformToTime({left:oe,width:pe},{scaleWidth:H,scale:ee,startLeft:q}),Qe=t.find(Qt=>Qt.id===r.id);if(!Qe)return;const et=Qe.actions.find(Qt=>Qt.id===I);et&&(et.start=ce,et.end=he,E([...t]),P&&P({action:et,row:r,start:ce,end:he,dir:Se}),ke(null))},e[60]=t,e[61]=I,e[62]=P,e[63]=r,e[64]=ee,e[65]=H,e[66]=q,e[67]=E,e[68]=z):z=e[68];const J=z;let V,B,le,ae,$,ue,N,ne,fe,de,ye,lt,ut,ft,dt,ht,Je,Ze,mt,pt,gt,vt,bt,St,_t,wt,Et,yt,Tt;if(e[69]!==s||e[70]!==p||e[71]!==y||e[72]!==S||e[73]!==$e||e[74]!==f||e[75]!==U||e[76]!==ie||e[77]!==We||e[78]!==h||e[79]!==nt||e[80]!==Ke||e[81]!==Be||e[82]!==J||e[83]!==Oe||e[84]!==Ge||e[85]!==k||e[86]!==Pe||e[87]!==se||e[88]!==W||e[89]!==G||e[90]!==Y||e[91]!==Z||e[92]!==Le||e[93]!==r||e[94]!==i||e[95]!==ee||e[96]!==H||e[97]!==q||e[98]!==K||e[99]!==C.assistPositions||e[100]!==Te.left||e[101]!==Te.width){const Se={...s,...D.parserTransformToTime({left:Te.left,width:Te.width},{startLeft:q,scaleWidth:H,scale:ee})},_e={...r,actions:[...r.actions]};r.actions.includes(s)&&(_e.actions[r.actions.indexOf(s)]=Se),V=dr,fe=Q,de=K,ye=q,lt=Te.left,ut=Te.width,ft=h&&We||D.DEFAULT_MOVE_GRID,dt=h?Math.max((We||D.DEFAULT_MOVE_GRID)/2,D.DEFAULT_SNAP_DISTANCE):D.DEFAULT_SNAP_DISTANCE,ht=C.assistPositions,e[131]!==Pe||e[132]!==Le?(Je=()=>({left:Pe,right:Le}),e[131]=Pe,e[132]=Le,e[133]=Je):Je=e[133];let oe;e[134]!==f||e[135]!==U?(oe=!f&&U&&`.${ve("action-left-stretch")}`,e[134]=f,e[135]=U,e[136]=oe):oe=e[136];let pe;e[137]!==f||e[138]!==U?(pe=!f&&U&&`.${ve("action-right-stretch")}`,e[137]=f,e[138]=U,e[139]=pe):pe=e[139],e[140]!==oe||e[141]!==pe?(Ze={left:oe,right:pe},e[140]=oe,e[141]=pe,e[142]=Ze):Ze=e[142],mt=!f&&se,pt=!f&&U,gt=Be,vt=nt,bt=Ke,St=Oe,_t=Ge,wt=J,Et=p,yt=S,Tt=y,e[143]===Symbol.for("react.memo_cache_sentinel")?(B=()=>{j.current=!1},e[143]=B):B=e[143],e[144]!==s||e[145]!==k||e[146]!==W||e[147]!==G||e[148]!==r?(le=ce=>{let he;W&&(he=k(ce),W(ce,{row:r,action:s,time:he})),!j.current&&G&&(he===void 0&&(he=k(ce)),G(ce,{row:r,action:s,time:he}))},e[144]=s,e[145]=k,e[146]=W,e[147]=G,e[148]=r,e[149]=le):le=e[149],e[150]!==s||e[151]!==k||e[152]!==Z||e[153]!==r?(ae=ce=>{if(Z){const he=k(ce);Z(ce,{row:r,action:s,time:he})}},e[150]=s,e[151]=k,e[152]=Z,e[153]=r,e[154]=ae):ae=e[154],e[155]!==s||e[156]!==k||e[157]!==Y||e[158]!==r?($=ce=>{if(Y){const he=k(ce);Y(ce,{row:r,action:s,time:he})}},e[155]=s,e[156]=k,e[157]=Y,e[158]=r,e[159]=$):$=e[159],ue=$e,e[160]!==i?(N={height:i},e[160]=i,e[161]=N):N=e[161],ne=ie&&ie(Se,_e),e[69]=s,e[70]=p,e[71]=y,e[72]=S,e[73]=$e,e[74]=f,e[75]=U,e[76]=ie,e[77]=We,e[78]=h,e[79]=nt,e[80]=Ke,e[81]=Be,e[82]=J,e[83]=Oe,e[84]=Ge,e[85]=k,e[86]=Pe,e[87]=se,e[88]=W,e[89]=G,e[90]=Y,e[91]=Z,e[92]=Le,e[93]=r,e[94]=i,e[95]=ee,e[96]=H,e[97]=q,e[98]=K,e[99]=C.assistPositions,e[100]=Te.left,e[101]=Te.width,e[102]=V,e[103]=B,e[104]=le,e[105]=ae,e[106]=$,e[107]=ue,e[108]=N,e[109]=ne,e[110]=fe,e[111]=de,e[112]=ye,e[113]=lt,e[114]=ut,e[115]=ft,e[116]=dt,e[117]=ht,e[118]=Je,e[119]=Ze,e[120]=mt,e[121]=pt,e[122]=gt,e[123]=vt,e[124]=bt,e[125]=St,e[126]=_t,e[127]=wt,e[128]=Et,e[129]=yt,e[130]=Tt}else V=e[102],B=e[103],le=e[104],ae=e[105],$=e[106],ue=e[107],N=e[108],ne=e[109],fe=e[110],de=e[111],ye=e[112],lt=e[113],ut=e[114],ft=e[115],dt=e[116],ht=e[117],Je=e[118],Ze=e[119],mt=e[120],pt=e[121],gt=e[122],vt=e[123],bt=e[124],St=e[125],_t=e[126],wt=e[127],Et=e[128],yt=e[129],Tt=e[130];let Rt;e[162]!==U?(Rt=U&&A.jsx("div",{className:ve("action-left-stretch"),style:{touchAction:"none"}}),e[162]=U,e[163]=Rt):Rt=e[163];let xt;e[164]!==U?(xt=U&&A.jsx("div",{className:ve("action-right-stretch"),style:{touchAction:"none"}}),e[164]=U,e[165]=xt):xt=e[165];let At;e[166]!==B||e[167]!==le||e[168]!==ae||e[169]!==$||e[170]!==ue||e[171]!==N||e[172]!==ne||e[173]!==Rt||e[174]!==xt?(At=A.jsxs("div",{onMouseDown:B,onClick:le,onDoubleClick:ae,onContextMenu:$,className:ue,style:N,children:[ne,Rt,xt]}),e[166]=B,e[167]=le,e[168]=ae,e[169]=$,e[170]=ue,e[171]=N,e[172]=ne,e[173]=Rt,e[174]=xt,e[175]=At):At=e[175];let jt;return e[176]!==V||e[177]!==fe||e[178]!==de||e[179]!==ye||e[180]!==lt||e[181]!==ut||e[182]!==ft||e[183]!==dt||e[184]!==ht||e[185]!==Je||e[186]!==Ze||e[187]!==mt||e[188]!==pt||e[189]!==gt||e[190]!==vt||e[191]!==bt||e[192]!==St||e[193]!==_t||e[194]!==wt||e[195]!==Et||e[196]!==yt||e[197]!==Tt||e[198]!==At?(jt=A.jsx(V,{ref:fe,parentRef:de,start:ye,left:lt,width:ut,grid:ft,snapDistance:dt,snapPositions:ht,getBounds:Je,edges:Ze,enableDragging:mt,enableResizing:pt,onDragStart:gt,onDrag:vt,onDragEnd:bt,onResizeStart:St,onResize:_t,onResizeEnd:wt,autoScroll:Et,autoScrollSpeed:yt,autoScrollMaxSpeed:Tt,children:At}),e[176]=V,e[177]=fe,e[178]=de,e[179]=ye,e[180]=lt,e[181]=ut,e[182]=ft,e[183]=dt,e[184]=ht,e[185]=Je,e[186]=Ze,e[187]=mt,e[188]=pt,e[189]=gt,e[190]=vt,e[191]=bt,e[192]=St,e[193]=_t,e[194]=wt,e[195]=Et,e[196]=yt,e[197]=Tt,e[198]=At,e[199]=jt):jt=e[199],jt};function Dt(n,e,t){let r=t.initialDeps??[],s;function o(){var i,a,c,u;let l;t.key&&((i=t.debug)!=null&&i.call(t))&&(l=Date.now());const h=n();if(!(h.length!==r.length||h.some((S,y)=>r[y]!==S)))return s;r=h;let p;if(t.key&&((a=t.debug)!=null&&a.call(t))&&(p=Date.now()),s=e(...h),t.key&&((c=t.debug)!=null&&c.call(t))){const S=Math.round((Date.now()-l)*100)/100,y=Math.round((Date.now()-p)*100)/100,w=y/16,T=(b,g)=>{for(b=String(b);b.length<g;)b=" "+b;return b};console.info(`%c⏱ ${T(y,5)} /${T(S,5)} ms`,`
11
- font-size: .6rem;
12
- font-weight: bold;
13
- color: hsl(${Math.max(0,Math.min(120-120*w,120))}deg 100% 31%);`,t?.key)}return(u=t?.onChange)==null||u.call(t,s),s}return o.updateDeps=i=>{r=i},o}function kn(n,e){if(n===void 0)throw new Error("Unexpected undefined");return n}const ao=(n,e)=>Math.abs(n-e)<1.01,co=(n,e,t)=>{let r;return function(...s){n.clearTimeout(r),r=n.setTimeout(()=>e.apply(this,s),t)}},Wn=n=>{const{offsetWidth:e,offsetHeight:t}=n;return{width:e,height:t}},lo=n=>n,uo=n=>{const e=Math.max(n.startIndex-n.overscan,0),t=Math.min(n.endIndex+n.overscan,n.count-1),r=[];for(let s=e;s<=t;s++)r.push(s);return r},fo=(n,e)=>{const t=n.scrollElement;if(!t)return;const r=n.targetWindow;if(!r)return;const s=i=>{const{width:a,height:c}=i;e({width:Math.round(a),height:Math.round(c)})};if(s(Wn(t)),!r.ResizeObserver)return()=>{};const o=new r.ResizeObserver(i=>{const a=()=>{const c=i[0];if(c?.borderBoxSize){const u=c.borderBoxSize[0];if(u){s({width:u.inlineSize,height:u.blockSize});return}}s(Wn(t))};n.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return o.observe(t,{box:"border-box"}),()=>{o.unobserve(t)}},zn={passive:!0},jn=typeof window>"u"?!0:"onscrollend"in window,ho=(n,e)=>{const t=n.scrollElement;if(!t)return;const r=n.targetWindow;if(!r)return;let s=0;const o=n.options.useScrollendEvent&&jn?()=>{}:co(r,()=>{e(s,!1)},n.options.isScrollingResetDelay),i=l=>()=>{const{horizontal:h,isRtl:f}=n.options;s=h?t.scrollLeft*(f&&-1||1):t.scrollTop,o(),e(s,l)},a=i(!0),c=i(!1);c(),t.addEventListener("scroll",a,zn);const u=n.options.useScrollendEvent&&jn;return u&&t.addEventListener("scrollend",c,zn),()=>{t.removeEventListener("scroll",a),u&&t.removeEventListener("scrollend",c)}},mo=(n,e,t)=>{if(e?.borderBoxSize){const r=e.borderBoxSize[0];if(r)return Math.round(r[t.options.horizontal?"inlineSize":"blockSize"])}return n[t.options.horizontal?"offsetWidth":"offsetHeight"]},po=(n,{adjustments:e=0,behavior:t},r)=>{var s,o;const i=n+e;(o=(s=r.scrollElement)==null?void 0:s.scrollTo)==null||o.call(s,{[r.options.horizontal?"left":"top"]:i,behavior:t})};class go{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let t=null;const r=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(s=>{s.forEach(o=>{const i=()=>{this._measureElement(o.target,o)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()})}));return{disconnect:()=>{var s;(s=r())==null||s.disconnect(),t=null},observe:s=>{var o;return(o=r())==null?void 0:o.observe(s,{box:"border-box"})},unobserve:s=>{var o;return(o=r())==null?void 0:o.unobserve(s)}}})(),this.range=null,this.setOptions=t=>{Object.entries(t).forEach(([r,s])=>{typeof s>"u"&&delete t[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:lo,rangeExtractor:uo,onChange:()=>{},measureElement:mo,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...t}},this.notify=t=>{var r,s;(s=(r=this.options).onChange)==null||s.call(r,this,t)},this.maybeNotify=Dt(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:process.env.NODE_ENV!=="production"&&"maybeNotify",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(s=>{this.observer.observe(s)}),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,s=>{this.scrollRect=s,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(s,o)=>{this.scrollAdjustments=0,this.scrollDirection=o?this.getScrollOffset()<s?"forward":"backward":null,this.scrollOffset=s,this.isScrolling=o,this.maybeNotify()}))}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(t,r)=>{const s=new Map,o=new Map;for(let i=r-1;i>=0;i--){const a=t[i];if(s.has(a.lane))continue;const c=o.get(a.lane);if(c==null||a.end>c.end?o.set(a.lane,a):a.end<c.end&&s.set(a.lane,!0),s.size===this.options.lanes)break}return o.size===this.options.lanes?Array.from(o.values()).sort((i,a)=>i.end===a.end?i.index-a.index:i.end-a.end)[0]:void 0},this.getMeasurementOptions=Dt(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled],(t,r,s,o,i)=>(this.pendingMeasuredCacheIndexes=[],{count:t,paddingStart:r,scrollMargin:s,getItemKey:o,enabled:i}),{key:!1}),this.getMeasurements=Dt(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:t,paddingStart:r,scrollMargin:s,getItemKey:o,enabled:i},a)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),[];this.measurementsCache.length===0&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(l=>{this.itemSizeCache.set(l.key,l.size)}));const c=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];const u=this.measurementsCache.slice(0,c);for(let l=c;l<t;l++){const h=o(l),f=this.options.lanes===1?u[l-1]:this.getFurthestMeasurement(u,l),p=f?f.end+this.options.gap:r+s,S=a.get(h),y=typeof S=="number"?S:this.options.estimateSize(l),w=p+y,T=f?f.lane:l%this.options.lanes;u[l]={index:l,start:p,size:y,end:w,key:h,lane:T}}return this.measurementsCache=u,u},{key:process.env.NODE_ENV!=="production"&&"getMeasurements",debug:()=>this.options.debug}),this.calculateRange=Dt(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,r,s,o)=>this.range=t.length>0&&r>0?vo({measurements:t,outerSize:r,scrollOffset:s,lanes:o}):null,{key:process.env.NODE_ENV!=="production"&&"calculateRange",debug:()=>this.options.debug}),this.getVirtualIndexes=Dt(()=>{let t=null,r=null;const s=this.calculateRange();return s&&(t=s.startIndex,r=s.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,r]},(t,r,s,o,i)=>o===null||i===null?[]:t({startIndex:o,endIndex:i,overscan:r,count:s}),{key:process.env.NODE_ENV!=="production"&&"getVirtualIndexes",debug:()=>this.options.debug}),this.indexFromElement=t=>{const r=this.options.indexAttribute,s=t.getAttribute(r);return s?parseInt(s,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this._measureElement=(t,r)=>{const s=this.indexFromElement(t),o=this.measurementsCache[s];if(!o)return;const i=o.key,a=this.elementsCache.get(i);a!==t&&(a&&this.observer.unobserve(a),this.observer.observe(t),this.elementsCache.set(i,t)),t.isConnected&&this.resizeItem(s,this.options.measureElement(t,r,this))},this.resizeItem=(t,r)=>{const s=this.measurementsCache[t];if(!s)return;const o=this.itemSizeCache.get(s.key)??s.size,i=r-o;i!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(s,i,this):s.start<this.getScrollOffset()+this.scrollAdjustments)&&(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("correction",i),this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=i,behavior:void 0})),this.pendingMeasuredCacheIndexes.push(s.index),this.itemSizeCache=new Map(this.itemSizeCache.set(s.key,r)),this.notify(!1))},this.measureElement=t=>{if(!t){this.elementsCache.forEach((r,s)=>{r.isConnected||(this.observer.unobserve(r),this.elementsCache.delete(s))});return}this._measureElement(t,void 0)},this.getVirtualItems=Dt(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,r)=>{const s=[];for(let o=0,i=t.length;o<i;o++){const a=t[o],c=r[a];s.push(c)}return s},{key:process.env.NODE_ENV!=="production"&&"getVirtualItems",debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const r=this.getMeasurements();if(r.length!==0)return kn(r[hr(0,r.length-1,s=>kn(r[s]).start,t)])},this.getOffsetForAlignment=(t,r,s=0)=>{const o=this.getSize(),i=this.getScrollOffset();r==="auto"&&(r=t>=i+o?"end":"start"),r==="center"?t+=(s-o)/2:r==="end"&&(t-=o);const a=this.getTotalSize()+this.options.scrollMargin-o;return Math.max(Math.min(a,t),0)},this.getOffsetForIndex=(t,r="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const s=this.measurementsCache[t];if(!s)return;const o=this.getSize(),i=this.getScrollOffset();if(r==="auto")if(s.end>=i+o-this.options.scrollPaddingEnd)r="end";else if(s.start<=i+this.options.scrollPaddingStart)r="start";else return[i,r];const a=r==="end"?s.end+this.options.scrollPaddingEnd:s.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,r,s.size),r]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(t,{align:r="start",behavior:s}={})=>{s==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(t,r),{adjustments:void 0,behavior:s})},this.scrollToIndex=(t,{align:r="auto",behavior:s}={})=>{s==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),t=Math.max(0,Math.min(t,this.options.count-1));let o=0;const i=10,a=u=>{if(!this.targetWindow)return;const l=this.getOffsetForIndex(t,u);if(!l){console.warn("Failed to get offset for index:",t);return}const[h,f]=l;this._scrollToOffset(h,{adjustments:void 0,behavior:s}),this.targetWindow.requestAnimationFrame(()=>{const p=this.getScrollOffset(),S=this.getOffsetForIndex(t,f);if(!S){console.warn("Failed to get offset for index:",t);return}ao(S[0],p)||c(f)})},c=u=>{this.targetWindow&&(o++,o<i?(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("Schedule retry",o,i),this.targetWindow.requestAnimationFrame(()=>a(u))):console.warn(`Failed to scroll to index ${t} after ${i} attempts.`))};a(r)},this.scrollBy=(t,{behavior:r}={})=>{r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+t,{adjustments:void 0,behavior:r})},this.getTotalSize=()=>{var t;const r=this.getMeasurements();let s;if(r.length===0)s=this.options.paddingStart;else if(this.options.lanes===1)s=((t=r[r.length-1])==null?void 0:t.end)??0;else{const o=Array(this.options.lanes).fill(null);let i=r.length-1;for(;i>=0&&o.some(a=>a===null);){const a=r[i];o[a.lane]===null&&(o[a.lane]=a.end),i--}s=Math.max(...o.filter(a=>a!==null))}return Math.max(s-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(t,{adjustments:r,behavior:s})=>{this.options.scrollToFn(t,{behavior:s,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.notify(!1)},this.setOptions(e)}}const hr=(n,e,t,r)=>{for(;n<=e;){const s=(n+e)/2|0,o=t(s);if(o<r)n=s+1;else if(o>r)e=s-1;else return s}return n>0?n-1:0};function vo({measurements:n,outerSize:e,scrollOffset:t,lanes:r}){const s=n.length-1,o=c=>n[c].start;if(n.length<=r)return{startIndex:0,endIndex:s};let i=hr(0,s,o,t),a=i;if(r===1)for(;a<s&&n[a].end<t+e;)a++;else if(r>1){const c=Array(r).fill(0);for(;a<s&&c.some(l=>l<t+e);){const l=n[a];c[l.lane]=l.end,a++}const u=Array(r).fill(t+e);for(;i>=0&&u.some(l=>l>=t);){const l=n[i];u[l.lane]=l.start,i--}i=Math.max(0,i-i%r),a=Math.min(s,a+(r-1-a%r))}return{startIndex:i,endIndex:a}}const Fn=typeof document<"u"?v.useLayoutEffect:v.useEffect;function bo(n){const e=v.useReducer(()=>({}),{})[1],t={...n,onChange:(s,o)=>{var i;o?gr.flushSync(e):e(),(i=n.onChange)==null||i.call(n,s,o)}},[r]=v.useState(()=>new go(t));return r.setOptions(t),Fn(()=>r._didMount(),[]),Fn(()=>r._willUpdate()),r}function mr(n){return bo({observeElementRect:fo,observeElementOffset:ho,scrollToFn:po,...n})}const So=n=>{const{rowData:e,style:t={},onClickRow:r,onDoubleClickRow:s,onContextMenuRow:o,scrollContainerRef:i,startLeft:a,scale:c,scaleWidth:u,unstable_rowActionsOverscan:l}=n,h=["edit-row"];e?.selected&&h.push("edit-row-selected");const f=c??D.DEFAULT_SCALE,p=u??D.DEFAULT_SCALE_WIDTH,S=a??D.DEFAULT_START_LEFT,y=g=>{if(!i.current)return 0;const R=g.currentTarget.getBoundingClientRect(),P=g.clientX-R.x;return D.parserPixelToTime(P,{startLeft:S,scale:f,scaleWidth:p})},w=M.useMemo(()=>(e?.actions?[...e.actions]:[]).sort((g,m)=>g.start-m.start),[e]),T=M.useCallback(g=>w[g]?.id??g,[w]),b=mr({horizontal:!0,count:w.length,getItemKey:T,getScrollElement:()=>i.current,estimateSize:g=>{if(!w[g])return 0;let m=g>0?w[g-1].end:0,R=w[g].end;if(m>R)return 0;let{width:_}=D.parserTimeToTransform({start:m,end:R},{startLeft:S,scale:f,scaleWidth:p});return _},overscan:l??5});return M.useEffect(()=>b.measure(),[f,p,S,b]),A.jsx("div",{className:`${ve(...h)} ${(e?.classNames||[]).join(" ")}`,style:t,onClick:g=>{if(e&&r){const m=y(g);r(g,{row:e,time:m})}},onDoubleClick:g=>{if(e&&s){const m=y(g);s(g,{row:e,time:m})}},onContextMenu:g=>{if(e&&o){const m=y(g);o(g,{row:e,time:m})}},children:e&&b.getVirtualItems().map(g=>{const m=w[g.index];if(!m)throw new Error("Action not found");return A.jsx(io,{...n,handleTime:y,row:e,action:m},m.id)})})},_o=n=>{const e=De.c(20);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={isMoving:!1,movePositions:[],assistPositions:[]},e[0]=t):t=e[0];const[r,s]=M.useState(t),o=M.useRef(null);let i;e[1]!==n||e[2]!==r?(i=()=>({...n,snapData:r}),e[1]=n,e[2]=r,e[3]=i):i=e[3];const a=M.useEffectEvent(i);let c;e[4]!==a?(c=()=>{const T=o.current,b=a();if(b.snap&&T&&b.snapData.isMoving&&b.snapPositions){const g=T.assistActionIds,m=b.snapPositions.filter(R=>!(R.actionId===T.action.id||g&&!g.includes(R.actionId))).map(wo);if(!b.hideCursor){const R=D.parserTimeToPixel(b.cursorTime,{scaleWidth:b.scaleWidth??160,scale:b.scale??1,startLeft:b.startLeft??20});m.push(R)}s(R=>({...R,assistPositions:m}))}else!b.snap&&b.snapData.isMoving&&s(Eo)},e[4]=a,e[5]=c):c=e[5];let u;e[6]!==n.snap?(u=[n.snap],e[6]=n.snap,e[7]=u):u=e[7],M.useEffect(c,u);let l;e[8]!==n?(l=T=>{const b=n.getAssistDragLineActionIds&&n.getAssistDragLineActionIds({action:T.action,row:T.row,editorData:n.editorData});if(o.current={action:T.action,row:T.row,assistActionIds:b},n.snap&&n.snapPositions){const g=n.snapPositions.filter(m=>!(m.actionId===T.action.id||b&&!b.includes(m.actionId))).map(yo);if(!n.hideCursor){const m=D.parserTimeToPixel(n.cursorTime,{scaleWidth:n.scaleWidth??160,scale:n.scale??1,startLeft:n.startLeft??20});g.push(m)}s({isMoving:!0,movePositions:[],assistPositions:g})}else s({isMoving:!0,movePositions:[],assistPositions:[]})},e[8]=n,e[9]=l):l=e[9];const h=l;let f;e[10]!==n.scale||e[11]!==n.scaleWidth||e[12]!==n.snap||e[13]!==n.startLeft?(f=T=>{if(n.snap){const b=n.scaleWidth??160,g=n.scale??1,m=n.startLeft??20,{left:R,width:_}=D.parserTimeToTransform({start:T.start,end:T.end},{startLeft:m,scaleWidth:b,scale:g}),P=T.dir?T.dir==="right"?[R+_]:[R]:[R,R+_];s(O=>({...O,movePositions:P}))}},e[10]=n.scale,e[11]=n.scaleWidth,e[12]=n.snap,e[13]=n.startLeft,e[14]=f):f=e[14];const p=f;let S;e[15]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{o.current=null,s({isMoving:!1,movePositions:[],assistPositions:[]})},e[15]=S):S=e[15];const y=S;let w;return e[16]!==h||e[17]!==p||e[18]!==r?(w={snapData:r,handleInitSnap:h,handleUpdateSnap:p,disposeSnap:y},e[16]=h,e[17]=p,e[18]=r,e[19]=w):w=e[19],w};function wo(n){return n.value}function Eo(n){return{...n,assistPositions:[]}}function yo(n){return n.value}const To=n=>{const e=De.c(34);let t,r;e[0]!==n?({ref:r,...t}=n,e[0]=n,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let s;e[3]!==t.cursorTime||e[4]!==t.editorData||e[5]!==t.getAssistDragLineActionIds||e[6]!==t.hideCursor||e[7]!==t.scale||e[8]!==t.scaleWidth||e[9]!==t.snap||e[10]!==t.snapPositions||e[11]!==t.startLeft?(s={snap:t.snap,hideCursor:t.hideCursor,cursorTime:t.cursorTime,scaleWidth:t.scaleWidth,scale:t.scale,startLeft:t.startLeft,getAssistDragLineActionIds:t.getAssistDragLineActionIds,editorData:t.editorData,snapPositions:t.snapPositions},e[3]=t.cursorTime,e[4]=t.editorData,e[5]=t.getAssistDragLineActionIds,e[6]=t.hideCursor,e[7]=t.scale,e[8]=t.scaleWidth,e[9]=t.snap,e[10]=t.snapPositions,e[11]=t.startLeft,e[12]=s):s=e[12];const{snapData:o,handleInitSnap:i,handleUpdateSnap:a,disposeSnap:c}=_o(s),u=t.rowHeight??32,l=t.scaleWidth??160,h=t.startLeft??20,f=Math.max(t.scaleCount*l+h,t.timelineWidth);let p;if(e[13]!==f||e[14]!==u||e[15]!==c||e[16]!==i||e[17]!==a||e[18]!==t||e[19]!==o){const R=[];let _=0;for(let P=0;P<t.editorData.length;P++){const O=t.editorData[P];if(!O)continue;const C=O.rowHeight||u;R.push(M.createElement(So,{...t,key:O.id,rowData:O,snapData:o,scrollContainerRef:t.scrollElementRef,style:{position:"absolute",top:0,left:0,width:f,height:`${C}px`,transform:`translateY(${_}px)`},onActionMoveStart:E=>(i(E),t.onActionMoveStart&&t.onActionMoveStart(E)),onActionResizeStart:E=>(i(E),t.onActionResizeStart&&t.onActionResizeStart(E)),onActionMoving:E=>(a(E),t.onActionMoving&&t.onActionMoving(E)),onActionResizing:E=>(a(E),t.onActionResizing&&t.onActionResizing(E)),onActionResizeEnd:E=>(c(),t.onActionResizeEnd&&t.onActionResizeEnd(E)),onActionMoveEnd:E=>(c(),t.onActionMoveEnd&&t.onActionMoveEnd(E))})),_=_+C}p=[_,R],e[13]=f,e[14]=u,e[15]=c,e[16]=i,e[17]=a,e[18]=t,e[19]=o,e[20]=p}else p=e[20];const[S,y]=p,w=`0, ${t.startLeft??20}px`,T=`${t.startLeft??20}px, ${t.scaleWidth??160}px`;let b;e[21]!==f||e[22]!==w||e[23]!==T||e[24]!==S?(b={width:f,height:S,position:"relative",backgroundPositionX:w,backgroundSize:T},e[21]=f,e[22]=w,e[23]=T,e[24]=S,e[25]=b):b=e[25];let g;e[26]!==t.snap||e[27]!==o?(g=t.snap&&A.jsx(Lr,{...o}),e[26]=t.snap,e[27]=o,e[28]=g):g=e[28];let m;return e[29]!==r||e[30]!==y||e[31]!==b||e[32]!==g?(m=A.jsxs("div",{ref:r,style:b,className:"timeline-editor-edit-area",children:[y,g]}),e[29]=r,e[30]=y,e[31]=b,e[32]=g,e[33]=m):m=e[33],m};function Ro({scaleSplitCount:n,scaleWidth:e,startLeft:t,scaleCount:r,maxScaleCount:s,scale:o,scrollElementRef:i,onClickTimeArea:a,setCursor:c,getScaleRender:u}){const l=n??1,h=e??160,f=t??20,p=(n??0)>0,S=p?r*(n??1)+1:r,y=(p?h/l:h)*(S-1)+f,T=mr({horizontal:!0,count:S,getScrollElement:()=>i.current,estimateSize:b=>{switch(b){case 0:return f;default:return p?h/l:h}},overscan:10});return M.useEffect(()=>T.measure(),[o,e,t,T]),A.jsx("div",{style:{width:`${y}px`},className:ve("time-area"),onClick:b=>{const g=t??20,m=e??160,R=o??1,_=s??1/0,P=b.currentTarget.getBoundingClientRect(),O=b.clientX-P.x,C=Math.max(O,g);if(C>_*m+g)return;const E=D.parserPixelToTime(C,{startLeft:g,scale:R,scaleWidth:m});a&&a(E,b),!b.defaultPrevented&&c({time:E})},children:T.getVirtualItems().map(b=>{const g=b.index,m=n??1,R=o??1,_=p?g%m===0:!0,P=[ve("time-unit"),ve(_?"time-unit-big":"time-unit-small")],O=(p?g/m:g)*R;return A.jsx("div",{"data-index":b.index,style:{width:`${b.size}px`,transform:`translateX(${b.start}px)`},className:P.join(" "),children:_&&A.jsx("div",{className:ve("time-unit-scale"),children:u?.(O)??O})},b.key)})})}function xo(n){return typeof n=="object"&&n!==null}function Ao(n,e,t){if(n instanceof EventTarget)return[n];if(typeof n=="string"){const s=document.querySelectorAll(n);return s?Array.from(s):[]}return Array.from(n)}function Co(n){return xo(n)&&"ownerSVGElement"in n}const Ht=new WeakMap;let Bt;const pr=(n,e,t)=>(r,s)=>s&&s[0]?s[0][n+"Size"]:Co(r)&&"getBBox"in r?r.getBBox()[e]:r[t],Do=pr("inline","width","offsetWidth"),Po=pr("block","height","offsetHeight");function Lo({target:n,borderBoxSize:e}){Ht.get(n)?.forEach(t=>{t(n,{get width(){return Do(n,e)},get height(){return Po(n,e)}})})}function Oo(n){n.forEach(Lo)}function Mo(){typeof ResizeObserver>"u"||(Bt=new ResizeObserver(Oo))}function Io(n,e){Bt||Mo();const t=Ao(n);return t.forEach(r=>{let s=Ht.get(r);s||(s=new Set,Ht.set(r,s)),s.add(e),Bt?.observe(r)}),()=>{t.forEach(r=>{const s=Ht.get(r);s?.delete(e),s?.size||Bt?.unobserve(r)})}}const Xt=new Set;let Pt;function No(){Pt=()=>{const n={get width(){return window.innerWidth},get height(){return window.innerHeight}};Xt.forEach(e=>e(n))},window.addEventListener("resize",Pt)}function ko(n){return Xt.add(n),Pt||No(),()=>{Xt.delete(n),!Xt.size&&typeof Pt=="function"&&(window.removeEventListener("resize",Pt),Pt=void 0)}}function Wo(n,e){return typeof n=="function"?ko(n):Io(n,e)}function zo(n){const e=De.c(4),{elementRef:t}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={width:0,height:0},e[0]=r):r=e[0];const[s,o]=M.useState(r);let i,a;return e[1]!==t?(i=()=>{t.current&&Wo(t.current,(c,u)=>{o({width:u.width,height:u.height})})},a=[t],e[1]=t,e[2]=i,e[3]=a):(i=e[2],a=e[3]),M.useLayoutEffect(i,a),s}const jo=n=>{const e=De.c(49),{disableDrag:t,cursorTime:r,setCursor:s,startLeft:o,scaleWidth:i,scale:a,scaleCount:c,scaleSplitCount:u,scrollElementRef:l,maxScaleCount:h,onCursorDragStart:f,onCursorDrag:p,onCursorDragEnd:S,cursorSnap:y,autoScrollSpeed:w,autoScrollMaxSpeed:T,snapPositions:b}=n;let g;e[0]!==b?(g=b===void 0?[]:b,e[0]=b,e[1]=g):g=e[1];const m=g,R=M.useRef(null),_=o??20,P=i??160,O=a??1;let C;e[2]!==y||e[3]!==m?(C=y?m:[],e[2]=y,e[3]=m,e[4]=C):C=e[4];const E=C;let W,G;e[5]!==r||e[6]!==a||e[7]!==i||e[8]!==o?(W=()=>{if(R.current){const te=o??20,U=i??160,se=a??1;R.current.updateLeft(D.parserTimeToPixel(r,{startLeft:te,scaleWidth:U,scale:se}))}},G=[r,o,i,a],e[5]=r,e[6]=a,e[7]=i,e[8]=o,e[9]=W,e[10]=G):(W=e[9],G=e[10]),M.useEffect(W,G);const Z=h??1/0,Y=(u??0)>0,ie=u??1,k=Y?c*(u??1)+1:c,K=o??20,Q=(Y?P/ie:P)*(k-1)+K;let j;e[11]!==_||e[12]!==Z||e[13]!==l||e[14]!==Q||e[15]!==P?(j=()=>({left:0,right:Math.min(Q,Z*P+_-(l.current?.scrollLeft??0))}),e[11]=_,e[12]=Z,e[13]=l,e[14]=Q,e[15]=P,e[16]=j):j=e[16];const I=!t;let d;e[17]!==r||e[18]!==_||e[19]!==f||e[20]!==O||e[21]!==P?(d=()=>{const te=R.current?.getLeft()??D.parserTimeToPixel(r,{startLeft:_,scaleWidth:P,scale:O}),U=D.parserPixelToTime(te,{startLeft:_,scale:O,scaleWidth:P});f&&f(U)},e[17]=r,e[18]=_,e[19]=f,e[20]=O,e[21]=P,e[22]=d):d=e[22];let x;e[23]!==_||e[24]!==S||e[25]!==O||e[26]!==s||e[27]!==P?(x=te=>{const{left:U}=te,se=D.parserPixelToTime(U,{startLeft:_,scale:O,scaleWidth:P});s({time:se}),S&&S(se)},e[23]=_,e[24]=S,e[25]=O,e[26]=s,e[27]=P,e[28]=x):x=e[28];let L;e[29]!==_||e[30]!==p||e[31]!==O||e[32]!==s||e[33]!==P?(L=te=>{const{left:U}=te,se=D.parserPixelToTime(U,{startLeft:_,scale:O,scaleWidth:P});s({time:se}),p&&p(se)},e[29]=_,e[30]=p,e[31]=O,e[32]=s,e[33]=P,e[34]=L):L=e[34];let F,me;e[35]===Symbol.for("react.memo_cache_sentinel")?(F=ve("cursor"),me=ve("cursor-top"),e[35]=F,e[36]=me):(F=e[35],me=e[36]);let ge;e[37]===Symbol.for("react.memo_cache_sentinel")?(ge=A.jsxs("div",{className:F,children:[A.jsx("svg",{className:me,width:"8",height:"12",viewBox:"0 0 8 12",fill:"none",children:A.jsx("path",{d:"M0 1C0 0.447715 0.447715 0 1 0H7C7.55228 0 8 0.447715 8 1V9.38197C8 9.76074 7.786 10.107 7.44721 10.2764L4.44721 11.7764C4.16569 11.9172 3.83431 11.9172 3.55279 11.7764L0.552786 10.2764C0.214002 10.107 0 9.76074 0 9.38197V1Z",fill:"currentColor"})}),A.jsx("div",{className:ve("cursor-area")})]}),e[37]=ge):ge=e[37];let X;return e[38]!==E||e[39]!==T||e[40]!==w||e[41]!==_||e[42]!==l||e[43]!==L||e[44]!==j||e[45]!==I||e[46]!==d||e[47]!==x?(X=A.jsx(dr,{start:_,ref:R,parentRef:l,getBounds:j,autoScroll:!0,autoScrollSpeed:w,autoScrollMaxSpeed:T,enableDragging:I,enableResizing:!1,snapPositions:E,snapDistance:D.DEFAULT_SNAP_DISTANCE,snapOrigin:"left",onDragStart:d,onDragEnd:x,onDrag:L,children:ge}),e[38]=E,e[39]=T,e[40]=w,e[41]=_,e[42]=l,e[43]=L,e[44]=j,e[45]=I,e[46]=d,e[47]=x,e[48]=X):X=e[48],X};function Un(n){const e=De.c(9);let t,r,s;e[0]!==n?({className:t,orientation:s,...r}=n,e[0]=n,e[1]=t,e[2]=r,e[3]=s):(t=e[1],r=e[2],s=e[3]);const o=s===void 0?"vertical":s;let i;e[4]===Symbol.for("react.memo_cache_sentinel")?(i=A.jsx(ar,{"data-slot":"scroll-area-thumb"}),e[4]=i):i=e[4];let a;return e[5]!==t||e[6]!==o||e[7]!==r?(a=A.jsx(rr,{"data-slot":"scroll-area-scrollbar",orientation:o,className:t,...r,children:i}),e[5]=t,e[6]=o,e[7]=r,e[8]=a):a=e[8],a}function Fo(n){const e=De.c(7),{scrollElementRef:t,scale:r,scaleWidth:s,startLeft:o,cursorTimeRef:i}=n,a=M.useRef(null),c=M.useRef(null);let u,l;e[0]!==i||e[1]!==r||e[2]!==s||e[3]!==t||e[4]!==o?(u=()=>{const h=t.current;if(a.current!==null&&c.current!==null&&h&&(a.current!==r||c.current!==s)){const f=h.scrollLeft,p=i.current,S=D.parserTimeToPixel(p,{startLeft:o,scale:a.current,scaleWidth:c.current}),y=D.parserTimeToPixel(p,{startLeft:o,scale:r,scaleWidth:s}),w=S-f,T=y-w;h.scrollLeft=T}a.current=r,c.current=s},l=[r,s,o,t,i],e[0]=i,e[1]=r,e[2]=s,e[3]=t,e[4]=o,e[5]=u,e[6]=l):(u=e[5],l=e[6]),M.useLayoutEffect(u,l)}function Uo({ref:n,...e}){const t=xr(e),r=M.useRef(null),{width:s,height:o}=zo({elementRef:r}),i=e.unstable_forceRemountEditorArea??0,a=t.minScaleCount??Math.max(D.getScaleCountByRows(t.editorData,{scale:t.scale,pad:.1}),Math.ceil((s-t.startLeft)/t.scaleWidth)),c=Math.min(t.maxScaleCount,a),u=t.editorData?D.parserActionsToPositions(t.editorData.flatMap(m=>m.actions),{startLeft:t.startLeft,scale:t.scale,scaleWidth:t.scaleWidth}):[],[l,h]=M.useState(null);M.useLayoutEffect(()=>{h(null)},[c]);const f=l??c,p=m=>{const R=Math.min(t.maxScaleCount,m);h(R)},[S,y]=M.useState(D.START_CURSOR_TIME),w=M.useRef(D.START_CURSOR_TIME);Fo({scrollElementRef:r,scale:t.scale,scaleWidth:t.scaleWidth,startLeft:t.startLeft,cursorTimeRef:w});const T=m=>{t.onChange?.(m)},b=m=>{let{left:R,time:_}=m;return typeof _<"u"?(y(_),w.current=_,!0):typeof R<"u"?(y(w.current=D.parserPixelToTime(R,{startLeft:t.startLeft,scale:t.scale,scaleWidth:t.scaleWidth})),!0):!1},g=(m,R={})=>{const _=r.current;if(!_)return;const{block:P="start",offset:O=0,onlyIfNotVisible:C=!1}=R,E=D.parserTimeToPixel(m,{startLeft:t.startLeft,scale:t.scale,scaleWidth:t.scaleWidth}),W=_.clientWidth;if(C){const Y=_.scrollLeft;if(E>=Y&&E<=Y+W)return}let G;P==="end"?G=E-W+O:P==="center"?G=E-W/2:G=E-O;const Z=Math.max(0,_.scrollWidth-W);_.scrollTo({left:Math.min(Math.max(G,0),Z),behavior:R.behavior??"instant"})};return M.useImperativeHandle(n,()=>({get target(){return r.current},set time(m){b({time:m})},get time(){return w.current},getTime(){return w.current},setTime(m){b({time:m})},getTimePixelPosition(m){return D.parserTimeToPixel(m??w.current,{startLeft:t.startLeft,scale:t.scale,scaleWidth:t.scaleWidth})},setScrollLeft:m=>{r.current&&(r.current.scrollLeft=m)},setScrollTop:m=>{r.current&&(r.current.scrollTop=m)},get scrollLeft(){return r.current?r.current.scrollLeft:0},get scrollTop(){return r.current?r.current.scrollTop:0},set scrollLeft(m){r.current&&(r.current.scrollLeft=m)},set scrollTop(m){r.current&&(r.current.scrollTop=m)},scrollToTime:g})),A.jsxs(Zs,{style:t.style,className:`${D.PREFIX} ${t.disableDrag?D.PREFIX+"-disable":""}`,"data-slot":"scroll-area",children:[A.jsxs(Qs,{"data-slot":"scroll-area-viewport",ref:r,onScroll:m=>{t.onScroll?.(m.currentTarget)},children:[A.jsx(Ro,{...t,setCursor:b,scaleCount:f,scrollElementRef:r}),A.jsx(To,{...t,scrollElementRef:r,timelineWidth:s,timelineHeight:o,disableDrag:t.disableDrag,editorData:t.editorData,cursorTime:S,scaleCount:f,setScaleCount:p,setEditorData:T,snapPositions:u},`__editor_area_${i}__`),!t.hideCursor&&A.jsx(jo,{...t,timelineWidth:s,height:o,scaleCount:f,setScaleCount:p,setCursor:b,cursorTime:S,editorData:t.editorData,scrollElementRef:r,snapPositions:u})]}),A.jsx(Un,{orientation:"horizontal"}),A.jsx(Un,{orientation:"vertical"}),A.jsx(eo,{})]})}exports.Timeline=Uo;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region \0rolldown/runtime.js
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
+ value: mod,
21
+ enumerable: true
22
+ }) : target, mod));
23
+ //#endregion
24
+ const require_deal_data = require("./deal-data-BnM2yYM0.cjs");
25
+ let react = require("react");
26
+ let react$1 = __toESM(react, 1);
27
+ react = __toESM(react);
28
+ let framework_utils = require("framework-utils");
29
+ let react_jsx_runtime = require("react/jsx-runtime");
30
+ let _use_gesture_react = require("@use-gesture/react");
31
+ let radix_ui = require("radix-ui");
32
+ let _tanstack_react_virtual = require("@tanstack/react-virtual");
33
+ let motion = require("motion");
34
+ //#region src/utils/with-defaults.ts
35
+ function withDefaults(props) {
36
+ let { editorData = [], effects = {}, scale = 1, scaleSplitCount = 10, scaleWidth = 160, startLeft = 20, minScaleCount, maxScaleCount = Infinity, rowHeight = 32, collapsedRowHeight, autoScrollSpeed = 1, autoScrollMaxSpeed = 10 } = props;
37
+ if (scale <= 0) {
38
+ console.error("Error: scale must be greater than 0!");
39
+ scale = 1;
40
+ }
41
+ if (scaleSplitCount <= 0) {
42
+ console.warn("Warning: scaleSplitCount cannot be less than 1!");
43
+ scaleSplitCount = 1;
44
+ }
45
+ if (scaleWidth <= 0) {
46
+ console.warn("Warning: scaleWidth must be greater than 0!");
47
+ scaleWidth = 160;
48
+ }
49
+ if (startLeft < 0) {
50
+ console.warn("Warning: startLeft cannot be less than 0!");
51
+ startLeft = 0;
52
+ }
53
+ if (typeof minScaleCount === "number") {
54
+ minScaleCount = parseInt(minScaleCount + "");
55
+ if (minScaleCount < 1) {
56
+ console.warn("Warning: minScaleCount must be greater than 1!");
57
+ minScaleCount = 20;
58
+ }
59
+ }
60
+ maxScaleCount = maxScaleCount === Infinity ? Infinity : parseInt(maxScaleCount + "");
61
+ if (maxScaleCount < 1) {
62
+ console.warn("Warning: maxScaleCount must be greater than 1!");
63
+ maxScaleCount = 20;
64
+ }
65
+ if (typeof minScaleCount === "number" && maxScaleCount < minScaleCount) {
66
+ console.warn("Warning: maxScaleCount cannot be less than minScaleCount!");
67
+ maxScaleCount = minScaleCount;
68
+ }
69
+ if (rowHeight <= 0) {
70
+ console.warn("Warning: rowHeight must be greater than 0!");
71
+ rowHeight = 32;
72
+ }
73
+ if (typeof collapsedRowHeight !== "undefined" && collapsedRowHeight <= 0) {
74
+ console.warn("Warning: collapsedRowHeight must be greater than 0!");
75
+ collapsedRowHeight = rowHeight;
76
+ }
77
+ if (editorData.some((row) => typeof row.collapsed?.height !== "undefined" && row.collapsed.height <= 0)) {
78
+ console.warn("Warning: collapsed row height must be greater than 0!");
79
+ editorData = editorData.map((row) => typeof row.collapsed?.height !== "undefined" && row.collapsed.height <= 0 ? {
80
+ ...row,
81
+ collapsed: {
82
+ ...row.collapsed,
83
+ height: void 0
84
+ }
85
+ } : row);
86
+ }
87
+ const temp = { ...props };
88
+ delete temp["style"];
89
+ return {
90
+ ...temp,
91
+ editorData,
92
+ effects,
93
+ scale,
94
+ scaleSplitCount,
95
+ scaleWidth,
96
+ startLeft,
97
+ minScaleCount,
98
+ maxScaleCount,
99
+ rowHeight,
100
+ collapsedRowHeight,
101
+ autoScrollSpeed,
102
+ autoScrollMaxSpeed
103
+ };
104
+ }
105
+ //#endregion
106
+ //#region src/utils/deal-class-prefix.ts
107
+ function prefix(...classNames) {
108
+ return (0, framework_utils.prefixNames)(`${require_deal_data.PREFIX}-`, ...classNames);
109
+ }
110
+ //#endregion
111
+ //#region src/components/edit_area/snap-lines.tsx
112
+ /** Drag auxiliary lines */
113
+ const SnapGuideLines = ({ isMoving, movePositions = [], assistPositions = [] }) => {
114
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
115
+ className: prefix("snap-line-container"),
116
+ children: isMoving && movePositions.filter((item) => assistPositions.includes(item)).map((linePos, index) => {
117
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
118
+ className: prefix("snap-line"),
119
+ style: { left: linePos }
120
+ }, index);
121
+ })
122
+ });
123
+ };
124
+ //#endregion
125
+ //#region src/components/row_rnd/hooks/use-auto-scroll.ts
126
+ const DEFAULT_SPEED = 1;
127
+ const MAX_SPEED = 10;
128
+ const CRITICAL_SIZE = 10;
129
+ function useAutoScroll(target, autoScrollSpeed = DEFAULT_SPEED, autoScrollMaxSpeed = MAX_SPEED) {
130
+ const leftBoundRef = (0, react$1.useRef)(Number.MIN_SAFE_INTEGER);
131
+ const rightBoundRef = (0, react$1.useRef)(Number.MAX_SAFE_INTEGER);
132
+ const speed = (0, react$1.useRef)(autoScrollSpeed);
133
+ const frame = (0, react$1.useRef)(void 0);
134
+ const initAutoScroll = () => {
135
+ if (target?.current) {
136
+ const { left, width } = target.current.getBoundingClientRect();
137
+ leftBoundRef.current = left;
138
+ rightBoundRef.current = left + width;
139
+ }
140
+ };
141
+ const dealDragAutoScroll = (e, deltaScroll) => {
142
+ if (e.clientX >= rightBoundRef.current || e.clientX <= leftBoundRef.current) {
143
+ if (frame.current !== void 0) cancelAnimationFrame(frame.current);
144
+ const over = Math.abs(e.clientX >= rightBoundRef.current ? e.clientX - rightBoundRef.current : e.clientX - leftBoundRef.current);
145
+ speed.current = Math.min(Math.max(Math.ceil(over / CRITICAL_SIZE) * autoScrollSpeed, autoScrollSpeed), autoScrollMaxSpeed);
146
+ const delta = (e.clientX >= rightBoundRef.current ? 1 : -1) * speed.current;
147
+ const loop = () => {
148
+ deltaScroll && deltaScroll(delta);
149
+ frame.current = requestAnimationFrame(loop);
150
+ };
151
+ frame.current = requestAnimationFrame(loop);
152
+ return false;
153
+ } else if (frame.current !== void 0) cancelAnimationFrame(frame.current);
154
+ return true;
155
+ };
156
+ const dealResizeAutoScroll = (e, _dir, deltaScroll) => {
157
+ if (e.clientX >= rightBoundRef.current || e.clientX < leftBoundRef.current) {
158
+ if (frame.current !== void 0) cancelAnimationFrame(frame.current);
159
+ const over = Math.abs(e.clientX >= rightBoundRef.current ? e.clientX - rightBoundRef.current : e.clientX - leftBoundRef.current);
160
+ speed.current = Math.min(Math.max(Math.ceil(over / CRITICAL_SIZE) * autoScrollSpeed, autoScrollSpeed), autoScrollMaxSpeed);
161
+ const delta = (e.clientX >= rightBoundRef.current ? 1 : -1) * speed.current;
162
+ const loop = () => {
163
+ deltaScroll && deltaScroll(delta);
164
+ frame.current = requestAnimationFrame(loop);
165
+ };
166
+ frame.current = requestAnimationFrame(loop);
167
+ return false;
168
+ } else if (frame.current !== void 0) cancelAnimationFrame(frame.current);
169
+ return true;
170
+ };
171
+ const stopAutoScroll = () => {
172
+ leftBoundRef.current = Number.MIN_SAFE_INTEGER;
173
+ rightBoundRef.current = Number.MAX_SAFE_INTEGER;
174
+ speed.current = autoScrollSpeed;
175
+ if (frame.current !== void 0) cancelAnimationFrame(frame.current);
176
+ };
177
+ return {
178
+ initAutoScroll,
179
+ dealDragAutoScroll,
180
+ dealResizeAutoScroll,
181
+ stopAutoScroll
182
+ };
183
+ }
184
+ //#endregion
185
+ //#region src/components/row_rnd/interactable.tsx
186
+ /**
187
+ * Helper function to create a GestureEvent from gesture state
188
+ */
189
+ const createGestureEvent = (target, delta, xy, edges, deltaRect) => ({
190
+ target,
191
+ dx: delta[0],
192
+ dy: delta[1],
193
+ clientX: xy[0],
194
+ clientY: xy[1],
195
+ ...edges && { edges },
196
+ ...deltaRect && { deltaRect }
197
+ });
198
+ /**
199
+ * Helper function to check if an event target is a resize handle
200
+ */
201
+ const isResizeHandle = (eventTarget, leftHandle, rightHandle) => {
202
+ if (!eventTarget) return false;
203
+ return eventTarget === leftHandle || eventTarget === rightHandle || (leftHandle?.contains(eventTarget) ?? false) || (rightHandle?.contains(eventTarget) ?? false);
204
+ };
205
+ const Interactable = ({ children, style, draggable, resizable, draggableOptions, resizableOptions, ref }) => {
206
+ const draggableOptionsRef = (0, react.useRef)(void 0);
207
+ const resizableOptionsRef = (0, react.useRef)(void 0);
208
+ const leftResizeHandleRef = (0, react.useRef)(null);
209
+ const rightResizeHandleRef = (0, react.useRef)(null);
210
+ (0, react.useLayoutEffect)(() => {
211
+ draggableOptionsRef.current = draggableOptions;
212
+ resizableOptionsRef.current = resizableOptions;
213
+ if (!ref?.current) return;
214
+ const currentLeftSelector = resizableOptions?.edges?.left;
215
+ const currentRightSelector = resizableOptions?.edges?.right;
216
+ const node = ref.current;
217
+ if (currentLeftSelector) leftResizeHandleRef.current = node.querySelector(currentLeftSelector);
218
+ if (currentRightSelector) rightResizeHandleRef.current = node.querySelector(currentRightSelector);
219
+ }, [
220
+ draggableOptions,
221
+ ref,
222
+ resizableOptions
223
+ ]);
224
+ (0, _use_gesture_react.useDrag)(({ active, delta, xy, event, first, last }) => {
225
+ const node = ref?.current;
226
+ if (!node) return;
227
+ if (isResizeHandle(event?.target, leftResizeHandleRef.current, rightResizeHandleRef.current)) return;
228
+ const gestureEvent = createGestureEvent(node, delta, xy);
229
+ if (first) draggableOptionsRef.current?.onstart?.(gestureEvent);
230
+ else if (last) draggableOptionsRef.current?.onend?.(gestureEvent);
231
+ else if (active) draggableOptionsRef.current?.onmove?.(gestureEvent);
232
+ }, {
233
+ enabled: draggable,
234
+ axis: draggableOptions?.lockAxis === "x" ? "x" : void 0,
235
+ pointer: { capture: true },
236
+ target: ref,
237
+ threshold: 0
238
+ });
239
+ (0, _use_gesture_react.useDrag)(({ active, delta, xy, first, last }) => {
240
+ const node = ref?.current;
241
+ if (!node) return;
242
+ const gestureEvent = createGestureEvent(node, delta, xy, { left: true }, { left: delta[0] });
243
+ if (first) resizableOptionsRef.current?.onstart?.(gestureEvent);
244
+ else if (last) resizableOptionsRef.current?.onend?.(gestureEvent);
245
+ else if (active) resizableOptionsRef.current?.onmove?.(gestureEvent);
246
+ }, {
247
+ enabled: resizable,
248
+ target: leftResizeHandleRef,
249
+ pointer: { capture: true },
250
+ threshold: 0
251
+ });
252
+ (0, _use_gesture_react.useDrag)(({ active, delta, xy, first, last }) => {
253
+ const node = ref?.current;
254
+ if (!node) return;
255
+ const gestureEvent = createGestureEvent(node, delta, xy, { right: true }, { right: delta[0] });
256
+ if (first) resizableOptionsRef.current?.onstart?.(gestureEvent);
257
+ else if (last) resizableOptionsRef.current?.onend?.(gestureEvent);
258
+ else if (active) resizableOptionsRef.current?.onmove?.(gestureEvent);
259
+ }, {
260
+ enabled: resizable,
261
+ target: rightResizeHandleRef,
262
+ pointer: { capture: true },
263
+ threshold: 0
264
+ });
265
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(radix_ui.Slot.Root, {
266
+ ref,
267
+ style: {
268
+ ...draggable ? { touchAction: "none" } : {},
269
+ ...style
270
+ },
271
+ draggable: false,
272
+ children
273
+ });
274
+ };
275
+ //#endregion
276
+ //#region src/components/row_rnd/row-rnd.tsx
277
+ const parseDatasetValue = (value, defaultValue = 0) => {
278
+ return value ? parseFloat(value) : defaultValue;
279
+ };
280
+ const calculateSnap = (position, snapPositions, snapDistance, minDis = Number.MAX_SAFE_INTEGER) => {
281
+ let snap = position;
282
+ let currentMinDis = minDis;
283
+ for (const item of snapPositions) {
284
+ const itemValue = typeof item === "number" ? item : item.value;
285
+ const dis = Math.abs(itemValue - position);
286
+ if (dis < snapDistance && dis < currentMinDis) {
287
+ snap = itemValue;
288
+ currentMinDis = dis;
289
+ }
290
+ }
291
+ return {
292
+ snap,
293
+ minDis: currentMinDis
294
+ };
295
+ };
296
+ function RowDnd({ children, edges, left, width, start = 20, grid = 1, getBounds = () => ({
297
+ left: Number.MIN_SAFE_INTEGER,
298
+ right: Number.MAX_SAFE_INTEGER
299
+ }), enableResizing = true, enableDragging = true, snapDistance = 8, snapPositions = [], snapOrigin = "leading", onResizeStart, onResize, onResizeEnd, onDragStart, onDragEnd, onDrag, parentRef, autoScroll = true, autoScrollSpeed, autoScrollMaxSpeed, ref }) {
300
+ const interactableRef = (0, react$1.useRef)(null);
301
+ const deltaX = (0, react$1.useRef)(0);
302
+ const isSnap = (0, react$1.useRef)(false);
303
+ const { initAutoScroll, stopAutoScroll, dealDragAutoScroll, dealResizeAutoScroll } = useAutoScroll(parentRef, autoScrollSpeed, autoScrollMaxSpeed);
304
+ const handleUpdateLeft = (left, reset = true) => {
305
+ if (!interactableRef.current) return;
306
+ if (reset) deltaX.current = 0;
307
+ const target = interactableRef.current;
308
+ target.style.setProperty("--translate-x", `${left}px`);
309
+ target.dataset.left = String(left);
310
+ };
311
+ const handleUpdateWidth = (width, reset = true) => {
312
+ if (!interactableRef.current) return;
313
+ if (reset) deltaX.current = 0;
314
+ const target = interactableRef.current;
315
+ target.style.width = `${width}px`;
316
+ target.dataset.width = String(width);
317
+ };
318
+ const handleGetLeft = () => {
319
+ if (!interactableRef.current) return 0;
320
+ return parseDatasetValue(interactableRef.current.dataset.left);
321
+ };
322
+ const handleGetWidth = () => {
323
+ if (!interactableRef.current) return 0;
324
+ return parseDatasetValue(interactableRef.current.dataset.width);
325
+ };
326
+ (0, react$1.useEffect)(() => {
327
+ if (!interactableRef.current) return;
328
+ const target = interactableRef.current;
329
+ handleUpdateWidth(typeof width === "undefined" ? target.offsetWidth : width, false);
330
+ }, [width]);
331
+ (0, react$1.useEffect)(() => {
332
+ handleUpdateLeft(left || 0, false);
333
+ }, [left]);
334
+ (0, react$1.useImperativeHandle)(ref, () => ({
335
+ updateLeft: (left) => handleUpdateLeft(left || 0, false),
336
+ updateWidth: (width) => handleUpdateWidth(width, false),
337
+ getLeft: handleGetLeft,
338
+ getWidth: handleGetWidth
339
+ }));
340
+ const handleMoveStart = () => {
341
+ deltaX.current = 0;
342
+ isSnap.current = false;
343
+ initAutoScroll();
344
+ onDragStart?.();
345
+ };
346
+ const move = (param) => {
347
+ const { preLeft, preWidth, scrollDelta } = param;
348
+ if (scrollDelta) deltaX.current += scrollDelta;
349
+ const distance = isSnap.current ? snapDistance : grid;
350
+ if (Math.abs(deltaX.current) < distance) return;
351
+ let curLeft = preLeft + Math.trunc(deltaX.current / distance) * distance;
352
+ const movingRight = deltaX.current > 0;
353
+ let checkPosition = curLeft;
354
+ if (snapOrigin === "leading") checkPosition = movingRight ? curLeft + preWidth : curLeft;
355
+ else if (snapOrigin === "right") checkPosition = curLeft + preWidth;
356
+ else if (snapOrigin === "center") checkPosition = curLeft + preWidth / 2;
357
+ const { snap: snapPosition } = calculateSnap(checkPosition, snapPositions, snapDistance);
358
+ if (snapPosition !== checkPosition) {
359
+ isSnap.current = true;
360
+ if (snapOrigin === "leading") curLeft = movingRight ? snapPosition - preWidth : snapPosition;
361
+ else if (snapOrigin === "right") curLeft = snapPosition - preWidth;
362
+ else if (snapOrigin === "center") curLeft = snapPosition - preWidth / 2;
363
+ else curLeft = snapPosition;
364
+ } else {
365
+ const offset = curLeft - start;
366
+ if (offset % grid !== 0) curLeft = start + grid * Math.round(offset / grid);
367
+ isSnap.current = false;
368
+ }
369
+ deltaX.current = deltaX.current % distance;
370
+ const bounds = getBounds();
371
+ if (curLeft < bounds.left) curLeft = bounds.left;
372
+ else if (curLeft + preWidth > bounds.right) curLeft = bounds.right - preWidth;
373
+ if (onDrag) {
374
+ if (onDrag({
375
+ lastLeft: preLeft,
376
+ left: curLeft,
377
+ lastWidth: preWidth,
378
+ width: preWidth
379
+ }, scrollDelta) === false) return;
380
+ }
381
+ handleUpdateLeft(curLeft, false);
382
+ };
383
+ const handleMove = (e) => {
384
+ const target = e.target;
385
+ const preLeft = parseDatasetValue(target.dataset.left);
386
+ const preWidth = parseDatasetValue(target.dataset.width);
387
+ deltaX.current += e.dx;
388
+ if (autoScroll && parentRef?.current) {
389
+ const deltaScroll = (delta) => {
390
+ if (!parentRef?.current || !interactableRef.current) return;
391
+ parentRef.current.scrollLeft += delta;
392
+ const currentTarget = interactableRef.current;
393
+ move({
394
+ preLeft: parseDatasetValue(currentTarget.dataset.left),
395
+ preWidth: parseDatasetValue(currentTarget.dataset.width),
396
+ scrollDelta: delta
397
+ });
398
+ };
399
+ if (!dealDragAutoScroll(e, deltaScroll)) return;
400
+ }
401
+ move({
402
+ preLeft,
403
+ preWidth
404
+ });
405
+ };
406
+ const handleMoveStop = (e) => {
407
+ deltaX.current = 0;
408
+ isSnap.current = false;
409
+ stopAutoScroll();
410
+ const target = e.target;
411
+ onDragEnd?.({
412
+ left: parseDatasetValue(target.dataset.left),
413
+ width: parseDatasetValue(target.dataset.width)
414
+ });
415
+ };
416
+ const handleResizeStart = (e) => {
417
+ deltaX.current = 0;
418
+ isSnap.current = false;
419
+ initAutoScroll();
420
+ const dir = e.edges?.right ? "right" : "left";
421
+ onResizeStart?.(dir);
422
+ };
423
+ const resize = (param) => {
424
+ const { dir, preWidth, preLeft, scrollDelta } = param;
425
+ if (scrollDelta) deltaX.current += scrollDelta;
426
+ const distance = isSnap.current ? snapDistance : grid;
427
+ if (Math.abs(deltaX.current) < distance) return;
428
+ const bounds = getBounds();
429
+ if (dir === "left") {
430
+ let curLeft = preLeft + Math.trunc(deltaX.current / distance) * distance;
431
+ const { snap } = calculateSnap(curLeft, snapPositions, snapDistance);
432
+ if (snap !== curLeft) {
433
+ isSnap.current = true;
434
+ curLeft = snap;
435
+ } else {
436
+ const offset = curLeft - start;
437
+ if (offset % grid !== 0) curLeft = start + grid * Math.round(offset / grid);
438
+ isSnap.current = false;
439
+ }
440
+ deltaX.current = deltaX.current % distance;
441
+ if (curLeft < bounds.left) curLeft = bounds.left;
442
+ const tempRight = preLeft + preWidth;
443
+ const curWidth = tempRight - curLeft;
444
+ if (curLeft >= tempRight) return;
445
+ if (onResize) {
446
+ if (onResize("left", {
447
+ lastLeft: preLeft,
448
+ lastWidth: preWidth,
449
+ left: curLeft,
450
+ width: curWidth
451
+ }) === false) return;
452
+ }
453
+ handleUpdateLeft(curLeft, false);
454
+ handleUpdateWidth(curWidth, false);
455
+ } else {
456
+ let curWidth = preWidth + Math.trunc(deltaX.current / distance) * distance;
457
+ const rightEdge = preLeft + curWidth;
458
+ const { snap } = calculateSnap(rightEdge, snapPositions, snapDistance);
459
+ if (snap !== rightEdge) {
460
+ isSnap.current = true;
461
+ curWidth = snap - preLeft;
462
+ } else {
463
+ let tempRight = preLeft + curWidth;
464
+ const offset = tempRight - start;
465
+ if (offset % grid !== 0) {
466
+ tempRight = start + grid * Math.round(offset / grid);
467
+ curWidth = tempRight - preLeft;
468
+ }
469
+ isSnap.current = false;
470
+ }
471
+ deltaX.current = deltaX.current % distance;
472
+ if (preLeft + curWidth > bounds.right) curWidth = bounds.right - preLeft;
473
+ if (curWidth <= 0) return;
474
+ if (onResize) {
475
+ if (onResize("right", {
476
+ lastLeft: preLeft,
477
+ lastWidth: preWidth,
478
+ left: preLeft,
479
+ width: curWidth
480
+ }) === false) return;
481
+ }
482
+ handleUpdateWidth(curWidth, false);
483
+ }
484
+ };
485
+ const handleResize = (e) => {
486
+ const target = e.target;
487
+ const dir = e.edges?.left ? "left" : "right";
488
+ const preLeft = parseDatasetValue(target.dataset.left);
489
+ const preWidth = parseDatasetValue(target.dataset.width);
490
+ deltaX.current += dir === "left" ? e.deltaRect?.left || 0 : e.deltaRect?.right || 0;
491
+ if (autoScroll && parentRef?.current) {
492
+ const deltaScroll = (delta) => {
493
+ if (!parentRef?.current || !interactableRef.current) return;
494
+ parentRef.current.scrollLeft += delta;
495
+ const currentTarget = interactableRef.current;
496
+ resize({
497
+ preLeft: parseDatasetValue(currentTarget.dataset.left),
498
+ preWidth: parseDatasetValue(currentTarget.dataset.width),
499
+ dir,
500
+ scrollDelta: delta
501
+ });
502
+ };
503
+ if (!dealResizeAutoScroll(e, dir, deltaScroll)) return;
504
+ }
505
+ resize({
506
+ preLeft,
507
+ preWidth,
508
+ dir
509
+ });
510
+ };
511
+ const handleResizeStop = (e) => {
512
+ deltaX.current = 0;
513
+ isSnap.current = false;
514
+ stopAutoScroll();
515
+ const target = e.target;
516
+ const dir = e.edges?.right ? "right" : "left";
517
+ onResizeEnd?.(dir, {
518
+ left: parseDatasetValue(target.dataset.left),
519
+ width: parseDatasetValue(target.dataset.width)
520
+ });
521
+ };
522
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Interactable, {
523
+ "data-left": left || 0,
524
+ style: {
525
+ "--translate-x": `${left || 0}px`,
526
+ transform: `translateX(var(--translate-x)) scaleX(var(--scale-x,1))`,
527
+ width
528
+ },
529
+ ref: interactableRef,
530
+ draggable: enableDragging,
531
+ resizable: enableResizing,
532
+ draggableOptions: {
533
+ lockAxis: "x",
534
+ onmove: handleMove,
535
+ onstart: handleMoveStart,
536
+ onend: handleMoveStop,
537
+ cursorChecker: () => ""
538
+ },
539
+ resizableOptions: {
540
+ axis: "x",
541
+ invert: "none",
542
+ edges,
543
+ onmove: handleResize,
544
+ onstart: handleResizeStart,
545
+ onend: handleResizeStop
546
+ },
547
+ children
548
+ });
549
+ }
550
+ //#endregion
551
+ //#region src/utils/clsx.ts
552
+ function clsx() {
553
+ let i = 0, tmp, str = "", len = arguments.length;
554
+ for (; i < len; i++) if (tmp = arguments[i]) {
555
+ if (typeof tmp === "string") str += (str && " ") + tmp;
556
+ }
557
+ return str;
558
+ }
559
+ //#endregion
560
+ //#region src/components/edit_area/edit-action.tsx
561
+ const EditAction = ({ editorData, row, rowRenderHeight, action, effects, scale, scaleWidth, scaleSplitCount, startLeft, gridSnap, disableDrag, autoScroll, autoScrollSpeed, autoScrollMaxSpeed, scaleCount, maxScaleCount, setScaleCount, onActionMoveStart, onActionMoving, onActionMoveEnd, onActionResizeStart, onActionResizeEnd, onActionResizing, snapData, setEditorData, onClickAction, onClickActionOnly, onDoubleClickAction, onContextMenuAction, getActionRender, handleTime, scrollContainerRef }) => {
562
+ const rowRnd = (0, react.useRef)(null);
563
+ const isDragWhenClick = (0, react.useRef)(false);
564
+ const { id, maxEnd, minStart, end, start, selected, flexible = true, movable = true, effectId } = action;
565
+ const safeScale = scale ?? 1;
566
+ const safeScaleWidth = scaleWidth ?? 160;
567
+ const safeStartLeft = startLeft ?? 20;
568
+ const safeScaleSplitCount = scaleSplitCount ?? 10;
569
+ const safeMaxScaleCount = maxScaleCount ?? Number.MAX_SAFE_INTEGER;
570
+ const leftLimit = require_deal_data.parserTimeToPixel(minStart || 0, {
571
+ startLeft: safeStartLeft,
572
+ scale: safeScale,
573
+ scaleWidth: safeScaleWidth
574
+ });
575
+ const rightLimit = Math.min(safeMaxScaleCount * safeScaleWidth + safeStartLeft, require_deal_data.parserTimeToPixel(maxEnd || Number.MAX_VALUE, {
576
+ startLeft: safeStartLeft,
577
+ scale: safeScale,
578
+ scaleWidth: safeScaleWidth
579
+ }));
580
+ const baseTransform = (0, react.useMemo)(() => {
581
+ return require_deal_data.parserTimeToTransform({
582
+ start,
583
+ end
584
+ }, {
585
+ startLeft: safeStartLeft,
586
+ scale: safeScale,
587
+ scaleWidth: safeScaleWidth
588
+ });
589
+ }, [
590
+ end,
591
+ start,
592
+ safeStartLeft,
593
+ safeScaleWidth,
594
+ safeScale
595
+ ]);
596
+ const [dragTransform, setDragTransform] = (0, react.useState)(null);
597
+ const transform = dragTransform ?? baseTransform;
598
+ const gridSize = safeScaleWidth / safeScaleSplitCount;
599
+ const classNames = prefix(clsx("action", movable && "action-movable", selected && "action-selected", flexible && "action-flexible", effects[effectId] && `action-effect-${effectId}`));
600
+ /** Calculate scale count */
601
+ const handleScaleCount = (left, width) => {
602
+ const curScaleCount = require_deal_data.getScaleCountByPixel(left + width, {
603
+ startLeft: safeStartLeft,
604
+ scaleCount,
605
+ scaleWidth: safeScaleWidth
606
+ });
607
+ if (curScaleCount !== scaleCount) setScaleCount(curScaleCount);
608
+ };
609
+ const handleDragStart = () => {
610
+ onActionMoveStart && onActionMoveStart({
611
+ action,
612
+ row
613
+ });
614
+ };
615
+ const handleDrag = ({ left, width }) => {
616
+ isDragWhenClick.current = true;
617
+ if (onActionMoving) {
618
+ const { start, end } = require_deal_data.parserTransformToTime({
619
+ left,
620
+ width
621
+ }, {
622
+ scaleWidth: safeScaleWidth,
623
+ scale: safeScale,
624
+ startLeft: safeStartLeft
625
+ });
626
+ if (onActionMoving({
627
+ action,
628
+ row,
629
+ start,
630
+ end
631
+ }) === false) return false;
632
+ }
633
+ setDragTransform({
634
+ left,
635
+ width
636
+ });
637
+ handleScaleCount(left, width);
638
+ };
639
+ const handleDragEnd = ({ left, width }) => {
640
+ const { start, end } = require_deal_data.parserTransformToTime({
641
+ left,
642
+ width
643
+ }, {
644
+ scaleWidth: safeScaleWidth,
645
+ scale: safeScale,
646
+ startLeft: safeStartLeft
647
+ });
648
+ const rowItem = editorData.find((item) => item.id === row.id);
649
+ if (!rowItem) return;
650
+ const actionItem = rowItem.actions.find((item) => item.id === id);
651
+ if (!actionItem) return;
652
+ actionItem.start = start;
653
+ actionItem.end = end;
654
+ setEditorData([...editorData]);
655
+ if (onActionMoveEnd) onActionMoveEnd({
656
+ action: actionItem,
657
+ row,
658
+ start,
659
+ end
660
+ });
661
+ setDragTransform(null);
662
+ };
663
+ const handleResizeStart = (dir) => {
664
+ onActionResizeStart && onActionResizeStart({
665
+ action,
666
+ row,
667
+ dir
668
+ });
669
+ };
670
+ const handleResizing = (dir, { left, width }) => {
671
+ isDragWhenClick.current = true;
672
+ if (onActionResizing) {
673
+ const { start, end } = require_deal_data.parserTransformToTime({
674
+ left,
675
+ width
676
+ }, {
677
+ scaleWidth: safeScaleWidth,
678
+ scale: safeScale,
679
+ startLeft: safeStartLeft
680
+ });
681
+ if (onActionResizing({
682
+ action,
683
+ row,
684
+ start,
685
+ end,
686
+ dir
687
+ }) === false) return false;
688
+ }
689
+ setDragTransform({
690
+ left,
691
+ width
692
+ });
693
+ handleScaleCount(left, width);
694
+ };
695
+ const handleResizeEnd = (dir, { left, width }) => {
696
+ const { start, end } = require_deal_data.parserTransformToTime({
697
+ left,
698
+ width
699
+ }, {
700
+ scaleWidth: safeScaleWidth,
701
+ scale: safeScale,
702
+ startLeft: safeStartLeft
703
+ });
704
+ const rowItem = editorData.find((item) => item.id === row.id);
705
+ if (!rowItem) return;
706
+ const actionItem = rowItem.actions.find((item) => item.id === id);
707
+ if (!actionItem) return;
708
+ actionItem.start = start;
709
+ actionItem.end = end;
710
+ setEditorData([...editorData]);
711
+ if (onActionResizeEnd) onActionResizeEnd({
712
+ action: actionItem,
713
+ row,
714
+ start,
715
+ end,
716
+ dir
717
+ });
718
+ setDragTransform(null);
719
+ };
720
+ const nowAction = {
721
+ ...action,
722
+ ...require_deal_data.parserTransformToTime({
723
+ left: transform.left,
724
+ width: transform.width
725
+ }, {
726
+ startLeft: safeStartLeft,
727
+ scaleWidth: safeScaleWidth,
728
+ scale: safeScale
729
+ })
730
+ };
731
+ const nowRow = {
732
+ ...row,
733
+ actions: [...row.actions]
734
+ };
735
+ if (row.actions.includes(action)) nowRow.actions[row.actions.indexOf(action)] = nowAction;
736
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RowDnd, {
737
+ ref: rowRnd,
738
+ parentRef: scrollContainerRef,
739
+ start: safeStartLeft,
740
+ left: transform.left,
741
+ width: transform.width,
742
+ grid: gridSnap && gridSize || 1,
743
+ snapDistance: gridSnap ? Math.max((gridSize || 1) / 2, 8) : 8,
744
+ snapPositions: snapData.assistPositions,
745
+ getBounds: () => {
746
+ return {
747
+ left: leftLimit,
748
+ right: rightLimit
749
+ };
750
+ },
751
+ edges: {
752
+ left: !disableDrag && flexible && `.${prefix("action-left-stretch")}`,
753
+ right: !disableDrag && flexible && `.${prefix("action-right-stretch")}`
754
+ },
755
+ enableDragging: !disableDrag && movable,
756
+ enableResizing: !disableDrag && flexible,
757
+ onDragStart: handleDragStart,
758
+ onDrag: handleDrag,
759
+ onDragEnd: handleDragEnd,
760
+ onResizeStart: handleResizeStart,
761
+ onResize: handleResizing,
762
+ onResizeEnd: handleResizeEnd,
763
+ autoScroll,
764
+ autoScrollSpeed,
765
+ autoScrollMaxSpeed,
766
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
767
+ onMouseDown: () => {
768
+ isDragWhenClick.current = false;
769
+ },
770
+ onClick: (e) => {
771
+ let time;
772
+ if (onClickAction) {
773
+ time = handleTime(e);
774
+ onClickAction(e, {
775
+ row,
776
+ action,
777
+ time
778
+ });
779
+ }
780
+ if (!isDragWhenClick.current && onClickActionOnly) {
781
+ if (time === void 0) time = handleTime(e);
782
+ onClickActionOnly(e, {
783
+ row,
784
+ action,
785
+ time
786
+ });
787
+ }
788
+ },
789
+ onDoubleClick: (e) => {
790
+ if (onDoubleClickAction) onDoubleClickAction(e, {
791
+ row,
792
+ action,
793
+ time: handleTime(e)
794
+ });
795
+ },
796
+ onContextMenu: (e) => {
797
+ if (onContextMenuAction) onContextMenuAction(e, {
798
+ row,
799
+ action,
800
+ time: handleTime(e)
801
+ });
802
+ },
803
+ className: classNames,
804
+ style: { height: rowRenderHeight },
805
+ children: [
806
+ getActionRender && getActionRender(nowAction, nowRow),
807
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
808
+ className: clsx(prefix("action-left-stretch")),
809
+ style: {
810
+ touchAction: "none",
811
+ visibility: flexible ? "visible" : "hidden",
812
+ pointerEvents: flexible ? "auto" : "none"
813
+ }
814
+ }),
815
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
816
+ className: prefix("action-right-stretch"),
817
+ style: {
818
+ touchAction: "none",
819
+ visibility: flexible ? "visible" : "hidden",
820
+ pointerEvents: flexible ? "auto" : "none"
821
+ }
822
+ })
823
+ ]
824
+ })
825
+ });
826
+ };
827
+ //#endregion
828
+ //#region src/components/edit_area/edit-row.tsx
829
+ const EditRow = (props) => {
830
+ const { rowData, rowRenderHeight, isCollapsed = false, style = {}, onClickRow, onDoubleClickRow, onContextMenuRow, scrollContainerRef, startLeft, scale, scaleWidth, unstable_rowActionsOverscan, getEmptyRowRender, getCollapsedRowLabelRender } = props;
831
+ const classNames = ["edit-row"];
832
+ if (rowData?.selected) classNames.push("edit-row-selected");
833
+ const safeScale = scale ?? 1;
834
+ const safeScaleWidth = scaleWidth ?? 160;
835
+ const safeStartLeft = startLeft ?? 20;
836
+ const handleTime = (e) => {
837
+ if (!scrollContainerRef.current) return 0;
838
+ const rect = e.currentTarget.getBoundingClientRect();
839
+ return require_deal_data.parserPixelToTime(e.clientX - rect.x, {
840
+ startLeft: safeStartLeft,
841
+ scale: safeScale,
842
+ scaleWidth: safeScaleWidth
843
+ });
844
+ };
845
+ const actions = (0, react.useMemo)(() => (rowData?.actions ? [...rowData.actions] : []).sort((a, b) => a.start - b.start), [rowData]);
846
+ const getItemKey = (0, react.useCallback)((index) => actions[index]?.id ?? index, [actions]);
847
+ const virtualizer = (0, _tanstack_react_virtual.useVirtualizer)({
848
+ horizontal: true,
849
+ count: actions.length,
850
+ getItemKey,
851
+ getScrollElement: () => scrollContainerRef.current,
852
+ estimateSize: (index) => {
853
+ if (!actions[index]) return 0;
854
+ let start = index > 0 ? actions[index - 1].end : 0;
855
+ let end = actions[index].end;
856
+ if (start > end) return 0;
857
+ let { width } = require_deal_data.parserTimeToTransform({
858
+ start,
859
+ end
860
+ }, {
861
+ startLeft: safeStartLeft,
862
+ scale: safeScale,
863
+ scaleWidth: safeScaleWidth
864
+ });
865
+ return width;
866
+ },
867
+ overscan: unstable_rowActionsOverscan ?? 5
868
+ });
869
+ (0, react.useEffect)(() => virtualizer.measure(), [
870
+ safeScale,
871
+ safeScaleWidth,
872
+ safeStartLeft,
873
+ virtualizer
874
+ ]);
875
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
876
+ className: `${prefix(...classNames)} ${(rowData?.classNames || []).join(" ")}`,
877
+ style,
878
+ onPointerEnter: props.onPointerEnter,
879
+ onPointerLeave: props.onPointerLeave,
880
+ onClick: (e) => {
881
+ if (rowData && onClickRow) onClickRow(e, {
882
+ row: rowData,
883
+ time: handleTime(e)
884
+ });
885
+ },
886
+ onDoubleClick: (e) => {
887
+ if (rowData && onDoubleClickRow) onDoubleClickRow(e, {
888
+ row: rowData,
889
+ time: handleTime(e)
890
+ });
891
+ },
892
+ onContextMenu: (e) => {
893
+ if (rowData && onContextMenuRow) onContextMenuRow(e, {
894
+ row: rowData,
895
+ time: handleTime(e)
896
+ });
897
+ },
898
+ children: [
899
+ rowData && isCollapsed && getCollapsedRowLabelRender && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
900
+ className: prefix("collapsed-row-label"),
901
+ "aria-hidden": "true",
902
+ children: getCollapsedRowLabelRender({
903
+ row: rowData,
904
+ height: rowRenderHeight
905
+ })
906
+ }),
907
+ rowData && actions.length === 0 && getEmptyRowRender && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
908
+ className: prefix("empty-row"),
909
+ children: getEmptyRowRender({
910
+ row: rowData,
911
+ height: rowRenderHeight
912
+ })
913
+ }),
914
+ rowData && virtualizer.getVirtualItems().map((virtualEntry) => {
915
+ const action = actions[virtualEntry.index];
916
+ if (!action) throw new Error("Action not found");
917
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EditAction, {
918
+ ...props,
919
+ handleTime,
920
+ row: rowData,
921
+ rowRenderHeight,
922
+ action
923
+ }, action.id);
924
+ })
925
+ ]
926
+ });
927
+ };
928
+ //#endregion
929
+ //#region src/components/edit_area/hooks/use-snap.ts
930
+ const useSnap = (props) => {
931
+ const [snapData, setSnapData] = (0, react$1.useState)({
932
+ isMoving: false,
933
+ movePositions: [],
934
+ assistPositions: []
935
+ });
936
+ const activeDragStateRef = (0, react$1.useRef)(null);
937
+ const snapDataRef = (0, react$1.useEffectEvent)(() => ({
938
+ ...props,
939
+ snapData
940
+ }));
941
+ (0, react$1.useEffect)(() => {
942
+ const activeDragState = activeDragStateRef.current;
943
+ const currentProps = snapDataRef();
944
+ if (currentProps.snap && activeDragState && currentProps.snapData.isMoving && currentProps.snapPositions) {
945
+ const assistActionIds = activeDragState.assistActionIds;
946
+ const assistPositions = currentProps.snapPositions.filter((pos) => {
947
+ if (pos.actionId === activeDragState.action.id) return false;
948
+ if (assistActionIds && !assistActionIds.includes(pos.actionId)) return false;
949
+ return true;
950
+ }).map((pos) => pos.value);
951
+ if (!currentProps.hideCursor) {
952
+ const cursorLeft = require_deal_data.parserTimeToPixel(currentProps.cursorTime, {
953
+ scaleWidth: currentProps.scaleWidth ?? 160,
954
+ scale: currentProps.scale ?? 1,
955
+ startLeft: currentProps.startLeft ?? 20
956
+ });
957
+ assistPositions.push(cursorLeft);
958
+ }
959
+ setSnapData((pre) => ({
960
+ ...pre,
961
+ assistPositions
962
+ }));
963
+ } else if (!currentProps.snap && currentProps.snapData.isMoving) setSnapData((pre) => ({
964
+ ...pre,
965
+ assistPositions: []
966
+ }));
967
+ }, [props.snap]);
968
+ const handleInitSnap = (data) => {
969
+ const assistActionIds = props.getAssistDragLineActionIds && props.getAssistDragLineActionIds({
970
+ action: data.action,
971
+ row: data.row,
972
+ editorData: props.editorData
973
+ });
974
+ activeDragStateRef.current = {
975
+ action: data.action,
976
+ row: data.row,
977
+ assistActionIds
978
+ };
979
+ if (props.snap && props.snapPositions) {
980
+ const assistPositions = props.snapPositions.filter((pos) => {
981
+ if (pos.actionId === data.action.id) return false;
982
+ if (assistActionIds && !assistActionIds.includes(pos.actionId)) return false;
983
+ return true;
984
+ }).map((pos) => pos.value);
985
+ if (!props.hideCursor) {
986
+ const cursorLeft = require_deal_data.parserTimeToPixel(props.cursorTime, {
987
+ scaleWidth: props.scaleWidth ?? 160,
988
+ scale: props.scale ?? 1,
989
+ startLeft: props.startLeft ?? 20
990
+ });
991
+ assistPositions.push(cursorLeft);
992
+ }
993
+ setSnapData({
994
+ isMoving: true,
995
+ movePositions: [],
996
+ assistPositions
997
+ });
998
+ } else setSnapData({
999
+ isMoving: true,
1000
+ movePositions: [],
1001
+ assistPositions: []
1002
+ });
1003
+ };
1004
+ const handleUpdateSnap = (data) => {
1005
+ if (props.snap) {
1006
+ const currentScaleWidth = props.scaleWidth ?? 160;
1007
+ const currentScale = props.scale ?? 1;
1008
+ const currentStartLeft = props.startLeft ?? 20;
1009
+ const { left, width } = require_deal_data.parserTimeToTransform({
1010
+ start: data.start,
1011
+ end: data.end
1012
+ }, {
1013
+ startLeft: currentStartLeft,
1014
+ scaleWidth: currentScaleWidth,
1015
+ scale: currentScale
1016
+ });
1017
+ const movePositions = data.dir ? data.dir === "right" ? [left + width] : [left] : [left, left + width];
1018
+ setSnapData((pre) => ({
1019
+ ...pre,
1020
+ movePositions
1021
+ }));
1022
+ }
1023
+ };
1024
+ const disposeSnap = () => {
1025
+ activeDragStateRef.current = null;
1026
+ setSnapData({
1027
+ isMoving: false,
1028
+ movePositions: [],
1029
+ assistPositions: []
1030
+ });
1031
+ };
1032
+ return {
1033
+ snapData,
1034
+ handleInitSnap,
1035
+ handleUpdateSnap,
1036
+ disposeSnap
1037
+ };
1038
+ };
1039
+ //#endregion
1040
+ //#region src/utils/row-layout.ts
1041
+ function getTimelineRowPresentation(params) {
1042
+ const layouts = [];
1043
+ let totalHeight = 0;
1044
+ const collapsibleRowIds = new Set(params.editorData.filter((row) => row.collapsed).map((row) => row.id));
1045
+ const defaultExpandedRowIds = params.editorData.filter((row) => row.collapsed?.expandedByDefault).map((row) => row.id);
1046
+ const focusedRowId = (params.lockedRowId && collapsibleRowIds.has(params.lockedRowId) ? params.lockedRowId : null) ?? (params.hoveredRowId && collapsibleRowIds.has(params.hoveredRowId) ? params.hoveredRowId : null) ?? defaultExpandedRowIds[0] ?? null;
1047
+ for (const row of params.editorData) {
1048
+ const expandedHeight = row.rowHeight || params.rowHeight;
1049
+ const collapsedHeight = row.collapsed?.height ?? params.collapsedRowHeight;
1050
+ const isCollapsed = Boolean(row.collapsed && row.id !== focusedRowId);
1051
+ const height = isCollapsed ? collapsedHeight : expandedHeight;
1052
+ layouts.push({
1053
+ row,
1054
+ top: totalHeight,
1055
+ height,
1056
+ isCollapsed
1057
+ });
1058
+ totalHeight += height;
1059
+ }
1060
+ return {
1061
+ layouts,
1062
+ totalHeight,
1063
+ defaultExpandedRowIds
1064
+ };
1065
+ }
1066
+ //#endregion
1067
+ //#region src/components/edit_area/edit-area.tsx
1068
+ const EditArea = ({ ref, ...props }) => {
1069
+ const { snapData, handleInitSnap, handleUpdateSnap, disposeSnap } = useSnap({
1070
+ snap: props.snap,
1071
+ hideCursor: props.hideCursor,
1072
+ cursorTime: props.cursorTime,
1073
+ scaleWidth: props.scaleWidth,
1074
+ scale: props.scale,
1075
+ startLeft: props.startLeft,
1076
+ getAssistDragLineActionIds: props.getAssistDragLineActionIds,
1077
+ editorData: props.editorData,
1078
+ snapPositions: props.snapPositions
1079
+ });
1080
+ const currentScaleWidth = props.scaleWidth ?? 160;
1081
+ const currentStartLeft = props.startLeft ?? 20;
1082
+ const contentWidth = Math.max(props.scaleCount * currentScaleWidth + currentStartLeft, props.timelineWidth);
1083
+ const rows = (() => {
1084
+ let result = [];
1085
+ for (const { row, top, height, isCollapsed } of props.rowLayouts) result.push(/* @__PURE__ */ (0, react.createElement)(EditRow, {
1086
+ ...props,
1087
+ key: row.id,
1088
+ rowData: row,
1089
+ rowRenderHeight: height,
1090
+ isCollapsed,
1091
+ snapData,
1092
+ scrollContainerRef: props.scrollElementRef,
1093
+ style: {
1094
+ position: "absolute",
1095
+ top: 0,
1096
+ left: 0,
1097
+ width: contentWidth,
1098
+ height: `${height}px`,
1099
+ transform: `translateY(${top}px)`
1100
+ },
1101
+ onPointerEnter: () => {
1102
+ if (row.collapsed) props.setHoveredRowId(row.id);
1103
+ },
1104
+ onPointerLeave: () => {
1105
+ props.clearHoveredRowId(row.id);
1106
+ },
1107
+ onActionMoveStart: (data) => {
1108
+ if (row.collapsed) props.setLockedRowId(row.id);
1109
+ handleInitSnap(data);
1110
+ return props.onActionMoveStart && props.onActionMoveStart(data);
1111
+ },
1112
+ onActionResizeStart: (data) => {
1113
+ if (row.collapsed) props.setLockedRowId(row.id);
1114
+ handleInitSnap(data);
1115
+ return props.onActionResizeStart && props.onActionResizeStart(data);
1116
+ },
1117
+ onActionMoving: (data) => {
1118
+ handleUpdateSnap(data);
1119
+ return props.onActionMoving && props.onActionMoving(data);
1120
+ },
1121
+ onActionResizing: (data) => {
1122
+ handleUpdateSnap(data);
1123
+ return props.onActionResizing && props.onActionResizing(data);
1124
+ },
1125
+ onActionResizeEnd: (data) => {
1126
+ props.setLockedRowId(null);
1127
+ disposeSnap();
1128
+ return props.onActionResizeEnd && props.onActionResizeEnd(data);
1129
+ },
1130
+ onActionMoveEnd: (data) => {
1131
+ props.setLockedRowId(null);
1132
+ disposeSnap();
1133
+ return props.onActionMoveEnd && props.onActionMoveEnd(data);
1134
+ }
1135
+ }));
1136
+ return result;
1137
+ })();
1138
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1139
+ ref,
1140
+ style: {
1141
+ width: contentWidth,
1142
+ height: props.rowLayoutsTotalHeight,
1143
+ position: "relative",
1144
+ backgroundPositionX: `0, ${props.startLeft ?? 20}px`,
1145
+ backgroundSize: `${props.startLeft ?? 20}px, ${props.scaleWidth ?? 160}px`
1146
+ },
1147
+ className: "timeline-editor-edit-area",
1148
+ children: [rows, props.snap && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SnapGuideLines, { ...snapData })]
1149
+ });
1150
+ };
1151
+ //#endregion
1152
+ //#region src/components/time_area/time-area.tsx
1153
+ function TimeArea({ scaleSplitCount, scaleWidth, startLeft, scaleCount, maxScaleCount, scale, scrollElementRef, onClickTimeArea, setCursor, getScaleRender }) {
1154
+ const splitCount = scaleSplitCount ?? 1;
1155
+ const width = scaleWidth ?? 160;
1156
+ const left = startLeft ?? 20;
1157
+ /** Whether to show sub-scale marks */
1158
+ const showUnit = (scaleSplitCount ?? 0) > 0;
1159
+ const columnCount = showUnit ? scaleCount * (scaleSplitCount ?? 1) + 1 : scaleCount;
1160
+ const totalWidth = (showUnit ? width / splitCount : width) * (columnCount - 1) + left;
1161
+ const getColumnWidth = (index) => {
1162
+ switch (index) {
1163
+ case 0: return left;
1164
+ default: return showUnit ? width / splitCount : width;
1165
+ }
1166
+ };
1167
+ const virtualizer = (0, _tanstack_react_virtual.useVirtualizer)({
1168
+ horizontal: true,
1169
+ count: columnCount,
1170
+ getScrollElement: () => scrollElementRef.current,
1171
+ estimateSize: getColumnWidth,
1172
+ overscan: 10
1173
+ });
1174
+ (0, react.useEffect)(() => virtualizer.measure(), [
1175
+ scale,
1176
+ scaleWidth,
1177
+ startLeft,
1178
+ virtualizer
1179
+ ]);
1180
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1181
+ style: { width: `${totalWidth}px` },
1182
+ className: prefix("time-area"),
1183
+ onClick: (e) => {
1184
+ const leftStart = startLeft ?? 20;
1185
+ const widthValue = scaleWidth ?? 160;
1186
+ const scaleValue = scale ?? 1;
1187
+ const maxCount = maxScaleCount ?? Infinity;
1188
+ const rect = e.currentTarget.getBoundingClientRect();
1189
+ const position = e.clientX - rect.x;
1190
+ const left = Math.max(position, leftStart);
1191
+ if (left > maxCount * widthValue + leftStart) return;
1192
+ const time = require_deal_data.parserPixelToTime(left, {
1193
+ startLeft: leftStart,
1194
+ scale: scaleValue,
1195
+ scaleWidth: widthValue
1196
+ });
1197
+ onClickTimeArea && onClickTimeArea(time, e);
1198
+ if (e.defaultPrevented) return;
1199
+ setCursor({ time });
1200
+ },
1201
+ children: virtualizer.getVirtualItems().map((virtualColumn) => {
1202
+ const columnIndex = virtualColumn.index;
1203
+ const splitCount = scaleSplitCount ?? 1;
1204
+ const scaleValue = scale ?? 1;
1205
+ const isShowScale = showUnit ? columnIndex % splitCount === 0 : true;
1206
+ const classNames = [prefix("time-unit"), isShowScale ? prefix("time-unit-big") : prefix("time-unit-small")];
1207
+ const item = (showUnit ? columnIndex / splitCount : columnIndex) * scaleValue;
1208
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1209
+ "data-index": virtualColumn.index,
1210
+ style: {
1211
+ width: `${virtualColumn.size}px`,
1212
+ transform: `translateX(${virtualColumn.start}px)`
1213
+ },
1214
+ className: classNames.join(" "),
1215
+ children: isShowScale && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1216
+ className: prefix("time-unit-scale"),
1217
+ children: getScaleRender?.(item) ?? item
1218
+ })
1219
+ }, virtualColumn.key);
1220
+ })
1221
+ });
1222
+ }
1223
+ //#endregion
1224
+ //#region src/utils/with-hook.tsx
1225
+ function withHooks(hook) {
1226
+ const Component = ({ children, ...params }) => {
1227
+ return children(hook(params));
1228
+ };
1229
+ Component.displayName = `withHooks(${hook.name || "Hook"})`;
1230
+ return Component;
1231
+ }
1232
+ //#endregion
1233
+ //#region src/utils/measured.tsx
1234
+ function useMeasure({ elementRef }) {
1235
+ const [size, setSize] = (0, react.useState)({
1236
+ width: 0,
1237
+ height: 0
1238
+ });
1239
+ (0, react.useLayoutEffect)(() => {
1240
+ if (!elementRef.current) return;
1241
+ (0, motion.resize)(elementRef.current, (_el, size) => {
1242
+ setSize({
1243
+ width: size.width,
1244
+ height: size.height
1245
+ });
1246
+ });
1247
+ }, [elementRef]);
1248
+ return size;
1249
+ }
1250
+ withHooks(useMeasure);
1251
+ //#endregion
1252
+ //#region src/components/cursor/cursor.tsx
1253
+ const Cursor = ({ disableDrag, height, cursorTime, setCursor, startLeft, scaleWidth, scale, scaleCount, scaleSplitCount, scrollElementRef, maxScaleCount, onCursorDragStart, onCursorDrag, onCursorDragEnd, cursorSnap, autoScrollSpeed, autoScrollMaxSpeed, snapPositions = [] }) => {
1254
+ const rowRnd = (0, react.useRef)(null);
1255
+ const leftStart = startLeft ?? 20;
1256
+ const width = scaleWidth ?? 160;
1257
+ const scaleValue = scale ?? 1;
1258
+ const activeSnapPositions = !cursorSnap ? [] : snapPositions;
1259
+ (0, react.useEffect)(() => {
1260
+ if (rowRnd.current) {
1261
+ const left = startLeft ?? 20;
1262
+ const width = scaleWidth ?? 160;
1263
+ const scaleValue = scale ?? 1;
1264
+ rowRnd.current.updateLeft(require_deal_data.parserTimeToPixel(cursorTime, {
1265
+ startLeft: left,
1266
+ scaleWidth: width,
1267
+ scale: scaleValue
1268
+ }));
1269
+ }
1270
+ }, [
1271
+ cursorTime,
1272
+ startLeft,
1273
+ scaleWidth,
1274
+ scale
1275
+ ]);
1276
+ const maxCount = maxScaleCount ?? Infinity;
1277
+ const showUnit = (scaleSplitCount ?? 0) > 0;
1278
+ const splitCount = scaleSplitCount ?? 1;
1279
+ const columnCount = showUnit ? scaleCount * (scaleSplitCount ?? 1) + 1 : scaleCount;
1280
+ const left = startLeft ?? 20;
1281
+ const totalWidth = (showUnit ? width / splitCount : width) * (columnCount - 1) + left;
1282
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RowDnd, {
1283
+ start: leftStart,
1284
+ ref: rowRnd,
1285
+ parentRef: scrollElementRef,
1286
+ getBounds: () => {
1287
+ return {
1288
+ left: 0,
1289
+ right: Math.min(totalWidth, maxCount * width + leftStart - (scrollElementRef.current?.scrollLeft ?? 0))
1290
+ };
1291
+ },
1292
+ autoScroll: true,
1293
+ autoScrollSpeed,
1294
+ autoScrollMaxSpeed,
1295
+ enableDragging: !disableDrag,
1296
+ enableResizing: false,
1297
+ snapPositions: activeSnapPositions,
1298
+ snapDistance: 8,
1299
+ snapOrigin: "left",
1300
+ onDragStart: () => {
1301
+ const time = require_deal_data.parserPixelToTime(rowRnd.current?.getLeft() ?? require_deal_data.parserTimeToPixel(cursorTime, {
1302
+ startLeft: leftStart,
1303
+ scaleWidth: width,
1304
+ scale: scaleValue
1305
+ }), {
1306
+ startLeft: leftStart,
1307
+ scale: scaleValue,
1308
+ scaleWidth: width
1309
+ });
1310
+ onCursorDragStart && onCursorDragStart(time);
1311
+ },
1312
+ onDragEnd: ({ left }) => {
1313
+ const time = require_deal_data.parserPixelToTime(left, {
1314
+ startLeft: leftStart,
1315
+ scale: scaleValue,
1316
+ scaleWidth: width
1317
+ });
1318
+ setCursor({ time });
1319
+ onCursorDragEnd && onCursorDragEnd(time);
1320
+ },
1321
+ onDrag: ({ left }) => {
1322
+ const time = require_deal_data.parserPixelToTime(left, {
1323
+ startLeft: leftStart,
1324
+ scale: scaleValue,
1325
+ scaleWidth: width
1326
+ });
1327
+ setCursor({ time });
1328
+ onCursorDrag && onCursorDrag(time);
1329
+ },
1330
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1331
+ className: prefix("cursor"),
1332
+ style: { height },
1333
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
1334
+ className: prefix("cursor-top"),
1335
+ width: "8",
1336
+ height: "12",
1337
+ viewBox: "0 0 8 12",
1338
+ fill: "none",
1339
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
1340
+ d: "M0 1C0 0.447715 0.447715 0 1 0H7C7.55228 0 8 0.447715 8 1V9.38197C8 9.76074 7.786 10.107 7.44721 10.2764L4.44721 11.7764C4.16569 11.9172 3.83431 11.9172 3.55279 11.7764L0.552786 10.2764C0.214002 10.107 0 9.76074 0 9.38197V1Z",
1341
+ fill: "currentColor"
1342
+ })
1343
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: prefix("cursor-area") })]
1344
+ })
1345
+ });
1346
+ };
1347
+ //#endregion
1348
+ //#region src/components/scroll-area.tsx
1349
+ function ScrollBar({ className, orientation = "vertical", ...props }) {
1350
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(radix_ui.ScrollArea.ScrollAreaScrollbar, {
1351
+ "data-slot": "scroll-area-scrollbar",
1352
+ orientation,
1353
+ className,
1354
+ ...props,
1355
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(radix_ui.ScrollArea.ScrollAreaThumb, { "data-slot": "scroll-area-thumb" })
1356
+ });
1357
+ }
1358
+ //#endregion
1359
+ //#region src/components/hooks/use-stable-scroll.ts
1360
+ /**
1361
+ * Hook to maintain scroll position stability when scale or scaleWidth changes.
1362
+ * Uses the cursor time as a reference point to keep it visually stable.
1363
+ */
1364
+ function useStableScroll({ scrollElementRef, scale, scaleWidth, startLeft, cursorTimeRef }) {
1365
+ const prevScaleRef = (0, react$1.useRef)(null);
1366
+ const prevScaleWidthRef = (0, react$1.useRef)(null);
1367
+ (0, react$1.useLayoutEffect)(() => {
1368
+ const scrollElement = scrollElementRef.current;
1369
+ if (prevScaleRef.current !== null && prevScaleWidthRef.current !== null && scrollElement && (prevScaleRef.current !== scale || prevScaleWidthRef.current !== scaleWidth)) {
1370
+ const currentScrollLeft = scrollElement.scrollLeft;
1371
+ const cursorTime = cursorTimeRef.current;
1372
+ const oldCursorPixelPosition = require_deal_data.parserTimeToPixel(cursorTime, {
1373
+ startLeft,
1374
+ scale: prevScaleRef.current,
1375
+ scaleWidth: prevScaleWidthRef.current
1376
+ });
1377
+ scrollElement.scrollLeft = require_deal_data.parserTimeToPixel(cursorTime, {
1378
+ startLeft,
1379
+ scale,
1380
+ scaleWidth
1381
+ }) - (oldCursorPixelPosition - currentScrollLeft);
1382
+ }
1383
+ prevScaleRef.current = scale;
1384
+ prevScaleWidthRef.current = scaleWidth;
1385
+ }, [
1386
+ scale,
1387
+ scaleWidth,
1388
+ startLeft,
1389
+ scrollElementRef,
1390
+ cursorTimeRef
1391
+ ]);
1392
+ }
1393
+ //#endregion
1394
+ //#region src/components/timeline.tsx
1395
+ function Timeline({ ref, ...props }) {
1396
+ const timelineProps = withDefaults(props);
1397
+ const domRef = (0, react.useRef)(null);
1398
+ const warnedDefaultRowsRef = (0, react.useRef)("");
1399
+ const { width, height } = useMeasure({ elementRef: domRef });
1400
+ const [hoveredRowId, setHoveredRowId] = (0, react.useState)(null);
1401
+ const [lockedRowId, setLockedRowId] = (0, react.useState)(null);
1402
+ const editorAreaKey = props.unstable_forceRemountEditorArea ?? 0;
1403
+ const minScaleCount = timelineProps.minScaleCount ?? Math.max(require_deal_data.getScaleCountByRows(timelineProps.editorData, {
1404
+ scale: timelineProps.scale,
1405
+ pad: .1
1406
+ }), Math.ceil((width - timelineProps.startLeft) / timelineProps.scaleWidth));
1407
+ const derivedScaleCount = Math.min(timelineProps.maxScaleCount, minScaleCount);
1408
+ const snapPositions = !timelineProps.editorData ? [] : require_deal_data.parserActionsToPositions(timelineProps.editorData.flatMap((row) => row.actions), {
1409
+ startLeft: timelineProps.startLeft,
1410
+ scale: timelineProps.scale,
1411
+ scaleWidth: timelineProps.scaleWidth
1412
+ });
1413
+ const [overrideScaleCount, setOverrideScaleCount] = (0, react.useState)(null);
1414
+ (0, react.useLayoutEffect)(() => {
1415
+ setOverrideScaleCount(null);
1416
+ }, [derivedScaleCount]);
1417
+ const scaleCount = overrideScaleCount ?? derivedScaleCount;
1418
+ const rowPresentation = getTimelineRowPresentation({
1419
+ editorData: timelineProps.editorData,
1420
+ rowHeight: timelineProps.rowHeight,
1421
+ collapsedRowHeight: timelineProps.collapsedRowHeight ?? timelineProps.rowHeight,
1422
+ hoveredRowId,
1423
+ lockedRowId
1424
+ });
1425
+ const duplicateDefaultRowsKey = rowPresentation.defaultExpandedRowIds.join("\n");
1426
+ if (rowPresentation.defaultExpandedRowIds.length > 1 && warnedDefaultRowsRef.current !== duplicateDefaultRowsKey) {
1427
+ warnedDefaultRowsRef.current = duplicateDefaultRowsKey;
1428
+ console.warn("Warning: multiple collapsible rows set expandedByDefault. The first row in editorData wins.");
1429
+ }
1430
+ /** Dynamically set scale count - overrides the derived value */
1431
+ const handleSetScaleCount = (value) => {
1432
+ setOverrideScaleCount(Math.min(timelineProps.maxScaleCount, value));
1433
+ };
1434
+ const [cursorTime, setCursorTime] = (0, react.useState)(0);
1435
+ const cursorTimeRef = (0, react.useRef)(0);
1436
+ useStableScroll({
1437
+ scrollElementRef: domRef,
1438
+ scale: timelineProps.scale,
1439
+ scaleWidth: timelineProps.scaleWidth,
1440
+ startLeft: timelineProps.startLeft,
1441
+ cursorTimeRef
1442
+ });
1443
+ /** Handle editor data changes */
1444
+ const handleEditorDataChange = (editorData) => {
1445
+ timelineProps.onChange?.(editorData);
1446
+ };
1447
+ /** Handle cursor */
1448
+ const handleSetCursor = (param) => {
1449
+ let { left, time } = param;
1450
+ if (typeof time !== "undefined") {
1451
+ setCursorTime(time);
1452
+ cursorTimeRef.current = time;
1453
+ return true;
1454
+ }
1455
+ if (typeof left !== "undefined") {
1456
+ setCursorTime(cursorTimeRef.current = require_deal_data.parserPixelToTime(left, {
1457
+ startLeft: timelineProps.startLeft,
1458
+ scale: timelineProps.scale,
1459
+ scaleWidth: timelineProps.scaleWidth
1460
+ }));
1461
+ return true;
1462
+ }
1463
+ return false;
1464
+ };
1465
+ const handleScrollToTime = (time, options = {}) => {
1466
+ const element = domRef.current;
1467
+ if (!element) return;
1468
+ const { block = "start", offset = 0, onlyIfNotVisible = false } = options;
1469
+ const target = require_deal_data.parserTimeToPixel(time, {
1470
+ startLeft: timelineProps.startLeft,
1471
+ scale: timelineProps.scale,
1472
+ scaleWidth: timelineProps.scaleWidth
1473
+ });
1474
+ const viewportWidth = element.clientWidth;
1475
+ if (onlyIfNotVisible) {
1476
+ const currentScrollLeft = element.scrollLeft;
1477
+ if (target >= currentScrollLeft && target <= currentScrollLeft + viewportWidth) return;
1478
+ }
1479
+ let targetScrollLeft;
1480
+ if (block === "end") targetScrollLeft = target - viewportWidth + offset;
1481
+ else if (block === "center") targetScrollLeft = target - viewportWidth / 2;
1482
+ else targetScrollLeft = target - offset;
1483
+ const maxScrollLeft = Math.max(0, element.scrollWidth - viewportWidth);
1484
+ element.scrollTo({
1485
+ left: Math.min(Math.max(targetScrollLeft, 0), maxScrollLeft),
1486
+ behavior: options.behavior ?? "instant"
1487
+ });
1488
+ };
1489
+ (0, react.useImperativeHandle)(ref, () => ({
1490
+ get target() {
1491
+ return domRef.current;
1492
+ },
1493
+ set time(time) {
1494
+ handleSetCursor({ time });
1495
+ },
1496
+ get time() {
1497
+ return cursorTimeRef.current;
1498
+ },
1499
+ getTime() {
1500
+ return cursorTimeRef.current;
1501
+ },
1502
+ setTime(time) {
1503
+ handleSetCursor({ time });
1504
+ },
1505
+ getTimePixelPosition(time) {
1506
+ return require_deal_data.parserTimeToPixel(time ?? cursorTimeRef.current, {
1507
+ startLeft: timelineProps.startLeft,
1508
+ scale: timelineProps.scale,
1509
+ scaleWidth: timelineProps.scaleWidth
1510
+ });
1511
+ },
1512
+ setScrollLeft: (val) => {
1513
+ if (!domRef.current) return;
1514
+ domRef.current.scrollLeft = val;
1515
+ },
1516
+ setScrollTop: (val) => {
1517
+ if (!domRef.current) return;
1518
+ domRef.current.scrollTop = val;
1519
+ },
1520
+ get scrollLeft() {
1521
+ if (!domRef.current) return 0;
1522
+ return domRef.current.scrollLeft;
1523
+ },
1524
+ get scrollTop() {
1525
+ if (!domRef.current) return 0;
1526
+ return domRef.current.scrollTop;
1527
+ },
1528
+ set scrollLeft(val) {
1529
+ if (!domRef.current) return;
1530
+ domRef.current.scrollLeft = val;
1531
+ },
1532
+ set scrollTop(val) {
1533
+ if (!domRef.current) return;
1534
+ domRef.current.scrollTop = val;
1535
+ },
1536
+ scrollToTime: handleScrollToTime
1537
+ }));
1538
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(radix_ui.ScrollArea.Root, {
1539
+ style: timelineProps.style,
1540
+ className: `${require_deal_data.PREFIX} ${timelineProps.disableDrag ? require_deal_data.PREFIX + "-disable" : ""}`,
1541
+ "data-slot": "scroll-area",
1542
+ children: [
1543
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(radix_ui.ScrollArea.Viewport, {
1544
+ "data-slot": "scroll-area-viewport",
1545
+ ref: domRef,
1546
+ onScroll: (e) => {
1547
+ timelineProps.onScroll?.(e.currentTarget);
1548
+ },
1549
+ children: [
1550
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TimeArea, {
1551
+ ...timelineProps,
1552
+ setCursor: handleSetCursor,
1553
+ scaleCount,
1554
+ scrollElementRef: domRef
1555
+ }),
1556
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EditArea, {
1557
+ ...timelineProps,
1558
+ scrollElementRef: domRef,
1559
+ timelineWidth: width,
1560
+ timelineHeight: height,
1561
+ disableDrag: timelineProps.disableDrag,
1562
+ editorData: timelineProps.editorData,
1563
+ cursorTime,
1564
+ scaleCount,
1565
+ setScaleCount: handleSetScaleCount,
1566
+ setEditorData: handleEditorDataChange,
1567
+ snapPositions,
1568
+ rowLayouts: rowPresentation.layouts,
1569
+ rowLayoutsTotalHeight: rowPresentation.totalHeight,
1570
+ setHoveredRowId,
1571
+ clearHoveredRowId: (rowId) => {
1572
+ setHoveredRowId((currentRowId) => currentRowId === rowId ? null : currentRowId);
1573
+ },
1574
+ setLockedRowId
1575
+ }, `__editor_area_${editorAreaKey}__`),
1576
+ !timelineProps.hideCursor && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Cursor, {
1577
+ ...timelineProps,
1578
+ timelineWidth: width,
1579
+ height: Math.max(height, rowPresentation.totalHeight + 42),
1580
+ scaleCount,
1581
+ setScaleCount: handleSetScaleCount,
1582
+ setCursor: handleSetCursor,
1583
+ cursorTime,
1584
+ editorData: timelineProps.editorData,
1585
+ scrollElementRef: domRef,
1586
+ snapPositions
1587
+ })
1588
+ ]
1589
+ }),
1590
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ScrollBar, { orientation: "horizontal" }),
1591
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ScrollBar, { orientation: "vertical" }),
1592
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(radix_ui.ScrollArea.Corner, {})
1593
+ ]
1594
+ });
1595
+ }
1596
+ //#endregion
1597
+ exports.Timeline = Timeline;