@jeevandev/flow-canvas 0.0.6 → 0.0.8

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,5 +1,5 @@
1
1
  import re, { createContext as qt, useContext as ht, useRef as ve, useEffect as ie, useState as Le, useCallback as ge, useMemo as tt } from "react";
2
- var Ae = { exports: {} }, Ee = {};
2
+ import './index.css';var Ae = { exports: {} }, Ee = {};
3
3
  var Et;
4
4
  function bn() {
5
5
  if (Et) return Ee;
@@ -1,12 +1,13 @@
1
- (function(G,k){typeof exports=="object"&&typeof module<"u"?k(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],k):(G=typeof globalThis<"u"?globalThis:G||self,k(G.FlowCanvas={},G.React))})(this,(function(G,k){"use strict";var Ce={exports:{}},we={};var _t;function yn(){if(_t)return we;_t=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(s,r,i){var o=null;if(i!==void 0&&(o=""+i),r.key!==void 0&&(o=""+r.key),"key"in r){i={};for(var a in r)a!=="key"&&(i[a]=r[a])}else i=r;return r=i.ref,{$$typeof:t,type:s,key:o,ref:r!==void 0?r:null,props:i}}return we.Fragment=e,we.jsx=n,we.jsxs=n,we}var Ee={};var vt;function _n(){return vt||(vt=1,process.env.NODE_ENV!=="production"&&(function(){function t(u){if(u==null)return null;if(typeof u=="function")return u.$$typeof===j?null:u.displayName||u.name||null;if(typeof u=="string")return u;switch(u){case c:return"Fragment";case p:return"Profiler";case g:return"StrictMode";case h:return"Suspense";case O:return"SuspenseList";case S:return"Activity"}if(typeof u=="object")switch(typeof u.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),u.$$typeof){case C:return"Portal";case _:return u.displayName||"Context";case b:return(u._context.displayName||"Context")+".Consumer";case D:var A=u.render;return u=u.displayName,u||(u=A.displayName||A.name||"",u=u!==""?"ForwardRef("+u+")":"ForwardRef"),u;case T:return A=u.displayName||null,A!==null?A:t(u.type)||"Memo";case I:A=u._payload,u=u._init;try{return t(u(A))}catch{}}return null}function e(u){return""+u}function n(u){try{e(u);var A=!1}catch{A=!0}if(A){A=console;var V=A.error,W=typeof Symbol=="function"&&Symbol.toStringTag&&u[Symbol.toStringTag]||u.constructor.name||"Object";return V.call(A,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",W),e(u)}}function s(u){if(u===c)return"<>";if(typeof u=="object"&&u!==null&&u.$$typeof===I)return"<...>";try{var A=t(u);return A?"<"+A+">":"<...>"}catch{return"<...>"}}function r(){var u=z.A;return u===null?null:u.getOwner()}function i(){return Error("react-stack-top-frame")}function o(u){if(E.call(u,"key")){var A=Object.getOwnPropertyDescriptor(u,"key").get;if(A&&A.isReactWarning)return!1}return u.key!==void 0}function a(u,A){function V(){q||(q=!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))}V.isReactWarning=!0,Object.defineProperty(u,"key",{get:V,configurable:!0})}function l(){var u=t(this.type);return H[u]||(H[u]=!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.")),u=this.props.ref,u!==void 0?u:null}function d(u,A,V,W,be,x){var R=V.ref;return u={$$typeof:N,type:u,key:A,props:V,_owner:W},(R!==void 0?R:null)!==null?Object.defineProperty(u,"ref",{enumerable:!1,get:l}):Object.defineProperty(u,"ref",{enumerable:!1,value:null}),u._store={},Object.defineProperty(u._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(u,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(u,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:be}),Object.defineProperty(u,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:x}),Object.freeze&&(Object.freeze(u.props),Object.freeze(u)),u}function f(u,A,V,W,be,x){var R=A.children;if(R!==void 0)if(W)if(B(R)){for(W=0;W<R.length;W++)v(R[W]);Object.freeze&&Object.freeze(R)}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 v(R);if(E.call(A,"key")){R=t(u);var K=Object.keys(A).filter(function(ne){return ne!=="key"});W=0<K.length?"{key: someKey, "+K.join(": ..., ")+": ...}":"{key: someKey}",re[R+W]||(K=0<K.length?"{"+K.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1
+ (function(G,I){typeof exports=="object"&&typeof module<"u"?I(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],I):(G=typeof globalThis<"u"?globalThis:G||self,I(G.FlowCanvas={},G.React))})(this,(function(G,I){"use strict";var vt=document.createElement("style");vt.textContent=`.ce-editor{position:relative;width:100%;height:100%;overflow:hidden;background-color:#f3f4f6}.ce-editor__canvas{position:absolute;top:0;left:0;width:100%;height:100%;touch-action:none;transform-origin:0 0}.ce-editor__viewport{width:100%;height:100%;overflow:hidden}.ce-editor__viewport--panning{cursor:grab!important}.ce-editor__viewport--panning *{pointer-events:none!important}.ce-editor__grid-layer{position:absolute;top:-50000px;left:-50000px;width:100000px;height:100000px;opacity:.5;pointer-events:none;z-index:0}.ce-editor__content-area{position:absolute;left:0;top:0;background-color:#fff;overflow:hidden;z-index:1;box-shadow:0 0 20px #0000001a}.ce-editor__infinite-area{position:relative;z-index:1}.ce-element{position:absolute;touch-action:none;-webkit-user-select:none;user-select:none;box-sizing:border-box;transition:box-shadow .1s}.ce-element--selected{outline:2px solid #3b82f6;outline-width:calc(2px * var(--ce-inverse-zoom, 1));box-shadow:0 0 0 calc(4px * var(--ce-inverse-zoom, 1)) #3b82f633;z-index:100!important}.ce-element img{pointer-events:none;-webkit-user-drag:none;-webkit-user-select:none;user-select:none}.ce-editor--connecting{cursor:crosshair!important}.ce-editor--connecting .ce-element:hover{outline:2px dashed #3b82f6;outline-width:calc(2px * var(--ce-inverse-zoom, 1));background-color:#3b82f60d;cursor:copy}.ce-editor--connecting .ce-handle:hover{transform:scale(1.5);background-color:#3b82f6!important;border-color:#fff!important;transition:transform .1s}.ce-resize-handle{width:calc(10px * var(--ce-inverse-zoom, 1));height:calc(10px * var(--ce-inverse-zoom, 1));background:#fff;border:calc(1px * var(--ce-inverse-zoom, 1)) solid #3b82f6;position:absolute;z-index:101}.ce-resize-handle--nw{top:calc(-6px * var(--ce-inverse-zoom, 1));left:calc(-6px * var(--ce-inverse-zoom, 1));cursor:nw-resize}.ce-resize-handle--ne{top:calc(-6px * var(--ce-inverse-zoom, 1));right:calc(-6px * var(--ce-inverse-zoom, 1));cursor:ne-resize}.ce-resize-handle--sw{bottom:calc(-6px * var(--ce-inverse-zoom, 1));left:calc(-6px * var(--ce-inverse-zoom, 1));cursor:sw-resize}.ce-resize-handle--se{bottom:calc(-6px * var(--ce-inverse-zoom, 1));right:calc(-6px * var(--ce-inverse-zoom, 1));cursor:se-resize}.ce-resize-handle--n{top:calc(-6px * var(--ce-inverse-zoom, 1));left:50%;transform:translate(-50%);cursor:n-resize}.ce-resize-handle--s{bottom:calc(-6px * var(--ce-inverse-zoom, 1));left:50%;transform:translate(-50%);cursor:s-resize}.ce-resize-handle--e{right:calc(-6px * var(--ce-inverse-zoom, 1));top:50%;transform:translateY(-50%);cursor:e-resize}.ce-resize-handle--w{left:calc(-6px * var(--ce-inverse-zoom, 1));top:50%;transform:translateY(-50%);cursor:w-resize}.ce-rotate-handle{width:calc(24px * var(--ce-inverse-zoom, 1));height:calc(24px * var(--ce-inverse-zoom, 1));background:#fff;border:none;box-shadow:0 2px 4px #0003;border-radius:50%;position:absolute;top:auto;bottom:calc(-35px * var(--ce-inverse-zoom, 1));left:50%;transform:translate(-50%);cursor:grab;z-index:101;display:flex;align-items:center;justify-content:center;color:#555}.ce-rotate-handle:after{display:none}.ce-rotate-handle:active{cursor:grabbing;background:#f3f4f6;color:#000}.ce-drag-handle-minimal{width:calc(24px * var(--ce-inverse-zoom, 1));height:calc(24px * var(--ce-inverse-zoom, 1));position:absolute;top:auto;bottom:calc(-35px * var(--ce-inverse-zoom, 1));left:calc(50% + calc(30px * var(--ce-inverse-zoom, 1)));transform:translate(-50%);background-color:#fff;border-radius:50%;box-shadow:0 2px 4px #0003;cursor:grab;z-index:102;display:flex;align-items:center;justify-content:center;color:#555;background-image:none}.ce-drag-handle-minimal:active{cursor:grabbing;background-color:#f3f4f6;color:#000}.ce-snap-guide{position:absolute;background-color:#f0f;pointer-events:none;z-index:200}.ce-snap-guide--vertical{width:1px;height:100vh}.ce-snap-guide--horizontal{height:1px;width:100vw}.ce-node-default,.ce-node-input,.ce-node-output{background:#fff;border:1px solid #777;border-radius:4px;padding:10px;min-width:180px;text-align:center;font-size:14px;color:#222;box-shadow:0 1px 4px #0000001a;position:relative}.ce-node-input{border-color:#3b82f6}.ce-node-output{border-color:#10b981}.ce-node-content{pointer-events:none}.ce-handle{width:10px;height:10px;background:#fff;border-radius:50%;position:absolute;border:3px solid #777;z-index:10;cursor:crosshair;transition:border-color .2s}.ce-handle--left{left:0;transform:translate(-50%)}.ce-handle--right{right:0;transform:translate(50%)}.ce-handle--top{top:0;transform:translateY(-50%)}.ce-handle--bottom{bottom:0;transform:translateY(50%)}.ce-workflow-node:hover .ce-delete-node-btn{opacity:1;pointer-events:auto}.ce-delete-node-btn{position:absolute;top:-8px;right:-8px;width:18px;height:18px;background:#ff4d4f;color:#fff;border:none;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;font-size:14px;line-height:1;padding:0;z-index:20;opacity:0;pointer-events:none;transition:opacity .2s,transform .1s;box-shadow:0 2px 4px #0000001a}.ce-delete-node-btn:hover{transform:scale(1.1);background:#ff7875}.ce-edge-group .ce-edge-delete-fo{opacity:0;pointer-events:none;transition:opacity .2s}.ce-edge-group:hover .ce-edge-delete-fo{opacity:1;pointer-events:auto}.ce-connection-line{animation:dashdraw .5s linear infinite}@keyframes dashdraw{0%{stroke-dashoffset:10}to{stroke-dashoffset:0}}
2
+ /*$vite$:1*/`,document.head.appendChild(vt);var Ce={exports:{}},we={};var _t;function vn(){if(_t)return we;_t=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(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:t,type:r,key:i,ref:s!==void 0?s:null,props:o}}return we.Fragment=e,we.jsx=n,we.jsxs=n,we}var xe={};var bt;function _n(){return bt||(bt=1,process.env.NODE_ENV!=="production"&&(function(){function t(u){if(u==null)return null;if(typeof u=="function")return u.$$typeof===j?null:u.displayName||u.name||null;if(typeof u=="string")return u;switch(u){case c:return"Fragment";case p:return"Profiler";case g:return"StrictMode";case h:return"Suspense";case O:return"SuspenseList";case S:return"Activity"}if(typeof u=="object")switch(typeof u.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),u.$$typeof){case C:return"Portal";case v:return u.displayName||"Context";case b:return(u._context.displayName||"Context")+".Consumer";case D:var A=u.render;return u=u.displayName,u||(u=A.displayName||A.name||"",u=u!==""?"ForwardRef("+u+")":"ForwardRef"),u;case T:return A=u.displayName||null,A!==null?A:t(u.type)||"Memo";case k:A=u._payload,u=u._init;try{return t(u(A))}catch{}}return null}function e(u){return""+u}function n(u){try{e(u);var A=!1}catch{A=!0}if(A){A=console;var H=A.error,W=typeof Symbol=="function"&&Symbol.toStringTag&&u[Symbol.toStringTag]||u.constructor.name||"Object";return H.call(A,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",W),e(u)}}function r(u){if(u===c)return"<>";if(typeof u=="object"&&u!==null&&u.$$typeof===k)return"<...>";try{var A=t(u);return A?"<"+A+">":"<...>"}catch{return"<...>"}}function s(){var u=R.A;return u===null?null:u.getOwner()}function o(){return Error("react-stack-top-frame")}function i(u){if(x.call(u,"key")){var A=Object.getOwnPropertyDescriptor(u,"key").get;if(A&&A.isReactWarning)return!1}return u.key!==void 0}function a(u,A){function H(){q||(q=!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))}H.isReactWarning=!0,Object.defineProperty(u,"key",{get:H,configurable:!0})}function l(){var u=t(this.type);return Y[u]||(Y[u]=!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.")),u=this.props.ref,u!==void 0?u:null}function d(u,A,H,W,be,E){var M=H.ref;return u={$$typeof:N,type:u,key:A,props:H,_owner:W},(M!==void 0?M:null)!==null?Object.defineProperty(u,"ref",{enumerable:!1,get:l}):Object.defineProperty(u,"ref",{enumerable:!1,value:null}),u._store={},Object.defineProperty(u._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(u,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(u,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:be}),Object.defineProperty(u,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:E}),Object.freeze&&(Object.freeze(u.props),Object.freeze(u)),u}function f(u,A,H,W,be,E){var M=A.children;if(M!==void 0)if(W)if(B(M)){for(W=0;W<M.length;W++)_(M[W]);Object.freeze&&Object.freeze(M)}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 _(M);if(x.call(A,"key")){M=t(u);var K=Object.keys(A).filter(function(ne){return ne!=="key"});W=0<K.length?"{key: someKey, "+K.join(": ..., ")+": ...}":"{key: someKey}",se[M+W]||(K=0<K.length?"{"+K.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
3
  let props = %s;
3
4
  <%s {...props} />
4
5
  React keys must be passed directly to JSX without using spread:
5
6
  let props = %s;
6
- <%s key={someKey} {...props} />`,W,R,K,R),re[R+W]=!0)}if(R=null,V!==void 0&&(n(V),R=""+V),o(A)&&(n(A.key),R=""+A.key),"key"in A){V={};for(var L in A)L!=="key"&&(V[L]=A[L])}else V=A;return R&&a(V,typeof u=="function"?u.displayName||u.name||"Unknown":u),d(u,R,V,r(),be,x)}function v(u){m(u)?u._store&&(u._store.validated=1):typeof u=="object"&&u!==null&&u.$$typeof===I&&(u._payload.status==="fulfilled"?m(u._payload.value)&&u._payload.value._store&&(u._payload.value._store.validated=1):u._store&&(u._store.validated=1))}function m(u){return typeof u=="object"&&u!==null&&u.$$typeof===N}var w=k,N=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),c=Symbol.for("react.fragment"),g=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),b=Symbol.for("react.consumer"),_=Symbol.for("react.context"),D=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),O=Symbol.for("react.suspense_list"),T=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),S=Symbol.for("react.activity"),j=Symbol.for("react.client.reference"),z=w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,E=Object.prototype.hasOwnProperty,B=Array.isArray,Z=console.createTask?console.createTask:function(){return null};w={react_stack_bottom_frame:function(u){return u()}};var q,H={},U=w.react_stack_bottom_frame.bind(w,i)(),de=Z(s(i)),re={};Ee.Fragment=c,Ee.jsx=function(u,A,V){var W=1e4>z.recentlyCreatedOwnerStacks++;return f(u,A,V,!1,W?Error("react-stack-top-frame"):U,W?Z(s(u)):de)},Ee.jsxs=function(u,A,V){var W=1e4>z.recentlyCreatedOwnerStacks++;return f(u,A,V,!0,W?Error("react-stack-top-frame"):U,W?Z(s(u)):de)}})()),Ee}var bt;function vn(){return bt||(bt=1,process.env.NODE_ENV==="production"?Ce.exports=yn():Ce.exports=_n()),Ce.exports}var y=vn();const wt=t=>{let e;const n=new Set,s=(d,f)=>{const v=typeof d=="function"?d(e):d;if(!Object.is(v,e)){const m=e;e=f??(typeof v!="object"||v===null)?v:Object.assign({},e,v),n.forEach(w=>w(e,m))}},r=()=>e,a={setState:s,getState:r,getInitialState:()=>l,subscribe:d=>(n.add(d),()=>n.delete(d))},l=e=t(s,r,a);return a},bn=(t=>t?wt(t):wt),wn=t=>t;function En(t,e=wn){const n=k.useSyncExternalStore(t.subscribe,k.useCallback(()=>e(t.getState()),[t,e]),k.useCallback(()=>e(t.getInitialState()),[t,e]));return k.useDebugValue(n),n}var Et=Symbol.for("immer-nothing"),xt=Symbol.for("immer-draftable"),J=Symbol.for("immer-state"),xn=process.env.NODE_ENV!=="production"?[function(t){return`The plugin for '${t}' has not been loaded into Immer. To enable the plugin, import and call \`enable${t}()\` when initializing your application.`},function(t){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${t}'`},"This object has been frozen and should not be mutated",function(t){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+t},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(t){return`'current' expects a draft, got: ${t}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(t){return`'original' expects a draft, got: ${t}`}]:[];function ee(t,...e){if(process.env.NODE_ENV!=="production"){const n=xn[t],s=he(n)?n.apply(null,e):n;throw new Error(`[Immer] ${s}`)}throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var te=Object,me=te.getPrototypeOf,Ae="constructor",Me="prototype",Je="configurable",Re="enumerable",je="writable",xe="value",ue=t=>!!t&&!!t[J];function ae(t){return t?Tt(t)||Le(t)||!!t[xt]||!!t[Ae]?.[xt]||$e(t)||He(t):!1}var Sn=te[Me][Ae].toString(),St=new WeakMap;function Tt(t){if(!t||!Qe(t))return!1;const e=me(t);if(e===null||e===te[Me])return!0;const n=te.hasOwnProperty.call(e,Ae)&&e[Ae];if(n===Object)return!0;if(!he(n))return!1;let s=St.get(n);return s===void 0&&(s=Function.toString.call(n),St.set(n,s)),s===Sn}function Se(t,e,n=!0){Te(t)===0?(n?Reflect.ownKeys(t):te.keys(t)).forEach(r=>{e(r,t[r],t)}):t.forEach((s,r)=>e(r,s,t))}function Te(t){const e=t[J];return e?e.type_:Le(t)?1:$e(t)?2:He(t)?3:0}var It=(t,e,n=Te(t))=>n===2?t.has(e):te[Me].hasOwnProperty.call(t,e),Ze=(t,e,n=Te(t))=>n===2?t.get(e):t[e],ze=(t,e,n,s=Te(t))=>{s===2?t.set(e,n):s===3?t.add(n):t[e]=n};function Tn(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var Le=Array.isArray,$e=t=>t instanceof Map,He=t=>t instanceof Set,Qe=t=>typeof t=="object",he=t=>typeof t=="function",et=t=>typeof t=="boolean",ce=t=>t.copy_||t.base_,tt=t=>t.modified_?t.copy_:t.base_;function nt(t,e){if($e(t))return new Map(t);if(He(t))return new Set(t);if(Le(t))return Array[Me].slice.call(t);const n=Tt(t);if(e===!0||e==="class_only"&&!n){const s=te.getOwnPropertyDescriptors(t);delete s[J];let r=Reflect.ownKeys(s);for(let i=0;i<r.length;i++){const o=r[i],a=s[o];a[je]===!1&&(a[je]=!0,a[Je]=!0),(a.get||a.set)&&(s[o]={[Je]:!0,[je]:!0,[Re]:a[Re],[xe]:t[o]})}return te.create(me(t),s)}else{const s=me(t);if(s!==null&&n)return{...t};const r=te.create(s);return te.assign(r,t)}}function st(t,e=!1){return Ye(t)||ue(t)||!ae(t)||(Te(t)>1&&te.defineProperties(t,{set:Ve,add:Ve,clear:Ve,delete:Ve}),te.freeze(t),e&&Se(t,(n,s)=>{st(s,!0)},!1)),t}function In(){ee(2)}var Ve={[xe]:In};function Ye(t){return t===null||!Qe(t)?!0:te.isFrozen(t)}var Fe="MapSet",rt="Patches",kt={};function ge(t){const e=kt[t];return e||ee(0,t),e}var kn=t=>!!kt[t],Ie,Pt=()=>Ie,Pn=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:kn(Fe)?ge(Fe):void 0});function Dt(t,e){e&&(t.patchPlugin_=ge(rt),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function it(t){ot(t),t.drafts_.forEach(Dn),t.drafts_=null}function ot(t){t===Ie&&(Ie=t.parent_)}var Ot=t=>Ie=Pn(Ie,t);function Dn(t){const e=t[J];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function Nt(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[J].modified_&&(it(e),ee(4)),ae(t)&&(t=Ct(e,t));const{patchPlugin_:r}=e;r&&r.generateReplacementPatches_(n[J].base_,t,e)}else t=Ct(e,n);return On(e,t,!0),it(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==Et?t:void 0}function Ct(t,e){if(Ye(e))return e;const n=e[J];if(!n)return at(e,t.handledSet_,t);if(!Ue(n,t))return e;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:s}=n;if(s)for(;s.length>0;)s.pop()(t);Rt(n,t)}return n.copy_}function On(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&st(e,n)}function At(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var Ue=(t,e)=>t.scope_===e,Nn=[];function Mt(t,e,n,s){const r=ce(t),i=t.type_;if(s!==void 0&&Ze(r,s,i)===e){ze(r,s,n,i);return}if(!t.draftLocations_){const a=t.draftLocations_=new Map;Se(r,(l,d)=>{if(ue(d)){const f=a.get(d)||[];f.push(l),a.set(d,f)}})}const o=t.draftLocations_.get(e)??Nn;for(const a of o)ze(r,a,n,i)}function Cn(t,e,n){t.callbacks_.push(function(r){const i=e;if(!i||!Ue(i,r))return;r.mapSetPlugin_?.fixSetContents(i);const o=tt(i);Mt(t,i.draft_??i,o,n),Rt(i,r)})}function Rt(t,e){if(t.modified_&&!t.finalized_&&(t.type_===3||(t.assigned_?.size??0)>0)){const{patchPlugin_:s}=e;if(s){const r=s.getPath(t);r&&s.generatePatches_(t,r,e)}At(t)}}function An(t,e,n){const{scope_:s}=t;if(ue(n)){const r=n[J];Ue(r,s)&&r.callbacks_.push(function(){Be(t);const o=tt(r);Mt(t,n,o,e)})}else ae(n)&&t.callbacks_.push(function(){const i=ce(t);Ze(i,e,t.type_)===n&&s.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&at(Ze(t.copy_,e,t.type_),s.handledSet_,s)})}function at(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||ue(t)||e.has(t)||!ae(t)||Ye(t)||(e.add(t),Se(t,(s,r)=>{if(ue(r)){const i=r[J];if(Ue(i,n)){const o=tt(i);ze(t,s,o,t.type_),At(i)}}else ae(r)&&at(r,e,n)})),t}function Mn(t,e){const n=Le(t),s={type_:n?1:0,scope_:e?e.scope_:Pt(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let r=s,i=ct;n&&(r=[s],i=ke);const{revoke:o,proxy:a}=Proxy.revocable(r,i);return s.draft_=a,s.revoke_=o,[a,s]}var ct={get(t,e){if(e===J)return t;const n=ce(t);if(!It(n,e,t.type_))return Rn(t,n,e);const s=n[e];if(t.finalized_||!ae(s))return s;if(s===lt(t.base_,e)){Be(t);const r=t.type_===1?+e:e,i=dt(t.scope_,s,t,r);return t.copy_[r]=i}return s},has(t,e){return e in ce(t)},ownKeys(t){return Reflect.ownKeys(ce(t))},set(t,e,n){const s=jt(ce(t),e);if(s?.set)return s.set.call(t.draft_,n),!0;if(!t.modified_){const r=lt(ce(t),e),i=r?.[J];if(i&&i.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(Tn(n,r)&&(n!==void 0||It(t.base_,e,t.type_)))return!0;Be(t),ut(t)}return t.copy_[e]===n&&(n!==void 0||e in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=n,t.assigned_.set(e,!0),An(t,e,n)),!0},deleteProperty(t,e){return Be(t),lt(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),ut(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=ce(t),s=Reflect.getOwnPropertyDescriptor(n,e);return s&&{[je]:!0,[Je]:t.type_!==1||e!=="length",[Re]:s[Re],[xe]:n[e]}},defineProperty(){ee(11)},getPrototypeOf(t){return me(t.base_)},setPrototypeOf(){ee(12)}},ke={};Se(ct,(t,e)=>{ke[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}}),ke.deleteProperty=function(t,e){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(e))&&ee(13),ke.set.call(this,t,e,void 0)},ke.set=function(t,e,n){return process.env.NODE_ENV!=="production"&&e!=="length"&&isNaN(parseInt(e))&&ee(14),ct.set.call(this,t[0],e,n,t[0])};function lt(t,e){const n=t[J];return(n?ce(n):t)[e]}function Rn(t,e,n){const s=jt(e,n);return s?xe in s?s[xe]:s.get?.call(t.draft_):void 0}function jt(t,e){if(!(e in t))return;let n=me(t);for(;n;){const s=Object.getOwnPropertyDescriptor(n,e);if(s)return s;n=me(n)}}function ut(t){t.modified_||(t.modified_=!0,t.parent_&&ut(t.parent_))}function Be(t){t.copy_||(t.assigned_=new Map,t.copy_=nt(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var jn=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,n,s)=>{if(he(e)&&!he(n)){const i=n;n=e;const o=this;return function(l=i,...d){return o.produce(l,f=>n.call(this,f,...d))}}he(n)||ee(6),s!==void 0&&!he(s)&&ee(7);let r;if(ae(e)){const i=Ot(this),o=dt(i,e,void 0);let a=!0;try{r=n(o),a=!1}finally{a?it(i):ot(i)}return Dt(i,s),Nt(r,i)}else if(!e||!Qe(e)){if(r=n(e),r===void 0&&(r=e),r===Et&&(r=void 0),this.autoFreeze_&&st(r,!0),s){const i=[],o=[];ge(rt).generateReplacementPatches_(e,r,{patches_:i,inversePatches_:o}),s(i,o)}return r}else ee(1,e)},this.produceWithPatches=(e,n)=>{if(he(e))return(o,...a)=>this.produceWithPatches(o,l=>e(l,...a));let s,r;return[this.produce(e,n,(o,a)=>{s=o,r=a}),s,r]},et(t?.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),et(t?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),et(t?.useStrictIteration)&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){ae(t)||ee(8),ue(t)&&(t=zn(t));const e=Ot(this),n=dt(e,t,void 0);return n[J].isManual_=!0,ot(e),n}finishDraft(t,e){const n=t&&t[J];(!n||!n.isManual_)&&ee(9);const{scope_:s}=n;return Dt(s,e),Nt(void 0,s)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,e){let n;for(n=e.length-1;n>=0;n--){const r=e[n];if(r.path.length===0&&r.op==="replace"){t=r.value;break}}n>-1&&(e=e.slice(n+1));const s=ge(rt).applyPatches_;return ue(t)?s(t,e):this.produce(t,r=>s(r,e))}};function dt(t,e,n,s){const[r,i]=$e(e)?ge(Fe).proxyMap_(e,n):He(e)?ge(Fe).proxySet_(e,n):Mn(e,n);return(n?.scope_??Pt()).drafts_.push(r),i.callbacks_=n?.callbacks_??[],i.key_=s,n&&s!==void 0?Cn(n,i,s):i.callbacks_.push(function(l){l.mapSetPlugin_?.fixSetContents(i);const{patchPlugin_:d}=l;i.modified_&&d&&d.generatePatches_(i,[],l)}),r}function zn(t){return ue(t)||ee(10,t),zt(t)}function zt(t){if(!ae(t)||Ye(t))return t;const e=t[J];let n,s=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=nt(t,e.scope_.immer_.useStrictShallowCopy_),s=e.scope_.immer_.shouldUseStrictIteration()}else n=nt(t,!0);return Se(n,(r,i)=>{ze(n,r,zt(i))},s),e&&(e.finalized_=!1),n}var Ln=new jn,$n=Ln.produce;const Hn=t=>(e,n,s)=>(s.setState=(r,i,...o)=>{const a=typeof r=="function"?$n(r):r;return e(a,i,...o)},t(s.setState,n,s)),Vn={snapping:!0,snapGuide:!0,rotation:!0,rotationSpeed:2,rotationSnap:5,zoom:!0,pan:!0,viewOnly:!1,minZoom:.1,maxZoom:5,showGrid:!0,gridSize:20,gridColor:"#ddd"},Yn=(t=[],e=[],n={})=>bn(Hn(s=>({nodes:t.reduce((r,i)=>({...r,[i.id]:i}),{}),edges:e.reduce((r,i)=>({...r,[i.id]:i}),{}),selectedIds:[],camera:{x:0,y:0,zoom:1},dimensions:{width:0,height:0},config:{...Vn,...n},connectionState:{nodeId:null,handleId:null,handleType:null,position:null,isValid:!1},startConnection:(r,i,o,a)=>s(l=>{l.connectionState={nodeId:r,handleId:i,handleType:o,position:a,isValid:!0}}),updateConnection:r=>s(i=>{i.connectionState.nodeId&&(i.connectionState.position=r)}),endConnection:()=>s(r=>{r.connectionState={nodeId:null,handleId:null,handleType:null,position:null,isValid:!1}}),setCamera:r=>s(i=>{Object.assign(i.camera,r)}),panCamera:(r,i)=>s(o=>{o.camera.x+=r,o.camera.y+=i}),zoomCamera:(r,i,o)=>s(a=>{const{minZoom:l=.1,maxZoom:d=5}=a.config,f=Math.min(Math.max(a.camera.zoom*r,l),d),v=(i-a.camera.x)/a.camera.zoom,m=(o-a.camera.y)/a.camera.zoom;a.camera.x=i-v*f,a.camera.y=o-m*f,a.camera.zoom=f}),setDimensions:(r,i)=>s(o=>{o.dimensions={width:r,height:i}}),setNodes:r=>s(i=>{i.nodes=r.reduce((o,a)=>({...o,[a.id]:a}),{})}),addNode:r=>s(i=>{i.nodes[r.id]=r}),updateNode:(r,i)=>s(o=>{o.nodes[r]&&Object.assign(o.nodes[r],i)}),registerHandle:(r,i,o)=>s(a=>{const l=a.nodes[r];l&&(l.handles||(l.handles={}),l.handles[i]={id:i,...o})}),removeNode:r=>s(i=>{delete i.nodes[r],Object.keys(i.edges).forEach(o=>{const a=i.edges[o];(a.source===r||a.target===r)&&delete i.edges[o]}),i.selectedIds=i.selectedIds.filter(o=>o!==r)}),setEdges:r=>s(i=>{i.edges=r.reduce((o,a)=>({...o,[a.id]:a}),{})}),addEdge:r=>s(i=>{Object.values(i.edges).some(a=>a.source===r.source&&a.target===r.target&&a.sourceHandle===r.sourceHandle&&a.targetHandle===r.targetHandle)||(i.edges[r.id]=r)}),removeEdge:r=>s(i=>{delete i.edges[r]}),selectNode:r=>s(i=>{i.selectedIds=r?[r]:[]}),resizeNode:(r,i,o,a,l)=>s(d=>{d.nodes[r]&&(d.nodes[r].x=i,d.nodes[r].y=o,d.nodes[r].width=a,d.nodes[r].height=l)}),rotateNode:(r,i)=>s(o=>{o.nodes[r]&&(o.nodes[r].rotation=i)}),deleteSelected:()=>s(r=>{r.selectedIds.forEach(i=>{r.nodes[i]?(delete r.nodes[i],Object.keys(r.edges).forEach(o=>{const a=r.edges[o];(a.source===i||a.target===i)&&delete r.edges[o]})):r.edges[i]&&delete r.edges[i]}),r.selectedIds=[]}),selectAll:()=>s(r=>{r.selectedIds=Object.keys(r.nodes)}),deselectAll:()=>s(r=>{r.selectedIds=[]}),duplicateSelected:()=>s(r=>{const i=[];r.selectedIds.forEach(o=>{const a=r.nodes[o];if(a){const l=`node-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,d={...a,id:l,x:a.x+20,y:a.y+20};r.nodes[l]=d,i.push(d)}}),r.selectedIds=i.map(o=>o.id)}),nudgeSelected:(r,i)=>s(o=>{o.selectedIds.forEach(a=>{const l=o.nodes[a];l&&(l.x+=r,l.y+=i)})}),setConfig:r=>s(i=>{i.config={...i.config,...r}})}))),ft=k.createContext(null),Fn=({children:t,initialNodes:e=[],initialEdges:n=[],nodes:s,config:r={},className:i="",style:o,onChange:a})=>{const l=k.useRef(null);return l.current||(l.current=Yn(e,n,r)),k.useEffect(()=>{s&&l.current&&l.current.getState().setNodes(s)},[s]),k.useEffect(()=>{if(!a||!l.current)return;const d=l.current.subscribe(f=>{a(f)});return()=>d()},[a]),k.useEffect(()=>{l.current&&l.current.getState().setConfig(r)},[r]),y.jsx(ft.Provider,{value:l.current,children:y.jsx("div",{className:`ce-editor ${i}`,style:o,children:t})})},M=t=>{const e=k.useContext(ft);if(!e)throw new Error("useEditor must be used within Editor");return En(e,t)},We=()=>{const t=k.useContext(ft);if(!t)throw new Error("useEditor must be used within Editor");return t},Lt=k.createContext(null),Un=({id:t,children:e})=>y.jsx(Lt.Provider,{value:t,children:e}),Bn=()=>{const t=k.useContext(Lt);return t||null},Pe=({type:t,id:e="default",position:n="top",className:s="",style:r,...i})=>{const o=Bn(),a=M(w=>w.startConnection),l=M(w=>w.camera),d=M(w=>w.registerHandle),f=We(),v=k.useRef(null);k.useEffect(()=>{if(!o||!v.current)return;const w=()=>{const c=document.getElementById(o);if(!c||!v.current)return;const g=c.getBoundingClientRect(),p=v.current.getBoundingClientRect(),b=f.getState().camera.zoom,_=(p.left+p.width/2-g.left)/b,D=(p.top+p.height/2-g.top)/b;d(o,e,{type:t,position:n,x:_,y:D,width:p.width/b,height:p.height/b})};w();const N=document.getElementById(o);if(!N)return;const C=new ResizeObserver(()=>{requestAnimationFrame(w)});return C.observe(N),()=>C.disconnect()},[o,e,t,n,d]);const m=w=>{if(!o)return;w.stopPropagation();const N=document.querySelector(".ce-editor__viewport")?.getBoundingClientRect();if(!N)return;const C=(w.clientX-N.left-l.x)/l.zoom,c=(w.clientY-N.top-l.y)/l.zoom;a(o,e,t,{x:C,y:c})};return y.jsx("div",{ref:v,"data-handle-type":t,"data-handle-id":e,onPointerDown:m,className:`ce-handle ce-handle--${n} ${s}`,style:r,...i})},Xe=({data:t,...e})=>y.jsxs("div",{className:"ce-node-default",...e,style:e.style,children:[y.jsx(Pe,{type:"target",position:"left",id:"input"}),y.jsx("div",{className:"ce-node-content",children:t.label||"Default Node"}),y.jsx(Pe,{type:"source",position:"right",id:"output"})]}),$t=({data:t,...e})=>y.jsxs("div",{className:"ce-node-input",...e,style:e.style,children:[y.jsx("div",{className:"ce-node-content",children:t.label||"Input Node"}),y.jsx(Pe,{type:"source",position:"right",id:"output"})]}),Ht=({data:t,...e})=>y.jsxs("div",{className:"ce-node-output",...e,style:e.style,children:[y.jsx(Pe,{type:"target",position:"left",id:"input"}),y.jsx("div",{className:"ce-node-content",children:t.label||"Output Node"})]});function Wn(t,e,n){return Math.max(e,Math.min(t,n))}const $={toVector(t,e){return t===void 0&&(t=e),Array.isArray(t)?t:[t,t]},add(t,e){return[t[0]+e[0],t[1]+e[1]]},sub(t,e){return[t[0]-e[0],t[1]-e[1]]},addTo(t,e){t[0]+=e[0],t[1]+=e[1]},subTo(t,e){t[0]-=e[0],t[1]-=e[1]}};function Vt(t,e,n){return e===0||Math.abs(e)===1/0?Math.pow(t,n*5):t*e*n/(e+n*t)}function Yt(t,e,n,s=.15){return s===0?Wn(t,e,n):t<e?-Vt(e-t,n-e,s)+e:t>n?+Vt(t-n,n-e,s)+n:t}function Xn(t,[e,n],[s,r]){const[[i,o],[a,l]]=t;return[Yt(e,i,o,s),Yt(n,a,l,r)]}function Kn(t,e){if(typeof t!="object"||t===null)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var s=n.call(t,e);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Gn(t){var e=Kn(t,"string");return typeof e=="symbol"?e:String(e)}function X(t,e,n){return e=Gn(e),e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ft(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,s)}return n}function Y(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Ft(Object(n),!0).forEach(function(s){X(t,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ft(Object(n)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(n,s))})}return t}const Ut={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 Bt(t){return t?t[0].toUpperCase()+t.slice(1):""}const qn=["enter","leave"];function Jn(t=!1,e){return t&&!qn.includes(e)}function Zn(t,e="",n=!1){const s=Ut[t],r=s&&s[e]||e;return"on"+Bt(t)+Bt(r)+(Jn(n,r)?"Capture":"")}const Qn=["gotpointercapture","lostpointercapture"];function es(t){let e=t.substring(2).toLowerCase();const n=!!~e.indexOf("passive");n&&(e=e.replace("passive",""));const s=Qn.includes(e)?"capturecapture":"capture",r=!!~e.indexOf(s);return r&&(e=e.replace("capture","")),{device:e,capture:r,passive:n}}function ts(t,e=""){const n=Ut[t],s=n&&n[e]||e;return t+s}function Ke(t){return"touches"in t}function Wt(t){return Ke(t)?"touch":"pointerType"in t?t.pointerType:"mouse"}function ns(t){return Array.from(t.touches).filter(e=>{var n,s;return e.target===t.currentTarget||((n=t.currentTarget)===null||n===void 0||(s=n.contains)===null||s===void 0?void 0:s.call(n,e.target))})}function ss(t){return t.type==="touchend"||t.type==="touchcancel"?t.changedTouches:t.targetTouches}function Xt(t){return Ke(t)?ss(t)[0]:t}function ht(t,e){try{const n=e.clientX-t.clientX,s=e.clientY-t.clientY,r=(e.clientX+t.clientX)/2,i=(e.clientY+t.clientY)/2,o=Math.hypot(n,s);return{angle:-(Math.atan2(n,s)*180)/Math.PI,distance:o,origin:[r,i]}}catch{}return null}function rs(t){return ns(t).map(e=>e.identifier)}function Kt(t,e){const[n,s]=Array.from(t.touches).filter(r=>e.includes(r.identifier));return ht(n,s)}function pt(t){const e=Xt(t);return Ke(t)?e.identifier:e.pointerId}function ye(t){const e=Xt(t);return[e.clientX,e.clientY]}const Gt=40,qt=800;function Jt(t){let{deltaX:e,deltaY:n,deltaMode:s}=t;return s===1?(e*=Gt,n*=Gt):s===2&&(e*=qt,n*=qt),[e,n]}function is(t){var e,n;const{scrollX:s,scrollY:r,scrollLeft:i,scrollTop:o}=t.currentTarget;return[(e=s??i)!==null&&e!==void 0?e:0,(n=r??o)!==null&&n!==void 0?n:0]}function os(t){const e={};if("buttons"in t&&(e.buttons=t.buttons),"shiftKey"in t){const{shiftKey:n,altKey:s,metaKey:r,ctrlKey:i}=t;Object.assign(e,{shiftKey:n,altKey:s,metaKey:r,ctrlKey:i})}return e}function Ge(t,...e){return typeof t=="function"?t(...e):t}function as(){}function cs(...t){return t.length===0?as:t.length===1?t[0]:function(){let e;for(const n of t)e=n.apply(this,arguments)||e;return e}}function Zt(t,e){return Object.assign({},e,t||{})}const ls=32;class Qt{constructor(e,n,s){this.ctrl=e,this.args=n,this.key=s,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:n,ingKey:s,args:r}=this;n[s]=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=r,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 n=this.state,s=this.config;n._active||(this.reset(),this.computeInitial(),n._active=!0,n.target=e.target,n.currentTarget=e.currentTarget,n.lastOffset=s.from?Ge(s.from,n):n.offset,n.offset=n.lastOffset,n.startTime=n.timeStamp=e.timeStamp)}computeValues(e){const n=this.state;n._values=e,n.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:n,config:s,shared:r}=this;n.args=this.args;let i=0;if(e&&(n.event=e,s.preventDefault&&e.cancelable&&n.event.preventDefault(),n.type=e.type,r.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,r.locked=!!document.pointerLockElement,Object.assign(r,os(e)),r.down=r.pressed=r.buttons%2===1||r.touches>0,i=e.timeStamp-n.timeStamp,n.timeStamp=e.timeStamp,n.elapsedTime=n.timeStamp-n.startTime),n._active){const h=n._delta.map(Math.abs);$.addTo(n._distance,h)}this.axisIntent&&this.axisIntent(e);const[o,a]=n._movement,[l,d]=s.threshold,{_step:f,values:v}=n;if(s.hasCustomTransform?(f[0]===!1&&(f[0]=Math.abs(o)>=l&&v[0]),f[1]===!1&&(f[1]=Math.abs(a)>=d&&v[1])):(f[0]===!1&&(f[0]=Math.abs(o)>=l&&Math.sign(o)*l),f[1]===!1&&(f[1]=Math.abs(a)>=d&&Math.sign(a)*d)),n.intentional=f[0]!==!1||f[1]!==!1,!n.intentional)return;const m=[0,0];if(s.hasCustomTransform){const[h,O]=v;m[0]=f[0]!==!1?h-f[0]:0,m[1]=f[1]!==!1?O-f[1]:0}else m[0]=f[0]!==!1?o-f[0]:0,m[1]=f[1]!==!1?a-f[1]:0;this.restrictToAxis&&!n._blocked&&this.restrictToAxis(m);const w=n.offset,N=n._active&&!n._blocked||n.active;N&&(n.first=n._active&&!n.active,n.last=!n._active&&n.active,n.active=r[this.ingKey]=n._active,e&&(n.first&&("bounds"in s&&(n._bounds=Ge(s.bounds,n)),this.setup&&this.setup()),n.movement=m,this.computeOffset()));const[C,c]=n.offset,[[g,p],[b,_]]=n._bounds;n.overflow=[C<g?-1:C>p?1:0,c<b?-1:c>_?1:0],n._movementBound[0]=n.overflow[0]?n._movementBound[0]===!1?n._movement[0]:n._movementBound[0]:!1,n._movementBound[1]=n.overflow[1]?n._movementBound[1]===!1?n._movement[1]:n._movementBound[1]:!1;const D=n._active?s.rubberband||[0,0]:[0,0];if(n.offset=Xn(n._bounds,n.offset,D),n.delta=$.sub(n.offset,w),this.computeMovement(),N&&(!n.last||i>ls)){n.delta=$.sub(n.offset,w);const h=n.delta.map(Math.abs);$.addTo(n.distance,h),n.direction=n.delta.map(Math.sign),n._direction=n._delta.map(Math.sign),!n.first&&i>0&&(n.velocity=[h[0]/i,h[1]/i],n.timeDelta=i)}}emit(){const e=this.state,n=this.shared,s=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!s.triggerAllEvents)return;const r=this.handler(Y(Y(Y({},n),e),{},{[this.aliasKey]:e.values}));r!==void 0&&(e.memo=r)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function us([t,e],n){const s=Math.abs(t),r=Math.abs(e);if(s>r&&s>n)return"x";if(r>s&&r>n)return"y"}class De extends Qt{constructor(...e){super(...e),X(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=$.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=$.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const n=this.state,s=this.config;if(!n.axis&&e){const r=typeof s.axisThreshold=="object"?s.axisThreshold[Wt(e)]:s.axisThreshold;n.axis=us(n._movement,r)}n._blocked=(s.lockDirection||!!s.axis)&&!n.axis||!!s.axis&&s.axis!==n.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 en=t=>t,tn=.15,mt={enabled(t=!0){return t},eventOptions(t,e,n){return Y(Y({},n.shared.eventOptions),t)},preventDefault(t=!1){return t},triggerAllEvents(t=!1){return t},rubberband(t=0){switch(t){case!0:return[tn,tn];case!1:return[0,0];default:return $.toVector(t)}},from(t){if(typeof t=="function")return t;if(t!=null)return $.toVector(t)},transform(t,e,n){const s=t||n.shared.transform;if(this.hasCustomTransform=!!s,process.env.NODE_ENV==="development"){const r=s||en;return i=>{const o=r(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 s||en},threshold(t){return $.toVector(t,0)}};process.env.NODE_ENV==="development"&&Object.assign(mt,{domTarget(t){if(t!==void 0)throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");return NaN},lockDirection(t){if(t!==void 0)throw Error("[@use-gesture]: `lockDirection` option has been merged with `axis`. Use it as in `{ axis: 'lock' }`");return NaN},initial(t){if(t!==void 0)throw Error("[@use-gesture]: `initial` option has been renamed to `from`.");return NaN}});const ds=0,pe=Y(Y({},mt),{},{axis(t,e,{axis:n}){if(this.lockDirection=n==="lock",!this.lockDirection)return n},axisThreshold(t=ds){return t},bounds(t={}){if(typeof t=="function")return i=>pe.bounds(t(i));if("current"in t)return()=>t.current;if(typeof HTMLElement=="function"&&t instanceof HTMLElement)return t;const{left:e=-1/0,right:n=1/0,top:s=-1/0,bottom:r=1/0}=t;return[[e,n],[s,r]]}}),nn={ArrowRight:(t,e=1)=>[t*e,0],ArrowLeft:(t,e=1)=>[-1*t*e,0],ArrowUp:(t,e=1)=>[0,-1*t*e],ArrowDown:(t,e=1)=>[0,t*e]};class fs extends De{constructor(...e){super(...e),X(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 n=e._bounds.getBoundingClientRect(),s=e.currentTarget.getBoundingClientRect(),r={left:n.left-s.left+e.offset[0],right:n.right-s.right+e.offset[0],top:n.top-s.top+e.offset[1],bottom:n.bottom-s.bottom+e.offset[1]};e._bounds=pe.bounds(r)}}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 n=this.config,s=this.state;if(e.buttons!=null&&(Array.isArray(n.pointerButtons)?!n.pointerButtons.includes(e.buttons):n.pointerButtons!==-1&&n.pointerButtons!==e.buttons))return;const r=this.ctrl.setEventIds(e);n.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(r&&r.size>1&&s._pointerActive)&&(this.start(e),this.setupPointer(e),s._pointerId=pt(e),s._pointerActive=!0,this.computeValues(ye(e)),this.computeInitial(),n.preventScrollAxis&&Wt(e)!=="mouse"?(s._active=!1,this.setupScrollPrevention(e)):n.delay>0?(this.setupDelayTrigger(e),n.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const n=this.state;n._active=!0,n._preventScroll=!0,n._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const n=this.state,s=this.config;if(!n._pointerActive)return;const r=pt(e);if(n._pointerId!==void 0&&r!==n._pointerId)return;const i=ye(e);if(document.pointerLockElement===e.target?n._delta=[e.movementX,e.movementY]:(n._delta=$.sub(i,n._values),this.computeValues(i)),$.addTo(n._movement,n._delta),this.compute(e),n._delayed&&n.intentional){this.timeoutStore.remove("dragDelay"),n.active=!1,this.startPointerDrag(e);return}if(s.preventScrollAxis&&!n._preventScroll)if(n.axis)if(n.axis===s.preventScrollAxis||s.preventScrollAxis==="xy"){n._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 n=this.state,s=this.config;if(!n._active||!n._pointerActive)return;const r=pt(e);if(n._pointerId!==void 0&&r!==n._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[i,o]=n._distance;if(n.tap=i<=s.tapsThreshold&&o<=s.tapsThreshold,n.tap&&s.filterTaps)n._force=!0;else{const[a,l]=n._delta,[d,f]=n._movement,[v,m]=s.swipe.velocity,[w,N]=s.swipe.distance,C=s.swipe.duration;if(n.elapsedTime<C){const c=Math.abs(a/n.timeDelta),g=Math.abs(l/n.timeDelta);c>v&&Math.abs(d)>w&&(n.swipe[0]=Math.sign(a)),g>m&&Math.abs(f)>N&&(n.swipe[1]=Math.sign(l))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const n=this.config,s=n.device;if(process.env.NODE_ENV==="development")try{if(s==="pointer"&&n.preventScrollDelay===void 0){const r="uv"in e?e.sourceEvent.currentTarget:e.currentTarget;window.getComputedStyle(r).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.",r)}}catch{}n.pointerLock&&e.currentTarget.requestPointerLock(),n.pointerCapture||(this.eventStore.add(this.sharedConfig.window,s,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,s,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,s,"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,hs(e);const n=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",n),this.eventStore.add(this.sharedConfig.window,"touch","cancel",n),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 n=nn[e.key];if(n){const s=this.state,r=e.shiftKey?10:e.altKey?.1:1;this.start(e),s._delta=n(this.config.keyboardDisplacement,r),s._keyboardActive=!0,$.addTo(s._movement,s._delta),this.compute(e),this.emit()}}keyUp(e){e.key in nn&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const n=this.config.device;e(n,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(n,"change",this.pointerMove.bind(this)),e(n,"end",this.pointerUp.bind(this)),e(n,"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 hs(t){"persist"in t&&typeof t.persist=="function"&&t.persist()}const Oe=typeof window<"u"&&window.document&&window.document.createElement;function sn(){return Oe&&"ontouchstart"in window}function ps(){return sn()||Oe&&window.navigator.maxTouchPoints>1}function ms(){return Oe&&"onpointerdown"in window}function gs(){return Oe&&"exitPointerLock"in window.document}function ys(){try{return"constructor"in GestureEvent}catch{return!1}}const se={isBrowser:Oe,gesture:ys(),touch:sn(),touchscreen:ps(),pointer:ms(),pointerLock:gs()},_s=250,vs=180,bs=.5,ws=50,Es=250,xs=10,rn={mouse:0,touch:0,pen:8},on=Y(Y({},pe),{},{device(t,e,{pointer:{touch:n=!1,lock:s=!1,mouse:r=!1}={}}){return this.pointerLock=s&&se.pointerLock,se.touch&&n?"touch":this.pointerLock?"mouse":se.pointer&&!r?"pointer":se.touch?"touch":"mouse"},preventScrollAxis(t,e,{preventScroll:n}){if(this.preventScrollDelay=typeof n=="number"?n:n||n===void 0&&t?_s:void 0,!(!se.touchscreen||n===!1))return t||(n!==void 0?"y":void 0)},pointerCapture(t,e,{pointer:{capture:n=!0,buttons:s=1,keys:r=!0}={}}){return this.pointerButtons=s,this.keys=r,!this.pointerLock&&this.device==="pointer"&&n},threshold(t,e,{filterTaps:n=!1,tapsThreshold:s=3,axis:r=void 0}){const i=$.toVector(t,n?s:r?1:0);return this.filterTaps=n,this.tapsThreshold=s,i},swipe({velocity:t=bs,distance:e=ws,duration:n=Es}={}){return{velocity:this.transform($.toVector(t)),distance:this.transform($.toVector(e)),duration:n}},delay(t=0){switch(t){case!0:return vs;case!1:return 0;default:return t}},axisThreshold(t){return t?Y(Y({},rn),t):rn},keyboardDisplacement(t=xs){return t}});process.env.NODE_ENV==="development"&&Object.assign(on,{useTouch(t){if(t!==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(t){if(t!==void 0)throw Error("[@use-gesture]: `experimental_preventWindowScrollY` option has been renamed to `preventScroll`.");return NaN},swipeVelocity(t){if(t!==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(t){if(t!==void 0)throw Error("[@use-gesture]: `swipeDistance` option has been renamed to `swipe.distance`. Use it as in `{ swipe: { distance: 50 } }`.");return NaN},swipeDuration(t){if(t!==void 0)throw Error("[@use-gesture]: `swipeDuration` option has been renamed to `swipe.duration`. Use it as in `{ swipe: { duration: 250 } }`.");return NaN}});function an(t){const[e,n]=t.overflow,[s,r]=t._delta,[i,o]=t._direction;(e<0&&s>0&&i<0||e>0&&s<0&&i>0)&&(t._movement[0]=t._movementBound[0]),(n<0&&r>0&&o<0||n>0&&r<0&&o>0)&&(t._movement[1]=t._movementBound[1])}const Ss=30,Ts=100;class Is extends Qt{constructor(...e){super(...e),X(this,"ingKey","pinching"),X(this,"aliasKey","da")}init(){this.state.offset=[1,0],this.state.lastOffset=[1,0],this.state._pointerEvents=new Map}reset(){super.reset();const e=this.state;e._touchIds=[],e.canceled=!1,e.cancel=this.cancel.bind(this),e.turns=0}computeOffset(){const{type:e,movement:n,lastOffset:s}=this.state;e==="wheel"?this.state.offset=$.add(n,s):this.state.offset=[(1+n[0])*s[0],n[1]+s[1]]}computeMovement(){const{offset:e,lastOffset:n}=this.state;this.state.movement=[e[0]/n[0],e[1]-n[1]]}axisIntent(){const e=this.state,[n,s]=e._movement;if(!e.axis){const r=Math.abs(n)*Ss-Math.abs(s);r<0?e.axis="angle":r>0&&(e.axis="scale")}}restrictToAxis(e){this.config.lockDirection&&(this.state.axis==="scale"?e[1]=0:this.state.axis==="angle"&&(e[0]=0))}cancel(){const e=this.state;e.canceled||setTimeout(()=>{e.canceled=!0,e._active=!1,this.compute(),this.emit()},0)}touchStart(e){this.ctrl.setEventIds(e);const n=this.state,s=this.ctrl.touchIds;if(n._active&&n._touchIds.every(i=>s.has(i))||s.size<2)return;this.start(e),n._touchIds=Array.from(s).slice(0,2);const r=Kt(e,n._touchIds);r&&this.pinchStart(e,r)}pointerStart(e){if(e.buttons!=null&&e.buttons%2!==1)return;this.ctrl.setEventIds(e),e.target.setPointerCapture(e.pointerId);const n=this.state,s=n._pointerEvents,r=this.ctrl.pointerIds;if(n._active&&Array.from(s.keys()).every(o=>r.has(o))||(s.size<2&&s.set(e.pointerId,e),n._pointerEvents.size<2))return;this.start(e);const i=ht(...Array.from(s.values()));i&&this.pinchStart(e,i)}pinchStart(e,n){const s=this.state;s.origin=n.origin,this.computeValues([n.distance,n.angle]),this.computeInitial(),this.compute(e),this.emit()}touchMove(e){if(!this.state._active)return;const n=Kt(e,this.state._touchIds);n&&this.pinchMove(e,n)}pointerMove(e){const n=this.state._pointerEvents;if(n.has(e.pointerId)&&n.set(e.pointerId,e),!this.state._active)return;const s=ht(...Array.from(n.values()));s&&this.pinchMove(e,s)}pinchMove(e,n){const s=this.state,r=s._values[1],i=n.angle-r;let o=0;Math.abs(i)>270&&(o+=Math.sign(i)),this.computeValues([n.distance,n.angle-360*o]),s.origin=n.origin,s.turns=o,s._movement=[s._values[0]/s._initial[0]-1,s._values[1]-s._initial[1]],this.compute(e),this.emit()}touchEnd(e){this.ctrl.setEventIds(e),this.state._active&&this.state._touchIds.some(n=>!this.ctrl.touchIds.has(n))&&(this.state._active=!1,this.compute(e),this.emit())}pointerEnd(e){const n=this.state;this.ctrl.setEventIds(e);try{e.target.releasePointerCapture(e.pointerId)}catch{}n._pointerEvents.has(e.pointerId)&&n._pointerEvents.delete(e.pointerId),n._active&&n._pointerEvents.size<2&&(n._active=!1,this.compute(e),this.emit())}gestureStart(e){e.cancelable&&e.preventDefault();const n=this.state;n._active||(this.start(e),this.computeValues([e.scale,e.rotation]),n.origin=[e.clientX,e.clientY],this.compute(e),this.emit())}gestureMove(e){if(e.cancelable&&e.preventDefault(),!this.state._active)return;const n=this.state;this.computeValues([e.scale,e.rotation]),n.origin=[e.clientX,e.clientY];const s=n._movement;n._movement=[e.scale-1,e.rotation],n._delta=$.sub(n._movement,s),this.compute(e),this.emit()}gestureEnd(e){this.state._active&&(this.state._active=!1,this.compute(e),this.emit())}wheel(e){const n=this.config.modifierKey;n&&(Array.isArray(n)?!n.find(s=>e[s]):!e[n])||(this.state._active?this.wheelChange(e):this.wheelStart(e),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this)))}wheelStart(e){this.start(e),this.wheelChange(e)}wheelChange(e){"uv"in e||(e.cancelable&&e.preventDefault(),process.env.NODE_ENV==="development"&&!e.defaultPrevented&&console.warn("[@use-gesture]: To properly support zoom on trackpads, try using the `target` option.\n\nThis message will only appear in development mode."));const s=this.state;s._delta=[-Jt(e)[1]/Ts*s.offset[0],0],$.addTo(s._movement,s._delta),an(s),this.state.origin=[e.clientX,e.clientY],this.compute(e),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){const n=this.config.device;n&&(e(n,"start",this[n+"Start"].bind(this)),e(n,"change",this[n+"Move"].bind(this)),e(n,"end",this[n+"End"].bind(this)),e(n,"cancel",this[n+"End"].bind(this)),e("lostPointerCapture","",this[n+"End"].bind(this))),this.config.pinchOnWheel&&e("wheel","",this.wheel.bind(this),{passive:!1})}}const ks=Y(Y({},mt),{},{device(t,e,{shared:n,pointer:{touch:s=!1}={}}){if(n.target&&!se.touch&&se.gesture)return"gesture";if(se.touch&&s)return"touch";if(se.touchscreen){if(se.pointer)return"pointer";if(se.touch)return"touch"}},bounds(t,e,{scaleBounds:n={},angleBounds:s={}}){const r=o=>{const a=Zt(Ge(n,o),{min:-1/0,max:1/0});return[a.min,a.max]},i=o=>{const a=Zt(Ge(s,o),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof n!="function"&&typeof s!="function"?[r(),i()]:o=>[r(o),i(o)]},threshold(t,e,n){return this.lockDirection=n.axis==="lock",$.toVector(t,this.lockDirection?[.1,3]:0)},modifierKey(t){return t===void 0?"ctrlKey":t},pinchOnWheel(t=!0){return t}});class Ps extends De{constructor(...e){super(...e),X(this,"ingKey","moving")}move(e){this.config.mouseOnly&&e.pointerType!=="mouse"||(this.state._active?this.moveChange(e):this.moveStart(e),this.timeoutStore.add("moveEnd",this.moveEnd.bind(this)))}moveStart(e){this.start(e),this.computeValues(ye(e)),this.compute(e),this.computeInitial(),this.emit()}moveChange(e){if(!this.state._active)return;const n=ye(e),s=this.state;s._delta=$.sub(n,s._values),$.addTo(s._movement,s._delta),this.computeValues(n),this.compute(e),this.emit()}moveEnd(e){this.state._active&&(this.state._active=!1,this.compute(e),this.emit())}bind(e){e("pointer","change",this.move.bind(this)),e("pointer","leave",this.moveEnd.bind(this))}}const Ds=Y(Y({},pe),{},{mouseOnly:(t=!0)=>t});class Os extends De{constructor(...e){super(...e),X(this,"ingKey","scrolling")}scroll(e){this.state._active||this.start(e),this.scrollChange(e),this.timeoutStore.add("scrollEnd",this.scrollEnd.bind(this))}scrollChange(e){e.cancelable&&e.preventDefault();const n=this.state,s=is(e);n._delta=$.sub(s,n._values),$.addTo(n._movement,n._delta),this.computeValues(s),this.compute(e),this.emit()}scrollEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){e("scroll","",this.scroll.bind(this))}}const Ns=pe;class Cs extends De{constructor(...e){super(...e),X(this,"ingKey","wheeling")}wheel(e){this.state._active||this.start(e),this.wheelChange(e),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this))}wheelChange(e){const n=this.state;n._delta=Jt(e),$.addTo(n._movement,n._delta),an(n),this.compute(e),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){e("wheel","",this.wheel.bind(this))}}const As=pe;class Ms extends De{constructor(...e){super(...e),X(this,"ingKey","hovering")}enter(e){this.config.mouseOnly&&e.pointerType!=="mouse"||(this.start(e),this.computeValues(ye(e)),this.compute(e),this.emit())}leave(e){if(this.config.mouseOnly&&e.pointerType!=="mouse")return;const n=this.state;if(!n._active)return;n._active=!1;const s=ye(e);n._movement=n._delta=$.sub(s,n._values),this.computeValues(s),this.compute(e),n.delta=n.movement,this.emit()}bind(e){e("pointer","enter",this.enter.bind(this)),e("pointer","leave",this.leave.bind(this))}}const Rs=Y(Y({},pe),{},{mouseOnly:(t=!0)=>t}),gt=new Map,yt=new Map;function js(t){gt.set(t.key,t.engine),yt.set(t.key,t.resolver)}const zs={key:"drag",engine:fs,resolver:on},Ls={key:"hover",engine:Ms,resolver:Rs},$s={key:"move",engine:Ps,resolver:Ds},Hs={key:"pinch",engine:Is,resolver:ks},Vs={key:"scroll",engine:Os,resolver:Ns},Ys={key:"wheel",engine:Cs,resolver:As};function Fs(t,e){if(t==null)return{};var n={},s=Object.keys(t),r,i;for(i=0;i<s.length;i++)r=s[i],!(e.indexOf(r)>=0)&&(n[r]=t[r]);return n}function Us(t,e){if(t==null)return{};var n=Fs(t,e),s,r;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)s=i[r],!(e.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(t,s)&&(n[s]=t[s])}return n}const Bs={target(t){if(t)return()=>"current"in t?t.current:t},enabled(t=!0){return t},window(t=se.isBrowser?window:void 0){return t},eventOptions({passive:t=!0,capture:e=!1}={}){return{passive:t,capture:e}},transform(t){return t}},Ws=["target","eventOptions","window","enabled","transform"];function qe(t={},e){const n={};for(const[s,r]of Object.entries(e))switch(typeof r){case"function":if(process.env.NODE_ENV==="development"){const i=r.call(n,t[s],s,t);Number.isNaN(i)||(n[s]=i)}else n[s]=r.call(n,t[s],s,t);break;case"object":n[s]=qe(t[s],r);break;case"boolean":r&&(n[s]=t[s]);break}return n}function Xs(t,e,n={}){const s=t,{target:r,eventOptions:i,window:o,enabled:a,transform:l}=s,d=Us(s,Ws);if(n.shared=qe({target:r,eventOptions:i,window:o,enabled:a,transform:l},Bs),e){const f=yt.get(e);n[e]=qe(Y({shared:n.shared},d),f)}else for(const f in d){const v=yt.get(f);if(v)n[f]=qe(Y({shared:n.shared},d[f]),v);else if(process.env.NODE_ENV==="development"&&!["drag","pinch","scroll","wheel","move","hover"].includes(f)){if(f==="domTarget")throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");console.warn(`[@use-gesture]: Unknown config key \`${f}\` was used. Please read the documentation for further information.`)}}return n}class cn{constructor(e,n){X(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=n}add(e,n,s,r,i){const o=this._listeners,a=ts(n,s),l=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},d=Y(Y({},l),i);e.addEventListener(a,r,d);const f=()=>{e.removeEventListener(a,r,d),o.delete(f)};return o.add(f),f}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class Ks{constructor(){X(this,"_timeouts",new Map)}add(e,n,s=140,...r){this.remove(e),this._timeouts.set(e,window.setTimeout(n,s,...r))}remove(e){const n=this._timeouts.get(e);n&&window.clearTimeout(n)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class Gs{constructor(e){X(this,"gestures",new Set),X(this,"_targetEventStore",new cn(this)),X(this,"gestureEventStores",{}),X(this,"gestureTimeoutStores",{}),X(this,"handlers",{}),X(this,"config",{}),X(this,"pointerIds",new Set),X(this,"touchIds",new Set),X(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),qs(this,e)}setEventIds(e){if(Ke(e))return this.touchIds=new Set(rs(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,n){this.handlers=e,this.nativeHandlers=n}applyConfig(e,n){this.config=Xs(e,n,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 n=this.config.shared,s={};let r;if(!(n.target&&(r=n.target(),!r))){if(n.enabled){for(const o of this.gestures){const a=this.config[o],l=ln(s,a.eventOptions,!!r);if(a.enabled){const d=gt.get(o);new d(this,e,o).bind(l)}}const i=ln(s,n.eventOptions,!!r);for(const o in this.nativeHandlers)i(o,"",a=>this.nativeHandlers[o](Y(Y({},this.state.shared),{},{event:a,args:e})),void 0,!0)}for(const i in s)s[i]=cs(...s[i]);if(!r)return s;for(const i in s){const{device:o,capture:a,passive:l}=es(i);this._targetEventStore.add(r,o,"",s[i],{capture:a,passive:l})}}}}function _e(t,e){t.gestures.add(e),t.gestureEventStores[e]=new cn(t,e),t.gestureTimeoutStores[e]=new Ks}function qs(t,e){e.drag&&_e(t,"drag"),e.wheel&&_e(t,"wheel"),e.scroll&&_e(t,"scroll"),e.move&&_e(t,"move"),e.pinch&&_e(t,"pinch"),e.hover&&_e(t,"hover")}const ln=(t,e,n)=>(s,r,i,o={},a=!1)=>{var l,d;const f=(l=o.capture)!==null&&l!==void 0?l:e.capture,v=(d=o.passive)!==null&&d!==void 0?d:e.passive;let m=a?s:Zn(s,r,f);n&&v&&(m+="Passive"),t[m]=t[m]||[],t[m].push(i)},Js=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function Zs(t){const e={},n={},s=new Set;for(let r in t)Js.test(r)?(s.add(RegExp.lastMatch),n[r]=t[r]):e[r]=t[r];return[n,e,s]}function ve(t,e,n,s,r,i){if(!t.has(n))return;if(!gt.has(s)){process.env.NODE_ENV==="development"&&console.warn(`[@use-gesture]: You've created a custom handler that that uses the \`${s}\` gesture but isn't properly configured.
7
+ <%s key={someKey} {...props} />`,W,M,K,M),se[M+W]=!0)}if(M=null,H!==void 0&&(n(H),M=""+H),i(A)&&(n(A.key),M=""+A.key),"key"in A){H={};for(var L in A)L!=="key"&&(H[L]=A[L])}else H=A;return M&&a(H,typeof u=="function"?u.displayName||u.name||"Unknown":u),d(u,M,H,s(),be,E)}function _(u){m(u)?u._store&&(u._store.validated=1):typeof u=="object"&&u!==null&&u.$$typeof===k&&(u._payload.status==="fulfilled"?m(u._payload.value)&&u._payload.value._store&&(u._payload.value._store.validated=1):u._store&&(u._store.validated=1))}function m(u){return typeof u=="object"&&u!==null&&u.$$typeof===N}var w=I,N=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),c=Symbol.for("react.fragment"),g=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),b=Symbol.for("react.consumer"),v=Symbol.for("react.context"),D=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),O=Symbol.for("react.suspense_list"),T=Symbol.for("react.memo"),k=Symbol.for("react.lazy"),S=Symbol.for("react.activity"),j=Symbol.for("react.client.reference"),R=w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,x=Object.prototype.hasOwnProperty,B=Array.isArray,Z=console.createTask?console.createTask:function(){return null};w={react_stack_bottom_frame:function(u){return u()}};var q,Y={},U=w.react_stack_bottom_frame.bind(w,o)(),de=Z(r(o)),se={};xe.Fragment=c,xe.jsx=function(u,A,H){var W=1e4>R.recentlyCreatedOwnerStacks++;return f(u,A,H,!1,W?Error("react-stack-top-frame"):U,W?Z(r(u)):de)},xe.jsxs=function(u,A,H){var W=1e4>R.recentlyCreatedOwnerStacks++;return f(u,A,H,!0,W?Error("react-stack-top-frame"):U,W?Z(r(u)):de)}})()),xe}var wt;function bn(){return wt||(wt=1,process.env.NODE_ENV==="production"?Ce.exports=vn():Ce.exports=_n()),Ce.exports}var y=bn();const xt=t=>{let e;const n=new Set,r=(d,f)=>{const _=typeof d=="function"?d(e):d;if(!Object.is(_,e)){const m=e;e=f??(typeof _!="object"||_===null)?_:Object.assign({},e,_),n.forEach(w=>w(e,m))}},s=()=>e,a={setState:r,getState:s,getInitialState:()=>l,subscribe:d=>(n.add(d),()=>n.delete(d))},l=e=t(r,s,a);return a},wn=(t=>t?xt(t):xt),xn=t=>t;function En(t,e=xn){const n=I.useSyncExternalStore(t.subscribe,I.useCallback(()=>e(t.getState()),[t,e]),I.useCallback(()=>e(t.getInitialState()),[t,e]));return I.useDebugValue(n),n}var Et=Symbol.for("immer-nothing"),St=Symbol.for("immer-draftable"),J=Symbol.for("immer-state"),Sn=process.env.NODE_ENV!=="production"?[function(t){return`The plugin for '${t}' has not been loaded into Immer. To enable the plugin, import and call \`enable${t}()\` when initializing your application.`},function(t){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${t}'`},"This object has been frozen and should not be mutated",function(t){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+t},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(t){return`'current' expects a draft, got: ${t}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(t){return`'original' expects a draft, got: ${t}`}]:[];function ee(t,...e){if(process.env.NODE_ENV!=="production"){const n=Sn[t],r=he(n)?n.apply(null,e):n;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var te=Object,me=te.getPrototypeOf,Ae="constructor",ze="prototype",Je="configurable",Me="enumerable",je="writable",Ee="value",ue=t=>!!t&&!!t[J];function ae(t){return t?kt(t)||Le(t)||!!t[St]||!!t[Ae]?.[St]||$e(t)||Ye(t):!1}var Tn=te[ze][Ae].toString(),Tt=new WeakMap;function kt(t){if(!t||!Qe(t))return!1;const e=me(t);if(e===null||e===te[ze])return!0;const n=te.hasOwnProperty.call(e,Ae)&&e[Ae];if(n===Object)return!0;if(!he(n))return!1;let r=Tt.get(n);return r===void 0&&(r=Function.toString.call(n),Tt.set(n,r)),r===Tn}function Se(t,e,n=!0){Te(t)===0?(n?Reflect.ownKeys(t):te.keys(t)).forEach(s=>{e(s,t[s],t)}):t.forEach((r,s)=>e(s,r,t))}function Te(t){const e=t[J];return e?e.type_:Le(t)?1:$e(t)?2:Ye(t)?3:0}var It=(t,e,n=Te(t))=>n===2?t.has(e):te[ze].hasOwnProperty.call(t,e),Ze=(t,e,n=Te(t))=>n===2?t.get(e):t[e],Re=(t,e,n,r=Te(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function kn(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var Le=Array.isArray,$e=t=>t instanceof Map,Ye=t=>t instanceof Set,Qe=t=>typeof t=="object",he=t=>typeof t=="function",et=t=>typeof t=="boolean",ce=t=>t.copy_||t.base_,tt=t=>t.modified_?t.copy_:t.base_;function nt(t,e){if($e(t))return new Map(t);if(Ye(t))return new Set(t);if(Le(t))return Array[ze].slice.call(t);const n=kt(t);if(e===!0||e==="class_only"&&!n){const r=te.getOwnPropertyDescriptors(t);delete r[J];let s=Reflect.ownKeys(r);for(let o=0;o<s.length;o++){const i=s[o],a=r[i];a[je]===!1&&(a[je]=!0,a[Je]=!0),(a.get||a.set)&&(r[i]={[Je]:!0,[je]:!0,[Me]:a[Me],[Ee]:t[i]})}return te.create(me(t),r)}else{const r=me(t);if(r!==null&&n)return{...t};const s=te.create(r);return te.assign(s,t)}}function rt(t,e=!1){return Ve(t)||ue(t)||!ae(t)||(Te(t)>1&&te.defineProperties(t,{set:He,add:He,clear:He,delete:He}),te.freeze(t),e&&Se(t,(n,r)=>{rt(r,!0)},!1)),t}function In(){ee(2)}var He={[Ee]:In};function Ve(t){return t===null||!Qe(t)?!0:te.isFrozen(t)}var Fe="MapSet",st="Patches",Pt={};function ge(t){const e=Pt[t];return e||ee(0,t),e}var Pn=t=>!!Pt[t],ke,Dt=()=>ke,Dn=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Pn(Fe)?ge(Fe):void 0});function Ot(t,e){e&&(t.patchPlugin_=ge(st),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function ot(t){it(t),t.drafts_.forEach(On),t.drafts_=null}function it(t){t===ke&&(ke=t.parent_)}var Nt=t=>ke=Dn(ke,t);function On(t){const e=t[J];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function Ct(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[J].modified_&&(ot(e),ee(4)),ae(t)&&(t=At(e,t));const{patchPlugin_:s}=e;s&&s.generateReplacementPatches_(n[J].base_,t,e)}else t=At(e,n);return Nn(e,t,!0),ot(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==Et?t:void 0}function At(t,e){if(Ve(e))return e;const n=e[J];if(!n)return at(e,t.handledSet_,t);if(!Ue(n,t))return e;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(t);jt(n,t)}return n.copy_}function Nn(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&rt(e,n)}function zt(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var Ue=(t,e)=>t.scope_===e,Cn=[];function Mt(t,e,n,r){const s=ce(t),o=t.type_;if(r!==void 0&&Ze(s,r,o)===e){Re(s,r,n,o);return}if(!t.draftLocations_){const a=t.draftLocations_=new Map;Se(s,(l,d)=>{if(ue(d)){const f=a.get(d)||[];f.push(l),a.set(d,f)}})}const i=t.draftLocations_.get(e)??Cn;for(const a of i)Re(s,a,n,o)}function An(t,e,n){t.callbacks_.push(function(s){const o=e;if(!o||!Ue(o,s))return;s.mapSetPlugin_?.fixSetContents(o);const i=tt(o);Mt(t,o.draft_??o,i,n),jt(o,s)})}function jt(t,e){if(t.modified_&&!t.finalized_&&(t.type_===3||(t.assigned_?.size??0)>0)){const{patchPlugin_:r}=e;if(r){const s=r.getPath(t);s&&r.generatePatches_(t,s,e)}zt(t)}}function zn(t,e,n){const{scope_:r}=t;if(ue(n)){const s=n[J];Ue(s,r)&&s.callbacks_.push(function(){Be(t);const i=tt(s);Mt(t,n,i,e)})}else ae(n)&&t.callbacks_.push(function(){const o=ce(t);Ze(o,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&at(Ze(t.copy_,e,t.type_),r.handledSet_,r)})}function at(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||ue(t)||e.has(t)||!ae(t)||Ve(t)||(e.add(t),Se(t,(r,s)=>{if(ue(s)){const o=s[J];if(Ue(o,n)){const i=tt(o);Re(t,r,i,t.type_),zt(o)}}else ae(s)&&at(s,e,n)})),t}function Mn(t,e){const n=Le(t),r={type_:n?1:0,scope_:e?e.scope_:Dt(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let s=r,o=ct;n&&(s=[r],o=Ie);const{revoke:i,proxy:a}=Proxy.revocable(s,o);return r.draft_=a,r.revoke_=i,[a,r]}var ct={get(t,e){if(e===J)return t;const n=ce(t);if(!It(n,e,t.type_))return jn(t,n,e);const r=n[e];if(t.finalized_||!ae(r))return r;if(r===lt(t.base_,e)){Be(t);const s=t.type_===1?+e:e,o=dt(t.scope_,r,t,s);return t.copy_[s]=o}return r},has(t,e){return e in ce(t)},ownKeys(t){return Reflect.ownKeys(ce(t))},set(t,e,n){const r=Rt(ce(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const s=lt(ce(t),e),o=s?.[J];if(o&&o.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(kn(n,s)&&(n!==void 0||It(t.base_,e,t.type_)))return!0;Be(t),ut(t)}return t.copy_[e]===n&&(n!==void 0||e in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=n,t.assigned_.set(e,!0),zn(t,e,n)),!0},deleteProperty(t,e){return Be(t),lt(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),ut(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=ce(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[je]:!0,[Je]:t.type_!==1||e!=="length",[Me]:r[Me],[Ee]:n[e]}},defineProperty(){ee(11)},getPrototypeOf(t){return me(t.base_)},setPrototypeOf(){ee(12)}},Ie={};Se(ct,(t,e)=>{Ie[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}}),Ie.deleteProperty=function(t,e){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(e))&&ee(13),Ie.set.call(this,t,e,void 0)},Ie.set=function(t,e,n){return process.env.NODE_ENV!=="production"&&e!=="length"&&isNaN(parseInt(e))&&ee(14),ct.set.call(this,t[0],e,n,t[0])};function lt(t,e){const n=t[J];return(n?ce(n):t)[e]}function jn(t,e,n){const r=Rt(e,n);return r?Ee in r?r[Ee]:r.get?.call(t.draft_):void 0}function Rt(t,e){if(!(e in t))return;let n=me(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=me(n)}}function ut(t){t.modified_||(t.modified_=!0,t.parent_&&ut(t.parent_))}function Be(t){t.copy_||(t.assigned_=new Map,t.copy_=nt(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Rn=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,n,r)=>{if(he(e)&&!he(n)){const o=n;n=e;const i=this;return function(l=o,...d){return i.produce(l,f=>n.call(this,f,...d))}}he(n)||ee(6),r!==void 0&&!he(r)&&ee(7);let s;if(ae(e)){const o=Nt(this),i=dt(o,e,void 0);let a=!0;try{s=n(i),a=!1}finally{a?ot(o):it(o)}return Ot(o,r),Ct(s,o)}else if(!e||!Qe(e)){if(s=n(e),s===void 0&&(s=e),s===Et&&(s=void 0),this.autoFreeze_&&rt(s,!0),r){const o=[],i=[];ge(st).generateReplacementPatches_(e,s,{patches_:o,inversePatches_:i}),r(o,i)}return s}else ee(1,e)},this.produceWithPatches=(e,n)=>{if(he(e))return(i,...a)=>this.produceWithPatches(i,l=>e(l,...a));let r,s;return[this.produce(e,n,(i,a)=>{r=i,s=a}),r,s]},et(t?.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),et(t?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),et(t?.useStrictIteration)&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){ae(t)||ee(8),ue(t)&&(t=Ln(t));const e=Nt(this),n=dt(e,t,void 0);return n[J].isManual_=!0,it(e),n}finishDraft(t,e){const n=t&&t[J];(!n||!n.isManual_)&&ee(9);const{scope_:r}=n;return Ot(r,e),Ct(void 0,r)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,e){let n;for(n=e.length-1;n>=0;n--){const s=e[n];if(s.path.length===0&&s.op==="replace"){t=s.value;break}}n>-1&&(e=e.slice(n+1));const r=ge(st).applyPatches_;return ue(t)?r(t,e):this.produce(t,s=>r(s,e))}};function dt(t,e,n,r){const[s,o]=$e(e)?ge(Fe).proxyMap_(e,n):Ye(e)?ge(Fe).proxySet_(e,n):Mn(e,n);return(n?.scope_??Dt()).drafts_.push(s),o.callbacks_=n?.callbacks_??[],o.key_=r,n&&r!==void 0?An(n,o,r):o.callbacks_.push(function(l){l.mapSetPlugin_?.fixSetContents(o);const{patchPlugin_:d}=l;o.modified_&&d&&d.generatePatches_(o,[],l)}),s}function Ln(t){return ue(t)||ee(10,t),Lt(t)}function Lt(t){if(!ae(t)||Ve(t))return t;const e=t[J];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=nt(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=nt(t,!0);return Se(n,(s,o)=>{Re(n,s,Lt(o))},r),e&&(e.finalized_=!1),n}var $n=new Rn,Yn=$n.produce;const Hn=t=>(e,n,r)=>(r.setState=(s,o,...i)=>{const a=typeof s=="function"?Yn(s):s;return e(a,o,...i)},t(r.setState,n,r)),Vn={snapping:!0,snapGuide:!0,rotation:!0,rotationSpeed:2,rotationSnap:5,zoom:!0,pan:!0,viewOnly:!1,minZoom:.1,maxZoom:5,showGrid:!0,gridSize:20,gridColor:"#ddd"},Fn=(t=[],e=[],n={})=>wn(Hn(r=>({nodes:t.reduce((s,o)=>({...s,[o.id]:o}),{}),edges:e.reduce((s,o)=>({...s,[o.id]:o}),{}),selectedIds:[],camera:{x:0,y:0,zoom:1},dimensions:{width:0,height:0},config:{...Vn,...n},connectionState:{nodeId:null,handleId:null,handleType:null,position:null,isValid:!1},startConnection:(s,o,i,a)=>r(l=>{l.connectionState={nodeId:s,handleId:o,handleType:i,position:a,isValid:!0}}),updateConnection:s=>r(o=>{o.connectionState.nodeId&&(o.connectionState.position=s)}),endConnection:()=>r(s=>{s.connectionState={nodeId:null,handleId:null,handleType:null,position:null,isValid:!1}}),setCamera:s=>r(o=>{Object.assign(o.camera,s)}),panCamera:(s,o)=>r(i=>{i.camera.x+=s,i.camera.y+=o}),zoomCamera:(s,o,i)=>r(a=>{const{minZoom:l=.1,maxZoom:d=5}=a.config,f=Math.min(Math.max(a.camera.zoom*s,l),d),_=(o-a.camera.x)/a.camera.zoom,m=(i-a.camera.y)/a.camera.zoom;a.camera.x=o-_*f,a.camera.y=i-m*f,a.camera.zoom=f}),setDimensions:(s,o)=>r(i=>{i.dimensions={width:s,height:o}}),setNodes:s=>r(o=>{o.nodes=s.reduce((i,a)=>({...i,[a.id]:a}),{})}),addNode:s=>r(o=>{o.nodes[s.id]=s}),updateNode:(s,o)=>r(i=>{i.nodes[s]&&Object.assign(i.nodes[s],o)}),registerHandle:(s,o,i)=>r(a=>{const l=a.nodes[s];l&&(l.handles||(l.handles={}),l.handles[o]={id:o,...i})}),removeNode:s=>r(o=>{delete o.nodes[s],Object.keys(o.edges).forEach(i=>{const a=o.edges[i];(a.source===s||a.target===s)&&delete o.edges[i]}),o.selectedIds=o.selectedIds.filter(i=>i!==s)}),setEdges:s=>r(o=>{o.edges=s.reduce((i,a)=>({...i,[a.id]:a}),{})}),addEdge:s=>r(o=>{Object.values(o.edges).some(a=>a.source===s.source&&a.target===s.target&&a.sourceHandle===s.sourceHandle&&a.targetHandle===s.targetHandle)||(o.edges[s.id]=s)}),removeEdge:s=>r(o=>{delete o.edges[s]}),selectNode:s=>r(o=>{o.selectedIds=s?[s]:[]}),resizeNode:(s,o,i,a,l)=>r(d=>{d.nodes[s]&&(d.nodes[s].x=o,d.nodes[s].y=i,d.nodes[s].width=a,d.nodes[s].height=l)}),rotateNode:(s,o)=>r(i=>{i.nodes[s]&&(i.nodes[s].rotation=o)}),deleteSelected:()=>r(s=>{s.selectedIds.forEach(o=>{s.nodes[o]?(delete s.nodes[o],Object.keys(s.edges).forEach(i=>{const a=s.edges[i];(a.source===o||a.target===o)&&delete s.edges[i]})):s.edges[o]&&delete s.edges[o]}),s.selectedIds=[]}),selectAll:()=>r(s=>{s.selectedIds=Object.keys(s.nodes)}),deselectAll:()=>r(s=>{s.selectedIds=[]}),duplicateSelected:()=>r(s=>{const o=[];s.selectedIds.forEach(i=>{const a=s.nodes[i];if(a){const l=`node-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,d={...a,id:l,x:a.x+20,y:a.y+20};s.nodes[l]=d,o.push(d)}}),s.selectedIds=o.map(i=>i.id)}),nudgeSelected:(s,o)=>r(i=>{i.selectedIds.forEach(a=>{const l=i.nodes[a];l&&(l.x+=s,l.y+=o)})}),setConfig:s=>r(o=>{o.config={...o.config,...s}})}))),ft=I.createContext(null),Un=({children:t,initialNodes:e=[],initialEdges:n=[],nodes:r,config:s={},className:o="",style:i,onChange:a})=>{const l=I.useRef(null);return l.current||(l.current=Fn(e,n,s)),I.useEffect(()=>{r&&l.current&&l.current.getState().setNodes(r)},[r]),I.useEffect(()=>{if(!a||!l.current)return;const d=l.current.subscribe(f=>{a(f)});return()=>d()},[a]),I.useEffect(()=>{l.current&&l.current.getState().setConfig(s)},[s]),y.jsx(ft.Provider,{value:l.current,children:y.jsx("div",{className:`ce-editor ${o}`,style:i,children:t})})},z=t=>{const e=I.useContext(ft);if(!e)throw new Error("useEditor must be used within Editor");return En(e,t)},We=()=>{const t=I.useContext(ft);if(!t)throw new Error("useEditor must be used within Editor");return t},$t=I.createContext(null),Bn=({id:t,children:e})=>y.jsx($t.Provider,{value:t,children:e}),Wn=()=>{const t=I.useContext($t);return t||null},Pe=({type:t,id:e="default",position:n="top",className:r="",style:s,...o})=>{const i=Wn(),a=z(w=>w.startConnection),l=z(w=>w.camera),d=z(w=>w.registerHandle),f=We(),_=I.useRef(null);I.useEffect(()=>{if(!i||!_.current)return;const w=()=>{const c=document.getElementById(i);if(!c||!_.current)return;const g=c.getBoundingClientRect(),p=_.current.getBoundingClientRect(),b=f.getState().camera.zoom,v=(p.left+p.width/2-g.left)/b,D=(p.top+p.height/2-g.top)/b;d(i,e,{type:t,position:n,x:v,y:D,width:p.width/b,height:p.height/b})};w();const N=document.getElementById(i);if(!N)return;const C=new ResizeObserver(()=>{requestAnimationFrame(w)});return C.observe(N),()=>C.disconnect()},[i,e,t,n,d]);const m=w=>{if(!i)return;w.stopPropagation();const N=document.querySelector(".ce-editor__viewport")?.getBoundingClientRect();if(!N)return;const C=(w.clientX-N.left-l.x)/l.zoom,c=(w.clientY-N.top-l.y)/l.zoom;a(i,e,t,{x:C,y:c})};return y.jsx("div",{ref:_,"data-handle-type":t,"data-handle-id":e,onPointerDown:m,className:`ce-handle ce-handle--${n} ${r}`,style:s,...o})},Xe=({data:t,...e})=>y.jsxs("div",{className:"ce-node-default",...e,style:e.style,children:[y.jsx(Pe,{type:"target",position:"left",id:"input"}),y.jsx("div",{className:"ce-node-content",children:t.label||"Default Node"}),y.jsx(Pe,{type:"source",position:"right",id:"output"})]}),Yt=({data:t,...e})=>y.jsxs("div",{className:"ce-node-input",...e,style:e.style,children:[y.jsx("div",{className:"ce-node-content",children:t.label||"Input Node"}),y.jsx(Pe,{type:"source",position:"right",id:"output"})]}),Ht=({data:t,...e})=>y.jsxs("div",{className:"ce-node-output",...e,style:e.style,children:[y.jsx(Pe,{type:"target",position:"left",id:"input"}),y.jsx("div",{className:"ce-node-content",children:t.label||"Output Node"})]});function Xn(t,e,n){return Math.max(e,Math.min(t,n))}const $={toVector(t,e){return t===void 0&&(t=e),Array.isArray(t)?t:[t,t]},add(t,e){return[t[0]+e[0],t[1]+e[1]]},sub(t,e){return[t[0]-e[0],t[1]-e[1]]},addTo(t,e){t[0]+=e[0],t[1]+=e[1]},subTo(t,e){t[0]-=e[0],t[1]-=e[1]}};function Vt(t,e,n){return e===0||Math.abs(e)===1/0?Math.pow(t,n*5):t*e*n/(e+n*t)}function Ft(t,e,n,r=.15){return r===0?Xn(t,e,n):t<e?-Vt(e-t,n-e,r)+e:t>n?+Vt(t-n,n-e,r)+n:t}function Kn(t,[e,n],[r,s]){const[[o,i],[a,l]]=t;return[Ft(e,o,i,r),Ft(n,a,l,s)]}function Gn(t,e){if(typeof t!="object"||t===null)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function qn(t){var e=Gn(t,"string");return typeof e=="symbol"?e:String(e)}function X(t,e,n){return e=qn(e),e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ut(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function V(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Ut(Object(n),!0).forEach(function(r){X(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ut(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}const Bt={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 Wt(t){return t?t[0].toUpperCase()+t.slice(1):""}const Jn=["enter","leave"];function Zn(t=!1,e){return t&&!Jn.includes(e)}function Qn(t,e="",n=!1){const r=Bt[t],s=r&&r[e]||e;return"on"+Wt(t)+Wt(s)+(Zn(n,s)?"Capture":"")}const er=["gotpointercapture","lostpointercapture"];function tr(t){let e=t.substring(2).toLowerCase();const n=!!~e.indexOf("passive");n&&(e=e.replace("passive",""));const r=er.includes(e)?"capturecapture":"capture",s=!!~e.indexOf(r);return s&&(e=e.replace("capture","")),{device:e,capture:s,passive:n}}function nr(t,e=""){const n=Bt[t],r=n&&n[e]||e;return t+r}function Ke(t){return"touches"in t}function Xt(t){return Ke(t)?"touch":"pointerType"in t?t.pointerType:"mouse"}function rr(t){return Array.from(t.touches).filter(e=>{var n,r;return e.target===t.currentTarget||((n=t.currentTarget)===null||n===void 0||(r=n.contains)===null||r===void 0?void 0:r.call(n,e.target))})}function sr(t){return t.type==="touchend"||t.type==="touchcancel"?t.changedTouches:t.targetTouches}function Kt(t){return Ke(t)?sr(t)[0]:t}function ht(t,e){try{const n=e.clientX-t.clientX,r=e.clientY-t.clientY,s=(e.clientX+t.clientX)/2,o=(e.clientY+t.clientY)/2,i=Math.hypot(n,r);return{angle:-(Math.atan2(n,r)*180)/Math.PI,distance:i,origin:[s,o]}}catch{}return null}function or(t){return rr(t).map(e=>e.identifier)}function Gt(t,e){const[n,r]=Array.from(t.touches).filter(s=>e.includes(s.identifier));return ht(n,r)}function pt(t){const e=Kt(t);return Ke(t)?e.identifier:e.pointerId}function ye(t){const e=Kt(t);return[e.clientX,e.clientY]}const qt=40,Jt=800;function Zt(t){let{deltaX:e,deltaY:n,deltaMode:r}=t;return r===1?(e*=qt,n*=qt):r===2&&(e*=Jt,n*=Jt),[e,n]}function ir(t){var e,n;const{scrollX:r,scrollY:s,scrollLeft:o,scrollTop:i}=t.currentTarget;return[(e=r??o)!==null&&e!==void 0?e:0,(n=s??i)!==null&&n!==void 0?n:0]}function ar(t){const e={};if("buttons"in t&&(e.buttons=t.buttons),"shiftKey"in t){const{shiftKey:n,altKey:r,metaKey:s,ctrlKey:o}=t;Object.assign(e,{shiftKey:n,altKey:r,metaKey:s,ctrlKey:o})}return e}function Ge(t,...e){return typeof t=="function"?t(...e):t}function cr(){}function lr(...t){return t.length===0?cr:t.length===1?t[0]:function(){let e;for(const n of t)e=n.apply(this,arguments)||e;return e}}function Qt(t,e){return Object.assign({},e,t||{})}const ur=32;class en{constructor(e,n,r){this.ctrl=e,this.args=n,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:n,ingKey:r,args:s}=this;n[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 n=this.state,r=this.config;n._active||(this.reset(),this.computeInitial(),n._active=!0,n.target=e.target,n.currentTarget=e.currentTarget,n.lastOffset=r.from?Ge(r.from,n):n.offset,n.offset=n.lastOffset,n.startTime=n.timeStamp=e.timeStamp)}computeValues(e){const n=this.state;n._values=e,n.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:n,config:r,shared:s}=this;n.args=this.args;let o=0;if(e&&(n.event=e,r.preventDefault&&e.cancelable&&n.event.preventDefault(),n.type=e.type,s.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,s.locked=!!document.pointerLockElement,Object.assign(s,ar(e)),s.down=s.pressed=s.buttons%2===1||s.touches>0,o=e.timeStamp-n.timeStamp,n.timeStamp=e.timeStamp,n.elapsedTime=n.timeStamp-n.startTime),n._active){const h=n._delta.map(Math.abs);$.addTo(n._distance,h)}this.axisIntent&&this.axisIntent(e);const[i,a]=n._movement,[l,d]=r.threshold,{_step:f,values:_}=n;if(r.hasCustomTransform?(f[0]===!1&&(f[0]=Math.abs(i)>=l&&_[0]),f[1]===!1&&(f[1]=Math.abs(a)>=d&&_[1])):(f[0]===!1&&(f[0]=Math.abs(i)>=l&&Math.sign(i)*l),f[1]===!1&&(f[1]=Math.abs(a)>=d&&Math.sign(a)*d)),n.intentional=f[0]!==!1||f[1]!==!1,!n.intentional)return;const m=[0,0];if(r.hasCustomTransform){const[h,O]=_;m[0]=f[0]!==!1?h-f[0]:0,m[1]=f[1]!==!1?O-f[1]:0}else m[0]=f[0]!==!1?i-f[0]:0,m[1]=f[1]!==!1?a-f[1]:0;this.restrictToAxis&&!n._blocked&&this.restrictToAxis(m);const w=n.offset,N=n._active&&!n._blocked||n.active;N&&(n.first=n._active&&!n.active,n.last=!n._active&&n.active,n.active=s[this.ingKey]=n._active,e&&(n.first&&("bounds"in r&&(n._bounds=Ge(r.bounds,n)),this.setup&&this.setup()),n.movement=m,this.computeOffset()));const[C,c]=n.offset,[[g,p],[b,v]]=n._bounds;n.overflow=[C<g?-1:C>p?1:0,c<b?-1:c>v?1:0],n._movementBound[0]=n.overflow[0]?n._movementBound[0]===!1?n._movement[0]:n._movementBound[0]:!1,n._movementBound[1]=n.overflow[1]?n._movementBound[1]===!1?n._movement[1]:n._movementBound[1]:!1;const D=n._active?r.rubberband||[0,0]:[0,0];if(n.offset=Kn(n._bounds,n.offset,D),n.delta=$.sub(n.offset,w),this.computeMovement(),N&&(!n.last||o>ur)){n.delta=$.sub(n.offset,w);const h=n.delta.map(Math.abs);$.addTo(n.distance,h),n.direction=n.delta.map(Math.sign),n._direction=n._delta.map(Math.sign),!n.first&&o>0&&(n.velocity=[h[0]/o,h[1]/o],n.timeDelta=o)}}emit(){const e=this.state,n=this.shared,r=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!r.triggerAllEvents)return;const s=this.handler(V(V(V({},n),e),{},{[this.aliasKey]:e.values}));s!==void 0&&(e.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function dr([t,e],n){const r=Math.abs(t),s=Math.abs(e);if(r>s&&r>n)return"x";if(s>r&&s>n)return"y"}class De extends en{constructor(...e){super(...e),X(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=$.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=$.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const n=this.state,r=this.config;if(!n.axis&&e){const s=typeof r.axisThreshold=="object"?r.axisThreshold[Xt(e)]:r.axisThreshold;n.axis=dr(n._movement,s)}n._blocked=(r.lockDirection||!!r.axis)&&!n.axis||!!r.axis&&r.axis!==n.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 tn=t=>t,nn=.15,mt={enabled(t=!0){return t},eventOptions(t,e,n){return V(V({},n.shared.eventOptions),t)},preventDefault(t=!1){return t},triggerAllEvents(t=!1){return t},rubberband(t=0){switch(t){case!0:return[nn,nn];case!1:return[0,0];default:return $.toVector(t)}},from(t){if(typeof t=="function")return t;if(t!=null)return $.toVector(t)},transform(t,e,n){const r=t||n.shared.transform;if(this.hasCustomTransform=!!r,process.env.NODE_ENV==="development"){const s=r||tn;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||tn},threshold(t){return $.toVector(t,0)}};process.env.NODE_ENV==="development"&&Object.assign(mt,{domTarget(t){if(t!==void 0)throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");return NaN},lockDirection(t){if(t!==void 0)throw Error("[@use-gesture]: `lockDirection` option has been merged with `axis`. Use it as in `{ axis: 'lock' }`");return NaN},initial(t){if(t!==void 0)throw Error("[@use-gesture]: `initial` option has been renamed to `from`.");return NaN}});const fr=0,pe=V(V({},mt),{},{axis(t,e,{axis:n}){if(this.lockDirection=n==="lock",!this.lockDirection)return n},axisThreshold(t=fr){return t},bounds(t={}){if(typeof t=="function")return o=>pe.bounds(t(o));if("current"in t)return()=>t.current;if(typeof HTMLElement=="function"&&t instanceof HTMLElement)return t;const{left:e=-1/0,right:n=1/0,top:r=-1/0,bottom:s=1/0}=t;return[[e,n],[r,s]]}}),rn={ArrowRight:(t,e=1)=>[t*e,0],ArrowLeft:(t,e=1)=>[-1*t*e,0],ArrowUp:(t,e=1)=>[0,-1*t*e],ArrowDown:(t,e=1)=>[0,t*e]};class hr extends De{constructor(...e){super(...e),X(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 n=e._bounds.getBoundingClientRect(),r=e.currentTarget.getBoundingClientRect(),s={left:n.left-r.left+e.offset[0],right:n.right-r.right+e.offset[0],top:n.top-r.top+e.offset[1],bottom:n.bottom-r.bottom+e.offset[1]};e._bounds=pe.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 n=this.config,r=this.state;if(e.buttons!=null&&(Array.isArray(n.pointerButtons)?!n.pointerButtons.includes(e.buttons):n.pointerButtons!==-1&&n.pointerButtons!==e.buttons))return;const s=this.ctrl.setEventIds(e);n.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(s&&s.size>1&&r._pointerActive)&&(this.start(e),this.setupPointer(e),r._pointerId=pt(e),r._pointerActive=!0,this.computeValues(ye(e)),this.computeInitial(),n.preventScrollAxis&&Xt(e)!=="mouse"?(r._active=!1,this.setupScrollPrevention(e)):n.delay>0?(this.setupDelayTrigger(e),n.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const n=this.state;n._active=!0,n._preventScroll=!0,n._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const n=this.state,r=this.config;if(!n._pointerActive)return;const s=pt(e);if(n._pointerId!==void 0&&s!==n._pointerId)return;const o=ye(e);if(document.pointerLockElement===e.target?n._delta=[e.movementX,e.movementY]:(n._delta=$.sub(o,n._values),this.computeValues(o)),$.addTo(n._movement,n._delta),this.compute(e),n._delayed&&n.intentional){this.timeoutStore.remove("dragDelay"),n.active=!1,this.startPointerDrag(e);return}if(r.preventScrollAxis&&!n._preventScroll)if(n.axis)if(n.axis===r.preventScrollAxis||r.preventScrollAxis==="xy"){n._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 n=this.state,r=this.config;if(!n._active||!n._pointerActive)return;const s=pt(e);if(n._pointerId!==void 0&&s!==n._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[o,i]=n._distance;if(n.tap=o<=r.tapsThreshold&&i<=r.tapsThreshold,n.tap&&r.filterTaps)n._force=!0;else{const[a,l]=n._delta,[d,f]=n._movement,[_,m]=r.swipe.velocity,[w,N]=r.swipe.distance,C=r.swipe.duration;if(n.elapsedTime<C){const c=Math.abs(a/n.timeDelta),g=Math.abs(l/n.timeDelta);c>_&&Math.abs(d)>w&&(n.swipe[0]=Math.sign(a)),g>m&&Math.abs(f)>N&&(n.swipe[1]=Math.sign(l))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const n=this.config,r=n.device;if(process.env.NODE_ENV==="development")try{if(r==="pointer"&&n.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{}n.pointerLock&&e.currentTarget.requestPointerLock(),n.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,pr(e);const n=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",n),this.eventStore.add(this.sharedConfig.window,"touch","cancel",n),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 n=rn[e.key];if(n){const r=this.state,s=e.shiftKey?10:e.altKey?.1:1;this.start(e),r._delta=n(this.config.keyboardDisplacement,s),r._keyboardActive=!0,$.addTo(r._movement,r._delta),this.compute(e),this.emit()}}keyUp(e){e.key in rn&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const n=this.config.device;e(n,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(n,"change",this.pointerMove.bind(this)),e(n,"end",this.pointerUp.bind(this)),e(n,"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 pr(t){"persist"in t&&typeof t.persist=="function"&&t.persist()}const Oe=typeof window<"u"&&window.document&&window.document.createElement;function sn(){return Oe&&"ontouchstart"in window}function mr(){return sn()||Oe&&window.navigator.maxTouchPoints>1}function gr(){return Oe&&"onpointerdown"in window}function yr(){return Oe&&"exitPointerLock"in window.document}function vr(){try{return"constructor"in GestureEvent}catch{return!1}}const re={isBrowser:Oe,gesture:vr(),touch:sn(),touchscreen:mr(),pointer:gr(),pointerLock:yr()},_r=250,br=180,wr=.5,xr=50,Er=250,Sr=10,on={mouse:0,touch:0,pen:8},an=V(V({},pe),{},{device(t,e,{pointer:{touch:n=!1,lock:r=!1,mouse:s=!1}={}}){return this.pointerLock=r&&re.pointerLock,re.touch&&n?"touch":this.pointerLock?"mouse":re.pointer&&!s?"pointer":re.touch?"touch":"mouse"},preventScrollAxis(t,e,{preventScroll:n}){if(this.preventScrollDelay=typeof n=="number"?n:n||n===void 0&&t?_r:void 0,!(!re.touchscreen||n===!1))return t||(n!==void 0?"y":void 0)},pointerCapture(t,e,{pointer:{capture:n=!0,buttons:r=1,keys:s=!0}={}}){return this.pointerButtons=r,this.keys=s,!this.pointerLock&&this.device==="pointer"&&n},threshold(t,e,{filterTaps:n=!1,tapsThreshold:r=3,axis:s=void 0}){const o=$.toVector(t,n?r:s?1:0);return this.filterTaps=n,this.tapsThreshold=r,o},swipe({velocity:t=wr,distance:e=xr,duration:n=Er}={}){return{velocity:this.transform($.toVector(t)),distance:this.transform($.toVector(e)),duration:n}},delay(t=0){switch(t){case!0:return br;case!1:return 0;default:return t}},axisThreshold(t){return t?V(V({},on),t):on},keyboardDisplacement(t=Sr){return t}});process.env.NODE_ENV==="development"&&Object.assign(an,{useTouch(t){if(t!==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(t){if(t!==void 0)throw Error("[@use-gesture]: `experimental_preventWindowScrollY` option has been renamed to `preventScroll`.");return NaN},swipeVelocity(t){if(t!==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(t){if(t!==void 0)throw Error("[@use-gesture]: `swipeDistance` option has been renamed to `swipe.distance`. Use it as in `{ swipe: { distance: 50 } }`.");return NaN},swipeDuration(t){if(t!==void 0)throw Error("[@use-gesture]: `swipeDuration` option has been renamed to `swipe.duration`. Use it as in `{ swipe: { duration: 250 } }`.");return NaN}});function cn(t){const[e,n]=t.overflow,[r,s]=t._delta,[o,i]=t._direction;(e<0&&r>0&&o<0||e>0&&r<0&&o>0)&&(t._movement[0]=t._movementBound[0]),(n<0&&s>0&&i<0||n>0&&s<0&&i>0)&&(t._movement[1]=t._movementBound[1])}const Tr=30,kr=100;class Ir extends en{constructor(...e){super(...e),X(this,"ingKey","pinching"),X(this,"aliasKey","da")}init(){this.state.offset=[1,0],this.state.lastOffset=[1,0],this.state._pointerEvents=new Map}reset(){super.reset();const e=this.state;e._touchIds=[],e.canceled=!1,e.cancel=this.cancel.bind(this),e.turns=0}computeOffset(){const{type:e,movement:n,lastOffset:r}=this.state;e==="wheel"?this.state.offset=$.add(n,r):this.state.offset=[(1+n[0])*r[0],n[1]+r[1]]}computeMovement(){const{offset:e,lastOffset:n}=this.state;this.state.movement=[e[0]/n[0],e[1]-n[1]]}axisIntent(){const e=this.state,[n,r]=e._movement;if(!e.axis){const s=Math.abs(n)*Tr-Math.abs(r);s<0?e.axis="angle":s>0&&(e.axis="scale")}}restrictToAxis(e){this.config.lockDirection&&(this.state.axis==="scale"?e[1]=0:this.state.axis==="angle"&&(e[0]=0))}cancel(){const e=this.state;e.canceled||setTimeout(()=>{e.canceled=!0,e._active=!1,this.compute(),this.emit()},0)}touchStart(e){this.ctrl.setEventIds(e);const n=this.state,r=this.ctrl.touchIds;if(n._active&&n._touchIds.every(o=>r.has(o))||r.size<2)return;this.start(e),n._touchIds=Array.from(r).slice(0,2);const s=Gt(e,n._touchIds);s&&this.pinchStart(e,s)}pointerStart(e){if(e.buttons!=null&&e.buttons%2!==1)return;this.ctrl.setEventIds(e),e.target.setPointerCapture(e.pointerId);const n=this.state,r=n._pointerEvents,s=this.ctrl.pointerIds;if(n._active&&Array.from(r.keys()).every(i=>s.has(i))||(r.size<2&&r.set(e.pointerId,e),n._pointerEvents.size<2))return;this.start(e);const o=ht(...Array.from(r.values()));o&&this.pinchStart(e,o)}pinchStart(e,n){const r=this.state;r.origin=n.origin,this.computeValues([n.distance,n.angle]),this.computeInitial(),this.compute(e),this.emit()}touchMove(e){if(!this.state._active)return;const n=Gt(e,this.state._touchIds);n&&this.pinchMove(e,n)}pointerMove(e){const n=this.state._pointerEvents;if(n.has(e.pointerId)&&n.set(e.pointerId,e),!this.state._active)return;const r=ht(...Array.from(n.values()));r&&this.pinchMove(e,r)}pinchMove(e,n){const r=this.state,s=r._values[1],o=n.angle-s;let i=0;Math.abs(o)>270&&(i+=Math.sign(o)),this.computeValues([n.distance,n.angle-360*i]),r.origin=n.origin,r.turns=i,r._movement=[r._values[0]/r._initial[0]-1,r._values[1]-r._initial[1]],this.compute(e),this.emit()}touchEnd(e){this.ctrl.setEventIds(e),this.state._active&&this.state._touchIds.some(n=>!this.ctrl.touchIds.has(n))&&(this.state._active=!1,this.compute(e),this.emit())}pointerEnd(e){const n=this.state;this.ctrl.setEventIds(e);try{e.target.releasePointerCapture(e.pointerId)}catch{}n._pointerEvents.has(e.pointerId)&&n._pointerEvents.delete(e.pointerId),n._active&&n._pointerEvents.size<2&&(n._active=!1,this.compute(e),this.emit())}gestureStart(e){e.cancelable&&e.preventDefault();const n=this.state;n._active||(this.start(e),this.computeValues([e.scale,e.rotation]),n.origin=[e.clientX,e.clientY],this.compute(e),this.emit())}gestureMove(e){if(e.cancelable&&e.preventDefault(),!this.state._active)return;const n=this.state;this.computeValues([e.scale,e.rotation]),n.origin=[e.clientX,e.clientY];const r=n._movement;n._movement=[e.scale-1,e.rotation],n._delta=$.sub(n._movement,r),this.compute(e),this.emit()}gestureEnd(e){this.state._active&&(this.state._active=!1,this.compute(e),this.emit())}wheel(e){const n=this.config.modifierKey;n&&(Array.isArray(n)?!n.find(r=>e[r]):!e[n])||(this.state._active?this.wheelChange(e):this.wheelStart(e),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this)))}wheelStart(e){this.start(e),this.wheelChange(e)}wheelChange(e){"uv"in e||(e.cancelable&&e.preventDefault(),process.env.NODE_ENV==="development"&&!e.defaultPrevented&&console.warn("[@use-gesture]: To properly support zoom on trackpads, try using the `target` option.\n\nThis message will only appear in development mode."));const r=this.state;r._delta=[-Zt(e)[1]/kr*r.offset[0],0],$.addTo(r._movement,r._delta),cn(r),this.state.origin=[e.clientX,e.clientY],this.compute(e),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){const n=this.config.device;n&&(e(n,"start",this[n+"Start"].bind(this)),e(n,"change",this[n+"Move"].bind(this)),e(n,"end",this[n+"End"].bind(this)),e(n,"cancel",this[n+"End"].bind(this)),e("lostPointerCapture","",this[n+"End"].bind(this))),this.config.pinchOnWheel&&e("wheel","",this.wheel.bind(this),{passive:!1})}}const Pr=V(V({},mt),{},{device(t,e,{shared:n,pointer:{touch:r=!1}={}}){if(n.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(t,e,{scaleBounds:n={},angleBounds:r={}}){const s=i=>{const a=Qt(Ge(n,i),{min:-1/0,max:1/0});return[a.min,a.max]},o=i=>{const a=Qt(Ge(r,i),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof n!="function"&&typeof r!="function"?[s(),o()]:i=>[s(i),o(i)]},threshold(t,e,n){return this.lockDirection=n.axis==="lock",$.toVector(t,this.lockDirection?[.1,3]:0)},modifierKey(t){return t===void 0?"ctrlKey":t},pinchOnWheel(t=!0){return t}});class Dr extends De{constructor(...e){super(...e),X(this,"ingKey","moving")}move(e){this.config.mouseOnly&&e.pointerType!=="mouse"||(this.state._active?this.moveChange(e):this.moveStart(e),this.timeoutStore.add("moveEnd",this.moveEnd.bind(this)))}moveStart(e){this.start(e),this.computeValues(ye(e)),this.compute(e),this.computeInitial(),this.emit()}moveChange(e){if(!this.state._active)return;const n=ye(e),r=this.state;r._delta=$.sub(n,r._values),$.addTo(r._movement,r._delta),this.computeValues(n),this.compute(e),this.emit()}moveEnd(e){this.state._active&&(this.state._active=!1,this.compute(e),this.emit())}bind(e){e("pointer","change",this.move.bind(this)),e("pointer","leave",this.moveEnd.bind(this))}}const Or=V(V({},pe),{},{mouseOnly:(t=!0)=>t});class Nr extends De{constructor(...e){super(...e),X(this,"ingKey","scrolling")}scroll(e){this.state._active||this.start(e),this.scrollChange(e),this.timeoutStore.add("scrollEnd",this.scrollEnd.bind(this))}scrollChange(e){e.cancelable&&e.preventDefault();const n=this.state,r=ir(e);n._delta=$.sub(r,n._values),$.addTo(n._movement,n._delta),this.computeValues(r),this.compute(e),this.emit()}scrollEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){e("scroll","",this.scroll.bind(this))}}const Cr=pe;class Ar extends De{constructor(...e){super(...e),X(this,"ingKey","wheeling")}wheel(e){this.state._active||this.start(e),this.wheelChange(e),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this))}wheelChange(e){const n=this.state;n._delta=Zt(e),$.addTo(n._movement,n._delta),cn(n),this.compute(e),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){e("wheel","",this.wheel.bind(this))}}const zr=pe;class Mr extends De{constructor(...e){super(...e),X(this,"ingKey","hovering")}enter(e){this.config.mouseOnly&&e.pointerType!=="mouse"||(this.start(e),this.computeValues(ye(e)),this.compute(e),this.emit())}leave(e){if(this.config.mouseOnly&&e.pointerType!=="mouse")return;const n=this.state;if(!n._active)return;n._active=!1;const r=ye(e);n._movement=n._delta=$.sub(r,n._values),this.computeValues(r),this.compute(e),n.delta=n.movement,this.emit()}bind(e){e("pointer","enter",this.enter.bind(this)),e("pointer","leave",this.leave.bind(this))}}const jr=V(V({},pe),{},{mouseOnly:(t=!0)=>t}),gt=new Map,yt=new Map;function Rr(t){gt.set(t.key,t.engine),yt.set(t.key,t.resolver)}const Lr={key:"drag",engine:hr,resolver:an},$r={key:"hover",engine:Mr,resolver:jr},Yr={key:"move",engine:Dr,resolver:Or},Hr={key:"pinch",engine:Ir,resolver:Pr},Vr={key:"scroll",engine:Nr,resolver:Cr},Fr={key:"wheel",engine:Ar,resolver:zr};function Ur(t,e){if(t==null)return{};var n={},r=Object.keys(t),s,o;for(o=0;o<r.length;o++)s=r[o],!(e.indexOf(s)>=0)&&(n[s]=t[s]);return n}function Br(t,e){if(t==null)return{};var n=Ur(t,e),r,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(s=0;s<o.length;s++)r=o[s],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}const Wr={target(t){if(t)return()=>"current"in t?t.current:t},enabled(t=!0){return t},window(t=re.isBrowser?window:void 0){return t},eventOptions({passive:t=!0,capture:e=!1}={}){return{passive:t,capture:e}},transform(t){return t}},Xr=["target","eventOptions","window","enabled","transform"];function qe(t={},e){const n={};for(const[r,s]of Object.entries(e))switch(typeof s){case"function":if(process.env.NODE_ENV==="development"){const o=s.call(n,t[r],r,t);Number.isNaN(o)||(n[r]=o)}else n[r]=s.call(n,t[r],r,t);break;case"object":n[r]=qe(t[r],s);break;case"boolean":s&&(n[r]=t[r]);break}return n}function Kr(t,e,n={}){const r=t,{target:s,eventOptions:o,window:i,enabled:a,transform:l}=r,d=Br(r,Xr);if(n.shared=qe({target:s,eventOptions:o,window:i,enabled:a,transform:l},Wr),e){const f=yt.get(e);n[e]=qe(V({shared:n.shared},d),f)}else for(const f in d){const _=yt.get(f);if(_)n[f]=qe(V({shared:n.shared},d[f]),_);else if(process.env.NODE_ENV==="development"&&!["drag","pinch","scroll","wheel","move","hover"].includes(f)){if(f==="domTarget")throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");console.warn(`[@use-gesture]: Unknown config key \`${f}\` was used. Please read the documentation for further information.`)}}return n}class ln{constructor(e,n){X(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=n}add(e,n,r,s,o){const i=this._listeners,a=nr(n,r),l=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},d=V(V({},l),o);e.addEventListener(a,s,d);const f=()=>{e.removeEventListener(a,s,d),i.delete(f)};return i.add(f),f}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class Gr{constructor(){X(this,"_timeouts",new Map)}add(e,n,r=140,...s){this.remove(e),this._timeouts.set(e,window.setTimeout(n,r,...s))}remove(e){const n=this._timeouts.get(e);n&&window.clearTimeout(n)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class qr{constructor(e){X(this,"gestures",new Set),X(this,"_targetEventStore",new ln(this)),X(this,"gestureEventStores",{}),X(this,"gestureTimeoutStores",{}),X(this,"handlers",{}),X(this,"config",{}),X(this,"pointerIds",new Set),X(this,"touchIds",new Set),X(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),Jr(this,e)}setEventIds(e){if(Ke(e))return this.touchIds=new Set(or(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,n){this.handlers=e,this.nativeHandlers=n}applyConfig(e,n){this.config=Kr(e,n,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 n=this.config.shared,r={};let s;if(!(n.target&&(s=n.target(),!s))){if(n.enabled){for(const i of this.gestures){const a=this.config[i],l=un(r,a.eventOptions,!!s);if(a.enabled){const d=gt.get(i);new d(this,e,i).bind(l)}}const o=un(r,n.eventOptions,!!s);for(const i in this.nativeHandlers)o(i,"",a=>this.nativeHandlers[i](V(V({},this.state.shared),{},{event:a,args:e})),void 0,!0)}for(const o in r)r[o]=lr(...r[o]);if(!s)return r;for(const o in r){const{device:i,capture:a,passive:l}=tr(o);this._targetEventStore.add(s,i,"",r[o],{capture:a,passive:l})}}}}function ve(t,e){t.gestures.add(e),t.gestureEventStores[e]=new ln(t,e),t.gestureTimeoutStores[e]=new Gr}function Jr(t,e){e.drag&&ve(t,"drag"),e.wheel&&ve(t,"wheel"),e.scroll&&ve(t,"scroll"),e.move&&ve(t,"move"),e.pinch&&ve(t,"pinch"),e.hover&&ve(t,"hover")}const un=(t,e,n)=>(r,s,o,i={},a=!1)=>{var l,d;const f=(l=i.capture)!==null&&l!==void 0?l:e.capture,_=(d=i.passive)!==null&&d!==void 0?d:e.passive;let m=a?r:Qn(r,s,f);n&&_&&(m+="Passive"),t[m]=t[m]||[],t[m].push(o)},Zr=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function Qr(t){const e={},n={},r=new Set;for(let s in t)Zr.test(s)?(r.add(RegExp.lastMatch),n[s]=t[s]):e[s]=t[s];return[n,e,r]}function _e(t,e,n,r,s,o){if(!t.has(n))return;if(!gt.has(r)){process.env.NODE_ENV==="development"&&console.warn(`[@use-gesture]: You've created a custom handler that that uses the \`${r}\` gesture but isn't properly configured.
7
8
 
8
- Please add \`${s}Action\` when creating your handler.`);return}const o=n+"Start",a=n+"End",l=d=>{let f;return d.first&&o in e&&e[o](d),n in e&&(f=e[n](d)),d.last&&a in e&&e[a](d),f};r[s]=l,i[s]=i[s]||{}}function Qs(t,e){const[n,s,r]=Zs(t),i={};return ve(r,n,"onDrag","drag",i,e),ve(r,n,"onWheel","wheel",i,e),ve(r,n,"onScroll","scroll",i,e),ve(r,n,"onPinch","pinch",i,e),ve(r,n,"onMove","move",i,e),ve(r,n,"onHover","hover",i,e),{handlers:i,config:e,nativeHandlers:s}}function er(t,e={},n,s){const r=k.useMemo(()=>new Gs(t),[]);if(r.applyHandlers(t,s),r.applyConfig(e,n),k.useEffect(r.effect.bind(r)),k.useEffect(()=>r.clean.bind(r),[]),e.target===void 0)return r.bind.bind(r)}function tr(t){return t.forEach(js),function(n,s){const{handlers:r,nativeHandlers:i,config:o}=Qs(n,s||{});return er(r,o,void 0,i)}}function Ne(t,e){return tr([zs,Hs,Vs,Ys,$s,Ls])(t,e||{})}const nr=({pos:t,onDragStart:e,onDragMove:n,onDragEnd:s,className:r="",style:i})=>{const o=Ne({onDrag:({first:a,movement:[l,d],memo:f,event:v})=>(v.stopPropagation(),a?e():(f&&n(t,l,d,f),f)),onDragEnd:({movement:[a,l],memo:d,event:f})=>{f.stopPropagation(),d&&s(t,a,l,d)}},{drag:{filterTaps:!0,threshold:0}});return y.jsx("div",{className:`ce-resize-handle ce-resize-handle--${t} ${r}`,style:{touchAction:"none",...i},...o()})},sr=({onDragStart:t,onDragMove:e,onDragEnd:n,className:s="",style:r})=>{const i=Ne({onDrag:({first:o,movement:[a,l],memo:d,event:f})=>(f.stopPropagation(),o?t(a,l):(d&&e(a,l,d),d)),onDragEnd:({movement:[o,a],memo:l,event:d})=>{d.stopPropagation(),l&&n(o,a,l)}},{drag:{filterTaps:!0,threshold:0}});return y.jsx("div",{className:`ce-rotate-handle ${s}`,style:{touchAction:"none",...r},...i(),children:y.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:y.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})})},un=({lines:t,className:e="",style:n})=>t.length?y.jsx(y.Fragment,{children:t.map((s,r)=>y.jsx("div",{className:`ce-snap-guide ce-snap-guide--${s.type} ${e}`,style:{left:s.type==="vertical"?s.pos:0,top:s.type==="horizontal"?s.pos:0,...n}},r))}):null,dn=5,fn=(t,e,n,s,r,i)=>{let o=e,a=n;const l=[],d=[e,e+s/2,e+s],f=[n,n+r/2,n+r];return Object.values(i).forEach(v=>{if(v.id===t)return;const m=[v.x,v.x+v.width/2,v.x+v.width];d.forEach((N,C)=>{m.forEach(c=>{Math.abs(N-c)<dn&&(C===0&&(o=c),C===1&&(o=c-s/2),C===2&&(o=c-s),l.push({type:"vertical",pos:c}))})});const w=[v.y,v.y+v.height/2,v.y+v.height];f.forEach((N,C)=>{w.forEach(c=>{Math.abs(N-c)<dn&&(C===0&&(a=c),C===1&&(a=c-r/2),C===2&&(a=c-r),l.push({type:"horizontal",pos:c}))})})}),{x:o,y:a,lines:l}},hn=(t,e,n,s,r,i,o)=>{let l=s,d=r,f=e,v=n;const m=[],w=e,N=e+s,C=e+s/2,c=n,g=n+r,p=n+r/2,b=i.includes("w"),_=i.includes("e"),D=i.includes("n"),h=i.includes("s"),O=i==="n"||i==="s",T=i==="e"||i==="w";Object.values(o).forEach(S=>{if(S.id===t)return;const j=S.x,z=S.x+S.width,E=S.x+S.width/2,B=S.y,Z=S.y+S.height,q=S.y+S.height/2;if(_&&[j,z,E].forEach(H=>{Math.abs(N-H)<5&&(l=H-e,m.push({type:"vertical",pos:H}))}),b){const H=e+s;[j,z,E].forEach(U=>{Math.abs(w-U)<5&&(f=U,l=H-U,m.push({type:"vertical",pos:U}))})}if(O&&Math.abs(C-E)<5&&(f=E-s/2,m.push({type:"vertical",pos:E})),h&&[B,Z,q].forEach(H=>{Math.abs(g-H)<5&&(d=H-n,m.push({type:"horizontal",pos:H}))}),D){const H=n+r;[B,Z,q].forEach(U=>{Math.abs(c-U)<5&&(v=U,d=H-U,m.push({type:"horizontal",pos:U}))})}T&&Math.abs(p-q)<5&&(v=q-r/2,m.push({type:"horizontal",pos:q}))});const I=10;return l<I&&(b&&(f=e+s-I),l=I),d<I&&(D&&(v=n+r-I),d=I),{x:f,y:v,width:l,height:d,lines:m}},pn=(t,e,n,s,r,i,o,a)=>{let l=.5,d=.5;i.includes("n")&&(d=1),i.includes("s")&&(d=0),i.includes("e")&&(l=0),i.includes("w")&&(l=1);const f=r*Math.PI/180,v=Math.cos(f),m=Math.sin(f),w=t+n/2,N=e+s/2,C=n*l-n/2,c=s*d-s/2,g=w+(C*v-c*m),p=N+(C*m+c*v),b=Math.cos(-f),_=Math.sin(-f),D=o*b-a*_,h=o*_+a*b;let O=0,T=0;i.includes("e")&&(O=D),i.includes("w")&&(O=-D),i.includes("s")&&(T=h),i.includes("n")&&(T=-h);const I=Math.max(10,n+O),S=Math.max(10,s+T),j=I*l-I/2,z=S*d-S/2,E=j*v-z*m,B=j*m+z*v,Z=g-E,q=p-B,H=Z-I/2,U=q-S/2;return{x:H,y:U,width:I,height:S}},rr=({id:t,children:e,className:n="",style:s,draggable:r,resizable:i,rotatable:o,selectable:a,rotationSnap:l,showDragHandle:d,doubleClickToEdit:f,...v})=>{const m=M(x=>x.nodes[t]),w=M(x=>x.config),N=M(x=>x.config.viewOnly||a===!1?!1:x.selectedIds?.includes(t)),C=M(x=>x.camera.zoom),c=We(),g=M(x=>x.selectNode),p=M(x=>x.updateNode),b=k.useRef(null),[_,D]=k.useState([]),[h,O]=k.useState(!1),T=k.useRef(!1);k.useEffect(()=>{N||(D([]),O(!1))},[N]);const I=k.useRef(m);k.useEffect(()=>{I.current=m},[m]);const S=!w.viewOnly,j=(x,R)=>x!==void 0?x:R!==void 0?R:!0,z=S&&j(r,m?.draggable),E=S&&j(i,m?.resizable),B=S&&j(o,m?.rotatable),Z=S&&a!==!1,q=S&&z&&d!==!1,H=f!==void 0?f:m?.doubleClickToEdit??m?.data?.doubleClickToEdit??!1,U=()=>typeof l=="number"?l:l===!1?0:l===!0?w.rotationSnap||15:w.rotationSnap||0,de=Ne({onDragStart:({event:x})=>{if(!S)return;const R=x.target;R.closest(".ce-resize-handle")||R.closest(".ce-rotate-handle")||h&&!R.closest(".ce-drag-handle-minimal")||Z&&!N&&g(t)},onDrag:({movement:[x,R],first:K,memo:L,event:ne})=>{if(!S||!z)return;const F=ne.target;if(F.closest(".ce-resize-handle")||F.closest(".ce-rotate-handle")||h&&!F.closest(".ce-drag-handle-minimal")||T.current||(ne&&ne.stopPropagation(),!m))return;if(K)return{x:m.x,y:m.y};const P=c.getState().nodes,Q=L?.x??m.x,oe=L?.y??m.y;let fe=Q+x/C,ie=oe+R/C;if(w.snapping){const le=fn(t,fe,ie,m.width,m.height,P);fe=le.x,ie=le.y,w.snapGuide&&D(le.lines)}if(w.isLimited){const le=(w.width||1920)-m.width,ur=(w.height||1080)-m.height;fe=Math.max(0,Math.min(fe,le)),ie=Math.max(0,Math.min(ie,ur))}return b.current&&(b.current.style.transform=`translate(${fe}px, ${ie}px) rotate(${m.rotation}deg)`),{x:Q,y:oe,finalX:fe,finalY:ie}},onDragEnd:({memo:x,event:R})=>{R&&R.stopPropagation(),D([]),x&&typeof x.finalX=="number"&&p(t,{x:x.finalX,y:x.finalY})}},{drag:{filterTaps:!0,threshold:3,enabled:S}}),re=k.useCallback(()=>{T.current=!0;const x=I.current;return x?{x:x.x,y:x.y,w:x.width,h:x.height,r:x.rotation||0}:{x:0,y:0,w:0,h:0,r:0}},[]),u=k.useCallback((x,R,K,L)=>{if(!b.current)return;const ne=c.getState().nodes,F=pn(L.x,L.y,L.w,L.h,L.r,x,R/C,K/C);let P={x:F.x,y:F.y,width:F.width,height:F.height,lines:[]};if(w.snapping?P=hn(t,F.x,F.y,F.width,F.height,x,ne):P={...F,lines:[]},w.isLimited){const Q=w.width||1920,oe=w.height||1080;P.x<0&&(P.width+=P.x,P.x=0),P.y<0&&(P.height+=P.y,P.y=0),P.x+P.width>Q&&(P.width=Q-P.x),P.y+P.height>oe&&(P.height=oe-P.y)}w.snapGuide&&D(P.lines),b.current.style.width=`${P.width}px`,b.current.style.height=`${P.height}px`,b.current.style.transform=`translate(${P.x}px, ${P.y}px) rotate(${L.r}deg)`},[t,C,w,c]),A=k.useCallback((x,R,K,L)=>{const ne=c.getState().nodes,F=pn(L.x,L.y,L.w,L.h,L.r,x,R/C,K/C);let P={...F};if(w.snapping&&(P=hn(t,F.x,F.y,F.width,F.height,x,ne)),w.isLimited){const Q=w.width||1920,oe=w.height||1080;P.x<0&&(P.width+=P.x,P.x=0),P.y<0&&(P.height+=P.y,P.y=0),P.x+P.width>Q&&(P.width=Q-P.x),P.y+P.height>oe&&(P.height=oe-P.y)}p(t,{x:P.x,y:P.y,width:P.width,height:P.height}),D([]),setTimeout(()=>{T.current=!1},100)},[t,C,p,w,c]),V=k.useCallback((x,R)=>{T.current=!0;const K=I.current;if(!K||!b.current)return{startRotation:0,startAngle:0};const L=b.current.getBoundingClientRect(),ne=L.left+L.width/2,F=L.top+L.height/2;let Q=Math.atan2(R-F,x-ne)*(180/Math.PI);return Q+=90,{startRotation:K.rotation,startAngle:Q}},[]),W=k.useCallback((x,R,K)=>{if(!b.current||!I.current)return;const L=b.current.getBoundingClientRect(),ne=L.left+L.width/2,F=L.top+L.height/2;let Q=Math.atan2(R-F,x-ne)*(180/Math.PI);Q+=90;const oe=Q-K.startAngle,fe=w.rotationSpeed||1;let ie=K.startRotation+oe*fe;const le=U();le>0&&(ie=Math.round(ie/le)*le),b.current.style.transform=`translate(${I.current.x}px, ${I.current.y}px) rotate(${ie}deg)`,b.current.__tempRotation=ie},[w.rotationSpeed,U]),be=k.useCallback(()=>{const x=b.current.__tempRotation;typeof x=="number"&&(p(t,{rotation:x}),delete b.current.__tempRotation),setTimeout(()=>{T.current=!1},100)},[t,p]);return m?y.jsxs(y.Fragment,{children:[y.jsx(un,{lines:_}),y.jsxs("div",{ref:b,"data-node-id":t,className:`ce-element ${N?"ce-element--selected":""} ${n}`,style:{transform:`translate(${m.x}px, ${m.y}px) rotate(${m.rotation}deg)`,width:m.width,height:m.height,zIndex:N?100:1,"--ce-inverse-zoom":1/C,...s},...de(),...v,onClick:x=>{x.stopPropagation(),S&&Z&&g(t)},onDoubleClick:x=>{S&&H&&(x.stopPropagation(),O(!0))},children:[y.jsx("div",{style:{width:"100%",height:"100%",pointerEvents:H&&!h?"none":"auto"},children:e}),N&&S&&y.jsxs(y.Fragment,{children:[q&&y.jsx("div",{className:"ce-drag-handle-minimal",children:y.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[y.jsx("polyline",{points:"5 9 2 12 5 15"}),y.jsx("polyline",{points:"9 5 12 2 15 5"}),y.jsx("polyline",{points:"19 9 22 12 19 15"}),y.jsx("polyline",{points:"9 19 12 22 15 19"}),y.jsx("path",{d:"M2 12h20"}),y.jsx("path",{d:"M12 2v20"})]})}),E&&["nw","ne","sw","se","n","s","e","w"].map(x=>y.jsx(nr,{pos:x,onDragStart:re,onDragMove:u,onDragEnd:A},x)),w.rotation&&B&&y.jsx(sr,{onDragStart:V,onDragMove:W,onDragEnd:be})]})]})]}):null},mn=k.memo(rr),ir=({id:t,children:e,className:n="",style:s,draggable:r=!0,selectable:i=!0})=>{const o=M(_=>_.nodes[t]),a=M(_=>_.config),l=We(),d=M(_=>_.removeNode),f=M(_=>_.config.viewOnly||!i?!1:_.selectedIds?.includes(t)),v=M(_=>_.camera.zoom),m=M(_=>_.selectNode),w=M(_=>_.updateNode),N=k.useRef(null),[C,c]=k.useState([]);if(k.useEffect(()=>{f||c([])},[f]),k.useEffect(()=>{if(!N.current)return;const _=new ResizeObserver(D=>{for(const h of D){const{width:O,height:T}=h.contentRect;o&&(Math.abs(o.width-O)>1||Math.abs(o.height-T)>1)&&w(t,{width:O,height:T})}});return _.observe(N.current),()=>_.disconnect()},[t,o?.width,o?.height,w]),!o)return null;const g=!a.viewOnly,p=g&&r&&o.draggable!==!1,b=Ne({onDragStart:({event:_})=>{if(!g)return;const D=_.target;D.tagName==="INPUT"||D.tagName==="TEXTAREA"||i&&!f&&m(t)},onDrag:({movement:[_,D],first:h,memo:O,event:T})=>{if(!p)return;if(T&&T.stopPropagation(),h)return{x:o.x,y:o.y};const I=l.getState().nodes,S=O?.x??o.x,j=O?.y??o.y;let z=S+_/v,E=j+D/v;if(a.snapping){const B=fn(t,z,E,o.width,o.height,I);z=B.x,E=B.y,a.snapGuide&&c(B.lines)}return w(t,{x:z,y:E}),N.current&&(N.current.style.transform=`translate(${z}px, ${E}px)`),{x:S,y:j,finalX:z,finalY:E}},onDragEnd:({event:_})=>{_&&_.stopPropagation(),c([])}},{drag:{filterTaps:!0,threshold:3,enabled:p}});return y.jsxs(y.Fragment,{children:[a.snapGuide&&y.jsx(un,{lines:C}),y.jsxs("div",{ref:N,"data-node-id":t,className:`ce-element ce-workflow-node ${f?"ce-element--selected":""} ${n}`,style:{position:"absolute",left:0,top:0,width:"max-content",transform:`translate(${o.x}px, ${o.y}px)`,zIndex:f?10:1,cursor:p?"grab":"default",touchAction:"none",...s},...b(),onClick:_=>{_.stopPropagation(),g&&i&&m(t)},children:[o.customCss&&y.jsx("style",{children:`
9
+ Please add \`${r}Action\` when creating your handler.`);return}const i=n+"Start",a=n+"End",l=d=>{let f;return d.first&&i in e&&e[i](d),n in e&&(f=e[n](d)),d.last&&a in e&&e[a](d),f};s[r]=l,o[r]=o[r]||{}}function es(t,e){const[n,r,s]=Qr(t),o={};return _e(s,n,"onDrag","drag",o,e),_e(s,n,"onWheel","wheel",o,e),_e(s,n,"onScroll","scroll",o,e),_e(s,n,"onPinch","pinch",o,e),_e(s,n,"onMove","move",o,e),_e(s,n,"onHover","hover",o,e),{handlers:o,config:e,nativeHandlers:r}}function ts(t,e={},n,r){const s=I.useMemo(()=>new qr(t),[]);if(s.applyHandlers(t,r),s.applyConfig(e,n),I.useEffect(s.effect.bind(s)),I.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function ns(t){return t.forEach(Rr),function(n,r){const{handlers:s,nativeHandlers:o,config:i}=es(n,r||{});return ts(s,i,void 0,o)}}function Ne(t,e){return ns([Lr,Hr,Vr,Fr,Yr,$r])(t,e||{})}const rs=({pos:t,onDragStart:e,onDragMove:n,onDragEnd:r,className:s="",style:o})=>{const i=Ne({onDrag:({first:a,movement:[l,d],memo:f,event:_})=>(_.stopPropagation(),a?e():(f&&n(t,l,d,f),f)),onDragEnd:({movement:[a,l],memo:d,event:f})=>{f.stopPropagation(),d&&r(t,a,l,d)}},{drag:{filterTaps:!0,threshold:0}});return y.jsx("div",{className:`ce-resize-handle ce-resize-handle--${t} ${s}`,style:{touchAction:"none",...o},...i()})},ss=({onDragStart:t,onDragMove:e,onDragEnd:n,className:r="",style:s})=>{const o=Ne({onDrag:({first:i,movement:[a,l],memo:d,event:f})=>(f.stopPropagation(),i?t(a,l):(d&&e(a,l,d),d)),onDragEnd:({movement:[i,a],memo:l,event:d})=>{d.stopPropagation(),l&&n(i,a,l)}},{drag:{filterTaps:!0,threshold:0}});return y.jsx("div",{className:`ce-rotate-handle ${r}`,style:{touchAction:"none",...s},...o(),children:y.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:y.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})})},dn=({lines:t,className:e="",style:n})=>t.length?y.jsx(y.Fragment,{children:t.map((r,s)=>y.jsx("div",{className:`ce-snap-guide ce-snap-guide--${r.type} ${e}`,style:{left:r.type==="vertical"?r.pos:0,top:r.type==="horizontal"?r.pos:0,...n}},s))}):null,fn=5,hn=(t,e,n,r,s,o)=>{let i=e,a=n;const l=[],d=[e,e+r/2,e+r],f=[n,n+s/2,n+s];return Object.values(o).forEach(_=>{if(_.id===t)return;const m=[_.x,_.x+_.width/2,_.x+_.width];d.forEach((N,C)=>{m.forEach(c=>{Math.abs(N-c)<fn&&(C===0&&(i=c),C===1&&(i=c-r/2),C===2&&(i=c-r),l.push({type:"vertical",pos:c}))})});const w=[_.y,_.y+_.height/2,_.y+_.height];f.forEach((N,C)=>{w.forEach(c=>{Math.abs(N-c)<fn&&(C===0&&(a=c),C===1&&(a=c-s/2),C===2&&(a=c-s),l.push({type:"horizontal",pos:c}))})})}),{x:i,y:a,lines:l}},pn=(t,e,n,r,s,o,i)=>{let l=r,d=s,f=e,_=n;const m=[],w=e,N=e+r,C=e+r/2,c=n,g=n+s,p=n+s/2,b=o.includes("w"),v=o.includes("e"),D=o.includes("n"),h=o.includes("s"),O=o==="n"||o==="s",T=o==="e"||o==="w";Object.values(i).forEach(S=>{if(S.id===t)return;const j=S.x,R=S.x+S.width,x=S.x+S.width/2,B=S.y,Z=S.y+S.height,q=S.y+S.height/2;if(v&&[j,R,x].forEach(Y=>{Math.abs(N-Y)<5&&(l=Y-e,m.push({type:"vertical",pos:Y}))}),b){const Y=e+r;[j,R,x].forEach(U=>{Math.abs(w-U)<5&&(f=U,l=Y-U,m.push({type:"vertical",pos:U}))})}if(O&&Math.abs(C-x)<5&&(f=x-r/2,m.push({type:"vertical",pos:x})),h&&[B,Z,q].forEach(Y=>{Math.abs(g-Y)<5&&(d=Y-n,m.push({type:"horizontal",pos:Y}))}),D){const Y=n+s;[B,Z,q].forEach(U=>{Math.abs(c-U)<5&&(_=U,d=Y-U,m.push({type:"horizontal",pos:U}))})}T&&Math.abs(p-q)<5&&(_=q-s/2,m.push({type:"horizontal",pos:q}))});const k=10;return l<k&&(b&&(f=e+r-k),l=k),d<k&&(D&&(_=n+s-k),d=k),{x:f,y:_,width:l,height:d,lines:m}},mn=(t,e,n,r,s,o,i,a)=>{let l=.5,d=.5;o.includes("n")&&(d=1),o.includes("s")&&(d=0),o.includes("e")&&(l=0),o.includes("w")&&(l=1);const f=s*Math.PI/180,_=Math.cos(f),m=Math.sin(f),w=t+n/2,N=e+r/2,C=n*l-n/2,c=r*d-r/2,g=w+(C*_-c*m),p=N+(C*m+c*_),b=Math.cos(-f),v=Math.sin(-f),D=i*b-a*v,h=i*v+a*b;let O=0,T=0;o.includes("e")&&(O=D),o.includes("w")&&(O=-D),o.includes("s")&&(T=h),o.includes("n")&&(T=-h);const k=Math.max(10,n+O),S=Math.max(10,r+T),j=k*l-k/2,R=S*d-S/2,x=j*_-R*m,B=j*m+R*_,Z=g-x,q=p-B,Y=Z-k/2,U=q-S/2;return{x:Y,y:U,width:k,height:S}},os=({id:t,children:e,className:n="",style:r,draggable:s,resizable:o,rotatable:i,selectable:a,rotationSnap:l,showDragHandle:d,doubleClickToEdit:f,..._})=>{const m=z(E=>E.nodes[t]),w=z(E=>E.config),N=z(E=>E.config.viewOnly||a===!1?!1:E.selectedIds?.includes(t)),C=z(E=>E.camera.zoom),c=We(),g=z(E=>E.selectNode),p=z(E=>E.updateNode),b=I.useRef(null),[v,D]=I.useState([]),[h,O]=I.useState(!1),T=I.useRef(!1);I.useEffect(()=>{N||(D([]),O(!1))},[N]);const k=I.useRef(m);I.useEffect(()=>{k.current=m},[m]);const S=!w.viewOnly,j=(E,M)=>E!==void 0?E:M!==void 0?M:!0,R=S&&j(s,m?.draggable),x=S&&j(o,m?.resizable),B=S&&j(i,m?.rotatable),Z=S&&a!==!1,q=S&&R&&d!==!1,Y=f!==void 0?f:m?.doubleClickToEdit??m?.data?.doubleClickToEdit??!1,U=()=>typeof l=="number"?l:l===!1?0:l===!0?w.rotationSnap||15:w.rotationSnap||0,de=Ne({onDragStart:({event:E})=>{if(!S)return;const M=E.target;M.closest(".ce-resize-handle")||M.closest(".ce-rotate-handle")||h&&!M.closest(".ce-drag-handle-minimal")||Z&&!N&&g(t)},onDrag:({movement:[E,M],first:K,memo:L,event:ne})=>{if(!S||!R)return;const F=ne.target;if(F.closest(".ce-resize-handle")||F.closest(".ce-rotate-handle")||h&&!F.closest(".ce-drag-handle-minimal")||T.current||(ne&&ne.stopPropagation(),!m))return;if(K)return{x:m.x,y:m.y};const P=c.getState().nodes,Q=L?.x??m.x,ie=L?.y??m.y;let fe=Q+E/C,oe=ie+M/C;if(w.snapping){const le=hn(t,fe,oe,m.width,m.height,P);fe=le.x,oe=le.y,w.snapGuide&&D(le.lines)}if(w.isLimited){const le=(w.width||1920)-m.width,ds=(w.height||1080)-m.height;fe=Math.max(0,Math.min(fe,le)),oe=Math.max(0,Math.min(oe,ds))}return b.current&&(b.current.style.transform=`translate(${fe}px, ${oe}px) rotate(${m.rotation}deg)`),{x:Q,y:ie,finalX:fe,finalY:oe}},onDragEnd:({memo:E,event:M})=>{M&&M.stopPropagation(),D([]),E&&typeof E.finalX=="number"&&p(t,{x:E.finalX,y:E.finalY})}},{drag:{filterTaps:!0,threshold:3,enabled:S}}),se=I.useCallback(()=>{T.current=!0;const E=k.current;return E?{x:E.x,y:E.y,w:E.width,h:E.height,r:E.rotation||0}:{x:0,y:0,w:0,h:0,r:0}},[]),u=I.useCallback((E,M,K,L)=>{if(!b.current)return;const ne=c.getState().nodes,F=mn(L.x,L.y,L.w,L.h,L.r,E,M/C,K/C);let P={x:F.x,y:F.y,width:F.width,height:F.height,lines:[]};if(w.snapping?P=pn(t,F.x,F.y,F.width,F.height,E,ne):P={...F,lines:[]},w.isLimited){const Q=w.width||1920,ie=w.height||1080;P.x<0&&(P.width+=P.x,P.x=0),P.y<0&&(P.height+=P.y,P.y=0),P.x+P.width>Q&&(P.width=Q-P.x),P.y+P.height>ie&&(P.height=ie-P.y)}w.snapGuide&&D(P.lines),b.current.style.width=`${P.width}px`,b.current.style.height=`${P.height}px`,b.current.style.transform=`translate(${P.x}px, ${P.y}px) rotate(${L.r}deg)`},[t,C,w,c]),A=I.useCallback((E,M,K,L)=>{const ne=c.getState().nodes,F=mn(L.x,L.y,L.w,L.h,L.r,E,M/C,K/C);let P={...F};if(w.snapping&&(P=pn(t,F.x,F.y,F.width,F.height,E,ne)),w.isLimited){const Q=w.width||1920,ie=w.height||1080;P.x<0&&(P.width+=P.x,P.x=0),P.y<0&&(P.height+=P.y,P.y=0),P.x+P.width>Q&&(P.width=Q-P.x),P.y+P.height>ie&&(P.height=ie-P.y)}p(t,{x:P.x,y:P.y,width:P.width,height:P.height}),D([]),setTimeout(()=>{T.current=!1},100)},[t,C,p,w,c]),H=I.useCallback((E,M)=>{T.current=!0;const K=k.current;if(!K||!b.current)return{startRotation:0,startAngle:0};const L=b.current.getBoundingClientRect(),ne=L.left+L.width/2,F=L.top+L.height/2;let Q=Math.atan2(M-F,E-ne)*(180/Math.PI);return Q+=90,{startRotation:K.rotation,startAngle:Q}},[]),W=I.useCallback((E,M,K)=>{if(!b.current||!k.current)return;const L=b.current.getBoundingClientRect(),ne=L.left+L.width/2,F=L.top+L.height/2;let Q=Math.atan2(M-F,E-ne)*(180/Math.PI);Q+=90;const ie=Q-K.startAngle,fe=w.rotationSpeed||1;let oe=K.startRotation+ie*fe;const le=U();le>0&&(oe=Math.round(oe/le)*le),b.current.style.transform=`translate(${k.current.x}px, ${k.current.y}px) rotate(${oe}deg)`,b.current.__tempRotation=oe},[w.rotationSpeed,U]),be=I.useCallback(()=>{const E=b.current.__tempRotation;typeof E=="number"&&(p(t,{rotation:E}),delete b.current.__tempRotation),setTimeout(()=>{T.current=!1},100)},[t,p]);return m?y.jsxs(y.Fragment,{children:[y.jsx(dn,{lines:v}),y.jsxs("div",{ref:b,"data-node-id":t,className:`ce-element ${N?"ce-element--selected":""} ${n}`,style:{transform:`translate(${m.x}px, ${m.y}px) rotate(${m.rotation}deg)`,width:m.width,height:m.height,zIndex:N?100:1,"--ce-inverse-zoom":1/C,...r},...de(),..._,onClick:E=>{E.stopPropagation(),S&&Z&&g(t)},onDoubleClick:E=>{S&&Y&&(E.stopPropagation(),O(!0))},children:[y.jsx("div",{style:{width:"100%",height:"100%",pointerEvents:Y&&!h?"none":"auto"},children:e}),N&&S&&y.jsxs(y.Fragment,{children:[q&&y.jsx("div",{className:"ce-drag-handle-minimal",children:y.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[y.jsx("polyline",{points:"5 9 2 12 5 15"}),y.jsx("polyline",{points:"9 5 12 2 15 5"}),y.jsx("polyline",{points:"19 9 22 12 19 15"}),y.jsx("polyline",{points:"9 19 12 22 15 19"}),y.jsx("path",{d:"M2 12h20"}),y.jsx("path",{d:"M12 2v20"})]})}),x&&["nw","ne","sw","se","n","s","e","w"].map(E=>y.jsx(rs,{pos:E,onDragStart:se,onDragMove:u,onDragEnd:A},E)),w.rotation&&B&&y.jsx(ss,{onDragStart:H,onDragMove:W,onDragEnd:be})]})]})]}):null},gn=I.memo(os),is=({id:t,children:e,className:n="",style:r,draggable:s=!0,selectable:o=!0})=>{const i=z(v=>v.nodes[t]),a=z(v=>v.config),l=We(),d=z(v=>v.removeNode),f=z(v=>v.config.viewOnly||!o?!1:v.selectedIds?.includes(t)),_=z(v=>v.camera.zoom),m=z(v=>v.selectNode),w=z(v=>v.updateNode),N=I.useRef(null),[C,c]=I.useState([]);if(I.useEffect(()=>{f||c([])},[f]),I.useEffect(()=>{if(!N.current)return;const v=new ResizeObserver(D=>{for(const h of D){const{width:O,height:T}=h.contentRect;i&&(Math.abs(i.width-O)>1||Math.abs(i.height-T)>1)&&w(t,{width:O,height:T})}});return v.observe(N.current),()=>v.disconnect()},[t,i?.width,i?.height,w]),!i)return null;const g=!a.viewOnly,p=g&&s&&i.draggable!==!1,b=Ne({onDragStart:({event:v})=>{if(!g)return;const D=v.target;D.tagName==="INPUT"||D.tagName==="TEXTAREA"||o&&!f&&m(t)},onDrag:({movement:[v,D],first:h,memo:O,event:T})=>{if(!p)return;if(T&&T.stopPropagation(),h)return{x:i.x,y:i.y};const k=l.getState().nodes,S=O?.x??i.x,j=O?.y??i.y;let R=S+v/_,x=j+D/_;if(a.snapping){const B=hn(t,R,x,i.width,i.height,k);R=B.x,x=B.y,a.snapGuide&&c(B.lines)}return w(t,{x:R,y:x}),N.current&&(N.current.style.transform=`translate(${R}px, ${x}px)`),{x:S,y:j,finalX:R,finalY:x}},onDragEnd:({event:v})=>{v&&v.stopPropagation(),c([])}},{drag:{filterTaps:!0,threshold:3,enabled:p}});return y.jsxs(y.Fragment,{children:[a.snapGuide&&y.jsx(dn,{lines:C}),y.jsxs("div",{ref:N,"data-node-id":t,className:`ce-element ce-workflow-node ${f?"ce-element--selected":""} ${n}`,style:{position:"absolute",left:0,top:0,width:"max-content",transform:`translate(${i.x}px, ${i.y}px)`,zIndex:f?10:1,cursor:p?"grab":"default",touchAction:"none",...r},...b(),onClick:v=>{v.stopPropagation(),g&&o&&m(t)},children:[i.customCss&&y.jsx("style",{children:`
9
10
  [data-node-id="${t}"] {
10
- ${o.customCss}
11
+ ${i.customCss}
11
12
  }
12
- `}),y.jsx(Un,{id:t,children:e}),g&&!a.viewOnly&&y.jsx("button",{className:"ce-delete-node-btn",onPointerDown:_=>_.stopPropagation(),onClick:_=>{_.stopPropagation(),d(t)},title:"Remove Node",children:"×"})]})]})},gn=k.memo(ir),or=()=>{const t=M(c=>c.edges),e=M(c=>c.nodes),n=M(c=>c.connectionState),s=M(c=>c.selectNode),r=M(c=>c.selectedIds),i=M(c=>c.removeEdge),o=(c,g,p,b,_)=>{const D=1-c;return Math.pow(D,3)*g+3*Math.pow(D,2)*c*p+3*D*Math.pow(c,2)*b+Math.pow(c,3)*_},a=(c,g,p,b)=>{const _=Math.abs(p-c)/2,D=c+_,h=g,O=p-_;return`M ${c} ${g} C ${D} ${h}, ${O} ${b}, ${p} ${b}`},l=(c,g,p,b)=>`M ${c} ${g} L ${p} ${b}`,d=(c,g,p,b)=>{const _=(c+p)/2;return`M ${c} ${g} L ${_} ${g} L ${_} ${b} L ${p} ${b}`},f=(c,g,p,b,_)=>{switch(c){case"straight":return l(g,p,b,_);case"step":return d(g,p,b,_);default:return a(g,p,b,_)}},v=M(c=>c.camera),m=M(c=>c.dimensions),N=k.useMemo(()=>m.width===0||m.height===0?Object.values(t):Object.values(t).filter(c=>{const g=e[c.source],p=e[c.target];if(!g||!p)return!1;const b=Math.min(g.x,p.x),_=Math.max(g.x+g.width,p.x+p.width),D=Math.min(g.y,p.y),h=Math.max(g.y+g.height,p.y+p.height),O=v.zoom,T=b*O+v.x,I=_*O+v.x,S=D*O+v.y,j=h*O+v.y,z=100;return!(I<-z||T>m.width+z||j<-z||S>m.height+z)}),[t,e,v,m]).map(c=>{const g=e[c.source],p=e[c.target];if(!g||!p)return null;let b=g.x+g.width/2,_=g.y+g.height/2,D=p.x+p.width/2,h=p.y+p.height/2;if(g.handles&&c.sourceHandle&&g.handles[c.sourceHandle]){const E=g.handles[c.sourceHandle];typeof E.x=="number"&&typeof E.y=="number"&&E.x!==0?(b=g.x+E.x,_=g.y+E.y):E.position==="top"?(b=g.x+g.width/2,_=g.y):E.position==="bottom"?(b=g.x+g.width/2,_=g.y+g.height):E.position==="left"?(b=g.x,_=g.y+g.height/2):E.position==="right"&&(b=g.x+g.width,_=g.y+g.height/2)}if(p.handles&&c.targetHandle&&p.handles[c.targetHandle]){const E=p.handles[c.targetHandle];typeof E.x=="number"&&typeof E.y=="number"&&E.x!==0?(D=p.x+E.x,h=p.y+E.y):E.position==="top"?(D=p.x+p.width/2,h=p.y):E.position==="bottom"?(D=p.x+p.width/2,h=p.y+p.height):E.position==="left"?(D=p.x,h=p.y+p.height/2):E.position==="right"&&(D=p.x+p.width,h=p.y+p.height/2)}const O=f(c.type,b,_,D,h),T=r.includes(c.id),I=(b+D)/2,S=(_+h)/2;let j=I,z=S;if(!c.type||c.type==="default"){const E=Math.abs(D-b)/2;j=o(.5,b,b+E,D-E,D),z=o(.5,_,_,h,h)}return y.jsxs("g",{className:"ce-edge-group",style:{pointerEvents:"all"},children:[y.jsx("path",{d:O,stroke:"transparent",strokeWidth:"20",fill:"none",style:{cursor:"pointer"},onClick:E=>{E.stopPropagation(),s(c.id)}}),y.jsx("path",{d:O,stroke:T?"#3b82f6":"#b1b1b7",strokeWidth:T?"3":"2",fill:"none",markerEnd:"url(#arrow-closed)",style:{pointerEvents:"none"}}),y.jsx("foreignObject",{x:j-10,y:z-10,width:20,height:20,className:"ce-edge-delete-fo",style:{overflow:"visible"},children:y.jsx("button",{className:"ce-edge-delete-btn",onClick:E=>{E.stopPropagation(),i(c.id)},title:"Disconnect",style:{width:"20px",height:"20px",borderRadius:"50%",background:"#ff4d4f",color:"white",border:"1px solid white",padding:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",lineHeight:1,cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.2)"},children:"×"})})]},c.id)});let C=null;if(n.isValid&&n.nodeId&&n.position&&e[n.nodeId]){const c=e[n.nodeId];let g=c.x+c.width/2,p=c.y+c.height/2;if(n.handleId&&c.handles&&c.handles[n.handleId]){const h=c.handles[n.handleId];typeof h.x=="number"&&typeof h.y=="number"&&h.x!==0?(g=c.x+h.x,p=c.y+h.y):h.position==="top"?(g=c.x+c.width/2,p=c.y):h.position==="bottom"?(g=c.x+c.width/2,p=c.y+c.height):h.position==="left"?(g=c.x,p=c.y+c.height/2):h.position==="right"&&(g=c.x+c.width,p=c.y+c.height/2)}const b=n.position.x,_=n.position.y,D=a(g,p,b,_);C=y.jsx("path",{d:D,stroke:"#3b82f6",strokeWidth:"2",strokeDasharray:"5,5",fill:"none",markerEnd:"url(#arrow-closed)",className:"ce-connection-line"})}return y.jsxs("svg",{className:"ce-edge-layer",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"visible",zIndex:0},children:[y.jsx("defs",{children:y.jsx("marker",{id:"arrow-closed",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"#b1b1b7"})})}),N,N,C]})},ar=({children:t,grid:e,background:n,className:s="",style:r,canvasStyle:i})=>{const o=k.useRef(null),a=M(h=>h.camera),l=M(h=>h.config),d=M(h=>h.panCamera),f=M(h=>h.zoomCamera),v=M(h=>h.deselectAll),m=M(h=>h.deleteSelected),w=M(h=>h.setDimensions);k.useEffect(()=>{const h=I=>{I.ctrlKey&&I.preventDefault()},O=o.current;O&&O.addEventListener("wheel",h,{passive:!1});let T=null;return O&&(T=new ResizeObserver(I=>{for(const S of I){const{width:j,height:z}=S.contentRect;w(j,z)}}),T.observe(O)),()=>{O&&O.removeEventListener("wheel",h),T&&T.disconnect()}},[w]);const[N,C]=k.useState(!1);k.useEffect(()=>{const h=T=>{if(T.code==="Space"&&!T.repeat&&C(!0),(T.code==="Delete"||T.code==="Backspace")&&!l.viewOnly){const I=T.target;I.tagName!=="INPUT"&&I.tagName!=="TEXTAREA"&&m()}},O=T=>{T.code==="Space"&&C(!1)};return window.addEventListener("keydown",h),window.addEventListener("keyup",O),()=>{window.removeEventListener("keydown",h),window.removeEventListener("keyup",O)}},[m,l.viewOnly]),Ne({onDrag:({delta:[h,O],event:T})=>{const I=T.target,S=I.closest(".ce-element")||I.closest(".ce-resize-handle");(N||l.pan&&!S)&&d(h,O)},onWheel:({event:h,delta:[,O],ctrlKey:T})=>{if(T||h.metaKey){if(l.zoom){const I=o.current?.getBoundingClientRect();if(I){let S,j;!l.pan&&!N?(S=(I.width||window.innerWidth)/2,j=(I.height||window.innerHeight)/2):(S=h.clientX-I.left,j=h.clientY-I.top),f(1-O/500,S,j)}}}else d(-h.deltaX,-h.deltaY)}},{target:o,drag:{filterTaps:!0}});const c=M(h=>h.connectionState),g=M(h=>h.updateConnection),p=M(h=>h.endConnection),b=M(h=>h.addEdge);k.useEffect(()=>{if(!c.isValid)return;const h=T=>{if(!o.current)return;const I=o.current.getBoundingClientRect();let S=(T.clientX-I.left-a.x)/a.zoom,j=(T.clientY-I.top-a.y)/a.zoom;const E=document.elementFromPoint(T.clientX,T.clientY)?.closest(".ce-handle");if(document.querySelectorAll(".ce-handle--valid").forEach(B=>B.classList.remove("ce-handle--valid")),E&&c.nodeId){const B=E.closest("[data-node-id]")?.getAttribute("data-node-id"),Z=E.dataset.handleId,q=E.dataset.handleType,H=c.handleType,U=B===c.nodeId;if(B&&Z&&!U&&(H==="source"&&q==="target"||H==="target"&&q==="source")){E.classList.add("ce-handle--valid");const re=E.getBoundingClientRect();S=(re.left+re.width/2-I.left-a.x)/a.zoom,j=(re.top+re.height/2-I.top-a.y)/a.zoom}}g({x:S,y:j})},O=T=>{const S=document.elementFromPoint(T.clientX,T.clientY)?.closest(".ce-handle");if(S&&c.nodeId){const j=S.closest("[data-node-id]")?.getAttribute("data-node-id"),z=S.dataset.handleId,E=S.dataset.handleType,B=c.handleType,Z=j===c.nodeId;if(j&&z&&!Z&&(B==="source"&&E==="target"||B==="target"&&E==="source")){let H=c.nodeId,U=c.handleId||void 0,de=j,re=z;B==="target"&&E==="source"&&(H=j,U=z,de=c.nodeId,re=c.handleId||void 0),b({id:`e-${Date.now()}`,source:H,sourceHandle:U||void 0,target:de,targetHandle:re})}}document.querySelectorAll(".ce-handle--valid").forEach(j=>j.classList.remove("ce-handle--valid")),p()};return window.addEventListener("pointermove",h),window.addEventListener("pointerup",O),()=>{window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",O),document.querySelectorAll(".ce-handle--valid").forEach(T=>T.classList.remove("ce-handle--valid"))}},[c.isValid,a,g,p,b,c.nodeId,c.handleType,c.handleId]);const _=()=>{l.viewOnly||v()},D=l.isLimited?{touchAction:"none",cursor:N?"grab":"default"}:{...r,touchAction:"none",cursor:N?"grab":"default"};return y.jsxs("div",{ref:o,className:`ce-editor__viewport ${N?"ce-editor__viewport--panning":""} ${s} ${l.viewOnly?"ce-editor--view-only":""} ${c.isValid?"ce-editor--connecting":""}`,style:D,onClick:_,children:[n,y.jsxs("div",{className:"ce-editor__canvas",style:{transform:`translate(${a.x}px, ${a.y}px) scale(${a.zoom})`,...i},children:[l.showGrid&&y.jsx("div",{className:"ce-editor__grid-layer",children:e||y.jsxs("svg",{width:"100%",height:"100%",children:[y.jsx("defs",{children:y.jsx("pattern",{id:"default-grid",width:l.gridSize,height:l.gridSize,patternUnits:"userSpaceOnUse",children:y.jsx("circle",{cx:"1",cy:"1",r:"1",fill:l.gridColor||"#ccc"})})}),y.jsx("rect",{width:"100%",height:"100%",fill:"url(#default-grid)"})]})}),y.jsx(or,{}),l.isLimited?y.jsx("div",{className:"ce-editor__content-area",style:{width:l.width||1920,height:l.height||1080,...r},children:t}):y.jsx("div",{className:"ce-editor__infinite-area",children:t})]})]})},cr={default:Xe,input:$t,output:Ht,workflow:Xe},lr=({nodeTypes:t={}})=>{const e=M(o=>o.nodes),n=M(o=>o.camera),s=M(o=>o.dimensions),r=k.useMemo(()=>({...cr,...t}),[t]),i=k.useMemo(()=>{if(s.width<=0||s.height<=0)return Object.values(e);const o=100;return Object.values(e).filter(a=>{const l=n.zoom,d=a.x*l+n.x,f=a.y*l+n.y,v=a.width*l,m=a.height*l;return!(d+v<-o||d>s.width+o||f+m<-o||f>s.height+o)})},[e,n,s]);return y.jsx(y.Fragment,{children:i.map(o=>{const a=r[o.type||"default"]||Xe;return o.type==="custom"||o.type==="design"||o.resizable||o.rotatable?y.jsx(mn,{id:o.id,draggable:o.draggable,resizable:o.resizable,rotatable:o.rotatable,children:y.jsx(a,{style:o.style,className:o.className,data:o.data,id:o.id})},o.id):y.jsx(gn,{id:o.id,draggable:o.draggable,className:o.className,style:o.style,children:y.jsx(a,{data:o.data,id:o.id})},o.id)})})};G.Canvas=ar,G.DefaultNode=Xe,G.Editor=Fn,G.ElementWrapper=mn,G.Handle=Pe,G.InputNode=$t,G.NodeLayer=lr,G.OutputNode=Ht,G.WorkflowNodeWrapper=gn,G.useEditor=M,G.useEditorStoreApi=We,Object.defineProperty(G,Symbol.toStringTag,{value:"Module"})}));
13
+ `}),y.jsx(Bn,{id:t,children:e}),g&&!a.viewOnly&&y.jsx("button",{className:"ce-delete-node-btn",onPointerDown:v=>v.stopPropagation(),onClick:v=>{v.stopPropagation(),d(t)},title:"Remove Node",children:"×"})]})]})},yn=I.memo(is),as=()=>{const t=z(c=>c.edges),e=z(c=>c.nodes),n=z(c=>c.connectionState),r=z(c=>c.selectNode),s=z(c=>c.selectedIds),o=z(c=>c.removeEdge),i=(c,g,p,b,v)=>{const D=1-c;return Math.pow(D,3)*g+3*Math.pow(D,2)*c*p+3*D*Math.pow(c,2)*b+Math.pow(c,3)*v},a=(c,g,p,b)=>{const v=Math.abs(p-c)/2,D=c+v,h=g,O=p-v;return`M ${c} ${g} C ${D} ${h}, ${O} ${b}, ${p} ${b}`},l=(c,g,p,b)=>`M ${c} ${g} L ${p} ${b}`,d=(c,g,p,b)=>{const v=(c+p)/2;return`M ${c} ${g} L ${v} ${g} L ${v} ${b} L ${p} ${b}`},f=(c,g,p,b,v)=>{switch(c){case"straight":return l(g,p,b,v);case"step":return d(g,p,b,v);default:return a(g,p,b,v)}},_=z(c=>c.camera),m=z(c=>c.dimensions),N=I.useMemo(()=>m.width===0||m.height===0?Object.values(t):Object.values(t).filter(c=>{const g=e[c.source],p=e[c.target];if(!g||!p)return!1;const b=Math.min(g.x,p.x),v=Math.max(g.x+g.width,p.x+p.width),D=Math.min(g.y,p.y),h=Math.max(g.y+g.height,p.y+p.height),O=_.zoom,T=b*O+_.x,k=v*O+_.x,S=D*O+_.y,j=h*O+_.y,R=100;return!(k<-R||T>m.width+R||j<-R||S>m.height+R)}),[t,e,_,m]).map(c=>{const g=e[c.source],p=e[c.target];if(!g||!p)return null;let b=g.x+g.width/2,v=g.y+g.height/2,D=p.x+p.width/2,h=p.y+p.height/2;if(g.handles&&c.sourceHandle&&g.handles[c.sourceHandle]){const x=g.handles[c.sourceHandle];typeof x.x=="number"&&typeof x.y=="number"&&x.x!==0?(b=g.x+x.x,v=g.y+x.y):x.position==="top"?(b=g.x+g.width/2,v=g.y):x.position==="bottom"?(b=g.x+g.width/2,v=g.y+g.height):x.position==="left"?(b=g.x,v=g.y+g.height/2):x.position==="right"&&(b=g.x+g.width,v=g.y+g.height/2)}if(p.handles&&c.targetHandle&&p.handles[c.targetHandle]){const x=p.handles[c.targetHandle];typeof x.x=="number"&&typeof x.y=="number"&&x.x!==0?(D=p.x+x.x,h=p.y+x.y):x.position==="top"?(D=p.x+p.width/2,h=p.y):x.position==="bottom"?(D=p.x+p.width/2,h=p.y+p.height):x.position==="left"?(D=p.x,h=p.y+p.height/2):x.position==="right"&&(D=p.x+p.width,h=p.y+p.height/2)}const O=f(c.type,b,v,D,h),T=s.includes(c.id),k=(b+D)/2,S=(v+h)/2;let j=k,R=S;if(!c.type||c.type==="default"){const x=Math.abs(D-b)/2;j=i(.5,b,b+x,D-x,D),R=i(.5,v,v,h,h)}return y.jsxs("g",{className:"ce-edge-group",style:{pointerEvents:"all"},children:[y.jsx("path",{d:O,stroke:"transparent",strokeWidth:"20",fill:"none",style:{cursor:"pointer"},onClick:x=>{x.stopPropagation(),r(c.id)}}),y.jsx("path",{d:O,stroke:T?"#3b82f6":"#b1b1b7",strokeWidth:T?"3":"2",fill:"none",markerEnd:"url(#arrow-closed)",style:{pointerEvents:"none"}}),y.jsx("foreignObject",{x:j-10,y:R-10,width:20,height:20,className:"ce-edge-delete-fo",style:{overflow:"visible"},children:y.jsx("button",{className:"ce-edge-delete-btn",onClick:x=>{x.stopPropagation(),o(c.id)},title:"Disconnect",style:{width:"20px",height:"20px",borderRadius:"50%",background:"#ff4d4f",color:"white",border:"1px solid white",padding:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",lineHeight:1,cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.2)"},children:"×"})})]},c.id)});let C=null;if(n.isValid&&n.nodeId&&n.position&&e[n.nodeId]){const c=e[n.nodeId];let g=c.x+c.width/2,p=c.y+c.height/2;if(n.handleId&&c.handles&&c.handles[n.handleId]){const h=c.handles[n.handleId];typeof h.x=="number"&&typeof h.y=="number"&&h.x!==0?(g=c.x+h.x,p=c.y+h.y):h.position==="top"?(g=c.x+c.width/2,p=c.y):h.position==="bottom"?(g=c.x+c.width/2,p=c.y+c.height):h.position==="left"?(g=c.x,p=c.y+c.height/2):h.position==="right"&&(g=c.x+c.width,p=c.y+c.height/2)}const b=n.position.x,v=n.position.y,D=a(g,p,b,v);C=y.jsx("path",{d:D,stroke:"#3b82f6",strokeWidth:"2",strokeDasharray:"5,5",fill:"none",markerEnd:"url(#arrow-closed)",className:"ce-connection-line"})}return y.jsxs("svg",{className:"ce-edge-layer",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"visible",zIndex:0},children:[y.jsx("defs",{children:y.jsx("marker",{id:"arrow-closed",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"#b1b1b7"})})}),N,N,C]})},cs=({children:t,grid:e,background:n,className:r="",style:s,canvasStyle:o})=>{const i=I.useRef(null),a=z(h=>h.camera),l=z(h=>h.config),d=z(h=>h.panCamera),f=z(h=>h.zoomCamera),_=z(h=>h.deselectAll),m=z(h=>h.deleteSelected),w=z(h=>h.setDimensions);I.useEffect(()=>{const h=k=>{k.ctrlKey&&k.preventDefault()},O=i.current;O&&O.addEventListener("wheel",h,{passive:!1});let T=null;return O&&(T=new ResizeObserver(k=>{for(const S of k){const{width:j,height:R}=S.contentRect;w(j,R)}}),T.observe(O)),()=>{O&&O.removeEventListener("wheel",h),T&&T.disconnect()}},[w]);const[N,C]=I.useState(!1);I.useEffect(()=>{const h=T=>{if(T.code==="Space"&&!T.repeat&&C(!0),(T.code==="Delete"||T.code==="Backspace")&&!l.viewOnly){const k=T.target;k.tagName!=="INPUT"&&k.tagName!=="TEXTAREA"&&m()}},O=T=>{T.code==="Space"&&C(!1)};return window.addEventListener("keydown",h),window.addEventListener("keyup",O),()=>{window.removeEventListener("keydown",h),window.removeEventListener("keyup",O)}},[m,l.viewOnly]),Ne({onDrag:({delta:[h,O],event:T})=>{const k=T.target,S=k.closest(".ce-element")||k.closest(".ce-resize-handle");(N||l.pan&&!S)&&d(h,O)},onWheel:({event:h,delta:[,O],ctrlKey:T})=>{if(T||h.metaKey){if(l.zoom){const k=i.current?.getBoundingClientRect();if(k){let S,j;!l.pan&&!N?(S=(k.width||window.innerWidth)/2,j=(k.height||window.innerHeight)/2):(S=h.clientX-k.left,j=h.clientY-k.top),f(1-O/500,S,j)}}}else d(-h.deltaX,-h.deltaY)}},{target:i,drag:{filterTaps:!0}});const c=z(h=>h.connectionState),g=z(h=>h.updateConnection),p=z(h=>h.endConnection),b=z(h=>h.addEdge);I.useEffect(()=>{if(!c.isValid)return;const h=T=>{if(!i.current)return;const k=i.current.getBoundingClientRect();let S=(T.clientX-k.left-a.x)/a.zoom,j=(T.clientY-k.top-a.y)/a.zoom;const x=document.elementFromPoint(T.clientX,T.clientY)?.closest(".ce-handle");if(document.querySelectorAll(".ce-handle--valid").forEach(B=>B.classList.remove("ce-handle--valid")),x&&c.nodeId){const B=x.closest("[data-node-id]")?.getAttribute("data-node-id"),Z=x.dataset.handleId,q=x.dataset.handleType,Y=c.handleType,U=B===c.nodeId;if(B&&Z&&!U&&(Y==="source"&&q==="target"||Y==="target"&&q==="source")){x.classList.add("ce-handle--valid");const se=x.getBoundingClientRect();S=(se.left+se.width/2-k.left-a.x)/a.zoom,j=(se.top+se.height/2-k.top-a.y)/a.zoom}}g({x:S,y:j})},O=T=>{const S=document.elementFromPoint(T.clientX,T.clientY)?.closest(".ce-handle");if(S&&c.nodeId){const j=S.closest("[data-node-id]")?.getAttribute("data-node-id"),R=S.dataset.handleId,x=S.dataset.handleType,B=c.handleType,Z=j===c.nodeId;if(j&&R&&!Z&&(B==="source"&&x==="target"||B==="target"&&x==="source")){let Y=c.nodeId,U=c.handleId||void 0,de=j,se=R;B==="target"&&x==="source"&&(Y=j,U=R,de=c.nodeId,se=c.handleId||void 0),b({id:`e-${Date.now()}`,source:Y,sourceHandle:U||void 0,target:de,targetHandle:se})}}document.querySelectorAll(".ce-handle--valid").forEach(j=>j.classList.remove("ce-handle--valid")),p()};return window.addEventListener("pointermove",h),window.addEventListener("pointerup",O),()=>{window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",O),document.querySelectorAll(".ce-handle--valid").forEach(T=>T.classList.remove("ce-handle--valid"))}},[c.isValid,a,g,p,b,c.nodeId,c.handleType,c.handleId]);const v=()=>{l.viewOnly||_()},D=l.isLimited?{touchAction:"none",cursor:N?"grab":"default"}:{...s,touchAction:"none",cursor:N?"grab":"default"};return y.jsxs("div",{ref:i,className:`ce-editor__viewport ${N?"ce-editor__viewport--panning":""} ${r} ${l.viewOnly?"ce-editor--view-only":""} ${c.isValid?"ce-editor--connecting":""}`,style:D,onClick:v,children:[n,y.jsxs("div",{className:"ce-editor__canvas",style:{transform:`translate(${a.x}px, ${a.y}px) scale(${a.zoom})`,...o},children:[l.showGrid&&y.jsx("div",{className:"ce-editor__grid-layer",children:e||y.jsxs("svg",{width:"100%",height:"100%",children:[y.jsx("defs",{children:y.jsx("pattern",{id:"default-grid",width:l.gridSize,height:l.gridSize,patternUnits:"userSpaceOnUse",children:y.jsx("circle",{cx:"1",cy:"1",r:"1",fill:l.gridColor||"#ccc"})})}),y.jsx("rect",{width:"100%",height:"100%",fill:"url(#default-grid)"})]})}),y.jsx(as,{}),l.isLimited?y.jsx("div",{className:"ce-editor__content-area",style:{width:l.width||1920,height:l.height||1080,...s},children:t}):y.jsx("div",{className:"ce-editor__infinite-area",children:t})]})]})},ls={default:Xe,input:Yt,output:Ht,workflow:Xe},us=({nodeTypes:t={}})=>{const e=z(i=>i.nodes),n=z(i=>i.camera),r=z(i=>i.dimensions),s=I.useMemo(()=>({...ls,...t}),[t]),o=I.useMemo(()=>{if(r.width<=0||r.height<=0)return Object.values(e);const i=100;return Object.values(e).filter(a=>{const l=n.zoom,d=a.x*l+n.x,f=a.y*l+n.y,_=a.width*l,m=a.height*l;return!(d+_<-i||d>r.width+i||f+m<-i||f>r.height+i)})},[e,n,r]);return y.jsx(y.Fragment,{children:o.map(i=>{const a=s[i.type||"default"]||Xe;return i.type==="custom"||i.type==="design"||i.resizable||i.rotatable?y.jsx(gn,{id:i.id,draggable:i.draggable,resizable:i.resizable,rotatable:i.rotatable,children:y.jsx(a,{style:i.style,className:i.className,data:i.data,id:i.id})},i.id):y.jsx(yn,{id:i.id,draggable:i.draggable,className:i.className,style:i.style,children:y.jsx(a,{data:i.data,id:i.id})},i.id)})})};G.Canvas=cs,G.DefaultNode=Xe,G.Editor=Un,G.ElementWrapper=gn,G.Handle=Pe,G.InputNode=Yt,G.NodeLayer=us,G.OutputNode=Ht,G.WorkflowNodeWrapper=yn,G.useEditor=z,G.useEditorStoreApi=We,Object.defineProperty(G,Symbol.toStringTag,{value:"Module"})}));
package/dist/index.css ADDED
@@ -0,0 +1 @@
1
+ .ce-editor{position:relative;width:100%;height:100%;overflow:hidden;background-color:#f3f4f6}.ce-editor__canvas{position:absolute;top:0;left:0;width:100%;height:100%;touch-action:none;transform-origin:0 0}.ce-editor__viewport{width:100%;height:100%;overflow:hidden}.ce-editor__viewport--panning{cursor:grab!important}.ce-editor__viewport--panning *{pointer-events:none!important}.ce-editor__grid-layer{position:absolute;top:-50000px;left:-50000px;width:100000px;height:100000px;opacity:.5;pointer-events:none;z-index:0}.ce-editor__content-area{position:absolute;left:0;top:0;background-color:#fff;overflow:hidden;z-index:1;box-shadow:0 0 20px #0000001a}.ce-editor__infinite-area{position:relative;z-index:1}.ce-element{position:absolute;touch-action:none;-webkit-user-select:none;user-select:none;box-sizing:border-box;transition:box-shadow .1s}.ce-element--selected{outline:2px solid #3b82f6;outline-width:calc(2px * var(--ce-inverse-zoom, 1));box-shadow:0 0 0 calc(4px * var(--ce-inverse-zoom, 1)) #3b82f633;z-index:100!important}.ce-element img{pointer-events:none;-webkit-user-drag:none;-webkit-user-select:none;user-select:none}.ce-editor--connecting{cursor:crosshair!important}.ce-editor--connecting .ce-element:hover{outline:2px dashed #3b82f6;outline-width:calc(2px * var(--ce-inverse-zoom, 1));background-color:#3b82f60d;cursor:copy}.ce-editor--connecting .ce-handle:hover{transform:scale(1.5);background-color:#3b82f6!important;border-color:#fff!important;transition:transform .1s}.ce-resize-handle{width:calc(10px * var(--ce-inverse-zoom, 1));height:calc(10px * var(--ce-inverse-zoom, 1));background:#fff;border:calc(1px * var(--ce-inverse-zoom, 1)) solid #3b82f6;position:absolute;z-index:101}.ce-resize-handle--nw{top:calc(-6px * var(--ce-inverse-zoom, 1));left:calc(-6px * var(--ce-inverse-zoom, 1));cursor:nw-resize}.ce-resize-handle--ne{top:calc(-6px * var(--ce-inverse-zoom, 1));right:calc(-6px * var(--ce-inverse-zoom, 1));cursor:ne-resize}.ce-resize-handle--sw{bottom:calc(-6px * var(--ce-inverse-zoom, 1));left:calc(-6px * var(--ce-inverse-zoom, 1));cursor:sw-resize}.ce-resize-handle--se{bottom:calc(-6px * var(--ce-inverse-zoom, 1));right:calc(-6px * var(--ce-inverse-zoom, 1));cursor:se-resize}.ce-resize-handle--n{top:calc(-6px * var(--ce-inverse-zoom, 1));left:50%;transform:translate(-50%);cursor:n-resize}.ce-resize-handle--s{bottom:calc(-6px * var(--ce-inverse-zoom, 1));left:50%;transform:translate(-50%);cursor:s-resize}.ce-resize-handle--e{right:calc(-6px * var(--ce-inverse-zoom, 1));top:50%;transform:translateY(-50%);cursor:e-resize}.ce-resize-handle--w{left:calc(-6px * var(--ce-inverse-zoom, 1));top:50%;transform:translateY(-50%);cursor:w-resize}.ce-rotate-handle{width:calc(24px * var(--ce-inverse-zoom, 1));height:calc(24px * var(--ce-inverse-zoom, 1));background:#fff;border:none;box-shadow:0 2px 4px #0003;border-radius:50%;position:absolute;top:auto;bottom:calc(-35px * var(--ce-inverse-zoom, 1));left:50%;transform:translate(-50%);cursor:grab;z-index:101;display:flex;align-items:center;justify-content:center;color:#555}.ce-rotate-handle:after{display:none}.ce-rotate-handle:active{cursor:grabbing;background:#f3f4f6;color:#000}.ce-drag-handle-minimal{width:calc(24px * var(--ce-inverse-zoom, 1));height:calc(24px * var(--ce-inverse-zoom, 1));position:absolute;top:auto;bottom:calc(-35px * var(--ce-inverse-zoom, 1));left:calc(50% + calc(30px * var(--ce-inverse-zoom, 1)));transform:translate(-50%);background-color:#fff;border-radius:50%;box-shadow:0 2px 4px #0003;cursor:grab;z-index:102;display:flex;align-items:center;justify-content:center;color:#555;background-image:none}.ce-drag-handle-minimal:active{cursor:grabbing;background-color:#f3f4f6;color:#000}.ce-snap-guide{position:absolute;background-color:#f0f;pointer-events:none;z-index:200}.ce-snap-guide--vertical{width:1px;height:100vh}.ce-snap-guide--horizontal{height:1px;width:100vw}.ce-node-default,.ce-node-input,.ce-node-output{background:#fff;border:1px solid #777;border-radius:4px;padding:10px;min-width:180px;text-align:center;font-size:14px;color:#222;box-shadow:0 1px 4px #0000001a;position:relative}.ce-node-input{border-color:#3b82f6}.ce-node-output{border-color:#10b981}.ce-node-content{pointer-events:none}.ce-handle{width:10px;height:10px;background:#fff;border-radius:50%;position:absolute;border:3px solid #777;z-index:10;cursor:crosshair;transition:border-color .2s}.ce-handle--left{left:0;transform:translate(-50%)}.ce-handle--right{right:0;transform:translate(50%)}.ce-handle--top{top:0;transform:translateY(-50%)}.ce-handle--bottom{bottom:0;transform:translateY(50%)}.ce-workflow-node:hover .ce-delete-node-btn{opacity:1;pointer-events:auto}.ce-delete-node-btn{position:absolute;top:-8px;right:-8px;width:18px;height:18px;background:#ff4d4f;color:#fff;border:none;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;font-size:14px;line-height:1;padding:0;z-index:20;opacity:0;pointer-events:none;transition:opacity .2s,transform .1s;box-shadow:0 2px 4px #0000001a}.ce-delete-node-btn:hover{transform:scale(1.1);background:#ff7875}.ce-edge-group .ce-edge-delete-fo{opacity:0;pointer-events:none;transition:opacity .2s}.ce-edge-group:hover .ce-edge-delete-fo{opacity:1;pointer-events:auto}.ce-connection-line{animation:dashdraw .5s linear infinite}@keyframes dashdraw{0%{stroke-dashoffset:10}to{stroke-dashoffset:0}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jeevandev/flow-canvas",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "type": "module",
5
5
  "main": "./dist/flow-canvas.umd.js",
6
6
  "module": "./dist/flow-canvas.es.js",
@@ -23,7 +23,6 @@
23
23
  "preview": "vite preview"
24
24
  },
25
25
  "dependencies": {
26
- "@jeevandev/flow-canvas": "^0.0.5",
27
26
  "@use-gesture/react": "^10.3.1",
28
27
  "immer": "^11.0.1",
29
28
  "lucide-react": "^0.561.0",
@@ -45,6 +44,7 @@
45
44
  "typescript": "~5.9.3",
46
45
  "typescript-eslint": "^8.46.4",
47
46
  "vite": "^7.2.4",
48
- "vite-plugin-dts": "^4.5.4"
47
+ "vite-plugin-dts": "^4.5.4",
48
+ "vite-plugin-lib-inject-css": "^2.2.2"
49
49
  }
50
50
  }