@cyca/react-timeline-editor 0.2.1-alpha.0 → 0.2.2-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react-timeline-editor.cjs +25 -0
- package/dist/react-timeline-editor.js +3207 -3011
- package/dist/style.css +1 -0
- package/package.json +20 -17
- package/dist/react-timeline-editor.css +0 -2
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";var He=Object.defineProperty;var Ye=(n,t,e)=>t in n?He(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var ot=(n,t,e)=>Ye(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react"),Ke=require("react-dom");function qe(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(t,e,r.get?r:{enumerable:!0,get:()=>n[e]})}}return t.default=n,Object.freeze(t)}const Et=qe(y);var Jt={exports:{}},Ct={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var se;function Je(){if(se)return Ct;se=1;var n=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function e(r,s,i){var o=null;if(i!==void 0&&(o=""+i),s.key!==void 0&&(o=""+s.key),"key"in s){i={};for(var c in s)c!=="key"&&(i[c]=s[c])}else i=s;return s=i.ref,{$$typeof:n,type:r,key:o,ref:s!==void 0?s:null,props:i}}return Ct.Fragment=t,Ct.jsx=e,Ct.jsxs=e,Ct}var Dt={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var ie;function Ze(){return ie||(ie=1,process.env.NODE_ENV!=="production"&&function(){function n(f){if(f==null)return null;if(typeof f=="function")return f.$$typeof===W?null:f.displayName||f.name||null;if(typeof f=="string")return f;switch(f){case m:return"Fragment";case v:return"Profiler";case h:return"StrictMode";case D:return"Suspense";case P:return"SuspenseList";case N:return"Activity"}if(typeof f=="object")switch(typeof f.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),f.$$typeof){case E:return"Portal";case R:return f.displayName||"Context";case T:return(f._context.displayName||"Context")+".Consumer";case b:var A=f.render;return f=f.displayName,f||(f=A.displayName||A.name||"",f=f!==""?"ForwardRef("+f+")":"ForwardRef"),f;case L:return A=f.displayName||null,A!==null?A:n(f.type)||"Memo";case j:A=f._payload,f=f._init;try{return n(f(A))}catch{}}return null}function t(f){return""+f}function e(f){try{t(f);var A=!1}catch{A=!0}if(A){A=console;var d=A.error,_=typeof Symbol=="function"&&Symbol.toStringTag&&f[Symbol.toStringTag]||f.constructor.name||"Object";return d.call(A,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",_),t(f)}}function r(f){if(f===m)return"<>";if(typeof f=="object"&&f!==null&&f.$$typeof===j)return"<...>";try{var A=n(f);return A?"<"+A+">":"<...>"}catch{return"<...>"}}function s(){var f=z.A;return f===null?null:f.getOwner()}function i(){return Error("react-stack-top-frame")}function o(f){if(Y.call(f,"key")){var A=Object.getOwnPropertyDescriptor(f,"key").get;if(A&&A.isReactWarning)return!1}return f.key!==void 0}function c(f,A){function d(){$||($=!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)",A))}d.isReactWarning=!0,Object.defineProperty(f,"key",{get:d,configurable:!0})}function l(){var f=n(this.type);return q[f]||(q[f]=!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.")),f=this.props.ref,f!==void 0?f:null}function u(f,A,d,_,w,M){var S=d.ref;return f={$$typeof:x,type:f,key:A,props:d,_owner:_},(S!==void 0?S:null)!==null?Object.defineProperty(f,"ref",{enumerable:!1,get:l}):Object.defineProperty(f,"ref",{enumerable:!1,value:null}),f._store={},Object.defineProperty(f._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(f,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(f,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:w}),Object.defineProperty(f,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:M}),Object.freeze&&(Object.freeze(f.props),Object.freeze(f)),f}function a(f,A,d,_,w,M){var S=A.children;if(S!==void 0)if(_)if(st(S)){for(_=0;_<S.length;_++)g(S[_]);Object.freeze&&Object.freeze(S)}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 g(S);if(Y.call(A,"key")){S=n(f);var X=Object.keys(A).filter(function(U){return U!=="key"});_=0<X.length?"{key: someKey, "+X.join(": ..., ")+": ...}":"{key: someKey}",dt[S+_]||(X=0<X.length?"{"+X.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
|
+
let props = %s;
|
|
19
|
+
<%s {...props} />
|
|
20
|
+
React keys must be passed directly to JSX without using spread:
|
|
21
|
+
let props = %s;
|
|
22
|
+
<%s key={someKey} {...props} />`,_,S,X,S),dt[S+_]=!0)}if(S=null,d!==void 0&&(e(d),S=""+d),o(A)&&(e(A.key),S=""+A.key),"key"in A){d={};for(var C in A)C!=="key"&&(d[C]=A[C])}else d=A;return S&&c(d,typeof f=="function"?f.displayName||f.name||"Unknown":f),u(f,S,d,s(),w,M)}function g(f){p(f)?f._store&&(f._store.validated=1):typeof f=="object"&&f!==null&&f.$$typeof===j&&(f._payload.status==="fulfilled"?p(f._payload.value)&&f._payload.value._store&&(f._payload.value._store.validated=1):f._store&&(f._store.validated=1))}function p(f){return typeof f=="object"&&f!==null&&f.$$typeof===x}var O=y,x=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),m=Symbol.for("react.fragment"),h=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),R=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),W=Symbol.for("react.client.reference"),z=O.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y=Object.prototype.hasOwnProperty,st=Array.isArray,I=console.createTask?console.createTask:function(){return null};O={react_stack_bottom_frame:function(f){return f()}};var $,q={},K=O.react_stack_bottom_frame.bind(O,i)(),pt=I(r(i)),dt={};Dt.Fragment=m,Dt.jsx=function(f,A,d){var _=1e4>z.recentlyCreatedOwnerStacks++;return a(f,A,d,!1,_?Error("react-stack-top-frame"):K,_?I(r(f)):pt)},Dt.jsxs=function(f,A,d){var _=1e4>z.recentlyCreatedOwnerStacks++;return a(f,A,d,!0,_?Error("react-stack-top-frame"):K,_?I(r(f)):pt)}}()),Dt}process.env.NODE_ENV==="production"?Jt.exports=Je():Jt.exports=Ze();var k=Jt.exports;const Zt="timeline-editor",Qe=0,Ft=1,Oe=10,Vt=160,Ut=20,Qt=1,te=8,oe=32,ee=20,Ae=5,Yt={trace:0,debug:1,info:2,warn:3,error:4,silent:5},tn=["trace","debug","info","warn","error"];var en=class Ce{constructor(t,e,r,s){ot(this,"s");ot(this,"ls",new Map);ot(this,"lvl");ot(this,"def");ot(this,"n");ot(this,"r");ot(this,"c",console);ot(this,"e");ot(this,"trace");ot(this,"debug");ot(this,"info");ot(this,"warn");ot(this,"error");ot(this,"noop",()=>{});this.s=t,this.e=e,this.n=r,this.r=s,this.bindMethods()}bindMethods(){tn.forEach(t=>{const e=this.e.bind(this.c,t,this.n);Object.defineProperty(this,t,{get:()=>Yt[t]>=Yt[this.currentLevel()]?e:this.noop,configurable:!0})})}storageKey(){return this.n?`loglevel:${String(this.n)}`:"loglevel"}currentLevel(){if(this.lvl)return this.lvl;const t=this.s.get(this.storageKey());return t&&t in Yt?(this.lvl=t,this.lvl):this.def?this.def:this.r?this.r.currentLevel():"trace"}setLevel(t){return this.lvl=t,this.s.set(this.storageKey(),t),this}setDefaultLevel(t){return this.s.get(this.storageKey())||(this.def=t),this}resetLevel(){return this.lvl=void 0,this.s.del(this.storageKey()),this}getLogger(t){if(!t)throw new Error("Logger name required");if(!this.ls.has(t)){const e=new Ce(this.s,this.e,t,this.r||this);this.ls.set(t,De(e))}return this.ls.get(t)}getLoggers(){const t={};return this.ls.forEach((e,r)=>{t[String(r)]=e}),t}use(t){this.c=t,this.bindMethods()}};function De(n){return new Proxy(n,{get(t,e,r){if(e in t)return Reflect.get(t,e,r);const s=t.c[e];return typeof s=="function"?s.bind(t.c):s}})}var nn=class{get(n){return localStorage.getItem(n)}set(n,t){localStorage.setItem(n,t)}del(n){localStorage.removeItem(n)}};const rn={trace:"#95bdb7",debug:"#ad95b8",info:"#b6bd73",warn:"#88a1bb",error:"#bf6c69"},ce={info:"⚡️",success:"✔",warn:"▲",error:"✖",log:"●",trace:"◔",debug:"◌"},sn={bind(n,t,e){const r=e?`${ce[t]} ${String(e)}:`:`${ce[t]}`;return(n[t]||n.log).bind(n,`%c${r}%c`,`color: ${rn[t]}; font-weight: bold;`,"color: inherit")}},bt=De(new en(new nn,sn));function on(n){let{editorData:t=[],effects:e={},scrollTop:r=0,scale:s=Ft,scaleSplitCount:i=Oe,scaleWidth:o=Vt,startLeft:c=Ut,minScaleCount:l=ee,maxScaleCount:u=1/0,rowHeight:a=oe}=n;s<=0&&(bt.error("Error: scale must be greater than 0!"),s=Ft),r<0&&(bt.warn("Warning: scrollTop cannot be less than 0!"),r=0),i<=0&&(bt.warn("Warning: scaleSplitCount cannot be less than 1!"),i=1),o<=0&&(bt.warn("Warning: scaleWidth must be greater than 0!"),o=Vt),c<0&&(bt.warn("Warning: startLeft cannot be less than 0!"),c=0),l<1&&(bt.warn("Warning: minScaleCount must be greater than 1!"),l=ee),l=parseInt(l+""),u<l&&(bt.warn("Warning: maxScaleCount cannot be less than minScaleCount!"),u=l),u=u===1/0?1/0:parseInt(u+""),a<=0&&(bt.warn("Warning: rowHeight must be greater than 0!"),a=oe);const g={...n};return delete g.style,{...g,editorData:t,effects:e,scrollTop:r,scale:s,scaleSplitCount:i,scaleWidth:o,startLeft:c,minScaleCount:l,maxScaleCount:u,rowHeight:a}}function ht(n,t){const{startLeft:e,scale:r,scaleWidth:s}=t;return e+n/r*s}function St(n,t){const{startLeft:e,scale:r,scaleWidth:s}=t;return(n-e)/s*r}function Mt(n,t){const{left:e,width:r}=n,s=St(e,t),i=St(e+r,t);return{start:s,end:i}}function Me(n,t){const{start:e,end:r}=n,s=ht(e,t),i=ht(r,t)-s;return{left:s,width:i}}function cn(n,t){let e=0;return n.forEach(s=>{s.actions.forEach(i=>{e=Math.max(e,i.end)})}),Math.ceil(e/t.scale)+Ae}function an(n,t){const{startLeft:e,scaleWidth:r}=t,s=Math.ceil((n-e)/r);return Math.max(s+Ae,t.scaleCount)}function ln(n,t){const e=[];return n.forEach(r=>{e.push(ht(r.start,t)),e.push(ht(r.end,t))}),e}function un(n){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];return t.map(function(r){return r.split(" ").map(function(s){return s?""+n+s:""}).join(" ")}).join(" ")}function tt(...n){return un(`${Zt}-`,...n)}const Lt=1,ae=3,le=10;function fn(n){const t=y.useRef(Number.MIN_SAFE_INTEGER),e=y.useRef(Number.MAX_SAFE_INTEGER),r=y.useRef(Lt),s=y.useRef(void 0);return{initAutoScroll:()=>{if(n!=null&&n.current){const{left:u,width:a}=n.current.getBoundingClientRect();t.current=u,e.current=u+a}},dealDragAutoScroll:(u,a)=>{if(u.clientX>=e.current||u.clientX<=t.current){s.current!==void 0&&cancelAnimationFrame(s.current);const g=Math.abs(u.clientX>=e.current?u.clientX-e.current:u.clientX-t.current);r.current=Math.min(Number((g/le).toFixed(0))*Lt,ae);const O=(u.clientX>=e.current?1:-1)*r.current,x=()=>{a&&a(O),s.current=requestAnimationFrame(x)};return s.current=requestAnimationFrame(x),!1}else s.current!==void 0&&cancelAnimationFrame(s.current);return!0},dealResizeAutoScroll:(u,a,g)=>{if(u.clientX>=e.current||u.clientX<t.current){s.current!==void 0&&cancelAnimationFrame(s.current);const p=Math.abs(u.clientX>=e.current?u.clientX-e.current:u.clientX-t.current);r.current=Math.min(Number((p/le).toFixed(0))*Lt,ae);const x=(u.clientX>=e.current?1:-1)*r.current,E=()=>{g&&g(x),s.current=requestAnimationFrame(E)};return s.current=requestAnimationFrame(E),!1}else s.current!==void 0&&cancelAnimationFrame(s.current);return!0},stopAutoScroll:()=>{t.current=Number.MIN_SAFE_INTEGER,e.current=Number.MAX_SAFE_INTEGER,r.current=Lt,s.current!==void 0&&cancelAnimationFrame(s.current)}}}function dn(n,t,e){return Math.max(t,Math.min(n,e))}const rt={toVector(n,t){return n===void 0&&(n=t),Array.isArray(n)?n:[n,n]},add(n,t){return[n[0]+t[0],n[1]+t[1]]},sub(n,t){return[n[0]-t[0],n[1]-t[1]]},addTo(n,t){n[0]+=t[0],n[1]+=t[1]},subTo(n,t){n[0]-=t[0],n[1]-=t[1]}};function ue(n,t,e){return t===0||Math.abs(t)===1/0?Math.pow(n,e*5):n*t*e/(t+e*n)}function fe(n,t,e,r=.15){return r===0?dn(n,t,e):n<t?-ue(t-n,e-t,r)+t:n>e?+ue(n-e,e-t,r)+e:n}function hn(n,[t,e],[r,s]){const[[i,o],[c,l]]=n;return[fe(t,i,o,r),fe(e,c,l,s)]}function pn(n,t){if(typeof n!="object"||n===null)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var r=e.call(n,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function mn(n){var t=pn(n,"string");return typeof t=="symbol"?t:String(t)}function ct(n,t,e){return t=mn(t),t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function de(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable})),e.push.apply(e,r)}return e}function G(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?de(Object(e),!0).forEach(function(r){ct(n,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):de(Object(e)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(e,r))})}return n}const Ie={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 he(n){return n?n[0].toUpperCase()+n.slice(1):""}const gn=["enter","leave"];function vn(n=!1,t){return n&&!gn.includes(t)}function bn(n,t="",e=!1){const r=Ie[n],s=r&&r[t]||t;return"on"+he(n)+he(s)+(vn(e,s)?"Capture":"")}const yn=["gotpointercapture","lostpointercapture"];function En(n){let t=n.substring(2).toLowerCase();const e=!!~t.indexOf("passive");e&&(t=t.replace("passive",""));const r=yn.includes(t)?"capturecapture":"capture",s=!!~t.indexOf(r);return s&&(t=t.replace("capture","")),{device:t,capture:s,passive:e}}function _n(n,t=""){const e=Ie[n],r=e&&e[t]||t;return n+r}function Bt(n){return"touches"in n}function Pe(n){return Bt(n)?"touch":"pointerType"in n?n.pointerType:"mouse"}function wn(n){return Array.from(n.touches).filter(t=>{var e,r;return t.target===n.currentTarget||((e=n.currentTarget)===null||e===void 0||(r=e.contains)===null||r===void 0?void 0:r.call(e,t.target))})}function Sn(n){return n.type==="touchend"||n.type==="touchcancel"?n.changedTouches:n.targetTouches}function ke(n){return Bt(n)?Sn(n)[0]:n}function xn(n){return wn(n).map(t=>t.identifier)}function Kt(n){const t=ke(n);return Bt(n)?t.identifier:t.pointerId}function pe(n){const t=ke(n);return[t.clientX,t.clientY]}function Tn(n){const t={};if("buttons"in n&&(t.buttons=n.buttons),"shiftKey"in n){const{shiftKey:e,altKey:r,metaKey:s,ctrlKey:i}=n;Object.assign(t,{shiftKey:e,altKey:r,metaKey:s,ctrlKey:i})}return t}function $t(n,...t){return typeof n=="function"?n(...t):n}function Rn(){}function On(...n){return n.length===0?Rn:n.length===1?n[0]:function(){let t;for(const e of n)t=e.apply(this,arguments)||t;return t}}function me(n,t){return Object.assign({},t,n||{})}const An=32;class Cn{constructor(t,e,r){this.ctrl=t,this.args=e,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(t){this.ctrl.state[this.key]=t}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:t,shared:e,ingKey:r,args:s}=this;e[r]=t._active=t.active=t._blocked=t._force=!1,t._step=[!1,!1],t.intentional=!1,t._movement=[0,0],t._distance=[0,0],t._direction=[0,0],t._delta=[0,0],t._bounds=[[-1/0,1/0],[-1/0,1/0]],t.args=s,t.axis=void 0,t.memo=void 0,t.elapsedTime=t.timeDelta=0,t.direction=[0,0],t.distance=[0,0],t.overflow=[0,0],t._movementBound=[!1,!1],t.velocity=[0,0],t.movement=[0,0],t.delta=[0,0],t.timeStamp=0}start(t){const e=this.state,r=this.config;e._active||(this.reset(),this.computeInitial(),e._active=!0,e.target=t.target,e.currentTarget=t.currentTarget,e.lastOffset=r.from?$t(r.from,e):e.offset,e.offset=e.lastOffset,e.startTime=e.timeStamp=t.timeStamp)}computeValues(t){const e=this.state;e._values=t,e.values=this.config.transform(t)}computeInitial(){const t=this.state;t._initial=t._values,t.initial=t.values}compute(t){const{state:e,config:r,shared:s}=this;e.args=this.args;let i=0;if(t&&(e.event=t,r.preventDefault&&t.cancelable&&e.event.preventDefault(),e.type=t.type,s.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,s.locked=!!document.pointerLockElement,Object.assign(s,Tn(t)),s.down=s.pressed=s.buttons%2===1||s.touches>0,i=t.timeStamp-e.timeStamp,e.timeStamp=t.timeStamp,e.elapsedTime=e.timeStamp-e.startTime),e._active){const D=e._delta.map(Math.abs);rt.addTo(e._distance,D)}this.axisIntent&&this.axisIntent(t);const[o,c]=e._movement,[l,u]=r.threshold,{_step:a,values:g}=e;if(r.hasCustomTransform?(a[0]===!1&&(a[0]=Math.abs(o)>=l&&g[0]),a[1]===!1&&(a[1]=Math.abs(c)>=u&&g[1])):(a[0]===!1&&(a[0]=Math.abs(o)>=l&&Math.sign(o)*l),a[1]===!1&&(a[1]=Math.abs(c)>=u&&Math.sign(c)*u)),e.intentional=a[0]!==!1||a[1]!==!1,!e.intentional)return;const p=[0,0];if(r.hasCustomTransform){const[D,P]=g;p[0]=a[0]!==!1?D-a[0]:0,p[1]=a[1]!==!1?P-a[1]:0}else p[0]=a[0]!==!1?o-a[0]:0,p[1]=a[1]!==!1?c-a[1]:0;this.restrictToAxis&&!e._blocked&&this.restrictToAxis(p);const O=e.offset,x=e._active&&!e._blocked||e.active;x&&(e.first=e._active&&!e.active,e.last=!e._active&&e.active,e.active=s[this.ingKey]=e._active,t&&(e.first&&("bounds"in r&&(e._bounds=$t(r.bounds,e)),this.setup&&this.setup()),e.movement=p,this.computeOffset()));const[E,m]=e.offset,[[h,v],[T,R]]=e._bounds;e.overflow=[E<h?-1:E>v?1:0,m<T?-1:m>R?1:0],e._movementBound[0]=e.overflow[0]?e._movementBound[0]===!1?e._movement[0]:e._movementBound[0]:!1,e._movementBound[1]=e.overflow[1]?e._movementBound[1]===!1?e._movement[1]:e._movementBound[1]:!1;const b=e._active?r.rubberband||[0,0]:[0,0];if(e.offset=hn(e._bounds,e.offset,b),e.delta=rt.sub(e.offset,O),this.computeMovement(),x&&(!e.last||i>An)){e.delta=rt.sub(e.offset,O);const D=e.delta.map(Math.abs);rt.addTo(e.distance,D),e.direction=e.delta.map(Math.sign),e._direction=e._delta.map(Math.sign),!e.first&&i>0&&(e.velocity=[D[0]/i,D[1]/i],e.timeDelta=i)}}emit(){const t=this.state,e=this.shared,r=this.config;if(t._active||this.clean(),(t._blocked||!t.intentional)&&!t._force&&!r.triggerAllEvents)return;const s=this.handler(G(G(G({},e),t),{},{[this.aliasKey]:t.values}));s!==void 0&&(t.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function Dn([n,t],e){const r=Math.abs(n),s=Math.abs(t);if(r>s&&r>e)return"x";if(s>r&&s>e)return"y"}class Mn extends Cn{constructor(...t){super(...t),ct(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=rt.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=rt.sub(this.state.offset,this.state.lastOffset)}axisIntent(t){const e=this.state,r=this.config;if(!e.axis&&t){const s=typeof r.axisThreshold=="object"?r.axisThreshold[Pe(t)]:r.axisThreshold;e.axis=Dn(e._movement,s)}e._blocked=(r.lockDirection||!!r.axis)&&!e.axis||!!r.axis&&r.axis!==e.axis}restrictToAxis(t){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":t[1]=0;break;case"y":t[0]=0;break}}}const ge=n=>n,ve=.15,re={enabled(n=!0){return n},eventOptions(n,t,e){return G(G({},e.shared.eventOptions),n)},preventDefault(n=!1){return n},triggerAllEvents(n=!1){return n},rubberband(n=0){switch(n){case!0:return[ve,ve];case!1:return[0,0];default:return rt.toVector(n)}},from(n){if(typeof n=="function")return n;if(n!=null)return rt.toVector(n)},transform(n,t,e){const r=n||e.shared.transform;if(this.hasCustomTransform=!!r,process.env.NODE_ENV==="development"){const s=r||ge;return i=>{const o=s(i);return(!isFinite(o[0])||!isFinite(o[1]))&&console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${o[0]},${[1]}]`),o}}return r||ge},threshold(n){return rt.toVector(n,0)}};process.env.NODE_ENV==="development"&&Object.assign(re,{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 In=0,It=G(G({},re),{},{axis(n,t,{axis:e}){if(this.lockDirection=e==="lock",!this.lockDirection)return e},axisThreshold(n=In){return n},bounds(n={}){if(typeof n=="function")return i=>It.bounds(n(i));if("current"in n)return()=>n.current;if(typeof HTMLElement=="function"&&n instanceof HTMLElement)return n;const{left:t=-1/0,right:e=1/0,top:r=-1/0,bottom:s=1/0}=n;return[[t,e],[r,s]]}}),be={ArrowRight:(n,t=1)=>[n*t,0],ArrowLeft:(n,t=1)=>[-1*n*t,0],ArrowUp:(n,t=1)=>[0,-1*n*t],ArrowDown:(n,t=1)=>[0,n*t]};class Pn extends Mn{constructor(...t){super(...t),ct(this,"ingKey","dragging")}reset(){super.reset();const t=this.state;t._pointerId=void 0,t._pointerActive=!1,t._keyboardActive=!1,t._preventScroll=!1,t._delayed=!1,t.swipe=[0,0],t.tap=!1,t.canceled=!1,t.cancel=this.cancel.bind(this)}setup(){const t=this.state;if(t._bounds instanceof HTMLElement){const e=t._bounds.getBoundingClientRect(),r=t.currentTarget.getBoundingClientRect(),s={left:e.left-r.left+t.offset[0],right:e.right-r.right+t.offset[0],top:e.top-r.top+t.offset[1],bottom:e.bottom-r.bottom+t.offset[1]};t._bounds=It.bounds(s)}}cancel(){const t=this.state;t.canceled||(t.canceled=!0,t._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(t){const e=this.config,r=this.state;if(t.buttons!=null&&(Array.isArray(e.pointerButtons)?!e.pointerButtons.includes(t.buttons):e.pointerButtons!==-1&&e.pointerButtons!==t.buttons))return;const s=this.ctrl.setEventIds(t);e.pointerCapture&&t.target.setPointerCapture(t.pointerId),!(s&&s.size>1&&r._pointerActive)&&(this.start(t),this.setupPointer(t),r._pointerId=Kt(t),r._pointerActive=!0,this.computeValues(pe(t)),this.computeInitial(),e.preventScrollAxis&&Pe(t)!=="mouse"?(r._active=!1,this.setupScrollPrevention(t)):e.delay>0?(this.setupDelayTrigger(t),e.triggerAllEvents&&(this.compute(t),this.emit())):this.startPointerDrag(t))}startPointerDrag(t){const e=this.state;e._active=!0,e._preventScroll=!0,e._delayed=!1,this.compute(t),this.emit()}pointerMove(t){const e=this.state,r=this.config;if(!e._pointerActive)return;const s=Kt(t);if(e._pointerId!==void 0&&s!==e._pointerId)return;const i=pe(t);if(document.pointerLockElement===t.target?e._delta=[t.movementX,t.movementY]:(e._delta=rt.sub(i,e._values),this.computeValues(i)),rt.addTo(e._movement,e._delta),this.compute(t),e._delayed&&e.intentional){this.timeoutStore.remove("dragDelay"),e.active=!1,this.startPointerDrag(t);return}if(r.preventScrollAxis&&!e._preventScroll)if(e.axis)if(e.axis===r.preventScrollAxis||r.preventScrollAxis==="xy"){e._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(t);return}else return;this.emit()}pointerUp(t){this.ctrl.setEventIds(t);try{this.config.pointerCapture&&t.target.hasPointerCapture(t.pointerId)&&t.target.releasePointerCapture(t.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 e=this.state,r=this.config;if(!e._active||!e._pointerActive)return;const s=Kt(t);if(e._pointerId!==void 0&&s!==e._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(t);const[i,o]=e._distance;if(e.tap=i<=r.tapsThreshold&&o<=r.tapsThreshold,e.tap&&r.filterTaps)e._force=!0;else{const[c,l]=e._delta,[u,a]=e._movement,[g,p]=r.swipe.velocity,[O,x]=r.swipe.distance,E=r.swipe.duration;if(e.elapsedTime<E){const m=Math.abs(c/e.timeDelta),h=Math.abs(l/e.timeDelta);m>g&&Math.abs(u)>O&&(e.swipe[0]=Math.sign(c)),h>p&&Math.abs(a)>x&&(e.swipe[1]=Math.sign(l))}}this.emit()}pointerClick(t){!this.state.tap&&t.detail>0&&(t.preventDefault(),t.stopPropagation())}setupPointer(t){const e=this.config,r=e.device;if(process.env.NODE_ENV==="development")try{if(r==="pointer"&&e.preventScrollDelay===void 0){const s="uv"in t?t.sourceEvent.currentTarget:t.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{}e.pointerLock&&t.currentTarget.requestPointerLock(),e.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(t){this.state._preventScroll&&t.cancelable&&t.preventDefault()}setupScrollPrevention(t){this.state._preventScroll=!1,kn(t);const e=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",e),this.eventStore.add(this.sharedConfig.window,"touch","cancel",e),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,t)}setupDelayTrigger(t){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(t)},this.config.delay)}keyDown(t){const e=be[t.key];if(e){const r=this.state,s=t.shiftKey?10:t.altKey?.1:1;this.start(t),r._delta=e(this.config.keyboardDisplacement,s),r._keyboardActive=!0,rt.addTo(r._movement,r._delta),this.compute(t),this.emit()}}keyUp(t){t.key in be&&(this.state._keyboardActive=!1,this.setActive(),this.compute(t),this.emit())}bind(t){const e=this.config.device;t(e,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(t(e,"change",this.pointerMove.bind(this)),t(e,"end",this.pointerUp.bind(this)),t(e,"cancel",this.pointerUp.bind(this)),t("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(t("key","down",this.keyDown.bind(this)),t("key","up",this.keyUp.bind(this))),this.config.filterTaps&&t("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function kn(n){"persist"in n&&typeof n.persist=="function"&&n.persist()}const Pt=typeof window<"u"&&window.document&&window.document.createElement;function Le(){return Pt&&"ontouchstart"in window}function Ln(){return Le()||Pt&&window.navigator.maxTouchPoints>1}function Nn(){return Pt&&"onpointerdown"in window}function jn(){return Pt&&"exitPointerLock"in window.document}function Wn(){try{return"constructor"in GestureEvent}catch{return!1}}const lt={isBrowser:Pt,gesture:Wn(),touch:Le(),touchscreen:Ln(),pointer:Nn(),pointerLock:jn()},zn=250,Fn=180,Vn=.5,$n=50,Un=250,Bn=10,ye={mouse:0,touch:0,pen:8},Ne=G(G({},It),{},{device(n,t,{pointer:{touch:e=!1,lock:r=!1,mouse:s=!1}={}}){return this.pointerLock=r&<.pointerLock,lt.touch&&e?"touch":this.pointerLock?"mouse":lt.pointer&&!s?"pointer":lt.touch?"touch":"mouse"},preventScrollAxis(n,t,{preventScroll:e}){if(this.preventScrollDelay=typeof e=="number"?e:e||e===void 0&&n?zn:void 0,!(!lt.touchscreen||e===!1))return n||(e!==void 0?"y":void 0)},pointerCapture(n,t,{pointer:{capture:e=!0,buttons:r=1,keys:s=!0}={}}){return this.pointerButtons=r,this.keys=s,!this.pointerLock&&this.device==="pointer"&&e},threshold(n,t,{filterTaps:e=!1,tapsThreshold:r=3,axis:s=void 0}){const i=rt.toVector(n,e?r:s?1:0);return this.filterTaps=e,this.tapsThreshold=r,i},swipe({velocity:n=Vn,distance:t=$n,duration:e=Un}={}){return{velocity:this.transform(rt.toVector(n)),distance:this.transform(rt.toVector(t)),duration:e}},delay(n=0){switch(n){case!0:return Fn;case!1:return 0;default:return n}},axisThreshold(n){return n?G(G({},ye),n):ye},keyboardDisplacement(n=Bn){return n}});process.env.NODE_ENV==="development"&&Object.assign(Ne,{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}});G(G({},re),{},{device(n,t,{shared:e,pointer:{touch:r=!1}={}}){if(e.target&&!lt.touch&<.gesture)return"gesture";if(lt.touch&&r)return"touch";if(lt.touchscreen){if(lt.pointer)return"pointer";if(lt.touch)return"touch"}},bounds(n,t,{scaleBounds:e={},angleBounds:r={}}){const s=o=>{const c=me($t(e,o),{min:-1/0,max:1/0});return[c.min,c.max]},i=o=>{const c=me($t(r,o),{min:-1/0,max:1/0});return[c.min,c.max]};return typeof e!="function"&&typeof r!="function"?[s(),i()]:o=>[s(o),i(o)]},threshold(n,t,e){return this.lockDirection=e.axis==="lock",rt.toVector(n,this.lockDirection?[.1,3]:0)},modifierKey(n){return n===void 0?"ctrlKey":n},pinchOnWheel(n=!0){return n}});G(G({},It),{},{mouseOnly:(n=!0)=>n});G(G({},It),{},{mouseOnly:(n=!0)=>n});const je=new Map,ne=new Map;function Xn(n){je.set(n.key,n.engine),ne.set(n.key,n.resolver)}const Gn={key:"drag",engine:Pn,resolver:Ne};function Hn(n,t){if(n==null)return{};var e={},r=Object.keys(n),s,i;for(i=0;i<r.length;i++)s=r[i],!(t.indexOf(s)>=0)&&(e[s]=n[s]);return e}function Yn(n,t){if(n==null)return{};var e=Hn(n,t),r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);for(s=0;s<i.length;s++)r=i[s],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(n,r)&&(e[r]=n[r])}return e}const Kn={target(n){if(n)return()=>"current"in n?n.current:n},enabled(n=!0){return n},window(n=lt.isBrowser?window:void 0){return n},eventOptions({passive:n=!0,capture:t=!1}={}){return{passive:n,capture:t}},transform(n){return n}},qn=["target","eventOptions","window","enabled","transform"];function jt(n={},t){const e={};for(const[r,s]of Object.entries(t))switch(typeof s){case"function":if(process.env.NODE_ENV==="development"){const i=s.call(e,n[r],r,n);Number.isNaN(i)||(e[r]=i)}else e[r]=s.call(e,n[r],r,n);break;case"object":e[r]=jt(n[r],s);break;case"boolean":s&&(e[r]=n[r]);break}return e}function Jn(n,t,e={}){const r=n,{target:s,eventOptions:i,window:o,enabled:c,transform:l}=r,u=Yn(r,qn);if(e.shared=jt({target:s,eventOptions:i,window:o,enabled:c,transform:l},Kn),t){const a=ne.get(t);e[t]=jt(G({shared:e.shared},u),a)}else for(const a in u){const g=ne.get(a);if(g)e[a]=jt(G({shared:e.shared},u[a]),g);else if(process.env.NODE_ENV==="development"&&!["drag","pinch","scroll","wheel","move","hover"].includes(a)){if(a==="domTarget")throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");console.warn(`[@use-gesture]: Unknown config key \`${a}\` was used. Please read the documentation for further information.`)}}return e}class We{constructor(t,e){ct(this,"_listeners",new Set),this._ctrl=t,this._gestureKey=e}add(t,e,r,s,i){const o=this._listeners,c=_n(e,r),l=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},u=G(G({},l),i);t.addEventListener(c,s,u);const a=()=>{t.removeEventListener(c,s,u),o.delete(a)};return o.add(a),a}clean(){this._listeners.forEach(t=>t()),this._listeners.clear()}}class Zn{constructor(){ct(this,"_timeouts",new Map)}add(t,e,r=140,...s){this.remove(t),this._timeouts.set(t,window.setTimeout(e,r,...s))}remove(t){const e=this._timeouts.get(t);e&&window.clearTimeout(e)}clean(){this._timeouts.forEach(t=>void window.clearTimeout(t)),this._timeouts.clear()}}class Qn{constructor(t){ct(this,"gestures",new Set),ct(this,"_targetEventStore",new We(this)),ct(this,"gestureEventStores",{}),ct(this,"gestureTimeoutStores",{}),ct(this,"handlers",{}),ct(this,"config",{}),ct(this,"pointerIds",new Set),ct(this,"touchIds",new Set),ct(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),tr(this,t)}setEventIds(t){if(Bt(t))return this.touchIds=new Set(xn(t)),this.touchIds;if("pointerId"in t)return t.type==="pointerup"||t.type==="pointercancel"?this.pointerIds.delete(t.pointerId):t.type==="pointerdown"&&this.pointerIds.add(t.pointerId),this.pointerIds}applyHandlers(t,e){this.handlers=t,this.nativeHandlers=e}applyConfig(t,e){this.config=Jn(t,e,this.config)}clean(){this._targetEventStore.clean();for(const t of this.gestures)this.gestureEventStores[t].clean(),this.gestureTimeoutStores[t].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...t){const e=this.config.shared,r={};let s;if(!(e.target&&(s=e.target(),!s))){if(e.enabled){for(const o of this.gestures){const c=this.config[o],l=Ee(r,c.eventOptions,!!s);if(c.enabled){const u=je.get(o);new u(this,t,o).bind(l)}}const i=Ee(r,e.eventOptions,!!s);for(const o in this.nativeHandlers)i(o,"",c=>this.nativeHandlers[o](G(G({},this.state.shared),{},{event:c,args:t})),void 0,!0)}for(const i in r)r[i]=On(...r[i]);if(!s)return r;for(const i in r){const{device:o,capture:c,passive:l}=En(i);this._targetEventStore.add(s,o,"",r[i],{capture:c,passive:l})}}}}function Rt(n,t){n.gestures.add(t),n.gestureEventStores[t]=new We(n,t),n.gestureTimeoutStores[t]=new Zn}function tr(n,t){t.drag&&Rt(n,"drag"),t.wheel&&Rt(n,"wheel"),t.scroll&&Rt(n,"scroll"),t.move&&Rt(n,"move"),t.pinch&&Rt(n,"pinch"),t.hover&&Rt(n,"hover")}const Ee=(n,t,e)=>(r,s,i,o={},c=!1)=>{var l,u;const a=(l=o.capture)!==null&&l!==void 0?l:t.capture,g=(u=o.passive)!==null&&u!==void 0?u:t.passive;let p=c?r:bn(r,s,a);e&&g&&(p+="Passive"),n[p]=n[p]||[],n[p].push(i)};function er(n,t){if(typeof n!="object"||n===null)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var r=e.call(n,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function nr(n){var t=er(n,"string");return typeof t=="symbol"?t:String(t)}function rr(n,t,e){return t=nr(t),t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function _e(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable})),e.push.apply(e,r)}return e}function Nt(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?_e(Object(e),!0).forEach(function(r){rr(n,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):_e(Object(e)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(e,r))})}return n}class sr{constructor(t,e,r,s,i){this._target=t,this._gestureKey=s,this._ctrl=new Qn(e),this._ctrl.applyHandlers(e,i),this._ctrl.applyConfig(Nt(Nt({},r),{},{target:t}),s),this._ctrl.effect()}destroy(){this._ctrl.clean()}setConfig(t){this._ctrl.clean(),this._ctrl.applyConfig(Nt(Nt({},t),{},{target:this._target}),this._gestureKey),this._ctrl.effect()}}const qt=function(t,e,r){return Xn(Gn),new sr(t,{drag:e},r||{},"drag")};function ze(...n){const t=n.filter(Boolean);return t.length<=1?t[0]||null:function(r){for(const s of t)typeof s=="function"?s(r):s&&(s.current=r)}}const Fe=({children:n,...t})=>{const e=y.Children.only(n),r=ir(e),s=e.props||{},i=s.style||{},o={...t,...s,style:{...t.style??{},...i},ref:ze(r,t.ref)};return y.cloneElement(e,o)};function ir(n){var r;let t=(r=Object.getOwnPropertyDescriptor(n,"ref"))==null?void 0:r.get;return t&&"isReactWarning"in t&&t.isReactWarning?n.props.ref:n.props.ref||n.ref}const or=({children:n,interactRef:t,draggable:e,resizable:r,draggableOptions:s,resizableOptions:i})=>{const o=y.useRef(null),c=y.useRef(void 0),l=y.useRef(void 0),u=y.useRef(void 0),a=y.useRef(void 0),g=y.useRef(void 0),p=y.useRef(null),O=y.useRef(null);y.useEffect(()=>{c.current=s,l.current=i},[s,i]);const x=y.useEffectEvent(()=>{var E,m;o.current&&(e&&c.current&&(u.current=new qt(o.current,h=>{var N,W,z,Y,st,I;const{active:v,delta:T,xy:R,event:b,first:D,last:P}=h,L=b==null?void 0:b.target;if(L&&(L===p.current||L===O.current||p.current&&p.current.contains(L)||O.current&&O.current.contains(L)))return;const j={target:o.current,dx:T[0],dy:T[1],clientX:R[0],clientY:R[1]};D?(W=(N=c.current)==null?void 0:N.onstart)==null||W.call(N,j):P?(Y=(z=c.current)==null?void 0:z.onend)==null||Y.call(z,j):v&&((I=(st=c.current)==null?void 0:st.onmove)==null||I.call(st,j))},{axis:((E=c.current)==null?void 0:E.lockAxis)==="x"?"x":void 0,pointer:{capture:!0}})),r&&((m=l.current)!=null&&m.edges)&&(l.current.edges.left&&(p.current||(p.current=o.current.querySelector(l.current.edges.left)),a.current=new qt(p.current,h=>{var L,j,N,W,z,Y;const{active:v,delta:T,xy:R,first:b,last:D}=h,P={target:o.current,dx:T[0],dy:0,clientX:R[0],clientY:R[1],edges:{left:!0},deltaRect:{left:T[0]}};D?(j=(L=l.current)==null?void 0:L.onend)==null||j.call(L,P):b?(W=(N=l.current)==null?void 0:N.onstart)==null||W.call(N,P):v&&((Y=(z=l.current)==null?void 0:z.onmove)==null||Y.call(z,P))},{pointer:{capture:!0}})),l.current.edges.right&&(O.current||(O.current=o.current.querySelector(l.current.edges.right)),g.current=new qt(O.current,h=>{var L,j,N,W,z,Y;const{active:v,delta:T,xy:R,first:b,last:D}=h,P={target:o.current,dx:T[0],dy:0,clientX:R[0],clientY:R[1],edges:{right:!0},deltaRect:{right:T[0]}};D?(j=(L=l.current)==null?void 0:L.onend)==null||j.call(L,P):b?(W=(N=l.current)==null?void 0:N.onstart)==null||W.call(N,P):v&&((Y=(z=l.current)==null?void 0:z.onmove)==null||Y.call(z,P))},{pointer:{capture:!0}}))))});return y.useEffect(()=>{var m,h,v;if(!o.current)return;(m=u.current)==null||m.destroy(),(h=a.current)==null||h.destroy(),(v=g.current)==null||v.destroy();const E={target:o.current,unset:()=>{var T,R,b;(T=u.current)==null||T.destroy(),(R=a.current)==null||R.destroy(),(b=g.current)==null||b.destroy()}};t&&(t.current=E),x()},[e,r,t]),Fe({children:n,ref:o,draggable:!1,style:{...e&&{touchAction:"none"}}})},Ve=y.forwardRef(({children:n,edges:t,left:e,width:r,start:s=Ut,grid:i=Qt,bounds:o={left:Number.MIN_SAFE_INTEGER,right:Number.MAX_SAFE_INTEGER},enableResizing:c=!0,enableDragging:l=!0,adsorptionDistance:u=te,adsorptionPositions:a=[],onResizeStart:g,onResize:p,onResizeEnd:O,onDragStart:x,onDragEnd:E,onDrag:m,parentRef:h,deltaScrollLeft:v},T)=>{const R=y.useRef(void 0),b=y.useRef(0),D=y.useRef(!1),{initAutoScroll:P,dealDragAutoScroll:L,dealResizeAutoScroll:j,stopAutoScroll:N}=fn(h);y.useEffect(()=>{let d=R.current;return()=>{d==null||d.unset()}},[]);const W=(d,_=!0)=>{if(!R.current||!R.current.target)return;_&&(b.current=0);const w=R.current.target;w.style.left=`${d}px`,Object.assign(w.dataset,{left:d})},z=(d,_=!0)=>{if(!R.current||!R.current.target)return;_&&(b.current=0);const w=R.current.target;w.style.width=`${d}px`,Object.assign(w.dataset,{width:d})},Y=()=>{var _,w;if(!((_=R.current)!=null&&_.target))return 0;const d=R.current.target;return parseFloat(((w=d==null?void 0:d.dataset)==null?void 0:w.left)||"0")},st=()=>{var _,w;if(!((_=R.current)!=null&&_.target))return 0;const d=R.current.target;return parseFloat(((w=d==null?void 0:d.dataset)==null?void 0:w.width)||"0")};y.useEffect(()=>{var _;if(!((_=R.current)!=null&&_.target))return;const d=R.current.target;z(typeof r>"u"?d.offsetWidth:r,!1)},[r]),y.useEffect(()=>{W(e||0,!1)},[e]),y.useImperativeHandle(T,()=>({updateLeft:d=>W(d||0,!1),updateWidth:d=>z(d,!1),getLeft:Y,getWidth:st}));const I=()=>{b.current=0,D.current=!1,P(),x&&x()},$=d=>{const{preLeft:_,preWidth:w,scrollDelta:M}=d,S=D.current?u:i;if(Math.abs(b.current)>=S){const X=parseInt(b.current/S+"");let C=_+X*S,U=C,J=Number.MAX_SAFE_INTEGER;if(a.forEach(V=>{const et=Math.abs(V-C);et<u&&et<J&&(U=V);const Z=Math.abs(V-(C+w));Z<u&&Z<J&&(U=V-w)}),U!==C?(D.current=!0,C=U):((C-s)%i!==0&&(C=s+i*Math.round((C-s)/i)),D.current=!1),b.current=b.current%S,C<o.left?C=o.left:C+w>o.right&&(C=o.right-w),m&&m({lastLeft:_,left:C,lastWidth:w,width:w},M)===!1)return;W(C,!1)}},q=d=>{const _=d.target;if(v&&(h!=null&&h.current)&&!L(d,U=>{v(U);let{left:J,width:V}=_.dataset;const et=parseFloat(J||"0"),Z=parseFloat(V||"0");b.current+=U,$({preLeft:et,preWidth:Z,scrollDelta:U})}))return;let{left:w,width:M}=_.dataset;const S=parseFloat(w||"0"),X=parseFloat(M||"0");b.current+=d.dx,$({preLeft:S,preWidth:X})},K=d=>{b.current=0,D.current=!1,N();const _=d.target;let{left:w,width:M}=_.dataset;E&&E({left:parseFloat(w||"0"),width:parseFloat(M||"0")})},pt=d=>{var w;b.current=0,D.current=!1,P();let _=(w=d.edges)!=null&&w.right?"right":"left";g&&g(_)},dt=d=>{const{dir:_,preWidth:w,preLeft:M}=d,S=D.current?u:i;if(_==="left"){if(Math.abs(b.current)>=S){const X=parseInt(b.current/S+"");let C=M+X*S,U=C,J=Number.MAX_SAFE_INTEGER;a.forEach(Z=>{const at=Math.abs(Z-C);at<u&&at<J&&(U=Z)}),U!==C?(D.current=!0,C=U):((C-s)%i!==0&&(C=s+i*Math.round((C-s)/i)),D.current=!1),b.current=b.current%S;const V=M+w;C<o.left&&(C=o.left);const et=V-C;if(p&&p("left",{lastLeft:M,lastWidth:w,left:C,width:et})===!1)return;W(C,!1),z(et,!1)}}else if(_==="right"&&Math.abs(b.current)>=S){const X=parseInt(b.current/i+"");let C=w+X*i,U=M+C,J=Number.MAX_SAFE_INTEGER;if(a.forEach(V=>{const et=Math.abs(V-(M+C));et<u&&et<J&&(U=V)}),U!==M+C)D.current=!0,C=U-M;else{let V=M+C;(V-s)%i!==0&&(V=s+i*Math.round((V-s)/i),C=V-M),D.current=!1}if(b.current=b.current%S,M+C>o.right&&(C=o.right-M),p&&p("right",{lastLeft:M,lastWidth:w,left:M,width:C})===!1)return;z(C,!1)}},f=d=>{var U,J,V;const _=d.target,w=(U=d.edges)!=null&&U.left?"left":"right";if(v&&(h!=null&&h.current)&&!j(d,w,Z=>{v(Z);let{left:at,width:_t}=_.dataset;const ut=parseFloat(at||"0"),xt=parseFloat(_t||"0");b.current+=Z,dt({preLeft:ut,preWidth:xt,dir:w})}))return;let{left:M,width:S}=_.dataset;const X=parseFloat(M||"0"),C=parseFloat(S||"0");b.current+=w==="left"?((J=d.deltaRect)==null?void 0:J.left)||0:((V=d.deltaRect)==null?void 0:V.right)||0,dt({preLeft:X,preWidth:C,dir:w})},A=d=>{var X;b.current=0,D.current=!1,N();const _=d.target;let{left:w,width:M}=_.dataset,S=(X=d.edges)!=null&&X.right?"right":"left";O&&O(S,{left:parseFloat(w||"0"),width:parseFloat(M||"0")})};return k.jsx(or,{interactRef:R,draggable:l,resizable:c,draggableOptions:{lockAxis:"x",onmove:q,onstart:I,onend:K,cursorChecker:()=>""},resizableOptions:{axis:"x",invert:"none",edges:t,onmove:f,onstart:pt,onend:A},children:Fe({children:n,style:{left:e,width:r}})})}),$e=Et.forwardRef(({children:n},t)=>{const[e,r]=Et.useState({clientHeight:0,clientWidth:0,scrollHeight:0,scrollLeft:0,scrollTop:0,scrollWidth:0}),s=Et.useCallback(i=>{r(o=>({...o,...i}))},[]);return Et.useImperativeHandle(t,()=>({get state(){return e},setScrollState:r,handleScroll:s})),n({...e,onScroll:s})});$e.displayName="ScrollSync";const cr=({disableDrag:n,cursorTime:t,setCursor:e,startLeft:r,timelineWidth:s,scaleWidth:i,scale:o,scrollLeft:c,scrollSync:l,areaRef:u,maxScaleCount:a,deltaScrollLeft:g,onCursorDragStart:p,onCursorDrag:O,onCursorDragEnd:x})=>{const E=y.useRef(null),m=y.useRef(void 0);y.useEffect(()=>{if(typeof m.current>"u"&&E.current){const b=r??20,D=i??160,P=o??1;E.current.updateLeft(ht(t,{startLeft:b,scaleWidth:D,scale:P})-c)}},[t,r,i,o,c]);const h=r??20,v=i??160,T=o??1,R=a??1/0;return k.jsx(Ve,{start:h,ref:E,parentRef:u,bounds:{left:0,right:Math.min(s,R*v+h-c)},deltaScrollLeft:g,enableDragging:!n,enableResizing:!1,onDragStart:()=>{var b;p&&p(t),m.current=ht(t,{startLeft:h,scaleWidth:v,scale:T})-c,(b=E.current)==null||b.updateLeft(m.current)},onDragEnd:()=>{if(typeof m.current<"u"){const b=St(m.current+c,{startLeft:h,scale:T,scaleWidth:v});e({time:b}),x&&x(b)}m.current=void 0},onDrag:({left:b},D=0)=>{var L,j;if(!((L=l.current)!=null&&L.state))return!1;const P=l.current.state.scrollLeft;if(!D||P===0?b<h-P?m.current=h-P:m.current=b:typeof m.current<"u"&&m.current<h-P-D&&(m.current=h-P-D),typeof m.current<"u"){(j=E.current)==null||j.updateLeft(m.current);const N=St(m.current+P,{startLeft:h,scale:T,scaleWidth:v});e({time:N}),O&&O(N)}return!1},children:k.jsxs("div",{className:tt("cursor"),children:[k.jsx("svg",{className:tt("cursor-top"),width:"8",height:"12",viewBox:"0 0 8 12",fill:"none",children:k.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:"#5297FF"})}),k.jsx("div",{className:tt("cursor-area")})]})})};function Ot(n,t,e){let r=e.initialDeps??[],s;function i(){var o,c,l,u;let a;e.key&&((o=e.debug)!=null&&o.call(e))&&(a=Date.now());const g=n();if(!(g.length!==r.length||g.some((x,E)=>r[E]!==x)))return s;r=g;let O;if(e.key&&((c=e.debug)!=null&&c.call(e))&&(O=Date.now()),s=t(...g),e.key&&((l=e.debug)!=null&&l.call(e))){const x=Math.round((Date.now()-a)*100)/100,E=Math.round((Date.now()-O)*100)/100,m=E/16,h=(v,T)=>{for(v=String(v);v.length<T;)v=" "+v;return v};console.info(`%c⏱ ${h(E,5)} /${h(x,5)} ms`,`
|
|
23
|
+
font-size: .6rem;
|
|
24
|
+
font-weight: bold;
|
|
25
|
+
color: hsl(${Math.max(0,Math.min(120-120*m,120))}deg 100% 31%);`,e==null?void 0:e.key)}return(u=e==null?void 0:e.onChange)==null||u.call(e,s),s}return i.updateDeps=o=>{r=o},i}function we(n,t){if(n===void 0)throw new Error("Unexpected undefined");return n}const ar=(n,t)=>Math.abs(n-t)<1.01,lr=(n,t,e)=>{let r;return function(...s){n.clearTimeout(r),r=n.setTimeout(()=>t.apply(this,s),e)}},Se=n=>{const{offsetWidth:t,offsetHeight:e}=n;return{width:t,height:e}},ur=n=>n,fr=n=>{const t=Math.max(n.startIndex-n.overscan,0),e=Math.min(n.endIndex+n.overscan,n.count-1),r=[];for(let s=t;s<=e;s++)r.push(s);return r},dr=(n,t)=>{const e=n.scrollElement;if(!e)return;const r=n.targetWindow;if(!r)return;const s=o=>{const{width:c,height:l}=o;t({width:Math.round(c),height:Math.round(l)})};if(s(Se(e)),!r.ResizeObserver)return()=>{};const i=new r.ResizeObserver(o=>{const c=()=>{const l=o[0];if(l!=null&&l.borderBoxSize){const u=l.borderBoxSize[0];if(u){s({width:u.inlineSize,height:u.blockSize});return}}s(Se(e))};n.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return i.observe(e,{box:"border-box"}),()=>{i.unobserve(e)}},xe={passive:!0},Te=typeof window>"u"?!0:"onscrollend"in window,hr=(n,t)=>{const e=n.scrollElement;if(!e)return;const r=n.targetWindow;if(!r)return;let s=0;const i=n.options.useScrollendEvent&&Te?()=>{}:lr(r,()=>{t(s,!1)},n.options.isScrollingResetDelay),o=a=>()=>{const{horizontal:g,isRtl:p}=n.options;s=g?e.scrollLeft*(p&&-1||1):e.scrollTop,i(),t(s,a)},c=o(!0),l=o(!1);l(),e.addEventListener("scroll",c,xe);const u=n.options.useScrollendEvent&&Te;return u&&e.addEventListener("scrollend",l,xe),()=>{e.removeEventListener("scroll",c),u&&e.removeEventListener("scrollend",l)}},pr=(n,t,e)=>{if(t!=null&&t.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[e.options.horizontal?"inlineSize":"blockSize"])}return n[e.options.horizontal?"offsetWidth":"offsetHeight"]},mr=(n,{adjustments:t=0,behavior:e},r)=>{var s,i;const o=n+t;(i=(s=r.scrollElement)==null?void 0:s.scrollTo)==null||i.call(s,{[r.options.horizontal?"left":"top"]:o,behavior:e})};class gr{constructor(t){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 e=null;const r=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(s=>{s.forEach(i=>{const o=()=>{this._measureElement(i.target,i)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var s;(s=r())==null||s.disconnect(),e=null},observe:s=>{var i;return(i=r())==null?void 0:i.observe(s,{box:"border-box"})},unobserve:s=>{var i;return(i=r())==null?void 0:i.unobserve(s)}}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([r,s])=>{typeof s>"u"&&delete e[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:ur,rangeExtractor:fr,onChange:()=>{},measureElement:pr,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,...e}},this.notify=e=>{var r,s;(s=(r=this.options).onChange)==null||s.call(r,this,e)},this.maybeNotify=Ot(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{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(e=>e()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e;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=((e=this.scrollElement)==null?void 0:e.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,i)=>{this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()<s?"forward":"backward":null,this.scrollOffset=s,this.isScrolling=i,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=(e,r)=>{const s=new Map,i=new Map;for(let o=r-1;o>=0;o--){const c=e[o];if(s.has(c.lane))continue;const l=i.get(c.lane);if(l==null||c.end>l.end?i.set(c.lane,c):c.end<l.end&&s.set(c.lane,!0),s.size===this.options.lanes)break}return i.size===this.options.lanes?Array.from(i.values()).sort((o,c)=>o.end===c.end?o.index-c.index:o.end-c.end)[0]:void 0},this.getMeasurementOptions=Ot(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled],(e,r,s,i,o)=>(this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:r,scrollMargin:s,getItemKey:i,enabled:o}),{key:!1}),this.getMeasurements=Ot(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:r,scrollMargin:s,getItemKey:i,enabled:o},c)=>{if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),[];this.measurementsCache.length===0&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(a=>{this.itemSizeCache.set(a.key,a.size)}));const l=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];const u=this.measurementsCache.slice(0,l);for(let a=l;a<e;a++){const g=i(a),p=this.options.lanes===1?u[a-1]:this.getFurthestMeasurement(u,a),O=p?p.end+this.options.gap:r+s,x=c.get(g),E=typeof x=="number"?x:this.options.estimateSize(a),m=O+E,h=p?p.lane:a%this.options.lanes;u[a]={index:a,start:O,size:E,end:m,key:g,lane:h}}return this.measurementsCache=u,u},{key:process.env.NODE_ENV!=="production"&&"getMeasurements",debug:()=>this.options.debug}),this.calculateRange=Ot(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,r,s,i)=>this.range=e.length>0&&r>0?vr({measurements:e,outerSize:r,scrollOffset:s,lanes:i}):null,{key:process.env.NODE_ENV!=="production"&&"calculateRange",debug:()=>this.options.debug}),this.getVirtualIndexes=Ot(()=>{let e=null,r=null;const s=this.calculateRange();return s&&(e=s.startIndex,r=s.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,r]},(e,r,s,i,o)=>i===null||o===null?[]:e({startIndex:i,endIndex:o,overscan:r,count:s}),{key:process.env.NODE_ENV!=="production"&&"getVirtualIndexes",debug:()=>this.options.debug}),this.indexFromElement=e=>{const r=this.options.indexAttribute,s=e.getAttribute(r);return s?parseInt(s,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this._measureElement=(e,r)=>{const s=this.indexFromElement(e),i=this.measurementsCache[s];if(!i)return;const o=i.key,c=this.elementsCache.get(o);c!==e&&(c&&this.observer.unobserve(c),this.observer.observe(e),this.elementsCache.set(o,e)),e.isConnected&&this.resizeItem(s,this.options.measureElement(e,r,this))},this.resizeItem=(e,r)=>{const s=this.measurementsCache[e];if(!s)return;const i=this.itemSizeCache.get(s.key)??s.size,o=r-i;o!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(s,o,this):s.start<this.getScrollOffset()+this.scrollAdjustments)&&(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("correction",o),this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0})),this.pendingMeasuredCacheIndexes.push(s.index),this.itemSizeCache=new Map(this.itemSizeCache.set(s.key,r)),this.notify(!1))},this.measureElement=e=>{if(!e){this.elementsCache.forEach((r,s)=>{r.isConnected||(this.observer.unobserve(r),this.elementsCache.delete(s))});return}this._measureElement(e,void 0)},this.getVirtualItems=Ot(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,r)=>{const s=[];for(let i=0,o=e.length;i<o;i++){const c=e[i],l=r[c];s.push(l)}return s},{key:process.env.NODE_ENV!=="production"&&"getVirtualItems",debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{const r=this.getMeasurements();if(r.length!==0)return we(r[Ue(0,r.length-1,s=>we(r[s]).start,e)])},this.getOffsetForAlignment=(e,r,s=0)=>{const i=this.getSize(),o=this.getScrollOffset();r==="auto"&&(r=e>=o+i?"end":"start"),r==="center"?e+=(s-i)/2:r==="end"&&(e-=i);const c=this.getTotalSize()+this.options.scrollMargin-i;return Math.max(Math.min(c,e),0)},this.getOffsetForIndex=(e,r="auto")=>{e=Math.max(0,Math.min(e,this.options.count-1));const s=this.measurementsCache[e];if(!s)return;const i=this.getSize(),o=this.getScrollOffset();if(r==="auto")if(s.end>=o+i-this.options.scrollPaddingEnd)r="end";else if(s.start<=o+this.options.scrollPaddingStart)r="start";else return[o,r];const c=r==="end"?s.end+this.options.scrollPaddingEnd:s.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(c,r,s.size),r]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(e,{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(e,r),{adjustments:void 0,behavior:s})},this.scrollToIndex=(e,{align:r="auto",behavior:s}={})=>{s==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),e=Math.max(0,Math.min(e,this.options.count-1));let i=0;const o=10,c=u=>{if(!this.targetWindow)return;const a=this.getOffsetForIndex(e,u);if(!a){console.warn("Failed to get offset for index:",e);return}const[g,p]=a;this._scrollToOffset(g,{adjustments:void 0,behavior:s}),this.targetWindow.requestAnimationFrame(()=>{const O=this.getScrollOffset(),x=this.getOffsetForIndex(e,p);if(!x){console.warn("Failed to get offset for index:",e);return}ar(x[0],O)||l(p)})},l=u=>{this.targetWindow&&(i++,i<o?(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("Schedule retry",i,o),this.targetWindow.requestAnimationFrame(()=>c(u))):console.warn(`Failed to scroll to index ${e} after ${o} attempts.`))};c(r)},this.scrollBy=(e,{behavior:r}={})=>{r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+e,{adjustments:void 0,behavior:r})},this.getTotalSize=()=>{var e;const r=this.getMeasurements();let s;if(r.length===0)s=this.options.paddingStart;else if(this.options.lanes===1)s=((e=r[r.length-1])==null?void 0:e.end)??0;else{const i=Array(this.options.lanes).fill(null);let o=r.length-1;for(;o>=0&&i.some(c=>c===null);){const c=r[o];i[c.lane]===null&&(i[c.lane]=c.end),o--}s=Math.max(...i.filter(c=>c!==null))}return Math.max(s-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:r,behavior:s})=>{this.options.scrollToFn(e,{behavior:s,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.notify(!1)},this.setOptions(t)}}const Ue=(n,t,e,r)=>{for(;n<=t;){const s=(n+t)/2|0,i=e(s);if(i<r)n=s+1;else if(i>r)t=s-1;else return s}return n>0?n-1:0};function vr({measurements:n,outerSize:t,scrollOffset:e,lanes:r}){const s=n.length-1,i=l=>n[l].start;if(n.length<=r)return{startIndex:0,endIndex:s};let o=Ue(0,s,i,e),c=o;if(r===1)for(;c<s&&n[c].end<e+t;)c++;else if(r>1){const l=Array(r).fill(0);for(;c<s&&l.some(a=>a<e+t);){const a=n[c];l[a.lane]=a.end,c++}const u=Array(r).fill(e+t);for(;o>=0&&u.some(a=>a>=e);){const a=n[o];u[a.lane]=a.start,o--}o=Math.max(0,o-o%r),c=Math.min(s,c+(r-1-c%r))}return{startIndex:o,endIndex:c}}const Re=typeof document<"u"?Et.useLayoutEffect:Et.useEffect;function br(n){const t=Et.useReducer(()=>({}),{})[1],e={...n,onChange:(s,i)=>{var o;i?Ke.flushSync(t):t(),(o=n.onChange)==null||o.call(n,s,i)}},[r]=Et.useState(()=>new gr(e));return r.setOptions(e),Re(()=>r._didMount(),[]),Re(()=>r._willUpdate()),r}function Be(n){return br({observeElementRect:dr,observeElementOffset:hr,scrollToFn:mr,...n})}const yr=({isMoving:n,movePositions:t=[],assistPositions:e=[],scrollLeft:r})=>k.jsx("div",{className:tt("drag-line-container"),children:n&&t.filter(s=>e.includes(s)).map((s,i)=>k.jsx("div",{className:tt("drag-line"),style:{left:s-r}},i))}),Er=({editorData:n,row:t,action:e,effects:r,rowHeight:s,scale:i,scaleWidth:o,scaleSplitCount:c,startLeft:l,gridSnap:u,disableDrag:a,scaleCount:g,maxScaleCount:p,setScaleCount:O,onActionMoveStart:x,onActionMoving:E,onActionMoveEnd:m,onActionResizeStart:h,onActionResizeEnd:v,onActionResizing:T,dragLineData:R,setEditorData:b,onClickAction:D,onClickActionOnly:P,onDoubleClickAction:L,onContextMenuAction:j,getActionRender:N,handleTime:W,areaRef:z,deltaScrollLeft:Y})=>{const st=y.useRef(null),I=y.useRef(!1),{id:$,maxEnd:q,minStart:K,end:pt,start:dt,selected:f,flexible:A=!0,movable:d=!0,effectId:_}=e,w=i??Ft,M=o??Vt,S=l??Ut,X=c??Oe,C=p??Number.MAX_SAFE_INTEGER,U=ht(K||0,{startLeft:S,scale:w,scaleWidth:M}),J=Math.min(C*M+S,ht(q||Number.MAX_VALUE,{startLeft:S,scale:w,scaleWidth:M})),V=y.useMemo(()=>Me({start:dt,end:pt},{startLeft:S,scale:w,scaleWidth:M}),[pt,dt,S,M,w]),[et,Z]=y.useState(null),at=et??V,_t=M/X,ut=["action"];d&&ut.push("action-movable"),f&&ut.push("action-selected"),A&&ut.push("action-flexible"),r[_]&&ut.push(`action-effect-${_}`);const xt=(F,B)=>{const it=an(F+B,{startLeft:S,scaleCount:g,scaleWidth:M});it!==g&&O(it)},Xt=()=>{x&&x({action:e,row:t})},kt=({left:F,width:B})=>{if(I.current=!0,E){const{start:it,end:ft}=Mt({left:F,width:B},{scaleWidth:M,scale:w,startLeft:S});if(E({action:e,row:t,start:it,end:ft})===!1)return!1}Z({left:F,width:B}),xt(F,B)},wt=({left:F,width:B})=>{const{start:it,end:ft}=Mt({left:F,width:B},{scaleWidth:M,scale:w,startLeft:S}),mt=n.find(vt=>vt.id===t.id);if(!mt)return;const gt=mt.actions.find(vt=>vt.id===$);gt&&(gt.start=it,gt.end=ft,b(n),m&&m({action:gt,row:t,start:it,end:ft}),Z(null))},Gt=F=>{h&&h({action:e,row:t,dir:F})},Q=(F,{left:B,width:it})=>{if(I.current=!0,T){const{start:ft,end:mt}=Mt({left:B,width:it},{scaleWidth:M,scale:w,startLeft:S});if(T({action:e,row:t,start:ft,end:mt,dir:F})===!1)return!1}Z({left:B,width:it}),xt(B,it)},nt=(F,{left:B,width:it})=>{const{start:ft,end:mt}=Mt({left:B,width:it},{scaleWidth:M,scale:w,startLeft:S}),gt=n.find(Ht=>Ht.id===t.id);if(!gt)return;const vt=gt.actions.find(Ht=>Ht.id===$);vt&&(vt.start=ft,vt.end=mt,b(n),v&&v({action:vt,row:t,start:ft,end:mt,dir:F}),Z(null))},H={...e,...Mt({left:at.left,width:at.width},{startLeft:S,scaleWidth:M,scale:w})},Tt={...t,actions:[...t.actions]};return t.actions.includes(e)&&(Tt.actions[t.actions.indexOf(e)]=H),k.jsx(Ve,{ref:st,parentRef:z,start:S,left:at.left,width:at.width,grid:u&&_t||Qt,adsorptionDistance:u?Math.max((_t||Qt)/2,te):te,adsorptionPositions:R.assistPositions,bounds:{left:U,right:J},edges:{left:!a&&A&&`.${tt("action-left-stretch")}`,right:!a&&A&&`.${tt("action-right-stretch")}`},enableDragging:!a&&d,enableResizing:!a&&A,onDragStart:Xt,onDrag:kt,onDragEnd:wt,onResizeStart:Gt,onResize:Q,onResizeEnd:nt,deltaScrollLeft:Y,children:k.jsxs("div",{onMouseDown:()=>{I.current=!1},onClick:F=>{let B;D&&(B=W(F),D(F,{row:t,action:e,time:B})),!I.current&&P&&(B===void 0&&(B=W(F)),P(F,{row:t,action:e,time:B}))},onDoubleClick:F=>{if(L){const B=W(F);L(F,{row:t,action:e,time:B})}},onContextMenu:F=>{if(j){const B=W(F);j(F,{row:t,action:e,time:B})}},className:tt((ut||[]).join(" ")),style:{height:s},children:[N&&N(H,Tt),A&&k.jsx("div",{className:tt("action-left-stretch"),style:{touchAction:"none"}}),A&&k.jsx("div",{className:tt("action-right-stretch"),style:{touchAction:"none"}})]})})},_r=n=>{const{rowData:t,style:e={},onClickRow:r,onDoubleClickRow:s,onContextMenuRow:i,areaRef:o,scrollLeft:c,startLeft:l,scale:u,scaleWidth:a}=n,g=["edit-row"];t!=null&&t.selected&&g.push("edit-row-selected");const p=u??Ft,O=a??Vt,x=l??Ut,E=m=>{if(!o.current)return 0;const h=o.current.getBoundingClientRect(),T=m.clientX-h.x+c;return St(T,{startLeft:x,scale:p,scaleWidth:O})};return k.jsx("div",{className:`${tt(...g)} ${((t==null?void 0:t.classNames)||[]).join(" ")}`,style:e,onClick:m=>{if(t&&r){const h=E(m);r(m,{row:t,time:h})}},onDoubleClick:m=>{if(t&&s){const h=E(m);s(m,{row:t,time:h})}},onContextMenu:m=>{if(t&&i){const h=E(m);i(m,{row:t,time:h})}},children:t&&(t.actions||[]).map(m=>k.jsx(Er,{...n,handleTime:E,row:t,action:m},m.id))})};function wr(){const[n,t]=y.useState({isMoving:!1,movePositions:[],assistPositions:[]});return{initDragLine:c=>{const{movePositions:l,assistPositions:u}=c;t({isMoving:!0,movePositions:l||[],assistPositions:u||[]})},updateDragLine:c=>{const{movePositions:l,assistPositions:u}=c;t(a=>({...a,movePositions:l||a.movePositions,assistPositions:u||a.assistPositions}))},disposeDragLine:()=>{t({isMoving:!1,movePositions:[],assistPositions:[]})},dragLineData:n,defaultGetAssistPosition:c=>{const{editorData:l,assistActionIds:u,action:a,row:g,scale:p,scaleWidth:O,startLeft:x,cursorLeft:E,hideCursor:m}=c,h=[];u?l.forEach(T=>{T.actions.forEach(R=>{u.includes(R.id)&&h.push(R)})}):l.forEach(T=>{T.id!==g.id?h.push(...T.actions):T.actions.forEach(R=>{R.id!==a.id&&h.push(R)})});const v=ln(h,{startLeft:x,scale:p,scaleWidth:O});return m||v.push(E),v},defaultGetMovePosition:c=>{const{start:l,end:u,dir:a,scale:g,scaleWidth:p,startLeft:O}=c,{left:x,width:E}=Me({start:l,end:u},{startLeft:O,scaleWidth:p,scale:g});return a?a==="right"?[x+E]:[x]:[x,x+E]}}}function Sr(n){return typeof n=="object"&&n!==null}function xr(n,t,e){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 Tr(n){return Sr(n)&&"ownerSVGElement"in n}const Wt=new WeakMap;let yt;const Xe=(n,t,e)=>(r,s)=>s&&s[0]?s[0][n+"Size"]:Tr(r)&&"getBBox"in r?r.getBBox()[t]:r[e],Rr=Xe("inline","width","offsetWidth"),Or=Xe("block","height","offsetHeight");function Ar({target:n,borderBoxSize:t}){var e;(e=Wt.get(n))==null||e.forEach(r=>{r(n,{get width(){return Rr(n,t)},get height(){return Or(n,t)}})})}function Cr(n){n.forEach(Ar)}function Dr(){typeof ResizeObserver>"u"||(yt=new ResizeObserver(Cr))}function Mr(n,t){yt||Dr();const e=xr(n);return e.forEach(r=>{let s=Wt.get(r);s||(s=new Set,Wt.set(r,s)),s.add(t),yt==null||yt.observe(r)}),()=>{e.forEach(r=>{const s=Wt.get(r);s==null||s.delete(t),s!=null&&s.size||yt==null||yt.unobserve(r)})}}const zt=new Set;let At;function Ir(){At=()=>{const n={get width(){return window.innerWidth},get height(){return window.innerHeight}};zt.forEach(t=>t(n))},window.addEventListener("resize",At)}function Pr(n){return zt.add(n),At||Ir(),()=>{zt.delete(n),!zt.size&&typeof At=="function"&&(window.removeEventListener("resize",At),At=void 0)}}function kr(n,t){return typeof n=="function"?Pr(n):Mr(n,t)}function Ge({render:n,ref:t,...e}){const[r,s]=y.useState({width:0,height:0}),i=y.useRef(null);return y.useLayoutEffect(()=>{i.current&&kr(i.current,(o,c)=>{s({width:c.width,height:c.height})})},[]),k.jsx("div",{ref:ze(i,t),...e,children:n(r)})}const Lr=({width:n,height:t,editAreaRef:e,editorData:r,rowHeight:s,scaleWidth:i,scaleCount:o,setScaleCount:c,startLeft:l,scrollLeft:u,scrollTop:a,scale:g,dragLine:p,getAssistDragLineActionIds:O,onActionMoveEnd:x,onActionMoveStart:E,onActionMoving:m,onActionResizeEnd:h,onActionResizeStart:v,onActionResizing:T,onScroll:R,cursorTime:b,hideCursor:D,setEditorData:P,deltaScrollLeft:L,timelineWidth:j,getActionRender:N,getScaleRender:W,onClickRow:z,onDoubleClickRow:Y,onContextMenuRow:st,onClickAction:I,onClickActionOnly:$,onDoubleClickAction:q,onContextMenuAction:K,onCursorDragStart:pt,onCursorDragEnd:dt,onCursorDrag:f,onClickTimeArea:A,gridSnap:d,effects:_})=>{const{dragLineData:w,initDragLine:M,updateDragLine:S,disposeDragLine:X,defaultGetAssistPosition:C,defaultGetMovePosition:U}=wr(),J=y.useRef(null),V=y.useRef(-1),et=Q=>{if(p){const nt=O&&O({action:Q.action,row:Q.row,editorData:r}),H=i??160,Tt=g??1,F=l??20,B=D??!1,it=ht(b,{scaleWidth:H,scale:Tt,startLeft:F}),ft=C({editorData:r,assistActionIds:nt,action:Q.action,row:Q.row,scale:Tt,scaleWidth:H,startLeft:F,hideCursor:B,cursorLeft:it});M({assistPositions:ft})}},Z=Q=>{if(p){const F=U({...Q,startLeft:l??20,scaleWidth:i??160,scale:g??1});S({movePositions:F})}};let at=0;const _t=s??32,ut=r.map(Q=>{const nt=Q.rowHeight||_t;return at+=nt,nt});at<t&&(ut.push(t-at),V.current!==t&&V.current>=0&&setTimeout(()=>{wt.measure()})),V.current=t;const xt=i??160,Xt=l??20,kt=Math.max(o*xt+Xt,n),wt=Be({count:ut.length,getScrollElement:()=>J.current,estimateSize:Q=>ut[Q]??_t,overscan:10});y.useLayoutEffect(()=>{J.current&&(a!==void 0&&(J.current.scrollTop=a),u!==void 0&&(J.current.scrollLeft=u))},[a,u]),y.useEffect(()=>{wt.measure()},[r,wt]);const Gt=Q=>{const nt=Q.currentTarget;R({clientHeight:nt.clientHeight,clientWidth:nt.clientWidth,scrollHeight:nt.scrollHeight,scrollLeft:nt.scrollLeft,scrollTop:nt.scrollTop,scrollWidth:nt.scrollWidth})};return k.jsxs(k.Fragment,{children:[k.jsx("div",{ref:J,style:{width:n,height:t,overflow:"auto"},onScroll:Gt,children:k.jsx("div",{style:{height:`${wt.getTotalSize()}px`,width:kt,position:"relative"},children:wt.getVirtualItems().map(Q=>{const nt=r[Q.index];return k.jsx(_r,{scaleCount:o,setScaleCount:c,cursorTime:b,editorData:r,rowHeight:s,scaleWidth:i,startLeft:l,scale:g,hideCursor:D,timelineWidth:j,getActionRender:N,getScaleRender:W,onClickRow:z,onDoubleClickRow:Y,onContextMenuRow:st,onClickAction:I,onClickActionOnly:$,onDoubleClickAction:q,onContextMenuAction:K,onCursorDragStart:pt,onCursorDragEnd:dt,onCursorDrag:f,onClickTimeArea:A,gridSnap:d,effects:_,setEditorData:P,deltaScrollLeft:L,style:{position:"absolute",top:0,left:0,width:kt,height:`${Q.size}px`,transform:`translateY(${Q.start}px)`,backgroundPositionX:`0, ${l??20}px`,backgroundSize:`${l??20}px, ${i??160}px`},areaRef:e,rowData:nt,dragLineData:w,onActionMoveStart:H=>(et(H),E&&E(H)),onActionResizeStart:H=>(et(H),v&&v(H)),onActionMoving:H=>(Z(H),m&&m(H)),onActionResizing:H=>(Z(H),T&&T(H)),onActionResizeEnd:H=>(X(),h&&h(H)),onActionMoveEnd:H=>(X(),x&&x(H)),scrollLeft:u},Q.key)})})}),p&&k.jsx(yr,{scrollLeft:u,...w})]})},Nr=y.forwardRef((n,t)=>{const e=y.useRef(null);return y.useImperativeHandle(t,()=>({get domRef(){return e}})),k.jsx(Ge,{ref:e,className:tt("edit-area"),render:({width:r,height:s})=>k.jsx(Lr,{...n,width:r,height:s,editAreaRef:e})})}),jr=({setCursor:n,maxScaleCount:t,hideCursor:e,scale:r,scaleWidth:s,scaleCount:i,scaleSplitCount:o,startLeft:c,scrollLeft:l,onClickTimeArea:u,getScaleRender:a})=>{const g=y.useRef(null),p=(o??0)>0,O=m=>{const h=o??1,v=s??160,T=c??20;switch(m){case 0:return T;default:return p?v/h:v}},x=p?i*(o??1)+1:i,E=Be({horizontal:!0,count:x,getScrollElement:()=>g.current,estimateSize:O,overscan:10});return y.useLayoutEffect(()=>{g.current&&l!==void 0&&(g.current.scrollLeft=l)},[l]),y.useEffect(()=>{E.measure()},[s,c,E]),k.jsx(Ge,{className:tt("time-area"),render:({width:m,height:h})=>k.jsxs(k.Fragment,{children:[k.jsx("div",{className:tt("time-area-virtual"),ref:g,style:{width:m,height:h,overflowX:"hidden",overflowY:"hidden"},children:k.jsx("div",{style:{width:`${E.getTotalSize()}px`,height:"100%",position:"relative"},children:E.getVirtualItems().map(v=>{const T=v.index,R=o??1,b=r??1,D=p?T%R===0:!0,P=["time-unit"];D&&P.push("time-unit-big");const L=(p?T/R:T)*b;return k.jsx("div",{"data-index":v.index,style:{position:"absolute",top:0,left:0,height:"100%",width:`${v.size}px`,transform:`translateX(${v.start}px)`},className:tt(...P),children:D&&k.jsx("div",{className:tt("time-unit-scale"),children:a?a(L):L})},v.key)})})}),k.jsx("div",{style:{width:m,height:h},onClick:v=>{if(e)return;const T=c??20,R=s??160,b=r??1,D=t??1/0,P=v.currentTarget.getBoundingClientRect(),L=v.clientX-P.x,j=Math.max(L+l,T);if(j>D*R+T-l)return;const N=St(j,{startLeft:T,scale:b,scaleWidth:R});(u&&u(N,v))!==!1&&n({time:N})},className:tt("time-area-interact")})]})})},Wr=y.forwardRef((n,t)=>{const e=on(n),{style:r}=n;let{editorData:s,scrollTop:i,autoScroll:o,hideCursor:c,disableDrag:l,scale:u=1,scaleWidth:a=160,startLeft:g=20,minScaleCount:p=20,maxScaleCount:O=1/0,onChange:x,onScroll:E}=e;const m=y.useRef(null),h=y.useRef(null),v=y.useRef(null),[T,R]=y.useState(s),[b,D]=y.useState(ee),[P,L]=y.useState(Qe),[j,N]=y.useState(Number.MAX_SAFE_INTEGER),W=y.useCallback(I=>{const $=Math.min(O,Math.max(p,I));D($)},[O,p]);y.useLayoutEffect(()=>{W(cn(s,{scale:u})),R(s)},[s,p,O,u,W]),y.useEffect(()=>{var I;i!==void 0&&((I=v.current)==null||I.setScrollState($=>({...$,scrollTop:i})))},[i]);const z=I=>{x==null||x(I)},Y=I=>{let{left:$,time:q}=I;if(typeof $>"u"&&typeof q>"u")return!0;typeof q>"u"&&($=ht(q??0,{startLeft:g,scale:u,scaleWidth:a}),q=St($,{startLeft:g,scale:u,scaleWidth:a}));let K=!0;return L(q),K},st=I=>{var q;!((q=v.current)!=null&&q.state)||v.current.state.scrollLeft+I>b*(a-1)+g-j||v.current&&v.current.setScrollState(K=>({...K,scrollLeft:Math.max(K.scrollLeft+I,0)}))};return y.useImperativeHandle(t,()=>({get target(){return m.current},set time(I){Y({time:I})},get time(){return P},setScrollLeft:I=>{v.current&&v.current.setScrollState($=>({...$,scrollLeft:Math.max(I,0)}))},setScrollTop:I=>{v.current&&v.current.setScrollState($=>({...$,scrollTop:Math.max(I,0)}))}})),y.useEffect(()=>{if(h.current){const I=new ResizeObserver(()=>{h.current&&N(h.current.getBoundingClientRect().width)});return I.observe(h.current),()=>{I&&I.disconnect()}}},[]),k.jsx("div",{ref:m,style:r,className:`${Zt} ${l?Zt+"-disable":""}`,children:k.jsx($e,{ref:v,children:({scrollLeft:I,scrollTop:$,onScroll:q})=>k.jsxs(k.Fragment,{children:[k.jsx(jr,{...e,timelineWidth:j,disableDrag:l,setCursor:Y,cursorTime:P,editorData:T,scaleCount:b,setScaleCount:W,onScroll:q,scrollLeft:I}),k.jsx(Nr,{...e,timelineWidth:j,ref:K=>{K!=null&&K.domRef.current&&(h.current=K.domRef.current)},disableDrag:l,editorData:T,cursorTime:P,scaleCount:b,setScaleCount:W,scrollTop:$,scrollLeft:I,setEditorData:z,deltaScrollLeft:o?st:void 0,onScroll:K=>{q(K),E==null||E(K)}}),!c&&k.jsx(cr,{...e,timelineWidth:j,scrollLeft:I,scaleCount:b,setScaleCount:W,setCursor:Y,cursorTime:P,editorData:T,areaRef:h,scrollSync:v,deltaScrollLeft:o?st:void 0})]})})})});exports.Timeline=Wr;
|