@tuongaz/seeflow 0.1.47 → 0.1.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/dist/web/assets/{index-BYeYJkCQ.js → index-CFn1Jdmi.js} +3 -3
- package/dist/web/assets/{index.es-CqkMwhBu.js → index.es-DQFAA-Eu.js} +1 -1
- package/dist/web/assets/{jspdf.es.min-DLHTB6Rk.js → jspdf.es.min-D7KeFi-m.js} +3 -3
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/src/api.ts +138 -102
- package/src/cli-helpers.ts +79 -0
- package/src/cli-manifest.ts +772 -0
- package/src/cli-ops.ts +18 -0
- package/src/cli.ts +164 -137
- package/src/events.ts +2 -1
- package/src/mcp.ts +104 -35
- package/src/merge.ts +3 -0
- package/src/operations.ts +320 -0
- package/src/registry-watcher.ts +86 -0
- package/src/registry.ts +132 -24
- package/src/schema.ts +2 -0
- package/src/server.ts +9 -0
- package/src/watcher.ts +32 -2
|
@@ -7800,11 +7800,11 @@ Error generating stack: `+i.message+`
|
|
|
7800
7800
|
`)},jq=function(){var e=parseInt(document.body.getAttribute(yu)||"0",10);return isFinite(e)?e:0},khe=function(){m.useEffect(function(){return document.body.setAttribute(yu,(jq()+1).toString()),function(){var e=jq()-1;e<=0?document.body.removeAttribute(yu):document.body.setAttribute(yu,e.toString())}},[])},ghe=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;khe();var i=m.useMemo(function(){return phe(o)},[o]);return m.createElement(yhe,{styles:mhe(i,!t,o,n?"":"!important")})},IN=!1;if(typeof window<"u")try{var _0=Object.defineProperty({},"passive",{get:function(){return IN=!0,!0}});window.addEventListener("test",_0,_0),window.removeEventListener("test",_0,_0)}catch{IN=!1}var S1=IN?{passive:!1}:!1,xhe=function(e){return e.tagName==="TEXTAREA"},TZ=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!xhe(e)&&n[t]==="visible")},vhe=function(e){return TZ(e,"overflowY")},whe=function(e){return TZ(e,"overflowX")},Tq=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=NZ(e,r);if(o){var i=DZ(e,r),a=i[1],s=i[2];if(a>s)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Mhe=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},bhe=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},NZ=function(e,t){return e==="v"?vhe(t):whe(t)},DZ=function(e,t){return e==="v"?Mhe(t):bhe(t)},Che=function(e,t){return e==="h"&&t==="rtl"?-1:1},She=function(e,t,n,r,o){var i=Che(e,window.getComputedStyle(t).direction),a=i*r,s=n.target,l=t.contains(s),c=!1,h=a>0,d=0,f=0;do{if(!s)break;var p=DZ(e,s),k=p[0],v=p[1],w=p[2],g=v-w-i*k;(k||g)&&NZ(e,s)&&(d+=g,f+=k);var M=s.parentNode;s=M&&M.nodeType===Node.DOCUMENT_FRAGMENT_NODE?M.host:M}while(!l&&s!==document.body||l&&(t.contains(s)||t===s));return(h&&Math.abs(d)<1||!h&&Math.abs(f)<1)&&(c=!0),c},H0=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Nq=function(e){return[e.deltaX,e.deltaY]},Dq=function(e){return e&&"current"in e?e.current:e},Lhe=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Ihe=function(e){return`
|
|
7801
7801
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
7802
7802
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
7803
|
-
`)},Ehe=0,L1=[];function Ahe(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(Ehe++)[0],i=m.useState(jZ)[0],a=m.useRef(e);m.useEffect(function(){a.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var v=X2e([e.lockRef.current],(e.shards||[]).map(Dq),!0).filter(Boolean);return v.forEach(function(w){return w.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),v.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var s=m.useCallback(function(v,w){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!a.current.allowPinchZoom;var g=H0(v),M=n.current,x="deltaX"in v?v.deltaX:M[0]-g[0],b="deltaY"in v?v.deltaY:M[1]-g[1],S,C=v.target,L=Math.abs(x)>Math.abs(b)?"h":"v";if("touches"in v&&L==="h"&&C.type==="range")return!1;var P=window.getSelection(),T=P&&P.anchorNode,E=T?T===C||T.contains(C):!1;if(E)return!1;var z=Tq(L,C);if(!z)return!0;if(z?S=L:(S=L==="v"?"h":"v",z=Tq(L,C)),!z)return!1;if(!r.current&&"changedTouches"in v&&(x||b)&&(r.current=S),!S)return!0;var A=r.current||S;return She(A,w,v,A==="h"?x:b)},[]),l=m.useCallback(function(v){var w=v;if(!(!L1.length||L1[L1.length-1]!==i)){var g="deltaY"in w?Nq(w):H0(w),M=t.current.filter(function(S){return S.name===w.type&&(S.target===w.target||w.target===S.shadowParent)&&Lhe(S.delta,g)})[0];if(M&&M.should){w.cancelable&&w.preventDefault();return}if(!M){var x=(a.current.shards||[]).map(Dq).filter(Boolean).filter(function(S){return S.contains(w.target)}),b=x.length>0?s(w,x[0]):!a.current.noIsolation;b&&w.cancelable&&w.preventDefault()}}},[]),c=m.useCallback(function(v,w,g,M){var x={name:v,delta:w,target:g,should:M,shadowParent:Phe(g)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(b){return b!==x})},1)},[]),h=m.useCallback(function(v){n.current=H0(v),r.current=void 0},[]),d=m.useCallback(function(v){c(v.type,Nq(v),v.target,s(v,e.lockRef.current))},[]),f=m.useCallback(function(v){c(v.type,H0(v),v.target,s(v,e.lockRef.current))},[]);m.useEffect(function(){return L1.push(i),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,S1),document.addEventListener("touchmove",l,S1),document.addEventListener("touchstart",h,S1),function(){L1=L1.filter(function(v){return v!==i}),document.removeEventListener("wheel",l,S1),document.removeEventListener("touchmove",l,S1),document.removeEventListener("touchstart",h,S1)}},[]);var p=e.removeScrollBar,k=e.inert;return m.createElement(m.Fragment,null,k?m.createElement(i,{styles:Ihe(o)}):null,p?m.createElement(ghe,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Phe(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Rhe=ihe(zZ,Ahe);var lz=m.forwardRef(function(e,t){return m.createElement(sz,so({},e,{ref:t,sideCar:Rhe}))});lz.classNames=sz.classNames;var cz="Popover",[_Z]=Nr(cz,[Yu]),Ih=Yu(),[zhe,Gi]=_Z(cz),HZ=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:a=!1}=e,s=Ih(t),l=m.useRef(null),[c,h]=m.useState(!1),[d,f]=c1({prop:r,defaultProp:o??!1,onChange:i,caller:cz});return y.jsx(z_,{...s,children:y.jsx(zhe,{scope:t,contentId:dn(),triggerRef:l,open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(p=>!p),[f]),hasCustomAnchor:c,onCustomAnchorAdd:m.useCallback(()=>h(!0),[]),onCustomAnchorRemove:m.useCallback(()=>h(!1),[]),modal:a,children:n})})};HZ.displayName=cz;var FZ="PopoverAnchor",OZ=m.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Gi(FZ,n),i=Ih(n),{onCustomAnchorAdd:a,onCustomAnchorRemove:s}=o;return m.useEffect(()=>(a(),()=>s()),[a,s]),y.jsx(az,{...i,...r,ref:t})});OZ.displayName=FZ;var qZ="PopoverTrigger",VZ=m.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Gi(qZ,n),i=Ih(n),a=dt(t,o.triggerRef),s=y.jsx(Ve.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":GZ(o.open),...r,ref:a,onClick:Ie(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?s:y.jsx(az,{asChild:!0,...i,children:s})});VZ.displayName=qZ;var D_="PopoverPortal",[jhe,The]=_Z(D_,{forceMount:void 0}),BZ=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,i=Gi(D_,t);return y.jsx(jhe,{scope:t,forceMount:n,children:y.jsx(Qn,{present:n||i.open,children:y.jsx(Lh,{asChild:!0,container:o,children:r})})})};BZ.displayName=D_;var _u="PopoverContent",$Z=m.forwardRef((e,t)=>{const n=The(_u,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,i=Gi(_u,e.__scopePopover);return y.jsx(Qn,{present:r||i.open,children:i.modal?y.jsx(Dhe,{...o,ref:t}):y.jsx(_he,{...o,ref:t})})});$Z.displayName=_u;var Nhe=Nu("PopoverContent.RemoveScroll"),Dhe=m.forwardRef((e,t)=>{const n=Gi(_u,e.__scopePopover),r=m.useRef(null),o=dt(t,r),i=m.useRef(!1);return m.useEffect(()=>{const a=r.current;if(a)return N_(a)},[]),y.jsx(lz,{as:Nhe,allowPinchZoom:!0,children:y.jsx(UZ,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ie(e.onCloseAutoFocus,a=>{var s;a.preventDefault(),i.current||(s=n.triggerRef.current)==null||s.focus()}),onPointerDownOutside:Ie(e.onPointerDownOutside,a=>{const s=a.detail.originalEvent,l=s.button===0&&s.ctrlKey===!0,c=s.button===2||l;i.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:Ie(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),_he=m.forwardRef((e,t)=>{const n=Gi(_u,e.__scopePopover),r=m.useRef(!1),o=m.useRef(!1);return y.jsx(UZ,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var a,s;(a=e.onCloseAutoFocus)==null||a.call(e,i),i.defaultPrevented||(r.current||(s=n.triggerRef.current)==null||s.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=i.target;((c=n.triggerRef.current)==null?void 0:c.contains(a))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),UZ=m.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:h,...d}=e,f=Gi(_u,n),p=Ih(n);return b_(),y.jsx(tz,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:y.jsx(Ch,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:h,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>f.onOpenChange(!1),children:y.jsx(j_,{"data-state":GZ(f.open),role:"dialog",id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),WZ="PopoverClose",Hhe=m.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Gi(WZ,n);return y.jsx(Ve.button,{type:"button",...r,ref:t,onClick:Ie(e.onClick,()=>o.onOpenChange(!1))})});Hhe.displayName=WZ;var Fhe="PopoverArrow",Ohe=m.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ih(n);return y.jsx(T_,{...o,...r,ref:t})});Ohe.displayName=Fhe;function GZ(e){return e?"open":"closed"}var qhe=HZ,Vhe=OZ,Bhe=VZ,$he=BZ,ZZ=$Z;const KZ=m.createContext(null);function Uhe({containerRef:e,children:t}){return y.jsx(KZ.Provider,{value:e.current,children:t})}function Qu(){return m.useContext(KZ)??void 0}const Ju=qhe,Eh=Bhe,Whe=Vhe,u1=m.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>{const i=Qu();return y.jsx($he,{container:i,children:y.jsx(ZZ,{ref:o,align:t,sideOffset:n,className:ie("sf:z-50 sf:w-72 sf:rounded-md sf:border sf:bg-popover sf:p-4 sf:text-popover-foreground sf:shadow-md sf:outline-hidden sf:data-[state=open]:animate-in sf:data-[state=closed]:animate-out sf:data-[state=closed]:fade-out-0 sf:data-[state=open]:fade-in-0 sf:data-[state=closed]:zoom-out-95 sf:data-[state=open]:zoom-in-95 sf:data-[side=bottom]:slide-in-from-top-2 sf:data-[side=left]:slide-in-from-right-2 sf:data-[side=right]:slide-in-from-left-2 sf:data-[side=top]:slide-in-from-bottom-2",e),...r})})});u1.displayName=ZZ.displayName;const I1=8,F0=32,_j=256,_q=2;function Ghe(e,t){const n=t.trim().toLowerCase();return n===""?e.slice():e.filter(r=>r.toLowerCase().includes(n))}function uz({open:e,onOpenChange:t,anchor:n,onPick:r,clearable:o=!0}){const[i,a]=m.useState(""),s=m.useMemo(()=>e?QG():[],[e]);return m.useEffect(()=>{e||a("")},[e]),y.jsxs(Ju,{open:e,onOpenChange:t,children:[y.jsx(Eh,{asChild:!0,children:n}),y.jsx(u1,{align:"start",side:"bottom",sideOffset:6,className:"sf:w-[340px] sf:p-0","data-testid":"icon-picker-popover",children:y.jsx(Zhe,{query:i,onQueryChange:a,recents:s,onPick:r,clearable:o})})]})}function Zhe({query:e,onQueryChange:t,recents:n,onPick:r,clearable:o=!0}){const i=m.useMemo(()=>Ghe(_ne,e),[e]),a=e.trim()===""&&n.length>0,s=o&&e.trim()==="",[l,c]=m.useState(0),h=Math.max(1,Math.ceil(i.length/I1)),d=h*F0,f=Math.ceil(_j/F0)+_q*2,p=Math.max(0,Math.floor(l/F0)-_q),k=Math.min(h,p+f),v=p*I1,w=Math.min(i.length,k*I1),g=i.slice(v,w);return y.jsxs("div",{className:"sf:flex sf:w-full sf:flex-col",children:[y.jsx("div",{className:"sf:border-b sf:border-border sf:p-2",children:y.jsx("input",{type:"text",value:e,placeholder:"Search icons…","aria-label":"Search icons","data-testid":"icon-picker-search",className:ie("sf:flex sf:h-8 sf:w-full sf:rounded-md sf:border sf:border-input sf:bg-background sf:px-3 sf:text-sm","placeholder:text-muted-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-1"),onChange:M=>t(M.target.value)})}),a?y.jsxs("div",{className:"sf:border-b sf:border-border sf:p-2","data-testid":"icon-picker-recents",children:[y.jsx("div",{className:"sf:mb-1 sf:px-1 sf:text-[11px] sf:font-medium sf:uppercase sf:tracking-wide sf:text-muted-foreground",children:"Recent"}),y.jsx("div",{className:"sf:grid sf:gap-1",style:{gridTemplateColumns:`repeat(${I1}, minmax(0, 1fr))`},children:n.map(M=>Hq(M,r,`icon-picker-recent-${M}`))})]}):null,y.jsxs("div",{className:"sf:p-2",children:[y.jsx("div",{className:"sf:mb-1 sf:px-1 sf:text-[11px] sf:font-medium sf:uppercase sf:tracking-wide sf:text-muted-foreground",children:"All icons"}),s?y.jsx("div",{className:"sf:mb-1 sf:grid sf:gap-1",style:{gridTemplateColumns:`repeat(${I1}, minmax(0, 1fr))`},children:Khe(r)}):null,i.length===0?y.jsx("div",{className:"sf:flex sf:items-center sf:justify-center sf:text-xs sf:text-muted-foreground",style:{height:_j},"data-testid":"icon-picker-empty",children:"No icons match."}):y.jsx("div",{"data-testid":"icon-picker-all",className:"overflow-y-auto",style:{height:_j},onScroll:M=>c(M.currentTarget.scrollTop),children:y.jsx("div",{style:{height:d,position:"relative"},children:y.jsx("div",{style:{position:"absolute",top:p*F0,left:0,right:0},children:y.jsx("div",{className:"sf:grid sf:gap-1",style:{gridTemplateColumns:`repeat(${I1}, minmax(0, 1fr))`},children:g.map(M=>Hq(M,r,`icon-picker-tile-${M}`))})})})})]})]})}function Hq(e,t,n){const r=Cu[e];return y.jsx("button",{type:"button",title:e,"aria-label":e,"data-testid":n,"data-icon-name":e,onClick:()=>t(e),className:ie("sf:inline-flex sf:h-7 sf:w-7 sf:items-center sf:justify-center sf:rounded-md sf:text-muted-foreground sf:transition-colors","sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-1"),children:r?y.jsx(r,{className:"sf:h-4 sf:w-4","aria-hidden":"true"}):null},n)}function Khe(e){return y.jsx("button",{type:"button",title:"No icon","aria-label":"No icon","data-testid":"icon-picker-tile-none",onClick:()=>e(null),className:ie("sf:inline-flex sf:h-7 sf:w-7 sf:items-center sf:justify-center sf:rounded-md sf:text-muted-foreground sf:transition-colors","sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-1"),children:y.jsx(Yd,{className:"sf:h-4 sf:w-4","aria-hidden":"true"})},"icon-picker-tile-none")}var Xhe=Symbol.for("react.lazy"),fR=dD[" use ".trim().toString()];function Yhe(e){return typeof e=="object"&&e!==null&&"then"in e}function XZ(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Xhe&&"_payload"in e&&Yhe(e._payload)}function Qhe(e){const t=e0e(e),n=m.forwardRef((r,o)=>{let{children:i,...a}=r;XZ(i)&&typeof fR=="function"&&(i=fR(i._payload));const s=m.Children.toArray(i),l=s.find(n0e);if(l){const c=l.props.children,h=s.map(d=>d===l?m.Children.count(c)>1?m.Children.only(null):m.isValidElement(c)?c.props.children:null:d);return y.jsx(t,{...a,ref:o,children:m.isValidElement(c)?m.cloneElement(c,void 0,h):null})}return y.jsx(t,{...a,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}var Jhe=Qhe("Slot");function e0e(e){const t=m.forwardRef((n,r)=>{let{children:o,...i}=n;if(XZ(o)&&typeof fR=="function"&&(o=fR(o._payload)),m.isValidElement(o)){const a=o0e(o),s=r0e(i,o.props);return o.type!==m.Fragment&&(s.ref=r?ko(r,a):a),m.cloneElement(o,s)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var t0e=Symbol("radix.slottable");function n0e(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===t0e}function r0e(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...s)=>{const l=i(...s);return o(...s),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function o0e(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const Fq=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Oq=eW,YZ=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return Oq(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:i}=t,a=Object.keys(o).map(c=>{const h=n==null?void 0:n[c],d=i==null?void 0:i[c];if(h===null)return null;const f=Fq(h)||Fq(d);return o[c][f]}),s=n&&Object.entries(n).reduce((c,h)=>{let[d,f]=h;return f===void 0||(c[d]=f),c},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((c,h)=>{let{class:d,className:f,...p}=h;return Object.entries(p).every(k=>{let[v,w]=k;return Array.isArray(w)?w.includes({...i,...s}[v]):{...i,...s}[v]===w})?[...c,d,f]:c},[]);return Oq(e,a,l,n==null?void 0:n.class,n==null?void 0:n.className)},i0e=YZ("sf:inline-flex sf:items-center sf:justify-center sf:whitespace-nowrap sf:rounded-md sf:text-sm sf:font-medium sf:ring-offset-background sf:transition-colors sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-2 sf:disabled:pointer-events-none sf:disabled:opacity-50",{variants:{variant:{default:"sf:bg-primary sf:text-primary-foreground sf:font-semibold sf:hover:bg-emerald-400",destructive:"sf:bg-destructive sf:text-destructive-foreground sf:hover:bg-destructive/90",outline:"sf:border sf:border-input sf:bg-background sf:hover:bg-secondary sf:hover:text-foreground",secondary:"sf:bg-secondary sf:text-secondary-foreground sf:hover:bg-secondary/80",ghost:"sf:text-muted-foreground sf:hover:bg-muted sf:hover:text-foreground",link:"sf:text-primary sf:underline-offset-4 sf:hover:underline"},size:{default:"sf:h-9 sf:px-4 sf:py-2",sm:"sf:h-8 sf:rounded-md sf:px-3",lg:"sf:h-11 sf:rounded-md sf:px-8",icon:"sf:h-9 sf:w-9"}},defaultVariants:{variant:"default",size:"default"}}),Nt=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},i)=>{const a=r?Jhe:"button";return y.jsx(a,{className:ie(i0e({variant:t,size:n,className:e})),ref:i,...o})});Nt.displayName="Button";function __(e,t){return e==="error"||(t==null?void 0:t.state)==="error"?"error":e==="running"||(t==null?void 0:t.state)==="pending"?"active":e==="done"||(t==null?void 0:t.state)==="ok"?"success":"idle"}const a0e={ok:"sf:bg-emerald-400",warn:"sf:bg-amber-400",error:"sf:bg-rose-400",pending:"sf:bg-slate-400"};function QZ({state:e,summary:t,"data-testid":n}){return y.jsxs("span",{"data-testid":n,"data-state":e,className:"sf:inline-flex sf:max-w-full sf:items-center sf:gap-1.5 sf:text-[11px] sf:leading-tight sf:text-muted-foreground",children:[y.jsx("span",{"aria-hidden":!0,className:ie("sf:h-2 sf:w-2 sf:shrink-0 sf:rounded-full",a0e[e])}),t?y.jsx("span",{className:"sf:min-w-0 sf:flex-1 sf:truncate",title:t,children:t}):null]})}const s0e=100,l0e=44,c0e=250;function u0e({visualStatus:e,disabled:t,buttonLabel:n,isError:r,onClick:o}){return y.jsxs(Nt,{type:"button",size:"sm",variant:"secondary",disabled:t,"data-testid":"play-button","data-status":e==="idle"?"idle":e,"data-visual-status":e,"aria-label":n,title:n,onClick:o,className:ie("sf:group sf:relative sf:h-8 sf:w-8 sf:rounded-full sf:p-0","sf:hover:bg-primary sf:hover:text-primary-foreground","sf:focus-visible:bg-primary sf:focus-visible:text-primary-foreground",e==="success"&&"sf:seeflow-play-pop",e==="error"&&"sf:inline-edit-shake",r&&"sf:border-2 sf:border-rose-500"),children:[e==="active"?y.jsx("span",{"aria-hidden":!0,"data-testid":"play-button-ring",className:ie("sf:absolute sf:inset-0 sf:rounded-full sf:seeflow-ring-spin"),style:{background:"conic-gradient(from 0deg, var(--emerald-glow) 0deg, transparent 200deg, var(--emerald-glow) 360deg)",WebkitMask:"radial-gradient(circle, transparent calc(50% - 2px), #000 calc(50% - 2px))",mask:"radial-gradient(circle, transparent calc(50% - 2px), #000 calc(50% - 2px))"}}):null,e==="success"?y.jsxs(y.Fragment,{children:[y.jsx(fo,{className:"sf:h-4 sf:w-4 sf:relative sf:text-emerald-300 sf:group-hover:hidden","aria-hidden":!0}),y.jsx(Bc,{className:"sf:h-4 sf:w-4 sf:relative sf:hidden sf:group-hover:block","aria-hidden":!0})]}):e==="error"?y.jsxs(y.Fragment,{children:[y.jsx(xi,{className:"sf:h-4 sf:w-4 sf:relative sf:text-rose-300 sf:group-hover:hidden","aria-hidden":!0}),y.jsx(Bc,{className:"sf:h-4 sf:w-4 sf:relative sf:hidden sf:group-hover:block","aria-hidden":!0})]}):y.jsx(Bc,{className:ie("sf:h-4 sf:w-4 sf:relative",e==="active"&&"sf:opacity-80"),"aria-hidden":!0})]})}function d0e({id:e,data:t,selected:n,isConnectable:r}){var A;const o=t.status,i=t.playAction,a=t.description??t.kind,s=!!i&&!!t.onPlay,l=__(o,t.statusReport),c=o==="running",h=l==="error",d=l==="active"?"Running…":l==="success"?"Succeeded, run again":l==="error"?t.errorMessage?`Failed: ${t.errorMessage}`:"Failed, run again":"Play",{isResizing:f,onResizeStart:p,onResizeEvent:k,onResizeEnd:v}=Zu({onResize:U=>{var R;return(R=t.onResize)==null?void 0:R.call(t,e,U)},onResizeEnd:U=>{var R;return(R=t.onResizeEnd)==null?void 0:R.call(t,e,U)},setResizing:t.setResizing}),[w,g]=m.useState(null),[M,x]=m.useState(!1),b=!!t.onNameChange,S=!!t.onDescriptionChange,C=!!t.onIconChange&&!!n&&!!t.icon,L=t.width!==void 0||t.height!==void 0,P={...t.fontSize!==void 0?{fontSize:`${t.fontSize}px`}:{},...tt(t.textColor,"text")},T=P,E={borderColor:((A=t.statusReport)==null?void 0:A.state)==="error"?tt("red","node").borderColor:tt(t.borderColor,"node").borderColor,backgroundColor:t.backgroundColor!==void 0?tt(t.backgroundColor,"node").backgroundColor:mh,borderWidth:t.borderSize!==void 0?t.borderSize:void 0,borderStyle:t.borderStyle,borderRadius:t.cornerRadius!==void 0?t.cornerRadius:void 0,...L?{}:{width:c0e}},z=b||S?U=>{if(w!==null)return;const R=U.target;if(!(R!=null&&R.closest(".react-flow__handle"))&&!(R!=null&&R.closest(".react-flow__resize-control"))){if(U.stopPropagation(),R!=null&&R.closest('[data-testid="node-header"]')){b&&g("name");return}if(R!=null&&R.closest('[data-testid="node-content"]')){S?g("description"):b&&g("name");return}S?g("description"):b&&g("name")}}:void 0;return y.jsxs("div",{className:ie("sf:group sf:flex sf:flex-col sf:justify-center sf:overflow-hidden sf:rounded-lg sf:border-[3px] sf:shadow-sm sf:transition-shadow",L?"sf:h-full sf:w-full":"",c?"seeflow-node-pulse":""),style:E,"data-status":o??"idle","data-testid":"play-node","data-node-type":"playNode",onDoubleClick:z,children:[y.jsx(Gu,{visible:!!n&&!!t.onResize,cornerVariant:"visible",minWidth:s0e,minHeight:l0e,onResizeStart:p,onResize:k,onResizeEnd:v}),y.jsx(at,{type:"target",position:ye.Top,id:"t",isConnectable:r,className:ie("sf:opacity-0 sf:transition-opacity",n&&"sf:opacity-100!")}),y.jsx(at,{type:"target",position:ye.Left,id:"l",isConnectable:r,className:ie("sf:opacity-0 sf:transition-opacity",n&&"sf:opacity-100!")}),y.jsxs("div",{className:"sf:flex sf:shrink-0 sf:items-center sf:justify-between sf:gap-2 sf:border-b sf:border-border sf:bg-muted/30 sf:px-3 sf:py-3","data-testid":"node-header",children:[t.icon?C&&t.onIconChange?y.jsx(uz,{open:M,onOpenChange:x,onPick:U=>{var R;(R=t.onIconChange)==null||R.call(t,e,U),x(!1)},anchor:y.jsx("button",{type:"button","data-testid":"play-node-icon-trigger","aria-label":"Change icon","aria-pressed":M,className:ie("sf:inline-flex sf:shrink-0 sf:cursor-pointer sf:items-center sf:justify-center sf:rounded-sm sf:bg-transparent sf:p-0 sf:transition-shadow","sf:hover:ring-2 sf:hover:ring-ring/40 sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring"),onClick:U=>{U.stopPropagation()},onMouseDown:U=>{U.stopPropagation()},onDoubleClick:U=>{U.stopPropagation()},children:y.jsx(t1,{name:t.icon,size:16,style:tt(t.textColor,"text"),"aria-hidden":!0})})}):y.jsx(t1,{name:t.icon,size:16,className:"shrink-0",style:tt(t.textColor,"text"),"aria-hidden":!0}):null,y.jsx("div",{className:"sf:min-w-0 sf:flex-1 sf:text-[18px] sf:font-semibold sf:leading-tight sf:text-foreground/90",style:P,children:w==="name"&&b?y.jsx(lo,{initialValue:t.name,field:"node-name",required:!0,commitMode:"blur-only",onCommit:U=>{var R;return(R=t.onNameChange)==null?void 0:R.call(t,e,U)},onExit:()=>g(null),className:"sf:text-[18px] sf:font-semibold sf:text-foreground/90",style:P}):y.jsx("button",{type:"button",className:ie("sf:block sf:w-full sf:whitespace-pre-wrap sf:wrap-break-word sf:bg-transparent sf:p-0 sf:text-left sf:text-[18px] sf:font-semibold sf:leading-tight sf:text-foreground/90",b?"sf:hover:opacity-80":""),style:P,children:t.name})}),y.jsx("div",{className:"sf:flex sf:shrink-0 sf:items-center sf:gap-1",children:y.jsx(u0e,{visualStatus:l,disabled:!s||l==="active",buttonLabel:d,isError:h,onClick:U=>{var R;U.stopPropagation(),(R=t.onPlay)==null||R.call(t,e)}})})]}),y.jsx("div",{className:"sf:flex sf:min-h-0 sf:flex-1 sf:items-center sf:px-3 sf:py-2","data-testid":"node-content","data-resizing":f?"true":void 0,children:w==="description"&&S?y.jsx(lo,{initialValue:t.description??"",field:"node-description",multiline:!0,onCommit:U=>{var R;return(R=t.onDescriptionChange)==null?void 0:R.call(t,e,U)},onExit:()=>g(null),className:"sf:w-full sf:text-[18px] sf:text-muted-foreground",style:T,placeholder:t.kind}):y.jsx("button",{type:"button",className:ie("sf:block sf:w-full sf:whitespace-normal sf:wrap-break-word sf:bg-transparent sf:p-0 sf:text-left sf:text-[18px] sf:text-muted-foreground",S?"sf:hover:opacity-80":""),style:T,children:a})}),t.statusReport&&y.jsx("div",{className:"sf:flex sf:items-center sf:px-3 sf:pb-2","data-testid":"play-node-status-badge",children:y.jsx(QZ,{state:t.statusReport.state,summary:t.statusReport.summary,"data-testid":"status-badge"})}),y.jsx(at,{type:"source",position:ye.Right,id:"r",isConnectable:r,className:ie("sf:opacity-0 sf:transition-opacity",n&&"sf:opacity-100!")}),y.jsx(at,{type:"source",position:ye.Bottom,id:"b",isConnectable:r,className:ie("sf:opacity-0 sf:transition-opacity",n&&"sf:opacity-100!")})]})}function h0e(e,t){return e.selected===t.selected&&e.data===t.data&&e.width===t.width&&e.height===t.height}const f0e=m.memo(d0e,h0e),Ah="var(--seeflow-node-border)",Ph="var(--seeflow-node-bg)",Rh=2;function zh(e){if(e==="dashed")return"6 4";if(e==="dotted")return"2 4"}const qq=5;function p0e({width:e,height:t,borderColor:n,backgroundColor:r,borderSize:o,borderStyle:i}){const a=n??Ah,s=r??Ph,l=o??Rh,c=zh(i),h=e-2*qq,d=h/7,f=h/7*1.5,p=d,k=qq,v=k+d,w=v+d+f,M=w+f+p+p,x=t*.85,b=[`M ${k} ${x}`,`A ${d} ${d} 0 0 1 ${v+d} ${x}`,`A ${f} ${f} 0 0 1 ${w+f} ${x}`,`A ${p} ${p} 0 0 1 ${M} ${x}`,`L ${M} ${t}`,`L ${k} ${t}`,"Z"].join(" ");return y.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${e} ${t}`,preserveAspectRatio:"none",role:"img","aria-label":"Cloud","data-testid":"cloud-shape",children:[y.jsx("title",{children:"Cloud"}),y.jsx("path",{d:b,fill:s,stroke:a,strokeWidth:l,strokeDasharray:c})]})}function y0e({width:e,height:t,borderColor:n,backgroundColor:r,borderSize:o,borderStyle:i}){const a=Math.max(6,Math.min(28,t*.12)),s=e/2,l=e/2,c=n??Ah,h=r??Ph,d=o??Rh,f=zh(i),p=`M 0 ${t-a} A ${s} ${a} 0 0 0 ${e} ${t-a}`;return y.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${e} ${t}`,preserveAspectRatio:"none",role:"img","aria-label":"Database","data-testid":"database-shape",children:[y.jsx("title",{children:"Database"}),y.jsx("rect",{x:0,y:a,width:e,height:Math.max(0,t-2*a),fill:h}),y.jsx("line",{x1:0,y1:a,x2:0,y2:t-a,stroke:c,strokeWidth:d,strokeDasharray:f}),y.jsx("line",{x1:e,y1:a,x2:e,y2:t-a,stroke:c,strokeWidth:d,strokeDasharray:f}),y.jsx("path",{d:p,fill:h,stroke:c,strokeWidth:d,strokeDasharray:f}),y.jsx("ellipse",{cx:l,cy:a,rx:s,ry:a,fill:h,stroke:c,strokeWidth:d,strokeDasharray:f})]})}function m0e({width:e,height:t,borderColor:n,backgroundColor:r,borderSize:o,borderStyle:i}){const a=n??Ah,s=r??Ph,l=o??Rh,c=zh(i),h=t/2,d=e*.25,f=e*.5,p=e*.75;return y.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${e} ${t}`,preserveAspectRatio:"none",role:"img","aria-label":"Queue","data-testid":"queue-shape",children:[y.jsx("title",{children:"Queue"}),y.jsx("rect",{x:0,y:0,width:e,height:t,rx:h,ry:h,fill:s,stroke:a,strokeWidth:l,strokeDasharray:c}),y.jsx("line",{x1:d,y1:0,x2:d,y2:t,stroke:a,strokeWidth:l,strokeDasharray:c}),y.jsx("line",{x1:f,y1:0,x2:f,y2:t,stroke:a,strokeWidth:l,strokeDasharray:c}),y.jsx("line",{x1:p,y1:0,x2:p,y2:t,stroke:a,strokeWidth:l,strokeDasharray:c})]})}const k0e=3;function g0e({width:e,height:t,borderColor:n,backgroundColor:r,borderSize:o,borderStyle:i}){const a=n??Ah,s=r??Ph,l=o??Rh,c=zh(i),h=t/k0e,d=Math.max(3,Math.min(6,h*.18)),f=e-Math.max(10,d*3),p=Math.min(8,Math.min(e,t)*.06);return y.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${e} ${t}`,preserveAspectRatio:"none",role:"img","aria-label":"Server","data-testid":"server-shape",children:[y.jsx("title",{children:"Server"}),y.jsx("rect",{x:0,y:0,width:e,height:t,rx:p,ry:p,fill:s,stroke:a,strokeWidth:l,strokeDasharray:c}),y.jsx("line",{x1:0,y1:h,x2:e,y2:h,stroke:a,strokeWidth:l,strokeDasharray:c}),y.jsx("line",{x1:0,y1:h*2,x2:e,y2:h*2,stroke:a,strokeWidth:l,strokeDasharray:c}),y.jsx("circle",{cx:f,cy:h/2,r:d,fill:a}),y.jsx("circle",{cx:f,cy:h+h/2,r:d,fill:a}),y.jsx("circle",{cx:f,cy:h*2+h/2,r:d,fill:a})]})}function x0e({width:e,height:t,borderColor:n,backgroundColor:r,borderSize:o,borderStyle:i}){const a=n??Ah,s=r??Ph,l=o??Rh,c=zh(i),h=t*.22,d=Math.max(8,Math.min(28,Math.min(e,t)*.18)),f=h+d+Math.max(4,t*.05),p=Math.max(6,e*.1),k=p,v=e-p,w=Math.min((v-k)/2,(t-f)/2,40),g=[`M ${k} ${t}`,`L ${k} ${f+w}`,`A ${w} ${w} 0 0 1 ${k+w} ${f}`,`L ${v-w} ${f}`,`A ${w} ${w} 0 0 1 ${v} ${f+w}`,`L ${v} ${t}`,"Z"].join(" ");return y.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${e} ${t}`,preserveAspectRatio:"none",role:"img","aria-label":"User","data-testid":"user-shape",children:[y.jsx("title",{children:"User"}),y.jsx("circle",{cx:e/2,cy:h,r:d,fill:s,stroke:a,strokeWidth:l,strokeDasharray:c}),y.jsx("path",{d:g,fill:s,stroke:a,strokeWidth:l,strokeDasharray:c})]})}const H_={database:y0e,server:g0e,user:x0e,queue:m0e,cloud:p0e},v0e=new Set(Object.keys(H_));function w0e(e){return v0e.has(e)}const pR={rectangle:{width:200,height:120},ellipse:{width:200,height:120},sticky:{width:180,height:180},text:{width:160,height:40},database:{width:120,height:140},server:{width:140,height:120},user:{width:100,height:140},queue:{width:220,height:80},cloud:{width:180,height:120}},M0e={rectangle:"sf:rounded-lg sf:border-[3px] sf:bg-transparent",ellipse:"sf:rounded-full sf:border-[3px] sf:bg-transparent",sticky:"sf:rounded-md sf:border-[3px] sf:shadow-md sf:-rotate-2",text:"sf:bg-transparent",database:"",server:"",user:"",queue:"",cloud:""};function JZ(e){return M0e[e]}function eK(e,t){if(e==="text")return{};if(w0e(e))return{};const n=t==null?void 0:t.backgroundColor;let r;n!==void 0?r=tt(n,"node").backgroundColor:e==="sticky"?r=tt("amber","node").backgroundColor:(e==="rectangle"||e==="ellipse")&&(r=mh);const o=e==="rectangle"||e==="sticky";return{borderColor:tt(t==null?void 0:t.borderColor,"node").borderColor,backgroundColor:r,borderWidth:(t==null?void 0:t.borderSize)!==void 0?t.borderSize:void 0,borderStyle:t==null?void 0:t.borderStyle,borderRadius:o&&(t==null?void 0:t.cornerRadius)!==void 0?t.cornerRadius:void 0}}function b0e(e){return{borderColor:tt(e.borderColor,"node").borderColor,backgroundColor:e.backgroundColor!==void 0?tt(e.backgroundColor,"node").backgroundColor:mh}}const O0="sf:opacity-0 sf:transition-opacity";function C0e({id:e,data:t,selected:n,isConnectable:r}){const o=t.shape,i=pR[o],{onResizeStart:a,onResizeEvent:s,onResizeEnd:l}=Zu({onResize:D=>{var N;return(N=t.onResize)==null?void 0:N.call(t,e,D)},onResizeEnd:D=>{var N;return(N=t.onResizeEnd)==null?void 0:N.call(t,e,D)},setResizing:t.setResizing}),[c,h]=m.useState(()=>t.autoEditOnMount?t.shape==="ellipse"||t.shape==="sticky"||t.shape==="rectangle"&&(t.name===void 0||t.name==="")?"description":"name":null),d=c!==null,f=!!t.onNameChange,p=!!t.onDescriptionChange,k=o==="rectangle",v=o==="ellipse"||o==="sticky",w=t.name!==void 0&&t.name!=="",g=k&&w,M=v||k&&!w,x=t.width!==void 0||t.height!==void 0,b=o==="text",S=t.textColor,C=S!==void 0?tt(S,"text"):b?tt(t.borderColor,"text"):{},L={...eK(o,t),...t.fontSize!==void 0?{fontSize:`${t.fontSize}px`}:{}},P={...t.fontSize!==void 0?{fontSize:`${t.fontSize}px`}:{},...C},T=x?L:{...L,width:t.width??i.width,height:t.height??i.height},E=f||p?D=>{if(d)return;const N=D.target;if(!(N!=null&&N.closest(".react-flow__handle"))&&!(N!=null&&N.closest(".react-flow__resize-control"))){if(D.stopPropagation(),g){if(N!=null&&N.closest('[data-testid="shape-node-header"]')){f&&h("name");return}p?h("description"):f&&h("name");return}if(M){p?h("description"):f&&h("name");return}f&&h("name")}}:void 0;let z=null;const A=H_[o];if(A){const D=t.width??i.width,N=t.height??i.height,{borderColor:I,backgroundColor:W}=b0e(t);z=y.jsx("div",{className:"sf:pointer-events-none sf:absolute sf:inset-0",children:y.jsx(A,{width:D,height:N,borderColor:I,backgroundColor:W,borderSize:t.borderSize,borderStyle:t.borderStyle})})}const U=t.description??"",R=U!=="",V={...t.fontSize!==void 0?{fontSize:`${t.fontSize}px`}:{},...C};let O;M?O=c==="description"&&p?y.jsx(lo,{initialValue:U,field:"node-description",commitMode:"blur-only",onCommit:D=>{var N;return(N=t.onDescriptionChange)==null?void 0:N.call(t,e,D)},onExit:()=>h(null),className:"sf:relative sf:text-[22px]",style:V,placeholder:"Description"}):y.jsx("button",{type:"button",className:ie("sf:relative sf:block sf:whitespace-pre-wrap sf:bg-transparent sf:p-0 sf:font-medium sf:leading-tight",R?"break-words":"sf:italic sf:text-muted-foreground/40"),style:V,children:R?U:""}):O=c==="name"&&f?y.jsx(lo,{initialValue:t.name??"",field:"node-label",commitMode:"blur-only",onCommit:D=>{var N;return(N=t.onNameChange)==null?void 0:N.call(t,e,D)},onExit:()=>h(null),className:"sf:relative sf:text-[22px]",style:P,placeholder:b?"Text":"Label"}):y.jsx("button",{type:"button",className:ie("sf:relative sf:block sf:whitespace-pre-wrap sf:bg-transparent sf:p-0 sf:font-medium sf:leading-tight",t.name?"break-words":"sf:text-muted-foreground/40 sf:italic"),style:P,children:t.name??(b&&f?"Text":"")});const B=y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"sf:relative sf:flex sf:shrink-0 sf:items-center sf:border-b sf:border-border sf:px-3 sf:py-2.5",style:tt(t.backgroundColor,"node-header"),"data-testid":"shape-node-header",children:y.jsx("div",{className:"sf:min-w-0 sf:flex-1 sf:whitespace-pre-wrap sf:wrap-break-word sf:text-left sf:font-semibold sf:text-[18px] sf:leading-tight",style:P,children:c==="name"&&f?y.jsx(lo,{initialValue:t.name??"",field:"node-label",commitMode:"blur-only",onCommit:D=>{var N;return(N=t.onNameChange)==null?void 0:N.call(t,e,D)},onExit:()=>h(null),className:"sf:text-[18px] sf:font-semibold",style:P,placeholder:"Title"}):y.jsx("button",{type:"button",className:ie("sf:block sf:w-full sf:whitespace-pre-wrap sf:wrap-break-word sf:bg-transparent sf:p-0 sf:text-left sf:font-semibold sf:text-[18px] sf:leading-tight",f?"sf:hover:opacity-80":""),style:P,children:t.name})})}),y.jsx("div",{className:"sf:relative sf:flex sf:min-h-0 sf:flex-1 sf:items-center sf:px-3 sf:py-2.5","data-testid":"shape-node-body",children:c==="description"&&p?y.jsx(lo,{initialValue:U,field:"node-description",commitMode:"blur-only",onCommit:D=>{var N;return(N=t.onDescriptionChange)==null?void 0:N.call(t,e,D)},onExit:()=>h(null),className:"sf:w-full sf:text-[16px] sf:text-muted-foreground",style:V,placeholder:"Description"}):y.jsx("button",{type:"button",className:ie("sf:block sf:w-full sf:whitespace-pre-wrap sf:wrap-break-word sf:bg-transparent sf:p-0 sf:text-left sf:text-[16px] sf:leading-tight",R?"text-muted-foreground":"sf:italic sf:text-muted-foreground/40",p?"sf:hover:opacity-80":""),style:V,children:R?U:p?"Double-click to add description":""})})]});return y.jsxs("div",{className:ie("group",g?"":"sf:relative",g?"sf:flex sf:flex-col sf:overflow-hidden sf:text-left":"sf:flex sf:items-center sf:justify-center sf:p-2 sf:text-center sf:text-[22px]",x?"sf:h-full sf:w-full":"",JZ(o)),style:T,"data-testid":"shape-node","data-node-type":"shapeNode","data-shape":o,onDoubleClick:E,children:[z,y.jsx(Gu,{visible:!!n&&!!t.onResize&&!d,cornerVariant:"visible",minWidth:80,minHeight:40,onResizeStart:a,onResize:s,onResizeEnd:l}),!b&&y.jsx(at,{type:"target",position:ye.Top,id:"t",isConnectable:r,className:ie(O0,n&&"sf:opacity-100!")}),!b&&y.jsx(at,{type:"target",position:ye.Left,id:"l",isConnectable:r,className:ie(O0,n&&"sf:opacity-100!")}),g?B:O,!b&&y.jsx(at,{type:"source",position:ye.Right,id:"r",isConnectable:r,className:ie(O0,n&&"sf:opacity-100!")}),!b&&y.jsx(at,{type:"source",position:ye.Bottom,id:"b",isConnectable:r,className:ie(O0,n&&"sf:opacity-100!")})]})}function S0e(e,t){return e.selected===t.selected&&e.data===t.data&&e.width===t.width&&e.height===t.height}const L0e=m.memo(C0e,S0e),I0e={active:"sf:border-amber-400 sf:bg-amber-950/40 sf:text-amber-300",success:"sf:border-emerald-400 sf:bg-emerald-950/40 sf:text-emerald-300 sf:seeflow-pill-pop",error:"sf:border-rose-400 sf:bg-rose-950/40 sf:text-rose-300 sf:seeflow-pill-pop"};function E0e({visualStatus:e,summary:t,"data-testid":n}){if(e==="idle")return null;const r=e==="active"?h2:e==="success"?fo:wi;return y.jsxs("span",{"data-testid":n,"data-visual-status":e,title:t,className:ie("sf:relative sf:inline-flex sf:h-5 sf:items-center sf:justify-center sf:rounded-full sf:border-[1.5px] sf:px-1",I0e[e]),children:[e==="active"?y.jsx("span",{"aria-hidden":!0,"data-testid":"status-icon-pill-ring",className:"sf:absolute sf:inset-0 sf:rounded-full sf:seeflow-ring-spin",style:{background:"conic-gradient(from 0deg, var(--amber-hi) 0deg, transparent 200deg, var(--amber-hi) 360deg)",WebkitMask:"radial-gradient(circle, transparent calc(50% - 1.5px), #000 calc(50% - 1.5px))",mask:"radial-gradient(circle, transparent calc(50% - 1.5px), #000 calc(50% - 1.5px))"}}):null,y.jsx(r,{className:"sf:h-3 sf:w-3 sf:relative","aria-hidden":!0})]})}const A0e=100,P0e=44,R0e=250;function z0e({id:e,data:t,selected:n,isConnectable:r}){var L,P;const o=t.status??"idle",i=__(t.status,t.statusReport),a=t.description??t.kind,{isResizing:s,onResizeStart:l,onResizeEvent:c,onResizeEnd:h}=Zu({onResize:T=>{var E;return(E=t.onResize)==null?void 0:E.call(t,e,T)},onResizeEnd:T=>{var E;return(E=t.onResizeEnd)==null?void 0:E.call(t,e,T)},setResizing:t.setResizing}),[d,f]=m.useState(null),[p,k]=m.useState(!1),v=!!t.onNameChange,w=!!t.onDescriptionChange,g=!!t.onIconChange&&!!n&&!!t.icon,M=t.width!==void 0||t.height!==void 0,x={...t.fontSize!==void 0?{fontSize:`${t.fontSize}px`}:{},...tt(t.textColor,"text")},b=x,S={borderColor:((L=t.statusReport)==null?void 0:L.state)==="error"?tt("red","node").borderColor:tt(t.borderColor,"node").borderColor,backgroundColor:tt(t.backgroundColor,"node").backgroundColor,borderWidth:t.borderSize!==void 0?t.borderSize:void 0,borderStyle:t.borderStyle,borderRadius:t.cornerRadius!==void 0?t.cornerRadius:void 0,...M?{}:{width:R0e}},C=v||w?T=>{if(d!==null)return;const E=T.target;if(!(E!=null&&E.closest(".react-flow__handle"))&&!(E!=null&&E.closest(".react-flow__resize-control"))){if(T.stopPropagation(),E!=null&&E.closest('[data-testid="node-header"]')){v&&f("name");return}if(E!=null&&E.closest('[data-testid="node-content"]')){w?f("description"):v&&f("name");return}w?f("description"):v&&f("name")}}:void 0;return y.jsxs("div",{className:ie("sf:group sf:flex sf:flex-col sf:justify-center sf:overflow-hidden sf:rounded-lg sf:border-[3px] sf:border-dashed sf:shadow-sm sf:transition-shadow",M?"sf:h-full sf:w-full":"",o==="running"?"seeflow-node-pulse":""),style:S,"data-status":o,"data-testid":"state-node","data-node-type":"stateNode",onDoubleClick:C,children:[y.jsx(Gu,{visible:!!n&&!!t.onResize,cornerVariant:"visible",minWidth:A0e,minHeight:P0e,onResizeStart:l,onResize:c,onResizeEnd:h}),y.jsx(at,{type:"target",position:ye.Top,id:"t",isConnectable:r,className:ie("sf:opacity-0 sf:transition-opacity",n&&"sf:opacity-100!")}),y.jsx(at,{type:"target",position:ye.Left,id:"l",isConnectable:r,className:ie("sf:opacity-0 sf:transition-opacity",n&&"sf:opacity-100!")}),y.jsxs("div",{className:"sf:flex sf:shrink-0 sf:items-center sf:justify-between sf:gap-2 sf:border-b sf:border-border sf:px-3 sf:py-3",style:tt(t.backgroundColor,"node-header"),"data-testid":"node-header",children:[t.icon?g&&t.onIconChange?y.jsx(uz,{open:p,onOpenChange:k,onPick:T=>{var E;(E=t.onIconChange)==null||E.call(t,e,T),k(!1)},anchor:y.jsx("button",{type:"button","data-testid":"state-node-icon-trigger","aria-label":"Change icon","aria-pressed":p,className:ie("sf:inline-flex sf:shrink-0 sf:cursor-pointer sf:items-center sf:justify-center sf:rounded-sm sf:bg-transparent sf:p-0 sf:transition-shadow","sf:hover:ring-2 sf:hover:ring-ring/40 sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring"),onClick:T=>{T.stopPropagation()},onMouseDown:T=>{T.stopPropagation()},onDoubleClick:T=>{T.stopPropagation()},children:y.jsx(t1,{name:t.icon,size:16,style:tt(t.textColor,"text"),"aria-hidden":!0})})}):y.jsx(t1,{name:t.icon,size:16,className:"shrink-0",style:tt(t.textColor,"text"),"aria-hidden":!0}):null,y.jsx("div",{className:"sf:min-w-0 sf:flex-1 sf:text-[18px] sf:font-semibold sf:leading-tight sf:text-foreground/90",style:x,children:d==="name"&&v?y.jsx(lo,{initialValue:t.name,field:"node-name",required:!0,commitMode:"blur-only",onCommit:T=>{var E;return(E=t.onNameChange)==null?void 0:E.call(t,e,T)},onExit:()=>f(null),className:"sf:text-[18px] sf:font-semibold sf:text-foreground/90",style:x}):y.jsx("button",{type:"button",className:ie("sf:block sf:w-full sf:whitespace-pre-wrap sf:wrap-break-word sf:bg-transparent sf:p-0 sf:text-left sf:text-[18px] sf:font-semibold sf:leading-tight sf:text-foreground/90",v?"sf:hover:opacity-80":""),style:x,children:t.name})}),y.jsx("div",{className:"sf:flex sf:shrink-0 sf:items-center sf:gap-1",children:y.jsx(E0e,{visualStatus:i,summary:(P=t.statusReport)==null?void 0:P.summary,"data-testid":"state-node-status-pill"})})]}),y.jsx("div",{className:"sf:flex sf:min-h-0 sf:flex-1 sf:items-center sf:px-3 sf:py-2","data-testid":"node-content","data-resizing":s?"true":void 0,children:d==="description"&&w?y.jsx(lo,{initialValue:t.description??"",field:"node-description",multiline:!0,onCommit:T=>{var E;return(E=t.onDescriptionChange)==null?void 0:E.call(t,e,T)},onExit:()=>f(null),className:"sf:w-full sf:text-[18px] sf:text-muted-foreground",style:b,placeholder:t.kind}):y.jsx("button",{type:"button",className:ie("sf:block sf:w-full sf:whitespace-normal sf:wrap-break-word sf:bg-transparent sf:p-0 sf:text-left sf:text-[18px] sf:text-muted-foreground",w?"sf:hover:opacity-80":""),style:b,children:a})}),y.jsx(at,{type:"source",position:ye.Right,id:"r",isConnectable:r,className:ie("sf:opacity-0 sf:transition-opacity",n&&"sf:opacity-100!")}),y.jsx(at,{type:"source",position:ye.Bottom,id:"b",isConnectable:r,className:ie("sf:opacity-0 sf:transition-opacity",n&&"sf:opacity-100!")})]})}function j0e(e,t){return e.selected===t.selected&&e.data===t.data&&e.width===t.width&&e.height===t.height}const T0e=m.memo(z0e,j0e);function N0e(e,t){return t==="success"&&e!=="success"}const D0e=8,q0=10,Vq=(e,t,n)=>{switch(n){case"top":return{cx:e,cy:t-q0};case"bottom":return{cx:e,cy:t+q0};case"left":return{cx:e-q0,cy:t};case"right":return{cx:e+q0,cy:t}}},Bq={top:ye.Top,right:ye.Right,bottom:ye.Bottom,left:ye.Left},$q=e=>{switch(e){case ye.Top:return"top";case ye.Right:return"right";case ye.Bottom:return"bottom";case ye.Left:return"left"}};function _0e({id:e,source:t,target:n,sourceX:r,sourceY:o,targetX:i,targetY:a,sourcePosition:s,targetPosition:l,label:c,style:h,markerEnd:d,markerStart:f,interactionWidth:p,data:k}){const[v,w]=m.useState(!1),g=XO(t),M=XO(n),x=(g==null?void 0:g.data)??{},b=__(x.status,x.statusReport),S=m.useRef(void 0);m.useEffect(()=>{const me=S.current;if(S.current=b,!N0e(me,b))return;const ge=document.querySelector(`.react-flow__edge[data-id="${CSS.escape(e)}"]`);if(!ge)return;ge.setAttribute("data-handoff","true");const ee=window.setTimeout(()=>{ge.removeAttribute("data-handoff")},500);return()=>{window.clearTimeout(ee),ge.removeAttribute("data-handoff")}},[e,b]);const C={x:r,y:o,side:$q(s)},L={x:i,y:a,side:$q(l)},P=oue(g?{box:{x:g.internals.positionAbsolute.x,y:g.internals.positionAbsolute.y,w:g.measured.width??g.width??0,h:g.measured.height??g.height??0},autoPicked:k==null?void 0:k.sourceHandleAutoPicked,pin:k==null?void 0:k.sourcePin,fallback:C}:null,M?{box:{x:M.internals.positionAbsolute.x,y:M.internals.positionAbsolute.y,w:M.measured.width??M.width??0,h:M.measured.height??M.height??0},autoPicked:k==null?void 0:k.targetHandleAutoPicked,pin:k==null?void 0:k.targetPin,fallback:L}:null),T=P.source.x,E=P.source.y,z=Bq[P.source.side],A=P.target.x,U=P.target.y,R=Bq[P.target.side],V=P.source.side,O=P.target.side,B=Vq(T,E,V),D=Vq(A,U,O);m.useEffect(()=>{const me=document.querySelector(`.react-flow__edge[data-id="${CSS.escape(e)}"]`);if(!me)return;const ge=me.querySelector(".react-flow__edgeupdater-source"),ee=me.querySelector(".react-flow__edgeupdater-target");ge&&(ge.setAttribute("cx",String(B.cx)),ge.setAttribute("cy",String(B.cy))),ee&&(ee.setAttribute("cx",String(D.cx)),ee.setAttribute("cy",String(D.cy)))},[e,B.cx,B.cy,D.cx,D.cy]);const[N,I,W]=(k==null?void 0:k.path)==="step"?nh({sourceX:T,sourceY:E,sourcePosition:z,targetX:A,targetY:U,targetPosition:R,borderRadius:D0e}):KR({sourceX:T,sourceY:E,sourcePosition:z,targetX:A,targetY:U,targetPosition:R}),H=k==null?void 0:k.onLabelChange,j=typeof c=="string"?c:"",G=!!H,X=k==null?void 0:k.fontSize,Y=typeof X=="number"?{fontSize:`${X}px`}:void 0,re=k==null?void 0:k.registerEditHandle;m.useEffect(()=>{if(!(!re||!G))return re(e,()=>w(!0))},[e,re,G]);const ne=typeof(k==null?void 0:k.kind)=="string"?k.kind:void 0;m.useEffect(()=>{if(!ne)return;const me=document.querySelector(`.react-flow__edge[data-id="${CSS.escape(e)}"]`);if(me)return me.setAttribute("data-edge-kind",ne),()=>{me.removeAttribute("data-edge-kind")}},[e,ne]);const ae=(k==null?void 0:k.reconnectable)===!0,ve=(k==null?void 0:k.sourcePin)!==void 0,be=(k==null?void 0:k.targetPin)!==void 0;return y.jsxs(y.Fragment,{children:[y.jsx(bh,{id:e,path:N,style:h,markerEnd:d,markerStart:f,interactionWidth:p}),ae?y.jsxs(k1e,{children:[y.jsx("div",{"data-testid":`edge-endpoint-source-${e}`,"data-pinned":ve?"true":"false",className:"seeflow-connector-endpoint-dot",style:{transform:`translate(-50%, -50%) translate(${B.cx}px, ${B.cy}px)`}}),y.jsx("div",{"data-testid":`edge-endpoint-target-${e}`,"data-pinned":be?"true":"false",className:"seeflow-connector-endpoint-dot",style:{transform:`translate(-50%, -50%) translate(${D.cx}px, ${D.cy}px)`}})]}):null,y.jsx(y1e,{children:y.jsx("div",{className:"nodrag nopan nowheel pointer-events-auto absolute",style:{transform:`translate(-50%, -50%) translate(${I}px, ${W}px)`},children:v&&G?y.jsx(lo,{initialValue:j,field:"connector-label",onCommit:me=>H==null?void 0:H(e,me),onExit:()=>w(!1),className:"sf:rounded-md sf:border sf:border-border sf:bg-card sf:px-1.5 sf:py-0.5 sf:text-[11px] sf:text-foreground/85 sf:shadow-md",style:Y,placeholder:"Label"}):j?y.jsx("button",{type:"button",className:ie("sf:rounded-md sf:border sf:border-border sf:bg-card sf:px-1.5 sf:py-0.5 sf:text-[11px] sf:text-foreground/85 sf:shadow-md",G?"sf:hover:bg-muted":""),style:Y,onDoubleClick:G?me=>{me.stopPropagation(),w(!0)}:void 0,children:j}):G?y.jsx("button",{type:"button","aria-label":"Add connector label",className:"sf:rounded-full sf:border sf:border-dashed sf:border-muted-foreground/40 sf:bg-card sf:px-1 sf:text-[10px] sf:text-muted-foreground/60 sf:opacity-0 sf:transition-opacity sf:hover:opacity-100 sf:group-hover/canvas:opacity-50",onDoubleClick:me=>{me.stopPropagation(),w(!0)},children:"+"}):null})})]})}var Uq=1,H0e=.9,F0e=.8,O0e=.17,Hj=.1,Fj=.999,q0e=.9999,V0e=.99,B0e=/[\\\/_+.#"@\[\(\{&]/,$0e=/[\\\/_+.#"@\[\(\{&]/g,U0e=/[\s-]/,tK=/[\s-]/g;function EN(e,t,n,r,o,i,a){if(i===t.length)return o===e.length?Uq:V0e;var s=`${o},${i}`;if(a[s]!==void 0)return a[s];for(var l=r.charAt(i),c=n.indexOf(l,o),h=0,d,f,p,k;c>=0;)d=EN(e,t,n,r,c+1,i+1,a),d>h&&(c===o?d*=Uq:B0e.test(e.charAt(c-1))?(d*=F0e,p=e.slice(o,c-1).match($0e),p&&o>0&&(d*=Math.pow(Fj,p.length))):U0e.test(e.charAt(c-1))?(d*=H0e,k=e.slice(o,c-1).match(tK),k&&o>0&&(d*=Math.pow(Fj,k.length))):(d*=O0e,o>0&&(d*=Math.pow(Fj,c-o))),e.charAt(c)!==t.charAt(i)&&(d*=q0e)),(d<Hj&&n.charAt(c-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(c-1)!==r.charAt(i))&&(f=EN(e,t,n,r,c+1,i+2,a),f*Hj>d&&(d=f*Hj)),d>h&&(h=d),c=n.indexOf(l,c+1);return a[s]=h,h}function Wq(e){return e.toLowerCase().replace(tK," ")}function W0e(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,EN(e,t,Wq(e),Wq(t),0,0,{})}var dz="Dialog",[nK]=Nr(dz),[G0e,Dr]=nK(dz),rK=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:a=!0}=e,s=m.useRef(null),l=m.useRef(null),[c,h]=c1({prop:r,defaultProp:o??!1,onChange:i,caller:dz});return y.jsx(G0e,{scope:t,triggerRef:s,contentRef:l,contentId:dn(),titleId:dn(),descriptionId:dn(),open:c,onOpenChange:h,onOpenToggle:m.useCallback(()=>h(d=>!d),[h]),modal:a,children:n})};rK.displayName=dz;var oK="DialogTrigger",Z0e=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Dr(oK,n),i=dt(t,o.triggerRef);return y.jsx(Ve.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":q_(o.open),...r,ref:i,onClick:Ie(e.onClick,o.onOpenToggle)})});Z0e.displayName=oK;var F_="DialogPortal",[K0e,iK]=nK(F_,{forceMount:void 0}),aK=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,i=Dr(F_,t);return y.jsx(K0e,{scope:t,forceMount:n,children:m.Children.map(r,a=>y.jsx(Qn,{present:n||i.open,children:y.jsx(Lh,{asChild:!0,container:o,children:a})}))})};aK.displayName=F_;var yR="DialogOverlay",sK=m.forwardRef((e,t)=>{const n=iK(yR,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=Dr(yR,e.__scopeDialog);return i.modal?y.jsx(Qn,{present:r||i.open,children:y.jsx(Y0e,{...o,ref:t})}):null});sK.displayName=yR;var X0e=Nu("DialogOverlay.RemoveScroll"),Y0e=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Dr(yR,n);return y.jsx(lz,{as:X0e,allowPinchZoom:!0,shards:[o.contentRef],children:y.jsx(Ve.div,{"data-state":q_(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),r1="DialogContent",lK=m.forwardRef((e,t)=>{const n=iK(r1,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=Dr(r1,e.__scopeDialog);return y.jsx(Qn,{present:r||i.open,children:i.modal?y.jsx(Q0e,{...o,ref:t}):y.jsx(J0e,{...o,ref:t})})});lK.displayName=r1;var Q0e=m.forwardRef((e,t)=>{const n=Dr(r1,e.__scopeDialog),r=m.useRef(null),o=dt(t,n.contentRef,r);return m.useEffect(()=>{const i=r.current;if(i)return N_(i)},[]),y.jsx(cK,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ie(e.onCloseAutoFocus,i=>{var a;i.preventDefault(),(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:Ie(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,s=a.button===0&&a.ctrlKey===!0;(a.button===2||s)&&i.preventDefault()}),onFocusOutside:Ie(e.onFocusOutside,i=>i.preventDefault())})}),J0e=m.forwardRef((e,t)=>{const n=Dr(r1,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return y.jsx(cK,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var a,s;(a=e.onCloseAutoFocus)==null||a.call(e,i),i.defaultPrevented||(r.current||(s=n.triggerRef.current)==null||s.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=i.target;((c=n.triggerRef.current)==null?void 0:c.contains(a))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),cK=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,...a}=e,s=Dr(r1,n),l=m.useRef(null),c=dt(t,l);return b_(),y.jsxs(y.Fragment,{children:[y.jsx(tz,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:y.jsx(Ch,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":q_(s.open),...a,ref:c,onDismiss:()=>s.onOpenChange(!1)})}),y.jsxs(y.Fragment,{children:[y.jsx(efe,{titleId:s.titleId}),y.jsx(nfe,{contentRef:l,descriptionId:s.descriptionId})]})]})}),O_="DialogTitle",uK=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Dr(O_,n);return y.jsx(Ve.h2,{id:o.titleId,...r,ref:t})});uK.displayName=O_;var dK="DialogDescription",hK=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Dr(dK,n);return y.jsx(Ve.p,{id:o.descriptionId,...r,ref:t})});hK.displayName=dK;var fK="DialogClose",pK=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Dr(fK,n);return y.jsx(Ve.button,{type:"button",...r,ref:t,onClick:Ie(e.onClick,()=>o.onOpenChange(!1))})});pK.displayName=fK;function q_(e){return e?"open":"closed"}var yK="DialogTitleWarning",[E8e,mK]=rde(yK,{contentName:r1,titleName:O_,docsSlug:"dialog"}),efe=({titleId:e})=>{const t=mK(yK),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
7803
|
+
`)},Ehe=0,L1=[];function Ahe(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(Ehe++)[0],i=m.useState(jZ)[0],a=m.useRef(e);m.useEffect(function(){a.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var v=X2e([e.lockRef.current],(e.shards||[]).map(Dq),!0).filter(Boolean);return v.forEach(function(w){return w.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),v.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var s=m.useCallback(function(v,w){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!a.current.allowPinchZoom;var g=H0(v),M=n.current,x="deltaX"in v?v.deltaX:M[0]-g[0],b="deltaY"in v?v.deltaY:M[1]-g[1],S,C=v.target,L=Math.abs(x)>Math.abs(b)?"h":"v";if("touches"in v&&L==="h"&&C.type==="range")return!1;var P=window.getSelection(),T=P&&P.anchorNode,E=T?T===C||T.contains(C):!1;if(E)return!1;var z=Tq(L,C);if(!z)return!0;if(z?S=L:(S=L==="v"?"h":"v",z=Tq(L,C)),!z)return!1;if(!r.current&&"changedTouches"in v&&(x||b)&&(r.current=S),!S)return!0;var A=r.current||S;return She(A,w,v,A==="h"?x:b)},[]),l=m.useCallback(function(v){var w=v;if(!(!L1.length||L1[L1.length-1]!==i)){var g="deltaY"in w?Nq(w):H0(w),M=t.current.filter(function(S){return S.name===w.type&&(S.target===w.target||w.target===S.shadowParent)&&Lhe(S.delta,g)})[0];if(M&&M.should){w.cancelable&&w.preventDefault();return}if(!M){var x=(a.current.shards||[]).map(Dq).filter(Boolean).filter(function(S){return S.contains(w.target)}),b=x.length>0?s(w,x[0]):!a.current.noIsolation;b&&w.cancelable&&w.preventDefault()}}},[]),c=m.useCallback(function(v,w,g,M){var x={name:v,delta:w,target:g,should:M,shadowParent:Phe(g)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(b){return b!==x})},1)},[]),h=m.useCallback(function(v){n.current=H0(v),r.current=void 0},[]),d=m.useCallback(function(v){c(v.type,Nq(v),v.target,s(v,e.lockRef.current))},[]),f=m.useCallback(function(v){c(v.type,H0(v),v.target,s(v,e.lockRef.current))},[]);m.useEffect(function(){return L1.push(i),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,S1),document.addEventListener("touchmove",l,S1),document.addEventListener("touchstart",h,S1),function(){L1=L1.filter(function(v){return v!==i}),document.removeEventListener("wheel",l,S1),document.removeEventListener("touchmove",l,S1),document.removeEventListener("touchstart",h,S1)}},[]);var p=e.removeScrollBar,k=e.inert;return m.createElement(m.Fragment,null,k?m.createElement(i,{styles:Ihe(o)}):null,p?m.createElement(ghe,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Phe(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Rhe=ihe(zZ,Ahe);var lz=m.forwardRef(function(e,t){return m.createElement(sz,so({},e,{ref:t,sideCar:Rhe}))});lz.classNames=sz.classNames;var cz="Popover",[_Z]=Nr(cz,[Yu]),Ih=Yu(),[zhe,Gi]=_Z(cz),HZ=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:a=!1}=e,s=Ih(t),l=m.useRef(null),[c,h]=m.useState(!1),[d,f]=c1({prop:r,defaultProp:o??!1,onChange:i,caller:cz});return y.jsx(z_,{...s,children:y.jsx(zhe,{scope:t,contentId:dn(),triggerRef:l,open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(p=>!p),[f]),hasCustomAnchor:c,onCustomAnchorAdd:m.useCallback(()=>h(!0),[]),onCustomAnchorRemove:m.useCallback(()=>h(!1),[]),modal:a,children:n})})};HZ.displayName=cz;var FZ="PopoverAnchor",OZ=m.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Gi(FZ,n),i=Ih(n),{onCustomAnchorAdd:a,onCustomAnchorRemove:s}=o;return m.useEffect(()=>(a(),()=>s()),[a,s]),y.jsx(az,{...i,...r,ref:t})});OZ.displayName=FZ;var qZ="PopoverTrigger",VZ=m.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Gi(qZ,n),i=Ih(n),a=dt(t,o.triggerRef),s=y.jsx(Ve.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":GZ(o.open),...r,ref:a,onClick:Ie(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?s:y.jsx(az,{asChild:!0,...i,children:s})});VZ.displayName=qZ;var D_="PopoverPortal",[jhe,The]=_Z(D_,{forceMount:void 0}),BZ=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,i=Gi(D_,t);return y.jsx(jhe,{scope:t,forceMount:n,children:y.jsx(Qn,{present:n||i.open,children:y.jsx(Lh,{asChild:!0,container:o,children:r})})})};BZ.displayName=D_;var _u="PopoverContent",$Z=m.forwardRef((e,t)=>{const n=The(_u,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,i=Gi(_u,e.__scopePopover);return y.jsx(Qn,{present:r||i.open,children:i.modal?y.jsx(Dhe,{...o,ref:t}):y.jsx(_he,{...o,ref:t})})});$Z.displayName=_u;var Nhe=Nu("PopoverContent.RemoveScroll"),Dhe=m.forwardRef((e,t)=>{const n=Gi(_u,e.__scopePopover),r=m.useRef(null),o=dt(t,r),i=m.useRef(!1);return m.useEffect(()=>{const a=r.current;if(a)return N_(a)},[]),y.jsx(lz,{as:Nhe,allowPinchZoom:!0,children:y.jsx(UZ,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ie(e.onCloseAutoFocus,a=>{var s;a.preventDefault(),i.current||(s=n.triggerRef.current)==null||s.focus()}),onPointerDownOutside:Ie(e.onPointerDownOutside,a=>{const s=a.detail.originalEvent,l=s.button===0&&s.ctrlKey===!0,c=s.button===2||l;i.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:Ie(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),_he=m.forwardRef((e,t)=>{const n=Gi(_u,e.__scopePopover),r=m.useRef(!1),o=m.useRef(!1);return y.jsx(UZ,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var a,s;(a=e.onCloseAutoFocus)==null||a.call(e,i),i.defaultPrevented||(r.current||(s=n.triggerRef.current)==null||s.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=i.target;((c=n.triggerRef.current)==null?void 0:c.contains(a))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),UZ=m.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:h,...d}=e,f=Gi(_u,n),p=Ih(n);return b_(),y.jsx(tz,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:y.jsx(Ch,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:h,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>f.onOpenChange(!1),children:y.jsx(j_,{"data-state":GZ(f.open),role:"dialog",id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),WZ="PopoverClose",Hhe=m.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Gi(WZ,n);return y.jsx(Ve.button,{type:"button",...r,ref:t,onClick:Ie(e.onClick,()=>o.onOpenChange(!1))})});Hhe.displayName=WZ;var Fhe="PopoverArrow",Ohe=m.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ih(n);return y.jsx(T_,{...o,...r,ref:t})});Ohe.displayName=Fhe;function GZ(e){return e?"open":"closed"}var qhe=HZ,Vhe=OZ,Bhe=VZ,$he=BZ,ZZ=$Z;const KZ=m.createContext(null);function Uhe({containerRef:e,children:t}){return y.jsx(KZ.Provider,{value:e.current,children:t})}function Qu(){return m.useContext(KZ)??void 0}const Ju=qhe,Eh=Bhe,Whe=Vhe,u1=m.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>{const i=Qu();return y.jsx($he,{container:i,children:y.jsx(ZZ,{ref:o,align:t,sideOffset:n,className:ie("sf:z-50 sf:w-72 sf:rounded-md sf:border sf:bg-popover sf:p-4 sf:text-popover-foreground sf:shadow-md sf:outline-hidden sf:data-[state=open]:animate-in sf:data-[state=closed]:animate-out sf:data-[state=closed]:fade-out-0 sf:data-[state=open]:fade-in-0 sf:data-[state=closed]:zoom-out-95 sf:data-[state=open]:zoom-in-95 sf:data-[side=bottom]:slide-in-from-top-2 sf:data-[side=left]:slide-in-from-right-2 sf:data-[side=right]:slide-in-from-left-2 sf:data-[side=top]:slide-in-from-bottom-2",e),...r})})});u1.displayName=ZZ.displayName;const I1=8,F0=32,_j=256,_q=2;function Ghe(e,t){const n=t.trim().toLowerCase();return n===""?e.slice():e.filter(r=>r.toLowerCase().includes(n))}function uz({open:e,onOpenChange:t,anchor:n,onPick:r,clearable:o=!0}){const[i,a]=m.useState(""),s=m.useMemo(()=>e?QG():[],[e]);return m.useEffect(()=>{e||a("")},[e]),y.jsxs(Ju,{open:e,onOpenChange:t,children:[y.jsx(Eh,{asChild:!0,children:n}),y.jsx(u1,{align:"start",side:"bottom",sideOffset:6,className:"sf:w-[340px] sf:p-0","data-testid":"icon-picker-popover",children:y.jsx(Zhe,{query:i,onQueryChange:a,recents:s,onPick:r,clearable:o})})]})}function Zhe({query:e,onQueryChange:t,recents:n,onPick:r,clearable:o=!0}){const i=m.useMemo(()=>Ghe(_ne,e),[e]),a=e.trim()===""&&n.length>0,s=o&&e.trim()==="",[l,c]=m.useState(0),h=Math.max(1,Math.ceil(i.length/I1)),d=h*F0,f=Math.ceil(_j/F0)+_q*2,p=Math.max(0,Math.floor(l/F0)-_q),k=Math.min(h,p+f),v=p*I1,w=Math.min(i.length,k*I1),g=i.slice(v,w);return y.jsxs("div",{className:"sf:flex sf:w-full sf:flex-col",children:[y.jsx("div",{className:"sf:border-b sf:border-border sf:p-2",children:y.jsx("input",{type:"text",value:e,placeholder:"Search icons…","aria-label":"Search icons","data-testid":"icon-picker-search",className:ie("sf:flex sf:h-8 sf:w-full sf:rounded-md sf:border sf:border-input sf:bg-background sf:px-3 sf:text-sm","placeholder:text-muted-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-1"),onChange:M=>t(M.target.value)})}),a?y.jsxs("div",{className:"sf:border-b sf:border-border sf:p-2","data-testid":"icon-picker-recents",children:[y.jsx("div",{className:"sf:mb-1 sf:px-1 sf:text-[11px] sf:font-medium sf:uppercase sf:tracking-wide sf:text-muted-foreground",children:"Recent"}),y.jsx("div",{className:"sf:grid sf:gap-1",style:{gridTemplateColumns:`repeat(${I1}, minmax(0, 1fr))`},children:n.map(M=>Hq(M,r,`icon-picker-recent-${M}`))})]}):null,y.jsxs("div",{className:"sf:p-2",children:[y.jsx("div",{className:"sf:mb-1 sf:px-1 sf:text-[11px] sf:font-medium sf:uppercase sf:tracking-wide sf:text-muted-foreground",children:"All icons"}),s?y.jsx("div",{className:"sf:mb-1 sf:grid sf:gap-1",style:{gridTemplateColumns:`repeat(${I1}, minmax(0, 1fr))`},children:Khe(r)}):null,i.length===0?y.jsx("div",{className:"sf:flex sf:items-center sf:justify-center sf:text-xs sf:text-muted-foreground",style:{height:_j},"data-testid":"icon-picker-empty",children:"No icons match."}):y.jsx("div",{"data-testid":"icon-picker-all",className:"overflow-y-auto",style:{height:_j},onScroll:M=>c(M.currentTarget.scrollTop),children:y.jsx("div",{style:{height:d,position:"relative"},children:y.jsx("div",{style:{position:"absolute",top:p*F0,left:0,right:0},children:y.jsx("div",{className:"sf:grid sf:gap-1",style:{gridTemplateColumns:`repeat(${I1}, minmax(0, 1fr))`},children:g.map(M=>Hq(M,r,`icon-picker-tile-${M}`))})})})})]})]})}function Hq(e,t,n){const r=Cu[e];return y.jsx("button",{type:"button",title:e,"aria-label":e,"data-testid":n,"data-icon-name":e,onClick:()=>t(e),className:ie("sf:inline-flex sf:h-7 sf:w-7 sf:items-center sf:justify-center sf:rounded-md sf:text-muted-foreground sf:transition-colors","sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-1"),children:r?y.jsx(r,{className:"sf:h-4 sf:w-4","aria-hidden":"true"}):null},n)}function Khe(e){return y.jsx("button",{type:"button",title:"No icon","aria-label":"No icon","data-testid":"icon-picker-tile-none",onClick:()=>e(null),className:ie("sf:inline-flex sf:h-7 sf:w-7 sf:items-center sf:justify-center sf:rounded-md sf:text-muted-foreground sf:transition-colors","sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-1"),children:y.jsx(Yd,{className:"sf:h-4 sf:w-4","aria-hidden":"true"})},"icon-picker-tile-none")}var Xhe=Symbol.for("react.lazy"),fR=dD[" use ".trim().toString()];function Yhe(e){return typeof e=="object"&&e!==null&&"then"in e}function XZ(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Xhe&&"_payload"in e&&Yhe(e._payload)}function Qhe(e){const t=e0e(e),n=m.forwardRef((r,o)=>{let{children:i,...a}=r;XZ(i)&&typeof fR=="function"&&(i=fR(i._payload));const s=m.Children.toArray(i),l=s.find(n0e);if(l){const c=l.props.children,h=s.map(d=>d===l?m.Children.count(c)>1?m.Children.only(null):m.isValidElement(c)?c.props.children:null:d);return y.jsx(t,{...a,ref:o,children:m.isValidElement(c)?m.cloneElement(c,void 0,h):null})}return y.jsx(t,{...a,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}var Jhe=Qhe("Slot");function e0e(e){const t=m.forwardRef((n,r)=>{let{children:o,...i}=n;if(XZ(o)&&typeof fR=="function"&&(o=fR(o._payload)),m.isValidElement(o)){const a=o0e(o),s=r0e(i,o.props);return o.type!==m.Fragment&&(s.ref=r?ko(r,a):a),m.cloneElement(o,s)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var t0e=Symbol("radix.slottable");function n0e(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===t0e}function r0e(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...s)=>{const l=i(...s);return o(...s),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function o0e(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const Fq=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Oq=eW,YZ=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return Oq(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:i}=t,a=Object.keys(o).map(c=>{const h=n==null?void 0:n[c],d=i==null?void 0:i[c];if(h===null)return null;const f=Fq(h)||Fq(d);return o[c][f]}),s=n&&Object.entries(n).reduce((c,h)=>{let[d,f]=h;return f===void 0||(c[d]=f),c},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((c,h)=>{let{class:d,className:f,...p}=h;return Object.entries(p).every(k=>{let[v,w]=k;return Array.isArray(w)?w.includes({...i,...s}[v]):{...i,...s}[v]===w})?[...c,d,f]:c},[]);return Oq(e,a,l,n==null?void 0:n.class,n==null?void 0:n.className)},i0e=YZ("sf:inline-flex sf:items-center sf:justify-center sf:whitespace-nowrap sf:rounded-md sf:text-sm sf:font-medium sf:ring-offset-background sf:transition-colors sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-2 sf:disabled:pointer-events-none sf:disabled:opacity-50",{variants:{variant:{default:"sf:bg-primary sf:text-primary-foreground sf:font-semibold sf:hover:bg-emerald-400",destructive:"sf:bg-destructive sf:text-destructive-foreground sf:hover:bg-destructive/90",outline:"sf:border sf:border-input sf:bg-background sf:hover:bg-secondary sf:hover:text-foreground",secondary:"sf:bg-secondary sf:text-secondary-foreground sf:hover:bg-secondary/80",ghost:"sf:text-muted-foreground sf:hover:bg-muted sf:hover:text-foreground",link:"sf:text-primary sf:underline-offset-4 sf:hover:underline"},size:{default:"sf:h-9 sf:px-4 sf:py-2",sm:"sf:h-8 sf:rounded-md sf:px-3",lg:"sf:h-11 sf:rounded-md sf:px-8",icon:"sf:h-9 sf:w-9"}},defaultVariants:{variant:"default",size:"default"}}),Nt=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},i)=>{const a=r?Jhe:"button";return y.jsx(a,{className:ie(i0e({variant:t,size:n,className:e})),ref:i,...o})});Nt.displayName="Button";function __(e,t){return e==="error"||(t==null?void 0:t.state)==="error"?"error":e==="running"||(t==null?void 0:t.state)==="pending"?"active":e==="done"||(t==null?void 0:t.state)==="ok"?"success":"idle"}const a0e={ok:"sf:bg-emerald-400",warn:"sf:bg-amber-400",error:"sf:bg-rose-400",pending:"sf:bg-slate-400"};function QZ({state:e,summary:t,"data-testid":n}){return y.jsxs("span",{"data-testid":n,"data-state":e,className:"sf:inline-flex sf:max-w-full sf:items-center sf:gap-1.5 sf:text-[11px] sf:leading-tight sf:text-muted-foreground",children:[y.jsx("span",{"aria-hidden":!0,className:ie("sf:h-2 sf:w-2 sf:shrink-0 sf:rounded-full",a0e[e])}),t?y.jsx("span",{className:"sf:min-w-0 sf:flex-1 sf:truncate",title:t,children:t}):null]})}const s0e=100,l0e=44,c0e=250;function u0e({visualStatus:e,disabled:t,buttonLabel:n,isError:r,onClick:o}){return y.jsxs(Nt,{type:"button",size:"sm",variant:"secondary",disabled:t,"data-testid":"play-button","data-status":e==="idle"?"idle":e,"data-visual-status":e,"aria-label":n,title:n,onClick:o,className:ie("sf:group sf:relative sf:h-8 sf:w-8 sf:rounded-full sf:p-0","sf:hover:bg-primary sf:hover:text-primary-foreground","sf:focus-visible:bg-primary sf:focus-visible:text-primary-foreground",e==="success"&&"sf:seeflow-play-pop",e==="error"&&"sf:inline-edit-shake",r&&"sf:border-2 sf:border-rose-500"),children:[e==="active"?y.jsx("span",{"aria-hidden":!0,"data-testid":"play-button-ring",className:ie("sf:absolute sf:inset-0 sf:rounded-full sf:seeflow-ring-spin"),style:{background:"conic-gradient(from 0deg, var(--emerald-glow) 0deg, transparent 200deg, var(--emerald-glow) 360deg)",WebkitMask:"radial-gradient(circle, transparent calc(50% - 2px), #000 calc(50% - 2px))",mask:"radial-gradient(circle, transparent calc(50% - 2px), #000 calc(50% - 2px))"}}):null,e==="success"?y.jsxs(y.Fragment,{children:[y.jsx(fo,{className:"sf:h-4 sf:w-4 sf:relative sf:text-emerald-300 sf:group-hover:hidden","aria-hidden":!0}),y.jsx(Bc,{className:"sf:h-4 sf:w-4 sf:relative sf:hidden sf:group-hover:block","aria-hidden":!0})]}):e==="error"?y.jsxs(y.Fragment,{children:[y.jsx(xi,{className:"sf:h-4 sf:w-4 sf:relative sf:text-rose-300 sf:group-hover:hidden","aria-hidden":!0}),y.jsx(Bc,{className:"sf:h-4 sf:w-4 sf:relative sf:hidden sf:group-hover:block","aria-hidden":!0})]}):y.jsx(Bc,{className:ie("sf:h-4 sf:w-4 sf:relative",e==="active"&&"sf:opacity-80"),"aria-hidden":!0})]})}function d0e({id:e,data:t,selected:n,isConnectable:r}){var A;const o=t.status,i=t.playAction,a=t.description??t.kind,s=!!i&&!!t.onPlay,l=__(o,t.statusReport),c=o==="running",h=l==="error",d=l==="active"?"Running…":l==="success"?"Succeeded, run again":l==="error"?t.errorMessage?`Failed: ${t.errorMessage}`:"Failed, run again":"Play",{isResizing:f,onResizeStart:p,onResizeEvent:k,onResizeEnd:v}=Zu({onResize:U=>{var R;return(R=t.onResize)==null?void 0:R.call(t,e,U)},onResizeEnd:U=>{var R;return(R=t.onResizeEnd)==null?void 0:R.call(t,e,U)},setResizing:t.setResizing}),[w,g]=m.useState(null),[M,x]=m.useState(!1),b=!!t.onNameChange,S=!!t.onDescriptionChange,C=!!t.onIconChange&&!!n&&!!t.icon,L=t.width!==void 0||t.height!==void 0,P={...t.fontSize!==void 0?{fontSize:`${t.fontSize}px`}:{},...tt(t.textColor,"text")},T=P,E={borderColor:((A=t.statusReport)==null?void 0:A.state)==="error"?tt("red","node").borderColor:tt(t.borderColor,"node").borderColor,backgroundColor:t.backgroundColor!==void 0?tt(t.backgroundColor,"node").backgroundColor:mh,borderWidth:t.borderSize!==void 0?t.borderSize:void 0,borderStyle:t.borderStyle,borderRadius:t.cornerRadius!==void 0?t.cornerRadius:void 0,...L?{}:{width:c0e}},z=b||S?U=>{if(w!==null)return;const R=U.target;if(!(R!=null&&R.closest(".react-flow__handle"))&&!(R!=null&&R.closest(".react-flow__resize-control"))){if(U.stopPropagation(),R!=null&&R.closest('[data-testid="node-header"]')){b&&g("name");return}if(R!=null&&R.closest('[data-testid="node-content"]')){S?g("description"):b&&g("name");return}S?g("description"):b&&g("name")}}:void 0;return y.jsxs("div",{className:ie("sf:group sf:flex sf:flex-col sf:justify-center sf:overflow-hidden sf:rounded-lg sf:border-[3px] sf:shadow-sm sf:transition-shadow",L?"sf:h-full sf:w-full":"",c?"seeflow-node-pulse":""),style:E,"data-status":o??"idle","data-testid":"play-node","data-node-type":"playNode",onDoubleClick:z,children:[y.jsx(Gu,{visible:!!n&&!!t.onResize,cornerVariant:"visible",minWidth:s0e,minHeight:l0e,onResizeStart:p,onResize:k,onResizeEnd:v}),y.jsx(at,{type:"target",position:ye.Top,id:"t",isConnectable:r,className:ie("sf:opacity-0 sf:transition-opacity",n&&"sf:opacity-100!")}),y.jsx(at,{type:"target",position:ye.Left,id:"l",isConnectable:r,className:ie("sf:opacity-0 sf:transition-opacity",n&&"sf:opacity-100!")}),y.jsxs("div",{className:"sf:flex sf:shrink-0 sf:items-center sf:justify-between sf:gap-2 sf:border-b sf:border-border sf:bg-muted/30 sf:px-3 sf:py-3","data-testid":"node-header",children:[t.icon?C&&t.onIconChange?y.jsx(uz,{open:M,onOpenChange:x,onPick:U=>{var R;(R=t.onIconChange)==null||R.call(t,e,U),x(!1)},anchor:y.jsx("button",{type:"button","data-testid":"play-node-icon-trigger","aria-label":"Change icon","aria-pressed":M,className:ie("sf:inline-flex sf:shrink-0 sf:cursor-pointer sf:items-center sf:justify-center sf:rounded-sm sf:bg-transparent sf:p-0 sf:transition-shadow","sf:hover:ring-2 sf:hover:ring-ring/40 sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring"),onClick:U=>{U.stopPropagation()},onMouseDown:U=>{U.stopPropagation()},onDoubleClick:U=>{U.stopPropagation()},children:y.jsx(t1,{name:t.icon,size:16,style:tt(t.textColor,"text"),"aria-hidden":!0})})}):y.jsx(t1,{name:t.icon,size:16,className:"shrink-0",style:tt(t.textColor,"text"),"aria-hidden":!0}):null,y.jsx("div",{className:"sf:min-w-0 sf:flex-1 sf:text-[18px] sf:font-semibold sf:leading-tight sf:text-foreground/90",style:P,children:w==="name"&&b?y.jsx(lo,{initialValue:t.name,field:"node-name",required:!0,commitMode:"blur-only",onCommit:U=>{var R;return(R=t.onNameChange)==null?void 0:R.call(t,e,U)},onExit:()=>g(null),className:"sf:text-[18px] sf:font-semibold sf:text-foreground/90",style:P}):y.jsx("button",{type:"button",className:ie("sf:block sf:w-full sf:whitespace-pre-wrap sf:wrap-break-word sf:bg-transparent sf:p-0 sf:text-left sf:text-[18px] sf:font-semibold sf:leading-tight sf:text-foreground/90",b?"sf:hover:opacity-80":""),style:P,children:t.name})}),y.jsx("div",{className:"sf:flex sf:shrink-0 sf:items-center sf:gap-1",children:y.jsx(u0e,{visualStatus:l,disabled:!s||l==="active",buttonLabel:d,isError:h,onClick:U=>{var R;U.stopPropagation(),(R=t.onPlay)==null||R.call(t,e)}})})]}),y.jsx("div",{className:"sf:flex sf:min-h-0 sf:flex-1 sf:items-center sf:px-3 sf:py-2","data-testid":"node-content","data-resizing":f?"true":void 0,children:w==="description"&&S?y.jsx(lo,{initialValue:t.description??"",field:"node-description",multiline:!0,onCommit:U=>{var R;return(R=t.onDescriptionChange)==null?void 0:R.call(t,e,U)},onExit:()=>g(null),className:"sf:w-full sf:text-[18px] sf:text-muted-foreground",style:T,placeholder:t.kind}):y.jsx("button",{type:"button",className:ie("sf:block sf:w-full sf:whitespace-normal sf:wrap-break-word sf:bg-transparent sf:p-0 sf:text-left sf:text-[18px] sf:text-muted-foreground",S?"sf:hover:opacity-80":""),style:T,children:a})}),t.statusReport&&y.jsx("div",{className:"sf:flex sf:items-center sf:px-3 sf:pb-2","data-testid":"play-node-status-badge",children:y.jsx(QZ,{state:t.statusReport.state,summary:t.statusReport.summary,"data-testid":"status-badge"})}),y.jsx(at,{type:"source",position:ye.Right,id:"r",isConnectable:r,className:ie("sf:opacity-0 sf:transition-opacity",n&&"sf:opacity-100!")}),y.jsx(at,{type:"source",position:ye.Bottom,id:"b",isConnectable:r,className:ie("sf:opacity-0 sf:transition-opacity",n&&"sf:opacity-100!")})]})}function h0e(e,t){return e.selected===t.selected&&e.data===t.data&&e.width===t.width&&e.height===t.height}const f0e=m.memo(d0e,h0e),Ah="var(--seeflow-node-border)",Ph="var(--seeflow-node-bg)",Rh=2;function zh(e){if(e==="dashed")return"6 4";if(e==="dotted")return"2 4"}const qq=5;function p0e({width:e,height:t,borderColor:n,backgroundColor:r,borderSize:o,borderStyle:i}){const a=n??Ah,s=r??Ph,l=o??Rh,c=zh(i),h=e-2*qq,d=h/7,f=h/7*1.5,p=d,k=qq,v=k+d,w=v+d+f,M=w+f+p+p,x=t*.85,b=[`M ${k} ${x}`,`A ${d} ${d} 0 0 1 ${v+d} ${x}`,`A ${f} ${f} 0 0 1 ${w+f} ${x}`,`A ${p} ${p} 0 0 1 ${M} ${x}`,`L ${M} ${t}`,`L ${k} ${t}`,"Z"].join(" ");return y.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${e} ${t}`,preserveAspectRatio:"none",role:"img","aria-label":"Cloud","data-testid":"cloud-shape",children:[y.jsx("title",{children:"Cloud"}),y.jsx("path",{d:b,fill:s,stroke:a,strokeWidth:l,strokeDasharray:c})]})}function y0e({width:e,height:t,borderColor:n,backgroundColor:r,borderSize:o,borderStyle:i}){const a=Math.max(6,Math.min(28,t*.12)),s=e/2,l=e/2,c=n??Ah,h=r??Ph,d=o??Rh,f=zh(i),p=`M 0 ${t-a} A ${s} ${a} 0 0 0 ${e} ${t-a}`;return y.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${e} ${t}`,preserveAspectRatio:"none",role:"img","aria-label":"Database","data-testid":"database-shape",children:[y.jsx("title",{children:"Database"}),y.jsx("rect",{x:0,y:a,width:e,height:Math.max(0,t-2*a),fill:h}),y.jsx("line",{x1:0,y1:a,x2:0,y2:t-a,stroke:c,strokeWidth:d,strokeDasharray:f}),y.jsx("line",{x1:e,y1:a,x2:e,y2:t-a,stroke:c,strokeWidth:d,strokeDasharray:f}),y.jsx("path",{d:p,fill:h,stroke:c,strokeWidth:d,strokeDasharray:f}),y.jsx("ellipse",{cx:l,cy:a,rx:s,ry:a,fill:h,stroke:c,strokeWidth:d,strokeDasharray:f})]})}function m0e({width:e,height:t,borderColor:n,backgroundColor:r,borderSize:o,borderStyle:i}){const a=n??Ah,s=r??Ph,l=o??Rh,c=zh(i),h=t/2,d=e*.25,f=e*.5,p=e*.75;return y.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${e} ${t}`,preserveAspectRatio:"none",role:"img","aria-label":"Queue","data-testid":"queue-shape",children:[y.jsx("title",{children:"Queue"}),y.jsx("rect",{x:0,y:0,width:e,height:t,rx:h,ry:h,fill:s,stroke:a,strokeWidth:l,strokeDasharray:c}),y.jsx("line",{x1:d,y1:0,x2:d,y2:t,stroke:a,strokeWidth:l,strokeDasharray:c}),y.jsx("line",{x1:f,y1:0,x2:f,y2:t,stroke:a,strokeWidth:l,strokeDasharray:c}),y.jsx("line",{x1:p,y1:0,x2:p,y2:t,stroke:a,strokeWidth:l,strokeDasharray:c})]})}const k0e=3;function g0e({width:e,height:t,borderColor:n,backgroundColor:r,borderSize:o,borderStyle:i}){const a=n??Ah,s=r??Ph,l=o??Rh,c=zh(i),h=t/k0e,d=Math.max(3,Math.min(6,h*.18)),f=e-Math.max(10,d*3),p=Math.min(8,Math.min(e,t)*.06);return y.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${e} ${t}`,preserveAspectRatio:"none",role:"img","aria-label":"Server","data-testid":"server-shape",children:[y.jsx("title",{children:"Server"}),y.jsx("rect",{x:0,y:0,width:e,height:t,rx:p,ry:p,fill:s,stroke:a,strokeWidth:l,strokeDasharray:c}),y.jsx("line",{x1:0,y1:h,x2:e,y2:h,stroke:a,strokeWidth:l,strokeDasharray:c}),y.jsx("line",{x1:0,y1:h*2,x2:e,y2:h*2,stroke:a,strokeWidth:l,strokeDasharray:c}),y.jsx("circle",{cx:f,cy:h/2,r:d,fill:a}),y.jsx("circle",{cx:f,cy:h+h/2,r:d,fill:a}),y.jsx("circle",{cx:f,cy:h*2+h/2,r:d,fill:a})]})}function x0e({width:e,height:t,borderColor:n,backgroundColor:r,borderSize:o,borderStyle:i}){const a=n??Ah,s=r??Ph,l=o??Rh,c=zh(i),h=t*.22,d=Math.max(8,Math.min(28,Math.min(e,t)*.18)),f=h+d+Math.max(4,t*.05),p=Math.max(6,e*.1),k=p,v=e-p,w=Math.min((v-k)/2,(t-f)/2,40),g=[`M ${k} ${t}`,`L ${k} ${f+w}`,`A ${w} ${w} 0 0 1 ${k+w} ${f}`,`L ${v-w} ${f}`,`A ${w} ${w} 0 0 1 ${v} ${f+w}`,`L ${v} ${t}`,"Z"].join(" ");return y.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${e} ${t}`,preserveAspectRatio:"none",role:"img","aria-label":"User","data-testid":"user-shape",children:[y.jsx("title",{children:"User"}),y.jsx("circle",{cx:e/2,cy:h,r:d,fill:s,stroke:a,strokeWidth:l,strokeDasharray:c}),y.jsx("path",{d:g,fill:s,stroke:a,strokeWidth:l,strokeDasharray:c})]})}const H_={database:y0e,server:g0e,user:x0e,queue:m0e,cloud:p0e},v0e=new Set(Object.keys(H_));function w0e(e){return v0e.has(e)}const pR={rectangle:{width:200,height:120},ellipse:{width:200,height:120},sticky:{width:180,height:180},text:{width:160,height:40},database:{width:120,height:140},server:{width:140,height:120},user:{width:100,height:140},queue:{width:220,height:80},cloud:{width:180,height:120}},M0e={rectangle:"sf:rounded-lg sf:border-[3px] sf:bg-transparent",ellipse:"sf:rounded-full sf:border-[3px] sf:bg-transparent",sticky:"sf:rounded-md sf:border-[3px] sf:shadow-md sf:-rotate-2",text:"sf:bg-transparent",database:"",server:"",user:"",queue:"",cloud:""};function JZ(e){return M0e[e]}function eK(e,t){if(e==="text")return{};if(w0e(e))return{};const n=t==null?void 0:t.backgroundColor;let r;n!==void 0?r=tt(n,"node").backgroundColor:e==="sticky"?r=tt("amber","node").backgroundColor:(e==="rectangle"||e==="ellipse")&&(r=mh);const o=e==="rectangle"||e==="sticky";return{borderColor:tt(t==null?void 0:t.borderColor,"node").borderColor,backgroundColor:r,borderWidth:(t==null?void 0:t.borderSize)!==void 0?t.borderSize:void 0,borderStyle:t==null?void 0:t.borderStyle,borderRadius:o&&(t==null?void 0:t.cornerRadius)!==void 0?t.cornerRadius:void 0}}function b0e(e){return{borderColor:tt(e.borderColor,"node").borderColor,backgroundColor:e.backgroundColor!==void 0?tt(e.backgroundColor,"node").backgroundColor:mh}}const O0="sf:opacity-0 sf:transition-opacity";function C0e({id:e,data:t,selected:n,isConnectable:r}){const o=t.shape,i=pR[o],{onResizeStart:a,onResizeEvent:s,onResizeEnd:l}=Zu({onResize:D=>{var N;return(N=t.onResize)==null?void 0:N.call(t,e,D)},onResizeEnd:D=>{var N;return(N=t.onResizeEnd)==null?void 0:N.call(t,e,D)},setResizing:t.setResizing}),[c,h]=m.useState(()=>t.autoEditOnMount?t.shape==="ellipse"||t.shape==="sticky"||t.shape==="rectangle"&&(t.name===void 0||t.name==="")?"description":"name":null),d=c!==null,f=!!t.onNameChange,p=!!t.onDescriptionChange,k=o==="rectangle",v=o==="ellipse"||o==="sticky",w=t.name!==void 0&&t.name!=="",g=k&&w,M=v||k&&!w,x=t.width!==void 0||t.height!==void 0,b=o==="text",S=t.textColor,C=S!==void 0?tt(S,"text"):b?tt(t.borderColor,"text"):{},L={...eK(o,t),...t.fontSize!==void 0?{fontSize:`${t.fontSize}px`}:{}},P={...t.fontSize!==void 0?{fontSize:`${t.fontSize}px`}:{},...C},T=x?L:{...L,width:t.width??i.width,height:t.height??i.height},E=f||p?D=>{if(d)return;const N=D.target;if(!(N!=null&&N.closest(".react-flow__handle"))&&!(N!=null&&N.closest(".react-flow__resize-control"))){if(D.stopPropagation(),g){if(N!=null&&N.closest('[data-testid="shape-node-header"]')){f&&h("name");return}p?h("description"):f&&h("name");return}if(M){p?h("description"):f&&h("name");return}f&&h("name")}}:void 0;let z=null;const A=H_[o];if(A){const D=t.width??i.width,N=t.height??i.height,{borderColor:I,backgroundColor:W}=b0e(t);z=y.jsx("div",{className:"sf:pointer-events-none sf:absolute sf:inset-0",children:y.jsx(A,{width:D,height:N,borderColor:I,backgroundColor:W,borderSize:t.borderSize,borderStyle:t.borderStyle})})}const U=t.description??"",R=U!=="",V={...t.fontSize!==void 0?{fontSize:`${t.fontSize}px`}:{},...C};let O;M?O=c==="description"&&p?y.jsx(lo,{initialValue:U,field:"node-description",commitMode:"blur-only",onCommit:D=>{var N;return(N=t.onDescriptionChange)==null?void 0:N.call(t,e,D)},onExit:()=>h(null),className:"sf:relative sf:text-[22px]",style:V,placeholder:"Description"}):y.jsx("button",{type:"button",className:ie("sf:relative sf:block sf:whitespace-pre-wrap sf:bg-transparent sf:p-0 sf:font-medium sf:leading-tight",R?"break-words":"sf:italic sf:text-muted-foreground/40"),style:V,children:R?U:""}):O=c==="name"&&f?y.jsx(lo,{initialValue:t.name??"",field:"node-label",commitMode:"blur-only",onCommit:D=>{var N;return(N=t.onNameChange)==null?void 0:N.call(t,e,D)},onExit:()=>h(null),className:"sf:relative sf:text-[22px]",style:P,placeholder:b?"Text":"Label"}):y.jsx("button",{type:"button",className:ie("sf:relative sf:block sf:whitespace-pre-wrap sf:bg-transparent sf:p-0 sf:font-medium sf:leading-tight",t.name?"break-words":"sf:text-muted-foreground/40 sf:italic"),style:P,children:t.name??(b&&f?"Text":"")});const B=y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"sf:relative sf:flex sf:shrink-0 sf:items-center sf:border-b sf:border-border sf:px-3 sf:py-2.5",style:tt(t.backgroundColor,"node-header"),"data-testid":"shape-node-header",children:y.jsx("div",{className:"sf:min-w-0 sf:flex-1 sf:whitespace-pre-wrap sf:wrap-break-word sf:text-left sf:font-semibold sf:text-[18px] sf:leading-tight",style:P,children:c==="name"&&f?y.jsx(lo,{initialValue:t.name??"",field:"node-label",commitMode:"blur-only",onCommit:D=>{var N;return(N=t.onNameChange)==null?void 0:N.call(t,e,D)},onExit:()=>h(null),className:"sf:text-[18px] sf:font-semibold",style:P,placeholder:"Title"}):y.jsx("button",{type:"button",className:ie("sf:block sf:w-full sf:whitespace-pre-wrap sf:wrap-break-word sf:bg-transparent sf:p-0 sf:text-left sf:font-semibold sf:text-[18px] sf:leading-tight",f?"sf:hover:opacity-80":""),style:P,children:t.name})})}),y.jsx("div",{className:"sf:relative sf:flex sf:min-h-0 sf:flex-1 sf:items-center sf:px-3 sf:py-2.5","data-testid":"shape-node-body",children:c==="description"&&p?y.jsx(lo,{initialValue:U,field:"node-description",commitMode:"blur-only",onCommit:D=>{var N;return(N=t.onDescriptionChange)==null?void 0:N.call(t,e,D)},onExit:()=>h(null),className:"sf:w-full sf:text-[16px] sf:text-muted-foreground",style:V,placeholder:"Description"}):y.jsx("button",{type:"button",className:ie("sf:block sf:w-full sf:whitespace-pre-wrap sf:wrap-break-word sf:bg-transparent sf:p-0 sf:text-left sf:text-[16px] sf:leading-tight",R?"text-muted-foreground":"sf:italic sf:text-muted-foreground/40",p?"sf:hover:opacity-80":""),style:V,children:R?U:p?"Double-click to add description":""})})]});return y.jsxs("div",{className:ie("group",g?"":"sf:relative",g?"sf:flex sf:flex-col sf:overflow-hidden sf:text-left":"sf:flex sf:items-center sf:justify-center sf:p-2 sf:text-center sf:text-[22px]",x?"sf:h-full sf:w-full":"",JZ(o)),style:T,"data-testid":"shape-node","data-node-type":"shapeNode","data-shape":o,onDoubleClick:E,children:[z,y.jsx(Gu,{visible:!!n&&!!t.onResize&&!d,cornerVariant:"visible",minWidth:80,minHeight:40,onResizeStart:a,onResize:s,onResizeEnd:l}),!b&&y.jsx(at,{type:"target",position:ye.Top,id:"t",isConnectable:r,className:ie(O0,n&&"sf:opacity-100!")}),!b&&y.jsx(at,{type:"target",position:ye.Left,id:"l",isConnectable:r,className:ie(O0,n&&"sf:opacity-100!")}),g?B:O,!b&&y.jsx(at,{type:"source",position:ye.Right,id:"r",isConnectable:r,className:ie(O0,n&&"sf:opacity-100!")}),!b&&y.jsx(at,{type:"source",position:ye.Bottom,id:"b",isConnectable:r,className:ie(O0,n&&"sf:opacity-100!")})]})}function S0e(e,t){return e.selected===t.selected&&e.data===t.data&&e.width===t.width&&e.height===t.height}const L0e=m.memo(C0e,S0e),I0e={active:"sf:border-amber-400 sf:bg-amber-950/40 sf:text-amber-300",success:"sf:border-emerald-400 sf:bg-emerald-950/40 sf:text-emerald-300 sf:seeflow-pill-pop",error:"sf:border-rose-400 sf:bg-rose-950/40 sf:text-rose-300 sf:seeflow-pill-pop"};function E0e({visualStatus:e,summary:t,"data-testid":n}){if(e==="idle")return null;const r=e==="active"?h2:e==="success"?fo:wi;return y.jsxs("span",{"data-testid":n,"data-visual-status":e,title:t,className:ie("sf:relative sf:inline-flex sf:h-5 sf:items-center sf:justify-center sf:rounded-full sf:border-[1.5px] sf:px-1",I0e[e]),children:[e==="active"?y.jsx("span",{"aria-hidden":!0,"data-testid":"status-icon-pill-ring",className:"sf:absolute sf:inset-0 sf:rounded-full sf:seeflow-ring-spin",style:{background:"conic-gradient(from 0deg, var(--amber-hi) 0deg, transparent 200deg, var(--amber-hi) 360deg)",WebkitMask:"radial-gradient(circle, transparent calc(50% - 1.5px), #000 calc(50% - 1.5px))",mask:"radial-gradient(circle, transparent calc(50% - 1.5px), #000 calc(50% - 1.5px))"}}):null,y.jsx(r,{className:"sf:h-3 sf:w-3 sf:relative","aria-hidden":!0})]})}const A0e=100,P0e=44,R0e=250;function z0e({id:e,data:t,selected:n,isConnectable:r}){var L,P;const o=t.status??"idle",i=__(t.status,t.statusReport),a=t.description??t.kind,{isResizing:s,onResizeStart:l,onResizeEvent:c,onResizeEnd:h}=Zu({onResize:T=>{var E;return(E=t.onResize)==null?void 0:E.call(t,e,T)},onResizeEnd:T=>{var E;return(E=t.onResizeEnd)==null?void 0:E.call(t,e,T)},setResizing:t.setResizing}),[d,f]=m.useState(null),[p,k]=m.useState(!1),v=!!t.onNameChange,w=!!t.onDescriptionChange,g=!!t.onIconChange&&!!n&&!!t.icon,M=t.width!==void 0||t.height!==void 0,x={...t.fontSize!==void 0?{fontSize:`${t.fontSize}px`}:{},...tt(t.textColor,"text")},b=x,S={borderColor:((L=t.statusReport)==null?void 0:L.state)==="error"?tt("red","node").borderColor:tt(t.borderColor,"node").borderColor,backgroundColor:tt(t.backgroundColor,"node").backgroundColor,borderWidth:t.borderSize!==void 0?t.borderSize:void 0,borderStyle:t.borderStyle,borderRadius:t.cornerRadius!==void 0?t.cornerRadius:void 0,...M?{}:{width:R0e}},C=v||w?T=>{if(d!==null)return;const E=T.target;if(!(E!=null&&E.closest(".react-flow__handle"))&&!(E!=null&&E.closest(".react-flow__resize-control"))){if(T.stopPropagation(),E!=null&&E.closest('[data-testid="node-header"]')){v&&f("name");return}if(E!=null&&E.closest('[data-testid="node-content"]')){w?f("description"):v&&f("name");return}w?f("description"):v&&f("name")}}:void 0;return y.jsxs("div",{className:ie("sf:group sf:flex sf:flex-col sf:justify-center sf:overflow-hidden sf:rounded-lg sf:border-[3px] sf:border-dashed sf:shadow-sm sf:transition-shadow",M?"sf:h-full sf:w-full":"",o==="running"?"seeflow-node-pulse":""),style:S,"data-status":o,"data-testid":"state-node","data-node-type":"stateNode",onDoubleClick:C,children:[y.jsx(Gu,{visible:!!n&&!!t.onResize,cornerVariant:"visible",minWidth:A0e,minHeight:P0e,onResizeStart:l,onResize:c,onResizeEnd:h}),y.jsx(at,{type:"target",position:ye.Top,id:"t",isConnectable:r,className:ie("sf:opacity-0 sf:transition-opacity",n&&"sf:opacity-100!")}),y.jsx(at,{type:"target",position:ye.Left,id:"l",isConnectable:r,className:ie("sf:opacity-0 sf:transition-opacity",n&&"sf:opacity-100!")}),y.jsxs("div",{className:"sf:flex sf:shrink-0 sf:items-center sf:justify-between sf:gap-2 sf:border-b sf:border-border sf:px-3 sf:py-3",style:tt(t.backgroundColor,"node-header"),"data-testid":"node-header",children:[t.icon?g&&t.onIconChange?y.jsx(uz,{open:p,onOpenChange:k,onPick:T=>{var E;(E=t.onIconChange)==null||E.call(t,e,T),k(!1)},anchor:y.jsx("button",{type:"button","data-testid":"state-node-icon-trigger","aria-label":"Change icon","aria-pressed":p,className:ie("sf:inline-flex sf:shrink-0 sf:cursor-pointer sf:items-center sf:justify-center sf:rounded-sm sf:bg-transparent sf:p-0 sf:transition-shadow","sf:hover:ring-2 sf:hover:ring-ring/40 sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring"),onClick:T=>{T.stopPropagation()},onMouseDown:T=>{T.stopPropagation()},onDoubleClick:T=>{T.stopPropagation()},children:y.jsx(t1,{name:t.icon,size:16,style:tt(t.textColor,"text"),"aria-hidden":!0})})}):y.jsx(t1,{name:t.icon,size:16,className:"shrink-0",style:tt(t.textColor,"text"),"aria-hidden":!0}):null,y.jsx("div",{className:"sf:min-w-0 sf:flex-1 sf:text-[18px] sf:font-semibold sf:leading-tight sf:text-foreground/90",style:x,children:d==="name"&&v?y.jsx(lo,{initialValue:t.name,field:"node-name",required:!0,commitMode:"blur-only",onCommit:T=>{var E;return(E=t.onNameChange)==null?void 0:E.call(t,e,T)},onExit:()=>f(null),className:"sf:text-[18px] sf:font-semibold sf:text-foreground/90",style:x}):y.jsx("button",{type:"button",className:ie("sf:block sf:w-full sf:whitespace-pre-wrap sf:wrap-break-word sf:bg-transparent sf:p-0 sf:text-left sf:text-[18px] sf:font-semibold sf:leading-tight sf:text-foreground/90",v?"sf:hover:opacity-80":""),style:x,children:t.name})}),y.jsx("div",{className:"sf:flex sf:shrink-0 sf:items-center sf:gap-1",children:y.jsx(E0e,{visualStatus:i,summary:(P=t.statusReport)==null?void 0:P.summary,"data-testid":"state-node-status-pill"})})]}),y.jsx("div",{className:"sf:flex sf:min-h-0 sf:flex-1 sf:items-center sf:px-3 sf:py-2","data-testid":"node-content","data-resizing":s?"true":void 0,children:d==="description"&&w?y.jsx(lo,{initialValue:t.description??"",field:"node-description",multiline:!0,onCommit:T=>{var E;return(E=t.onDescriptionChange)==null?void 0:E.call(t,e,T)},onExit:()=>f(null),className:"sf:w-full sf:text-[18px] sf:text-muted-foreground",style:b,placeholder:t.kind}):y.jsx("button",{type:"button",className:ie("sf:block sf:w-full sf:whitespace-normal sf:wrap-break-word sf:bg-transparent sf:p-0 sf:text-left sf:text-[18px] sf:text-muted-foreground",w?"sf:hover:opacity-80":""),style:b,children:a})}),y.jsx(at,{type:"source",position:ye.Right,id:"r",isConnectable:r,className:ie("sf:opacity-0 sf:transition-opacity",n&&"sf:opacity-100!")}),y.jsx(at,{type:"source",position:ye.Bottom,id:"b",isConnectable:r,className:ie("sf:opacity-0 sf:transition-opacity",n&&"sf:opacity-100!")})]})}function j0e(e,t){return e.selected===t.selected&&e.data===t.data&&e.width===t.width&&e.height===t.height}const T0e=m.memo(z0e,j0e);function N0e(e,t){return t==="success"&&e!=="success"}const D0e=8,q0=10,Vq=(e,t,n)=>{switch(n){case"top":return{cx:e,cy:t-q0};case"bottom":return{cx:e,cy:t+q0};case"left":return{cx:e-q0,cy:t};case"right":return{cx:e+q0,cy:t}}},Bq={top:ye.Top,right:ye.Right,bottom:ye.Bottom,left:ye.Left},$q=e=>{switch(e){case ye.Top:return"top";case ye.Right:return"right";case ye.Bottom:return"bottom";case ye.Left:return"left"}};function _0e({id:e,source:t,target:n,sourceX:r,sourceY:o,targetX:i,targetY:a,sourcePosition:s,targetPosition:l,label:c,style:h,markerEnd:d,markerStart:f,interactionWidth:p,data:k}){const[v,w]=m.useState(!1),g=XO(t),M=XO(n),x=(g==null?void 0:g.data)??{},b=__(x.status,x.statusReport),S=m.useRef(void 0);m.useEffect(()=>{const me=S.current;if(S.current=b,!N0e(me,b))return;const ge=document.querySelector(`.react-flow__edge[data-id="${CSS.escape(e)}"]`);if(!ge)return;ge.setAttribute("data-handoff","true");const ee=window.setTimeout(()=>{ge.removeAttribute("data-handoff")},500);return()=>{window.clearTimeout(ee),ge.removeAttribute("data-handoff")}},[e,b]);const C={x:r,y:o,side:$q(s)},L={x:i,y:a,side:$q(l)},P=oue(g?{box:{x:g.internals.positionAbsolute.x,y:g.internals.positionAbsolute.y,w:g.measured.width??g.width??0,h:g.measured.height??g.height??0},autoPicked:k==null?void 0:k.sourceHandleAutoPicked,pin:k==null?void 0:k.sourcePin,fallback:C}:null,M?{box:{x:M.internals.positionAbsolute.x,y:M.internals.positionAbsolute.y,w:M.measured.width??M.width??0,h:M.measured.height??M.height??0},autoPicked:k==null?void 0:k.targetHandleAutoPicked,pin:k==null?void 0:k.targetPin,fallback:L}:null),T=P.source.x,E=P.source.y,z=Bq[P.source.side],A=P.target.x,U=P.target.y,R=Bq[P.target.side],V=P.source.side,O=P.target.side,B=Vq(T,E,V),D=Vq(A,U,O);m.useEffect(()=>{const me=document.querySelector(`.react-flow__edge[data-id="${CSS.escape(e)}"]`);if(!me)return;const ge=me.querySelector(".react-flow__edgeupdater-source"),ee=me.querySelector(".react-flow__edgeupdater-target");ge&&(ge.setAttribute("cx",String(B.cx)),ge.setAttribute("cy",String(B.cy))),ee&&(ee.setAttribute("cx",String(D.cx)),ee.setAttribute("cy",String(D.cy)))},[e,B.cx,B.cy,D.cx,D.cy]);const[N,I,W]=(k==null?void 0:k.path)==="step"?nh({sourceX:T,sourceY:E,sourcePosition:z,targetX:A,targetY:U,targetPosition:R,borderRadius:D0e}):KR({sourceX:T,sourceY:E,sourcePosition:z,targetX:A,targetY:U,targetPosition:R}),H=k==null?void 0:k.onLabelChange,j=typeof c=="string"?c:"",G=!!H,X=k==null?void 0:k.fontSize,Y=typeof X=="number"?{fontSize:`${X}px`}:void 0,re=k==null?void 0:k.registerEditHandle;m.useEffect(()=>{if(!(!re||!G))return re(e,()=>w(!0))},[e,re,G]);const ne=typeof(k==null?void 0:k.kind)=="string"?k.kind:void 0;m.useEffect(()=>{if(!ne)return;const me=document.querySelector(`.react-flow__edge[data-id="${CSS.escape(e)}"]`);if(me)return me.setAttribute("data-edge-kind",ne),()=>{me.removeAttribute("data-edge-kind")}},[e,ne]);const ae=(k==null?void 0:k.reconnectable)===!0,ve=(k==null?void 0:k.sourcePin)!==void 0,be=(k==null?void 0:k.targetPin)!==void 0;return y.jsxs(y.Fragment,{children:[y.jsx(bh,{id:e,path:N,style:h,markerEnd:d,markerStart:f,interactionWidth:p}),ae?y.jsxs(k1e,{children:[y.jsx("div",{"data-testid":`edge-endpoint-source-${e}`,"data-pinned":ve?"true":"false",className:"seeflow-connector-endpoint-dot",style:{transform:`translate(-50%, -50%) translate(${B.cx}px, ${B.cy}px)`}}),y.jsx("div",{"data-testid":`edge-endpoint-target-${e}`,"data-pinned":be?"true":"false",className:"seeflow-connector-endpoint-dot",style:{transform:`translate(-50%, -50%) translate(${D.cx}px, ${D.cy}px)`}})]}):null,y.jsx(y1e,{children:y.jsx("div",{className:"nodrag nopan nowheel pointer-events-auto absolute",style:{transform:`translate(-50%, -50%) translate(${I}px, ${W}px)`},children:v&&G?y.jsx(lo,{initialValue:j,field:"connector-label",onCommit:me=>H==null?void 0:H(e,me),onExit:()=>w(!1),className:"sf:rounded-md sf:border sf:border-border sf:bg-card sf:px-1.5 sf:py-0.5 sf:text-[11px] sf:text-foreground/85 sf:shadow-md",style:Y,placeholder:"Label"}):j?y.jsx("button",{type:"button",className:ie("sf:rounded-md sf:border sf:border-border sf:bg-card sf:px-1.5 sf:py-0.5 sf:text-[11px] sf:text-foreground/85 sf:shadow-md",G?"sf:hover:bg-muted":""),style:Y,onDoubleClick:G?me=>{me.stopPropagation(),w(!0)}:void 0,children:j}):G?y.jsx("button",{type:"button","aria-label":"Add connector label",className:"sf:rounded-full sf:border sf:border-dashed sf:border-muted-foreground/40 sf:bg-card sf:px-1 sf:text-[10px] sf:text-muted-foreground/60 sf:opacity-0 sf:transition-opacity sf:hover:opacity-100 sf:group-hover/canvas:opacity-50",onDoubleClick:me=>{me.stopPropagation(),w(!0)},children:"+"}):null})})]})}var Uq=1,H0e=.9,F0e=.8,O0e=.17,Hj=.1,Fj=.999,q0e=.9999,V0e=.99,B0e=/[\\\/_+.#"@\[\(\{&]/,$0e=/[\\\/_+.#"@\[\(\{&]/g,U0e=/[\s-]/,tK=/[\s-]/g;function EN(e,t,n,r,o,i,a){if(i===t.length)return o===e.length?Uq:V0e;var s=`${o},${i}`;if(a[s]!==void 0)return a[s];for(var l=r.charAt(i),c=n.indexOf(l,o),h=0,d,f,p,k;c>=0;)d=EN(e,t,n,r,c+1,i+1,a),d>h&&(c===o?d*=Uq:B0e.test(e.charAt(c-1))?(d*=F0e,p=e.slice(o,c-1).match($0e),p&&o>0&&(d*=Math.pow(Fj,p.length))):U0e.test(e.charAt(c-1))?(d*=H0e,k=e.slice(o,c-1).match(tK),k&&o>0&&(d*=Math.pow(Fj,k.length))):(d*=O0e,o>0&&(d*=Math.pow(Fj,c-o))),e.charAt(c)!==t.charAt(i)&&(d*=q0e)),(d<Hj&&n.charAt(c-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(c-1)!==r.charAt(i))&&(f=EN(e,t,n,r,c+1,i+2,a),f*Hj>d&&(d=f*Hj)),d>h&&(h=d),c=n.indexOf(l,c+1);return a[s]=h,h}function Wq(e){return e.toLowerCase().replace(tK," ")}function W0e(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,EN(e,t,Wq(e),Wq(t),0,0,{})}var dz="Dialog",[nK]=Nr(dz),[G0e,Dr]=nK(dz),rK=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:a=!0}=e,s=m.useRef(null),l=m.useRef(null),[c,h]=c1({prop:r,defaultProp:o??!1,onChange:i,caller:dz});return y.jsx(G0e,{scope:t,triggerRef:s,contentRef:l,contentId:dn(),titleId:dn(),descriptionId:dn(),open:c,onOpenChange:h,onOpenToggle:m.useCallback(()=>h(d=>!d),[h]),modal:a,children:n})};rK.displayName=dz;var oK="DialogTrigger",Z0e=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Dr(oK,n),i=dt(t,o.triggerRef);return y.jsx(Ve.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":q_(o.open),...r,ref:i,onClick:Ie(e.onClick,o.onOpenToggle)})});Z0e.displayName=oK;var F_="DialogPortal",[K0e,iK]=nK(F_,{forceMount:void 0}),aK=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,i=Dr(F_,t);return y.jsx(K0e,{scope:t,forceMount:n,children:m.Children.map(r,a=>y.jsx(Qn,{present:n||i.open,children:y.jsx(Lh,{asChild:!0,container:o,children:a})}))})};aK.displayName=F_;var yR="DialogOverlay",sK=m.forwardRef((e,t)=>{const n=iK(yR,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=Dr(yR,e.__scopeDialog);return i.modal?y.jsx(Qn,{present:r||i.open,children:y.jsx(Y0e,{...o,ref:t})}):null});sK.displayName=yR;var X0e=Nu("DialogOverlay.RemoveScroll"),Y0e=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Dr(yR,n);return y.jsx(lz,{as:X0e,allowPinchZoom:!0,shards:[o.contentRef],children:y.jsx(Ve.div,{"data-state":q_(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),r1="DialogContent",lK=m.forwardRef((e,t)=>{const n=iK(r1,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=Dr(r1,e.__scopeDialog);return y.jsx(Qn,{present:r||i.open,children:i.modal?y.jsx(Q0e,{...o,ref:t}):y.jsx(J0e,{...o,ref:t})})});lK.displayName=r1;var Q0e=m.forwardRef((e,t)=>{const n=Dr(r1,e.__scopeDialog),r=m.useRef(null),o=dt(t,n.contentRef,r);return m.useEffect(()=>{const i=r.current;if(i)return N_(i)},[]),y.jsx(cK,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ie(e.onCloseAutoFocus,i=>{var a;i.preventDefault(),(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:Ie(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,s=a.button===0&&a.ctrlKey===!0;(a.button===2||s)&&i.preventDefault()}),onFocusOutside:Ie(e.onFocusOutside,i=>i.preventDefault())})}),J0e=m.forwardRef((e,t)=>{const n=Dr(r1,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return y.jsx(cK,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var a,s;(a=e.onCloseAutoFocus)==null||a.call(e,i),i.defaultPrevented||(r.current||(s=n.triggerRef.current)==null||s.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=i.target;((c=n.triggerRef.current)==null?void 0:c.contains(a))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),cK=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,...a}=e,s=Dr(r1,n),l=m.useRef(null),c=dt(t,l);return b_(),y.jsxs(y.Fragment,{children:[y.jsx(tz,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:y.jsx(Ch,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":q_(s.open),...a,ref:c,onDismiss:()=>s.onOpenChange(!1)})}),y.jsxs(y.Fragment,{children:[y.jsx(efe,{titleId:s.titleId}),y.jsx(nfe,{contentRef:l,descriptionId:s.descriptionId})]})]})}),O_="DialogTitle",uK=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Dr(O_,n);return y.jsx(Ve.h2,{id:o.titleId,...r,ref:t})});uK.displayName=O_;var dK="DialogDescription",hK=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Dr(dK,n);return y.jsx(Ve.p,{id:o.descriptionId,...r,ref:t})});hK.displayName=dK;var fK="DialogClose",pK=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Dr(fK,n);return y.jsx(Ve.button,{type:"button",...r,ref:t,onClick:Ie(e.onClick,()=>o.onOpenChange(!1))})});pK.displayName=fK;function q_(e){return e?"open":"closed"}var yK="DialogTitleWarning",[A8e,mK]=rde(yK,{contentName:r1,titleName:O_,docsSlug:"dialog"}),efe=({titleId:e})=>{const t=mK(yK),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
7804
7804
|
|
|
7805
7805
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
7806
7806
|
|
|
7807
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},tfe="DialogDescriptionWarning",nfe=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${mK(tfe).contentName}}.`;return m.useEffect(()=>{var i;const o=(i=e.current)==null?void 0:i.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},hz=rK,fz=aK,jh=sK,ed=lK,pz=uK,yz=hK,kK=pK,Cd='[cmdk-group=""]',Oj='[cmdk-group-items=""]',rfe='[cmdk-group-heading=""]',gK='[cmdk-item=""]',Gq=`${gK}:not([aria-disabled="true"])`,AN="cmdk-item-select",j1="data-value",ofe=(e,t,n)=>W0e(e,t,n),xK=m.createContext(void 0),Th=()=>m.useContext(xK),vK=m.createContext(void 0),V_=()=>m.useContext(vK),wK=m.createContext(void 0),MK=m.forwardRef((e,t)=>{let n=T1(()=>{var H,j;return{search:"",value:(j=(H=e.value)!=null?H:e.defaultValue)!=null?j:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=T1(()=>new Set),o=T1(()=>new Map),i=T1(()=>new Map),a=T1(()=>new Set),s=bK(e),{label:l,children:c,value:h,onValueChange:d,filter:f,shouldFilter:p,loop:k,disablePointerSelection:v=!1,vimBindings:w=!0,...g}=e,M=dn(),x=dn(),b=dn(),S=m.useRef(null),C=yfe();o1(()=>{if(h!==void 0){let H=h.trim();n.current.value=H,L.emit()}},[h]),o1(()=>{C(6,U)},[]);let L=m.useMemo(()=>({subscribe:H=>(a.current.add(H),()=>a.current.delete(H)),snapshot:()=>n.current,setState:(H,j,G)=>{var X,Y,re,ne;if(!Object.is(n.current[H],j)){if(n.current[H]=j,H==="search")A(),E(),C(1,z);else if(H==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ae=document.getElementById(b);ae?ae.focus():(X=document.getElementById(M))==null||X.focus()}if(C(7,()=>{var ae;n.current.selectedItemId=(ae=R())==null?void 0:ae.id,L.emit()}),G||C(5,U),((Y=s.current)==null?void 0:Y.value)!==void 0){let ae=j??"";(ne=(re=s.current).onValueChange)==null||ne.call(re,ae);return}}L.emit()}},emit:()=>{a.current.forEach(H=>H())}}),[]),P=m.useMemo(()=>({value:(H,j,G)=>{var X;j!==((X=i.current.get(H))==null?void 0:X.value)&&(i.current.set(H,{value:j,keywords:G}),n.current.filtered.items.set(H,T(j,G)),C(2,()=>{E(),L.emit()}))},item:(H,j)=>(r.current.add(H),j&&(o.current.has(j)?o.current.get(j).add(H):o.current.set(j,new Set([H]))),C(3,()=>{A(),E(),n.current.value||z(),L.emit()}),()=>{i.current.delete(H),r.current.delete(H),n.current.filtered.items.delete(H);let G=R();C(4,()=>{A(),(G==null?void 0:G.getAttribute("id"))===H&&z(),L.emit()})}),group:H=>(o.current.has(H)||o.current.set(H,new Set),()=>{i.current.delete(H),o.current.delete(H)}),filter:()=>s.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:M,inputId:b,labelId:x,listInnerRef:S}),[]);function T(H,j){var G,X;let Y=(X=(G=s.current)==null?void 0:G.filter)!=null?X:ofe;return H?Y(H,n.current.search,j):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let H=n.current.filtered.items,j=[];n.current.filtered.groups.forEach(X=>{let Y=o.current.get(X),re=0;Y.forEach(ne=>{let ae=H.get(ne);re=Math.max(ae,re)}),j.push([X,re])});let G=S.current;V().sort((X,Y)=>{var re,ne;let ae=X.getAttribute("id"),ve=Y.getAttribute("id");return((re=H.get(ve))!=null?re:0)-((ne=H.get(ae))!=null?ne:0)}).forEach(X=>{let Y=X.closest(Oj);Y?Y.appendChild(X.parentElement===Y?X:X.closest(`${Oj} > *`)):G.appendChild(X.parentElement===G?X:X.closest(`${Oj} > *`))}),j.sort((X,Y)=>Y[1]-X[1]).forEach(X=>{var Y;let re=(Y=S.current)==null?void 0:Y.querySelector(`${Cd}[${j1}="${encodeURIComponent(X[0])}"]`);re==null||re.parentElement.appendChild(re)})}function z(){let H=V().find(G=>G.getAttribute("aria-disabled")!=="true"),j=H==null?void 0:H.getAttribute(j1);L.setState("value",j||void 0)}function A(){var H,j,G,X;if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let Y=0;for(let re of r.current){let ne=(j=(H=i.current.get(re))==null?void 0:H.value)!=null?j:"",ae=(X=(G=i.current.get(re))==null?void 0:G.keywords)!=null?X:[],ve=T(ne,ae);n.current.filtered.items.set(re,ve),ve>0&&Y++}for(let[re,ne]of o.current)for(let ae of ne)if(n.current.filtered.items.get(ae)>0){n.current.filtered.groups.add(re);break}n.current.filtered.count=Y}function U(){var H,j,G;let X=R();X&&(((H=X.parentElement)==null?void 0:H.firstChild)===X&&((G=(j=X.closest(Cd))==null?void 0:j.querySelector(rfe))==null||G.scrollIntoView({block:"nearest"})),X.scrollIntoView({block:"nearest"}))}function R(){var H;return(H=S.current)==null?void 0:H.querySelector(`${gK}[aria-selected="true"]`)}function V(){var H;return Array.from(((H=S.current)==null?void 0:H.querySelectorAll(Gq))||[])}function O(H){let j=V()[H];j&&L.setState("value",j.getAttribute(j1))}function B(H){var j;let G=R(),X=V(),Y=X.findIndex(ne=>ne===G),re=X[Y+H];(j=s.current)!=null&&j.loop&&(re=Y+H<0?X[X.length-1]:Y+H===X.length?X[0]:X[Y+H]),re&&L.setState("value",re.getAttribute(j1))}function D(H){let j=R(),G=j==null?void 0:j.closest(Cd),X;for(;G&&!X;)G=H>0?ffe(G,Cd):pfe(G,Cd),X=G==null?void 0:G.querySelector(Gq);X?L.setState("value",X.getAttribute(j1)):B(H)}let N=()=>O(V().length-1),I=H=>{H.preventDefault(),H.metaKey?N():H.altKey?D(1):B(1)},W=H=>{H.preventDefault(),H.metaKey?O(0):H.altKey?D(-1):B(-1)};return m.createElement(Ve.div,{ref:t,tabIndex:-1,...g,"cmdk-root":"",onKeyDown:H=>{var j;(j=g.onKeyDown)==null||j.call(g,H);let G=H.nativeEvent.isComposing||H.keyCode===229;if(!(H.defaultPrevented||G))switch(H.key){case"n":case"j":{w&&H.ctrlKey&&I(H);break}case"ArrowDown":{I(H);break}case"p":case"k":{w&&H.ctrlKey&&W(H);break}case"ArrowUp":{W(H);break}case"Home":{H.preventDefault(),O(0);break}case"End":{H.preventDefault(),N();break}case"Enter":{H.preventDefault();let X=R();if(X){let Y=new Event(AN);X.dispatchEvent(Y)}}}}},m.createElement("label",{"cmdk-label":"",htmlFor:P.inputId,id:P.labelId,style:kfe},l),mz(e,H=>m.createElement(vK.Provider,{value:L},m.createElement(xK.Provider,{value:P},H))))}),ife=m.forwardRef((e,t)=>{var n,r;let o=dn(),i=m.useRef(null),a=m.useContext(wK),s=Th(),l=bK(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:a==null?void 0:a.forceMount;o1(()=>{if(!c)return s.item(o,a==null?void 0:a.id)},[c]);let h=CK(o,i,[e.value,e.children,i],e.keywords),d=V_(),f=Bi(C=>C.value&&C.value===h.current),p=Bi(C=>c||s.filter()===!1?!0:C.search?C.filtered.items.get(o)>0:!0);m.useEffect(()=>{let C=i.current;if(!(!C||e.disabled))return C.addEventListener(AN,k),()=>C.removeEventListener(AN,k)},[p,e.onSelect,e.disabled]);function k(){var C,L;v(),(L=(C=l.current).onSelect)==null||L.call(C,h.current)}function v(){d.setState("value",h.current,!0)}if(!p)return null;let{disabled:w,value:g,onSelect:M,forceMount:x,keywords:b,...S}=e;return m.createElement(Ve.div,{ref:ko(i,t),...S,id:o,"cmdk-item":"",role:"option","aria-disabled":!!w,"aria-selected":!!f,"data-disabled":!!w,"data-selected":!!f,onPointerMove:w||s.getDisablePointerSelection()?void 0:v,onClick:w?void 0:k},e.children)}),afe=m.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...i}=e,a=dn(),s=m.useRef(null),l=m.useRef(null),c=dn(),h=Th(),d=Bi(p=>o||h.filter()===!1?!0:p.search?p.filtered.groups.has(a):!0);o1(()=>h.group(a),[]),CK(a,s,[e.value,e.heading,l]);let f=m.useMemo(()=>({id:a,forceMount:o}),[o]);return m.createElement(Ve.div,{ref:ko(s,t),...i,"cmdk-group":"",role:"presentation",hidden:d?void 0:!0},n&&m.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),mz(e,p=>m.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},m.createElement(wK.Provider,{value:f},p))))}),sfe=m.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=m.useRef(null),i=Bi(a=>!a.search);return!n&&!i?null:m.createElement(Ve.div,{ref:ko(o,t),...r,"cmdk-separator":"",role:"separator"})}),lfe=m.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,i=V_(),a=Bi(c=>c.search),s=Bi(c=>c.selectedItemId),l=Th();return m.useEffect(()=>{e.value!=null&&i.setState("search",e.value)},[e.value]),m.createElement(Ve.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":s,id:l.inputId,type:"text",value:o?e.value:a,onChange:c=>{o||i.setState("search",c.target.value),n==null||n(c.target.value)}})}),cfe=m.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,i=m.useRef(null),a=m.useRef(null),s=Bi(c=>c.selectedItemId),l=Th();return m.useEffect(()=>{if(a.current&&i.current){let c=a.current,h=i.current,d,f=new ResizeObserver(()=>{d=requestAnimationFrame(()=>{let p=c.offsetHeight;h.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return f.observe(c),()=>{cancelAnimationFrame(d),f.unobserve(c)}}},[]),m.createElement(Ve.div,{ref:ko(i,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:l.listId},mz(e,c=>m.createElement("div",{ref:ko(a,l.listInnerRef),"cmdk-list-sizer":""},c)))}),ufe=m.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:i,container:a,...s}=e;return m.createElement(hz,{open:n,onOpenChange:r},m.createElement(fz,{container:a},m.createElement(jh,{"cmdk-overlay":"",className:o}),m.createElement(ed,{"aria-label":e.label,"cmdk-dialog":"",className:i},m.createElement(MK,{ref:t,...s}))))}),dfe=m.forwardRef((e,t)=>Bi(n=>n.filtered.count===0)?m.createElement(Ve.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),hfe=m.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...i}=e;return m.createElement(Ve.div,{ref:t,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},mz(e,a=>m.createElement("div",{"aria-hidden":!0},a)))}),Pn=Object.assign(MK,{List:cfe,Item:ife,Input:lfe,Group:afe,Separator:sfe,Dialog:ufe,Empty:dfe,Loading:hfe});function ffe(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function pfe(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function bK(e){let t=m.useRef(e);return o1(()=>{t.current=e}),t}var o1=typeof window>"u"?m.useEffect:m.useLayoutEffect;function T1(e){let t=m.useRef();return t.current===void 0&&(t.current=e()),t}function Bi(e){let t=V_(),n=()=>e(t.snapshot());return m.useSyncExternalStore(t.subscribe,n,n)}function CK(e,t,n,r=[]){let o=m.useRef(),i=Th();return o1(()=>{var a;let s=(()=>{var c;for(let h of n){if(typeof h=="string")return h.trim();if(typeof h=="object"&&"current"in h)return h.current?(c=h.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());i.value(e,s,l),(a=t.current)==null||a.setAttribute(j1,s),o.current=s}),o}var yfe=()=>{let[e,t]=m.useState(),n=T1(()=>new Map);return o1(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function mfe(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function mz({asChild:e,children:t},n){return e&&m.isValidElement(t)?m.cloneElement(mfe(t),{ref:t.ref},n(t.props.children)):n(t)}var kfe={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const kz=hz,gfe=({children:e,...t})=>{const n=Qu();return y.jsx(fz,{container:n,...t,children:e})},SK=m.forwardRef(({className:e,...t},n)=>y.jsx(jh,{ref:n,className:ie("sf:fixed sf:inset-0 sf:z-50 sf:bg-black/80 sf:data-[state=open]:animate-in sf:data-[state=closed]:animate-out sf:data-[state=closed]:fade-out-0 sf:data-[state=open]:fade-in-0",e),...t}));SK.displayName=jh.displayName;const Nh=m.forwardRef(({className:e,children:t,...n},r)=>y.jsxs(gfe,{children:[y.jsx(SK,{}),y.jsxs(ed,{ref:r,className:ie("sf:fixed sf:left-[50%] sf:top-[50%] sf:z-50 sf:grid sf:w-full sf:max-w-lg sf:translate-x-[-50%] sf:translate-y-[-50%] sf:gap-4 sf:border sf:border-border sf:bg-card sf:p-6 sf:shadow-lg sf:duration-200 sf:data-[state=open]:animate-in sf:data-[state=closed]:animate-out sf:data-[state=closed]:fade-out-0 sf:data-[state=open]:fade-in-0 sf:data-[state=closed]:zoom-out-95 sf:data-[state=open]:zoom-in-95 sf:data-[state=closed]:slide-out-to-left-1/2 sf:data-[state=closed]:slide-out-to-top-[48%] sf:data-[state=open]:slide-in-from-left-1/2 sf:data-[state=open]:slide-in-from-top-[48%] sf:sm:rounded-lg",e),...n,children:[t,y.jsxs(kK,{className:"sf:absolute sf:right-4 sf:top-4 sf:rounded-sm sf:opacity-70 sf:ring-offset-background sf:transition-opacity sf:hover:opacity-100 sf:focus:outline-hidden sf:focus:ring-2 sf:focus:ring-ring sf:focus:ring-offset-2 sf:disabled:pointer-events-none",children:[y.jsx(uu,{className:"sf:h-4 sf:w-4"}),y.jsx("span",{className:"sf:sr-only",children:"Close"})]})]})]}));Nh.displayName=ed.displayName;const Dh=({className:e,...t})=>y.jsx("div",{className:ie("sf:flex sf:flex-col sf:space-y-1.5 sf:text-center sf:sm:text-left",e),...t});Dh.displayName="DialogHeader";const Hu=({className:e,...t})=>y.jsx("div",{className:ie("sf:flex sf:flex-col-reverse sf:sm:flex-row sf:sm:justify-end sf:sm:space-x-2",e),...t});Hu.displayName="DialogFooter";const _h=m.forwardRef(({className:e,...t},n)=>y.jsx(pz,{ref:n,className:ie("sf:text-lg sf:font-semibold sf:leading-none sf:tracking-tight",e),...t}));_h.displayName=pz.displayName;const Hh=m.forwardRef(({className:e,...t},n)=>y.jsx(yz,{ref:n,className:ie("sf:text-sm sf:text-muted-foreground",e),...t}));Hh.displayName=yz.displayName;const LK=m.forwardRef(({className:e,...t},n)=>y.jsx(Pn,{ref:n,className:ie("sf:flex sf:h-full sf:w-full sf:flex-col sf:overflow-hidden sf:rounded-md sf:bg-card sf:text-foreground",e),...t}));LK.displayName=Pn.displayName;const IK=m.forwardRef(({className:e,...t},n)=>y.jsxs("div",{className:"sf:flex sf:items-center sf:border-b sf:px-3","cmdk-input-wrapper":"",children:[y.jsx(p2,{className:"sf:mr-2 sf:h-4 sf:w-4 sf:shrink-0 sf:opacity-50"}),y.jsx(Pn.Input,{ref:n,className:ie("sf:flex sf:h-11 sf:w-full sf:rounded-md sf:bg-transparent sf:py-3 sf:text-sm sf:outline-hidden sf:placeholder:text-muted-foreground sf:disabled:cursor-not-allowed sf:disabled:opacity-50",e),...t})]}));IK.displayName=Pn.Input.displayName;const EK=m.forwardRef(({className:e,...t},n)=>y.jsx(Pn.List,{ref:n,className:ie("sf:max-h-[300px] sf:overflow-y-auto sf:overflow-x-hidden",e),...t}));EK.displayName=Pn.List.displayName;const AK=m.forwardRef((e,t)=>y.jsx(Pn.Empty,{ref:t,className:"sf:py-6 sf:text-center sf:text-sm",...e}));AK.displayName=Pn.Empty.displayName;const PN=m.forwardRef(({className:e,...t},n)=>y.jsx(Pn.Group,{ref:n,className:ie("sf:overflow-hidden sf:p-1 sf:text-foreground sf:**:[[cmdk-group-heading]]:px-2 sf:**:[[cmdk-group-heading]]:py-1.5 sf:**:[[cmdk-group-heading]]:text-xs sf:**:[[cmdk-group-heading]]:font-medium sf:**:[[cmdk-group-heading]]:text-muted-foreground",e),...t}));PN.displayName=Pn.Group.displayName;const PK=m.forwardRef(({className:e,...t},n)=>y.jsx(Pn.Separator,{ref:n,className:ie("sf:-mx-1 sf:h-px sf:bg-border",e),...t}));PK.displayName=Pn.Separator.displayName;const RN=m.forwardRef(({className:e,...t},n)=>y.jsx(Pn.Item,{ref:n,className:ie("sf:relative sf:flex sf:cursor-default sf:select-none sf:items-center sf:rounded-sm sf:px-2 sf:py-1.5 sf:text-sm sf:outline-hidden sf:aria-selected:bg-muted sf:aria-selected:text-foreground sf:data-[disabled='true']:pointer-events-none sf:data-[disabled='true']:opacity-50",e),...t}));RN.displayName=Pn.Item.displayName;const RK=({className:e,...t})=>y.jsx("span",{className:ie("sf:ml-auto sf:text-xs sf:tracking-widest sf:text-muted-foreground",e),...t});RK.displayName="CommandShortcut";function B_(e){const t=e+"CollectionProvider",[n,r]=Nr(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=v=>{const{scope:w,children:g}=v,M=oo.useRef(null),x=oo.useRef(new Map).current;return y.jsx(o,{scope:w,itemMap:x,collectionRef:M,children:g})};a.displayName=t;const s=e+"CollectionSlot",l=Nu(s),c=oo.forwardRef((v,w)=>{const{scope:g,children:M}=v,x=i(s,g),b=dt(w,x.collectionRef);return y.jsx(l,{ref:b,children:M})});c.displayName=s;const h=e+"CollectionItemSlot",d="data-radix-collection-item",f=Nu(h),p=oo.forwardRef((v,w)=>{const{scope:g,children:M,...x}=v,b=oo.useRef(null),S=dt(w,b),C=i(h,g);return oo.useEffect(()=>(C.itemMap.set(b,{ref:b,...x}),()=>void C.itemMap.delete(b))),y.jsx(f,{[d]:"",ref:S,children:M})});p.displayName=h;function k(v){const w=i(e+"CollectionConsumer",v);return oo.useCallback(()=>{const M=w.collectionRef.current;if(!M)return[];const x=Array.from(M.querySelectorAll(`[${d}]`));return Array.from(w.itemMap.values()).sort((C,L)=>x.indexOf(C.ref.current)-x.indexOf(L.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:a,Slot:c,ItemSlot:p},k,r]}var xfe=m.createContext(void 0);function gz(e){const t=m.useContext(xfe);return e||t||"ltr"}var qj="rovingFocusGroup.onEntryFocus",vfe={bubbles:!1,cancelable:!0},Fh="RovingFocusGroup",[zN,zK,wfe]=B_(Fh),[Mfe,xz]=Nr(Fh,[wfe]),[bfe,Cfe]=Mfe(Fh),jK=m.forwardRef((e,t)=>y.jsx(zN.Provider,{scope:e.__scopeRovingFocusGroup,children:y.jsx(zN.Slot,{scope:e.__scopeRovingFocusGroup,children:y.jsx(Sfe,{...e,ref:t})})}));jK.displayName=Fh;var Sfe=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:a,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:h=!1,...d}=e,f=m.useRef(null),p=dt(t,f),k=gz(i),[v,w]=c1({prop:a,defaultProp:s??null,onChange:l,caller:Fh}),[g,M]=m.useState(!1),x=go(c),b=zK(n),S=m.useRef(!1),[C,L]=m.useState(0);return m.useEffect(()=>{const P=f.current;if(P)return P.addEventListener(qj,x),()=>P.removeEventListener(qj,x)},[x]),y.jsx(bfe,{scope:n,orientation:r,dir:k,loop:o,currentTabStopId:v,onItemFocus:m.useCallback(P=>w(P),[w]),onItemShiftTab:m.useCallback(()=>M(!0),[]),onFocusableItemAdd:m.useCallback(()=>L(P=>P+1),[]),onFocusableItemRemove:m.useCallback(()=>L(P=>P-1),[]),children:y.jsx(Ve.div,{tabIndex:g||C===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:"none",...e.style},onMouseDown:Ie(e.onMouseDown,()=>{S.current=!0}),onFocus:Ie(e.onFocus,P=>{const T=!S.current;if(P.target===P.currentTarget&&T&&!g){const E=new CustomEvent(qj,vfe);if(P.currentTarget.dispatchEvent(E),!E.defaultPrevented){const z=b().filter(O=>O.focusable),A=z.find(O=>O.active),U=z.find(O=>O.id===v),V=[A,U,...z].filter(Boolean).map(O=>O.ref.current);DK(V,h)}}S.current=!1}),onBlur:Ie(e.onBlur,()=>M(!1))})})}),TK="RovingFocusGroupItem",NK=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:a,...s}=e,l=dn(),c=i||l,h=Cfe(TK,n),d=h.currentTabStopId===c,f=zK(n),{onFocusableItemAdd:p,onFocusableItemRemove:k,currentTabStopId:v}=h;return m.useEffect(()=>{if(r)return p(),()=>k()},[r,p,k]),y.jsx(zN.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:y.jsx(Ve.span,{tabIndex:d?0:-1,"data-orientation":h.orientation,...s,ref:t,onMouseDown:Ie(e.onMouseDown,w=>{r?h.onItemFocus(c):w.preventDefault()}),onFocus:Ie(e.onFocus,()=>h.onItemFocus(c)),onKeyDown:Ie(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){h.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const g=Efe(w,h.orientation,h.dir);if(g!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let x=f().filter(b=>b.focusable).map(b=>b.ref.current);if(g==="last")x.reverse();else if(g==="prev"||g==="next"){g==="prev"&&x.reverse();const b=x.indexOf(w.currentTarget);x=h.loop?Afe(x,b+1):x.slice(b+1)}setTimeout(()=>DK(x))}}),children:typeof a=="function"?a({isCurrentTabStop:d,hasTabStop:v!=null}):a})})});NK.displayName=TK;var Lfe={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Ife(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Efe(e,t,n){const r=Ife(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Lfe[r]}function DK(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Afe(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var _K=jK,HK=NK,jN=["Enter"," "],Pfe=["ArrowDown","PageUp","Home"],FK=["ArrowUp","PageDown","End"],Rfe=[...Pfe,...FK],zfe={ltr:[...jN,"ArrowRight"],rtl:[...jN,"ArrowLeft"]},jfe={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Oh="Menu",[ih,Tfe,Nfe]=B_(Oh),[d1,vz]=Nr(Oh,[Nfe,Yu,xz]),wz=Yu(),OK=xz(),[Dfe,h1]=d1(Oh),[_fe,qh]=d1(Oh),qK=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:i,modal:a=!0}=e,s=wz(t),[l,c]=m.useState(null),h=m.useRef(!1),d=go(i),f=gz(o);return m.useEffect(()=>{const p=()=>{h.current=!0,document.addEventListener("pointerdown",k,{capture:!0,once:!0}),document.addEventListener("pointermove",k,{capture:!0,once:!0})},k=()=>h.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",k,{capture:!0}),document.removeEventListener("pointermove",k,{capture:!0})}},[]),y.jsx(z_,{...s,children:y.jsx(Dfe,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:y.jsx(_fe,{scope:t,onClose:m.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:h,dir:f,modal:a,children:r})})})};qK.displayName=Oh;var Hfe="MenuAnchor",$_=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=wz(n);return y.jsx(az,{...o,...r,ref:t})});$_.displayName=Hfe;var U_="MenuPortal",[Ffe,VK]=d1(U_,{forceMount:void 0}),BK=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,i=h1(U_,t);return y.jsx(Ffe,{scope:t,forceMount:n,children:y.jsx(Qn,{present:n||i.open,children:y.jsx(Lh,{asChild:!0,container:o,children:r})})})};BK.displayName=U_;var ur="MenuContent",[Ofe,W_]=d1(ur),$K=m.forwardRef((e,t)=>{const n=VK(ur,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,i=h1(ur,e.__scopeMenu),a=qh(ur,e.__scopeMenu);return y.jsx(ih.Provider,{scope:e.__scopeMenu,children:y.jsx(Qn,{present:r||i.open,children:y.jsx(ih.Slot,{scope:e.__scopeMenu,children:a.modal?y.jsx(qfe,{...o,ref:t}):y.jsx(Vfe,{...o,ref:t})})})})}),qfe=m.forwardRef((e,t)=>{const n=h1(ur,e.__scopeMenu),r=m.useRef(null),o=dt(t,r);return m.useEffect(()=>{const i=r.current;if(i)return N_(i)},[]),y.jsx(G_,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ie(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Vfe=m.forwardRef((e,t)=>{const n=h1(ur,e.__scopeMenu);return y.jsx(G_,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Bfe=Nu("MenuContent.ScrollLock"),G_=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:s,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:h,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:k,...v}=e,w=h1(ur,n),g=qh(ur,n),M=wz(n),x=OK(n),b=Tfe(n),[S,C]=m.useState(null),L=m.useRef(null),P=dt(t,L,w.onContentChange),T=m.useRef(0),E=m.useRef(""),z=m.useRef(0),A=m.useRef(null),U=m.useRef("right"),R=m.useRef(0),V=k?lz:m.Fragment,O=k?{as:Bfe,allowPinchZoom:!0}:void 0,B=N=>{var re,ne;const I=E.current+N,W=b().filter(ae=>!ae.disabled),H=document.activeElement,j=(re=W.find(ae=>ae.ref.current===H))==null?void 0:re.textValue,G=W.map(ae=>ae.textValue),X=tpe(G,I,j),Y=(ne=W.find(ae=>ae.textValue===X))==null?void 0:ne.ref.current;(function ae(ve){E.current=ve,window.clearTimeout(T.current),ve!==""&&(T.current=window.setTimeout(()=>ae(""),1e3))})(I),Y&&setTimeout(()=>Y.focus())};m.useEffect(()=>()=>window.clearTimeout(T.current),[]),b_();const D=m.useCallback(N=>{var W,H;return U.current===((W=A.current)==null?void 0:W.side)&&rpe(N,(H=A.current)==null?void 0:H.area)},[]);return y.jsx(Ofe,{scope:n,searchRef:E,onItemEnter:m.useCallback(N=>{D(N)&&N.preventDefault()},[D]),onItemLeave:m.useCallback(N=>{var I;D(N)||((I=L.current)==null||I.focus(),C(null))},[D]),onTriggerLeave:m.useCallback(N=>{D(N)&&N.preventDefault()},[D]),pointerGraceTimerRef:z,onPointerGraceIntentChange:m.useCallback(N=>{A.current=N},[]),children:y.jsx(V,{...O,children:y.jsx(tz,{asChild:!0,trapped:o,onMountAutoFocus:Ie(i,N=>{var I;N.preventDefault(),(I=L.current)==null||I.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:y.jsx(Ch,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:c,onPointerDownOutside:h,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:y.jsx(_K,{asChild:!0,...x,dir:g.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:Ie(l,N=>{g.isUsingKeyboardRef.current||N.preventDefault()}),preventScrollOnEntryFocus:!0,children:y.jsx(j_,{role:"menu","aria-orientation":"vertical","data-state":aX(w.open),"data-radix-menu-content":"",dir:g.dir,...M,...v,ref:P,style:{outline:"none",...v.style},onKeyDown:Ie(v.onKeyDown,N=>{const W=N.target.closest("[data-radix-menu-content]")===N.currentTarget,H=N.ctrlKey||N.altKey||N.metaKey,j=N.key.length===1;W&&(N.key==="Tab"&&N.preventDefault(),!H&&j&&B(N.key));const G=L.current;if(N.target!==G||!Rfe.includes(N.key))return;N.preventDefault();const Y=b().filter(re=>!re.disabled).map(re=>re.ref.current);FK.includes(N.key)&&Y.reverse(),Jfe(Y)}),onBlur:Ie(e.onBlur,N=>{N.currentTarget.contains(N.target)||(window.clearTimeout(T.current),E.current="")}),onPointerMove:Ie(e.onPointerMove,ah(N=>{const I=N.target,W=R.current!==N.clientX;if(N.currentTarget.contains(I)&&W){const H=N.clientX>R.current?"right":"left";U.current=H,R.current=N.clientX}}))})})})})})})});$K.displayName=ur;var $fe="MenuGroup",Z_=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return y.jsx(Ve.div,{role:"group",...r,ref:t})});Z_.displayName=$fe;var Ufe="MenuLabel",UK=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return y.jsx(Ve.div,{...r,ref:t})});UK.displayName=Ufe;var mR="MenuItem",Zq="menu.itemSelect",Mz=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,i=m.useRef(null),a=qh(mR,e.__scopeMenu),s=W_(mR,e.__scopeMenu),l=dt(t,i),c=m.useRef(!1),h=()=>{const d=i.current;if(!n&&d){const f=new CustomEvent(Zq,{bubbles:!0,cancelable:!0});d.addEventListener(Zq,p=>r==null?void 0:r(p),{once:!0}),rZ(d,f),f.defaultPrevented?c.current=!1:a.onClose()}};return y.jsx(WK,{...o,ref:l,disabled:n,onClick:Ie(e.onClick,h),onPointerDown:d=>{var f;(f=e.onPointerDown)==null||f.call(e,d),c.current=!0},onPointerUp:Ie(e.onPointerUp,d=>{var f;c.current||(f=d.currentTarget)==null||f.click()}),onKeyDown:Ie(e.onKeyDown,d=>{const f=s.searchRef.current!=="";n||f&&d.key===" "||jN.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});Mz.displayName=mR;var WK=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...i}=e,a=W_(mR,n),s=OK(n),l=m.useRef(null),c=dt(t,l),[h,d]=m.useState(!1),[f,p]=m.useState("");return m.useEffect(()=>{const k=l.current;k&&p((k.textContent??"").trim())},[i.children]),y.jsx(ih.ItemSlot,{scope:n,disabled:r,textValue:o??f,children:y.jsx(HK,{asChild:!0,...s,focusable:!r,children:y.jsx(Ve.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...i,ref:c,onPointerMove:Ie(e.onPointerMove,ah(k=>{r?a.onItemLeave(k):(a.onItemEnter(k),k.defaultPrevented||k.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ie(e.onPointerLeave,ah(k=>a.onItemLeave(k))),onFocus:Ie(e.onFocus,()=>d(!0)),onBlur:Ie(e.onBlur,()=>d(!1))})})})}),Wfe="MenuCheckboxItem",GK=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return y.jsx(QK,{scope:e.__scopeMenu,checked:n,children:y.jsx(Mz,{role:"menuitemcheckbox","aria-checked":kR(n)?"mixed":n,...o,ref:t,"data-state":X_(n),onSelect:Ie(o.onSelect,()=>r==null?void 0:r(kR(n)?!0:!n),{checkForDefaultPrevented:!1})})})});GK.displayName=Wfe;var ZK="MenuRadioGroup",[Gfe,Zfe]=d1(ZK,{value:void 0,onValueChange:()=>{}}),KK=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,i=go(r);return y.jsx(Gfe,{scope:e.__scopeMenu,value:n,onValueChange:i,children:y.jsx(Z_,{...o,ref:t})})});KK.displayName=ZK;var XK="MenuRadioItem",YK=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=Zfe(XK,e.__scopeMenu),i=n===o.value;return y.jsx(QK,{scope:e.__scopeMenu,checked:i,children:y.jsx(Mz,{role:"menuitemradio","aria-checked":i,...r,ref:t,"data-state":X_(i),onSelect:Ie(r.onSelect,()=>{var a;return(a=o.onValueChange)==null?void 0:a.call(o,n)},{checkForDefaultPrevented:!1})})})});YK.displayName=XK;var K_="MenuItemIndicator",[QK,Kfe]=d1(K_,{checked:!1}),JK=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,i=Kfe(K_,n);return y.jsx(Qn,{present:r||kR(i.checked)||i.checked===!0,children:y.jsx(Ve.span,{...o,ref:t,"data-state":X_(i.checked)})})});JK.displayName=K_;var Xfe="MenuSeparator",eX=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return y.jsx(Ve.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});eX.displayName=Xfe;var Yfe="MenuArrow",tX=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=wz(n);return y.jsx(T_,{...o,...r,ref:t})});tX.displayName=Yfe;var Qfe="MenuSub",[A8e,nX]=d1(Qfe),Hd="MenuSubTrigger",rX=m.forwardRef((e,t)=>{const n=h1(Hd,e.__scopeMenu),r=qh(Hd,e.__scopeMenu),o=nX(Hd,e.__scopeMenu),i=W_(Hd,e.__scopeMenu),a=m.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:l}=i,c={__scopeMenu:e.__scopeMenu},h=m.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return m.useEffect(()=>h,[h]),m.useEffect(()=>{const d=s.current;return()=>{window.clearTimeout(d),l(null)}},[s,l]),y.jsx($_,{asChild:!0,...c,children:y.jsx(WK,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":aX(n.open),...e,ref:ko(t,o.onTriggerChange),onClick:d=>{var f;(f=e.onClick)==null||f.call(e,d),!(e.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Ie(e.onPointerMove,ah(d=>{i.onItemEnter(d),!d.defaultPrevented&&!e.disabled&&!n.open&&!a.current&&(i.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{n.onOpenChange(!0),h()},100))})),onPointerLeave:Ie(e.onPointerLeave,ah(d=>{var p,k;h();const f=(p=n.content)==null?void 0:p.getBoundingClientRect();if(f){const v=(k=n.content)==null?void 0:k.dataset.side,w=v==="right",g=w?-5:5,M=f[w?"left":"right"],x=f[w?"right":"left"];i.onPointerGraceIntentChange({area:[{x:d.clientX+g,y:d.clientY},{x:M,y:f.top},{x,y:f.top},{x,y:f.bottom},{x:M,y:f.bottom}],side:v}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(d),d.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:Ie(e.onKeyDown,d=>{var p;const f=i.searchRef.current!=="";e.disabled||f&&d.key===" "||zfe[r.dir].includes(d.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),d.preventDefault())})})})});rX.displayName=Hd;var oX="MenuSubContent",iX=m.forwardRef((e,t)=>{const n=VK(ur,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,i=h1(ur,e.__scopeMenu),a=qh(ur,e.__scopeMenu),s=nX(oX,e.__scopeMenu),l=m.useRef(null),c=dt(t,l);return y.jsx(ih.Provider,{scope:e.__scopeMenu,children:y.jsx(Qn,{present:r||i.open,children:y.jsx(ih.Slot,{scope:e.__scopeMenu,children:y.jsx(G_,{id:s.contentId,"aria-labelledby":s.triggerId,...o,ref:c,align:"start",side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:h=>{var d;a.isUsingKeyboardRef.current&&((d=l.current)==null||d.focus()),h.preventDefault()},onCloseAutoFocus:h=>h.preventDefault(),onFocusOutside:Ie(e.onFocusOutside,h=>{h.target!==s.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Ie(e.onEscapeKeyDown,h=>{a.onClose(),h.preventDefault()}),onKeyDown:Ie(e.onKeyDown,h=>{var p;const d=h.currentTarget.contains(h.target),f=jfe[a.dir].includes(h.key);d&&f&&(i.onOpenChange(!1),(p=s.trigger)==null||p.focus(),h.preventDefault())})})})})})});iX.displayName=oX;function aX(e){return e?"open":"closed"}function kR(e){return e==="indeterminate"}function X_(e){return kR(e)?"indeterminate":e?"checked":"unchecked"}function Jfe(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function epe(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function tpe(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let a=epe(e,Math.max(i,0));o.length===1&&(a=a.filter(c=>c!==n));const l=a.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function npe(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){const s=t[i],l=t[a],c=s.x,h=s.y,d=l.x,f=l.y;h>r!=f>r&&n<(d-c)*(r-h)/(f-h)+c&&(o=!o)}return o}function rpe(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return npe(n,t)}function ah(e){return t=>t.pointerType==="mouse"?e(t):void 0}var sX=qK,lX=$_,cX=BK,uX=$K,dX=Z_,hX=UK,fX=Mz,pX=GK,yX=KK,mX=YK,kX=JK,gX=eX,xX=tX,vX=rX,wX=iX,Y_="ContextMenu",[ope]=Nr(Y_,[vz]),pn=vz(),[ipe,MX]=ope(Y_),bX=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:r,dir:o,modal:i=!0}=e,[a,s]=m.useState(!1),l=pn(t),c=go(r),h=m.useCallback(d=>{s(d),c(d)},[c]);return y.jsx(ipe,{scope:t,open:a,onOpenChange:h,modal:i,children:y.jsx(sX,{...l,dir:o,open:a,onOpenChange:h,modal:i,children:n})})};bX.displayName=Y_;var CX="ContextMenuTrigger",SX=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,disabled:r=!1,...o}=e,i=MX(CX,n),a=pn(n),s=m.useRef({x:0,y:0}),l=m.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...s.current})}),c=m.useRef(0),h=m.useCallback(()=>window.clearTimeout(c.current),[]),d=f=>{s.current={x:f.clientX,y:f.clientY},i.onOpenChange(!0)};return m.useEffect(()=>h,[h]),m.useEffect(()=>void(r&&h()),[r,h]),y.jsxs(y.Fragment,{children:[y.jsx(lX,{...a,virtualRef:l}),y.jsx(Ve.span,{"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,...o,ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:r?e.onContextMenu:Ie(e.onContextMenu,f=>{h(),d(f),f.preventDefault()}),onPointerDown:r?e.onPointerDown:Ie(e.onPointerDown,V0(f=>{h(),c.current=window.setTimeout(()=>d(f),700)})),onPointerMove:r?e.onPointerMove:Ie(e.onPointerMove,V0(h)),onPointerCancel:r?e.onPointerCancel:Ie(e.onPointerCancel,V0(h)),onPointerUp:r?e.onPointerUp:Ie(e.onPointerUp,V0(h))})]})});SX.displayName=CX;var ape="ContextMenuPortal",LX=e=>{const{__scopeContextMenu:t,...n}=e,r=pn(t);return y.jsx(cX,{...r,...n})};LX.displayName=ape;var IX="ContextMenuContent",EX=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=MX(IX,n),i=pn(n),a=m.useRef(!1);return y.jsx(uX,{...i,...r,ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:s=>{var l;(l=e.onCloseAutoFocus)==null||l.call(e,s),!s.defaultPrevented&&a.current&&s.preventDefault(),a.current=!1},onInteractOutside:s=>{var l;(l=e.onInteractOutside)==null||l.call(e,s),!s.defaultPrevented&&!o.modal&&(a.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});EX.displayName=IX;var spe="ContextMenuGroup",lpe=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return y.jsx(dX,{...o,...r,ref:t})});lpe.displayName=spe;var cpe="ContextMenuLabel",upe=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return y.jsx(hX,{...o,...r,ref:t})});upe.displayName=cpe;var dpe="ContextMenuItem",AX=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return y.jsx(fX,{...o,...r,ref:t})});AX.displayName=dpe;var hpe="ContextMenuCheckboxItem",fpe=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return y.jsx(pX,{...o,...r,ref:t})});fpe.displayName=hpe;var ppe="ContextMenuRadioGroup",ype=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return y.jsx(yX,{...o,...r,ref:t})});ype.displayName=ppe;var mpe="ContextMenuRadioItem",kpe=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return y.jsx(mX,{...o,...r,ref:t})});kpe.displayName=mpe;var gpe="ContextMenuItemIndicator",xpe=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return y.jsx(kX,{...o,...r,ref:t})});xpe.displayName=gpe;var vpe="ContextMenuSeparator",PX=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return y.jsx(gX,{...o,...r,ref:t})});PX.displayName=vpe;var wpe="ContextMenuArrow",Mpe=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return y.jsx(xX,{...o,...r,ref:t})});Mpe.displayName=wpe;var bpe="ContextMenuSubTrigger",Cpe=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return y.jsx(vX,{...o,...r,ref:t})});Cpe.displayName=bpe;var Spe="ContextMenuSubContent",Lpe=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return y.jsx(wX,{...o,...r,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Lpe.displayName=Spe;function V0(e){return t=>t.pointerType!=="mouse"?e(t):void 0}var Ipe=bX,Epe=SX,Ape=LX,RX=EX,zX=AX,jX=PX;const Ppe=Ipe,Rpe=Epe,TX=m.forwardRef(({className:e,...t},n)=>{const r=Qu();return y.jsx(Ape,{container:r,children:y.jsx(RX,{ref:n,className:ie("sf:z-50 sf:min-w-40 sf:overflow-hidden sf:rounded-md sf:border sf:bg-popover sf:p-1 sf:text-popover-foreground sf:shadow-md sf:data-[state=open]:animate-in sf:data-[state=closed]:animate-out sf:data-[state=closed]:fade-out-0 sf:data-[state=open]:fade-in-0 sf:data-[state=closed]:zoom-out-95 sf:data-[state=open]:zoom-in-95",e),...t})})});TX.displayName=RX.displayName;const to=m.forwardRef(({className:e,...t},n)=>y.jsx(zX,{ref:n,className:ie("sf:relative sf:flex sf:cursor-default sf:select-none sf:items-center sf:rounded-sm sf:px-2 sf:py-1.5 sf:text-sm sf:outline-hidden sf:data-disabled:pointer-events-none sf:data-highlighted:bg-accent sf:data-highlighted:text-accent-foreground sf:data-disabled:opacity-50",e),...t}));to.displayName=zX.displayName;const MP=m.forwardRef(({className:e,...t},n)=>y.jsx(jX,{ref:n,className:ie("sf:-mx-1 sf:my-1 sf:h-px sf:bg-border",e),...t}));MP.displayName=jX.displayName;const TN=({className:e,...t})=>y.jsx("span",{className:ie("sf:ml-auto sf:pl-4 sf:text-xs sf:tracking-widest sf:text-muted-foreground",e),...t});TN.displayName="ContextMenuShortcut";var bz="DropdownMenu",[zpe]=Nr(bz,[vz]),yn=vz(),[jpe,NX]=zpe(bz),DX=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:i,onOpenChange:a,modal:s=!0}=e,l=yn(t),c=m.useRef(null),[h,d]=c1({prop:o,defaultProp:i??!1,onChange:a,caller:bz});return y.jsx(jpe,{scope:t,triggerId:dn(),triggerRef:c,contentId:dn(),open:h,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),modal:s,children:y.jsx(sX,{...l,open:h,onOpenChange:d,dir:r,modal:s,children:n})})};DX.displayName=bz;var _X="DropdownMenuTrigger",HX=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,i=NX(_X,n),a=yn(n);return y.jsx(lX,{asChild:!0,...a,children:y.jsx(Ve.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:ko(t,i.triggerRef),onPointerDown:Ie(e.onPointerDown,s=>{!r&&s.button===0&&s.ctrlKey===!1&&(i.onOpenToggle(),i.open||s.preventDefault())}),onKeyDown:Ie(e.onKeyDown,s=>{r||(["Enter"," "].includes(s.key)&&i.onOpenToggle(),s.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(s.key)&&s.preventDefault())})})})});HX.displayName=_X;var Tpe="DropdownMenuPortal",FX=e=>{const{__scopeDropdownMenu:t,...n}=e,r=yn(t);return y.jsx(cX,{...r,...n})};FX.displayName=Tpe;var OX="DropdownMenuContent",qX=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=NX(OX,n),i=yn(n),a=m.useRef(!1);return y.jsx(uX,{id:o.contentId,"aria-labelledby":o.triggerId,...i,...r,ref:t,onCloseAutoFocus:Ie(e.onCloseAutoFocus,s=>{var l;a.current||(l=o.triggerRef.current)==null||l.focus(),a.current=!1,s.preventDefault()}),onInteractOutside:Ie(e.onInteractOutside,s=>{const l=s.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,h=l.button===2||c;(!o.modal||h)&&(a.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});qX.displayName=OX;var Npe="DropdownMenuGroup",Dpe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yn(n);return y.jsx(dX,{...o,...r,ref:t})});Dpe.displayName=Npe;var _pe="DropdownMenuLabel",Hpe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yn(n);return y.jsx(hX,{...o,...r,ref:t})});Hpe.displayName=_pe;var Fpe="DropdownMenuItem",VX=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yn(n);return y.jsx(fX,{...o,...r,ref:t})});VX.displayName=Fpe;var Ope="DropdownMenuCheckboxItem",qpe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yn(n);return y.jsx(pX,{...o,...r,ref:t})});qpe.displayName=Ope;var Vpe="DropdownMenuRadioGroup",Bpe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yn(n);return y.jsx(yX,{...o,...r,ref:t})});Bpe.displayName=Vpe;var $pe="DropdownMenuRadioItem",Upe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yn(n);return y.jsx(mX,{...o,...r,ref:t})});Upe.displayName=$pe;var Wpe="DropdownMenuItemIndicator",Gpe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yn(n);return y.jsx(kX,{...o,...r,ref:t})});Gpe.displayName=Wpe;var Zpe="DropdownMenuSeparator",BX=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yn(n);return y.jsx(gX,{...o,...r,ref:t})});BX.displayName=Zpe;var Kpe="DropdownMenuArrow",Xpe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yn(n);return y.jsx(xX,{...o,...r,ref:t})});Xpe.displayName=Kpe;var Ype="DropdownMenuSubTrigger",Qpe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yn(n);return y.jsx(vX,{...o,...r,ref:t})});Qpe.displayName=Ype;var Jpe="DropdownMenuSubContent",eye=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yn(n);return y.jsx(wX,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});eye.displayName=Jpe;var tye=DX,nye=HX,rye=FX,$X=qX,UX=VX,WX=BX;const oye=tye,iye=nye,GX=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>{const o=Qu();return y.jsx(rye,{container:o,children:y.jsx($X,{ref:r,sideOffset:t,className:ie("sf:z-50 sf:min-w-40 sf:overflow-hidden sf:rounded-md sf:border sf:bg-popover sf:p-1 sf:text-popover-foreground sf:shadow-md sf:data-[state=open]:animate-in sf:data-[state=closed]:animate-out sf:data-[state=closed]:fade-out-0 sf:data-[state=open]:fade-in-0 sf:data-[state=closed]:zoom-out-95 sf:data-[state=open]:zoom-in-95 sf:data-[side=bottom]:slide-in-from-top-2 sf:data-[side=left]:slide-in-from-right-2 sf:data-[side=right]:slide-in-from-left-2 sf:data-[side=top]:slide-in-from-bottom-2",e),...n})})});GX.displayName=$X.displayName;const Fd=m.forwardRef(({className:e,...t},n)=>y.jsx(UX,{ref:n,className:ie("sf:relative sf:flex sf:cursor-default sf:select-none sf:items-center sf:gap-2 sf:rounded-sm sf:px-2 sf:py-1.5 sf:text-sm sf:outline-hidden sf:data-disabled:pointer-events-none sf:data-highlighted:bg-accent sf:data-highlighted:text-accent-foreground sf:data-disabled:opacity-50",e),...t}));Fd.displayName=UX.displayName;const aye=m.forwardRef(({className:e,...t},n)=>y.jsx(WX,{ref:n,className:ie("sf:-mx-1 sf:my-1 sf:h-px sf:bg-border",e),...t}));aye.displayName=WX.displayName;var sye=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),lye="VisuallyHidden",ZX=m.forwardRef((e,t)=>y.jsx(Ve.span,{...e,ref:t,style:{...sye,...e.style}}));ZX.displayName=lye;var cye=ZX,[Cz]=Nr("Tooltip",[Yu]),Sz=Yu(),KX="TooltipProvider",uye=700,NN="tooltip.open",[dye,Q_]=Cz(KX),XX=e=>{const{__scopeTooltip:t,delayDuration:n=uye,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:i}=e,a=m.useRef(!0),s=m.useRef(!1),l=m.useRef(0);return m.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),y.jsx(dye,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:m.useCallback(()=>{window.clearTimeout(l.current),a.current=!1},[]),onClose:m.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>a.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:m.useCallback(c=>{s.current=c},[]),disableHoverableContent:o,children:i})};XX.displayName=KX;var sh="Tooltip",[hye,Vh]=Cz(sh),YX=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:i,disableHoverableContent:a,delayDuration:s}=e,l=Q_(sh,e.__scopeTooltip),c=Sz(t),[h,d]=m.useState(null),f=dn(),p=m.useRef(0),k=a??l.disableHoverableContent,v=s??l.delayDuration,w=m.useRef(!1),[g,M]=c1({prop:r,defaultProp:o??!1,onChange:L=>{L?(l.onOpen(),document.dispatchEvent(new CustomEvent(NN))):l.onClose(),i==null||i(L)},caller:sh}),x=m.useMemo(()=>g?w.current?"delayed-open":"instant-open":"closed",[g]),b=m.useCallback(()=>{window.clearTimeout(p.current),p.current=0,w.current=!1,M(!0)},[M]),S=m.useCallback(()=>{window.clearTimeout(p.current),p.current=0,M(!1)},[M]),C=m.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{w.current=!0,M(!0),p.current=0},v)},[v,M]);return m.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),y.jsx(z_,{...c,children:y.jsx(hye,{scope:t,contentId:f,open:g,stateAttribute:x,trigger:h,onTriggerChange:d,onTriggerEnter:m.useCallback(()=>{l.isOpenDelayedRef.current?C():b()},[l.isOpenDelayedRef,C,b]),onTriggerLeave:m.useCallback(()=>{k?S():(window.clearTimeout(p.current),p.current=0)},[S,k]),onOpen:b,onClose:S,disableHoverableContent:k,children:n})})};YX.displayName=sh;var DN="TooltipTrigger",QX=m.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Vh(DN,n),i=Q_(DN,n),a=Sz(n),s=m.useRef(null),l=dt(t,s,o.onTriggerChange),c=m.useRef(!1),h=m.useRef(!1),d=m.useCallback(()=>c.current=!1,[]);return m.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),y.jsx(az,{asChild:!0,...a,children:y.jsx(Ve.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:Ie(e.onPointerMove,f=>{f.pointerType!=="touch"&&!h.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),h.current=!0)}),onPointerLeave:Ie(e.onPointerLeave,()=>{o.onTriggerLeave(),h.current=!1}),onPointerDown:Ie(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Ie(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:Ie(e.onBlur,o.onClose),onClick:Ie(e.onClick,o.onClose)})})});QX.displayName=DN;var J_="TooltipPortal",[fye,pye]=Cz(J_,{forceMount:void 0}),JX=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,i=Vh(J_,t);return y.jsx(fye,{scope:t,forceMount:n,children:y.jsx(Qn,{present:n||i.open,children:y.jsx(Lh,{asChild:!0,container:o,children:r})})})};JX.displayName=J_;var Fu="TooltipContent",eY=m.forwardRef((e,t)=>{const n=pye(Fu,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,a=Vh(Fu,e.__scopeTooltip);return y.jsx(Qn,{present:r||a.open,children:a.disableHoverableContent?y.jsx(tY,{side:o,...i,ref:t}):y.jsx(yye,{side:o,...i,ref:t})})}),yye=m.forwardRef((e,t)=>{const n=Vh(Fu,e.__scopeTooltip),r=Q_(Fu,e.__scopeTooltip),o=m.useRef(null),i=dt(t,o),[a,s]=m.useState(null),{trigger:l,onClose:c}=n,h=o.current,{onPointerInTransitChange:d}=r,f=m.useCallback(()=>{s(null),d(!1)},[d]),p=m.useCallback((k,v)=>{const w=k.currentTarget,g={x:k.clientX,y:k.clientY},M=vye(g,w.getBoundingClientRect()),x=wye(g,M),b=Mye(v.getBoundingClientRect()),S=Cye([...x,...b]);s(S),d(!0)},[d]);return m.useEffect(()=>()=>f(),[f]),m.useEffect(()=>{if(l&&h){const k=w=>p(w,h),v=w=>p(w,l);return l.addEventListener("pointerleave",k),h.addEventListener("pointerleave",v),()=>{l.removeEventListener("pointerleave",k),h.removeEventListener("pointerleave",v)}}},[l,h,p,f]),m.useEffect(()=>{if(a){const k=v=>{const w=v.target,g={x:v.clientX,y:v.clientY},M=(l==null?void 0:l.contains(w))||(h==null?void 0:h.contains(w)),x=!bye(g,a);M?f():x&&(f(),c())};return document.addEventListener("pointermove",k),()=>document.removeEventListener("pointermove",k)}},[l,h,a,c,f]),y.jsx(tY,{...e,ref:i})}),[mye,kye]=Cz(sh,{isInside:!1}),gye=ade("TooltipContent"),tY=m.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:a,...s}=e,l=Vh(Fu,n),c=Sz(n),{onClose:h}=l;return m.useEffect(()=>(document.addEventListener(NN,h),()=>document.removeEventListener(NN,h)),[h]),m.useEffect(()=>{if(l.trigger){const d=f=>{const p=f.target;p!=null&&p.contains(l.trigger)&&h()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,h]),y.jsx(Ch,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:d=>d.preventDefault(),onDismiss:h,children:y.jsxs(j_,{"data-state":l.stateAttribute,...c,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[y.jsx(gye,{children:r}),y.jsx(mye,{scope:n,isInside:!0,children:y.jsx(cye,{id:l.contentId,role:"tooltip",children:o||r})})]})})});eY.displayName=Fu;var nY="TooltipArrow",xye=m.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Sz(n);return kye(nY,n).isInside?null:y.jsx(T_,{...o,...r,ref:t})});xye.displayName=nY;function vye(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function wye(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function Mye(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function bye(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){const s=t[i],l=t[a],c=s.x,h=s.y,d=l.x,f=l.y;h>r!=f>r&&n<(d-c)*(r-h)/(f-h)+c&&(o=!o)}return o}function Cye(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),Sye(t)}function Sye(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const i=t[t.length-1],a=t[t.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const i=n[n.length-1],a=n[n.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Lye=XX,Iye=YX,Eye=QX,Aye=JX,rY=eY;const L2=Lye,Bh=Iye,$h=Eye,td=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>{const o=Qu();return y.jsx(Aye,{container:o,children:y.jsx(rY,{ref:r,sideOffset:t,className:ie("sf:z-50 sf:overflow-hidden sf:rounded-md sf:bg-foreground sf:px-3 sf:py-1.5 sf:text-sm sf:text-background sf:shadow-md sf:animate-in sf:fade-in-0 sf:zoom-in-95 sf:data-[state=closed]:animate-out sf:data-[state=closed]:fade-out-0 sf:data-[state=closed]:zoom-out-95 sf:data-[side=bottom]:slide-in-from-top-2 sf:data-[side=left]:slide-in-from-right-2 sf:data-[side=right]:slide-in-from-left-2 sf:data-[side=top]:slide-in-from-bottom-2",e),...n})})});td.displayName=rY.displayName;function Sd({value:e,onChange:t,options:n,ariaLabel:r,className:o}){return y.jsx(L2,{delayDuration:300,children:y.jsx("div",{"aria-label":r,className:ie("sf:inline-flex sf:h-9 sf:items-stretch sf:overflow-hidden sf:rounded-md sf:border sf:border-input sf:bg-background sf:p-0.5",o),children:n.map((i,a)=>{const s=e===i.value,l=i.icon;return y.jsxs(m.Fragment,{children:[a>0?y.jsx("div",{"aria-hidden":!0,className:"sf:mx-0.5 sf:w-px sf:self-stretch sf:bg-border/70"}):null,y.jsxs(Bh,{children:[y.jsx($h,{asChild:!0,children:y.jsx("button",{type:"button","aria-pressed":s,"aria-label":i.label,"data-active":s,"data-testid":i.testId,onClick:()=>t(i.value),className:ie("sf:flex sf:flex-1 sf:items-center sf:justify-center sf:rounded sf:px-2 sf:transition-colors sf:focus-visible:outline-hidden sf:focus-visible:ring-1 sf:focus-visible:ring-ring",s?"sf:bg-secondary sf:text-secondary-foreground sf:shadow-sm":"sf:text-muted-foreground sf:hover:bg-accent sf:hover:text-accent-foreground"),children:y.jsx(l,{className:"sf:h-4 sf:w-4"})})}),y.jsx(td,{side:"top",className:"sf:px-2 sf:py-1 sf:text-xs",children:i.label})]})]},i.value)})})})}const Uh=e=>({width:16,height:16,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeWidth:1.75,...e}),gR=e=>y.jsx("svg",{...Uh(e),"aria-hidden":"true",children:y.jsx("line",{x1:"2",y1:"8",x2:"14",y2:"8"})}),oY=e=>y.jsx("svg",{...Uh(e),"aria-hidden":"true",children:y.jsx("line",{x1:"2",y1:"8",x2:"14",y2:"8",strokeDasharray:"3 2.5"})}),iY=e=>y.jsx("svg",{...Uh(e),"aria-hidden":"true",children:y.jsx("line",{x1:"2",y1:"8",x2:"14",y2:"8",strokeDasharray:"0.1 2.6"})}),aY=e=>y.jsx("svg",{...Uh(e),"aria-hidden":"true",children:y.jsx("path",{d:"M2 12 C 5 12, 5 4, 8 4 S 11 12, 14 12"})}),Pye=e=>y.jsx("svg",{...Uh(e),"aria-hidden":"true",children:y.jsx("path",{d:"M2 12 H 6 V 4 H 14"})}),Rye=hz,zye=({children:e,...t})=>{const n=Qu();return y.jsx(fz,{container:n,...t,children:e})},sY=m.forwardRef(({className:e,...t},n)=>y.jsx(jh,{className:ie("sf:fixed sf:inset-0 sf:z-50 sf:bg-black/80 sf:data-[state=open]:animate-in sf:data-[state=closed]:animate-out sf:data-[state=closed]:fade-out-0 sf:data-[state=open]:fade-in-0",e),...t,ref:n}));sY.displayName=jh.displayName;const jye=YZ("sf:fixed sf:z-50 sf:gap-4 sf:bg-card sf:border-border sf:p-6 sf:shadow-lg sf:transition sf:ease-in-out sf:data-[state=open]:animate-in sf:data-[state=closed]:animate-out sf:data-[state=closed]:duration-300 sf:data-[state=open]:duration-500",{variants:{side:{top:"sf:inset-x-0 sf:top-0 sf:border-b sf:data-[state=closed]:slide-out-to-top sf:data-[state=open]:slide-in-from-top",bottom:"sf:inset-x-0 sf:bottom-0 sf:border-t sf:data-[state=closed]:slide-out-to-bottom sf:data-[state=open]:slide-in-from-bottom",left:"sf:inset-y-0 sf:left-0 sf:h-full sf:w-3/4 sf:border-r sf:data-[state=closed]:slide-out-to-left sf:data-[state=open]:slide-in-from-left sf:sm:max-w-sm",right:"sf:inset-y-0 sf:right-0 sf:h-full sf:w-3/4 sf:border-l sf:data-[state=closed]:slide-out-to-right sf:data-[state=open]:slide-in-from-right sf:sm:max-w-sm"}},defaultVariants:{side:"right"}}),lY=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>y.jsxs(zye,{children:[y.jsx(sY,{}),y.jsxs(ed,{ref:o,className:ie(jye({side:e}),t),...r,children:[n,y.jsxs(kK,{className:"sf:absolute sf:right-4 sf:top-4 sf:rounded-sm sf:opacity-70 sf:ring-offset-background sf:transition-opacity sf:hover:opacity-100 sf:focus:outline-hidden sf:focus:ring-2 sf:focus:ring-ring sf:focus:ring-offset-2 sf:disabled:pointer-events-none",children:[y.jsx(uu,{className:"sf:h-4 sf:w-4"}),y.jsx("span",{className:"sf:sr-only",children:"Close"})]})]})]}));lY.displayName=ed.displayName;const bP=m.forwardRef(({className:e,...t},n)=>y.jsx(pz,{ref:n,className:ie("sf:text-lg sf:font-semibold sf:text-foreground",e),...t}));bP.displayName=pz.displayName;const _N=m.forwardRef(({className:e,...t},n)=>y.jsx(yz,{ref:n,className:ie("sf:text-sm sf:text-muted-foreground",e),...t}));_N.displayName=yz.displayName;function cY(e,[t,n]){return Math.min(n,Math.max(t,e))}function Tye(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var uY=["PageUp","PageDown"],dY=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],hY={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},nd="Slider",[HN,Nye,Dye]=B_(nd),[fY]=Nr(nd,[Dye]),[_ye,Lz]=fY(nd),pY=m.forwardRef((e,t)=>{const{name:n,min:r=0,max:o=100,step:i=1,orientation:a="horizontal",disabled:s=!1,minStepsBetweenThumbs:l=0,defaultValue:c=[r],value:h,onValueChange:d=()=>{},onValueCommit:f=()=>{},inverted:p=!1,form:k,...v}=e,w=m.useRef(new Set),g=m.useRef(0),x=a==="horizontal"?Hye:Fye,[b=[],S]=c1({prop:h,defaultProp:c,onChange:z=>{var U;(U=[...w.current][g.current])==null||U.focus(),d(z)}}),C=m.useRef(b);function L(z){const A=$ye(b,z);E(z,A)}function P(z){E(z,g.current)}function T(){const z=C.current[g.current];b[g.current]!==z&&f(b)}function E(z,A,{commit:U}={commit:!1}){const R=Zye(i),V=Kye(Math.round((z-r)/i)*i+r,R),O=cY(V,[r,o]);S((B=[])=>{const D=Vye(B,O,A);if(Gye(D,l*i)){g.current=D.indexOf(O);const N=String(D)!==String(B);return N&&U&&f(D),N?D:B}else return B})}return y.jsx(_ye,{scope:e.__scopeSlider,name:n,disabled:s,min:r,max:o,valueIndexToChangeRef:g,thumbs:w.current,values:b,orientation:a,form:k,children:y.jsx(HN.Provider,{scope:e.__scopeSlider,children:y.jsx(HN.Slot,{scope:e.__scopeSlider,children:y.jsx(x,{"aria-disabled":s,"data-disabled":s?"":void 0,...v,ref:t,onPointerDown:Ie(v.onPointerDown,()=>{s||(C.current=b)}),min:r,max:o,inverted:p,onSlideStart:s?void 0:L,onSlideMove:s?void 0:P,onSlideEnd:s?void 0:T,onHomeKeyDown:()=>!s&&E(r,0,{commit:!0}),onEndKeyDown:()=>!s&&E(o,b.length-1,{commit:!0}),onStepKeyDown:({event:z,direction:A})=>{if(!s){const V=uY.includes(z.key)||z.shiftKey&&dY.includes(z.key)?10:1,O=g.current,B=b[O],D=i*V*A;E(B+D,O,{commit:!0})}}})})})})});pY.displayName=nd;var[yY,mY]=fY(nd,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Hye=m.forwardRef((e,t)=>{const{min:n,max:r,dir:o,inverted:i,onSlideStart:a,onSlideMove:s,onSlideEnd:l,onStepKeyDown:c,...h}=e,[d,f]=m.useState(null),p=dt(t,x=>f(x)),k=m.useRef(void 0),v=gz(o),w=v==="ltr",g=w&&!i||!w&&i;function M(x){const b=k.current||d.getBoundingClientRect(),S=[0,b.width],L=eH(S,g?[n,r]:[r,n]);return k.current=b,L(x-b.left)}return y.jsx(yY,{scope:e.__scopeSlider,startEdge:g?"left":"right",endEdge:g?"right":"left",direction:g?1:-1,size:"width",children:y.jsx(kY,{dir:v,"data-orientation":"horizontal",...h,ref:p,style:{...h.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:x=>{const b=M(x.clientX);a==null||a(b)},onSlideMove:x=>{const b=M(x.clientX);s==null||s(b)},onSlideEnd:()=>{k.current=void 0,l==null||l()},onStepKeyDown:x=>{const S=hY[g?"from-left":"from-right"].includes(x.key);c==null||c({event:x,direction:S?-1:1})}})})}),Fye=m.forwardRef((e,t)=>{const{min:n,max:r,inverted:o,onSlideStart:i,onSlideMove:a,onSlideEnd:s,onStepKeyDown:l,...c}=e,h=m.useRef(null),d=dt(t,h),f=m.useRef(void 0),p=!o;function k(v){const w=f.current||h.current.getBoundingClientRect(),g=[0,w.height],x=eH(g,p?[r,n]:[n,r]);return f.current=w,x(v-w.top)}return y.jsx(yY,{scope:e.__scopeSlider,startEdge:p?"bottom":"top",endEdge:p?"top":"bottom",size:"height",direction:p?1:-1,children:y.jsx(kY,{"data-orientation":"vertical",...c,ref:d,style:{...c.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:v=>{const w=k(v.clientY);i==null||i(w)},onSlideMove:v=>{const w=k(v.clientY);a==null||a(w)},onSlideEnd:()=>{f.current=void 0,s==null||s()},onStepKeyDown:v=>{const g=hY[p?"from-bottom":"from-top"].includes(v.key);l==null||l({event:v,direction:g?-1:1})}})})}),kY=m.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:o,onSlideEnd:i,onHomeKeyDown:a,onEndKeyDown:s,onStepKeyDown:l,...c}=e,h=Lz(nd,n);return y.jsx(Ve.span,{...c,ref:t,onKeyDown:Ie(e.onKeyDown,d=>{d.key==="Home"?(a(d),d.preventDefault()):d.key==="End"?(s(d),d.preventDefault()):uY.concat(dY).includes(d.key)&&(l(d),d.preventDefault())}),onPointerDown:Ie(e.onPointerDown,d=>{const f=d.target;f.setPointerCapture(d.pointerId),d.preventDefault(),h.thumbs.has(f)?f.focus():r(d)}),onPointerMove:Ie(e.onPointerMove,d=>{d.target.hasPointerCapture(d.pointerId)&&o(d)}),onPointerUp:Ie(e.onPointerUp,d=>{const f=d.target;f.hasPointerCapture(d.pointerId)&&(f.releasePointerCapture(d.pointerId),i(d))})})}),gY="SliderTrack",xY=m.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=Lz(gY,n);return y.jsx(Ve.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...r,ref:t})});xY.displayName=gY;var FN="SliderRange",vY=m.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=Lz(FN,n),i=mY(FN,n),a=m.useRef(null),s=dt(t,a),l=o.values.length,c=o.values.map(f=>bY(f,o.min,o.max)),h=l>1?Math.min(...c):0,d=100-Math.max(...c);return y.jsx(Ve.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...r,ref:s,style:{...e.style,[i.startEdge]:h+"%",[i.endEdge]:d+"%"}})});vY.displayName=FN;var ON="SliderThumb",wY=m.forwardRef((e,t)=>{const n=Nye(e.__scopeSlider),[r,o]=m.useState(null),i=dt(t,s=>o(s)),a=m.useMemo(()=>r?n().findIndex(s=>s.ref.current===r):-1,[n,r]);return y.jsx(Oye,{...e,ref:i,index:a})}),Oye=m.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:o,...i}=e,a=Lz(ON,n),s=mY(ON,n),[l,c]=m.useState(null),h=dt(t,M=>c(M)),d=l?a.form||!!l.closest("form"):!0,f=xZ(l),p=a.values[r],k=p===void 0?0:bY(p,a.min,a.max),v=Bye(r,a.values.length),w=f==null?void 0:f[s.size],g=w?Uye(w,k,s.direction):0;return m.useEffect(()=>{if(l)return a.thumbs.add(l),()=>{a.thumbs.delete(l)}},[l,a.thumbs]),y.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[s.startEdge]:`calc(${k}% + ${g}px)`},children:[y.jsx(HN.ItemSlot,{scope:e.__scopeSlider,children:y.jsx(Ve.span,{role:"slider","aria-label":e["aria-label"]||v,"aria-valuemin":a.min,"aria-valuenow":p,"aria-valuemax":a.max,"aria-orientation":a.orientation,"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,tabIndex:a.disabled?void 0:0,...i,ref:h,style:p===void 0?{display:"none"}:e.style,onFocus:Ie(e.onFocus,()=>{a.valueIndexToChangeRef.current=r})})}),d&&y.jsx(MY,{name:o??(a.name?a.name+(a.values.length>1?"[]":""):void 0),form:a.form,value:p},r)]})});wY.displayName=ON;var qye="RadioBubbleInput",MY=m.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const o=m.useRef(null),i=dt(o,r),a=Tye(t);return m.useEffect(()=>{const s=o.current;if(!s)return;const l=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(l,"value").set;if(a!==t&&h){const d=new Event("input",{bubbles:!0});h.call(s,t),s.dispatchEvent(d)}},[a,t]),y.jsx(Ve.input,{style:{display:"none"},...n,ref:i,defaultValue:t})});MY.displayName=qye;function Vye(e=[],t,n){const r=[...e];return r[n]=t,r.sort((o,i)=>o-i)}function bY(e,t,n){const i=100/(n-t)*(e-t);return cY(i,[0,100])}function Bye(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function $ye(e,t){if(e.length===1)return 0;const n=e.map(o=>Math.abs(o-t)),r=Math.min(...n);return n.indexOf(r)}function Uye(e,t,n){const r=e/2,i=eH([0,50],[0,r]);return(r-i(t)*n)*n}function Wye(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function Gye(e,t){if(t>0){const n=Wye(e);return Math.min(...n)>=t}return!0}function eH(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Zye(e){return(String(e).split(".")[1]||"").length}function Kye(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var CY=pY,Xye=xY,Yye=vY,Qye=wY;const SY=m.forwardRef(({className:e,...t},n)=>y.jsxs(CY,{ref:n,className:ie("sf:relative sf:flex sf:w-full sf:touch-none sf:select-none sf:items-center",e),...t,children:[y.jsx(Xye,{className:"sf:relative sf:h-1.5 sf:w-full sf:grow sf:overflow-hidden sf:rounded-full sf:bg-secondary",children:y.jsx(Yye,{className:"sf:absolute sf:h-full sf:bg-primary"})}),y.jsx(Qye,{className:"sf:block sf:h-4 sf:w-4 sf:rounded-full sf:border sf:border-primary/60 sf:bg-background sf:shadow-sm sf:transition-colors sf:hover:border-primary sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:disabled:pointer-events-none sf:disabled:opacity-50"})]}));SY.displayName=CY.displayName;var Iz="Tabs",[Jye]=Nr(Iz,[xz]),LY=xz(),[eme,tH]=Jye(Iz),tme=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:a="horizontal",dir:s,activationMode:l="automatic",...c}=e,h=gz(s),[d,f]=c1({prop:r,onChange:o,defaultProp:i??"",caller:Iz});return y.jsx(eme,{scope:n,baseId:dn(),value:d,onValueChange:f,orientation:a,dir:h,activationMode:l,children:y.jsx(Ve.div,{dir:h,"data-orientation":a,...c,ref:t})})});tme.displayName=Iz;var IY="TabsList",EY=m.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=tH(IY,n),a=LY(n);return y.jsx(_K,{asChild:!0,...a,orientation:i.orientation,dir:i.dir,loop:r,children:y.jsx(Ve.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});EY.displayName=IY;var AY="TabsTrigger",PY=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,a=tH(AY,n),s=LY(n),l=jY(a.baseId,r),c=TY(a.baseId,r),h=r===a.value;return y.jsx(HK,{asChild:!0,...s,focusable:!o,active:h,children:y.jsx(Ve.button,{type:"button",role:"tab","aria-selected":h,"aria-controls":c,"data-state":h?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:l,...i,ref:t,onMouseDown:Ie(e.onMouseDown,d=>{!o&&d.button===0&&d.ctrlKey===!1?a.onValueChange(r):d.preventDefault()}),onKeyDown:Ie(e.onKeyDown,d=>{[" ","Enter"].includes(d.key)&&a.onValueChange(r)}),onFocus:Ie(e.onFocus,()=>{const d=a.activationMode!=="manual";!h&&!o&&d&&a.onValueChange(r)})})})});PY.displayName=AY;var RY="TabsContent",zY=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...a}=e,s=tH(RY,n),l=jY(s.baseId,r),c=TY(s.baseId,r),h=r===s.value,d=m.useRef(h);return m.useEffect(()=>{const f=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(f)},[]),y.jsx(Qn,{present:o||h,children:({present:f})=>y.jsx(Ve.div,{"data-state":h?"active":"inactive","data-orientation":s.orientation,role:"tabpanel","aria-labelledby":l,hidden:!f,id:c,tabIndex:0,...a,ref:t,style:{...e.style,animationDuration:d.current?"0s":void 0},children:f&&i})})});zY.displayName=RY;function jY(e,t){return`${e}-trigger-${t}`}function TY(e,t){return`${e}-content-${t}`}var NY=EY,DY=PY,_Y=zY;const nme=m.forwardRef(({className:e,...t},n)=>y.jsx(NY,{ref:n,className:ie("sf:inline-flex sf:h-9 sf:items-center sf:justify-center sf:rounded-md sf:bg-muted sf:p-1 sf:text-muted-foreground",e),...t}));nme.displayName=NY.displayName;const rme=m.forwardRef(({className:e,...t},n)=>y.jsx(DY,{ref:n,className:ie("sf:inline-flex sf:items-center sf:justify-center sf:whitespace-nowrap sf:rounded-sm sf:px-3 sf:py-1 sf:text-xs sf:font-medium sf:ring-offset-background sf:transition-all sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-2 sf:disabled:pointer-events-none sf:disabled:opacity-50 sf:data-[state=active]:bg-background sf:data-[state=active]:text-foreground sf:data-[state=active]:shadow-sm",e),...t}));rme.displayName=DY.displayName;const ome=m.forwardRef(({className:e,...t},n)=>y.jsx(_Y,{ref:n,className:ie("sf:mt-2 sf:ring-offset-background sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-2",e),...t}));ome.displayName=_Y.displayName;const Kq="application/x-seeflow-create-html-block",HY=[{shape:"rectangle",label:"Rectangle",commandId:"tool.rectangle",Icon:au},{shape:"ellipse",label:"Ellipse",commandId:"tool.ellipse",Icon:Jd}],FY=[{shape:"sticky",label:"Sticky note",commandId:"tool.sticky",Icon:g2},{shape:"text",label:"Text",commandId:"tool.text",Icon:cu}],qN=[{shape:"database",label:"Database",commandId:"tool.database",Icon:t2},{shape:"server",label:"Server",commandId:"tool.server",Icon:y2},{shape:"user",label:"User",commandId:"tool.user",Icon:M2},{shape:"queue",label:"Queue",commandId:"tool.queue",Icon:vi},{shape:"cloud",label:"Cloud",commandId:"tool.cloud",Icon:e2}],ime=[...HY,...FY,...qN],Xq="Insert icon",Yq="Shape";function ame({activeShape:e,onSelectShape:t,iconPickerOpen:n,onOpenIconPicker:r,onCloseIconPicker:o,onPickIcon:i}){const[a,s]=m.useState(!1),l=e!==null&&qN.some(h=>h.shape===e),c=({shape:h,commandId:d,Icon:f})=>{const p=e===h,k=iq(d);return y.jsx("button",{type:"button","data-testid":`toolbar-shape-${h}`,"data-active":p?"true":"false","aria-pressed":p,"aria-label":k,title:k,onClick:()=>t(p?null:h),className:ie("sf:inline-flex sf:h-8 sf:w-8 sf:items-center sf:justify-center sf:rounded-md sf:text-muted-foreground sf:transition-colors",p?"sf:bg-primary/20 sf:text-primary sf:ring-1 sf:ring-primary/50 sf:shadow-[0_0_0_1px_hsl(var(--primary)/0.5)_inset]":"sf:hover:bg-muted sf:hover:text-foreground"),children:y.jsx(f,{className:"sf:h-4 sf:w-4"})},h)};return y.jsxs("div",{"data-testid":"canvas-toolbar",className:"sf:pointer-events-auto sf:flex sf:flex-col sf:items-center sf:gap-1 sf:rounded-lg sf:border sf:border-border sf:bg-card sf:p-1 sf:shadow-md sf:backdrop-blur",children:[HY.map(c),y.jsxs(Ju,{open:a,onOpenChange:s,children:[y.jsx(Eh,{asChild:!0,children:y.jsx("button",{type:"button","data-testid":"toolbar-shape-picker","aria-label":Yq,"aria-pressed":a||l,title:Yq,className:ie("sf:inline-flex sf:h-8 sf:w-8 sf:items-center sf:justify-center sf:rounded-md sf:text-muted-foreground sf:transition-colors",a||l?"sf:bg-primary/20 sf:text-primary sf:ring-1 sf:ring-primary/50":"sf:hover:bg-muted sf:hover:text-foreground"),children:y.jsx(m2,{className:"sf:h-4 sf:w-4","aria-hidden":"true"})})}),y.jsx(u1,{align:"start",side:"right",sideOffset:6,className:"sf:w-auto sf:p-1","data-testid":"shape-picker-popover",onOpenAutoFocus:h=>{h.preventDefault()},children:y.jsx("div",{role:"menu","aria-label":"More shapes",className:"sf:flex sf:flex-col sf:gap-0.5",children:qN.map(({shape:h,label:d,commandId:f,Icon:p})=>{const k=e===h,v=iq(f);return y.jsxs("button",{type:"button",role:"menuitem","data-testid":`shape-picker-${h}`,"data-active":k?"true":"false","aria-pressed":k,"aria-label":v,title:v,onClick:()=>{t(k?null:h),s(!1)},className:ie("sf:flex sf:items-center sf:gap-2 sf:rounded-sm sf:px-2 sf:py-1.5 sf:text-left sf:text-sm",k?"sf:bg-primary/20 sf:text-primary sf:ring-1 sf:ring-primary/50":"sf:hover:bg-muted sf:focus:bg-muted sf:focus:outline-hidden"),children:[y.jsx(p,{className:"sf:h-4 sf:w-4 sf:text-muted-foreground","aria-hidden":"true"}),y.jsx("span",{children:d})]},h)})})})]}),i?y.jsx(uz,{open:n??!1,onOpenChange:h=>{h?r==null||r():o==null||o()},anchor:y.jsx("button",{type:"button","data-testid":"toolbar-insert-icon","aria-label":Xq,"aria-pressed":n??!1,title:Xq,className:ie("sf:inline-flex sf:h-8 sf:w-8 sf:items-center sf:justify-center sf:rounded-md sf:text-muted-foreground sf:transition-colors",n?"sf:bg-primary/20 sf:text-primary sf:ring-1 sf:ring-primary/50":"sf:hover:bg-muted sf:hover:text-foreground"),children:y.jsx(lu,{className:"sf:h-4 sf:w-4","aria-hidden":"true"})}),clearable:!1,onPick:h=>{h!==null&&i(h)}}):null,y.jsx("div",{className:"sf:my-1 sf:h-px sf:w-6 sf:bg-border","aria-hidden":"true"}),FY.map(c)]})}function sme(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const lme=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,cme=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ume={};function Qq(e,t){return(ume.jsx?cme:lme).test(e)}const dme=/[ \t\n\f\r]/g;function hme(e){return typeof e=="object"?e.type==="text"?Jq(e.value):!1:Jq(e)}function Jq(e){return e.replace(dme,"")===""}class Wh{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Wh.prototype.normal={};Wh.prototype.property={};Wh.prototype.space=void 0;function OY(e,t){const n={},r={};for(const o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new Wh(n,r,t)}function VN(e){return e.toLowerCase()}class Rn{constructor(t,n){this.attribute=n,this.property=t}}Rn.prototype.attribute="";Rn.prototype.booleanish=!1;Rn.prototype.boolean=!1;Rn.prototype.commaOrSpaceSeparated=!1;Rn.prototype.commaSeparated=!1;Rn.prototype.defined=!1;Rn.prototype.mustUseProperty=!1;Rn.prototype.number=!1;Rn.prototype.overloadedBoolean=!1;Rn.prototype.property="";Rn.prototype.spaceSeparated=!1;Rn.prototype.space=void 0;let fme=0;const $e=f1(),Tt=f1(),BN=f1(),pe=f1(),ft=f1(),mu=f1(),Fn=f1();function f1(){return 2**++fme}const $N=Object.freeze(Object.defineProperty({__proto__:null,boolean:$e,booleanish:Tt,commaOrSpaceSeparated:Fn,commaSeparated:mu,number:pe,overloadedBoolean:BN,spaceSeparated:ft},Symbol.toStringTag,{value:"Module"})),Vj=Object.keys($N);class nH extends Rn{constructor(t,n,r,o){let i=-1;if(super(t,n),eV(this,"space",o),typeof r=="number")for(;++i<Vj.length;){const a=Vj[i];eV(this,Vj[i],(r&$N[a])===$N[a])}}}nH.prototype.defined=!0;function eV(e,t,n){n&&(e[t]=n)}function rd(e){const t={},n={};for(const[r,o]of Object.entries(e.properties)){const i=new nH(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[VN(r)]=r,n[VN(i.attribute)]=r}return new Wh(t,n,e.space)}const qY=rd({properties:{ariaActiveDescendant:null,ariaAtomic:Tt,ariaAutoComplete:null,ariaBusy:Tt,ariaChecked:Tt,ariaColCount:pe,ariaColIndex:pe,ariaColSpan:pe,ariaControls:ft,ariaCurrent:null,ariaDescribedBy:ft,ariaDetails:null,ariaDisabled:Tt,ariaDropEffect:ft,ariaErrorMessage:null,ariaExpanded:Tt,ariaFlowTo:ft,ariaGrabbed:Tt,ariaHasPopup:null,ariaHidden:Tt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ft,ariaLevel:pe,ariaLive:null,ariaModal:Tt,ariaMultiLine:Tt,ariaMultiSelectable:Tt,ariaOrientation:null,ariaOwns:ft,ariaPlaceholder:null,ariaPosInSet:pe,ariaPressed:Tt,ariaReadOnly:Tt,ariaRelevant:null,ariaRequired:Tt,ariaRoleDescription:ft,ariaRowCount:pe,ariaRowIndex:pe,ariaRowSpan:pe,ariaSelected:Tt,ariaSetSize:pe,ariaSort:null,ariaValueMax:pe,ariaValueMin:pe,ariaValueNow:pe,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function VY(e,t){return t in e?e[t]:t}function BY(e,t){return VY(e,t.toLowerCase())}const pme=rd({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:mu,acceptCharset:ft,accessKey:ft,action:null,allow:null,allowFullScreen:$e,allowPaymentRequest:$e,allowUserMedia:$e,alt:null,as:null,async:$e,autoCapitalize:null,autoComplete:ft,autoFocus:$e,autoPlay:$e,blocking:ft,capture:null,charSet:null,checked:$e,cite:null,className:ft,cols:pe,colSpan:null,content:null,contentEditable:Tt,controls:$e,controlsList:ft,coords:pe|mu,crossOrigin:null,data:null,dateTime:null,decoding:null,default:$e,defer:$e,dir:null,dirName:null,disabled:$e,download:BN,draggable:Tt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:$e,formTarget:null,headers:ft,height:pe,hidden:BN,high:pe,href:null,hrefLang:null,htmlFor:ft,httpEquiv:ft,id:null,imageSizes:null,imageSrcSet:null,inert:$e,inputMode:null,integrity:null,is:null,isMap:$e,itemId:null,itemProp:ft,itemRef:ft,itemScope:$e,itemType:ft,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:$e,low:pe,manifest:null,max:null,maxLength:pe,media:null,method:null,min:null,minLength:pe,multiple:$e,muted:$e,name:null,nonce:null,noModule:$e,noValidate:$e,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:$e,optimum:pe,pattern:null,ping:ft,placeholder:null,playsInline:$e,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:$e,referrerPolicy:null,rel:ft,required:$e,reversed:$e,rows:pe,rowSpan:pe,sandbox:ft,scope:null,scoped:$e,seamless:$e,selected:$e,shadowRootClonable:$e,shadowRootDelegatesFocus:$e,shadowRootMode:null,shape:null,size:pe,sizes:null,slot:null,span:pe,spellCheck:Tt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:pe,step:null,style:null,tabIndex:pe,target:null,title:null,translate:null,type:null,typeMustMatch:$e,useMap:null,value:Tt,width:pe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ft,axis:null,background:null,bgColor:null,border:pe,borderColor:null,bottomMargin:pe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:$e,declare:$e,event:null,face:null,frame:null,frameBorder:null,hSpace:pe,leftMargin:pe,link:null,longDesc:null,lowSrc:null,marginHeight:pe,marginWidth:pe,noResize:$e,noHref:$e,noShade:$e,noWrap:$e,object:null,profile:null,prompt:null,rev:null,rightMargin:pe,rules:null,scheme:null,scrolling:Tt,standby:null,summary:null,text:null,topMargin:pe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:pe,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:$e,disableRemotePlayback:$e,prefix:null,property:null,results:pe,security:null,unselectable:null},space:"html",transform:BY}),yme=rd({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Fn,accentHeight:pe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:pe,amplitude:pe,arabicForm:null,ascent:pe,attributeName:null,attributeType:null,azimuth:pe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:pe,by:null,calcMode:null,capHeight:pe,className:ft,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:pe,diffuseConstant:pe,direction:null,display:null,dur:null,divisor:pe,dominantBaseline:null,download:$e,dx:null,dy:null,edgeMode:null,editable:null,elevation:pe,enableBackground:null,end:null,event:null,exponent:pe,externalResourcesRequired:null,fill:null,fillOpacity:pe,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:mu,g2:mu,glyphName:mu,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:pe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:pe,horizOriginX:pe,horizOriginY:pe,id:null,ideographic:pe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:pe,k:pe,k1:pe,k2:pe,k3:pe,k4:pe,kernelMatrix:Fn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:pe,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:pe,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:pe,overlineThickness:pe,paintOrder:null,panose1:null,path:null,pathLength:pe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ft,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:pe,pointsAtY:pe,pointsAtZ:pe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Fn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Fn,rev:Fn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Fn,requiredFeatures:Fn,requiredFonts:Fn,requiredFormats:Fn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:pe,specularExponent:pe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:pe,strikethroughThickness:pe,string:null,stroke:null,strokeDashArray:Fn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:pe,strokeOpacity:pe,strokeWidth:null,style:null,surfaceScale:pe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Fn,tabIndex:pe,tableValues:null,target:null,targetX:pe,targetY:pe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Fn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:pe,underlineThickness:pe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:pe,values:null,vAlphabetic:pe,vMathematical:pe,vectorEffect:null,vHanging:pe,vIdeographic:pe,version:null,vertAdvY:pe,vertOriginX:pe,vertOriginY:pe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:pe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:VY}),$Y=rd({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),UY=rd({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:BY}),WY=rd({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),mme={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},kme=/[A-Z]/g,tV=/-[a-z]/g,gme=/^data[-\w.:]+$/i;function xme(e,t){const n=VN(t);let r=t,o=Rn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&gme.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(tV,wme);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!tV.test(i)){let a=i.replace(kme,vme);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}o=nH}return new o(r,t)}function vme(e){return"-"+e.toLowerCase()}function wme(e){return e.charAt(1).toUpperCase()}const Mme=OY([qY,pme,$Y,UY,WY],"html"),rH=OY([qY,yme,$Y,UY,WY],"svg");function bme(e){return e.join(" ").trim()}var oH={},nV=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Cme=/\n/g,Sme=/^\s*/,Lme=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Ime=/^:\s*/,Eme=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,Ame=/^[;\s]*/,Pme=/^\s+|\s+$/g,Rme=`
|
|
7807
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},tfe="DialogDescriptionWarning",nfe=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${mK(tfe).contentName}}.`;return m.useEffect(()=>{var i;const o=(i=e.current)==null?void 0:i.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},hz=rK,fz=aK,jh=sK,ed=lK,pz=uK,yz=hK,kK=pK,Cd='[cmdk-group=""]',Oj='[cmdk-group-items=""]',rfe='[cmdk-group-heading=""]',gK='[cmdk-item=""]',Gq=`${gK}:not([aria-disabled="true"])`,AN="cmdk-item-select",j1="data-value",ofe=(e,t,n)=>W0e(e,t,n),xK=m.createContext(void 0),Th=()=>m.useContext(xK),vK=m.createContext(void 0),V_=()=>m.useContext(vK),wK=m.createContext(void 0),MK=m.forwardRef((e,t)=>{let n=T1(()=>{var H,j;return{search:"",value:(j=(H=e.value)!=null?H:e.defaultValue)!=null?j:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=T1(()=>new Set),o=T1(()=>new Map),i=T1(()=>new Map),a=T1(()=>new Set),s=bK(e),{label:l,children:c,value:h,onValueChange:d,filter:f,shouldFilter:p,loop:k,disablePointerSelection:v=!1,vimBindings:w=!0,...g}=e,M=dn(),x=dn(),b=dn(),S=m.useRef(null),C=yfe();o1(()=>{if(h!==void 0){let H=h.trim();n.current.value=H,L.emit()}},[h]),o1(()=>{C(6,U)},[]);let L=m.useMemo(()=>({subscribe:H=>(a.current.add(H),()=>a.current.delete(H)),snapshot:()=>n.current,setState:(H,j,G)=>{var X,Y,re,ne;if(!Object.is(n.current[H],j)){if(n.current[H]=j,H==="search")A(),E(),C(1,z);else if(H==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ae=document.getElementById(b);ae?ae.focus():(X=document.getElementById(M))==null||X.focus()}if(C(7,()=>{var ae;n.current.selectedItemId=(ae=R())==null?void 0:ae.id,L.emit()}),G||C(5,U),((Y=s.current)==null?void 0:Y.value)!==void 0){let ae=j??"";(ne=(re=s.current).onValueChange)==null||ne.call(re,ae);return}}L.emit()}},emit:()=>{a.current.forEach(H=>H())}}),[]),P=m.useMemo(()=>({value:(H,j,G)=>{var X;j!==((X=i.current.get(H))==null?void 0:X.value)&&(i.current.set(H,{value:j,keywords:G}),n.current.filtered.items.set(H,T(j,G)),C(2,()=>{E(),L.emit()}))},item:(H,j)=>(r.current.add(H),j&&(o.current.has(j)?o.current.get(j).add(H):o.current.set(j,new Set([H]))),C(3,()=>{A(),E(),n.current.value||z(),L.emit()}),()=>{i.current.delete(H),r.current.delete(H),n.current.filtered.items.delete(H);let G=R();C(4,()=>{A(),(G==null?void 0:G.getAttribute("id"))===H&&z(),L.emit()})}),group:H=>(o.current.has(H)||o.current.set(H,new Set),()=>{i.current.delete(H),o.current.delete(H)}),filter:()=>s.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:M,inputId:b,labelId:x,listInnerRef:S}),[]);function T(H,j){var G,X;let Y=(X=(G=s.current)==null?void 0:G.filter)!=null?X:ofe;return H?Y(H,n.current.search,j):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let H=n.current.filtered.items,j=[];n.current.filtered.groups.forEach(X=>{let Y=o.current.get(X),re=0;Y.forEach(ne=>{let ae=H.get(ne);re=Math.max(ae,re)}),j.push([X,re])});let G=S.current;V().sort((X,Y)=>{var re,ne;let ae=X.getAttribute("id"),ve=Y.getAttribute("id");return((re=H.get(ve))!=null?re:0)-((ne=H.get(ae))!=null?ne:0)}).forEach(X=>{let Y=X.closest(Oj);Y?Y.appendChild(X.parentElement===Y?X:X.closest(`${Oj} > *`)):G.appendChild(X.parentElement===G?X:X.closest(`${Oj} > *`))}),j.sort((X,Y)=>Y[1]-X[1]).forEach(X=>{var Y;let re=(Y=S.current)==null?void 0:Y.querySelector(`${Cd}[${j1}="${encodeURIComponent(X[0])}"]`);re==null||re.parentElement.appendChild(re)})}function z(){let H=V().find(G=>G.getAttribute("aria-disabled")!=="true"),j=H==null?void 0:H.getAttribute(j1);L.setState("value",j||void 0)}function A(){var H,j,G,X;if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let Y=0;for(let re of r.current){let ne=(j=(H=i.current.get(re))==null?void 0:H.value)!=null?j:"",ae=(X=(G=i.current.get(re))==null?void 0:G.keywords)!=null?X:[],ve=T(ne,ae);n.current.filtered.items.set(re,ve),ve>0&&Y++}for(let[re,ne]of o.current)for(let ae of ne)if(n.current.filtered.items.get(ae)>0){n.current.filtered.groups.add(re);break}n.current.filtered.count=Y}function U(){var H,j,G;let X=R();X&&(((H=X.parentElement)==null?void 0:H.firstChild)===X&&((G=(j=X.closest(Cd))==null?void 0:j.querySelector(rfe))==null||G.scrollIntoView({block:"nearest"})),X.scrollIntoView({block:"nearest"}))}function R(){var H;return(H=S.current)==null?void 0:H.querySelector(`${gK}[aria-selected="true"]`)}function V(){var H;return Array.from(((H=S.current)==null?void 0:H.querySelectorAll(Gq))||[])}function O(H){let j=V()[H];j&&L.setState("value",j.getAttribute(j1))}function B(H){var j;let G=R(),X=V(),Y=X.findIndex(ne=>ne===G),re=X[Y+H];(j=s.current)!=null&&j.loop&&(re=Y+H<0?X[X.length-1]:Y+H===X.length?X[0]:X[Y+H]),re&&L.setState("value",re.getAttribute(j1))}function D(H){let j=R(),G=j==null?void 0:j.closest(Cd),X;for(;G&&!X;)G=H>0?ffe(G,Cd):pfe(G,Cd),X=G==null?void 0:G.querySelector(Gq);X?L.setState("value",X.getAttribute(j1)):B(H)}let N=()=>O(V().length-1),I=H=>{H.preventDefault(),H.metaKey?N():H.altKey?D(1):B(1)},W=H=>{H.preventDefault(),H.metaKey?O(0):H.altKey?D(-1):B(-1)};return m.createElement(Ve.div,{ref:t,tabIndex:-1,...g,"cmdk-root":"",onKeyDown:H=>{var j;(j=g.onKeyDown)==null||j.call(g,H);let G=H.nativeEvent.isComposing||H.keyCode===229;if(!(H.defaultPrevented||G))switch(H.key){case"n":case"j":{w&&H.ctrlKey&&I(H);break}case"ArrowDown":{I(H);break}case"p":case"k":{w&&H.ctrlKey&&W(H);break}case"ArrowUp":{W(H);break}case"Home":{H.preventDefault(),O(0);break}case"End":{H.preventDefault(),N();break}case"Enter":{H.preventDefault();let X=R();if(X){let Y=new Event(AN);X.dispatchEvent(Y)}}}}},m.createElement("label",{"cmdk-label":"",htmlFor:P.inputId,id:P.labelId,style:kfe},l),mz(e,H=>m.createElement(vK.Provider,{value:L},m.createElement(xK.Provider,{value:P},H))))}),ife=m.forwardRef((e,t)=>{var n,r;let o=dn(),i=m.useRef(null),a=m.useContext(wK),s=Th(),l=bK(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:a==null?void 0:a.forceMount;o1(()=>{if(!c)return s.item(o,a==null?void 0:a.id)},[c]);let h=CK(o,i,[e.value,e.children,i],e.keywords),d=V_(),f=Bi(C=>C.value&&C.value===h.current),p=Bi(C=>c||s.filter()===!1?!0:C.search?C.filtered.items.get(o)>0:!0);m.useEffect(()=>{let C=i.current;if(!(!C||e.disabled))return C.addEventListener(AN,k),()=>C.removeEventListener(AN,k)},[p,e.onSelect,e.disabled]);function k(){var C,L;v(),(L=(C=l.current).onSelect)==null||L.call(C,h.current)}function v(){d.setState("value",h.current,!0)}if(!p)return null;let{disabled:w,value:g,onSelect:M,forceMount:x,keywords:b,...S}=e;return m.createElement(Ve.div,{ref:ko(i,t),...S,id:o,"cmdk-item":"",role:"option","aria-disabled":!!w,"aria-selected":!!f,"data-disabled":!!w,"data-selected":!!f,onPointerMove:w||s.getDisablePointerSelection()?void 0:v,onClick:w?void 0:k},e.children)}),afe=m.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...i}=e,a=dn(),s=m.useRef(null),l=m.useRef(null),c=dn(),h=Th(),d=Bi(p=>o||h.filter()===!1?!0:p.search?p.filtered.groups.has(a):!0);o1(()=>h.group(a),[]),CK(a,s,[e.value,e.heading,l]);let f=m.useMemo(()=>({id:a,forceMount:o}),[o]);return m.createElement(Ve.div,{ref:ko(s,t),...i,"cmdk-group":"",role:"presentation",hidden:d?void 0:!0},n&&m.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),mz(e,p=>m.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},m.createElement(wK.Provider,{value:f},p))))}),sfe=m.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=m.useRef(null),i=Bi(a=>!a.search);return!n&&!i?null:m.createElement(Ve.div,{ref:ko(o,t),...r,"cmdk-separator":"",role:"separator"})}),lfe=m.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,i=V_(),a=Bi(c=>c.search),s=Bi(c=>c.selectedItemId),l=Th();return m.useEffect(()=>{e.value!=null&&i.setState("search",e.value)},[e.value]),m.createElement(Ve.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":s,id:l.inputId,type:"text",value:o?e.value:a,onChange:c=>{o||i.setState("search",c.target.value),n==null||n(c.target.value)}})}),cfe=m.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,i=m.useRef(null),a=m.useRef(null),s=Bi(c=>c.selectedItemId),l=Th();return m.useEffect(()=>{if(a.current&&i.current){let c=a.current,h=i.current,d,f=new ResizeObserver(()=>{d=requestAnimationFrame(()=>{let p=c.offsetHeight;h.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return f.observe(c),()=>{cancelAnimationFrame(d),f.unobserve(c)}}},[]),m.createElement(Ve.div,{ref:ko(i,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:l.listId},mz(e,c=>m.createElement("div",{ref:ko(a,l.listInnerRef),"cmdk-list-sizer":""},c)))}),ufe=m.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:i,container:a,...s}=e;return m.createElement(hz,{open:n,onOpenChange:r},m.createElement(fz,{container:a},m.createElement(jh,{"cmdk-overlay":"",className:o}),m.createElement(ed,{"aria-label":e.label,"cmdk-dialog":"",className:i},m.createElement(MK,{ref:t,...s}))))}),dfe=m.forwardRef((e,t)=>Bi(n=>n.filtered.count===0)?m.createElement(Ve.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),hfe=m.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...i}=e;return m.createElement(Ve.div,{ref:t,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},mz(e,a=>m.createElement("div",{"aria-hidden":!0},a)))}),Pn=Object.assign(MK,{List:cfe,Item:ife,Input:lfe,Group:afe,Separator:sfe,Dialog:ufe,Empty:dfe,Loading:hfe});function ffe(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function pfe(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function bK(e){let t=m.useRef(e);return o1(()=>{t.current=e}),t}var o1=typeof window>"u"?m.useEffect:m.useLayoutEffect;function T1(e){let t=m.useRef();return t.current===void 0&&(t.current=e()),t}function Bi(e){let t=V_(),n=()=>e(t.snapshot());return m.useSyncExternalStore(t.subscribe,n,n)}function CK(e,t,n,r=[]){let o=m.useRef(),i=Th();return o1(()=>{var a;let s=(()=>{var c;for(let h of n){if(typeof h=="string")return h.trim();if(typeof h=="object"&&"current"in h)return h.current?(c=h.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());i.value(e,s,l),(a=t.current)==null||a.setAttribute(j1,s),o.current=s}),o}var yfe=()=>{let[e,t]=m.useState(),n=T1(()=>new Map);return o1(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function mfe(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function mz({asChild:e,children:t},n){return e&&m.isValidElement(t)?m.cloneElement(mfe(t),{ref:t.ref},n(t.props.children)):n(t)}var kfe={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const kz=hz,gfe=({children:e,...t})=>{const n=Qu();return y.jsx(fz,{container:n,...t,children:e})},SK=m.forwardRef(({className:e,...t},n)=>y.jsx(jh,{ref:n,className:ie("sf:fixed sf:inset-0 sf:z-50 sf:bg-black/80 sf:data-[state=open]:animate-in sf:data-[state=closed]:animate-out sf:data-[state=closed]:fade-out-0 sf:data-[state=open]:fade-in-0",e),...t}));SK.displayName=jh.displayName;const Nh=m.forwardRef(({className:e,children:t,...n},r)=>y.jsxs(gfe,{children:[y.jsx(SK,{}),y.jsxs(ed,{ref:r,className:ie("sf:fixed sf:left-[50%] sf:top-[50%] sf:z-50 sf:grid sf:w-full sf:max-w-lg sf:translate-x-[-50%] sf:translate-y-[-50%] sf:gap-4 sf:border sf:border-border sf:bg-card sf:p-6 sf:shadow-lg sf:duration-200 sf:data-[state=open]:animate-in sf:data-[state=closed]:animate-out sf:data-[state=closed]:fade-out-0 sf:data-[state=open]:fade-in-0 sf:data-[state=closed]:zoom-out-95 sf:data-[state=open]:zoom-in-95 sf:data-[state=closed]:slide-out-to-left-1/2 sf:data-[state=closed]:slide-out-to-top-[48%] sf:data-[state=open]:slide-in-from-left-1/2 sf:data-[state=open]:slide-in-from-top-[48%] sf:sm:rounded-lg",e),...n,children:[t,y.jsxs(kK,{className:"sf:absolute sf:right-4 sf:top-4 sf:rounded-sm sf:opacity-70 sf:ring-offset-background sf:transition-opacity sf:hover:opacity-100 sf:focus:outline-hidden sf:focus:ring-2 sf:focus:ring-ring sf:focus:ring-offset-2 sf:disabled:pointer-events-none",children:[y.jsx(uu,{className:"sf:h-4 sf:w-4"}),y.jsx("span",{className:"sf:sr-only",children:"Close"})]})]})]}));Nh.displayName=ed.displayName;const Dh=({className:e,...t})=>y.jsx("div",{className:ie("sf:flex sf:flex-col sf:space-y-1.5 sf:text-center sf:sm:text-left",e),...t});Dh.displayName="DialogHeader";const Hu=({className:e,...t})=>y.jsx("div",{className:ie("sf:flex sf:flex-col-reverse sf:sm:flex-row sf:sm:justify-end sf:sm:space-x-2",e),...t});Hu.displayName="DialogFooter";const _h=m.forwardRef(({className:e,...t},n)=>y.jsx(pz,{ref:n,className:ie("sf:text-lg sf:font-semibold sf:leading-none sf:tracking-tight",e),...t}));_h.displayName=pz.displayName;const Hh=m.forwardRef(({className:e,...t},n)=>y.jsx(yz,{ref:n,className:ie("sf:text-sm sf:text-muted-foreground",e),...t}));Hh.displayName=yz.displayName;const LK=m.forwardRef(({className:e,...t},n)=>y.jsx(Pn,{ref:n,className:ie("sf:flex sf:h-full sf:w-full sf:flex-col sf:overflow-hidden sf:rounded-md sf:bg-card sf:text-foreground",e),...t}));LK.displayName=Pn.displayName;const IK=m.forwardRef(({className:e,...t},n)=>y.jsxs("div",{className:"sf:flex sf:items-center sf:border-b sf:px-3","cmdk-input-wrapper":"",children:[y.jsx(p2,{className:"sf:mr-2 sf:h-4 sf:w-4 sf:shrink-0 sf:opacity-50"}),y.jsx(Pn.Input,{ref:n,className:ie("sf:flex sf:h-11 sf:w-full sf:rounded-md sf:bg-transparent sf:py-3 sf:text-sm sf:outline-hidden sf:placeholder:text-muted-foreground sf:disabled:cursor-not-allowed sf:disabled:opacity-50",e),...t})]}));IK.displayName=Pn.Input.displayName;const EK=m.forwardRef(({className:e,...t},n)=>y.jsx(Pn.List,{ref:n,className:ie("sf:max-h-[300px] sf:overflow-y-auto sf:overflow-x-hidden",e),...t}));EK.displayName=Pn.List.displayName;const AK=m.forwardRef((e,t)=>y.jsx(Pn.Empty,{ref:t,className:"sf:py-6 sf:text-center sf:text-sm",...e}));AK.displayName=Pn.Empty.displayName;const PN=m.forwardRef(({className:e,...t},n)=>y.jsx(Pn.Group,{ref:n,className:ie("sf:overflow-hidden sf:p-1 sf:text-foreground sf:**:[[cmdk-group-heading]]:px-2 sf:**:[[cmdk-group-heading]]:py-1.5 sf:**:[[cmdk-group-heading]]:text-xs sf:**:[[cmdk-group-heading]]:font-medium sf:**:[[cmdk-group-heading]]:text-muted-foreground",e),...t}));PN.displayName=Pn.Group.displayName;const PK=m.forwardRef(({className:e,...t},n)=>y.jsx(Pn.Separator,{ref:n,className:ie("sf:-mx-1 sf:h-px sf:bg-border",e),...t}));PK.displayName=Pn.Separator.displayName;const RN=m.forwardRef(({className:e,...t},n)=>y.jsx(Pn.Item,{ref:n,className:ie("sf:relative sf:flex sf:cursor-default sf:select-none sf:items-center sf:rounded-sm sf:px-2 sf:py-1.5 sf:text-sm sf:outline-hidden sf:aria-selected:bg-muted sf:aria-selected:text-foreground sf:data-[disabled='true']:pointer-events-none sf:data-[disabled='true']:opacity-50",e),...t}));RN.displayName=Pn.Item.displayName;const RK=({className:e,...t})=>y.jsx("span",{className:ie("sf:ml-auto sf:text-xs sf:tracking-widest sf:text-muted-foreground",e),...t});RK.displayName="CommandShortcut";function B_(e){const t=e+"CollectionProvider",[n,r]=Nr(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=v=>{const{scope:w,children:g}=v,M=oo.useRef(null),x=oo.useRef(new Map).current;return y.jsx(o,{scope:w,itemMap:x,collectionRef:M,children:g})};a.displayName=t;const s=e+"CollectionSlot",l=Nu(s),c=oo.forwardRef((v,w)=>{const{scope:g,children:M}=v,x=i(s,g),b=dt(w,x.collectionRef);return y.jsx(l,{ref:b,children:M})});c.displayName=s;const h=e+"CollectionItemSlot",d="data-radix-collection-item",f=Nu(h),p=oo.forwardRef((v,w)=>{const{scope:g,children:M,...x}=v,b=oo.useRef(null),S=dt(w,b),C=i(h,g);return oo.useEffect(()=>(C.itemMap.set(b,{ref:b,...x}),()=>void C.itemMap.delete(b))),y.jsx(f,{[d]:"",ref:S,children:M})});p.displayName=h;function k(v){const w=i(e+"CollectionConsumer",v);return oo.useCallback(()=>{const M=w.collectionRef.current;if(!M)return[];const x=Array.from(M.querySelectorAll(`[${d}]`));return Array.from(w.itemMap.values()).sort((C,L)=>x.indexOf(C.ref.current)-x.indexOf(L.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:a,Slot:c,ItemSlot:p},k,r]}var xfe=m.createContext(void 0);function gz(e){const t=m.useContext(xfe);return e||t||"ltr"}var qj="rovingFocusGroup.onEntryFocus",vfe={bubbles:!1,cancelable:!0},Fh="RovingFocusGroup",[zN,zK,wfe]=B_(Fh),[Mfe,xz]=Nr(Fh,[wfe]),[bfe,Cfe]=Mfe(Fh),jK=m.forwardRef((e,t)=>y.jsx(zN.Provider,{scope:e.__scopeRovingFocusGroup,children:y.jsx(zN.Slot,{scope:e.__scopeRovingFocusGroup,children:y.jsx(Sfe,{...e,ref:t})})}));jK.displayName=Fh;var Sfe=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:a,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:h=!1,...d}=e,f=m.useRef(null),p=dt(t,f),k=gz(i),[v,w]=c1({prop:a,defaultProp:s??null,onChange:l,caller:Fh}),[g,M]=m.useState(!1),x=go(c),b=zK(n),S=m.useRef(!1),[C,L]=m.useState(0);return m.useEffect(()=>{const P=f.current;if(P)return P.addEventListener(qj,x),()=>P.removeEventListener(qj,x)},[x]),y.jsx(bfe,{scope:n,orientation:r,dir:k,loop:o,currentTabStopId:v,onItemFocus:m.useCallback(P=>w(P),[w]),onItemShiftTab:m.useCallback(()=>M(!0),[]),onFocusableItemAdd:m.useCallback(()=>L(P=>P+1),[]),onFocusableItemRemove:m.useCallback(()=>L(P=>P-1),[]),children:y.jsx(Ve.div,{tabIndex:g||C===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:"none",...e.style},onMouseDown:Ie(e.onMouseDown,()=>{S.current=!0}),onFocus:Ie(e.onFocus,P=>{const T=!S.current;if(P.target===P.currentTarget&&T&&!g){const E=new CustomEvent(qj,vfe);if(P.currentTarget.dispatchEvent(E),!E.defaultPrevented){const z=b().filter(O=>O.focusable),A=z.find(O=>O.active),U=z.find(O=>O.id===v),V=[A,U,...z].filter(Boolean).map(O=>O.ref.current);DK(V,h)}}S.current=!1}),onBlur:Ie(e.onBlur,()=>M(!1))})})}),TK="RovingFocusGroupItem",NK=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:a,...s}=e,l=dn(),c=i||l,h=Cfe(TK,n),d=h.currentTabStopId===c,f=zK(n),{onFocusableItemAdd:p,onFocusableItemRemove:k,currentTabStopId:v}=h;return m.useEffect(()=>{if(r)return p(),()=>k()},[r,p,k]),y.jsx(zN.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:y.jsx(Ve.span,{tabIndex:d?0:-1,"data-orientation":h.orientation,...s,ref:t,onMouseDown:Ie(e.onMouseDown,w=>{r?h.onItemFocus(c):w.preventDefault()}),onFocus:Ie(e.onFocus,()=>h.onItemFocus(c)),onKeyDown:Ie(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){h.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const g=Efe(w,h.orientation,h.dir);if(g!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let x=f().filter(b=>b.focusable).map(b=>b.ref.current);if(g==="last")x.reverse();else if(g==="prev"||g==="next"){g==="prev"&&x.reverse();const b=x.indexOf(w.currentTarget);x=h.loop?Afe(x,b+1):x.slice(b+1)}setTimeout(()=>DK(x))}}),children:typeof a=="function"?a({isCurrentTabStop:d,hasTabStop:v!=null}):a})})});NK.displayName=TK;var Lfe={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Ife(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Efe(e,t,n){const r=Ife(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Lfe[r]}function DK(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Afe(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var _K=jK,HK=NK,jN=["Enter"," "],Pfe=["ArrowDown","PageUp","Home"],FK=["ArrowUp","PageDown","End"],Rfe=[...Pfe,...FK],zfe={ltr:[...jN,"ArrowRight"],rtl:[...jN,"ArrowLeft"]},jfe={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Oh="Menu",[ih,Tfe,Nfe]=B_(Oh),[d1,vz]=Nr(Oh,[Nfe,Yu,xz]),wz=Yu(),OK=xz(),[Dfe,h1]=d1(Oh),[_fe,qh]=d1(Oh),qK=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:i,modal:a=!0}=e,s=wz(t),[l,c]=m.useState(null),h=m.useRef(!1),d=go(i),f=gz(o);return m.useEffect(()=>{const p=()=>{h.current=!0,document.addEventListener("pointerdown",k,{capture:!0,once:!0}),document.addEventListener("pointermove",k,{capture:!0,once:!0})},k=()=>h.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",k,{capture:!0}),document.removeEventListener("pointermove",k,{capture:!0})}},[]),y.jsx(z_,{...s,children:y.jsx(Dfe,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:y.jsx(_fe,{scope:t,onClose:m.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:h,dir:f,modal:a,children:r})})})};qK.displayName=Oh;var Hfe="MenuAnchor",$_=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=wz(n);return y.jsx(az,{...o,...r,ref:t})});$_.displayName=Hfe;var U_="MenuPortal",[Ffe,VK]=d1(U_,{forceMount:void 0}),BK=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,i=h1(U_,t);return y.jsx(Ffe,{scope:t,forceMount:n,children:y.jsx(Qn,{present:n||i.open,children:y.jsx(Lh,{asChild:!0,container:o,children:r})})})};BK.displayName=U_;var ur="MenuContent",[Ofe,W_]=d1(ur),$K=m.forwardRef((e,t)=>{const n=VK(ur,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,i=h1(ur,e.__scopeMenu),a=qh(ur,e.__scopeMenu);return y.jsx(ih.Provider,{scope:e.__scopeMenu,children:y.jsx(Qn,{present:r||i.open,children:y.jsx(ih.Slot,{scope:e.__scopeMenu,children:a.modal?y.jsx(qfe,{...o,ref:t}):y.jsx(Vfe,{...o,ref:t})})})})}),qfe=m.forwardRef((e,t)=>{const n=h1(ur,e.__scopeMenu),r=m.useRef(null),o=dt(t,r);return m.useEffect(()=>{const i=r.current;if(i)return N_(i)},[]),y.jsx(G_,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ie(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Vfe=m.forwardRef((e,t)=>{const n=h1(ur,e.__scopeMenu);return y.jsx(G_,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Bfe=Nu("MenuContent.ScrollLock"),G_=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:s,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:h,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:k,...v}=e,w=h1(ur,n),g=qh(ur,n),M=wz(n),x=OK(n),b=Tfe(n),[S,C]=m.useState(null),L=m.useRef(null),P=dt(t,L,w.onContentChange),T=m.useRef(0),E=m.useRef(""),z=m.useRef(0),A=m.useRef(null),U=m.useRef("right"),R=m.useRef(0),V=k?lz:m.Fragment,O=k?{as:Bfe,allowPinchZoom:!0}:void 0,B=N=>{var re,ne;const I=E.current+N,W=b().filter(ae=>!ae.disabled),H=document.activeElement,j=(re=W.find(ae=>ae.ref.current===H))==null?void 0:re.textValue,G=W.map(ae=>ae.textValue),X=tpe(G,I,j),Y=(ne=W.find(ae=>ae.textValue===X))==null?void 0:ne.ref.current;(function ae(ve){E.current=ve,window.clearTimeout(T.current),ve!==""&&(T.current=window.setTimeout(()=>ae(""),1e3))})(I),Y&&setTimeout(()=>Y.focus())};m.useEffect(()=>()=>window.clearTimeout(T.current),[]),b_();const D=m.useCallback(N=>{var W,H;return U.current===((W=A.current)==null?void 0:W.side)&&rpe(N,(H=A.current)==null?void 0:H.area)},[]);return y.jsx(Ofe,{scope:n,searchRef:E,onItemEnter:m.useCallback(N=>{D(N)&&N.preventDefault()},[D]),onItemLeave:m.useCallback(N=>{var I;D(N)||((I=L.current)==null||I.focus(),C(null))},[D]),onTriggerLeave:m.useCallback(N=>{D(N)&&N.preventDefault()},[D]),pointerGraceTimerRef:z,onPointerGraceIntentChange:m.useCallback(N=>{A.current=N},[]),children:y.jsx(V,{...O,children:y.jsx(tz,{asChild:!0,trapped:o,onMountAutoFocus:Ie(i,N=>{var I;N.preventDefault(),(I=L.current)==null||I.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:y.jsx(Ch,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:c,onPointerDownOutside:h,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:y.jsx(_K,{asChild:!0,...x,dir:g.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:Ie(l,N=>{g.isUsingKeyboardRef.current||N.preventDefault()}),preventScrollOnEntryFocus:!0,children:y.jsx(j_,{role:"menu","aria-orientation":"vertical","data-state":aX(w.open),"data-radix-menu-content":"",dir:g.dir,...M,...v,ref:P,style:{outline:"none",...v.style},onKeyDown:Ie(v.onKeyDown,N=>{const W=N.target.closest("[data-radix-menu-content]")===N.currentTarget,H=N.ctrlKey||N.altKey||N.metaKey,j=N.key.length===1;W&&(N.key==="Tab"&&N.preventDefault(),!H&&j&&B(N.key));const G=L.current;if(N.target!==G||!Rfe.includes(N.key))return;N.preventDefault();const Y=b().filter(re=>!re.disabled).map(re=>re.ref.current);FK.includes(N.key)&&Y.reverse(),Jfe(Y)}),onBlur:Ie(e.onBlur,N=>{N.currentTarget.contains(N.target)||(window.clearTimeout(T.current),E.current="")}),onPointerMove:Ie(e.onPointerMove,ah(N=>{const I=N.target,W=R.current!==N.clientX;if(N.currentTarget.contains(I)&&W){const H=N.clientX>R.current?"right":"left";U.current=H,R.current=N.clientX}}))})})})})})})});$K.displayName=ur;var $fe="MenuGroup",Z_=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return y.jsx(Ve.div,{role:"group",...r,ref:t})});Z_.displayName=$fe;var Ufe="MenuLabel",UK=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return y.jsx(Ve.div,{...r,ref:t})});UK.displayName=Ufe;var mR="MenuItem",Zq="menu.itemSelect",Mz=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,i=m.useRef(null),a=qh(mR,e.__scopeMenu),s=W_(mR,e.__scopeMenu),l=dt(t,i),c=m.useRef(!1),h=()=>{const d=i.current;if(!n&&d){const f=new CustomEvent(Zq,{bubbles:!0,cancelable:!0});d.addEventListener(Zq,p=>r==null?void 0:r(p),{once:!0}),rZ(d,f),f.defaultPrevented?c.current=!1:a.onClose()}};return y.jsx(WK,{...o,ref:l,disabled:n,onClick:Ie(e.onClick,h),onPointerDown:d=>{var f;(f=e.onPointerDown)==null||f.call(e,d),c.current=!0},onPointerUp:Ie(e.onPointerUp,d=>{var f;c.current||(f=d.currentTarget)==null||f.click()}),onKeyDown:Ie(e.onKeyDown,d=>{const f=s.searchRef.current!=="";n||f&&d.key===" "||jN.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});Mz.displayName=mR;var WK=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...i}=e,a=W_(mR,n),s=OK(n),l=m.useRef(null),c=dt(t,l),[h,d]=m.useState(!1),[f,p]=m.useState("");return m.useEffect(()=>{const k=l.current;k&&p((k.textContent??"").trim())},[i.children]),y.jsx(ih.ItemSlot,{scope:n,disabled:r,textValue:o??f,children:y.jsx(HK,{asChild:!0,...s,focusable:!r,children:y.jsx(Ve.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...i,ref:c,onPointerMove:Ie(e.onPointerMove,ah(k=>{r?a.onItemLeave(k):(a.onItemEnter(k),k.defaultPrevented||k.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ie(e.onPointerLeave,ah(k=>a.onItemLeave(k))),onFocus:Ie(e.onFocus,()=>d(!0)),onBlur:Ie(e.onBlur,()=>d(!1))})})})}),Wfe="MenuCheckboxItem",GK=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return y.jsx(QK,{scope:e.__scopeMenu,checked:n,children:y.jsx(Mz,{role:"menuitemcheckbox","aria-checked":kR(n)?"mixed":n,...o,ref:t,"data-state":X_(n),onSelect:Ie(o.onSelect,()=>r==null?void 0:r(kR(n)?!0:!n),{checkForDefaultPrevented:!1})})})});GK.displayName=Wfe;var ZK="MenuRadioGroup",[Gfe,Zfe]=d1(ZK,{value:void 0,onValueChange:()=>{}}),KK=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,i=go(r);return y.jsx(Gfe,{scope:e.__scopeMenu,value:n,onValueChange:i,children:y.jsx(Z_,{...o,ref:t})})});KK.displayName=ZK;var XK="MenuRadioItem",YK=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=Zfe(XK,e.__scopeMenu),i=n===o.value;return y.jsx(QK,{scope:e.__scopeMenu,checked:i,children:y.jsx(Mz,{role:"menuitemradio","aria-checked":i,...r,ref:t,"data-state":X_(i),onSelect:Ie(r.onSelect,()=>{var a;return(a=o.onValueChange)==null?void 0:a.call(o,n)},{checkForDefaultPrevented:!1})})})});YK.displayName=XK;var K_="MenuItemIndicator",[QK,Kfe]=d1(K_,{checked:!1}),JK=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,i=Kfe(K_,n);return y.jsx(Qn,{present:r||kR(i.checked)||i.checked===!0,children:y.jsx(Ve.span,{...o,ref:t,"data-state":X_(i.checked)})})});JK.displayName=K_;var Xfe="MenuSeparator",eX=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return y.jsx(Ve.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});eX.displayName=Xfe;var Yfe="MenuArrow",tX=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=wz(n);return y.jsx(T_,{...o,...r,ref:t})});tX.displayName=Yfe;var Qfe="MenuSub",[P8e,nX]=d1(Qfe),Hd="MenuSubTrigger",rX=m.forwardRef((e,t)=>{const n=h1(Hd,e.__scopeMenu),r=qh(Hd,e.__scopeMenu),o=nX(Hd,e.__scopeMenu),i=W_(Hd,e.__scopeMenu),a=m.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:l}=i,c={__scopeMenu:e.__scopeMenu},h=m.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return m.useEffect(()=>h,[h]),m.useEffect(()=>{const d=s.current;return()=>{window.clearTimeout(d),l(null)}},[s,l]),y.jsx($_,{asChild:!0,...c,children:y.jsx(WK,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":aX(n.open),...e,ref:ko(t,o.onTriggerChange),onClick:d=>{var f;(f=e.onClick)==null||f.call(e,d),!(e.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Ie(e.onPointerMove,ah(d=>{i.onItemEnter(d),!d.defaultPrevented&&!e.disabled&&!n.open&&!a.current&&(i.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{n.onOpenChange(!0),h()},100))})),onPointerLeave:Ie(e.onPointerLeave,ah(d=>{var p,k;h();const f=(p=n.content)==null?void 0:p.getBoundingClientRect();if(f){const v=(k=n.content)==null?void 0:k.dataset.side,w=v==="right",g=w?-5:5,M=f[w?"left":"right"],x=f[w?"right":"left"];i.onPointerGraceIntentChange({area:[{x:d.clientX+g,y:d.clientY},{x:M,y:f.top},{x,y:f.top},{x,y:f.bottom},{x:M,y:f.bottom}],side:v}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(d),d.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:Ie(e.onKeyDown,d=>{var p;const f=i.searchRef.current!=="";e.disabled||f&&d.key===" "||zfe[r.dir].includes(d.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),d.preventDefault())})})})});rX.displayName=Hd;var oX="MenuSubContent",iX=m.forwardRef((e,t)=>{const n=VK(ur,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,i=h1(ur,e.__scopeMenu),a=qh(ur,e.__scopeMenu),s=nX(oX,e.__scopeMenu),l=m.useRef(null),c=dt(t,l);return y.jsx(ih.Provider,{scope:e.__scopeMenu,children:y.jsx(Qn,{present:r||i.open,children:y.jsx(ih.Slot,{scope:e.__scopeMenu,children:y.jsx(G_,{id:s.contentId,"aria-labelledby":s.triggerId,...o,ref:c,align:"start",side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:h=>{var d;a.isUsingKeyboardRef.current&&((d=l.current)==null||d.focus()),h.preventDefault()},onCloseAutoFocus:h=>h.preventDefault(),onFocusOutside:Ie(e.onFocusOutside,h=>{h.target!==s.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Ie(e.onEscapeKeyDown,h=>{a.onClose(),h.preventDefault()}),onKeyDown:Ie(e.onKeyDown,h=>{var p;const d=h.currentTarget.contains(h.target),f=jfe[a.dir].includes(h.key);d&&f&&(i.onOpenChange(!1),(p=s.trigger)==null||p.focus(),h.preventDefault())})})})})})});iX.displayName=oX;function aX(e){return e?"open":"closed"}function kR(e){return e==="indeterminate"}function X_(e){return kR(e)?"indeterminate":e?"checked":"unchecked"}function Jfe(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function epe(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function tpe(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let a=epe(e,Math.max(i,0));o.length===1&&(a=a.filter(c=>c!==n));const l=a.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function npe(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){const s=t[i],l=t[a],c=s.x,h=s.y,d=l.x,f=l.y;h>r!=f>r&&n<(d-c)*(r-h)/(f-h)+c&&(o=!o)}return o}function rpe(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return npe(n,t)}function ah(e){return t=>t.pointerType==="mouse"?e(t):void 0}var sX=qK,lX=$_,cX=BK,uX=$K,dX=Z_,hX=UK,fX=Mz,pX=GK,yX=KK,mX=YK,kX=JK,gX=eX,xX=tX,vX=rX,wX=iX,Y_="ContextMenu",[ope]=Nr(Y_,[vz]),pn=vz(),[ipe,MX]=ope(Y_),bX=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:r,dir:o,modal:i=!0}=e,[a,s]=m.useState(!1),l=pn(t),c=go(r),h=m.useCallback(d=>{s(d),c(d)},[c]);return y.jsx(ipe,{scope:t,open:a,onOpenChange:h,modal:i,children:y.jsx(sX,{...l,dir:o,open:a,onOpenChange:h,modal:i,children:n})})};bX.displayName=Y_;var CX="ContextMenuTrigger",SX=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,disabled:r=!1,...o}=e,i=MX(CX,n),a=pn(n),s=m.useRef({x:0,y:0}),l=m.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...s.current})}),c=m.useRef(0),h=m.useCallback(()=>window.clearTimeout(c.current),[]),d=f=>{s.current={x:f.clientX,y:f.clientY},i.onOpenChange(!0)};return m.useEffect(()=>h,[h]),m.useEffect(()=>void(r&&h()),[r,h]),y.jsxs(y.Fragment,{children:[y.jsx(lX,{...a,virtualRef:l}),y.jsx(Ve.span,{"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,...o,ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:r?e.onContextMenu:Ie(e.onContextMenu,f=>{h(),d(f),f.preventDefault()}),onPointerDown:r?e.onPointerDown:Ie(e.onPointerDown,V0(f=>{h(),c.current=window.setTimeout(()=>d(f),700)})),onPointerMove:r?e.onPointerMove:Ie(e.onPointerMove,V0(h)),onPointerCancel:r?e.onPointerCancel:Ie(e.onPointerCancel,V0(h)),onPointerUp:r?e.onPointerUp:Ie(e.onPointerUp,V0(h))})]})});SX.displayName=CX;var ape="ContextMenuPortal",LX=e=>{const{__scopeContextMenu:t,...n}=e,r=pn(t);return y.jsx(cX,{...r,...n})};LX.displayName=ape;var IX="ContextMenuContent",EX=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=MX(IX,n),i=pn(n),a=m.useRef(!1);return y.jsx(uX,{...i,...r,ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:s=>{var l;(l=e.onCloseAutoFocus)==null||l.call(e,s),!s.defaultPrevented&&a.current&&s.preventDefault(),a.current=!1},onInteractOutside:s=>{var l;(l=e.onInteractOutside)==null||l.call(e,s),!s.defaultPrevented&&!o.modal&&(a.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});EX.displayName=IX;var spe="ContextMenuGroup",lpe=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return y.jsx(dX,{...o,...r,ref:t})});lpe.displayName=spe;var cpe="ContextMenuLabel",upe=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return y.jsx(hX,{...o,...r,ref:t})});upe.displayName=cpe;var dpe="ContextMenuItem",AX=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return y.jsx(fX,{...o,...r,ref:t})});AX.displayName=dpe;var hpe="ContextMenuCheckboxItem",fpe=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return y.jsx(pX,{...o,...r,ref:t})});fpe.displayName=hpe;var ppe="ContextMenuRadioGroup",ype=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return y.jsx(yX,{...o,...r,ref:t})});ype.displayName=ppe;var mpe="ContextMenuRadioItem",kpe=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return y.jsx(mX,{...o,...r,ref:t})});kpe.displayName=mpe;var gpe="ContextMenuItemIndicator",xpe=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return y.jsx(kX,{...o,...r,ref:t})});xpe.displayName=gpe;var vpe="ContextMenuSeparator",PX=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return y.jsx(gX,{...o,...r,ref:t})});PX.displayName=vpe;var wpe="ContextMenuArrow",Mpe=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return y.jsx(xX,{...o,...r,ref:t})});Mpe.displayName=wpe;var bpe="ContextMenuSubTrigger",Cpe=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return y.jsx(vX,{...o,...r,ref:t})});Cpe.displayName=bpe;var Spe="ContextMenuSubContent",Lpe=m.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return y.jsx(wX,{...o,...r,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Lpe.displayName=Spe;function V0(e){return t=>t.pointerType!=="mouse"?e(t):void 0}var Ipe=bX,Epe=SX,Ape=LX,RX=EX,zX=AX,jX=PX;const Ppe=Ipe,Rpe=Epe,TX=m.forwardRef(({className:e,...t},n)=>{const r=Qu();return y.jsx(Ape,{container:r,children:y.jsx(RX,{ref:n,className:ie("sf:z-50 sf:min-w-40 sf:overflow-hidden sf:rounded-md sf:border sf:bg-popover sf:p-1 sf:text-popover-foreground sf:shadow-md sf:data-[state=open]:animate-in sf:data-[state=closed]:animate-out sf:data-[state=closed]:fade-out-0 sf:data-[state=open]:fade-in-0 sf:data-[state=closed]:zoom-out-95 sf:data-[state=open]:zoom-in-95",e),...t})})});TX.displayName=RX.displayName;const to=m.forwardRef(({className:e,...t},n)=>y.jsx(zX,{ref:n,className:ie("sf:relative sf:flex sf:cursor-default sf:select-none sf:items-center sf:rounded-sm sf:px-2 sf:py-1.5 sf:text-sm sf:outline-hidden sf:data-disabled:pointer-events-none sf:data-highlighted:bg-accent sf:data-highlighted:text-accent-foreground sf:data-disabled:opacity-50",e),...t}));to.displayName=zX.displayName;const MP=m.forwardRef(({className:e,...t},n)=>y.jsx(jX,{ref:n,className:ie("sf:-mx-1 sf:my-1 sf:h-px sf:bg-border",e),...t}));MP.displayName=jX.displayName;const TN=({className:e,...t})=>y.jsx("span",{className:ie("sf:ml-auto sf:pl-4 sf:text-xs sf:tracking-widest sf:text-muted-foreground",e),...t});TN.displayName="ContextMenuShortcut";var bz="DropdownMenu",[zpe]=Nr(bz,[vz]),yn=vz(),[jpe,NX]=zpe(bz),DX=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:i,onOpenChange:a,modal:s=!0}=e,l=yn(t),c=m.useRef(null),[h,d]=c1({prop:o,defaultProp:i??!1,onChange:a,caller:bz});return y.jsx(jpe,{scope:t,triggerId:dn(),triggerRef:c,contentId:dn(),open:h,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),modal:s,children:y.jsx(sX,{...l,open:h,onOpenChange:d,dir:r,modal:s,children:n})})};DX.displayName=bz;var _X="DropdownMenuTrigger",HX=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,i=NX(_X,n),a=yn(n);return y.jsx(lX,{asChild:!0,...a,children:y.jsx(Ve.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:ko(t,i.triggerRef),onPointerDown:Ie(e.onPointerDown,s=>{!r&&s.button===0&&s.ctrlKey===!1&&(i.onOpenToggle(),i.open||s.preventDefault())}),onKeyDown:Ie(e.onKeyDown,s=>{r||(["Enter"," "].includes(s.key)&&i.onOpenToggle(),s.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(s.key)&&s.preventDefault())})})})});HX.displayName=_X;var Tpe="DropdownMenuPortal",FX=e=>{const{__scopeDropdownMenu:t,...n}=e,r=yn(t);return y.jsx(cX,{...r,...n})};FX.displayName=Tpe;var OX="DropdownMenuContent",qX=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=NX(OX,n),i=yn(n),a=m.useRef(!1);return y.jsx(uX,{id:o.contentId,"aria-labelledby":o.triggerId,...i,...r,ref:t,onCloseAutoFocus:Ie(e.onCloseAutoFocus,s=>{var l;a.current||(l=o.triggerRef.current)==null||l.focus(),a.current=!1,s.preventDefault()}),onInteractOutside:Ie(e.onInteractOutside,s=>{const l=s.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,h=l.button===2||c;(!o.modal||h)&&(a.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});qX.displayName=OX;var Npe="DropdownMenuGroup",Dpe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yn(n);return y.jsx(dX,{...o,...r,ref:t})});Dpe.displayName=Npe;var _pe="DropdownMenuLabel",Hpe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yn(n);return y.jsx(hX,{...o,...r,ref:t})});Hpe.displayName=_pe;var Fpe="DropdownMenuItem",VX=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yn(n);return y.jsx(fX,{...o,...r,ref:t})});VX.displayName=Fpe;var Ope="DropdownMenuCheckboxItem",qpe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yn(n);return y.jsx(pX,{...o,...r,ref:t})});qpe.displayName=Ope;var Vpe="DropdownMenuRadioGroup",Bpe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yn(n);return y.jsx(yX,{...o,...r,ref:t})});Bpe.displayName=Vpe;var $pe="DropdownMenuRadioItem",Upe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yn(n);return y.jsx(mX,{...o,...r,ref:t})});Upe.displayName=$pe;var Wpe="DropdownMenuItemIndicator",Gpe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yn(n);return y.jsx(kX,{...o,...r,ref:t})});Gpe.displayName=Wpe;var Zpe="DropdownMenuSeparator",BX=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yn(n);return y.jsx(gX,{...o,...r,ref:t})});BX.displayName=Zpe;var Kpe="DropdownMenuArrow",Xpe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yn(n);return y.jsx(xX,{...o,...r,ref:t})});Xpe.displayName=Kpe;var Ype="DropdownMenuSubTrigger",Qpe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yn(n);return y.jsx(vX,{...o,...r,ref:t})});Qpe.displayName=Ype;var Jpe="DropdownMenuSubContent",eye=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yn(n);return y.jsx(wX,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});eye.displayName=Jpe;var tye=DX,nye=HX,rye=FX,$X=qX,UX=VX,WX=BX;const oye=tye,iye=nye,GX=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>{const o=Qu();return y.jsx(rye,{container:o,children:y.jsx($X,{ref:r,sideOffset:t,className:ie("sf:z-50 sf:min-w-40 sf:overflow-hidden sf:rounded-md sf:border sf:bg-popover sf:p-1 sf:text-popover-foreground sf:shadow-md sf:data-[state=open]:animate-in sf:data-[state=closed]:animate-out sf:data-[state=closed]:fade-out-0 sf:data-[state=open]:fade-in-0 sf:data-[state=closed]:zoom-out-95 sf:data-[state=open]:zoom-in-95 sf:data-[side=bottom]:slide-in-from-top-2 sf:data-[side=left]:slide-in-from-right-2 sf:data-[side=right]:slide-in-from-left-2 sf:data-[side=top]:slide-in-from-bottom-2",e),...n})})});GX.displayName=$X.displayName;const Fd=m.forwardRef(({className:e,...t},n)=>y.jsx(UX,{ref:n,className:ie("sf:relative sf:flex sf:cursor-default sf:select-none sf:items-center sf:gap-2 sf:rounded-sm sf:px-2 sf:py-1.5 sf:text-sm sf:outline-hidden sf:data-disabled:pointer-events-none sf:data-highlighted:bg-accent sf:data-highlighted:text-accent-foreground sf:data-disabled:opacity-50",e),...t}));Fd.displayName=UX.displayName;const aye=m.forwardRef(({className:e,...t},n)=>y.jsx(WX,{ref:n,className:ie("sf:-mx-1 sf:my-1 sf:h-px sf:bg-border",e),...t}));aye.displayName=WX.displayName;var sye=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),lye="VisuallyHidden",ZX=m.forwardRef((e,t)=>y.jsx(Ve.span,{...e,ref:t,style:{...sye,...e.style}}));ZX.displayName=lye;var cye=ZX,[Cz]=Nr("Tooltip",[Yu]),Sz=Yu(),KX="TooltipProvider",uye=700,NN="tooltip.open",[dye,Q_]=Cz(KX),XX=e=>{const{__scopeTooltip:t,delayDuration:n=uye,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:i}=e,a=m.useRef(!0),s=m.useRef(!1),l=m.useRef(0);return m.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),y.jsx(dye,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:m.useCallback(()=>{window.clearTimeout(l.current),a.current=!1},[]),onClose:m.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>a.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:m.useCallback(c=>{s.current=c},[]),disableHoverableContent:o,children:i})};XX.displayName=KX;var sh="Tooltip",[hye,Vh]=Cz(sh),YX=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:i,disableHoverableContent:a,delayDuration:s}=e,l=Q_(sh,e.__scopeTooltip),c=Sz(t),[h,d]=m.useState(null),f=dn(),p=m.useRef(0),k=a??l.disableHoverableContent,v=s??l.delayDuration,w=m.useRef(!1),[g,M]=c1({prop:r,defaultProp:o??!1,onChange:L=>{L?(l.onOpen(),document.dispatchEvent(new CustomEvent(NN))):l.onClose(),i==null||i(L)},caller:sh}),x=m.useMemo(()=>g?w.current?"delayed-open":"instant-open":"closed",[g]),b=m.useCallback(()=>{window.clearTimeout(p.current),p.current=0,w.current=!1,M(!0)},[M]),S=m.useCallback(()=>{window.clearTimeout(p.current),p.current=0,M(!1)},[M]),C=m.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{w.current=!0,M(!0),p.current=0},v)},[v,M]);return m.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),y.jsx(z_,{...c,children:y.jsx(hye,{scope:t,contentId:f,open:g,stateAttribute:x,trigger:h,onTriggerChange:d,onTriggerEnter:m.useCallback(()=>{l.isOpenDelayedRef.current?C():b()},[l.isOpenDelayedRef,C,b]),onTriggerLeave:m.useCallback(()=>{k?S():(window.clearTimeout(p.current),p.current=0)},[S,k]),onOpen:b,onClose:S,disableHoverableContent:k,children:n})})};YX.displayName=sh;var DN="TooltipTrigger",QX=m.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Vh(DN,n),i=Q_(DN,n),a=Sz(n),s=m.useRef(null),l=dt(t,s,o.onTriggerChange),c=m.useRef(!1),h=m.useRef(!1),d=m.useCallback(()=>c.current=!1,[]);return m.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),y.jsx(az,{asChild:!0,...a,children:y.jsx(Ve.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:Ie(e.onPointerMove,f=>{f.pointerType!=="touch"&&!h.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),h.current=!0)}),onPointerLeave:Ie(e.onPointerLeave,()=>{o.onTriggerLeave(),h.current=!1}),onPointerDown:Ie(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Ie(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:Ie(e.onBlur,o.onClose),onClick:Ie(e.onClick,o.onClose)})})});QX.displayName=DN;var J_="TooltipPortal",[fye,pye]=Cz(J_,{forceMount:void 0}),JX=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,i=Vh(J_,t);return y.jsx(fye,{scope:t,forceMount:n,children:y.jsx(Qn,{present:n||i.open,children:y.jsx(Lh,{asChild:!0,container:o,children:r})})})};JX.displayName=J_;var Fu="TooltipContent",eY=m.forwardRef((e,t)=>{const n=pye(Fu,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,a=Vh(Fu,e.__scopeTooltip);return y.jsx(Qn,{present:r||a.open,children:a.disableHoverableContent?y.jsx(tY,{side:o,...i,ref:t}):y.jsx(yye,{side:o,...i,ref:t})})}),yye=m.forwardRef((e,t)=>{const n=Vh(Fu,e.__scopeTooltip),r=Q_(Fu,e.__scopeTooltip),o=m.useRef(null),i=dt(t,o),[a,s]=m.useState(null),{trigger:l,onClose:c}=n,h=o.current,{onPointerInTransitChange:d}=r,f=m.useCallback(()=>{s(null),d(!1)},[d]),p=m.useCallback((k,v)=>{const w=k.currentTarget,g={x:k.clientX,y:k.clientY},M=vye(g,w.getBoundingClientRect()),x=wye(g,M),b=Mye(v.getBoundingClientRect()),S=Cye([...x,...b]);s(S),d(!0)},[d]);return m.useEffect(()=>()=>f(),[f]),m.useEffect(()=>{if(l&&h){const k=w=>p(w,h),v=w=>p(w,l);return l.addEventListener("pointerleave",k),h.addEventListener("pointerleave",v),()=>{l.removeEventListener("pointerleave",k),h.removeEventListener("pointerleave",v)}}},[l,h,p,f]),m.useEffect(()=>{if(a){const k=v=>{const w=v.target,g={x:v.clientX,y:v.clientY},M=(l==null?void 0:l.contains(w))||(h==null?void 0:h.contains(w)),x=!bye(g,a);M?f():x&&(f(),c())};return document.addEventListener("pointermove",k),()=>document.removeEventListener("pointermove",k)}},[l,h,a,c,f]),y.jsx(tY,{...e,ref:i})}),[mye,kye]=Cz(sh,{isInside:!1}),gye=ade("TooltipContent"),tY=m.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:a,...s}=e,l=Vh(Fu,n),c=Sz(n),{onClose:h}=l;return m.useEffect(()=>(document.addEventListener(NN,h),()=>document.removeEventListener(NN,h)),[h]),m.useEffect(()=>{if(l.trigger){const d=f=>{const p=f.target;p!=null&&p.contains(l.trigger)&&h()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,h]),y.jsx(Ch,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:d=>d.preventDefault(),onDismiss:h,children:y.jsxs(j_,{"data-state":l.stateAttribute,...c,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[y.jsx(gye,{children:r}),y.jsx(mye,{scope:n,isInside:!0,children:y.jsx(cye,{id:l.contentId,role:"tooltip",children:o||r})})]})})});eY.displayName=Fu;var nY="TooltipArrow",xye=m.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Sz(n);return kye(nY,n).isInside?null:y.jsx(T_,{...o,...r,ref:t})});xye.displayName=nY;function vye(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function wye(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function Mye(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function bye(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){const s=t[i],l=t[a],c=s.x,h=s.y,d=l.x,f=l.y;h>r!=f>r&&n<(d-c)*(r-h)/(f-h)+c&&(o=!o)}return o}function Cye(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),Sye(t)}function Sye(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const i=t[t.length-1],a=t[t.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const i=n[n.length-1],a=n[n.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Lye=XX,Iye=YX,Eye=QX,Aye=JX,rY=eY;const L2=Lye,Bh=Iye,$h=Eye,td=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>{const o=Qu();return y.jsx(Aye,{container:o,children:y.jsx(rY,{ref:r,sideOffset:t,className:ie("sf:z-50 sf:overflow-hidden sf:rounded-md sf:bg-foreground sf:px-3 sf:py-1.5 sf:text-sm sf:text-background sf:shadow-md sf:animate-in sf:fade-in-0 sf:zoom-in-95 sf:data-[state=closed]:animate-out sf:data-[state=closed]:fade-out-0 sf:data-[state=closed]:zoom-out-95 sf:data-[side=bottom]:slide-in-from-top-2 sf:data-[side=left]:slide-in-from-right-2 sf:data-[side=right]:slide-in-from-left-2 sf:data-[side=top]:slide-in-from-bottom-2",e),...n})})});td.displayName=rY.displayName;function Sd({value:e,onChange:t,options:n,ariaLabel:r,className:o}){return y.jsx(L2,{delayDuration:300,children:y.jsx("div",{"aria-label":r,className:ie("sf:inline-flex sf:h-9 sf:items-stretch sf:overflow-hidden sf:rounded-md sf:border sf:border-input sf:bg-background sf:p-0.5",o),children:n.map((i,a)=>{const s=e===i.value,l=i.icon;return y.jsxs(m.Fragment,{children:[a>0?y.jsx("div",{"aria-hidden":!0,className:"sf:mx-0.5 sf:w-px sf:self-stretch sf:bg-border/70"}):null,y.jsxs(Bh,{children:[y.jsx($h,{asChild:!0,children:y.jsx("button",{type:"button","aria-pressed":s,"aria-label":i.label,"data-active":s,"data-testid":i.testId,onClick:()=>t(i.value),className:ie("sf:flex sf:flex-1 sf:items-center sf:justify-center sf:rounded sf:px-2 sf:transition-colors sf:focus-visible:outline-hidden sf:focus-visible:ring-1 sf:focus-visible:ring-ring",s?"sf:bg-secondary sf:text-secondary-foreground sf:shadow-sm":"sf:text-muted-foreground sf:hover:bg-accent sf:hover:text-accent-foreground"),children:y.jsx(l,{className:"sf:h-4 sf:w-4"})})}),y.jsx(td,{side:"top",className:"sf:px-2 sf:py-1 sf:text-xs",children:i.label})]})]},i.value)})})})}const Uh=e=>({width:16,height:16,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeWidth:1.75,...e}),gR=e=>y.jsx("svg",{...Uh(e),"aria-hidden":"true",children:y.jsx("line",{x1:"2",y1:"8",x2:"14",y2:"8"})}),oY=e=>y.jsx("svg",{...Uh(e),"aria-hidden":"true",children:y.jsx("line",{x1:"2",y1:"8",x2:"14",y2:"8",strokeDasharray:"3 2.5"})}),iY=e=>y.jsx("svg",{...Uh(e),"aria-hidden":"true",children:y.jsx("line",{x1:"2",y1:"8",x2:"14",y2:"8",strokeDasharray:"0.1 2.6"})}),aY=e=>y.jsx("svg",{...Uh(e),"aria-hidden":"true",children:y.jsx("path",{d:"M2 12 C 5 12, 5 4, 8 4 S 11 12, 14 12"})}),Pye=e=>y.jsx("svg",{...Uh(e),"aria-hidden":"true",children:y.jsx("path",{d:"M2 12 H 6 V 4 H 14"})}),Rye=hz,zye=({children:e,...t})=>{const n=Qu();return y.jsx(fz,{container:n,...t,children:e})},sY=m.forwardRef(({className:e,...t},n)=>y.jsx(jh,{className:ie("sf:fixed sf:inset-0 sf:z-50 sf:bg-black/80 sf:data-[state=open]:animate-in sf:data-[state=closed]:animate-out sf:data-[state=closed]:fade-out-0 sf:data-[state=open]:fade-in-0",e),...t,ref:n}));sY.displayName=jh.displayName;const jye=YZ("sf:fixed sf:z-50 sf:gap-4 sf:bg-card sf:border-border sf:p-6 sf:shadow-lg sf:transition sf:ease-in-out sf:data-[state=open]:animate-in sf:data-[state=closed]:animate-out sf:data-[state=closed]:duration-300 sf:data-[state=open]:duration-500",{variants:{side:{top:"sf:inset-x-0 sf:top-0 sf:border-b sf:data-[state=closed]:slide-out-to-top sf:data-[state=open]:slide-in-from-top",bottom:"sf:inset-x-0 sf:bottom-0 sf:border-t sf:data-[state=closed]:slide-out-to-bottom sf:data-[state=open]:slide-in-from-bottom",left:"sf:inset-y-0 sf:left-0 sf:h-full sf:w-3/4 sf:border-r sf:data-[state=closed]:slide-out-to-left sf:data-[state=open]:slide-in-from-left sf:sm:max-w-sm",right:"sf:inset-y-0 sf:right-0 sf:h-full sf:w-3/4 sf:border-l sf:data-[state=closed]:slide-out-to-right sf:data-[state=open]:slide-in-from-right sf:sm:max-w-sm"}},defaultVariants:{side:"right"}}),lY=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>y.jsxs(zye,{children:[y.jsx(sY,{}),y.jsxs(ed,{ref:o,className:ie(jye({side:e}),t),...r,children:[n,y.jsxs(kK,{className:"sf:absolute sf:right-4 sf:top-4 sf:rounded-sm sf:opacity-70 sf:ring-offset-background sf:transition-opacity sf:hover:opacity-100 sf:focus:outline-hidden sf:focus:ring-2 sf:focus:ring-ring sf:focus:ring-offset-2 sf:disabled:pointer-events-none",children:[y.jsx(uu,{className:"sf:h-4 sf:w-4"}),y.jsx("span",{className:"sf:sr-only",children:"Close"})]})]})]}));lY.displayName=ed.displayName;const bP=m.forwardRef(({className:e,...t},n)=>y.jsx(pz,{ref:n,className:ie("sf:text-lg sf:font-semibold sf:text-foreground",e),...t}));bP.displayName=pz.displayName;const _N=m.forwardRef(({className:e,...t},n)=>y.jsx(yz,{ref:n,className:ie("sf:text-sm sf:text-muted-foreground",e),...t}));_N.displayName=yz.displayName;function cY(e,[t,n]){return Math.min(n,Math.max(t,e))}function Tye(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var uY=["PageUp","PageDown"],dY=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],hY={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},nd="Slider",[HN,Nye,Dye]=B_(nd),[fY]=Nr(nd,[Dye]),[_ye,Lz]=fY(nd),pY=m.forwardRef((e,t)=>{const{name:n,min:r=0,max:o=100,step:i=1,orientation:a="horizontal",disabled:s=!1,minStepsBetweenThumbs:l=0,defaultValue:c=[r],value:h,onValueChange:d=()=>{},onValueCommit:f=()=>{},inverted:p=!1,form:k,...v}=e,w=m.useRef(new Set),g=m.useRef(0),x=a==="horizontal"?Hye:Fye,[b=[],S]=c1({prop:h,defaultProp:c,onChange:z=>{var U;(U=[...w.current][g.current])==null||U.focus(),d(z)}}),C=m.useRef(b);function L(z){const A=$ye(b,z);E(z,A)}function P(z){E(z,g.current)}function T(){const z=C.current[g.current];b[g.current]!==z&&f(b)}function E(z,A,{commit:U}={commit:!1}){const R=Zye(i),V=Kye(Math.round((z-r)/i)*i+r,R),O=cY(V,[r,o]);S((B=[])=>{const D=Vye(B,O,A);if(Gye(D,l*i)){g.current=D.indexOf(O);const N=String(D)!==String(B);return N&&U&&f(D),N?D:B}else return B})}return y.jsx(_ye,{scope:e.__scopeSlider,name:n,disabled:s,min:r,max:o,valueIndexToChangeRef:g,thumbs:w.current,values:b,orientation:a,form:k,children:y.jsx(HN.Provider,{scope:e.__scopeSlider,children:y.jsx(HN.Slot,{scope:e.__scopeSlider,children:y.jsx(x,{"aria-disabled":s,"data-disabled":s?"":void 0,...v,ref:t,onPointerDown:Ie(v.onPointerDown,()=>{s||(C.current=b)}),min:r,max:o,inverted:p,onSlideStart:s?void 0:L,onSlideMove:s?void 0:P,onSlideEnd:s?void 0:T,onHomeKeyDown:()=>!s&&E(r,0,{commit:!0}),onEndKeyDown:()=>!s&&E(o,b.length-1,{commit:!0}),onStepKeyDown:({event:z,direction:A})=>{if(!s){const V=uY.includes(z.key)||z.shiftKey&&dY.includes(z.key)?10:1,O=g.current,B=b[O],D=i*V*A;E(B+D,O,{commit:!0})}}})})})})});pY.displayName=nd;var[yY,mY]=fY(nd,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Hye=m.forwardRef((e,t)=>{const{min:n,max:r,dir:o,inverted:i,onSlideStart:a,onSlideMove:s,onSlideEnd:l,onStepKeyDown:c,...h}=e,[d,f]=m.useState(null),p=dt(t,x=>f(x)),k=m.useRef(void 0),v=gz(o),w=v==="ltr",g=w&&!i||!w&&i;function M(x){const b=k.current||d.getBoundingClientRect(),S=[0,b.width],L=eH(S,g?[n,r]:[r,n]);return k.current=b,L(x-b.left)}return y.jsx(yY,{scope:e.__scopeSlider,startEdge:g?"left":"right",endEdge:g?"right":"left",direction:g?1:-1,size:"width",children:y.jsx(kY,{dir:v,"data-orientation":"horizontal",...h,ref:p,style:{...h.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:x=>{const b=M(x.clientX);a==null||a(b)},onSlideMove:x=>{const b=M(x.clientX);s==null||s(b)},onSlideEnd:()=>{k.current=void 0,l==null||l()},onStepKeyDown:x=>{const S=hY[g?"from-left":"from-right"].includes(x.key);c==null||c({event:x,direction:S?-1:1})}})})}),Fye=m.forwardRef((e,t)=>{const{min:n,max:r,inverted:o,onSlideStart:i,onSlideMove:a,onSlideEnd:s,onStepKeyDown:l,...c}=e,h=m.useRef(null),d=dt(t,h),f=m.useRef(void 0),p=!o;function k(v){const w=f.current||h.current.getBoundingClientRect(),g=[0,w.height],x=eH(g,p?[r,n]:[n,r]);return f.current=w,x(v-w.top)}return y.jsx(yY,{scope:e.__scopeSlider,startEdge:p?"bottom":"top",endEdge:p?"top":"bottom",size:"height",direction:p?1:-1,children:y.jsx(kY,{"data-orientation":"vertical",...c,ref:d,style:{...c.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:v=>{const w=k(v.clientY);i==null||i(w)},onSlideMove:v=>{const w=k(v.clientY);a==null||a(w)},onSlideEnd:()=>{f.current=void 0,s==null||s()},onStepKeyDown:v=>{const g=hY[p?"from-bottom":"from-top"].includes(v.key);l==null||l({event:v,direction:g?-1:1})}})})}),kY=m.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:o,onSlideEnd:i,onHomeKeyDown:a,onEndKeyDown:s,onStepKeyDown:l,...c}=e,h=Lz(nd,n);return y.jsx(Ve.span,{...c,ref:t,onKeyDown:Ie(e.onKeyDown,d=>{d.key==="Home"?(a(d),d.preventDefault()):d.key==="End"?(s(d),d.preventDefault()):uY.concat(dY).includes(d.key)&&(l(d),d.preventDefault())}),onPointerDown:Ie(e.onPointerDown,d=>{const f=d.target;f.setPointerCapture(d.pointerId),d.preventDefault(),h.thumbs.has(f)?f.focus():r(d)}),onPointerMove:Ie(e.onPointerMove,d=>{d.target.hasPointerCapture(d.pointerId)&&o(d)}),onPointerUp:Ie(e.onPointerUp,d=>{const f=d.target;f.hasPointerCapture(d.pointerId)&&(f.releasePointerCapture(d.pointerId),i(d))})})}),gY="SliderTrack",xY=m.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=Lz(gY,n);return y.jsx(Ve.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...r,ref:t})});xY.displayName=gY;var FN="SliderRange",vY=m.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=Lz(FN,n),i=mY(FN,n),a=m.useRef(null),s=dt(t,a),l=o.values.length,c=o.values.map(f=>bY(f,o.min,o.max)),h=l>1?Math.min(...c):0,d=100-Math.max(...c);return y.jsx(Ve.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...r,ref:s,style:{...e.style,[i.startEdge]:h+"%",[i.endEdge]:d+"%"}})});vY.displayName=FN;var ON="SliderThumb",wY=m.forwardRef((e,t)=>{const n=Nye(e.__scopeSlider),[r,o]=m.useState(null),i=dt(t,s=>o(s)),a=m.useMemo(()=>r?n().findIndex(s=>s.ref.current===r):-1,[n,r]);return y.jsx(Oye,{...e,ref:i,index:a})}),Oye=m.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:o,...i}=e,a=Lz(ON,n),s=mY(ON,n),[l,c]=m.useState(null),h=dt(t,M=>c(M)),d=l?a.form||!!l.closest("form"):!0,f=xZ(l),p=a.values[r],k=p===void 0?0:bY(p,a.min,a.max),v=Bye(r,a.values.length),w=f==null?void 0:f[s.size],g=w?Uye(w,k,s.direction):0;return m.useEffect(()=>{if(l)return a.thumbs.add(l),()=>{a.thumbs.delete(l)}},[l,a.thumbs]),y.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[s.startEdge]:`calc(${k}% + ${g}px)`},children:[y.jsx(HN.ItemSlot,{scope:e.__scopeSlider,children:y.jsx(Ve.span,{role:"slider","aria-label":e["aria-label"]||v,"aria-valuemin":a.min,"aria-valuenow":p,"aria-valuemax":a.max,"aria-orientation":a.orientation,"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,tabIndex:a.disabled?void 0:0,...i,ref:h,style:p===void 0?{display:"none"}:e.style,onFocus:Ie(e.onFocus,()=>{a.valueIndexToChangeRef.current=r})})}),d&&y.jsx(MY,{name:o??(a.name?a.name+(a.values.length>1?"[]":""):void 0),form:a.form,value:p},r)]})});wY.displayName=ON;var qye="RadioBubbleInput",MY=m.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const o=m.useRef(null),i=dt(o,r),a=Tye(t);return m.useEffect(()=>{const s=o.current;if(!s)return;const l=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(l,"value").set;if(a!==t&&h){const d=new Event("input",{bubbles:!0});h.call(s,t),s.dispatchEvent(d)}},[a,t]),y.jsx(Ve.input,{style:{display:"none"},...n,ref:i,defaultValue:t})});MY.displayName=qye;function Vye(e=[],t,n){const r=[...e];return r[n]=t,r.sort((o,i)=>o-i)}function bY(e,t,n){const i=100/(n-t)*(e-t);return cY(i,[0,100])}function Bye(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function $ye(e,t){if(e.length===1)return 0;const n=e.map(o=>Math.abs(o-t)),r=Math.min(...n);return n.indexOf(r)}function Uye(e,t,n){const r=e/2,i=eH([0,50],[0,r]);return(r-i(t)*n)*n}function Wye(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function Gye(e,t){if(t>0){const n=Wye(e);return Math.min(...n)>=t}return!0}function eH(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Zye(e){return(String(e).split(".")[1]||"").length}function Kye(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var CY=pY,Xye=xY,Yye=vY,Qye=wY;const SY=m.forwardRef(({className:e,...t},n)=>y.jsxs(CY,{ref:n,className:ie("sf:relative sf:flex sf:w-full sf:touch-none sf:select-none sf:items-center",e),...t,children:[y.jsx(Xye,{className:"sf:relative sf:h-1.5 sf:w-full sf:grow sf:overflow-hidden sf:rounded-full sf:bg-secondary",children:y.jsx(Yye,{className:"sf:absolute sf:h-full sf:bg-primary"})}),y.jsx(Qye,{className:"sf:block sf:h-4 sf:w-4 sf:rounded-full sf:border sf:border-primary/60 sf:bg-background sf:shadow-sm sf:transition-colors sf:hover:border-primary sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:disabled:pointer-events-none sf:disabled:opacity-50"})]}));SY.displayName=CY.displayName;var Iz="Tabs",[Jye]=Nr(Iz,[xz]),LY=xz(),[eme,tH]=Jye(Iz),tme=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:a="horizontal",dir:s,activationMode:l="automatic",...c}=e,h=gz(s),[d,f]=c1({prop:r,onChange:o,defaultProp:i??"",caller:Iz});return y.jsx(eme,{scope:n,baseId:dn(),value:d,onValueChange:f,orientation:a,dir:h,activationMode:l,children:y.jsx(Ve.div,{dir:h,"data-orientation":a,...c,ref:t})})});tme.displayName=Iz;var IY="TabsList",EY=m.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=tH(IY,n),a=LY(n);return y.jsx(_K,{asChild:!0,...a,orientation:i.orientation,dir:i.dir,loop:r,children:y.jsx(Ve.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});EY.displayName=IY;var AY="TabsTrigger",PY=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,a=tH(AY,n),s=LY(n),l=jY(a.baseId,r),c=TY(a.baseId,r),h=r===a.value;return y.jsx(HK,{asChild:!0,...s,focusable:!o,active:h,children:y.jsx(Ve.button,{type:"button",role:"tab","aria-selected":h,"aria-controls":c,"data-state":h?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:l,...i,ref:t,onMouseDown:Ie(e.onMouseDown,d=>{!o&&d.button===0&&d.ctrlKey===!1?a.onValueChange(r):d.preventDefault()}),onKeyDown:Ie(e.onKeyDown,d=>{[" ","Enter"].includes(d.key)&&a.onValueChange(r)}),onFocus:Ie(e.onFocus,()=>{const d=a.activationMode!=="manual";!h&&!o&&d&&a.onValueChange(r)})})})});PY.displayName=AY;var RY="TabsContent",zY=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...a}=e,s=tH(RY,n),l=jY(s.baseId,r),c=TY(s.baseId,r),h=r===s.value,d=m.useRef(h);return m.useEffect(()=>{const f=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(f)},[]),y.jsx(Qn,{present:o||h,children:({present:f})=>y.jsx(Ve.div,{"data-state":h?"active":"inactive","data-orientation":s.orientation,role:"tabpanel","aria-labelledby":l,hidden:!f,id:c,tabIndex:0,...a,ref:t,style:{...e.style,animationDuration:d.current?"0s":void 0},children:f&&i})})});zY.displayName=RY;function jY(e,t){return`${e}-trigger-${t}`}function TY(e,t){return`${e}-content-${t}`}var NY=EY,DY=PY,_Y=zY;const nme=m.forwardRef(({className:e,...t},n)=>y.jsx(NY,{ref:n,className:ie("sf:inline-flex sf:h-9 sf:items-center sf:justify-center sf:rounded-md sf:bg-muted sf:p-1 sf:text-muted-foreground",e),...t}));nme.displayName=NY.displayName;const rme=m.forwardRef(({className:e,...t},n)=>y.jsx(DY,{ref:n,className:ie("sf:inline-flex sf:items-center sf:justify-center sf:whitespace-nowrap sf:rounded-sm sf:px-3 sf:py-1 sf:text-xs sf:font-medium sf:ring-offset-background sf:transition-all sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-2 sf:disabled:pointer-events-none sf:disabled:opacity-50 sf:data-[state=active]:bg-background sf:data-[state=active]:text-foreground sf:data-[state=active]:shadow-sm",e),...t}));rme.displayName=DY.displayName;const ome=m.forwardRef(({className:e,...t},n)=>y.jsx(_Y,{ref:n,className:ie("sf:mt-2 sf:ring-offset-background sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-2",e),...t}));ome.displayName=_Y.displayName;const Kq="application/x-seeflow-create-html-block",HY=[{shape:"rectangle",label:"Rectangle",commandId:"tool.rectangle",Icon:au},{shape:"ellipse",label:"Ellipse",commandId:"tool.ellipse",Icon:Jd}],FY=[{shape:"sticky",label:"Sticky note",commandId:"tool.sticky",Icon:g2},{shape:"text",label:"Text",commandId:"tool.text",Icon:cu}],qN=[{shape:"database",label:"Database",commandId:"tool.database",Icon:t2},{shape:"server",label:"Server",commandId:"tool.server",Icon:y2},{shape:"user",label:"User",commandId:"tool.user",Icon:M2},{shape:"queue",label:"Queue",commandId:"tool.queue",Icon:vi},{shape:"cloud",label:"Cloud",commandId:"tool.cloud",Icon:e2}],ime=[...HY,...FY,...qN],Xq="Insert icon",Yq="Shape";function ame({activeShape:e,onSelectShape:t,iconPickerOpen:n,onOpenIconPicker:r,onCloseIconPicker:o,onPickIcon:i}){const[a,s]=m.useState(!1),l=e!==null&&qN.some(h=>h.shape===e),c=({shape:h,commandId:d,Icon:f})=>{const p=e===h,k=iq(d);return y.jsx("button",{type:"button","data-testid":`toolbar-shape-${h}`,"data-active":p?"true":"false","aria-pressed":p,"aria-label":k,title:k,onClick:()=>t(p?null:h),className:ie("sf:inline-flex sf:h-8 sf:w-8 sf:items-center sf:justify-center sf:rounded-md sf:text-muted-foreground sf:transition-colors",p?"sf:bg-primary/20 sf:text-primary sf:ring-1 sf:ring-primary/50 sf:shadow-[0_0_0_1px_hsl(var(--primary)/0.5)_inset]":"sf:hover:bg-muted sf:hover:text-foreground"),children:y.jsx(f,{className:"sf:h-4 sf:w-4"})},h)};return y.jsxs("div",{"data-testid":"canvas-toolbar",className:"sf:pointer-events-auto sf:flex sf:flex-col sf:items-center sf:gap-1 sf:rounded-lg sf:border sf:border-border sf:bg-card sf:p-1 sf:shadow-md sf:backdrop-blur",children:[HY.map(c),y.jsxs(Ju,{open:a,onOpenChange:s,children:[y.jsx(Eh,{asChild:!0,children:y.jsx("button",{type:"button","data-testid":"toolbar-shape-picker","aria-label":Yq,"aria-pressed":a||l,title:Yq,className:ie("sf:inline-flex sf:h-8 sf:w-8 sf:items-center sf:justify-center sf:rounded-md sf:text-muted-foreground sf:transition-colors",a||l?"sf:bg-primary/20 sf:text-primary sf:ring-1 sf:ring-primary/50":"sf:hover:bg-muted sf:hover:text-foreground"),children:y.jsx(m2,{className:"sf:h-4 sf:w-4","aria-hidden":"true"})})}),y.jsx(u1,{align:"start",side:"right",sideOffset:6,className:"sf:w-auto sf:p-1","data-testid":"shape-picker-popover",onOpenAutoFocus:h=>{h.preventDefault()},children:y.jsx("div",{role:"menu","aria-label":"More shapes",className:"sf:flex sf:flex-col sf:gap-0.5",children:qN.map(({shape:h,label:d,commandId:f,Icon:p})=>{const k=e===h,v=iq(f);return y.jsxs("button",{type:"button",role:"menuitem","data-testid":`shape-picker-${h}`,"data-active":k?"true":"false","aria-pressed":k,"aria-label":v,title:v,onClick:()=>{t(k?null:h),s(!1)},className:ie("sf:flex sf:items-center sf:gap-2 sf:rounded-sm sf:px-2 sf:py-1.5 sf:text-left sf:text-sm",k?"sf:bg-primary/20 sf:text-primary sf:ring-1 sf:ring-primary/50":"sf:hover:bg-muted sf:focus:bg-muted sf:focus:outline-hidden"),children:[y.jsx(p,{className:"sf:h-4 sf:w-4 sf:text-muted-foreground","aria-hidden":"true"}),y.jsx("span",{children:d})]},h)})})})]}),i?y.jsx(uz,{open:n??!1,onOpenChange:h=>{h?r==null||r():o==null||o()},anchor:y.jsx("button",{type:"button","data-testid":"toolbar-insert-icon","aria-label":Xq,"aria-pressed":n??!1,title:Xq,className:ie("sf:inline-flex sf:h-8 sf:w-8 sf:items-center sf:justify-center sf:rounded-md sf:text-muted-foreground sf:transition-colors",n?"sf:bg-primary/20 sf:text-primary sf:ring-1 sf:ring-primary/50":"sf:hover:bg-muted sf:hover:text-foreground"),children:y.jsx(lu,{className:"sf:h-4 sf:w-4","aria-hidden":"true"})}),clearable:!1,onPick:h=>{h!==null&&i(h)}}):null,y.jsx("div",{className:"sf:my-1 sf:h-px sf:w-6 sf:bg-border","aria-hidden":"true"}),FY.map(c)]})}function sme(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const lme=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,cme=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ume={};function Qq(e,t){return(ume.jsx?cme:lme).test(e)}const dme=/[ \t\n\f\r]/g;function hme(e){return typeof e=="object"?e.type==="text"?Jq(e.value):!1:Jq(e)}function Jq(e){return e.replace(dme,"")===""}class Wh{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Wh.prototype.normal={};Wh.prototype.property={};Wh.prototype.space=void 0;function OY(e,t){const n={},r={};for(const o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new Wh(n,r,t)}function VN(e){return e.toLowerCase()}class Rn{constructor(t,n){this.attribute=n,this.property=t}}Rn.prototype.attribute="";Rn.prototype.booleanish=!1;Rn.prototype.boolean=!1;Rn.prototype.commaOrSpaceSeparated=!1;Rn.prototype.commaSeparated=!1;Rn.prototype.defined=!1;Rn.prototype.mustUseProperty=!1;Rn.prototype.number=!1;Rn.prototype.overloadedBoolean=!1;Rn.prototype.property="";Rn.prototype.spaceSeparated=!1;Rn.prototype.space=void 0;let fme=0;const $e=f1(),Tt=f1(),BN=f1(),pe=f1(),ft=f1(),mu=f1(),Fn=f1();function f1(){return 2**++fme}const $N=Object.freeze(Object.defineProperty({__proto__:null,boolean:$e,booleanish:Tt,commaOrSpaceSeparated:Fn,commaSeparated:mu,number:pe,overloadedBoolean:BN,spaceSeparated:ft},Symbol.toStringTag,{value:"Module"})),Vj=Object.keys($N);class nH extends Rn{constructor(t,n,r,o){let i=-1;if(super(t,n),eV(this,"space",o),typeof r=="number")for(;++i<Vj.length;){const a=Vj[i];eV(this,Vj[i],(r&$N[a])===$N[a])}}}nH.prototype.defined=!0;function eV(e,t,n){n&&(e[t]=n)}function rd(e){const t={},n={};for(const[r,o]of Object.entries(e.properties)){const i=new nH(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[VN(r)]=r,n[VN(i.attribute)]=r}return new Wh(t,n,e.space)}const qY=rd({properties:{ariaActiveDescendant:null,ariaAtomic:Tt,ariaAutoComplete:null,ariaBusy:Tt,ariaChecked:Tt,ariaColCount:pe,ariaColIndex:pe,ariaColSpan:pe,ariaControls:ft,ariaCurrent:null,ariaDescribedBy:ft,ariaDetails:null,ariaDisabled:Tt,ariaDropEffect:ft,ariaErrorMessage:null,ariaExpanded:Tt,ariaFlowTo:ft,ariaGrabbed:Tt,ariaHasPopup:null,ariaHidden:Tt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ft,ariaLevel:pe,ariaLive:null,ariaModal:Tt,ariaMultiLine:Tt,ariaMultiSelectable:Tt,ariaOrientation:null,ariaOwns:ft,ariaPlaceholder:null,ariaPosInSet:pe,ariaPressed:Tt,ariaReadOnly:Tt,ariaRelevant:null,ariaRequired:Tt,ariaRoleDescription:ft,ariaRowCount:pe,ariaRowIndex:pe,ariaRowSpan:pe,ariaSelected:Tt,ariaSetSize:pe,ariaSort:null,ariaValueMax:pe,ariaValueMin:pe,ariaValueNow:pe,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function VY(e,t){return t in e?e[t]:t}function BY(e,t){return VY(e,t.toLowerCase())}const pme=rd({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:mu,acceptCharset:ft,accessKey:ft,action:null,allow:null,allowFullScreen:$e,allowPaymentRequest:$e,allowUserMedia:$e,alt:null,as:null,async:$e,autoCapitalize:null,autoComplete:ft,autoFocus:$e,autoPlay:$e,blocking:ft,capture:null,charSet:null,checked:$e,cite:null,className:ft,cols:pe,colSpan:null,content:null,contentEditable:Tt,controls:$e,controlsList:ft,coords:pe|mu,crossOrigin:null,data:null,dateTime:null,decoding:null,default:$e,defer:$e,dir:null,dirName:null,disabled:$e,download:BN,draggable:Tt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:$e,formTarget:null,headers:ft,height:pe,hidden:BN,high:pe,href:null,hrefLang:null,htmlFor:ft,httpEquiv:ft,id:null,imageSizes:null,imageSrcSet:null,inert:$e,inputMode:null,integrity:null,is:null,isMap:$e,itemId:null,itemProp:ft,itemRef:ft,itemScope:$e,itemType:ft,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:$e,low:pe,manifest:null,max:null,maxLength:pe,media:null,method:null,min:null,minLength:pe,multiple:$e,muted:$e,name:null,nonce:null,noModule:$e,noValidate:$e,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:$e,optimum:pe,pattern:null,ping:ft,placeholder:null,playsInline:$e,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:$e,referrerPolicy:null,rel:ft,required:$e,reversed:$e,rows:pe,rowSpan:pe,sandbox:ft,scope:null,scoped:$e,seamless:$e,selected:$e,shadowRootClonable:$e,shadowRootDelegatesFocus:$e,shadowRootMode:null,shape:null,size:pe,sizes:null,slot:null,span:pe,spellCheck:Tt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:pe,step:null,style:null,tabIndex:pe,target:null,title:null,translate:null,type:null,typeMustMatch:$e,useMap:null,value:Tt,width:pe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ft,axis:null,background:null,bgColor:null,border:pe,borderColor:null,bottomMargin:pe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:$e,declare:$e,event:null,face:null,frame:null,frameBorder:null,hSpace:pe,leftMargin:pe,link:null,longDesc:null,lowSrc:null,marginHeight:pe,marginWidth:pe,noResize:$e,noHref:$e,noShade:$e,noWrap:$e,object:null,profile:null,prompt:null,rev:null,rightMargin:pe,rules:null,scheme:null,scrolling:Tt,standby:null,summary:null,text:null,topMargin:pe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:pe,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:$e,disableRemotePlayback:$e,prefix:null,property:null,results:pe,security:null,unselectable:null},space:"html",transform:BY}),yme=rd({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Fn,accentHeight:pe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:pe,amplitude:pe,arabicForm:null,ascent:pe,attributeName:null,attributeType:null,azimuth:pe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:pe,by:null,calcMode:null,capHeight:pe,className:ft,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:pe,diffuseConstant:pe,direction:null,display:null,dur:null,divisor:pe,dominantBaseline:null,download:$e,dx:null,dy:null,edgeMode:null,editable:null,elevation:pe,enableBackground:null,end:null,event:null,exponent:pe,externalResourcesRequired:null,fill:null,fillOpacity:pe,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:mu,g2:mu,glyphName:mu,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:pe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:pe,horizOriginX:pe,horizOriginY:pe,id:null,ideographic:pe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:pe,k:pe,k1:pe,k2:pe,k3:pe,k4:pe,kernelMatrix:Fn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:pe,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:pe,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:pe,overlineThickness:pe,paintOrder:null,panose1:null,path:null,pathLength:pe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ft,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:pe,pointsAtY:pe,pointsAtZ:pe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Fn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Fn,rev:Fn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Fn,requiredFeatures:Fn,requiredFonts:Fn,requiredFormats:Fn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:pe,specularExponent:pe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:pe,strikethroughThickness:pe,string:null,stroke:null,strokeDashArray:Fn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:pe,strokeOpacity:pe,strokeWidth:null,style:null,surfaceScale:pe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Fn,tabIndex:pe,tableValues:null,target:null,targetX:pe,targetY:pe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Fn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:pe,underlineThickness:pe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:pe,values:null,vAlphabetic:pe,vMathematical:pe,vectorEffect:null,vHanging:pe,vIdeographic:pe,version:null,vertAdvY:pe,vertOriginX:pe,vertOriginY:pe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:pe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:VY}),$Y=rd({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),UY=rd({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:BY}),WY=rd({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),mme={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},kme=/[A-Z]/g,tV=/-[a-z]/g,gme=/^data[-\w.:]+$/i;function xme(e,t){const n=VN(t);let r=t,o=Rn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&gme.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(tV,wme);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!tV.test(i)){let a=i.replace(kme,vme);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}o=nH}return new o(r,t)}function vme(e){return"-"+e.toLowerCase()}function wme(e){return e.charAt(1).toUpperCase()}const Mme=OY([qY,pme,$Y,UY,WY],"html"),rH=OY([qY,yme,$Y,UY,WY],"svg");function bme(e){return e.join(" ").trim()}var oH={},nV=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Cme=/\n/g,Sme=/^\s*/,Lme=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Ime=/^:\s*/,Eme=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,Ame=/^[;\s]*/,Pme=/^\s+|\s+$/g,Rme=`
|
|
7808
7808
|
`,rV="/",oV="*",Dc="",zme="comment",jme="declaration";function Tme(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function o(k){var v=k.match(Cme);v&&(n+=v.length);var w=k.lastIndexOf(Rme);r=~w?k.length-w:r+k.length}function i(){var k={line:n,column:r};return function(v){return v.position=new a(k),c(),v}}function a(k){this.start=k,this.end={line:n,column:r},this.source=t.source}a.prototype.content=e;function s(k){var v=new Error(t.source+":"+n+":"+r+": "+k);if(v.reason=k,v.filename=t.source,v.line=n,v.column=r,v.source=e,!t.silent)throw v}function l(k){var v=k.exec(e);if(v){var w=v[0];return o(w),e=e.slice(w.length),v}}function c(){l(Sme)}function h(k){var v;for(k=k||[];v=d();)v!==!1&&k.push(v);return k}function d(){var k=i();if(!(rV!=e.charAt(0)||oV!=e.charAt(1))){for(var v=2;Dc!=e.charAt(v)&&(oV!=e.charAt(v)||rV!=e.charAt(v+1));)++v;if(v+=2,Dc===e.charAt(v-1))return s("End of comment missing");var w=e.slice(2,v-2);return r+=2,o(w),e=e.slice(v),r+=2,k({type:zme,comment:w})}}function f(){var k=i(),v=l(Lme);if(v){if(d(),!l(Ime))return s("property missing ':'");var w=l(Eme),g=k({type:jme,property:iV(v[0].replace(nV,Dc)),value:w?iV(w[0].replace(nV,Dc)):Dc});return l(Ame),g}}function p(){var k=[];h(k);for(var v;v=f();)v!==!1&&(k.push(v),h(k));return k}return c(),p()}function iV(e){return e?e.replace(Pme,Dc):Dc}var Nme=Tme,Dme=LP&&LP.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(oH,"__esModule",{value:!0});oH.default=Hme;const _me=Dme(Nme);function Hme(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,_me.default)(e),o=typeof t=="function";return r.forEach(i=>{if(i.type!=="declaration")return;const{property:a,value:s}=i;o?t(a,s,i):s&&(n=n||{},n[a]=s)}),n}var Ez={};Object.defineProperty(Ez,"__esModule",{value:!0});Ez.camelCase=void 0;var Fme=/^--[a-zA-Z0-9_-]+$/,Ome=/-([a-z])/g,qme=/^[^-]+$/,Vme=/^-(webkit|moz|ms|o|khtml)-/,Bme=/^-(ms)-/,$me=function(e){return!e||qme.test(e)||Fme.test(e)},Ume=function(e,t){return t.toUpperCase()},aV=function(e,t){return"".concat(t,"-")},Wme=function(e,t){return t===void 0&&(t={}),$me(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(Bme,aV):e=e.replace(Vme,aV),e.replace(Ome,Ume))};Ez.camelCase=Wme;var Gme=LP&&LP.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},Zme=Gme(oH),Kme=Ez;function UN(e,t){var n={};return!e||typeof e!="string"||(0,Zme.default)(e,function(r,o){r&&o&&(n[(0,Kme.camelCase)(r,t)]=o)}),n}UN.default=UN;var Xme=UN;const Yme=uh(Xme),GY=ZY("end"),iH=ZY("start");function ZY(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Qme(e){const t=iH(e),n=GY(e);if(t&&n)return{start:t,end:n}}function I2(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?sV(e.position):"start"in e||"end"in e?sV(e):"line"in e||"column"in e?WN(e):""}function WN(e){return lV(e&&e.line)+":"+lV(e&&e.column)}function sV(e){return WN(e&&e.start)+"-"+WN(e&&e.end)}function lV(e){return e&&typeof e=="number"?e:1}class on extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let o="",i={},a=!1;if(n&&("line"in n&&"column"in n?i={place:n}:"start"in n&&"end"in n?i={place:n}:"type"in n?i={ancestors:[n],place:n.position}:i={...n}),typeof t=="string"?o=t:!i.cause&&t&&(a=!0,o=t.message,i.cause=t),!i.ruleId&&!i.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?i.ruleId=r:(i.source=r.slice(0,l),i.ruleId=r.slice(l+1))}if(!i.place&&i.ancestors&&i.ancestors){const l=i.ancestors[i.ancestors.length-1];l&&(i.place=l.position)}const s=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=s?s.line:void 0,this.name=I2(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}on.prototype.file="";on.prototype.name="";on.prototype.reason="";on.prototype.message="";on.prototype.stack="";on.prototype.column=void 0;on.prototype.line=void 0;on.prototype.ancestors=void 0;on.prototype.cause=void 0;on.prototype.fatal=void 0;on.prototype.place=void 0;on.prototype.ruleId=void 0;on.prototype.source=void 0;const aH={}.hasOwnProperty,Jme=new Map,eke=/[A-Z]/g,tke=new Set(["table","tbody","thead","tfoot","tr"]),nke=new Set(["td","th"]),KY="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function rke(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=dke(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=uke(n,t.jsx,t.jsxs)}const o={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?rH:Mme,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=XY(o,e,void 0);return i&&typeof i!="string"?i:o.create(e,o.Fragment,{children:i||void 0},void 0)}function XY(e,t,n){if(t.type==="element")return oke(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return ike(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return ske(e,t,n);if(t.type==="mdxjsEsm")return ake(e,t);if(t.type==="root")return lke(e,t,n);if(t.type==="text")return cke(e,t)}function oke(e,t,n){const r=e.schema;let o=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(o=rH,e.schema=o),e.ancestors.push(t);const i=QY(e,t.tagName,!1),a=hke(e,t);let s=lH(e,t);return tke.has(t.tagName)&&(s=s.filter(function(l){return typeof l=="string"?!hme(l):!0})),YY(e,a,i,t),sH(a,s),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function ike(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}lh(e,t.position)}function ake(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);lh(e,t.position)}function ske(e,t,n){const r=e.schema;let o=r;t.name==="svg"&&r.space==="html"&&(o=rH,e.schema=o),e.ancestors.push(t);const i=t.name===null?e.Fragment:QY(e,t.name,!0),a=fke(e,t),s=lH(e,t);return YY(e,a,i,t),sH(a,s),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function lke(e,t,n){const r={};return sH(r,lH(e,t)),e.create(t,e.Fragment,r,n)}function cke(e,t){return t.value}function YY(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function sH(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function uke(e,t,n){return r;function r(o,i,a,s){const c=Array.isArray(a.children)?n:t;return s?c(i,a,s):c(i,a)}}function dke(e,t){return n;function n(r,o,i,a){const s=Array.isArray(i.children),l=iH(r);return t(o,i,a,s,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function hke(e,t){const n={};let r,o;for(o in t.properties)if(o!=="children"&&aH.call(t.properties,o)){const i=pke(e,o,t.properties[o]);if(i){const[a,s]=i;e.tableCellAlignToStyle&&a==="align"&&typeof s=="string"&&nke.has(t.tagName)?r=s:n[a]=s}}if(r){const i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function fke(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const i=r.data.estree.body[0];i.type;const a=i.expression;a.type;const s=a.properties[0];s.type,Object.assign(n,e.evaluater.evaluateExpression(s.argument))}else lh(e,t.position);else{const o=r.name;let i;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const s=r.value.data.estree.body[0];s.type,i=e.evaluater.evaluateExpression(s.expression)}else lh(e,t.position);else i=r.value===null?!0:r.value;n[o]=i}return n}function lH(e,t){const n=[];let r=-1;const o=e.passKeys?new Map:Jme;for(;++r<t.children.length;){const i=t.children[r];let a;if(e.passKeys){const l=i.type==="element"?i.tagName:i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement"?i.name:void 0;if(l){const c=o.get(l)||0;a=l+"-"+c,o.set(l,c+1)}}const s=XY(e,i,a);s!==void 0&&n.push(s)}return n}function pke(e,t,n){const r=xme(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?sme(n):bme(n)),r.property==="style"){let o=typeof n=="object"?n:yke(e,String(n));return e.stylePropertyNameCase==="css"&&(o=mke(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&r.space?mme[r.property]||r.property:r.attribute,n]}}function yke(e,t){try{return Yme(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,o=new on("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=e.filePath||void 0,o.url=KY+"#cannot-parse-style-attribute",o}}function QY(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const o=t.split(".");let i=-1,a;for(;++i<o.length;){const s=Qq(o[i])?{type:"Identifier",name:o[i]}:{type:"Literal",value:o[i]};a=a?{type:"MemberExpression",object:a,property:s,computed:!!(i&&s.type==="Literal"),optional:!1}:s}r=a}else r=Qq(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const o=r.value;return aH.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(r);lh(e)}function lh(e,t){const n=new on("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=KY+"#cannot-handle-mdx-estrees-without-createevaluater",n}function mke(e){const t={};let n;for(n in e)aH.call(e,n)&&(t[kke(n)]=e[n]);return t}function kke(e){let t=e.replace(eke,gke);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function gke(e){return"-"+e.toLowerCase()}const Bj={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},xke={};function cH(e,t){const n=xke,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,o=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return JY(e,r,o)}function JY(e,t,n){if(vke(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return cV(e.children,t,n)}return Array.isArray(e)?cV(e,t,n):""}function cV(e,t,n){const r=[];let o=-1;for(;++o<e.length;)r[o]=JY(e[o],t,n);return r.join("")}function vke(e){return!!(e&&typeof e=="object")}const uV=document.createElement("i");function uH(e){const t="&"+e+";";uV.innerHTML=t;const n=uV.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Gn(e,t,n,r){const o=e.length;let i=0,a;if(t<0?t=-t>o?0:o+t:t=t>o?o:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);i<r.length;)a=r.slice(i,i+1e4),a.unshift(t,0),e.splice(...a),i+=1e4,t+=1e4}function sr(e,t){return e.length>0?(Gn(e,e.length,0,t),e):t}const dV={}.hasOwnProperty;function eQ(e){const t={};let n=-1;for(;++n<e.length;)wke(t,e[n]);return t}function wke(e,t){let n;for(n in t){const o=(dV.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let a;if(i)for(a in i){dV.call(o,a)||(o[a]=[]);const s=i[a];Mke(o[a],Array.isArray(s)?s:s?[s]:[])}}}function Mke(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Gn(e,0,0,r)}function tQ(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Pr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const cn=Zi(/[A-Za-z]/),tn=Zi(/[\dA-Za-z]/),bke=Zi(/[#-'*+\--9=?A-Z^-~]/);function xR(e){return e!==null&&(e<32||e===127)}const GN=Zi(/\d/),Cke=Zi(/[\dA-Fa-f]/),Ske=Zi(/[!-/:-@[-`{-~]/);function je(e){return e!==null&&e<-2}function ut(e){return e!==null&&(e<0||e===32)}function Ge(e){return e===-2||e===-1||e===32}const Az=Zi(new RegExp("\\p{P}|\\p{S}","u")),i1=Zi(/\s/);function Zi(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function od(e){const t=[];let n=-1,r=0,o=0;for(;++n<e.length;){const i=e.charCodeAt(n);let a="";if(i===37&&tn(e.charCodeAt(n+1))&&tn(e.charCodeAt(n+2)))o=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(a=String.fromCharCode(i));else if(i>55295&&i<57344){const s=e.charCodeAt(n+1);i<56320&&s>56319&&s<57344?(a=String.fromCharCode(i,s),o=1):a="�"}else a=String.fromCharCode(i);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+o+1,a=""),o&&(n+=o,o=0)}return t.join("")+e.slice(r)}function Xe(e,t,n,r){const o=r?r-1:Number.POSITIVE_INFINITY;let i=0;return a;function a(l){return Ge(l)?(e.enter(n),s(l)):t(l)}function s(l){return Ge(l)&&i++<o?(e.consume(l),s):(e.exit(n),t(l))}}const Lke={tokenize:Ike};function Ike(e){const t=e.attempt(this.parser.constructs.contentInitial,r,o);let n;return t;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),Xe(e,t,"linePrefix")}function o(s){return e.enter("paragraph"),i(s)}function i(s){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,a(s)}function a(s){if(s===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(s);return}return je(s)?(e.consume(s),e.exit("chunkText"),i):(e.consume(s),a)}}const Eke={tokenize:Ake},hV={tokenize:Pke};function Ake(e){const t=this,n=[];let r=0,o,i,a;return s;function s(x){if(r<n.length){const b=n[r];return t.containerState=b[1],e.attempt(b[0].continuation,l,c)(x)}return c(x)}function l(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&M();const b=t.events.length;let S=b,C;for(;S--;)if(t.events[S][0]==="exit"&&t.events[S][1].type==="chunkFlow"){C=t.events[S][1].end;break}g(r);let L=b;for(;L<t.events.length;)t.events[L][1].end={...C},L++;return Gn(t.events,S+1,0,t.events.slice(b)),t.events.length=L,c(x)}return s(x)}function c(x){if(r===n.length){if(!o)return f(x);if(o.currentConstruct&&o.currentConstruct.concrete)return k(x);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(hV,h,d)(x)}function h(x){return o&&M(),g(r),f(x)}function d(x){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,k(x)}function f(x){return t.containerState={},e.attempt(hV,p,k)(x)}function p(x){return r++,n.push([t.currentConstruct,t.containerState]),f(x)}function k(x){if(x===null){o&&M(),g(0),e.consume(x);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:i}),v(x)}function v(x){if(x===null){w(e.exit("chunkFlow"),!0),g(0),e.consume(x);return}return je(x)?(e.consume(x),w(e.exit("chunkFlow")),r=0,t.interrupt=void 0,s):(e.consume(x),v)}function w(x,b){const S=t.sliceStream(x);if(b&&S.push(null),x.previous=i,i&&(i.next=x),i=x,o.defineSkip(x.start),o.write(S),t.parser.lazy[x.start.line]){let C=o.events.length;for(;C--;)if(o.events[C][1].start.offset<a&&(!o.events[C][1].end||o.events[C][1].end.offset>a))return;const L=t.events.length;let P=L,T,E;for(;P--;)if(t.events[P][0]==="exit"&&t.events[P][1].type==="chunkFlow"){if(T){E=t.events[P][1].end;break}T=!0}for(g(r),C=L;C<t.events.length;)t.events[C][1].end={...E},C++;Gn(t.events,P+1,0,t.events.slice(L)),t.events.length=C}}function g(x){let b=n.length;for(;b-- >x;){const S=n[b];t.containerState=S[1],S[0].exit.call(t,e)}n.length=x}function M(){o.write([null]),i=void 0,o=void 0,t.containerState._closeFlow=void 0}}function Pke(e,t,n){return Xe(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ou(e){if(e===null||ut(e)||i1(e))return 1;if(Az(e))return 2}function Pz(e,t,n){const r=[];let o=-1;for(;++o<e.length;){const i=e[o].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}const ZN={name:"attention",resolveAll:Rke,tokenize:zke};function Rke(e,t){let n=-1,r,o,i,a,s,l,c,h;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const d={...e[r][1].end},f={...e[n][1].start};fV(d,-l),fV(f,l),a={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},s={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:f},i={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},o={type:l>1?"strong":"emphasis",start:{...a.start},end:{...s.end}},e[r][1].end={...a.start},e[n][1].start={...s.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=sr(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=sr(c,[["enter",o,t],["enter",a,t],["exit",a,t],["enter",i,t]]),c=sr(c,Pz(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=sr(c,[["exit",i,t],["enter",s,t],["exit",s,t],["exit",o,t]]),e[n][1].end.offset-e[n][1].start.offset?(h=2,c=sr(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):h=0,Gn(e,r-1,n-r+3,c),n=r+c.length-h-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function zke(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=Ou(r);let i;return a;function a(l){return i=l,e.enter("attentionSequence"),s(l)}function s(l){if(l===i)return e.consume(l),s;const c=e.exit("attentionSequence"),h=Ou(l),d=!h||h===2&&o||n.includes(l),f=!o||o===2&&h||n.includes(r);return c._open=!!(i===42?d:d&&(o||!f)),c._close=!!(i===42?f:f&&(h||!d)),t(l)}}function fV(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const jke={name:"autolink",tokenize:Tke};function Tke(e,t,n){let r=0;return o;function o(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(p){return cn(p)?(e.consume(p),a):p===64?n(p):c(p)}function a(p){return p===43||p===45||p===46||tn(p)?(r=1,s(p)):c(p)}function s(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||tn(p))&&r++<32?(e.consume(p),s):(r=0,c(p))}function l(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||xR(p)?n(p):(e.consume(p),l)}function c(p){return p===64?(e.consume(p),h):bke(p)?(e.consume(p),c):n(p)}function h(p){return tn(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,h):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):f(p)}function f(p){if((p===45||tn(p))&&r++<63){const k=p===45?f:d;return e.consume(p),k}return n(p)}}const Gh={partial:!0,tokenize:Nke};function Nke(e,t,n){return r;function r(i){return Ge(i)?Xe(e,o,"linePrefix")(i):o(i)}function o(i){return i===null||je(i)?t(i):n(i)}}const nQ={continuation:{tokenize:_ke},exit:Hke,name:"blockQuote",tokenize:Dke};function Dke(e,t,n){const r=this;return o;function o(a){if(a===62){const s=r.containerState;return s.open||(e.enter("blockQuote",{_container:!0}),s.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),i}return n(a)}function i(a){return Ge(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function _ke(e,t,n){const r=this;return o;function o(a){return Ge(a)?Xe(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):i(a)}function i(a){return e.attempt(nQ,t,n)(a)}}function Hke(e){e.exit("blockQuote")}const rQ={name:"characterEscape",tokenize:Fke};function Fke(e,t,n){return r;function r(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),o}function o(i){return Ske(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const oQ={name:"characterReference",tokenize:Oke};function Oke(e,t,n){const r=this;let o=0,i,a;return s;function s(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),l}function l(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),i=31,a=tn,h(d))}function c(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,a=Cke,h):(e.enter("characterReferenceValue"),i=7,a=GN,h(d))}function h(d){if(d===59&&o){const f=e.exit("characterReferenceValue");return a===tn&&!uH(r.sliceSerialize(f))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(d)&&o++<i?(e.consume(d),h):n(d)}}const pV={partial:!0,tokenize:Vke},yV={concrete:!0,name:"codeFenced",tokenize:qke};function qke(e,t,n){const r=this,o={partial:!0,tokenize:S};let i=0,a=0,s;return l;function l(C){return c(C)}function c(C){const L=r.events[r.events.length-1];return i=L&&L[1].type==="linePrefix"?L[2].sliceSerialize(L[1],!0).length:0,s=C,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),h(C)}function h(C){return C===s?(a++,e.consume(C),h):a<3?n(C):(e.exit("codeFencedFenceSequence"),Ge(C)?Xe(e,d,"whitespace")(C):d(C))}function d(C){return C===null||je(C)?(e.exit("codeFencedFence"),r.interrupt?t(C):e.check(pV,v,b)(C)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(C))}function f(C){return C===null||je(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(C)):Ge(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Xe(e,p,"whitespace")(C)):C===96&&C===s?n(C):(e.consume(C),f)}function p(C){return C===null||je(C)?d(C):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),k(C))}function k(C){return C===null||je(C)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(C)):C===96&&C===s?n(C):(e.consume(C),k)}function v(C){return e.attempt(o,b,w)(C)}function w(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),g}function g(C){return i>0&&Ge(C)?Xe(e,M,"linePrefix",i+1)(C):M(C)}function M(C){return C===null||je(C)?e.check(pV,v,b)(C):(e.enter("codeFlowValue"),x(C))}function x(C){return C===null||je(C)?(e.exit("codeFlowValue"),M(C)):(e.consume(C),x)}function b(C){return e.exit("codeFenced"),t(C)}function S(C,L,P){let T=0;return E;function E(V){return C.enter("lineEnding"),C.consume(V),C.exit("lineEnding"),z}function z(V){return C.enter("codeFencedFence"),Ge(V)?Xe(C,A,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(V):A(V)}function A(V){return V===s?(C.enter("codeFencedFenceSequence"),U(V)):P(V)}function U(V){return V===s?(T++,C.consume(V),U):T>=a?(C.exit("codeFencedFenceSequence"),Ge(V)?Xe(C,R,"whitespace")(V):R(V)):P(V)}function R(V){return V===null||je(V)?(C.exit("codeFencedFence"),L(V)):P(V)}}}function Vke(e,t,n){const r=this;return o;function o(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const $j={name:"codeIndented",tokenize:$ke},Bke={partial:!0,tokenize:Uke};function $ke(e,t,n){const r=this;return o;function o(c){return e.enter("codeIndented"),Xe(e,i,"linePrefix",5)(c)}function i(c){const h=r.events[r.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?a(c):n(c)}function a(c){return c===null?l(c):je(c)?e.attempt(Bke,a,l)(c):(e.enter("codeFlowValue"),s(c))}function s(c){return c===null||je(c)?(e.exit("codeFlowValue"),a(c)):(e.consume(c),s)}function l(c){return e.exit("codeIndented"),t(c)}}function Uke(e,t,n){const r=this;return o;function o(a){return r.parser.lazy[r.now().line]?n(a):je(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o):Xe(e,i,"linePrefix",5)(a)}function i(a){const s=r.events[r.events.length-1];return s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?t(a):je(a)?o(a):n(a)}}const Wke={name:"codeText",previous:Zke,resolve:Gke,tokenize:Kke};function Gke(e){let t=e.length-4,n=3,r,o;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)o===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(o=r):(r===t||e[r][1].type==="lineEnding")&&(e[o][1].type="codeTextData",r!==o+2&&(e[o][1].end=e[r-1][1].end,e.splice(o+2,r-o-2),t-=r-o-2,r=o+2),o=void 0);return e}function Zke(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Kke(e,t,n){let r=0,o,i;return a;function a(d){return e.enter("codeText"),e.enter("codeTextSequence"),s(d)}function s(d){return d===96?(e.consume(d),r++,s):(e.exit("codeTextSequence"),l(d))}function l(d){return d===null?n(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),l):d===96?(i=e.enter("codeTextSequence"),o=0,h(d)):je(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),l):(e.enter("codeTextData"),c(d))}function c(d){return d===null||d===32||d===96||je(d)?(e.exit("codeTextData"),l(d)):(e.consume(d),c)}function h(d){return d===96?(e.consume(d),o++,h):o===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(d)):(i.type="codeTextData",c(d))}}class Xke{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const o=n||0;this.setCursor(Math.trunc(t));const i=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return r&&Ld(this.left,r),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Ld(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Ld(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Ld(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Ld(this.left,n.reverse())}}}function Ld(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function iQ(e){const t={};let n=-1,r,o,i,a,s,l,c;const h=new Xke(e);for(;++n<h.length;){for(;n in t;)n=t[n];if(r=h.get(n),n&&r[1].type==="chunkFlow"&&h.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,i=0,i<l.length&&l[i][1].type==="lineEndingBlank"&&(i+=2),i<l.length&&l[i][1].type==="content"))for(;++i<l.length&&l[i][1].type!=="content";)l[i][1].type==="chunkText"&&(l[i][1]._isInFirstContentOfListItem=!0,i++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,Yke(h,n)),n=t[n],c=!0);else if(r[1]._container){for(i=n,o=void 0;i--;)if(a=h.get(i),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(o&&(h.get(o)[1].type="lineEndingBlank"),a[1].type="lineEnding",o=i);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;o&&(r[1].end={...h.get(o)[1].start},s=h.slice(o,n),s.unshift(r),h.splice(o,n-o+1,s))}}return Gn(e,0,Number.POSITIVE_INFINITY,h.slice(0)),!c}function Yke(e,t){const n=e.get(t)[1],r=e.get(t)[2];let o=t-1;const i=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const s=a.events,l=[],c={};let h,d,f=-1,p=n,k=0,v=0;const w=[v];for(;p;){for(;e.get(++o)[1]!==p;);i.push(o),p._tokenizer||(h=r.sliceStream(p),p.next||h.push(null),d&&a.defineSkip(p.start),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(h),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]==="exit"&&s[f-1][0]==="enter"&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(v=f+1,w.push(v),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(a.events=[],p?(p._tokenizer=void 0,p.previous=void 0):w.pop(),f=w.length;f--;){const g=s.slice(w[f],w[f+1]),M=i.pop();l.push([M,M+g.length-1]),e.splice(M,2,g)}for(l.reverse(),f=-1;++f<l.length;)c[k+l[f][0]]=k+l[f][1],k+=l[f][1]-l[f][0]-1;return c}const Qke={resolve:ege,tokenize:tge},Jke={partial:!0,tokenize:nge};function ege(e){return iQ(e),e}function tge(e,t){let n;return r;function r(s){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),o(s)}function o(s){return s===null?i(s):je(s)?e.check(Jke,a,i)(s):(e.consume(s),o)}function i(s){return e.exit("chunkContent"),e.exit("content"),t(s)}function a(s){return e.consume(s),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,o}}function nge(e,t,n){const r=this;return o;function o(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Xe(e,i,"linePrefix")}function i(a){if(a===null||je(a))return n(a);const s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function aQ(e,t,n,r,o,i,a,s,l){const c=l||Number.POSITIVE_INFINITY;let h=0;return d;function d(g){return g===60?(e.enter(r),e.enter(o),e.enter(i),e.consume(g),e.exit(i),f):g===null||g===32||g===41||xR(g)?n(g):(e.enter(r),e.enter(a),e.enter(s),e.enter("chunkString",{contentType:"string"}),v(g))}function f(g){return g===62?(e.enter(i),e.consume(g),e.exit(i),e.exit(o),e.exit(r),t):(e.enter(s),e.enter("chunkString",{contentType:"string"}),p(g))}function p(g){return g===62?(e.exit("chunkString"),e.exit(s),f(g)):g===null||g===60||je(g)?n(g):(e.consume(g),g===92?k:p)}function k(g){return g===60||g===62||g===92?(e.consume(g),p):p(g)}function v(g){return!h&&(g===null||g===41||ut(g))?(e.exit("chunkString"),e.exit(s),e.exit(a),e.exit(r),t(g)):h<c&&g===40?(e.consume(g),h++,v):g===41?(e.consume(g),h--,v):g===null||g===32||g===40||xR(g)?n(g):(e.consume(g),g===92?w:v)}function w(g){return g===40||g===41||g===92?(e.consume(g),v):v(g)}}function sQ(e,t,n,r,o,i){const a=this;let s=0,l;return c;function c(p){return e.enter(r),e.enter(o),e.consume(p),e.exit(o),e.enter(i),h}function h(p){return s>999||p===null||p===91||p===93&&!l||p===94&&!s&&"_hiddenFootnoteSupport"in a.parser.constructs?n(p):p===93?(e.exit(i),e.enter(o),e.consume(p),e.exit(o),e.exit(r),t):je(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),h):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||je(p)||s++>999?(e.exit("chunkString"),h(p)):(e.consume(p),l||(l=!Ge(p)),p===92?f:d)}function f(p){return p===91||p===92||p===93?(e.consume(p),s++,d):d(p)}}function lQ(e,t,n,r,o,i){let a;return s;function s(f){return f===34||f===39||f===40?(e.enter(r),e.enter(o),e.consume(f),e.exit(o),a=f===40?41:f,l):n(f)}function l(f){return f===a?(e.enter(o),e.consume(f),e.exit(o),e.exit(r),t):(e.enter(i),c(f))}function c(f){return f===a?(e.exit(i),l(a)):f===null?n(f):je(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),Xe(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),h(f))}function h(f){return f===a||f===null||je(f)?(e.exit("chunkString"),c(f)):(e.consume(f),f===92?d:h)}function d(f){return f===a||f===92?(e.consume(f),h):h(f)}}function E2(e,t){let n;return r;function r(o){return je(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,r):Ge(o)?Xe(e,r,n?"linePrefix":"lineSuffix")(o):t(o)}}const rge={name:"definition",tokenize:ige},oge={partial:!0,tokenize:age};function ige(e,t,n){const r=this;let o;return i;function i(p){return e.enter("definition"),a(p)}function a(p){return sQ.call(r,e,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function s(p){return o=Pr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):n(p)}function l(p){return ut(p)?E2(e,c)(p):c(p)}function c(p){return aQ(e,h,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function h(p){return e.attempt(oge,d,d)(p)}function d(p){return Ge(p)?Xe(e,f,"whitespace")(p):f(p)}function f(p){return p===null||je(p)?(e.exit("definition"),r.parser.defined.push(o),t(p)):n(p)}}function age(e,t,n){return r;function r(s){return ut(s)?E2(e,o)(s):n(s)}function o(s){return lQ(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(s)}function i(s){return Ge(s)?Xe(e,a,"whitespace")(s):a(s)}function a(s){return s===null||je(s)?t(s):n(s)}}const sge={name:"hardBreakEscape",tokenize:lge};function lge(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),o}function o(i){return je(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const cge={name:"headingAtx",resolve:uge,tokenize:dge};function uge(e,t){let n=e.length-2,r=3,o,i;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(o={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},i={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Gn(e,r,n-r+1,[["enter",o,t],["enter",i,t],["exit",i,t],["exit",o,t]])),e}function dge(e,t,n){let r=0;return o;function o(h){return e.enter("atxHeading"),i(h)}function i(h){return e.enter("atxHeadingSequence"),a(h)}function a(h){return h===35&&r++<6?(e.consume(h),a):h===null||ut(h)?(e.exit("atxHeadingSequence"),s(h)):n(h)}function s(h){return h===35?(e.enter("atxHeadingSequence"),l(h)):h===null||je(h)?(e.exit("atxHeading"),t(h)):Ge(h)?Xe(e,s,"whitespace")(h):(e.enter("atxHeadingText"),c(h))}function l(h){return h===35?(e.consume(h),l):(e.exit("atxHeadingSequence"),s(h))}function c(h){return h===null||h===35||ut(h)?(e.exit("atxHeadingText"),s(h)):(e.consume(h),c)}}const hge=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],mV=["pre","script","style","textarea"],fge={concrete:!0,name:"htmlFlow",resolveTo:mge,tokenize:kge},pge={partial:!0,tokenize:xge},yge={partial:!0,tokenize:gge};function mge(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function kge(e,t,n){const r=this;let o,i,a,s,l;return c;function c(j){return h(j)}function h(j){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(j),d}function d(j){return j===33?(e.consume(j),f):j===47?(e.consume(j),i=!0,v):j===63?(e.consume(j),o=3,r.interrupt?t:I):cn(j)?(e.consume(j),a=String.fromCharCode(j),w):n(j)}function f(j){return j===45?(e.consume(j),o=2,p):j===91?(e.consume(j),o=5,s=0,k):cn(j)?(e.consume(j),o=4,r.interrupt?t:I):n(j)}function p(j){return j===45?(e.consume(j),r.interrupt?t:I):n(j)}function k(j){const G="CDATA[";return j===G.charCodeAt(s++)?(e.consume(j),s===G.length?r.interrupt?t:A:k):n(j)}function v(j){return cn(j)?(e.consume(j),a=String.fromCharCode(j),w):n(j)}function w(j){if(j===null||j===47||j===62||ut(j)){const G=j===47,X=a.toLowerCase();return!G&&!i&&mV.includes(X)?(o=1,r.interrupt?t(j):A(j)):hge.includes(a.toLowerCase())?(o=6,G?(e.consume(j),g):r.interrupt?t(j):A(j)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(j):i?M(j):x(j))}return j===45||tn(j)?(e.consume(j),a+=String.fromCharCode(j),w):n(j)}function g(j){return j===62?(e.consume(j),r.interrupt?t:A):n(j)}function M(j){return Ge(j)?(e.consume(j),M):E(j)}function x(j){return j===47?(e.consume(j),E):j===58||j===95||cn(j)?(e.consume(j),b):Ge(j)?(e.consume(j),x):E(j)}function b(j){return j===45||j===46||j===58||j===95||tn(j)?(e.consume(j),b):S(j)}function S(j){return j===61?(e.consume(j),C):Ge(j)?(e.consume(j),S):x(j)}function C(j){return j===null||j===60||j===61||j===62||j===96?n(j):j===34||j===39?(e.consume(j),l=j,L):Ge(j)?(e.consume(j),C):P(j)}function L(j){return j===l?(e.consume(j),l=null,T):j===null||je(j)?n(j):(e.consume(j),L)}function P(j){return j===null||j===34||j===39||j===47||j===60||j===61||j===62||j===96||ut(j)?S(j):(e.consume(j),P)}function T(j){return j===47||j===62||Ge(j)?x(j):n(j)}function E(j){return j===62?(e.consume(j),z):n(j)}function z(j){return j===null||je(j)?A(j):Ge(j)?(e.consume(j),z):n(j)}function A(j){return j===45&&o===2?(e.consume(j),O):j===60&&o===1?(e.consume(j),B):j===62&&o===4?(e.consume(j),W):j===63&&o===3?(e.consume(j),I):j===93&&o===5?(e.consume(j),N):je(j)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(pge,H,U)(j)):j===null||je(j)?(e.exit("htmlFlowData"),U(j)):(e.consume(j),A)}function U(j){return e.check(yge,R,H)(j)}function R(j){return e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),V}function V(j){return j===null||je(j)?U(j):(e.enter("htmlFlowData"),A(j))}function O(j){return j===45?(e.consume(j),I):A(j)}function B(j){return j===47?(e.consume(j),a="",D):A(j)}function D(j){if(j===62){const G=a.toLowerCase();return mV.includes(G)?(e.consume(j),W):A(j)}return cn(j)&&a.length<8?(e.consume(j),a+=String.fromCharCode(j),D):A(j)}function N(j){return j===93?(e.consume(j),I):A(j)}function I(j){return j===62?(e.consume(j),W):j===45&&o===2?(e.consume(j),I):A(j)}function W(j){return j===null||je(j)?(e.exit("htmlFlowData"),H(j)):(e.consume(j),W)}function H(j){return e.exit("htmlFlow"),t(j)}}function gge(e,t,n){const r=this;return o;function o(a){return je(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):n(a)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function xge(e,t,n){return r;function r(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(Gh,t,n)}}const vge={name:"htmlText",tokenize:wge};function wge(e,t,n){const r=this;let o,i,a;return s;function s(I){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(I),l}function l(I){return I===33?(e.consume(I),c):I===47?(e.consume(I),S):I===63?(e.consume(I),x):cn(I)?(e.consume(I),P):n(I)}function c(I){return I===45?(e.consume(I),h):I===91?(e.consume(I),i=0,k):cn(I)?(e.consume(I),M):n(I)}function h(I){return I===45?(e.consume(I),p):n(I)}function d(I){return I===null?n(I):I===45?(e.consume(I),f):je(I)?(a=d,B(I)):(e.consume(I),d)}function f(I){return I===45?(e.consume(I),p):d(I)}function p(I){return I===62?O(I):I===45?f(I):d(I)}function k(I){const W="CDATA[";return I===W.charCodeAt(i++)?(e.consume(I),i===W.length?v:k):n(I)}function v(I){return I===null?n(I):I===93?(e.consume(I),w):je(I)?(a=v,B(I)):(e.consume(I),v)}function w(I){return I===93?(e.consume(I),g):v(I)}function g(I){return I===62?O(I):I===93?(e.consume(I),g):v(I)}function M(I){return I===null||I===62?O(I):je(I)?(a=M,B(I)):(e.consume(I),M)}function x(I){return I===null?n(I):I===63?(e.consume(I),b):je(I)?(a=x,B(I)):(e.consume(I),x)}function b(I){return I===62?O(I):x(I)}function S(I){return cn(I)?(e.consume(I),C):n(I)}function C(I){return I===45||tn(I)?(e.consume(I),C):L(I)}function L(I){return je(I)?(a=L,B(I)):Ge(I)?(e.consume(I),L):O(I)}function P(I){return I===45||tn(I)?(e.consume(I),P):I===47||I===62||ut(I)?T(I):n(I)}function T(I){return I===47?(e.consume(I),O):I===58||I===95||cn(I)?(e.consume(I),E):je(I)?(a=T,B(I)):Ge(I)?(e.consume(I),T):O(I)}function E(I){return I===45||I===46||I===58||I===95||tn(I)?(e.consume(I),E):z(I)}function z(I){return I===61?(e.consume(I),A):je(I)?(a=z,B(I)):Ge(I)?(e.consume(I),z):T(I)}function A(I){return I===null||I===60||I===61||I===62||I===96?n(I):I===34||I===39?(e.consume(I),o=I,U):je(I)?(a=A,B(I)):Ge(I)?(e.consume(I),A):(e.consume(I),R)}function U(I){return I===o?(e.consume(I),o=void 0,V):I===null?n(I):je(I)?(a=U,B(I)):(e.consume(I),U)}function R(I){return I===null||I===34||I===39||I===60||I===61||I===96?n(I):I===47||I===62||ut(I)?T(I):(e.consume(I),R)}function V(I){return I===47||I===62||ut(I)?T(I):n(I)}function O(I){return I===62?(e.consume(I),e.exit("htmlTextData"),e.exit("htmlText"),t):n(I)}function B(I){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),D}function D(I){return Ge(I)?Xe(e,N,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):N(I)}function N(I){return e.enter("htmlTextData"),a(I)}}const dH={name:"labelEnd",resolveAll:Sge,resolveTo:Lge,tokenize:Ige},Mge={tokenize:Ege},bge={tokenize:Age},Cge={tokenize:Pge};function Sge(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const o=r.type==="labelImage"?4:2;r.type="data",t+=o}}return e.length!==n.length&&Gn(e,0,e.length,n),e}function Lge(e,t){let n=e.length,r=0,o,i,a,s;for(;n--;)if(o=e[n][1],i){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[n][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(i=n,o.type!=="labelLink")){r=2;break}}else o.type==="labelEnd"&&(a=n);const l={type:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[i][1].start},end:{...e[a][1].end}},h={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return s=[["enter",l,t],["enter",c,t]],s=sr(s,e.slice(i+1,i+r+3)),s=sr(s,[["enter",h,t]]),s=sr(s,Pz(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),s=sr(s,[["exit",h,t],e[a-2],e[a-1],["exit",c,t]]),s=sr(s,e.slice(a+1)),s=sr(s,[["exit",l,t]]),Gn(e,i,e.length,s),e}function Ige(e,t,n){const r=this;let o=r.events.length,i,a;for(;o--;)if((r.events[o][1].type==="labelImage"||r.events[o][1].type==="labelLink")&&!r.events[o][1]._balanced){i=r.events[o][1];break}return s;function s(f){return i?i._inactive?d(f):(a=r.parser.defined.includes(Pr(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelEnd"),l):n(f)}function l(f){return f===40?e.attempt(Mge,h,a?h:d)(f):f===91?e.attempt(bge,h,a?c:d)(f):a?h(f):d(f)}function c(f){return e.attempt(Cge,h,d)(f)}function h(f){return t(f)}function d(f){return i._balanced=!0,n(f)}}function Ege(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),o}function o(d){return ut(d)?E2(e,i)(d):i(d)}function i(d){return d===41?h(d):aQ(e,a,s,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function a(d){return ut(d)?E2(e,l)(d):h(d)}function s(d){return n(d)}function l(d){return d===34||d===39||d===40?lQ(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):h(d)}function c(d){return ut(d)?E2(e,h)(d):h(d)}function h(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function Age(e,t,n){const r=this;return o;function o(s){return sQ.call(r,e,i,a,"reference","referenceMarker","referenceString")(s)}function i(s){return r.parser.defined.includes(Pr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function a(s){return n(s)}}function Pge(e,t,n){return r;function r(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),o}function o(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):n(i)}}const Rge={name:"labelStartImage",resolveAll:dH.resolveAll,tokenize:zge};function zge(e,t,n){const r=this;return o;function o(s){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(s),e.exit("labelImageMarker"),i}function i(s){return s===91?(e.enter("labelMarker"),e.consume(s),e.exit("labelMarker"),e.exit("labelImage"),a):n(s)}function a(s){return s===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(s):t(s)}}const jge={name:"labelStartLink",resolveAll:dH.resolveAll,tokenize:Tge};function Tge(e,t,n){const r=this;return o;function o(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),i}function i(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const Uj={name:"lineEnding",tokenize:Nge};function Nge(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Xe(e,t,"linePrefix")}}const CP={name:"thematicBreak",tokenize:Dge};function Dge(e,t,n){let r=0,o;return i;function i(c){return e.enter("thematicBreak"),a(c)}function a(c){return o=c,s(c)}function s(c){return c===o?(e.enter("thematicBreakSequence"),l(c)):r>=3&&(c===null||je(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===o?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),Ge(c)?Xe(e,s,"whitespace")(c):s(c))}}const Mn={continuation:{tokenize:Oge},exit:Vge,name:"list",tokenize:Fge},_ge={partial:!0,tokenize:Bge},Hge={partial:!0,tokenize:qge};function Fge(e,t,n){const r=this,o=r.events[r.events.length-1];let i=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,a=0;return s;function s(p){const k=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(k==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:GN(p)){if(r.containerState.type||(r.containerState.type=k,e.enter(k,{_container:!0})),k==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(CP,n,c)(p):c(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(p)}return n(p)}function l(p){return GN(p)&&++a<10?(e.consume(p),l):(!r.interrupt||a<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),c(p)):n(p)}function c(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(Gh,r.interrupt?n:h,e.attempt(_ge,f,d))}function h(p){return r.containerState.initialBlankLine=!0,i++,f(p)}function d(p){return Ge(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),f):n(p)}function f(p){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function Oge(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Gh,o,i);function o(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Xe(e,t,"listItemIndent",r.containerState.size+1)(s)}function i(s){return r.containerState.furtherBlankLines||!Ge(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Hge,t,a)(s))}function a(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,Xe(e,e.attempt(Mn,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s)}}function qge(e,t,n){const r=this;return Xe(e,o,"listItemIndent",r.containerState.size+1);function o(i){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(i):n(i)}}function Vge(e){e.exit(this.containerState.type)}function Bge(e,t,n){const r=this;return Xe(e,o,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(i){const a=r.events[r.events.length-1];return!Ge(i)&&a&&a[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const kV={name:"setextUnderline",resolveTo:$ge,tokenize:Uge};function $ge(e,t){let n=e.length,r,o,i;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(o=n)}else e[n][1].type==="content"&&e.splice(n,1),!i&&e[n][1].type==="definition"&&(i=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",i?(e.splice(o,0,["enter",a,t]),e.splice(i+1,0,["exit",e[r][1],t]),e[r][1].end={...e[i][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function Uge(e,t,n){const r=this;let o;return i;function i(c){let h=r.events.length,d;for(;h--;)if(r.events[h][1].type!=="lineEnding"&&r.events[h][1].type!=="linePrefix"&&r.events[h][1].type!=="content"){d=r.events[h][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),o=c,a(c)):n(c)}function a(c){return e.enter("setextHeadingLineSequence"),s(c)}function s(c){return c===o?(e.consume(c),s):(e.exit("setextHeadingLineSequence"),Ge(c)?Xe(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||je(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const Wge={tokenize:Gge};function Gge(e){const t=this,n=e.attempt(Gh,r,e.attempt(this.parser.constructs.flowInitial,o,Xe(e,e.attempt(this.parser.constructs.flow,o,e.attempt(Qke,o)),"linePrefix")));return n;function r(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function o(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Zge={resolveAll:uQ()},Kge=cQ("string"),Xge=cQ("text");function cQ(e){return{resolveAll:uQ(e==="text"?Yge:void 0),tokenize:t};function t(n){const r=this,o=this.parser.constructs[e],i=n.attempt(o,a,s);return a;function a(h){return c(h)?i(h):s(h)}function s(h){if(h===null){n.consume(h);return}return n.enter("data"),n.consume(h),l}function l(h){return c(h)?(n.exit("data"),i(h)):(n.consume(h),l)}function c(h){if(h===null)return!0;const d=o[h];let f=-1;if(d)for(;++f<d.length;){const p=d[f];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function uQ(e){return t;function t(n,r){let o=-1,i;for(;++o<=n.length;)i===void 0?n[o]&&n[o][1].type==="data"&&(i=o,o++):(!n[o]||n[o][1].type!=="data")&&(o!==i+2&&(n[i][1].end=n[o-1][1].end,n.splice(i+2,o-i-2),o=i+2),i=void 0);return e?e(n,r):n}}function Yge(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],o=t.sliceStream(r);let i=o.length,a=-1,s=0,l;for(;i--;){const c=o[i];if(typeof c=="string"){for(a=c.length;c.charCodeAt(a-1)===32;)s++,a--;if(a)break;a=-1}else if(c===-2)l=!0,s++;else if(c!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){const c={type:n===e.length||l||s<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?a:r.start._bufferIndex+a,_index:r.start._index+i,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}const Qge={42:Mn,43:Mn,45:Mn,48:Mn,49:Mn,50:Mn,51:Mn,52:Mn,53:Mn,54:Mn,55:Mn,56:Mn,57:Mn,62:nQ},Jge={91:rge},e4e={[-2]:$j,[-1]:$j,32:$j},t4e={35:cge,42:CP,45:[kV,CP],60:fge,61:kV,95:CP,96:yV,126:yV},n4e={38:oQ,92:rQ},r4e={[-5]:Uj,[-4]:Uj,[-3]:Uj,33:Rge,38:oQ,42:ZN,60:[jke,vge],91:jge,92:[sge,rQ],93:dH,95:ZN,96:Wke},o4e={null:[ZN,Zge]},i4e={null:[42,95]},a4e={null:[]},s4e=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:i4e,contentInitial:Jge,disable:a4e,document:Qge,flow:t4e,flowInitial:e4e,insideSpan:o4e,string:n4e,text:r4e},Symbol.toStringTag,{value:"Module"}));function l4e(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const o={},i=[];let a=[],s=[];const l={attempt:L(S),check:L(C),consume:M,enter:x,exit:b,interrupt:L(C,{interrupt:!0})},c={code:null,containerState:{},defineSkip:v,events:[],now:k,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d};let h=t.tokenize.call(c,l);return t.resolveAll&&i.push(t),c;function d(z){return a=sr(a,z),w(),a[a.length-1]!==null?[]:(P(t,0),c.events=Pz(i,c.events,c),c.events)}function f(z,A){return u4e(p(z),A)}function p(z){return c4e(a,z)}function k(){const{_bufferIndex:z,_index:A,line:U,column:R,offset:V}=r;return{_bufferIndex:z,_index:A,line:U,column:R,offset:V}}function v(z){o[z.line]=z.column,E()}function w(){let z;for(;r._index<a.length;){const A=a[r._index];if(typeof A=="string")for(z=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===z&&r._bufferIndex<A.length;)g(A.charCodeAt(r._bufferIndex));else g(A)}}function g(z){h=h(z)}function M(z){je(z)?(r.line++,r.column=1,r.offset+=z===-3?2:1,E()):z!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=z}function x(z,A){const U=A||{};return U.type=z,U.start=k(),c.events.push(["enter",U,c]),s.push(U),U}function b(z){const A=s.pop();return A.end=k(),c.events.push(["exit",A,c]),A}function S(z,A){P(z,A.from)}function C(z,A){A.restore()}function L(z,A){return U;function U(R,V,O){let B,D,N,I;return Array.isArray(R)?H(R):"tokenize"in R?H([R]):W(R);function W(Y){return re;function re(ne){const ae=ne!==null&&Y[ne],ve=ne!==null&&Y.null,be=[...Array.isArray(ae)?ae:ae?[ae]:[],...Array.isArray(ve)?ve:ve?[ve]:[]];return H(be)(ne)}}function H(Y){return B=Y,D=0,Y.length===0?O:j(Y[D])}function j(Y){return re;function re(ne){return I=T(),N=Y,Y.partial||(c.currentConstruct=Y),Y.name&&c.parser.constructs.disable.null.includes(Y.name)?X():Y.tokenize.call(A?Object.assign(Object.create(c),A):c,l,G,X)(ne)}}function G(Y){return z(N,I),V}function X(Y){return I.restore(),++D<B.length?j(B[D]):O}}}function P(z,A){z.resolveAll&&!i.includes(z)&&i.push(z),z.resolve&&Gn(c.events,A,c.events.length-A,z.resolve(c.events.slice(A),c)),z.resolveTo&&(c.events=z.resolveTo(c.events,c))}function T(){const z=k(),A=c.previous,U=c.currentConstruct,R=c.events.length,V=Array.from(s);return{from:R,restore:O};function O(){r=z,c.previous=A,c.currentConstruct=U,c.events.length=R,s=V,E()}}function E(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function c4e(e,t){const n=t.start._index,r=t.start._bufferIndex,o=t.end._index,i=t.end._bufferIndex;let a;if(n===o)a=[e[n].slice(r,i)];else{if(a=e.slice(n,o),r>-1){const s=a[0];typeof s=="string"?a[0]=s.slice(r):a.shift()}i>0&&a.push(e[o].slice(0,i))}return a}function u4e(e,t){let n=-1;const r=[];let o;for(;++n<e.length;){const i=e[n];let a;if(typeof i=="string")a=i;else switch(i){case-5:{a="\r";break}case-4:{a=`
|
|
7809
7809
|
`;break}case-3:{a=`\r
|
|
7810
7810
|
`;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&o)continue;a=" ";break}default:a=String.fromCharCode(i)}o=i===-2,r.push(a)}return r.join("")}function d4e(e){const r={constructs:eQ([s4e,...(e||{}).extensions||[]]),content:o(Lke),defined:[],document:o(Eke),flow:o(Wge),lazy:{},string:o(Kge),text:o(Xge)};return r;function o(i){return a;function a(s){return l4e(r,i,s)}}}function h4e(e){for(;!iQ(e););return e}const gV=/[\0\t\n\r]/g;function f4e(){let e=1,t="",n=!0,r;return o;function o(i,a,s){const l=[];let c,h,d,f,p;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(a||void 0).decode(i)),d=0,t="",n&&(i.charCodeAt(0)===65279&&d++,n=void 0);d<i.length;){if(gV.lastIndex=d,c=gV.exec(i),f=c&&c.index!==void 0?c.index:i.length,p=i.charCodeAt(f),!c){t=i.slice(d);break}if(p===10&&d===f&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),d<f&&(l.push(i.slice(d,f)),e+=f-d),p){case 0:{l.push(65533),e++;break}case 9:{for(h=Math.ceil(e/4)*4,l.push(-2);e++<h;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}d=f+1}return s&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const p4e=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function y4e(e){return e.replace(p4e,m4e)}function m4e(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const o=n.charCodeAt(1),i=o===120||o===88;return tQ(n.slice(i?2:1),i?16:10)}return uH(n)||e}const dQ={}.hasOwnProperty;function k4e(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),g4e(n)(h4e(d4e(n).document().write(f4e()(e,t,!0))))}function g4e(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(ht),autolinkProtocol:T,autolinkEmail:T,atxHeading:i(ke),blockQuote:i(ve),characterEscape:T,characterReference:T,codeFenced:i(be),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:i(be,a),codeText:i(me,a),codeTextData:T,data:T,codeFlowValue:T,definition:i(ge),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:i(ee),hardBreakEscape:i(Fe),hardBreakTrailing:i(Fe),htmlFlow:i(rt,a),htmlFlowData:T,htmlText:i(rt,a),htmlTextData:T,image:i(mt),label:a,link:i(ht),listItem:i(Q),listItemValue:f,listOrdered:i(le,d),listUnordered:i(le),paragraph:i(fe),reference:j,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:i(ke),strong:i(we),thematicBreak:i(Oe)},exit:{atxHeading:l(),atxHeadingSequence:S,autolink:l(),autolinkEmail:ae,autolinkProtocol:ne,blockQuote:l(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:X,characterReferenceMarkerNumeric:X,characterReferenceValue:Y,characterReference:re,codeFenced:l(w),codeFencedFence:v,codeFencedFenceInfo:p,codeFencedFenceMeta:k,codeFlowValue:E,codeIndented:l(g),codeText:l(V),codeTextData:E,data:E,definition:l(),definitionDestinationString:b,definitionLabelString:M,definitionTitleString:x,emphasis:l(),hardBreakEscape:l(A),hardBreakTrailing:l(A),htmlFlow:l(U),htmlFlowData:E,htmlText:l(R),htmlTextData:E,image:l(B),label:N,labelText:D,lineEnding:z,link:l(O),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:G,resourceDestinationString:I,resourceTitleString:W,resource:H,setextHeading:l(P),setextHeadingLineSequence:L,setextHeadingText:C,strong:l(),thematicBreak:l()}};hQ(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(te){let de={type:"root",children:[]};const Pe={stack:[de],tokenStack:[],config:t,enter:s,exit:c,buffer:a,resume:h,data:n},qe=[];let We=-1;for(;++We<te.length;)if(te[We][1].type==="listOrdered"||te[We][1].type==="listUnordered")if(te[We][0]==="enter")qe.push(We);else{const Rt=qe.pop();We=o(te,Rt,We)}for(We=-1;++We<te.length;){const Rt=t[te[We][0]];dQ.call(Rt,te[We][1].type)&&Rt[te[We][1].type].call(Object.assign({sliceSerialize:te[We][2].sliceSerialize},Pe),te[We][1])}if(Pe.tokenStack.length>0){const Rt=Pe.tokenStack[Pe.tokenStack.length-1];(Rt[1]||xV).call(Pe,void 0,Rt[0])}for(de.position={start:pi(te.length>0?te[0][1].start:{line:1,column:1,offset:0}),end:pi(te.length>0?te[te.length-2][1].end:{line:1,column:1,offset:0})},We=-1;++We<t.transforms.length;)de=t.transforms[We](de)||de;return de}function o(te,de,Pe){let qe=de-1,We=-1,Rt=!1,st,Ne,ot,Jn;for(;++qe<=Pe;){const zt=te[qe];switch(zt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{zt[0]==="enter"?We++:We--,Jn=void 0;break}case"lineEndingBlank":{zt[0]==="enter"&&(st&&!Jn&&!We&&!ot&&(ot=qe),Jn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Jn=void 0}if(!We&&zt[0]==="enter"&&zt[1].type==="listItemPrefix"||We===-1&&zt[0]==="exit"&&(zt[1].type==="listUnordered"||zt[1].type==="listOrdered")){if(st){let zn=qe;for(Ne=void 0;zn--;){const Kt=te[zn];if(Kt[1].type==="lineEnding"||Kt[1].type==="lineEndingBlank"){if(Kt[0]==="exit")continue;Ne&&(te[Ne][1].type="lineEndingBlank",Rt=!0),Kt[1].type="lineEnding",Ne=zn}else if(!(Kt[1].type==="linePrefix"||Kt[1].type==="blockQuotePrefix"||Kt[1].type==="blockQuotePrefixWhitespace"||Kt[1].type==="blockQuoteMarker"||Kt[1].type==="listItemIndent"))break}ot&&(!Ne||ot<Ne)&&(st._spread=!0),st.end=Object.assign({},Ne?te[Ne][1].start:zt[1].end),te.splice(Ne||qe,0,["exit",st,zt[2]]),qe++,Pe++}if(zt[1].type==="listItemPrefix"){const zn={type:"listItem",_spread:!1,start:Object.assign({},zt[1].start),end:void 0};st=zn,te.splice(qe,0,["enter",zn,zt[2]]),qe++,Pe++,ot=void 0,Jn=!0}}}return te[de][1]._spread=Rt,Pe}function i(te,de){return Pe;function Pe(qe){s.call(this,te(qe),qe),de&&de.call(this,qe)}}function a(){this.stack.push({type:"fragment",children:[]})}function s(te,de,Pe){this.stack[this.stack.length-1].children.push(te),this.stack.push(te),this.tokenStack.push([de,Pe||void 0]),te.position={start:pi(de.start),end:void 0}}function l(te){return de;function de(Pe){te&&te.call(this,Pe),c.call(this,Pe)}}function c(te,de){const Pe=this.stack.pop(),qe=this.tokenStack.pop();if(qe)qe[0].type!==te.type&&(de?de.call(this,te,qe[0]):(qe[1]||xV).call(this,te,qe[0]));else throw new Error("Cannot close `"+te.type+"` ("+I2({start:te.start,end:te.end})+"): it’s not open");Pe.position.end=pi(te.end)}function h(){return cH(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(te){if(this.data.expectingFirstListItemValue){const de=this.stack[this.stack.length-2];de.start=Number.parseInt(this.sliceSerialize(te),10),this.data.expectingFirstListItemValue=void 0}}function p(){const te=this.resume(),de=this.stack[this.stack.length-1];de.lang=te}function k(){const te=this.resume(),de=this.stack[this.stack.length-1];de.meta=te}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function w(){const te=this.resume(),de=this.stack[this.stack.length-1];de.value=te.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function g(){const te=this.resume(),de=this.stack[this.stack.length-1];de.value=te.replace(/(\r?\n|\r)$/g,"")}function M(te){const de=this.resume(),Pe=this.stack[this.stack.length-1];Pe.label=de,Pe.identifier=Pr(this.sliceSerialize(te)).toLowerCase()}function x(){const te=this.resume(),de=this.stack[this.stack.length-1];de.title=te}function b(){const te=this.resume(),de=this.stack[this.stack.length-1];de.url=te}function S(te){const de=this.stack[this.stack.length-1];if(!de.depth){const Pe=this.sliceSerialize(te).length;de.depth=Pe}}function C(){this.data.setextHeadingSlurpLineEnding=!0}function L(te){const de=this.stack[this.stack.length-1];de.depth=this.sliceSerialize(te).codePointAt(0)===61?1:2}function P(){this.data.setextHeadingSlurpLineEnding=void 0}function T(te){const Pe=this.stack[this.stack.length-1].children;let qe=Pe[Pe.length-1];(!qe||qe.type!=="text")&&(qe=Se(),qe.position={start:pi(te.start),end:void 0},Pe.push(qe)),this.stack.push(qe)}function E(te){const de=this.stack.pop();de.value+=this.sliceSerialize(te),de.position.end=pi(te.end)}function z(te){const de=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Pe=de.children[de.children.length-1];Pe.position.end=pi(te.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(de.type)&&(T.call(this,te),E.call(this,te))}function A(){this.data.atHardBreak=!0}function U(){const te=this.resume(),de=this.stack[this.stack.length-1];de.value=te}function R(){const te=this.resume(),de=this.stack[this.stack.length-1];de.value=te}function V(){const te=this.resume(),de=this.stack[this.stack.length-1];de.value=te}function O(){const te=this.stack[this.stack.length-1];if(this.data.inReference){const de=this.data.referenceType||"shortcut";te.type+="Reference",te.referenceType=de,delete te.url,delete te.title}else delete te.identifier,delete te.label;this.data.referenceType=void 0}function B(){const te=this.stack[this.stack.length-1];if(this.data.inReference){const de=this.data.referenceType||"shortcut";te.type+="Reference",te.referenceType=de,delete te.url,delete te.title}else delete te.identifier,delete te.label;this.data.referenceType=void 0}function D(te){const de=this.sliceSerialize(te),Pe=this.stack[this.stack.length-2];Pe.label=y4e(de),Pe.identifier=Pr(de).toLowerCase()}function N(){const te=this.stack[this.stack.length-1],de=this.resume(),Pe=this.stack[this.stack.length-1];if(this.data.inReference=!0,Pe.type==="link"){const qe=te.children;Pe.children=qe}else Pe.alt=de}function I(){const te=this.resume(),de=this.stack[this.stack.length-1];de.url=te}function W(){const te=this.resume(),de=this.stack[this.stack.length-1];de.title=te}function H(){this.data.inReference=void 0}function j(){this.data.referenceType="collapsed"}function G(te){const de=this.resume(),Pe=this.stack[this.stack.length-1];Pe.label=de,Pe.identifier=Pr(this.sliceSerialize(te)).toLowerCase(),this.data.referenceType="full"}function X(te){this.data.characterReferenceType=te.type}function Y(te){const de=this.sliceSerialize(te),Pe=this.data.characterReferenceType;let qe;Pe?(qe=tQ(de,Pe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):qe=uH(de);const We=this.stack[this.stack.length-1];We.value+=qe}function re(te){const de=this.stack.pop();de.position.end=pi(te.end)}function ne(te){E.call(this,te);const de=this.stack[this.stack.length-1];de.url=this.sliceSerialize(te)}function ae(te){E.call(this,te);const de=this.stack[this.stack.length-1];de.url="mailto:"+this.sliceSerialize(te)}function ve(){return{type:"blockquote",children:[]}}function be(){return{type:"code",lang:null,meta:null,value:""}}function me(){return{type:"inlineCode",value:""}}function ge(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ee(){return{type:"emphasis",children:[]}}function ke(){return{type:"heading",depth:0,children:[]}}function Fe(){return{type:"break"}}function rt(){return{type:"html",value:""}}function mt(){return{type:"image",title:null,url:"",alt:null}}function ht(){return{type:"link",title:null,url:"",children:[]}}function le(te){return{type:"list",ordered:te.type==="listOrdered",start:null,spread:te._spread,children:[]}}function Q(te){return{type:"listItem",spread:te._spread,checked:null,children:[]}}function fe(){return{type:"paragraph",children:[]}}function we(){return{type:"strong",children:[]}}function Se(){return{type:"text",value:""}}function Oe(){return{type:"thematicBreak"}}}function pi(e){return{line:e.line,column:e.column,offset:e.offset}}function hQ(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?hQ(e,r):x4e(e,r)}}function x4e(e,t){let n;for(n in t)if(dQ.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function xV(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+I2({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+I2({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+I2({start:t.start,end:t.end})+") is still open")}function v4e(e){const t=this;t.parser=n;function n(r){return k4e(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function w4e(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function M4e(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
@@ -7835,4 +7835,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
7835
7835
|
`))}function l(p,k,v,w){const g=v.enter("tableCell"),M=v.enter("phrasing"),x=v.containerPhrasing(p,{...w,before:i,after:i});return M(),g(),x}function c(p,k){return Lxe(p,{align:k,alignDelimiters:r,padding:n,stringLength:o})}function h(p,k,v){const w=p.children;let g=-1;const M=[],x=k.enter("table");for(;++g<w.length;)M[g]=d(w[g],k,v);return x(),M}function d(p,k,v){const w=p.children;let g=-1;const M=[],x=k.enter("tableRow");for(;++g<w.length;)M[g]=l(w[g],p,k,v);return x(),M}function f(p,k,v){let w=DQ.inlineCode(p,k,v);return v.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function fve(){return{exit:{taskListCheckValueChecked:UV,taskListCheckValueUnchecked:UV,paragraph:yve}}}function pve(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:mve}}}function UV(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function yve(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const o=t.children;let i=-1,a;for(;++i<o.length;){const s=o[i];if(s.type==="paragraph"){a=s;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function mve(e,t,n,r){const o=e.children[0],i=typeof e.checked=="boolean"&&o&&o.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",s=n.createTracker(r);i&&s.move(a);let l=DQ.listItem(e,t,n,{...r,...s.current()});return i&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(h){return h+a}}function kve(){return[K5e(),mxe(),vxe(),ave(),fve()]}function gve(e){return{extensions:[X5e(),kxe(e),wxe(),hve(e),pve()]}}const xve={tokenize:Sve,partial:!0},_Q={tokenize:Lve,partial:!0},HQ={tokenize:Ive,partial:!0},FQ={tokenize:Eve,partial:!0},vve={tokenize:Ave,partial:!0},OQ={name:"wwwAutolink",tokenize:bve,previous:VQ},qQ={name:"protocolAutolink",tokenize:Cve,previous:BQ},Qo={name:"emailAutolink",tokenize:Mve,previous:$Q},wo={};function wve(){return{text:wo}}let la=48;for(;la<123;)wo[la]=Qo,la++,la===58?la=65:la===91&&(la=97);wo[43]=Qo;wo[45]=Qo;wo[46]=Qo;wo[95]=Qo;wo[72]=[Qo,qQ];wo[104]=[Qo,qQ];wo[87]=[Qo,OQ];wo[119]=[Qo,OQ];function Mve(e,t,n){const r=this;let o,i;return a;function a(d){return!JN(d)||!$Q.call(r,r.previous)||vH(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),s(d))}function s(d){return JN(d)?(e.consume(d),s):d===64?(e.consume(d),l):n(d)}function l(d){return d===46?e.check(vve,h,c)(d):d===45||d===95||tn(d)?(i=!0,e.consume(d),l):h(d)}function c(d){return e.consume(d),o=!0,l}function h(d){return i&&o&&cn(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function bve(e,t,n){const r=this;return o;function o(a){return a!==87&&a!==119||!VQ.call(r,r.previous)||vH(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(xve,e.attempt(_Q,e.attempt(HQ,i),n),n)(a))}function i(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function Cve(e,t,n){const r=this;let o="",i=!1;return a;function a(d){return(d===72||d===104)&&BQ.call(r,r.previous)&&!vH(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(d),e.consume(d),s):n(d)}function s(d){if(cn(d)&&o.length<5)return o+=String.fromCodePoint(d),e.consume(d),s;if(d===58){const f=o.toLowerCase();if(f==="http"||f==="https")return e.consume(d),l}return n(d)}function l(d){return d===47?(e.consume(d),i?c:(i=!0,l)):n(d)}function c(d){return d===null||xR(d)||ut(d)||i1(d)||Az(d)?n(d):e.attempt(_Q,e.attempt(HQ,h),n)(d)}function h(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function Sve(e,t,n){let r=0;return o;function o(a){return(a===87||a===119)&&r<3?(r++,e.consume(a),o):a===46&&r===3?(e.consume(a),i):n(a)}function i(a){return a===null?n(a):t(a)}}function Lve(e,t,n){let r,o,i;return a;function a(c){return c===46||c===95?e.check(FQ,l,s)(c):c===null||ut(c)||i1(c)||c!==45&&Az(c)?l(c):(i=!0,e.consume(c),a)}function s(c){return c===95?r=!0:(o=r,r=void 0),e.consume(c),a}function l(c){return o||r||!i?n(c):t(c)}}function Ive(e,t){let n=0,r=0;return o;function o(a){return a===40?(n++,e.consume(a),o):a===41&&r<n?i(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(FQ,t,i)(a):a===null||ut(a)||i1(a)?t(a):(e.consume(a),o)}function i(a){return a===41&&r++,e.consume(a),o}}function Eve(e,t,n){return r;function r(s){return s===33||s===34||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===63||s===95||s===126?(e.consume(s),r):s===38?(e.consume(s),i):s===93?(e.consume(s),o):s===60||s===null||ut(s)||i1(s)?t(s):n(s)}function o(s){return s===null||s===40||s===91||ut(s)||i1(s)?t(s):r(s)}function i(s){return cn(s)?a(s):n(s)}function a(s){return s===59?(e.consume(s),r):cn(s)?(e.consume(s),a):n(s)}}function Ave(e,t,n){return r;function r(i){return e.consume(i),o}function o(i){return tn(i)?n(i):t(i)}}function VQ(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||ut(e)}function BQ(e){return!cn(e)}function $Q(e){return!(e===47||JN(e))}function JN(e){return e===43||e===45||e===46||e===95||tn(e)}function vH(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Pve={tokenize:Hve,partial:!0};function Rve(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Nve,continuation:{tokenize:Dve},exit:_ve}},text:{91:{name:"gfmFootnoteCall",tokenize:Tve},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:zve,resolveTo:jve}}}}function zve(e,t,n){const r=this;let o=r.events.length;const i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;o--;){const l=r.events[o][1];if(l.type==="labelImage"){a=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return s;function s(l){if(!a||!a._balanced)return n(l);const c=Pr(r.sliceSerialize({start:a.end,end:r.now()}));return c.codePointAt(0)!==94||!i.includes(c.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function jve(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const i={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},i.start),end:Object.assign({},i.end)},s=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",o,t],["exit",o,t],["enter",i,t],["enter",a,t],["exit",a,t],["exit",i,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...s),e}function Tve(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i=0,a;return s;function s(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(d){if(i>999||d===93&&!a||d===null||d===91||ut(d))return n(d);if(d===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return o.includes(Pr(r.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return ut(d)||(a=!0),i++,e.consume(d),d===92?h:c}function h(d){return d===91||d===92||d===93?(e.consume(d),i++,c):c(d)}}function Nve(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i,a=0,s;return l;function l(k){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(k){return k===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",h):n(k)}function h(k){if(a>999||k===93&&!s||k===null||k===91||ut(k))return n(k);if(k===93){e.exit("chunkString");const v=e.exit("gfmFootnoteDefinitionLabelString");return i=Pr(r.sliceSerialize(v)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return ut(k)||(s=!0),a++,e.consume(k),k===92?d:h}function d(k){return k===91||k===92||k===93?(e.consume(k),a++,h):h(k)}function f(k){return k===58?(e.enter("definitionMarker"),e.consume(k),e.exit("definitionMarker"),o.includes(i)||o.push(i),Xe(e,p,"gfmFootnoteDefinitionWhitespace")):n(k)}function p(k){return t(k)}}function Dve(e,t,n){return e.check(Gh,t,e.attempt(Pve,t,n))}function _ve(e){e.exit("gfmFootnoteDefinition")}function Hve(e,t,n){const r=this;return Xe(e,o,"gfmFootnoteDefinitionIndent",5);function o(i){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?t(i):n(i)}}function Fve(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:i,resolveAll:o};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function o(a,s){let l=-1;for(;++l<a.length;)if(a[l][0]==="enter"&&a[l][1].type==="strikethroughSequenceTemporary"&&a[l][1]._close){let c=l;for(;c--;)if(a[c][0]==="exit"&&a[c][1].type==="strikethroughSequenceTemporary"&&a[c][1]._open&&a[l][1].end.offset-a[l][1].start.offset===a[c][1].end.offset-a[c][1].start.offset){a[l][1].type="strikethroughSequence",a[c][1].type="strikethroughSequence";const h={type:"strikethrough",start:Object.assign({},a[c][1].start),end:Object.assign({},a[l][1].end)},d={type:"strikethroughText",start:Object.assign({},a[c][1].end),end:Object.assign({},a[l][1].start)},f=[["enter",h,s],["enter",a[c][1],s],["exit",a[c][1],s],["enter",d,s]],p=s.parser.constructs.insideSpan.null;p&&Gn(f,f.length,0,Pz(p,a.slice(c+1,l),s)),Gn(f,f.length,0,[["exit",d,s],["enter",a[l][1],s],["exit",a[l][1],s],["exit",h,s]]),Gn(a,c-1,l-c+3,f),l=c+f.length-2;break}}for(l=-1;++l<a.length;)a[l][1].type==="strikethroughSequenceTemporary"&&(a[l][1].type="data");return a}function i(a,s,l){const c=this.previous,h=this.events;let d=0;return f;function f(k){return c===126&&h[h.length-1][1].type!=="characterEscape"?l(k):(a.enter("strikethroughSequenceTemporary"),p(k))}function p(k){const v=Ou(c);if(k===126)return d>1?l(k):(a.consume(k),d++,p);if(d<2&&!n)return l(k);const w=a.exit("strikethroughSequenceTemporary"),g=Ou(k);return w._open=!g||g===2&&!!v,w._close=!v||v===2&&!!g,s(k)}}}class Ove{constructor(){this.map=[]}add(t,n,r){qve(this,t,n,r)}consume(t){if(this.map.sort(function(i,a){return i[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let o=r.pop();for(;o;){for(const i of o)t.push(i);o=r.pop()}this.map.length=0}}function qve(e,t,n,r){let o=0;if(!(n===0&&r.length===0)){for(;o<e.map.length;){if(e.map[o][0]===t){e.map[o][1]+=n,e.map[o][2].push(...r);return}o+=1}e.map.push([t,n,r])}}function Vve(e,t){let n=!1;const r=[];for(;t<e.length;){const o=e[t];if(n){if(o[0]==="enter")o[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const i=r.length-1;r[i]=r[i]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function Bve(){return{flow:{null:{name:"table",tokenize:$ve,resolveAll:Uve}}}}function $ve(e,t,n){const r=this;let o=0,i=0,a;return s;function s(E){let z=r.events.length-1;for(;z>-1;){const R=r.events[z][1].type;if(R==="lineEnding"||R==="linePrefix")z--;else break}const A=z>-1?r.events[z][1].type:null,U=A==="tableHead"||A==="tableRow"?C:l;return U===C&&r.parser.lazy[r.now().line]?n(E):U(E)}function l(E){return e.enter("tableHead"),e.enter("tableRow"),c(E)}function c(E){return E===124||(a=!0,i+=1),h(E)}function h(E){return E===null?n(E):je(E)?i>1?(i=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),p):n(E):Ge(E)?Xe(e,h,"whitespace")(E):(i+=1,a&&(a=!1,o+=1),E===124?(e.enter("tableCellDivider"),e.consume(E),e.exit("tableCellDivider"),a=!0,h):(e.enter("data"),d(E)))}function d(E){return E===null||E===124||ut(E)?(e.exit("data"),h(E)):(e.consume(E),E===92?f:d)}function f(E){return E===92||E===124?(e.consume(E),d):d(E)}function p(E){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(E):(e.enter("tableDelimiterRow"),a=!1,Ge(E)?Xe(e,k,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):k(E))}function k(E){return E===45||E===58?w(E):E===124?(a=!0,e.enter("tableCellDivider"),e.consume(E),e.exit("tableCellDivider"),v):S(E)}function v(E){return Ge(E)?Xe(e,w,"whitespace")(E):w(E)}function w(E){return E===58?(i+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(E),e.exit("tableDelimiterMarker"),g):E===45?(i+=1,g(E)):E===null||je(E)?b(E):S(E)}function g(E){return E===45?(e.enter("tableDelimiterFiller"),M(E)):S(E)}function M(E){return E===45?(e.consume(E),M):E===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(E),e.exit("tableDelimiterMarker"),x):(e.exit("tableDelimiterFiller"),x(E))}function x(E){return Ge(E)?Xe(e,b,"whitespace")(E):b(E)}function b(E){return E===124?k(E):E===null||je(E)?!a||o!==i?S(E):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(E)):S(E)}function S(E){return n(E)}function C(E){return e.enter("tableRow"),L(E)}function L(E){return E===124?(e.enter("tableCellDivider"),e.consume(E),e.exit("tableCellDivider"),L):E===null||je(E)?(e.exit("tableRow"),t(E)):Ge(E)?Xe(e,L,"whitespace")(E):(e.enter("data"),P(E))}function P(E){return E===null||E===124||ut(E)?(e.exit("data"),L(E)):(e.consume(E),E===92?T:P)}function T(E){return E===92||E===124?(e.consume(E),P):P(E)}}function Uve(e,t){let n=-1,r=!0,o=0,i=[0,0,0,0],a=[0,0,0,0],s=!1,l=0,c,h,d;const f=new Ove;for(;++n<e.length;){const p=e[n],k=p[1];p[0]==="enter"?k.type==="tableHead"?(s=!1,l!==0&&(WV(f,t,l,c,h),h=void 0,l=0),c={type:"table",start:Object.assign({},k.start),end:Object.assign({},k.end)},f.add(n,0,[["enter",c,t]])):k.type==="tableRow"||k.type==="tableDelimiterRow"?(r=!0,d=void 0,i=[0,0,0,0],a=[0,n+1,0,0],s&&(s=!1,h={type:"tableBody",start:Object.assign({},k.start),end:Object.assign({},k.end)},f.add(n,0,[["enter",h,t]])),o=k.type==="tableDelimiterRow"?2:h?3:1):o&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(i[1]!==0&&(a[0]=a[1],d=W0(f,t,i,o,void 0,d),i=[0,0,0,0]),a[2]=n)):k.type==="tableCellDivider"&&(r?r=!1:(i[1]!==0&&(a[0]=a[1],d=W0(f,t,i,o,void 0,d)),i=a,a=[i[1],n,0,0])):k.type==="tableHead"?(s=!0,l=n):k.type==="tableRow"||k.type==="tableDelimiterRow"?(l=n,i[1]!==0?(a[0]=a[1],d=W0(f,t,i,o,n,d)):a[1]!==0&&(d=W0(f,t,a,o,n,d)),o=0):o&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")&&(a[3]=n)}for(l!==0&&WV(f,t,l,c,h),f.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=Vve(t.events,n))}return e}function W0(e,t,n,r,o,i){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",s="tableContent";n[0]!==0&&(i.end=Object.assign({},N1(t.events,n[0])),e.add(n[0],0,[["exit",i,t]]));const l=N1(t.events,n[1]);if(i={type:a,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",i,t]]),n[2]!==0){const c=N1(t.events,n[2]),h=N1(t.events,n[3]),d={type:s,start:Object.assign({},c),end:Object.assign({},h)};if(e.add(n[2],0,[["enter",d,t]]),r!==2){const f=t.events[n[2]],p=t.events[n[3]];if(f[1].end=Object.assign({},p[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const k=n[2]+1,v=n[3]-n[2]-1;e.add(k,v,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return o!==void 0&&(i.end=Object.assign({},N1(t.events,o)),e.add(o,0,[["exit",i,t]]),i=void 0),i}function WV(e,t,n,r,o){const i=[],a=N1(t.events,n);o&&(o.end=Object.assign({},a),i.push(["exit",o,t])),r.end=Object.assign({},a),i.push(["exit",r,t]),e.add(n+1,0,i)}function N1(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const Wve={name:"tasklistCheck",tokenize:Zve};function Gve(){return{text:{91:Wve}}}function Zve(e,t,n){const r=this;return o;function o(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),i)}function i(l){return ut(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),a):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),a):n(l)}function a(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),s):n(l)}function s(l){return je(l)?t(l):Ge(l)?e.check({tokenize:Kve},t,n)(l):n(l)}}function Kve(e,t,n){return Xe(e,r,"whitespace");function r(o){return o===null?n(o):t(o)}}function Xve(e){return eQ([wve(),Rve(),Fve(e),Bve(),Gve()])}const Yve={};function Qve(e){const t=this,n=e||Yve,r=t.data(),o=r.micromarkExtensions||(r.micromarkExtensions=[]),i=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);o.push(Xve(n)),i.push(kve()),a.push(gve(n))}function Jve({flowId:e,node:t,connector:n,adapter:r,onNameChange:o,onDescriptionChange:i,onDetailChange:a,onIconChange:s,statusReport:l,onClose:c}){const h=(t==null?void 0:t.type)==="shapeNode"&&t.data.shape==="text",d=(t==null?void 0:t.type)==="shapeNode"?t.data.shape:void 0,f=d==="ellipse"||d==="sticky",p=h?null:t,k=p!==null||n!==null,v=p&&"name"in p.data?p.data.name??"":"",w=(p==null?void 0:p.data.description)??"",g=(p==null?void 0:p.data.detail)??"",M=p!==null&&!f,x=p!==null&&(p.type==="playNode"||p.type==="stateNode"),b=x&&typeof s=="function",S=x&&p&&"icon"in p.data?p.data.icon??null:null,[C,L]=m.useState(()=>J1e()),P=E=>{E.preventDefault(),tue(C,E.clientX,{onWidth:L,onCommit:eue})},T={"--detail-panel-w":`${C}px`};return y.jsx(Rye,{open:k,modal:!1,onOpenChange:E=>{E||c()},children:y.jsxs(lY,{side:"right",className:"sf:w-full! sf:max-w-full! sf:overflow-y-auto sf:bg-card/94 sf:backdrop-blur-[14px] sf:border-border sf:shadow-[-12px_0_40px_-12px_rgba(0,0,0,0.6)] sf:sm:w-(--detail-panel-w)! sf:sm:max-w-(--detail-panel-w)!",style:T,"data-testid":"detail-panel",onEscapeKeyDown:E=>{var A;const z=document.activeElement;(A=z==null?void 0:z.getAttribute("data-testid"))!=null&&A.endsWith("-editor")&&E.preventDefault()},onInteractOutside:E=>{var U;const z=document.activeElement;(U=z==null?void 0:z.getAttribute("data-testid"))!=null&&U.endsWith("-editor")&&z.blur();const A=E.target;A!=null&&A.closest(".react-flow__resize-control")&&E.preventDefault(),A!=null&&A.closest("[data-radix-popper-content-wrapper]")&&E.preventDefault(),A!=null&&A.closest('[data-testid="canvas-style-strip"]')&&E.preventDefault(),A!=null&&A.closest(".react-flow__node")&&E.preventDefault(),A!=null&&A.closest(".react-flow__edge")&&E.preventDefault()},children:[y.jsx("div",{"aria-label":"Resize detail panel",onPointerDown:P,"data-testid":"detail-panel-resize-handle",className:"sf:absolute sf:inset-y-0 sf:left-0 sf:z-10 sf:hidden sf:w-1.5 sf:cursor-col-resize sf:bg-transparent sf:transition-colors sf:hover:bg-border sf:sm:block"}),p?y.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-4",children:[y.jsxs("div",{className:"sf:-mx-6 sf:-mt-6 sf:flex sf:flex-col sf:border-b sf:border-border/60 sf:bg-card/60 sf:px-6 sf:pb-2.5 sf:pt-3 sf:pr-12",children:[M?y.jsx(bP,{"data-testid":"detail-panel-title",children:y.jsxs("div",{className:"sf:flex sf:items-center sf:gap-2",children:[b&&s?y.jsx(e3e,{nodeId:p.id,icon:S,onChange:s}):x&&S?y.jsx("span",{"data-testid":"detail-panel-icon-readonly","aria-hidden":!0,className:"sf:inline-flex sf:h-7 sf:w-7 sf:shrink-0 sf:items-center sf:justify-center sf:text-foreground/90",children:y.jsx(t1,{name:S,size:16})}):null,y.jsx("div",{className:"sf:min-w-0 sf:flex-1",children:y.jsx(rT,{nodeId:p.id,value:v,placeholder:"Name",multiline:!1,ariaLabel:"Name",testIdBase:"detail-panel-name",onSave:o,textClassName:"sf:text-lg sf:font-semibold sf:tracking-tight sf:text-foreground/95"})})]})}):y.jsx(bP,{"data-testid":"detail-panel-title",className:"sf:sr-only",children:p.id}),y.jsxs(_N,{className:"sf:sr-only",children:[p.id," · ",p.type]})]}),y.jsxs("div",{className:"sf:mt-0 sf:flex sf:flex-col sf:gap-3",children:[l?y.jsx(o3e,{report:l}):null,y.jsx(rT,{nodeId:p.id,value:w,placeholder:"Short description shown on the node body",multiline:!0,ariaLabel:"Description",testIdBase:"detail-panel-description",onSave:i,textClassName:"sf:text-[13px] sf:leading-relaxed sf:text-muted-foreground"}),y.jsx(rT,{nodeId:p.id,value:g,placeholder:"Long-form notes, context, anything…",multiline:!0,ariaLabel:"Detail",testIdBase:"detail-panel-detail",onSave:a,markdown:!0,textClassName:"sf:text-sm sf:leading-relaxed sf:text-foreground/90"}),p.type==="htmlNode"&&e?y.jsx(t3e,{adapter:r,nodeId:p.id,htmlPath:"view.html"}):null]})]}):n?y.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-4",children:[y.jsxs("div",{className:"sf:-mx-6 sf:-mt-6 sf:flex sf:flex-col sf:border-b sf:border-border/60 sf:bg-card/60 sf:px-6 sf:pb-2.5 sf:pt-3 sf:pr-12",children:[y.jsx(bP,{"data-testid":"detail-panel-title",className:"sf:text-lg sf:font-semibold sf:tracking-tight sf:text-foreground/95",children:n.label??"Connector"}),y.jsxs(_N,{className:"sf:sr-only",children:[n.id," · ",n.kind]})]}),y.jsx("div",{className:"sf:mt-0 sf:flex sf:flex-col sf:gap-3",children:y.jsx(i3e,{connector:n})})]}):null]})})}function rT({nodeId:e,value:t,placeholder:n,multiline:r,ariaLabel:o,testIdBase:i,onSave:a,textClassName:s,markdown:l=!1}){const[c,h]=m.useState(!1),d=m.useRef(null),f=m.useRef(!1);m.useEffect(()=>{if(!c)return;const S=d.current;if(!S)return;S.textContent=t,S.focus();const C=window.getSelection();if(C){const L=document.createRange();L.selectNodeContents(S),L.collapse(!1),C.removeAllRanges(),C.addRange(L)}},[c,t]);const p=t==="";if(!a)return y.jsx("div",{"data-testid":i,"aria-label":o,className:ie("sf:w-full sf:rounded-md sf:px-2 sf:py-1.5 sf:text-sm",p?"sf:italic sf:text-muted-foreground/50":"text-foreground",!l&&"sf:whitespace-pre-wrap sf:wrap-break-word",s),children:p?n:l?y.jsx(GV,{value:t}):t});const k=()=>{var C;const S=((C=d.current)==null?void 0:C.textContent)??t;a(e,S),h(!1)},v=()=>{h(!1)},w=S=>{if(S.stopPropagation(),S.nativeEvent.stopPropagation(),S.key==="Escape"){S.preventDefault(),f.current=!0,v();return}if(S.key==="Enter"){if(S.preventDefault(),S.shiftKey||!r){k();return}document.execCommand("insertText",!1,`
|
|
7836
7836
|
`)}},g=S=>{S.preventDefault();const C=S.clipboardData.getData("text/plain");document.execCommand("insertText",!1,C)},M=S=>{},x=()=>{if(f.current){f.current=!1;return}k()},b=()=>{c||h(!0)};return y.jsx("div",{className:"relative","data-testid":i,"data-editing":c?"true":"false",children:c?y.jsx("div",{ref:d,contentEditable:"plaintext-only",suppressContentEditableWarning:!0,spellCheck:!1,tabIndex:0,onKeyDown:w,onPaste:g,onInput:M,onBlur:x,"data-testid":`${i}-editor`,className:ie("sf:block sf:w-full sf:whitespace-pre-wrap sf:wrap-break-word sf:rounded-md sf:px-2 sf:py-1.5 sf:text-sm sf:outline-hidden",s),role:"textbox","aria-multiline":r?"true":"false","aria-label":o}):y.jsx("button",{type:"button",onClick:b,"aria-label":`Edit ${o.toLowerCase()}`,className:ie("sf:block sf:w-full sf:cursor-text sf:rounded-md sf:px-2 sf:py-1.5 sf:text-left sf:text-sm sf:transition-colors sf:hover:bg-muted/50",p?"sf:italic sf:text-muted-foreground/50":"text-foreground",!l&&"sf:whitespace-pre-wrap sf:wrap-break-word",s),children:p?n:l?y.jsx(GV,{value:t}):t})})}function e3e({nodeId:e,icon:t,onChange:n}){const[r,o]=m.useState(!1);return y.jsx(uz,{open:r,onOpenChange:o,onPick:i=>{n(e,i),o(!1)},anchor:y.jsx("button",{type:"button","data-testid":"detail-panel-icon-trigger","aria-label":t?"Change icon":"Add icon","aria-pressed":r,className:ie("sf:inline-flex sf:h-7 sf:w-7 sf:shrink-0 sf:items-center sf:justify-center sf:rounded-md sf:text-foreground sf:transition-colors",t?"sf:hover:bg-muted":"sf:border sf:border-dashed sf:border-muted-foreground/40 sf:text-muted-foreground/60 sf:hover:border-muted-foreground sf:hover:text-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-1"),children:t?y.jsx(t1,{name:t,size:16,"aria-hidden":!0}):y.jsx(i2,{className:"sf:h-4 sf:w-4","aria-hidden":!0})})})}function t3e({adapter:e,nodeId:t,htmlPath:n}){const[r,o]=m.useState({kind:"idle"}),i=typeof(e==null?void 0:e.openFile)=="function",a=typeof(e==null?void 0:e.revealFile)=="function",s=`nodes/${t}/${n}`,l=async c=>{var h,d;o({kind:"pending"});try{c==="open"?await((h=e==null?void 0:e.openFile)==null?void 0:h.call(e,s)):await((d=e==null?void 0:e.revealFile)==null?void 0:d.call(e,s)),o({kind:"idle"})}catch(f){o({kind:"error",message:f instanceof Error?f.message:String(f)})}};return y.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-2 sf:rounded-md sf:border sf:bg-card sf:px-3 sf:py-2 sf:text-xs","data-testid":"detail-panel-html-node",children:[y.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-1",children:[y.jsx("span",{className:"sf:font-mono sf:text-[11px] sf:text-muted-foreground sf:uppercase sf:tracking-widest",children:"Path"}),y.jsx("code",{"data-testid":"detail-panel-html-path",className:"sf:block sf:break-all sf:rounded sf:bg-muted/40 sf:px-2 sf:py-1 sf:font-mono sf:text-[11px]",children:n})]}),i||a?y.jsxs("div",{className:"sf:flex sf:flex-wrap sf:items-center sf:gap-2",children:[i?y.jsxs(Nt,{type:"button",size:"sm",variant:"outline",className:"sf:h-7 sf:gap-1.5 sf:px-2",onClick:()=>{l("open")},disabled:r.kind==="pending","data-testid":"detail-panel-html-open","aria-label":"Open in editor",children:[y.jsx(u2,{className:"sf:h-3.5 sf:w-3.5"}),"Open in editor"]}):null,a?y.jsxs(Nt,{type:"button",size:"sm",variant:"outline",className:"sf:h-7 sf:gap-1.5 sf:px-2",onClick:()=>{l("reveal")},disabled:r.kind==="pending","data-testid":"detail-panel-html-reveal","aria-label":"Reveal in Finder/Explorer",children:[y.jsx(o2,{className:"sf:h-3.5 sf:w-3.5"}),"Reveal"]}):null]}):null,r.kind==="error"?y.jsx("div",{"data-testid":"detail-panel-html-status","data-status":r.kind,className:ie("sf:text-[11px] sf:text-destructive"),children:r.message??""}):null]})}function n3e(e,t){const n=Math.max(0,t-e);if(n<1e3)return"just now";const r=Math.floor(n/1e3);if(r<60)return`${r}s ago`;const o=Math.floor(r/60);if(o<60)return`${o}m ago`;const i=Math.floor(o/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function r3e(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function o3e({report:e,now:t=Date.now()}){const n=e.data?Object.entries(e.data):[];return y.jsxs("section",{className:"sf:flex sf:flex-col sf:gap-2 sf:rounded-md sf:border sf:bg-card sf:px-3 sf:py-2 sf:text-xs","data-testid":"detail-panel-status","data-state":e.state,children:[y.jsxs("div",{className:"sf:flex sf:items-center sf:justify-between sf:gap-2",children:[y.jsx(QZ,{state:e.state,summary:e.summary,"data-testid":"detail-panel-status-badge"}),y.jsx("span",{className:"sf:shrink-0 sf:text-[10px] sf:text-muted-foreground","data-testid":"detail-panel-status-relative-time",children:`Last updated: ${n3e(e.ts,t)}`})]}),e.detail?y.jsx("div",{"data-testid":"detail-panel-status-detail",className:"sf:whitespace-pre-wrap sf:wrap-break-word sf:rounded sf:bg-muted/40 sf:px-2 sf:py-1 sf:text-[11px] sf:text-foreground",children:e.detail}):null,n.length>0?y.jsx("dl",{"data-testid":"detail-panel-status-data",className:"sf:grid sf:grid-cols-[auto_1fr] sf:gap-x-3 sf:gap-y-1 sf:text-[11px]",children:n.map(([r,o])=>y.jsxs("div",{className:"contents","data-testid":"detail-panel-status-data-row",children:[y.jsx("dt",{className:"sf:truncate sf:font-medium sf:text-muted-foreground",children:r}),y.jsx("dd",{className:"sf:break-all sf:font-mono sf:text-foreground",children:r3e(o)})]},r))}):null]})}function GV({value:e}){return y.jsx(F5e,{remarkPlugins:[Qve],components:{h1:({children:t})=>y.jsx("h1",{className:"sf:mb-1 sf:text-base sf:font-bold sf:leading-snug",children:t}),h2:({children:t})=>y.jsx("h2",{className:"sf:mb-1 sf:text-sm sf:font-semibold sf:leading-snug",children:t}),h3:({children:t})=>y.jsx("h3",{className:"sf:mb-0.5 sf:text-sm sf:font-medium sf:leading-snug",children:t}),p:({children:t})=>y.jsx("p",{className:"sf:mb-2 sf:last:mb-0 sf:leading-relaxed",children:t}),ul:({children:t})=>y.jsx("ul",{className:"sf:mb-2 sf:list-disc sf:pl-4 sf:last:mb-0",children:t}),ol:({children:t})=>y.jsx("ol",{className:"sf:mb-2 sf:list-decimal sf:pl-4 sf:last:mb-0",children:t}),li:({children:t})=>y.jsx("li",{className:"mb-0.5",children:t}),code:({children:t,className:n})=>(n==null?void 0:n.includes("language-"))?y.jsx("code",{className:"sf:block sf:overflow-x-auto sf:rounded sf:bg-muted/60 sf:px-2 sf:py-1 sf:font-mono sf:text-xs",children:t}):y.jsx("code",{className:"sf:rounded sf:bg-muted/60 sf:px-1 sf:py-0.5 sf:font-mono sf:text-xs",children:t}),pre:({children:t})=>y.jsx("pre",{className:"sf:mb-2 sf:last:mb-0",children:t}),blockquote:({children:t})=>y.jsx("blockquote",{className:"sf:mb-2 sf:border-l-2 sf:border-muted-foreground/30 sf:pl-3 sf:italic sf:text-muted-foreground sf:last:mb-0",children:t}),a:({href:t,children:n})=>y.jsx("a",{href:t,target:"_blank",rel:"noreferrer",className:"sf:text-primary sf:underline sf:underline-offset-2",children:n}),strong:({children:t})=>y.jsx("strong",{className:"font-semibold",children:t}),em:({children:t})=>y.jsx("em",{className:"italic",children:t}),hr:()=>y.jsx("hr",{className:"sf:my-2 sf:border-border"}),table:({children:t})=>y.jsx("div",{className:"sf:mb-2 sf:overflow-x-auto sf:last:mb-0",children:y.jsx("table",{className:"sf:w-full sf:border-collapse sf:text-xs",children:t})}),th:({children:t})=>y.jsx("th",{className:"sf:border sf:border-border sf:bg-muted/40 sf:px-2 sf:py-1 sf:text-left sf:font-medium",children:t}),td:({children:t})=>y.jsx("td",{className:"sf:border sf:border-border sf:px-2 sf:py-1",children:t})},children:e})}function i3e({connector:e}){return y.jsx("div",{className:"sf:rounded-md sf:border sf:bg-card sf:px-3 sf:py-2 sf:text-xs",children:y.jsxs("dl",{className:"divide-y",children:[y.jsx(Qr,{label:"Source",value:e.source}),y.jsx(Qr,{label:"Target",value:e.target}),y.jsx(Qr,{label:"Kind",value:e.kind}),e.label?y.jsx(Qr,{label:"Label",value:e.label}):null,e.style?y.jsx(Qr,{label:"Style",value:e.style}):null,e.color?y.jsx(Qr,{label:"Color",value:e.color}):null,e.direction?y.jsx(Qr,{label:"Direction",value:e.direction}):null,e.kind==="http"&&e.url?y.jsx(Qr,{label:"URL",value:`${e.method??"GET"} ${e.url}`}):null,e.kind==="event"?y.jsx(Qr,{label:"Event",value:e.eventName}):null,e.kind==="queue"?y.jsx(Qr,{label:"Queue",value:e.queueName}):null]})})}function Qr({label:e,value:t}){return y.jsxs("div",{className:"sf:flex sf:items-start sf:gap-3 sf:py-2 sf:first:pt-0 sf:last:pb-0",children:[y.jsx("dt",{className:"sf:w-20 sf:shrink-0 sf:font-medium sf:text-muted-foreground",children:e}),y.jsx("dd",{className:"sf:flex-1 sf:break-all sf:font-mono",children:t})]})}const a3e="https://seeflow.dev/embed",s3e=e=>`${a3e}/${encodeURIComponent(e)}`,l3e=e=>e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<"),c3e=e=>[`<iframe src="${l3e(e)}"`,' width="100%"',' height="600"',' style="border:0"',' allow="fullscreen"',' loading="lazy"></iframe>'].join(`
|
|
7837
7837
|
`),u3e="Embed this canvas",d3e="Paste this iframe into any page to embed the canvas.",h3e="Copy snippet",f3e="Copied!",p3e="Press ⌘C to copy",y3e="Close",m3e=1500;function k3e({open:e,onOpenChange:t,projectId:n}){const r=c3e(s3e(n)),[o,i]=m.useState("idle"),a=m.useRef(null),s=m.useCallback(async()=>{try{await navigator.clipboard.writeText(r),i("copied"),setTimeout(()=>i("idle"),m3e)}catch{i("fallback");const l=a.current;l&&(l.focus(),l.select())}},[r]);return y.jsx(kz,{open:e,onOpenChange:t,children:y.jsxs(Nh,{"data-testid":"embed-dialog-content",children:[y.jsxs(Dh,{children:[y.jsx(_h,{children:u3e}),y.jsx(Hh,{children:d3e})]}),y.jsx("textarea",{ref:a,"data-testid":"embed-dialog-snippet",readOnly:!0,rows:7,value:r,spellCheck:!1,onFocus:l=>l.currentTarget.select(),className:"sf:w-full sf:resize-none sf:rounded-md sf:border sf:border-border sf:bg-background sf:p-3 sf:font-mono sf:text-xs sf:leading-relaxed sf:text-foreground sf:focus:outline-hidden sf:focus:ring-2 sf:focus:ring-ring"}),o==="fallback"?y.jsx("p",{"data-testid":"embed-dialog-fallback-hint",className:"sf:text-xs sf:text-muted-foreground",children:p3e}):null,y.jsxs(Hu,{children:[y.jsx(Nt,{variant:"outline","data-testid":"embed-dialog-close",onClick:()=>t(!1),children:y3e}),y.jsx(Nt,{"data-testid":"embed-dialog-copy",onClick:s,children:o==="copied"?f3e:h3e})]})]})})}const ZV="Share / download",g3e="Download PDF",x3e="Download PNG",v3e="Embed",w3e="Export to seeflow.dev";function M3e({mode:e,projectId:t,enableEmbed:n,onDownloadPdf:r,onDownloadPng:o,onExportToCloud:i,embedOpen:a,onEmbedOpenChange:s}){const[l,c]=m.useState(!1),[h,d]=m.useState(!1),[f,p]=m.useState(!1),k=a!==void 0,v=k?a:f,w=m.useCallback(L=>{k||p(L),s==null||s(L)},[k,s]),g=m.useCallback(()=>{!r||l||(c(!0),Promise.resolve(r()).finally(()=>c(!1)))},[r,l]),M=m.useCallback(()=>{!o||h||(d(!0),Promise.resolve(o()).finally(()=>d(!1)))},[o,h]),x=!!r,b=!!o,S=n&&typeof t=="string"&&t.length>0,C=e==="edit"&&!!i;return!x&&!b&&!S&&!C?null:y.jsxs(y.Fragment,{children:[y.jsxs(oye,{children:[y.jsx(iye,{asChild:!0,children:y.jsx("button",{type:"button","data-testid":"share-menu-trigger","aria-label":ZV,title:ZV,className:ie("sf:inline-flex sf:h-8 sf:w-8 sf:items-center sf:justify-center sf:rounded-md sf:border sf:border-border sf:bg-background/95 sf:text-muted-foreground sf:shadow-md sf:backdrop-blur-sm sf:transition-colors","sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring"),children:y.jsx(k2,{className:"sf:h-4 sf:w-4","aria-hidden":"true"})})}),y.jsxs(GX,{align:"end","data-testid":"share-menu-content",onCloseAutoFocus:L=>{L.preventDefault()},children:[x?y.jsxs(Fd,{"data-testid":"share-menu-pdf",disabled:l,onSelect:L=>{L.preventDefault(),g()},children:[l?y.jsx(Cr,{className:"sf:h-4 sf:w-4 sf:animate-spin","aria-hidden":"true"}):y.jsx(r2,{className:"sf:h-4 sf:w-4","aria-hidden":"true"}),y.jsx("span",{children:g3e})]}):null,b?y.jsxs(Fd,{"data-testid":"share-menu-png",disabled:h,onSelect:L=>{L.preventDefault(),M()},children:[h?y.jsx(Cr,{className:"sf:h-4 sf:w-4 sf:animate-spin","aria-hidden":"true"}):y.jsx(a2,{className:"sf:h-4 sf:w-4","aria-hidden":"true"}),y.jsx("span",{children:x3e})]}):null,S?y.jsxs(Fd,{"data-testid":"share-menu-embed",onSelect:L=>{L.preventDefault(),w(!0)},children:[y.jsx(au,{className:"sf:h-4 sf:w-4","aria-hidden":"true"}),y.jsx("span",{children:v3e})]}):null,C?y.jsxs(Fd,{"data-testid":"share-menu-export-cloud",onSelect:()=>{i==null||i()},children:[y.jsx(w2,{className:"sf:h-4 sf:w-4","aria-hidden":"true"}),y.jsx("span",{children:w3e})]}):null]})]}),S&&t?y.jsx(k3e,{open:v,onOpenChange:w,projectId:t}):null]})}function b3e({onRestartDemo:e}){const[t,n]=m.useState(!1),r=m.useCallback(()=>{t||(n(!0),Promise.resolve(e()).finally(()=>{n(!1)}))},[e,t]);return y.jsxs(Bh,{children:[y.jsx($h,{asChild:!0,children:y.jsx(Nt,{"data-testid":"header-restart-demo",type:"button",variant:"ghost",size:"icon","aria-label":"Restart demo",title:"Restart demo",disabled:t,onClick:r,className:"sf:h-8 sf:w-8",children:t?y.jsx(Cr,{className:"sf:h-4 sf:w-4 sf:animate-spin","aria-hidden":"true"}):y.jsx(f2,{className:"sf:h-4 sf:w-4","aria-hidden":"true"})})}),y.jsx(td,{side:"bottom",children:"Restart demo"})]})}const C3e=8;function S3e(e){let t=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY,i=!1;for(const a of e){const s=a.data.width,l=a.data.height;s===void 0||l===void 0||(i=!0,a.position.x<t&&(t=a.position.x),a.position.y<n&&(n=a.position.y),a.position.x+s>r&&(r=a.position.x+s),a.position.y+l>o&&(o=a.position.y+l))}return i?{x:t,y:n,width:r-t,height:o-n}:null}function L3e(e){return e.length>=2}function I3e({selectedNodes:e,onMultiResize:t,paddingPx:n=C3e}){JR();const[r,o]=m.useState(null),[i,a]=m.useState(null);if(m.useRef(!1),m.useRef(null),!L3e(e))return null;const s=S3e(e);if(!s)return null;const l=i??s;return l.x-n,l.y-n,l.width+n*2,l.height+n*2,null}const KV=22,XV=11,YV=3,QV=2,oT=8,E3e={http:"solid",event:"dashed",queue:"dotted",default:"solid"},UQ=["default","slate","blue","green","amber","red","purple","pink"],G0=[{value:"solid",icon:gR,label:"Solid",testId:"style-tab-border-style-solid"},{value:"dashed",icon:oY,label:"Dashed",testId:"style-tab-border-style-dashed"},{value:"dotted",icon:iY,label:"Dotted",testId:"style-tab-border-style-dotted"}],JV=[{value:"solid",icon:gR,label:"Solid",testId:"style-tab-edge-style-solid"},{value:"dashed",icon:oY,label:"Dashed",testId:"style-tab-edge-style-dashed"},{value:"dotted",icon:iY,label:"Dotted",testId:"style-tab-edge-style-dotted"}],eB=[{value:"curve",icon:aY,label:"Curve",testId:"style-tab-edge-path-curve"},{value:"step",icon:Pye,label:"Zigzag",testId:"style-tab-edge-path-step"}],tB=[{value:"none",icon:l2,label:"None",testId:"style-tab-direction-none"},{value:"backward",icon:c2,label:"Backward",testId:"style-tab-direction-backward"},{value:"forward",icon:ru,label:"Forward",testId:"style-tab-direction-forward"},{value:"both",icon:Xd,label:"Both",testId:"style-tab-direction-both"}];function A3e({nodes:e,connectors:t,onStyleNode:n,onStyleNodePreview:r,onStyleNodes:o,onStyleNodesPreview:i,onStyleConnector:a,onStyleConnectorPreview:s,onRequestIconReplace:l}){const c=e.length>0,h=t.length>0;if(!c&&!h)return null;const d=c&&!h,f=!c&&h,p=e[0],k=t[0],v=e.filter(fe=>fe.type!=="iconNode"),w=v[0],g=d&&e.every(fe=>fe.type==="iconNode"),M=g?e.find(fe=>fe.type==="iconNode"):void 0,x=d&&e.every(fe=>fe.type==="imageNode"),b=d&&(p==null?void 0:p.type)==="shapeNode"&&p.data.shape==="text",S=(f?k==null?void 0:k.color:w==null?void 0:w.data.borderColor)??"default",C=(w==null?void 0:w.data.backgroundColor)??"default",L=(w==null?void 0:w.data.borderStyle)??"solid",P=k?k.style??E3e[k.kind]:"solid",T=(k==null?void 0:k.direction)??"forward",E=(k==null?void 0:k.path)??"curve",z=fe=>{for(const we of e)n(we.id,{borderColor:fe});for(const we of t)a(we.id,{color:fe})},A=fe=>{for(const we of e)n(we.id,{backgroundColor:fe})},U=fe=>{for(const we of e)n(we.id,{borderStyle:fe});for(const we of t)a(we.id,{style:fe})},R=fe=>{for(const we of e)n(we.id,{borderSize:fe});for(const we of t)a(we.id,{borderSize:fe})},V=fe=>{for(const we of e)r==null||r(we.id,{borderSize:fe});for(const we of t)s==null||s(we.id,{borderSize:fe})},O=fe=>{if(e.length>1&&o)o(e.map(we=>we.id),{fontSize:fe});else for(const we of e)n(we.id,{fontSize:fe})},B=fe=>{if(e.length>1&&i)i(e.map(we=>we.id),{fontSize:fe});else for(const we of e)r==null||r(we.id,{fontSize:fe})},D=v.length>1&&new Set(v.map(fe=>fe.data.fontSize??KV)).size>1,N=fe=>{if(e.length>1&&o)o(e.map(we=>we.id),{textColor:fe});else for(const we of e)n(we.id,{textColor:fe})},I=(w==null?void 0:w.data.textColor)??(b?(w==null?void 0:w.data.borderColor)??"default":"default"),W=fe=>{for(const we of t)a(we.id,{fontSize:fe})},H=fe=>{for(const we of t)s==null||s(we.id,{fontSize:fe})},j=t.length>1&&new Set(t.map(fe=>fe.fontSize??XV)).size>1,G=fe=>{for(const we of e)n(we.id,{cornerRadius:fe})},X=fe=>{for(const we of e)r==null||r(we.id,{cornerRadius:fe})},Y=v.length>1&&new Set(v.map(fe=>fe.data.cornerRadius??oT)).size>1,re=fe=>{for(const we of t)a(we.id,{path:fe})},ne=fe=>{for(const we of t)a(we.id,{direction:fe})},ae=fe=>{for(const we of e)n(we.id,{color:fe})},ve=(M==null?void 0:M.data.color)??"default",be=f?(k==null?void 0:k.borderSize)??QV:(w==null?void 0:w.data.borderSize)??YV,me=f?QV:YV,ge=f?"edge":"border",ee=f?"Connector color":b?"Color":"Border color",ke=f?"connector color":b?"color":"border color",Fe=f?"style-tab-edge-color-trigger":b?"style-tab-color-trigger":"style-tab-border-color-trigger",rt=f||b?"style-tab-color":"style-tab-border-color";if(g){const fe=!!l&&e.length===1&&!!M,we=()=>{M&&l&&l(M.id)};return y.jsx(L2,{delayDuration:300,children:y.jsxs("div",{"data-testid":"canvas-style-strip",className:"sf:pointer-events-auto sf:flex sf:flex-col sf:items-center sf:gap-1 sf:rounded-lg sf:border sf:border-border sf:bg-background/95 sf:p-1 sf:shadow-md sf:backdrop-blur",children:[y.jsx(nB,{testId:"style-strip-icon-color",tooltip:"Icon color",ariaLabel:"icon color",activeToken:ve,previewKind:"edge",tokenTestIdPrefix:"style-tab-icon-color",innerTestId:"style-tab-icon-color-trigger",onSelect:ae}),fe?y.jsxs(Bh,{children:[y.jsx($h,{asChild:!0,children:y.jsx("button",{type:"button","data-testid":"style-strip-change-icon","aria-label":"change icon",title:"Change icon",onClick:we,className:ie("sf:inline-flex sf:h-8 sf:w-8 sf:items-center sf:justify-center sf:rounded-md sf:text-muted-foreground sf:transition-colors sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-1"),children:y.jsx(lu,{className:"sf:h-4 sf:w-4"})})}),y.jsx(td,{side:"right",className:"sf:px-2 sf:py-1 sf:text-xs",children:"Change icon"})]}):null]})})}if(x){const fe=e[0],we=(fe==null?void 0:fe.data.borderColor)??"default",Se=(fe==null?void 0:fe.data.borderStyle)??"solid",Oe=(fe==null?void 0:fe.data.borderWidth)??1,te=st=>{for(const Ne of e)n(Ne.id,{borderColor:st})},de=st=>{for(const Ne of e)n(Ne.id,{borderStyle:st})},Pe=st=>{for(const Ne of e)n(Ne.id,{borderWidth:st})},qe=st=>{for(const Ne of e)r==null||r(Ne.id,{borderWidth:st})},We=st=>{for(const Ne of e)n(Ne.id,{cornerRadius:st})},Rt=st=>{for(const Ne of e)r==null||r(Ne.id,{cornerRadius:st})};return y.jsx(L2,{delayDuration:300,children:y.jsxs("div",{"data-testid":"canvas-style-strip",className:"sf:pointer-events-auto sf:flex sf:flex-col sf:items-center sf:gap-1 sf:rounded-lg sf:border sf:border-border sf:bg-background/95 sf:p-1 sf:shadow-md sf:backdrop-blur",children:[y.jsx(nB,{testId:"style-strip-image-border-color",tooltip:"Border color",ariaLabel:"image border color",activeToken:we,previewKind:"border",tokenTestIdPrefix:"style-tab-image-border-color",innerTestId:"style-tab-image-border-color-trigger",onSelect:te}),y.jsx(jo,{testId:"style-strip-image-border-style",tooltip:"Border style",ariaLabel:"image border style",renderIcon:()=>{var Ne;const st=((Ne=G0.find(ot=>ot.value===Se))==null?void 0:Ne.icon)??gR;return y.jsx(st,{className:"sf:h-4 sf:w-4"})},children:y.jsx(Sd,{ariaLabel:"Border style",value:Se,onChange:de,options:G0})}),y.jsx(jo,{testId:"style-strip-image-border-width",tooltip:"Border width",ariaLabel:"image border width",renderIcon:()=>y.jsx("span",{className:"sf:font-mono sf:text-[10px] sf:tabular-nums",children:Oe}),children:y.jsx(Ed,{value:fe==null?void 0:fe.data.borderWidth,defaultValue:1,min:1,max:8,suffix:"px",onPreview:qe,onCommit:Pe,testId:"style-tab-image-border-width-slider"})}),y.jsx(jo,{testId:"style-strip-image-corner-radius",tooltip:"Corners",ariaLabel:"image corner radius",renderIcon:()=>y.jsx(su,{className:"sf:h-4 sf:w-4"}),children:y.jsx(Ed,{value:fe==null?void 0:fe.data.cornerRadius,defaultValue:oT,min:0,max:32,suffix:"px",onPreview:Rt,onCommit:We,testId:"style-tab-image-corner-radius-slider"})})]})})}const mt=d&&!b,ht=!b,le=!f,Q=()=>{if(f){const Se=Kd[S].edge;return y.jsx("span",{className:"sf:inline-block sf:h-5 sf:w-5 sf:rounded-full sf:ring-1 sf:ring-border",style:{backgroundColor:Se}})}const fe=Kd[S].border,we=Kd[C].background;return y.jsx("span",{className:"sf:inline-block sf:h-5 sf:w-5 sf:rounded-md sf:ring-1 sf:ring-border",style:{backgroundColor:we,border:`2px solid ${fe}`}})};return y.jsx(L2,{delayDuration:300,children:y.jsxs("div",{"data-testid":"canvas-style-strip",className:"sf:pointer-events-auto sf:flex sf:flex-col sf:items-center sf:gap-1 sf:rounded-lg sf:border sf:border-border sf:bg-background/95 sf:p-1 sf:shadow-md sf:backdrop-blur",children:[b?null:y.jsx(jo,{testId:"style-strip-colors",tooltip:"Colors",ariaLabel:"colors",renderIcon:Q,children:y.jsxs("div",{className:"sf:flex sf:w-56 sf:flex-col sf:gap-3",children:[y.jsx(A1,{label:ee,children:y.jsx(iT,{testId:"style-strip-border-color",activeToken:S,previewKind:ge,tokenTestIdPrefix:rt,innerTestId:Fe,ariaLabel:ke,onSelect:z})}),mt?y.jsx(A1,{label:"Fill",children:y.jsx(iT,{testId:"style-strip-fill",activeToken:C,previewKind:"background",tokenTestIdPrefix:"style-tab-background-color",innerTestId:"style-tab-background-color-trigger",ariaLabel:"fill",onSelect:A})}):null]})}),ht?y.jsx(jo,{testId:"style-strip-border",tooltip:f?"Connector":"Border",ariaLabel:f?"connector":"border",renderIcon:()=>{var we,Se;const fe=(f?(we=JV.find(Oe=>Oe.value===P))==null?void 0:we.icon:(Se=G0.find(Oe=>Oe.value===L))==null?void 0:Se.icon)??gR;return y.jsx(fe,{className:"sf:h-4 sf:w-4"})},children:y.jsxs("div",{className:"sf:flex sf:w-56 sf:flex-col sf:gap-3",children:[y.jsx(A1,{label:"Style",testId:"style-strip-border-style",children:f?y.jsx(Sd,{ariaLabel:"Connector style",value:P,onChange:fe=>U(fe),options:JV}):y.jsx(Sd,{ariaLabel:"Border style",value:L,onChange:fe=>U(fe),options:G0})}),y.jsx(A1,{label:"Width",testId:"style-strip-border-size",children:y.jsx(Ed,{value:be,defaultValue:me,min:1,max:8,suffix:"px",onPreview:V,onCommit:R,testId:f?"style-tab-stroke-width-slider":"style-tab-border-size-slider"})})]})}):null,c||f?y.jsx(jo,{testId:"style-strip-text",tooltip:"Text",ariaLabel:"text",renderIcon:()=>y.jsx(cu,{className:"sf:h-4 sf:w-4"}),children:y.jsxs("div",{className:"sf:flex sf:w-56 sf:flex-col sf:gap-3",children:[y.jsx(A1,{label:"Size",testId:f?"style-strip-connector-font-size":"style-strip-font-size",children:y.jsx(Ed,{value:f?k==null?void 0:k.fontSize:w==null?void 0:w.data.fontSize,defaultValue:f?XV:KV,min:f?8:10,max:32,suffix:"px",indeterminate:f?j:D,onPreview:f?H:B,onCommit:f?W:O,testId:f?"style-tab-connector-font-size-slider":"style-tab-font-size-slider"})}),le?y.jsx(A1,{label:"Color",children:y.jsx(iT,{testId:"style-strip-text-color",activeToken:I,previewKind:"edge",tokenTestIdPrefix:"style-tab-text-color",innerTestId:"style-tab-text-color-trigger",ariaLabel:"text color",onSelect:N})}):null]})}):null,c&&!b?y.jsx(jo,{testId:"style-strip-corner-radius",tooltip:"Corners",ariaLabel:"corner radius",renderIcon:()=>y.jsx(su,{className:"sf:h-4 sf:w-4"}),children:y.jsx(Ed,{value:w==null?void 0:w.data.cornerRadius,defaultValue:oT,min:0,max:32,suffix:"px",indeterminate:Y,onPreview:X,onCommit:G,testId:"style-tab-corner-radius-slider"})}):null,f?y.jsx(jo,{testId:"style-strip-path",tooltip:"Connector path",ariaLabel:"connector path",renderIcon:()=>{var we;const fe=((we=eB.find(Se=>Se.value===E))==null?void 0:we.icon)??aY;return y.jsx(fe,{className:"sf:h-4 sf:w-4"})},children:y.jsx(Sd,{ariaLabel:"Connector path",value:E,onChange:re,options:eB})}):null,f?y.jsx(jo,{testId:"style-strip-direction",tooltip:"Direction",ariaLabel:"direction",renderIcon:()=>{var we;const fe=((we=tB.find(Se=>Se.value===T))==null?void 0:we.icon)??ru;return y.jsx(fe,{className:"sf:h-4 sf:w-4"})},children:y.jsx(Sd,{ariaLabel:"Connector direction",value:T,onChange:ne,options:tB})}):null]})})}function WQ(e,t){const n=Kd[e];return t==="background"?{backgroundColor:n.background,borderColor:n.border}:t==="edge"?{backgroundColor:n.edge,borderColor:n.edge}:{borderColor:n.border,backgroundColor:n.background}}function P3e(e,t){const n=Kd[e];return t==="background"?{backgroundColor:n.background}:t==="edge"?{backgroundColor:n.edge}:{backgroundColor:n.border}}function nB({testId:e,tooltip:t,ariaLabel:n,activeToken:r,previewKind:o,tokenTestIdPrefix:i,innerTestId:a,onSelect:s}){const[l,c]=m.useState(!1),h=r==="default";return y.jsxs(Ju,{open:l,onOpenChange:c,children:[y.jsxs(Bh,{children:[y.jsx($h,{asChild:!0,children:y.jsx(Eh,{asChild:!0,children:y.jsx("button",{type:"button","data-testid":e,"data-active-token":r,"aria-label":`${n}: ${r}`,title:t,className:ie("sf:group sf:relative sf:inline-flex sf:h-8 sf:w-8 sf:items-center sf:justify-center sf:rounded-md sf:text-muted-foreground sf:transition-colors sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-1"),children:y.jsx("span",{"data-testid":a,className:"sf:relative sf:h-5 sf:w-5 sf:rounded-full sf:ring-1 sf:ring-border",style:P3e(r,o),children:h?y.jsx("span",{"aria-hidden":"true",className:"sf:pointer-events-none sf:absolute sf:inset-0 sf:rounded-full",style:{backgroundImage:"linear-gradient(45deg, transparent 45%, currentColor 45%, currentColor 55%, transparent 55%)",color:"hsl(var(--muted-foreground))",opacity:.5}}):null})})})}),y.jsx(td,{side:"right",className:"sf:px-2 sf:py-1 sf:text-xs",children:t})]}),y.jsx(u1,{side:"right",align:"start",className:"sf:w-auto sf:p-2","data-testid":`${a}-popover`,children:y.jsx("div",{className:"sf:grid sf:grid-cols-4 sf:gap-1.5",children:UQ.map(d=>{const f=r===d;return y.jsx("button",{type:"button",onClick:()=>{s(d),c(!1)},"data-testid":`${i}-${d}`,"data-active":f,"aria-label":`${n} ${d}`,"aria-pressed":f,title:d,className:ie("sf:relative sf:flex sf:h-7 sf:w-7 sf:items-center sf:justify-center sf:rounded-full sf:border-2 sf:transition-all",f?"sf:ring-2 sf:ring-ring sf:ring-offset-2 sf:ring-offset-popover":"sf:hover:scale-110"),style:WQ(d,o),children:f?y.jsx(fo,{className:"sf:h-3 sf:w-3 sf:drop-shadow-sm",style:{color:"hsl(var(--foreground))"}}):null},d)})})})]})}function iT({testId:e,activeToken:t,previewKind:n,tokenTestIdPrefix:r,innerTestId:o,ariaLabel:i,onSelect:a}){return y.jsx("div",{"data-testid":e,"data-active-token":t,"data-inner-testid":o,className:"sf:grid sf:grid-cols-4 sf:gap-1.5",children:UQ.map(s=>{const l=t===s;return y.jsx("button",{type:"button",onClick:()=>a(s),"data-testid":`${r}-${s}`,"data-active":l,"aria-label":`${i} ${s}`,"aria-pressed":l,title:s,className:ie("sf:relative sf:flex sf:h-7 sf:w-7 sf:items-center sf:justify-center sf:rounded-full sf:border-2 sf:transition-all",l?"sf:ring-2 sf:ring-ring sf:ring-offset-2 sf:ring-offset-popover":"sf:hover:scale-110"),style:WQ(s,n),children:l?y.jsx(fo,{className:"sf:h-3 sf:w-3 sf:drop-shadow-sm",style:{color:"hsl(var(--foreground))"}}):null},s)})})}function A1({label:e,testId:t,children:n}){return y.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-1.5","data-testid":t,children:[y.jsx("div",{className:"sf:text-[11px] sf:font-medium sf:uppercase sf:tracking-wide sf:text-muted-foreground",children:e}),n]})}function jo({testId:e,tooltip:t,ariaLabel:n,renderIcon:r,children:o}){const[i,a]=m.useState(!1);return y.jsxs(Ju,{open:i,onOpenChange:a,children:[y.jsxs(Bh,{children:[y.jsx($h,{asChild:!0,children:y.jsx(Eh,{asChild:!0,children:y.jsx("button",{type:"button","data-testid":e,"aria-label":n,title:t,className:ie("sf:inline-flex sf:h-8 sf:w-8 sf:items-center sf:justify-center sf:rounded-md sf:text-muted-foreground sf:transition-colors sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-1"),children:r()})})}),y.jsx(td,{side:"right",className:"sf:px-2 sf:py-1 sf:text-xs",children:t})]}),y.jsx(u1,{side:"right",align:"start",className:"sf:w-auto sf:p-3",children:o})]})}function Ed({value:e,defaultValue:t,min:n,max:r,suffix:o,indeterminate:i,onPreview:a,onCommit:s,testId:l}){const c=e??t,[h,d]=m.useState(c),[f,p]=m.useState(!1);m.useEffect(()=>{d(c),p(!1)},[c]);const k=i&&!f;return y.jsxs("div",{className:"sf:flex sf:w-48 sf:items-center sf:gap-3",children:[y.jsx(SY,{min:n,max:r,step:1,value:[h],onValueChange:([v])=>{const w=v??n;d(w),p(!0),a==null||a(w)},onValueCommit:([v])=>s(v??n),"data-testid":l,"data-indeterminate":k?"true":void 0,className:ie("sf:flex-1",k&&"sf:opacity-60")}),y.jsx("span",{"data-testid":`${l}-value`,className:"sf:w-12 sf:shrink-0 sf:text-right sf:text-xs sf:tabular-nums sf:text-muted-foreground",children:k?"Mixed":y.jsxs(y.Fragment,{children:[h,o]})})]})}const R3e="modulepreload",z3e=function(e){return"/"+e},rB={},j3e=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),s=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));o=Promise.allSettled(n.map(l=>{if(l=z3e(l),l in rB)return;rB[l]=!0;const c=l.endsWith(".css"),h=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${h}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":R3e,c||(d.as="script"),d.crossOrigin="",d.href=l,s&&d.setAttribute("nonce",s),document.head.appendChild(d),c)return new Promise((f,p)=>{d.addEventListener("load",f),d.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${l}`)))})}))}function i(a){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=a,window.dispatchEvent(s),!s.defaultPrevented)throw a}return o.then(a=>{for(const s of a||[])s.status==="rejected"&&i(s.reason);return t().catch(i)})};function T3e(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const n=document.implementation.createHTMLDocument(),r=n.createElement("base"),o=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(o),t&&(r.href=t),o.href=e,o.href}const N3e=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function Di(e){const t=[];for(let n=0,r=e.length;n<r;n++)t.push(e[n]);return t}let P1=null;function GQ(e={}){return P1||(e.includeStyleProperties?(P1=e.includeStyleProperties,P1):(P1=Di(window.getComputedStyle(document.documentElement)),P1))}function bR(e,t){const r=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function D3e(e){const t=bR(e,"border-left-width"),n=bR(e,"border-right-width");return e.clientWidth+t+n}function _3e(e){const t=bR(e,"border-top-width"),n=bR(e,"border-bottom-width");return e.clientHeight+t+n}function ZQ(e,t={}){const n=t.width||D3e(e),r=t.height||_3e(e);return{width:n,height:r}}function H3e(){let e,t;try{t=process}catch{}const n=t&&t.env?t.env.devicePixelRatio:null;return n&&(e=parseInt(n,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}const _n=16384;function F3e(e){(e.width>_n||e.height>_n)&&(e.width>_n&&e.height>_n?e.width>e.height?(e.height*=_n/e.width,e.width=_n):(e.width*=_n/e.height,e.height=_n):e.width>_n?(e.height*=_n/e.width,e.width=_n):(e.width*=_n/e.height,e.height=_n))}function CR(e){return new Promise((t,n)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=n,r.crossOrigin="anonymous",r.decoding="async",r.src=e})}async function O3e(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function q3e(e,t,n){const r="http://www.w3.org/2000/svg",o=document.createElementNS(r,"svg"),i=document.createElementNS(r,"foreignObject");return o.setAttribute("width",`${t}`),o.setAttribute("height",`${n}`),o.setAttribute("viewBox",`0 0 ${t} ${n}`),i.setAttribute("width","100%"),i.setAttribute("height","100%"),i.setAttribute("x","0"),i.setAttribute("y","0"),i.setAttribute("externalResourcesRequired","true"),o.appendChild(i),i.appendChild(e),O3e(o)}const An=(e,t)=>{if(e instanceof t)return!0;const n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||An(n,t)};function V3e(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function B3e(e,t){return GQ(t).map(n=>{const r=e.getPropertyValue(n),o=e.getPropertyPriority(n);return`${n}: ${r}${o?" !important":""};`}).join(" ")}function $3e(e,t,n,r){const o=`.${e}:${t}`,i=n.cssText?V3e(n):B3e(n,r);return document.createTextNode(`${o}{${i}}`)}function oB(e,t,n,r){const o=window.getComputedStyle(e,n),i=o.getPropertyValue("content");if(i===""||i==="none")return;const a=N3e();try{t.className=`${t.className} ${a}`}catch{return}const s=document.createElement("style");s.appendChild($3e(a,n,o,r)),t.appendChild(s)}function U3e(e,t,n){oB(e,t,":before",n),oB(e,t,":after",n)}const iB="application/font-woff",aB="image/jpeg",W3e={woff:iB,woff2:iB,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:aB,jpeg:aB,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function G3e(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function wH(e){const t=G3e(e).toLowerCase();return W3e[t]||""}function Z3e(e){return e.split(/,/)[1]}function eD(e){return e.search(/^(data:)/)!==-1}function K3e(e,t){return`data:${t};base64,${e}`}async function KQ(e,t,n){const r=await fetch(e,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const o=await r.blob();return new Promise((i,a)=>{const s=new FileReader;s.onerror=a,s.onloadend=()=>{try{i(n({res:r,result:s.result}))}catch(l){a(l)}},s.readAsDataURL(o)})}const aT={};function X3e(e,t,n){let r=e.replace(/\?.*/,"");return n&&(r=e),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function MH(e,t,n){const r=X3e(e,t,n.includeQueryParams);if(aT[r]!=null)return aT[r];n.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let o;try{const i=await KQ(e,n.fetchRequestInit,({res:a,result:s})=>(t||(t=a.headers.get("Content-Type")||""),Z3e(s)));o=K3e(i,t)}catch(i){o=n.imagePlaceholder||"";let a=`Failed to fetch resource: ${e}`;i&&(a=typeof i=="string"?i:i.message),a&&console.warn(a)}return aT[r]=o,o}async function Y3e(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):CR(t)}async function Q3e(e,t){if(e.currentSrc){const i=document.createElement("canvas"),a=i.getContext("2d");i.width=e.clientWidth,i.height=e.clientHeight,a==null||a.drawImage(e,0,0,i.width,i.height);const s=i.toDataURL();return CR(s)}const n=e.poster,r=wH(n),o=await MH(n,r,t);return CR(o)}async function J3e(e,t){var n;try{if(!((n=e==null?void 0:e.contentDocument)===null||n===void 0)&&n.body)return await Tz(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function ewe(e,t){return An(e,HTMLCanvasElement)?Y3e(e):An(e,HTMLVideoElement)?Q3e(e,t):An(e,HTMLIFrameElement)?J3e(e,t):e.cloneNode(XQ(e))}const twe=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",XQ=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function nwe(e,t,n){var r,o;if(XQ(t))return t;let i=[];return twe(e)&&e.assignedNodes?i=Di(e.assignedNodes()):An(e,HTMLIFrameElement)&&(!((r=e.contentDocument)===null||r===void 0)&&r.body)?i=Di(e.contentDocument.body.childNodes):i=Di(((o=e.shadowRoot)!==null&&o!==void 0?o:e).childNodes),i.length===0||An(e,HTMLVideoElement)||await i.reduce((a,s)=>a.then(()=>Tz(s,n)).then(l=>{l&&t.appendChild(l)}),Promise.resolve()),t}function rwe(e,t,n){const r=t.style;if(!r)return;const o=window.getComputedStyle(e);o.cssText?(r.cssText=o.cssText,r.transformOrigin=o.transformOrigin):GQ(n).forEach(i=>{let a=o.getPropertyValue(i);i==="font-size"&&a.endsWith("px")&&(a=`${Math.floor(parseFloat(a.substring(0,a.length-2)))-.1}px`),An(e,HTMLIFrameElement)&&i==="display"&&a==="inline"&&(a="block"),i==="d"&&t.getAttribute("d")&&(a=`path(${t.getAttribute("d")})`),r.setProperty(i,a,o.getPropertyPriority(i))})}function owe(e,t){An(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),An(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function iwe(e,t){if(An(e,HTMLSelectElement)){const n=t,r=Array.from(n.children).find(o=>e.value===o.getAttribute("value"));r&&r.setAttribute("selected","")}}function awe(e,t,n){return An(t,Element)&&(rwe(e,t,n),U3e(e,t,n),owe(e,t),iwe(e,t)),t}async function swe(e,t){const n=e.querySelectorAll?e.querySelectorAll("use"):[];if(n.length===0)return e;const r={};for(let i=0;i<n.length;i++){const s=n[i].getAttribute("xlink:href");if(s){const l=e.querySelector(s),c=document.querySelector(s);!l&&c&&!r[s]&&(r[s]=await Tz(c,t,!0))}}const o=Object.values(r);if(o.length){const i="http://www.w3.org/1999/xhtml",a=document.createElementNS(i,"svg");a.setAttribute("xmlns",i),a.style.position="absolute",a.style.width="0",a.style.height="0",a.style.overflow="hidden",a.style.display="none";const s=document.createElementNS(i,"defs");a.appendChild(s);for(let l=0;l<o.length;l++)s.appendChild(o[l]);e.appendChild(a)}return e}async function Tz(e,t,n){return!n&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(r=>ewe(r,t)).then(r=>nwe(e,r,t)).then(r=>awe(e,r,t)).then(r=>swe(r,t))}const YQ=/url\((['"]?)([^'"]+?)\1\)/g,lwe=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,cwe=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function uwe(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function dwe(e){const t=[];return e.replace(YQ,(n,r,o)=>(t.push(o),n)),t.filter(n=>!eD(n))}async function hwe(e,t,n,r,o){try{const i=n?T3e(t,n):t,a=wH(t);let s;return o||(s=await MH(i,a,r)),e.replace(uwe(t),`$1${s}$3`)}catch{}return e}function fwe(e,{preferredFontFormat:t}){return t?e.replace(cwe,n=>{for(;;){const[r,,o]=lwe.exec(n)||[];if(!o)return"";if(o===t)return`src: ${r};`}}):e}function QQ(e){return e.search(YQ)!==-1}async function JQ(e,t,n){if(!QQ(e))return e;const r=fwe(e,n);return dwe(r).reduce((i,a)=>i.then(s=>hwe(s,a,t,n)),Promise.resolve(r))}async function R1(e,t,n){var r;const o=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(e);if(o){const i=await JQ(o,null,n);return t.style.setProperty(e,i,t.style.getPropertyPriority(e)),!0}return!1}async function pwe(e,t){await R1("background",e,t)||await R1("background-image",e,t),await R1("mask",e,t)||await R1("-webkit-mask",e,t)||await R1("mask-image",e,t)||await R1("-webkit-mask-image",e,t)}async function ywe(e,t){const n=An(e,HTMLImageElement);if(!(n&&!eD(e.src))&&!(An(e,SVGImageElement)&&!eD(e.href.baseVal)))return;const r=n?e.src:e.href.baseVal,o=await MH(r,wH(r),t);await new Promise((i,a)=>{e.onload=i,e.onerror=t.onImageErrorHandler?(...l)=>{try{i(t.onImageErrorHandler(...l))}catch(c){a(c)}}:a;const s=e;s.decode&&(s.decode=i),s.loading==="lazy"&&(s.loading="eager"),n?(e.srcset="",e.src=o):e.href.baseVal=o})}async function mwe(e,t){const r=Di(e.childNodes).map(o=>eJ(o,t));await Promise.all(r).then(()=>e)}async function eJ(e,t){An(e,Element)&&(await pwe(e,t),await ywe(e,t),await mwe(e,t))}function kwe(e,t){const{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);const r=t.style;return r!=null&&Object.keys(r).forEach(o=>{n[o]=r[o]}),e}const sB={};async function lB(e){let t=sB[e];if(t!=null)return t;const r=await(await fetch(e)).text();return t={url:e,cssText:r},sB[e]=t,t}async function cB(e,t){let n=e.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,i=(n.match(/url\([^)]+\)/g)||[]).map(async a=>{let s=a.replace(r,"$1");return s.startsWith("https://")||(s=new URL(s,e.url).href),KQ(s,t.fetchRequestInit,({result:l})=>(n=n.replace(a,`url(${l})`),[a,l]))});return Promise.all(i).then(()=>n)}function uB(e){if(e==null)return[];const t=[],n=/(\/\*[\s\S]*?\*\/)/gi;let r=e.replace(n,"");const o=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const l=o.exec(r);if(l===null)break;t.push(l[0])}r=r.replace(o,"");const i=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,a="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",s=new RegExp(a,"gi");for(;;){let l=i.exec(r);if(l===null){if(l=s.exec(r),l===null)break;i.lastIndex=s.lastIndex}else s.lastIndex=i.lastIndex;t.push(l[0])}return t}async function gwe(e,t){const n=[],r=[];return e.forEach(o=>{if("cssRules"in o)try{Di(o.cssRules||[]).forEach((i,a)=>{if(i.type===CSSRule.IMPORT_RULE){let s=a+1;const l=i.href,c=lB(l).then(h=>cB(h,t)).then(h=>uB(h).forEach(d=>{try{o.insertRule(d,d.startsWith("@import")?s+=1:o.cssRules.length)}catch(f){console.error("Error inserting rule from remote css",{rule:d,error:f})}})).catch(h=>{console.error("Error loading remote css",h.toString())});r.push(c)}})}catch(i){const a=e.find(s=>s.href==null)||document.styleSheets[0];o.href!=null&&r.push(lB(o.href).then(s=>cB(s,t)).then(s=>uB(s).forEach(l=>{a.insertRule(l,a.cssRules.length)})).catch(s=>{console.error("Error loading remote stylesheet",s)})),console.error("Error inlining remote css file",i)}}),Promise.all(r).then(()=>(e.forEach(o=>{if("cssRules"in o)try{Di(o.cssRules||[]).forEach(i=>{n.push(i)})}catch(i){console.error(`Error while reading CSS rules from ${o.href}`,i)}}),n))}function xwe(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>QQ(t.style.getPropertyValue("src")))}async function vwe(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const n=Di(e.ownerDocument.styleSheets),r=await gwe(n,t);return xwe(r)}function tJ(e){return e.trim().replace(/["']/g,"")}function wwe(e){const t=new Set;function n(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(i=>{t.add(tJ(i))}),Array.from(r.children).forEach(i=>{i instanceof HTMLElement&&n(i)})}return n(e),t}async function Mwe(e,t){const n=await vwe(e,t),r=wwe(e);return(await Promise.all(n.filter(i=>r.has(tJ(i.style.fontFamily))).map(i=>{const a=i.parentStyleSheet?i.parentStyleSheet.href:null;return JQ(i.cssText,a,t)}))).join(`
|
|
7838
|
-
`)}async function bwe(e,t){const n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await Mwe(e,t);if(n){const r=document.createElement("style"),o=document.createTextNode(n);r.appendChild(o),e.firstChild?e.insertBefore(r,e.firstChild):e.appendChild(r)}}async function Cwe(e,t={}){const{width:n,height:r}=ZQ(e,t),o=await Tz(e,t,!0);return await bwe(o,t),await eJ(o,t),kwe(o,t),await q3e(o,n,r)}async function Swe(e,t={}){const{width:n,height:r}=ZQ(e,t),o=await Cwe(e,t),i=await CR(o),a=document.createElement("canvas"),s=a.getContext("2d"),l=t.pixelRatio||H3e(),c=t.canvasWidth||n,h=t.canvasHeight||r;return a.width=c*l,a.height=h*l,t.skipAutoScale||F3e(a),a.style.width=`${c}`,a.style.height=`${h}`,t.backgroundColor&&(s.fillStyle=t.backgroundColor,s.fillRect(0,0,a.width,a.height)),s.drawImage(i,0,0,a.width,a.height),a}async function Lwe(e,t={}){return(await Swe(e,t)).toDataURL()}const Iwe=e=>e instanceof Element?!(e.classList.contains("react-flow__minimap")||e.classList.contains("react-flow__controls")||e.classList.contains("react-flow__panel")):!0,dB="#0a0a0c",Ewe=e=>{let t=e;for(;t&&!t.classList.contains("seeflow-canvas-root");)t=t.parentElement;if(!t)return dB;const n=getComputedStyle(t).getPropertyValue("--bg-canvas").trim();return n.length>0?n:dB},Awe=async e=>{const t=await Lwe(e,{cacheBust:!0,filter:Iwe,backgroundColor:Ewe(e)}),n=await new Promise((r,o)=>{const i=new Image;i.onload=()=>r({width:i.naturalWidth,height:i.naturalHeight}),i.onerror=()=>o(new Error("Failed to decode captured image")),i.src=t});return{dataUrl:t,...n}},Pwe=(e,t)=>{const n=document.createElement("a");n.href=e,n.download=t,n.rel="noopener",document.body.appendChild(n),n.click(),n.remove()},Rwe=e=>{const t=e.replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"");return t.length>0?t.slice(0,80):"canvas"},hB=(e,t)=>`${Rwe(e??"canvas")}.${t}`,zwe=({projectId:e,getReactFlow:t})=>{const[n,r]=m.useState(null),o=m.useCallback(()=>r(null),[]),i=m.useCallback(async()=>{const c=t();if(!c)return null;const h=document.querySelector(".react-flow__viewport");if(!h)return null;const d=c.getViewport();try{return await c.fitView({duration:0,padding:.1}),await new Promise(f=>requestAnimationFrame(()=>f())),await Awe(h)}finally{c.setViewport(d,{duration:0})}},[t]),a=m.useCallback(async()=>{r(null);try{const c=await i();if(!c)return;Pwe(c.dataUrl,hB(e,"png"))}catch(c){r(c instanceof Error?c.message:String(c))}},[i,e]),s=m.useCallback(async()=>{r(null);try{const c=await i();if(!c)return;const{jsPDF:h}=await j3e(async()=>{const{jsPDF:p}=await import("./jspdf.es.min-DLHTB6Rk.js").then(k=>k.j);return{jsPDF:p}},[]),d=c.width>c.height?"landscape":"portrait",f=new h({orientation:d,unit:"px",format:[c.width,c.height],hotfixes:["px_scaling"]});f.addImage(c.dataUrl,"PNG",0,0,c.width,c.height),f.save(hB(e,"pdf"))}catch(c){r(c instanceof Error?c.message:String(c))}},[i,e]),l=m.useCallback(async()=>{const c=await i();return c==null?void 0:c.dataUrl},[i]);return{exportPdf:s,exportPng:a,capturePreview:l,lastError:n,clearError:o}},jwe=12,Twe=1200;function Nwe(e,t={}){const n=t.idleMs??Twe;let r,o=null,i=null;const a=typeof requestAnimationFrame<"u",s=()=>{r!==void 0&&(clearTimeout(r),r=void 0)},l=()=>{i!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(i),i=null},c=()=>{if(i=null,!o)return;const{clientX:p,clientY:k}=o;o=null;const v=e.getBoundingClientRect();e.style.setProperty("--mx",`${p-v.left}px`),e.style.setProperty("--my",`${k-v.top}px`),e.dataset.active="true",s(),r=setTimeout(()=>{e.dataset.active="false",r=void 0},n)};return{onMove:p=>{if(o={clientX:p.clientX,clientY:p.clientY},!a){c();return}i===null&&(i=requestAnimationFrame(c))},onLeave:()=>{l(),o=null,s(),e.dataset.active="false"},dispose:()=>{l(),o=null,s()}}}function Dwe(){const e=m.useRef(null),t=_e(a=>a.transform,(a,s)=>a[0]===s[0]&&a[1]===s[1]&&a[2]===s[2]),[n,r,o]=t,i=jwe*o;return m.useEffect(()=>{var d;const a=e.current;if(!a)return;const s=(d=a.parentElement)==null?void 0:d.querySelector(".react-flow__pane");if(!s)return;const{onMove:l,onLeave:c,dispose:h}=Nwe(a);return s.addEventListener("mousemove",l,{passive:!0}),s.addEventListener("mouseleave",c,{passive:!0}),()=>{s.removeEventListener("mousemove",l),s.removeEventListener("mouseleave",c),h()}},[]),y.jsx("div",{ref:e,className:"glow-overlay","data-active":"false","data-testid":"canvas-glow-overlay",style:{backgroundPosition:`${n}px ${r}px`,backgroundSize:`${i}px ${i}px`}})}const _we={showToolbar:!0,showStyleStrip:!0,showDetailPanel:!0,showStatusBadges:!0,showResizeHandles:!0,showControls:!0,showShareMenu:!0,showRestart:!0,enableKeyboard:!0,enableContextMenu:!0,enableDragDrop:!0,enableImageDrop:!0,enableZoom:!0,enablePan:!0,enableSelection:!0,enableNodeMove:!0,enableEmbed:!1},Hwe={showToolbar:!1,showStyleStrip:!1,showDetailPanel:!1,showStatusBadges:!0,showResizeHandles:!1,showControls:!0,showShareMenu:!0,showRestart:!1,enableKeyboard:!1,enableContextMenu:!1,enableDragDrop:!1,enableImageDrop:!1,enableZoom:!0,enablePan:!0,enableSelection:!0,enableNodeMove:!0,enableEmbed:!1},Fwe={showToolbar:!1,showStyleStrip:!1,showDetailPanel:!1,showStatusBadges:!1,showResizeHandles:!1,showControls:!1,showShareMenu:!1,showRestart:!1,enableKeyboard:!1,enableContextMenu:!1,enableDragDrop:!1,enableImageDrop:!1,enableZoom:!1,enablePan:!1,enableSelection:!1,enableNodeMove:!1,enableEmbed:!1};function Owe(e){const t=e.mode==="edit"?_we:e.mode==="mini"?Fwe:Hwe;return{showToolbar:e.showToolbar??t.showToolbar,showStyleStrip:e.showStyleStrip??t.showStyleStrip,showDetailPanel:e.showDetailPanel??t.showDetailPanel,showStatusBadges:e.showStatusBadges??t.showStatusBadges,showResizeHandles:e.showResizeHandles??t.showResizeHandles,showControls:e.showControls??t.showControls,showShareMenu:e.showShareMenu??t.showShareMenu,showRestart:e.showRestart??t.showRestart,enableKeyboard:e.enableKeyboard??t.enableKeyboard,enableContextMenu:e.enableContextMenu??t.enableContextMenu,enableDragDrop:e.enableDragDrop??t.enableDragDrop,enableImageDrop:e.enableImageDrop??t.enableImageDrop,enableZoom:e.enableZoom??t.enableZoom,enablePan:e.enablePan??t.enablePan,enableSelection:e.enableSelection??t.enableSelection,enableNodeMove:e.enableNodeMove??t.enableNodeMove,enableEmbed:e.enableEmbed??t.enableEmbed}}const fB=40,Ad={padding:.15,duration:300,includeHiddenNodes:!1};function qwe(e){return e===void 0||e===!1?{onMount:!1,onExternalNodeChange:!1}:e===!0?{onMount:!0,onExternalNodeChange:!0}:{onMount:e.onMount??!0,onExternalNodeChange:e.onExternalNodeChange??!0}}const pB=e=>{if("clientX"in e)return{clientX:e.clientX,clientY:e.clientY};const t=e.changedTouches[0]??e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null},Vwe=(e,t)=>{var r;const n=document.elementsFromPoint(e,t);for(const o of n){const i=(r=o.closest)==null?void 0:r.call(o,".react-flow__node");if(i)return i}return null},nJ=15,sT=(e,t,n)=>{const r=Vwe(t,n);if(r)return r;if(!e)return null;let o=null,i=nJ;const a=e.querySelectorAll(".react-flow__node");for(const s of a){const l=s.getBoundingClientRect();if(l.width===0||l.height===0)continue;const c=Math.max(l.left-t,0,t-l.right),h=Math.max(l.top-n,0,n-l.bottom),d=Math.hypot(c,h);d<=i&&(o=s,i=d)}return o};function yB(e,t,n,r,o){if(e==="source"?(r==null?void 0:r.targetPin)!==void 0||(r==null?void 0:r.targetHandleAutoPicked)===!1:(r==null?void 0:r.sourcePin)!==void 0||(r==null?void 0:r.sourceHandleAutoPicked)===!1)return;const a=e==="source"?n:t,s=e==="source"?t:n,l=o(a),c=o(s);if(!l||!c)return;const h=l.measured.width??l.width??0,d=l.measured.height??l.height??0,f=c.measured.width??c.width??0,p=c.measured.height??c.height??0;if(h===0||d===0||f===0||p===0)return;const k={x:l.internals.positionAbsolute.x,y:l.internals.positionAbsolute.y,w:h,h:d},v={x:c.internals.positionAbsolute.x+f/2,y:c.internals.positionAbsolute.y+p/2};return rue(k,sR(k,v))}function Bwe(e,t,n,r){if(r===null)return"no-op";const o=e==="source"?t:n;return r===(e==="source"?n:t)?"self-loop":r===o?"pin-own":"reconnect-and-pin"}const $we=(e,t)=>{if(!t)return e;const n=t.data?{...e.data,...t.data}:e.data;return{...e,...t,data:n}},Uwe=(e,t)=>t?{...e,...t}:e,Wwe={playNode:f0e,stateNode:T0e,shapeNode:L0e,imageNode:nde,iconNode:pue,htmlNode:Yue},Gwe={editableEdge:_0e},Zwe={zIndex:0},Kwe=8,mB=(e,t)=>e?typeof e=="string"?`url('#${e}')`:`url('#${`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`}')`:void 0,Xwe=e=>function({fromX:n,fromY:r,toX:o,toY:i,fromPosition:a,toPosition:s,connectionLineStyle:l}){const c=_e(W=>e.current?W.edges.find(H=>H.reconnectable===!0)??null:null),h=c==null?void 0:c.data,d=_e(W=>{var j;const H=W.connection;return((j=H==null?void 0:H.fromHandle)==null?void 0:j.nodeId)??null}),f=_e(W=>c!=null&&c.source?W.nodeLookup.get(c.source)??null:null),p=_e(W=>c!=null&&c.target?W.nodeLookup.get(c.target)??null:null),k=_e(W=>d?W.nodeLookup.get(d)??null:null),v=(c==null?void 0:c.source)===d,w=c?v?f:p:k,g=v?p:f,M=v?h==null?void 0:h.sourcePin:h==null?void 0:h.targetPin,x=v?h==null?void 0:h.sourceHandleAutoPicked:h==null?void 0:h.targetHandleAutoPicked;let b=n,S=r,C=a;if(w){const W=w.measured.width??w.width??0,H=w.measured.height??w.height??0;if(W>0&&H>0){const j={x:w.internals.positionAbsolute.x,y:w.internals.positionAbsolute.y,w:W,h:H};let G=null;if(M)G=lR(j,M);else if(x!==!1&&g){const X=g.measured.width??g.width??0,Y=g.measured.height??g.height??0;if(X>0&&Y>0){const re={x:g.internals.positionAbsolute.x+X/2,y:g.internals.positionAbsolute.y+Y/2};G=sR(j,re)}}G&&(b=G.x,S=G.y,C=kB[G.side])}}const L=_e(W=>W.transform[2]),P=_e(W=>W.nodeLookup),T=_e(W=>{var H;return((H=W.connection.toHandle)==null?void 0:H.nodeId)??null});let E=o,z=i,A=s;if(L>0){const W=nJ/L,H=c?v?c.target:c.source:null;let j=null;if(T&&T!==H){const G=P.get(T)??null;G&&(j=G)}if(!j){let G=W;for(const X of P.values()){if(H&&X.id===H||w&&X.id===w.id)continue;const Y=X.measured.width??X.width??0,re=X.measured.height??X.height??0;if(Y===0||re===0)continue;const ne=X.internals.positionAbsolute.x,ae=X.internals.positionAbsolute.y,ve=Math.max(ne-o,0,o-(ne+Y)),be=Math.max(ae-i,0,i-(ae+re)),me=Math.hypot(ve,be);me<=G&&(G=me,j=X)}}if(!j&&c&&w){const G=w.measured.width??w.width??0,X=w.measured.height??w.height??0;if(G>0&&X>0){const Y=w.internals.positionAbsolute.x,re=w.internals.positionAbsolute.y,ne=Math.max(Y-o,0,o-(Y+G)),ae=Math.max(re-i,0,i-(re+X));Math.hypot(ne,ae)<=W&&(j=w)}}if(j){const G=j.measured.width??j.width??0,X=j.measured.height??j.height??0;if(G>0&&X>0){const Y=wN({x:j.internals.positionAbsolute.x,y:j.internals.positionAbsolute.y,w:G,h:X},{x:o,y:i}),re=lR({x:j.internals.positionAbsolute.x,y:j.internals.positionAbsolute.y,w:G,h:X},Y);E=re.x,z=re.y,A=kB[re.side]}}}const U=(h==null?void 0:h.path)==="step",[R]=U?nh({sourceX:b,sourceY:S,sourcePosition:C,targetX:E,targetY:z,targetPosition:A,borderRadius:Kwe}):KR({sourceX:b,sourceY:S,sourcePosition:C,targetX:E,targetY:z,targetPosition:A}),V=(c==null?void 0:c.style)??l??void 0,O=_e(W=>W.rfId),B=v?c==null?void 0:c.markerStart:c==null?void 0:c.markerEnd,D=v?c==null?void 0:c.markerEnd:c==null?void 0:c.markerStart,N=mB(B,O),I=mB(D,O);return y.jsx("path",{d:R,fill:"none",className:"react-flow__connection-path",style:V,markerStart:N,markerEnd:I})},kB={top:ye.Top,right:ye.Right,bottom:ye.Bottom,left:ye.Left};function Ywe({storeApiRef:e}){const t=yt();return m.useEffect(()=>(e.current=t,()=>{e.current===t&&(e.current=null)}),[t,e]),null}function Qwe({wrapperRef:e}){const t=_e(r=>r.transform[2]),n=e.current;return n&&n.style.setProperty("--rf-zoom",String(t)),null}const Jwe=new Set(["INPUT","TEXTAREA","SELECT"]),rJ=e=>e?Jwe.has(e.tagName)?!0:e instanceof HTMLElement&&e.isContentEditable:!1;function e6e(e){const{event:t,selectedNodeIds:n,hasClipboard:r,activeElement:o,onCopySelection:i,onPasteSelection:a}=e;if(!(t.metaKey||t.ctrlKey)||t.shiftKey||t.altKey)return!1;const s=t.key.toLowerCase();return s!=="c"&&s!=="v"||rJ(o)?!1:s==="c"?n.length===0||!i?!1:(t.preventDefault(),i([...n]),!0):!r||!a?!1:(t.preventDefault(),a(),!0)}const gB=(e,t)=>{var n;return((n=e==null?void 0:e[t])==null?void 0:n.status)??"idle"},t6e=(e,t)=>{var n;return(n=e==null?void 0:e[t])==null?void 0:n.status},n6e=(e,t)=>{var n,r;return((n=e==null?void 0:e[t])==null?void 0:n.status)==="error"?(r=e[t])==null?void 0:r.error:void 0};function r6e(e,t){var NH,DH;const{mode:n,adapter:r,projectId:o,fileBaseUrl:i,nodes:a,connectors:s,selectedNodeIds:l,selectedConnectorIds:c,onSelectionChange:h,runtime:d,onPlayNode:f,onNodePositionChange:p,onNodePositionsChange:k,onNodeResize:v,onNodeResizeEnd:w,onHtmlNodeFitToContent:g,onMultiResize:M,onNodeNameChange:x,onNodeDescriptionChange:b,onConnectorLabelChange:S,onCreateShapeNode:C,onCreateImageFromFile:L,onRetryImageUpload:P,onCreateHtmlNode:T,onCreateConnector:E,onReconnectConnector:z,onReorderNode:A,onDeleteNode:U,onCopyNode:R,onPasteAt:V,hasClipboard:O,onCopySelection:B,onPasteSelection:D,selectedNodes:N,selectedConnectors:I,onStyleNode:W,onStyleNodePreview:H,onStyleNodes:j,onStyleNodesPreview:G,onStyleConnector:X,onStyleConnectorPreview:Y,onRfInit:re,onTidy:ne,onNodeClick:ae,onConnectorClick:ve,onPaneClick:be,onCreateAndConnectFromPane:me,pendingEditNodeId:ge,iconPickerOpen:ee,onOpenIconPicker:ke,onCloseIconPicker:Fe,onPickIcon:rt,onRequestIconReplace:mt,onPinEndpoint:ht,onUnpinEndpoint:le,activeShape:Q,onSelectShape:fe,disableSidebar:we,statusReport:Se,onNameChange:Oe,onDescriptionChange:te,onDetailChange:de,onIconChange:Pe,autoFitView:qe,autoFitViewSignal:We,customIcons:Rt,onExportToCloud:st,onRestartDemo:Ne,showToolbar:ot,showStyleStrip:Jn,showDetailPanel:zt,showStatusBadges:zn,showResizeHandles:Kt,showControls:p1,showShareMenu:y1,showRestart:Jo,enableKeyboard:ei,enableContextMenu:_r,enableDragDrop:Ki,enableImageDrop:ti,enableZoom:fr,enablePan:Hr,enableSelection:pr,enableNodeMove:m1,enableEmbed:k1}=e,He=m.useMemo(()=>Owe({mode:n,showToolbar:ot,showStyleStrip:Jn,showDetailPanel:zt,showStatusBadges:zn,showResizeHandles:Kt,showControls:p1,showShareMenu:y1,showRestart:Jo,enableKeyboard:ei,enableContextMenu:_r,enableDragDrop:Ki,enableImageDrop:ti,enableZoom:fr,enablePan:Hr,enableSelection:pr,enableNodeMove:m1,enableEmbed:k1}),[n,ot,Jn,zt,zn,Kt,p1,y1,Jo,ei,_r,Ki,ti,fr,Hr,pr,m1,k1]),Mt=n==="edit",Fr=m.useRef(He);m.useEffect(()=>{Fr.current=He},[He]);const Or=qe??(n==="mini"?!0:void 0),jn=m.useMemo(()=>qwe(Or),[Or]),yr=d==null?void 0:d.runs,Mo=d==null?void 0:d.statuses,er=(NH=d==null?void 0:d.pendingOverrides)==null?void 0:NH.nodes,qr=(DH=d==null?void 0:d.pendingOverrides)==null?void 0:DH.connectors,an=m.useRef(null),jt=m.useRef(null),bo=m.useRef(!1),mr=m.useRef(!1),Xi=m.useRef(!1),Yi=m.useRef(jn);Yi.current=jn,m.useEffect(()=>{if(bo.current||!jn.onMount||a.length===0)return;const K=jt.current;K&&(K.fitView(Ad),bo.current=!0)},[a,jn.onMount]);const Co=m.useRef(null),Ct=Q,Qi=fe,Tn=m.useRef(new Map),ni=m.useCallback((K,J)=>(Tn.current.set(K,J),()=>{Tn.current.get(K)===J&&Tn.current.delete(K)}),[]),[tr,kr]=m.useState(!1),g1=m.useRef(!1);m.useEffect(()=>{g1.current=tr},[tr]);const Ji=m.useRef(!1),ea=m.useRef(!1),ri=m.useRef(!1),[mn,Vr]=m.useState(null),Br=m.useRef(null);m.useEffect(()=>{Br.current=mn},[mn]),m.useCallback(()=>{Vr(null)},[]);const x1=m.useMemo(()=>Xwe(ri),[]),So=m.useRef(null),nr=m.useRef(null),kn=m.useCallback(K=>{const J=an.current;if(!J){So.current=K;return}const se=So.current;if(se&&se!==K){const ce=J.querySelector(`.react-flow__node[data-id="${CSS.escape(se)}"]`);ce==null||ce.removeAttribute("data-connect-source")}if(K){const ce=J.querySelector(`.react-flow__node[data-id="${CSS.escape(K)}"]`);ce==null||ce.setAttribute("data-connect-source","true")}So.current=K},[]),sn=m.useCallback(K=>{const J=an.current,se=nr.current;if(se!==K){if(J&&se){const ce=J.querySelector(`.react-flow__node[data-id="${CSS.escape(se)}"]`);ce==null||ce.removeAttribute("data-connect-target")}if(J&&K){const ce=J.querySelector(`.react-flow__node[data-id="${CSS.escape(K)}"]`);ce==null||ce.setAttribute("data-connect-target","true")}nr.current=K}},[]),oi=m.useCallback(()=>{kn(null),sn(null)},[kn,sn]);m.useEffect(()=>{if(!tr){sn(null);return}let K=null,J=null;const se=()=>{K=null;const ue=J;if(J=null,!ue)return;const Re=sT(an.current,ue.clientX,ue.clientY),xe=(Re==null?void 0:Re.getAttribute("data-id"))??null;if(xe&&xe===So.current){sn(null);return}sn(xe)},ce=ue=>{J={clientX:ue.clientX,clientY:ue.clientY},K===null&&(K=requestAnimationFrame(se))};return document.addEventListener("pointermove",ce,{passive:!0}),()=>{document.removeEventListener("pointermove",ce),K!==null&&cancelAnimationFrame(K)}},[tr,sn]);const[rr,$r]=m.useState(null),[Ur,Lo]=m.useState(null),Je=m.useRef(null),Wr=m.useRef(null),Nn=m.useRef(null),Xt=m.useRef(!1);m.useEffect(()=>{Je.current=Ct},[Ct]);const Gr=m.useCallback(()=>{Qi(null),$r(null),Lo(null),Je.current=null,Wr.current=null,Nn.current=null,Xt.current=!1},[Qi]);m.useEffect(()=>{if(!He.enableKeyboard)return;const K=J=>{var ue,Re;if(J.key!=="Escape"||rJ(document.activeElement))return;if(Je.current){J.preventDefault(),Gr();return}if(g1.current){J.preventDefault(),Ji.current=!0,ea.current=!0;try{(ue=Co.current)==null||ue.getState().cancelConnection()}catch{}document.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,button:0})),kr(!1);return}if(Br.current){J.preventDefault(),Vr(null);return}const se=vn.current.size>0,ce=Po.current.size>0;(se||ce)&&(J.preventDefault(),(Re=Zr.current)==null||Re.call(Zr,[],[]))};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[Gr,He.enableKeyboard]),m.useEffect(()=>{if(!He.enableKeyboard)return;const K=J=>{e6e({event:J,selectedNodeIds:l,hasClipboard:!!O,activeElement:document.activeElement,onCopySelection:B,onPasteSelection:D})};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[l,O,B,D,He.enableKeyboard]);const v1=m.useCallback(K=>{var ce,ue;if(!Je.current)return;const J=K.target;if(!(J!=null&&J.classList.contains("react-flow__pane")))return;const se={x:K.clientX,y:K.clientY};Xt.current=!0,Wr.current=se,Nn.current=se,$r(se),Lo(se);try{(ue=(ce=K.currentTarget).setPointerCapture)==null||ue.call(ce,K.pointerId)}catch{}K.preventDefault(),K.stopPropagation()},[]),Dz=m.useCallback(K=>{if(!Xt.current)return;const J={x:K.clientX,y:K.clientY};Nn.current=J,Lo(J)},[]),Kh=m.useCallback(K=>{var Xr,dd;if(!Xt.current)return;Xt.current=!1;try{(dd=(Xr=K.currentTarget).releasePointerCapture)==null||dd.call(Xr,K.pointerId)}catch{}const J=Wr.current,se=Nn.current,ce=Je.current,ue=jt.current;if(Gr(),!J||!se||!ce||!ue)return;const Re=Math.min(J.x,se.x),xe=Math.min(J.y,se.y),Ee=Math.max(J.x,se.x),Ke=Math.max(J.y,se.y),et=Ee-Re,lt=Ke-xe,Te=ue.screenToFlowPosition({x:Re,y:xe}),wn=ue.screenToFlowPosition({x:Ee,y:Ke}),Kr=wn.x-Te.x,ct=wn.y-Te.y,Le=et<fB||lt<fB,Ft=Le?pR[ce].width:Kr,w1=Le?pR[ce].height:ct;C==null||C(ce,Te,{width:Ft,height:w1})},[Gr,C]),Io=m.useRef(!1),ta=m.useRef(!1),id=m.useRef(new Map),ii=m.useCallback(()=>{var K;mr.current&&(ta.current||Io.current||(mr.current=!1,(K=jt.current)==null||K.fitView(Ad)))},[]),ad=m.useCallback(K=>{ta.current=K,K||ii()},[ii]);m.useEffect(()=>{var K;if(!Xi.current){Xi.current=!0;return}if(Yi.current.onExternalNodeChange){if(ta.current||Io.current){mr.current=!0;return}(K=jt.current)==null||K.fitView(Ad)}},[We]);const sd=!!A||!!U||!!R||!!V||!!le,[F,q]=m.useState(null),[Z,$]=m.useState(!1),[_,oe]=m.useState(null),[Ae,Me]=m.useState(null),Ue=m.useRef(null),Ut=m.useRef(null);m.useEffect(()=>{if(!F)return;const K=Ut.current;if(!K)return;const J=new MouseEvent("contextmenu",{clientX:F.x,clientY:F.y,bubbles:!0,cancelable:!0,button:2,buttons:2});K.dispatchEvent(J)},[F]);const Eo=m.useCallback(K=>{const J=Ue.current;!J||!A||A(J,K)},[A]),Dn=m.useCallback(()=>{const K=Ue.current;!K||!U||U(K)},[U]),ze=m.useCallback(()=>{const K=Ue.current;!K||!R||R(K)},[R]),it=m.useCallback(()=>{const K=Ue.current;!K||!mt||mt(K)},[mt]);m.useCallback((K,J,se,ce,ue)=>{Fr.current.enableContextMenu&&(Ue.current=null,$(!1),oe(null),Me({connectorId:K,kind:J,pinned:se}),q({x:ce,y:ue}))},[]);const Yt=m.useCallback(()=>{const K=Ae;!K||!le||le(K.connectorId,K.kind)},[Ae,le]),gn=m.useCallback(()=>{if(!V)return;const K=F,J=jt.current;if(!K||!J)return;const se=J.screenToFlowPosition({x:K.x,y:K.y});V(se)},[F,V]),na=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent||""),_z=na?"⌘C":"Ctrl+C",ai=na?"⌘V":"Ctrl+V",De=m.useMemo(()=>new Set(l),[l]),Qe=m.useMemo(()=>new Set(c),[c]),Ht=m.useMemo(()=>{if(l.length<2)return[];const K=er,J=[];for(const se of l){const ce=a.find(Ee=>Ee.id===se);if(!ce)continue;const ue=K==null?void 0:K[se],Re=(ue==null?void 0:ue.data)??{},xe=ce.data;J.push({id:se,position:(ue==null?void 0:ue.position)??ce.position,data:{width:Re.width??xe.width,height:Re.height??xe.height}})}return J},[a,er,l]),xn=N??[],Ao=m.useMemo(()=>{const K=ue=>{const Re=Mt?void 0:id.current.get(ue.id),xe={id:ue.id,type:ue.type,position:Re??ue.position,data:{...ue.data,projectId:o,fileBaseUrl:i,onRetryUpload:P,status:t6e(yr,ue.id),errorMessage:n6e(yr,ue.id),statusReport:Mo==null?void 0:Mo[ue.id],onPlay:f,onResize:v,onResizeEnd:w,setResizing:ad,onFitToContent:ue.type==="htmlNode"?g:void 0,onNameChange:(()=>{if(Mt&&!(ue.type==="shapeNode"&&ue.data.shape==="ellipse"))return x})(),onDescriptionChange:(()=>{if(Mt){if(ue.type==="shapeNode"){const Ee=ue.data.shape;return Ee==="rectangle"||Ee==="ellipse"||Ee==="sticky"?b:void 0}if(!(ue.type==="imageNode"||ue.type==="iconNode"))return b}})(),onIconChange:(()=>{if(Mt&&!(ue.type!=="playNode"&&ue.type!=="stateNode"))return Pe})(),autoEditOnMount:ge===ue.id?!0:void 0},selected:De.has(ue.id)};return ue.data.width!==void 0&&(xe.width=ue.data.width),ue.data.height!==void 0&&(xe.height=ue.data.height),De.has(ue.id)||(xe.connectable=!1),xe},J=a.map(ue=>K($we(ue,er==null?void 0:er[ue.id]))),se=new Set(a.map(ue=>ue.id)),ce=[];if(er)for(const[ue,Re]of Object.entries(er)){if(se.has(ue))continue;const xe=Re;typeof xe.type!="string"||!xe.position||!xe.data||ce.push(K({...xe,id:ue}))}return[...J,...ce]},[o,i,a,De,yr,Mo,f,v,w,g,ad,er,x,b,Pe,P,ge,Mt]),[ra,ld]=m.useState(Ao);m.useEffect(()=>{Io.current||ta.current||ld(Ao)},[Ao]),m.useEffect(()=>{cd.current=ra},[ra]);const vn=m.useRef(De);m.useEffect(()=>{vn.current=De},[De]);const Zr=m.useRef(h);m.useEffect(()=>{Zr.current=h},[h]);const Po=m.useRef(Qe);m.useEffect(()=>{Po.current=Qe},[Qe]);const cd=m.useRef(Ao),oa=m.useRef(!1),Xh=m.useRef(new Set),Yh=m.useRef(new Set),Hz=m.useRef(new Set),Fz=m.useRef(new Set),si=m.useRef(null),vJ=m.useCallback(K=>{var ct;const J=oa.current?Hz.current:(ct=si.current)!=null&&ct.shift?si.current.nodeIds:null,se=J&&J.size>0?K.filter(Le=>Le.type!=="select"?!0:!(Le.selected===!1&&J.has(Le.id))):K,ce=new Set;for(const Le of se)Le.type==="select"&&ce.add(Le.id);const ue=vG(se,cd.current),Re=new Set;if(ta.current)for(const Le of se)Le.type==="dimensions"&&Re.add(Le.id);const xe=Re.size===0?ue:ue.map(Le=>!Re.has(Le.id)||Le.width===void 0&&Le.height===void 0?Le:{...Le,data:{...Le.data,...Le.width!==void 0?{width:Le.width}:{},...Le.height!==void 0?{height:Le.height}:{}}}),Ee=vn.current,Ke=oa.current||Ee.size===0?xe:xe.map(Le=>Ee.has(Le.id)&&!ce.has(Le.id)&&!Le.selected?{...Le,selected:!0}:Le);if(cd.current=Ke,ld(Ke),ce.size===0)return;if(oa.current){for(const Le of se)Le.type==="select"&&(Le.selected?Xh.current.add(Le.id):Xh.current.delete(Le.id));return}const et=Zr.current;if(!et)return;const lt=Ke.filter(Le=>Le.selected).map(Le=>Le.id),Te=vn.current;Te.size===lt.length&<.every(Le=>Te.has(Le))||(vn.current=new Set(lt),et(lt,[...Po.current]))},[]),Qh=m.useRef([]),wJ=m.useCallback(K=>{var lt;const J=oa.current?Fz.current:(lt=si.current)!=null&<.shift?si.current.edgeIds:null,se=J&&J.size>0?K.filter(Te=>Te.type!=="select"?!0:!(Te.selected===!1&&J.has(Te.id))):K,ce=new Set;for(const Te of se)Te.type==="select"&&ce.add(Te.id);if(ce.size===0)return;if(oa.current){for(const Te of se)Te.type==="select"&&(Te.selected?Yh.current.add(Te.id):Yh.current.delete(Te.id));return}const ue=Zr.current;if(!ue)return;const xe=wG(se,Qh.current).filter(Te=>Te.selected).map(Te=>Te.id),Ee=Po.current;Ee.size===xe.length&&xe.every(Te=>Ee.has(Te))||(Po.current=new Set(xe),ue([...vn.current],xe))},[]),MJ=m.useCallback(K=>{oa.current=!0;const J=si.current,se=(J==null?void 0:J.shift)??(K.shiftKey||K.metaKey||K.ctrlKey);Hz.current=se?new Set((J==null?void 0:J.nodeIds)??vn.current):new Set,Fz.current=se?new Set((J==null?void 0:J.edgeIds)??Po.current):new Set,Xh.current=new Set(Hz.current),Yh.current=new Set(Fz.current)},[]),bJ=m.useCallback(()=>{oa.current=!1,si.current=null;const K=Zr.current;if(!K)return;const J=[...Xh.current],se=new Set(J),ce=new Set(Yh.current);for(const Ke of Qh.current)se.has(Ke.source)&&se.has(Ke.target)&&ce.add(Ke.id);const ue=vn.current,Re=Po.current,xe=ue.size===se.size&&J.every(Ke=>ue.has(Ke)),Ee=Re.size===ce.size&&[...ce].every(Ke=>Re.has(Ke));xe&&Ee||(vn.current=new Set(J),Po.current=new Set(ce),K(J,[...ce]))},[]),CJ=m.useCallback(K=>{if(si.current=null,Je.current||K.button!==0)return;const J=K.target;J!=null&&J.classList.contains("react-flow__pane")&&(si.current={shift:K.shiftKey||K.metaKey||K.ctrlKey,nodeIds:new Set(vn.current),edgeIds:new Set(Po.current)})},[]),SJ=m.useCallback(K=>{if(!Fr.current.enableContextMenu||vn.current.size<2)return;const se=K.target;se!==Ut.current&&(se!=null&&se.closest(".seeflow-connector-endpoint-dot")||(K.preventDefault(),K.stopPropagation(),Ue.current=null,$(!0),oe(null),Me(null),q({x:K.clientX,y:K.clientY})))},[]),LJ=m.useCallback(K=>{const J=K.dataTransfer;if(!J)return;const se=J.types?Array.from(J.types):[],ce=se.includes("Files"),ue=se.includes(Kq),Re=ce&&!!L&&He.enableImageDrop,xe=ue&&!!T&&He.enableDragDrop;if(!(!Re&&!xe)){K.preventDefault();try{J.dropEffect="copy"}catch{}}},[L,T,He.enableImageDrop,He.enableDragDrop]),IJ=m.useCallback(K=>{const J=K.dataTransfer;if((J!=null&&J.types?Array.from(J.types):[]).includes(Kq)&&T&&He.enableDragDrop){K.preventDefault();const Re=jt.current;if(!Re)return;const xe=Re.screenToFlowPosition({x:K.clientX,y:K.clientY});T({position:xe});return}if(!L||!He.enableImageDrop)return;const ue={x:K.clientX,y:K.clientY};K.preventDefault(),$ne({dataTransfer:J,clientPos:ue,rfInstance:jt.current,computeDims:Une,dispatch:L})},[L,T,He.enableImageDrop,He.enableDragDrop]),LH=!!z,IH=Qe.size===1?[...Qe][0]:null,Oz=m.useMemo(()=>{const K=Ee=>{const Ke=gB(yr,Ee.source)==="running"||gB(yr,Ee.target)==="running",et=Qe.has(Ee.id),lt=Y1e(Ee,Ke,et);et&&(lt.selected=!0);const Te=LH&&Ee.id===IH,wn=Te?{...lt,reconnectable:!0}:lt;return{...wn,data:{...wn.data,onLabelChange:Mt?S:void 0,reconnectable:Te,registerEditHandle:ni}}},J=new Set(s.map(Ee=>Ee.id)),se=s.map(Ee=>K(Uwe(Ee,qr==null?void 0:qr[Ee.id]))),ce=[];if(qr)for(const[Ee,Ke]of Object.entries(qr)){if(J.has(Ee))continue;const et=Ke;typeof et.source!="string"||typeof et.target!="string"||typeof et.kind!="string"||ce.push(K({...et,id:Ee}))}const ue=[...se,...ce],Re=[],xe=[];for(const Ee of ue)Qe.has(Ee.id)?xe.push(Ee):Re.push(Ee);return[...Re,...xe]},[s,yr,Qe,IH,qr,S,LH,ni,Mt]);m.useEffect(()=>{Qh.current=Oz},[Oz]);const ud=e.adapter??null,EJ=m.useMemo(()=>{if(ud!=null&&ud.computeLayout)return async()=>{const K=jt.current,J=cd.current;if(J.length<2)return;const se=J.map(ct=>{var dd;const Le=(dd=K==null?void 0:K.getInternalNode(ct.id))==null?void 0:dd.measured,Ft=ct.data,w1=(Le==null?void 0:Le.width)??Ft.width??200,Xr=(Le==null?void 0:Le.height)??Ft.height??120;return{id:ct.id,type:ct.type,width:w1,height:Xr}}),ce=new Map;for(const ct of J)ce.set(ct.id,ct.position);const ue=Qh.current.map(ct=>({id:ct.id,source:ct.source,target:ct.target})),Re=ud.computeLayout;if(!Re)return;const xe=await Re(se,ue),Ee=new Map;for(const[ct,Le]of Object.entries(xe.nodes))Ee.set(ct,Le.position);let Ke=Number.POSITIVE_INFINITY,et=Number.POSITIVE_INFINITY,lt=Number.POSITIVE_INFINITY,Te=Number.POSITIVE_INFINITY;for(const ct of se){const Le=ce.get(ct.id);if(!Le)continue;Le.x<Ke&&(Ke=Le.x),Le.y<et&&(et=Le.y);const Ft=Ee.get(ct.id);Ft&&(Ft.x<lt&&(lt=Ft.x),Ft.y<Te&&(Te=Ft.y))}const wn=Number.isFinite(Ke)&&Number.isFinite(lt)?Ke-lt:0,Kr=Number.isFinite(et)&&Number.isFinite(Te)?et-Te:0;ld(ct=>ct.map(Le=>{const Ft=Ee.get(Le.id);return Ft?{...Le,position:{x:Ft.x+wn,y:Ft.y+Kr}}:Le}))}},[ud]),Jh=ne??(Mt?void 0:EJ),e0=m.useRef(!1),EH=m.useRef(null),AJ=m.useCallback(K=>{var Ee;if(!Mt||!E)return;const{source:J,target:se}=K;if(!J||!se||J===se)return;e0.current=!0;const ce=((Ee=EH.current)==null?void 0:Ee.nodeId)??null,ue=ce!==null&&ce===se&&ce!==J;E(ue?se:J,ue?J:se)},[E,Mt]),qz=m.useCallback(K=>{const J=se=>{if(!se)return!1;const ce=cd.current.find(ue=>ue.id===se);return ce?ce.type==="shapeNode"&&ce.data.shape==="text":!1};return!J(K.source)&&!J(K.target)},[]),PJ=m.useCallback((K,J)=>{var lt;kr(!1),oi();const se=e0.current;if(e0.current=!1,se||ri.current)return;if(Ji.current){Ji.current=!1;return}if(!E)return;const ce=(lt=J.fromNode)==null?void 0:lt.id,ue=J.fromHandle;if(!ce||!ue)return;const Re=pB(K);if(!Re)return;const xe=sT(an.current,Re.clientX,Re.clientY);if(!xe)return;const Ee=xe.getAttribute("data-id");if(!Ee||Ee===ce||!qz({source:ce,target:Ee,sourceHandle:null,targetHandle:null}))return;let Ke;const et=jt.current;if(et){const Te=et.getInternalNode(Ee);if(Te){const wn=Te.measured.width??Te.width??0,Kr=Te.measured.height??Te.height??0;if(wn>0&&Kr>0){const ct=et.screenToFlowPosition({x:Re.clientX,y:Re.clientY});Ke=wN({x:Te.internals.positionAbsolute.x,y:Te.internals.positionAbsolute.y,w:wn,h:Kr},ct)}}}E(ce,Ee,Ke?{targetPin:Ke}:void 0)},[E,oi,qz]),t0=m.useRef(!1),RJ=m.useCallback((K,J)=>{if(!z)return;const{source:se,target:ce,sourceHandle:ue,targetHandle:Re}=J;if(!se||!ce||se===ce)return;const xe={};if(se!==K.source&&(xe.source=se),ce!==K.target&&(xe.target=ce),typeof ue=="string"&&ue!==K.sourceHandle&&(xe.sourceHandle=ue),typeof Re=="string"&&Re!==K.targetHandle&&(xe.targetHandle=Re),xe.source===void 0&&xe.target===void 0&&xe.sourceHandle===void 0&&xe.targetHandle===void 0)return;(xe.source!==void 0||xe.sourceHandle!==void 0)&&(xe.sourceHandleAutoPicked=!1),(xe.target!==void 0||xe.targetHandle!==void 0)&&(xe.targetHandleAutoPicked=!1);const Ee=jt.current;if(!(xe.source===void 0&&xe.target===void 0)&&Ee){const et=xe.source!==void 0?"source":"target",lt=yB(et,K.source,K.target,K.data,Te=>Ee.getInternalNode(Te)??null);lt&&(et==="source"?xe.targetPin=lt:xe.sourcePin=lt)}t0.current=!0,z(K.id,xe)},[z]),zJ=m.useCallback((K,J,se,ce)=>{var w1;kr(!1),oi(),ri.current=!1;const ue=t0.current;if(t0.current=!1,ue)return;if(ea.current){ea.current=!1;return}if(!z)return;const Re=pB(K);let xe=((w1=ce.toNode)==null?void 0:w1.id)??null;if(!xe&&Re){const Xr=sT(an.current,Re.clientX,Re.clientY);xe=(Xr==null?void 0:Xr.getAttribute("data-id"))??null}const Ee=se==="source"?"target":"source",Ke=Bwe(Ee,J.source,J.target,xe);if(Ke==="no-op"||Ke==="self-loop"||!Re)return;const et=jt.current;if(!et)return;const lt=Ke==="pin-own"?Ee==="source"?J.source:J.target:xe,Te=et.getInternalNode(lt);if(!Te)return;const wn=Te.measured.width??Te.width??0,Kr=Te.measured.height??Te.height??0;if(wn===0||Kr===0)return;const ct=et.screenToFlowPosition({x:Re.clientX,y:Re.clientY}),Le=wN({x:Te.internals.positionAbsolute.x,y:Te.internals.positionAbsolute.y,w:wn,h:Kr},ct);if(Ke==="pin-own"){if(!ht)return;ht(J.id,Ee,Le);return}const Ft=yB(Ee,J.source,J.target,J.data,Xr=>et.getInternalNode(Xr)??null);Ee==="source"?z(J.id,{source:xe,sourceHandle:null,sourceHandleAutoPicked:!1,sourcePin:Le,...Ft?{targetPin:Ft}:{}}):z(J.id,{target:xe,targetHandle:null,targetHandleAutoPicked:!1,targetPin:Le,...Ft?{sourcePin:Ft}:{}})},[z,oi,ht]),ia=m.useMemo(()=>{var Ee;if(!rr||!Ur)return null;const K=(Ee=an.current)==null?void 0:Ee.getBoundingClientRect(),J=(K==null?void 0:K.left)??0,se=(K==null?void 0:K.top)??0,ce=Math.min(rr.x,Ur.x),ue=Math.min(rr.y,Ur.y),Re=Math.abs(Ur.x-rr.x),xe=Math.abs(Ur.y-rr.y);return{left:ce-J,top:ue-se,width:Re,height:xe}},[rr,Ur]),jJ=Ct?JZ(Ct):"",TJ=Ct?eK(Ct):void 0,NJ=Ct==="text",[AH,PH]=m.useState(!1),[DJ,n0]=m.useState(!1),[_J,RH]=m.useState(!1),li=zwe({projectId:o,getReactFlow:()=>jt.current});m.useImperativeHandle(t,()=>({exportPdf:li.exportPdf,exportPng:li.exportPng,openEmbedDialog:()=>RH(!0),capturePreview:li.capturePreview}),[li.exportPdf,li.exportPng,li.capturePreview]),m.useEffect(()=>{if(!He.enableKeyboard)return;const K=ce=>{if(!ce)return!1;const ue=ce.tagName;return ue==="INPUT"||ue==="TEXTAREA"||ue==="SELECT"?!0:ce instanceof HTMLElement&&ce.isContentEditable},J=ce=>{ce.code==="Space"&&(K(document.activeElement)||(ce.preventDefault(),PH(!0)))},se=ce=>{ce.code==="Space"&&(PH(!1),n0(!1))};return window.addEventListener("keydown",J),window.addEventListener("keyup",se),()=>{window.removeEventListener("keydown",J),window.removeEventListener("keyup",se)}},[He.enableKeyboard]);const r0=m.useCallback(K=>{if(K.length!==0){if(!Mt){const J=id.current;for(const se of K)J.set(se.id,{x:se.position.x,y:se.position.y});return}if(K.length===1){const J=K[0];J&&p&&p(J.id,{x:J.position.x,y:J.position.y});return}if(k){k(K.map(J=>({id:J.id,position:{x:J.position.x,y:J.position.y}})));return}if(p)for(const J of K)p(J.id,{x:J.position.x,y:J.position.y})}},[p,k,Mt]),HJ=m.useCallback((K,J,se)=>{Io.current=!1,r0(se),ii()},[r0,ii]),FJ=m.useCallback(()=>{Io.current=!0},[]),OJ=m.useCallback((K,J)=>{Io.current=!1,r0(J),ii()},[r0,ii]),qJ=m.useCallback((K,J)=>{ae==null||ae(J.id)},[ae]),VJ=m.useCallback(K=>{be==null||be()},[be]),BJ=m.useCallback((K,J)=>{ve==null||ve(J.id)},[ve]),zH=Ct?"crosshair":AH?DJ?"grabbing":"grab":void 0,jH=l[0],TH=c[0],$J=jH?a.find(K=>K.id===jH)??null:null,UJ=TH?s.find(K=>K.id===TH)??null:null,WJ=o??null,GJ=He.showDetailPanel&&!we,ZJ=m.useMemo(()=>({custom:Rt??{}}),[Rt]);return y.jsx(Bue,{value:ZJ,children:y.jsx("div",{"data-testid":"seeflow-canvas","data-mode":n,ref:an,className:"seeflow-canvas-root sf:relative sf:h-full sf:w-full",style:zH?{cursor:zH}:void 0,onPointerDownCapture:CJ,onPointerDown:K=>{AH&&n0(!0),v1(K)},onPointerMove:Dz,onPointerUp:K=>{n0(!1),Kh(K)},onPointerCancel:()=>{Xt.current=!1,Wr.current=null,Nn.current=null,$r(null),Lo(null),n0(!1)},onContextMenuCapture:SJ,onDragOver:LJ,onDrop:IJ,children:y.jsxs(Uhe,{containerRef:an,children:[y.jsxs(f1e,{nodes:ra,edges:Oz,onNodesChange:vJ,nodeTypes:Wwe,edgeTypes:Gwe,proOptions:{hideAttribution:!0},fitView:!0,minZoom:n==="mini"?.05:.5,nodesDraggable:(Mt?!!p:!0)&&!Ct&&He.enableNodeMove,nodesConnectable:Mt&&!!E&&!Ct,deleteKeyCode:Mt?["Backspace","Delete"]:null,zoomOnScroll:He.enableZoom,zoomOnPinch:He.enableZoom,className:tr?"seeflow-connecting":void 0,onConnect:Mt?AJ:void 0,isValidConnection:qz,onConnectStart:(K,J)=>{kr(!0),e0.current=!1,EH.current={nodeId:J.nodeId??null,handleType:J.handleType??null},kn(J.nodeId??null)},onConnectEnd:PJ,onReconnect:Mt&&z?RJ:void 0,onReconnectStart:(K,J,se)=>{kr(!0),t0.current=!1,ri.current=!0;const ce=se==="source"?J.source:J.target;kn(ce)},onReconnectEnd:zJ,connectionLineComponent:x1,connectionLineStyle:{strokeWidth:2},connectionRadius:32,reconnectRadius:10,edgesReconnectable:!1,elevateNodesOnSelect:!1,elementsSelectable:!Ct&&He.enableSelection,selectNodesOnDrag:!1,nodeClickDistance:5,selectionOnDrag:!Ct&&He.enableSelection,panOnDrag:Ct?!1:He.enablePan?[1,2]:!1,selectionMode:Eu.Partial,selectionKeyCode:null,multiSelectionKeyCode:Ct?null:["Meta","Shift"],panActivationKeyCode:Ct?null:"Space",onSelectionStart:MJ,onSelectionEnd:bJ,defaultEdgeOptions:Zwe,zoomOnDoubleClick:!1,onInit:K=>{jt.current=K;const J=an.current;J&&J.style.setProperty("--rf-zoom",String(K.getZoom())),J&&J.setAttribute("data-canvas-ready","true"),!bo.current&&jn.onMount&&a.length>0&&(K.fitView(Ad),bo.current=!0),re==null||re(K)},onMove:(K,J)=>{Br.current&&Vr(null);const se=an.current;se&&se.style.setProperty("--rf-zoom",String(J.zoom))},onEdgesChange:wJ,onNodeDragStart:()=>{Io.current=!0},onNodeDragStop:HJ,onSelectionDragStart:FJ,onSelectionDragStop:OJ,onNodeClick:qJ,onEdgeClick:BJ,onEdgeDoubleClick:(K,J)=>{var se;(se=Tn.current.get(J.id))==null||se()},onPaneClick:VJ,onNodeContextMenu:He.enableContextMenu&&sd?(K,J)=>{K.preventDefault(),Ue.current=J.id,$(!0),oe(J.type??null),Me(null),q({x:K.clientX,y:K.clientY})}:void 0,onPaneContextMenu:He.enableContextMenu&&V?K=>{K.preventDefault(),Ue.current=null,$(!1),oe(null),Me(null),q({x:K.clientX,y:K.clientY})}:void 0,children:[y.jsx(Ywe,{storeApiRef:Co}),y.jsx(Qwe,{wrapperRef:an}),y.jsx(b1e,{gap:12,size:.6}),y.jsx(Dwe,{}),He.showControls?y.jsxs(P1e,{showInteractive:!1,showFitView:!1,children:[y.jsx(X1,{"data-testid":"controls-fit-view","aria-label":"Fit view",title:"Fit view",disabled:a.length===0,onClick:()=>{var K;(K=jt.current)==null||K.fitView(Ad)},children:y.jsx(iu,{className:"sf:h-3 sf:w-3","aria-hidden":"true"})}),y.jsx(X1,{"data-testid":"controls-tidy","aria-label":"Tidy layout (⌘⇧L)",title:"Tidy layout (⌘⇧L)",disabled:!Jh,onClick:()=>Jh==null?void 0:Jh(),children:y.jsx(s2,{className:"sf:h-3 sf:w-3","aria-hidden":"true"})})]}):null,He.showResizeHandles?y.jsx(I3e,{selectedNodes:Ht,onMultiResize:M}):null,He.showToolbar&&C||He.showStyleStrip&&W&&X?y.jsx(ju,{position:"top-left",children:y.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-2",children:[He.showToolbar&&C?y.jsx(ame,{activeShape:Ct,onSelectShape:Qi,iconPickerOpen:ee??!1,onOpenIconPicker:ke,onCloseIconPicker:Fe,onPickIcon:rt}):null,He.showStyleStrip&&W&&X?y.jsx(A3e,{nodes:xn,connectors:I??[],onStyleNode:W,onStyleNodePreview:H,onStyleNodes:j,onStyleNodesPreview:G,onStyleConnector:X,onStyleConnectorPreview:Y,onRequestIconReplace:mt}):null]})}):null,He.showShareMenu||He.showRestart&&Ne?y.jsx(ju,{position:"top-right",children:y.jsxs("div",{className:"sf:flex sf:items-center sf:gap-1",children:[He.showRestart&&Ne?y.jsx(b3e,{onRestartDemo:Ne}):null,He.showShareMenu?y.jsx(M3e,{mode:n==="mini"?"view":n,projectId:o,enableEmbed:He.enableEmbed,onDownloadPdf:li.exportPdf,onDownloadPng:li.exportPng,onExportToCloud:st,embedOpen:_J,onEmbedOpenChange:RH}):null]})}):null]}),ia?y.jsx("div",{"data-testid":"canvas-draw-ghost","data-ghost-shape":Ct??void 0,"aria-hidden":!0,className:ie("sf:pointer-events-none sf:absolute sf:z-10",jJ,NJ?"sf:rounded-sm sf:border sf:border-dashed sf:border-muted-foreground/40":""),style:{...TJ,left:ia.left,top:ia.top,width:ia.width,height:ia.height},children:(()=>{const K=Ct?H_[Ct]:void 0;return K?y.jsx(K,{width:ia.width,height:ia.height,borderColor:tt(void 0,"node").borderColor,backgroundColor:mh,borderSize:M_}):null})()}):null,He.enableContextMenu&&sd?y.jsxs(Ppe,{onOpenChange:K=>{K||(q(null),Ue.current=null,oe(null),Me(null))},children:[y.jsx(Rpe,{asChild:!0,children:y.jsx("div",{ref:Ut,"data-testid":"node-context-menu-trigger","aria-hidden":!0,className:"sf:pointer-events-none sf:fixed",style:{left:(F==null?void 0:F.x)??0,top:(F==null?void 0:F.y)??0,width:0,height:0}})}),y.jsxs(TX,{"data-testid":"node-context-menu",children:[Ae!=null&&Ae.pinned&&le?y.jsx(to,{"data-testid":"connector-endpoint-context-menu-unpin",onSelect:Yt,children:"Unpin"}):null,Z&&R?y.jsxs(to,{"data-testid":"node-context-menu-copy",onSelect:ze,children:["Copy",y.jsx(TN,{children:_z})]}):null,V?y.jsxs(to,{"data-testid":"node-context-menu-paste",disabled:!O,onSelect:gn,children:["Paste",y.jsx(TN,{children:ai})]}):null,Z&&(R||V)&&(_==="iconNode"&&mt||A||U)?y.jsx(MP,{}):null,Z&&_==="iconNode"&&mt?y.jsx(to,{"data-testid":"node-context-menu-change-icon",onSelect:it,children:"Change icon"}):null,Z&&_==="iconNode"&&mt&&(A||U)?y.jsx(MP,{}):null,Z&&A?y.jsxs(y.Fragment,{children:[y.jsx(to,{"data-testid":"node-context-menu-to-front",onSelect:()=>Eo({op:"toFront"}),children:"Bring to front"}),y.jsx(to,{"data-testid":"node-context-menu-forward",onSelect:()=>Eo({op:"forward"}),children:"Bring forward"}),y.jsx(to,{"data-testid":"node-context-menu-backward",onSelect:()=>Eo({op:"backward"}),children:"Send backward"}),y.jsx(to,{"data-testid":"node-context-menu-to-back",onSelect:()=>Eo({op:"toBack"}),children:"Send to back"})]}):null,Z&&A&&U?y.jsx(MP,{}):null,Z&&U?y.jsx(to,{"data-testid":"node-context-menu-delete",onSelect:Dn,children:"Delete"}):null]})]}):null,me?y.jsxs(Ju,{open:!!mn,onOpenChange:K=>{K||Vr(null)},children:[y.jsx(Whe,{asChild:!0,children:y.jsx("div",{"data-testid":"drop-popover-anchor","aria-hidden":!0,className:"sf:pointer-events-none sf:fixed",style:{left:(mn==null?void 0:mn.clientX)??0,top:(mn==null?void 0:mn.clientY)??0,width:0,height:0}})}),y.jsx(u1,{"data-testid":"drop-popover",align:"start",side:"bottom",sideOffset:4,className:"sf:w-auto sf:p-1",onOpenAutoFocus:K=>{K.preventDefault()},children:y.jsx("div",{role:"menu","aria-label":"Create connected node",className:"sf:flex sf:flex-col sf:gap-0.5",children:ime.map(({shape:K,label:J,Icon:se})=>y.jsxs("button",{type:"button",role:"menuitem","data-testid":`drop-popover-shape-${K}`,onClick:()=>{const ce=mn;ce&&(me({sourceNodeId:ce.sourceNodeId,position:{x:ce.flowX,y:ce.flowY},shape:K}),Vr(null))},className:ie("sf:flex sf:items-center sf:gap-2 sf:rounded-sm sf:px-2 sf:py-1.5 sf:text-left sf:text-sm","sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus:bg-accent sf:focus:text-accent-foreground sf:focus:outline-hidden"),children:[y.jsx(se,{className:"sf:h-4 sf:w-4 sf:text-muted-foreground","aria-hidden":"true"}),y.jsx("span",{children:J})]},K))})})]}):null,GJ?y.jsx(Jve,{flowId:WJ,node:$J,connector:UJ,adapter:r??null,statusReport:Se,onNameChange:Oe,onDescriptionChange:te,onDetailChange:de,onIconChange:Pe,onClose:()=>{var K;(K=Zr.current)==null||K.call(Zr,[],[])}}):null]})})})}const o6e=m.forwardRef(r6e);function i6e({open:e,onOpenChange:t,onCreated:n}){const[r,o]=m.useState(""),[i,a]=m.useState(null),[s,l]=m.useState(!1);m.useEffect(()=>{e&&(o(""),a(null),l(!1))},[e]);const c=r.trim(),h=c.length>0&&!s,d=async f=>{if(f.preventDefault(),!!h){l(!0),a(null);try{const p=await Cne({name:c});n(p),t(!1)}catch(p){a(p instanceof Error?p.message:String(p)),l(!1)}}};return y.jsx(kz,{open:e,onOpenChange:t,children:y.jsxs(Nh,{className:"sm:max-w-md","data-testid":"create-project-dialog",onOpenAutoFocus:f=>{f.preventDefault();const p=document.querySelector('[data-testid="create-project-name-input"]');p==null||p.focus()},children:[y.jsxs(Dh,{children:[y.jsx(_h,{children:"Create new project"}),y.jsxs(Hh,{children:["The project will be created at ",y.jsx("code",{children:"~/.seeflow/<slug>"}),"."]})]}),y.jsxs("form",{onSubmit:d,className:"flex flex-col gap-4",children:[y.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[y.jsx("span",{className:"font-medium",children:"Project name"}),y.jsx("input",{type:"text",required:!0,autoComplete:"off",spellCheck:!1,value:r,onChange:f=>o(f.target.value),"data-testid":"create-project-name-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"})]}),i?y.jsx("div",{role:"alert","data-testid":"create-project-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:i}):null,y.jsxs(Hu,{children:[y.jsx(Nt,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:s,children:"Cancel"}),y.jsx(Nt,{type:"submit",disabled:!h,"data-testid":"create-project-submit",children:s?"Creating…":"Create project"})]})]})]})})}const tD="seeflow:navigate",a6e=e=>(window.addEventListener("popstate",e),window.addEventListener(tD,e),()=>{window.removeEventListener("popstate",e),window.removeEventListener(tD,e)}),xB=()=>window.location.pathname,s6e=()=>m.useSyncExternalStore(a6e,xB,xB),qu=e=>{e!==window.location.pathname&&(window.history.pushState({},"",e),window.dispatchEvent(new Event(tD)))};function l6e({demos:e,currentSlug:t,onProjectCreated:n,onProjectUnregistered:r}){const[o,i]=m.useState(!1),[a,s]=m.useState(!1),[l,c]=m.useState(null),[h,d]=m.useState(!1),[f,p]=m.useState(null);m.useEffect(()=>{const x=b=>{b.key==="k"&&(b.metaKey||b.ctrlKey)&&(b.preventDefault(),i(S=>!S))};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[]);const k=e.find(x=>x.slug===t),v=x=>{n==null||n(x),qu(`/d/${x.slug}`)},w=x=>{c(x),p(null)},g=()=>{h||(c(null),p(null))},M=async()=>{if(l){d(!0),p(null);try{await bne(l.id);const x=l.id;c(null),r==null||r(x)}catch(x){p(x instanceof Error?x.message:String(x))}finally{d(!1)}}};return y.jsxs(y.Fragment,{children:[y.jsxs(Ju,{open:o,onOpenChange:i,children:[y.jsx(Eh,{asChild:!0,children:y.jsxs(Nt,{type:"button",variant:"outline",size:"sm","aria-label":"Switch demo","aria-expanded":o,className:"gap-2","data-testid":"project-switcher-trigger",children:[y.jsx("span",{className:"max-w-[180px] truncate text-sm",children:(k==null?void 0:k.name)??"Select demo"}),y.jsx(RK,{children:"⌘K"}),y.jsx(Qd,{className:"h-3.5 w-3.5 opacity-60"})]})}),y.jsx(u1,{align:"end",sideOffset:6,className:"w-[320px] p-0","data-testid":"project-switcher-popover",children:y.jsxs(LK,{children:[y.jsx(IK,{placeholder:"Search demos..."}),y.jsxs(EK,{children:[y.jsx(AK,{children:"No demos."}),e.length>0?y.jsx(PN,{heading:"Demos",children:e.map(x=>y.jsxs(RN,{value:`${x.name} ${x.slug}`,onSelect:()=>{i(!1),qu(`/d/${x.slug}`)},className:"group flex items-center justify-between gap-2",children:[y.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-0.5",children:[y.jsx("span",{className:"font-medium",children:x.name}),y.jsx("span",{className:"w-full truncate text-xs text-muted-foreground",children:x.repoPath})]}),y.jsx("button",{type:"button","aria-label":`Unregister ${x.name}`,className:"shrink-0 rounded p-0.5 opacity-0 transition-opacity hover:text-destructive group-hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring",onClick:b=>{b.stopPropagation(),i(!1),w(x)},children:y.jsx(v2,{className:"h-3.5 w-3.5"})})]},x.id))}):null,e.length>0?y.jsx(PK,{}):null,y.jsx(PN,{children:y.jsxs(RN,{value:"+ create new project",onSelect:()=>{i(!1),s(!0)},"data-testid":"project-switcher-create",className:"flex items-center gap-2 text-sm",children:[y.jsx(d2,{className:"h-4 w-4 opacity-70"}),y.jsx("span",{className:"font-medium",children:"Create new project"})]})})]})]})})]}),y.jsx(i6e,{open:a,onOpenChange:s,onCreated:v}),y.jsx(kz,{open:l!==null,onOpenChange:x=>{x||g()},children:y.jsxs(Nh,{className:"sm:max-w-md","data-testid":"unregister-project-dialog",children:[y.jsxs(Dh,{children:[y.jsx(_h,{children:"Unregister project?"}),y.jsxs(Hh,{children:["This removes ",y.jsx("strong",{children:l==null?void 0:l.name})," from SeeFlow. Your files at"," ",y.jsx("code",{className:"text-xs",children:l==null?void 0:l.repoPath})," will not be deleted."]})]}),f?y.jsx("div",{role:"alert","data-testid":"unregister-project-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:f}):null,y.jsxs(Hu,{children:[y.jsx(Nt,{type:"button",variant:"ghost",onClick:g,disabled:h,children:"Cancel"}),y.jsx(Nt,{type:"button",variant:"destructive",onClick:M,disabled:h,"data-testid":"unregister-project-confirm",children:h?"Unregistering…":"Unregister"})]})]})})]})}function c6e({demos:e,currentSlug:t,onProjectCreated:n,onProjectUnregistered:r}){return y.jsxs("header",{className:"relative flex h-14 shrink-0 items-center justify-between border-b border-border/60 bg-background/85 px-5 backdrop-blur-md shadow-[0_4px_12px_-6px_rgba(0,0,0,0.6)]",children:[y.jsxs("button",{type:"button",onClick:()=>qu("/"),className:"-ml-1.5 flex items-center gap-2 rounded-md px-1.5 py-1 text-base font-bold tracking-tight transition-colors hover:bg-muted/60",children:[y.jsx(b2,{size:18,strokeWidth:2.25,className:"text-emerald-400"}),"SeeFlow",y.jsxs("span",{className:"ml-1 text-[10px] font-normal tracking-normal text-muted-foreground/70",children:["v","0.1.47"]})]}),y.jsx("div",{className:"flex items-center gap-3",children:y.jsx(l6e,{demos:e,currentSlug:t,onProjectCreated:n,onProjectUnregistered:r})})]})}const u6e=e=>{const[t,n]=m.useState(null),[r,o]=m.useState(e!==null),[i,a]=m.useState(null),s=m.useCallback(()=>{e&&(o(!0),KU(e).then(c=>{n(c),a(null)}).catch(c=>{console.error("[useDemoData] failed",c),a(String(c))}).finally(()=>o(!1)))},[e]),l=m.useCallback(c=>{n(c),a(null)},[]);return m.useEffect(()=>{if(!e){n(null),o(!1);return}s()},[e,s]),{detail:t,loading:r,error:i,refresh:s,applyDetail:l}},d6e=()=>{const[e,t]=m.useState(null),[n,r]=m.useState(null),o=m.useCallback(()=>Mne().then(i=>{t(i),r(null)}).catch(i=>{console.error("[useDemos] failed",i),t([]),r(String(i))}),[]);return m.useEffect(()=>{o()},[o]),{demos:e,error:n,refresh:o}},h6e=5,f6e={"node:running":"running","node:done":"done","node:error":"error"},p6e=(e,t)=>{if(t.type==="reset")return{};const n=e[t.nodeId]??[],r=[t.entry,...n].slice(0,h6e);return{...e,[t.nodeId]:r}},y6e=e=>{const[t,n]=m.useReducer(p6e,{}),r=m.useRef(n);r.current=n,m.useEffect(()=>{r.current({type:"reset"})},[e]);const o=m.useCallback(a=>{const s=f6e[a.type];if(!s)return;const l=typeof a.nodeId=="string"?a.nodeId:null;if(!l)return;const c=typeof a.runId=="string"?a.runId:void 0,h=typeof a.ts=="number"?a.ts:Date.now();r.current({type:"append",nodeId:l,entry:{status:s,ts:h,runId:c}})},[]),i=m.useCallback(()=>{r.current({type:"reset"})},[]);return{events:t,apply:o,reset:i}},m6e=(e,t)=>{var n,r;switch(t.type){case"reset":return{};case"running":return{...e,[t.nodeId]:{status:"running",runId:t.runId,ts:t.ts??Date.now()}};case"done":return{...e,[t.nodeId]:{...e[t.nodeId],status:"done",runId:t.runId??((n=e[t.nodeId])==null?void 0:n.runId),responseStatus:t.responseStatus,body:t.body,ts:t.ts??Date.now()}};case"error":return{...e,[t.nodeId]:{...e[t.nodeId],status:"error",runId:t.runId??((r=e[t.nodeId])==null?void 0:r.runId),error:t.message,ts:t.ts??Date.now()}}}},k6e=e=>{const[t,n]=m.useReducer(m6e,{}),r=m.useRef(n);r.current=n,m.useEffect(()=>{r.current({type:"reset"})},[e]);const o=m.useCallback(a=>{const s=typeof a.nodeId=="string"?a.nodeId:null;if(!s)return;const l=typeof a.runId=="string"?a.runId:void 0;if(a.type==="node:running"){r.current({type:"running",nodeId:s,runId:l,ts:a.ts});return}if(a.type==="node:done"){const c=typeof a.status=="number"?a.status:void 0;r.current({type:"done",nodeId:s,runId:l,responseStatus:c,body:a.body,ts:a.ts});return}if(a.type==="node:error"){const c=typeof a.message=="string"?a.message:void 0;r.current({type:"error",nodeId:s,runId:l,message:c,ts:a.ts})}},[]),i=m.useCallback(()=>{r.current({type:"reset"})},[]);return{runs:t,apply:o,reset:i}},g6e=new Set(["ok","warn","error","pending"]),x6e=(e,t)=>{if(t.type!=="node:status")return e;const n=typeof t.nodeId=="string"?t.nodeId:null;if(!n||typeof t.state!="string"||!g6e.has(t.state))return e;const r=typeof t.summary=="string"?t.summary:void 0,o=typeof t.detail=="string"?t.detail:void 0,i=t.data&&typeof t.data=="object"&&!Array.isArray(t.data)?t.data:void 0,a=typeof t.ts=="number"?t.ts:Date.now();return{...e,[n]:{state:t.state,summary:r,detail:o,data:i,ts:a}}},v6e=(e,t)=>{switch(t.type){case"reset":return{};case"event":return x6e(e,t.event)}},w6e=e=>{const[t,n]=m.useReducer(v6e,{}),r=m.useRef(n);r.current=n,m.useEffect(()=>{r.current({type:"reset"})},[e]);const o=m.useCallback(a=>{r.current({type:"event",event:a})},[]),i=m.useCallback(()=>{r.current({type:"reset"})},[]);return{statusByNode:t,apply:o,reset:i}},M6e=(e,t={})=>{const[n,r]=m.useState(!1),{onHello:o,onFlowReload:i,onEvent:a}=t,s=m.useRef(o),l=m.useRef(i),c=m.useRef(a);return m.useEffect(()=>{s.current=o,l.current=i,c.current=a},[o,i,a]),m.useEffect(()=>{if(!e){r(!1);return}const h=`/api/events?flowId=${encodeURIComponent(e)}`,d=new EventSource(h);d.addEventListener("open",()=>r(!0)),d.addEventListener("error",()=>r(!1)),d.addEventListener("hello",()=>{var f;(f=s.current)==null||f.call(s)}),d.addEventListener("flow:reload",f=>{var v,w;const p=vB(f,"flow:reload");(v=c.current)==null||v.call(c,p);const k=b6e(p);k&&((w=l.current)==null||w.call(l,k))});for(const f of["node:running","node:done","node:error","node:status"])d.addEventListener(f,p=>{var k;(k=c.current)==null||k.call(c,vB(p,f))});return()=>{d.close()}},[e]),{connected:n}},vB=(e,t)=>{try{const n=JSON.parse(e.data);return{type:t,ts:Date.now(),...n}}catch{return{type:t,ts:Date.now()}}},b6e=e=>e.valid===!0&&e.flow&&typeof e.flow=="object"?{valid:!0,flow:e.flow}:e.valid===!1&&typeof e.error=="string"?{valid:!1,error:e.error}:null,oJ="seeflow:last-project",C6e=()=>{if(typeof window>"u")return null;try{return window.localStorage.getItem(oJ)}catch{return null}},wB=e=>{if(!(typeof window>"u"))try{window.localStorage.setItem(oJ,e)}catch{}},S6e=(e,t)=>{if(e.length===0)return null;if(e.length===1)return e[0]??null;if(t){const n=e.find(r=>r.id===t);if(n)return n}return null},MB=["File","Edit","View","Tools","Layout","Selection","Help"],iJ="seeflow:command-palette:recent",aJ=5,sJ=new Map(v_.map(e=>[e.id,e])),L6e=e=>typeof e=="string"&&sJ.has(e),bB=()=>{if(typeof window>"u")return[];try{const e=window.localStorage.getItem(iJ);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(L6e).slice(0,aJ):[]}catch{return[]}},I6e=e=>{if(!(typeof window>"u"))try{window.localStorage.setItem(iJ,JSON.stringify(e))}catch{}},CB=(e,t)=>e.enabled?e.enabled(t):!0,E6e=(e,t)=>t.length===0?!0:`${e.label} ${e.description??""}`.toLowerCase().includes(t);function A6e({open:e,onOpenChange:t,runCommand:n,ctx:r}){const[o,i]=m.useState(""),[a,s]=m.useState(0),[l,c]=m.useState(()=>bB()),h=m.useRef(null),d=m.useRef(null);m.useEffect(()=>{e&&(i(""),s(0),c(bB()))},[e]);const{groups:f,flat:p}=m.useMemo(()=>{const b=o.trim().toLowerCase();if(b.length===0){if(l.length===0)return{groups:[],flat:[]};const T=[];for(const z of l){const A=sJ.get(z);A&&T.push({cmd:A,enabled:CB(A,r)})}return{groups:[{category:"Recent",rows:T}],flat:T}}const S=new Map;for(const T of v_){if(!E6e(T,b))continue;const E={cmd:T,enabled:CB(T,r)},z=S.get(T.category);z?z.push(E):S.set(T.category,[E])}const L=[...MB.filter(T=>S.has(T)),...Array.from(S.keys()).filter(T=>!MB.includes(T))].map(T=>({category:T,rows:S.get(T)??[]})),P=L.flatMap(T=>T.rows);return{groups:L,flat:P}},[o,r,l]);m.useEffect(()=>{if(p.length===0){s(0);return}s(b=>{var C;let S=b;if(S>=p.length&&(S=0),!((C=p[S])!=null&&C.enabled)){const L=p.findIndex(P=>P.enabled);L!==-1&&(S=L)}return S})},[p]);const k=m.useCallback(b=>{p.length!==0&&s(S=>{var L;let C=S;for(let P=0;P<p.length;P++)if(C=(C+b+p.length)%p.length,(L=p[C])!=null&&L.enabled)return C;return S})},[p]),v=m.useCallback(b=>{c(S=>{const C=[b,...S.filter(L=>L!==b)].slice(0,aJ);return I6e(C),C})},[]),w=m.useCallback(b=>{const S=p[b];!S||!S.enabled||(v(S.cmd.id),n(S.cmd.id),t(!1))},[p,t,v,n]),g=m.useCallback(b=>{if(b.key==="ArrowDown"){b.preventDefault(),k(1);return}if(b.key==="ArrowUp"){b.preventDefault(),k(-1);return}b.key==="Enter"&&(b.preventDefault(),w(a))},[w,a,k]);m.useEffect(()=>{if(!e)return;const b=d.current;if(!b)return;const S=b.querySelector(`[data-command-row-index="${a}"]`);S&&typeof S.scrollIntoView=="function"&&S.scrollIntoView({block:"nearest"})},[a,e]);const x=o.trim().length>0;return y.jsx(hz,{open:e,onOpenChange:t,children:y.jsx(fz,{children:y.jsxs(ed,{className:ie("fixed left-0 right-0 top-[20%] z-50 mx-auto w-[480px] max-w-[90vw] border border-border bg-card shadow-lg duration-200","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","sm:rounded-lg"),"data-testid":"command-palette",onOpenAutoFocus:b=>{var S;b.preventDefault(),(S=h.current)==null||S.focus()},children:[y.jsx("div",{className:ie("border-b",p.length===0&&!x&&"border-b-0"),children:y.jsx("input",{ref:h,type:"text",value:o,onChange:b=>i(b.target.value),onKeyDown:g,placeholder:"Type a command…","data-testid":"command-palette-input","aria-label":"Search commands",autoComplete:"off",spellCheck:!1,className:"w-full bg-transparent px-4 py-3 text-sm outline-hidden placeholder:text-muted-foreground"})}),y.jsx("div",{ref:d,"data-testid":"command-palette-list","data-empty":p.length===0?"true":"false",className:ie("max-h-[50vh] overflow-y-auto",p.length>0?"py-1":"","seeflow-no-scrollbar"),children:p.length===0?x?y.jsxs("div",{"data-testid":"command-palette-empty",className:"px-4 py-6 text-center text-sm text-muted-foreground",children:['No commands match "',o,'"']}):null:(()=>{let b=-1;return f.map(S=>y.jsxs("div",{className:"py-1",children:[y.jsx("div",{className:"px-3 pb-1 pt-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:S.category}),S.rows.map(C=>{b+=1;const L=b,P=L===a;return y.jsxs("button",{type:"button","data-testid":`command-palette-row-${C.cmd.id}`,"data-command-row-index":L,"data-highlighted":P?"true":"false","aria-disabled":C.enabled?void 0:!0,disabled:!C.enabled,onMouseEnter:()=>{C.enabled&&s(L)},onClick:()=>w(L),className:ie("flex w-full items-center justify-between gap-3 px-3 py-2 text-left text-sm outline-hidden",C.enabled?"cursor-pointer text-foreground hover:bg-muted":"cursor-not-allowed text-muted-foreground/50",P&&C.enabled?"bg-muted":""),children:[y.jsxs("div",{className:"flex min-w-0 flex-col",children:[y.jsx("span",{className:"truncate font-medium",children:C.cmd.label}),C.cmd.description?y.jsx("span",{className:"truncate text-xs text-muted-foreground",children:C.cmd.description}):null]}),C.cmd.shortcut?y.jsx("kbd",{"data-testid":`command-palette-shortcut-${C.cmd.id}`,className:"shrink-0 rounded border bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:C.cmd.shortcut}):null]},C.cmd.id)})]},S.category))})()})]})})})}var rn=Uint8Array,$n=Uint16Array,bH=Int32Array,CH=new rn([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),SH=new rn([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),SB=new rn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),lJ=function(e,t){for(var n=new $n(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var o=new bH(n[30]),r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)o[i]=i-n[r]<<5|r;return{b:n,r:o}},cJ=lJ(CH,2),P6e=cJ.b,nD=cJ.r;P6e[28]=258,nD[258]=28;var R6e=lJ(SH,0),LB=R6e.r,rD=new $n(32768);for(var xt=0;xt<32768;++xt){var yi=(xt&43690)>>1|(xt&21845)<<1;yi=(yi&52428)>>2|(yi&13107)<<2,yi=(yi&61680)>>4|(yi&3855)<<4,rD[xt]=((yi&65280)>>8|(yi&255)<<8)>>1}var P2=function(e,t,n){for(var r=e.length,o=0,i=new $n(t);o<r;++o)e[o]&&++i[e[o]-1];var a=new $n(t);for(o=1;o<t;++o)a[o]=a[o-1]+i[o-1]<<1;var s;if(n){s=new $n(1<<t);var l=15-t;for(o=0;o<r;++o)if(e[o])for(var c=o<<4|e[o],h=t-e[o],d=a[e[o]-1]++<<h,f=d|(1<<h)-1;d<=f;++d)s[rD[d]>>l]=c}else for(s=new $n(r),o=0;o<r;++o)e[o]&&(s[o]=rD[a[e[o]-1]++]>>15-e[o]);return s},a1=new rn(288);for(var xt=0;xt<144;++xt)a1[xt]=8;for(var xt=144;xt<256;++xt)a1[xt]=9;for(var xt=256;xt<280;++xt)a1[xt]=7;for(var xt=280;xt<288;++xt)a1[xt]=8;var SR=new rn(32);for(var xt=0;xt<32;++xt)SR[xt]=5;var z6e=P2(a1,9,0),j6e=P2(SR,5,0),uJ=function(e){return(e+7)/8|0},dJ=function(e,t,n){return(n==null||n>e.length)&&(n=e.length),new rn(e.subarray(t,n))},T6e=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Nz=function(e,t,n){var r=new Error(t||T6e[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Nz),!n)throw r;return r},To=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},Pd=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},lT=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var o=n.length,i=n.slice();if(!o)return{t:fJ,l:0};if(o==1){var a=new rn(n[0].s+1);return a[n[0].s]=1,{t:a,l:1}}n.sort(function(S,C){return S.f-C.f}),n.push({s:-1,f:25001});var s=n[0],l=n[1],c=0,h=1,d=2;for(n[0]={s:-1,f:s.f+l.f,l:s,r:l};h!=o-1;)s=n[n[c].f<n[d].f?c++:d++],l=n[c!=h&&n[c].f<n[d].f?c++:d++],n[h++]={s:-1,f:s.f+l.f,l:s,r:l};for(var f=i[0].s,r=1;r<o;++r)i[r].s>f&&(f=i[r].s);var p=new $n(f+1),k=oD(n[h-1],p,0);if(k>t){var r=0,v=0,w=k-t,g=1<<w;for(i.sort(function(C,L){return p[L.s]-p[C.s]||C.f-L.f});r<o;++r){var M=i[r].s;if(p[M]>t)v+=g-(1<<k-p[M]),p[M]=t;else break}for(v>>=w;v>0;){var x=i[r].s;p[x]<t?v-=1<<t-p[x]++-1:++r}for(;r>=0&&v;--r){var b=i[r].s;p[b]==t&&(--p[b],++v)}k=t}return{t:new rn(p),l:k}},oD=function(e,t,n){return e.s==-1?Math.max(oD(e.l,t,n+1),oD(e.r,t,n+1)):t[e.s]=n},IB=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new $n(++t),r=0,o=e[0],i=1,a=function(l){n[r++]=l},s=1;s<=t;++s)if(e[s]==o&&s!=t)++i;else{if(!o&&i>2){for(;i>138;i-=138)a(32754);i>2&&(a(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(a(o),--i;i>6;i-=6)a(8304);i>2&&(a(i-3<<5|8208),i=0)}for(;i--;)a(o);i=1,o=e[s]}return{c:n.subarray(0,r),n:t}},Rd=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},hJ=function(e,t,n){var r=n.length,o=uJ(t+2);e[o]=r&255,e[o+1]=r>>8,e[o+2]=e[o]^255,e[o+3]=e[o+1]^255;for(var i=0;i<r;++i)e[o+i+4]=n[i];return(o+4+r)*8},EB=function(e,t,n,r,o,i,a,s,l,c,h){To(t,h++,n),++o[256];for(var d=lT(o,15),f=d.t,p=d.l,k=lT(i,15),v=k.t,w=k.l,g=IB(f),M=g.c,x=g.n,b=IB(v),S=b.c,C=b.n,L=new $n(19),P=0;P<M.length;++P)++L[M[P]&31];for(var P=0;P<S.length;++P)++L[S[P]&31];for(var T=lT(L,7),E=T.t,z=T.l,A=19;A>4&&!E[SB[A-1]];--A);var U=c+5<<3,R=Rd(o,a1)+Rd(i,SR)+a,V=Rd(o,f)+Rd(i,v)+a+14+3*A+Rd(L,E)+2*L[16]+3*L[17]+7*L[18];if(l>=0&&U<=R&&U<=V)return hJ(t,h,e.subarray(l,l+c));var O,B,D,N;if(To(t,h,1+(V<R)),h+=2,V<R){O=P2(f,p,0),B=f,D=P2(v,w,0),N=v;var I=P2(E,z,0);To(t,h,x-257),To(t,h+5,C-1),To(t,h+10,A-4),h+=14;for(var P=0;P<A;++P)To(t,h+3*P,E[SB[P]]);h+=3*A;for(var W=[M,S],H=0;H<2;++H)for(var j=W[H],P=0;P<j.length;++P){var G=j[P]&31;To(t,h,I[G]),h+=E[G],G>15&&(To(t,h,j[P]>>5&127),h+=j[P]>>12)}}else O=z6e,B=a1,D=j6e,N=SR;for(var P=0;P<s;++P){var X=r[P];if(X>255){var G=X>>18&31;Pd(t,h,O[G+257]),h+=B[G+257],G>7&&(To(t,h,X>>23&31),h+=CH[G]);var Y=X&31;Pd(t,h,D[Y]),h+=N[Y],Y>3&&(Pd(t,h,X>>5&8191),h+=SH[Y])}else Pd(t,h,O[X]),h+=B[X]}return Pd(t,h,O[256]),h+B[256]},N6e=new bH([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),fJ=new rn(0),D6e=function(e,t,n,r,o,i){var a=i.z||e.length,s=new rn(r+a+5*(1+Math.ceil(a/7e3))+o),l=s.subarray(r,s.length-o),c=i.l,h=(i.r||0)&7;if(t){h&&(l[0]=i.r>>3);for(var d=N6e[t-1],f=d>>13,p=d&8191,k=(1<<n)-1,v=i.p||new $n(32768),w=i.h||new $n(k+1),g=Math.ceil(n/3),M=2*g,x=function(ee){return(e[ee]^e[ee+1]<<g^e[ee+2]<<M)&k},b=new bH(25e3),S=new $n(288),C=new $n(32),L=0,P=0,T=i.i||0,E=0,z=i.w||0,A=0;T+2<a;++T){var U=x(T),R=T&32767,V=w[U];if(v[R]=V,w[U]=R,z<=T){var O=a-T;if((L>7e3||E>24576)&&(O>423||!c)){h=EB(e,l,0,b,S,C,P,E,A,T-A,h),E=L=P=0,A=T;for(var B=0;B<286;++B)S[B]=0;for(var B=0;B<30;++B)C[B]=0}var D=2,N=0,I=p,W=R-V&32767;if(O>2&&U==x(T-W))for(var H=Math.min(f,O)-1,j=Math.min(32767,T),G=Math.min(258,O);W<=j&&--I&&R!=V;){if(e[T+D]==e[T+D-W]){for(var X=0;X<G&&e[T+X]==e[T+X-W];++X);if(X>D){if(D=X,N=W,X>H)break;for(var Y=Math.min(W,X-2),re=0,B=0;B<Y;++B){var ne=T-W+B&32767,ae=v[ne],ve=ne-ae&32767;ve>re&&(re=ve,V=ne)}}}R=V,V=v[R],W+=R-V&32767}if(N){b[E++]=268435456|nD[D]<<18|LB[N];var be=nD[D]&31,me=LB[N]&31;P+=CH[be]+SH[me],++S[257+be],++C[me],z=T+D,++L}else b[E++]=e[T],++S[e[T]]}}for(T=Math.max(T,z);T<a;++T)b[E++]=e[T],++S[e[T]];h=EB(e,l,c,b,S,C,P,E,A,T-A,h),c||(i.r=h&7|l[h/8|0]<<3,h-=7,i.h=w,i.p=v,i.i=T,i.w=z)}else{for(var T=i.w||0;T<a+c;T+=65535){var ge=T+65535;ge>=a&&(l[h/8|0]=c,ge=a),h=hJ(l,h+1,e.subarray(T,ge))}i.i=a}return dJ(s,0,r+uJ(h)+o)},_6e=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),H6e=function(){var e=-1;return{p:function(t){for(var n=e,r=0;r<t.length;++r)n=_6e[n&255^t[r]]^n>>>8;e=n},d:function(){return~e}}},pJ=function(){var e=1,t=0;return{p:function(n){for(var r=e,o=t,i=n.length|0,a=0;a!=i;){for(var s=Math.min(a+2655,i);a<s;++a)o+=r+=n[a];r=(r&65535)+15*(r>>16),o=(o&65535)+15*(o>>16)}e=r,t=o},d:function(){return e%=65521,t%=65521,(e&255)<<24|(e&65280)<<8|(t&255)<<8|t>>8}}},yJ=function(e,t,n,r,o){if(!o&&(o={l:1},t.dictionary)){var i=t.dictionary.subarray(-32768),a=new rn(i.length+e.length);a.set(i),a.set(e,i.length),e=a,o.w=i.length}return D6e(e,t.level==null?6:t.level,t.mem==null?o.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,r,o)},mJ=function(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n},Ot=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},F6e=function(e,t){var n=t.level,r=n==0?0:n<6?1:n==9?3:2;if(e[0]=120,e[1]=r<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var o=pJ();o.p(t.dictionary),Ot(e,2,o.d())}};function O6e(e,t){return yJ(e,t||{},0,0)}function P8e(e,t){t||(t={});var n=pJ();n.p(e);var r=yJ(e,t,t.dictionary?6:2,4);return F6e(r,t),Ot(r,r.length-4,n.d()),r}var kJ=function(e,t,n,r){for(var o in e){var i=e[o],a=t+o,s=r;Array.isArray(i)&&(s=mJ(r,i[1]),i=i[0]),i instanceof rn?n[a]=[i,s]:(n[a+="/"]=[new rn(0),s],kJ(i,a,n,r))}},AB=typeof TextEncoder<"u"&&new TextEncoder,q6e=typeof TextDecoder<"u"&&new TextDecoder,V6e=0;try{q6e.decode(fJ,{stream:!0}),V6e=1}catch{}function iD(e,t){var n;if(AB)return AB.encode(e);for(var r=e.length,o=new rn(e.length+(e.length>>1)),i=0,a=function(c){o[i++]=c},n=0;n<r;++n){if(i+5>o.length){var s=new rn(i+8+(r-n<<1));s.set(o),o=s}var l=e.charCodeAt(n);l<128||t?a(l):l<2048?(a(192|l>>6),a(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|e.charCodeAt(++n)&1023,a(240|l>>18),a(128|l>>12&63),a(128|l>>6&63),a(128|l&63)):(a(224|l>>12),a(128|l>>6&63),a(128|l&63))}return dJ(o,0,i)}var aD=function(e){var t=0;if(e)for(var n in e){var r=e[n].length;r>65535&&Nz(9),t+=r+4}return t},PB=function(e,t,n,r,o,i,a,s){var l=r.length,c=n.extra,h=s&&s.length,d=aD(c);Ot(e,t,a!=null?33639248:67324752),t+=4,a!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(i<0&&8),e[t++]=o&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),p=f.getFullYear()-1980;if((p<0||p>119)&&Nz(10),Ot(e,t,p<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,i!=-1&&(Ot(e,t,n.crc),Ot(e,t+4,i<0?-i-2:i),Ot(e,t+8,n.size)),Ot(e,t+12,l),Ot(e,t+14,d),t+=16,a!=null&&(Ot(e,t,h),Ot(e,t+6,n.attrs),Ot(e,t+10,a),t+=14),e.set(r,t),t+=l,d)for(var k in c){var v=c[k],w=v.length;Ot(e,t,+k),Ot(e,t+2,w),e.set(v,t+4),t+=4+w}return h&&(e.set(s,t),t+=h),t},B6e=function(e,t,n,r,o){Ot(e,t,101010256),Ot(e,t+8,n),Ot(e,t+10,n),Ot(e,t+12,r),Ot(e,t+16,o)};function $6e(e,t){t||(t={});var n={},r=[];kJ(e,"",n,t);var o=0,i=0;for(var a in n){var s=n[a],l=s[0],c=s[1],h=c.level==0?0:8,d=iD(a),f=d.length,p=c.comment,k=p&&iD(p),v=k&&k.length,w=aD(c.extra);f>65535&&Nz(11);var g=h?O6e(l,c):l,M=g.length,x=H6e();x.p(l),r.push(mJ(c,{size:l.length,crc:x.d(),c:g,f:d,m:k,u:f!=a.length||k&&p.length!=v,o,compression:h})),o+=30+f+w+M,i+=76+2*(f+w)+(v||0)+M}for(var b=new rn(i+22),S=o,C=i-o,L=0;L<r.length;++L){var d=r[L];PB(b,d.o,d,d.f,d.u,d.c.length);var P=30+d.f.length+aD(d.extra);b.set(d.c,d.o+P),PB(b,o,d,d.f,d.u,d.c.length,d.o,d.m),o+=16+P+(d.m?d.m.length:0)}return B6e(b,o,r.length,C,S),b}const U6e="https://seeflow.dev/api";async function W6e(e,t,n,r,o){const i=await KU(e);if(!i.flow)throw new Error("Flow has no data");const a=i.flow,s=new Set,l=[];for(const k of a.nodes)k.type==="imageNode"&&k.data.path&&!s.has(k.data.path)&&(s.add(k.data.path),l.push(k.data.path));const h={[r==="link"?"flow.private.json":"flow.json"]:iD(JSON.stringify(a))};if(o){const k=o.split(",")[1];k&&(h["preview.png"]=Uint8Array.from(atob(k),v=>v.charCodeAt(0)))}for(const k of l){const v=await fetch(`/api/projects/${encodeURIComponent(e)}/files/${k}`);v.ok&&(h[`files/${k}`]=new Uint8Array(await v.arrayBuffer()))}const d=$6e(h),f=await fetch(`${U6e}/flows?email=${encodeURIComponent(t)}&name=${encodeURIComponent(n)}`,{method:"POST",headers:{"content-type":"application/zip"},body:d.buffer});if(!f.ok)throw new Error(`Export failed with status ${f.status}`);const p=await f.json();if(typeof p.url!="string")throw new Error("Invalid response from cloud API: missing url");return{shareUrl:p.url}}function G6e(e){return m.useCallback((t,n,r,o)=>W6e(e,t,n,r,o),[e])}const RB="seeflow.export.email",zB="seeflow.export.name",jB="seeflow.export.visibility";function Z6e({open:e,onOpenChange:t,projectId:n,onCapturePreview:r}){const[o,i]=m.useState(""),[a,s]=m.useState(""),[l,c]=m.useState("public"),[h,d]=m.useState({kind:"idle"}),[f,p]=m.useState(!1),k=G6e(n);m.useEffect(()=>{e&&(i(localStorage.getItem(RB)??""),s(localStorage.getItem(zB)??""),c(localStorage.getItem(jB)??"public"),d({kind:"idle"}),p(!1))},[e]);const v=m.useCallback(async()=>{d({kind:"loading"});try{const x=await(r==null?void 0:r()),{shareUrl:b}=await k(o.trim(),a.trim(),l,x);localStorage.setItem(RB,o.trim()),localStorage.setItem(zB,a.trim()),localStorage.setItem(jB,l),d({kind:"done",shareUrl:b})}catch(x){d({kind:"error",message:x instanceof Error?x.message:String(x)})}},[k,o,a,l,r]),w=m.useCallback(async()=>{if(h.kind==="done")try{await navigator.clipboard.writeText(h.shareUrl),p(!0),setTimeout(()=>p(!1),2e3)}catch(x){console.error("Failed to copy to clipboard:",x)}},[h]),g=h.kind==="loading",M=o.trim().length>0&&a.trim().length>0;return y.jsx(kz,{open:e,onOpenChange:t,children:y.jsxs(Nh,{className:"sm:max-w-md","data-testid":"export-dialog",onOpenAutoFocus:x=>{x.preventDefault();const b=document.querySelector('[data-testid="export-email-input"]');b==null||b.focus()},children:[y.jsxs(Dh,{children:[y.jsx(_h,{children:"Export to seeflow.dev"}),y.jsx(Hh,{children:"Upload this diagram to the cloud and get a shareable link."})]}),h.kind!=="done"?y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex flex-col gap-4",children:[y.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[y.jsx("span",{className:"font-medium",children:"Email"}),y.jsx("input",{type:"email",required:!0,autoComplete:"email",value:o,onChange:x=>i(x.target.value),disabled:g,"data-testid":"export-email-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"}),y.jsx("span",{className:"text-xs text-muted-foreground",children:"We'll use this to let you manage your flows in the future."})]}),y.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[y.jsx("span",{className:"font-medium",children:"Flow Name"}),y.jsx("input",{type:"text",required:!0,value:a,onChange:x=>s(x.target.value),disabled:g,"data-testid":"export-name-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"})]}),y.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[y.jsx("span",{className:"font-medium",children:"Visibility"}),y.jsxs("select",{value:l,onChange:x=>c(x.target.value),disabled:g,"data-testid":"export-visibility-select",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",children:[y.jsx("option",{value:"public",children:"Public — anyone can discover it"}),y.jsx("option",{value:"link",children:"Anyone with the link"})]})]}),h.kind==="error"?y.jsx("div",{role:"alert","data-testid":"export-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:h.message}):null]}),y.jsx(Hu,{children:h.kind==="error"?y.jsxs(y.Fragment,{children:[y.jsx(Nt,{type:"button",variant:"ghost",onClick:()=>t(!1),"data-testid":"export-cancel",children:"Cancel"}),y.jsx(Nt,{type:"button",onClick:()=>d({kind:"idle"}),"data-testid":"export-retry",children:"Try again"})]}):y.jsxs(y.Fragment,{children:[y.jsx(Nt,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:g,"data-testid":"export-cancel",children:"Cancel"}),y.jsx(Nt,{type:"button",onClick:v,disabled:g||!M,"data-testid":"export-submit",children:g?y.jsxs(y.Fragment,{children:[y.jsx(Cr,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}),y.jsx("span",{children:"Uploading…"})]}):"Export"})]})})]}):y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex flex-col gap-3",children:[y.jsx("p",{className:"text-sm text-muted-foreground",children:"Your diagram is live. Share this link:"}),y.jsxs("div",{className:"flex gap-2",children:[y.jsx("input",{type:"text",readOnly:!0,value:h.shareUrl,"data-testid":"export-share-url",className:"min-w-0 flex-1 rounded-md border bg-muted px-3 py-2 text-sm outline-hidden"}),y.jsx(Nt,{type:"button",variant:"outline",size:"icon",onClick:w,"aria-label":"Copy link","data-testid":"export-copy",children:f?y.jsx(fo,{className:"h-4 w-4","aria-hidden":"true"}):y.jsx(ou,{className:"h-4 w-4","aria-hidden":"true"})}),y.jsx(Nt,{type:"button",variant:"outline",size:"icon",onClick:()=>window.open(h.shareUrl,"_blank"),"aria-label":"View in new tab","data-testid":"export-view",children:y.jsx(n2,{className:"h-4 w-4","aria-hidden":"true"})})]})]}),y.jsx(Hu,{children:y.jsx(Nt,{type:"button",onClick:()=>t(!1),"data-testid":"export-done",children:"Done"})})]})]})})}const K6e=(e,t)=>{if(e.has(t))return e;const n=new Set(e);return n.add(t),n},X6e=(e,t)=>{if(t.length===0)return e;let n=!1;const r=new Set(e);for(const o of t)r.has(o)||(r.add(o),n=!0);return n?r:e},Y6e=(e,t)=>{if(!e.has(t))return e;const n=new Set(e);return n.delete(t),n},Q6e=(e,t)=>{if(t.length===0)return e;let n=!1;const r=new Set(e);for(const o of t)r.has(o)&&(r.delete(o),n=!0);return n?r:e},J6e=(e,t)=>{if(e.size===0)return e;const n=new Set(t.map(i=>i.id));let r=!1;const o=new Set(e);for(const i of o)n.has(i)||(o.delete(i),r=!0);return r?o:e},TB=()=>{const[e,t]=m.useState(()=>new Set),n=m.useCallback(l=>{t(c=>K6e(c,l))},[]),r=m.useCallback(l=>{t(c=>X6e(c,l))},[]),o=m.useCallback(l=>{t(c=>Y6e(c,l))},[]),i=m.useCallback(l=>{t(c=>Q6e(c,l))},[]),a=m.useCallback(l=>{t(c=>J6e(c,l))},[]),s=m.useCallback(()=>t(new Set),[]);return{ids:e,mark:n,markMany:r,unmark:o,unmarkMany:i,pruneAgainst:a,reset:s}},e8e=(e,t)=>e===t?!0:e==null||t==null||typeof e!=typeof t||typeof e!="object"?!1:JSON.stringify(e)===JSON.stringify(t),t8e=(e,t,n)=>({...e,[t]:{...e[t],...n}}),n8e=(e,t)=>{if(!(t in e))return e;const n={...e};return delete n[t],n},r8e=(e,t)=>{const n=Object.entries(e);if(n.length===0)return e;const r=new Map(t.map(a=>[a.id,a]));let o=!1;const i={...e};for(const[a,s]of n){const l=r.get(a);if(!l)continue;const c={};let h=!1;for(const d of Object.keys(s))e8e(s[d],l[d])?o=!0:(c[d]=s[d],h=!0);h?i[a]=c:(o=!0,delete i[a])}return o?i:e},NB=()=>{const[e,t]=m.useState({}),n=m.useCallback((a,s)=>{t(l=>t8e(l,a,s))},[]),r=m.useCallback(a=>{t(s=>n8e(s,a))},[]),o=m.useCallback(a=>{t(s=>r8e(s,a))},[]),i=m.useCallback(()=>t({}),[]);return{overrides:e,setOverride:n,dropOverride:r,pruneAgainst:o,reset:i}},o8e=500,i8e=500,a8e={stack:[],cursor:0},s8e=(e,t,n)=>{const r=Date.now(),o=o8e,i=i8e,{stack:a,cursor:s}=e;if(t.coalesceKey&&s>0){const h=a[s-1];if(h&&h.coalesceKey===t.coalesceKey&&r-h.capturedAt<=i){const d=a.slice(0,s);return d[s-1]={...h,do:t.do,capturedAt:r},{stack:d,cursor:s}}}const l=a.slice(0,s);l.push({...t,capturedAt:r});let c=s+1;for(;l.length>o;)l.shift(),c-=1;return c<0&&(c=0),{stack:l,cursor:c}},l8e=e=>e.cursor===0?{state:e,entry:void 0}:{state:{...e,cursor:e.cursor-1},entry:e.stack[e.cursor-1]},c8e=e=>e.cursor===e.stack.length?{state:e,entry:void 0}:{state:{...e,cursor:e.cursor+1},entry:e.stack[e.cursor]},u8e=()=>({stack:[],cursor:0}),d8e=e=>{if(e.cursor===0)return e;const t=e.stack.slice();return t.splice(e.cursor-1,1),{stack:t,cursor:e.cursor-1}},h8e=(e,t)=>t.state,f8e=()=>{const[e,t]=m.useReducer(h8e,a8e),n=m.useRef(e);n.current=e;const r=m.useRef(Promise.resolve()),o=m.useRef(0),i=m.useCallback(p=>{p!==n.current&&(n.current=p,t({type:"replace",state:p}))},[]),a=m.useCallback(p=>{const k={do:p.do,undo:p.undo,coalesceKey:p.coalesceKey,capturedAt:p.capturedAt??Date.now()};i(s8e(n.current,k))},[i]),s=m.useCallback(()=>{o.current=Date.now();const p=r.current.then(()=>{const k=l8e(n.current);if(k.entry)return i(k.state),{entry:k.entry}});return r.current=p.then(()=>{},()=>{}),p},[i]),l=m.useCallback(()=>{o.current=Date.now();const p=r.current.then(()=>{const k=c8e(n.current);if(k.entry)return i(k.state),{entry:k.entry}});return r.current=p.then(()=>{},()=>{}),p},[i]),c=m.useCallback(()=>{i(u8e())},[i]),h=m.useCallback(()=>{i(d8e(n.current))},[i]),d=m.useCallback(()=>{o.current=Date.now()},[]),f=m.useCallback(()=>o.current,[]);return{push:a,undo:s,redo:l,clear:c,dropTop:h,canUndo:e.cursor>0,canRedo:e.cursor<e.stack.length,markMutation:d,lastMutationAt:f}};function p8e({nodes:e,connectors:t,flowPos:n,nodeIdGen:r,connectorIdGen:o,defaultOffset:i={x:24,y:24}}){const a=new Map;for(const p of e)a.set(p.id,r(p.id));let s=Number.POSITIVE_INFINITY,l=Number.POSITIVE_INFINITY;for(const p of e)p.position.x<s&&(s=p.position.x),p.position.y<l&&(l=p.position.y);Number.isFinite(s)||(s=0),Number.isFinite(l)||(l=0);const c=n?n.x-s:i.x,h=n?n.y-l:i.y,d=e.map(p=>{const k=a.get(p.id);if(k===void 0)throw new Error(`paste id missing for ${p.id}`);return{...p,id:k,position:{x:p.position.x+c,y:p.position.y+h}}}),f=t.map(p=>{const k=o(p.id);return{...p,id:k,source:a.get(p.source)??p.source,target:a.get(p.target)??p.target}});return{newNodes:d,newConnectors:f,idMap:a}}const y8e=e=>({type:"imageNode",position:e.position,data:{path:"",alt:e.originalFilename,width:e.dims.width,height:e.dims.height,_uploading:!0}}),m8e=e=>({type:"imageNode",data:gJ(e)}),k8e=e=>({type:"imageNode",position:e.position,data:{path:"",alt:e.originalFilename,width:e.dims.width,height:e.dims.height,_uploadError:e.message}}),gJ=e=>({...zue(e.path,e.dims,e.lastUsed),alt:e.originalFilename}),g8e=async(e,t)=>{const{nodeId:n,flowId:r,file:o,originalFilename:i,position:a,dims:s,lastUsed:l}=e;t.rememberRetry(n,{file:o,originalFilename:i,position:a,dims:s}),t.setOverride(n,y8e({position:a,dims:s,originalFilename:i}));let c;try{c=(await t.upload(r,n,o,i)).path}catch(p){const k=p instanceof Error?p.message:String(p);throw t.setOverride(n,k8e({position:a,dims:s,originalFilename:i,message:k})),p}t.setOverride(n,m8e({path:c,dims:s,originalFilename:i,lastUsed:l}));const h=gJ({path:c,dims:s,originalFilename:i,lastUsed:l}),d={id:n,type:"imageNode",position:a,data:h},{id:f}=await t.createNode(r,d);t.forgetRetry(n),t.pushUndo&&t.pushUndo({do:async()=>{await t.createNode(r,{...d,id:f})},undo:async()=>{await t.deleteNode(r,f)}})},x8e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",v8e=248;function No(e=10){let t="";const n=new Uint8Array(e*2);for(;t.length<e;){crypto.getRandomValues(n);for(let r=0;r<n.length&&t.length<e;r++){const o=n[r];o<v8e&&(t+=x8e[o%62])}}return t}const w8e=new Set(["INPUT","TEXTAREA","SELECT"]),xr=e=>e?w8e.has(e.tagName)?!0:e instanceof HTMLElement&&e.isContentEditable:!1,M8e=(e,t,n)=>{const r=e.indexOf(t);if(r<0)return null;const o=e.length,i=[...e];switch(n.op){case"forward":{if(r>=o-1)return null;const a=i[r],s=i[r+1];return a===void 0||s===void 0?null:(i[r]=s,i[r+1]=a,i)}case"backward":{if(r<=0)return null;const a=i[r],s=i[r-1];return a===void 0||s===void 0?null:(i[r]=s,i[r-1]=a,i)}case"toFront":{if(r===o-1)return null;const[a]=i.splice(r,1);return a===void 0?null:(i.push(a),i)}case"toBack":{if(r===0)return null;const[a]=i.splice(r,1);return a===void 0?null:(i.unshift(a),i)}case"toIndex":{const a=Math.min(Math.max(n.index,0),o-1);if(a===r)return null;const[s]=i.splice(r,1);return s===void 0?null:(i.splice(a,0,s),i)}}};function b8e({slug:e,demos:t,detail:n,loading:r,runs:o,nodeEvents:i,statusByNode:a,onPlayNode:s,onRestartDemo:l}){var ad,sd;const c=t.find(F=>F.slug===e),[h,d]=m.useState([]),[f,p]=m.useState([]),[k,v]=m.useState(null),w=m.useRef(h),g=m.useRef(f);m.useEffect(()=>{w.current=h},[h]),m.useEffect(()=>{g.current=f},[f]);const M=m.useRef(null),x=m.useRef(null),b=m.useRef(null),S=NB(),C=NB(),L=TB(),P=TB(),[T,E]=m.useState(null),[z,A]=m.useState(null),[U,R]=m.useState(null),V=m.useRef(null);m.useEffect(()=>{V.current=U},[U]);const[O,B]=m.useState(!1),[D,N]=m.useState(0),I=m.useRef(null),W=m.useRef(null),H=m.useCallback(F=>{W.current=F},[]),j=f8e(),{push:G,dropTop:X,markMutation:Y,clear:re,lastMutationAt:ne}=j,{reset:ae}=S,{reset:ve}=C,{reset:be}=L,{reset:me}=P;m.useEffect(()=>{d([]),p([]),v(null),ae(),ve(),be(),me(),E(null),A(null),Br.current=null,So(!1),mr.current.clear(),j.clear()},[n==null?void 0:n.id]);const ge=m.useCallback((F,q)=>{d(F),p(q)},[]),ee=(ad=n==null?void 0:n.flow)==null?void 0:ad.nodes,ke=(sd=n==null?void 0:n.flow)==null?void 0:sd.connectors,{pruneAgainst:Fe}=S,{pruneAgainst:rt}=C,{pruneAgainst:mt}=L,{pruneAgainst:ht}=P;m.useEffect(()=>{ee&&(Fe(ee),mt(ee)),Date.now()-ne()>2e3&&re()},[ee,Fe,mt,ne,re]),m.useEffect(()=>{if(!ee)return;const F=I.current,q=new Set(ee.map(oe=>oe.id));if(I.current=q,F===null)return;const Z=S.overrides,$=L.ids;let _=!1;for(const oe of q)if(!F.has(oe)&&!(oe in Z)){_=!0;break}if(!_){for(const oe of F)if(!q.has(oe)&&!$.has(oe)){_=!0;break}}_&&N(oe=>oe+1)},[ee]),m.useEffect(()=>{ke&&(rt(ke),ht(ke)),Date.now()-ne()>2e3&&re()},[ke,rt,ht,ne,re]),m.useEffect(()=>{if(!(!ee||!T)&&ee.length===T.length){for(let F=0;F<ee.length;F++){const q=ee[F],Z=T[F];if(!q||q.id!==Z)return}E(null)}},[ee,T]);const le=(n==null?void 0:n.id)??null,Q=m.useMemo(()=>le?jue({baseUrl:"",flowId:le}):null,[le]),[fe,we]=m.useState(!1),{setOverride:Se,dropOverride:Oe}=S,te=m.useRef(S.overrides);m.useEffect(()=>{te.current=S.overrides},[S.overrides]);const de=m.useCallback((F,q)=>{var $;if(!le||!Q)return;const Z=($=ee==null?void 0:ee.find(_=>_.id===F))==null?void 0:$.position;Se(F,{position:q}),A(null),Y(),Z&&G({do:async()=>{await Q.updateNodePosition(F,q)},undo:async()=>{await Q.updateNodePosition(F,Z)},coalesceKey:`node:${F}:position`}),Q.updateNodePosition(F,q).catch(_=>{Oe(F),Z&&X(),A(_ instanceof Error?_.message:String(_)),console.error("updateNodePosition failed",_)})},[le,Q,ee,Se,Oe,G,X,Y]),Pe=m.useCallback(F=>{if(!le||!Q||F.length===0)return;const q=te.current,Z=F.map($=>{var Ae;const _=ee==null?void 0:ee.find(Me=>Me.id===$.id);if(!_)return null;const oe=((Ae=q[$.id])==null?void 0:Ae.position)??_.position;return{id:$.id,prev:oe,next:$.position}}).filter($=>$!==null);if(Z.length!==0){for(const $ of Z)Se($.id,{position:$.next});A(null),Y(),G({do:async()=>{await Promise.allSettled(Z.map($=>Q.updateNodePosition($.id,$.next)))},undo:async()=>{await Promise.allSettled(Z.map($=>Q.updateNodePosition($.id,$.prev)))}}),Promise.all(Z.map(async $=>{try{return await Q.updateNodePosition($.id,$.next),null}catch(_){return Oe($.id),_ instanceof Error?_.message:String(_)}})).then($=>{const _=$.find(oe=>oe!==null);_&&A(_)})}},[le,Q,ee,Se,Oe,G,Y]),qe=m.useCallback((F,q)=>{Se(F,{position:{x:q.x,y:q.y},data:{width:q.width,height:q.height}})},[Se]),We=m.useCallback((F,q)=>{if(!le||!Q)return;const Z=ee==null?void 0:ee.find(oe=>oe.id===F),$=Z?{width:Z.data.width,height:Z.data.height,position:{x:Z.position.x,y:Z.position.y}}:void 0,_={width:q.width,height:q.height,position:{x:q.x,y:q.y}};Se(F,{position:_.position,data:{width:_.width,height:_.height}}),A(null),Y(),$&&G({do:async()=>{await Q.updateNode(F,_)},undo:async()=>{await Q.updateNode(F,$)},coalesceKey:`node:${F}:resize`}),Q.updateNode(F,_).catch(oe=>{Oe(F),$&&X(),A(oe instanceof Error?oe.message:String(oe)),console.error("updateNode resize failed",oe)})},[le,Q,ee,Se,Oe,G,X,Y]),Rt=m.useCallback(F=>{if(!le||!Q)return;const q=ee==null?void 0:ee.find(_=>_.id===F);if(!q)return;const Z={autoSize:q.data.autoSize,width:q.data.width,height:q.data.height},$={autoSize:!0};Se(F,{data:{autoSize:!0,width:void 0,height:void 0}}),A(null),Y(),G({do:async()=>{await Q.updateNode(F,$)},undo:async()=>{await Q.updateNode(F,Z)},coalesceKey:`node:${F}:fit-to-content`}),Q.updateNode(F,$).catch(_=>{Oe(F),X(),A(_ instanceof Error?_.message:String(_)),console.error("updateNode (fit-to-content) failed",_)})},[le,Q,ee,Se,Oe,G,X,Y]),st=m.useCallback(F=>{if(!le||!Q||F.length===0)return;const q=[];for(const $ of F){const _=ee==null?void 0:ee.find(Ue=>Ue.id===$.id);if(!_)continue;const oe=_.data,Ae={position:{x:_.position.x,y:_.position.y}};oe.width!==void 0&&(Ae.width=oe.width),oe.height!==void 0&&(Ae.height=oe.height);const Me={position:$.position};$.width!==void 0&&(Me.width=$.width),$.height!==void 0&&(Me.height=$.height),q.push({id:$.id,prev:Ae,next:Me})}if(q.length===0)return;for(const $ of q){const _={};$.next.width!==void 0&&(_.width=$.next.width),$.next.height!==void 0&&(_.height=$.next.height),Se($.id,{position:$.next.position,...Object.keys(_).length>0?{data:_}:{}})}A(null),Y();const Z=q.map($=>$.id).sort();G({do:async()=>{await Promise.allSettled(q.map($=>Q.updateNode($.id,$.next)))},undo:async()=>{await Promise.allSettled(q.map($=>Q.updateNode($.id,$.prev)))},coalesceKey:`multi:resize:${Z.join(",")}`}),Promise.all(q.map(async $=>{try{return await Q.updateNode($.id,$.next),null}catch(_){return Oe($.id),_ instanceof Error?_.message:String(_)}})).then($=>{const _=$.find(oe=>oe!==null);_&&A(_)})},[le,Q,ee,Se,Oe,G,Y]),{setOverride:Ne,dropOverride:ot}=C,Jn=m.useCallback((F,q)=>{Se(F,{data:q})},[Se]),zt=m.useCallback((F,q)=>{for(const Z of F)Se(Z,{data:q})},[Se]),zn=m.useCallback((F,q)=>{Ne(F,q)},[Ne]),Kt=m.useCallback((F,q)=>{if(!le||!Q)return;aq(aa,q);const Z=ee==null?void 0:ee.find(_=>_.id===F);let $=null;if(Z){$={};const _=Z.data;for(const oe of Object.keys(q))$[oe]=_[oe]}if(Se(F,{data:q}),A(null),Y(),$){const _=$;G({do:async()=>{await Q.updateNode(F,q)},undo:async()=>{await Q.updateNode(F,_)},coalesceKey:`node:${F}:style`})}Q.updateNode(F,q).catch(_=>{Oe(F),$&&X(),A(_ instanceof Error?_.message:String(_)),console.error("updateNode style failed",_)})},[le,Q,ee,Se,Oe,G,X,Y]),p1=m.useCallback((F,q)=>{if(!le||!Q||F.length===0)return;aq(aa,q);const Z=F.map($=>{const _=ee==null?void 0:ee.find(Me=>Me.id===$);if(!_)return null;const oe=_.data,Ae={};for(const Me of Object.keys(q))Ae[Me]=oe[Me];return{id:$,prev:Ae}}).filter($=>$!==null);if(Z.length!==0){for(const $ of Z)Se($.id,{data:q});A(null),Y(),G({do:async()=>{await Promise.allSettled(Z.map($=>Q.updateNode($.id,q)))},undo:async()=>{await Promise.allSettled(Z.map($=>Q.updateNode($.id,$.prev)))}}),Promise.all(Z.map(async $=>{try{return await Q.updateNode($.id,q),null}catch(_){return Oe($.id),_ instanceof Error?_.message:String(_)}})).then($=>{const _=$.find(oe=>oe!==null);_&&A(_)})}},[le,Q,ee,Se,Oe,G,Y]),y1=m.useCallback((F,q)=>{if(!le||!Q)return;Iue(aa,q);const Z=ke==null?void 0:ke.find(_=>_.id===F);let $=null;if(Z){$={};const _=Z;for(const oe of Object.keys(q))$[oe]=_[oe]}if(Ne(F,q),A(null),Y(),$){const _=$;G({do:async()=>{await Q.updateConnector(F,q)},undo:async()=>{await Q.updateConnector(F,_)},coalesceKey:`connector:${F}:style`})}Q.updateConnector(F,q).catch(_=>{ot(F),$&&X(),A(_ instanceof Error?_.message:String(_)),console.error("updateConnector failed",_)})},[le,Q,ke,Ne,ot,G,X,Y]),{mark:Jo,markMany:ei,unmark:_r,unmarkMany:Ki}=L,{mark:ti,markMany:fr,unmark:Hr,unmarkMany:pr}=P,m1=m.useCallback(F=>{if(!le||!Q)return;const q=ee==null?void 0:ee.find(Me=>Me.id===F);if(!q)return;const Z=(ke??[]).filter(Me=>Me.source===F||Me.target===F),$=Z.map(Me=>Me.id),_=new Set($);A(null),Jo(F),$.length>0&&fr($),d(Me=>Me.filter(Ue=>Ue!==F)),p(Me=>Me.filter(Ue=>!_.has(Ue))),Y();const oe=q,Ae=Z;G({do:async()=>{Jo(F),$.length>0&&fr($),await Q.deleteNode(F)},undo:async()=>{_r(F),$.length>0&&pr($),await Q.createNode({id:oe.id,type:oe.type,position:oe.position,data:oe.data});for(const Me of Ae)await Q.createConnector({...Me,id:Me.id})}}),Q.deleteNode(F).catch(Me=>{_r(F),$.length>0&&pr($),X(),A(Me instanceof Error?Me.message:String(Me)),console.error("deleteNode failed",Me)})},[le,Q,ee,ke,Jo,fr,_r,pr,G,X,Y]),k1=m.useCallback((F,q)=>{if(!le||!Q||!ee)return;const Z=T??ee.map(oe=>oe.id),$=M8e(Z,F,q);if(!$)return;const _=Z.indexOf(F);E($),A(null),Y(),G({do:async()=>{await Q.reorderNode(F,q)},undo:async()=>{await Q.reorderNode(F,{op:"toIndex",index:_})}}),Q.reorderNode(F,q).catch(oe=>{E(null),X(),A(oe instanceof Error?oe.message:String(oe)),console.error("reorderNode failed",oe)})},[le,Q,ee,T,G,X,Y]);m.useCallback(F=>{if(!le||!Q)return;const q=ke==null?void 0:ke.find($=>$.id===F);if(!q)return;A(null),ti(F),p($=>$.filter(_=>_!==F)),Y();const Z=q;G({do:async()=>{ti(F),await Q.deleteConnector(F)},undo:async()=>{Hr(F),await Q.createConnector({...Z,id:Z.id})}}),Q.deleteConnector(F).catch($=>{Hr(F),X(),A($ instanceof Error?$.message:String($)),console.error("deleteConnector failed",$)})},[le,Q,ke,ti,Hr,G,X,Y]);const He=m.useCallback((F,q)=>{if(!le||!Q||F.length===0&&q.length===0)return;const Z=new Set(F),$=F.map(ze=>ee==null?void 0:ee.find(it=>it.id===ze)).filter(ze=>!!ze),_=(ke??[]).filter(ze=>Z.has(ze.source)||Z.has(ze.target)),oe=new Set(_.map(ze=>ze.id)),Ae=q.map(ze=>ke==null?void 0:ke.find(it=>it.id===ze)).filter(ze=>!!ze).filter(ze=>!oe.has(ze.id));if($.length===0&&_.length===0&&Ae.length===0)return;A(null);const Me=$.map(ze=>ze.id),Ue=[..._.map(ze=>ze.id),...Ae.map(ze=>ze.id)];Me.length>0&&ei(Me),Ue.length>0&&fr(Ue);const Ut=$;d(ze=>ze.filter(it=>!Z.has(it)));const Eo=new Set(Ae.map(ze=>ze.id));p(ze=>ze.filter(it=>!Eo.has(it)&&!oe.has(it))),Y(),G({do:async()=>{Me.length>0&&ei(Me),Ue.length>0&&fr(Ue);for(const ze of Ut)await Q.deleteNode(ze.id).catch(()=>{});await Promise.allSettled(Ae.map(ze=>Q.deleteConnector(ze.id)))},undo:async()=>{Me.length>0&&Ki(Me),Ue.length>0&&pr(Ue);for(let ze=Ut.length-1;ze>=0;ze--){const it=Ut[ze];it&&await Q.createNode({id:it.id,type:it.type,position:it.position,data:it.data})}for(const ze of[..._,...Ae])await Q.createConnector({...ze,id:ze.id})}});const Dn=new Map;for(const ze of $)Dn.set(ze.id,_.filter(it=>it.source===ze.id||it.target===ze.id).map(it=>it.id));(async()=>{const ze=[];for(const Yt of Ut)try{await Q.deleteNode(Yt.id)}catch(gn){_r(Yt.id);const na=Dn.get(Yt.id)??[];na.length>0&&pr(na),ze.push(gn instanceof Error?gn.message:String(gn))}const it=await Promise.all(Ae.map(async Yt=>{try{return await Q.deleteConnector(Yt.id),null}catch(gn){return Hr(Yt.id),gn instanceof Error?gn.message:String(gn)}}));for(const Yt of it)Yt!==null&&ze.push(Yt);ze.length>0&&ze[0]!==void 0&&A(ze[0])})()},[le,Q,ee,ke,ei,fr,_r,Ki,Hr,pr,G,Y]);m.useEffect(()=>{M.current=He},[He]),m.useEffect(()=>{const F=q=>{if(q.key!=="Delete"&&q.key!=="Backspace"||xr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=w.current,$=g.current;Z.length===0&&$.length===0||(q.preventDefault(),He(Z,$))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[He]);const{undo:Mt,redo:Fr,canUndo:Or,canRedo:jn}=j;m.useEffect(()=>{const F=async q=>{if((q.metaKey||q.ctrlKey)&&q.key.toLowerCase()==="z"&&!xr(document.activeElement)){if(q.preventDefault(),q.shiftKey){if(!jn)return;try{const Z=await Fr();Z!=null&&Z.entry&&await Z.entry.do()}catch(Z){A(Z instanceof Error?Z.message:String(Z)),console.error("redo failed",Z)}return}if(Or)try{const Z=await Mt();Z!=null&&Z.entry&&await Z.entry.undo()}catch(Z){A(Z instanceof Error?Z.message:String(Z)),console.error("undo failed",Z)}}};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[Mt,Fr,Or,jn]);const yr=m.useCallback((F,q)=>{if(!le||!Q)return;const Z=ee==null?void 0:ee.find(oe=>oe.id===F),_=(Z&&"name"in Z.data?Z.data.name:void 0)??"";Se(F,{data:{name:q}}),A(null),Y(),Z&&G({do:async()=>{await Q.updateNode(F,{name:q})},undo:async()=>{await Q.updateNode(F,{name:_})},coalesceKey:`node:${F}:name`}),Q.updateNode(F,{name:q}).catch(oe=>{Z&&X(),A(oe instanceof Error?oe.message:String(oe)),console.error("updateNode name failed",oe)})},[le,Q,ee,Se,G,X,Y]),Mo=m.useCallback((F,q)=>{if(!le||!Q)return;const Z=ee==null?void 0:ee.find(_=>_.id===F);if(!Z)return;const $=Z.data.description??"";Se(F,{data:{description:q}}),A(null),Y(),G({do:async()=>{await Q.updateNode(F,{description:q})},undo:async()=>{await Q.updateNode(F,{description:$})},coalesceKey:`node:${F}:description`}),Q.updateNode(F,{description:q}).catch(_=>{X(),A(_ instanceof Error?_.message:String(_)),console.error("updateNode description failed",_)})},[le,Q,ee,Se,G,X,Y]),er=m.useCallback((F,q)=>{if(!le||!Q)return;const Z=ee==null?void 0:ee.find(_=>_.id===F);if(!Z)return;const $=Z.data.detail??"";Se(F,{data:{detail:q}}),A(null),Y(),G({do:async()=>{await Q.updateNode(F,{detail:q})},undo:async()=>{await Q.updateNode(F,{detail:$})},coalesceKey:`node:${F}:detail`}),Q.updateNode(F,{detail:q}).catch(_=>{X(),A(_ instanceof Error?_.message:String(_)),console.error("updateNode detail failed",_)})},[le,Q,ee,Se,G,X,Y]),qr=m.useCallback((F,q)=>{if(!le||!Q)return;const Z=ee==null?void 0:ee.find(_=>_.id===F);if(!Z)return;const $="icon"in Z.data?Z.data.icon??null:null;Se(F,{data:{icon:q??void 0}}),A(null),Y(),G({do:async()=>{await Q.updateNode(F,{icon:q})},undo:async()=>{await Q.updateNode(F,{icon:$})},coalesceKey:`node:${F}:icon`}),Q.updateNode(F,{icon:q}).catch(_=>{X(),A(_ instanceof Error?_.message:String(_)),console.error("updateNode icon failed",_)})},[le,Q,ee,Se,G,X,Y]),an=m.useCallback((F,q,Z)=>{if(!le||!Q)return;A(null);const $=`node-${No()}`,_=lq(F,Z,P0(aa).node),oe={id:$,type:"shapeNode",position:q,data:_};Se($,{id:$,type:"shapeNode",position:q,data:_}),Y(),Q.createNode(oe).then(({id:Me})=>{G({do:async()=>{await Q.createNode({...oe,id:Me})},undo:async()=>{await Q.deleteNode(Me)}})}).catch(Me=>{Oe($),A(Me instanceof Error?Me.message:String(Me)),console.error("createNode failed",Me)})},[le,Q,Se,Oe,G,Y]),jt=m.useCallback((F,q)=>{if(!le||!Q)return;A(null);const Z=`node-${No()}`,$={icon:F,width:Tu.width,height:Tu.height},_={id:Z,type:"iconNode",position:q,data:$};Se(Z,{id:Z,type:"iconNode",position:q,data:$}),d([Z]),Y(),Q.createNode(_).then(({id:Ae})=>{G({do:async()=>{await Q.createNode({..._,id:Ae})},undo:async()=>{await Q.deleteNode(Ae)}})}).catch(Ae=>{Oe(Z),A(Ae instanceof Error?Ae.message:String(Ae)),console.error("createNode (icon) failed",Ae)})},[le,Q,Se,Oe,G,Y]),bo=m.useCallback(F=>{if(!le||!Q)return;A(null);const q=`node-${No()}`,Z={id:q,type:"htmlNode",position:F.position,data:{}},$={id:q,type:"htmlNode",position:F.position,data:{}};Se(q,$),d([q]),Y(),Q.createNode(Z).then(({id:_})=>{G({do:async()=>{await Q.createNode({...Z,id:_})},undo:async()=>{await Q.deleteNode(_)}})}).catch(_=>{Oe(q),A(_ instanceof Error?_.message:String(_)),console.error("createNode (htmlNode) failed",_)})},[le,Q,Se,Oe,G,Y]),mr=m.useRef(new Map),Xi=m.useCallback((F,q)=>{mr.current.set(F,q)},[]),Yi=m.useCallback(F=>{mr.current.delete(F)},[]),Co=m.useCallback(F=>{!le||!Q||(A(null),Y(),g8e({...F,flowId:le,lastUsed:P0(aa).node},{upload:(q,Z,$,_)=>Q.uploadImage(Z,$,_),createNode:async(q,Z)=>{const{id:$}=await Q.createNode(Z);return{id:$}},deleteNode:async(q,Z)=>(await Q.deleteNode(Z),{ok:!0}),setOverride:Se,pushUndo:G,rememberRetry:Xi,forgetRetry:Yi}).catch(q=>{console.error("image-upload-flow failed",q)}))},[le,Q,Se,G,Y,Xi,Yi]),Ct=m.useCallback(F=>{if(!le||!Q)return;const q=`node-${No()}`;Co({nodeId:q,...F})},[le,Q,Co]),Qi=m.useCallback(F=>{const q=mr.current.get(F);q&&Co({nodeId:F,...q})},[Co]),[Tn,ni]=m.useState({open:!1,mode:"insert"}),tr=m.useCallback((F,q)=>{ni({open:!0,mode:F,nodeId:q})},[]),kr=m.useCallback(()=>{ni(F=>({...F,open:!1}))},[]),g1=m.useCallback(()=>{tr("insert")},[tr]),Ji=m.useCallback(F=>tr("replace",F),[tr]),ea=m.useCallback(F=>{if(kue(F),Tn.mode==="replace"&&Tn.nodeId){if(le&&Q){const q=Tn.nodeId,Z=ee==null?void 0:ee.find(_=>_.id===q),$=(Z==null?void 0:Z.type)==="iconNode"?Z.data.icon:void 0;if(Se(q,{data:{icon:F}}),A(null),Y(),$!==void 0){const _=$;G({do:async()=>{await Q.updateNode(q,{icon:F})},undo:async()=>{await Q.updateNode(q,{icon:_})},coalesceKey:`node:${q}:icon`})}Q.updateNode(q,{icon:F}).catch(_=>{Oe(q),$!==void 0&&X(),A(_ instanceof Error?_.message:String(_)),console.error("updateNode (icon replace) failed",_)})}}else{const q=W.current;if(q&&le){const Z=yue(q,{width:window.innerWidth,height:window.innerHeight});jt(F,Z)}}kr()},[Tn.mode,Tn.nodeId,le,Q,ee,Se,Oe,G,X,Y,jt,kr]),ri=m.useCallback((F,q)=>{if(!le||!Q)return;const Z=ke==null?void 0:ke.find(_=>_.id===F),$=Z==null?void 0:Z.label;Ne(F,{label:q}),A(null),Y(),Z&&G({do:async()=>{await Q.updateConnector(F,{label:q})},undo:async()=>{await Q.updateConnector(F,{label:$})},coalesceKey:`connector:${F}:label`}),Q.updateConnector(F,{label:q}).catch(_=>{Z&&X(),A(_ instanceof Error?_.message:String(_)),console.error("updateConnector label failed",_)})},[le,Q,ke,Ne,G,X,Y]),mn=m.useCallback((F,q,Z)=>{if(!le||!Q)return;const $=`conn-${No()}`,_=Z==null?void 0:Z.targetPin,oe=P0(aa).connector,Ae={id:$,source:F,target:q,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,..._?{targetPin:_}:{},...oe,kind:"default"},Me={id:$,source:F,target:q,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,..._?{targetPin:_}:{},...oe,kind:"default"};Ne($,Ae),A(null),Y(),Q.createConnector(Me).then(({id:Ue})=>{G({do:async()=>{await Q.createConnector({...Me,id:Ue})},undo:async()=>{await Q.deleteConnector(Ue)}})}).catch(Ue=>{ot($),A(Ue instanceof Error?Ue.message:String(Ue)),console.error("createConnector failed",Ue)})},[le,Q,Ne,ot,G,Y]),Vr=m.useCallback(({sourceNodeId:F,position:q,shape:Z})=>{if(!le||!Q)return;A(null);const $=`node-${No()}`,_=`conn-${No()}`,oe=pR[Z],Ae=P0(aa),Me=lq(Z,oe,Ae.node),Ue={id:$,type:"shapeNode",position:q,data:Me},Ut={id:_,source:F,target:$,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...Ae.connector,kind:"default"};Se($,{id:$,type:"shapeNode",position:q,data:Me}),Ne(_,Ut),v($),Y(),(async()=>{try{await Q.createNode(Ue),await Q.createConnector(Ut),G({do:async()=>{await Q.createNode(Ue),await Q.createConnector(Ut)},undo:async()=>{ot(_),Oe($),await Q.deleteConnector(_).catch(()=>{}),await Q.deleteNode($).catch(()=>{})}})}catch(Dn){Oe($),ot(_),A(Dn instanceof Error?Dn.message:String(Dn)),console.error("createAndConnectFromPane failed",Dn)}})()},[le,Q,Se,Oe,Ne,ot,G,Y]),Br=m.useRef(null),[x1,So]=m.useState(!1),nr=m.useCallback(F=>{if(!ee)return;const q=new Set(F),Z=ee.filter(_=>q.has(_.id));if(Z.length===0)return;const $=(ke??[]).filter(_=>q.has(_.source)&&q.has(_.target));Br.current=JSON.parse(JSON.stringify({nodes:Z,connectors:$})),So(!0)},[ee,ke]),kn=m.useCallback(F=>{if(!le||!Q)return;const q=Br.current;if(!q||q.nodes.length===0)return;const{newNodes:Z,newConnectors:$}=p8e({nodes:q.nodes,connectors:q.connectors,flowPos:F,nodeIdGen:()=>`node-${No()}`,connectorIdGen:()=>`conn-${No()}`});for(const _ of Z)Se(_.id,_);for(const _ of $)Ne(_.id,_);d(Z.map(_=>_.id)),p($.map(_=>_.id)),A(null),Y(),(async()=>{try{for(const _ of Z)await Q.createNode({id:_.id,type:_.type,position:_.position,data:_.data});for(const _ of $)await Q.createConnector(_);G({do:async()=>{for(const _ of Z)await Q.createNode({id:_.id,type:_.type,position:_.position,data:_.data});for(const _ of $)await Q.createConnector(_)},undo:async()=>{await Promise.allSettled($.map(_=>Q.deleteConnector(_.id))),await Promise.allSettled(Z.map(_=>Q.deleteNode(_.id)))}})}catch(_){for(const oe of Z)Oe(oe.id);for(const oe of $)ot(oe.id);A(_ instanceof Error?_.message:String(_)),console.error("paste failed",_)}})()},[le,Q,Se,Oe,Ne,ot,Y,G]);m.useEffect(()=>{const F=q=>{const Z=Sue({event:q,isEditableActive:xr(document.activeElement),hasNodes:!!ee&&ee.length>0,hasConnectors:!!ke&&ke.length>0,selectedIds:w.current,hasClipboard:!!Br.current});if(Z.type!=="noop"&&!(Z.type==="copy"||Z.type==="paste")){if(q.preventDefault(),Z.type==="selectAll"){d((ee??[]).map($=>$.id)),p((ke??[]).map($=>$.id));return}nr([...Z.ids]),kn(null)}};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[ee,ke,nr,kn]),m.useEffect(()=>{const F=q=>{const Z=Mue(q);if(!Z||xr(document.activeElement))return;const $=w.current;if($.length===0)return;const _=S.overrides,oe=(ee??[]).map(Me=>{var Ut;const Ue=((Ut=_[Me.id])==null?void 0:Ut.position)??Me.position;return{id:Me.id,position:Ue}}),Ae=Cue(Z,$,oe);if(Ae.length!==0)if(q.preventDefault(),Ae.length===1){const Me=Ae[0];Me&&de(Me.id,Me.position)}else Pe(Ae)};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[ee,S.overrides,de,Pe]),m.useEffect(()=>{const F=q=>{const Z=bue(q);if(!Z||xr(document.activeElement))return;q.preventDefault();const $=W.current;$&&(Z==="fit"?$.fitView({padding:.2,duration:200}):Z==="in"?$.zoomIn({duration:150}):$.zoomOut({duration:150}))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]);const sn=m.useCallback(async F=>{if(!le||!Q||!ee||!Q.computeLayout)return;const q=S.overrides,Z=W.current,$=F==="selection"?new Set(w.current):null,_=$?ee.filter(De=>$.has(De.id)):ee;if(_.length<2)return;const oe=new Set(_.map(De=>De.id)),Ae=(ke??[]).filter(De=>oe.has(De.source)&&oe.has(De.target)),Me=new Map,Ue=_.map(De=>{var vn;const Qe=((vn=q[De.id])==null?void 0:vn.position)??De.position;Me.set(De.id,Qe);const Ht=Z==null?void 0:Z.getInternalNode(De.id),xn=Ht==null?void 0:Ht.measured,Ao=De.data,ra=(xn==null?void 0:xn.width)??Ao.width??200,ld=(xn==null?void 0:xn.height)??Ao.height??120;return{id:De.id,type:De.type,width:ra,height:ld}}),Ut=Ae.map(De=>({id:De.id,source:De.source,target:De.target})),Eo=await Q.computeLayout(Ue,Ut),Dn=new Map;for(const[De,Qe]of Object.entries(Eo.nodes))Dn.set(De,Qe.position);let ze=Number.POSITIVE_INFINITY,it=Number.POSITIVE_INFINITY,Yt=Number.POSITIVE_INFINITY,gn=Number.POSITIVE_INFINITY;for(const De of Ue){const Qe=Me.get(De.id);if(!Qe)continue;Qe.x<ze&&(ze=Qe.x),Qe.y<it&&(it=Qe.y);const Ht=Dn.get(De.id);Ht&&(Ht.x<Yt&&(Yt=Ht.x),Ht.y<gn&&(gn=Ht.y))}const na=Number.isFinite(ze)&&Number.isFinite(Yt)?ze-Yt:0,_z=Number.isFinite(it)&&Number.isFinite(gn)?it-gn:0,ai=[];for(const De of Ue){const Qe=Me.get(De.id),Ht=Dn.get(De.id);if(!Qe||!Ht)continue;const xn={x:Ht.x+na,y:Ht.y+_z},Ao=xn.x-Qe.x,ra=xn.y-Qe.y;Math.abs(Ao)<1&&Math.abs(ra)<1||ai.push({id:De.id,prev:Qe,next:xn})}if(ai.length!==0){A(null);for(const De of ai)Se(De.id,{position:De.next});Y(),G({do:async()=>{await Promise.allSettled(ai.map(De=>Q.updateNodePosition(De.id,De.next)))},undo:async()=>{await Promise.allSettled(ai.map(De=>Q.updateNodePosition(De.id,De.prev)))}}),Promise.all(ai.map(async De=>{try{return await Q.updateNodePosition(De.id,De.next),null}catch(Qe){return Oe(De.id),Qe instanceof Error?Qe.message:String(Qe)}})).then(De=>{const Qe=De.filter(xn=>xn!==null),Ht=Qe[0];Ht&&(A(Qe.length===1?Ht:`${Qe.length} node updates failed (first: ${Ht})`),console.error("Tidy: some updateNodePosition calls failed",Qe))})}},[le,Q,ee,ke,S.overrides,Se,Oe,G,Y]);m.useEffect(()=>{const F=q=>{if(!(q.metaKey||q.ctrlKey)||!q.shiftKey||q.altKey||q.key.toLowerCase()!=="l"||xr(document.activeElement))return;q.preventDefault();const Z=w.current.length>0?"selection":"all";sn(Z)};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[sn]);const oi=m.useCallback(()=>{const F=w.current.length>0?"selection":"all";sn(F)},[sn]);m.useEffect(()=>{const F=q=>{if(xr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=Lue(q);if(Z===null)return;const $=Z==="select"?null:Z;if(V.current===$){R(null);return}R($)};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]),m.useEffect(()=>{const F=q=>{q.key==="Escape"&&(xr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]')||(w.current.length>0&&d([]),g.current.length>0&&p([]),V.current!==null&&R(null)))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]),m.useEffect(()=>{const F=q=>{if(q.key.toLowerCase()!=="f"||q.metaKey||q.ctrlKey||q.shiftKey||q.altKey||xr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=w.current;if(Z.length===0)return;const $=W.current;$&&$.fitView({nodes:Z.map(_=>({id:_})),padding:.2,duration:200})};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]),m.useEffect(()=>{const F=q=>{if(q.key!=="1"||q.metaKey||q.ctrlKey||q.shiftKey||q.altKey||xr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=W.current;if(!Z)return;const{x:$,y:_}=Z.getViewport();Z.setViewport({x:$,y:_,zoom:1},{duration:150})};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]);const rr=m.useCallback(F=>{var q,Z,$;switch(F){case"tool.select":R(null);return;case"tool.rectangle":R("rectangle");return;case"tool.ellipse":R("ellipse");return;case"tool.text":R("text");return;case"tool.sticky":R("sticky");return;case"tool.database":R("database");return;case"edit.undo":{if(!Or)return;(async()=>{try{const _=await Mt();_!=null&&_.entry&&await _.entry.undo()}catch(_){A(_ instanceof Error?_.message:String(_)),console.error("undo failed",_)}})();return}case"edit.redo":{if(!jn)return;(async()=>{try{const _=await Fr();_!=null&&_.entry&&await _.entry.do()}catch(_){A(_ instanceof Error?_.message:String(_)),console.error("redo failed",_)}})();return}case"edit.copy":{const _=w.current;if(_.length===0)return;nr([..._]);return}case"edit.paste":kn(null);return;case"edit.duplicate":{const _=w.current;if(_.length===0)return;nr([..._]),kn(null);return}case"edit.delete":{const _=w.current,oe=g.current;if(_.length===0&&oe.length===0)return;He([..._],[...oe]);return}case"edit.selectAll":d((ee??[]).map(_=>_.id)),p((ke??[]).map(_=>_.id));return;case"view.fit":{const _=W.current;if(!_)return;_.fitView({padding:.2,duration:200});return}case"view.zoomIn":{const _=W.current;if(!_)return;_.zoomIn({duration:150});return}case"view.zoomOut":{const _=W.current;if(!_)return;_.zoomOut({duration:150});return}case"view.zoom100":{const _=W.current;if(!_)return;const{x:oe,y:Ae}=_.getViewport();_.setViewport({x:oe,y:Ae,zoom:1},{duration:150});return}case"view.zoomToSelection":{const _=w.current;if(_.length===0)return;const oe=W.current;if(!oe)return;oe.fitView({nodes:_.map(Ae=>({id:Ae})),padding:.2,duration:200});return}case"layout.tidy":{const _=w.current.length>0?"selection":"all";sn(_);return}case"selection.deselect":w.current.length>0&&d([]),g.current.length>0&&p([]),V.current!==null&&R(null);return;case"help.commandPalette":B(!0);return;case"export.pdf":{(q=b.current)==null||q.exportPdf();return}case"export.png":{(Z=b.current)==null||Z.exportPng();return}case"session.reset":{($=x.current)==null||$.call(x);return}}},[Or,jn,Mt,Fr,nr,kn,He,ee,ke,sn]);m.useEffect(()=>{const F=q=>{(q.metaKey||q.ctrlKey)&&(q.shiftKey||q.altKey||q.key.toLowerCase()==="p"&&(q.preventDefault(),!xr(document.activeElement)&&rr("help.commandPalette")))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[rr]),m.useEffect(()=>{x.current=l??null},[l]);const $r=m.useCallback((F,q)=>{if(!le||!Q)return;const Z=ke==null?void 0:ke.find(oe=>oe.id===F),$=Z?{source:Z.source,target:Z.target,sourceHandle:Z.sourceHandle,targetHandle:Z.targetHandle,sourceHandleAutoPicked:Z.sourceHandleAutoPicked,targetHandleAutoPicked:Z.targetHandleAutoPicked,sourcePin:Z.sourcePin??null,targetPin:Z.targetPin??null}:null,_={...q.source!==void 0?{source:q.source}:{},...q.target!==void 0?{target:q.target}:{},...q.sourceHandle!==void 0?{sourceHandle:q.sourceHandle===null?void 0:q.sourceHandle}:{},...q.targetHandle!==void 0?{targetHandle:q.targetHandle===null?void 0:q.targetHandle}:{},...q.sourceHandleAutoPicked!==void 0?{sourceHandleAutoPicked:q.sourceHandleAutoPicked}:{},...q.targetHandleAutoPicked!==void 0?{targetHandleAutoPicked:q.targetHandleAutoPicked}:{},...q.sourcePin!==void 0?{sourcePin:q.sourcePin===null?void 0:q.sourcePin}:{},...q.targetPin!==void 0?{targetPin:q.targetPin===null?void 0:q.targetPin}:{}};if(Ne(F,_),A(null),Y(),$){const oe=$;G({do:async()=>{await Q.updateConnector(F,q)},undo:async()=>{await Q.updateConnector(F,oe)},coalesceKey:`connector:${F}:reconnect`})}Q.updateConnector(F,q).catch(oe=>{ot(F),$&&X(),A(oe instanceof Error?oe.message:String(oe)),console.error("updateConnector reconnect failed",oe)})},[le,Q,ke,Ne,ot,G,X,Y]),Ur=m.useCallback((F,q,Z)=>{if(!le||!Q)return;const $=ke==null?void 0:ke.find(Ae=>Ae.id===F),_=$?q==="source"?$.sourcePin:$.targetPin:void 0,oe=q==="source"?"sourcePin":"targetPin";if(Ne(F,{[oe]:Z}),A(null),Y(),$){const Ae={[oe]:_??null};G({do:async()=>{await Q.updateConnector(F,{[oe]:Z})},undo:async()=>{await Q.updateConnector(F,Ae)},coalesceKey:`connector:${F}:${oe}`})}Q.updateConnector(F,{[oe]:Z}).catch(Ae=>{ot(F),$&&X(),A(Ae instanceof Error?Ae.message:String(Ae)),console.error("updateConnector pin failed",Ae)})},[le,Q,ke,Ne,ot,G,X,Y]),Lo=m.useCallback((F,q)=>{if(!le||!Q)return;const Z=ke==null?void 0:ke.find(oe=>oe.id===F),$=Z?q==="source"?Z.sourcePin:Z.targetPin:void 0;if(!$)return;const _=q==="source"?"sourcePin":"targetPin";Ne(F,{[_]:void 0}),A(null),Y(),G({do:async()=>{await Q.updateConnector(F,{[_]:null})},undo:async()=>{await Q.updateConnector(F,{[_]:$})}}),Q.updateConnector(F,{[_]:null}).catch(oe=>{ot(F),X(),A(oe instanceof Error?oe.message:String(oe)),console.error("updateConnector unpin failed",oe)})},[le,Q,ke,Ne,ot,G,X,Y]),Je=n==null?void 0:n.flow,Wr=S.overrides,Nn=C.overrides,Xt=L.ids,Gr=P.ids,v1=m.useMemo(()=>{if(!Je||h.length===0)return[];const F=new Map(Je.nodes.map(Z=>[Z.id,Z])),q=[];for(const Z of h){const $=F.get(Z);if(!$)continue;const _=Wr[Z];if(!_){q.push($);continue}const oe=_.data?{...$.data,..._.data}:$.data;q.push({...$,..._,data:oe})}return q},[Je,h,Wr]),Dz=m.useMemo(()=>{if(!Je||f.length===0)return[];const F=new Map(Je.connectors.map(Z=>[Z.id,Z])),q=[];for(const Z of f){const $=F.get(Z);if(!$)continue;const _=Nn[Z];q.push(_?{...$,..._}:$)}return q},[Je,f,Nn]),Kh=m.useMemo(()=>{if(!Je)return null;if(!T)return Je.nodes;const F=new Map(Je.nodes.map($=>[$.id,$])),q=[],Z=new Set;for(const $ of T){const _=F.get($);_&&(q.push(_),Z.add($))}for(const $ of Je.nodes)Z.has($.id)||q.push($);return q},[Je,T]),Io=m.useMemo(()=>{const F=Kh??(Je==null?void 0:Je.nodes)??null;return F?Xt.size===0?F:F.filter(q=>!Xt.has(q.id)):null},[Kh,Je,Xt]),ta=m.useMemo(()=>{const F=(Je==null?void 0:Je.connectors)??null;return F?Gr.size===0&&Xt.size===0?F:F.filter(q=>!Gr.has(q.id)&&!Xt.has(q.source)&&!Xt.has(q.target)):null},[Je,Gr,Xt]);if(!c)return y.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[y.jsxs("p",{className:"text-sm font-medium",children:["Unknown demo: ",e]}),y.jsx("p",{className:"text-xs text-muted-foreground",children:"The slug may have been removed. Re-register from the project repo to bring it back."})]});if(r&&!n)return y.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"Loading demo…"});const id=h[0],ii=id?a[id]:void 0;return y.jsxs("div",{className:"relative h-full w-full",children:[n&&!n.valid?y.jsxs("div",{"data-testid":"demo-error-banner",className:"absolute inset-x-0 top-0 z-10 border-b border-rose-500/40 bg-rose-50 px-4 py-2 text-xs text-rose-900 shadow-xs dark:bg-rose-950/40 dark:text-rose-100",children:[y.jsx("span",{className:"font-medium uppercase tracking-wide",children:"Invalid demo: "}),y.jsx("span",{className:"font-mono",children:n.error})]}):null,Je&&Q?y.jsx(o6e,{ref:b,mode:"edit",adapter:Q,projectId:le??void 0,enableEmbed:!1,onExportToCloud:le?()=>we(!0):void 0,onRestartDemo:l,nodes:Io??Je.nodes,connectors:ta??Je.connectors,selectedNodeIds:h,selectedConnectorIds:f,onSelectionChange:ge,runtime:{runs:o,statuses:a,pendingOverrides:{nodes:Wr,connectors:Nn}},onPlayNode:s,onNodePositionChange:de,onNodePositionsChange:Pe,onNodeResize:qe,onNodeResizeEnd:We,onHtmlNodeFitToContent:Rt,onMultiResize:st,onNodeNameChange:yr,onNodeDescriptionChange:Mo,onConnectorLabelChange:ri,onCreateShapeNode:an,onCreateImageFromFile:le?Ct:void 0,onRetryImageUpload:le?Qi:void 0,onCreateHtmlNode:le?bo:void 0,iconPickerOpen:Tn.open,onOpenIconPicker:le?g1:void 0,onCloseIconPicker:le?kr:void 0,onPickIcon:le?ea:void 0,onRequestIconReplace:le?Ji:void 0,onCreateConnector:mn,onReconnectConnector:$r,onPinEndpoint:le?Ur:void 0,onUnpinEndpoint:le?Lo:void 0,onReorderNode:k1,onDeleteNode:m1,onCopyNode:F=>nr([F]),onPasteAt:kn,onCopySelection:le?nr:void 0,onPasteSelection:le?()=>kn(null):void 0,hasClipboard:x1,selectedNodes:v1,selectedConnectors:Dz,onStyleNode:Kt,onStyleNodePreview:Jn,onStyleNodes:p1,onStyleNodesPreview:zt,onStyleConnector:y1,onStyleConnectorPreview:zn,onRfInit:H,onTidy:ee?oi:void 0,onCreateAndConnectFromPane:Vr,pendingEditNodeId:k,activeShape:U,onSelectShape:R,statusReport:ii,onNameChange:yr,onDescriptionChange:Mo,onDetailChange:er,onIconChange:qr,autoFitView:!0,autoFitViewSignal:D}):y.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"No demo data yet."}),z?y.jsxs("div",{"data-testid":"edit-error-banner",className:"absolute inset-x-0 bottom-4 z-20 mx-auto w-fit max-w-[80%] rounded-md border border-rose-500/50 bg-rose-50 px-3 py-2 text-xs text-rose-900 shadow-md dark:bg-rose-950/60 dark:text-rose-100",children:[y.jsx("span",{className:"font-medium",children:"Couldn't save change: "}),y.jsx("span",{className:"font-mono",children:z}),y.jsx("button",{type:"button",className:"ml-3 underline underline-offset-2",onClick:()=>A(null),children:"Dismiss"})]}):null,y.jsx(A6e,{open:O,onOpenChange:B,runCommand:rr,ctx:{hasSelection:h.length>0||f.length>0,canUndo:Or,canRedo:jn,hasClipboard:x1,canExportDemo:!!le,canResetSession:!!l}}),le?y.jsx(Z6e,{open:fe,onOpenChange:we,projectId:le,onCapturePreview:()=>{var F;return((F=b.current)==null?void 0:F.capturePreview())??Promise.resolve(void 0)}}):null]})}const DB="npx seeflow register --path .";function C8e(){const[e,t]=m.useState(!1),n=async()=>{try{await navigator.clipboard.writeText(DB),t(!0),setTimeout(()=>t(!1),1200)}catch(r){console.error("[empty-state] copy failed",r)}};return y.jsx("div",{"data-testid":"seeflow-empty-state",className:"flex h-full w-full items-center justify-center bg-background p-6",children:y.jsxs("div",{className:"flex max-w-lg flex-col items-center gap-6 text-center",children:[y.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:y.jsx(x2,{className:"h-6 w-6 text-muted-foreground"})}),y.jsxs("div",{className:"space-y-2",children:[y.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:"No demos registered yet"}),y.jsxs("p",{className:"text-sm text-muted-foreground",children:["Point SeeFlow at any folder containing a"," ",y.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs",children:".seeflow/flow.json"})," file and it'll appear here."]})]}),y.jsxs("div",{className:"flex w-full items-center gap-2 rounded-md border border-border bg-card px-3 py-2 font-mono text-sm",children:[y.jsx("span",{className:"text-muted-foreground select-none",children:"$"}),y.jsx("code",{className:"flex-1 truncate text-left",children:DB}),y.jsx(Nt,{type:"button",variant:"ghost",size:"sm",onClick:n,"aria-label":"Copy register command",children:e?y.jsx(fo,{className:"h-4 w-4"}):y.jsx(ou,{className:"h-4 w-4"})})]})]})})}function S8e({demos:e}){return e.length===0?y.jsx(C8e,{}):y.jsx("div",{className:"flex h-full w-full items-start justify-center overflow-y-auto bg-background p-8",children:y.jsxs("div",{"data-testid":"studio-home-picker",className:"flex w-full max-w-2xl flex-col gap-6 pt-8",children:[y.jsxs("div",{className:"space-y-1",children:[y.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Open a demo"}),y.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.length," demos registered — pick one to load its canvas."]})]}),y.jsx("ul",{className:"flex flex-col gap-2",children:e.map(t=>y.jsx("li",{children:y.jsxs("button",{type:"button",onClick:()=>qu(`/d/${t.slug}`),"data-testid":`studio-home-demo-${t.slug}`,className:"flex w-full flex-col items-start gap-0.5 rounded-lg border border-border bg-card px-4 py-3 text-left transition-colors hover:border-input",style:{boxShadow:"var(--shadow-card)"},children:[y.jsx("span",{className:"text-sm font-medium",children:t.name}),y.jsx("span",{className:"truncate text-xs text-muted-foreground",children:t.repoPath})]})},t.id))})]})})}const L8e=e=>{if(!e.startsWith("/d/"))return null;const t=e.slice(3);return t.length>0?decodeURIComponent(t):null};function I8e(){const e=s6e(),{demos:t,refresh:n}=d6e(),r=L8e(e),o=r?(t??[]).find(P=>P.slug===r):void 0,i=(o==null?void 0:o.id)??null,{detail:a,loading:s,refresh:l,applyDetail:c}=u6e(i),{runs:h,apply:d}=k6e(i),{events:f,apply:p}=y6e(i),{statusByNode:k,apply:v,reset:w}=w6e(i),g=m.useCallback(()=>{w(),l(),n()},[l,n,w]),M=m.useCallback(P=>{if(!i||!o)return;const T={id:i,slug:o.slug,filePath:""},E=P.valid?{...T,name:P.flow.name??o.name,flow:P.flow,valid:!0,error:null}:{...T,name:o.name,flow:null,valid:!1,error:P.error};c(E)},[i,o,c]),x=m.useCallback(P=>{d(P),p(P),v(P)},[d,p,v]);M6e(i,{onHello:g,onFlowReload:M,onEvent:x});const b=m.useCallback(async()=>{if(i)try{await Sne(i)}catch(P){console.error("Failed to restart demo:",P)}},[i]),S=m.useCallback(P=>{wB(P.id),n()},[n]),C=m.useCallback(async P=>{await n(),i===P&&qu("/")},[n,i]);m.useEffect(()=>{if(e!=="/"||t===null)return;const P=S6e(t,C6e());P&&qu(`/d/${P.slug}`)},[e,t]),m.useEffect(()=>{o&&wB(o.id)},[o]);const L=m.useCallback(P=>{i&&Lne(i,P).catch(T=>{d({type:"node:error",nodeId:P,message:T instanceof Error?T.message:String(T),ts:Date.now()})})},[i,d]);return t===null?y.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading…"}):y.jsx(L2,{delayDuration:150,children:y.jsxs("div",{className:"flex h-full w-full flex-col bg-background text-foreground",children:[y.jsx(c6e,{demos:t,currentSlug:r??void 0,onProjectCreated:S,onProjectUnregistered:C}),y.jsx("main",{className:"min-h-0 flex-1",children:r?y.jsx(b8e,{slug:r,demos:t,detail:a,loading:s,runs:h,nodeEvents:f,statusByNode:k,onPlayNode:L,onRestartDemo:i?b:void 0}):y.jsx(S8e,{demos:t})})]})})}const xJ=document.getElementById("root");if(!xJ)throw new Error("Root element #root not found");cT.createRoot(xJ).render(y.jsx(oo.StrictMode,{children:y.jsx(I8e,{})}));export{j3e as _,LP as c,uh as g,P8e as z};
|
|
7838
|
+
`)}async function bwe(e,t){const n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await Mwe(e,t);if(n){const r=document.createElement("style"),o=document.createTextNode(n);r.appendChild(o),e.firstChild?e.insertBefore(r,e.firstChild):e.appendChild(r)}}async function Cwe(e,t={}){const{width:n,height:r}=ZQ(e,t),o=await Tz(e,t,!0);return await bwe(o,t),await eJ(o,t),kwe(o,t),await q3e(o,n,r)}async function Swe(e,t={}){const{width:n,height:r}=ZQ(e,t),o=await Cwe(e,t),i=await CR(o),a=document.createElement("canvas"),s=a.getContext("2d"),l=t.pixelRatio||H3e(),c=t.canvasWidth||n,h=t.canvasHeight||r;return a.width=c*l,a.height=h*l,t.skipAutoScale||F3e(a),a.style.width=`${c}`,a.style.height=`${h}`,t.backgroundColor&&(s.fillStyle=t.backgroundColor,s.fillRect(0,0,a.width,a.height)),s.drawImage(i,0,0,a.width,a.height),a}async function Lwe(e,t={}){return(await Swe(e,t)).toDataURL()}const Iwe=e=>e instanceof Element?!(e.classList.contains("react-flow__minimap")||e.classList.contains("react-flow__controls")||e.classList.contains("react-flow__panel")):!0,dB="#0a0a0c",Ewe=e=>{let t=e;for(;t&&!t.classList.contains("seeflow-canvas-root");)t=t.parentElement;if(!t)return dB;const n=getComputedStyle(t).getPropertyValue("--bg-canvas").trim();return n.length>0?n:dB},Awe=async e=>{const t=await Lwe(e,{cacheBust:!0,filter:Iwe,backgroundColor:Ewe(e)}),n=await new Promise((r,o)=>{const i=new Image;i.onload=()=>r({width:i.naturalWidth,height:i.naturalHeight}),i.onerror=()=>o(new Error("Failed to decode captured image")),i.src=t});return{dataUrl:t,...n}},Pwe=(e,t)=>{const n=document.createElement("a");n.href=e,n.download=t,n.rel="noopener",document.body.appendChild(n),n.click(),n.remove()},Rwe=e=>{const t=e.replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"");return t.length>0?t.slice(0,80):"canvas"},hB=(e,t)=>`${Rwe(e??"canvas")}.${t}`,zwe=({projectId:e,getReactFlow:t})=>{const[n,r]=m.useState(null),o=m.useCallback(()=>r(null),[]),i=m.useCallback(async()=>{const c=t();if(!c)return null;const h=document.querySelector(".react-flow__viewport");if(!h)return null;const d=c.getViewport();try{return await c.fitView({duration:0,padding:.1}),await new Promise(f=>requestAnimationFrame(()=>f())),await Awe(h)}finally{c.setViewport(d,{duration:0})}},[t]),a=m.useCallback(async()=>{r(null);try{const c=await i();if(!c)return;Pwe(c.dataUrl,hB(e,"png"))}catch(c){r(c instanceof Error?c.message:String(c))}},[i,e]),s=m.useCallback(async()=>{r(null);try{const c=await i();if(!c)return;const{jsPDF:h}=await j3e(async()=>{const{jsPDF:p}=await import("./jspdf.es.min-D7KeFi-m.js").then(k=>k.j);return{jsPDF:p}},[]),d=c.width>c.height?"landscape":"portrait",f=new h({orientation:d,unit:"px",format:[c.width,c.height],hotfixes:["px_scaling"]});f.addImage(c.dataUrl,"PNG",0,0,c.width,c.height),f.save(hB(e,"pdf"))}catch(c){r(c instanceof Error?c.message:String(c))}},[i,e]),l=m.useCallback(async()=>{const c=await i();return c==null?void 0:c.dataUrl},[i]);return{exportPdf:s,exportPng:a,capturePreview:l,lastError:n,clearError:o}},jwe=12,Twe=1200;function Nwe(e,t={}){const n=t.idleMs??Twe;let r,o=null,i=null;const a=typeof requestAnimationFrame<"u",s=()=>{r!==void 0&&(clearTimeout(r),r=void 0)},l=()=>{i!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(i),i=null},c=()=>{if(i=null,!o)return;const{clientX:p,clientY:k}=o;o=null;const v=e.getBoundingClientRect();e.style.setProperty("--mx",`${p-v.left}px`),e.style.setProperty("--my",`${k-v.top}px`),e.dataset.active="true",s(),r=setTimeout(()=>{e.dataset.active="false",r=void 0},n)};return{onMove:p=>{if(o={clientX:p.clientX,clientY:p.clientY},!a){c();return}i===null&&(i=requestAnimationFrame(c))},onLeave:()=>{l(),o=null,s(),e.dataset.active="false"},dispose:()=>{l(),o=null,s()}}}function Dwe(){const e=m.useRef(null),t=_e(a=>a.transform,(a,s)=>a[0]===s[0]&&a[1]===s[1]&&a[2]===s[2]),[n,r,o]=t,i=jwe*o;return m.useEffect(()=>{var d;const a=e.current;if(!a)return;const s=(d=a.parentElement)==null?void 0:d.querySelector(".react-flow__pane");if(!s)return;const{onMove:l,onLeave:c,dispose:h}=Nwe(a);return s.addEventListener("mousemove",l,{passive:!0}),s.addEventListener("mouseleave",c,{passive:!0}),()=>{s.removeEventListener("mousemove",l),s.removeEventListener("mouseleave",c),h()}},[]),y.jsx("div",{ref:e,className:"glow-overlay","data-active":"false","data-testid":"canvas-glow-overlay",style:{backgroundPosition:`${n}px ${r}px`,backgroundSize:`${i}px ${i}px`}})}const _we={showToolbar:!0,showStyleStrip:!0,showDetailPanel:!0,showStatusBadges:!0,showResizeHandles:!0,showControls:!0,showShareMenu:!0,showRestart:!0,enableKeyboard:!0,enableContextMenu:!0,enableDragDrop:!0,enableImageDrop:!0,enableZoom:!0,enablePan:!0,enableSelection:!0,enableNodeMove:!0,enableEmbed:!1},Hwe={showToolbar:!1,showStyleStrip:!1,showDetailPanel:!1,showStatusBadges:!0,showResizeHandles:!1,showControls:!0,showShareMenu:!0,showRestart:!1,enableKeyboard:!1,enableContextMenu:!1,enableDragDrop:!1,enableImageDrop:!1,enableZoom:!0,enablePan:!0,enableSelection:!0,enableNodeMove:!0,enableEmbed:!1},Fwe={showToolbar:!1,showStyleStrip:!1,showDetailPanel:!1,showStatusBadges:!1,showResizeHandles:!1,showControls:!1,showShareMenu:!1,showRestart:!1,enableKeyboard:!1,enableContextMenu:!1,enableDragDrop:!1,enableImageDrop:!1,enableZoom:!1,enablePan:!1,enableSelection:!1,enableNodeMove:!1,enableEmbed:!1};function Owe(e){const t=e.mode==="edit"?_we:e.mode==="mini"?Fwe:Hwe;return{showToolbar:e.showToolbar??t.showToolbar,showStyleStrip:e.showStyleStrip??t.showStyleStrip,showDetailPanel:e.showDetailPanel??t.showDetailPanel,showStatusBadges:e.showStatusBadges??t.showStatusBadges,showResizeHandles:e.showResizeHandles??t.showResizeHandles,showControls:e.showControls??t.showControls,showShareMenu:e.showShareMenu??t.showShareMenu,showRestart:e.showRestart??t.showRestart,enableKeyboard:e.enableKeyboard??t.enableKeyboard,enableContextMenu:e.enableContextMenu??t.enableContextMenu,enableDragDrop:e.enableDragDrop??t.enableDragDrop,enableImageDrop:e.enableImageDrop??t.enableImageDrop,enableZoom:e.enableZoom??t.enableZoom,enablePan:e.enablePan??t.enablePan,enableSelection:e.enableSelection??t.enableSelection,enableNodeMove:e.enableNodeMove??t.enableNodeMove,enableEmbed:e.enableEmbed??t.enableEmbed}}const fB=40,Ad={padding:.15,duration:300,includeHiddenNodes:!1};function qwe(e){return e===void 0||e===!1?{onMount:!1,onExternalNodeChange:!1}:e===!0?{onMount:!0,onExternalNodeChange:!0}:{onMount:e.onMount??!0,onExternalNodeChange:e.onExternalNodeChange??!0}}const pB=e=>{if("clientX"in e)return{clientX:e.clientX,clientY:e.clientY};const t=e.changedTouches[0]??e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null},Vwe=(e,t)=>{var r;const n=document.elementsFromPoint(e,t);for(const o of n){const i=(r=o.closest)==null?void 0:r.call(o,".react-flow__node");if(i)return i}return null},nJ=15,sT=(e,t,n)=>{const r=Vwe(t,n);if(r)return r;if(!e)return null;let o=null,i=nJ;const a=e.querySelectorAll(".react-flow__node");for(const s of a){const l=s.getBoundingClientRect();if(l.width===0||l.height===0)continue;const c=Math.max(l.left-t,0,t-l.right),h=Math.max(l.top-n,0,n-l.bottom),d=Math.hypot(c,h);d<=i&&(o=s,i=d)}return o};function yB(e,t,n,r,o){if(e==="source"?(r==null?void 0:r.targetPin)!==void 0||(r==null?void 0:r.targetHandleAutoPicked)===!1:(r==null?void 0:r.sourcePin)!==void 0||(r==null?void 0:r.sourceHandleAutoPicked)===!1)return;const a=e==="source"?n:t,s=e==="source"?t:n,l=o(a),c=o(s);if(!l||!c)return;const h=l.measured.width??l.width??0,d=l.measured.height??l.height??0,f=c.measured.width??c.width??0,p=c.measured.height??c.height??0;if(h===0||d===0||f===0||p===0)return;const k={x:l.internals.positionAbsolute.x,y:l.internals.positionAbsolute.y,w:h,h:d},v={x:c.internals.positionAbsolute.x+f/2,y:c.internals.positionAbsolute.y+p/2};return rue(k,sR(k,v))}function Bwe(e,t,n,r){if(r===null)return"no-op";const o=e==="source"?t:n;return r===(e==="source"?n:t)?"self-loop":r===o?"pin-own":"reconnect-and-pin"}const $we=(e,t)=>{if(!t)return e;const n=t.data?{...e.data,...t.data}:e.data;return{...e,...t,data:n}},Uwe=(e,t)=>t?{...e,...t}:e,Wwe={playNode:f0e,stateNode:T0e,shapeNode:L0e,imageNode:nde,iconNode:pue,htmlNode:Yue},Gwe={editableEdge:_0e},Zwe={zIndex:0},Kwe=8,mB=(e,t)=>e?typeof e=="string"?`url('#${e}')`:`url('#${`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`}')`:void 0,Xwe=e=>function({fromX:n,fromY:r,toX:o,toY:i,fromPosition:a,toPosition:s,connectionLineStyle:l}){const c=_e(W=>e.current?W.edges.find(H=>H.reconnectable===!0)??null:null),h=c==null?void 0:c.data,d=_e(W=>{var j;const H=W.connection;return((j=H==null?void 0:H.fromHandle)==null?void 0:j.nodeId)??null}),f=_e(W=>c!=null&&c.source?W.nodeLookup.get(c.source)??null:null),p=_e(W=>c!=null&&c.target?W.nodeLookup.get(c.target)??null:null),k=_e(W=>d?W.nodeLookup.get(d)??null:null),v=(c==null?void 0:c.source)===d,w=c?v?f:p:k,g=v?p:f,M=v?h==null?void 0:h.sourcePin:h==null?void 0:h.targetPin,x=v?h==null?void 0:h.sourceHandleAutoPicked:h==null?void 0:h.targetHandleAutoPicked;let b=n,S=r,C=a;if(w){const W=w.measured.width??w.width??0,H=w.measured.height??w.height??0;if(W>0&&H>0){const j={x:w.internals.positionAbsolute.x,y:w.internals.positionAbsolute.y,w:W,h:H};let G=null;if(M)G=lR(j,M);else if(x!==!1&&g){const X=g.measured.width??g.width??0,Y=g.measured.height??g.height??0;if(X>0&&Y>0){const re={x:g.internals.positionAbsolute.x+X/2,y:g.internals.positionAbsolute.y+Y/2};G=sR(j,re)}}G&&(b=G.x,S=G.y,C=kB[G.side])}}const L=_e(W=>W.transform[2]),P=_e(W=>W.nodeLookup),T=_e(W=>{var H;return((H=W.connection.toHandle)==null?void 0:H.nodeId)??null});let E=o,z=i,A=s;if(L>0){const W=nJ/L,H=c?v?c.target:c.source:null;let j=null;if(T&&T!==H){const G=P.get(T)??null;G&&(j=G)}if(!j){let G=W;for(const X of P.values()){if(H&&X.id===H||w&&X.id===w.id)continue;const Y=X.measured.width??X.width??0,re=X.measured.height??X.height??0;if(Y===0||re===0)continue;const ne=X.internals.positionAbsolute.x,ae=X.internals.positionAbsolute.y,ve=Math.max(ne-o,0,o-(ne+Y)),be=Math.max(ae-i,0,i-(ae+re)),me=Math.hypot(ve,be);me<=G&&(G=me,j=X)}}if(!j&&c&&w){const G=w.measured.width??w.width??0,X=w.measured.height??w.height??0;if(G>0&&X>0){const Y=w.internals.positionAbsolute.x,re=w.internals.positionAbsolute.y,ne=Math.max(Y-o,0,o-(Y+G)),ae=Math.max(re-i,0,i-(re+X));Math.hypot(ne,ae)<=W&&(j=w)}}if(j){const G=j.measured.width??j.width??0,X=j.measured.height??j.height??0;if(G>0&&X>0){const Y=wN({x:j.internals.positionAbsolute.x,y:j.internals.positionAbsolute.y,w:G,h:X},{x:o,y:i}),re=lR({x:j.internals.positionAbsolute.x,y:j.internals.positionAbsolute.y,w:G,h:X},Y);E=re.x,z=re.y,A=kB[re.side]}}}const U=(h==null?void 0:h.path)==="step",[R]=U?nh({sourceX:b,sourceY:S,sourcePosition:C,targetX:E,targetY:z,targetPosition:A,borderRadius:Kwe}):KR({sourceX:b,sourceY:S,sourcePosition:C,targetX:E,targetY:z,targetPosition:A}),V=(c==null?void 0:c.style)??l??void 0,O=_e(W=>W.rfId),B=v?c==null?void 0:c.markerStart:c==null?void 0:c.markerEnd,D=v?c==null?void 0:c.markerEnd:c==null?void 0:c.markerStart,N=mB(B,O),I=mB(D,O);return y.jsx("path",{d:R,fill:"none",className:"react-flow__connection-path",style:V,markerStart:N,markerEnd:I})},kB={top:ye.Top,right:ye.Right,bottom:ye.Bottom,left:ye.Left};function Ywe({storeApiRef:e}){const t=yt();return m.useEffect(()=>(e.current=t,()=>{e.current===t&&(e.current=null)}),[t,e]),null}function Qwe({wrapperRef:e}){const t=_e(r=>r.transform[2]),n=e.current;return n&&n.style.setProperty("--rf-zoom",String(t)),null}const Jwe=new Set(["INPUT","TEXTAREA","SELECT"]),rJ=e=>e?Jwe.has(e.tagName)?!0:e instanceof HTMLElement&&e.isContentEditable:!1;function e6e(e){const{event:t,selectedNodeIds:n,hasClipboard:r,activeElement:o,onCopySelection:i,onPasteSelection:a}=e;if(!(t.metaKey||t.ctrlKey)||t.shiftKey||t.altKey)return!1;const s=t.key.toLowerCase();return s!=="c"&&s!=="v"||rJ(o)?!1:s==="c"?n.length===0||!i?!1:(t.preventDefault(),i([...n]),!0):!r||!a?!1:(t.preventDefault(),a(),!0)}const gB=(e,t)=>{var n;return((n=e==null?void 0:e[t])==null?void 0:n.status)??"idle"},t6e=(e,t)=>{var n;return(n=e==null?void 0:e[t])==null?void 0:n.status},n6e=(e,t)=>{var n,r;return((n=e==null?void 0:e[t])==null?void 0:n.status)==="error"?(r=e[t])==null?void 0:r.error:void 0};function r6e(e,t){var NH,DH;const{mode:n,adapter:r,projectId:o,fileBaseUrl:i,nodes:a,connectors:s,selectedNodeIds:l,selectedConnectorIds:c,onSelectionChange:h,runtime:d,onPlayNode:f,onNodePositionChange:p,onNodePositionsChange:k,onNodeResize:v,onNodeResizeEnd:w,onHtmlNodeFitToContent:g,onMultiResize:M,onNodeNameChange:x,onNodeDescriptionChange:b,onConnectorLabelChange:S,onCreateShapeNode:C,onCreateImageFromFile:L,onRetryImageUpload:P,onCreateHtmlNode:T,onCreateConnector:E,onReconnectConnector:z,onReorderNode:A,onDeleteNode:U,onCopyNode:R,onPasteAt:V,hasClipboard:O,onCopySelection:B,onPasteSelection:D,selectedNodes:N,selectedConnectors:I,onStyleNode:W,onStyleNodePreview:H,onStyleNodes:j,onStyleNodesPreview:G,onStyleConnector:X,onStyleConnectorPreview:Y,onRfInit:re,onTidy:ne,onNodeClick:ae,onConnectorClick:ve,onPaneClick:be,onCreateAndConnectFromPane:me,pendingEditNodeId:ge,iconPickerOpen:ee,onOpenIconPicker:ke,onCloseIconPicker:Fe,onPickIcon:rt,onRequestIconReplace:mt,onPinEndpoint:ht,onUnpinEndpoint:le,activeShape:Q,onSelectShape:fe,disableSidebar:we,statusReport:Se,onNameChange:Oe,onDescriptionChange:te,onDetailChange:de,onIconChange:Pe,autoFitView:qe,autoFitViewSignal:We,customIcons:Rt,onExportToCloud:st,onRestartDemo:Ne,showToolbar:ot,showStyleStrip:Jn,showDetailPanel:zt,showStatusBadges:zn,showResizeHandles:Kt,showControls:p1,showShareMenu:y1,showRestart:Jo,enableKeyboard:ei,enableContextMenu:_r,enableDragDrop:Ki,enableImageDrop:ti,enableZoom:fr,enablePan:Hr,enableSelection:pr,enableNodeMove:m1,enableEmbed:k1}=e,He=m.useMemo(()=>Owe({mode:n,showToolbar:ot,showStyleStrip:Jn,showDetailPanel:zt,showStatusBadges:zn,showResizeHandles:Kt,showControls:p1,showShareMenu:y1,showRestart:Jo,enableKeyboard:ei,enableContextMenu:_r,enableDragDrop:Ki,enableImageDrop:ti,enableZoom:fr,enablePan:Hr,enableSelection:pr,enableNodeMove:m1,enableEmbed:k1}),[n,ot,Jn,zt,zn,Kt,p1,y1,Jo,ei,_r,Ki,ti,fr,Hr,pr,m1,k1]),Mt=n==="edit",Fr=m.useRef(He);m.useEffect(()=>{Fr.current=He},[He]);const Or=qe??(n==="mini"?!0:void 0),jn=m.useMemo(()=>qwe(Or),[Or]),yr=d==null?void 0:d.runs,Mo=d==null?void 0:d.statuses,er=(NH=d==null?void 0:d.pendingOverrides)==null?void 0:NH.nodes,qr=(DH=d==null?void 0:d.pendingOverrides)==null?void 0:DH.connectors,an=m.useRef(null),jt=m.useRef(null),bo=m.useRef(!1),mr=m.useRef(!1),Xi=m.useRef(!1),Yi=m.useRef(jn);Yi.current=jn,m.useEffect(()=>{if(bo.current||!jn.onMount||a.length===0)return;const K=jt.current;K&&(K.fitView(Ad),bo.current=!0)},[a,jn.onMount]);const Co=m.useRef(null),Ct=Q,Qi=fe,Tn=m.useRef(new Map),ni=m.useCallback((K,J)=>(Tn.current.set(K,J),()=>{Tn.current.get(K)===J&&Tn.current.delete(K)}),[]),[tr,kr]=m.useState(!1),g1=m.useRef(!1);m.useEffect(()=>{g1.current=tr},[tr]);const Ji=m.useRef(!1),ea=m.useRef(!1),ri=m.useRef(!1),[mn,Vr]=m.useState(null),Br=m.useRef(null);m.useEffect(()=>{Br.current=mn},[mn]),m.useCallback(()=>{Vr(null)},[]);const x1=m.useMemo(()=>Xwe(ri),[]),So=m.useRef(null),nr=m.useRef(null),kn=m.useCallback(K=>{const J=an.current;if(!J){So.current=K;return}const se=So.current;if(se&&se!==K){const ce=J.querySelector(`.react-flow__node[data-id="${CSS.escape(se)}"]`);ce==null||ce.removeAttribute("data-connect-source")}if(K){const ce=J.querySelector(`.react-flow__node[data-id="${CSS.escape(K)}"]`);ce==null||ce.setAttribute("data-connect-source","true")}So.current=K},[]),sn=m.useCallback(K=>{const J=an.current,se=nr.current;if(se!==K){if(J&&se){const ce=J.querySelector(`.react-flow__node[data-id="${CSS.escape(se)}"]`);ce==null||ce.removeAttribute("data-connect-target")}if(J&&K){const ce=J.querySelector(`.react-flow__node[data-id="${CSS.escape(K)}"]`);ce==null||ce.setAttribute("data-connect-target","true")}nr.current=K}},[]),oi=m.useCallback(()=>{kn(null),sn(null)},[kn,sn]);m.useEffect(()=>{if(!tr){sn(null);return}let K=null,J=null;const se=()=>{K=null;const ue=J;if(J=null,!ue)return;const Re=sT(an.current,ue.clientX,ue.clientY),xe=(Re==null?void 0:Re.getAttribute("data-id"))??null;if(xe&&xe===So.current){sn(null);return}sn(xe)},ce=ue=>{J={clientX:ue.clientX,clientY:ue.clientY},K===null&&(K=requestAnimationFrame(se))};return document.addEventListener("pointermove",ce,{passive:!0}),()=>{document.removeEventListener("pointermove",ce),K!==null&&cancelAnimationFrame(K)}},[tr,sn]);const[rr,$r]=m.useState(null),[Ur,Lo]=m.useState(null),Je=m.useRef(null),Wr=m.useRef(null),Nn=m.useRef(null),Xt=m.useRef(!1);m.useEffect(()=>{Je.current=Ct},[Ct]);const Gr=m.useCallback(()=>{Qi(null),$r(null),Lo(null),Je.current=null,Wr.current=null,Nn.current=null,Xt.current=!1},[Qi]);m.useEffect(()=>{if(!He.enableKeyboard)return;const K=J=>{var ue,Re;if(J.key!=="Escape"||rJ(document.activeElement))return;if(Je.current){J.preventDefault(),Gr();return}if(g1.current){J.preventDefault(),Ji.current=!0,ea.current=!0;try{(ue=Co.current)==null||ue.getState().cancelConnection()}catch{}document.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,button:0})),kr(!1);return}if(Br.current){J.preventDefault(),Vr(null);return}const se=vn.current.size>0,ce=Po.current.size>0;(se||ce)&&(J.preventDefault(),(Re=Zr.current)==null||Re.call(Zr,[],[]))};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[Gr,He.enableKeyboard]),m.useEffect(()=>{if(!He.enableKeyboard)return;const K=J=>{e6e({event:J,selectedNodeIds:l,hasClipboard:!!O,activeElement:document.activeElement,onCopySelection:B,onPasteSelection:D})};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[l,O,B,D,He.enableKeyboard]);const v1=m.useCallback(K=>{var ce,ue;if(!Je.current)return;const J=K.target;if(!(J!=null&&J.classList.contains("react-flow__pane")))return;const se={x:K.clientX,y:K.clientY};Xt.current=!0,Wr.current=se,Nn.current=se,$r(se),Lo(se);try{(ue=(ce=K.currentTarget).setPointerCapture)==null||ue.call(ce,K.pointerId)}catch{}K.preventDefault(),K.stopPropagation()},[]),Dz=m.useCallback(K=>{if(!Xt.current)return;const J={x:K.clientX,y:K.clientY};Nn.current=J,Lo(J)},[]),Kh=m.useCallback(K=>{var Xr,dd;if(!Xt.current)return;Xt.current=!1;try{(dd=(Xr=K.currentTarget).releasePointerCapture)==null||dd.call(Xr,K.pointerId)}catch{}const J=Wr.current,se=Nn.current,ce=Je.current,ue=jt.current;if(Gr(),!J||!se||!ce||!ue)return;const Re=Math.min(J.x,se.x),xe=Math.min(J.y,se.y),Ee=Math.max(J.x,se.x),Ke=Math.max(J.y,se.y),et=Ee-Re,lt=Ke-xe,Te=ue.screenToFlowPosition({x:Re,y:xe}),wn=ue.screenToFlowPosition({x:Ee,y:Ke}),Kr=wn.x-Te.x,ct=wn.y-Te.y,Le=et<fB||lt<fB,Ft=Le?pR[ce].width:Kr,w1=Le?pR[ce].height:ct;C==null||C(ce,Te,{width:Ft,height:w1})},[Gr,C]),Io=m.useRef(!1),ta=m.useRef(!1),id=m.useRef(new Map),ii=m.useCallback(()=>{var K;mr.current&&(ta.current||Io.current||(mr.current=!1,(K=jt.current)==null||K.fitView(Ad)))},[]),ad=m.useCallback(K=>{ta.current=K,K||ii()},[ii]);m.useEffect(()=>{var K;if(!Xi.current){Xi.current=!0;return}if(Yi.current.onExternalNodeChange){if(ta.current||Io.current){mr.current=!0;return}(K=jt.current)==null||K.fitView(Ad)}},[We]);const sd=!!A||!!U||!!R||!!V||!!le,[F,q]=m.useState(null),[Z,$]=m.useState(!1),[_,oe]=m.useState(null),[Ae,Me]=m.useState(null),Ue=m.useRef(null),Ut=m.useRef(null);m.useEffect(()=>{if(!F)return;const K=Ut.current;if(!K)return;const J=new MouseEvent("contextmenu",{clientX:F.x,clientY:F.y,bubbles:!0,cancelable:!0,button:2,buttons:2});K.dispatchEvent(J)},[F]);const Eo=m.useCallback(K=>{const J=Ue.current;!J||!A||A(J,K)},[A]),Dn=m.useCallback(()=>{const K=Ue.current;!K||!U||U(K)},[U]),ze=m.useCallback(()=>{const K=Ue.current;!K||!R||R(K)},[R]),it=m.useCallback(()=>{const K=Ue.current;!K||!mt||mt(K)},[mt]);m.useCallback((K,J,se,ce,ue)=>{Fr.current.enableContextMenu&&(Ue.current=null,$(!1),oe(null),Me({connectorId:K,kind:J,pinned:se}),q({x:ce,y:ue}))},[]);const Yt=m.useCallback(()=>{const K=Ae;!K||!le||le(K.connectorId,K.kind)},[Ae,le]),gn=m.useCallback(()=>{if(!V)return;const K=F,J=jt.current;if(!K||!J)return;const se=J.screenToFlowPosition({x:K.x,y:K.y});V(se)},[F,V]),na=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent||""),_z=na?"⌘C":"Ctrl+C",ai=na?"⌘V":"Ctrl+V",De=m.useMemo(()=>new Set(l),[l]),Qe=m.useMemo(()=>new Set(c),[c]),Ht=m.useMemo(()=>{if(l.length<2)return[];const K=er,J=[];for(const se of l){const ce=a.find(Ee=>Ee.id===se);if(!ce)continue;const ue=K==null?void 0:K[se],Re=(ue==null?void 0:ue.data)??{},xe=ce.data;J.push({id:se,position:(ue==null?void 0:ue.position)??ce.position,data:{width:Re.width??xe.width,height:Re.height??xe.height}})}return J},[a,er,l]),xn=N??[],Ao=m.useMemo(()=>{const K=ue=>{const Re=Mt?void 0:id.current.get(ue.id),xe={id:ue.id,type:ue.type,position:Re??ue.position,data:{...ue.data,projectId:o,fileBaseUrl:i,onRetryUpload:P,status:t6e(yr,ue.id),errorMessage:n6e(yr,ue.id),statusReport:Mo==null?void 0:Mo[ue.id],onPlay:f,onResize:v,onResizeEnd:w,setResizing:ad,onFitToContent:ue.type==="htmlNode"?g:void 0,onNameChange:(()=>{if(Mt&&!(ue.type==="shapeNode"&&ue.data.shape==="ellipse"))return x})(),onDescriptionChange:(()=>{if(Mt){if(ue.type==="shapeNode"){const Ee=ue.data.shape;return Ee==="rectangle"||Ee==="ellipse"||Ee==="sticky"?b:void 0}if(!(ue.type==="imageNode"||ue.type==="iconNode"))return b}})(),onIconChange:(()=>{if(Mt&&!(ue.type!=="playNode"&&ue.type!=="stateNode"))return Pe})(),autoEditOnMount:ge===ue.id?!0:void 0},selected:De.has(ue.id)};return ue.data.width!==void 0&&(xe.width=ue.data.width),ue.data.height!==void 0&&(xe.height=ue.data.height),De.has(ue.id)||(xe.connectable=!1),xe},J=a.map(ue=>K($we(ue,er==null?void 0:er[ue.id]))),se=new Set(a.map(ue=>ue.id)),ce=[];if(er)for(const[ue,Re]of Object.entries(er)){if(se.has(ue))continue;const xe=Re;typeof xe.type!="string"||!xe.position||!xe.data||ce.push(K({...xe,id:ue}))}return[...J,...ce]},[o,i,a,De,yr,Mo,f,v,w,g,ad,er,x,b,Pe,P,ge,Mt]),[ra,ld]=m.useState(Ao);m.useEffect(()=>{Io.current||ta.current||ld(Ao)},[Ao]),m.useEffect(()=>{cd.current=ra},[ra]);const vn=m.useRef(De);m.useEffect(()=>{vn.current=De},[De]);const Zr=m.useRef(h);m.useEffect(()=>{Zr.current=h},[h]);const Po=m.useRef(Qe);m.useEffect(()=>{Po.current=Qe},[Qe]);const cd=m.useRef(Ao),oa=m.useRef(!1),Xh=m.useRef(new Set),Yh=m.useRef(new Set),Hz=m.useRef(new Set),Fz=m.useRef(new Set),si=m.useRef(null),vJ=m.useCallback(K=>{var ct;const J=oa.current?Hz.current:(ct=si.current)!=null&&ct.shift?si.current.nodeIds:null,se=J&&J.size>0?K.filter(Le=>Le.type!=="select"?!0:!(Le.selected===!1&&J.has(Le.id))):K,ce=new Set;for(const Le of se)Le.type==="select"&&ce.add(Le.id);const ue=vG(se,cd.current),Re=new Set;if(ta.current)for(const Le of se)Le.type==="dimensions"&&Re.add(Le.id);const xe=Re.size===0?ue:ue.map(Le=>!Re.has(Le.id)||Le.width===void 0&&Le.height===void 0?Le:{...Le,data:{...Le.data,...Le.width!==void 0?{width:Le.width}:{},...Le.height!==void 0?{height:Le.height}:{}}}),Ee=vn.current,Ke=oa.current||Ee.size===0?xe:xe.map(Le=>Ee.has(Le.id)&&!ce.has(Le.id)&&!Le.selected?{...Le,selected:!0}:Le);if(cd.current=Ke,ld(Ke),ce.size===0)return;if(oa.current){for(const Le of se)Le.type==="select"&&(Le.selected?Xh.current.add(Le.id):Xh.current.delete(Le.id));return}const et=Zr.current;if(!et)return;const lt=Ke.filter(Le=>Le.selected).map(Le=>Le.id),Te=vn.current;Te.size===lt.length&<.every(Le=>Te.has(Le))||(vn.current=new Set(lt),et(lt,[...Po.current]))},[]),Qh=m.useRef([]),wJ=m.useCallback(K=>{var lt;const J=oa.current?Fz.current:(lt=si.current)!=null&<.shift?si.current.edgeIds:null,se=J&&J.size>0?K.filter(Te=>Te.type!=="select"?!0:!(Te.selected===!1&&J.has(Te.id))):K,ce=new Set;for(const Te of se)Te.type==="select"&&ce.add(Te.id);if(ce.size===0)return;if(oa.current){for(const Te of se)Te.type==="select"&&(Te.selected?Yh.current.add(Te.id):Yh.current.delete(Te.id));return}const ue=Zr.current;if(!ue)return;const xe=wG(se,Qh.current).filter(Te=>Te.selected).map(Te=>Te.id),Ee=Po.current;Ee.size===xe.length&&xe.every(Te=>Ee.has(Te))||(Po.current=new Set(xe),ue([...vn.current],xe))},[]),MJ=m.useCallback(K=>{oa.current=!0;const J=si.current,se=(J==null?void 0:J.shift)??(K.shiftKey||K.metaKey||K.ctrlKey);Hz.current=se?new Set((J==null?void 0:J.nodeIds)??vn.current):new Set,Fz.current=se?new Set((J==null?void 0:J.edgeIds)??Po.current):new Set,Xh.current=new Set(Hz.current),Yh.current=new Set(Fz.current)},[]),bJ=m.useCallback(()=>{oa.current=!1,si.current=null;const K=Zr.current;if(!K)return;const J=[...Xh.current],se=new Set(J),ce=new Set(Yh.current);for(const Ke of Qh.current)se.has(Ke.source)&&se.has(Ke.target)&&ce.add(Ke.id);const ue=vn.current,Re=Po.current,xe=ue.size===se.size&&J.every(Ke=>ue.has(Ke)),Ee=Re.size===ce.size&&[...ce].every(Ke=>Re.has(Ke));xe&&Ee||(vn.current=new Set(J),Po.current=new Set(ce),K(J,[...ce]))},[]),CJ=m.useCallback(K=>{if(si.current=null,Je.current||K.button!==0)return;const J=K.target;J!=null&&J.classList.contains("react-flow__pane")&&(si.current={shift:K.shiftKey||K.metaKey||K.ctrlKey,nodeIds:new Set(vn.current),edgeIds:new Set(Po.current)})},[]),SJ=m.useCallback(K=>{if(!Fr.current.enableContextMenu||vn.current.size<2)return;const se=K.target;se!==Ut.current&&(se!=null&&se.closest(".seeflow-connector-endpoint-dot")||(K.preventDefault(),K.stopPropagation(),Ue.current=null,$(!0),oe(null),Me(null),q({x:K.clientX,y:K.clientY})))},[]),LJ=m.useCallback(K=>{const J=K.dataTransfer;if(!J)return;const se=J.types?Array.from(J.types):[],ce=se.includes("Files"),ue=se.includes(Kq),Re=ce&&!!L&&He.enableImageDrop,xe=ue&&!!T&&He.enableDragDrop;if(!(!Re&&!xe)){K.preventDefault();try{J.dropEffect="copy"}catch{}}},[L,T,He.enableImageDrop,He.enableDragDrop]),IJ=m.useCallback(K=>{const J=K.dataTransfer;if((J!=null&&J.types?Array.from(J.types):[]).includes(Kq)&&T&&He.enableDragDrop){K.preventDefault();const Re=jt.current;if(!Re)return;const xe=Re.screenToFlowPosition({x:K.clientX,y:K.clientY});T({position:xe});return}if(!L||!He.enableImageDrop)return;const ue={x:K.clientX,y:K.clientY};K.preventDefault(),$ne({dataTransfer:J,clientPos:ue,rfInstance:jt.current,computeDims:Une,dispatch:L})},[L,T,He.enableImageDrop,He.enableDragDrop]),LH=!!z,IH=Qe.size===1?[...Qe][0]:null,Oz=m.useMemo(()=>{const K=Ee=>{const Ke=gB(yr,Ee.source)==="running"||gB(yr,Ee.target)==="running",et=Qe.has(Ee.id),lt=Y1e(Ee,Ke,et);et&&(lt.selected=!0);const Te=LH&&Ee.id===IH,wn=Te?{...lt,reconnectable:!0}:lt;return{...wn,data:{...wn.data,onLabelChange:Mt?S:void 0,reconnectable:Te,registerEditHandle:ni}}},J=new Set(s.map(Ee=>Ee.id)),se=s.map(Ee=>K(Uwe(Ee,qr==null?void 0:qr[Ee.id]))),ce=[];if(qr)for(const[Ee,Ke]of Object.entries(qr)){if(J.has(Ee))continue;const et=Ke;typeof et.source!="string"||typeof et.target!="string"||typeof et.kind!="string"||ce.push(K({...et,id:Ee}))}const ue=[...se,...ce],Re=[],xe=[];for(const Ee of ue)Qe.has(Ee.id)?xe.push(Ee):Re.push(Ee);return[...Re,...xe]},[s,yr,Qe,IH,qr,S,LH,ni,Mt]);m.useEffect(()=>{Qh.current=Oz},[Oz]);const ud=e.adapter??null,EJ=m.useMemo(()=>{if(ud!=null&&ud.computeLayout)return async()=>{const K=jt.current,J=cd.current;if(J.length<2)return;const se=J.map(ct=>{var dd;const Le=(dd=K==null?void 0:K.getInternalNode(ct.id))==null?void 0:dd.measured,Ft=ct.data,w1=(Le==null?void 0:Le.width)??Ft.width??200,Xr=(Le==null?void 0:Le.height)??Ft.height??120;return{id:ct.id,type:ct.type,width:w1,height:Xr}}),ce=new Map;for(const ct of J)ce.set(ct.id,ct.position);const ue=Qh.current.map(ct=>({id:ct.id,source:ct.source,target:ct.target})),Re=ud.computeLayout;if(!Re)return;const xe=await Re(se,ue),Ee=new Map;for(const[ct,Le]of Object.entries(xe.nodes))Ee.set(ct,Le.position);let Ke=Number.POSITIVE_INFINITY,et=Number.POSITIVE_INFINITY,lt=Number.POSITIVE_INFINITY,Te=Number.POSITIVE_INFINITY;for(const ct of se){const Le=ce.get(ct.id);if(!Le)continue;Le.x<Ke&&(Ke=Le.x),Le.y<et&&(et=Le.y);const Ft=Ee.get(ct.id);Ft&&(Ft.x<lt&&(lt=Ft.x),Ft.y<Te&&(Te=Ft.y))}const wn=Number.isFinite(Ke)&&Number.isFinite(lt)?Ke-lt:0,Kr=Number.isFinite(et)&&Number.isFinite(Te)?et-Te:0;ld(ct=>ct.map(Le=>{const Ft=Ee.get(Le.id);return Ft?{...Le,position:{x:Ft.x+wn,y:Ft.y+Kr}}:Le}))}},[ud]),Jh=ne??(Mt?void 0:EJ),e0=m.useRef(!1),EH=m.useRef(null),AJ=m.useCallback(K=>{var Ee;if(!Mt||!E)return;const{source:J,target:se}=K;if(!J||!se||J===se)return;e0.current=!0;const ce=((Ee=EH.current)==null?void 0:Ee.nodeId)??null,ue=ce!==null&&ce===se&&ce!==J;E(ue?se:J,ue?J:se)},[E,Mt]),qz=m.useCallback(K=>{const J=se=>{if(!se)return!1;const ce=cd.current.find(ue=>ue.id===se);return ce?ce.type==="shapeNode"&&ce.data.shape==="text":!1};return!J(K.source)&&!J(K.target)},[]),PJ=m.useCallback((K,J)=>{var lt;kr(!1),oi();const se=e0.current;if(e0.current=!1,se||ri.current)return;if(Ji.current){Ji.current=!1;return}if(!E)return;const ce=(lt=J.fromNode)==null?void 0:lt.id,ue=J.fromHandle;if(!ce||!ue)return;const Re=pB(K);if(!Re)return;const xe=sT(an.current,Re.clientX,Re.clientY);if(!xe)return;const Ee=xe.getAttribute("data-id");if(!Ee||Ee===ce||!qz({source:ce,target:Ee,sourceHandle:null,targetHandle:null}))return;let Ke;const et=jt.current;if(et){const Te=et.getInternalNode(Ee);if(Te){const wn=Te.measured.width??Te.width??0,Kr=Te.measured.height??Te.height??0;if(wn>0&&Kr>0){const ct=et.screenToFlowPosition({x:Re.clientX,y:Re.clientY});Ke=wN({x:Te.internals.positionAbsolute.x,y:Te.internals.positionAbsolute.y,w:wn,h:Kr},ct)}}}E(ce,Ee,Ke?{targetPin:Ke}:void 0)},[E,oi,qz]),t0=m.useRef(!1),RJ=m.useCallback((K,J)=>{if(!z)return;const{source:se,target:ce,sourceHandle:ue,targetHandle:Re}=J;if(!se||!ce||se===ce)return;const xe={};if(se!==K.source&&(xe.source=se),ce!==K.target&&(xe.target=ce),typeof ue=="string"&&ue!==K.sourceHandle&&(xe.sourceHandle=ue),typeof Re=="string"&&Re!==K.targetHandle&&(xe.targetHandle=Re),xe.source===void 0&&xe.target===void 0&&xe.sourceHandle===void 0&&xe.targetHandle===void 0)return;(xe.source!==void 0||xe.sourceHandle!==void 0)&&(xe.sourceHandleAutoPicked=!1),(xe.target!==void 0||xe.targetHandle!==void 0)&&(xe.targetHandleAutoPicked=!1);const Ee=jt.current;if(!(xe.source===void 0&&xe.target===void 0)&&Ee){const et=xe.source!==void 0?"source":"target",lt=yB(et,K.source,K.target,K.data,Te=>Ee.getInternalNode(Te)??null);lt&&(et==="source"?xe.targetPin=lt:xe.sourcePin=lt)}t0.current=!0,z(K.id,xe)},[z]),zJ=m.useCallback((K,J,se,ce)=>{var w1;kr(!1),oi(),ri.current=!1;const ue=t0.current;if(t0.current=!1,ue)return;if(ea.current){ea.current=!1;return}if(!z)return;const Re=pB(K);let xe=((w1=ce.toNode)==null?void 0:w1.id)??null;if(!xe&&Re){const Xr=sT(an.current,Re.clientX,Re.clientY);xe=(Xr==null?void 0:Xr.getAttribute("data-id"))??null}const Ee=se==="source"?"target":"source",Ke=Bwe(Ee,J.source,J.target,xe);if(Ke==="no-op"||Ke==="self-loop"||!Re)return;const et=jt.current;if(!et)return;const lt=Ke==="pin-own"?Ee==="source"?J.source:J.target:xe,Te=et.getInternalNode(lt);if(!Te)return;const wn=Te.measured.width??Te.width??0,Kr=Te.measured.height??Te.height??0;if(wn===0||Kr===0)return;const ct=et.screenToFlowPosition({x:Re.clientX,y:Re.clientY}),Le=wN({x:Te.internals.positionAbsolute.x,y:Te.internals.positionAbsolute.y,w:wn,h:Kr},ct);if(Ke==="pin-own"){if(!ht)return;ht(J.id,Ee,Le);return}const Ft=yB(Ee,J.source,J.target,J.data,Xr=>et.getInternalNode(Xr)??null);Ee==="source"?z(J.id,{source:xe,sourceHandle:null,sourceHandleAutoPicked:!1,sourcePin:Le,...Ft?{targetPin:Ft}:{}}):z(J.id,{target:xe,targetHandle:null,targetHandleAutoPicked:!1,targetPin:Le,...Ft?{sourcePin:Ft}:{}})},[z,oi,ht]),ia=m.useMemo(()=>{var Ee;if(!rr||!Ur)return null;const K=(Ee=an.current)==null?void 0:Ee.getBoundingClientRect(),J=(K==null?void 0:K.left)??0,se=(K==null?void 0:K.top)??0,ce=Math.min(rr.x,Ur.x),ue=Math.min(rr.y,Ur.y),Re=Math.abs(Ur.x-rr.x),xe=Math.abs(Ur.y-rr.y);return{left:ce-J,top:ue-se,width:Re,height:xe}},[rr,Ur]),jJ=Ct?JZ(Ct):"",TJ=Ct?eK(Ct):void 0,NJ=Ct==="text",[AH,PH]=m.useState(!1),[DJ,n0]=m.useState(!1),[_J,RH]=m.useState(!1),li=zwe({projectId:o,getReactFlow:()=>jt.current});m.useImperativeHandle(t,()=>({exportPdf:li.exportPdf,exportPng:li.exportPng,openEmbedDialog:()=>RH(!0),capturePreview:li.capturePreview}),[li.exportPdf,li.exportPng,li.capturePreview]),m.useEffect(()=>{if(!He.enableKeyboard)return;const K=ce=>{if(!ce)return!1;const ue=ce.tagName;return ue==="INPUT"||ue==="TEXTAREA"||ue==="SELECT"?!0:ce instanceof HTMLElement&&ce.isContentEditable},J=ce=>{ce.code==="Space"&&(K(document.activeElement)||(ce.preventDefault(),PH(!0)))},se=ce=>{ce.code==="Space"&&(PH(!1),n0(!1))};return window.addEventListener("keydown",J),window.addEventListener("keyup",se),()=>{window.removeEventListener("keydown",J),window.removeEventListener("keyup",se)}},[He.enableKeyboard]);const r0=m.useCallback(K=>{if(K.length!==0){if(!Mt){const J=id.current;for(const se of K)J.set(se.id,{x:se.position.x,y:se.position.y});return}if(K.length===1){const J=K[0];J&&p&&p(J.id,{x:J.position.x,y:J.position.y});return}if(k){k(K.map(J=>({id:J.id,position:{x:J.position.x,y:J.position.y}})));return}if(p)for(const J of K)p(J.id,{x:J.position.x,y:J.position.y})}},[p,k,Mt]),HJ=m.useCallback((K,J,se)=>{Io.current=!1,r0(se),ii()},[r0,ii]),FJ=m.useCallback(()=>{Io.current=!0},[]),OJ=m.useCallback((K,J)=>{Io.current=!1,r0(J),ii()},[r0,ii]),qJ=m.useCallback((K,J)=>{ae==null||ae(J.id)},[ae]),VJ=m.useCallback(K=>{be==null||be()},[be]),BJ=m.useCallback((K,J)=>{ve==null||ve(J.id)},[ve]),zH=Ct?"crosshair":AH?DJ?"grabbing":"grab":void 0,jH=l[0],TH=c[0],$J=jH?a.find(K=>K.id===jH)??null:null,UJ=TH?s.find(K=>K.id===TH)??null:null,WJ=o??null,GJ=He.showDetailPanel&&!we,ZJ=m.useMemo(()=>({custom:Rt??{}}),[Rt]);return y.jsx(Bue,{value:ZJ,children:y.jsx("div",{"data-testid":"seeflow-canvas","data-mode":n,ref:an,className:"seeflow-canvas-root sf:relative sf:h-full sf:w-full",style:zH?{cursor:zH}:void 0,onPointerDownCapture:CJ,onPointerDown:K=>{AH&&n0(!0),v1(K)},onPointerMove:Dz,onPointerUp:K=>{n0(!1),Kh(K)},onPointerCancel:()=>{Xt.current=!1,Wr.current=null,Nn.current=null,$r(null),Lo(null),n0(!1)},onContextMenuCapture:SJ,onDragOver:LJ,onDrop:IJ,children:y.jsxs(Uhe,{containerRef:an,children:[y.jsxs(f1e,{nodes:ra,edges:Oz,onNodesChange:vJ,nodeTypes:Wwe,edgeTypes:Gwe,proOptions:{hideAttribution:!0},fitView:!0,minZoom:n==="mini"?.05:.5,nodesDraggable:(Mt?!!p:!0)&&!Ct&&He.enableNodeMove,nodesConnectable:Mt&&!!E&&!Ct,deleteKeyCode:Mt?["Backspace","Delete"]:null,zoomOnScroll:He.enableZoom,zoomOnPinch:He.enableZoom,className:tr?"seeflow-connecting":void 0,onConnect:Mt?AJ:void 0,isValidConnection:qz,onConnectStart:(K,J)=>{kr(!0),e0.current=!1,EH.current={nodeId:J.nodeId??null,handleType:J.handleType??null},kn(J.nodeId??null)},onConnectEnd:PJ,onReconnect:Mt&&z?RJ:void 0,onReconnectStart:(K,J,se)=>{kr(!0),t0.current=!1,ri.current=!0;const ce=se==="source"?J.source:J.target;kn(ce)},onReconnectEnd:zJ,connectionLineComponent:x1,connectionLineStyle:{strokeWidth:2},connectionRadius:32,reconnectRadius:10,edgesReconnectable:!1,elevateNodesOnSelect:!1,elementsSelectable:!Ct&&He.enableSelection,selectNodesOnDrag:!1,nodeClickDistance:5,selectionOnDrag:!Ct&&He.enableSelection,panOnDrag:Ct?!1:He.enablePan?[1,2]:!1,selectionMode:Eu.Partial,selectionKeyCode:null,multiSelectionKeyCode:Ct?null:["Meta","Shift"],panActivationKeyCode:Ct?null:"Space",onSelectionStart:MJ,onSelectionEnd:bJ,defaultEdgeOptions:Zwe,zoomOnDoubleClick:!1,onInit:K=>{jt.current=K;const J=an.current;J&&J.style.setProperty("--rf-zoom",String(K.getZoom())),J&&J.setAttribute("data-canvas-ready","true"),!bo.current&&jn.onMount&&a.length>0&&(K.fitView(Ad),bo.current=!0),re==null||re(K)},onMove:(K,J)=>{Br.current&&Vr(null);const se=an.current;se&&se.style.setProperty("--rf-zoom",String(J.zoom))},onEdgesChange:wJ,onNodeDragStart:()=>{Io.current=!0},onNodeDragStop:HJ,onSelectionDragStart:FJ,onSelectionDragStop:OJ,onNodeClick:qJ,onEdgeClick:BJ,onEdgeDoubleClick:(K,J)=>{var se;(se=Tn.current.get(J.id))==null||se()},onPaneClick:VJ,onNodeContextMenu:He.enableContextMenu&&sd?(K,J)=>{K.preventDefault(),Ue.current=J.id,$(!0),oe(J.type??null),Me(null),q({x:K.clientX,y:K.clientY})}:void 0,onPaneContextMenu:He.enableContextMenu&&V?K=>{K.preventDefault(),Ue.current=null,$(!1),oe(null),Me(null),q({x:K.clientX,y:K.clientY})}:void 0,children:[y.jsx(Ywe,{storeApiRef:Co}),y.jsx(Qwe,{wrapperRef:an}),y.jsx(b1e,{gap:12,size:.6}),n!=="mini"&&y.jsx(Dwe,{}),He.showControls?y.jsxs(P1e,{showInteractive:!1,showFitView:!1,children:[y.jsx(X1,{"data-testid":"controls-fit-view","aria-label":"Fit view",title:"Fit view",disabled:a.length===0,onClick:()=>{var K;(K=jt.current)==null||K.fitView(Ad)},children:y.jsx(iu,{className:"sf:h-3 sf:w-3","aria-hidden":"true"})}),y.jsx(X1,{"data-testid":"controls-tidy","aria-label":"Tidy layout (⌘⇧L)",title:"Tidy layout (⌘⇧L)",disabled:!Jh,onClick:()=>Jh==null?void 0:Jh(),children:y.jsx(s2,{className:"sf:h-3 sf:w-3","aria-hidden":"true"})})]}):null,He.showResizeHandles?y.jsx(I3e,{selectedNodes:Ht,onMultiResize:M}):null,He.showToolbar&&C||He.showStyleStrip&&W&&X?y.jsx(ju,{position:"top-left",children:y.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-2",children:[He.showToolbar&&C?y.jsx(ame,{activeShape:Ct,onSelectShape:Qi,iconPickerOpen:ee??!1,onOpenIconPicker:ke,onCloseIconPicker:Fe,onPickIcon:rt}):null,He.showStyleStrip&&W&&X?y.jsx(A3e,{nodes:xn,connectors:I??[],onStyleNode:W,onStyleNodePreview:H,onStyleNodes:j,onStyleNodesPreview:G,onStyleConnector:X,onStyleConnectorPreview:Y,onRequestIconReplace:mt}):null]})}):null,He.showShareMenu||He.showRestart&&Ne?y.jsx(ju,{position:"top-right",children:y.jsxs("div",{className:"sf:flex sf:items-center sf:gap-1",children:[He.showRestart&&Ne?y.jsx(b3e,{onRestartDemo:Ne}):null,He.showShareMenu?y.jsx(M3e,{mode:n==="mini"?"view":n,projectId:o,enableEmbed:He.enableEmbed,onDownloadPdf:li.exportPdf,onDownloadPng:li.exportPng,onExportToCloud:st,embedOpen:_J,onEmbedOpenChange:RH}):null]})}):null]}),ia?y.jsx("div",{"data-testid":"canvas-draw-ghost","data-ghost-shape":Ct??void 0,"aria-hidden":!0,className:ie("sf:pointer-events-none sf:absolute sf:z-10",jJ,NJ?"sf:rounded-sm sf:border sf:border-dashed sf:border-muted-foreground/40":""),style:{...TJ,left:ia.left,top:ia.top,width:ia.width,height:ia.height},children:(()=>{const K=Ct?H_[Ct]:void 0;return K?y.jsx(K,{width:ia.width,height:ia.height,borderColor:tt(void 0,"node").borderColor,backgroundColor:mh,borderSize:M_}):null})()}):null,He.enableContextMenu&&sd?y.jsxs(Ppe,{onOpenChange:K=>{K||(q(null),Ue.current=null,oe(null),Me(null))},children:[y.jsx(Rpe,{asChild:!0,children:y.jsx("div",{ref:Ut,"data-testid":"node-context-menu-trigger","aria-hidden":!0,className:"sf:pointer-events-none sf:fixed",style:{left:(F==null?void 0:F.x)??0,top:(F==null?void 0:F.y)??0,width:0,height:0}})}),y.jsxs(TX,{"data-testid":"node-context-menu",children:[Ae!=null&&Ae.pinned&&le?y.jsx(to,{"data-testid":"connector-endpoint-context-menu-unpin",onSelect:Yt,children:"Unpin"}):null,Z&&R?y.jsxs(to,{"data-testid":"node-context-menu-copy",onSelect:ze,children:["Copy",y.jsx(TN,{children:_z})]}):null,V?y.jsxs(to,{"data-testid":"node-context-menu-paste",disabled:!O,onSelect:gn,children:["Paste",y.jsx(TN,{children:ai})]}):null,Z&&(R||V)&&(_==="iconNode"&&mt||A||U)?y.jsx(MP,{}):null,Z&&_==="iconNode"&&mt?y.jsx(to,{"data-testid":"node-context-menu-change-icon",onSelect:it,children:"Change icon"}):null,Z&&_==="iconNode"&&mt&&(A||U)?y.jsx(MP,{}):null,Z&&A?y.jsxs(y.Fragment,{children:[y.jsx(to,{"data-testid":"node-context-menu-to-front",onSelect:()=>Eo({op:"toFront"}),children:"Bring to front"}),y.jsx(to,{"data-testid":"node-context-menu-forward",onSelect:()=>Eo({op:"forward"}),children:"Bring forward"}),y.jsx(to,{"data-testid":"node-context-menu-backward",onSelect:()=>Eo({op:"backward"}),children:"Send backward"}),y.jsx(to,{"data-testid":"node-context-menu-to-back",onSelect:()=>Eo({op:"toBack"}),children:"Send to back"})]}):null,Z&&A&&U?y.jsx(MP,{}):null,Z&&U?y.jsx(to,{"data-testid":"node-context-menu-delete",onSelect:Dn,children:"Delete"}):null]})]}):null,me?y.jsxs(Ju,{open:!!mn,onOpenChange:K=>{K||Vr(null)},children:[y.jsx(Whe,{asChild:!0,children:y.jsx("div",{"data-testid":"drop-popover-anchor","aria-hidden":!0,className:"sf:pointer-events-none sf:fixed",style:{left:(mn==null?void 0:mn.clientX)??0,top:(mn==null?void 0:mn.clientY)??0,width:0,height:0}})}),y.jsx(u1,{"data-testid":"drop-popover",align:"start",side:"bottom",sideOffset:4,className:"sf:w-auto sf:p-1",onOpenAutoFocus:K=>{K.preventDefault()},children:y.jsx("div",{role:"menu","aria-label":"Create connected node",className:"sf:flex sf:flex-col sf:gap-0.5",children:ime.map(({shape:K,label:J,Icon:se})=>y.jsxs("button",{type:"button",role:"menuitem","data-testid":`drop-popover-shape-${K}`,onClick:()=>{const ce=mn;ce&&(me({sourceNodeId:ce.sourceNodeId,position:{x:ce.flowX,y:ce.flowY},shape:K}),Vr(null))},className:ie("sf:flex sf:items-center sf:gap-2 sf:rounded-sm sf:px-2 sf:py-1.5 sf:text-left sf:text-sm","sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus:bg-accent sf:focus:text-accent-foreground sf:focus:outline-hidden"),children:[y.jsx(se,{className:"sf:h-4 sf:w-4 sf:text-muted-foreground","aria-hidden":"true"}),y.jsx("span",{children:J})]},K))})})]}):null,GJ?y.jsx(Jve,{flowId:WJ,node:$J,connector:UJ,adapter:r??null,statusReport:Se,onNameChange:Oe,onDescriptionChange:te,onDetailChange:de,onIconChange:Pe,onClose:()=>{var K;(K=Zr.current)==null||K.call(Zr,[],[])}}):null]})})})}const o6e=m.forwardRef(r6e);function i6e({open:e,onOpenChange:t,onCreated:n}){const[r,o]=m.useState(""),[i,a]=m.useState(null),[s,l]=m.useState(!1);m.useEffect(()=>{e&&(o(""),a(null),l(!1))},[e]);const c=r.trim(),h=c.length>0&&!s,d=async f=>{if(f.preventDefault(),!!h){l(!0),a(null);try{const p=await Cne({name:c});n(p),t(!1)}catch(p){a(p instanceof Error?p.message:String(p)),l(!1)}}};return y.jsx(kz,{open:e,onOpenChange:t,children:y.jsxs(Nh,{className:"sm:max-w-md","data-testid":"create-project-dialog",onOpenAutoFocus:f=>{f.preventDefault();const p=document.querySelector('[data-testid="create-project-name-input"]');p==null||p.focus()},children:[y.jsxs(Dh,{children:[y.jsx(_h,{children:"Create new project"}),y.jsxs(Hh,{children:["The project will be created at ",y.jsx("code",{children:"~/.seeflow/<slug>"}),"."]})]}),y.jsxs("form",{onSubmit:d,className:"flex flex-col gap-4",children:[y.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[y.jsx("span",{className:"font-medium",children:"Project name"}),y.jsx("input",{type:"text",required:!0,autoComplete:"off",spellCheck:!1,value:r,onChange:f=>o(f.target.value),"data-testid":"create-project-name-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"})]}),i?y.jsx("div",{role:"alert","data-testid":"create-project-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:i}):null,y.jsxs(Hu,{children:[y.jsx(Nt,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:s,children:"Cancel"}),y.jsx(Nt,{type:"submit",disabled:!h,"data-testid":"create-project-submit",children:s?"Creating…":"Create project"})]})]})]})})}const tD="seeflow:navigate",a6e=e=>(window.addEventListener("popstate",e),window.addEventListener(tD,e),()=>{window.removeEventListener("popstate",e),window.removeEventListener(tD,e)}),xB=()=>window.location.pathname,s6e=()=>m.useSyncExternalStore(a6e,xB,xB),qu=e=>{e!==window.location.pathname&&(window.history.pushState({},"",e),window.dispatchEvent(new Event(tD)))};function l6e({demos:e,currentSlug:t,onProjectCreated:n,onProjectUnregistered:r}){const[o,i]=m.useState(!1),[a,s]=m.useState(!1),[l,c]=m.useState(null),[h,d]=m.useState(!1),[f,p]=m.useState(null);m.useEffect(()=>{const x=b=>{b.key==="k"&&(b.metaKey||b.ctrlKey)&&(b.preventDefault(),i(S=>!S))};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[]);const k=e.find(x=>x.slug===t),v=x=>{n==null||n(x),qu(`/d/${x.slug}`)},w=x=>{c(x),p(null)},g=()=>{h||(c(null),p(null))},M=async()=>{if(l){d(!0),p(null);try{await bne(l.id);const x=l.id;c(null),r==null||r(x)}catch(x){p(x instanceof Error?x.message:String(x))}finally{d(!1)}}};return y.jsxs(y.Fragment,{children:[y.jsxs(Ju,{open:o,onOpenChange:i,children:[y.jsx(Eh,{asChild:!0,children:y.jsxs(Nt,{type:"button",variant:"outline",size:"sm","aria-label":"Switch demo","aria-expanded":o,className:"gap-2","data-testid":"project-switcher-trigger",children:[y.jsx("span",{className:"max-w-[180px] truncate text-sm",children:(k==null?void 0:k.name)??"Select demo"}),y.jsx(RK,{children:"⌘K"}),y.jsx(Qd,{className:"h-3.5 w-3.5 opacity-60"})]})}),y.jsx(u1,{align:"end",sideOffset:6,className:"w-[320px] p-0","data-testid":"project-switcher-popover",children:y.jsxs(LK,{children:[y.jsx(IK,{placeholder:"Search demos..."}),y.jsxs(EK,{children:[y.jsx(AK,{children:"No demos."}),e.length>0?y.jsx(PN,{heading:"Demos",children:e.map(x=>y.jsxs(RN,{value:`${x.name} ${x.slug}`,onSelect:()=>{i(!1),qu(`/d/${x.slug}`)},className:"group flex items-center justify-between gap-2",children:[y.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-0.5",children:[y.jsx("span",{className:"font-medium",children:x.name}),y.jsx("span",{className:"w-full truncate text-xs text-muted-foreground",children:x.repoPath})]}),y.jsx("button",{type:"button","aria-label":`Unregister ${x.name}`,className:"shrink-0 rounded p-0.5 opacity-0 transition-opacity hover:text-destructive group-hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring",onClick:b=>{b.stopPropagation(),i(!1),w(x)},children:y.jsx(v2,{className:"h-3.5 w-3.5"})})]},x.id))}):null,e.length>0?y.jsx(PK,{}):null,y.jsx(PN,{children:y.jsxs(RN,{value:"+ create new project",onSelect:()=>{i(!1),s(!0)},"data-testid":"project-switcher-create",className:"flex items-center gap-2 text-sm",children:[y.jsx(d2,{className:"h-4 w-4 opacity-70"}),y.jsx("span",{className:"font-medium",children:"Create new project"})]})})]})]})})]}),y.jsx(i6e,{open:a,onOpenChange:s,onCreated:v}),y.jsx(kz,{open:l!==null,onOpenChange:x=>{x||g()},children:y.jsxs(Nh,{className:"sm:max-w-md","data-testid":"unregister-project-dialog",children:[y.jsxs(Dh,{children:[y.jsx(_h,{children:"Unregister project?"}),y.jsxs(Hh,{children:["This removes ",y.jsx("strong",{children:l==null?void 0:l.name})," from SeeFlow. Your files at"," ",y.jsx("code",{className:"text-xs",children:l==null?void 0:l.repoPath})," will not be deleted."]})]}),f?y.jsx("div",{role:"alert","data-testid":"unregister-project-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:f}):null,y.jsxs(Hu,{children:[y.jsx(Nt,{type:"button",variant:"ghost",onClick:g,disabled:h,children:"Cancel"}),y.jsx(Nt,{type:"button",variant:"destructive",onClick:M,disabled:h,"data-testid":"unregister-project-confirm",children:h?"Unregistering…":"Unregister"})]})]})})]})}function c6e({demos:e,currentSlug:t,onProjectCreated:n,onProjectUnregistered:r}){return y.jsxs("header",{className:"relative flex h-14 shrink-0 items-center justify-between border-b border-border/60 bg-background/85 px-5 backdrop-blur-md shadow-[0_4px_12px_-6px_rgba(0,0,0,0.6)]",children:[y.jsxs("button",{type:"button",onClick:()=>qu("/"),className:"-ml-1.5 flex items-center gap-2 rounded-md px-1.5 py-1 text-base font-bold tracking-tight transition-colors hover:bg-muted/60",children:[y.jsx(b2,{size:18,strokeWidth:2.25,className:"text-emerald-400"}),"SeeFlow",y.jsxs("span",{className:"ml-1 text-[10px] font-normal tracking-normal text-muted-foreground/70",children:["v","0.1.51"]})]}),y.jsx("div",{className:"flex items-center gap-3",children:y.jsx(l6e,{demos:e,currentSlug:t,onProjectCreated:n,onProjectUnregistered:r})})]})}const u6e=e=>{const[t,n]=m.useState(null),[r,o]=m.useState(e!==null),[i,a]=m.useState(null),s=m.useCallback(()=>{e&&(o(!0),KU(e).then(c=>{n(c),a(null)}).catch(c=>{console.error("[useDemoData] failed",c),a(String(c))}).finally(()=>o(!1)))},[e]),l=m.useCallback(c=>{n(c),a(null)},[]);return m.useEffect(()=>{if(!e){n(null),o(!1);return}s()},[e,s]),{detail:t,loading:r,error:i,refresh:s,applyDetail:l}},d6e=()=>{const[e,t]=m.useState(null),[n,r]=m.useState(null),o=m.useCallback(()=>Mne().then(i=>{t(i),r(null)}).catch(i=>{console.error("[useDemos] failed",i),t([]),r(String(i))}),[]);return m.useEffect(()=>{o()},[o]),{demos:e,error:n,refresh:o}},h6e=5,f6e={"node:running":"running","node:done":"done","node:error":"error"},p6e=(e,t)=>{if(t.type==="reset")return{};const n=e[t.nodeId]??[],r=[t.entry,...n].slice(0,h6e);return{...e,[t.nodeId]:r}},y6e=e=>{const[t,n]=m.useReducer(p6e,{}),r=m.useRef(n);r.current=n,m.useEffect(()=>{r.current({type:"reset"})},[e]);const o=m.useCallback(a=>{const s=f6e[a.type];if(!s)return;const l=typeof a.nodeId=="string"?a.nodeId:null;if(!l)return;const c=typeof a.runId=="string"?a.runId:void 0,h=typeof a.ts=="number"?a.ts:Date.now();r.current({type:"append",nodeId:l,entry:{status:s,ts:h,runId:c}})},[]),i=m.useCallback(()=>{r.current({type:"reset"})},[]);return{events:t,apply:o,reset:i}},m6e=(e,t)=>{var n,r;switch(t.type){case"reset":return{};case"running":return{...e,[t.nodeId]:{status:"running",runId:t.runId,ts:t.ts??Date.now()}};case"done":return{...e,[t.nodeId]:{...e[t.nodeId],status:"done",runId:t.runId??((n=e[t.nodeId])==null?void 0:n.runId),responseStatus:t.responseStatus,body:t.body,ts:t.ts??Date.now()}};case"error":return{...e,[t.nodeId]:{...e[t.nodeId],status:"error",runId:t.runId??((r=e[t.nodeId])==null?void 0:r.runId),error:t.message,ts:t.ts??Date.now()}}}},k6e=e=>{const[t,n]=m.useReducer(m6e,{}),r=m.useRef(n);r.current=n,m.useEffect(()=>{r.current({type:"reset"})},[e]);const o=m.useCallback(a=>{const s=typeof a.nodeId=="string"?a.nodeId:null;if(!s)return;const l=typeof a.runId=="string"?a.runId:void 0;if(a.type==="node:running"){r.current({type:"running",nodeId:s,runId:l,ts:a.ts});return}if(a.type==="node:done"){const c=typeof a.status=="number"?a.status:void 0;r.current({type:"done",nodeId:s,runId:l,responseStatus:c,body:a.body,ts:a.ts});return}if(a.type==="node:error"){const c=typeof a.message=="string"?a.message:void 0;r.current({type:"error",nodeId:s,runId:l,message:c,ts:a.ts})}},[]),i=m.useCallback(()=>{r.current({type:"reset"})},[]);return{runs:t,apply:o,reset:i}},g6e=new Set(["ok","warn","error","pending"]),x6e=(e,t)=>{if(t.type!=="node:status")return e;const n=typeof t.nodeId=="string"?t.nodeId:null;if(!n||typeof t.state!="string"||!g6e.has(t.state))return e;const r=typeof t.summary=="string"?t.summary:void 0,o=typeof t.detail=="string"?t.detail:void 0,i=t.data&&typeof t.data=="object"&&!Array.isArray(t.data)?t.data:void 0,a=typeof t.ts=="number"?t.ts:Date.now();return{...e,[n]:{state:t.state,summary:r,detail:o,data:i,ts:a}}},v6e=(e,t)=>{switch(t.type){case"reset":return{};case"event":return x6e(e,t.event)}},w6e=e=>{const[t,n]=m.useReducer(v6e,{}),r=m.useRef(n);r.current=n,m.useEffect(()=>{r.current({type:"reset"})},[e]);const o=m.useCallback(a=>{r.current({type:"event",event:a})},[]),i=m.useCallback(()=>{r.current({type:"reset"})},[]);return{statusByNode:t,apply:o,reset:i}},M6e=(e={})=>{const[t,n]=m.useState(!1),{onRegistryReload:r,onHello:o}=e,i=m.useRef(r),a=m.useRef(o);return m.useEffect(()=>{i.current=r,a.current=o},[r,o]),m.useEffect(()=>{const s=new EventSource("/api/registry/events");return s.addEventListener("open",()=>n(!0)),s.addEventListener("error",()=>n(!1)),s.addEventListener("hello",()=>{var l;(l=a.current)==null||l.call(a)}),s.addEventListener("registry:reload",()=>{var l;(l=i.current)==null||l.call(i)}),()=>{s.close()}},[]),{connected:t}},b6e=(e,t={})=>{const[n,r]=m.useState(!1),{onHello:o,onFlowReload:i,onEvent:a}=t,s=m.useRef(o),l=m.useRef(i),c=m.useRef(a);return m.useEffect(()=>{s.current=o,l.current=i,c.current=a},[o,i,a]),m.useEffect(()=>{if(!e){r(!1);return}const h=`/api/events?flowId=${encodeURIComponent(e)}`,d=new EventSource(h);d.addEventListener("open",()=>r(!0)),d.addEventListener("error",()=>r(!1)),d.addEventListener("hello",()=>{var f;(f=s.current)==null||f.call(s)}),d.addEventListener("flow:reload",f=>{var v,w;const p=vB(f,"flow:reload");(v=c.current)==null||v.call(c,p);const k=C6e(p);k&&((w=l.current)==null||w.call(l,k))});for(const f of["node:running","node:done","node:error","node:status"])d.addEventListener(f,p=>{var k;(k=c.current)==null||k.call(c,vB(p,f))});return()=>{d.close()}},[e]),{connected:n}},vB=(e,t)=>{try{const n=JSON.parse(e.data);return{type:t,ts:Date.now(),...n}}catch{return{type:t,ts:Date.now()}}},C6e=e=>e.valid===!0&&e.flow&&typeof e.flow=="object"?{valid:!0,flow:e.flow}:e.valid===!1&&typeof e.error=="string"?{valid:!1,error:e.error}:null,oJ="seeflow:last-project",S6e=()=>{if(typeof window>"u")return null;try{return window.localStorage.getItem(oJ)}catch{return null}},wB=e=>{if(!(typeof window>"u"))try{window.localStorage.setItem(oJ,e)}catch{}},L6e=(e,t)=>{if(e.length===0)return null;if(e.length===1)return e[0]??null;if(t){const n=e.find(r=>r.id===t);if(n)return n}return null},MB=["File","Edit","View","Tools","Layout","Selection","Help"],iJ="seeflow:command-palette:recent",aJ=5,sJ=new Map(v_.map(e=>[e.id,e])),I6e=e=>typeof e=="string"&&sJ.has(e),bB=()=>{if(typeof window>"u")return[];try{const e=window.localStorage.getItem(iJ);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(I6e).slice(0,aJ):[]}catch{return[]}},E6e=e=>{if(!(typeof window>"u"))try{window.localStorage.setItem(iJ,JSON.stringify(e))}catch{}},CB=(e,t)=>e.enabled?e.enabled(t):!0,A6e=(e,t)=>t.length===0?!0:`${e.label} ${e.description??""}`.toLowerCase().includes(t);function P6e({open:e,onOpenChange:t,runCommand:n,ctx:r}){const[o,i]=m.useState(""),[a,s]=m.useState(0),[l,c]=m.useState(()=>bB()),h=m.useRef(null),d=m.useRef(null);m.useEffect(()=>{e&&(i(""),s(0),c(bB()))},[e]);const{groups:f,flat:p}=m.useMemo(()=>{const b=o.trim().toLowerCase();if(b.length===0){if(l.length===0)return{groups:[],flat:[]};const T=[];for(const z of l){const A=sJ.get(z);A&&T.push({cmd:A,enabled:CB(A,r)})}return{groups:[{category:"Recent",rows:T}],flat:T}}const S=new Map;for(const T of v_){if(!A6e(T,b))continue;const E={cmd:T,enabled:CB(T,r)},z=S.get(T.category);z?z.push(E):S.set(T.category,[E])}const L=[...MB.filter(T=>S.has(T)),...Array.from(S.keys()).filter(T=>!MB.includes(T))].map(T=>({category:T,rows:S.get(T)??[]})),P=L.flatMap(T=>T.rows);return{groups:L,flat:P}},[o,r,l]);m.useEffect(()=>{if(p.length===0){s(0);return}s(b=>{var C;let S=b;if(S>=p.length&&(S=0),!((C=p[S])!=null&&C.enabled)){const L=p.findIndex(P=>P.enabled);L!==-1&&(S=L)}return S})},[p]);const k=m.useCallback(b=>{p.length!==0&&s(S=>{var L;let C=S;for(let P=0;P<p.length;P++)if(C=(C+b+p.length)%p.length,(L=p[C])!=null&&L.enabled)return C;return S})},[p]),v=m.useCallback(b=>{c(S=>{const C=[b,...S.filter(L=>L!==b)].slice(0,aJ);return E6e(C),C})},[]),w=m.useCallback(b=>{const S=p[b];!S||!S.enabled||(v(S.cmd.id),n(S.cmd.id),t(!1))},[p,t,v,n]),g=m.useCallback(b=>{if(b.key==="ArrowDown"){b.preventDefault(),k(1);return}if(b.key==="ArrowUp"){b.preventDefault(),k(-1);return}b.key==="Enter"&&(b.preventDefault(),w(a))},[w,a,k]);m.useEffect(()=>{if(!e)return;const b=d.current;if(!b)return;const S=b.querySelector(`[data-command-row-index="${a}"]`);S&&typeof S.scrollIntoView=="function"&&S.scrollIntoView({block:"nearest"})},[a,e]);const x=o.trim().length>0;return y.jsx(hz,{open:e,onOpenChange:t,children:y.jsx(fz,{children:y.jsxs(ed,{className:ie("fixed left-0 right-0 top-[20%] z-50 mx-auto w-[480px] max-w-[90vw] border border-border bg-card shadow-lg duration-200","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","sm:rounded-lg"),"data-testid":"command-palette",onOpenAutoFocus:b=>{var S;b.preventDefault(),(S=h.current)==null||S.focus()},children:[y.jsx("div",{className:ie("border-b",p.length===0&&!x&&"border-b-0"),children:y.jsx("input",{ref:h,type:"text",value:o,onChange:b=>i(b.target.value),onKeyDown:g,placeholder:"Type a command…","data-testid":"command-palette-input","aria-label":"Search commands",autoComplete:"off",spellCheck:!1,className:"w-full bg-transparent px-4 py-3 text-sm outline-hidden placeholder:text-muted-foreground"})}),y.jsx("div",{ref:d,"data-testid":"command-palette-list","data-empty":p.length===0?"true":"false",className:ie("max-h-[50vh] overflow-y-auto",p.length>0?"py-1":"","seeflow-no-scrollbar"),children:p.length===0?x?y.jsxs("div",{"data-testid":"command-palette-empty",className:"px-4 py-6 text-center text-sm text-muted-foreground",children:['No commands match "',o,'"']}):null:(()=>{let b=-1;return f.map(S=>y.jsxs("div",{className:"py-1",children:[y.jsx("div",{className:"px-3 pb-1 pt-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:S.category}),S.rows.map(C=>{b+=1;const L=b,P=L===a;return y.jsxs("button",{type:"button","data-testid":`command-palette-row-${C.cmd.id}`,"data-command-row-index":L,"data-highlighted":P?"true":"false","aria-disabled":C.enabled?void 0:!0,disabled:!C.enabled,onMouseEnter:()=>{C.enabled&&s(L)},onClick:()=>w(L),className:ie("flex w-full items-center justify-between gap-3 px-3 py-2 text-left text-sm outline-hidden",C.enabled?"cursor-pointer text-foreground hover:bg-muted":"cursor-not-allowed text-muted-foreground/50",P&&C.enabled?"bg-muted":""),children:[y.jsxs("div",{className:"flex min-w-0 flex-col",children:[y.jsx("span",{className:"truncate font-medium",children:C.cmd.label}),C.cmd.description?y.jsx("span",{className:"truncate text-xs text-muted-foreground",children:C.cmd.description}):null]}),C.cmd.shortcut?y.jsx("kbd",{"data-testid":`command-palette-shortcut-${C.cmd.id}`,className:"shrink-0 rounded border bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:C.cmd.shortcut}):null]},C.cmd.id)})]},S.category))})()})]})})})}var rn=Uint8Array,$n=Uint16Array,bH=Int32Array,CH=new rn([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),SH=new rn([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),SB=new rn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),lJ=function(e,t){for(var n=new $n(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var o=new bH(n[30]),r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)o[i]=i-n[r]<<5|r;return{b:n,r:o}},cJ=lJ(CH,2),R6e=cJ.b,nD=cJ.r;R6e[28]=258,nD[258]=28;var z6e=lJ(SH,0),LB=z6e.r,rD=new $n(32768);for(var xt=0;xt<32768;++xt){var yi=(xt&43690)>>1|(xt&21845)<<1;yi=(yi&52428)>>2|(yi&13107)<<2,yi=(yi&61680)>>4|(yi&3855)<<4,rD[xt]=((yi&65280)>>8|(yi&255)<<8)>>1}var P2=function(e,t,n){for(var r=e.length,o=0,i=new $n(t);o<r;++o)e[o]&&++i[e[o]-1];var a=new $n(t);for(o=1;o<t;++o)a[o]=a[o-1]+i[o-1]<<1;var s;if(n){s=new $n(1<<t);var l=15-t;for(o=0;o<r;++o)if(e[o])for(var c=o<<4|e[o],h=t-e[o],d=a[e[o]-1]++<<h,f=d|(1<<h)-1;d<=f;++d)s[rD[d]>>l]=c}else for(s=new $n(r),o=0;o<r;++o)e[o]&&(s[o]=rD[a[e[o]-1]++]>>15-e[o]);return s},a1=new rn(288);for(var xt=0;xt<144;++xt)a1[xt]=8;for(var xt=144;xt<256;++xt)a1[xt]=9;for(var xt=256;xt<280;++xt)a1[xt]=7;for(var xt=280;xt<288;++xt)a1[xt]=8;var SR=new rn(32);for(var xt=0;xt<32;++xt)SR[xt]=5;var j6e=P2(a1,9,0),T6e=P2(SR,5,0),uJ=function(e){return(e+7)/8|0},dJ=function(e,t,n){return(n==null||n>e.length)&&(n=e.length),new rn(e.subarray(t,n))},N6e=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Nz=function(e,t,n){var r=new Error(t||N6e[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Nz),!n)throw r;return r},To=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},Pd=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},lT=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var o=n.length,i=n.slice();if(!o)return{t:fJ,l:0};if(o==1){var a=new rn(n[0].s+1);return a[n[0].s]=1,{t:a,l:1}}n.sort(function(S,C){return S.f-C.f}),n.push({s:-1,f:25001});var s=n[0],l=n[1],c=0,h=1,d=2;for(n[0]={s:-1,f:s.f+l.f,l:s,r:l};h!=o-1;)s=n[n[c].f<n[d].f?c++:d++],l=n[c!=h&&n[c].f<n[d].f?c++:d++],n[h++]={s:-1,f:s.f+l.f,l:s,r:l};for(var f=i[0].s,r=1;r<o;++r)i[r].s>f&&(f=i[r].s);var p=new $n(f+1),k=oD(n[h-1],p,0);if(k>t){var r=0,v=0,w=k-t,g=1<<w;for(i.sort(function(C,L){return p[L.s]-p[C.s]||C.f-L.f});r<o;++r){var M=i[r].s;if(p[M]>t)v+=g-(1<<k-p[M]),p[M]=t;else break}for(v>>=w;v>0;){var x=i[r].s;p[x]<t?v-=1<<t-p[x]++-1:++r}for(;r>=0&&v;--r){var b=i[r].s;p[b]==t&&(--p[b],++v)}k=t}return{t:new rn(p),l:k}},oD=function(e,t,n){return e.s==-1?Math.max(oD(e.l,t,n+1),oD(e.r,t,n+1)):t[e.s]=n},IB=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new $n(++t),r=0,o=e[0],i=1,a=function(l){n[r++]=l},s=1;s<=t;++s)if(e[s]==o&&s!=t)++i;else{if(!o&&i>2){for(;i>138;i-=138)a(32754);i>2&&(a(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(a(o),--i;i>6;i-=6)a(8304);i>2&&(a(i-3<<5|8208),i=0)}for(;i--;)a(o);i=1,o=e[s]}return{c:n.subarray(0,r),n:t}},Rd=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},hJ=function(e,t,n){var r=n.length,o=uJ(t+2);e[o]=r&255,e[o+1]=r>>8,e[o+2]=e[o]^255,e[o+3]=e[o+1]^255;for(var i=0;i<r;++i)e[o+i+4]=n[i];return(o+4+r)*8},EB=function(e,t,n,r,o,i,a,s,l,c,h){To(t,h++,n),++o[256];for(var d=lT(o,15),f=d.t,p=d.l,k=lT(i,15),v=k.t,w=k.l,g=IB(f),M=g.c,x=g.n,b=IB(v),S=b.c,C=b.n,L=new $n(19),P=0;P<M.length;++P)++L[M[P]&31];for(var P=0;P<S.length;++P)++L[S[P]&31];for(var T=lT(L,7),E=T.t,z=T.l,A=19;A>4&&!E[SB[A-1]];--A);var U=c+5<<3,R=Rd(o,a1)+Rd(i,SR)+a,V=Rd(o,f)+Rd(i,v)+a+14+3*A+Rd(L,E)+2*L[16]+3*L[17]+7*L[18];if(l>=0&&U<=R&&U<=V)return hJ(t,h,e.subarray(l,l+c));var O,B,D,N;if(To(t,h,1+(V<R)),h+=2,V<R){O=P2(f,p,0),B=f,D=P2(v,w,0),N=v;var I=P2(E,z,0);To(t,h,x-257),To(t,h+5,C-1),To(t,h+10,A-4),h+=14;for(var P=0;P<A;++P)To(t,h+3*P,E[SB[P]]);h+=3*A;for(var W=[M,S],H=0;H<2;++H)for(var j=W[H],P=0;P<j.length;++P){var G=j[P]&31;To(t,h,I[G]),h+=E[G],G>15&&(To(t,h,j[P]>>5&127),h+=j[P]>>12)}}else O=j6e,B=a1,D=T6e,N=SR;for(var P=0;P<s;++P){var X=r[P];if(X>255){var G=X>>18&31;Pd(t,h,O[G+257]),h+=B[G+257],G>7&&(To(t,h,X>>23&31),h+=CH[G]);var Y=X&31;Pd(t,h,D[Y]),h+=N[Y],Y>3&&(Pd(t,h,X>>5&8191),h+=SH[Y])}else Pd(t,h,O[X]),h+=B[X]}return Pd(t,h,O[256]),h+B[256]},D6e=new bH([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),fJ=new rn(0),_6e=function(e,t,n,r,o,i){var a=i.z||e.length,s=new rn(r+a+5*(1+Math.ceil(a/7e3))+o),l=s.subarray(r,s.length-o),c=i.l,h=(i.r||0)&7;if(t){h&&(l[0]=i.r>>3);for(var d=D6e[t-1],f=d>>13,p=d&8191,k=(1<<n)-1,v=i.p||new $n(32768),w=i.h||new $n(k+1),g=Math.ceil(n/3),M=2*g,x=function(ee){return(e[ee]^e[ee+1]<<g^e[ee+2]<<M)&k},b=new bH(25e3),S=new $n(288),C=new $n(32),L=0,P=0,T=i.i||0,E=0,z=i.w||0,A=0;T+2<a;++T){var U=x(T),R=T&32767,V=w[U];if(v[R]=V,w[U]=R,z<=T){var O=a-T;if((L>7e3||E>24576)&&(O>423||!c)){h=EB(e,l,0,b,S,C,P,E,A,T-A,h),E=L=P=0,A=T;for(var B=0;B<286;++B)S[B]=0;for(var B=0;B<30;++B)C[B]=0}var D=2,N=0,I=p,W=R-V&32767;if(O>2&&U==x(T-W))for(var H=Math.min(f,O)-1,j=Math.min(32767,T),G=Math.min(258,O);W<=j&&--I&&R!=V;){if(e[T+D]==e[T+D-W]){for(var X=0;X<G&&e[T+X]==e[T+X-W];++X);if(X>D){if(D=X,N=W,X>H)break;for(var Y=Math.min(W,X-2),re=0,B=0;B<Y;++B){var ne=T-W+B&32767,ae=v[ne],ve=ne-ae&32767;ve>re&&(re=ve,V=ne)}}}R=V,V=v[R],W+=R-V&32767}if(N){b[E++]=268435456|nD[D]<<18|LB[N];var be=nD[D]&31,me=LB[N]&31;P+=CH[be]+SH[me],++S[257+be],++C[me],z=T+D,++L}else b[E++]=e[T],++S[e[T]]}}for(T=Math.max(T,z);T<a;++T)b[E++]=e[T],++S[e[T]];h=EB(e,l,c,b,S,C,P,E,A,T-A,h),c||(i.r=h&7|l[h/8|0]<<3,h-=7,i.h=w,i.p=v,i.i=T,i.w=z)}else{for(var T=i.w||0;T<a+c;T+=65535){var ge=T+65535;ge>=a&&(l[h/8|0]=c,ge=a),h=hJ(l,h+1,e.subarray(T,ge))}i.i=a}return dJ(s,0,r+uJ(h)+o)},H6e=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),F6e=function(){var e=-1;return{p:function(t){for(var n=e,r=0;r<t.length;++r)n=H6e[n&255^t[r]]^n>>>8;e=n},d:function(){return~e}}},pJ=function(){var e=1,t=0;return{p:function(n){for(var r=e,o=t,i=n.length|0,a=0;a!=i;){for(var s=Math.min(a+2655,i);a<s;++a)o+=r+=n[a];r=(r&65535)+15*(r>>16),o=(o&65535)+15*(o>>16)}e=r,t=o},d:function(){return e%=65521,t%=65521,(e&255)<<24|(e&65280)<<8|(t&255)<<8|t>>8}}},yJ=function(e,t,n,r,o){if(!o&&(o={l:1},t.dictionary)){var i=t.dictionary.subarray(-32768),a=new rn(i.length+e.length);a.set(i),a.set(e,i.length),e=a,o.w=i.length}return _6e(e,t.level==null?6:t.level,t.mem==null?o.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,r,o)},mJ=function(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n},Ot=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},O6e=function(e,t){var n=t.level,r=n==0?0:n<6?1:n==9?3:2;if(e[0]=120,e[1]=r<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var o=pJ();o.p(t.dictionary),Ot(e,2,o.d())}};function q6e(e,t){return yJ(e,t||{},0,0)}function R8e(e,t){t||(t={});var n=pJ();n.p(e);var r=yJ(e,t,t.dictionary?6:2,4);return O6e(r,t),Ot(r,r.length-4,n.d()),r}var kJ=function(e,t,n,r){for(var o in e){var i=e[o],a=t+o,s=r;Array.isArray(i)&&(s=mJ(r,i[1]),i=i[0]),i instanceof rn?n[a]=[i,s]:(n[a+="/"]=[new rn(0),s],kJ(i,a,n,r))}},AB=typeof TextEncoder<"u"&&new TextEncoder,V6e=typeof TextDecoder<"u"&&new TextDecoder,B6e=0;try{V6e.decode(fJ,{stream:!0}),B6e=1}catch{}function iD(e,t){var n;if(AB)return AB.encode(e);for(var r=e.length,o=new rn(e.length+(e.length>>1)),i=0,a=function(c){o[i++]=c},n=0;n<r;++n){if(i+5>o.length){var s=new rn(i+8+(r-n<<1));s.set(o),o=s}var l=e.charCodeAt(n);l<128||t?a(l):l<2048?(a(192|l>>6),a(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|e.charCodeAt(++n)&1023,a(240|l>>18),a(128|l>>12&63),a(128|l>>6&63),a(128|l&63)):(a(224|l>>12),a(128|l>>6&63),a(128|l&63))}return dJ(o,0,i)}var aD=function(e){var t=0;if(e)for(var n in e){var r=e[n].length;r>65535&&Nz(9),t+=r+4}return t},PB=function(e,t,n,r,o,i,a,s){var l=r.length,c=n.extra,h=s&&s.length,d=aD(c);Ot(e,t,a!=null?33639248:67324752),t+=4,a!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(i<0&&8),e[t++]=o&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),p=f.getFullYear()-1980;if((p<0||p>119)&&Nz(10),Ot(e,t,p<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,i!=-1&&(Ot(e,t,n.crc),Ot(e,t+4,i<0?-i-2:i),Ot(e,t+8,n.size)),Ot(e,t+12,l),Ot(e,t+14,d),t+=16,a!=null&&(Ot(e,t,h),Ot(e,t+6,n.attrs),Ot(e,t+10,a),t+=14),e.set(r,t),t+=l,d)for(var k in c){var v=c[k],w=v.length;Ot(e,t,+k),Ot(e,t+2,w),e.set(v,t+4),t+=4+w}return h&&(e.set(s,t),t+=h),t},$6e=function(e,t,n,r,o){Ot(e,t,101010256),Ot(e,t+8,n),Ot(e,t+10,n),Ot(e,t+12,r),Ot(e,t+16,o)};function U6e(e,t){t||(t={});var n={},r=[];kJ(e,"",n,t);var o=0,i=0;for(var a in n){var s=n[a],l=s[0],c=s[1],h=c.level==0?0:8,d=iD(a),f=d.length,p=c.comment,k=p&&iD(p),v=k&&k.length,w=aD(c.extra);f>65535&&Nz(11);var g=h?q6e(l,c):l,M=g.length,x=F6e();x.p(l),r.push(mJ(c,{size:l.length,crc:x.d(),c:g,f:d,m:k,u:f!=a.length||k&&p.length!=v,o,compression:h})),o+=30+f+w+M,i+=76+2*(f+w)+(v||0)+M}for(var b=new rn(i+22),S=o,C=i-o,L=0;L<r.length;++L){var d=r[L];PB(b,d.o,d,d.f,d.u,d.c.length);var P=30+d.f.length+aD(d.extra);b.set(d.c,d.o+P),PB(b,o,d,d.f,d.u,d.c.length,d.o,d.m),o+=16+P+(d.m?d.m.length:0)}return $6e(b,o,r.length,C,S),b}const W6e="https://seeflow.dev/api";async function G6e(e,t,n,r,o){const i=await KU(e);if(!i.flow)throw new Error("Flow has no data");const a=i.flow,s=new Set,l=[];for(const k of a.nodes)k.type==="imageNode"&&k.data.path&&!s.has(k.data.path)&&(s.add(k.data.path),l.push(k.data.path));const h={[r==="link"?"flow.private.json":"flow.json"]:iD(JSON.stringify(a))};if(o){const k=o.split(",")[1];k&&(h["preview.png"]=Uint8Array.from(atob(k),v=>v.charCodeAt(0)))}for(const k of l){const v=await fetch(`/api/projects/${encodeURIComponent(e)}/files/${k}`);v.ok&&(h[`files/${k}`]=new Uint8Array(await v.arrayBuffer()))}const d=U6e(h),f=await fetch(`${W6e}/flows?email=${encodeURIComponent(t)}&name=${encodeURIComponent(n)}`,{method:"POST",headers:{"content-type":"application/zip"},body:d.buffer});if(!f.ok)throw new Error(`Export failed with status ${f.status}`);const p=await f.json();if(typeof p.url!="string")throw new Error("Invalid response from cloud API: missing url");return{shareUrl:p.url}}function Z6e(e){return m.useCallback((t,n,r,o)=>G6e(e,t,n,r,o),[e])}const RB="seeflow.export.email",zB="seeflow.export.name",jB="seeflow.export.visibility";function K6e({open:e,onOpenChange:t,projectId:n,onCapturePreview:r}){const[o,i]=m.useState(""),[a,s]=m.useState(""),[l,c]=m.useState("public"),[h,d]=m.useState({kind:"idle"}),[f,p]=m.useState(!1),k=Z6e(n);m.useEffect(()=>{e&&(i(localStorage.getItem(RB)??""),s(localStorage.getItem(zB)??""),c(localStorage.getItem(jB)??"public"),d({kind:"idle"}),p(!1))},[e]);const v=m.useCallback(async()=>{d({kind:"loading"});try{const x=await(r==null?void 0:r()),{shareUrl:b}=await k(o.trim(),a.trim(),l,x);localStorage.setItem(RB,o.trim()),localStorage.setItem(zB,a.trim()),localStorage.setItem(jB,l),d({kind:"done",shareUrl:b})}catch(x){d({kind:"error",message:x instanceof Error?x.message:String(x)})}},[k,o,a,l,r]),w=m.useCallback(async()=>{if(h.kind==="done")try{await navigator.clipboard.writeText(h.shareUrl),p(!0),setTimeout(()=>p(!1),2e3)}catch(x){console.error("Failed to copy to clipboard:",x)}},[h]),g=h.kind==="loading",M=o.trim().length>0&&a.trim().length>0;return y.jsx(kz,{open:e,onOpenChange:t,children:y.jsxs(Nh,{className:"sm:max-w-md","data-testid":"export-dialog",onOpenAutoFocus:x=>{x.preventDefault();const b=document.querySelector('[data-testid="export-email-input"]');b==null||b.focus()},children:[y.jsxs(Dh,{children:[y.jsx(_h,{children:"Export to seeflow.dev"}),y.jsx(Hh,{children:"Upload this diagram to the cloud and get a shareable link."})]}),h.kind!=="done"?y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex flex-col gap-4",children:[y.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[y.jsx("span",{className:"font-medium",children:"Email"}),y.jsx("input",{type:"email",required:!0,autoComplete:"email",value:o,onChange:x=>i(x.target.value),disabled:g,"data-testid":"export-email-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"}),y.jsx("span",{className:"text-xs text-muted-foreground",children:"We'll use this to let you manage your flows in the future."})]}),y.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[y.jsx("span",{className:"font-medium",children:"Flow Name"}),y.jsx("input",{type:"text",required:!0,value:a,onChange:x=>s(x.target.value),disabled:g,"data-testid":"export-name-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"})]}),y.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[y.jsx("span",{className:"font-medium",children:"Visibility"}),y.jsxs("select",{value:l,onChange:x=>c(x.target.value),disabled:g,"data-testid":"export-visibility-select",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",children:[y.jsx("option",{value:"public",children:"Public — anyone can discover it"}),y.jsx("option",{value:"link",children:"Anyone with the link"})]})]}),h.kind==="error"?y.jsx("div",{role:"alert","data-testid":"export-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:h.message}):null]}),y.jsx(Hu,{children:h.kind==="error"?y.jsxs(y.Fragment,{children:[y.jsx(Nt,{type:"button",variant:"ghost",onClick:()=>t(!1),"data-testid":"export-cancel",children:"Cancel"}),y.jsx(Nt,{type:"button",onClick:()=>d({kind:"idle"}),"data-testid":"export-retry",children:"Try again"})]}):y.jsxs(y.Fragment,{children:[y.jsx(Nt,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:g,"data-testid":"export-cancel",children:"Cancel"}),y.jsx(Nt,{type:"button",onClick:v,disabled:g||!M,"data-testid":"export-submit",children:g?y.jsxs(y.Fragment,{children:[y.jsx(Cr,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}),y.jsx("span",{children:"Uploading…"})]}):"Export"})]})})]}):y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex flex-col gap-3",children:[y.jsx("p",{className:"text-sm text-muted-foreground",children:"Your diagram is live. Share this link:"}),y.jsxs("div",{className:"flex gap-2",children:[y.jsx("input",{type:"text",readOnly:!0,value:h.shareUrl,"data-testid":"export-share-url",className:"min-w-0 flex-1 rounded-md border bg-muted px-3 py-2 text-sm outline-hidden"}),y.jsx(Nt,{type:"button",variant:"outline",size:"icon",onClick:w,"aria-label":"Copy link","data-testid":"export-copy",children:f?y.jsx(fo,{className:"h-4 w-4","aria-hidden":"true"}):y.jsx(ou,{className:"h-4 w-4","aria-hidden":"true"})}),y.jsx(Nt,{type:"button",variant:"outline",size:"icon",onClick:()=>window.open(h.shareUrl,"_blank"),"aria-label":"View in new tab","data-testid":"export-view",children:y.jsx(n2,{className:"h-4 w-4","aria-hidden":"true"})})]})]}),y.jsx(Hu,{children:y.jsx(Nt,{type:"button",onClick:()=>t(!1),"data-testid":"export-done",children:"Done"})})]})]})})}const X6e=(e,t)=>{if(e.has(t))return e;const n=new Set(e);return n.add(t),n},Y6e=(e,t)=>{if(t.length===0)return e;let n=!1;const r=new Set(e);for(const o of t)r.has(o)||(r.add(o),n=!0);return n?r:e},Q6e=(e,t)=>{if(!e.has(t))return e;const n=new Set(e);return n.delete(t),n},J6e=(e,t)=>{if(t.length===0)return e;let n=!1;const r=new Set(e);for(const o of t)r.has(o)&&(r.delete(o),n=!0);return n?r:e},e8e=(e,t)=>{if(e.size===0)return e;const n=new Set(t.map(i=>i.id));let r=!1;const o=new Set(e);for(const i of o)n.has(i)||(o.delete(i),r=!0);return r?o:e},TB=()=>{const[e,t]=m.useState(()=>new Set),n=m.useCallback(l=>{t(c=>X6e(c,l))},[]),r=m.useCallback(l=>{t(c=>Y6e(c,l))},[]),o=m.useCallback(l=>{t(c=>Q6e(c,l))},[]),i=m.useCallback(l=>{t(c=>J6e(c,l))},[]),a=m.useCallback(l=>{t(c=>e8e(c,l))},[]),s=m.useCallback(()=>t(new Set),[]);return{ids:e,mark:n,markMany:r,unmark:o,unmarkMany:i,pruneAgainst:a,reset:s}},t8e=(e,t)=>e===t?!0:e==null||t==null||typeof e!=typeof t||typeof e!="object"?!1:JSON.stringify(e)===JSON.stringify(t),n8e=(e,t,n)=>({...e,[t]:{...e[t],...n}}),r8e=(e,t)=>{if(!(t in e))return e;const n={...e};return delete n[t],n},o8e=(e,t)=>{const n=Object.entries(e);if(n.length===0)return e;const r=new Map(t.map(a=>[a.id,a]));let o=!1;const i={...e};for(const[a,s]of n){const l=r.get(a);if(!l)continue;const c={};let h=!1;for(const d of Object.keys(s))t8e(s[d],l[d])?o=!0:(c[d]=s[d],h=!0);h?i[a]=c:(o=!0,delete i[a])}return o?i:e},NB=()=>{const[e,t]=m.useState({}),n=m.useCallback((a,s)=>{t(l=>n8e(l,a,s))},[]),r=m.useCallback(a=>{t(s=>r8e(s,a))},[]),o=m.useCallback(a=>{t(s=>o8e(s,a))},[]),i=m.useCallback(()=>t({}),[]);return{overrides:e,setOverride:n,dropOverride:r,pruneAgainst:o,reset:i}},i8e=500,a8e=500,s8e={stack:[],cursor:0},l8e=(e,t,n)=>{const r=Date.now(),o=i8e,i=a8e,{stack:a,cursor:s}=e;if(t.coalesceKey&&s>0){const h=a[s-1];if(h&&h.coalesceKey===t.coalesceKey&&r-h.capturedAt<=i){const d=a.slice(0,s);return d[s-1]={...h,do:t.do,capturedAt:r},{stack:d,cursor:s}}}const l=a.slice(0,s);l.push({...t,capturedAt:r});let c=s+1;for(;l.length>o;)l.shift(),c-=1;return c<0&&(c=0),{stack:l,cursor:c}},c8e=e=>e.cursor===0?{state:e,entry:void 0}:{state:{...e,cursor:e.cursor-1},entry:e.stack[e.cursor-1]},u8e=e=>e.cursor===e.stack.length?{state:e,entry:void 0}:{state:{...e,cursor:e.cursor+1},entry:e.stack[e.cursor]},d8e=()=>({stack:[],cursor:0}),h8e=e=>{if(e.cursor===0)return e;const t=e.stack.slice();return t.splice(e.cursor-1,1),{stack:t,cursor:e.cursor-1}},f8e=(e,t)=>t.state,p8e=()=>{const[e,t]=m.useReducer(f8e,s8e),n=m.useRef(e);n.current=e;const r=m.useRef(Promise.resolve()),o=m.useRef(0),i=m.useCallback(p=>{p!==n.current&&(n.current=p,t({type:"replace",state:p}))},[]),a=m.useCallback(p=>{const k={do:p.do,undo:p.undo,coalesceKey:p.coalesceKey,capturedAt:p.capturedAt??Date.now()};i(l8e(n.current,k))},[i]),s=m.useCallback(()=>{o.current=Date.now();const p=r.current.then(()=>{const k=c8e(n.current);if(k.entry)return i(k.state),{entry:k.entry}});return r.current=p.then(()=>{},()=>{}),p},[i]),l=m.useCallback(()=>{o.current=Date.now();const p=r.current.then(()=>{const k=u8e(n.current);if(k.entry)return i(k.state),{entry:k.entry}});return r.current=p.then(()=>{},()=>{}),p},[i]),c=m.useCallback(()=>{i(d8e())},[i]),h=m.useCallback(()=>{i(h8e(n.current))},[i]),d=m.useCallback(()=>{o.current=Date.now()},[]),f=m.useCallback(()=>o.current,[]);return{push:a,undo:s,redo:l,clear:c,dropTop:h,canUndo:e.cursor>0,canRedo:e.cursor<e.stack.length,markMutation:d,lastMutationAt:f}};function y8e({nodes:e,connectors:t,flowPos:n,nodeIdGen:r,connectorIdGen:o,defaultOffset:i={x:24,y:24}}){const a=new Map;for(const p of e)a.set(p.id,r(p.id));let s=Number.POSITIVE_INFINITY,l=Number.POSITIVE_INFINITY;for(const p of e)p.position.x<s&&(s=p.position.x),p.position.y<l&&(l=p.position.y);Number.isFinite(s)||(s=0),Number.isFinite(l)||(l=0);const c=n?n.x-s:i.x,h=n?n.y-l:i.y,d=e.map(p=>{const k=a.get(p.id);if(k===void 0)throw new Error(`paste id missing for ${p.id}`);return{...p,id:k,position:{x:p.position.x+c,y:p.position.y+h}}}),f=t.map(p=>{const k=o(p.id);return{...p,id:k,source:a.get(p.source)??p.source,target:a.get(p.target)??p.target}});return{newNodes:d,newConnectors:f,idMap:a}}const m8e=e=>({type:"imageNode",position:e.position,data:{path:"",alt:e.originalFilename,width:e.dims.width,height:e.dims.height,_uploading:!0}}),k8e=e=>({type:"imageNode",data:gJ(e)}),g8e=e=>({type:"imageNode",position:e.position,data:{path:"",alt:e.originalFilename,width:e.dims.width,height:e.dims.height,_uploadError:e.message}}),gJ=e=>({...zue(e.path,e.dims,e.lastUsed),alt:e.originalFilename}),x8e=async(e,t)=>{const{nodeId:n,flowId:r,file:o,originalFilename:i,position:a,dims:s,lastUsed:l}=e;t.rememberRetry(n,{file:o,originalFilename:i,position:a,dims:s}),t.setOverride(n,m8e({position:a,dims:s,originalFilename:i}));let c;try{c=(await t.upload(r,n,o,i)).path}catch(p){const k=p instanceof Error?p.message:String(p);throw t.setOverride(n,g8e({position:a,dims:s,originalFilename:i,message:k})),p}t.setOverride(n,k8e({path:c,dims:s,originalFilename:i,lastUsed:l}));const h=gJ({path:c,dims:s,originalFilename:i,lastUsed:l}),d={id:n,type:"imageNode",position:a,data:h},{id:f}=await t.createNode(r,d);t.forgetRetry(n),t.pushUndo&&t.pushUndo({do:async()=>{await t.createNode(r,{...d,id:f})},undo:async()=>{await t.deleteNode(r,f)}})},v8e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",w8e=248;function No(e=10){let t="";const n=new Uint8Array(e*2);for(;t.length<e;){crypto.getRandomValues(n);for(let r=0;r<n.length&&t.length<e;r++){const o=n[r];o<w8e&&(t+=v8e[o%62])}}return t}const M8e=new Set(["INPUT","TEXTAREA","SELECT"]),xr=e=>e?M8e.has(e.tagName)?!0:e instanceof HTMLElement&&e.isContentEditable:!1,b8e=(e,t,n)=>{const r=e.indexOf(t);if(r<0)return null;const o=e.length,i=[...e];switch(n.op){case"forward":{if(r>=o-1)return null;const a=i[r],s=i[r+1];return a===void 0||s===void 0?null:(i[r]=s,i[r+1]=a,i)}case"backward":{if(r<=0)return null;const a=i[r],s=i[r-1];return a===void 0||s===void 0?null:(i[r]=s,i[r-1]=a,i)}case"toFront":{if(r===o-1)return null;const[a]=i.splice(r,1);return a===void 0?null:(i.push(a),i)}case"toBack":{if(r===0)return null;const[a]=i.splice(r,1);return a===void 0?null:(i.unshift(a),i)}case"toIndex":{const a=Math.min(Math.max(n.index,0),o-1);if(a===r)return null;const[s]=i.splice(r,1);return s===void 0?null:(i.splice(a,0,s),i)}}};function C8e({slug:e,demos:t,detail:n,loading:r,runs:o,nodeEvents:i,statusByNode:a,onPlayNode:s,onRestartDemo:l}){var ad,sd;const c=t.find(F=>F.slug===e),[h,d]=m.useState([]),[f,p]=m.useState([]),[k,v]=m.useState(null),w=m.useRef(h),g=m.useRef(f);m.useEffect(()=>{w.current=h},[h]),m.useEffect(()=>{g.current=f},[f]);const M=m.useRef(null),x=m.useRef(null),b=m.useRef(null),S=NB(),C=NB(),L=TB(),P=TB(),[T,E]=m.useState(null),[z,A]=m.useState(null),[U,R]=m.useState(null),V=m.useRef(null);m.useEffect(()=>{V.current=U},[U]);const[O,B]=m.useState(!1),[D,N]=m.useState(0),I=m.useRef(null),W=m.useRef(null),H=m.useCallback(F=>{W.current=F},[]),j=p8e(),{push:G,dropTop:X,markMutation:Y,clear:re,lastMutationAt:ne}=j,{reset:ae}=S,{reset:ve}=C,{reset:be}=L,{reset:me}=P;m.useEffect(()=>{d([]),p([]),v(null),ae(),ve(),be(),me(),E(null),A(null),Br.current=null,So(!1),mr.current.clear(),j.clear()},[n==null?void 0:n.id]);const ge=m.useCallback((F,q)=>{d(F),p(q)},[]),ee=(ad=n==null?void 0:n.flow)==null?void 0:ad.nodes,ke=(sd=n==null?void 0:n.flow)==null?void 0:sd.connectors,{pruneAgainst:Fe}=S,{pruneAgainst:rt}=C,{pruneAgainst:mt}=L,{pruneAgainst:ht}=P;m.useEffect(()=>{ee&&(Fe(ee),mt(ee)),Date.now()-ne()>2e3&&re()},[ee,Fe,mt,ne,re]),m.useEffect(()=>{if(!ee)return;const F=I.current,q=new Set(ee.map(oe=>oe.id));if(I.current=q,F===null)return;const Z=S.overrides,$=L.ids;let _=!1;for(const oe of q)if(!F.has(oe)&&!(oe in Z)){_=!0;break}if(!_){for(const oe of F)if(!q.has(oe)&&!$.has(oe)){_=!0;break}}_&&N(oe=>oe+1)},[ee]),m.useEffect(()=>{ke&&(rt(ke),ht(ke)),Date.now()-ne()>2e3&&re()},[ke,rt,ht,ne,re]),m.useEffect(()=>{if(!(!ee||!T)&&ee.length===T.length){for(let F=0;F<ee.length;F++){const q=ee[F],Z=T[F];if(!q||q.id!==Z)return}E(null)}},[ee,T]);const le=(n==null?void 0:n.id)??null,Q=m.useMemo(()=>le?jue({baseUrl:"",flowId:le}):null,[le]),[fe,we]=m.useState(!1),{setOverride:Se,dropOverride:Oe}=S,te=m.useRef(S.overrides);m.useEffect(()=>{te.current=S.overrides},[S.overrides]);const de=m.useCallback((F,q)=>{var $;if(!le||!Q)return;const Z=($=ee==null?void 0:ee.find(_=>_.id===F))==null?void 0:$.position;Se(F,{position:q}),A(null),Y(),Z&&G({do:async()=>{await Q.updateNodePosition(F,q)},undo:async()=>{await Q.updateNodePosition(F,Z)},coalesceKey:`node:${F}:position`}),Q.updateNodePosition(F,q).catch(_=>{Oe(F),Z&&X(),A(_ instanceof Error?_.message:String(_)),console.error("updateNodePosition failed",_)})},[le,Q,ee,Se,Oe,G,X,Y]),Pe=m.useCallback(F=>{if(!le||!Q||F.length===0)return;const q=te.current,Z=F.map($=>{var Ae;const _=ee==null?void 0:ee.find(Me=>Me.id===$.id);if(!_)return null;const oe=((Ae=q[$.id])==null?void 0:Ae.position)??_.position;return{id:$.id,prev:oe,next:$.position}}).filter($=>$!==null);if(Z.length!==0){for(const $ of Z)Se($.id,{position:$.next});A(null),Y(),G({do:async()=>{await Promise.allSettled(Z.map($=>Q.updateNodePosition($.id,$.next)))},undo:async()=>{await Promise.allSettled(Z.map($=>Q.updateNodePosition($.id,$.prev)))}}),Promise.all(Z.map(async $=>{try{return await Q.updateNodePosition($.id,$.next),null}catch(_){return Oe($.id),_ instanceof Error?_.message:String(_)}})).then($=>{const _=$.find(oe=>oe!==null);_&&A(_)})}},[le,Q,ee,Se,Oe,G,Y]),qe=m.useCallback((F,q)=>{Se(F,{position:{x:q.x,y:q.y},data:{width:q.width,height:q.height}})},[Se]),We=m.useCallback((F,q)=>{if(!le||!Q)return;const Z=ee==null?void 0:ee.find(oe=>oe.id===F),$=Z?{width:Z.data.width,height:Z.data.height,position:{x:Z.position.x,y:Z.position.y}}:void 0,_={width:q.width,height:q.height,position:{x:q.x,y:q.y}};Se(F,{position:_.position,data:{width:_.width,height:_.height}}),A(null),Y(),$&&G({do:async()=>{await Q.updateNode(F,_)},undo:async()=>{await Q.updateNode(F,$)},coalesceKey:`node:${F}:resize`}),Q.updateNode(F,_).catch(oe=>{Oe(F),$&&X(),A(oe instanceof Error?oe.message:String(oe)),console.error("updateNode resize failed",oe)})},[le,Q,ee,Se,Oe,G,X,Y]),Rt=m.useCallback(F=>{if(!le||!Q)return;const q=ee==null?void 0:ee.find(_=>_.id===F);if(!q)return;const Z={autoSize:q.data.autoSize,width:q.data.width,height:q.data.height},$={autoSize:!0};Se(F,{data:{autoSize:!0,width:void 0,height:void 0}}),A(null),Y(),G({do:async()=>{await Q.updateNode(F,$)},undo:async()=>{await Q.updateNode(F,Z)},coalesceKey:`node:${F}:fit-to-content`}),Q.updateNode(F,$).catch(_=>{Oe(F),X(),A(_ instanceof Error?_.message:String(_)),console.error("updateNode (fit-to-content) failed",_)})},[le,Q,ee,Se,Oe,G,X,Y]),st=m.useCallback(F=>{if(!le||!Q||F.length===0)return;const q=[];for(const $ of F){const _=ee==null?void 0:ee.find(Ue=>Ue.id===$.id);if(!_)continue;const oe=_.data,Ae={position:{x:_.position.x,y:_.position.y}};oe.width!==void 0&&(Ae.width=oe.width),oe.height!==void 0&&(Ae.height=oe.height);const Me={position:$.position};$.width!==void 0&&(Me.width=$.width),$.height!==void 0&&(Me.height=$.height),q.push({id:$.id,prev:Ae,next:Me})}if(q.length===0)return;for(const $ of q){const _={};$.next.width!==void 0&&(_.width=$.next.width),$.next.height!==void 0&&(_.height=$.next.height),Se($.id,{position:$.next.position,...Object.keys(_).length>0?{data:_}:{}})}A(null),Y();const Z=q.map($=>$.id).sort();G({do:async()=>{await Promise.allSettled(q.map($=>Q.updateNode($.id,$.next)))},undo:async()=>{await Promise.allSettled(q.map($=>Q.updateNode($.id,$.prev)))},coalesceKey:`multi:resize:${Z.join(",")}`}),Promise.all(q.map(async $=>{try{return await Q.updateNode($.id,$.next),null}catch(_){return Oe($.id),_ instanceof Error?_.message:String(_)}})).then($=>{const _=$.find(oe=>oe!==null);_&&A(_)})},[le,Q,ee,Se,Oe,G,Y]),{setOverride:Ne,dropOverride:ot}=C,Jn=m.useCallback((F,q)=>{Se(F,{data:q})},[Se]),zt=m.useCallback((F,q)=>{for(const Z of F)Se(Z,{data:q})},[Se]),zn=m.useCallback((F,q)=>{Ne(F,q)},[Ne]),Kt=m.useCallback((F,q)=>{if(!le||!Q)return;aq(aa,q);const Z=ee==null?void 0:ee.find(_=>_.id===F);let $=null;if(Z){$={};const _=Z.data;for(const oe of Object.keys(q))$[oe]=_[oe]}if(Se(F,{data:q}),A(null),Y(),$){const _=$;G({do:async()=>{await Q.updateNode(F,q)},undo:async()=>{await Q.updateNode(F,_)},coalesceKey:`node:${F}:style`})}Q.updateNode(F,q).catch(_=>{Oe(F),$&&X(),A(_ instanceof Error?_.message:String(_)),console.error("updateNode style failed",_)})},[le,Q,ee,Se,Oe,G,X,Y]),p1=m.useCallback((F,q)=>{if(!le||!Q||F.length===0)return;aq(aa,q);const Z=F.map($=>{const _=ee==null?void 0:ee.find(Me=>Me.id===$);if(!_)return null;const oe=_.data,Ae={};for(const Me of Object.keys(q))Ae[Me]=oe[Me];return{id:$,prev:Ae}}).filter($=>$!==null);if(Z.length!==0){for(const $ of Z)Se($.id,{data:q});A(null),Y(),G({do:async()=>{await Promise.allSettled(Z.map($=>Q.updateNode($.id,q)))},undo:async()=>{await Promise.allSettled(Z.map($=>Q.updateNode($.id,$.prev)))}}),Promise.all(Z.map(async $=>{try{return await Q.updateNode($.id,q),null}catch(_){return Oe($.id),_ instanceof Error?_.message:String(_)}})).then($=>{const _=$.find(oe=>oe!==null);_&&A(_)})}},[le,Q,ee,Se,Oe,G,Y]),y1=m.useCallback((F,q)=>{if(!le||!Q)return;Iue(aa,q);const Z=ke==null?void 0:ke.find(_=>_.id===F);let $=null;if(Z){$={};const _=Z;for(const oe of Object.keys(q))$[oe]=_[oe]}if(Ne(F,q),A(null),Y(),$){const _=$;G({do:async()=>{await Q.updateConnector(F,q)},undo:async()=>{await Q.updateConnector(F,_)},coalesceKey:`connector:${F}:style`})}Q.updateConnector(F,q).catch(_=>{ot(F),$&&X(),A(_ instanceof Error?_.message:String(_)),console.error("updateConnector failed",_)})},[le,Q,ke,Ne,ot,G,X,Y]),{mark:Jo,markMany:ei,unmark:_r,unmarkMany:Ki}=L,{mark:ti,markMany:fr,unmark:Hr,unmarkMany:pr}=P,m1=m.useCallback(F=>{if(!le||!Q)return;const q=ee==null?void 0:ee.find(Me=>Me.id===F);if(!q)return;const Z=(ke??[]).filter(Me=>Me.source===F||Me.target===F),$=Z.map(Me=>Me.id),_=new Set($);A(null),Jo(F),$.length>0&&fr($),d(Me=>Me.filter(Ue=>Ue!==F)),p(Me=>Me.filter(Ue=>!_.has(Ue))),Y();const oe=q,Ae=Z;G({do:async()=>{Jo(F),$.length>0&&fr($),await Q.deleteNode(F)},undo:async()=>{_r(F),$.length>0&&pr($),await Q.createNode({id:oe.id,type:oe.type,position:oe.position,data:oe.data});for(const Me of Ae)await Q.createConnector({...Me,id:Me.id})}}),Q.deleteNode(F).catch(Me=>{_r(F),$.length>0&&pr($),X(),A(Me instanceof Error?Me.message:String(Me)),console.error("deleteNode failed",Me)})},[le,Q,ee,ke,Jo,fr,_r,pr,G,X,Y]),k1=m.useCallback((F,q)=>{if(!le||!Q||!ee)return;const Z=T??ee.map(oe=>oe.id),$=b8e(Z,F,q);if(!$)return;const _=Z.indexOf(F);E($),A(null),Y(),G({do:async()=>{await Q.reorderNode(F,q)},undo:async()=>{await Q.reorderNode(F,{op:"toIndex",index:_})}}),Q.reorderNode(F,q).catch(oe=>{E(null),X(),A(oe instanceof Error?oe.message:String(oe)),console.error("reorderNode failed",oe)})},[le,Q,ee,T,G,X,Y]);m.useCallback(F=>{if(!le||!Q)return;const q=ke==null?void 0:ke.find($=>$.id===F);if(!q)return;A(null),ti(F),p($=>$.filter(_=>_!==F)),Y();const Z=q;G({do:async()=>{ti(F),await Q.deleteConnector(F)},undo:async()=>{Hr(F),await Q.createConnector({...Z,id:Z.id})}}),Q.deleteConnector(F).catch($=>{Hr(F),X(),A($ instanceof Error?$.message:String($)),console.error("deleteConnector failed",$)})},[le,Q,ke,ti,Hr,G,X,Y]);const He=m.useCallback((F,q)=>{if(!le||!Q||F.length===0&&q.length===0)return;const Z=new Set(F),$=F.map(ze=>ee==null?void 0:ee.find(it=>it.id===ze)).filter(ze=>!!ze),_=(ke??[]).filter(ze=>Z.has(ze.source)||Z.has(ze.target)),oe=new Set(_.map(ze=>ze.id)),Ae=q.map(ze=>ke==null?void 0:ke.find(it=>it.id===ze)).filter(ze=>!!ze).filter(ze=>!oe.has(ze.id));if($.length===0&&_.length===0&&Ae.length===0)return;A(null);const Me=$.map(ze=>ze.id),Ue=[..._.map(ze=>ze.id),...Ae.map(ze=>ze.id)];Me.length>0&&ei(Me),Ue.length>0&&fr(Ue);const Ut=$;d(ze=>ze.filter(it=>!Z.has(it)));const Eo=new Set(Ae.map(ze=>ze.id));p(ze=>ze.filter(it=>!Eo.has(it)&&!oe.has(it))),Y(),G({do:async()=>{Me.length>0&&ei(Me),Ue.length>0&&fr(Ue);for(const ze of Ut)await Q.deleteNode(ze.id).catch(()=>{});await Promise.allSettled(Ae.map(ze=>Q.deleteConnector(ze.id)))},undo:async()=>{Me.length>0&&Ki(Me),Ue.length>0&&pr(Ue);for(let ze=Ut.length-1;ze>=0;ze--){const it=Ut[ze];it&&await Q.createNode({id:it.id,type:it.type,position:it.position,data:it.data})}for(const ze of[..._,...Ae])await Q.createConnector({...ze,id:ze.id})}});const Dn=new Map;for(const ze of $)Dn.set(ze.id,_.filter(it=>it.source===ze.id||it.target===ze.id).map(it=>it.id));(async()=>{const ze=[];for(const Yt of Ut)try{await Q.deleteNode(Yt.id)}catch(gn){_r(Yt.id);const na=Dn.get(Yt.id)??[];na.length>0&&pr(na),ze.push(gn instanceof Error?gn.message:String(gn))}const it=await Promise.all(Ae.map(async Yt=>{try{return await Q.deleteConnector(Yt.id),null}catch(gn){return Hr(Yt.id),gn instanceof Error?gn.message:String(gn)}}));for(const Yt of it)Yt!==null&&ze.push(Yt);ze.length>0&&ze[0]!==void 0&&A(ze[0])})()},[le,Q,ee,ke,ei,fr,_r,Ki,Hr,pr,G,Y]);m.useEffect(()=>{M.current=He},[He]),m.useEffect(()=>{const F=q=>{if(q.key!=="Delete"&&q.key!=="Backspace"||xr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=w.current,$=g.current;Z.length===0&&$.length===0||(q.preventDefault(),He(Z,$))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[He]);const{undo:Mt,redo:Fr,canUndo:Or,canRedo:jn}=j;m.useEffect(()=>{const F=async q=>{if((q.metaKey||q.ctrlKey)&&q.key.toLowerCase()==="z"&&!xr(document.activeElement)){if(q.preventDefault(),q.shiftKey){if(!jn)return;try{const Z=await Fr();Z!=null&&Z.entry&&await Z.entry.do()}catch(Z){A(Z instanceof Error?Z.message:String(Z)),console.error("redo failed",Z)}return}if(Or)try{const Z=await Mt();Z!=null&&Z.entry&&await Z.entry.undo()}catch(Z){A(Z instanceof Error?Z.message:String(Z)),console.error("undo failed",Z)}}};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[Mt,Fr,Or,jn]);const yr=m.useCallback((F,q)=>{if(!le||!Q)return;const Z=ee==null?void 0:ee.find(oe=>oe.id===F),_=(Z&&"name"in Z.data?Z.data.name:void 0)??"";Se(F,{data:{name:q}}),A(null),Y(),Z&&G({do:async()=>{await Q.updateNode(F,{name:q})},undo:async()=>{await Q.updateNode(F,{name:_})},coalesceKey:`node:${F}:name`}),Q.updateNode(F,{name:q}).catch(oe=>{Z&&X(),A(oe instanceof Error?oe.message:String(oe)),console.error("updateNode name failed",oe)})},[le,Q,ee,Se,G,X,Y]),Mo=m.useCallback((F,q)=>{if(!le||!Q)return;const Z=ee==null?void 0:ee.find(_=>_.id===F);if(!Z)return;const $=Z.data.description??"";Se(F,{data:{description:q}}),A(null),Y(),G({do:async()=>{await Q.updateNode(F,{description:q})},undo:async()=>{await Q.updateNode(F,{description:$})},coalesceKey:`node:${F}:description`}),Q.updateNode(F,{description:q}).catch(_=>{X(),A(_ instanceof Error?_.message:String(_)),console.error("updateNode description failed",_)})},[le,Q,ee,Se,G,X,Y]),er=m.useCallback((F,q)=>{if(!le||!Q)return;const Z=ee==null?void 0:ee.find(_=>_.id===F);if(!Z)return;const $=Z.data.detail??"";Se(F,{data:{detail:q}}),A(null),Y(),G({do:async()=>{await Q.updateNode(F,{detail:q})},undo:async()=>{await Q.updateNode(F,{detail:$})},coalesceKey:`node:${F}:detail`}),Q.updateNode(F,{detail:q}).catch(_=>{X(),A(_ instanceof Error?_.message:String(_)),console.error("updateNode detail failed",_)})},[le,Q,ee,Se,G,X,Y]),qr=m.useCallback((F,q)=>{if(!le||!Q)return;const Z=ee==null?void 0:ee.find(_=>_.id===F);if(!Z)return;const $="icon"in Z.data?Z.data.icon??null:null;Se(F,{data:{icon:q??void 0}}),A(null),Y(),G({do:async()=>{await Q.updateNode(F,{icon:q})},undo:async()=>{await Q.updateNode(F,{icon:$})},coalesceKey:`node:${F}:icon`}),Q.updateNode(F,{icon:q}).catch(_=>{X(),A(_ instanceof Error?_.message:String(_)),console.error("updateNode icon failed",_)})},[le,Q,ee,Se,G,X,Y]),an=m.useCallback((F,q,Z)=>{if(!le||!Q)return;A(null);const $=`node-${No()}`,_=lq(F,Z,P0(aa).node),oe={id:$,type:"shapeNode",position:q,data:_};Se($,{id:$,type:"shapeNode",position:q,data:_}),Y(),Q.createNode(oe).then(({id:Me})=>{G({do:async()=>{await Q.createNode({...oe,id:Me})},undo:async()=>{await Q.deleteNode(Me)}})}).catch(Me=>{Oe($),A(Me instanceof Error?Me.message:String(Me)),console.error("createNode failed",Me)})},[le,Q,Se,Oe,G,Y]),jt=m.useCallback((F,q)=>{if(!le||!Q)return;A(null);const Z=`node-${No()}`,$={icon:F,width:Tu.width,height:Tu.height},_={id:Z,type:"iconNode",position:q,data:$};Se(Z,{id:Z,type:"iconNode",position:q,data:$}),d([Z]),Y(),Q.createNode(_).then(({id:Ae})=>{G({do:async()=>{await Q.createNode({..._,id:Ae})},undo:async()=>{await Q.deleteNode(Ae)}})}).catch(Ae=>{Oe(Z),A(Ae instanceof Error?Ae.message:String(Ae)),console.error("createNode (icon) failed",Ae)})},[le,Q,Se,Oe,G,Y]),bo=m.useCallback(F=>{if(!le||!Q)return;A(null);const q=`node-${No()}`,Z={id:q,type:"htmlNode",position:F.position,data:{}},$={id:q,type:"htmlNode",position:F.position,data:{}};Se(q,$),d([q]),Y(),Q.createNode(Z).then(({id:_})=>{G({do:async()=>{await Q.createNode({...Z,id:_})},undo:async()=>{await Q.deleteNode(_)}})}).catch(_=>{Oe(q),A(_ instanceof Error?_.message:String(_)),console.error("createNode (htmlNode) failed",_)})},[le,Q,Se,Oe,G,Y]),mr=m.useRef(new Map),Xi=m.useCallback((F,q)=>{mr.current.set(F,q)},[]),Yi=m.useCallback(F=>{mr.current.delete(F)},[]),Co=m.useCallback(F=>{!le||!Q||(A(null),Y(),x8e({...F,flowId:le,lastUsed:P0(aa).node},{upload:(q,Z,$,_)=>Q.uploadImage(Z,$,_),createNode:async(q,Z)=>{const{id:$}=await Q.createNode(Z);return{id:$}},deleteNode:async(q,Z)=>(await Q.deleteNode(Z),{ok:!0}),setOverride:Se,pushUndo:G,rememberRetry:Xi,forgetRetry:Yi}).catch(q=>{console.error("image-upload-flow failed",q)}))},[le,Q,Se,G,Y,Xi,Yi]),Ct=m.useCallback(F=>{if(!le||!Q)return;const q=`node-${No()}`;Co({nodeId:q,...F})},[le,Q,Co]),Qi=m.useCallback(F=>{const q=mr.current.get(F);q&&Co({nodeId:F,...q})},[Co]),[Tn,ni]=m.useState({open:!1,mode:"insert"}),tr=m.useCallback((F,q)=>{ni({open:!0,mode:F,nodeId:q})},[]),kr=m.useCallback(()=>{ni(F=>({...F,open:!1}))},[]),g1=m.useCallback(()=>{tr("insert")},[tr]),Ji=m.useCallback(F=>tr("replace",F),[tr]),ea=m.useCallback(F=>{if(kue(F),Tn.mode==="replace"&&Tn.nodeId){if(le&&Q){const q=Tn.nodeId,Z=ee==null?void 0:ee.find(_=>_.id===q),$=(Z==null?void 0:Z.type)==="iconNode"?Z.data.icon:void 0;if(Se(q,{data:{icon:F}}),A(null),Y(),$!==void 0){const _=$;G({do:async()=>{await Q.updateNode(q,{icon:F})},undo:async()=>{await Q.updateNode(q,{icon:_})},coalesceKey:`node:${q}:icon`})}Q.updateNode(q,{icon:F}).catch(_=>{Oe(q),$!==void 0&&X(),A(_ instanceof Error?_.message:String(_)),console.error("updateNode (icon replace) failed",_)})}}else{const q=W.current;if(q&&le){const Z=yue(q,{width:window.innerWidth,height:window.innerHeight});jt(F,Z)}}kr()},[Tn.mode,Tn.nodeId,le,Q,ee,Se,Oe,G,X,Y,jt,kr]),ri=m.useCallback((F,q)=>{if(!le||!Q)return;const Z=ke==null?void 0:ke.find(_=>_.id===F),$=Z==null?void 0:Z.label;Ne(F,{label:q}),A(null),Y(),Z&&G({do:async()=>{await Q.updateConnector(F,{label:q})},undo:async()=>{await Q.updateConnector(F,{label:$})},coalesceKey:`connector:${F}:label`}),Q.updateConnector(F,{label:q}).catch(_=>{Z&&X(),A(_ instanceof Error?_.message:String(_)),console.error("updateConnector label failed",_)})},[le,Q,ke,Ne,G,X,Y]),mn=m.useCallback((F,q,Z)=>{if(!le||!Q)return;const $=`conn-${No()}`,_=Z==null?void 0:Z.targetPin,oe=P0(aa).connector,Ae={id:$,source:F,target:q,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,..._?{targetPin:_}:{},...oe,kind:"default"},Me={id:$,source:F,target:q,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,..._?{targetPin:_}:{},...oe,kind:"default"};Ne($,Ae),A(null),Y(),Q.createConnector(Me).then(({id:Ue})=>{G({do:async()=>{await Q.createConnector({...Me,id:Ue})},undo:async()=>{await Q.deleteConnector(Ue)}})}).catch(Ue=>{ot($),A(Ue instanceof Error?Ue.message:String(Ue)),console.error("createConnector failed",Ue)})},[le,Q,Ne,ot,G,Y]),Vr=m.useCallback(({sourceNodeId:F,position:q,shape:Z})=>{if(!le||!Q)return;A(null);const $=`node-${No()}`,_=`conn-${No()}`,oe=pR[Z],Ae=P0(aa),Me=lq(Z,oe,Ae.node),Ue={id:$,type:"shapeNode",position:q,data:Me},Ut={id:_,source:F,target:$,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...Ae.connector,kind:"default"};Se($,{id:$,type:"shapeNode",position:q,data:Me}),Ne(_,Ut),v($),Y(),(async()=>{try{await Q.createNode(Ue),await Q.createConnector(Ut),G({do:async()=>{await Q.createNode(Ue),await Q.createConnector(Ut)},undo:async()=>{ot(_),Oe($),await Q.deleteConnector(_).catch(()=>{}),await Q.deleteNode($).catch(()=>{})}})}catch(Dn){Oe($),ot(_),A(Dn instanceof Error?Dn.message:String(Dn)),console.error("createAndConnectFromPane failed",Dn)}})()},[le,Q,Se,Oe,Ne,ot,G,Y]),Br=m.useRef(null),[x1,So]=m.useState(!1),nr=m.useCallback(F=>{if(!ee)return;const q=new Set(F),Z=ee.filter(_=>q.has(_.id));if(Z.length===0)return;const $=(ke??[]).filter(_=>q.has(_.source)&&q.has(_.target));Br.current=JSON.parse(JSON.stringify({nodes:Z,connectors:$})),So(!0)},[ee,ke]),kn=m.useCallback(F=>{if(!le||!Q)return;const q=Br.current;if(!q||q.nodes.length===0)return;const{newNodes:Z,newConnectors:$}=y8e({nodes:q.nodes,connectors:q.connectors,flowPos:F,nodeIdGen:()=>`node-${No()}`,connectorIdGen:()=>`conn-${No()}`});for(const _ of Z)Se(_.id,_);for(const _ of $)Ne(_.id,_);d(Z.map(_=>_.id)),p($.map(_=>_.id)),A(null),Y(),(async()=>{try{for(const _ of Z)await Q.createNode({id:_.id,type:_.type,position:_.position,data:_.data});for(const _ of $)await Q.createConnector(_);G({do:async()=>{for(const _ of Z)await Q.createNode({id:_.id,type:_.type,position:_.position,data:_.data});for(const _ of $)await Q.createConnector(_)},undo:async()=>{await Promise.allSettled($.map(_=>Q.deleteConnector(_.id))),await Promise.allSettled(Z.map(_=>Q.deleteNode(_.id)))}})}catch(_){for(const oe of Z)Oe(oe.id);for(const oe of $)ot(oe.id);A(_ instanceof Error?_.message:String(_)),console.error("paste failed",_)}})()},[le,Q,Se,Oe,Ne,ot,Y,G]);m.useEffect(()=>{const F=q=>{const Z=Sue({event:q,isEditableActive:xr(document.activeElement),hasNodes:!!ee&&ee.length>0,hasConnectors:!!ke&&ke.length>0,selectedIds:w.current,hasClipboard:!!Br.current});if(Z.type!=="noop"&&!(Z.type==="copy"||Z.type==="paste")){if(q.preventDefault(),Z.type==="selectAll"){d((ee??[]).map($=>$.id)),p((ke??[]).map($=>$.id));return}nr([...Z.ids]),kn(null)}};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[ee,ke,nr,kn]),m.useEffect(()=>{const F=q=>{const Z=Mue(q);if(!Z||xr(document.activeElement))return;const $=w.current;if($.length===0)return;const _=S.overrides,oe=(ee??[]).map(Me=>{var Ut;const Ue=((Ut=_[Me.id])==null?void 0:Ut.position)??Me.position;return{id:Me.id,position:Ue}}),Ae=Cue(Z,$,oe);if(Ae.length!==0)if(q.preventDefault(),Ae.length===1){const Me=Ae[0];Me&&de(Me.id,Me.position)}else Pe(Ae)};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[ee,S.overrides,de,Pe]),m.useEffect(()=>{const F=q=>{const Z=bue(q);if(!Z||xr(document.activeElement))return;q.preventDefault();const $=W.current;$&&(Z==="fit"?$.fitView({padding:.2,duration:200}):Z==="in"?$.zoomIn({duration:150}):$.zoomOut({duration:150}))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]);const sn=m.useCallback(async F=>{if(!le||!Q||!ee||!Q.computeLayout)return;const q=S.overrides,Z=W.current,$=F==="selection"?new Set(w.current):null,_=$?ee.filter(De=>$.has(De.id)):ee;if(_.length<2)return;const oe=new Set(_.map(De=>De.id)),Ae=(ke??[]).filter(De=>oe.has(De.source)&&oe.has(De.target)),Me=new Map,Ue=_.map(De=>{var vn;const Qe=((vn=q[De.id])==null?void 0:vn.position)??De.position;Me.set(De.id,Qe);const Ht=Z==null?void 0:Z.getInternalNode(De.id),xn=Ht==null?void 0:Ht.measured,Ao=De.data,ra=(xn==null?void 0:xn.width)??Ao.width??200,ld=(xn==null?void 0:xn.height)??Ao.height??120;return{id:De.id,type:De.type,width:ra,height:ld}}),Ut=Ae.map(De=>({id:De.id,source:De.source,target:De.target})),Eo=await Q.computeLayout(Ue,Ut),Dn=new Map;for(const[De,Qe]of Object.entries(Eo.nodes))Dn.set(De,Qe.position);let ze=Number.POSITIVE_INFINITY,it=Number.POSITIVE_INFINITY,Yt=Number.POSITIVE_INFINITY,gn=Number.POSITIVE_INFINITY;for(const De of Ue){const Qe=Me.get(De.id);if(!Qe)continue;Qe.x<ze&&(ze=Qe.x),Qe.y<it&&(it=Qe.y);const Ht=Dn.get(De.id);Ht&&(Ht.x<Yt&&(Yt=Ht.x),Ht.y<gn&&(gn=Ht.y))}const na=Number.isFinite(ze)&&Number.isFinite(Yt)?ze-Yt:0,_z=Number.isFinite(it)&&Number.isFinite(gn)?it-gn:0,ai=[];for(const De of Ue){const Qe=Me.get(De.id),Ht=Dn.get(De.id);if(!Qe||!Ht)continue;const xn={x:Ht.x+na,y:Ht.y+_z},Ao=xn.x-Qe.x,ra=xn.y-Qe.y;Math.abs(Ao)<1&&Math.abs(ra)<1||ai.push({id:De.id,prev:Qe,next:xn})}if(ai.length!==0){A(null);for(const De of ai)Se(De.id,{position:De.next});Y(),G({do:async()=>{await Promise.allSettled(ai.map(De=>Q.updateNodePosition(De.id,De.next)))},undo:async()=>{await Promise.allSettled(ai.map(De=>Q.updateNodePosition(De.id,De.prev)))}}),Promise.all(ai.map(async De=>{try{return await Q.updateNodePosition(De.id,De.next),null}catch(Qe){return Oe(De.id),Qe instanceof Error?Qe.message:String(Qe)}})).then(De=>{const Qe=De.filter(xn=>xn!==null),Ht=Qe[0];Ht&&(A(Qe.length===1?Ht:`${Qe.length} node updates failed (first: ${Ht})`),console.error("Tidy: some updateNodePosition calls failed",Qe))})}},[le,Q,ee,ke,S.overrides,Se,Oe,G,Y]);m.useEffect(()=>{const F=q=>{if(!(q.metaKey||q.ctrlKey)||!q.shiftKey||q.altKey||q.key.toLowerCase()!=="l"||xr(document.activeElement))return;q.preventDefault();const Z=w.current.length>0?"selection":"all";sn(Z)};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[sn]);const oi=m.useCallback(()=>{const F=w.current.length>0?"selection":"all";sn(F)},[sn]);m.useEffect(()=>{const F=q=>{if(xr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=Lue(q);if(Z===null)return;const $=Z==="select"?null:Z;if(V.current===$){R(null);return}R($)};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]),m.useEffect(()=>{const F=q=>{q.key==="Escape"&&(xr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]')||(w.current.length>0&&d([]),g.current.length>0&&p([]),V.current!==null&&R(null)))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]),m.useEffect(()=>{const F=q=>{if(q.key.toLowerCase()!=="f"||q.metaKey||q.ctrlKey||q.shiftKey||q.altKey||xr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=w.current;if(Z.length===0)return;const $=W.current;$&&$.fitView({nodes:Z.map(_=>({id:_})),padding:.2,duration:200})};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]),m.useEffect(()=>{const F=q=>{if(q.key!=="1"||q.metaKey||q.ctrlKey||q.shiftKey||q.altKey||xr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=W.current;if(!Z)return;const{x:$,y:_}=Z.getViewport();Z.setViewport({x:$,y:_,zoom:1},{duration:150})};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]);const rr=m.useCallback(F=>{var q,Z,$;switch(F){case"tool.select":R(null);return;case"tool.rectangle":R("rectangle");return;case"tool.ellipse":R("ellipse");return;case"tool.text":R("text");return;case"tool.sticky":R("sticky");return;case"tool.database":R("database");return;case"edit.undo":{if(!Or)return;(async()=>{try{const _=await Mt();_!=null&&_.entry&&await _.entry.undo()}catch(_){A(_ instanceof Error?_.message:String(_)),console.error("undo failed",_)}})();return}case"edit.redo":{if(!jn)return;(async()=>{try{const _=await Fr();_!=null&&_.entry&&await _.entry.do()}catch(_){A(_ instanceof Error?_.message:String(_)),console.error("redo failed",_)}})();return}case"edit.copy":{const _=w.current;if(_.length===0)return;nr([..._]);return}case"edit.paste":kn(null);return;case"edit.duplicate":{const _=w.current;if(_.length===0)return;nr([..._]),kn(null);return}case"edit.delete":{const _=w.current,oe=g.current;if(_.length===0&&oe.length===0)return;He([..._],[...oe]);return}case"edit.selectAll":d((ee??[]).map(_=>_.id)),p((ke??[]).map(_=>_.id));return;case"view.fit":{const _=W.current;if(!_)return;_.fitView({padding:.2,duration:200});return}case"view.zoomIn":{const _=W.current;if(!_)return;_.zoomIn({duration:150});return}case"view.zoomOut":{const _=W.current;if(!_)return;_.zoomOut({duration:150});return}case"view.zoom100":{const _=W.current;if(!_)return;const{x:oe,y:Ae}=_.getViewport();_.setViewport({x:oe,y:Ae,zoom:1},{duration:150});return}case"view.zoomToSelection":{const _=w.current;if(_.length===0)return;const oe=W.current;if(!oe)return;oe.fitView({nodes:_.map(Ae=>({id:Ae})),padding:.2,duration:200});return}case"layout.tidy":{const _=w.current.length>0?"selection":"all";sn(_);return}case"selection.deselect":w.current.length>0&&d([]),g.current.length>0&&p([]),V.current!==null&&R(null);return;case"help.commandPalette":B(!0);return;case"export.pdf":{(q=b.current)==null||q.exportPdf();return}case"export.png":{(Z=b.current)==null||Z.exportPng();return}case"session.reset":{($=x.current)==null||$.call(x);return}}},[Or,jn,Mt,Fr,nr,kn,He,ee,ke,sn]);m.useEffect(()=>{const F=q=>{(q.metaKey||q.ctrlKey)&&(q.shiftKey||q.altKey||q.key.toLowerCase()==="p"&&(q.preventDefault(),!xr(document.activeElement)&&rr("help.commandPalette")))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[rr]),m.useEffect(()=>{x.current=l??null},[l]);const $r=m.useCallback((F,q)=>{if(!le||!Q)return;const Z=ke==null?void 0:ke.find(oe=>oe.id===F),$=Z?{source:Z.source,target:Z.target,sourceHandle:Z.sourceHandle,targetHandle:Z.targetHandle,sourceHandleAutoPicked:Z.sourceHandleAutoPicked,targetHandleAutoPicked:Z.targetHandleAutoPicked,sourcePin:Z.sourcePin??null,targetPin:Z.targetPin??null}:null,_={...q.source!==void 0?{source:q.source}:{},...q.target!==void 0?{target:q.target}:{},...q.sourceHandle!==void 0?{sourceHandle:q.sourceHandle===null?void 0:q.sourceHandle}:{},...q.targetHandle!==void 0?{targetHandle:q.targetHandle===null?void 0:q.targetHandle}:{},...q.sourceHandleAutoPicked!==void 0?{sourceHandleAutoPicked:q.sourceHandleAutoPicked}:{},...q.targetHandleAutoPicked!==void 0?{targetHandleAutoPicked:q.targetHandleAutoPicked}:{},...q.sourcePin!==void 0?{sourcePin:q.sourcePin===null?void 0:q.sourcePin}:{},...q.targetPin!==void 0?{targetPin:q.targetPin===null?void 0:q.targetPin}:{}};if(Ne(F,_),A(null),Y(),$){const oe=$;G({do:async()=>{await Q.updateConnector(F,q)},undo:async()=>{await Q.updateConnector(F,oe)},coalesceKey:`connector:${F}:reconnect`})}Q.updateConnector(F,q).catch(oe=>{ot(F),$&&X(),A(oe instanceof Error?oe.message:String(oe)),console.error("updateConnector reconnect failed",oe)})},[le,Q,ke,Ne,ot,G,X,Y]),Ur=m.useCallback((F,q,Z)=>{if(!le||!Q)return;const $=ke==null?void 0:ke.find(Ae=>Ae.id===F),_=$?q==="source"?$.sourcePin:$.targetPin:void 0,oe=q==="source"?"sourcePin":"targetPin";if(Ne(F,{[oe]:Z}),A(null),Y(),$){const Ae={[oe]:_??null};G({do:async()=>{await Q.updateConnector(F,{[oe]:Z})},undo:async()=>{await Q.updateConnector(F,Ae)},coalesceKey:`connector:${F}:${oe}`})}Q.updateConnector(F,{[oe]:Z}).catch(Ae=>{ot(F),$&&X(),A(Ae instanceof Error?Ae.message:String(Ae)),console.error("updateConnector pin failed",Ae)})},[le,Q,ke,Ne,ot,G,X,Y]),Lo=m.useCallback((F,q)=>{if(!le||!Q)return;const Z=ke==null?void 0:ke.find(oe=>oe.id===F),$=Z?q==="source"?Z.sourcePin:Z.targetPin:void 0;if(!$)return;const _=q==="source"?"sourcePin":"targetPin";Ne(F,{[_]:void 0}),A(null),Y(),G({do:async()=>{await Q.updateConnector(F,{[_]:null})},undo:async()=>{await Q.updateConnector(F,{[_]:$})}}),Q.updateConnector(F,{[_]:null}).catch(oe=>{ot(F),X(),A(oe instanceof Error?oe.message:String(oe)),console.error("updateConnector unpin failed",oe)})},[le,Q,ke,Ne,ot,G,X,Y]),Je=n==null?void 0:n.flow,Wr=S.overrides,Nn=C.overrides,Xt=L.ids,Gr=P.ids,v1=m.useMemo(()=>{if(!Je||h.length===0)return[];const F=new Map(Je.nodes.map(Z=>[Z.id,Z])),q=[];for(const Z of h){const $=F.get(Z);if(!$)continue;const _=Wr[Z];if(!_){q.push($);continue}const oe=_.data?{...$.data,..._.data}:$.data;q.push({...$,..._,data:oe})}return q},[Je,h,Wr]),Dz=m.useMemo(()=>{if(!Je||f.length===0)return[];const F=new Map(Je.connectors.map(Z=>[Z.id,Z])),q=[];for(const Z of f){const $=F.get(Z);if(!$)continue;const _=Nn[Z];q.push(_?{...$,..._}:$)}return q},[Je,f,Nn]),Kh=m.useMemo(()=>{if(!Je)return null;if(!T)return Je.nodes;const F=new Map(Je.nodes.map($=>[$.id,$])),q=[],Z=new Set;for(const $ of T){const _=F.get($);_&&(q.push(_),Z.add($))}for(const $ of Je.nodes)Z.has($.id)||q.push($);return q},[Je,T]),Io=m.useMemo(()=>{const F=Kh??(Je==null?void 0:Je.nodes)??null;return F?Xt.size===0?F:F.filter(q=>!Xt.has(q.id)):null},[Kh,Je,Xt]),ta=m.useMemo(()=>{const F=(Je==null?void 0:Je.connectors)??null;return F?Gr.size===0&&Xt.size===0?F:F.filter(q=>!Gr.has(q.id)&&!Xt.has(q.source)&&!Xt.has(q.target)):null},[Je,Gr,Xt]);if(!c)return y.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[y.jsxs("p",{className:"text-sm font-medium",children:["Unknown demo: ",e]}),y.jsx("p",{className:"text-xs text-muted-foreground",children:"The slug may have been removed. Re-register from the project repo to bring it back."})]});if(r&&!n)return y.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"Loading demo…"});const id=h[0],ii=id?a[id]:void 0;return y.jsxs("div",{className:"relative h-full w-full",children:[n&&!n.valid?y.jsxs("div",{"data-testid":"demo-error-banner",className:"absolute inset-x-0 top-0 z-10 border-b border-rose-500/40 bg-rose-50 px-4 py-2 text-xs text-rose-900 shadow-xs dark:bg-rose-950/40 dark:text-rose-100",children:[y.jsx("span",{className:"font-medium uppercase tracking-wide",children:"Invalid demo: "}),y.jsx("span",{className:"font-mono",children:n.error})]}):null,Je&&Q?y.jsx(o6e,{ref:b,mode:"edit",adapter:Q,projectId:le??void 0,enableEmbed:!1,onExportToCloud:le?()=>we(!0):void 0,onRestartDemo:l,nodes:Io??Je.nodes,connectors:ta??Je.connectors,selectedNodeIds:h,selectedConnectorIds:f,onSelectionChange:ge,runtime:{runs:o,statuses:a,pendingOverrides:{nodes:Wr,connectors:Nn}},onPlayNode:s,onNodePositionChange:de,onNodePositionsChange:Pe,onNodeResize:qe,onNodeResizeEnd:We,onHtmlNodeFitToContent:Rt,onMultiResize:st,onNodeNameChange:yr,onNodeDescriptionChange:Mo,onConnectorLabelChange:ri,onCreateShapeNode:an,onCreateImageFromFile:le?Ct:void 0,onRetryImageUpload:le?Qi:void 0,onCreateHtmlNode:le?bo:void 0,iconPickerOpen:Tn.open,onOpenIconPicker:le?g1:void 0,onCloseIconPicker:le?kr:void 0,onPickIcon:le?ea:void 0,onRequestIconReplace:le?Ji:void 0,onCreateConnector:mn,onReconnectConnector:$r,onPinEndpoint:le?Ur:void 0,onUnpinEndpoint:le?Lo:void 0,onReorderNode:k1,onDeleteNode:m1,onCopyNode:F=>nr([F]),onPasteAt:kn,onCopySelection:le?nr:void 0,onPasteSelection:le?()=>kn(null):void 0,hasClipboard:x1,selectedNodes:v1,selectedConnectors:Dz,onStyleNode:Kt,onStyleNodePreview:Jn,onStyleNodes:p1,onStyleNodesPreview:zt,onStyleConnector:y1,onStyleConnectorPreview:zn,onRfInit:H,onTidy:ee?oi:void 0,onCreateAndConnectFromPane:Vr,pendingEditNodeId:k,activeShape:U,onSelectShape:R,statusReport:ii,onNameChange:yr,onDescriptionChange:Mo,onDetailChange:er,onIconChange:qr,autoFitView:!0,autoFitViewSignal:D}):y.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"No demo data yet."}),z?y.jsxs("div",{"data-testid":"edit-error-banner",className:"absolute inset-x-0 bottom-4 z-20 mx-auto w-fit max-w-[80%] rounded-md border border-rose-500/50 bg-rose-50 px-3 py-2 text-xs text-rose-900 shadow-md dark:bg-rose-950/60 dark:text-rose-100",children:[y.jsx("span",{className:"font-medium",children:"Couldn't save change: "}),y.jsx("span",{className:"font-mono",children:z}),y.jsx("button",{type:"button",className:"ml-3 underline underline-offset-2",onClick:()=>A(null),children:"Dismiss"})]}):null,y.jsx(P6e,{open:O,onOpenChange:B,runCommand:rr,ctx:{hasSelection:h.length>0||f.length>0,canUndo:Or,canRedo:jn,hasClipboard:x1,canExportDemo:!!le,canResetSession:!!l}}),le?y.jsx(K6e,{open:fe,onOpenChange:we,projectId:le,onCapturePreview:()=>{var F;return((F=b.current)==null?void 0:F.capturePreview())??Promise.resolve(void 0)}}):null]})}const DB="npx seeflow register --path .";function S8e(){const[e,t]=m.useState(!1),n=async()=>{try{await navigator.clipboard.writeText(DB),t(!0),setTimeout(()=>t(!1),1200)}catch(r){console.error("[empty-state] copy failed",r)}};return y.jsx("div",{"data-testid":"seeflow-empty-state",className:"flex h-full w-full items-center justify-center bg-background p-6",children:y.jsxs("div",{className:"flex max-w-lg flex-col items-center gap-6 text-center",children:[y.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:y.jsx(x2,{className:"h-6 w-6 text-muted-foreground"})}),y.jsxs("div",{className:"space-y-2",children:[y.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:"No demos registered yet"}),y.jsxs("p",{className:"text-sm text-muted-foreground",children:["Point SeeFlow at any folder containing a"," ",y.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs",children:".seeflow/flow.json"})," file and it'll appear here."]})]}),y.jsxs("div",{className:"flex w-full items-center gap-2 rounded-md border border-border bg-card px-3 py-2 font-mono text-sm",children:[y.jsx("span",{className:"text-muted-foreground select-none",children:"$"}),y.jsx("code",{className:"flex-1 truncate text-left",children:DB}),y.jsx(Nt,{type:"button",variant:"ghost",size:"sm",onClick:n,"aria-label":"Copy register command",children:e?y.jsx(fo,{className:"h-4 w-4"}):y.jsx(ou,{className:"h-4 w-4"})})]})]})})}function L8e({demos:e}){return e.length===0?y.jsx(S8e,{}):y.jsx("div",{className:"flex h-full w-full items-start justify-center overflow-y-auto bg-background p-8",children:y.jsxs("div",{"data-testid":"studio-home-picker",className:"flex w-full max-w-2xl flex-col gap-6 pt-8",children:[y.jsxs("div",{className:"space-y-1",children:[y.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Open a demo"}),y.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.length," demos registered — pick one to load its canvas."]})]}),y.jsx("ul",{className:"flex flex-col gap-2",children:e.map(t=>y.jsx("li",{children:y.jsxs("button",{type:"button",onClick:()=>qu(`/d/${t.slug}`),"data-testid":`studio-home-demo-${t.slug}`,className:"flex w-full flex-col items-start gap-0.5 rounded-lg border border-border bg-card px-4 py-3 text-left transition-colors hover:border-input",style:{boxShadow:"var(--shadow-card)"},children:[y.jsx("span",{className:"text-sm font-medium",children:t.name}),y.jsx("span",{className:"truncate text-xs text-muted-foreground",children:t.repoPath})]})},t.id))})]})})}const I8e=e=>{if(!e.startsWith("/d/"))return null;const t=e.slice(3);return t.length>0?decodeURIComponent(t):null};function E8e(){const e=s6e(),{demos:t,refresh:n}=d6e(),r=I8e(e);M6e({onRegistryReload:n});const o=r?(t??[]).find(P=>P.slug===r):void 0,i=(o==null?void 0:o.id)??null,{detail:a,loading:s,refresh:l,applyDetail:c}=u6e(i),{runs:h,apply:d}=k6e(i),{events:f,apply:p}=y6e(i),{statusByNode:k,apply:v,reset:w}=w6e(i),g=m.useCallback(()=>{w(),l(),n()},[l,n,w]),M=m.useCallback(P=>{if(!i||!o)return;const T={id:i,slug:o.slug,filePath:""},E=P.valid?{...T,name:P.flow.name??o.name,flow:P.flow,valid:!0,error:null}:{...T,name:o.name,flow:null,valid:!1,error:P.error};c(E)},[i,o,c]),x=m.useCallback(P=>{d(P),p(P),v(P)},[d,p,v]);b6e(i,{onHello:g,onFlowReload:M,onEvent:x});const b=m.useCallback(async()=>{if(i)try{await Sne(i)}catch(P){console.error("Failed to restart demo:",P)}},[i]),S=m.useCallback(P=>{wB(P.id),n()},[n]),C=m.useCallback(async P=>{await n(),i===P&&qu("/")},[n,i]);m.useEffect(()=>{if(e!=="/"||t===null)return;const P=L6e(t,S6e());P&&qu(`/d/${P.slug}`)},[e,t]),m.useEffect(()=>{o&&wB(o.id)},[o]);const L=m.useCallback(P=>{i&&Lne(i,P).catch(T=>{d({type:"node:error",nodeId:P,message:T instanceof Error?T.message:String(T),ts:Date.now()})})},[i,d]);return t===null?y.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading…"}):y.jsx(L2,{delayDuration:150,children:y.jsxs("div",{className:"flex h-full w-full flex-col bg-background text-foreground",children:[y.jsx(c6e,{demos:t,currentSlug:r??void 0,onProjectCreated:S,onProjectUnregistered:C}),y.jsx("main",{className:"min-h-0 flex-1",children:r?y.jsx(C8e,{slug:r,demos:t,detail:a,loading:s,runs:h,nodeEvents:f,statusByNode:k,onPlayNode:L,onRestartDemo:i?b:void 0}):y.jsx(L8e,{demos:t})})]})})}const xJ=document.getElementById("root");if(!xJ)throw new Error("Root element #root not found");cT.createRoot(xJ).render(y.jsx(oo.StrictMode,{children:y.jsx(E8e,{})}));export{j3e as _,LP as c,uh as g,R8e as z};
|