mobileboost-cli 0.2.2 → 0.2.3

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.
Files changed (37) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/assets/index-wAXRnbNo.js +520 -0
  3. package/.output/public/assets/{main-BbUrvuLL.js → main-CeoNGsUp.js} +1 -1
  4. package/.output/server/chunks/_/{_tanstack-start-manifest_v-CCgm5JAL.mjs → _tanstack-start-manifest_v-DA-9ufHl.mjs} +1 -1
  5. package/.output/server/chunks/_/actions-CszEX8Wv.mjs +1 -0
  6. package/.output/server/chunks/_/{agent-CUyzfc4e.mjs → agent-CYjOntOE.mjs} +1 -1
  7. package/.output/server/chunks/_/ai-client-B037VO11.mjs +1 -0
  8. package/.output/server/chunks/_/{appium-CMKpXGap.mjs → appium-CB7q1F7-.mjs} +1 -1
  9. package/.output/server/chunks/_/appium-client-NLCErNZG.mjs +1 -0
  10. package/.output/server/chunks/_/{client-CM5hUS2d.mjs → client-B14sS6WP.mjs} +1 -1
  11. package/.output/server/chunks/_/{describe-BfbyupMJ.mjs → describe-BN5m4F-F.mjs} +1 -1
  12. package/.output/server/chunks/_/device-CFbX4Slf.mjs +1 -0
  13. package/.output/server/chunks/_/files-D27pPBly.mjs +1 -0
  14. package/.output/server/chunks/_/hierarchy-RZUZWmuO.mjs +1 -0
  15. package/.output/server/chunks/_/hierarchy-helpers-CR7kKS69.mjs +3 -0
  16. package/.output/server/chunks/_/index-BwPMhGOi.mjs +502 -0
  17. package/.output/server/chunks/_/{router-DYcFhNaL.mjs → router-BkeWjFXo.mjs} +1 -1
  18. package/.output/server/chunks/_/{screenshot-Csbvymnl.mjs → screenshot-BR2gF_yP.mjs} +1 -1
  19. package/.output/server/chunks/_/server.mjs +3 -3
  20. package/.output/server/chunks/_/step-BuczzV1F.mjs +1 -0
  21. package/.output/server/chunks/_/stores-k5WcYw_y.mjs +1 -0
  22. package/.output/server/index.mjs +4 -4
  23. package/.output/server/package.json +2 -0
  24. package/dist/cli.js +1 -1
  25. package/dist/cli.js.map +1 -1
  26. package/package.json +2 -1
  27. package/.output/public/assets/index-D7JF4301.js +0 -492
  28. package/.output/server/chunks/_/actions-CvabQsJo.mjs +0 -1
  29. package/.output/server/chunks/_/ai-client-waGeh-P8.mjs +0 -1
  30. package/.output/server/chunks/_/appium-client-DiTTrl8p.mjs +0 -1
  31. package/.output/server/chunks/_/device-CWFVkH1s.mjs +0 -1
  32. package/.output/server/chunks/_/files-CB9WpUb0.mjs +0 -1
  33. package/.output/server/chunks/_/hierarchy-DfPTUh7F.mjs +0 -1
  34. package/.output/server/chunks/_/hierarchy-helpers-BaGN7WBn.mjs +0 -3
  35. package/.output/server/chunks/_/index-BZ9EyYaV.mjs +0 -474
  36. package/.output/server/chunks/_/step-D2WQqd4J.mjs +0 -1
  37. package/.output/server/chunks/_/stores-2rWNmXVj.mjs +0 -1
@@ -0,0 +1,502 @@
1
+ import{jsxs as x,Fragment as It,jsx as s}from"react/jsx-runtime";import ne,{useRef as H,useEffect as we,useContext as Mo,useLayoutEffect as wa,useState as ye,useMemo as ur,useCallback as En}from"react";import T from"@emotion/styled";import{useMutation as ee,mutationOptions as ve,useQueryClient as Pn,useQuery as Ze,queryOptions as Ft}from"@tanstack/react-query";import{useStore as be,Store as Ca}from"@tanstack/react-store";import{CircularProgress as Wo,Typography as V,Box as q,IconButton as R,Divider as rn,Dialog as pr,DialogTitle as Go,DialogContent as fr,TextField as J,DialogActions as zo,Button as $e,Tooltip as pt,FormControl as Ot,InputLabel as Lt,Select as Vt,MenuItem as et,ToggleButtonGroup as Ia,ToggleButton as Qr,Snackbar as Na,Alert as Sa,List as Ho,FormHelperText as on,FormControlLabel as An,Checkbox as mr,Badge as Oa,RadioGroup as Pa,Radio as Aa,ListItem as Wn,InputAdornment as Ra,ListItemIcon as Zr,ListItemText as eo,Collapse as Ta,styled as Pt,Chip as L,Fab as Ba,Paper as Uo}from"@mui/material";import{Stop as jo,CameraAlt as $a,PlayArrow as ka,FiberManualRecord as _a,Layers as Fa,Animation as La}from"@mui/icons-material";import Va,{flushSync as qo}from"react-dom";import{bindActionCreators as to,createStore as Ma,compose as Wa,applyMiddleware as Ga}from"redux";import{connect as Ko,Provider as za}from"react-redux";import no from"tiny-invariant";import Yo from"@babel/runtime/helpers/esm/extends";import{C,R as Gn,U as Xo,u as Ha,d as Ua,S as ja,m as qa,c as Ka,l as Ya,r as Xa,i as Ja,s as Qa,k as ro,w as Za}from"./stores-k5WcYw_y.mjs";import{styled as an}from"@mui/material/styles";import es from"@mui/icons-material/Keyboard";import Jo from"@mui/icons-material/SwipeVertical";import ts from"@mui/icons-material/ZoomInMap";import ns from"@mui/icons-material/Search";import rs from"@mui/icons-material/Link";import os from"@mui/icons-material/SmartToy";import tt from"@mui/icons-material/PlayArrow";import nt from"@mui/icons-material/FastForward";import rt from"@mui/icons-material/Edit";import Ke from"@mui/icons-material/Delete";import is from"@mui/icons-material/TouchApp";import as from"@mui/icons-material/FactCheck";import{a as oe,g as ss,T as ls}from"./server.mjs";import{d as cs,r as ds,x as us,u as ps,b as fs,l as ms,a as hr}from"./device-CFbX4Slf.mjs";import{performTap as hs,performType as gs,getPageSource as Rn,performSwipe as Qo,performDeepLink as bs,performZoom as ys,getPlatform as gr,getDeviceSize as br,ensureAppiumSession as vs,restartApp as xs,scaleForIOS as Ds}from"./appium-client-NLCErNZG.mjs";import{R as Es,L as ws,X as Cs,K as yr,j as vr,B as Is,H as Ns,U as Ss,q as Os}from"./hierarchy-helpers-CR7kKS69.mjs";import{f as Ps,u as As,b as Rs}from"./adb-client-DwefjXbe.mjs";import{m as Ts,u as Bs}from"./ios-client-1xTZzFD8.mjs";import{z as k}from"zod";import{l as $s}from"./step-BuczzV1F.mjs";import oo from"node:fs";import Te from"node:path";import ks from"node:crypto";import Ut from"sharp";import{a as _s,i as Fs,o as Ls}from"./cache-CtBF0d8x.mjs";import{R as bt}from"./constants-Dh9o88yr.mjs";import{F as Vs,W as Ms,P as Ws,K as Gs}from"./ai-client-B037VO11.mjs";import{readFile as zs}from"node:fs/promises";import Be from"fs-extra";import Hs from"dotenv";import{useForm as Us}from"@tanstack/react-form";import js from"@mui/icons-material/Save";import Zo from"@mui/icons-material/Close";import qs from"@mui/icons-material/CheckCircle";import Ks from"@mui/icons-material/Info";import Ys from"@mui/icons-material/ListAlt";import ei from"@react-hook/mouse-position";import{useDebouncer as io}from"@tanstack/react-pacer";import ti from"@mui/icons-material/Add";import Xs from"@mui/icons-material/Refresh";import Js from"@mui/icons-material/CreateNewFolder";import Qs from"@mui/icons-material/Folder";import Zs from"@mui/icons-material/InsertDriveFile";import el from"@mui/icons-material/ExpandLess";import tl from"@mui/icons-material/ExpandMore";import nl from"@mui/icons-material/Check";import rl from"@mui/material/AlertTitle";import"@tanstack/history";import"@tanstack/router-core/ssr/client";import"@tanstack/router-core";import"node:async_hooks";import"@tanstack/router-core/ssr/server";import"../../index.mjs";import"node:http";import"node:stream";import"node:https";import"node:http2";import"node:url";import"seroval";import"@tanstack/react-router/ssr/server";import"@tanstack/react-router";import"webdriverio";import"xml2js";import"linkedom";import"node:child_process";import"node:util";var qe=function(t){var n=t.top,r=t.right,o=t.bottom,i=t.left,a=r-i,l=o-n,d={top:n,right:r,bottom:o,left:i,width:a,height:l,x:i,y:n,center:{x:(r+i)/2,y:(o+n)/2}};return d},xr=function(t,n){return{top:t.top-n.top,left:t.left-n.left,bottom:t.bottom+n.bottom,right:t.right+n.right}},ao=function(t,n){return{top:t.top+n.top,left:t.left+n.left,bottom:t.bottom-n.bottom,right:t.right-n.right}},ol=function(t,n){return{top:t.top+n.y,left:t.left+n.x,bottom:t.bottom+n.y,right:t.right+n.x}},zn={top:0,right:0,bottom:0,left:0},Dr=function(t){var n=t.borderBox,r=t.margin,o=r===void 0?zn:r,i=t.border,a=i===void 0?zn:i,l=t.padding,d=l===void 0?zn:l,c=qe(xr(n,o)),f=qe(ao(n,a)),p=qe(ao(f,d));return{marginBox:c,borderBox:qe(n),paddingBox:f,contentBox:p,margin:o,border:a,padding:d}},Me=function(t){var n=t.slice(0,-2),r=t.slice(-2);if(r!=="px")return 0;var o=Number(n);return isNaN(o)&&(process.env.NODE_ENV!=="production"?no(!1,"Could not parse value [raw: "+t+", without suffix: "+n+"]"):no(!1)),o},il=function(){return{x:window.pageXOffset,y:window.pageYOffset}},wn=function(t,n){var r=t.borderBox,o=t.border,i=t.margin,a=t.padding,l=ol(r,n);return Dr({borderBox:l,border:o,margin:i,padding:a})},Cn=function(t,n){return n===void 0&&(n=il()),wn(t,n)},ni=function(t,n){var r={top:Me(n.marginTop),right:Me(n.marginRight),bottom:Me(n.marginBottom),left:Me(n.marginLeft)},o={top:Me(n.paddingTop),right:Me(n.paddingRight),bottom:Me(n.paddingBottom),left:Me(n.paddingLeft)},i={top:Me(n.borderTopWidth),right:Me(n.borderRightWidth),bottom:Me(n.borderBottomWidth),left:Me(n.borderLeftWidth)};return Dr({borderBox:t,margin:r,padding:o,border:i})},ri=function(t){var n=t.getBoundingClientRect(),r=window.getComputedStyle(t);return ni(n,r)},Kt=function(t){var n=[],r=null,o=function(){for(var a=arguments.length,l=new Array(a),d=0;d<a;d++)l[d]=arguments[d];n=l,!r&&(r=requestAnimationFrame(function(){r=null,t.apply(void 0,n)}))};return o.cancel=function(){r&&(cancelAnimationFrame(r),r=null)},o};const al=process.env.NODE_ENV==="production",sl=/[ \t]{2,}/g,ll=/^[ \t]*/gm,so=e=>e.replace(sl," ").replace(ll,"").trim(),cl=e=>so(`
2
+ %c@hello-pangea/dnd
3
+
4
+ %c${so(e)}
5
+
6
+ %c👷‍ This is a development only message. It will be removed in production builds.
7
+ `),dl=e=>[cl(e),"color: #00C584; font-size: 1.2em; font-weight: bold;","line-height: 1.5","color: #723874;"],ul="__@hello-pangea/dnd-disable-dev-warnings";function oi(e,t){al||typeof window<"u"&&window[ul]||console[e](...dl(t))}const re=oi.bind(null,"warn"),rr=oi.bind(null,"error");function yt(){}function pl(e,t){return{...e,...t}}function Ge(e,t,n){const r=t.map(o=>{const i=pl(n,o.options);return e.addEventListener(o.eventName,o.fn,i),function(){e.removeEventListener(o.eventName,o.fn,i)}});return function(){r.forEach(i=>{i()})}}const fl=process.env.NODE_ENV==="production",lo="Invariant failed";class Yt extends Error{}Yt.prototype.toString=function(){return this.message};function h(e,t){throw fl?new Yt(lo):new Yt(`${lo}: ${t||""}`)}class ml extends ne.Component{constructor(...t){super(...t),this.callbacks=null,this.unbind=yt,this.onWindowError=n=>{const r=this.getCallbacks();r.isDragging()&&(r.tryAbort(),process.env.NODE_ENV!=="production"&&re(`
8
+ An error was caught by our window 'error' event listener while a drag was occurring.
9
+ The active drag has been aborted.
10
+ `));const o=n.error;o instanceof Yt&&(n.preventDefault(),process.env.NODE_ENV!=="production"&&rr(o.message))},this.getCallbacks=()=>{if(!this.callbacks)throw new Error("Unable to find AppCallbacks in <ErrorBoundary/>");return this.callbacks},this.setCallbacks=n=>{this.callbacks=n}}componentDidMount(){this.unbind=Ge(window,[{eventName:"error",fn:this.onWindowError}])}componentDidCatch(t){if(t instanceof Yt){process.env.NODE_ENV!=="production"&&rr(t.message),this.setState({});return}throw t}componentWillUnmount(){this.unbind()}render(){return this.props.children(this.setCallbacks)}}const hl=`
11
+ Press space bar to start a drag.
12
+ When dragging you can use the arrow keys to move the item around and escape to cancel.
13
+ Some screen readers may require you to be in focus mode or to use your pass through key
14
+ `,In=e=>e+1,gl=e=>`
15
+ You have lifted an item in position ${In(e.source.index)}
16
+ `,ii=(e,t)=>{const n=e.droppableId===t.droppableId,r=In(e.index),o=In(t.index);return n?`
17
+ You have moved the item from position ${r}
18
+ to position ${o}
19
+ `:`
20
+ You have moved the item from position ${r}
21
+ in list ${e.droppableId}
22
+ to list ${t.droppableId}
23
+ in position ${o}
24
+ `},ai=(e,t,n)=>t.droppableId===n.droppableId?`
25
+ The item ${e}
26
+ has been combined with ${n.draggableId}`:`
27
+ The item ${e}
28
+ in list ${t.droppableId}
29
+ has been combined with ${n.draggableId}
30
+ in list ${n.droppableId}
31
+ `,bl=e=>{const t=e.destination;if(t)return ii(e.source,t);const n=e.combine;return n?ai(e.draggableId,e.source,n):"You are over an area that cannot be dropped on"},co=e=>`
32
+ The item has returned to its starting position
33
+ of ${In(e.index)}
34
+ `,yl=e=>{if(e.reason==="CANCEL")return`
35
+ Movement cancelled.
36
+ ${co(e.source)}
37
+ `;const t=e.destination,n=e.combine;return t?`
38
+ You have dropped the item.
39
+ ${ii(e.source,t)}
40
+ `:n?`
41
+ You have dropped the item.
42
+ ${ai(e.draggableId,e.source,n)}
43
+ `:`
44
+ The item has been dropped while not over a drop area.
45
+ ${co(e.source)}
46
+ `},Dn={dragHandleUsageInstructions:hl,onDragStart:gl,onDragUpdate:bl,onDragEnd:yl};function vl(e,t){return!!(e===t||Number.isNaN(e)&&Number.isNaN(t))}function si(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!vl(e[n],t[n]))return!1;return!0}function G(e,t){const n=ye(()=>({inputs:t,result:e()}))[0],r=H(!0),o=H(n),a=r.current||!!(t&&o.current.inputs&&si(t,o.current.inputs))?o.current:{inputs:t,result:e()};return we(()=>{r.current=!1,o.current=a},[a]),a.result}function I(e,t){return G(()=>e,t)}const Ie={x:0,y:0},Oe=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),ke=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),vt=(e,t)=>e.x===t.x&&e.y===t.y,Mt=e=>({x:e.x!==0?-e.x:0,y:e.y!==0?-e.y:0}),Nt=(e,t,n=0)=>e==="x"?{x:t,y:n}:{x:n,y:t},Xt=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),uo=(e,t)=>Math.min(...t.map(n=>Xt(e,n))),li=e=>t=>({x:e(t.x),y:e(t.y)});var xl=(e,t)=>{const n=qe({top:Math.max(t.top,e.top),right:Math.min(t.right,e.right),bottom:Math.min(t.bottom,e.bottom),left:Math.max(t.left,e.left)});return n.width<=0||n.height<=0?null:n};const sn=(e,t)=>({top:e.top+t.y,left:e.left+t.x,bottom:e.bottom+t.y,right:e.right+t.x}),po=e=>[{x:e.left,y:e.top},{x:e.right,y:e.top},{x:e.left,y:e.bottom},{x:e.right,y:e.bottom}],Dl={top:0,right:0,bottom:0,left:0},El=(e,t)=>t?sn(e,t.scroll.diff.displacement):e,wl=(e,t,n)=>n&&n.increasedBy?{...e,[t.end]:e[t.end]+n.increasedBy[t.line]}:e,Cl=(e,t)=>t&&t.shouldClipSubject?xl(t.pageMarginBox,e):qe(e);var $t=({page:e,withPlaceholder:t,axis:n,frame:r})=>{const o=El(e.marginBox,r),i=wl(o,n,t),a=Cl(i,r);return{page:e,withPlaceholder:t,active:a}},Er=(e,t)=>{e.frame||(process.env.NODE_ENV,h());const n=e.frame,r=ke(t,n.scroll.initial),o=Mt(r),i={...n,scroll:{initial:n.scroll.initial,current:t,diff:{value:r,displacement:o},max:n.scroll.max}},a=$t({page:e.subject.page,withPlaceholder:e.subject.withPlaceholder,axis:e.axis,frame:i});return{...e,frame:i,subject:a}};function Ce(e,t=si){let n=null;function r(...o){if(n&&n.lastThis===this&&t(o,n.lastArgs))return n.lastResult;const i=e.apply(this,o);return n={lastResult:i,lastArgs:o,lastThis:this},i}return r.clear=function(){n=null},r}const ci=Ce(e=>e.reduce((t,n)=>(t[n.descriptor.id]=n,t),{})),di=Ce(e=>e.reduce((t,n)=>(t[n.descriptor.id]=n,t),{})),Tn=Ce(e=>Object.values(e)),Il=Ce(e=>Object.values(e));var At=Ce((e,t)=>Il(t).filter(r=>e===r.descriptor.droppableId).sort((r,o)=>r.descriptor.index-o.descriptor.index));function wr(e){return e.at&&e.at.type==="REORDER"?e.at.destination:null}function Bn(e){return e.at&&e.at.type==="COMBINE"?e.at.combine:null}var $n=Ce((e,t)=>t.filter(n=>n.descriptor.id!==e.descriptor.id)),Nl=({isMovingForward:e,draggable:t,destination:n,insideDestination:r,previousImpact:o})=>{if(!n.isCombineEnabled||!wr(o))return null;function a(m){const g={type:"COMBINE",combine:{draggableId:m,droppableId:n.descriptor.id}};return{...o,at:g}}const l=o.displaced.all,d=l.length?l[0]:null;if(e)return d?a(d):null;const c=$n(t,r);if(!d){if(!c.length)return null;const m=c[c.length-1];return a(m.descriptor.id)}const f=c.findIndex(m=>m.descriptor.id===d);f===-1&&(process.env.NODE_ENV!=="production"?h(!1,"Could not find displaced item in set"):h());const p=f-1;if(p<0)return null;const u=c[p];return a(u.descriptor.id)},Wt=(e,t)=>e.descriptor.droppableId===t.descriptor.id;const ui={point:Ie,value:0},Jt={invisible:{},visible:{},all:[]},Sl={displaced:Jt,displacedBy:ui,at:null};var ze=(e,t)=>n=>e<=n&&n<=t,pi=e=>{const t=ze(e.top,e.bottom),n=ze(e.left,e.right);return r=>{if(t(r.top)&&t(r.bottom)&&n(r.left)&&n(r.right))return!0;const i=t(r.top)||t(r.bottom),a=n(r.left)||n(r.right);if(i&&a)return!0;const d=r.top<e.top&&r.bottom>e.bottom,c=r.left<e.left&&r.right>e.right;return d&&c?!0:d&&a||c&&i}},Ol=e=>{const t=ze(e.top,e.bottom),n=ze(e.left,e.right);return r=>t(r.top)&&t(r.bottom)&&n(r.left)&&n(r.right)};const Cr={direction:"vertical",line:"y",crossAxisLine:"x",start:"top",end:"bottom",size:"height",crossAxisStart:"left",crossAxisEnd:"right",crossAxisSize:"width"},fi={direction:"horizontal",line:"x",crossAxisLine:"y",start:"left",end:"right",size:"width",crossAxisStart:"top",crossAxisEnd:"bottom",crossAxisSize:"height"};var Pl=e=>t=>{const n=ze(t.top,t.bottom),r=ze(t.left,t.right);return o=>e===Cr?n(o.top)&&n(o.bottom):r(o.left)&&r(o.right)};const Al=(e,t)=>{const n=t.frame?t.frame.scroll.diff.displacement:Ie;return sn(e,n)},Rl=(e,t,n)=>t.subject.active?n(t.subject.active)(e):!1,Tl=(e,t,n)=>n(t)(e),Ir=({target:e,destination:t,viewport:n,withDroppableDisplacement:r,isVisibleThroughFrameFn:o})=>{const i=r?Al(e,t):e;return Rl(i,t,o)&&Tl(i,n,o)},Bl=e=>Ir({...e,isVisibleThroughFrameFn:pi}),mi=e=>Ir({...e,isVisibleThroughFrameFn:Ol}),$l=e=>Ir({...e,isVisibleThroughFrameFn:Pl(e.destination.axis)}),kl=(e,t,n)=>{if(typeof n=="boolean")return n;if(!t)return!0;const{invisible:r,visible:o}=t;if(r[e])return!1;const i=o[e];return i?i.shouldAnimate:!0};function _l(e,t){const n=e.page.marginBox,r={top:t.point.y,right:0,bottom:0,left:t.point.x};return qe(xr(n,r))}function Qt({afterDragging:e,destination:t,displacedBy:n,viewport:r,forceShouldAnimate:o,last:i}){return e.reduce(function(l,d){const c=_l(d,n),f=d.descriptor.id;if(l.all.push(f),!Bl({target:c,destination:t,viewport:r,withDroppableDisplacement:!0}))return l.invisible[d.descriptor.id]=!0,l;const u=kl(f,i,o),m={draggableId:f,shouldAnimate:u};return l.visible[f]=m,l},{all:[],visible:{},invisible:{}})}function Fl(e,t){if(!e.length)return 0;const n=e[e.length-1].descriptor.index;return t.inHomeList?n:n+1}function fo({insideDestination:e,inHomeList:t,displacedBy:n,destination:r}){const o=Fl(e,{inHomeList:t});return{displaced:Jt,displacedBy:n,at:{type:"REORDER",destination:{droppableId:r.descriptor.id,index:o}}}}function Nn({draggable:e,insideDestination:t,destination:n,viewport:r,displacedBy:o,last:i,index:a,forceShouldAnimate:l}){const d=Wt(e,n);if(a==null)return fo({insideDestination:t,inHomeList:d,displacedBy:o,destination:n});const c=t.find(g=>g.descriptor.index===a);if(!c)return fo({insideDestination:t,inHomeList:d,displacedBy:o,destination:n});const f=$n(e,t),p=t.indexOf(c),u=f.slice(p);return{displaced:Qt({afterDragging:u,destination:n,displacedBy:o,last:i,viewport:r.frame,forceShouldAnimate:l}),displacedBy:o,at:{type:"REORDER",destination:{droppableId:n.descriptor.id,index:a}}}}function xt(e,t){return!!t.effected[e]}var Ll=({isMovingForward:e,destination:t,draggables:n,combine:r,afterCritical:o})=>{if(!t.isCombineEnabled)return null;const i=r.draggableId,l=n[i].descriptor.index;return xt(i,o)?e?l:l-1:e?l+1:l},Vl=({isMovingForward:e,isInHomeList:t,insideDestination:n,location:r})=>{if(!n.length)return null;const o=r.index,i=e?o+1:o-1,a=n[0].descriptor.index,l=n[n.length-1].descriptor.index,d=t?l:l+1;return i<a||i>d?null:i},Ml=({isMovingForward:e,isInHomeList:t,draggable:n,draggables:r,destination:o,insideDestination:i,previousImpact:a,viewport:l,afterCritical:d})=>{const c=a.at;if(c||(process.env.NODE_ENV!=="production"?h(!1,"Cannot move in direction without previous impact location"):h()),c.type==="REORDER"){const p=Vl({isMovingForward:e,isInHomeList:t,location:c.destination,insideDestination:i});return p==null?null:Nn({draggable:n,insideDestination:i,destination:o,viewport:l,last:a.displaced,displacedBy:a.displacedBy,index:p})}const f=Ll({isMovingForward:e,destination:o,displaced:a.displaced,draggables:r,combine:c.combine,afterCritical:d});return f==null?null:Nn({draggable:n,insideDestination:i,destination:o,viewport:l,last:a.displaced,displacedBy:a.displacedBy,index:f})},Wl=({displaced:e,afterCritical:t,combineWith:n,displacedBy:r})=>{const o=!!(e.visible[n]||e.invisible[n]);return xt(n,t)?o?Ie:Mt(r.point):o?r.point:Ie},Gl=({afterCritical:e,impact:t,draggables:n})=>{const r=Bn(t);r||(process.env.NODE_ENV,h());const o=r.draggableId,i=n[o].page.borderBox.center,a=Wl({displaced:t.displaced,afterCritical:e,combineWith:o,displacedBy:t.displacedBy});return Oe(i,a)};const hi=(e,t)=>t.margin[e.start]+t.borderBox[e.size]/2,zl=(e,t)=>t.margin[e.end]+t.borderBox[e.size]/2,Nr=(e,t,n)=>t[e.crossAxisStart]+n.margin[e.crossAxisStart]+n.borderBox[e.crossAxisSize]/2,mo=({axis:e,moveRelativeTo:t,isMoving:n})=>Nt(e.line,t.marginBox[e.end]+hi(e,n),Nr(e,t.marginBox,n)),ho=({axis:e,moveRelativeTo:t,isMoving:n})=>Nt(e.line,t.marginBox[e.start]-zl(e,n),Nr(e,t.marginBox,n)),Hl=({axis:e,moveInto:t,isMoving:n})=>Nt(e.line,t.contentBox[e.start]+hi(e,n),Nr(e,t.contentBox,n));var Ul=({impact:e,draggable:t,draggables:n,droppable:r,afterCritical:o})=>{const i=At(r.descriptor.id,n),a=t.page,l=r.axis;if(!i.length)return Hl({axis:l,moveInto:r.page,isMoving:a});const{displaced:d,displacedBy:c}=e,f=d.all[0];if(f){const u=n[f];if(xt(f,o))return ho({axis:l,moveRelativeTo:u.page,isMoving:a});const m=wn(u.page,c.point);return ho({axis:l,moveRelativeTo:m,isMoving:a})}const p=i[i.length-1];if(p.descriptor.id===t.descriptor.id)return a.borderBox.center;if(xt(p.descriptor.id,o)){const u=wn(p.page,Mt(o.displacedBy.point));return mo({axis:l,moveRelativeTo:u,isMoving:a})}return mo({axis:l,moveRelativeTo:p.page,isMoving:a})},or=(e,t)=>{const n=e.frame;return n?Oe(t,n.scroll.diff.displacement):t};const jl=({impact:e,draggable:t,droppable:n,draggables:r,afterCritical:o})=>{const i=t.page.borderBox.center,a=e.at;return!n||!a?i:a.type==="REORDER"?Ul({impact:e,draggable:t,draggables:r,droppable:n,afterCritical:o}):Gl({impact:e,draggables:r,afterCritical:o})};var kn=e=>{const t=jl(e),n=e.droppable;return n?or(n,t):t},gi=(e,t)=>{const n=ke(t,e.scroll.initial),r=Mt(n);return{frame:qe({top:t.y,bottom:t.y+e.frame.height,left:t.x,right:t.x+e.frame.width}),scroll:{initial:e.scroll.initial,max:e.scroll.max,current:t,diff:{value:n,displacement:r}}}};function go(e,t){return e.map(n=>t[n])}function ql(e,t){for(let n=0;n<t.length;n++){const r=t[n].visible[e];if(r)return r}return null}var Kl=({impact:e,viewport:t,destination:n,draggables:r,maxScrollChange:o})=>{const i=gi(t,Oe(t.scroll.current,o)),a=n.frame?Er(n,Oe(n.frame.scroll.current,o)):n,l=e.displaced,d=Qt({afterDragging:go(l.all,r),destination:n,displacedBy:e.displacedBy,viewport:i.frame,last:l,forceShouldAnimate:!1}),c=Qt({afterDragging:go(l.all,r),destination:a,displacedBy:e.displacedBy,viewport:t.frame,last:l,forceShouldAnimate:!1}),f={},p={},u=[l,d,c];return l.all.forEach(g=>{const y=ql(g,u);if(y){p[g]=y;return}f[g]=!0}),{...e,displaced:{all:l.all,invisible:f,visible:p}}},Yl=(e,t)=>Oe(e.scroll.diff.displacement,t),Sr=({pageBorderBoxCenter:e,draggable:t,viewport:n})=>{const r=Yl(n,e),o=ke(r,t.page.borderBox.center);return Oe(t.client.borderBox.center,o)},bi=({draggable:e,destination:t,newPageBorderBoxCenter:n,viewport:r,withDroppableDisplacement:o,onlyOnMainAxis:i=!1})=>{const a=ke(n,e.page.borderBox.center),d={target:sn(e.page.borderBox,a),destination:t,withDroppableDisplacement:o,viewport:r};return i?$l(d):mi(d)},Xl=({isMovingForward:e,draggable:t,destination:n,draggables:r,previousImpact:o,viewport:i,previousPageBorderBoxCenter:a,previousClientSelection:l,afterCritical:d})=>{if(!n.isEnabled)return null;const c=At(n.descriptor.id,r),f=Wt(t,n),p=Nl({isMovingForward:e,draggable:t,destination:n,insideDestination:c,previousImpact:o})||Ml({isMovingForward:e,isInHomeList:f,draggable:t,draggables:r,destination:n,insideDestination:c,previousImpact:o,viewport:i,afterCritical:d});if(!p)return null;const u=kn({impact:p,draggable:t,droppable:n,draggables:r,afterCritical:d});if(bi({draggable:t,destination:n,newPageBorderBoxCenter:u,viewport:i.frame,withDroppableDisplacement:!1,onlyOnMainAxis:!0}))return{clientSelection:Sr({pageBorderBoxCenter:u,draggable:t,viewport:i}),impact:p,scrollJumpRequest:null};const g=ke(u,a),y=Kl({impact:p,viewport:i,destination:n,draggables:r,maxScrollChange:g});return{clientSelection:l,impact:y,scrollJumpRequest:g}};const Re=e=>{const t=e.subject.active;return t||(process.env.NODE_ENV!=="production"?h(!1,"Cannot get clipped area from droppable"):h()),t};var Jl=({isMovingForward:e,pageBorderBoxCenter:t,source:n,droppables:r,viewport:o})=>{const i=n.subject.active;if(!i)return null;const a=n.axis,l=ze(i[a.start],i[a.end]),d=Tn(r).filter(f=>f!==n).filter(f=>f.isEnabled).filter(f=>!!f.subject.active).filter(f=>pi(o.frame)(Re(f))).filter(f=>{const p=Re(f);return e?i[a.crossAxisEnd]<p[a.crossAxisEnd]:p[a.crossAxisStart]<i[a.crossAxisStart]}).filter(f=>{const p=Re(f),u=ze(p[a.start],p[a.end]);return l(p[a.start])||l(p[a.end])||u(i[a.start])||u(i[a.end])}).sort((f,p)=>{const u=Re(f)[a.crossAxisStart],m=Re(p)[a.crossAxisStart];return e?u-m:m-u}).filter((f,p,u)=>Re(f)[a.crossAxisStart]===Re(u[0])[a.crossAxisStart]);if(!d.length)return null;if(d.length===1)return d[0];const c=d.filter(f=>ze(Re(f)[a.start],Re(f)[a.end])(t[a.line]));return c.length===1?c[0]:c.length>1?c.sort((f,p)=>Re(f)[a.start]-Re(p)[a.start])[0]:d.sort((f,p)=>{const u=uo(t,po(Re(f))),m=uo(t,po(Re(p)));return u!==m?u-m:Re(f)[a.start]-Re(p)[a.start]})[0]};const bo=(e,t)=>{const n=e.page.borderBox.center;return xt(e.descriptor.id,t)?ke(n,t.displacedBy.point):n},Ql=(e,t)=>{const n=e.page.borderBox;return xt(e.descriptor.id,t)?sn(n,Mt(t.displacedBy.point)):n};var Zl=({pageBorderBoxCenter:e,viewport:t,destination:n,insideDestination:r,afterCritical:o})=>r.filter(a=>mi({target:Ql(a,o),destination:n,viewport:t.frame,withDroppableDisplacement:!0})).sort((a,l)=>{const d=Xt(e,or(n,bo(a,o))),c=Xt(e,or(n,bo(l,o)));return d<c?-1:c<d?1:a.descriptor.index-l.descriptor.index})[0]||null,ln=Ce(function(t,n){const r=n[t.line];return{value:r,point:Nt(t.line,r)}});const ec=(e,t,n)=>{const r=e.axis;if(e.descriptor.mode==="virtual")return Nt(r.line,t[r.line]);const o=e.subject.page.contentBox[r.size],d=At(e.descriptor.id,n).reduce((c,f)=>c+f.client.marginBox[r.size],0)+t[r.line]-o;return d<=0?null:Nt(r.line,d)},yi=(e,t)=>({...e,scroll:{...e.scroll,max:t}}),vi=(e,t,n)=>{const r=e.frame;Wt(t,e)&&(process.env.NODE_ENV!=="production"?h(!1,"Should not add placeholder space to home list"):h()),e.subject.withPlaceholder&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot add placeholder size to a subject when it already has one"):h());const o=ln(e.axis,t.displaceBy).point,i=ec(e,o,n),a={placeholderSize:o,increasedBy:i,oldFrameMaxScroll:e.frame?e.frame.scroll.max:null};if(!r){const f=$t({page:e.subject.page,withPlaceholder:a,axis:e.axis,frame:e.frame});return{...e,subject:f}}const l=i?Oe(r.scroll.max,i):r.scroll.max,d=yi(r,l),c=$t({page:e.subject.page,withPlaceholder:a,axis:e.axis,frame:d});return{...e,subject:c,frame:d}},tc=e=>{const t=e.subject.withPlaceholder;t||(process.env.NODE_ENV!=="production"?h(!1,"Cannot remove placeholder form subject when there was none"):h());const n=e.frame;if(!n){const a=$t({page:e.subject.page,axis:e.axis,frame:null,withPlaceholder:null});return{...e,subject:a}}const r=t.oldFrameMaxScroll;r||(process.env.NODE_ENV!=="production"?h(!1,"Expected droppable with frame to have old max frame scroll when removing placeholder"):h());const o=yi(n,r),i=$t({page:e.subject.page,axis:e.axis,frame:o,withPlaceholder:null});return{...e,subject:i,frame:o}};var nc=({previousPageBorderBoxCenter:e,moveRelativeTo:t,insideDestination:n,draggable:r,draggables:o,destination:i,viewport:a,afterCritical:l})=>{if(!t){if(n.length)return null;const p={displaced:Jt,displacedBy:ui,at:{type:"REORDER",destination:{droppableId:i.descriptor.id,index:0}}},u=kn({impact:p,draggable:r,droppable:i,draggables:o,afterCritical:l}),m=Wt(r,i)?i:vi(i,r,o);return bi({draggable:r,destination:m,newPageBorderBoxCenter:u,viewport:a.frame,withDroppableDisplacement:!1,onlyOnMainAxis:!0})?p:null}const d=e[i.axis.line]<=t.page.borderBox.center[i.axis.line],c=(()=>{const p=t.descriptor.index;return t.descriptor.id===r.descriptor.id||d?p:p+1})(),f=ln(i.axis,r.displaceBy);return Nn({draggable:r,insideDestination:n,destination:i,viewport:a,displacedBy:f,last:Jt,index:c})},rc=({isMovingForward:e,previousPageBorderBoxCenter:t,draggable:n,isOver:r,draggables:o,droppables:i,viewport:a,afterCritical:l})=>{const d=Jl({isMovingForward:e,pageBorderBoxCenter:t,source:r,droppables:i,viewport:a});if(!d)return null;const c=At(d.descriptor.id,o),f=Zl({pageBorderBoxCenter:t,viewport:a,destination:d,insideDestination:c,afterCritical:l}),p=nc({previousPageBorderBoxCenter:t,destination:d,draggable:n,draggables:o,moveRelativeTo:f,insideDestination:c,viewport:a,afterCritical:l});if(!p)return null;const u=kn({impact:p,draggable:n,droppable:d,draggables:o,afterCritical:l});return{clientSelection:Sr({pageBorderBoxCenter:u,draggable:n,viewport:a}),impact:p,scrollJumpRequest:null}},_e=e=>{const t=e.at;return t?t.type==="REORDER"?t.destination.droppableId:t.combine.droppableId:null};const oc=(e,t)=>{const n=_e(e);return n?t[n]:null};var ic=({state:e,type:t})=>{const n=oc(e.impact,e.dimensions.droppables),r=!!n,o=e.dimensions.droppables[e.critical.droppable.id],i=n||o,a=i.axis.direction,l=a==="vertical"&&(t==="MOVE_UP"||t==="MOVE_DOWN")||a==="horizontal"&&(t==="MOVE_LEFT"||t==="MOVE_RIGHT");if(l&&!r)return null;const d=t==="MOVE_DOWN"||t==="MOVE_RIGHT",c=e.dimensions.draggables[e.critical.draggable.id],f=e.current.page.borderBoxCenter,{draggables:p,droppables:u}=e.dimensions;return l?Xl({isMovingForward:d,previousPageBorderBoxCenter:f,draggable:c,destination:i,draggables:p,viewport:e.viewport,previousClientSelection:e.current.client.selection,previousImpact:e.impact,afterCritical:e.afterCritical}):rc({isMovingForward:d,previousPageBorderBoxCenter:f,draggable:c,isOver:i,draggables:p,droppables:u,viewport:e.viewport,afterCritical:e.afterCritical})};function Ct(e){return e.phase==="DRAGGING"||e.phase==="COLLECTING"}function xi(e){const t=ze(e.top,e.bottom),n=ze(e.left,e.right);return function(o){return t(o.y)&&n(o.x)}}function ac(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top}function sc({pageBorderBox:e,draggable:t,candidates:n}){const r=t.page.borderBox.center,o=n.map(i=>{const a=i.axis,l=Nt(i.axis.line,e.center[a.line],i.page.borderBox.center[a.crossAxisLine]);return{id:i.descriptor.id,distance:Xt(r,l)}}).sort((i,a)=>a.distance-i.distance);return o[0]?o[0].id:null}function lc({pageBorderBox:e,draggable:t,droppables:n}){const r=Tn(n).filter(o=>{if(!o.isEnabled)return!1;const i=o.subject.active;if(!i||!ac(e,i))return!1;if(xi(i)(e.center))return!0;const a=o.axis,l=i.center[a.crossAxisLine],d=e[a.crossAxisStart],c=e[a.crossAxisEnd],f=ze(i[a.crossAxisStart],i[a.crossAxisEnd]),p=f(d),u=f(c);return!p&&!u?!0:p?d<l:c>l});return r.length?r.length===1?r[0].descriptor.id:sc({pageBorderBox:e,draggable:t,candidates:r}):null}const Di=(e,t)=>qe(sn(e,t));var cc=(e,t)=>{const n=e.frame;return n?Di(t,n.scroll.diff.value):t};function Ei({displaced:e,id:t}){return!!(e.visible[t]||e.invisible[t])}function dc({draggable:e,closest:t,inHomeList:n}){return t?n&&t.descriptor.index>e.descriptor.index?t.descriptor.index-1:t.descriptor.index:null}var uc=({pageBorderBoxWithDroppableScroll:e,draggable:t,destination:n,insideDestination:r,last:o,viewport:i,afterCritical:a})=>{const l=n.axis,d=ln(n.axis,t.displaceBy),c=d.value,f=e[l.start],p=e[l.end],m=$n(t,r).find(y=>{const b=y.descriptor.id,D=y.page.borderBox.center[l.line],E=xt(b,a),S=Ei({displaced:o,id:b});return E?S?p<=D:f<D-c:S?p<=D+c:f<D})||null,g=dc({draggable:t,closest:m,inHomeList:Wt(t,n)});return Nn({draggable:t,insideDestination:r,destination:n,viewport:i,last:o,displacedBy:d,index:g})};const pc=4;var fc=({draggable:e,pageBorderBoxWithDroppableScroll:t,previousImpact:n,destination:r,insideDestination:o,afterCritical:i})=>{if(!r.isCombineEnabled)return null;const a=r.axis,l=ln(r.axis,e.displaceBy),d=l.value,c=t[a.start],f=t[a.end],u=$n(e,o).find(g=>{const y=g.descriptor.id,b=g.page.borderBox,E=b[a.size]/pc,S=xt(y,i),N=Ei({displaced:n.displaced,id:y});return S?N?f>b[a.start]+E&&f<b[a.end]-E:c>b[a.start]-d+E&&c<b[a.end]-d-E:N?f>b[a.start]+d+E&&f<b[a.end]+d-E:c>b[a.start]+E&&c<b[a.end]-E});return u?{displacedBy:l,displaced:n.displaced,at:{type:"COMBINE",combine:{draggableId:u.descriptor.id,droppableId:r.descriptor.id}}}:null},wi=({pageOffset:e,draggable:t,draggables:n,droppables:r,previousImpact:o,viewport:i,afterCritical:a})=>{const l=Di(t.page.borderBox,e),d=lc({pageBorderBox:l,draggable:t,droppables:r});if(!d)return Sl;const c=r[d],f=At(c.descriptor.id,n),p=cc(c,l);return fc({pageBorderBoxWithDroppableScroll:p,draggable:t,previousImpact:o,destination:c,insideDestination:f,afterCritical:a})||uc({pageBorderBoxWithDroppableScroll:p,draggable:t,destination:c,insideDestination:f,last:o.displaced,viewport:i,afterCritical:a})},Or=(e,t)=>({...e,[t.descriptor.id]:t});const mc=({previousImpact:e,impact:t,droppables:n})=>{const r=_e(e),o=_e(t);if(!r||r===o)return n;const i=n[r];if(!i.subject.withPlaceholder)return n;const a=tc(i);return Or(n,a)};var hc=({draggable:e,draggables:t,droppables:n,previousImpact:r,impact:o})=>{const i=mc({previousImpact:r,impact:o,droppables:n}),a=_e(o);if(!a)return i;const l=n[a];if(Wt(e,l)||l.subject.withPlaceholder)return i;const d=vi(l,e,t);return Or(i,d)},jt=({state:e,clientSelection:t,dimensions:n,viewport:r,impact:o,scrollJumpRequest:i})=>{const a=r||e.viewport,l=n||e.dimensions,d=t||e.current.client.selection,c=ke(d,e.initial.client.selection),f={offset:c,selection:d,borderBoxCenter:Oe(e.initial.client.borderBoxCenter,c)},p={selection:Oe(f.selection,a.scroll.current),borderBoxCenter:Oe(f.borderBoxCenter,a.scroll.current),offset:Oe(f.offset,a.scroll.diff.value)},u={client:f,page:p};if(e.phase==="COLLECTING")return{...e,dimensions:l,viewport:a,current:u};const m=l.draggables[e.critical.draggable.id],g=o||wi({pageOffset:p.offset,draggable:m,draggables:l.draggables,droppables:l.droppables,previousImpact:e.impact,viewport:a,afterCritical:e.afterCritical}),y=hc({draggable:m,impact:g,previousImpact:e.impact,draggables:l.draggables,droppables:l.droppables});return{...e,current:u,dimensions:{draggables:l.draggables,droppables:y},impact:g,viewport:a,scrollJumpRequest:i||null,forceShouldAnimate:i?!1:null}};function gc(e,t){return e.map(n=>t[n])}var Ci=({impact:e,viewport:t,draggables:n,destination:r,forceShouldAnimate:o})=>{const i=e.displaced,a=gc(i.all,n),l=Qt({afterDragging:a,destination:r,displacedBy:e.displacedBy,viewport:t.frame,forceShouldAnimate:o,last:i});return{...e,displaced:l}},Ii=({impact:e,draggable:t,droppable:n,draggables:r,viewport:o,afterCritical:i})=>{const a=kn({impact:e,draggable:t,draggables:r,droppable:n,afterCritical:i});return Sr({pageBorderBoxCenter:a,draggable:t,viewport:o})},Ni=({state:e,dimensions:t,viewport:n})=>{e.movementMode!=="SNAP"&&(process.env.NODE_ENV,h());const r=e.impact,o=n||e.viewport,i=t||e.dimensions,{draggables:a,droppables:l}=i,d=a[e.critical.draggable.id],c=_e(r);c||(process.env.NODE_ENV!=="production"?h(!1,"Must be over a destination in SNAP movement mode"):h());const f=l[c],p=Ci({impact:r,viewport:o,destination:f,draggables:a}),u=Ii({impact:p,draggable:d,droppable:f,draggables:a,viewport:o,afterCritical:e.afterCritical});return jt({impact:p,clientSelection:u,state:e,dimensions:i,viewport:o})},bc=e=>({index:e.index,droppableId:e.droppableId}),Si=({draggable:e,home:t,draggables:n,viewport:r})=>{const o=ln(t.axis,e.displaceBy),i=At(t.descriptor.id,n),a=i.indexOf(e);a===-1&&(process.env.NODE_ENV!=="production"?h(!1,"Expected draggable to be inside home list"):h());const l=i.slice(a+1),d=l.reduce((u,m)=>(u[m.descriptor.id]=!0,u),{}),c={inVirtualList:t.descriptor.mode==="virtual",displacedBy:o,effected:d};return{impact:{displaced:Qt({afterDragging:l,destination:t,displacedBy:o,last:null,viewport:r.frame,forceShouldAnimate:!1}),displacedBy:o,at:{type:"REORDER",destination:bc(e.descriptor)}},afterCritical:c}},yc=(e,t)=>({draggables:e.draggables,droppables:Or(e.droppables,t)});const cn=e=>{process.env.NODE_ENV},dn=e=>{process.env.NODE_ENV};var vc=({draggable:e,offset:t,initialWindowScroll:n})=>{const r=wn(e.client,t),o=Cn(r,n);return{...e,placeholder:{...e.placeholder,client:r},client:r,page:o}},xc=e=>{const t=e.frame;return t||(process.env.NODE_ENV!=="production"?h(!1,"Expected Droppable to have a frame"):h()),t},Dc=({additions:e,updatedDroppables:t,viewport:n})=>{const r=n.scroll.diff.value;return e.map(o=>{const i=o.descriptor.droppableId,a=t[i],d=xc(a).scroll.diff.value,c=Oe(r,d);return vc({draggable:o,offset:c,initialWindowScroll:n.scroll.initial})})},Ec=({state:e,published:t})=>{cn();const n=t.modified.map(D=>{const E=e.dimensions.droppables[D.droppableId];return Er(E,D.scroll)}),r={...e.dimensions.droppables,...ci(n)},o=di(Dc({additions:t.additions,updatedDroppables:r,viewport:e.viewport})),i={...e.dimensions.draggables,...o};t.removals.forEach(D=>{delete i[D]});const a={droppables:r,draggables:i},l=_e(e.impact),d=l?a.droppables[l]:null,c=a.draggables[e.critical.draggable.id],f=a.droppables[e.critical.droppable.id],{impact:p,afterCritical:u}=Si({draggable:c,home:f,draggables:i,viewport:e.viewport}),m=d&&d.isCombineEnabled?e.impact:p,g=wi({pageOffset:e.current.page.offset,draggable:a.draggables[e.critical.draggable.id],draggables:a.draggables,droppables:a.droppables,previousImpact:m,viewport:e.viewport,afterCritical:u});dn();const y={...e,phase:"DRAGGING",impact:g,onLiftImpact:p,dimensions:a,afterCritical:u,forceShouldAnimate:!1};return e.phase==="COLLECTING"?y:{...y,phase:"DROP_PENDING",reason:e.reason,isWaiting:!1}};const ir=e=>e.movementMode==="SNAP",Hn=(e,t,n)=>{const r=yc(e.dimensions,t);return!ir(e)||n?jt({state:e,dimensions:r}):Ni({state:e,dimensions:r})};function Un(e){return e.isDragging&&e.movementMode==="SNAP"?{...e,scrollJumpRequest:null}:e}const yo={phase:"IDLE",completed:null,shouldFlush:!1};var wc=(e=yo,t)=>{if(t.type==="FLUSH")return{...yo,shouldFlush:!0};if(t.type==="INITIAL_PUBLISH"){e.phase!=="IDLE"&&(process.env.NODE_ENV!=="production"?h(!1,"INITIAL_PUBLISH must come after a IDLE phase"):h());const{critical:n,clientSelection:r,viewport:o,dimensions:i,movementMode:a}=t.payload,l=i.draggables[n.draggable.id],d=i.droppables[n.droppable.id],c={selection:r,borderBoxCenter:l.client.borderBox.center,offset:Ie},f={client:c,page:{selection:Oe(c.selection,o.scroll.initial),borderBoxCenter:Oe(c.selection,o.scroll.initial),offset:Oe(c.selection,o.scroll.diff.value)}},p=Tn(i.droppables).every(y=>!y.isFixedOnPage),{impact:u,afterCritical:m}=Si({draggable:l,home:d,draggables:i.draggables,viewport:o});return{phase:"DRAGGING",isDragging:!0,critical:n,movementMode:a,dimensions:i,initial:f,current:f,isWindowScrollAllowed:p,impact:u,afterCritical:m,onLiftImpact:u,viewport:o,scrollJumpRequest:null,forceShouldAnimate:null}}if(t.type==="COLLECTION_STARTING")return e.phase==="COLLECTING"||e.phase==="DROP_PENDING"?e:(e.phase!=="DRAGGING"&&(process.env.NODE_ENV!=="production"?h(!1,`Collection cannot start from phase ${e.phase}`):h()),{...e,phase:"COLLECTING"});if(t.type==="PUBLISH_WHILE_DRAGGING")return e.phase==="COLLECTING"||e.phase==="DROP_PENDING"||(process.env.NODE_ENV!=="production"?h(!1,`Unexpected ${t.type} received in phase ${e.phase}`):h()),Ec({state:e,published:t.payload});if(t.type==="MOVE"){if(e.phase==="DROP_PENDING")return e;Ct(e)||(process.env.NODE_ENV!=="production"?h(!1,`${t.type} not permitted in phase ${e.phase}`):h());const{client:n}=t.payload;return vt(n,e.current.client.selection)?e:jt({state:e,clientSelection:n,impact:ir(e)?e.impact:null})}if(t.type==="UPDATE_DROPPABLE_SCROLL"){if(e.phase==="DROP_PENDING"||e.phase==="COLLECTING")return Un(e);Ct(e)||(process.env.NODE_ENV!=="production"?h(!1,`${t.type} not permitted in phase ${e.phase}`):h());const{id:n,newScroll:r}=t.payload,o=e.dimensions.droppables[n];if(!o)return e;const i=Er(o,r);return Hn(e,i,!1)}if(t.type==="UPDATE_DROPPABLE_IS_ENABLED"){if(e.phase==="DROP_PENDING")return e;Ct(e)||(process.env.NODE_ENV!=="production"?h(!1,`Attempting to move in an unsupported phase ${e.phase}`):h());const{id:n,isEnabled:r}=t.payload,o=e.dimensions.droppables[n];o||(process.env.NODE_ENV!=="production"?h(!1,`Cannot find Droppable[id: ${n}] to toggle its enabled state`):h()),o.isEnabled===r&&(process.env.NODE_ENV!=="production"?h(!1,`Trying to set droppable isEnabled to ${String(r)}
47
+ but it is already ${String(o.isEnabled)}`):h());const i={...o,isEnabled:r};return Hn(e,i,!0)}if(t.type==="UPDATE_DROPPABLE_IS_COMBINE_ENABLED"){if(e.phase==="DROP_PENDING")return e;Ct(e)||(process.env.NODE_ENV!=="production"?h(!1,`Attempting to move in an unsupported phase ${e.phase}`):h());const{id:n,isCombineEnabled:r}=t.payload,o=e.dimensions.droppables[n];o||(process.env.NODE_ENV!=="production"?h(!1,`Cannot find Droppable[id: ${n}] to toggle its isCombineEnabled state`):h()),o.isCombineEnabled===r&&(process.env.NODE_ENV!=="production"?h(!1,`Trying to set droppable isCombineEnabled to ${String(r)}
48
+ but it is already ${String(o.isCombineEnabled)}`):h());const i={...o,isCombineEnabled:r};return Hn(e,i,!0)}if(t.type==="MOVE_BY_WINDOW_SCROLL"){if(e.phase==="DROP_PENDING"||e.phase==="DROP_ANIMATING")return e;Ct(e)||(process.env.NODE_ENV!=="production"?h(!1,`Cannot move by window in phase ${e.phase}`):h()),e.isWindowScrollAllowed||(process.env.NODE_ENV!=="production"?h(!1,"Window scrolling is currently not supported for fixed lists"):h());const n=t.payload.newScroll;if(vt(e.viewport.scroll.current,n))return Un(e);const r=gi(e.viewport,n);return ir(e)?Ni({state:e,viewport:r}):jt({state:e,viewport:r})}if(t.type==="UPDATE_VIEWPORT_MAX_SCROLL"){if(!Ct(e))return e;const n=t.payload.maxScroll;if(vt(n,e.viewport.scroll.max))return e;const r={...e.viewport,scroll:{...e.viewport.scroll,max:n}};return{...e,viewport:r}}if(t.type==="MOVE_UP"||t.type==="MOVE_DOWN"||t.type==="MOVE_LEFT"||t.type==="MOVE_RIGHT"){if(e.phase==="COLLECTING"||e.phase==="DROP_PENDING")return e;e.phase!=="DRAGGING"&&(process.env.NODE_ENV!=="production"?h(!1,`${t.type} received while not in DRAGGING phase`):h());const n=ic({state:e,type:t.type});return n?jt({state:e,impact:n.impact,clientSelection:n.clientSelection,scrollJumpRequest:n.scrollJumpRequest}):e}if(t.type==="DROP_PENDING"){const n=t.payload.reason;return e.phase!=="COLLECTING"&&(process.env.NODE_ENV!=="production"?h(!1,"Can only move into the DROP_PENDING phase from the COLLECTING phase"):h()),{...e,phase:"DROP_PENDING",isWaiting:!0,reason:n}}if(t.type==="DROP_ANIMATE"){const{completed:n,dropDuration:r,newHomeClientOffset:o}=t.payload;return e.phase==="DRAGGING"||e.phase==="DROP_PENDING"||(process.env.NODE_ENV!=="production"?h(!1,`Cannot animate drop from phase ${e.phase}`):h()),{phase:"DROP_ANIMATING",completed:n,dropDuration:r,newHomeClientOffset:o,dimensions:e.dimensions}}if(t.type==="DROP_COMPLETE"){const{completed:n}=t.payload;return{phase:"IDLE",completed:n,shouldFlush:!1}}return e};function Y(e,t){return e instanceof Object&&"type"in e&&e.type===t}const Cc=e=>({type:"BEFORE_INITIAL_CAPTURE",payload:e}),Ic=e=>({type:"LIFT",payload:e}),Nc=e=>({type:"INITIAL_PUBLISH",payload:e}),Sc=e=>({type:"PUBLISH_WHILE_DRAGGING",payload:e}),Oc=()=>({type:"COLLECTION_STARTING",payload:null}),Pc=e=>({type:"UPDATE_DROPPABLE_SCROLL",payload:e}),Ac=e=>({type:"UPDATE_DROPPABLE_IS_ENABLED",payload:e}),Rc=e=>({type:"UPDATE_DROPPABLE_IS_COMBINE_ENABLED",payload:e}),Oi=e=>({type:"MOVE",payload:e}),Tc=e=>({type:"MOVE_BY_WINDOW_SCROLL",payload:e}),Bc=e=>({type:"UPDATE_VIEWPORT_MAX_SCROLL",payload:e}),$c=()=>({type:"MOVE_UP",payload:null}),kc=()=>({type:"MOVE_DOWN",payload:null}),_c=()=>({type:"MOVE_RIGHT",payload:null}),Fc=()=>({type:"MOVE_LEFT",payload:null}),Pr=()=>({type:"FLUSH",payload:null}),Lc=e=>({type:"DROP_ANIMATE",payload:e}),Ar=e=>({type:"DROP_COMPLETE",payload:e}),Pi=e=>({type:"DROP",payload:e}),Vc=e=>({type:"DROP_PENDING",payload:e}),Ai=()=>({type:"DROP_ANIMATION_FINISHED",payload:null});function Mc(e){if(e.length<=1)return;const t=e.map(o=>o.descriptor.index),n={};for(let o=1;o<t.length;o++){const i=t[o],a=t[o-1];i!==a+1&&(n[i]=!0)}if(!Object.keys(n).length)return;const r=t.map(o=>!!n[o]?`[🔥${o}]`:`${o}`).join(", ");process.env.NODE_ENV!=="production"&&re(`
49
+ Detected non-consecutive <Draggable /> indexes.
50
+
51
+ (This can cause unexpected bugs)
52
+
53
+ ${r}
54
+ `)}function Wc(e,t){if(process.env.NODE_ENV!=="production"){const n=At(e.droppable.id,t.draggables);Mc(n)}}var Gc=e=>({getState:t,dispatch:n})=>r=>o=>{if(!Y(o,"LIFT")){r(o);return}const{id:i,clientSelection:a,movementMode:l}=o.payload,d=t();d.phase==="DROP_ANIMATING"&&n(Ar({completed:d.completed})),t().phase!=="IDLE"&&(process.env.NODE_ENV!=="production"?h(!1,"Unexpected phase to start a drag"):h()),n(Pr()),n(Cc({draggableId:i,movementMode:l}));const f={draggableId:i,scrollOptions:{shouldPublishImmediately:l==="SNAP"}},{critical:p,dimensions:u,viewport:m}=e.startPublishing(f);Wc(p,u),n(Nc({critical:p,dimensions:u,clientSelection:a,movementMode:l,viewport:m}))},zc=e=>()=>t=>n=>{Y(n,"INITIAL_PUBLISH")&&e.dragging(),Y(n,"DROP_ANIMATE")&&e.dropping(n.payload.completed.result.reason),(Y(n,"FLUSH")||Y(n,"DROP_COMPLETE"))&&e.resting(),t(n)};const Rr={outOfTheWay:"cubic-bezier(0.2, 0, 0, 1)",drop:"cubic-bezier(.2,1,.1,1)"},Zt={opacity:{drop:0,combining:.7},scale:{drop:.75}},Ri={outOfTheWay:.2,minDropTime:.33,maxDropTime:.55},wt=`${Ri.outOfTheWay}s ${Rr.outOfTheWay}`,qt={fluid:`opacity ${wt}`,snap:`transform ${wt}, opacity ${wt}`,drop:e=>{const t=`${e}s ${Rr.drop}`;return`transform ${t}, opacity ${t}`},outOfTheWay:`transform ${wt}`,placeholder:`height ${wt}, width ${wt}, margin ${wt}`},vo=e=>vt(e,Ie)?void 0:`translate(${e.x}px, ${e.y}px)`,ar={moveTo:vo,drop:(e,t)=>{const n=vo(e);if(n)return t?`${n} scale(${Zt.scale.drop})`:n}},{minDropTime:sr,maxDropTime:Ti}=Ri,Hc=Ti-sr,xo=1500,Uc=.6;var jc=({current:e,destination:t,reason:n})=>{const r=Xt(e,t);if(r<=0)return sr;if(r>=xo)return Ti;const o=r/xo,i=sr+Hc*o,a=n==="CANCEL"?i*Uc:i;return Number(a.toFixed(2))},qc=({impact:e,draggable:t,dimensions:n,viewport:r,afterCritical:o})=>{const{draggables:i,droppables:a}=n,l=_e(e),d=l?a[l]:null,c=a[t.descriptor.droppableId],f=Ii({impact:e,draggable:t,draggables:i,afterCritical:o,droppable:d||c,viewport:r});return ke(f,t.client.borderBox.center)},Kc=({draggables:e,reason:t,lastImpact:n,home:r,viewport:o,onLiftImpact:i})=>!n.at||t!=="DROP"?{impact:Ci({draggables:e,impact:i,destination:r,viewport:o,forceShouldAnimate:!0}),didDropInsideDroppable:!1}:n.at.type==="REORDER"?{impact:n,didDropInsideDroppable:!0}:{impact:{...n,displaced:Jt},didDropInsideDroppable:!0};const Yc=({getState:e,dispatch:t})=>n=>r=>{if(!Y(r,"DROP")){n(r);return}const o=e(),i=r.payload.reason;if(o.phase==="COLLECTING"){t(Vc({reason:i}));return}if(o.phase==="IDLE")return;o.phase==="DROP_PENDING"&&o.isWaiting&&(process.env.NODE_ENV!=="production"?h(!1,"A DROP action occurred while DROP_PENDING and still waiting"):h()),o.phase==="DRAGGING"||o.phase==="DROP_PENDING"||(process.env.NODE_ENV!=="production"?h(!1,`Cannot drop in phase: ${o.phase}`):h());const l=o.critical,d=o.dimensions,c=d.draggables[o.critical.draggable.id],{impact:f,didDropInsideDroppable:p}=Kc({reason:i,lastImpact:o.impact,afterCritical:o.afterCritical,onLiftImpact:o.onLiftImpact,home:o.dimensions.droppables[o.critical.droppable.id],viewport:o.viewport,draggables:o.dimensions.draggables}),u=p?wr(f):null,m=p?Bn(f):null,g={index:l.draggable.index,droppableId:l.droppable.id},y={draggableId:c.descriptor.id,type:c.descriptor.type,source:g,reason:i,mode:o.movementMode,destination:u,combine:m},b=qc({impact:f,draggable:c,dimensions:d,viewport:o.viewport,afterCritical:o.afterCritical}),D={critical:o.critical,afterCritical:o.afterCritical,result:y,impact:f};if(!(!vt(o.current.client.offset,b)||!!y.combine)){t(Ar({completed:D}));return}const S=jc({current:o.current.client.offset,destination:b,reason:i});t(Lc({newHomeClientOffset:b,dropDuration:S,completed:D}))};var Bi=()=>({x:window.pageXOffset,y:window.pageYOffset});function Xc(e){return{eventName:"scroll",options:{passive:!0,capture:!1},fn:t=>{t.target!==window&&t.target!==window.document||e()}}}function Jc({onWindowScroll:e}){function t(){e(Bi())}const n=Kt(t),r=Xc(n);let o=yt;function i(){return o!==yt}function a(){i()&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot start scroll listener when already active"):h()),o=Ge(window,[r])}function l(){i()||(process.env.NODE_ENV!=="production"?h(!1,"Cannot stop scroll listener when not active"):h()),n.cancel(),o(),o=yt}return{start:a,stop:l,isActive:i}}const Qc=e=>Y(e,"DROP_COMPLETE")||Y(e,"DROP_ANIMATE")||Y(e,"FLUSH"),Zc=e=>{const t=Jc({onWindowScroll:n=>{e.dispatch(Tc({newScroll:n}))}});return n=>r=>{!t.isActive()&&Y(r,"INITIAL_PUBLISH")&&t.start(),t.isActive()&&Qc(r)&&t.stop(),n(r)}};var ed=e=>{let t=!1,n=!1;const r=setTimeout(()=>{n=!0}),o=i=>{if(t){process.env.NODE_ENV!=="production"&&re("Announcement already made. Not making a second announcement");return}if(n){process.env.NODE_ENV!=="production"&&re(`
55
+ Announcements cannot be made asynchronously.
56
+ Default message has already been announced.
57
+ `);return}t=!0,e(i),clearTimeout(r)};return o.wasCalled=()=>t,o},td=()=>{const e=[],t=o=>{const i=e.findIndex(l=>l.timerId===o);i===-1&&(process.env.NODE_ENV!=="production"?h(!1,"Could not find timer"):h());const[a]=e.splice(i,1);a.callback()};return{add:o=>{const i=setTimeout(()=>t(i)),a={timerId:i,callback:o};e.push(a)},flush:()=>{if(!e.length)return;const o=[...e];e.length=0,o.forEach(i=>{clearTimeout(i.timerId),i.callback()})}}};const nd=(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:e.droppableId===t.droppableId&&e.index===t.index,rd=(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:e.draggableId===t.draggableId&&e.droppableId===t.droppableId,od=(e,t)=>{if(e===t)return!0;const n=e.draggable.id===t.draggable.id&&e.draggable.droppableId===t.draggable.droppableId&&e.draggable.type===t.draggable.type&&e.draggable.index===t.draggable.index,r=e.droppable.id===t.droppable.id&&e.droppable.type===t.droppable.type;return n&&r},Gt=(e,t)=>{cn(),t(),dn()},yn=(e,t)=>({draggableId:e.draggable.id,type:e.droppable.type,source:{droppableId:e.droppable.id,index:e.draggable.index},mode:t});function jn(e,t,n,r){if(!e){n(r(t));return}const o=ed(n);e(t,{announce:o}),o.wasCalled()||n(r(t))}var id=(e,t)=>{const n=td();let r=null;const o=(p,u)=>{r&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot fire onBeforeCapture as a drag start has already been published"):h()),Gt("onBeforeCapture",()=>{const m=e().onBeforeCapture;m&&m({draggableId:p,mode:u})})},i=(p,u)=>{r&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot fire onBeforeDragStart as a drag start has already been published"):h()),Gt("onBeforeDragStart",()=>{const m=e().onBeforeDragStart;m&&m(yn(p,u))})},a=(p,u)=>{r&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot fire onBeforeDragStart as a drag start has already been published"):h());const m=yn(p,u);r={mode:u,lastCritical:p,lastLocation:m.source,lastCombine:null},n.add(()=>{Gt("onDragStart",()=>jn(e().onDragStart,m,t,Dn.onDragStart))})},l=(p,u)=>{const m=wr(u),g=Bn(u);r||(process.env.NODE_ENV!=="production"?h(!1,"Cannot fire onDragMove when onDragStart has not been called"):h());const y=!od(p,r.lastCritical);y&&(r.lastCritical=p);const b=!nd(r.lastLocation,m);b&&(r.lastLocation=m);const D=!rd(r.lastCombine,g);if(D&&(r.lastCombine=g),!y&&!b&&!D)return;const E={...yn(p,r.mode),combine:g,destination:m};n.add(()=>{Gt("onDragUpdate",()=>jn(e().onDragUpdate,E,t,Dn.onDragUpdate))})},d=()=>{r||(process.env.NODE_ENV!=="production"?h(!1,"Can only flush responders while dragging"):h()),n.flush()},c=p=>{r||(process.env.NODE_ENV!=="production"?h(!1,"Cannot fire onDragEnd when there is no matching onDragStart"):h()),r=null,Gt("onDragEnd",()=>jn(e().onDragEnd,p,t,Dn.onDragEnd))};return{beforeCapture:o,beforeStart:i,start:a,update:l,flush:d,drop:c,abort:()=>{if(!r)return;const p={...yn(r.lastCritical,r.mode),combine:null,destination:null,reason:"CANCEL"};c(p)}}},ad=(e,t)=>{const n=id(e,t);return r=>o=>i=>{if(Y(i,"BEFORE_INITIAL_CAPTURE")){n.beforeCapture(i.payload.draggableId,i.payload.movementMode);return}if(Y(i,"INITIAL_PUBLISH")){const l=i.payload.critical;n.beforeStart(l,i.payload.movementMode),o(i),n.start(l,i.payload.movementMode);return}if(Y(i,"DROP_COMPLETE")){const l=i.payload.completed.result;n.flush(),o(i),n.drop(l);return}if(o(i),Y(i,"FLUSH")){n.abort();return}const a=r.getState();a.phase==="DRAGGING"&&n.update(a.critical,a.impact)}};const sd=e=>t=>n=>{if(!Y(n,"DROP_ANIMATION_FINISHED")){t(n);return}const r=e.getState();r.phase!=="DROP_ANIMATING"&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot finish a drop animating when no drop is occurring"):h()),e.dispatch(Ar({completed:r.completed}))},ld=e=>{let t=null,n=null;function r(){n&&(cancelAnimationFrame(n),n=null),t&&(t(),t=null)}return o=>i=>{if((Y(i,"FLUSH")||Y(i,"DROP_COMPLETE")||Y(i,"DROP_ANIMATION_FINISHED"))&&r(),o(i),!Y(i,"DROP_ANIMATE"))return;const a={eventName:"scroll",options:{capture:!0,passive:!1,once:!0},fn:function(){e.getState().phase==="DROP_ANIMATING"&&e.dispatch(Ai())}};n=requestAnimationFrame(()=>{n=null,t=Ge(window,[a])})}};var cd=e=>()=>t=>n=>{(Y(n,"DROP_COMPLETE")||Y(n,"FLUSH")||Y(n,"DROP_ANIMATE"))&&e.stopPublishing(),t(n)},dd=e=>{let t=!1;return()=>n=>r=>{if(Y(r,"INITIAL_PUBLISH")){t=!0,e.tryRecordFocus(r.payload.critical.draggable.id),n(r),e.tryRestoreFocusRecorded();return}if(n(r),!!t){if(Y(r,"FLUSH")){t=!1,e.tryRestoreFocusRecorded();return}if(Y(r,"DROP_COMPLETE")){t=!1;const o=r.payload.completed.result;o.combine&&e.tryShiftRecord(o.draggableId,o.combine.draggableId),e.tryRestoreFocusRecorded()}}}};const ud=e=>Y(e,"DROP_COMPLETE")||Y(e,"DROP_ANIMATE")||Y(e,"FLUSH");var pd=e=>t=>n=>r=>{if(ud(r)){e.stop(),n(r);return}if(Y(r,"INITIAL_PUBLISH")){n(r);const o=t.getState();o.phase!=="DRAGGING"&&(process.env.NODE_ENV!=="production"?h(!1,"Expected phase to be DRAGGING after INITIAL_PUBLISH"):h()),e.start(o);return}n(r),e.scroll(t.getState())};const fd=e=>t=>n=>{if(t(n),!Y(n,"PUBLISH_WHILE_DRAGGING"))return;const r=e.getState();r.phase==="DROP_PENDING"&&(r.isWaiting||e.dispatch(Pi({reason:r.reason})))},md=process.env.NODE_ENV!=="production"&&typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({name:"@hello-pangea/dnd"}):Wa;var hd=({dimensionMarshal:e,focusMarshal:t,styleMarshal:n,getResponders:r,announce:o,autoScroller:i})=>Ma(wc,md(Ga(zc(n),cd(e),Gc(e),Yc,sd,ld,fd,pd(i),Zc,dd(t),ad(r,o))));const qn=()=>({additions:{},removals:{},modified:{}});function gd({registry:e,callbacks:t}){let n=qn(),r=null;const o=()=>{r||(t.collectionStarting(),r=requestAnimationFrame(()=>{r=null,cn();const{additions:d,removals:c,modified:f}=n,p=Object.keys(d).map(g=>e.draggable.getById(g).getDimension(Ie)).sort((g,y)=>g.descriptor.index-y.descriptor.index),u=Object.keys(f).map(g=>{const b=e.droppable.getById(g).callbacks.getScrollWhileDragging();return{droppableId:g,scroll:b}}),m={additions:p,removals:Object.keys(c),modified:u};n=qn(),dn(),t.publish(m)}))};return{add:d=>{const c=d.descriptor.id;n.additions[c]=d,n.modified[d.descriptor.droppableId]=!0,n.removals[c]&&delete n.removals[c],o()},remove:d=>{const c=d.descriptor;n.removals[c.id]=!0,n.modified[c.droppableId]=!0,n.additions[c.id]&&delete n.additions[c.id],o()},stop:()=>{r&&(cancelAnimationFrame(r),r=null,n=qn())}}}var $i=({scrollHeight:e,scrollWidth:t,height:n,width:r})=>{const o=ke({x:t,y:e},{x:r,y:n});return{x:Math.max(0,o.x),y:Math.max(0,o.y)}},ki=()=>{const e=document.documentElement;return e||(process.env.NODE_ENV!=="production"?h(!1,"Cannot find document.documentElement"):h()),e},_i=()=>{const e=ki();return $i({scrollHeight:e.scrollHeight,scrollWidth:e.scrollWidth,width:e.clientWidth,height:e.clientHeight})},bd=()=>{const e=Bi(),t=_i(),n=e.y,r=e.x,o=ki(),i=o.clientWidth,a=o.clientHeight,l=r+i,d=n+a;return{frame:qe({top:n,left:r,right:l,bottom:d}),scroll:{initial:e,current:e,max:t,diff:{value:Ie,displacement:Ie}}}},yd=({critical:e,scrollOptions:t,registry:n})=>{cn();const r=bd(),o=r.scroll.current,i=e.droppable,a=n.droppable.getAllByType(i.type).map(f=>f.callbacks.getDimensionAndWatchScroll(o,t)),l=n.draggable.getAllByType(e.draggable.type).map(f=>f.getDimension(o)),d={draggables:di(l),droppables:ci(a)};return dn(),{dimensions:d,critical:e,viewport:r}};function Do(e,t,n){return n.descriptor.id===t.id||n.descriptor.type!==t.type?!1:e.droppable.getById(n.descriptor.droppableId).descriptor.mode!=="virtual"?(process.env.NODE_ENV!=="production"&&re(`
58
+ You are attempting to add or remove a Draggable [id: ${n.descriptor.id}]
59
+ while a drag is occurring. This is only supported for virtual lists.
60
+
61
+ See https://github.com/hello-pangea/dnd/blob/main/docs/patterns/virtual-lists.md
62
+ `),!1):!0}var vd=(e,t)=>{let n=null;const r=gd({callbacks:{publish:t.publishWhileDragging,collectionStarting:t.collectionStarting},registry:e}),o=(u,m)=>{e.droppable.exists(u)||(process.env.NODE_ENV!=="production"?h(!1,`Cannot update is enabled flag of Droppable ${u} as it is not registered`):h()),n&&t.updateDroppableIsEnabled({id:u,isEnabled:m})},i=(u,m)=>{n&&(e.droppable.exists(u)||(process.env.NODE_ENV!=="production"?h(!1,`Cannot update isCombineEnabled flag of Droppable ${u} as it is not registered`):h()),t.updateDroppableIsCombineEnabled({id:u,isCombineEnabled:m}))},a=(u,m)=>{n&&(e.droppable.exists(u)||(process.env.NODE_ENV!=="production"?h(!1,`Cannot update the scroll on Droppable ${u} as it is not registered`):h()),t.updateDroppableScroll({id:u,newScroll:m}))},l=(u,m)=>{n&&e.droppable.getById(u).callbacks.scroll(m)},d=()=>{if(!n)return;r.stop();const u=n.critical.droppable;e.droppable.getAllByType(u.type).forEach(m=>m.callbacks.dragStopped()),n.unsubscribe(),n=null},c=u=>{n||(process.env.NODE_ENV!=="production"?h(!1,"Should only be subscribed when a collection is occurring"):h());const m=n.critical.draggable;u.type==="ADDITION"&&Do(e,m,u.value)&&r.add(u.value),u.type==="REMOVAL"&&Do(e,m,u.value)&&r.remove(u.value)};return{updateDroppableIsEnabled:o,updateDroppableIsCombineEnabled:i,scrollDroppable:l,updateDroppableScroll:a,startPublishing:u=>{n&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot start capturing critical dimensions as there is already a collection"):h());const m=e.draggable.getById(u.draggableId),g=e.droppable.getById(m.descriptor.droppableId),y={draggable:m.descriptor,droppable:g.descriptor},b=e.subscribe(c);return n={critical:y,unsubscribe:b},yd({critical:y,registry:e,scrollOptions:u.scrollOptions})},stopPublishing:d}},Fi=(e,t)=>e.phase==="IDLE"?!0:e.phase!=="DROP_ANIMATING"||e.completed.result.draggableId===t?!1:e.completed.result.reason==="DROP",xd=e=>{window.scrollBy(e.x,e.y)};const Dd=Ce(e=>Tn(e).filter(t=>!(!t.isEnabled||!t.frame))),Ed=(e,t)=>Dd(t).find(r=>(r.frame||(process.env.NODE_ENV!=="production"?h(!1,"Invalid result"):h()),xi(r.frame.pageMarginBox)(e)))||null;var wd=({center:e,destination:t,droppables:n})=>{if(t){const o=n[t];return o.frame?o:null}return Ed(e,n)};const en={startFromPercentage:.25,maxScrollAtPercentage:.05,maxPixelScroll:28,ease:e=>e**2,durationDampening:{stopDampeningAt:1200,accelerateAt:360},disabled:!1};var Cd=(e,t,n=()=>en)=>{const r=n(),o=e[t.size]*r.startFromPercentage,i=e[t.size]*r.maxScrollAtPercentage;return{startScrollingFrom:o,maxScrollValueAt:i}},Li=({startOfRange:e,endOfRange:t,current:n})=>{const r=t-e;return r===0?(process.env.NODE_ENV!=="production"&&re(`
63
+ Detected distance range of 0 in the fluid auto scroller
64
+ This is unexpected and would cause a divide by 0 issue.
65
+ Not allowing an auto scroll
66
+ `),0):(n-e)/r},Tr=1,Id=(e,t,n=()=>en)=>{const r=n();if(e>t.startScrollingFrom)return 0;if(e<=t.maxScrollValueAt)return r.maxPixelScroll;if(e===t.startScrollingFrom)return Tr;const i=1-Li({startOfRange:t.maxScrollValueAt,endOfRange:t.startScrollingFrom,current:e}),a=r.maxPixelScroll*r.ease(i);return Math.ceil(a)},Nd=(e,t,n)=>{const r=n(),o=r.durationDampening.accelerateAt,i=r.durationDampening.stopDampeningAt,a=t,l=i,c=Date.now()-a;if(c>=i)return e;if(c<o)return Tr;const f=Li({startOfRange:o,endOfRange:l,current:c}),p=e*r.ease(f);return Math.ceil(p)},Eo=({distanceToEdge:e,thresholds:t,dragStartTime:n,shouldUseTimeDampening:r,getAutoScrollerOptions:o})=>{const i=Id(e,t,o);return i===0?0:r?Math.max(Nd(i,n,o),Tr):i},wo=({container:e,distanceToEdges:t,dragStartTime:n,axis:r,shouldUseTimeDampening:o,getAutoScrollerOptions:i})=>{const a=Cd(e,r,i);return t[r.end]<t[r.start]?Eo({distanceToEdge:t[r.end],thresholds:a,dragStartTime:n,shouldUseTimeDampening:o,getAutoScrollerOptions:i}):-1*Eo({distanceToEdge:t[r.start],thresholds:a,dragStartTime:n,shouldUseTimeDampening:o,getAutoScrollerOptions:i})},Sd=({container:e,subject:t,proposedScroll:n})=>{const r=t.height>e.height,o=t.width>e.width;return!o&&!r?n:o&&r?null:{x:o?0:n.x,y:r?0:n.y}};const Od=li(e=>e===0?0:e);var Vi=({dragStartTime:e,container:t,subject:n,center:r,shouldUseTimeDampening:o,getAutoScrollerOptions:i})=>{const a={top:r.y-t.top,right:t.right-r.x,bottom:t.bottom-r.y,left:r.x-t.left},l=wo({container:t,distanceToEdges:a,dragStartTime:e,axis:Cr,shouldUseTimeDampening:o,getAutoScrollerOptions:i}),d=wo({container:t,distanceToEdges:a,dragStartTime:e,axis:fi,shouldUseTimeDampening:o,getAutoScrollerOptions:i}),c=Od({x:d,y:l});if(vt(c,Ie))return null;const f=Sd({container:t,subject:n,proposedScroll:c});return f?vt(f,Ie)?null:f:null};const Pd=li(e=>e===0?0:e>0?1:-1),Br=(()=>{const e=(t,n)=>t<0?t:t>n?t-n:0;return({current:t,max:n,change:r})=>{const o=Oe(t,r),i={x:e(o.x,n.x),y:e(o.y,n.y)};return vt(i,Ie)?null:i}})(),Mi=({max:e,current:t,change:n})=>{const r={x:Math.max(t.x,e.x),y:Math.max(t.y,e.y)},o=Pd(n),i=Br({max:r,current:t,change:o});return!i||o.x!==0&&i.x===0||o.y!==0&&i.y===0},$r=(e,t)=>Mi({current:e.scroll.current,max:e.scroll.max,change:t}),Ad=(e,t)=>{if(!$r(e,t))return null;const n=e.scroll.max,r=e.scroll.current;return Br({current:r,max:n,change:t})},kr=(e,t)=>{const n=e.frame;return n?Mi({current:n.scroll.current,max:n.scroll.max,change:t}):!1},Rd=(e,t)=>{const n=e.frame;return!n||!kr(e,t)?null:Br({current:n.scroll.current,max:n.scroll.max,change:t})};var Td=({viewport:e,subject:t,center:n,dragStartTime:r,shouldUseTimeDampening:o,getAutoScrollerOptions:i})=>{const a=Vi({dragStartTime:r,container:e.frame,subject:t,center:n,shouldUseTimeDampening:o,getAutoScrollerOptions:i});return a&&$r(e,a)?a:null},Bd=({droppable:e,subject:t,center:n,dragStartTime:r,shouldUseTimeDampening:o,getAutoScrollerOptions:i})=>{const a=e.frame;if(!a)return null;const l=Vi({dragStartTime:r,container:a.pageMarginBox,subject:t,center:n,shouldUseTimeDampening:o,getAutoScrollerOptions:i});return l&&kr(e,l)?l:null},Co=({state:e,dragStartTime:t,shouldUseTimeDampening:n,scrollWindow:r,scrollDroppable:o,getAutoScrollerOptions:i})=>{const a=e.current.page.borderBoxCenter,d=e.dimensions.draggables[e.critical.draggable.id].page.marginBox;if(e.isWindowScrollAllowed){const p=e.viewport,u=Td({dragStartTime:t,viewport:p,subject:d,center:a,shouldUseTimeDampening:n,getAutoScrollerOptions:i});if(u){r(u);return}}const c=wd({center:a,destination:_e(e.impact),droppables:e.dimensions.droppables});if(!c)return;const f=Bd({dragStartTime:t,droppable:c,subject:d,center:a,shouldUseTimeDampening:n,getAutoScrollerOptions:i});f&&o(c.descriptor.id,f)},$d=({scrollWindow:e,scrollDroppable:t,getAutoScrollerOptions:n=()=>en})=>{const r=Kt(e),o=Kt(t);let i=null;const a=c=>{i||(process.env.NODE_ENV!=="production"?h(!1,"Cannot fluid scroll if not dragging"):h());const{shouldUseTimeDampening:f,dragStartTime:p}=i;Co({state:c,scrollWindow:r,scrollDroppable:o,dragStartTime:p,shouldUseTimeDampening:f,getAutoScrollerOptions:n})};return{start:c=>{cn(),i&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot start auto scrolling when already started"):h());const f=Date.now();let p=!1;const u=()=>{p=!0};Co({state:c,dragStartTime:0,shouldUseTimeDampening:!1,scrollWindow:u,scrollDroppable:u,getAutoScrollerOptions:n}),i={dragStartTime:f,shouldUseTimeDampening:p},dn(),p&&a(c)},stop:()=>{i&&(r.cancel(),o.cancel(),i=null)},scroll:a}},kd=({move:e,scrollDroppable:t,scrollWindow:n})=>{const r=(l,d)=>{const c=Oe(l.current.client.selection,d);e({client:c})},o=(l,d)=>{if(!kr(l,d))return d;const c=Rd(l,d);if(!c)return t(l.descriptor.id,d),null;const f=ke(d,c);return t(l.descriptor.id,f),ke(d,f)},i=(l,d,c)=>{if(!l||!$r(d,c))return c;const f=Ad(d,c);if(!f)return n(c),null;const p=ke(c,f);return n(p),ke(c,p)};return l=>{const d=l.scrollJumpRequest;if(!d)return;const c=_e(l.impact);c||(process.env.NODE_ENV!=="production"?h(!1,"Cannot perform a jump scroll when there is no destination"):h());const f=o(l.dimensions.droppables[c],d);if(!f)return;const p=l.viewport,u=i(l.isWindowScrollAllowed,p,f);u&&r(l,u)}},_d=({scrollDroppable:e,scrollWindow:t,move:n,getAutoScrollerOptions:r})=>{const o=$d({scrollWindow:t,scrollDroppable:e,getAutoScrollerOptions:r}),i=kd({move:n,scrollWindow:t,scrollDroppable:e});return{scroll:d=>{if(!(r().disabled||d.phase!=="DRAGGING")){if(d.movementMode==="FLUID"){o.scroll(d);return}d.scrollJumpRequest&&i(d)}},start:o.start,stop:o.stop}};const kt="data-rfd",_t=(()=>{const e=`${kt}-drag-handle`;return{base:e,draggableId:`${e}-draggable-id`,contextId:`${e}-context-id`}})(),lr=(()=>{const e=`${kt}-draggable`;return{base:e,contextId:`${e}-context-id`,id:`${e}-id`}})(),Fd=(()=>{const e=`${kt}-droppable`;return{base:e,contextId:`${e}-context-id`,id:`${e}-id`}})(),Io={contextId:`${kt}-scroll-container-context-id`},Ld=e=>t=>`[${t}="${e}"]`,zt=(e,t)=>e.map(n=>{const r=n.styles[t];return r?`${n.selector} { ${r} }`:""}).join(" "),Vd="pointer-events: none;";var Md=e=>{const t=Ld(e),n=(()=>{const l=`
67
+ cursor: -webkit-grab;
68
+ cursor: grab;
69
+ `;return{selector:t(_t.contextId),styles:{always:`
70
+ -webkit-touch-callout: none;
71
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
72
+ touch-action: manipulation;
73
+ `,resting:l,dragging:Vd,dropAnimating:l}}})(),r=(()=>{const l=`
74
+ transition: ${qt.outOfTheWay};
75
+ `;return{selector:t(lr.contextId),styles:{dragging:l,dropAnimating:l,userCancel:l}}})(),o={selector:t(Fd.contextId),styles:{always:"overflow-anchor: none;"}},a=[r,n,o,{selector:"body",styles:{dragging:`
76
+ cursor: grabbing;
77
+ cursor: -webkit-grabbing;
78
+ user-select: none;
79
+ -webkit-user-select: none;
80
+ -moz-user-select: none;
81
+ -ms-user-select: none;
82
+ overflow-anchor: none;
83
+ `}}];return{always:zt(a,"always"),resting:zt(a,"resting"),dragging:zt(a,"dragging"),dropAnimating:zt(a,"dropAnimating"),userCancel:zt(a,"userCancel")}};const Fe=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?wa:we,Kn=()=>{const e=document.querySelector("head");return e||(process.env.NODE_ENV!=="production"?h(!1,"Cannot find the head to append a style to"):h()),e},No=e=>{const t=document.createElement("style");return e&&t.setAttribute("nonce",e),t.type="text/css",t};function Wd(e,t){const n=G(()=>Md(e),[e]),r=H(null),o=H(null),i=I(Ce(p=>{const u=o.current;u||(process.env.NODE_ENV!=="production"?h(!1,"Cannot set dynamic style element if it is not set"):h()),u.textContent=p}),[]),a=I(p=>{const u=r.current;u||(process.env.NODE_ENV!=="production"?h(!1,"Cannot set dynamic style element if it is not set"):h()),u.textContent=p},[]);Fe(()=>{!r.current&&!o.current||(process.env.NODE_ENV!=="production"?h(!1,"style elements already mounted"):h());const p=No(t),u=No(t);return r.current=p,o.current=u,p.setAttribute(`${kt}-always`,e),u.setAttribute(`${kt}-dynamic`,e),Kn().appendChild(p),Kn().appendChild(u),a(n.always),i(n.resting),()=>{const m=g=>{const y=g.current;y||(process.env.NODE_ENV!=="production"?h(!1,"Cannot unmount ref as it is not set"):h()),Kn().removeChild(y),g.current=null};m(r),m(o)}},[t,a,i,n.always,n.resting,e]);const l=I(()=>i(n.dragging),[i,n.dragging]),d=I(p=>{if(p==="DROP"){i(n.dropAnimating);return}i(n.userCancel)},[i,n.dropAnimating,n.userCancel]),c=I(()=>{o.current&&i(n.resting)},[i,n.resting]);return G(()=>({dragging:l,dropping:d,resting:c}),[l,d,c])}function Wi(e,t){return Array.from(e.querySelectorAll(t))}var Gi=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView:window;function un(e){return e instanceof Gi(e).HTMLElement}function zi(e,t){const n=`[${_t.contextId}="${e}"]`,r=Wi(document,n);if(!r.length)return process.env.NODE_ENV!=="production"&&re(`Unable to find any drag handles in the context "${e}"`),null;const o=r.find(i=>i.getAttribute(_t.draggableId)===t);return o?un(o)?o:(process.env.NODE_ENV!=="production"&&re("drag handle needs to be a HTMLElement"),null):(process.env.NODE_ENV!=="production"&&re(`Unable to find drag handle with id "${t}" as no handle with a matching id was found`),null)}function Gd(e){const t=H({}),n=H(null),r=H(null),o=H(!1),i=I(function(u,m){const g={id:u,focus:m};return t.current[u]=g,function(){const b=t.current;b[u]!==g&&delete b[u]}},[]),a=I(function(u){const m=zi(e,u);m&&m!==document.activeElement&&m.focus()},[e]),l=I(function(u,m){n.current===u&&(n.current=m)},[]),d=I(function(){r.current||o.current&&(r.current=requestAnimationFrame(()=>{r.current=null;const u=n.current;u&&a(u)}))},[a]),c=I(function(u){n.current=null;const m=document.activeElement;m&&m.getAttribute(_t.draggableId)===u&&(n.current=u)},[]);return Fe(()=>(o.current=!0,function(){o.current=!1;const u=r.current;u&&cancelAnimationFrame(u)}),[]),G(()=>({register:i,tryRecordFocus:c,tryRestoreFocusRecorded:d,tryShiftRecord:l}),[i,c,d,l])}function zd(){const e={draggables:{},droppables:{}},t=[];function n(p){return t.push(p),function(){const m=t.indexOf(p);m!==-1&&t.splice(m,1)}}function r(p){t.length&&t.forEach(u=>u(p))}function o(p){return e.draggables[p]||null}function i(p){const u=o(p);return u||(process.env.NODE_ENV!=="production"?h(!1,`Cannot find draggable entry with id [${p}]`):h()),u}const a={register:p=>{e.draggables[p.descriptor.id]=p,r({type:"ADDITION",value:p})},update:(p,u)=>{const m=e.draggables[u.descriptor.id];m&&m.uniqueId===p.uniqueId&&(delete e.draggables[u.descriptor.id],e.draggables[p.descriptor.id]=p)},unregister:p=>{const u=p.descriptor.id,m=o(u);m&&p.uniqueId===m.uniqueId&&(delete e.draggables[u],e.droppables[p.descriptor.droppableId]&&r({type:"REMOVAL",value:p}))},getById:i,findById:o,exists:p=>!!o(p),getAllByType:p=>Object.values(e.draggables).filter(u=>u.descriptor.type===p)};function l(p){return e.droppables[p]||null}function d(p){const u=l(p);return u||(process.env.NODE_ENV!=="production"?h(!1,`Cannot find droppable entry with id [${p}]`):h()),u}const c={register:p=>{e.droppables[p.descriptor.id]=p},unregister:p=>{const u=l(p.descriptor.id);u&&p.uniqueId===u.uniqueId&&delete e.droppables[p.descriptor.id]},getById:d,findById:l,exists:p=>!!l(p),getAllByType:p=>Object.values(e.droppables).filter(u=>u.descriptor.type===p)};function f(){e.draggables={},e.droppables={},t.length=0}return{draggable:a,droppable:c,subscribe:n,clean:f}}function Hd(){const e=G(zd,[]);return we(()=>function(){e.clean()},[e]),e}var _r=ne.createContext(null),tn=()=>{const e=document.body;return e||(process.env.NODE_ENV!=="production"?h(!1,"Cannot find document.body"):h()),e};const Ud={position:"absolute",width:"1px",height:"1px",margin:"-1px",border:"0",padding:"0",overflow:"hidden",clip:"rect(0 0 0 0)","clip-path":"inset(100%)"},jd=e=>`rfd-announcement-${e}`;function qd(e){const t=G(()=>jd(e),[e]),n=H(null);return we(function(){const i=document.createElement("div");return n.current=i,i.id=t,i.setAttribute("aria-live","assertive"),i.setAttribute("aria-atomic","true"),Yo(i.style,Ud),tn().appendChild(i),function(){setTimeout(function(){const d=tn();d.contains(i)&&d.removeChild(i),i===n.current&&(n.current=null)})}},[t]),I(o=>{const i=n.current;if(i){i.textContent=o;return}process.env.NODE_ENV!=="production"&&re(`
84
+ A screen reader message was trying to be announced but it was unable to do so.
85
+ This can occur if you unmount your <DragDropContext /> in your onDragEnd.
86
+ Consider calling provided.announce() before the unmount so that the instruction will
87
+ not be lost for users relying on a screen reader.
88
+
89
+ Message not passed to screen reader:
90
+
91
+ "${o}"
92
+ `)},[])}const Kd={separator:"::"};function Fr(e,t=Kd){const n=ne.useId();return G(()=>`${e}${t.separator}${n}`,[t.separator,e,n])}function Yd({contextId:e,uniqueId:t}){return`rfd-hidden-text-${e}-${t}`}function Xd({contextId:e,text:t}){const n=Fr("hidden-text",{separator:"-"}),r=G(()=>Yd({contextId:e,uniqueId:n}),[n,e]);return we(function(){const i=document.createElement("div");return i.id=r,i.textContent=t,i.style.display="none",tn().appendChild(i),function(){const l=tn();l.contains(i)&&l.removeChild(i)}},[r,t]),r}var _n=ne.createContext(null),Jd={react:"^18.0.0 || ^19.0.0"};const Qd=/(\d+)\.(\d+)\.(\d+)/,So=e=>{const t=Qd.exec(e);t==null&&(process.env.NODE_ENV!=="production"?h(!1,`Unable to parse React version ${e}`):h());const n=Number(t[1]),r=Number(t[2]),o=Number(t[3]);return{major:n,minor:r,patch:o,raw:e}},Zd=(e,t)=>t.major>e.major?!0:t.major<e.major?!1:t.minor>e.minor?!0:t.minor<e.minor?!1:t.patch>=e.patch;var eu=(e,t)=>{const n=So(e),r=So(t);Zd(n,r)||process.env.NODE_ENV!=="production"&&re(`
93
+ React version: [${r.raw}]
94
+ does not satisfy expected peer dependency version: [${n.raw}]
95
+
96
+ This can result in run time bugs, and even fatal crashes
97
+ `)};const Yn=`
98
+ We expect a html5 doctype: <!doctype html>
99
+ This is to ensure consistent browser layout and measurement
100
+
101
+ More information: https://github.com/hello-pangea/dnd/blob/main/docs/guides/doctype.md
102
+ `;var tu=e=>{const t=e.doctype;if(!t){process.env.NODE_ENV!=="production"&&re(`
103
+ No <!doctype html> found.
104
+
105
+ ${Yn}
106
+ `);return}t.name.toLowerCase()!=="html"&&process.env.NODE_ENV!=="production"&&re(`
107
+ Unexpected <!doctype> found: (${t.name})
108
+
109
+ ${Yn}
110
+ `),t.publicId!==""&&process.env.NODE_ENV!=="production"&&re(`
111
+ Unexpected <!doctype> publicId found: (${t.publicId})
112
+ A html5 doctype does not have a publicId
113
+
114
+ ${Yn}
115
+ `)};function Lr(e){process.env.NODE_ENV!=="production"&&e()}function pn(e,t){Lr(()=>{we(()=>{try{e()}catch(n){rr(`
116
+ A setup problem was encountered.
117
+
118
+ > ${n.message}
119
+ `)}},t)})}function nu(){pn(()=>{eu(Jd.react,ne.version),tu(document)},[])}function Vr(e){const t=H(e);return we(()=>{t.current=e}),t}function ru(){let e=null;function t(){return!!e}function n(a){return a===e}function r(a){e&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot claim lock as it is already claimed"):h());const l={abandon:a};return e=l,l}function o(){e||(process.env.NODE_ENV!=="production"?h(!1,"Cannot release lock when there is no lock"):h()),e=null}function i(){e&&(e.abandon(),o())}return{isClaimed:t,isActive:n,claim:r,release:o,tryAbandon:i}}function nn(e){return e.phase==="IDLE"||e.phase==="DROP_ANIMATING"?!1:e.isDragging}const ou=9,iu=13,Mr=27,Hi=32,au=33,su=34,lu=35,cu=36,du=37,uu=38,pu=39,fu=40,mu={[iu]:!0,[ou]:!0};var Ui=e=>{mu[e.keyCode]&&e.preventDefault()};const Fn=(()=>{const e="visibilitychange";return typeof document>"u"?e:[e,`ms${e}`,`webkit${e}`,`moz${e}`,`o${e}`].find(r=>`on${r}`in document)||e})(),ji=0,Oo=5;function hu(e,t){return Math.abs(t.x-e.x)>=Oo||Math.abs(t.y-e.y)>=Oo}const Po={type:"IDLE"};function gu({cancel:e,completed:t,getPhase:n,setPhase:r}){return[{eventName:"mousemove",fn:o=>{const{button:i,clientX:a,clientY:l}=o;if(i!==ji)return;const d={x:a,y:l},c=n();if(c.type==="DRAGGING"){o.preventDefault(),c.actions.move(d);return}c.type!=="PENDING"&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot be IDLE"):h());const f=c.point;if(!hu(f,d))return;o.preventDefault();const p=c.actions.fluidLift(d);r({type:"DRAGGING",actions:p})}},{eventName:"mouseup",fn:o=>{const i=n();if(i.type!=="DRAGGING"){e();return}o.preventDefault(),i.actions.drop({shouldBlockNextClick:!0}),t()}},{eventName:"mousedown",fn:o=>{n().type==="DRAGGING"&&o.preventDefault(),e()}},{eventName:"keydown",fn:o=>{if(n().type==="PENDING"){e();return}if(o.keyCode===Mr){o.preventDefault(),e();return}Ui(o)}},{eventName:"resize",fn:e},{eventName:"scroll",options:{passive:!0,capture:!1},fn:()=>{n().type==="PENDING"&&e()}},{eventName:"webkitmouseforcedown",fn:o=>{const i=n();if(i.type==="IDLE"&&(process.env.NODE_ENV!=="production"?h(!1,"Unexpected phase"):h()),i.actions.shouldRespectForcePress()){e();return}o.preventDefault()}},{eventName:Fn,fn:e}]}function bu(e){const t=H(Po),n=H(yt),r=G(()=>({eventName:"mousedown",fn:function(p){if(p.defaultPrevented||p.button!==ji||p.ctrlKey||p.metaKey||p.shiftKey||p.altKey)return;const u=e.findClosestDraggableId(p);if(!u)return;const m=e.tryGetLock(u,a,{sourceEvent:p});if(!m)return;p.preventDefault();const g={x:p.clientX,y:p.clientY};n.current(),c(m,g)}}),[e]),o=G(()=>({eventName:"webkitmouseforcewillbegin",fn:f=>{if(f.defaultPrevented)return;const p=e.findClosestDraggableId(f);if(!p)return;const u=e.findOptionsForDraggable(p);u&&(u.shouldRespectForcePress||e.canGetLock(p)&&f.preventDefault())}}),[e]),i=I(function(){const p={passive:!1,capture:!0};n.current=Ge(window,[o,r],p)},[o,r]),a=I(()=>{t.current.type!=="IDLE"&&(t.current=Po,n.current(),i())},[i]),l=I(()=>{const f=t.current;a(),f.type==="DRAGGING"&&f.actions.cancel({shouldBlockNextClick:!0}),f.type==="PENDING"&&f.actions.abort()},[a]),d=I(function(){const p={capture:!0,passive:!1},u=gu({cancel:l,completed:a,getPhase:()=>t.current,setPhase:m=>{t.current=m}});n.current=Ge(window,u,p)},[l,a]),c=I(function(p,u){t.current.type!=="IDLE"&&(process.env.NODE_ENV!=="production"?h(!1,"Expected to move from IDLE to PENDING drag"):h()),t.current={type:"PENDING",point:u,actions:p},d()},[d]);Fe(function(){return i(),function(){n.current()}},[i])}function yu(){}const vu={[su]:!0,[au]:!0,[cu]:!0,[lu]:!0};function xu(e,t){function n(){t(),e.cancel()}function r(){t(),e.drop()}return[{eventName:"keydown",fn:o=>{if(o.keyCode===Mr){o.preventDefault(),n();return}if(o.keyCode===Hi){o.preventDefault(),r();return}if(o.keyCode===fu){o.preventDefault(),e.moveDown();return}if(o.keyCode===uu){o.preventDefault(),e.moveUp();return}if(o.keyCode===pu){o.preventDefault(),e.moveRight();return}if(o.keyCode===du){o.preventDefault(),e.moveLeft();return}if(vu[o.keyCode]){o.preventDefault();return}Ui(o)}},{eventName:"mousedown",fn:n},{eventName:"mouseup",fn:n},{eventName:"click",fn:n},{eventName:"touchstart",fn:n},{eventName:"resize",fn:n},{eventName:"wheel",fn:n,options:{passive:!0}},{eventName:Fn,fn:n}]}function Du(e){const t=H(yu),n=G(()=>({eventName:"keydown",fn:function(i){if(i.defaultPrevented||i.keyCode!==Hi)return;const a=e.findClosestDraggableId(i);if(!a)return;const l=e.tryGetLock(a,f,{sourceEvent:i});if(!l)return;i.preventDefault();let d=!0;const c=l.snapLift();t.current();function f(){d||(process.env.NODE_ENV!=="production"?h(!1,"Cannot stop capturing a keyboard drag when not capturing"):h()),d=!1,t.current(),r()}t.current=Ge(window,xu(c,f),{capture:!0,passive:!1})}}),[e]),r=I(function(){const i={passive:!1,capture:!0};t.current=Ge(window,[n],i)},[n]);Fe(function(){return r(),function(){t.current()}},[r])}const Xn={type:"IDLE"},Eu=120,wu=.15;function Cu({cancel:e,getPhase:t}){return[{eventName:"orientationchange",fn:e},{eventName:"resize",fn:e},{eventName:"contextmenu",fn:n=>{n.preventDefault()}},{eventName:"keydown",fn:n=>{if(t().type!=="DRAGGING"){e();return}n.keyCode===Mr&&n.preventDefault(),e()}},{eventName:Fn,fn:e}]}function Iu({cancel:e,completed:t,getPhase:n}){return[{eventName:"touchmove",options:{capture:!1},fn:r=>{const o=n();if(o.type!=="DRAGGING"){e();return}o.hasMoved=!0;const{clientX:i,clientY:a}=r.touches[0],l={x:i,y:a};r.preventDefault(),o.actions.move(l)}},{eventName:"touchend",fn:r=>{const o=n();if(o.type!=="DRAGGING"){e();return}r.preventDefault(),o.actions.drop({shouldBlockNextClick:!0}),t()}},{eventName:"touchcancel",fn:r=>{if(n().type!=="DRAGGING"){e();return}r.preventDefault(),e()}},{eventName:"touchforcechange",fn:r=>{const o=n();o.type==="IDLE"&&(process.env.NODE_ENV,h());const i=r.touches[0];if(!i||!(i.force>=wu))return;const l=o.actions.shouldRespectForcePress();if(o.type==="PENDING"){l&&e();return}if(l){if(o.hasMoved){r.preventDefault();return}e();return}r.preventDefault()}},{eventName:Fn,fn:e}]}function Nu(e){const t=H(Xn),n=H(yt),r=I(function(){return t.current},[]),o=I(function(m){t.current=m},[]),i=G(()=>({eventName:"touchstart",fn:function(m){if(m.defaultPrevented)return;const g=e.findClosestDraggableId(m);if(!g)return;const y=e.tryGetLock(g,l,{sourceEvent:m});if(!y)return;const b=m.touches[0],{clientX:D,clientY:E}=b,S={x:D,y:E};n.current(),p(y,S)}}),[e]),a=I(function(){const m={capture:!0,passive:!1};n.current=Ge(window,[i],m)},[i]),l=I(()=>{const u=t.current;u.type!=="IDLE"&&(u.type==="PENDING"&&clearTimeout(u.longPressTimerId),o(Xn),n.current(),a())},[a,o]),d=I(()=>{const u=t.current;l(),u.type==="DRAGGING"&&u.actions.cancel({shouldBlockNextClick:!0}),u.type==="PENDING"&&u.actions.abort()},[l]),c=I(function(){const m={capture:!0,passive:!1},g={cancel:d,completed:l,getPhase:r},y=Ge(window,Iu(g),m),b=Ge(window,Cu(g),m);n.current=function(){y(),b()}},[d,r,l]),f=I(function(){const m=r();m.type!=="PENDING"&&(process.env.NODE_ENV!=="production"?h(!1,`Cannot start dragging from phase ${m.type}`):h());const g=m.actions.fluidLift(m.point);o({type:"DRAGGING",actions:g,hasMoved:!1})},[r,o]),p=I(function(m,g){r().type!=="IDLE"&&(process.env.NODE_ENV!=="production"?h(!1,"Expected to move from IDLE to PENDING drag"):h());const y=setTimeout(f,Eu);o({type:"PENDING",point:g,actions:m,longPressTimerId:y}),c()},[c,r,o,f]);Fe(function(){return a(),function(){n.current();const g=r();g.type==="PENDING"&&(clearTimeout(g.longPressTimerId),o(Xn))}},[r,a,o]),Fe(function(){return Ge(window,[{eventName:"touchmove",fn:()=>{},options:{capture:!1,passive:!1}}])},[])}function Su(e){Lr(()=>{const t=Vr(e);pn(()=>{t.current.length!==e.length&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot change the amount of sensor hooks after mounting"):h(!1))})})}const Ou=["input","button","textarea","select","option","optgroup","video","audio"];function qi(e,t){if(t==null)return!1;if(Ou.includes(t.tagName.toLowerCase()))return!0;const r=t.getAttribute("contenteditable");return r==="true"||r===""?!0:t===e?!1:qi(e,t.parentElement)}function Pu(e,t){const n=t.target;return un(n)?qi(e,n):!1}var Au=e=>qe(e.getBoundingClientRect()).center;function Ru(e){return e instanceof Gi(e).Element}const Tu=(()=>{const e="matches";return typeof document>"u"?e:[e,"msMatchesSelector","webkitMatchesSelector"].find(r=>r in Element.prototype)||e})();function Ki(e,t){return e==null?null:e[Tu](t)?e:Ki(e.parentElement,t)}function Bu(e,t){return e.closest?e.closest(t):Ki(e,t)}function $u(e){return`[${_t.contextId}="${e}"]`}function ku(e,t){const n=t.target;if(!Ru(n))return process.env.NODE_ENV!=="production"&&re("event.target must be a Element"),null;const r=$u(e),o=Bu(n,r);return o?un(o)?o:(process.env.NODE_ENV!=="production"&&re("drag handle must be a HTMLElement"),null):null}function _u(e,t){const n=ku(e,t);return n?n.getAttribute(_t.draggableId):null}function Fu(e,t){const n=`[${lr.contextId}="${e}"]`,o=Wi(document,n).find(i=>i.getAttribute(lr.id)===t);return o?un(o)?o:(process.env.NODE_ENV!=="production"&&re("Draggable element is not a HTMLElement"),null):null}function Lu(e){e.preventDefault()}function vn({expected:e,phase:t,isLockActive:n,shouldWarn:r}){return n()?e!==t?(r&&process.env.NODE_ENV!=="production"&&re(`
120
+ Cannot perform action.
121
+ The actions you used belong to an outdated phase
122
+
123
+ Current phase: ${e}
124
+ You called an action from outdated phase: ${t}
125
+
126
+ Tips:
127
+
128
+ - Do not use preDragActions actions after calling preDragActions.lift()
129
+ `),!1):!0:(r&&process.env.NODE_ENV!=="production"&&re(`
130
+ Cannot perform action.
131
+ The sensor no longer has an action lock.
132
+
133
+ Tips:
134
+
135
+ - Throw away your action handlers when forceStop() is called
136
+ - Check actions.isActive() if you really need to
137
+ `),!1)}function Yi({lockAPI:e,store:t,registry:n,draggableId:r}){if(e.isClaimed())return!1;const o=n.draggable.findById(r);return o?!(!o.options.isEnabled||!Fi(t.getState(),r)):(process.env.NODE_ENV!=="production"&&re(`Unable to find draggable with id: ${r}`),!1)}function Vu({lockAPI:e,contextId:t,store:n,registry:r,draggableId:o,forceSensorStop:i,sourceEvent:a}){if(!Yi({lockAPI:e,store:n,registry:r,draggableId:o}))return null;const d=r.draggable.getById(o),c=Fu(t,d.descriptor.id);if(!c)return process.env.NODE_ENV!=="production"&&re(`Unable to find draggable element with id: ${o}`),null;if(a&&!d.options.canDragInteractiveElements&&Pu(c,a))return null;const f=e.claim(i||yt);let p="PRE_DRAG";function u(){return d.options.shouldRespectForcePress}function m(){return e.isActive(f)}function g(B,$){vn({expected:B,phase:p,isLockActive:m,shouldWarn:!0})&&n.dispatch($())}const y=g.bind(null,"DRAGGING");function b(B){function $(){e.release(),p="COMPLETED"}p!=="PRE_DRAG"&&($(),process.env.NODE_ENV!=="production"?h(!1,`Cannot lift in phase ${p}`):h()),n.dispatch(Ic(B.liftActionArgs)),p="DRAGGING";function ae(le,Ae={shouldBlockNextClick:!1}){if(B.cleanup(),Ae.shouldBlockNextClick){const pe=Ge(window,[{eventName:"click",fn:Lu,options:{once:!0,passive:!1,capture:!0}}]);setTimeout(pe)}$(),n.dispatch(Pi({reason:le}))}return{isActive:()=>vn({expected:"DRAGGING",phase:p,isLockActive:m,shouldWarn:!1}),shouldRespectForcePress:u,drop:le=>ae("DROP",le),cancel:le=>ae("CANCEL",le),...B.actions}}function D(B){const $=Kt(le=>{y(()=>Oi({client:le}))});return{...b({liftActionArgs:{id:o,clientSelection:B,movementMode:"FLUID"},cleanup:()=>$.cancel(),actions:{move:$}}),move:$}}function E(){const B={moveUp:()=>y($c),moveRight:()=>y(_c),moveDown:()=>y(kc),moveLeft:()=>y(Fc)};return b({liftActionArgs:{id:o,clientSelection:Au(c),movementMode:"SNAP"},cleanup:yt,actions:B})}function S(){vn({expected:"PRE_DRAG",phase:p,isLockActive:m,shouldWarn:!0})&&e.release()}return{isActive:()=>vn({expected:"PRE_DRAG",phase:p,isLockActive:m,shouldWarn:!1}),shouldRespectForcePress:u,fluidLift:D,snapLift:E,abort:S}}const Mu=[bu,Du,Nu];function Wu({contextId:e,store:t,registry:n,customSensors:r,enableDefaultSensors:o}){const i=[...o?Mu:[],...r||[]],a=ye(()=>ru())[0],l=I(function(b,D){nn(b)&&!nn(D)&&a.tryAbandon()},[a]);Fe(function(){let b=t.getState();return t.subscribe(()=>{const E=t.getState();l(b,E),b=E})},[a,t,l]),Fe(()=>a.tryAbandon,[a.tryAbandon]);const d=I(y=>Yi({lockAPI:a,registry:n,store:t,draggableId:y}),[a,n,t]),c=I((y,b,D)=>Vu({lockAPI:a,registry:n,contextId:e,store:t,draggableId:y,forceSensorStop:b||null,sourceEvent:D&&D.sourceEvent?D.sourceEvent:null}),[e,a,n,t]),f=I(y=>_u(e,y),[e]),p=I(y=>{const b=n.draggable.findById(y);return b?b.options:null},[n.draggable]),u=I(function(){a.isClaimed()&&(a.tryAbandon(),t.getState().phase!=="IDLE"&&t.dispatch(Pr()))},[a,t]),m=I(()=>a.isClaimed(),[a]),g=G(()=>({canGetLock:d,tryGetLock:c,findClosestDraggableId:f,findOptionsForDraggable:p,tryReleaseLock:u,isLockClaimed:m}),[d,c,f,p,u,m]);Su(i);for(let y=0;y<i.length;y++)i[y](g)}const Gu=e=>({onBeforeCapture:t=>{qo(()=>{e.onBeforeCapture&&e.onBeforeCapture(t)})},onBeforeDragStart:e.onBeforeDragStart,onDragStart:e.onDragStart,onDragEnd:e.onDragEnd,onDragUpdate:e.onDragUpdate}),zu=e=>({...en,...e.autoScrollerOptions,durationDampening:{...en.durationDampening,...e.autoScrollerOptions}});function Ht(e){return e.current||(process.env.NODE_ENV!=="production"?h(!1,"Could not find store from lazy ref"):h()),e.current}function Hu(e){const{contextId:t,setCallbacks:n,sensors:r,nonce:o,dragHandleUsageInstructions:i}=e,a=H(null);nu();const l=Vr(e),d=I(()=>Gu(l.current),[l]),c=I(()=>zu(l.current),[l]),f=qd(t),p=Xd({contextId:t,text:i}),u=Wd(t,o),m=I(pe=>{Ht(a).dispatch(pe)},[]),g=G(()=>to({publishWhileDragging:Sc,updateDroppableScroll:Pc,updateDroppableIsEnabled:Ac,updateDroppableIsCombineEnabled:Rc,collectionStarting:Oc},m),[m]),y=Hd(),b=G(()=>vd(y,g),[y,g]),D=G(()=>_d({scrollWindow:xd,scrollDroppable:b.scrollDroppable,getAutoScrollerOptions:c,...to({move:Oi},m)}),[b.scrollDroppable,m,c]),E=Gd(t),S=G(()=>hd({announce:f,autoScroller:D,dimensionMarshal:b,focusMarshal:E,getResponders:d,styleMarshal:u}),[f,D,b,E,d,u]);process.env.NODE_ENV!=="production"&&a.current&&a.current!==S&&process.env.NODE_ENV!=="production"&&re("unexpected store change"),a.current=S;const N=I(()=>{const pe=Ht(a);pe.getState().phase!=="IDLE"&&pe.dispatch(Pr())},[]),B=I(()=>{const pe=Ht(a).getState();return pe.phase==="DROP_ANIMATING"?!0:pe.phase==="IDLE"?!1:pe.isDragging},[]),$=G(()=>({isDragging:B,tryAbort:N}),[B,N]);n($);const ae=I(pe=>Fi(Ht(a).getState(),pe),[]),le=I(()=>Ct(Ht(a).getState()),[]),Ae=G(()=>({marshal:b,focus:E,contextId:t,canLift:ae,isMovementAllowed:le,dragHandleUsageInstructionsId:p,registry:y}),[t,b,p,E,ae,le,y]);return Wu({contextId:t,store:S,registry:y,customSensors:r||null,enableDefaultSensors:e.enableDefaultSensors!==!1}),we(()=>N,[N]),ne.createElement(_n.Provider,{value:Ae},ne.createElement(za,{context:_r,store:S},e.children))}function Uu(){return ne.useId()}function Xi(e){const t=Uu(),n=e.dragHandleUsageInstructions||Dn.dragHandleUsageInstructions;return ne.createElement(ml,null,r=>ne.createElement(Hu,{nonce:e.nonce,contextId:t,setCallbacks:r,dragHandleUsageInstructions:n,enableDefaultSensors:e.enableDefaultSensors,sensors:e.sensors,onBeforeCapture:e.onBeforeCapture,onBeforeDragStart:e.onBeforeDragStart,onDragStart:e.onDragStart,onDragUpdate:e.onDragUpdate,onDragEnd:e.onDragEnd,autoScrollerOptions:e.autoScrollerOptions},e.children))}const Ao={dragging:5e3,dropAnimating:4500},ju=(e,t)=>t?qt.drop(t.duration):e?qt.snap:qt.fluid,qu=(e,t)=>{if(e)return t?Zt.opacity.drop:Zt.opacity.combining},Ku=e=>e.forceShouldAnimate!=null?e.forceShouldAnimate:e.mode==="SNAP";function Yu(e){const n=e.dimension.client,{offset:r,combineWith:o,dropping:i}=e,a=!!o,l=Ku(e),d=!!i,c=d?ar.drop(r,a):ar.moveTo(r);return{position:"fixed",top:n.marginBox.top,left:n.marginBox.left,boxSizing:"border-box",width:n.borderBox.width,height:n.borderBox.height,transition:ju(l,i),transform:c,opacity:qu(a,d),zIndex:d?Ao.dropAnimating:Ao.dragging,pointerEvents:"none"}}function Xu(e){return{transform:ar.moveTo(e.offset),transition:e.shouldAnimateDisplacement?void 0:"none"}}function Ju(e){return e.type==="DRAGGING"?Yu(e):Xu(e)}function Qu(e,t,n=Ie){const r=window.getComputedStyle(t),o=t.getBoundingClientRect(),i=ni(o,r),a=Cn(i,n),l={client:i,tagName:t.tagName.toLowerCase(),display:r.display},d={x:i.marginBox.width,y:i.marginBox.height};return{descriptor:e,placeholder:l,displaceBy:d,client:i,page:a}}function Zu(e){const t=Fr("draggable"),{descriptor:n,registry:r,getDraggableRef:o,canDragInteractiveElements:i,shouldRespectForcePress:a,isEnabled:l}=e,d=G(()=>({canDragInteractiveElements:i,shouldRespectForcePress:a,isEnabled:l}),[i,l,a]),c=I(m=>{const g=o();return g||(process.env.NODE_ENV!=="production"?h(!1,"Cannot get dimension when no ref is set"):h()),Qu(n,g,m)},[n,o]),f=G(()=>({uniqueId:t,descriptor:n,options:d,getDimension:c}),[n,c,d,t]),p=H(f),u=H(!0);Fe(()=>(r.draggable.register(p.current),()=>r.draggable.unregister(p.current)),[r.draggable]),Fe(()=>{if(u.current){u.current=!1;return}const m=p.current;p.current=f,r.draggable.update(f,m)},[f,r.draggable])}var Wr=ne.createContext(null);function Ji(e){e&&un(e)||(process.env.NODE_ENV!=="production"?h(!1,`
138
+ provided.innerRef has not been provided with a HTMLElement.
139
+
140
+ You can find a guide on using the innerRef callback functions at:
141
+ https://github.com/hello-pangea/dnd/blob/main/docs/guides/using-inner-ref.md
142
+ `):h())}function ep(e,t,n){pn(()=>{function r(i){return`Draggable[id: ${i}]: `}const o=e.draggableId;o||(process.env.NODE_ENV!=="production"?h(!1,"Draggable requires a draggableId"):h(!1)),typeof o!="string"&&(process.env.NODE_ENV!=="production"?h(!1,`Draggable requires a [string] draggableId.
143
+ Provided: [type: ${typeof o}] (value: ${o})`):h(!1)),Number.isInteger(e.index)||(process.env.NODE_ENV!=="production"?h(!1,`${r(o)} requires an integer index prop`):h(!1)),e.mapped.type!=="DRAGGING"&&(Ji(n()),e.isEnabled&&(zi(t,o)||(process.env.NODE_ENV!=="production"?h(!1,`${r(o)} Unable to find drag handle`):h(!1))))})}function tp(e){Lr(()=>{const t=H(e);pn(()=>{e!==t.current&&(process.env.NODE_ENV!=="production"?h(!1,"Draggable isClone prop value changed during component life"):h(!1))},[e])})}function Sn(e){const t=Mo(e);return t||(process.env.NODE_ENV!=="production"?h(!1,"Could not find required context"):h()),t}function np(e){e.preventDefault()}const rp=e=>{const t=H(null),n=I(($=null)=>{t.current=$},[]),r=I(()=>t.current,[]),{contextId:o,dragHandleUsageInstructionsId:i,registry:a}=Sn(_n),{type:l,droppableId:d}=Sn(Wr),c=G(()=>({id:e.draggableId,index:e.index,type:l,droppableId:d}),[e.draggableId,e.index,l,d]),{children:f,draggableId:p,isEnabled:u,shouldRespectForcePress:m,canDragInteractiveElements:g,isClone:y,mapped:b,dropAnimationFinished:D}=e;if(ep(e,o,r),tp(y),!y){const $=G(()=>({descriptor:c,registry:a,getDraggableRef:r,canDragInteractiveElements:g,shouldRespectForcePress:m,isEnabled:u}),[c,a,r,g,m,u]);Zu($)}const E=G(()=>u?{tabIndex:0,role:"button","aria-describedby":i,"data-rfd-drag-handle-draggable-id":p,"data-rfd-drag-handle-context-id":o,draggable:!1,onDragStart:np}:null,[o,i,p,u]),S=I($=>{b.type==="DRAGGING"&&b.dropping&&$.propertyName==="transform"&&qo(D)},[D,b]),N=G(()=>{const $=Ju(b),ae=b.type==="DRAGGING"&&b.dropping?S:void 0;return{innerRef:n,draggableProps:{"data-rfd-draggable-context-id":o,"data-rfd-draggable-id":p,style:$,onTransitionEnd:ae},dragHandleProps:E}},[o,E,p,b,S,n]),B=G(()=>({draggableId:c.id,type:c.type,source:{index:c.index,droppableId:c.droppableId}}),[c.droppableId,c.id,c.index,c.type]);return ne.createElement(ne.Fragment,null,f(N,b.snapshot,B))};var Qi=(e,t)=>e===t,Zi=e=>{const{combine:t,destination:n}=e;return n?n.droppableId:t?t.droppableId:null};const op=e=>e.combine?e.combine.draggableId:null,ip=e=>e.at&&e.at.type==="COMBINE"?e.at.combine.draggableId:null;function ap(){const e=Ce((o,i)=>({x:o,y:i})),t=Ce((o,i,a=null,l=null,d=null)=>({isDragging:!0,isClone:i,isDropAnimating:!!d,dropAnimation:d,mode:o,draggingOver:a,combineWith:l,combineTargetFor:null})),n=Ce((o,i,a,l,d=null,c=null,f=null)=>({mapped:{type:"DRAGGING",dropping:null,draggingOver:d,combineWith:c,mode:i,offset:o,dimension:a,forceShouldAnimate:f,snapshot:t(i,l,d,c,null)}}));return(o,i)=>{if(nn(o)){if(o.critical.draggable.id!==i.draggableId)return null;const a=o.current.client.offset,l=o.dimensions.draggables[i.draggableId],d=_e(o.impact),c=ip(o.impact),f=o.forceShouldAnimate;return n(e(a.x,a.y),o.movementMode,l,i.isClone,d,c,f)}if(o.phase==="DROP_ANIMATING"){const a=o.completed;if(a.result.draggableId!==i.draggableId)return null;const l=i.isClone,d=o.dimensions.draggables[i.draggableId],c=a.result,f=c.mode,p=Zi(c),u=op(c),g={duration:o.dropDuration,curve:Rr.drop,moveTo:o.newHomeClientOffset,opacity:u?Zt.opacity.drop:null,scale:u?Zt.scale.drop:null};return{mapped:{type:"DRAGGING",offset:o.newHomeClientOffset,dimension:d,dropping:g,draggingOver:p,combineWith:u,mode:f,forceShouldAnimate:null,snapshot:t(f,l,p,u,g)}}}return null}}function ea(e=null){return{isDragging:!1,isDropAnimating:!1,isClone:!1,dropAnimation:null,mode:null,draggingOver:null,combineTargetFor:e,combineWith:null}}const sp={mapped:{type:"SECONDARY",offset:Ie,combineTargetFor:null,shouldAnimateDisplacement:!0,snapshot:ea(null)}};function lp(){const e=Ce((a,l)=>({x:a,y:l})),t=Ce(ea),n=Ce((a,l=null,d)=>({mapped:{type:"SECONDARY",offset:a,combineTargetFor:l,shouldAnimateDisplacement:d,snapshot:t(l)}})),r=a=>a?n(Ie,a,!0):null,o=(a,l,d,c)=>{const f=d.displaced.visible[a],p=!!(c.inVirtualList&&c.effected[a]),u=Bn(d),m=u&&u.draggableId===a?l:null;if(!f){if(!p)return r(m);if(d.displaced.invisible[a])return null;const b=Mt(c.displacedBy.point),D=e(b.x,b.y);return n(D,m,!0)}if(p)return r(m);const g=d.displacedBy.point,y=e(g.x,g.y);return n(y,m,f.shouldAnimate)};return(a,l)=>{if(nn(a))return a.critical.draggable.id===l.draggableId?null:o(l.draggableId,a.critical.draggable.id,a.impact,a.afterCritical);if(a.phase==="DROP_ANIMATING"){const d=a.completed;return d.result.draggableId===l.draggableId?null:o(l.draggableId,d.result.draggableId,d.impact,d.afterCritical)}return null}}const cp=()=>{const e=ap(),t=lp();return(r,o)=>e(r,o)||t(r,o)||sp},dp={dropAnimationFinished:Ai},up=Ko(cp,dp,null,{context:_r,areStatePropsEqual:Qi})(rp);function ta(e){return Sn(Wr).isUsingCloneFor===e.draggableId&&!e.isClone?null:ne.createElement(up,e)}function Gr(e){const t=typeof e.isDragDisabled=="boolean"?!e.isDragDisabled:!0,n=!!e.disableInteractiveElementBlocking,r=!!e.shouldRespectForcePress;return ne.createElement(ta,Yo({},e,{isClone:!1,isEnabled:t,canDragInteractiveElements:n,shouldRespectForcePress:r}))}const zr=e=>t=>e===t,pp=zr("scroll"),fp=zr("auto"),mp=zr("visible"),Ro=(e,t)=>t(e.overflowX)||t(e.overflowY),hp=(e,t)=>t(e.overflowX)&&t(e.overflowY),na=e=>{const t=window.getComputedStyle(e),n={overflowX:t.overflowX,overflowY:t.overflowY};return Ro(n,pp)||Ro(n,fp)},gp=()=>{if(process.env.NODE_ENV==="production")return!1;const e=tn(),t=document.documentElement;if(t||(process.env.NODE_ENV,h()),!na(e))return!1;const n=window.getComputedStyle(t),r={overflowX:n.overflowX,overflowY:n.overflowY};return hp(r,mp)||process.env.NODE_ENV!=="production"&&re(`
144
+ We have detected that your <body> element might be a scroll container.
145
+ We have found no reliable way of detecting whether the <body> element is a scroll container.
146
+ Under most circumstances a <body> scroll bar will be on the <html> element (document.documentElement)
147
+
148
+ Because we cannot determine if the <body> is a scroll container, and generally it is not one,
149
+ we will be treating the <body> as *not* a scroll container
150
+
151
+ More information: https://github.com/hello-pangea/dnd/blob/main/docs/guides/how-we-detect-scroll-containers.md
152
+ `),!1},Hr=e=>e==null?null:e===document.body?gp()?e:null:e===document.documentElement?null:na(e)?e:Hr(e.parentElement);var bp=e=>{!e||!Hr(e.parentElement)||process.env.NODE_ENV!=="production"&&re(`
153
+ Droppable: unsupported nested scroll container detected.
154
+ A Droppable can only have one scroll parent (which can be itself)
155
+ Nested scroll containers are currently not supported.
156
+
157
+ We hope to support nested scroll containers soon: https://github.com/atlassian/react-beautiful-dnd/issues/131
158
+ `)},cr=e=>({x:e.scrollLeft,y:e.scrollTop});const ra=e=>e?window.getComputedStyle(e).position==="fixed"?!0:ra(e.parentElement):!1;var yp=e=>{const t=Hr(e),n=ra(e);return{closestScrollable:t,isFixedOnPage:n}},vp=({descriptor:e,isEnabled:t,isCombineEnabled:n,isFixedOnPage:r,direction:o,client:i,page:a,closest:l})=>{const d=(()=>{if(!l)return null;const{scrollSize:u,client:m}=l,g=$i({scrollHeight:u.scrollHeight,scrollWidth:u.scrollWidth,height:m.paddingBox.height,width:m.paddingBox.width});return{pageMarginBox:l.page.marginBox,frameClient:m,scrollSize:u,shouldClipSubject:l.shouldClipSubject,scroll:{initial:l.scroll,current:l.scroll,max:g,diff:{value:Ie,displacement:Ie}}}})(),c=o==="vertical"?Cr:fi,f=$t({page:a,withPlaceholder:null,axis:c,frame:d});return{descriptor:e,isCombineEnabled:n,isFixedOnPage:r,axis:c,isEnabled:t,client:i,page:a,frame:d,subject:f}};const xp=(e,t)=>{const n=ri(e);if(!t||e!==t)return n;const r=n.paddingBox.top-t.scrollTop,o=n.paddingBox.left-t.scrollLeft,i=r+t.scrollHeight,a=o+t.scrollWidth,d=xr({top:r,right:a,bottom:i,left:o},n.border);return Dr({borderBox:d,margin:n.margin,border:n.border,padding:n.padding})};var Dp=({ref:e,descriptor:t,env:n,windowScroll:r,direction:o,isDropDisabled:i,isCombineEnabled:a,shouldClipSubject:l})=>{const d=n.closestScrollable,c=xp(e,d),f=Cn(c,r),p=(()=>{if(!d)return null;const m=ri(d),g={scrollHeight:d.scrollHeight,scrollWidth:d.scrollWidth};return{client:m,page:Cn(m,r),scroll:cr(d),scrollSize:g,shouldClipSubject:l}})();return vp({descriptor:t,isEnabled:!i,isCombineEnabled:a,isFixedOnPage:n.isFixedOnPage,direction:o,client:c,page:f,closest:p})};const Ep={passive:!1},wp={passive:!0};var To=e=>e.shouldPublishImmediately?Ep:wp;const xn=e=>e&&e.env.closestScrollable||null;function Cp(e){const t=H(null),n=Sn(_n),r=Fr("droppable"),{registry:o,marshal:i}=n,a=Vr(e),l=G(()=>({id:e.droppableId,type:e.type,mode:e.mode}),[e.droppableId,e.mode,e.type]),d=H(l),c=G(()=>Ce((N,B)=>{t.current||(process.env.NODE_ENV!=="production"?h(!1,"Can only update scroll when dragging"):h());const $={x:N,y:B};i.updateDroppableScroll(l.id,$)}),[l.id,i]),f=I(()=>{const N=t.current;return!N||!N.env.closestScrollable?Ie:cr(N.env.closestScrollable)},[]),p=I(()=>{const N=f();c(N.x,N.y)},[f,c]),u=G(()=>Kt(p),[p]),m=I(()=>{const N=t.current,B=xn(N);if(N&&B||(process.env.NODE_ENV!=="production"?h(!1,"Could not find scroll options while scrolling"):h()),N.scrollOptions.shouldPublishImmediately){p();return}u()},[u,p]),g=I((N,B)=>{t.current&&(process.env.NODE_ENV!=="production"?h(!1,"Cannot collect a droppable while a drag is occurring"):h());const $=a.current,ae=$.getDroppableRef();ae||(process.env.NODE_ENV!=="production"?h(!1,"Cannot collect without a droppable ref"):h());const le=yp(ae),Ae={ref:ae,descriptor:l,env:le,scrollOptions:B};t.current=Ae;const pe=Dp({ref:ae,descriptor:l,env:le,windowScroll:N,direction:$.direction,isDropDisabled:$.isDropDisabled,isCombineEnabled:$.isCombineEnabled,shouldClipSubject:!$.ignoreContainerClipping}),w=le.closestScrollable;return w&&(w.setAttribute(Io.contextId,n.contextId),w.addEventListener("scroll",m,To(Ae.scrollOptions)),process.env.NODE_ENV!=="production"&&bp(w)),pe},[n.contextId,l,m,a]),y=I(()=>{const N=t.current,B=xn(N);return N&&B||(process.env.NODE_ENV!=="production"?h(!1,"Can only recollect Droppable client for Droppables that have a scroll container"):h()),cr(B)},[]),b=I(()=>{const N=t.current;N||(process.env.NODE_ENV!=="production"?h(!1,"Cannot stop drag when no active drag"):h());const B=xn(N);t.current=null,B&&(u.cancel(),B.removeAttribute(Io.contextId),B.removeEventListener("scroll",m,To(N.scrollOptions)))},[m,u]),D=I(N=>{const B=t.current;B||(process.env.NODE_ENV!=="production"?h(!1,"Cannot scroll when there is no drag"):h());const $=xn(B);$||(process.env.NODE_ENV!=="production"?h(!1,"Cannot scroll a droppable with no closest scrollable"):h()),$.scrollTop+=N.y,$.scrollLeft+=N.x},[]),E=G(()=>({getDimensionAndWatchScroll:g,getScrollWhileDragging:y,dragStopped:b,scroll:D}),[b,g,y,D]),S=G(()=>({uniqueId:r,descriptor:l,callbacks:E}),[E,l,r]);Fe(()=>(d.current=S.descriptor,o.droppable.register(S),()=>{t.current&&(process.env.NODE_ENV!=="production"&&re("Unsupported: changing the droppableId or type of a Droppable during a drag"),b()),o.droppable.unregister(S)}),[E,l,b,S,i,o.droppable]),Fe(()=>{t.current&&i.updateDroppableIsEnabled(d.current.id,!e.isDropDisabled)},[e.isDropDisabled,i]),Fe(()=>{t.current&&i.updateDroppableIsCombineEnabled(d.current.id,e.isCombineEnabled)},[e.isCombineEnabled,i])}function Jn(){}const Bo={width:0,height:0,margin:Dl},Ip=({isAnimatingOpenOnMount:e,placeholder:t,animate:n})=>e||n==="close"?Bo:{height:t.client.borderBox.height,width:t.client.borderBox.width,margin:t.client.margin},Np=({isAnimatingOpenOnMount:e,placeholder:t,animate:n})=>{const r=Ip({isAnimatingOpenOnMount:e,placeholder:t,animate:n});return{display:t.display,boxSizing:"border-box",width:r.width,height:r.height,marginTop:r.margin.top,marginRight:r.margin.right,marginBottom:r.margin.bottom,marginLeft:r.margin.left,flexShrink:"0",flexGrow:"0",pointerEvents:"none",transition:n!=="none"?qt.placeholder:null}},Sp=e=>{const t=H(null),n=I(()=>{t.current&&(clearTimeout(t.current),t.current=null)},[]),{animate:r,onTransitionEnd:o,onClose:i,contextId:a}=e,[l,d]=ye(e.animate==="open");we(()=>l?r!=="open"?(n(),d(!1),Jn):t.current?Jn:(t.current=setTimeout(()=>{t.current=null,d(!1)}),n):Jn,[r,l,n]);const c=I(p=>{p.propertyName==="height"&&(o(),r==="close"&&i())},[r,i,o]),f=Np({isAnimatingOpenOnMount:l,animate:e.animate,placeholder:e.placeholder});return ne.createElement(e.placeholder.tagName,{style:f,"data-rfd-placeholder-context-id":a,onTransitionEnd:c,ref:e.innerRef})};var Op=ne.memo(Sp);function Qn(e){return typeof e=="boolean"}function Zn(e,t){t.forEach(n=>n(e))}const Pp=[function({props:t}){t.droppableId||(process.env.NODE_ENV!=="production"?h(!1,"A Droppable requires a droppableId prop"):h()),typeof t.droppableId!="string"&&(process.env.NODE_ENV!=="production"?h(!1,`A Droppable requires a [string] droppableId. Provided: [${typeof t.droppableId}]`):h())},function({props:t}){Qn(t.isDropDisabled)||(process.env.NODE_ENV!=="production"?h(!1,"isDropDisabled must be a boolean"):h()),Qn(t.isCombineEnabled)||(process.env.NODE_ENV!=="production"?h(!1,"isCombineEnabled must be a boolean"):h()),Qn(t.ignoreContainerClipping)||(process.env.NODE_ENV!=="production"?h(!1,"ignoreContainerClipping must be a boolean"):h())},function({getDroppableRef:t}){Ji(t())}],Ap=[function({props:t,getPlaceholderRef:n}){!t.placeholder||n()||process.env.NODE_ENV!=="production"&&re(`
159
+ Droppable setup issue [droppableId: "${t.droppableId}"]:
160
+ DroppableProvided > placeholder could not be found.
161
+
162
+ Please be sure to add the {provided.placeholder} React Node as a child of your Droppable.
163
+ More information: https://github.com/hello-pangea/dnd/blob/main/docs/api/droppable.md
164
+ `)}],Rp=[function({props:t}){t.renderClone||(process.env.NODE_ENV!=="production"?h(!1,"Must provide a clone render function (renderClone) for virtual lists"):h())},function({getPlaceholderRef:t}){t()&&(process.env.NODE_ENV!=="production"?h(!1,"Expected virtual list to not have a placeholder"):h())}];function Tp(e){pn(()=>{Zn(e,Pp),e.props.mode==="standard"&&Zn(e,Ap),e.props.mode==="virtual"&&Zn(e,Rp)})}class Bp extends ne.PureComponent{constructor(...t){super(...t),this.state={isVisible:!!this.props.on,data:this.props.on,animate:this.props.shouldAnimate&&this.props.on?"open":"none"},this.onClose=()=>{this.state.animate==="close"&&this.setState({isVisible:!1})}}static getDerivedStateFromProps(t,n){return t.shouldAnimate?t.on?{isVisible:!0,data:t.on,animate:"open"}:n.isVisible?{isVisible:!0,data:n.data,animate:"close"}:{isVisible:!1,animate:"close",data:null}:{isVisible:!!t.on,data:t.on,animate:"none"}}render(){if(!this.state.isVisible)return null;const t={onClose:this.onClose,data:this.state.data,animate:this.state.animate};return this.props.children(t)}}const $p=e=>{const t=Mo(_n);t||(process.env.NODE_ENV!=="production"?h(!1,"Could not find app context"):h());const{contextId:n,isMovementAllowed:r}=t,o=H(null),i=H(null),{children:a,droppableId:l,type:d,mode:c,direction:f,ignoreContainerClipping:p,isDropDisabled:u,isCombineEnabled:m,snapshot:g,useClone:y,updateViewportMaxScroll:b,getContainerForClone:D}=e,E=I(()=>o.current,[]),S=I((Z=null)=>{o.current=Z},[]),N=I(()=>i.current,[]),B=I((Z=null)=>{i.current=Z},[]);Tp({props:e,getDroppableRef:E,getPlaceholderRef:N});const $=I(()=>{r()&&b({maxScroll:_i()})},[r,b]);Cp({droppableId:l,type:d,mode:c,direction:f,isDropDisabled:u,isCombineEnabled:m,ignoreContainerClipping:p,getDroppableRef:E});const ae=G(()=>ne.createElement(Bp,{on:e.placeholder,shouldAnimate:e.shouldAnimatePlaceholder},({onClose:Z,data:P,animate:_})=>ne.createElement(Op,{placeholder:P,onClose:Z,innerRef:B,animate:_,contextId:n,onTransitionEnd:$})),[n,$,e.placeholder,e.shouldAnimatePlaceholder,B]),le=G(()=>({innerRef:S,placeholder:ae,droppableProps:{"data-rfd-droppable-id":l,"data-rfd-droppable-context-id":n}}),[n,l,ae,S]),Ae=y?y.dragging.draggableId:null,pe=G(()=>({droppableId:l,type:d,isUsingCloneFor:Ae}),[l,Ae,d]);function w(){if(!y)return null;const{dragging:Z,render:P}=y,_=ne.createElement(ta,{draggableId:Z.draggableId,index:Z.source.index,isClone:!0,isEnabled:!0,shouldRespectForcePress:!1,canDragInteractiveElements:!0},(O,M)=>P(O,M,Z));return Va.createPortal(_,D())}return ne.createElement(Wr.Provider,{value:pe},a(le,g),w())};function kp(){return document.body||(process.env.NODE_ENV!=="production"?h(!1,"document.body is not ready"):h()),document.body}const $o={mode:"standard",type:"DEFAULT",direction:"vertical",isDropDisabled:!1,isCombineEnabled:!1,ignoreContainerClipping:!1,renderClone:null,getContainerForClone:kp},oa=e=>{let t={...e},n;for(n in $o)e[n]===void 0&&(t={...t,[n]:$o[n]});return t},er=(e,t)=>e===t.droppable.type,ko=(e,t)=>t.draggables[e.draggable.id],_p=()=>{const e={placeholder:null,shouldAnimatePlaceholder:!0,snapshot:{isDraggingOver:!1,draggingOverWith:null,draggingFromThisWith:null,isUsingPlaceholder:!1},useClone:null},t={...e,shouldAnimatePlaceholder:!1},n=Ce(i=>({draggableId:i.id,type:i.type,source:{index:i.index,droppableId:i.droppableId}})),r=Ce((i,a,l,d,c,f)=>{const p=c.descriptor.id;if(c.descriptor.droppableId===i){const g=f?{render:f,dragging:n(c.descriptor)}:null,y={isDraggingOver:l,draggingOverWith:l?p:null,draggingFromThisWith:p,isUsingPlaceholder:!0};return{placeholder:c.placeholder,shouldAnimatePlaceholder:!1,snapshot:y,useClone:g}}if(!a)return t;if(!d)return e;const m={isDraggingOver:l,draggingOverWith:p,draggingFromThisWith:null,isUsingPlaceholder:!0};return{placeholder:c.placeholder,shouldAnimatePlaceholder:!0,snapshot:m,useClone:null}});return(i,a)=>{const l=oa(a),d=l.droppableId,c=l.type,f=!l.isDropDisabled,p=l.renderClone;if(nn(i)){const u=i.critical;if(!er(c,u))return t;const m=ko(u,i.dimensions),g=_e(i.impact)===d;return r(d,f,g,g,m,p)}if(i.phase==="DROP_ANIMATING"){const u=i.completed;if(!er(c,u.critical))return t;const m=ko(u.critical,i.dimensions);return r(d,f,Zi(u.result)===d,_e(u.impact)===d,m,p)}if(i.phase==="IDLE"&&i.completed&&!i.shouldFlush){const u=i.completed;if(!er(c,u.critical))return t;const m=_e(u.impact)===d,g=!!(u.impact.at&&u.impact.at.type==="COMBINE"),y=u.critical.droppable.id===d;return m?g?e:t:y?e:t}return t}},Fp={updateViewportMaxScroll:Bc},On=Ko(_p,Fp,(e,t,n)=>({...oa(n),...e,...t}),{context:_r,areStatePropsEqual:Qi})($p),Ln=T.div`
165
+ /* Act as a flexible panel that can live inside grid/flex cells */
166
+ display: flex;
167
+ flex-direction: column;
168
+ height: 100%;
169
+ min-height: 0; /* allow inner children to shrink/scroll */
170
+ /* Contain overflow by default; individual inner areas can scroll */
171
+ overflow: hidden;
172
+
173
+ border-radius: 12px;
174
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
175
+ background-color: #fff;
176
+ padding: 1.5rem;
177
+ `,ot=an(Uo)(({theme:e,$hasOrigin:t})=>({display:"flex",alignItems:"flex-start",padding:e.spacing(2),marginBottom:e.spacing(1),gap:e.spacing(2),animation:"fadeIn 0.3s ease-in",borderLeft:t?`4px solid ${e.palette.info.main}`:void 0,backgroundColor:t?`${e.palette.info.light}22`:void 0,"@keyframes fadeIn":{from:{opacity:0,transform:"translateY(10px)"},to:{opacity:1,transform:"translateY(0)"}},position:"relative","&:hover .step-actions-overlay":{opacity:1,transform:"translateY(0)"}})),it=an(V)(({theme:e})=>({fontWeight:"bold",fontSize:"1.2em",color:e.palette.primary.main,minWidth:30})),at=an(q)({flexGrow:1}),ft=({path:e})=>x(V,{variant:"caption",color:"info.main",sx:{display:"block",fontFamily:"monospace"},children:["from ",e]}),st=an(V)(({statuscolor:e})=>({fontSize:"0.8em",marginTop:4,color:e||"#666",fontWeight:500})),lt=an(q)(({theme:e})=>({position:"absolute",top:-16,right:16,backgroundColor:e.palette.background.paper,boxShadow:e.shadows[3],border:`1px solid ${e.palette.divider}`,display:"flex",alignItems:"center",justifyContent:"center",gap:e.spacing(.5),opacity:0,transition:"all 0.2s ease-in-out",zIndex:10,borderRadius:16,padding:"4px 8px",transform:"translateY(5px)","&.visible":{opacity:1,transform:"translateY(0)"}})),Lp=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>x(ot,{elevation:1,children:[s(it,{children:t}),x(at,{children:[s(V,{variant:"body2",color:"text.secondary",fontFamily:"monospace",children:"📄 File Reference"}),s(V,{fontWeight:"bold",children:e.descriptionText||"Add steps from file"}),x(V,{variant:"body2",children:["Path: ",e.path]}),e.overrides&&Object.keys(e.overrides).length>0&&x(q,{sx:{mt:.5,display:"flex",alignItems:"center",flexWrap:"wrap",gap:.5},children:[s(V,{variant:"caption",color:"text.secondary",children:"Overrides:"}),Object.keys(e.overrides).map(a=>s(L,{size:"small",label:`${a}`},a))]}),e.status&&s(st,{statuscolor:e.statusColor,children:e.status}),s(q,{sx:{mt:1,display:"flex",gap:1,alignItems:"center"},children:e.optional?s(L,{size:"small",label:"Optional"}):null})]}),x(lt,{className:"step-actions-overlay",children:[r&&s(R,{onClick:r,size:"small","aria-label":"Play",children:s(tt,{})}),r&&s(R,{onClick:r,size:"small","aria-label":"Play from here",children:s(nt,{})}),o&&s(R,{onClick:o,size:"small","aria-label":"Edit",children:s(rt,{})}),i&&s(R,{onClick:i,size:"small","aria-label":"Delete",children:s(Ke,{})})]})]}),Vp=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>x(ot,{elevation:1,$hasOrigin:!!e.originRef,children:[s(it,{children:t}),s(L,{icon:s(is,{}),label:"Tap",color:"primary",variant:"outlined"}),x(at,{children:[e.originRef?.path&&s(ft,{path:e.originRef?.path}),s(V,{fontWeight:"bold",children:e.descriptionText||"Tap Interaction"}),e.status&&s(st,{statuscolor:e.statusColor,children:e.status}),x(q,{sx:{mt:1,display:"flex",gap:1,flexWrap:"wrap"},children:[e.optional?s(L,{size:"small",label:"Optional"}):null,e.useLlmOnly?s(L,{size:"small",label:"LLM Only"}):null,e.elementId?s(L,{size:"small",label:`Element ID: ${e.elementId}`}):null,typeof e.timeout=="number"?s(L,{size:"small",label:`Timeout: ${e.timeout} ms`}):null]})]}),x(lt,{className:"step-actions-overlay",children:[s(R,{size:"small",onClick:n,title:"Play this step",children:s(tt,{})}),s(R,{size:"small",onClick:r,title:"Play from here",children:s(nt,{})}),s(R,{size:"small",onClick:o,title:"Edit",children:s(rt,{})}),s(R,{size:"small",onClick:i,title:"Delete",children:s(Ke,{})})]})]}),Mp=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>x(ot,{elevation:1,$hasOrigin:!!e.originRef,children:[s(it,{children:t}),s(L,{icon:s(as,{}),label:"Assert",color:"warning",variant:"outlined"}),x(at,{children:[e.originRef?.path&&s(ft,{path:e.originRef?.path}),s(V,{fontWeight:"bold",children:e.descriptionText||"Assert Element"}),e.status&&s(st,{statuscolor:e.statusColor,children:e.status}),x(q,{sx:{mt:1,display:"flex",gap:1,flexWrap:"wrap"},children:[e.optional?s(L,{size:"small",label:"Optional"}):null,e.useLlmOnly?s(L,{size:"small",label:"LLM Only"}):null,e.elementId?s(L,{size:"small",label:`Element ID: ${e.elementId}`}):null,typeof e.timeout=="number"?s(L,{size:"small",label:`Timeout: ${e.timeout} ms`}):null]})]}),x(lt,{className:"step-actions-overlay",children:[s(R,{size:"small",onClick:n,title:"Play this step",children:s(tt,{})}),s(R,{size:"small",onClick:r,title:"Play from here",children:s(nt,{})}),s(R,{size:"small",onClick:o,title:"Edit",children:s(rt,{})}),s(R,{size:"small",onClick:i,title:"Delete",children:s(Ke,{})})]})]}),Wp=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>x(ot,{elevation:1,$hasOrigin:!!e.originRef,children:[s(it,{children:t}),s(L,{icon:s(es,{}),label:"Type",color:"primary",variant:"outlined"}),x(at,{children:[e.originRef?.path&&s(ft,{path:e.originRef?.path}),s(V,{fontWeight:"bold",children:e.descriptionText||`Type "${e.text}"`}),e.status&&s(st,{statuscolor:e.statusColor,children:e.status}),x(q,{sx:{mt:1,display:"flex",gap:1,flexWrap:"wrap"},children:[s(L,{size:"small",label:`Text: ${e.text}`}),e.optional?s(L,{size:"small",label:"Optional"}):null]})]}),x(lt,{className:"step-actions-overlay",children:[s(R,{size:"small",onClick:n,title:"Play this step",children:s(tt,{})}),s(R,{size:"small",onClick:r,title:"Play from here",children:s(nt,{})}),s(R,{size:"small",onClick:o,title:"Edit",children:s(rt,{})}),s(R,{size:"small",onClick:i,title:"Delete",children:s(Ke,{})})]})]}),Gp=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>x(ot,{elevation:1,$hasOrigin:!!e.originRef,children:[s(it,{children:t}),s(L,{icon:s(Jo,{}),label:"Scroll",color:"secondary",variant:"outlined"}),x(at,{children:[e.originRef?.path&&s(ft,{path:e.originRef?.path}),s(V,{fontWeight:"bold",children:e.descriptionText||`Scroll ${e.direction}`}),e.status&&s(st,{statuscolor:e.statusColor,children:e.status}),x(q,{display:"flex",gap:1,mt:1,children:[s(L,{label:`Direction: ${e.direction}`,size:"small"}),e.optional?s(L,{size:"small",label:"Optional"}):null]})]}),x(lt,{className:"step-actions-overlay",children:[s(R,{size:"small",onClick:n,title:"Play this step",children:s(tt,{})}),s(R,{size:"small",onClick:r,title:"Play from here",children:s(nt,{})}),s(R,{size:"small",onClick:o,title:"Edit",children:s(rt,{})}),s(R,{size:"small",onClick:i,title:"Delete",children:s(Ke,{})})]})]}),zp=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>x(ot,{elevation:1,$hasOrigin:!!e.originRef,children:[s(it,{children:t}),s(L,{icon:s(Jo,{}),label:"Swipe",color:"secondary",variant:"outlined"}),x(at,{children:[e.originRef?.path&&s(ft,{path:e.originRef?.path}),s(V,{fontWeight:"bold",children:e.descriptionText||`Swipe ${e.direction}`}),e.status&&s(st,{statuscolor:e.statusColor,children:e.status}),x(q,{display:"flex",gap:1,mt:1,children:[s(L,{label:`Direction: ${e.direction}`,size:"small"}),typeof e.x=="number"&&typeof e.y=="number"?s(L,{label:`Start: ${e.x}, ${e.y}`,size:"small"}):null,typeof e.duration=="number"?s(L,{label:`Duration: ${e.duration}ms`,size:"small"}):null,e.optional?s(L,{size:"small",label:"Optional"}):null]})]}),x(lt,{className:"step-actions-overlay",children:[s(R,{size:"small",onClick:n,title:"Play this step",children:s(tt,{})}),s(R,{size:"small",onClick:r,title:"Play from here",children:s(nt,{})}),s(R,{size:"small",onClick:o,title:"Edit",children:s(rt,{})}),s(R,{size:"small",onClick:i,title:"Delete",children:s(Ke,{})})]})]}),Hp=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>x(ot,{elevation:1,$hasOrigin:!!e.originRef,children:[s(it,{children:t}),s(L,{icon:s(ts,{}),label:"Zoom",color:"secondary",variant:"outlined"}),x(at,{children:[e.originRef?.path&&s(ft,{path:e.originRef?.path}),s(V,{fontWeight:"bold",children:e.descriptionText||`Zoom ${e.direction}`}),e.status&&s(st,{statuscolor:e.statusColor,children:e.status}),x(q,{display:"flex",gap:1,mt:1,children:[s(L,{label:`Direction: ${e.direction}`,size:"small"}),e.optional?s(L,{size:"small",label:"Optional"}):null]})]}),x(lt,{className:"step-actions-overlay",children:[s(R,{size:"small",onClick:n,title:"Play this step",children:s(tt,{})}),s(R,{size:"small",onClick:r,title:"Play from here",children:s(nt,{})}),s(R,{size:"small",onClick:o,title:"Edit",children:s(rt,{})}),s(R,{size:"small",onClick:i,title:"Delete",children:s(Ke,{})})]})]}),Up=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>x(ot,{elevation:1,$hasOrigin:!!e.originRef,children:[s(it,{children:t}),s(L,{icon:s(ns,{}),label:"Scroll Until",color:"info",variant:"outlined"}),x(at,{children:[e.originRef?.path&&s(ft,{path:e.originRef?.path}),s(V,{fontWeight:"bold",children:e.descriptionText||"Scroll Until Found"}),e.status&&s(st,{statuscolor:e.statusColor,children:e.status}),x(q,{display:"flex",gap:1,mt:1,alignItems:"center",sx:{flexWrap:"wrap"},children:[e.text?s(L,{label:`Find: ${e.text}`,size:"small"}):null,e.elementId?s(L,{label:`Element ID: ${e.elementId}`,size:"small"}):null,s(L,{label:`Direction: ${e.direction}`,size:"small"}),s(L,{label:`Max Scrolls: ${e.maxScrolls}`,size:"small"}),e.optional?s(L,{size:"small",label:"Optional"}):null]})]}),x(lt,{className:"step-actions-overlay",children:[s(R,{size:"small",onClick:n,title:"Play this step",children:s(tt,{})}),s(R,{size:"small",onClick:r,title:"Play from here",children:s(nt,{})}),s(R,{size:"small",onClick:o,title:"Edit",children:s(rt,{})}),s(R,{size:"small",onClick:i,title:"Delete",children:s(Ke,{})})]})]}),jp=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>x(ot,{elevation:1,$hasOrigin:!!e.originRef,children:[s(it,{children:t}),s(L,{icon:s(rs,{}),label:"Deeplink",color:"success",variant:"outlined"}),x(at,{children:[e.originRef?.path&&s(ft,{path:e.originRef?.path}),s(V,{fontWeight:"bold",children:e.descriptionText||"Open Deep Link"}),e.status&&s(st,{statuscolor:e.statusColor,children:e.status}),x(q,{sx:{mt:1,display:"flex",gap:1,flexWrap:"wrap"},children:[s(L,{size:"small",label:`URL: ${e.url}`}),e.optional?s(L,{size:"small",label:"Optional"}):null]})]}),x(lt,{className:"step-actions-overlay",children:[s(R,{size:"small",onClick:n,title:"Play this step",children:s(tt,{})}),s(R,{size:"small",onClick:r,title:"Play from here",children:s(nt,{})}),s(R,{size:"small",onClick:o,title:"Edit",children:s(rt,{})}),s(R,{size:"small",onClick:i,title:"Delete",children:s(Ke,{})})]})]}),qp=({step:e,stepNumber:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>x(ot,{elevation:1,$hasOrigin:!!e.originRef,children:[s(it,{children:t}),s(L,{icon:s(os,{}),label:"AI",color:"secondary"}),x(at,{children:[e.originRef?.path&&s(ft,{path:e.originRef?.path}),s(V,{fontWeight:"bold",children:e.descriptionText||"AI Instruction"}),e.status&&s(st,{statuscolor:e.statusColor,children:e.status}),x(q,{sx:{mt:1,display:"flex",gap:1,flexWrap:"wrap"},children:[s(L,{size:"small",label:`Instruction: ${e.instruction}`}),e.optional?s(L,{size:"small",label:"Optional"}):null]})]}),x(lt,{className:"step-actions-overlay",children:[s(R,{size:"small",onClick:n,title:"Play this step",children:s(tt,{})}),s(R,{size:"small",onClick:r,title:"Play from here",children:s(nt,{})}),s(R,{size:"small",onClick:o,title:"Edit",children:s(rt,{})}),s(R,{size:"small",onClick:i,title:"Delete",children:s(Ke,{})})]})]}),ie=e=>{const t="/_serverFn/"+e;return Object.assign(async(...n)=>(await ss(e))(...n),{url:t,functionId:e,[ls]:!0})},Kp=ie("605c05774def700303f9889c0f8a28fed026e0b5c36a1563cff2835ee01d26b1"),Yp=oe({method:"POST"}).inputValidator(cs).handler(Kp,async({data:e})=>(console.log(`Performing tap at ${e.x}, ${e.y}`),await hs(e),{success:!0})),ia=ve({mutationKey:["device","tap"],mutationFn:e=>Yp({data:e})}),Xp=ie("07e23aa87e88d53c6c9e3d8e88de788d27d7b10930150bc4fd510d4447aaf3de"),Jp=oe({method:"POST"}).inputValidator(ds).handler(Xp,async({data:e})=>(console.log(`Performing type: "${e.text}"`),await gs(e),{success:!0})),aa=ve({mutationKey:["device","type"],mutationFn:e=>Jp({data:e})}),Qp=ie("2b4a002699960d578addbcf4dd83fedcec62444d7da4bf7c2359be991ed6207e"),Zp=oe({method:"POST"}).inputValidator(ms).handler(Qp,async({data:e})=>(console.log(`Performing swipe: ${e.x1},${e.y1} -> ${e.x2},${e.y2}`),await Qo(e),{success:!0})),sa=ve({mutationKey:["device","swipe"],mutationFn:e=>Zp({data:e})}),ef=ie("10b616f4aacf11bb275166e4ae03f441f1d7c9a68a670dfadb03b74e1d012900"),tf=oe({method:"POST"}).inputValidator(us).handler(ef,async({data:e})=>{console.log(`Performing scroll until: text="${e.text}", id="${e.elementId}", dir=${e.direction}`);for(let t=0;t<(e.maxScrolls??15);t++){console.log(`Scroll Until Loop: ${t+1}/${e.maxScrolls}`);const n=await Rn(),r=await Es(n);let o=r.hierarchy?.node?.[0];const i=r.hierarchy?.node;if(i){const l=i.find(d=>d.$&&d.$.package!=="com.android.systemui");l&&(o=l)}let a=!1;if(e.elementId&&ws(o,e.elementId)&&(a=!0),!a&&e.text&&Cs(o,e.text)&&(a=!0),a)return console.log("Target found!"),{success:!0,scrolls:t};t<(e.maxScrolls??15)-1&&(await Qo({direction:e.direction}),await new Promise(l=>setTimeout(l,1e3)))}return console.log("Target NOT found after max scrolls"),{success:!1}}),nf=ve({mutationKey:["device","scrollUntil"],mutationFn:e=>tf({data:e})}),rf=ie("c23cd3196f54848abd64a8b8d4660d7826a70cf44169d7bf29fc82e74a2cf612"),of=oe({method:"POST"}).inputValidator(fs).handler(rf,async({data:e})=>(console.log(`Performing zoom: ${e.direction}`),await ys(e),{success:!0})),af=ve({mutationKey:["device","zoom"],mutationFn:e=>of({data:e})}),sf=ie("566ee4344553ab6300f847f5de346e037f92d986cb824ba1c313346e62345fbe"),lf=oe({method:"POST"}).inputValidator(ps).handler(sf,async({data:e})=>(console.log(`Performing deep link: "${e.url}"`),await bs(e.url),{success:!0})),cf=ve({mutationKey:["device","deepLink"],mutationFn:e=>lf({data:e})}),df=ie("74707f0f69b6fbfb702db467d1eb3f8fb90ba2efd5f82338b79ec07903e39dc6"),uf=oe({method:"POST"}).handler(df,async e=>{const t=e.data;return console.log(`Restarting app on device: ${t.deviceId??"default"}`),await xs(t.platform,t.deviceId),{success:!0}}),pf=ve({mutationKey:["device","restartApp"],mutationFn:e=>uf({data:e})}),ff=ie("eea1073a910f7f023004366aafcef05a8c47a3a1a4a09721f71a2efe311ee70f"),mf=oe({method:"POST"}).handler(ff,async e=>{const{platform:t="android",deviceId:n}=hr.parse(e.data);return await vs(t,n),{success:!0}}),hf=ve({mutationKey:["device","appium","start"],mutationFn:e=>mf({data:e})}),gf=ie("6dbdc2968dc27a948c345034d1e55082b86918953b61da020ea8dd5836c79db3"),bf=oe({method:"GET"}).handler(gf,async e=>{const{platform:t="android",deviceId:n}=hr.parse(e.data),{isAppiumConnected:r}=await import("./appium-client-NLCErNZG.mjs");return{connected:r(t,n)}}),yf=(e={})=>Ft({queryKey:["device","appium","status",e],queryFn:()=>bf({data:e}),refetchInterval:2e3}),vf=ie("c5aeaa72b9b3303af5d82ee2fa59e3e90ffef3c3f0fb32707cee49e78ff41066"),la=oe({method:"GET"}).handler(vf,async e=>{const t=hr.parse(e.data),{platform:n="android",deviceId:r}=t,o=async()=>({success:!0,base64:`data:image/png;base64,${(await As(r)).toString("base64")}`,format:"base64",platform:"android",deviceId:r}),i=async()=>({success:!0,base64:`data:image/jpeg;base64,${(await Bs(r)).toString("base64")}`,format:"base64",platform:"ios",deviceId:r});try{return n==="android"?await o():await i()}catch(a){return console.error(`Screenshot failed for ${n} ${r||""}:`,a),{success:!1,error:a.message}}}),ca=(e={})=>Ft({queryKey:["device","screenshot",e],queryFn:()=>la({data:e}),staleTime:0,gcTime:0}),xf=ve({mutationKey:["device","screenshot_mutation"],mutationFn:e=>la({data:e})}),Df=ie("1ed4d2aa14be99e8c5a81eefbece63cea629a89f75862c60f9ff19c4d4dc67c5"),Ef=oe().handler(Df,async()=>{const e=await Rn(),t=gr(),n=br(),r=t==="ios"?yr(e):vr(e),o=Is({elements:r,deviceDimensions:n,allowNonClickableItems:!0,ignoredElements:[]}),i=Ns({items:o});return{...n,elements:i}}),wf=k.object({x:k.number(),y:k.number(),screenshotHeight:k.number(),screenshotWidth:k.number()}),Cf=ie("05faf0772038a170c70083fd8de4a8b77a40e4ec46e0bbf6878670f02621b5df"),If=oe({method:"POST"}).inputValidator(wf).handler(Cf,async({data:e})=>{console.log(`Getting element ID at ${e.x}, ${e.y}`);const t=await Rn();console.log("pageSource",t);const n=gr(),r=br(),o=Ds(e.x,e.y,n,e.screenshotWidth,e.screenshotHeight,r.width,r.height);console.log("scaled",o);const i=n==="ios"?yr(t):vr(t);console.log("elements",i);const a=Ss(i,o.x,o.y,r);if(!a)return console.log("No element found at coordinates"),{elementId:""};const l=(a.attributes?.["resource-id"]??a.attributes?.accessibilityIdentifier)?.trim();if(l){let d=l;const c=Os(i,a,d);return c>=0?(d=`${d}[${c}]`,console.log(`Found duplicate IDs, using indexed ID: ${d}`)):console.log("Found unique element ID:",d),{elementId:d}}return console.log("Element found but has no resource-id"),{elementId:""}}),Nf=ve({mutationKey:["device","hierarchy","getElementId"],mutationFn:e=>If({data:e})}),Sf=ie("9bcbf5303827d2a25f347c2054b0121655a82322fa07108653f43246875348f7"),Of=oe({method:"POST"}).inputValidator($s).handler(Sf,async({data:e})=>{console.log(`Finding element by ID: ${e.elementId}`);const t=await Rn(),n=gr();br();const r=n==="ios"?yr(t):vr(t),o=e.elementId.match(/^(.+)\[(\d+)\]$/),i=o?o[1]:e.elementId,a=o?parseInt(o[2],10):-1,l=r.filter(p=>(p.attributes?.["resource-id"]??p.attributes?.accessibilityIdentifier)===i);if(l.length===0)return console.log("No element found with ID:",e.elementId),{found:!1,x:0,y:0};const d=a>=0&&a<l.length?l[a]:l[0],c=d.bounds.x+d.bounds.width/2,f=d.bounds.y+d.bounds.height/2;return console.log(`Found element at center: (${c}, ${f})`),{found:!0,x:c,y:f}}),Pf=ve({mutationKey:["device","hierarchy","findElementById"],mutationFn:e=>Of({data:e})}),da=({enabled:e})=>Ft({queryKey:["visibleElements"],queryFn:Ef,enabled:e}),Af=ie("9f335634267a450fc9f34b1ab33c55da00cb1efc709604b2e3114602020075a2"),Rf=oe({method:"POST"}).handler(Af,async()=>(console.log("Disabling Android animations..."),await Rs(),{success:!0})),Tf=ve({mutationKey:["device","adb","disableAnimations"],mutationFn:()=>Rf()}),Bf=ie("33557b2fcc5cedc5814d20bca9cd9cde2e45318755de1da4d613e8fa84ee38d1"),$f=oe({method:"GET"}).handler(Bf,async()=>{const[e,t]=await Promise.all([Ps(),Ts()]);return[...e,...t]}),ua=Ft({queryKey:["devices"],queryFn:()=>$f()}),pa="https://cache.mobileboost.io";function fa(){const e=Te.join(process.cwd(),"mobileboost.config.json");if(!oo.existsSync(e))throw new Error("mobileboost.config.json not found");const t=oo.readFileSync(e,"utf-8");return JSON.parse(t)}function ma(e,t,n,r,o,i){const a=i?`${i.width}x${i.height}`:"",l=`${e}${t||""}${n}${r}${o||""}${a}`;return ks.createHash("sha256").update(l).digest("hex")}function ha(e,t){return e.match(/([xy])=(\d+)/)?e.replace(/([xy])=(\d+)/g,(n,r,o)=>{const i=parseInt(o,10);let a;return t==="multiply"?a=Math.round(i*bt):a=Math.round(i/bt),`${r}=${a}`}):e.replace(/(^|;)(\d+);(\d+)(;|$)/,(n,r,o,i,a)=>{const l=parseInt(o,10),d=parseInt(i,10);let c,f;return t==="multiply"?(c=Math.round(l*bt),f=Math.round(d*bt)):(c=Math.round(l/bt),f=Math.round(d/bt)),`${r}${c};${f}${a}`})}const kf=ie("fcbe7e11d05240fa28a1dd79ec8c395f6c03682edbaeb19f469bd78d6399cdde"),_f=oe({method:"POST"}).inputValidator(e=>Ls.parse(e)).handler(kf,async({data:e})=>{try{const t=fa().apiKey;if(!t)throw new Error("API Key missing");const n=ma(t,e.filepath,e.stepNumber,e.stepDescription,e.platform,e.screenResolution),r=await Promise.all(e.executionData.map(async l=>{const d=Buffer.from(l.screenshot.replace(/^data:image\/\w+;base64,/,""),"base64"),c=(await Ut(d).metadata()).width??1080,f=Math.round(c/bt),p=await Ut(d).resize({width:f,withoutEnlargement:!0}).toBuffer(),u=l.commands.map(m=>ha(m,"divide"));return{screenshot:p.toString("base64"),commands:u}})),o=JSON.stringify(r),i=(o.length/(1024*1024)).toFixed(2);console.log(`[Cache Client] Populating cache with payload size: ~${i} MB (Hash: ${n})`);const a=await fetch(`${pa}/populate-cache?hash=${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:o});return a.ok?{success:!0}:(console.error("Failed to populate cache:",await a.text()),{success:!1})}catch(t){return console.error("Error populating cache:",t),{success:!1,error:String(t)}}}),Ff=ie("7d2aacaab26ab11cdc66f03a4ed01b8b38186abf16ab1f9306801ea7769aaa2a"),Lf=oe({method:"POST"}).inputValidator(e=>_s.parse(e)).handler(Ff,async({data:e})=>{try{const t=fa().apiKey;if(!t)throw new Error("API Key missing");const n=ma(t,e.filepath,e.stepNumber,e.stepDescription,e.platform,e.screenResolution),r=Buffer.from(e.screenshot.replace(/^data:image\/\w+;base64,/,""),"base64"),o=(await Ut(r).metadata()).width??1080,i=Math.round(o/bt),a=await Ut(r).resize({width:i,withoutEnlargement:!0}).toBuffer(),l=await Ut(a).metadata();console.log(l.width,l.height);const d=new FormData;d.append("hash",n);const c=new Blob([new Uint8Array(a)],{type:"image/png"}),f=(c.size/(1024*1024)).toFixed(2);console.log(`[Cache Client] Executing from cache with screenshot size: ${f} MB (Hash: ${n})`),d.append("screenshot",c,"screenshot.png"),e.highest_used_index!==void 0&&e.highest_used_index!==null&&(console.log(`[Cache Client] Sending highest_used_index: ${e.highest_used_index} (Type: ${typeof e.highest_used_index})`),d.append("highest_used_index",String(e.highest_used_index)));const p=await fetch(`${pa}/execute-from-cache`,{method:"POST",body:d});if(!p.ok){const g=await p.text();return console.warn("Cache lookup failed:",g),{found:!1}}const u=await p.json(),m=Fs.safeParse(u);if(m.success){const g={...m.data};return g.found&&g.cacheCommands&&(g.cacheCommands=g.cacheCommands.map(y=>ha(y,"multiply"))),g}return console.error("Invalid cache response:",u),{found:!1}}catch(t){return console.error("Error executing from cache:",t),{found:!1,error:String(t)}}}),Vf={mutationFn:e=>Lf({data:e}),mutationKey:["executeFromCache"]},ga={mutationFn:e=>_f({data:e}),mutationKey:["populateCache"]},Mf=ie("5918013064f9b88efb265b30a770275d6c9d52bf42318f451bab8a47bc850917"),Wf=oe({method:"POST"}).inputValidator(Vs).handler(Mf,async({data:e})=>await Ms(e)),Gf=ve({mutationKey:["ai","executeAgentStep"],mutationFn:e=>Wf({data:e})});async function fn(){const e=Te.join(process.cwd(),"mobileboost.config.json");let t="./tests";if(await Be.pathExists(e))try{const n=await Be.readJSON(e);n.testDir&&(t=n.testDir)}catch(n){console.error("Error reading config, using default testDir",n)}return Te.resolve(process.cwd(),t)}async function Vn(e){const t=await fn(),n=Te.resolve(t,e);if(!n.startsWith(t))throw new Error("Invalid path: must be within test directory");return n}k.object({name:k.string(),type:k.enum(["file","directory"]),path:k.string()});const zf=ie("00fb1fe03e9689cf8c179ba0d5cadc5eeaa6879def224ac38037d70a1a51300d"),Hf=oe({method:"GET"}).handler(zf,async()=>{const e=await fn();await Be.ensureDir(e);async function t(n){let r=[];const o=await Be.readdir(n,{withFileTypes:!0});for(const i of o){const a=Te.join(n,i.name),l=Te.relative(e,a);i.isDirectory()?(r.push({name:i.name,type:"directory",path:l}),r=r.concat(await t(a))):r.push({name:i.name,type:"file",path:l})}return r}return{files:await t(e)}}),Uf=k.record(k.string(),k.string()).optional().default({});k.object({testDir:k.string(),driver:k.string(),port:k.number(),apiKey:k.string(),variables:Uf});const jf=ie("54b0d7153f4ee4f963b29e7c835e76cedaaf345527fdc912c49030ea79353b5e"),qf=oe({method:"GET"}).handler(jf,async()=>{let e={};const t=Te.join(process.cwd(),"mobileboost.config.json"),n=Te.join(process.cwd(),".env");if(await Be.pathExists(t))try{e={...(await Be.readJSON(t)).variables}}catch{}if(await Be.pathExists(n))try{const r=await zs(n,"utf-8"),o=Hs.parse(r);e={...e,...o}}catch{}return e}),Ur=Ft({queryKey:["files"],queryFn:()=>Hf()}),Kf=k.object({name:k.string(),type:k.enum(["file","directory"]),parentPath:k.string().optional()}),Yf=ie("ac7bf7f1d727949cd28713a8f36bb77e7bd8fc0e48854ed8cb1ee93ce80fb6d0"),Xf=oe({method:"POST"}).inputValidator(Kf).handler(Yf,async({data:e})=>{const t=await fn(),n=e.parentPath?Te.join(t,e.parentPath):t;if(!Te.resolve(n).startsWith(t))throw new Error("Invalid parent path");const r=Te.join(n,e.name);if(e.type==="directory")await Be.ensureDir(r);else{if(await Be.pathExists(r))throw new Error("File already exists");await Be.writeJSON(r,[],{spaces:2})}return{success:!0}}),Jf=ve({mutationKey:["createFile"],mutationFn:e=>Xf({data:e})}),Qf=k.object({path:k.string()}),Zf=ie("b41e844ce533c224e7c720e69d821468deffcbf208fc008a7f5af83cb0596b15"),em=oe({method:"POST"}).inputValidator(Qf).handler(Zf,async({data:e})=>{const t=await Vn(e.path);try{return{content:await Be.readJSON(t),path:e.path}}catch(n){throw console.error("Failed to read file",n),new Error("Failed to read file or invalid format")}}),jr=ve({mutationKey:["readFile"],mutationFn:e=>em({data:e})}),tm=k.object({path:k.string(),content:Za}),nm=ie("1b2a0d276d9ce90b2a1d72134c1bf95b9f6b7b049a8f415e8f0da3e6fc5ce4ae"),rm=oe({method:"POST"}).inputValidator(tm).handler(nm,async({data:e})=>{const t=await Vn(e.path);return await Be.writeJSON(t,e.content,{spaces:2}),{success:!0}}),ba=Ft({queryKey:["variables"],queryFn:qf,refetchInterval:1e4}),om=ve({mutationKey:["saveFile"],mutationFn:e=>rm({data:e})}),im=k.object({oldPath:k.string(),newPath:k.string()}),am=ie("098d52adf25ea567d43facba347871f887828c6ab804021bbfa0f2759209c0c6"),sm=oe({method:"POST"}).inputValidator(im).handler(am,async({data:e})=>{const t=await Vn(e.oldPath),n=await fn(),r=Te.resolve(n,e.newPath);if(!r.startsWith(n))throw new Error("Invalid new path");return await Be.rename(t,r),{success:!0}}),lm=ve({mutationKey:["renameFile"],mutationFn:e=>sm({data:e})}),cm=k.object({sourcePath:k.string(),targetPath:k.string()}),dm=ie("efbbc22c41cf491631b07076417c9ec65d5ac71debfcc00b5a7e0d368772104f"),um=oe({method:"POST"}).inputValidator(cm).handler(dm,async({data:e})=>{const t=await Vn(e.sourcePath),n=await fn(),r=Te.resolve(n,e.targetPath);if(!r.startsWith(n))throw new Error("Invalid target path");await Be.ensureDir(r);const o=Te.basename(t),i=Te.join(r,o);return await Be.move(t,i,{overwrite:!1}),{success:!0}});ve({mutationKey:["moveFile"],mutationFn:e=>um({data:e})});function pm(e){const t=e?.bounds||e?.attributes?.bounds,n=t?{x:t.x,y:t.y,width:t.width,height:t.height}:void 0,r=e?.text??e?.attributes?.text??e?.name??void 0,o=e?.resourceId??e?.attributes?.["resource-id"]??void 0,i=e?.attributes?.["content-desc"]??e?.attributes?.["accessibility-text"]??e?.accessibilityText??void 0,a=e?.label??e?.attributes?.label??void 0,l=e?.accessibilityIdentifier??e?.attributes?.accessibilityIdentifier??void 0,d=e?.hint??e?.attributes?.hint??e?.value??e?.attributes?.value??void 0,c={...n?{bounds:n}:{},...r?{text:String(r)}:{},...o?{resourceId:String(o)}:{},...i?{contentDesc:String(i)}:{},...a?{accessibilityLabel:String(a)}:{},...l?{accessibilityIdentifier:String(l)}:{},...d?{hint:String(d)}:{}};return Object.keys(c).length>0?c:void 0}function fm(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){const r=pm(n);r&&t.push(r)}return t}const mm=/\{\{\s*([a-zA-Z0-9_.-]+)\s*\}\}/g,qr=e=>{if(!e)return[];const t=new Set;let n;const r=new RegExp(mm);for(;(n=r.exec(e))!==null;)n[1]&&t.add(n[1]);return Array.from(t)},St=(e,t)=>{const n=t?.required??!1;return({value:r})=>{const o=String(r??"").trim();if(!o)return n?"This field is required":void 0;const i=qr(o);if(i.length===0)return;const a=e(),l=i.filter(d=>!Object.prototype.hasOwnProperty.call(a,d));if(l.length>0)return`Undefined params: ${l.join(", ")}`}},We=k.number().min(0,"Must be 0 or greater");k.string().min(1,"This field is required");const ya=k.enum(["up","down"]),hm=k.enum(["left","right"]),gm=k.enum(["in","out"]),bm=k.string().min(1,"URL is required").regex(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/.+$/,"Invalid deeplink format (e.g., myapp://screen)"),te=e=>e.length?e.map(t=>typeof t=="string"?t:t?.message).filter(Boolean).join(", "):null,ym=({step:e,onSave:t,onCancel:n})=>{const r=En(()=>({id:Date.now(),type:"tap",descriptionText:"",optional:!1,timeout:3e3,useLlmOnly:!1,text:"",elementId:"",maxScrolls:15,direction:"down",url:"",instruction:"",path:""}),[]),{data:o}=Ze(Ur),{data:i}=Ze(ba),a=ne.useCallback(()=>({...C.state.test.params,...i??{}}),[i]),l=new Set((o?.files||[]).filter(c=>c.type==="file").map(c=>c.path)),d=Us({defaultValues:{...r(),...e},onSubmit:({value:c})=>{if(c&&(c.type==="tap"||c.type==="assert")&&("x"in c&&delete c.x,"y"in c&&delete c.y),c.type==="fileRef"){const p=(c.path||"").trim();if(!p||o&&!l.has(p)){alert("The specified file does not exist in your tests directory.");return}}let f;switch(c.type){case"tap":f=Qa.parse(c);break;case"assert":f=Ja.parse(c);break;case"type":f=Xa.parse(c);break;case"scroll":f=Ya.parse(c);break;case"swipe":f=Ka.parse(c);break;case"scrollUntil":f=qa.parse(c);break;case"deeplink":f=ja.parse(c);break;case"ai":f=Ua.parse(c);break;case"fileRef":f=Ha.parse(c);break;default:f=Xo.parse(c)}if(!e)C.setState(p=>({...p,test:{...p.test,steps:[...p.test.steps,f]}}));else{const p=f.id;C.setState(u=>({...u,test:{...u.test,steps:u.test.steps.map(m=>m.id===p?f:m)}}))}t()}});return x(Am,{children:[s(V,{variant:"h6",gutterBottom:!0,children:e?"Edit Step":"Add New Step"}),s("form",{onSubmit:c=>{c.preventDefault(),c.stopPropagation(),d.handleSubmit()},children:x(Rm,{children:[s(d.Field,{name:"type",validators:{onChange:ro},children:c=>{const f=c.state.meta.errors.length>0;return x(Ot,{fullWidth:!0,error:f,children:[s(Lt,{id:"step-type",children:"Step type"}),s(Vt,{labelId:"step-type",id:"step-type",value:c.state.value,label:"Step type",onChange:p=>{const u=p.target.value,m=d.state.values.id;d.reset(),d.setFieldValue("id",m),d.setFieldValue("type",u)},onBlur:c.handleBlur,children:ro.options.map(p=>s(et,{value:p,children:p},p))}),f&&s(on,{children:te(c.state.meta.errors)})]})}}),s(rn,{sx:{mb:1}}),x(Tm,{children:[s(He,{children:"General Settings"}),s(d.Field,{name:"descriptionText",validators:{onChange:St(a,{required:!1})},children:c=>s(J,{id:"description-text",label:"Description",value:c.state.value??"",onChange:f=>c.handleChange(f.target.value),onBlur:c.handleBlur,placeholder:"Enter a description (you can use {{key}})",helperText:te(c.state.meta.errors)??"Use {{key}} to insert a param value",error:c.state.meta.errors?.length>0})}),s(d.Field,{name:"optional",validators:{onChange:k.boolean().optional()},children:c=>s(An,{control:s(mr,{checked:c.state.value??!1,onChange:f=>c.handleChange(f.target.checked)}),label:"Optional"})})]}),s(d.Subscribe,{selector:c=>c.values.type,children:c=>{switch(c){case"tap":return s(Dm,{form:d});case"assert":return s(Em,{form:d});case"type":return s(wm,{form:d,getDefinedParams:a});case"scroll":return s(Cm,{form:d});case"swipe":return s(Im,{form:d});case"zoom":return s(Nm,{form:d});case"scrollUntil":return s(Sm,{form:d,getDefinedParams:a});case"deeplink":return s(Om,{form:d,getDefinedParams:a});case"ai":return s(Pm,{form:d,getDefinedParams:a});case"fileRef":return s(vm,{form:d,getDefinedParams:a});default:return null}}}),x(Bm,{children:[s($e,{startIcon:s(js,{}),variant:"contained",type:"submit",children:"Save"}),s($e,{startIcon:s(Zo,{}),variant:"outlined",color:"error",onClick:n,children:"Cancel"})]})]})})]})},vm=({form:e,getDefinedParams:t})=>{const{data:n,isLoading:r}=Ze(Ur),o=new Set((n?.files||[]).filter(i=>i.type==="file").map(i=>i.path));return x(ct,{children:[s(He,{children:"File Reference"}),s(e.Field,{name:"path",validators:{onChange:({value:i})=>{const a=String(i??"").trim();if(!a)return"This field is required";if(qr(a).length>0)return St(t,{required:!0})({value:a});if(!r&&n&&!o.has(a))return"File not found in tests directory"}},children:i=>{const a=i.state.meta.errors?.length>0,l=a?te(i.state.meta.errors):r?"Checking files...":"Path is relative to your tests directory (supports {{key}})";return s(J,{id:"file-path",label:"File path",placeholder:"e.g., test2.json or subfolder/flow.json (you can use {{key}})",value:i.state.value??"",onChange:d=>i.handleChange(d.target.value),onBlur:i.handleBlur,error:a,helperText:l,fullWidth:!0})}}),s(e.Subscribe,{selector:i=>({path:i.values.path,overrides:i.values.overrides}),children:({path:i,overrides:a})=>s(xm,{path:i,overrides:a,onChange:l=>e.setFieldValue("overrides",l),validPaths:o})})]})},xm=({path:e,overrides:t,onChange:n,validPaths:r})=>{const[o,i]=ne.useState(!1),[a,l]=ne.useState({}),d=ee(jr);ne.useEffect(()=>{let u=!1;return(async()=>{if(!e||!r.has(e)){l({});return}i(!0);try{const m=(await d.mutateAsync({path:e}))?.content;Array.isArray(m)?l({}):l(m&&typeof m=="object"?m.params||{}:{})}catch{l({})}finally{u||i(!1)}})(),()=>{u=!0}},[e]);const c=t||{},f=(u,m)=>{const g={...c};m?g[u]=m:delete g[u],n(g)},p=Object.keys(a);return e?x(q,{sx:{mt:2},children:[s(V,{variant:"subtitle2",children:"Param overrides"}),o?s(V,{variant:"caption",color:"text.secondary",children:"Loading referenced test…"}):p.length===0?s(V,{variant:"caption",color:"text.secondary",children:"Referenced test has no params"}):s(q,{sx:{display:"flex",flexDirection:"column",gap:1,mt:1},children:p.map(u=>x(q,{sx:{display:"grid",gridTemplateColumns:"160px 1fr",gap:1,alignItems:"center"},children:[s(J,{size:"small",label:"Key",value:u,disabled:!0}),x(q,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:[s(J,{size:"small",label:"Default",value:a[u]??"",disabled:!0}),s(J,{size:"small",label:"Override (optional)",value:c[u]??"",onChange:m=>f(u,m.target.value)})]})]},u))})]}):null},Dm=({form:e})=>x(ct,{children:[s(He,{children:"Tap Configuration"}),s(e.Field,{name:"timeout",validators:{onChange:We},children:t=>{const n=t.state.meta.errors?.length>0;return s(J,{type:"number",id:"timeout",label:"Timeout (ms)",value:t.state.value??0,onChange:r=>t.handleChange(parseInt(r.target.value)||0),onBlur:t.handleBlur,placeholder:"Enter timeout",error:n,helperText:te(t.state.meta.errors)})}}),s(e.Field,{name:"elementId",validators:{onChange:k.string().optional()},children:t=>{const n=t.state.meta.errors?.length>0;return s(J,{id:"tap-element-id",label:"Element Identifier (elementId)",value:t.state.value??"",onChange:r=>t.handleChange(r.target.value),onBlur:t.handleBlur,placeholder:"Android: com.app:id/button | iOS: accessibilityIdentifier/name/label",error:n,helperText:te(t.state.meta.errors)??(C.state.selectedPlatform==="ios"?"Optional. iOS: prefer accessibilityIdentifier, otherwise name/label. Supports index like value[2].":"Optional. Android: resource-id (e.g., com.app:id/button). Supports index like id[2].")})}}),s(e.Field,{name:"useLlmOnly",validators:{onChange:k.boolean().optional()},children:t=>s(An,{control:s(mr,{checked:t.state.value??!1,onChange:n=>t.handleChange(n.target.checked)}),label:"Use LLM only"})})]}),Em=({form:e})=>x(ct,{children:[s(He,{children:"Assert Configuration"}),s(e.Field,{name:"timeout",validators:{onChange:We},children:t=>{const n=t.state.meta.errors?.length>0;return s(J,{type:"number",id:"timeout",label:"Timeout (ms)",value:t.state.value??0,onChange:r=>t.handleChange(parseInt(r.target.value)||0),onBlur:t.handleBlur,placeholder:"Enter timeout",error:n,helperText:te(t.state.meta.errors)})}}),s(e.Field,{name:"elementId",validators:{onChange:k.string().optional()},children:t=>{const n=t.state.meta.errors?.length>0;return s(J,{id:"assert-element-id",label:"Resource ID (elementId)",value:t.state.value??"",onChange:r=>t.handleChange(r.target.value),onBlur:t.handleBlur,placeholder:"e.g. com.app:id/label or com.app:id/label[1]",error:n,helperText:te(t.state.meta.errors)??"Optional. Android resource-id of the element to assert."})}}),s(e.Field,{name:"useLlmOnly",validators:{onChange:k.boolean().optional()},children:t=>s(An,{control:s(mr,{checked:t.state.value??!1,onChange:n=>t.handleChange(n.target.checked)}),label:"Use LLM only"})})]}),wm=({form:e,getDefinedParams:t})=>x(ct,{children:[s(He,{children:"Type Configuration"}),s(e.Field,{name:"text",validators:{onChange:St(t,{required:!0})},children:n=>{const r=n.state.meta.errors?.length>0;return s(J,{id:"text",label:"Text to type",value:n.state.value??"",onChange:o=>n.handleChange(o.target.value),onBlur:n.handleBlur,placeholder:"Enter text to type (you can use {{key}})",multiline:!0,rows:3,error:r,helperText:te(n.state.meta.errors)??"Use {{key}} to insert a param value"})}})]}),Cm=({form:e})=>x(ct,{children:[s(He,{children:"Scroll Configuration"}),s(e.Field,{name:"direction",validators:{onChange:ya},children:t=>{const n=t.state.meta.errors?.length>0;return x(Ot,{fullWidth:!0,error:n,children:[s(Lt,{id:"scroll-direction",children:"Direction"}),x(Vt,{labelId:"scroll-direction",id:"scroll-direction",value:t.state.value??"down",label:"Direction",onChange:r=>t.handleChange(r.target.value),onBlur:t.handleBlur,children:[s(et,{value:"up",children:"Up"}),s(et,{value:"down",children:"Down"})]}),n&&s(on,{children:te(t.state.meta.errors)})]})}}),s(V,{variant:"caption",color:"text.secondary",sx:{mt:1},children:"Start coordinates (optional)"}),x(q,{sx:{display:"flex",gap:2},children:[s(e.Field,{name:"x1",validators:{onChange:We.optional()},children:t=>s(J,{type:"number",id:"scroll-start-x",label:"Start X",value:t.state.value??"",onChange:n=>{const r=n.target.value;t.handleChange(r===""?void 0:parseInt(r))},onBlur:t.handleBlur,placeholder:"e.g., 200",error:t.state.meta.errors?.length>0,helperText:te(t.state.meta.errors),fullWidth:!0})}),s(e.Field,{name:"y1",validators:{onChange:We.optional()},children:t=>s(J,{type:"number",id:"scroll-start-y",label:"Start Y",value:t.state.value??"",onChange:n=>{const r=n.target.value;t.handleChange(r===""?void 0:parseInt(r))},onBlur:t.handleBlur,placeholder:"e.g., 600",error:t.state.meta.errors?.length>0,helperText:te(t.state.meta.errors),fullWidth:!0})})]}),s(V,{variant:"caption",color:"text.secondary",sx:{mt:1},children:"End coordinates (optional - if not set, calculated from direction)"}),x(q,{sx:{display:"flex",gap:2},children:[s(e.Field,{name:"x2",validators:{onChange:We.optional()},children:t=>s(J,{type:"number",id:"scroll-end-x",label:"End X",value:t.state.value??"",onChange:n=>{const r=n.target.value;t.handleChange(r===""?void 0:parseInt(r))},onBlur:t.handleBlur,placeholder:"e.g., 200",error:t.state.meta.errors?.length>0,helperText:te(t.state.meta.errors),fullWidth:!0})}),s(e.Field,{name:"y2",validators:{onChange:We.optional()},children:t=>s(J,{type:"number",id:"scroll-end-y",label:"End Y",value:t.state.value??"",onChange:n=>{const r=n.target.value;t.handleChange(r===""?void 0:parseInt(r))},onBlur:t.handleBlur,placeholder:"e.g., 300",error:t.state.meta.errors?.length>0,helperText:te(t.state.meta.errors),fullWidth:!0})})]})]}),Im=({form:e})=>x(ct,{children:[s(He,{children:"Swipe Configuration"}),s(e.Field,{name:"direction",validators:{onChange:hm},children:t=>{const n=t.state.meta.errors?.length>0;return x(Ot,{fullWidth:!0,error:n,children:[s(Lt,{id:"swipe-direction",children:"Direction"}),x(Vt,{labelId:"swipe-direction",id:"swipe-direction",value:t.state.value??"left",label:"Direction",onChange:r=>t.handleChange(r.target.value),onBlur:t.handleBlur,children:[s(et,{value:"left",children:"Left"}),s(et,{value:"right",children:"Right"})]}),n&&s(on,{children:te(t.state.meta.errors)})]})}}),s(e.Field,{name:"duration",validators:{onChange:We.optional()},children:t=>{const n=t.state.meta.errors?.length>0;return s(J,{type:"number",id:"swipe-duration",label:"Duration (ms)",value:t.state.value??"",onChange:r=>{const o=r.target.value;t.handleChange(o===""?void 0:parseInt(o))},onBlur:t.handleBlur,placeholder:"e.g., 500 (default)",error:n,helperText:te(t.state.meta.errors)??"Optional. Duration of the swipe gesture in milliseconds."})}}),s(V,{variant:"caption",color:"text.secondary",sx:{mt:1},children:"Start coordinates (optional - defaults based on direction)"}),x(q,{sx:{display:"flex",gap:2},children:[s(e.Field,{name:"x1",validators:{onChange:We.optional()},children:t=>s(J,{type:"number",id:"swipe-start-x",label:"Start X",value:t.state.value??"",onChange:n=>{const r=n.target.value;t.handleChange(r===""?void 0:parseInt(r))},onBlur:t.handleBlur,placeholder:"e.g., 800",error:t.state.meta.errors?.length>0,helperText:te(t.state.meta.errors),fullWidth:!0})}),s(e.Field,{name:"y1",validators:{onChange:We.optional()},children:t=>s(J,{type:"number",id:"swipe-start-y",label:"Start Y",value:t.state.value??"",onChange:n=>{const r=n.target.value;t.handleChange(r===""?void 0:parseInt(r))},onBlur:t.handleBlur,placeholder:"e.g., 500",error:t.state.meta.errors?.length>0,helperText:te(t.state.meta.errors),fullWidth:!0})})]}),s(V,{variant:"caption",color:"text.secondary",sx:{mt:1},children:"End coordinates (optional - if not set, calculated from direction)"}),x(q,{sx:{display:"flex",gap:2},children:[s(e.Field,{name:"x2",validators:{onChange:We.optional()},children:t=>s(J,{type:"number",id:"swipe-end-x",label:"End X",value:t.state.value??"",onChange:n=>{const r=n.target.value;t.handleChange(r===""?void 0:parseInt(r))},onBlur:t.handleBlur,placeholder:"e.g., 200",error:t.state.meta.errors?.length>0,helperText:te(t.state.meta.errors),fullWidth:!0})}),s(e.Field,{name:"y2",validators:{onChange:We.optional()},children:t=>s(J,{type:"number",id:"swipe-end-y",label:"End Y",value:t.state.value??"",onChange:n=>{const r=n.target.value;t.handleChange(r===""?void 0:parseInt(r))},onBlur:t.handleBlur,placeholder:"e.g., 500",error:t.state.meta.errors?.length>0,helperText:te(t.state.meta.errors),fullWidth:!0})})]})]}),Nm=({form:e})=>x(ct,{children:[s(He,{children:"Zoom Configuration"}),s(e.Field,{name:"direction",validators:{onChange:gm},children:t=>{const n=t.state.meta.errors?.length>0;return x(Ot,{fullWidth:!0,error:n,children:[s(Lt,{id:"zoom-direction",children:"Direction"}),x(Vt,{labelId:"zoom-direction",id:"zoom-direction",value:t.state.value??"in",label:"Direction",onChange:r=>t.handleChange(r.target.value),onBlur:t.handleBlur,children:[s(et,{value:"in",children:"In (spread)"}),s(et,{value:"out",children:"Out (pinch)"})]}),n&&s(on,{children:te(t.state.meta.errors)})]})}})]}),Sm=({form:e,getDefinedParams:t})=>x(ct,{children:[s(He,{children:"Scroll Until Configuration"}),s(e.Field,{name:"direction",validators:{onChange:ya},children:n=>{const r=n.state.meta.errors?.length>0;return x(Ot,{fullWidth:!0,error:r,children:[s(Lt,{id:"scroll-until-direction",children:"Direction"}),x(Vt,{labelId:"scroll-until-direction",id:"scroll-until-direction",value:n.state.value??"down",label:"Direction",onChange:o=>n.handleChange(o.target.value),onBlur:n.handleBlur,children:[s(et,{value:"up",children:"Up"}),s(et,{value:"down",children:"Down"})]}),r&&s(on,{children:te(n.state.meta.errors)})]})}}),s(e.Field,{name:"maxScrolls",validators:{onChange:We},children:n=>{const r=n.state.meta.errors?.length>0;return s(J,{type:"number",id:"max-scrolls",label:"Max Scrolls",value:n.state.value??15,onChange:o=>n.handleChange(parseInt(o.target.value)||15),onBlur:n.handleBlur,placeholder:"Maximum scroll attempts",error:r,helperText:te(n.state.meta.errors)??"Maximum number of scroll attempts (default: 15)"})}}),s(He,{sx:{mt:1},children:"Stop Condition (at least one)"}),s(e.Field,{name:"text",validators:{onChange:St(t,{required:!1})},children:n=>{const r=n.state.meta.errors?.length>0;return s(J,{id:"scroll-until-text",label:"Text to find",value:n.state.value??"",onChange:o=>n.handleChange(o.target.value),onBlur:n.handleBlur,placeholder:"Text content to scroll until visible (supports {{key}})",error:r,helperText:te(n.state.meta.errors)??"Scroll until this text (with params resolved) is visible on screen"})}}),s(e.Field,{name:"elementId",validators:{onChange:St(t,{required:!1})},children:n=>{const r=n.state.meta.errors?.length>0;return s(J,{id:"scroll-until-element-id",label:"Element ID",value:n.state.value??"",onChange:o=>n.handleChange(o.target.value),onBlur:n.handleBlur,placeholder:"Element ID to scroll until visible (supports {{key}})",error:r,helperText:te(n.state.meta.errors)??"Scroll until element with this ID (after resolving params) is visible"})}})]}),Om=({form:e,getDefinedParams:t})=>x(ct,{children:[s(He,{children:"Deeplink Configuration"}),s(e.Field,{name:"url",validators:{onChange:({value:n})=>{const r=String(n??"").trim();if(!r)return"URL is required";if(qr(r).length>0)return St(t,{required:!0})({value:r});const o=bm.safeParse(r);return o.success?void 0:o.error.issues[0]?.message||"Invalid URL"}},children:n=>{const r=n.state.meta.errors?.length>0;return s(J,{id:"url",label:"URL",value:n.state.value??"",onChange:o=>n.handleChange(o.target.value),onBlur:n.handleBlur,placeholder:"Enter deeplink URL (you can use {{key}})",fullWidth:!0,error:r,helperText:te(n.state.meta.errors)??"Use {{key}} to insert a param value"})}})]}),Pm=({form:e,getDefinedParams:t})=>x(ct,{children:[s(He,{children:"AI Configuration"}),s(e.Field,{name:"instruction",validators:{onChange:St(t,{required:!0})},children:n=>{const r=n.state.meta.errors?.length>0;return s(J,{id:"instruction",label:"AI Instruction",value:n.state.value??"",onChange:o=>n.handleChange(o.target.value),onBlur:n.handleBlur,placeholder:"Enter instruction for AI to execute (you can use {{key}})",multiline:!0,rows:4,error:r,helperText:te(n.state.meta.errors)??"Use {{key}} to insert a param value"})}})]}),Am=Pt(q)`
178
+ padding: 1.5rem;
179
+ margin-bottom: 1.5rem;
180
+ `,Rm=Pt(q)`
181
+ display: flex;
182
+ flex-direction: column;
183
+ gap: 1.25rem;
184
+ `,va=Pt(q)`
185
+ display: flex;
186
+ flex-direction: column;
187
+ gap: 1rem;
188
+ padding: 1rem;
189
+ border-radius: 6px;
190
+ `,Tm=Pt(va)`
191
+ background-color: #fafafa;
192
+ border: 1px solid #e0e0e0;
193
+ `,ct=Pt(va)`
194
+ background-color: #f5f5f5;
195
+ border: 1px dashed #bdbdbd;
196
+ `,He=Pt(V)`
197
+ font-size: 0.75rem;
198
+ color: #757575;
199
+ text-transform: uppercase;
200
+ letter-spacing: 0.5px;
201
+ margin-bottom: 0.5rem;
202
+ `,Bm=Pt(q)`
203
+ display: flex;
204
+ gap: 0.5rem;
205
+ justify-content: center;
206
+ `,$m=()=>{const[e,t]=ye(!1),n=be(C,i=>i.executionLog),r=be(C,i=>i.isPlaying);if(n.length===0&&!r)return null;const o=()=>{t(!e)};return x(It,{children:[!e&&s(pt,{title:"Execution Log",placement:"left",children:s(km,{color:"primary",onClick:o,"aria-label":"Open execution log",children:s(Oa,{badgeContent:n.length,color:"error",max:99,children:s(Ys,{})})})}),e&&x(_m,{children:[x(Fm,{children:[x(V,{variant:"subtitle2",children:["Execution Log (",n.length," steps)"]}),s(R,{size:"small",onClick:o,children:s(Zo,{})})]}),s(Lm,{children:s(Vm,{children:n.map(i=>x(Mm,{children:[s(Wm,{src:i.screenshot,alt:`Step ${i.stepNumber}`}),x(Gm,{children:[x(zm,{children:["#",i.stepNumber]}),s(Hm,{children:i.cacheHit?s(pt,{title:"Cache Hit",children:s(qs,{color:"success",fontSize:"small"})}):s(pt,{title:"Cache Miss / Fresh Execution",children:s(Ks,{color:"info",fontSize:"small"})})})]}),x(Um,{children:[i.stepDescription&&x(It,{children:[s(_o,{children:"Description"}),s(Fo,{children:i.stepDescription})]}),i.executedCommands&&i.executedCommands.length>0&&x(It,{children:[s(_o,{children:i.cacheHit?"Commands (from cache)":"Commands"}),s(Fo,{children:i.executedCommands.join(`
207
+ `)})]})]})]},i.stepId))})})]})]})},km=T(Ba)`
208
+ position: fixed;
209
+ bottom: 24px;
210
+ right: 24px;
211
+ z-index: 1300;
212
+ `,_m=T(Uo)`
213
+ position: fixed;
214
+ bottom: 0;
215
+ left: 0;
216
+ right: 0;
217
+ z-index: 1300;
218
+ width: 100vw;
219
+ height: 400px;
220
+ max-height: calc(100vh - 48px);
221
+ border-radius: 12px 12px 0 0;
222
+ overflow: hidden;
223
+ display: flex;
224
+ flex-direction: column;
225
+ background-color: ${({theme:e})=>e.palette?.background?.paper||"#fff"};
226
+ box-shadow: 0px -4px 20px rgba(0,0,0,0.15);
227
+ `,Fm=T.div`
228
+ height: 48px;
229
+ padding: 0 16px;
230
+ display: flex;
231
+ align-items: center;
232
+ justify-content: space-between;
233
+ background-color: rgba(0, 0, 0, 0.05);
234
+ flex-shrink: 0;
235
+ border-bottom: 1px solid rgba(0, 0, 0, 0.1);
236
+ `,Lm=T.div`
237
+ flex: 1;
238
+ overflow-x: auto;
239
+ overflow-y: hidden;
240
+ padding: 16px;
241
+ background-color: rgba(0,0,0,0.02);
242
+ `,Vm=T.div`
243
+ display: flex;
244
+ gap: 16px;
245
+ height: 100%;
246
+ align-items: center;
247
+ `,Mm=T.div`
248
+ position: relative;
249
+ height: 100%;
250
+ aspect-ratio: 9/16;
251
+ border-radius: 8px;
252
+ overflow: hidden;
253
+ box-shadow: 0 4px 6px rgba(0,0,0,0.1);
254
+ background: #000;
255
+ flex-shrink: 0;
256
+ `,Wm=T.img`
257
+ width: 100%;
258
+ height: 100%;
259
+ object-fit: contain;
260
+ `,Gm=T.div`
261
+ position: absolute;
262
+ top: 0;
263
+ left: 0;
264
+ right: 0;
265
+ padding: 4px 8px;
266
+ display: flex;
267
+ justify-content: space-between;
268
+ align-items: start;
269
+ background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0) 100%);
270
+ `,zm=T.span`
271
+ color: white;
272
+ font-weight: bold;
273
+ font-size: 14px;
274
+ text-shadow: 0 1px 2px rgba(0,0,0,0.8);
275
+ `,Hm=T.div`
276
+ display: flex;
277
+ align-items: center;
278
+ justify-content: center;
279
+ background: rgba(255,255,255,0.9);
280
+ border-radius: 50%;
281
+ padding: 2px;
282
+ `,Um=T.div`
283
+ position: absolute;
284
+ top: 0;
285
+ left: 0;
286
+ right: 0;
287
+ bottom: 0;
288
+ background: rgba(0, 0, 0, 0.85);
289
+ color: white;
290
+ padding: 12px;
291
+ display: flex;
292
+ flex-direction: column;
293
+ opacity: 0;
294
+ transition: opacity 0.2s ease;
295
+ overflow-y: auto;
296
+ font-size: 11px;
297
+ font-family: monospace;
298
+ white-space: pre-wrap;
299
+ z-index: 10;
300
+
301
+ &:hover {
302
+ opacity: 1;
303
+ }
304
+ `,_o=T.div`
305
+ font-weight: bold;
306
+ margin-bottom: 4px;
307
+ color: #888;
308
+ font-size: 10px;
309
+ text-transform: uppercase;
310
+ margin-top: 8px;
311
+ &:first-of-type {
312
+ margin-top: 0;
313
+ }
314
+ `,Fo=T.div`
315
+ margin-bottom: 4px;
316
+ line-height: 1.4;
317
+ word-break: break-all;
318
+ `,mn=new Ca({open:!1,maintainDisplayed:!1});function jm(){mn.setState(e=>({...e,open:!1}))}function Kr(e,t){mn.setState({type:"success",title:t?.title??"Success",description:e,listContent:t?.listContent,open:!0,maintainDisplayed:t?.maintainDisplayed??!1})}function dr(e,t){mn.setState({type:"error",title:t?.title??"Error",description:e,listContent:t?.listContent,open:!0,maintainDisplayed:t?.maintainDisplayed??!1})}function qm(e,t){mn.setState({type:"info",title:t?.title,description:e,listContent:t?.listContent,open:!0,maintainDisplayed:t?.maintainDisplayed??!1})}const Km=/\{\{\s*([a-zA-Z0-9_.-]+)\s*\}\}/g;function Ym(e,t){const n=new Set;return{value:e.replace(Km,(r,o)=>Object.prototype.hasOwnProperty.call(t,o)?t[o]??"":(n.add(o),"")),missing:Array.from(n)}}function Bt(e,t){const n={...e},r={},o=i=>{const a=n[i];if(typeof a=="string"&&a.includes("{{")){const{value:l,missing:d}=Ym(a,t);n[i]=l,d.length&&(r[i]=d)}};return o("descriptionText"),o("text"),o("elementId"),o("url"),o("instruction"),o("path"),{step:n,missingMap:r}}const Xm=({step:e,index:t,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i})=>{const a={stepNumber:t+1,onPlay:n,onPlayFromHere:r,onEdit:o,onDelete:i};switch(e.type){case"tap":return s(Vp,{step:e,...a});case"assert":return s(Mp,{step:e,...a});case"type":return s(Wp,{step:e,...a});case"scroll":return s(Gp,{step:e,...a});case"swipe":return s(zp,{step:e,...a});case"zoom":return s(Hp,{step:e,...a});case"scrollUntil":return s(Up,{step:e,...a});case"deeplink":return s(jp,{step:e,...a});case"ai":return s(qp,{step:e,...a});case"fileRef":return s(Lp,{step:e,...a});default:return null}},Jm=({onSave:e,canSave:t})=>{const[n,r]=ye(!1),[o,i]=ye(void 0),a=be(C,v=>v.isRecording),l=be(C,v=>v.test.steps),d=be(C,v=>v.isPlaying),c=be(C,v=>v.selectedPlatform),f=be(C,v=>v.selectedDeviceId),p=be(C,v=>v.filePath),{data:u=[]}=Ze(ua),m=H(null),g=()=>{C.setState(v=>({...v,isRecording:!v.isRecording,...v.isRecording?{mode:"interact"}:{}}))},y=ee(ia),b=ee(aa),D=ee(nf),E=ee(cf),S=ee(af),N=ee(sa);ee(Pf);const B=ee(xf),$=ee(Vf),ae=ee(ga),le=ee(Gf),Ae=ee(jr),pe=Pn(),w=(v,A,W)=>{C.setState(Q=>({...Q,test:{...Q.test,steps:Q.test.steps.map(ce=>ce.id===v?{...ce,status:A,statusColor:W}:ce)}}))},Z=v=>{C.setState(A=>({...A,currentStepId:v}))},{data:P}=Ze(ba),_=v=>new Promise(A=>setTimeout(A,v)),O=async()=>{try{const v=await B.mutateAsync({platform:c,deviceId:f});if(!v.success||!v.base64)throw new Error(v.error||"Failed to capture screenshot");const A=(v.base64.length*.75/(1024*1024)).toFixed(2);return console.log(`[Editor] Captured screenshot: ~${A} MB (${v.base64.length} chars)`),v.base64}catch(v){throw console.error("Screenshot failed:",v),v}},M=v=>new Promise(A=>{const W=new Image;W.onload=()=>A({width:W.naturalWidth,height:W.naturalHeight}),W.src=v}),xe=async(v,A,W,Q,ce=[],De,ge)=>{w(v,"Starting Smart Loop...","purple");try{let z=0;const se=15;let F=[...ce],K,me=!1;const de=[];for(;z<se;){if(m.current?.signal.aborted)throw new Error("Aborted");let fe="",Ee=[],Et=!1;const Mn=2e3,Le=500,Je=Math.floor(Mn/Le);for(let U=0;U<Je;U++){if(m.current?.signal.aborted)throw new Error("Aborted");fe=await O();try{const{width:j,height:ue}=await M(fe);console.log(`Checking cache (Attempt ${U+1}/${Je}) with:`,{stepNumber:A,description:W,platform:c,resolution:{width:j,height:ue},highest_used_index:K});const Se=await $.mutateAsync({stepNumber:A,stepDescription:W,filepath:ge,screenshot:fe,platform:c,screenResolution:{width:j,height:ue},highest_used_index:K});if(console.log("Cache result:",Se),Se.found&&Se.cacheCommands){Ee=Se.cacheCommands,K=Se.cacheIndex,Et=!0,w(v,`Cache Hit! (${Ee.length} cmds)`,"green");break}}catch(j){console.warn("Cache check failed:",j)}U<Je-1&&(w(v,`Cache miss, retrying... (${U+1}/${Je})`,"orange"),await _(Le))}C.setState(U=>({...U,executionLog:[...U.executionLog,{stepId:v,stepNumber:A,screenshot:fe,cacheHit:Et,timestamp:Date.now(),stepDescription:W,executedCommands:Ee}]}));let mt=[],Qe=[],dt=[];if(!Et){me=!0,w(v,"Cache Miss. Asking AI...","orange");let U;if(De)try{const X=await pe.fetchQuery(da({enabled:!0}));U=fm(X.elements)}catch(X){console.warn("Failed to fetch visible elements for uiHierarchy:",X)}const j=await le.mutateAsync({base64_screenshot:fe.replace(/^data:image\/\w+;base64,/,""),instruction:Q,action_history:F,elementId:De,uiHierarchy:U});Qe=j.appetizeCommands||[],dt=[];const ue=j.gptCommands?.findIndex(X=>X.startsWith("actions_description:"));ue!==void 0&&ue!==-1&&(dt=j.gptCommands?.slice(ue,ue+1)||[]);const Se=j.gptCommands?.findIndex(X=>X.startsWith("reasoning:"));if(Se!==void 0&&Se!==-1){mt=j.gptCommands?.slice(Se)||[];const X=mt.filter(Ve=>Ve.startsWith("remember:"));X?.length>0&&ce.push(...X),F=[...F,...mt]}const Tt=j.gptCommands||[];Ee=[...dt,...Qe],C.setState(X=>{let Ve=-1;for(let ut=X.executionLog.length-1;ut>=0;ut--)if(X.executionLog[ut].stepId===v){Ve=ut;break}if(Ve===-1)return X;const gt=[...X.executionLog];return gt[Ve]={...gt[Ve],executedCommands:Ee},{...X,executionLog:gt}})}de.push({screenshot:fe,commands:Ee});let ht=!1,hn=!1;Ee.length>0&&(console.log(`[Step ${v}] Executing commands:`,Ee),Et&&w(v,`Executing ${Ee.length} cached commands...`,"blue"));for(const U of Ee){if(m.current?.signal.aborted)throw new Error("Aborted");if(U.toLowerCase().includes("task complete:")){hn=!0;continue}if(U.toLowerCase().includes("error detected:"))throw new Error(`AI Reported Error: ${U}`);if(U.startsWith("remember:")&&ce.push(U),U.match(/^t(ap|ab)On:/)){console.log(`Tap Match: ${U}`);let j,ue;const Se=U.match(/x=(\d+)/),Tt=U.match(/y=(\d+)/);if(Se&&Tt)j=parseInt(Se[1],10),ue=parseInt(Tt[1],10);else{const X=U.split(";");X.length>=3&&(j=parseInt(X[1],10),ue=parseInt(X[2],10))}if(console.log(`Tap: ${j},${ue}`),j!==void 0&&ue!==void 0){const X=await M(fe);w(v,`Exec: Tap ${j},${ue}`,"blue"),await y.mutateAsync({x:j,y:ue,platform:c,deviceId:f,screenshotHeight:X.height,screenshotWidth:X.width}),ht=!0}}else if(U.startsWith("wait:")){const j=U.match(/wait:\s*(\d+)/)?.[1];if(j){const ue=parseInt(j,10);w(v,`Exec: Wait ${ue}s`,"blue"),await _(ue*1e3),ht=!0}}else if(U.startsWith("scroll:")){const j=U.match(/scroll:\s*(up|down)/i)?.[1],ue=await M(fe);j&&(w(v,`Scroll ${j}`,"blue"),await N.mutateAsync({direction:j.toLowerCase(),platform:c,deviceId:f,screenshotHeight:ue.height,screenshotWidth:ue.width,duration:500}),ht=!0)}else if(U.startsWith("slide")){const j=U.match(/slide\s+(up|down|left|right)\s+(\d+)%(?::\s*[^;]*)?;(\d+);(\d+)/i);if(j){const ue=j[1].toLowerCase(),Se={down:"up",up:"down",left:"right",right:"left"}[ue],Tt=parseInt(j[2]),X=parseInt(j[3]),Ve=parseInt(j[4]),gt=await M(fe),ut=Math.round((Se==="up"||Se==="down"?gt.height:gt.width)*(Tt/100));let gn=X,bn=Ve;switch(Se){case"up":bn=Ve+ut;break;case"down":bn=Ve-ut;break;case"left":gn=X-ut;break;case"right":gn=X+ut;break}w(v,`Slide ${ue} ${Tt}% from (${X}, ${Ve}) to (${gn}, ${bn})`,"blue"),await N.mutateAsync({direction:Se,platform:c,deviceId:f,x1:X,y1:Ve,x2:gn,y2:bn,screenshotHeight:gt.height,screenshotWidth:gt.width,duration:500}),ht=!0}}}if(ht&&(Et&&F.push(...Ee),await _(100)),hn)return w(v,"Executed","green"),me?ae.mutate({stepNumber:A,stepDescription:W,filepath:ge,executionData:de,platform:c,screenResolution:await M(de[0].screenshot)}):(console.log("Skipping cache population (all actions cached)"),w(v,"Executed (from cache)","green")),!0;z++}throw new Error("Smart Loop Timeout")}catch(z){throw z}},Ue=async(v,A,W,Q=[])=>{if(W.aborted)return!1;Z(v.id),w(v.id,"Executing...","blue");const ce={platform:c,deviceId:f},De=Date.now();try{let ge;const z=()=>C.state.currentScreenshot||void 0;switch(v.type){case"tap":{let F=v.descriptionText;F||(v.elementId&&v.elementId.trim()?F=`tap the element with id "${v.elementId}"`:F="tap on the screen"),await xe(v.id,A,v.descriptionText||"tap",F,Q,v.elementId,v?.originRef?.path??p??void 0);break}case"scroll":case"swipe":{const F=v.descriptionText;if(F)await xe(v.id,A,F,F,Q,void 0,v?.originRef?.path??p??void 0);else{const K=await M(z());await N.mutateAsync({direction:v.direction,platform:c,deviceId:f,x1:v.x1,y1:v.y1,x2:v.x2,y2:v.y2,screenshotHeight:K.height,screenshotWidth:K.width,duration:500})}w(v.id,"Swipe Performed","green");break}case"assert":{let F=`Verify that: ${v.descriptionText}`;!v.descriptionText&&v.elementId&&(F=`Verify element with id ${v.elementId} exists`),await xe(v.id,A,v.descriptionText||"assert",F,Q,v.elementId,v?.originRef?.path??p??void 0),w(v.id,"Assertion Passed","green");break}case"ai":{const F={...P,...C.state.test.params},{step:K,missingMap:me}=Bt(v,F);if(me.instruction?.length)throw new Error(`Missing params for placeholders -> instruction: ${me.instruction.join(", ")}`);await xe(v.id,A,K.instruction,K.instruction,Q,void 0,v?.originRef?.path??p??void 0);break}case"type":{ge=z();const F={...P,...C.state.test.params},{step:K,missingMap:me}=Bt(v,F);if(Object.keys(me).length){const de=Object.entries(me).map(([fe,Ee])=>`${fe}: ${Ee.join(", ")}`).join("; ");throw new Error(`Missing params for placeholders -> ${de}`)}await b.mutateAsync({text:K.text,...ce}),w(v.id,"Typed","green");break}case"zoom":{ge=z(),await S.mutateAsync({direction:v.direction,...ce}),w(v.id,"Zoomed","green");break}case"scrollUntil":{ge=z();const F={...P,...C.state.test.params},{step:K,missingMap:me}=Bt(v,F);if(me.text?.length)throw new Error(`Missing params for placeholders -> text: ${me.text.join(", ")}`);w(v.id,"Scrolling until found...","blue");const de=await D.mutateAsync({text:K.text,elementId:K.elementId,direction:K.direction,maxScrolls:K.maxScrolls,...ce});if(de.success)w(v.id,`Found after ${de.scrolls??0} scrolls`,"green");else throw new Error("Target not found after scrolling");break}case"deeplink":{ge=z();const F={...P,...C.state.test.params},{step:K,missingMap:me}=Bt(v,F);if(me.url?.length)throw new Error(`Missing params for placeholders -> url: ${me.url.join(", ")}`);await E.mutateAsync({url:K.url,...ce}),w(v.id,"Opened deeplink","green");break}case"fileRef":{w(v.id,"Loading steps from file...","blue");const F={...P,...C.state.test.params},{step:K,missingMap:me}=Bt(v,F);if(me.path?.length)throw new Error(`Missing params for placeholders -> path: ${me.path.join(", ")}`);const de=(await Ae.mutateAsync({path:K.path}))?.content;let fe=[],Ee={};if(Array.isArray(de))fe=de;else if(de&&Array.isArray(de.steps))fe=de.steps,Ee=de.params||{};else throw new Error("Referenced file must be an array or an object with steps");const Et={...P,...C.state.test.params,...Ee,...v.overrides},Mn=Xo.array().parse(fe).map((Le,Je)=>{const mt=typeof Le.id=="number"?Le.id:Date.now()+Je,{step:Qe,missingMap:dt}=Bt(Le,Et);if(Qe.type==="type"&&dt.text?.length||Qe.type==="scrollUntil"&&dt.text?.length||Qe.type==="deeplink"&&dt.url?.length||Qe.type==="ai"&&dt.instruction?.length){const ht=[];for(const[hn,U]of Object.entries(dt))U.length&&ht.push(`${hn}: ${U.join(", ")}`);throw new Error(`Referenced step has missing params -> ${ht.join("; ")}`)}return{id:mt,...Qe,originRef:{refId:v.id,path:v.path,descriptionText:v.descriptionText,optional:v.optional,overrides:v.overrides,stepNumber:Je+1}}});C.setState(Le=>{const Je=Le.test.steps.findIndex(Qe=>Qe.id===v.id);if(Je===-1)return Le;const mt=[...Le.test.steps];return mt.splice(Je,1,...Mn),{...Le,test:{...Le.test,steps:mt}}}),w(v.id,"Expanded steps from file","green");break}}await _(100);const se=Date.now()-De;return console.log(`[Step ${v.id}] Execution Finished. Total Duration: ${se}ms`),ge&&C.setState(F=>({...F,executionLog:[...F.executionLog,{stepId:v.id,stepNumber:A,screenshot:ge,cacheHit:!1,timestamp:Date.now()}]})),!0}catch(ge){const z=ge instanceof Error?ge.message:"Unknown error";return v.optional?(w(v.id,`Failed (optional): ${z}`,"orange"),!0):(w(v.id,`Error: ${z}`,"red"),!1)}},Rt=()=>{C.setState(v=>{const A=v.test.steps,W=[],Q=new Set,ce=new Set;let De=0;for(;De<A.length;){const z=A[De];if(z?.type==="fileRef"){const se=z.path;if(ce.has(se)){De++;continue}Q.add(z.id),ce.add(se),W.push(z),De++;continue}if(z&&z.originRef){const se=z.originRef.refId,F=z.originRef.path,K=z.originRef.descriptionText,me=z.originRef.optional;let de=De;for(;de<A.length&&A[de]?.originRef?.refId===se;)de++;if(Q.has(se)||ce.has(F)){De=de;continue}const fe={id:se,type:"fileRef",path:F,descriptionText:K,optional:me,overrides:z?.originRef?.overrides};W.some(Ee=>Ee.id===fe.id)&&(fe.id=Date.now()),W.push(fe),Q.add(fe.id),ce.add(F),De=de;continue}W.push(z),De++}const ge=[];for(const z of W){const se=ge[ge.length-1];se?.type==="fileRef"&&z?.type==="fileRef"&&se.path===z.path||ge.push(z)}return{...v,test:{...v.test,steps:ge}}})},je=async(v,A)=>{if(console.log("Running playback from index:",v),C.state.test.steps.length===0){alert("No steps to play!");return}m.current=new AbortController;const W=m.current.signal;C.setState(se=>({...se,isPlaying:!0})),C.setState(se=>({...se,test:{...se.test,steps:se.test.steps.map((F,K)=>K>=v?{...F,status:"",statusColor:""}:F)},executionLog:[]}));let Q=v;const ce=v+1,De=[];let ge=!1,z;for(;!W.aborted;){const se=C.state.test.steps,F=A?ce:se.length;if(Q>=F)break;const K=se[Q],me=K.type,de=K?.originRef?.stepNumber??Q+1;if(!await Ue(K,de,W,De)&&!K.optional){ge=!0,z=C.state.test.steps.find(fe=>fe.id===K.id)?.status||"Execution failed";break}if(me==="fileRef"){if(A)break;continue}Q++}await _(500),Rt(),Z(null),C.setState(se=>({...se,isPlaying:!1})),m.current=null,W.aborted||(ge?dr(z||"Playback failed",{title:"Execution Failed"}):Kr("Playback finished successfully",{title:"Execution Completed"}))},Dt=()=>je(0,!1),Ye=v=>{const A=l.findIndex(W=>W.id===v);A!==-1&&je(A,!0)},he=v=>{const A=l.findIndex(W=>W.id===v);A!==-1&&je(A,!1)},Pe=()=>{m.current?.abort(),Rt(),C.setState(v=>({...v,isPlaying:!1})),Z(null),qm("Playback stopped",{title:"Stopped"})},Ne=v=>{i(v),r(!1)},Xe=()=>{r(!1),i(void 0)},Yr=()=>{r(!1),i(void 0)},Da=v=>{confirm("Delete this step?")&&C.setState(A=>({...A,test:{...A.test,steps:A.test.steps.filter(W=>W.id!==v)}}))},Ea=()=>{confirm("Are you sure you want to clear all steps?")&&C.setState(v=>({...v,test:{...v.test,steps:[]}}))},Xr=d||a,Jr=n||!!o;return x(Qm,{$hasForm:Jr,children:[x(nh,{children:[s(J,{variant:"standard",value:be(C,v=>v.test.name),onChange:v=>{C.setState(A=>({...A,test:{...A.test,name:v.target.value}}))},placeholder:"Untitled",InputProps:{disableUnderline:!0,style:{fontSize:"1.5rem",fontWeight:500}},fullWidth:!0,sx:{mr:2}}),e&&s($e,{variant:"contained",color:"primary",onClick:e,disabled:!t||d,sx:{flexShrink:0},children:"Save"})]}),s(rn,{}),x(Zm,{children:[s($e,{variant:a?"contained":"outlined",color:a?"error":"primary",startIcon:a?s(jo,{}):s($a,{}),onClick:g,children:a?"Stop Recording":"Record"}),d?s($e,{variant:"contained",color:"error",onClick:Pe,children:"Stop"}):s($e,{variant:"contained",disabled:a||l.length===0,onClick:Dt,startIcon:s(ka,{}),children:"Run from start"}),s($e,{variant:"outlined",disabled:Xr||l.length===0,onClick:Ea,children:"Clear All"})]}),s(pr,{open:n||!!o,onClose:Yr,maxWidth:"md",fullWidth:!0,children:s(fr,{children:s(q,{pt:1,children:s(ym,{step:o,onSave:Xe,onCancel:Yr})})})}),x(eh,{children:[l.length===0?s(th,{children:s(V,{color:"text.secondary",children:"No steps recorded yet. Enable recording and click on the device screen to add steps."})}):s(Xi,{onDragEnd:v=>{const{source:A,destination:W}=v;if(!W||A.index===W.index)return;const Q=[...C.state.test.steps],[ce]=Q.splice(A.index,1);Q.splice(W.index,0,ce),C.setState(De=>({...De,test:{...De.test,steps:Q}}))},children:s(On,{droppableId:"steps-droppable",children:v=>x("div",{ref:v.innerRef,...v.droppableProps,children:[l.map((A,W)=>s(Gr,{draggableId:String(A.id),index:W,children:(Q,ce)=>s("div",{ref:Q.innerRef,...Q.draggableProps,...Q.dragHandleProps,style:{...Q.draggableProps.style,opacity:ce.isDragging?.9:1},children:s(Xm,{step:A,index:W,onPlay:()=>Ye(A.id),onPlayFromHere:()=>he(A.id),onEdit:()=>Ne(A),onDelete:()=>Da(A.id)})})},A.id)),v.placeholder]})})}),!Jr&&s(q,{mt:2,display:"flex",justifyContent:"center",children:s($e,{variant:"contained",disabled:Xr,onClick:()=>r(!0),fullWidth:!0,children:"+ Add Step"})})]}),s($m,{})]})},Qm=T(Ln)`
319
+ display: grid;
320
+ grid-template-areas:
321
+ 'header'
322
+ 'divider'
323
+ 'actions'
324
+ 'steps';
325
+ grid-template-rows: auto auto auto minmax(0, 1fr);
326
+ row-gap: 0.75rem;
327
+ overflow: hidden;
328
+ `,Zm=T.div`
329
+ display: flex;
330
+ gap: 0.5rem;
331
+ flex-wrap: wrap;
332
+ `,eh=T.div`
333
+ overflow-y: auto;
334
+ padding-right: 0.5rem;
335
+ `,th=T.div`
336
+ display: flex;
337
+ align-items: center;
338
+ justify-content: center;
339
+ height: 100%;
340
+ padding: 2rem;
341
+ text-align: center;
342
+ `,nh=T.div`
343
+ grid-area: header;
344
+ display: flex;
345
+ justify-content: space-between;
346
+ align-items: center;
347
+ `,rh=(e,t,n,r,o,i)=>o>=e&&o<=e+n&&i>=t&&i<=t+r,oh=({dimensions:e,elements:t,mouse:n})=>{if(t.length===0)return null;const r=t.filter(o=>{const i=o.bounds;if(i==null)return!1;const a=o.text??o.attributes?.text,l=o.resourceId??o.attributes?.["resource-id"],d=o.accessibilityText??o.attributes?.accessibilityText??o.attributes?.["accessibility-text"]??o.attributes?.["content-desc"],c=o.accessibilityIdentifier??o.attributes?.accessibilityIdentifier,f=o.name??o.attributes?.name,p=o.label??o.attributes?.label,u=o.value??o.attributes?.value;if(!a&&!l&&!d&&!c&&!f&&!p&&!u)return!1;const{x:m,y:g,width:y,height:b}=i,{x:D,y:E,elementWidth:S,elementHeight:N}=n;return D===null||E===null||S===null||N===null?!1:rh(m/e.width,g/e.height,y/e.width,b/e.height,D/S,E/N)});return r.length===0?null:r.sort((o,i)=>{if(o.bounds==null&&i.bounds==null)return 0;if(o.bounds==null)return 1;if(i.bounds==null)return-1;const a=o.drawingOrderPath??o.indexPath??[],l=i.drawingOrderPath??i.indexPath??[];for(let d=0;d<Math.min(a.length,l.length);d++){const c=parseInt(a[d]),f=parseInt(l[d]);if(c!==f)return f-c}return a.length!==l.length?l.length-a.length:o.bounds.width*o.bounds.height-i.bounds.width*i.bounds.height})[0]},Lo=(e,t)=>`${Math.round(100*e/t)}%`,ih=e=>{if(typeof e.x!="number"||typeof e.y!="number"||typeof e.elementWidth!="number"||typeof e.elementHeight!="number")return null;const t=Lo(e.x,e.elementWidth),n=Lo(e.y,e.elementHeight);return`${t}, ${n}`},ah=({open:e,handleClose:t,options:n,onAfterCopy:r})=>{const o=ur(()=>n?typeof n[0]=="string"?n.map(c=>({label:c,value:c})):n:[],[n]),[i,a]=ye(""),l=En(()=>{a(""),t()},[t]),d=En(async()=>{const c=i||(o[0]?.value??"");if(c){try{await navigator.clipboard.writeText(c),Kr("Copied to clipboard")}catch{}r?.(),l()}},[i,o,r,l]);return x(pr,{open:e,onClose:l,maxWidth:"md",fullWidth:!0,children:[s(Go,{children:"Select an attribute"}),s(fr,{children:s(Ot,{children:s(Pa,{name:"attribute-options",children:o.map(c=>s(An,{value:c.value,control:s(Aa,{}),label:c.label,onChange:()=>a(c.value)},`${c.label}-${c.value}`))})})}),x(zo,{children:[s($e,{color:"error",onClick:l,children:"Cancel"}),s($e,{onClick:d,disabled:!i&&o.length===0,variant:"contained",children:"Copy"})]})]})},sh=ie("f8084cb106c8126bb2deaeef7c98992d9ff9475ad3dc85c6ced04f08c3962b6e"),lh=oe({method:"POST"}).inputValidator(Ws).handler(sh,async({data:e})=>({description:await Gs(e)})),ch=ve({mutationKey:["ai","describe"],mutationFn:e=>lh({data:e})});function dh(e){return e.normalize("NFKC").replace(`
348
+ `,"").replace(/['`´''‚‛′']/g,"'").replace(/[""„‟″]/g,'"').replace(/[–—]/g,"-").replace(/[\u00A0\u2000-\u200A\u202F\u205F]/g," ").replace(/[\u200B-\u200F\uFEFF]/g,"").replace(/[\uE000-\uF8FF]|[\u{F0000}-\u{FFFFD}]|[\u{100000}-\u{10FFFD}]/gu,"").trim()}function uh(e,t){switch(e.type){case"tap":return`tapOn: x=${e.x} y=${e.y}`;case"assert":return"assert";case"swipe":return`swipe: direction=${e.direction} from=(${e.startCoords.x},${e.startCoords.y}) to=(${e.endCoords.x},${e.endCoords.y})`;case"scroll":{let n;if(e.direction==="up"||e.direction==="down"){console.log("interaction",e);const r=Math.abs(e.endCoords.y-e.startCoords.y);n=Math.round(r/t*100)}return`slide ${{down:"up",up:"down"}[e.direction]||e.direction} ${n}%;${e.startCoords.x};${e.startCoords.y}`}}}function ph(e){const t=e.elementId?` on "${e.elementId}"`:"";switch(e.type){case"tap":return`Tap Interaction${t}`;case"assert":return`Assert Element${t}`;case"swipe":return`Swipe ${e.direction}${t}`;case"scroll":return`Scroll ${e.direction}${t}`}}async function Vo(e,t){const{stepId:n,interaction:r,beforeImage:o,platform:i,deviceId:a,screenWidth:l,screenHeight:d}=e,{queryClient:c,describeMutation:f,populateCacheMutation:p}=t;let u=o;if(r.type!=="assert"&&a){await new Promise(y=>setTimeout(y,2e3));try{const y=await c.fetchQuery({...ca({platform:i,deviceId:a}),staleTime:0});y?.base64&&(u=y.base64)}catch(y){console.error("Failed to fetch post-action screenshot",y)}}const m=y=>{C.setState(b=>({...b,test:{...b.test,steps:b.test.steps.map(D=>D.id===n?{...D,descriptionText:y}:D)}}))},g=y=>{try{const b=C.state.test.steps,D=b.findIndex(S=>S.id===n),E=D!==-1?D+1:b.length;p.mutate({stepNumber:E,stepDescription:y,...e.filePath&&{filepath:e.filePath},executionData:[{screenshot:o,commands:[uh(r,d),r.type==="assert"?`task complete: ${y}`:"task complete:"]}],platform:i,screenResolution:{width:l,height:d}})}catch(b){console.error("Error populating cache:",b)}};try{let y,b;if(r.type==="swipe"||r.type==="scroll"){y=r.direction;const E=Math.abs(r.endCoords.x-r.startCoords.x),S=Math.abs(r.endCoords.y-r.startCoords.y);y==="left"||y==="right"?b=`${Math.round(E/l*100)}%`:b=`${Math.round(S/d*100)}%`}const D=(await f.mutateAsync({fullImage:o??"",croppedImage:r.cropBase64,targetImage:u??"",type:r.type,elementId:r.elementId,direction:y,distance:b})).description;m(D),g(D)}catch(y){console.error("Failed to describe interaction",y);const b=ph(r);m(b),g(b)}}const fh=()=>{const e=be(C,w=>w.mode),t=be(C,w=>w.isRecording),n=be(C,w=>w.enableAnimations);Pn();const r=H(null),[o,i]=ye(!1),[a,l]=ye(!1),[d,c]=ye([]),{data:f=[]}=Ze(ua),p=be(C,w=>w.selectedDeviceId);be(C,w=>w.selectedPlatform),we(()=>{if(!p&&f.length>0){const w=f[0];C.setState(Z=>({...Z,selectedDeviceId:w.id,selectedPlatform:w.platform}))}},[f,p]);const u=f.find(w=>w.id===p),{data:m,isError:g,isLoading:y}=Ze({...ca({platform:u?.platform,deviceId:u?.id}),refetchInterval:250,enabled:!!u});we(()=>{const w=m?.base64;w&&C.setState(Z=>({...Z,currentScreenshot:w}))},[m]);const{data:b}=Ze({...yf({platform:u?.platform,deviceId:u?.id}),enabled:!!u,refetchInterval:1e3}),D=ee(hf),{data:E}=Ze({...da({enabled:o&&!!u}),refetchInterval:o?1e3:!1});we(()=>{u?.id&&b?.connected===!1&&!D.isPending&&D.mutate({platform:u.platform,deviceId:u.id})},[u,b?.connected]);const S=m?.success??!1,N=b?.connected??!1,B=S&&N,$=m?.base64,ae=ee(Tf);ee(pf);const le=async()=>{const w=!n;C.setState(Z=>({...Z,enableAnimations:w})),w||await ae.mutateAsync()},Ae=()=>{C.setState(w=>({...w,isRecording:!w.isRecording,...w.isRecording?{mode:"interact"}:{}}))},pe=y?"Connecting...":g?"Error":B?"Connected":S&&!N?"Starting Appium...":"Disconnected";return x(wh,{children:[x(Ch,{children:[s(V,{variant:"h5",children:"Device"}),x(Ih,{children:[s(pt,{title:t?"Stop Recording":"Start Recording",children:s(R,{onClick:Ae,color:t?"error":"default",size:"small",children:t?s(jo,{}):s(_a,{})})}),s(pt,{title:o?"Disable UI Inspector":"Enable UI Inspector",children:s(R,{onClick:()=>i(!o),color:o?"primary":"default",size:"small",children:s(Fa,{})})}),s(pt,{title:n?"Disable Animations":"Enable Animations",children:s(R,{onClick:le,color:n?"primary":"default",size:"small",children:s(La,{})})})]})]}),s(rn,{}),x(Nh,{children:[x(q,{display:"flex",alignItems:"center",gap:1,flexGrow:1,children:[x(Ot,{size:"small",sx:{minWidth:150,flex:1},children:[s(Lt,{children:"Device"}),s(Vt,{value:p||"",label:"Device",onChange:w=>{const Z=w.target.value,P=f.find(_=>_.id===Z);C.setState(_=>({..._,selectedDeviceId:Z,selectedPlatform:P?.platform||"android"}))},children:f.map(w=>x(et,{value:w.id,children:[w.name," (",w.platform,")"]},w.id))})]}),s(Sh,{connected:B,children:pe})]}),t&&x(Ia,{color:"primary",exclusive:!0,value:e,onChange:(w,Z)=>{Z&&C.setState(P=>({...P,mode:Z}))},size:"small",children:[s(Qr,{value:"interact",children:"Interact"}),s(Qr,{value:"assert",children:"Assert"})]})]}),s(Oh,{children:$?x(Rh,{children:[s(Ph,{ref:r,src:$,alt:"Device Screen",draggable:!1,recording:t}),s(xh,{imgRef:r,uiDisabled:o,platform:u?.platform||"android",deviceId:u?.id,src:$}),o&&E?.elements&&s(Eh,{imgRef:r,deviceWidth:E.width,deviceHeight:E.height,elements:E.elements,onPickAttributes:w=>{c(w),l(!0)}})]}):s(Ah,{children:f.length===0?s(V,{variant:"body2",color:"text.secondary",children:"No devices found."}):p?x(It,{children:[s(Wo,{}),s(V,{variant:"body2",color:"text.secondary",children:"Connecting to device..."})]}):s(V,{variant:"body2",color:"text.secondary",children:"Select a device."})})}),s(ah,{open:a,handleClose:()=>l(!1),options:d,onAfterCopy:()=>i(!1)})]})},mh=50,hh=10,gh=250,bh=800,yh=180,vh=40,xh=({imgRef:e,uiDisabled:t,platform:n,deviceId:r,src:o})=>{const i=H(null);ei(i,{enterDelay:0,leaveDelay:0});const a=be(C,P=>P.isRecording),l=be(C,P=>P.mode),d=be(C,P=>P.filePath);we(()=>{a&&i.current&&i.current.focus()},[a]);const c=ee(ia),f=ee(aa),p=ee(sa),u=ee(Nf),m=Pn(),g=ee(ch),y=ee(ga),b=H(null),D=H(""),E=H(0),S=()=>({platform:n??"android",deviceId:r}),N=(P,_)=>{const O=e.current;if(!O)return null;const M=O.getBoundingClientRect(),xe=O.naturalWidth/M.width,Ue=O.naturalHeight/M.height;return{x:Math.round((P-M.left)*xe),y:Math.round((_-M.top)*Ue),rect:M,img:O}},B=async(P,_,O,M,xe,Ue,Rt=500)=>{const je=Date.now(),Dt={id:je,type:P,direction:_,x1:O.x,y1:O.y,x2:M.x,y2:M.y,...P==="swipe"?{duration:Rt}:{},elementId:"",descriptionText:"Getting element ID..."};C.setState(he=>({...he,test:{...he.test,steps:[...he.test.steps,Dt]}}));let Ye="";try{Ye=(await u.mutateAsync({x:O.x,y:O.y,screenshotHeight:xe.naturalHeight,screenshotWidth:xe.naturalWidth}))?.elementId||""}catch{}C.setState(he=>({...he,test:{...he.test,steps:he.test.steps.map(Pe=>Pe.id===je?{...Pe,elementId:Ye,descriptionText:"Generating description..."}:Pe)}})),Vo({stepId:je,interaction:{type:P,direction:_,startCoords:O,endCoords:M,cropBase64:Ue,elementId:Ye},filePath:d,beforeImage:o,platform:n||"android",deviceId:r,screenWidth:xe.naturalWidth,screenHeight:xe.naturalHeight},{queryClient:m,describeMutation:g,populateCacheMutation:y})},$=async()=>{const P=D.current;P&&(D.current="",await f.mutateAsync({text:P,...S()}),a&&C.setState(_=>({..._,test:{..._.test,steps:[..._.test.steps,{id:Date.now(),type:"type",text:P}]}})))},ae=io($,{wait:bh}),le=io(async(P,_)=>{const O=E.current;if(E.current=0,Math.abs(O)<vh)return;const M=N(P,_);if(!M)return;const xe=O>0?"down":"up";let Ue;a&&(Ue=tr(M.img,M.x,M.y,M.x,M.y)),a&&B("scroll",xe,{x:M.x,y:M.y},{x:M.x,y:M.y},M.img,Ue),await p.mutateAsync({direction:xe,x1:M.x,y1:M.y,duration:500,...S()})},{wait:yh}),Ae=P=>{if(t)return;const _=N(P.clientX,P.clientY);_&&(b.current={x:_.x,y:_.y,t:Date.now()},i.current?.focus())},pe=async P=>{if(t)return;const _=b.current;b.current=null;const O=N(P.clientX,P.clientY);if(!_||!O)return;const M=O.x-_.x,xe=O.y-_.y,Ue=Math.hypot(M,xe),Rt=Date.now()-_.t,je=S();if(Ue<=hh&&Rt<=gh){const Dt=o;if(a){const Ye=Dh(O.img,O.x,O.y),he=Date.now();C.setState(Ne=>({...Ne,test:{...Ne.test,steps:[...Ne.test.steps,{id:he,type:l==="assert"?"assert":"tap",x:O.x,y:O.y,cropBase64:Ye,elementId:"",descriptionText:"Getting element ID..."}]}}));let Pe="";u.mutateAsync({x:O.x,y:O.y,screenshotHeight:O.img.naturalHeight,screenshotWidth:O.img.naturalWidth}).then(Ne=>{Pe=Ne?.elementId||""}).finally(()=>{C.setState(Ne=>({...Ne,test:{...Ne.test,steps:Ne.test.steps.map(Xe=>Xe.id===he?{...Xe,elementId:Pe,descriptionText:"Generating description..."}:Xe)}})),Vo({stepId:he,interaction:{type:l==="assert"?"assert":"tap",x:O.x,y:O.y,cropBase64:Ye,elementId:Pe},filePath:d,beforeImage:Dt,platform:n||"android",deviceId:r,screenWidth:O.img.naturalWidth,screenHeight:O.img.naturalHeight},{queryClient:m,describeMutation:g,populateCacheMutation:y})})}l!=="assert"&&await c.mutateAsync({x:O.x,y:O.y,screenshotHeight:O.img.naturalHeight,screenshotWidth:O.img.naturalWidth,...je});return}if(Ue>=mh){const Dt=Math.abs(M),Ye=Math.abs(xe),he={x:_.x,y:_.y},Pe={x:O.x,y:O.y};if(Ye>=Dt*1.5){const Ne=xe>0?"up":"down";let Xe;a&&(Xe=tr(O.img,he.x,he.y,Pe.x,Pe.y),B("scroll",Ne,he,Pe,O.img,Xe)),await p.mutateAsync({direction:Ne,x1:_.x,y1:_.y,x2:O.x,y2:O.y,screenshotHeight:O.img.naturalHeight,screenshotWidth:O.img.naturalWidth,duration:500,...je})}else{const Ne=M>=0?"right":"left";if(a){const Xe=tr(O.img,he.x,he.y,Pe.x,Pe.y);B("swipe",Ne,he,Pe,O.img,Xe,500)}await p.mutateAsync({direction:Ne,x1:_.x,y1:_.y,x2:O.x,y2:O.y,screenshotHeight:O.img.naturalHeight,screenshotWidth:O.img.naturalWidth,duration:500,...je})}}},w=P=>{t||(P.preventDefault(),E.current+=P.deltaY,le.maybeExecute(P.clientX,P.clientY))},Z=async P=>{if(!t){if(P.key.length===1||P.key===" "){D.current+=P.key,ae.maybeExecute(),P.preventDefault();return}if(P.key==="Backspace"){ae.cancel(),await $(),await f.mutateAsync({text:"",...S()}),P.preventDefault();return}P.key==="Enter"&&(D.current+=`
349
+ `,ae.maybeExecute(),P.preventDefault())}};return we(()=>()=>{ae.flush()},[]),s("div",{ref:i,tabIndex:0,onMouseDown:Ae,onMouseUp:pe,onWheel:w,onKeyDown:Z,style:{position:"absolute",inset:0,outline:"none"}})};function Dh(e,t,n,r=100){const o=document.createElement("canvas");o.width=r,o.height=r;const i=o.getContext("2d");if(i)return i.drawImage(e,t-r/2,n-r/2,r,r,0,0,r,r),o.toDataURL("image/jpeg",.8)}function tr(e,t,n,r,o,i=50){const a=Math.max(0,Math.min(t,r)-i),l=Math.max(0,Math.min(n,o)-i),d=Math.min(e.naturalWidth,Math.max(t,r)+i),c=Math.min(e.naturalHeight,Math.max(n,o)+i),f=d-a,p=c-l;if(f<=0||p<=0)return;const u=document.createElement("canvas");u.width=f,u.height=p;const m=u.getContext("2d");if(m)return m.drawImage(e,a,l,f,p,0,0,f,p),u.toDataURL("image/jpeg",.8)}const Eh=({imgRef:e,deviceWidth:t,deviceHeight:n,elements:r,onPickAttributes:o})=>{const[i,a]=ye(null),l=H(null),d=ei(l,{enterDelay:100,leaveDelay:100}),c=i!=null?r[i]:null,f=ur(()=>{const u=c,m=u?.text||u?.attributes?.text||"",g=u?.accessibilityText||u?.attributes?.["accessibility-text"]||u?.attributes?.["content-desc"]||"",y=u?.resourceId||u?.attributes?.["resource-id"]||"",b=u?.accessibilityIdentifier||u?.attributes?.accessibilityIdentifier||"",D=u?.name||u?.attributes?.name||"",E=u?.label||u?.attributes?.label||"",S=u?.value||u?.attributes?.value||"";return b||D||E||m||g||y||S||ih(d)||""},[c,d]);we(()=>{if(!d?.isOver){a(null);return}const u=oh({dimensions:{width:t,height:n},elements:r,mouse:d});if(!u){a(null);return}let m=r.indexOf(u);if(m<0&&u.bounds){const g=u.bounds;m=r.findIndex(y=>y.bounds&&y.bounds.x===g.x&&y.bounds.y===g.y&&y.bounds.width===g.width&&y.bounds.height===g.height)}a(m>=0?m:null)},[d,t,n,r]);const p=d?.isOver&&typeof d.x=="number"&&typeof d.y=="number"&&typeof d.elementWidth=="number"&&typeof d.elementHeight=="number";return s(pt,{title:f,followCursor:!0,children:x(Th,{ref:l,onClick:()=>{const u=i!=null?r[i]:null;if(!u)return;const m=[],g=(y,b)=>{const D=typeof b=="string"?dh(b):"";D&&!m.some(E=>E.value===D)&&m.push({label:`${y}: "${D}"`,value:D})};g("accessibility-id",u.accessibilityIdentifier??u.attributes?.accessibilityIdentifier),g("name",u.name??u.attributes?.name),g("label",u.label??u.attributes?.label),g("text",u.text??u.attributes?.text),g("accessibility-text",u.accessibilityText??u.attributes?.["accessibility-text"]??u.attributes?.["content-desc"]),g("resource-id",u.resourceId??u.attributes?.["resource-id"]),m.length>0&&o(m)},children:[p&&x(It,{children:[s($h,{style:{left:`${d.x/d.elementWidth*100}%`}}),s(kh,{style:{top:`${d.y/d.elementHeight*100}%`}})]}),r.map((u,m)=>{if(!u.bounds)return null;const{x:g,y,width:b,height:D}=u.bounds;return s(Bh,{style:{left:`${g/t*100}%`,top:`${y/n*100}%`,width:`${b/t*100}%`,height:`${D/n*100}%`},"data-hovered":i===m||void 0},m)})]})})},wh=T(Ln)`
350
+ display: grid;
351
+ grid-template-areas: 'header' 'divider' 'actions' 'device';
352
+ grid-template-rows: auto auto auto minmax(0, 1fr);
353
+ row-gap: 0.75rem;
354
+ overflow: hidden;
355
+ min-width: 0;
356
+ `,Ch=T.div`
357
+ grid-area: header;
358
+ display: flex;
359
+ justify-content: space-between;
360
+ align-items: center;
361
+ `,Ih=T.div`
362
+ display: flex;
363
+ gap: 0.25rem;
364
+ `,Nh=T.div`
365
+ grid-area: actions;
366
+ display: flex;
367
+ gap: 0.5rem;
368
+ flex-wrap: wrap;
369
+ align-items: center;
370
+ justify-content: space-between;
371
+ `,Sh=T(V)`
372
+ font-size: 0.875rem;
373
+ color: ${({connected:e})=>e?"#4caf50":"#f44336"};
374
+ `,Oh=T.div`
375
+ grid-area: device;
376
+ display: flex;
377
+ justify-content: center;
378
+ align-items: flex-start;
379
+ overflow: scroll;
380
+ height: 100%;
381
+ min-height: 0;
382
+ min-width: 0;
383
+ `,Ph=T.img`
384
+ display: block;
385
+ max-width: 100%;
386
+ height: auto;
387
+ border: 2px solid #333;
388
+ border-radius: 8px;
389
+ cursor: crosshair;
390
+ box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
391
+ ${({recording:e})=>e&&"border-color: #2196f3; box-shadow: 0 0 20px rgba(33, 150, 243, 0.4);"}
392
+ `,Ah=T(q)`
393
+ display: flex;
394
+ flex-direction: column;
395
+ align-items: center;
396
+ gap: 1rem;
397
+ `,Rh=T.div`
398
+ position: relative;
399
+ display: inline-block;
400
+ max-width: 100%;
401
+ height: auto;
402
+ `,Th=T.div`
403
+ position: absolute;
404
+ inset: 0;
405
+ pointer-events: auto;
406
+ `,Bh=T.div`
407
+ position: absolute;
408
+ box-sizing: border-box;
409
+ pointer-events: none;
410
+ border: 2px dashed rgba(236, 72, 153, 0.7);
411
+ background: transparent;
412
+ &[data-hovered] {
413
+ border-color: rgba(59, 130, 246, 0.95);
414
+ border-style: solid;
415
+ outline: 2px solid rgba(59, 130, 246, 0.6);
416
+ }
417
+ `,$h=T.div`
418
+ position: absolute;
419
+ top: 0;
420
+ bottom: 0;
421
+ width: 1px;
422
+ background: rgba(59, 130, 246, 0.9);
423
+ transform: translateX(-0.5px);
424
+ pointer-events: none;
425
+ `,kh=T.div`
426
+ position: absolute;
427
+ left: 0;
428
+ right: 0;
429
+ height: 1px;
430
+ background: rgba(59, 130, 246, 0.9);
431
+ transform: translateY(-0.5px);
432
+ pointer-events: none;
433
+ `;function _h(e){const t={};return e.forEach(n=>{const r=n.path.split("/");let o=t,i="";r.forEach((a,l)=>{i=i?`${i}/${a}`:a,o[a]||(o[a]={name:a,fullPath:i,type:l===r.length-1?n.type:"directory",children:{}}),l===r.length-1&&(o[a].type=n.type,o[a].fullPath=i),o=o[a].children})}),t}const xa=({item:e,level:t,onSelect:n,selectedFile:r,onRename:o})=>{const i=r&&r.startsWith(e.fullPath+"/"),a=r===e.fullPath,[l,d]=ye(!1),[c,f]=ye(!1),[p,u]=ye(e.name);we(()=>{i&&d(!0)},[i]);const m=()=>{p&&p!==e.name&&o(e.fullPath,p),f(!1)},g=Object.keys(e.children).length>0,y=Object.values(e.children).sort((b,D)=>b.type===D.type?b.name.localeCompare(D.name):b.type==="directory"?-1:1);return c?s(Wn,{sx:{pl:t*2},children:s(J,{value:p,onChange:b=>u(b.target.value),size:"small",autoFocus:!0,onBlur:m,onKeyDown:b=>{b.key==="Enter"&&m(),b.key==="Escape"&&f(!1)},InputProps:{endAdornment:s(Ra,{position:"end",children:s(R,{size:"small",onMouseDown:m,children:s(nl,{fontSize:"small"})})})}})}):x(It,{children:[e.type==="directory"?s(On,{droppableId:`FOLDER_ROW::${e.fullPath}`,children:(b,D)=>x("div",{ref:b.innerRef,...b.droppableProps,children:[x(Wn,{button:!0,onClick:E=>{d(!l)},onDoubleClick:()=>{u(e.name),f(!0)},selected:a,sx:{pl:t*2,bgcolor:D.isDraggingOver?"action.hover":void 0,borderLeft:i?"3px solid":void 0,borderLeftColor:i?"primary.main":void 0,opacity:i?1:void 0},children:[s(Zr,{sx:{minWidth:32},children:s(Qs,{fontSize:"small",color:i?"primary":"action"})}),s(eo,{primary:e.name,primaryTypographyProps:{variant:"body2",noWrap:!0,fontWeight:i?600:400}}),g&&(l?s(el,{fontSize:"small"}):s(tl,{fontSize:"small"}))]}),b.placeholder]})}):x(Wn,{button:!0,onClick:()=>n(e.fullPath),onDoubleClick:()=>{u(e.name),f(!0)},selected:a,sx:{pl:t*2,bgcolor:a?"action.selected":void 0,"&.Mui-selected":{bgcolor:"action.selected","&:hover":{bgcolor:"action.selected"}}},children:[s(Zr,{sx:{minWidth:32},children:s(Zs,{fontSize:"small",color:a?"primary":"action"})}),s(eo,{primary:e.name,primaryTypographyProps:{variant:"body2",noWrap:!0,fontWeight:a?600:400}})]}),e.type==="directory"&&s(Ta,{in:l,timeout:"auto",unmountOnExit:!0,children:s(On,{droppableId:e.fullPath,children:b=>x(Ho,{component:"div",disablePadding:!0,ref:b.innerRef,...b.droppableProps,children:[y.map((D,E)=>s(Gr,{draggableId:D.fullPath,index:E,children:(S,N)=>s("div",{ref:S.innerRef,...S.draggableProps,...S.dragHandleProps,style:{...S.draggableProps.style,opacity:N.isDragging?.9:1},children:s(xa,{item:D,level:t+1,onSelect:n,selectedFile:r,onRename:o})})},D.fullPath)),b.placeholder]})})})]})};function Fh({files:e,onSelect:t,selectedFile:n,refetch:r}){const o=_h(e),i=Object.values(o).sort((d,c)=>d.type===c.type?d.name.localeCompare(c.name):d.type==="directory"?-1:1),a=ee(lm),l=async(d,c)=>{try{const f=d.split("/");f.pop();const p=f.join("/"),u=p?`${p}/${c}`:c;await a.mutateAsync({oldPath:d,newPath:u}),r()}catch(f){alert("Rename failed: "+f.message)}};return s(Xi,{onDragEnd:async d=>{const{destination:c,draggableId:f}=d;if(!c)return;const p=c.droppableId;let u="";p==="ROOT"?u="":p.startsWith("FOLDER_ROW::")?u=p.slice(12):u=p;const m=f;if(!m||u&&(m===u||u.startsWith(m+"/")))return;const g=m.lastIndexOf("/"),y=g>=0?m.slice(0,g):"";if((u||"")===y)return;const b=g>=0?m.slice(g+1):m,D=u?`${u}/${b}`:b;try{await a.mutateAsync({oldPath:m,newPath:D}),r()}catch(E){alert("Move failed: "+E.message)}},children:s(On,{droppableId:"ROOT",children:d=>x(Ho,{dense:!0,ref:d.innerRef,...d.droppableProps,children:[i.map((c,f)=>s(Gr,{draggableId:c.fullPath||c.name,index:f,children:(p,u)=>s("div",{ref:p.innerRef,...p.draggableProps,...p.dragHandleProps,style:{...p.draggableProps.style,opacity:u.isDragging?.9:1},children:s(xa,{item:c,level:1,onSelect:t,selectedFile:n,onRename:l})})},c.fullPath||c.name)),d.placeholder]})})})}function Lh({onSelectFile:e,selectedFile:t}){const{data:n,isLoading:r,error:o,refetch:i}=Ze({...Ur,refetchInterval:2e3}),[a,l]=ye(!1),[d,c]=ye("file"),[f,p]=ye(""),u=ee(Jf),m=async()=>{if(!f)return;let b=f;d==="file"&&!b.endsWith(".json")&&(b+=".json");try{await u.mutateAsync({name:b,type:d}),l(!1),p(""),d==="file"&&e(b),i()}catch(D){alert("Failed to create: "+D.message)}},g=b=>{c(b),p(""),l(!0)};if(r)return s(nr,{children:s(Wo,{})});if(o)return s(nr,{children:s(V,{color:"error",children:"Error loading files"})});const y=n?.files||[];return x(nr,{children:[x(Vh,{children:[s(V,{variant:"h6",children:"Tests"}),x(q,{children:[s(R,{onClick:()=>i(),size:"small",title:"Refresh",children:s(Xs,{})}),s(R,{onClick:()=>g("directory"),size:"small",title:"New Folder",children:s(Js,{})}),s(R,{onClick:()=>g("file"),size:"small",color:"primary",title:"New Test",children:s(ti,{})})]})]}),s(rn,{}),s(Mh,{children:y.length===0?s(V,{variant:"caption",sx:{p:2,display:"block",textAlign:"center",color:"text.secondary"},children:"No tests found"}):s(Fh,{files:y,onSelect:e,selectedFile:t,refetch:i})}),x(pr,{open:a,onClose:()=>l(!1),children:[x(Go,{children:["Create New ",d==="file"?"Test":"Folder"]}),s(fr,{children:s(J,{autoFocus:!0,margin:"dense",label:"Name",fullWidth:!0,value:f,onChange:b=>p(b.target.value),placeholder:d==="file"?"my-test":"my-folder"})}),x(zo,{children:[s($e,{onClick:()=>l(!1),children:"Cancel"}),s($e,{onClick:m,variant:"contained",children:"Create"})]})]})]})}const nr=T(Ln)`
434
+ display: flex;
435
+ flex-direction: column;
436
+ padding: 0;
437
+ overflow: hidden;
438
+ height: 100%;
439
+ `,Vh=T.div`
440
+ padding: 1rem;
441
+ display: flex;
442
+ align-items: center;
443
+ justify-content: space-between;
444
+ `,Mh=T.div`
445
+ flex: 1;
446
+ overflow-y: auto;
447
+ padding: 0.5rem 0;
448
+ `;function Wh({disabled:e}){const t=be(C,c=>c.test.params),[n,r]=ye(()=>Object.entries(t||{}).map(([c,f])=>({key:c,value:f})));we(()=>{r(Object.entries(t||{}).map(([c,f])=>({key:c,value:f})))},[t]),ur(()=>new Set(n.map(c=>c.key)),[n]);const o=c=>{const f={};for(const p of c)p.key&&(f[p.key]=p.value);C.setState(p=>({...p,test:{...p.test,params:f}}))},i=()=>{const c=[...n,{key:"",value:""}];r(c)},a=c=>{const f=n.filter((p,u)=>u!==c);r(f),o(f)},l=(c,f)=>{const p=n.map((u,m)=>m===c?{...u,key:f}:u);r(p),o(p)},d=(c,f)=>{const p=n.map((u,m)=>m===c?{...u,value:f}:u);r(p),o(p)};return x(Gh,{children:[x(zh,{children:[s(V,{variant:"subtitle1",children:"Test Params"}),s(pt,{title:e?"Select a test to edit params":"Add parameter",children:s("span",{children:s(R,{size:"small",disabled:e,onClick:i,color:"primary",children:s(ti,{})})})})]}),s(rn,{}),x(Hh,{children:[n.length===0&&s(jh,{children:s(V,{variant:"caption",color:"text.secondary",children:e?"No test selected":"No params. Click + to add"})}),n.map((c,f)=>{const p=c.key&&n.some((u,m)=>m!==f&&u.key===c.key);return x(Uh,{children:[s(J,{size:"small",label:"Key",value:c.key,onChange:u=>l(f,u.target.value),disabled:e,error:!!p,helperText:p?"Duplicate key":" "}),s(J,{size:"small",label:"Value",value:c.value,onChange:u=>d(f,u.target.value),disabled:e}),s(pt,{title:e?"":"Remove",children:s("span",{children:s(R,{size:"small",disabled:e,onClick:()=>a(f),children:s(Ke,{})})})})]},f)})]}),!e&&n.length>0&&s(q,{sx:{p:1,display:"flex",justifyContent:"flex-end"},children:s($e,{size:"small",onClick:()=>o(n),children:"Apply"})})]})}const Gh=T(Ln)`
449
+ display: flex;
450
+ flex-direction: column;
451
+ padding: 0;
452
+ height: 100%;
453
+ overflow: hidden;
454
+ `,zh=T.div`
455
+ padding: 0.75rem 1rem;
456
+ display: flex;
457
+ align-items: center;
458
+ justify-content: space-between;
459
+ `,Hh=T.div`
460
+ padding: 0.5rem 0.75rem;
461
+ display: flex;
462
+ flex-direction: column;
463
+ gap: 0.5rem;
464
+ overflow: auto;
465
+ `,Uh=T.div`
466
+ display: grid;
467
+ grid-template-columns: 1fr 1fr auto;
468
+ gap: 0.5rem;
469
+ align-items: start;
470
+ padding-top: 0.5rem;
471
+ `,jh=T.div`
472
+ padding: 0.75rem;
473
+ text-align: center;
474
+ `;function qh(){const e=be(mn,n=>n),t=En(()=>{jm()},[]);return s(Na,{open:e.open,onClose:t,className:"absolute z-10",style:{maxWidth:"384px"},anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:e.maintainDisplayed?null:3e3,children:x(Sa,{severity:e.type,onClose:t,children:[e.title!==void 0&&s(rl,{sx:{...e.description==null&&e.listContent==null&&{marginBottom:0}},children:e.title}),e.description!==void 0&&e.description,e.listContent!==void 0&&e.listContent.length>0&&s("ul",{className:"mt-2 ml-2 list-disc list-inside",children:e.listContent.map((n,r)=>s("li",{children:n},r))})]})})}function Ib(){const[e,t]=ye(),n=ee(jr),r=ee(om),o=Pn(),[i,a]=ye("");we(()=>{e?n.mutateAsync({path:e}).then(c=>{const f=c.content;let p=[],u={};Array.isArray(f)?(p=f,u={}):f&&Array.isArray(f.steps)&&(p=f.steps,u=f.params||{});const m=p.map((D,E)=>({...D,id:D.id||Date.now()+E})),g={name:c.path,steps:m,params:u};C.setState(D=>({...D,test:g,filePath:e}));const y=C.state.test,b={...y,steps:y.steps.map(D=>{const E={...D};for(const S of Object.keys(Gn))delete E[S];return E})};a(JSON.stringify(b))}).catch(c=>{c instanceof Error?c.message:String(c),dr("Failed to read file",{title:"Read Error"})}):a(JSON.stringify({name:"untitled",steps:[],params:{}}))},[e]);const l=be(C,c=>c.test),d=(()=>{const c={...l,steps:l.steps.map(f=>{const p={...f};for(const u of Object.keys(Gn))delete p[u];return p})};return JSON.stringify(c)!==i})();return x(It,{children:[x(Kh,{children:[s(Yh,{children:s(Lh,{onSelectFile:t,selectedFile:e})}),s(Xh,{children:s(Wh,{disabled:!e})}),s(Jh,{children:s(Jm,{onSave:async()=>{let c=e;const f=C.state.test,p=f.steps.map(m=>{const g={...m};for(const y of Object.keys(Gn))delete g[y];return g}),u={...f,steps:p};if(!c){const m=(f.name||"untitled").replace(/[^a-z0-9_\-\.]/gi,"_");c=m.endsWith(".json")?m:`${m}.json`}try{console.log("content",u),await r.mutateAsync({path:c,content:u}),a(JSON.stringify(u)),e||(t(c),o.invalidateQueries({queryKey:["files"]})),Kr("File saved",{title:"Saved"})}catch(m){dr(m?.message?String(m.message):"Failed to save",{title:"Save Error"})}},canSave:d})}),s(Qh,{children:s(fh,{})})]}),s(qh,{})]})}const Kh=T.div`
475
+ display: grid;
476
+ grid-template-areas:
477
+ 'files editor simulator'
478
+ 'params editor simulator';
479
+ grid-template-columns: 250px minmax(0, 1fr) 400px;
480
+ grid-template-rows: 1fr minmax(160px, 35%);
481
+ background-color: #f0f2f5;
482
+ height: 100vh;
483
+ padding: 1rem;
484
+ column-gap: 1rem;
485
+ row-gap: 1rem;
486
+ `,Yh=T.div`
487
+ grid-area: files;
488
+ min-height: 0; /* allow internal scroll */
489
+ `,Xh=T.div`
490
+ grid-area: params;
491
+ min-height: 0;
492
+ `,Jh=T.div`
493
+ grid-area: editor;
494
+ min-height: 0;
495
+ height: 100%;
496
+ overflow-y: auto;
497
+ `,Qh=T.div`
498
+ grid-area: simulator;
499
+ min-height: 0;
500
+ min-width: 0; /* allow child panel to shrink horizontally */
501
+ height: 100%;
502
+ `;export{Ib as component};