veza/apps/web/dist_verification/assets/vendor-motion-B3XPS3Jc.js
senke 04c25aa24f Phase 2 stabilisation: code mort, Modal→Dialog, feature flags, tests, router split, Rust legacy
Bloc A - Code mort:
- Suppression Studio (components, views, features)
- Suppression gamification + services mock (projectService, storageService, gamificationService)
- Mise à jour Sidebar, Navbar, locales

Bloc B - Frontend:
- Suppression modal.tsx deprecated, Modal.stories (doublon Dialog)
- Feature flags: PLAYLIST_SEARCH, PLAYLIST_RECOMMENDATIONS, ROLE_MANAGEMENT = true
- Suppression 19 tests orphelins, retrait exclusions vitest.config

Bloc C - Backend:
- Extraction routes_auth.go depuis router.go

Bloc D - Rust:
- Suppression security_legacy.rs (code mort, patterns déjà dans security/)
2026-02-14 17:23:32 +01:00

9 lines
30 KiB
JavaScript

import{a as u,j as V}from"./vendor-react-yWUy5XPk.js";import{i as st,g as Kt,s as Et,a as St,b as ot,c as Mt,d as Xt,e as Yt,f as qt,h as Jt,r as Qt,j as Zt,k as Vt,l as te,m as ee,n as ne,o as se,S as oe,H as ie,F as b,p as re,q as bt,t as k,u as it,v as M,w as At,x as ae,y as ue,z as le,A as F,B as X,C as rt,D as ce,E as fe,G as S,I as he,J as de,K as me,L as at,M as pe,N as ge,O as ve,P as ye,Q as j,R as Pe,T as xe,U as Dt,V as we,W as Ce}from"./vendor-CveO81sn.js";const J=u.createContext({});function Q(e){const t=u.useRef(null);return t.current===null&&(t.current=e()),t.current}const Lt=typeof window<"u",Tt=Lt?u.useLayoutEffect:u.useEffect,G=u.createContext(null),Z=u.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function ut(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ee(...e){return t=>{let n=!1;const s=e.map(o=>{const i=ut(o,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let o=0;o<s.length;o++){const i=s[o];typeof i=="function"?i():ut(e[o],null)}}}}function Se(...e){return u.useCallback(Ee(...e),e)}class Me extends u.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const s=n.offsetParent,o=st(s)&&s.offsetWidth||0,i=st(s)&&s.offsetHeight||0,r=this.props.sizeRef.current;r.height=n.offsetHeight||0,r.width=n.offsetWidth||0,r.top=n.offsetTop,r.left=n.offsetLeft,r.right=o-r.width-r.left,r.bottom=i-r.height-r.top}return null}componentDidUpdate(){}render(){return this.props.children}}function Ve({children:e,isPresent:t,anchorX:n,anchorY:s,root:o}){const i=u.useId(),r=u.useRef(null),l=u.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0}),{nonce:h}=u.useContext(Z),m=e.props?.ref??e?.ref,f=Se(r,m);return u.useInsertionEffect(()=>{const{width:c,height:a,top:d,left:p,right:g,bottom:v}=l.current;if(t||!r.current||!c||!a)return;const P=n==="left"?`left: ${p}`:`right: ${g}`,x=s==="bottom"?`bottom: ${v}`:`top: ${d}`;r.current.dataset.motionPopId=i;const y=document.createElement("style");h&&(y.nonce=h);const C=o??document.head;return C.appendChild(y),y.sheet&&y.sheet.insertRule(`
[data-motion-pop-id="${i}"] {
position: absolute !important;
width: ${c}px !important;
height: ${a}px !important;
${P}px !important;
${x}px !important;
}
`),()=>{C.contains(y)&&C.removeChild(y)}},[t]),V.jsx(Me,{isPresent:t,childRef:r,sizeRef:l,children:u.cloneElement(e,{ref:f})})}const be=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:o,presenceAffectsLayout:i,mode:r,anchorX:l,anchorY:h,root:m})=>{const f=Q(Ae),c=u.useId();let a=!0,d=u.useMemo(()=>(a=!1,{id:c,initial:t,isPresent:n,custom:o,onExitComplete:p=>{f.set(p,!0);for(const g of f.values())if(!g)return;s&&s()},register:p=>(f.set(p,!1),()=>f.delete(p))}),[n,f,s]);return i&&a&&(d={...d}),u.useMemo(()=>{f.forEach((p,g)=>f.set(g,!1))},[n]),u.useEffect(()=>{!n&&!f.size&&s&&s()},[n]),r==="popLayout"&&(e=V.jsx(Ve,{isPresent:n,anchorX:l,anchorY:h,root:m,children:e})),V.jsx(G.Provider,{value:d,children:e})};function Ae(){return new Map}function Rt(e=!0){const t=u.useContext(G);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:o}=t,i=u.useId();u.useEffect(()=>{if(e)return o(i)},[e]);const r=u.useCallback(()=>e&&s&&s(i),[i,s,e]);return!n&&s?[!1,r]:[!0]}const R=e=>e.key||"";function lt(e){const t=[];return u.Children.forEach(e,n=>{u.isValidElement(n)&&t.push(n)}),t}const Gn=({children:e,custom:t,initial:n=!0,onExitComplete:s,presenceAffectsLayout:o=!0,mode:i="sync",propagate:r=!1,anchorX:l="left",anchorY:h="top",root:m})=>{const[f,c]=Rt(r),a=u.useMemo(()=>lt(e),[e]),d=r&&!f?[]:a.map(R),p=u.useRef(!0),g=u.useRef(a),v=Q(()=>new Map),P=u.useRef(new Set),[x,y]=u.useState(a),[C,H]=u.useState(a);Tt(()=>{p.current=!1,g.current=a;for(let E=0;E<C.length;E++){const w=R(C[E]);d.includes(w)?(v.delete(w),P.current.delete(w)):v.get(w)!==!0&&v.set(w,!1)}},[C,d.length,d.join("-")]);const B=[];if(a!==x){let E=[...a];for(let w=0;w<C.length;w++){const A=C[w],U=R(A);d.includes(U)||(E.splice(w,0,A),B.push(A))}return i==="wait"&&B.length&&(E=B),H(lt(E)),y(a),null}const{forceRender:zt}=u.useContext(J);return V.jsx(V.Fragment,{children:C.map(E=>{const w=R(E),A=r&&!f?!1:a===C||d.includes(w),U=()=>{if(P.current.has(w))return;if(P.current.add(w),v.has(w))v.set(w,!0);else return;let nt=!0;v.forEach(_t=>{_t||(nt=!1)}),nt&&(zt?.(),H(g.current),r&&c?.(),s&&s())};return V.jsx(be,{isPresent:A,initial:!p.current||n?void 0:!1,custom:t,presenceAffectsLayout:o,mode:i,root:m,onExitComplete:A?void 0:U,anchorX:l,anchorY:h,children:E},w)})})},It=u.createContext({strict:!1}),ct={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let ft=!1;function De(){if(ft)return;const e={};for(const t in ct)e[t]={isEnabled:n=>ct[t].some(s=>!!n[s])};Et(e),ft=!0}function jt(){return De(),Kt()}function Le(e){const t=jt();for(const n in e)t[n]={...t[n],...e[n]};Et(t)}const Te=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function O(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||Te.has(e)}let kt=e=>!O(e);function Re(e){typeof e=="function"&&(kt=t=>t.startsWith("on")?!O(t):e(t))}try{Re(require("@emotion/is-prop-valid").default)}catch{}function Ie(e,t,n){const s={};for(const o in e)o==="values"&&typeof e.values=="object"||(kt(o)||n===!0&&O(o)||!t&&!O(o)||e.draggable&&o.startsWith("onDrag"))&&(s[o]=e[o]);return s}const W=u.createContext({});function je(e,t){if(St(e)){const{initial:n,animate:s}=e;return{initial:n===!1||ot(n)?n:void 0,animate:ot(s)?s:void 0}}return e.inherit!==!1?t:{}}function ke(e){const{initial:t,animate:n}=je(e,u.useContext(W));return u.useMemo(()=>({initial:t,animate:n}),[ht(t),ht(n)])}function ht(e){return Array.isArray(e)?e.join(" "):e}const tt=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Ft(e,t,n){for(const s in t)!Mt(t[s])&&!Xt(s,n)&&(e[s]=t[s])}function Fe({transformTemplate:e},t){return u.useMemo(()=>{const n=tt();return Yt(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Oe(e,t){const n=e.style||{},s={};return Ft(s,n,e),Object.assign(s,Fe(e,t)),s}function Ge(e,t){const n={},s=Oe(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=s,n}const Ot=()=>({...tt(),attrs:{}});function We(e,t,n,s){const o=u.useMemo(()=>{const i=Ot();return qt(i,t,Jt(s),e.transformTemplate,e.style),{...i.attrs,style:{...i.style}}},[t]);if(e.style){const i={};Ft(i,e.style,e),o.style={...i,...o.style}}return o}const He=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function et(e){return typeof e!="string"||e.includes("-")?!1:!!(He.indexOf(e)>-1||/[A-Z]/u.test(e))}function Be(e,t,n,{latestValues:s},o,i=!1,r){const h=(r??et(e)?We:Ge)(t,s,o,e),m=Ie(t,typeof e=="string",i),f=e!==u.Fragment?{...m,...h,ref:n}:{},{children:c}=t,a=u.useMemo(()=>Mt(c)?c.get():c,[c]);return u.createElement(e,{...f,children:a})}function Ue({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,o){return{latestValues:Ne(n,s,o,e),renderState:t()}}function Ne(e,t,n,s){const o={},i=s(e,{});for(const a in i)o[a]=Qt(i[a]);let{initial:r,animate:l}=e;const h=St(e),m=Zt(e);t&&m&&!h&&e.inherit!==!1&&(r===void 0&&(r=t.initial),l===void 0&&(l=t.animate));let f=n?n.initial===!1:!1;f=f||r===!1;const c=f?l:r;if(c&&typeof c!="boolean"&&!Vt(c)){const a=Array.isArray(c)?c:[c];for(let d=0;d<a.length;d++){const p=te(e,a[d]);if(p){const{transitionEnd:g,transition:v,...P}=p;for(const x in P){let y=P[x];if(Array.isArray(y)){const C=f?y.length-1:0;y=y[C]}y!==null&&(o[x]=y)}for(const x in g)o[x]=g[x]}}}return o}const Gt=e=>(t,n)=>{const s=u.useContext(W),o=u.useContext(G),i=()=>Ue(e,t,s,o);return n?i():Q(i)},$e=Gt({scrapeMotionValuesFromProps:ee,createRenderState:tt}),ze=Gt({scrapeMotionValuesFromProps:ne,createRenderState:Ot}),_e=Symbol.for("motionComponentSymbol");function Ke(e,t,n){const s=u.useRef(n);u.useInsertionEffect(()=>{s.current=n});const o=u.useRef(null);return u.useCallback(i=>{i&&e.onMount?.(i),t&&(i?t.mount(i):t.unmount());const r=s.current;if(typeof r=="function")if(i){const l=r(i);typeof l=="function"&&(o.current=l)}else o.current?(o.current(),o.current=null):r(i);else r&&(r.current=i)},[t])}const Wt=u.createContext({});function D(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function Xe(e,t,n,s,o,i){const{visualElement:r}=u.useContext(W),l=u.useContext(It),h=u.useContext(G),m=u.useContext(Z).reducedMotion,f=u.useRef(null),c=u.useRef(!1);s=s||l.renderer,!f.current&&s&&(f.current=s(e,{visualState:t,parent:r,props:n,presenceContext:h,blockInitialAnimation:h?h.initial===!1:!1,reducedMotionConfig:m,isSVG:i}),c.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));const a=f.current,d=u.useContext(Wt);a&&!a.projection&&o&&(a.type==="html"||a.type==="svg")&&Ye(f.current,n,o,d);const p=u.useRef(!1);u.useInsertionEffect(()=>{a&&p.current&&a.update(n,h)});const g=n[se],v=u.useRef(!!g&&!window.MotionHandoffIsComplete?.(g)&&window.MotionHasOptimisedAnimation?.(g));return Tt(()=>{c.current=!0,a&&(p.current=!0,window.MotionIsMounted=!0,a.updateFeatures(),a.scheduleRenderMicrotask(),v.current&&a.animationState&&a.animationState.animateChanges())}),u.useEffect(()=>{a&&(!v.current&&a.animationState&&a.animationState.animateChanges(),v.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(g)}),v.current=!1),a.enteringChildren=void 0)}),a}function Ye(e,t,n,s){const{layoutId:o,layout:i,drag:r,dragConstraints:l,layoutScroll:h,layoutRoot:m,layoutCrossfade:f}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:Ht(e.parent)),e.projection.setOptions({layoutId:o,layout:i,alwaysMeasureLayout:!!r||l&&D(l),visualElement:e,animationType:typeof i=="string"?i:"both",initialPromotionConfig:s,crossfade:f,layoutScroll:h,layoutRoot:m})}function Ht(e){if(e)return e.options.allowProjection!==!1?e.projection:Ht(e.parent)}function N(e,{forwardMotionProps:t=!1,type:n}={},s,o){s&&Le(s);const i=n?n==="svg":et(e),r=i?ze:$e;function l(m,f){let c;const a={...u.useContext(Z),...m,layoutId:qe(m)},{isStatic:d}=a,p=ke(m),g=r(m,d);if(!d&&Lt){Je();const v=Qe(a);c=v.MeasureLayout,p.visualElement=Xe(e,g,a,o,v.ProjectionNode,i)}return V.jsxs(W.Provider,{value:p,children:[c&&p.visualElement?V.jsx(c,{visualElement:p.visualElement,...a}):null,Be(e,m,Ke(g,p.visualElement,f),g,d,t,i)]})}l.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const h=u.forwardRef(l);return h[_e]=e,h}function qe({layoutId:e}){const t=u.useContext(J).id;return t&&e!==void 0?t+"-"+e:e}function Je(e,t){u.useContext(It).strict}function Qe(e){const t=jt(),{drag:n,layout:s}=t;if(!n&&!s)return{};const o={...n,...s};return{MeasureLayout:n?.isEnabled(e)||s?.isEnabled(e)?o.MeasureLayout:void 0,ProjectionNode:o.ProjectionNode}}function Ze(e,t){if(typeof Proxy>"u")return N;const n=new Map,s=(i,r)=>N(i,r,e,t),o=(i,r)=>s(i,r);return new Proxy(o,{get:(i,r)=>r==="create"?s:(n.has(r)||n.set(r,N(r,void 0,e,t)),n.get(r))})}const tn=(e,t)=>t.isSVG??et(e)?new oe(t):new ie(t,{allowProjection:e!==u.Fragment});class en extends b{constructor(t){super(t),t.animationState||(t.animationState=re(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Vt(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let nn=0;class sn extends b{constructor(){super(...arguments),this.id=nn++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===s)return;const o=this.node.animationState.setActive("exit",!t);n&&!t&&o.then(()=>{n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const on={animation:{Feature:en},exit:{Feature:sn}};function T(e){return{point:{x:e.pageX,y:e.pageY}}}const rn=e=>t=>bt(t)&&e(t,T(t));function L(e,t,n,s){return k(e,t,rn(n),s)}const Bt=({current:e})=>e?e.ownerDocument.defaultView:null,dt=(e,t)=>Math.abs(e-t);function an(e,t){const n=dt(e.x,t.x),s=dt(e.y,t.y);return Math.sqrt(n**2+s**2)}const mt=new Set(["auto","scroll"]);class Ut{constructor(t,n,{transformPagePoint:s,contextWindow:o=window,dragSnapToOrigin:i=!1,distanceThreshold:r=3,element:l}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=d=>{this.handleScroll(d.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const d=z(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,g=an(d.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!g)return;const{point:v}=d,{timestamp:P}=it;this.history.push({...v,timestamp:P});const{onStart:x,onMove:y}=this.handlers;p||(x&&x(this.lastMoveEvent,d),this.startEvent=this.lastMoveEvent),y&&y(this.lastMoveEvent,d)},this.handlePointerMove=(d,p)=>{this.lastMoveEvent=d,this.lastMoveEventInfo=$(p,this.transformPagePoint),M.update(this.updatePoint,!0)},this.handlePointerUp=(d,p)=>{this.end();const{onEnd:g,onSessionEnd:v,resumeAnimation:P}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&P&&P(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const x=z(d.type==="pointercancel"?this.lastMoveEventInfo:$(p,this.transformPagePoint),this.history);this.startEvent&&g&&g(d,x),v&&v(d,x)},!bt(t))return;this.dragSnapToOrigin=i,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=r,this.contextWindow=o||window;const h=T(t),m=$(h,this.transformPagePoint),{point:f}=m,{timestamp:c}=it;this.history=[{...f,timestamp:c}];const{onSessionStart:a}=n;a&&a(t,z(m,this.history)),this.removeListeners=At(L(this.contextWindow,"pointermove",this.handlePointerMove),L(this.contextWindow,"pointerup",this.handlePointerUp),L(this.contextWindow,"pointercancel",this.handlePointerUp)),l&&this.startScrollTracking(l)}startScrollTracking(t){let n=t.parentElement;for(;n;){const s=getComputedStyle(n);(mt.has(s.overflowX)||mt.has(s.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0,passive:!0}),window.addEventListener("scroll",this.onWindowScroll,{passive:!0}),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const n=this.scrollPositions.get(t);if(!n)return;const s=t===window,o=s?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},i={x:o.x-n.x,y:o.y-n.y};i.x===0&&i.y===0||(s?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(t,o),M.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),ae(this.updatePoint)}}function $(e,t){return t?{point:t(e.point)}:e}function pt(e,t){return{x:e.x-t.x,y:e.y-t.y}}function z({point:e},t){return{point:e,delta:pt(e,Nt(t)),offset:pt(e,un(t)),velocity:ln(t,.1)}}function un(e){return e[0]}function Nt(e){return e[e.length-1]}function ln(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const o=Nt(e);for(;n>=0&&(s=e[n],!(o.timestamp-s.timestamp>ue(t)));)n--;if(!s)return{x:0,y:0};const i=le(o.timestamp-s.timestamp);if(i===0)return{x:0,y:0};const r={x:(o.x-s.x)/i,y:(o.y-s.y)/i};return r.x===1/0&&(r.x=0),r.y===1/0&&(r.y=0),r}function cn(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?F(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?F(n,e,s.max):Math.min(e,n)),e}function gt(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function fn(e,{top:t,left:n,bottom:s,right:o}){return{x:gt(e.x,n,o),y:gt(e.y,t,s)}}function vt(e,t){let n=t.min-e.min,s=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,s]=[s,n]),{min:n,max:s}}function hn(e,t){return{x:vt(e.x,t.x),y:vt(e.y,t.y)}}function dn(e,t){let n=.5;const s=X(e),o=X(t);return o>s?n=rt(t.min,t.max-s,e.min):s>o&&(n=rt(e.min,e.max-o,t.min)),ce(0,1,n)}function mn(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const Y=.35;function pn(e=Y){return e===!1?e=0:e===!0&&(e=Y),{x:yt(e,"left","right"),y:yt(e,"top","bottom")}}function yt(e,t,n){return{min:Pt(e,t),max:Pt(e,n)}}function Pt(e,t){return typeof e=="number"?e:e[t]||0}const gn=new WeakMap;class vn{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=fe(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:o}=this.visualElement;if(o&&o.isPresent===!1)return;const i=c=>{n?(this.stopAnimation(),this.snapToCursor(T(c).point)):this.pauseAnimation()},r=(c,a)=>{this.stopAnimation();const{drag:d,dragPropagation:p,onDragStart:g}=this.getProps();if(d&&!p&&(this.openDragLock&&this.openDragLock(),this.openDragLock=ge(d),!this.openDragLock))return;this.latestPointerEvent=c,this.latestPanInfo=a,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),S(P=>{let x=this.getAxisMotionValue(P).get()||0;if(ve.test(x)){const{projection:y}=this.visualElement;if(y&&y.layout){const C=y.layout.layoutBox[P];C&&(x=X(C)*(parseFloat(x)/100))}}this.originPoint[P]=x}),g&&M.postRender(()=>g(c,a)),at(this.visualElement,"transform");const{animationState:v}=this.visualElement;v&&v.setActive("whileDrag",!0)},l=(c,a)=>{this.latestPointerEvent=c,this.latestPanInfo=a;const{dragPropagation:d,dragDirectionLock:p,onDirectionLock:g,onDrag:v}=this.getProps();if(!d&&!this.openDragLock)return;const{offset:P}=a;if(p&&this.currentDirection===null){this.currentDirection=yn(P),this.currentDirection!==null&&g&&g(this.currentDirection);return}this.updateAxis("x",a.point,P),this.updateAxis("y",a.point,P),this.visualElement.render(),v&&v(c,a)},h=(c,a)=>{this.latestPointerEvent=c,this.latestPanInfo=a,this.stop(c,a),this.latestPointerEvent=null,this.latestPanInfo=null},m=()=>S(c=>this.getAnimationState(c)==="paused"&&this.getAxisMotionValue(c).animation?.play()),{dragSnapToOrigin:f}=this.getProps();this.panSession=new Ut(t,{onSessionStart:i,onStart:r,onMove:l,onSessionEnd:h,resumeAnimation:m},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:f,distanceThreshold:s,contextWindow:Bt(this.visualElement),element:this.visualElement.current})}stop(t,n){const s=t||this.latestPointerEvent,o=n||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!o||!s)return;const{velocity:r}=o;this.startAnimation(r);const{onDragEnd:l}=this.getProps();l&&M.postRender(()=>l(s,o))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,n,s){const{drag:o}=this.getProps();if(!s||!I(t,o,this.currentDirection))return;const i=this.getAxisMotionValue(t);let r=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(r=cn(r,this.constraints[t],this.elastic[t])),i.set(r)}resolveConstraints(){const{dragConstraints:t,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,o=this.constraints;t&&D(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=fn(s.layoutBox,t):this.constraints=!1,this.elastic=pn(n),o!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&S(i=>{this.constraints!==!1&&this.getAxisMotionValue(i)&&(this.constraints[i]=mn(s.layoutBox[i],this.constraints[i]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!D(t))return!1;const s=t.current,{projection:o}=this.visualElement;if(!o||!o.layout)return!1;const i=he(s,o.root,this.visualElement.getTransformPagePoint());let r=hn(o.layout.layoutBox,i);if(n){const l=n(de(r));this.hasMutatedConstraints=!!l,l&&(r=me(l))}return r}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:o,dragTransition:i,dragSnapToOrigin:r,onDragTransitionEnd:l}=this.getProps(),h=this.constraints||{},m=S(f=>{if(!I(f,n,this.currentDirection))return;let c=h&&h[f]||{};r&&(c={min:0,max:0});const a=o?200:1e6,d=o?40:1e7,p={type:"inertia",velocity:s?t[f]:0,bounceStiffness:a,bounceDamping:d,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(f,p)});return Promise.all(m).then(l)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return at(this.visualElement,t),s.start(pe(t,s,0,n,this.visualElement,!1))}stopAnimation(){S(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){S(t=>this.getAxisMotionValue(t).animation?.pause())}getAnimationState(t){return this.getAxisMotionValue(t).animation?.state}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,s=this.visualElement.getProps(),o=s[n];return o||this.visualElement.getValue(t,(s.initial?s.initial[t]:void 0)||0)}snapToCursor(t){S(n=>{const{drag:s}=this.getProps();if(!I(n,s,this.currentDirection))return;const{projection:o}=this.visualElement,i=this.getAxisMotionValue(n);if(o&&o.layout){const{min:r,max:l}=o.layout.layoutBox[n],h=i.get()||0;i.set(t[n]-F(r,l,.5)+h)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!D(n)||!s||!this.constraints)return;this.stopAnimation();const o={x:0,y:0};S(r=>{const l=this.getAxisMotionValue(r);if(l&&this.constraints!==!1){const h=l.get();o[r]=dn({min:h,max:h},this.constraints[r])}});const{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),S(r=>{if(!I(r,t,null))return;const l=this.getAxisMotionValue(r),{min:h,max:m}=this.constraints[r];l.set(F(h,m,o[r]))})}addListeners(){if(!this.visualElement.current)return;gn.set(this.visualElement,this);const t=this.visualElement.current,n=L(t,"pointerdown",h=>{const{drag:m,dragListener:f=!0}=this.getProps(),c=h.target,a=c!==t&&ye(c);m&&f&&!a&&this.start(h)}),s=()=>{const{dragConstraints:h}=this.getProps();D(h)&&h.current&&(this.constraints=this.resolveRefConstraints())},{projection:o}=this.visualElement,i=o.addEventListener("measure",s);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),M.read(s);const r=k(window,"resize",()=>this.scalePositionWithinConstraints()),l=o.addEventListener("didUpdate",(({delta:h,hasLayoutChanged:m})=>{this.isDragging&&m&&(S(f=>{const c=this.getAxisMotionValue(f);c&&(this.originPoint[f]+=h[f].translate,c.set(c.get()+h[f].translate))}),this.visualElement.render())}));return()=>{r(),n(),i(),l&&l()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:o=!1,dragConstraints:i=!1,dragElastic:r=Y,dragMomentum:l=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:o,dragConstraints:i,dragElastic:r,dragMomentum:l}}}function I(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function yn(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class Pn extends b{constructor(t){super(t),this.removeGroupControls=j,this.removeListeners=j,this.controls=new vn(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||j}update(){const{dragControls:t}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};t!==n&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const xt=e=>(t,n)=>{e&&M.postRender(()=>e(t,n))};class xn extends b{constructor(){super(...arguments),this.removePointerDownListener=j}onPointerDown(t){this.session=new Ut(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Bt(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:o}=this.node.getProps();return{onSessionStart:xt(t),onStart:xt(n),onMove:s,onEnd:(i,r)=>{delete this.session,o&&M.postRender(()=>o(i,r))}}}mount(){this.removePointerDownListener=L(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let _=!1;class wn extends u.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:o}=this.props,{projection:i}=t;i&&(n.group&&n.group.add(i),s&&s.register&&o&&s.register(i),_&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Pe.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:s,drag:o,isPresent:i}=this.props,{projection:r}=s;return r&&(r.isPresent=i,t.layoutDependency!==n&&r.setOptions({...r.options,layoutDependency:n}),_=!0,o||t.layoutDependency!==n||n===void 0||t.isPresent!==i?r.willUpdate():this.safeToRemove(),t.isPresent!==i&&(i?r.promote():r.relegate()||M.postRender(()=>{const l=r.getStack();(!l||!l.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),xe.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:o}=t;_=!0,o&&(o.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(o),s&&s.deregister&&s.deregister(o))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function $t(e){const[t,n]=Rt(),s=u.useContext(J);return V.jsx(wn,{...e,layoutGroup:s,switchLayoutGroup:u.useContext(Wt),isPresent:t,safeToRemove:n})}const Cn={pan:{Feature:xn},drag:{Feature:Pn,ProjectionNode:Dt,MeasureLayout:$t}};function wt(e,t,n){const{props:s}=e;e.animationState&&s.whileHover&&e.animationState.setActive("whileHover",n==="Start");const o="onHover"+n,i=s[o];i&&M.postRender(()=>i(t,T(t)))}class En extends b{mount(){const{current:t}=this.node;t&&(this.unmount=we(t,(n,s)=>(wt(this.node,s,"Start"),o=>wt(this.node,o,"End"))))}unmount(){}}class Sn extends b{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=At(k(this.node.current,"focus",()=>this.onFocus()),k(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Ct(e,t,n){const{props:s}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&s.whileTap&&e.animationState.setActive("whileTap",n==="Start");const o="onTap"+(n==="End"?"":n),i=s[o];i&&M.postRender(()=>i(t,T(t)))}class Mn extends b{mount(){const{current:t}=this.node;t&&(this.unmount=Ce(t,(n,s)=>(Ct(this.node,s,"Start"),(o,{success:i})=>Ct(this.node,o,i?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const q=new WeakMap,K=new WeakMap,Vn=e=>{const t=q.get(e.target);t&&t(e)},bn=e=>{e.forEach(Vn)};function An({root:e,...t}){const n=e||document;K.has(n)||K.set(n,{});const s=K.get(n),o=JSON.stringify(t);return s[o]||(s[o]=new IntersectionObserver(bn,{root:e,...t})),s[o]}function Dn(e,t,n){const s=An(t);return q.set(e,n),s.observe(e),()=>{q.delete(e),s.unobserve(e)}}const Ln={some:0,all:1};class Tn extends b{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:s,amount:o="some",once:i}=t,r={root:n?n.current:void 0,rootMargin:s,threshold:typeof o=="number"?o:Ln[o]},l=h=>{const{isIntersecting:m}=h;if(this.isInView===m||(this.isInView=m,i&&!m&&this.hasEnteredView))return;m&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",m);const{onViewportEnter:f,onViewportLeave:c}=this.node.getProps(),a=m?f:c;a&&a(h)};return Dn(this.node.current,r,l)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(Rn(t,n))&&this.startObserver()}unmount(){}}function Rn({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const In={inView:{Feature:Tn},tap:{Feature:Mn},focus:{Feature:Sn},hover:{Feature:En}},jn={layout:{ProjectionNode:Dt,MeasureLayout:$t}},kn={...on,...In,...Cn,...jn},Wn=Ze(kn,tn);export{Gn as A,Wn as m};