@lacrous/omnicloud 0.2.28 → 0.2.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lacrous/omnicloud",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.29",
|
|
4
4
|
"description": "SDK and core building blocks for OmniCloud — self-hosted cloud storage powered by your Telegram account.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"prisma": "^6.2.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@omnicloud/core": "0.2.
|
|
52
|
-
"@omnicloud/shared": "0.2.
|
|
53
|
-
"@omnicloud/telegram": "0.2.
|
|
51
|
+
"@omnicloud/core": "0.2.29",
|
|
52
|
+
"@omnicloud/shared": "0.2.29",
|
|
53
|
+
"@omnicloud/telegram": "0.2.29",
|
|
54
54
|
"@types/node": "^22.10.0",
|
|
55
55
|
"esbuild": "0.25.12",
|
|
56
56
|
"tsup": "^8.3.0",
|
package/server/index.js
CHANGED
|
@@ -5197,7 +5197,7 @@ function encryptionCheck(configured) {
|
|
|
5197
5197
|
}
|
|
5198
5198
|
|
|
5199
5199
|
// ../../apps/api/src/routes/storage.ts
|
|
5200
|
-
var VERSION = "0.2.
|
|
5200
|
+
var VERSION = "0.2.29";
|
|
5201
5201
|
function registerStorageRoutes(app2, container2) {
|
|
5202
5202
|
app2.get("/api/health", async () => {
|
|
5203
5203
|
const database = await probeDatabase(container2);
|
|
@@ -336,7 +336,7 @@ Please change the parent <Route path="${P}"> to <Route path="${P==="/"?"*":`${P}
|
|
|
336
336
|
${_}px !important;
|
|
337
337
|
${I}px !important;
|
|
338
338
|
}
|
|
339
|
-
`),()=>{var B;(B=d.current)==null||B.removeAttribute("data-motion-pop-id"),D.contains(R)&&D.removeChild(R)}},[t]),p.jsx(TR,{isPresent:t,childRef:d,sizeRef:h,pop:l,children:l===!1?e:S.cloneElement(e,{ref:v})})}const NR=({children:e,initial:t,isPresent:s,onExitComplete:i,custom:o,presenceAffectsLayout:l,mode:u,anchorX:d,anchorY:h,root:m})=>{const y=uh(bR),v=S.useId(),x=S.useRef(s),C=S.useRef(i);Co(()=>{x.current=s,C.current=i});let k=!0,E=S.useMemo(()=>(k=!1,{id:v,initial:t,isPresent:s,custom:o,onExitComplete:T=>{y.set(T,!0);for(const P of y.values())if(!P)return;i&&i()},register:T=>(y.set(T,!1),()=>{var P;y.delete(T),!x.current&&!y.size&&((P=C.current)==null||P.call(C))})}),[s,y,i]);return l&&k&&(E={...E}),S.useMemo(()=>{y.forEach((T,P)=>y.set(P,!1))},[s]),S.useEffect(()=>{!s&&!y.size&&i&&i()},[s]),e=p.jsx(PR,{pop:u==="popLayout",isPresent:s,anchorX:d,anchorY:h,root:m,children:e}),p.jsx(Hl.Provider,{value:E,children:e})};function bR(){return new Map}function Gw(e=!0){const t=S.useContext(Hl);if(t===null)return[!0,null];const{isPresent:s,onExitComplete:i,register:o}=t,l=S.useId();S.useEffect(()=>{if(e)return o(l)},[e]);const u=S.useCallback(()=>e&&i&&i(l),[l,i,e]);return!s&&i?[!1,u]:[!0]}const po=e=>e.key||"";function j0(e){const t=[];return S.Children.forEach(e,s=>{S.isValidElement(s)&&t.push(s)}),t}const Lr=({children:e,custom:t,initial:s=!0,onExitComplete:i,presenceAffectsLayout:o=!0,mode:l="sync",propagate:u=!1,anchorX:d="left",anchorY:h="top",root:m})=>{const[y,v]=Gw(u),x=S.useMemo(()=>j0(e),[e]),C=u&&!y?[]:x.map(po),k=S.useRef(!0),E=uh(()=>new Map),T=S.useRef(new Set),[P,L]=S.useState(x),[b,M]=S.useState(x);Co(()=>{u&&!y&&!b.length&&(v==null||v())},[y,u,b.length,v]),Co(()=>{k.current=!1;for(let R=0;R<b.length;R++){const D=po(b[R]);C.includes(D)?(E.delete(D),T.current.delete(D)):E.get(D)!==!0&&E.set(D,!1)}},[b,C.length,C.join("-")]);const _=[];if(x!==P){let R=[...x],D=0;for(const B of b){const W=C.indexOf(po(B));W===-1?(R.splice(D++,0,B),_.push(B)):D=W+_.length+1}return _.every(B=>E.get(po(B)))?R=x:l==="wait"&&(R=_),M(j0(R)),L(x),null}const{forceRender:I}=S.useContext(lh);return p.jsx(p.Fragment,{children:b.map(R=>{const D=po(R),B=u&&!y?!1:x===b||C.includes(D),W=()=>{if(T.current.has(D))return;if(E.has(D))T.current.add(D),E.set(D,!0);else return;let G=!0;E.forEach(K=>{K||(G=!1)}),G&&(I==null||I(),L([]),u&&(v==null||v()),i&&i())};return p.jsx(NR,{isPresent:B,initial:!k.current||s?void 0:!1,custom:t,presenceAffectsLayout:o,mode:l,root:m,onExitComplete:B?void 0:W,anchorX:d,anchorY:h,children:R},D)})})},Yw=S.createContext({strict:!1}),M0={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 D0=!1;function RR(){if(D0)return;const e={};for(const t in M0)e[t]={isEnabled:s=>M0[t].some(i=>!!s[i])};Dw(e),D0=!0}function Xw(){return RR(),Tb()}function jR(e){const t=Xw();for(const s in e)t[s]={...t[s],...e[s]};Dw(t)}const Gl=S.createContext({});function MR(e,t){if(Ql(e)){const{initial:s,animate:i}=e;return{initial:s===!1||bo(s)?s:void 0,animate:bo(i)?i:void 0}}return e.inherit!==!1?t:{}}function DR(e){const{initial:t,animate:s}=MR(e,S.useContext(Gl));return S.useMemo(()=>({initial:t,animate:s}),[A0(t),A0(s)])}function A0(e){return Array.isArray(e)?e.join(" "):e}const Oh=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Jw(e,t,s){for(const i in t)!ct(t[i])&&!Iw(i,s)&&(e[i]=t[i])}function AR({transformTemplate:e},t){return S.useMemo(()=>{const s=Oh();return Mh(s,t,e),Object.assign({},s.vars,s.style)},[t])}function LR(e,t){const s=e.style||{},i={};return Jw(i,s,e),Object.assign(i,AR(e,t)),i}function IR(e,t){const s={},i=LR(e,t);return e.drag&&e.dragListener!==!1&&(s.draggable=!1,i.userSelect=i.WebkitUserSelect=i.WebkitTouchCallout="none",i.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(s.tabIndex=0),s.style=i,s}const Zw=()=>({...Oh(),attrs:{}});function FR(e,t,s,i){const o=S.useMemo(()=>{const l=Zw();return Sw(l,t,_w(i),e.transformTemplate,e.style),{...l.attrs,style:{...l.style}}},[t]);if(e.style){const l={};Jw(l,e.style,e),o.style={...l,...o.style}}return o}const _R=new Set(["animate","exit","variants","initial","style","values","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function Vl(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||_R.has(e)}function OR(e,t){return e.startsWith("on")?!Vl(e):(t==null?void 0:t(e))??!Vl(e)}function VR(e,t,s,i){const o={};for(const l in e)l==="values"&&typeof e.values=="object"||ct(e[l])||(OR(l,i)||s===!0&&Vl(l)||!t&&!Vl(l)||e.draggable&&l.startsWith("onDrag"))&&(o[l]=e[l]);return o}const BR=["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 Vh(e){return typeof e!="string"||e.includes("-")?!1:!!(BR.indexOf(e)>-1||/[A-Z]/u.test(e))}function zR(e,t,s,{latestValues:i},o,l=!1,u,d){const m=(u??Vh(e)?FR:IR)(t,i,o,e),y=VR(t,typeof e=="string",l,d),v=e!==S.Fragment?{...y,...m,ref:s}:{},{children:x}=t,C=S.useMemo(()=>ct(x)?x.get():x,[x]);return S.createElement(e,{...v,children:C})}function UR({scrapeMotionValuesFromProps:e,createRenderState:t},s,i,o){return{latestValues:$R(s,i,o,e),renderState:t()}}function $R(e,t,s,i){const o={},l=i(e,{});for(const x in l)o[x]=Cl(l[x]);let{initial:u,animate:d}=e;const h=Ql(e),m=jw(e);t&&m&&!h&&e.inherit!==!1&&(u===void 0&&(u=t.initial),d===void 0&&(d=t.animate));let y=s?s.initial===!1:!1;y=y||u===!1;const v=y?d:u;if(v&&typeof v!="boolean"&&!ql(v)){const x=Array.isArray(v)?v:[v];for(let C=0;C<x.length;C++){const k=hw(e,x[C]);if(k){const{transitionEnd:E,transition:T,...P}=k;for(const L in P){let b=P[L];if(Array.isArray(b)){const M=y?b.length-1:0;b=b[M]}b!==null&&(o[L]=b)}for(const L in E)o[L]=E[L]}}}return o}const eS=e=>(t,s)=>{const i=S.useContext(Gl),o=S.useContext(Hl),l=()=>UR(e,t,i,o);return s?l():uh(l)},HR=eS({scrapeMotionValuesFromProps:Fh,createRenderState:Oh}),KR=eS({scrapeMotionValuesFromProps:Ow,createRenderState:Zw}),WR=Symbol.for("motionComponentSymbol");function qR(e,t,s){const i=S.useRef(s);S.useInsertionEffect(()=>{i.current=s});const o=S.useRef(null);return S.useCallback(l=>{var d;l&&((d=e.onMount)==null||d.call(e,l)),t&&(l?t.mount(l):t.unmount());const u=i.current;if(typeof u=="function")if(l){const h=u(l);typeof h=="function"&&(o.current=h)}else o.current?(o.current(),o.current=null):u(l);else u&&(u.current=l)},[t])}const tS=S.createContext({});function Ks(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function QR(e,t,s,i,o,l){var b,M;const{visualElement:u}=S.useContext(Gl),d=S.useContext(Yw),h=S.useContext(Hl),m=S.useContext(_h),y=m.reducedMotion,v=m.skipAnimations,x=S.useRef(null),C=S.useRef(!1);i=i||d.renderer,!x.current&&i&&(x.current=i(e,{visualState:t,parent:u,props:s,presenceContext:h,blockInitialAnimation:h?h.initial===!1:!1,reducedMotionConfig:y,skipAnimations:v,isSVG:l}),C.current&&x.current&&(x.current.manuallyAnimateOnMount=!0));const k=x.current,E=S.useContext(tS);k&&!k.projection&&o&&(k.type==="html"||k.type==="svg")&&GR(x.current,s,o,E);const T=S.useRef(!1);S.useInsertionEffect(()=>{k&&T.current&&k.update(s,h)});const P=s[gw],L=S.useRef(!!P&&typeof window<"u"&&!((b=window.MotionHandoffIsComplete)!=null&&b.call(window,P))&&((M=window.MotionHasOptimisedAnimation)==null?void 0:M.call(window,P)));return Co(()=>{var _;!C.current||!k||((_=k.animationState)==null||_.animateChanges(),k.enteringChildren=void 0)},[]),Co(()=>{C.current=!0,k&&(T.current=!0,window.MotionIsMounted=!0,k.updateFeatures(),k.scheduleRenderMicrotask(),L.current&&k.animationState&&k.animationState.animateChanges())}),S.useEffect(()=>{k&&(!L.current&&k.animationState&&k.animationState.animateChanges(),L.current&&(queueMicrotask(()=>{var _;(_=window.MotionHandoffMarkAsComplete)==null||_.call(window,P)}),L.current=!1),k.enteringChildren=void 0)}),k}function GR(e,t,s,i){const{layoutId:o,layout:l,drag:u,dragConstraints:d,layoutScroll:h,layoutRoot:m,layoutAnchor:y,layoutCrossfade:v}=t;e.projection=new s(e.latestValues,t["data-framer-portal-id"]?void 0:nS(e.parent)),e.projection.setOptions({layoutId:o,layout:l,alwaysMeasureLayout:!!u||d&&Ks(d),visualElement:e,animationType:typeof l=="string"?l:"both",initialPromotionConfig:i,crossfade:v,layoutScroll:h,layoutRoot:m,layoutAnchor:y})}function nS(e){if(e)return e.options.allowProjection!==!1?e.projection:nS(e.parent)}function yd(e,{forwardMotionProps:t=!1,type:s}={},i,o){i&&jR(i);const l=s?s==="svg":Vh(e),u=l?KR:HR;function d(m,y){let v;const x={...S.useContext(_h),...m,layoutId:YR(m)},{isStatic:C,isValidProp:k}=x,E=DR(m),T=u(m,C);if(!C&&typeof window<"u"){XR();const P=JR(x);v=P.MeasureLayout,E.visualElement=QR(e,T,x,o,P.ProjectionNode,l)}return p.jsxs(Gl.Provider,{value:E,children:[v&&E.visualElement?p.jsx(v,{visualElement:E.visualElement,...x}):null,zR(e,m,qR(T,E.visualElement,y),T,C,t,l,k)]})}d.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const h=S.forwardRef(d);return h[WR]=e,h}function YR({layoutId:e}){const t=S.useContext(lh).id;return t&&e!==void 0?t+"-"+e:e}function XR(e,t){S.useContext(Yw).strict}function JR(e){const t=Xw(),{drag:s,layout:i}=t;if(!s&&!i)return{};const o={...s,...i};return{MeasureLayout:s!=null&&s.isEnabled(e)||i!=null&&i.isEnabled(e)?o.MeasureLayout:void 0,ProjectionNode:o.ProjectionNode}}function ZR(e,t){if(typeof Proxy>"u")return yd;const s=new Map,i=(l,u)=>yd(l,u,e,t),o=(l,u)=>i(l,u);return new Proxy(o,{get:(l,u)=>u==="create"?i:(s.has(u)||s.set(u,yd(u,void 0,e,t)),s.get(u))})}const ej=(e,t)=>t.isSVG??Vh(e)?new jb(t):new bb(t,{allowProjection:e!==S.Fragment});class tj extends Ar{constructor(t){super(t),t.animationState||(t.animationState=Db(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();ql(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:s}=this.node.prevProps||{};t!==s&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)==null||t.call(this)}}let nj=0;class rj extends Ar{constructor(){super(...arguments),this.id=nj++}update(){var h;const{presenceContext:t,prevPresenceContext:s,animationState:i}=this.node;if(!t||!i)return;const{isPresent:o,onExitComplete:l}=t,u=s==null?void 0:s.isPresent;if(o===u)return;if(o&&u===!1){if(this.exit===!0){const{initial:m}=this.node.getProps();if(m&&!Array.isArray(m)){const{transition:y,transitionEnd:v,...x}=ds(this.node,m)||{};for(const C in x)(h=this.node.getValue(C))==null||h.jump(x[C])}this.node.blockInitialAnimation=!1,i.reset(),i.animateChanges()}else i.setActive("exit",!1);this.exit=void 0;return}const d=this.exit=i.setActive("exit",!o);l&&!o&&d.then(()=>{this.exit===d&&(this.exit=!0,l(this.id))})}mount(){const{register:t,onExitComplete:s}=this.node.presenceContext||{};s&&s(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const sj={animation:{Feature:tj},exit:{Feature:rj}};function Yl(e){return{point:{x:e.pageX,y:e.pageY}}}const ij=e=>t=>Ah(t)&&e(t,Yl(t));function So(e,t,s,i){return jo(e,t,ij(s),i)}const rS=({current:e})=>e?e.ownerDocument.defaultView:null,L0=(e,t)=>Math.abs(e-t);function oj(e,t){const s=L0(e.x,t.x),i=L0(e.y,t.y);return Math.sqrt(s**2+i**2)}const I0=new Set(["auto","scroll"]);class sS{constructor(t,s,{transformPagePoint:i,contextWindow:o=window,dragSnapToOrigin:l=!1,distanceThreshold:u=3,element:d}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=k=>{this.handleScroll(k.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.hasPendingMove=!1,this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=al(this.lastRawMoveEventInfo,this.transformPagePoint));const k=vd(this.lastMoveEventInfo,this.history),E=this.startEvent!==null,T=oj(k.offset,{x:0,y:0})>=this.distanceThreshold;if(!E&&!T)return;const{point:P}=k;this.history.push({...P,timestamp:ut.now()});const{onStart:L,onMove:b}=this.handlers;E||(L&&L(this.lastMoveEvent,k),this.startEvent=this.lastMoveEvent),b&&b(this.lastMoveEvent,k)},this.handlePointerMove=(k,E)=>{this.lastMoveEvent=k,this.lastRawMoveEventInfo=E,this.lastMoveEventInfo=al(E,this.transformPagePoint),this.hasPendingMove=!0,Le.update(this.updatePoint,!0)},this.handlePointerUp=(k,E)=>{this.hasPendingMove&&this.updatePoint(),this.end();const{onEnd:T,onSessionEnd:P,resumeAnimation:L}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&L&&L(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const b=vd(k.type==="pointercancel"?this.lastMoveEventInfo:al(E,this.transformPagePoint),this.history);this.startEvent&&T&&T(k,b),P&&P(k,b)},!Ah(t))return;this.dragSnapToOrigin=l,this.handlers=s,this.transformPagePoint=i,this.distanceThreshold=u,this.contextWindow=o||window;const h=Yl(t),m=al(h,this.transformPagePoint),{point:y}=m,{timestamp:v}=Ze;this.history=[{...y,timestamp:v}];const{onSessionStart:x}=s;x&&x(t,vd(m,this.history));const C={passive:!0,capture:!0};this.removeListeners=Vo(So(this.contextWindow,"pointermove",this.handlePointerMove,C),So(this.contextWindow,"pointerup",this.handlePointerUp,C),So(this.contextWindow,"pointercancel",this.handlePointerUp,C)),d&&this.startScrollTracking(d)}startScrollTracking(t){let s=t.parentElement;for(;s;){const i=getComputedStyle(s);(I0.has(i.overflowX)||I0.has(i.overflowY))&&this.scrollPositions.set(s,{x:s.scrollLeft,y:s.scrollTop}),s=s.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const s=this.scrollPositions.get(t);if(!s)return;const i=t===window,o=i?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},l={x:o.x-s.x,y:o.y-s.y};l.x===0&&l.y===0||(i?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=l.x,this.lastMoveEventInfo.point.y+=l.y):this.history.length>0&&(this.history[0].x-=l.x,this.history[0].y-=l.y),this.scrollPositions.set(t,o),Le.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Mr(this.updatePoint)}}function al(e,t){return t?{point:t(e.point)}:e}function F0(e,t){return{x:e.x-t.x,y:e.y-t.y}}function vd({point:e},t){return{point:e,delta:F0(e,iS(t)),offset:F0(e,aj(t)),velocity:lj(t,.1)}}function aj(e){return e[0]}function iS(e){return e[e.length-1]}function lj(e,t){if(e.length<2)return{x:0,y:0};let s=e.length-1,i=null;const o=iS(e);for(;s>=0&&(i=e[s],!(o.timestamp-i.timestamp>Wt(t)));)s--;if(!i)return{x:0,y:0};i===e[0]&&e.length>2&&o.timestamp-i.timestamp>Wt(t)*2&&(i=e[1]);const l=Ht(o.timestamp-i.timestamp);if(l===0)return{x:0,y:0};const u={x:(o.x-i.x)/l,y:(o.y-i.y)/l};return u.x===1/0&&(u.x=0),u.y===1/0&&(u.y=0),u}function uj(e,{min:t,max:s},i){return t!==void 0&&e<t?e=i?Ae(t,e,i.min):Math.max(e,t):s!==void 0&&e>s&&(e=i?Ae(s,e,i.max):Math.min(e,s)),e}function _0(e,t,s){return{min:t!==void 0?e.min+t:void 0,max:s!==void 0?e.max+s-(e.max-e.min):void 0}}function cj(e,{top:t,left:s,bottom:i,right:o}){return{x:_0(e.x,s,o),y:_0(e.y,t,i)}}function O0(e,t){let s=t.min-e.min,i=t.max-e.max;return t.max-t.min<e.max-e.min&&([s,i]=[i,s]),{min:s,max:i}}function dj(e,t){return{x:O0(e.x,t.x),y:O0(e.y,t.y)}}function fj(e,t){let s=.5;const i=Ct(e),o=Ct(t);return o>i?s=Eo(t.min,t.max-i,e.min):i>o&&(s=Eo(e.min,e.max-o,t.min)),Qn(0,1,s)}function hj(e,t){const s={};return t.min!==void 0&&(s.min=t.min-e.min),t.max!==void 0&&(s.max=t.max-e.min),s}const Ff=.35;function pj(e=Ff){return e===!1?e=0:e===!0&&(e=Ff),{x:V0(e,"left","right"),y:V0(e,"top","bottom")}}function V0(e,t,s){return{min:B0(e,t),max:B0(e,s)}}function B0(e,t){return typeof e=="number"?e:e[t]||0}const mj=new WeakMap;class gj{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=Je(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:s=!1,distanceThreshold:i}={}){const{presenceContext:o}=this.visualElement;if(o&&o.isPresent===!1)return;const l=v=>{s&&this.snapToCursor(v),this.stopAnimation()},u=(v,x)=>{const{drag:C,dragPropagation:k,onDragStart:E}=this.getProps();if(C&&!k&&(this.openDragLock&&this.openDragLock(),this.openDragLock=sb(C),!this.openDragLock))return;this.latestPointerEvent=v,this.latestPanInfo=x,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),kn(P=>{let L=this.getAxisMotionValue(P).get()||0;if(Rn.test(L)){const{projection:b}=this.visualElement;if(b&&b.layout){const M=b.layout.layoutBox[P];M&&(L=Ct(M)*(parseFloat(L)/100))}}this.originPoint[P]=L}),E&&Le.update(()=>E(v,x),!1,!0),jf(this.visualElement,"transform");const{animationState:T}=this.visualElement;T&&T.setActive("whileDrag",!0)},d=(v,x)=>{this.latestPointerEvent=v,this.latestPanInfo=x;const{dragPropagation:C,dragDirectionLock:k,onDirectionLock:E,onDrag:T}=this.getProps();if(!C&&!this.openDragLock)return;const{offset:P}=x;if(k&&this.currentDirection===null){this.currentDirection=vj(P),this.currentDirection!==null&&E&&E(this.currentDirection);return}this.updateAxis("x",x.point,P),this.updateAxis("y",x.point,P),this.visualElement.render(),T&&Le.update(()=>T(v,x),!1,!0)},h=(v,x)=>{this.latestPointerEvent=v,this.latestPanInfo=x,this.stop(v,x),this.latestPointerEvent=null,this.latestPanInfo=null},m=()=>{const{dragSnapToOrigin:v}=this.getProps();(v||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:y}=this.getProps();this.panSession=new sS(t,{onSessionStart:l,onStart:u,onMove:d,onSessionEnd:h,resumeAnimation:m},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:y,distanceThreshold:i,contextWindow:rS(this.visualElement),element:this.visualElement.current})}stop(t,s){const i=t||this.latestPointerEvent,o=s||this.latestPanInfo,l=this.isDragging;if(this.cancel(),!l||!o||!i)return;const{velocity:u}=o;this.startAnimation(u);const{onDragEnd:d}=this.getProps();d&&Le.postRender(()=>d(i,o))}cancel(){this.isDragging=!1;const{projection:t,animationState:s}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:i}=this.getProps();!i&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),s&&s.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,s,i){const{drag:o}=this.getProps();if(!i||!ll(t,o,this.currentDirection))return;const l=this.getAxisMotionValue(t);let u=this.originPoint[t]+i[t];this.constraints&&this.constraints[t]&&(u=uj(u,this.constraints[t],this.elastic[t])),l.set(u)}resolveConstraints(){var l;const{dragConstraints:t,dragElastic:s}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(l=this.visualElement.projection)==null?void 0:l.layout,o=this.constraints;t&&Ks(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&i?this.constraints=cj(i.layoutBox,t):this.constraints=!1,this.elastic=pj(s),o!==this.constraints&&!Ks(t)&&i&&this.constraints&&!this.hasMutatedConstraints&&kn(u=>{this.constraints!==!1&&this.getAxisMotionValue(u)&&(this.constraints[u]=hj(i.layoutBox[u],this.constraints[u]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:s}=this.getProps();if(!t||!Ks(t))return!1;const i=t.current,{projection:o}=this.visualElement;if(!o||!o.layout)return!1;o.root&&(o.root.scroll=void 0,o.root.updateScroll());const l=rb(i,o.root,this.visualElement.getTransformPagePoint());let u=dj(o.layout.layoutBox,l);if(s){const d=s(eb(u));this.hasMutatedConstraints=!!d,d&&(u=kw(d))}return u}startAnimation(t){const{drag:s,dragMomentum:i,dragElastic:o,dragTransition:l,dragSnapToOrigin:u,onDragTransitionEnd:d}=this.getProps(),h=this.constraints||{},m=kn(y=>{if(!ll(y,s,this.currentDirection))return;let v=h&&h[y]||{};(u===!0||u===y)&&(v={min:0,max:0});const x=o?200:1e6,C=o?40:1e7,k={type:"inertia",velocity:i?t[y]:0,bounceStiffness:x,bounceDamping:C,timeConstant:750,restDelta:1,restSpeed:10,...l,...v};return this.startAxisValueAnimation(y,k)});return Promise.all(m).then(d)}startAxisValueAnimation(t,s){const i=this.getAxisMotionValue(t);return jf(this.visualElement,t),i.start(Nh(t,i,0,s,this.visualElement,!1))}stopAnimation(){kn(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const s=`_drag${t.toUpperCase()}`,o=this.visualElement.getProps()[s];return o||this.visualElement.getValue(t,this.visualElement.latestValues[t]??0)}snapToCursor({clientX:t,clientY:s}){var d;const{drag:i}=this.getProps(),o={x:t,y:s},l=((d=this.visualElement.getTransformPagePoint())==null?void 0:d(o))||o,u=this.visualElement.measureViewportBox();kn(h=>{if(!ll(h,i,this.currentDirection))return;const m=this.getAxisMotionValue(h),{min:y,max:v}=u[h];m.set((m.get()||0)+l[h]-Ae(y,v,.5))})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:s}=this.getProps(),{projection:i}=this.visualElement;if(!Ks(s)||!i||!this.constraints)return;this.stopAnimation();const o=this.constraints,l={x:0,y:0};kn(d=>{const h=this.getAxisMotionValue(d).get();l[d]=fj({min:h,max:h},o[d])});const{transformTemplate:u}=this.visualElement.getProps();this.visualElement.current.style.transform=u?u({},""):"none",i.root&&i.root.updateScroll(),i.updateLayout(),this.constraints=!1,this.resolveConstraints(),kn(d=>{const h=this.getAxisMotionValue(d);if(!ll(d,t,null)||!h.get())return;const{min:m,max:y}=this.constraints[d];h.set(Ae(m,y,l[d]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;mj.set(this.visualElement,this);const t=this.visualElement.current,s=So(t,"pointerdown",m=>{const{drag:y,dragListener:v=!0}=this.getProps(),x=m.target,C=x!==t&&cb(x);y&&v&&!C&&this.start(m)});let i;const o=()=>{const{dragConstraints:m}=this.getProps();Ks(m)&&m.current&&(this.constraints=this.resolveRefConstraints(),i||(i=yj(t,m.current,()=>this.scalePositionWithinConstraints())))},{projection:l}=this.visualElement,u=l.addEventListener("measure",o);l&&!l.layout&&(l.root&&l.root.updateScroll(),l.updateLayout()),Le.read(o);const d=jo(window,"resize",()=>this.scalePositionWithinConstraints()),h=l.addEventListener("didUpdate",(({delta:m,hasLayoutChanged:y})=>{this.isDragging&&y&&(kn(v=>{const x=this.getAxisMotionValue(v);x&&(this.originPoint[v]+=m[v].translate,x.set(x.get()+m[v].translate))}),this.visualElement.render())}));return()=>{d(),s(),u(),h&&h(),i&&i()}}getProps(){const t=this.visualElement.getProps(),{drag:s=!1,dragDirectionLock:i=!1,dragPropagation:o=!1,dragConstraints:l=!1,dragElastic:u=Ff,dragMomentum:d=!0}=t;return{...t,drag:s,dragDirectionLock:i,dragPropagation:o,dragConstraints:l,dragElastic:u,dragMomentum:d}}}function z0(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function yj(e,t,s){const i=Zy(e,z0(s)),o=Zy(t,z0(s));return()=>{i(),o()}}function ll(e,t,s){return(t===!0||t===e)&&(s===null||s===e)}function vj(e,t=10){let s=null;return Math.abs(e.y)>t?s="y":Math.abs(e.x)>t&&(s="x"),s}class xj extends Ar{constructor(t){super(t),this.removeGroupControls=dn,this.removeListeners=dn,this.controls=new gj(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||dn}update(){const{dragControls:t}=this.node.getProps(),{dragControls:s}=this.node.prevProps||{};t!==s&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const xd=e=>(t,s)=>{e&&Le.update(()=>e(t,s),!1,!0)};class wj extends Ar{constructor(){super(...arguments),this.removePointerDownListener=dn}onPointerDown(t){this.session=new sS(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:rS(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:s,onPan:i,onPanEnd:o}=this.node.getProps();return{onSessionStart:xd(t),onStart:xd(s),onMove:xd(i),onEnd:(l,u)=>{delete this.session,o&&Le.postRender(()=>o(l,u))}}}mount(){this.removePointerDownListener=So(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 wd=!1;class Sj extends S.Component{componentDidMount(){const{visualElement:t,layoutGroup:s,switchLayoutGroup:i,layoutId:o}=this.props,{projection:l}=t;l&&(s.group&&s.group.add(l),i&&i.register&&o&&i.register(l),wd&&l.root.didUpdate(),l.addEventListener("animationComplete",()=>{this.safeToRemove()}),l.setOptions({...l.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),El.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:s,visualElement:i,drag:o,isPresent:l}=this.props,{projection:u}=i;return u&&(u.isPresent=l,t.layoutDependency!==s&&u.setOptions({...u.options,layoutDependency:s}),wd=!0,o||t.layoutDependency!==s||s===void 0||t.isPresent!==l?u.willUpdate():this.safeToRemove(),t.isPresent!==l&&(l?u.promote():u.relegate()||Le.postRender(()=>{const d=u.getStack();(!d||!d.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:s}=this.props,{projection:i}=t;i&&(i.options.layoutAnchor=s,i.root.didUpdate(),Dh.postRender(()=>{!i.currentAnimation&&i.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:s,switchLayoutGroup:i}=this.props,{projection:o}=t;wd=!0,o&&(o.scheduleCheckAfterUnmount(),s&&s.group&&s.group.remove(o),i&&i.deregister&&i.deregister(o))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function oS(e){const[t,s]=Gw(),i=S.useContext(lh);return p.jsx(Sj,{...e,layoutGroup:i,switchLayoutGroup:S.useContext(tS),isPresent:t,safeToRemove:s})}const kj={pan:{Feature:wj},drag:{Feature:xj,ProjectionNode:Qw,MeasureLayout:oS}};function U0(e,t,s){const{props:i}=e;e.animationState&&i.whileHover&&e.animationState.setActive("whileHover",s==="Start");const o="onHover"+s,l=i[o];l&&Le.postRender(()=>l(t,Yl(t)))}class Cj extends Ar{mount(){const{current:t}=this.node;t&&(this.unmount=ob(t,(s,i)=>(U0(this.node,i,"Start"),o=>U0(this.node,o,"End"))))}unmount(){}}class Ej extends Ar{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=Vo(jo(this.node.current,"focus",()=>this.onFocus()),jo(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function $0(e,t,s){const{props:i}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&i.whileTap&&e.animationState.setActive("whileTap",s==="Start");const o="onTap"+(s==="End"?"":s),l=i[o];l&&Le.postRender(()=>l(t,Yl(t)))}class Tj extends Ar{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:s,propagate:i}=this.node.props;this.unmount=fb(t,(o,l)=>($0(this.node,l,"Start"),(u,{success:d})=>$0(this.node,u,d?"End":"Cancel")),{useGlobalTarget:s,stopPropagation:(i==null?void 0:i.tap)===!1})}unmount(){}}const _f=new WeakMap,Sd=new WeakMap,Pj=e=>{const t=_f.get(e.target);t&&t(e)},Nj=e=>{e.forEach(Pj)};function bj({root:e,...t}){const s=e||document;Sd.has(s)||Sd.set(s,{});const i=Sd.get(s),o=JSON.stringify(t);return i[o]||(i[o]=new IntersectionObserver(Nj,{root:e,...t})),i[o]}function Rj(e,t,s){const i=bj(t);return _f.set(e,s),i.observe(e),()=>{_f.delete(e),i.unobserve(e)}}const jj={some:0,all:1};class Mj extends Ar{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var h;(h=this.stopObserver)==null||h.call(this);const{viewport:t={}}=this.node.getProps(),{root:s,margin:i,amount:o="some",once:l}=t,u={root:s?s.current:void 0,rootMargin:i,threshold:typeof o=="number"?o:jj[o]},d=m=>{const{isIntersecting:y}=m;if(this.isInView===y||(this.isInView=y,l&&!y&&this.hasEnteredView))return;y&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",y);const{onViewportEnter:v,onViewportLeave:x}=this.node.getProps(),C=y?v:x;C&&C(m)};this.stopObserver=Rj(this.node.current,u,d)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:s}=this.node;["amount","margin","root"].some(Dj(t,s))&&this.startObserver()}unmount(){var t;(t=this.stopObserver)==null||t.call(this),this.hasEnteredView=!1,this.isInView=!1}}function Dj({viewport:e={}},{viewport:t={}}={}){return s=>e[s]!==t[s]}const Aj={inView:{Feature:Mj},tap:{Feature:Tj},focus:{Feature:Ej},hover:{Feature:Cj}},Lj={layout:{ProjectionNode:Qw,MeasureLayout:oS}},Ij={...sj,...Aj,...kj,...Lj},Fj=ZR(Ij,ej);function mn(){!Ih.current&&Mw();const[e]=S.useState(Fl.current);return e}const Qt=Fj;function _j(e,t){const[s,i]=S.useState(e);return S.useEffect(()=>{const o=window.setTimeout(()=>i(e),t);return()=>window.clearTimeout(o)},[e,t]),s}const aS=S.createContext(null);function Xl(){const e=S.useContext(aS);if(e===null)throw new Error("useDriveShell must be used within the drive layout");return e}function Oj(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable}function Vj(e,t=!0){const s=S.useRef(e);s.current=e,S.useEffect(()=>{if(!t)return;const i=o=>{const l=o.ctrlKey||o.metaKey,u=Oj(o.target),d=s.current;if(l&&o.key.toLowerCase()==="k"){o.preventDefault(),d.onSearch();return}if(l&&o.key.toLowerCase()==="a"){if(u)return;o.preventDefault(),d.onSelectAll();return}if(o.key==="Escape"){d.onEscape();return}if(!u){if(o.key==="Delete"||o.key==="Backspace"){o.preventDefault(),d.onDelete();return}if(o.key==="Enter"){d.onEnter();return}o.key==="?"&&(o.preventDefault(),d.onHelp())}};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[t])}const Uo=["me"],Bh=["folders","tree"],Bj=["storage","stats"],lS={user:null,storage:null,health:null};function ms(e){e.invalidateQueries({queryKey:["files"]}),e.invalidateQueries({queryKey:["folders"]}),e.invalidateQueries({queryKey:["trash"]}),e.invalidateQueries({queryKey:["starred"]}),e.invalidateQueries({queryKey:["recent"]}),e.invalidateQueries({queryKey:["search"]}),e.invalidateQueries({queryKey:["activity"]}),e.invalidateQueries({queryKey:["subtree-files"]}),e.invalidateQueries({queryKey:["storage"]})}function zj(e,t){e.invalidateQueries({queryKey:["versions",t]})}function zh(){return Dr({queryKey:Uo,queryFn:we.auth.me})}function H0(e){return typeof e=="object"&&e!==null}function Uj(e,t){let s=null;try{s=JSON.parse(t)}catch{}if(H0(s)&&H0(s.file)){const i=s.file;if(typeof i.id=="string"&&typeof i.name=="string")return i}throw new Rr(e,"UNKNOWN","The server returned an unexpected response")}function uS(e,t,s,i){return new Promise((o,l)=>{const u=new XMLHttpRequest;u.open("POST",e);const d=new FormData;d.append("file",t,t.name),s!==null&&d.append("folderId",s),i.operationId&&d.append("operationId",i.operationId),u.upload.addEventListener("progress",m=>{var v;if(!m.lengthComputable)return;const y=Math.min(100,Math.round(m.loaded/m.total*100));(v=i.onProgress)==null||v.call(i,{loaded:m.loaded,total:m.total,percent:y})}),u.addEventListener("load",()=>{if(u.status>=200&&u.status<300){try{o(Uj(u.status,u.responseText))}catch(y){l(y)}return}const m=C1(u.status,u.responseText);u.status===401&&m.code!=="TELEGRAM_AUTH_REQUIRED"&&k1(),l(m)}),u.addEventListener("error",()=>{l(new Rr(0,"NETWORK_ERROR","Could not reach the server. Check your connection and try again."))}),u.addEventListener("abort",()=>{l(new Rr(0,"ABORTED","Upload cancelled"))});const h=i.signal;if(h!==void 0){if(h.aborted){l(new Rr(0,"ABORTED","Upload cancelled"));return}h.addEventListener("abort",()=>u.abort(),{once:!0})}u.send(d)})}function $j(e,t,s={}){return uS("/api/files",e,t,s)}function Hj(e,t,s={}){return uS(`/api/files/${encodeURIComponent(t)}/replace`,e,null,s)}const cS=S.createContext(null),Kj=4e3;function Wj({children:e}){const[t,s]=S.useState([]),i=mn(),o=S.useRef(new Set),l=S.useRef(0);S.useEffect(()=>{const y=o.current;return()=>{for(const v of y)window.clearTimeout(v)}},[]);const u=S.useCallback(y=>{s(v=>v.filter(x=>x.id!==y))},[]),d=S.useCallback((y,v)=>{const x=l.current;l.current+=1,s(k=>[...k,{id:x,kind:y,message:v}]);const C=window.setTimeout(()=>{o.current.delete(C),u(x)},Kj);o.current.add(C)},[u]),h=S.useMemo(()=>({success:y=>d("success",y),error:y=>d("error",y)}),[d]),m=i?0:16;return p.jsxs(cS.Provider,{value:h,children:[e,p.jsx("div",{"aria-live":"polite",className:"pointer-events-none fixed top-4 right-4 z-[200] flex w-80 max-w-[calc(100vw-2rem)] flex-col gap-2",children:p.jsx(Lr,{children:t.map(y=>p.jsxs(Qt.div,{role:y.kind==="error"?"alert":"status",initial:{opacity:0,x:m},animate:{opacity:1,x:0},exit:{opacity:0,x:m},transition:{duration:.18,ease:"easeOut"},className:"glass-strong pointer-events-auto flex items-start gap-2.5 rounded-xl border border-line px-4 py-3 text-[13px]",children:[y.kind==="error"?p.jsx(hT,{className:"mt-0.5 h-4 w-4 shrink-0 text-bad","aria-hidden":"true"}):p.jsx(sh,{className:"mt-0.5 h-4 w-4 shrink-0 text-gold-text","aria-hidden":"true"}),p.jsx("p",{className:"min-w-0 flex-1 break-words",children:y.message}),p.jsx("button",{type:"button","aria-label":"Dismiss notification",onClick:()=>u(y.id),className:"muted rounded p-0.5 transition-colors hover:bg-bg-soft hover:text-gold-text",children:p.jsx(cn,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]},y.id))})})]})}function gs(){const e=S.useContext(cS);if(e===null)throw new Error("useToast must be used within a ToastProvider");return e}let ul=0;function K0(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`op-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}function qj(){const e=fn(),t=gs(),[s,i]=S.useState([]),o=S.useRef(new Map),l=S.useRef(new Map),u=S.useRef(Promise.resolve()),d=S.useRef(new Set),h=S.useRef(!0),m=S.useRef(null),y=S.useRef(null);S.useEffect(()=>{const I=d.current,R=l.current;return()=>{h.current=!1;for(const D of I)window.clearTimeout(D);for(const D of R.values())D.abort()}},[]);const v=S.useCallback(I=>{const R=window.setTimeout(()=>{d.current.delete(R),i(D=>D.filter(B=>B.id!==I)),o.current.delete(I)},5e3);d.current.add(R)},[]),x=S.useCallback(async I=>{const R=new AbortController;l.current.set(I.id,R);try{const D={signal:R.signal,onProgress:({loaded:W,total:G,percent:K})=>{i(U=>U.map(X=>X.id===I.id?{...X,loaded:W,size:G||X.size,percent:K}:X))}},B=I.replaceId===null?await $j(I.file,I.folderId,{...D,operationId:I.operationId}):await Hj(I.file,I.replaceId,{...D,operationId:I.operationId});if(!h.current)return;i(W=>W.map(G=>G.id===I.id?{...G,status:"done",percent:100}:G)),ms(e),I.replaceId!==null&&zj(e,I.replaceId),t.success(I.replaceId===null?`Uploaded "${B.name}"`:`Replaced "${B.name}"`),v(I.id)}catch(D){if(!h.current)return;const B=ze(D,"Upload failed"),W=B==="Upload cancelled";i(G=>G.map(K=>K.id===I.id?{...K,status:W?"cancelled":"error",message:B}:K)),W||t.error(`Could not upload "${I.file.name}": ${B}`)}finally{l.current.delete(I.id)}},[e,v,t]),C=S.useCallback(I=>{o.current.set(I.id,I),i(R=>[...R,{id:I.id,name:I.file.name,size:I.file.size,loaded:0,percent:0,status:"uploading"}]),u.current=u.current.then(()=>x(I))},[x]),k=S.useCallback((I,R)=>{for(const D of I)ul+=1,C({id:ul,file:D,replaceId:null,folderId:R,operationId:K0()})},[C]),E=S.useCallback((I,R)=>{ul+=1,C({id:ul,file:I,replaceId:R,folderId:null,operationId:K0()})},[C]),T=S.useCallback(I=>{var R;(R=l.current.get(I))==null||R.abort()},[]),P=S.useCallback(I=>{const R=o.current.get(I);R!==void 0&&(i(D=>D.map(B=>B.id===I?{...B,status:"uploading",percent:0,loaded:0,message:void 0}:B)),u.current=u.current.then(()=>x(R)))},[x]),L=S.useCallback(I=>{var R;(R=l.current.get(I))==null||R.abort(),o.current.delete(I),i(D=>D.filter(B=>B.id!==I))},[]),b=S.useCallback(()=>{i(I=>{for(const R of I)R.status!=="uploading"&&o.current.delete(R.id);return I.filter(R=>R.status==="uploading")})},[]),M=S.useCallback(I=>{var R;y.current=I,(R=m.current)==null||R.click()},[]),_=S.useCallback(()=>{const I=m.current;if(I===null)return;const R=Array.from(I.files??[]);I.value="",R.length>0&&k(R,y.current)},[k]);return{uploads:s,enqueue:k,replace:E,cancel:T,retry:P,dismiss:L,clearFinished:b,openPicker:M,pickerInputRef:m,onPickerChange:_}}function $o({title:e,onClose:t,children:s}){const i=S.useRef(null),o=S.useId(),l=mn();return S.useEffect(()=>{const u=d=>{d.key==="Escape"&&t()};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[t]),S.useEffect(()=>{const u=i.current;u!==null&&(u.contains(document.activeElement)||u.focus())},[]),p.jsx("div",{className:"fixed inset-0 z-[150] flex items-center justify-center bg-black/50 p-4 backdrop-blur-sm",onMouseDown:u=>{u.target===u.currentTarget&&t()},children:p.jsxs(Qt.div,{ref:i,role:"dialog","aria-modal":"true","aria-labelledby":o,tabIndex:-1,initial:l?{opacity:0}:{opacity:0,y:-12,scale:.97},animate:{opacity:1,y:0,scale:1},transition:{duration:.18,ease:"easeOut"},className:"glass-strong w-full max-w-md rounded-2xl border border-line p-6 outline-none",children:[p.jsxs("div",{className:"mb-4 flex items-start justify-between gap-4",children:[p.jsx("h2",{id:o,className:"text-[15px] font-semibold",children:e}),p.jsx("button",{type:"button","aria-label":"Close dialog",onClick:t,className:"muted grid h-8 w-8 shrink-0 place-items-center rounded-lg transition-colors hover:bg-bg-soft hover:text-gold-text",children:p.jsx(cn,{className:"h-4 w-4","aria-hidden":"true"})})]}),s]})})}function dS({title:e,label:t,confirmLabel:s,initialValue:i,pending:o,onSubmit:l,onClose:u}){const[d,h]=S.useState(i),m=S.useId(),y=d.trim(),v=y===i.trim(),x=C=>{C.preventDefault(),!(o||y===""||v)&&l(y)};return p.jsx($o,{title:e,onClose:u,children:p.jsxs("form",{onSubmit:x,noValidate:!0,children:[p.jsxs("label",{htmlFor:m,className:"grid gap-1.5",children:[p.jsx("span",{className:"text-[13px] font-medium",children:t}),p.jsx("input",{id:m,type:"text",autoFocus:!0,value:d,maxLength:255,disabled:o,onFocus:C=>C.target.select(),onChange:C=>h(C.target.value),className:"input"})]}),p.jsxs("div",{className:"mt-5 flex justify-end gap-2.5",children:[p.jsx("button",{type:"button",className:"btn-ghost",onClick:u,disabled:o,children:"Cancel"}),p.jsxs("button",{type:"submit",className:"btn-gold",disabled:o||y===""||v,children:[o&&p.jsx(kt,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}),o?"Saving…":s]})]})]})})}const W0=["B","KB","MB","GB","TB","PB"];function jt(e){if(!Number.isFinite(e)||e<=0)return"0 B";let t=e,s=0;for(;t>=1024&&s<W0.length-1;)t/=1024,s+=1;const i=W0[s]??"B";return s===0?`${Math.round(t)} ${i}`:`${t.toFixed(1)} ${i}`}function Qj(e){const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function Ys(e){const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}const Gj=[{limit:60,divisor:1,unit:"second"},{limit:3600,divisor:60,unit:"minute"},{limit:86400,divisor:3600,unit:"hour"},{limit:604800,divisor:86400,unit:"day"},{limit:2629800,divisor:604800,unit:"week"},{limit:31557600,divisor:2629800,unit:"month"}];function Of(e,t=new Date){const s=new Date(e);if(Number.isNaN(s.getTime()))return"";const i=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"}),o=(s.getTime()-t.getTime())/1e3,l=Math.abs(o);for(const{limit:u,divisor:d,unit:h}of Gj)if(l<u)return i.format(Math.round(o/d),h);return i.format(Math.round(o/31557600),"year")}function Nn(e,t){return`${e} ${t}${e===1?"":"s"}`}function Yj(e,t=new Date){const s=new Date(e);if(Number.isNaN(s.getTime()))return"Unknown";const i=l=>new Date(l.getFullYear(),l.getMonth(),l.getDate()).getTime(),o=Math.round((i(t)-i(s))/864e5);return o<=0?"Today":o===1?"Yesterday":s.toLocaleDateString(void 0,{month:"long",day:"numeric",year:"numeric"})}const Xj={image:ST,video:xT,audio:bT,archive:yT,pdf:sd,text:sd,document:sd,other:vT},Jj={image:"Image",video:"Video",audio:"Audio",archive:"Archive",pdf:"PDF",text:"Text",document:"Document",other:"File"},Zj={image:"text-gold-text",video:"muted",audio:"muted",archive:"muted",pdf:"muted",text:"muted",document:"muted",other:"muted"};function Kn(e){const t=AT(e);return{Icon:Xj[t],label:Jj[t],color:Zj[t]}}function Ci(e){return{kind:"file",id:e.id,name:e.name,size:e.size,mimeType:e.mimeType,starred:e.starred,trashed:e.trashed,deletedAt:e.deletedAt,createdAt:e.createdAt,updatedAt:e.updatedAt,versionCount:e.versionCount,file:e,folder:null}}function Uh(e){return{kind:"folder",id:e.id,name:e.name,size:0,mimeType:"",starred:e.starred,trashed:e.trashed,deletedAt:e.deletedAt,createdAt:e.createdAt,updatedAt:e.updatedAt,versionCount:0,file:null,folder:e}}function cl(e){return{kind:e.kind,id:e.id}}function ln(e){return`${e.kind}:${e.id}`}function $h(e){return e==="list"||e==="grid"}function Hh({label:e="Loading"}){return p.jsx("div",{role:"status","aria-label":e,className:"mt-10 flex justify-center",children:p.jsx(kt,{className:"h-6 w-6 animate-spin text-gold","aria-hidden":"true"})})}const eM="Try type:pdf size:>100MB folder:Projects starred:true after:2026-01-01";function q0({icon:e,label:t,meta:s,onSelect:i}){return p.jsx("li",{children:p.jsxs("button",{type:"button",onClick:i,className:"flex w-full items-center gap-3 rounded-xl border border-transparent px-3 py-2.5 text-left transition-colors hover:border-gold/40 hover:bg-bg-soft",children:[e,p.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",title:t,children:t}),p.jsx("span",{className:"muted shrink-0 text-[12px]",children:s})]})})}function tM({query:e,onClose:t,onOpenFolder:s,onOpenFile:i}){var m,y;const o=mn(),l=Dr({queryKey:["search",e],queryFn:()=>we.search.query(e),enabled:e!=="",placeholderData:Mk});S.useEffect(()=>{const v=x=>{x.key==="Escape"&&t()};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[t]);const u=((m=l.data)==null?void 0:m.folders)??[],d=((y=l.data)==null?void 0:y.files)??[],h=u.length===0&&d.length===0;return p.jsx("div",{className:"fixed inset-0 z-[95] flex justify-center bg-black/40 p-4 pt-20",onMouseDown:v=>{v.target===v.currentTarget&&t()},children:p.jsxs(Qt.div,{role:"dialog","aria-modal":"true","aria-label":`Search results for ${e}`,initial:o?{opacity:0}:{opacity:0,y:-10},animate:{opacity:1,y:0},transition:{duration:.18,ease:"easeOut"},className:"glass-strong flex max-h-[70dvh] w-full max-w-2xl flex-col overflow-hidden rounded-2xl border border-line",children:[p.jsxs("header",{className:"flex items-center gap-3 border-b border-line/70 px-5 py-4",children:[p.jsx(h1,{className:"h-4 w-4 shrink-0 text-gold","aria-hidden":"true"}),p.jsxs("h2",{className:"min-w-0 flex-1 truncate text-[14px] font-semibold",children:["Results for “",e,"”"]}),p.jsx("button",{type:"button","aria-label":"Close search",onClick:t,className:"muted grid h-8 w-8 shrink-0 place-items-center rounded-lg transition-colors hover:bg-bg-soft hover:text-gold-text",children:p.jsx(cn,{className:"h-4 w-4","aria-hidden":"true"})})]}),p.jsx("p",{className:"muted border-b border-line/70 px-5 py-2 font-mono text-[11.5px]",children:eM}),p.jsx("div",{className:"flex-1 overflow-y-auto p-3",children:l.isPending?p.jsx(Hh,{label:"Searching"}):l.error!==null?p.jsx("p",{role:"alert",className:"notice notice-error",children:ze(l.error,"The search failed.")}):h?p.jsxs("div",{className:"flex flex-col items-center py-12 text-center",children:[p.jsx(jT,{className:"h-7 w-7 text-gold","aria-hidden":"true"}),p.jsxs("p",{className:"muted mt-3 text-sm",children:["No matches for “",e,"”."]})]}):p.jsxs(p.Fragment,{children:[u.length>0?p.jsxs("section",{className:"mb-3",children:[p.jsx("h3",{className:"eyebrow mb-2",children:"Folders"}),p.jsx("ul",{className:"grid gap-0.5",children:u.map(v=>p.jsx(q0,{icon:p.jsx(wi,{className:"h-4 w-4 shrink-0 text-gold","aria-hidden":"true"}),label:v.name,meta:"Folder",onSelect:()=>s(v)},v.id))})]}):null,d.length>0?p.jsxs("section",{children:[p.jsx("h3",{className:"eyebrow mb-2",children:"Files"}),p.jsx("ul",{className:"grid gap-0.5",children:d.map(v=>{const{Icon:x,color:C,label:k}=Kn(v.mimeType);return p.jsx(q0,{icon:p.jsx(x,{className:`h-4 w-4 shrink-0 ${C}`,"aria-hidden":"true"}),label:v.name,meta:`${jt(v.size)} · ${k}`,onSelect:()=>i(Ci(v))},v.id)})})]}):null]})})]})})}const nM=[{keys:"Ctrl/⌘ K",label:"Focus search"},{keys:"Enter",label:"Open the focused item"},{keys:"Delete",label:"Move selection to Trash"},{keys:"Ctrl/⌘ A",label:"Select all visible items"},{keys:"Esc",label:"Clear selection / close panels"},{keys:"Shift-click",label:"Select a range of items"},{keys:"Ctrl/⌘-click",label:"Add or remove one item"},{keys:"Click the ⋯",label:"Item actions menu"},{keys:"Right-click",label:"Context menu"},{keys:"?",label:"Show this help"}];function rM({onClose:e}){return p.jsx($o,{title:"Keyboard shortcuts",onClose:e,children:p.jsx("dl",{className:"grid gap-2",children:nM.map(t=>p.jsxs("div",{className:"flex items-center justify-between gap-4",children:[p.jsx("dt",{className:"muted text-[13px]",children:t.label}),p.jsx("dd",{children:p.jsx("kbd",{className:"rounded-md border border-line-strong bg-surface px-2 py-1 font-mono text-[12px]",children:t.keys})})]},t.keys))})})}const sM={DISCONNECTED:"Disconnected",CONNECTING:"Connecting",CONNECTED:"Connected",RECONNECTING:"Reconnecting",ERROR:"Connection error",AUTH_REQUIRED:"Reconnect required"};function iM(e){if(e===null)return{tone:"text-muted",label:"Unknown",usable:!1,hint:null};const t=sM[e.state];return e.state==="AUTH_REQUIRED"?{tone:"text-bad",label:t,usable:!1,hint:e.message??"Reconnect Telegram in Settings to keep syncing."}:e.state==="ERROR"||e.status==="unavailable"?{tone:"text-bad",label:t,usable:!1,hint:e.message??"The storage backend is unavailable right now."}:e.state==="CONNECTED"&&e.status==="healthy"?{tone:"text-ok",label:t,usable:!0,hint:null}:{tone:"text-gold-text",label:t,usable:e.state==="CONNECTED"||e.state==="CONNECTING"||e.state==="RECONNECTING",hint:e.message}}const oM=[{id:"drive",label:"My Drive",path:"/",icon:wT,regionLabel:"My Drive"},{id:"recent",label:"Recent",path:"/recent",icon:Ix,regionLabel:"Recent files"},{id:"starred",label:"Starred",path:"/starred",icon:ps,regionLabel:"Starred items"},{id:"trash",label:"Trash",path:"/trash",icon:br,regionLabel:"Trash"},{id:"storage",label:"Storage",path:"/storage",icon:ko,regionLabel:"Storage"}];function aM({tone:e,label:t}){return p.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[p.jsx("span",{className:`h-2 w-2 shrink-0 rounded-full bg-current ${e}`,"aria-hidden":"true"}),p.jsx("span",{className:`text-[11px] font-medium ${e}`,children:t})]})}function Q0({storage:e,health:t,username:s,onCreateFolder:i,onClose:o}){const l=iM(t);return p.jsxs("div",{className:"flex h-full flex-col bg-bg-soft",children:[p.jsxs("div",{className:"flex items-center justify-between px-4 pt-4 pb-2",children:[p.jsx("span",{className:"eyebrow",children:"Drive"}),o!==void 0?p.jsx("button",{type:"button","aria-label":"Close navigation",onClick:o,className:"muted grid h-8 w-8 place-items-center rounded-lg transition-colors hover:bg-surface hover:text-gold-text md:hidden",children:p.jsx(cn,{className:"h-4 w-4","aria-hidden":"true"})}):null]}),p.jsx("nav",{"aria-label":"Main",className:"px-3",children:p.jsx("ul",{className:"grid gap-0.5",children:oM.map(u=>{const d=u.icon;return p.jsx("li",{children:p.jsxs(kx,{to:u.path,end:u.path==="/",onClick:()=>o==null?void 0:o(),className:({isActive:h})=>`flex items-center gap-2.5 rounded-lg px-3 py-2 text-sm transition-colors ${h?"bg-surface font-medium text-gold-text":"muted hover:bg-surface hover:text-gold-text"}`,children:[p.jsx(d,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),u.label]})},u.id)})})}),p.jsx("div",{className:"px-3 pt-3",children:p.jsxs("button",{type:"button",className:"btn-secondary w-full justify-center",onClick:i,children:[p.jsx(Gx,{className:"h-4 w-4","aria-hidden":"true"}),"New folder"]})}),p.jsx("div",{className:"mt-auto p-3",children:p.jsxs("div",{className:"rounded-2xl border border-line bg-surface p-4",children:[p.jsxs("div",{className:"flex items-center gap-2.5",children:[p.jsx(Ox,{className:"h-5 w-5 shrink-0 text-gold","aria-hidden":"true"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",title:(e==null?void 0:e.title)??void 0,children:(e==null?void 0:e.title)??"No storage"})]}),p.jsx("div",{className:"mt-2",children:t!==null?p.jsx(aM,{tone:l.tone,label:l.label}):p.jsx("span",{className:"muted text-[11px]",children:"Status unknown"})}),l.hint!==null?p.jsx("p",{className:`mt-1.5 text-[11px] leading-snug ${l.tone}`,children:l.hint}):null,p.jsxs("p",{className:"muted mt-2 flex items-center gap-1.5 font-mono text-[11px] uppercase tracking-wide",children:[p.jsx(ko,{className:"h-3 w-3","aria-hidden":"true"}),(e==null?void 0:e.provider)??"—"]}),p.jsx("div",{className:"hairline mt-3"}),s!==null&&s!==""?p.jsxs("p",{className:"muted mt-2.5 truncate font-mono text-[11px] select-all",children:["@",s]}):null]})})]})}const G0="omnicloud:theme-changed";function lM(e){const t=s=>e(s.detail);return window.addEventListener(G0,t),()=>window.removeEventListener(G0,t)}const uM=450;function cM(){return document.documentElement.dataset.theme==="light"?"light":"dark"}function dM({size:e=16}){return p.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[p.jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"}),p.jsx("path",{d:"M20 2 21.1 3.9 23 5 21.1 6.1 20 8 18.9 6.1 17 5 18.9 3.9Z"})]})}function fM({size:e=16}){return p.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[p.jsx("circle",{cx:"12",cy:"12",r:"3.6"}),p.jsx("path",{d:"M12 1.6 13.6 4.6 12 7.6 10.4 4.6Z"}),p.jsx("path",{d:"M12 16.4 13.6 19.4 12 22.4 10.4 19.4Z"}),p.jsx("path",{d:"M1.6 12 4.6 10.4 7.6 12 4.6 13.6Z"}),p.jsx("path",{d:"M16.4 12 19.4 10.4 22.4 12 19.4 13.6Z"})]})}function fS({compact:e=!1}){const[t,s]=S.useState(cM),i=mn();S.useEffect(()=>lM(s),[]);const o=S.useRef(void 0);S.useEffect(()=>{document.documentElement.dataset.theme=t;try{localStorage.setItem("omnicloud-theme",t)}catch{}},[t]),S.useEffect(()=>()=>window.clearTimeout(o.current),[]);const l=t==="dark"?"light":"dark";function u(){if(!i){const m=document.documentElement;m.classList.add("theme-anim"),window.clearTimeout(o.current),o.current=window.setTimeout(()=>m.classList.remove("theme-anim"),uM)}s(l)}const d=e?15:16,h=t==="light"?p.jsx(dM,{size:d}):p.jsx(fM,{size:d});return p.jsx("button",{type:"button",onClick:u,"aria-label":`Switch to ${l} theme`,title:`Switch to ${l} theme`,className:`theme-toggle relative grid place-items-center rounded-full ${e?"h-7 w-7":"h-9 w-9"}`,children:i?h:p.jsx(Lr,{mode:"wait",initial:!1,children:p.jsx(Qt.span,{className:"grid place-items-center",initial:{opacity:0,scale:.4,rotate:-120},animate:{opacity:1,scale:1,rotate:0,transition:{duration:.3,ease:[.34,1.56,.64,1]}},exit:{opacity:0,scale:.4,rotate:120,transition:{duration:.15,ease:"easeIn"}},children:h},t)})})}function hM({storage:e,displayName:t,username:s,search:i,onUpload:o,onToggleSidebar:l,onOpenHelp:u,onSignOut:d,signingOut:h}){const[m,y]=S.useState(!1),v=mn(),x=t.charAt(0).toUpperCase()||"?",C=S.useCallback(()=>y(!1),[]);S.useEffect(()=>{if(!m)return;const T=L=>{var b,M;(M=(b=L.target).closest)!=null&&M.call(b,"[data-account-menu]")||y(!1)},P=L=>{L.key==="Escape"&&y(!1)};return document.addEventListener("pointerdown",T),document.addEventListener("keydown",P),()=>{document.removeEventListener("pointerdown",T),document.removeEventListener("keydown",P)}},[m]);const k=v?0:-6,E=S.useId();return p.jsxs("header",{className:"nav-blur sticky top-0 z-50 flex h-14 shrink-0 items-center gap-3 border-b border-line/70 px-4 md:px-6",children:[p.jsx("button",{type:"button","aria-label":"Open navigation",onClick:l,className:"muted grid h-9 w-9 shrink-0 place-items-center rounded-lg transition-colors hover:bg-surface hover:text-gold-text md:hidden",children:p.jsx(NT,{className:"h-5 w-5","aria-hidden":"true"})}),p.jsxs("a",{href:"/",className:"flex shrink-0 items-center gap-2.5 text-[15px] font-semibold tracking-tight",children:[p.jsx("span",{className:"text-lg leading-none text-gold",children:"◈"}),p.jsxs("span",{className:"hidden sm:inline",children:["Omni",p.jsx("span",{className:"muted font-normal",children:"Cloud"})]})]}),p.jsxs("div",{className:"relative ml-1 min-w-0 max-w-md flex-1",children:[p.jsx("label",{htmlFor:E,className:"sr-only",children:"Search files and folders"}),p.jsx(h1,{className:"muted pointer-events-none absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2","aria-hidden":"true"}),p.jsx("input",{id:E,ref:i.inputRef,type:"search",placeholder:"Search (Ctrl/⌘K)",value:i.value,onChange:T=>i.onChange(T.target.value),className:"input h-9 rounded-full py-0 pl-9"})]}),p.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2.5",children:[p.jsx("button",{type:"button",onClick:u,"aria-label":"Keyboard shortcuts",title:"Keyboard shortcuts (?)",className:"muted hidden h-9 w-9 place-items-center rounded-full border border-line-strong bg-surface transition-colors hover:border-gold hover:text-gold-text sm:grid",children:p.jsx(CT,{className:"h-4 w-4","aria-hidden":"true"})}),p.jsxs("button",{type:"button",className:"btn-gold hidden px-3.5 py-2 text-[13px] sm:inline-flex",onClick:o,children:[p.jsx(bl,{className:"h-4 w-4","aria-hidden":"true"}),"Upload"]}),p.jsx(fS,{}),p.jsxs("div",{className:"relative","data-account-menu":!0,children:[p.jsx("button",{type:"button","aria-label":"Account","aria-haspopup":"menu","aria-expanded":m,onClick:()=>y(T=>!T),className:"muted flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-line-strong bg-surface text-sm font-semibold transition-colors hover:border-gold hover:text-gold-text",children:x}),p.jsx(Lr,{children:m?p.jsxs(Qt.div,{initial:{opacity:0,y:k},animate:{opacity:1,y:0},exit:{opacity:0,y:k},transition:{duration:.15,ease:"easeOut"},className:"menu-panel absolute top-full right-0 z-50 mt-2 w-60",children:[p.jsxs("div",{className:"border-b border-line/70 px-3 py-2.5",children:[p.jsx("p",{className:"truncate text-[13px] font-semibold",children:t}),p.jsx("p",{className:"muted truncate text-[12px]",children:s!==null&&s!==""?`@${s}`:"Telegram account"})]}),p.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2",children:[p.jsx(ko,{className:"h-4 w-4 shrink-0 text-gold","aria-hidden":"true"}),p.jsxs("span",{className:"min-w-0 flex-1",children:[p.jsx("span",{className:"block truncate text-[13px] font-medium",title:(e==null?void 0:e.title)??void 0,children:(e==null?void 0:e.title)??"No storage"}),p.jsx("span",{className:"muted block truncate text-[11px] uppercase tracking-wide",children:(e==null?void 0:e.provider)??"—"})]})]}),p.jsxs("button",{type:"button",onClick:()=>{C(),d()},disabled:h,className:"menu-item menu-item-danger",children:[p.jsx(PT,{className:"h-4 w-4","aria-hidden":"true"}),h?"Signing out...":"Sign out"]})]},"account-menu"):null})]})]})]})}function pM(e){return e==="uploading"?p.jsx(kt,{className:"h-4 w-4 shrink-0 animate-spin text-gold-text","aria-hidden":"true"}):e==="done"?p.jsx(sh,{className:"h-4 w-4 shrink-0 text-ok","aria-hidden":"true"}):e==="cancelled"?p.jsx(cn,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):p.jsx(cn,{className:"h-4 w-4 shrink-0 text-bad","aria-hidden":"true"})}function mM({uploads:e,onCancel:t,onRetry:s,onDismiss:i,onClearFinished:o}){if(e.length===0)return null;const l=e.some(u=>u.status!=="uploading");return p.jsxs("section",{"aria-label":"Upload progress",className:"glass-strong fixed bottom-4 left-4 z-40 w-80 max-w-[calc(100vw-2rem)] overflow-hidden rounded-2xl border border-line",children:[p.jsxs("header",{className:"flex items-center justify-between border-b border-line/70 px-4 py-3",children:[p.jsxs("h2",{className:"flex items-center gap-2 text-[13px] font-semibold",children:[p.jsx(bl,{className:"h-4 w-4 text-gold","aria-hidden":"true"}),"Uploads"]}),l?p.jsx("button",{type:"button",onClick:o,className:"muted rounded px-1.5 py-0.5 text-xs transition-colors hover:bg-bg-soft hover:text-gold-text",children:"Clear finished"}):null]}),p.jsx("ul",{className:"max-h-72 divide-y divide-line/70 overflow-y-auto p-1.5",children:e.map(u=>p.jsxs("li",{className:"px-2.5 py-2.5",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[pM(u.status),p.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px]",title:u.name,children:u.name}),u.status==="uploading"?p.jsxs("span",{className:"muted shrink-0 text-[12px] tabular-nums",children:[jt(u.loaded)," / ",jt(u.size)]}):p.jsx("span",{className:"muted shrink-0 text-[12px] tabular-nums",children:jt(u.size)})]}),u.status==="uploading"?p.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[p.jsx("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-surface-2",children:p.jsx("div",{className:"progress-fill",style:{width:`${u.percent}%`}})}),p.jsxs("span",{className:"muted w-9 shrink-0 text-right text-[11px] tabular-nums",children:[u.percent,"%"]}),p.jsx("button",{type:"button","aria-label":`Cancel upload of ${u.name}`,onClick:()=>t(u.id),className:"muted rounded p-0.5 transition-colors hover:bg-bg-soft hover:text-bad",children:p.jsx(cn,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}):u.status==="error"||u.status==="cancelled"?p.jsxs("div",{className:"mt-1.5 flex items-center justify-between gap-2",children:[p.jsx("p",{className:`min-w-0 flex-1 text-xs ${u.status==="error"?"text-bad":"muted"}`,children:u.message??"Cancelled"}),p.jsxs("button",{type:"button",className:"muted inline-flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-xs transition-colors hover:bg-bg-soft hover:text-gold-text",onClick:()=>s(u.id),children:[p.jsx(oh,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Retry"]}),p.jsx("button",{type:"button","aria-label":`Dismiss upload of ${u.name}`,onClick:()=>i(u.id),className:"muted shrink-0 rounded p-0.5 transition-colors hover:bg-bg-soft hover:text-gold-text",children:p.jsx(cn,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}):p.jsx("div",{className:"mt-1.5 flex justify-end",children:p.jsx("button",{type:"button","aria-label":`Dismiss upload of ${u.name}`,onClick:()=>i(u.id),className:"muted rounded p-0.5 transition-colors hover:bg-bg-soft hover:text-gold-text",children:p.jsx(cn,{className:"h-3.5 w-3.5","aria-hidden":"true"})})})]},u.id))})]})}function gM(){var ue,J,V;const e=zh(),t=fn(),s=xi(),i=gs(),o=qj(),l=mn(),u=((ue=e.data)==null?void 0:ue.storage)??null,d=((J=e.data)==null?void 0:J.health)??null,h=S.useRef(null),[m,y]=S.useState(""),x=_j(m,300).trim(),[C,k]=S.useState(!1),[E,T]=S.useState(!1),[P,L]=S.useState(!1),[b,M]=S.useState(null),[_,I]=S.useState(null),R=S.useRef(null);R.current=_;const D=Kt({mutationFn:F=>we.folders.create(F,b),onSuccess:F=>{ms(t),L(!1),i.success(`Created "${F.folder.name}"`)},onError:F=>i.error(ze(F,"Could not create folder"))}),B=Kt({mutationFn:we.auth.logout,onSuccess:()=>{t.setQueryData(Uo,lS),t.removeQueries({predicate:F=>F.queryKey[0]!=="me"})},onError:F=>i.error(ze(F,"Could not sign out"))}),W=S.useCallback(()=>{var F,ne;(F=h.current)==null||F.focus(),(ne=h.current)==null||ne.select()},[]),G=S.useCallback(()=>y(""),[]);Vj({onSearch:W,onDelete:()=>{var F,ne;return(ne=(F=R.current)==null?void 0:F.onDelete)==null?void 0:ne.call(F)},onEnter:()=>{var F,ne;return(ne=(F=R.current)==null?void 0:F.onEnter)==null?void 0:ne.call(F)},onSelectAll:()=>{var F,ne;return(ne=(F=R.current)==null?void 0:F.onSelectAll)==null?void 0:ne.call(F)},onEscape:()=>{var F,ne;(ne=(F=R.current)==null?void 0:F.onEscape)==null||ne.call(F),E?T(!1):C?k(!1):x!==""&&y("")},onHelp:()=>T(F=>!F)},!0),S.useEffect(()=>{if(C)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[C]);const K=((V=e.data)==null?void 0:V.user)??null,U=K!==null?K.firstName??K.username??"Account":"Account",X=(K==null?void 0:K.username)??null,ge={uploads:o,activeFolderId:b,setActiveFolderId:M,openCreateFolder:()=>L(!0),clearSearch:G,openShortcuts:()=>T(!0),searchInputRef:h,registerPageShortcuts:I},me=F=>{y(""),s(`/?folder=${encodeURIComponent(F)}`)},Ee=F=>{F.file!==null&&we.files.download(F.file.id),G()},ee=l?0:-20;return p.jsx(aS.Provider,{value:ge,children:p.jsxs("div",{className:"flex h-dvh",children:[p.jsx("a",{href:"#main",className:"skip-link btn-gold",children:"Skip to content"}),p.jsx("aside",{className:"hidden w-60 shrink-0 border-r border-line md:block",children:p.jsx(Q0,{storage:u,health:d,username:X,onCreateFolder:()=>L(!0)})}),p.jsx(Lr,{children:C?p.jsxs("div",{className:"fixed inset-0 z-[80] md:hidden",children:[p.jsx(Qt.div,{className:"absolute inset-0 bg-black/50",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>k(!1),"aria-hidden":"true"}),p.jsx(Qt.div,{initial:{x:ee,opacity:0},animate:{x:0,opacity:1},exit:{x:ee,opacity:0},transition:{duration:.2,ease:"easeOut"},className:"absolute top-0 bottom-0 left-0 w-64 border-r border-line",children:p.jsx(Q0,{storage:u,health:d,username:X,onCreateFolder:()=>{k(!1),L(!0)},onClose:()=>k(!1)})})]}):null}),p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[p.jsx(hM,{storage:u,displayName:U,username:X,search:{value:m,onChange:y,inputRef:h},onUpload:()=>o.openPicker(b),onToggleSidebar:()=>k(!0),onOpenHelp:()=>T(!0),onSignOut:()=>B.mutate(),signingOut:B.isPending}),p.jsx("main",{id:"main",className:"relative flex-1 overflow-y-auto",children:p.jsx(mE,{})})]}),p.jsx("input",{ref:o.pickerInputRef,type:"file",multiple:!0,className:"hidden","aria-hidden":"true",tabIndex:-1,onChange:o.onPickerChange}),p.jsx(mM,{uploads:o.uploads,onCancel:o.cancel,onRetry:o.retry,onDismiss:o.dismiss,onClearFinished:o.clearFinished}),P?p.jsx(dS,{title:"Create folder",label:"Folder name",confirmLabel:"Create",initialValue:"",pending:D.isPending,onSubmit:F=>D.mutate(F),onClose:()=>L(!1)}):null,E?p.jsx(rM,{onClose:()=>T(!1)}):null,x!==""?p.jsx(tM,{query:x,onClose:G,onOpenFolder:F=>me(F.id),onOpenFile:Ee}):null]})})}function Kh(e){const t=new Map;for(const o of e)t.set(o.id,{folder:o,children:[]});const s=[];for(const o of t.values()){const l=o.folder.parentId===null?void 0:t.get(o.folder.parentId);l===void 0?s.push(o):l.children.push(o)}const i=o=>{o.sort((l,u)=>l.folder.name.localeCompare(u.folder.name));for(const l of o)i(l.children);return o};return i(s)}function hS(e,t){for(const s of e){if(s.folder.id===t)return s.folder;const i=hS(s.children,t);if(i!==null)return i}return null}function yM(e,t){if(t===null)return[];const s=[],i=new Set;let o=t;for(;o!==null&&!i.has(o);){i.add(o);const l=hS(e,o);if(l===null)break;s.unshift(l),o=l.parentId}return s}function Wh(e,t){const s=[],i=l=>{s.push(l.folder.id);for(const u of l.children)i(u)},o=l=>{for(const u of l){if(u.folder.id===t)return i(u),!0;if(o(u.children))return!0}return!1};return o(e),s}function Mo({queryKey:e,queryFn:t,enabled:s=!0}){var d;const i=lC({queryKey:e,enabled:s,initialPageParam:1,queryFn:({pageParam:h})=>t(h),getNextPageParam:h=>h.pagination.hasMore?h.pagination.page+1:void 0}),o=((d=i.data)==null?void 0:d.pages)??[],l=o.flatMap(h=>h.items),u=o[o.length-1];return{items:l,pagination:(u==null?void 0:u.pagination)??null,isLoading:i.isPending,isLoadingMore:i.isFetchingNextPage,isFetching:i.isFetching,isError:i.isError,error:i.error,hasMore:i.hasNextPage,loadMore:()=>{i.fetchNextPage()},refetch:()=>{i.refetch()}}}function pS({title:e,message:t,confirmLabel:s="Confirm",destructive:i=!1,busy:o=!1,onConfirm:l,onClose:u}){return p.jsxs($o,{title:e,onClose:u,children:[p.jsxs("div",{className:"flex items-start gap-3",children:[i?p.jsx(Nl,{className:"mt-0.5 h-5 w-5 shrink-0 text-bad","aria-hidden":"true"}):null,p.jsx("div",{className:"text-[13.5px] leading-relaxed",children:t})]}),p.jsxs("div",{className:"mt-6 flex justify-end gap-2.5",children:[p.jsx("button",{type:"button",className:"btn-ghost",onClick:u,disabled:o,children:"Cancel"}),p.jsx("button",{type:"button",autoFocus:!0,className:i?"btn-danger":"btn-gold",onClick:l,disabled:o,children:o?"Working…":s})]})]})}function vM(e,t){const s=Wh(t,e);return Promise.all(s.map(i=>we.files.list({folderId:i,limit:200}))).then(i=>i.reduce((o,l)=>o+l.files.length,0))}function xM({folder:e,tree:t,onClose:s}){const i=fn(),o=gs(),l=Dr({queryKey:["subtree-files",e.id],queryFn:()=>vM(e.id,t),staleTime:0}),u=Kt({mutationFn:()=>we.folders.delete(e.id),onSuccess:y=>{ms(i),o.success(`Deleted ${Nn(y.affectedFolders,"folder")} and ${Nn(y.affectedFiles,"file")}`),s()},onError:y=>o.error(ze(y,"Could not delete folder"))}),d=Wh(t,e.id).length-1,h=l.data;let m=`the folder "${e.name}"`;return d>0&&(m+=` and its ${Nn(d,"subfolder")}`),h!==void 0?m+=` and ${Nn(h,"file")}`:m+=" and all files inside it",p.jsxs($o,{title:`Delete "${e.name}"?`,onClose:s,children:[p.jsxs("section",{className:"rounded-2xl border border-bad/40 p-5",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Nl,{className:"h-4 w-4 shrink-0 text-bad","aria-hidden":"true"}),p.jsx("h3",{className:"text-[15px] font-semibold",children:"Danger zone"})]}),p.jsxs("p",{className:"muted mt-1.5 text-[13px] leading-relaxed",children:["This will permanently delete ",m,". This action cannot be undone."]})]}),p.jsxs("div",{className:"mt-5 flex justify-end gap-2.5",children:[p.jsx("button",{type:"button",className:"btn-ghost",onClick:s,disabled:u.isPending,children:"Cancel"}),p.jsxs("button",{type:"button",className:"btn-danger",onClick:()=>u.mutate(),disabled:u.isPending,children:[u.isPending&&p.jsx(kt,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}),"Delete"]})]})]})}function Y0(e){var t,s;return e.kind==="file"?((t=e.file)==null?void 0:t.folderId)??null:((s=e.folder)==null?void 0:s.parentId)??null}function mS({nodes:e,depth:t,groupName:s,selectedId:i,disabledIds:o,collapsedIds:l,onToggle:u,onSelect:d}){return p.jsx("ul",{className:"space-y-0.5",children:e.map(h=>{const m=h.folder.id,y=o.has(m),v=h.children.length>0,x=l.has(m);return p.jsxs("li",{children:[p.jsxs("div",{className:`flex items-center gap-1 rounded-lg pr-2 transition-colors ${y?"":"hover:bg-surface"}`,style:{paddingLeft:`${t*1.25+.375}rem`},children:[v?p.jsx("button",{type:"button","aria-label":x?`Expand ${h.folder.name}`:`Collapse ${h.folder.name}`,"aria-expanded":!x,onClick:()=>u(m),className:"muted shrink-0 rounded p-0.5 transition-colors hover:text-gold-text",children:p.jsx(dT,{className:`h-3.5 w-3.5 transition-transform ${x?"-rotate-90":""}`,"aria-hidden":"true"})}):p.jsx("span",{className:"w-[1.125rem] shrink-0","aria-hidden":"true"}),p.jsxs("label",{className:`flex min-w-0 flex-1 items-center gap-2.5 py-1.5 text-sm ${y?"cursor-not-allowed":"cursor-pointer"}`,children:[p.jsx("input",{type:"radio",name:s,value:m,checked:i===m,disabled:y,onChange:()=>d(m),className:"h-3.5 w-3.5",style:{accentColor:"var(--gold)"}}),p.jsx(wi,{className:`h-4 w-4 shrink-0 ${y?"muted":"text-gold"}`,"aria-hidden":"true"}),p.jsx("span",{className:`min-w-0 truncate ${y?"muted opacity-60":""}`,children:h.folder.name})]})]}),v&&!x?p.jsx(mS,{nodes:h.children,depth:t+1,groupName:s,selectedId:i,disabledIds:o,collapsedIds:l,onToggle:u,onSelect:d}):null]},m)})})}function wM({targets:e,onClose:t,onMoved:s}){const i=fn(),o=gs(),l=Dr({queryKey:Bh,queryFn:we.folders.tree}),u=S.useMemo(()=>{var P;return Kh(((P=l.data)==null?void 0:P.folders)??[])},[l.data]),d=e[0],[h,m]=S.useState(()=>d===void 0?null:Y0(d)),[y,v]=S.useState(new Set),x=e.length===1&&d!==void 0?`"${d.name}"`:`${e.length} items`,C=S.useMemo(()=>{var L;const P=new Set;for(const b of e)if(b.kind==="folder")for(const M of Wh(u,((L=b.folder)==null?void 0:L.id)??b.id))P.add(M);return P},[u,e]),k=Kt({mutationFn:async()=>{await Promise.all(e.map(P=>P.kind==="file"?we.files.move(P.id,h):we.folders.move(P.id,h)))},onSuccess:()=>{ms(i),o.success(`Moved ${x}`),s==null||s(),t()},onError:P=>o.error(ze(P,"Could not move item"))}),E=e.every(P=>Y0(P)===h),T=P=>{v(L=>{const b=new Set(L);return b.has(P)?b.delete(P):b.add(P),b})};return p.jsxs($o,{title:`Move ${x}`,onClose:t,children:[p.jsx("p",{className:"muted text-[13px]",children:"Choose a destination folder."}),p.jsxs("fieldset",{"aria-label":"Destination folder",className:"mt-3 max-h-72 overflow-y-auto rounded-xl border border-line bg-bg-soft p-2",children:[p.jsxs("label",{className:`flex items-center gap-2.5 rounded-lg px-2 py-1.5 text-sm transition-colors ${h===null?"bg-surface":"hover:bg-surface"}`,children:[p.jsx("input",{type:"radio",name:"move-target",checked:h===null,onChange:()=>m(null),className:"h-3.5 w-3.5",style:{accentColor:"var(--gold)"}}),p.jsx(wi,{className:"h-4 w-4 shrink-0 text-gold","aria-hidden":"true"}),p.jsx("span",{children:"My Drive (root)"})]}),p.jsx(mS,{nodes:u,depth:0,groupName:"move-target",selectedId:h,disabledIds:C,collapsedIds:y,onToggle:T,onSelect:m})]}),l.isPending?p.jsx("p",{className:"muted mt-2 text-[13px]",children:"Loading folders..."}):null,p.jsxs("div",{className:"mt-5 flex justify-end gap-2.5",children:[p.jsx("button",{type:"button",className:"btn-ghost",onClick:t,disabled:k.isPending,children:"Cancel"}),p.jsxs("button",{type:"button",className:"btn-gold",disabled:E||k.isPending,onClick:()=>k.mutate(),children:[k.isPending&&p.jsx(kt,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}),k.isPending?"Moving...":"Move"]})]})]})}function X0(e){const t=e[0];return e.length===1&&t!==void 0?`"${t.name}"`:`${e.length} items`}function qh({onOpenItem:e,onShowDetails:t,onReplaceFile:s}){var G;const i=fn(),o=gs(),[l,u]=S.useState(null),[d,h]=S.useState(null),[m,y]=S.useState(null),[v,x]=S.useState(null),C=S.useRef(null),k=S.useRef(null),E=Dr({queryKey:Bh,queryFn:we.folders.tree}),T=S.useCallback(K=>{ms(i),o.success(K)},[i,o]),P=Kt({mutationFn:async K=>{if(K.item.kind==="file"){const{file:X}=await we.files.update(K.item.id,{name:K.name});return{name:X.name}}const{folder:U}=await we.folders.update(K.item.id,{name:K.name});return{name:U.name}},onSuccess:(K,U)=>{u(null),T(`Renamed to "${U.name}"`)},onError:K=>o.error(ze(K,"Could not rename item"))}),L=Kt({mutationFn:async K=>{const U=[],X=[];for(const me of K.items)me.kind==="file"?U.push(me.id):X.push(me.id);const ge=[];return U.length>0&&ge.push(await we.files.batch({operation:K.operation,ids:U,...K.folderId!==void 0?{folderId:K.folderId}:{}})),X.length>0&&ge.push(await we.folders.batch({operation:K.operation,ids:X,...K.folderId!==void 0?{folderId:K.folderId}:{}})),ge.reduce((me,Ee)=>({requested:me.requested+Ee.requested,succeeded:me.succeeded+Ee.succeeded,failed:me.failed+Ee.failed}),{requested:0,succeeded:0,failed:0})},onSuccess:(K,U)=>{ms(i);const X=X0(U.items);K.failed>0?o.error(`${K.succeeded} of ${K.requested} succeeded — ${K.failed} failed`):o.success(`Updated ${X}`),y(null),h(null)},onError:K=>o.error(ze(K,"The operation failed"))}),b=S.useCallback(K=>{K.length>0&&h(K)},[]),M=S.useCallback(K=>{if(K.length===0)return;const U=K.length===1?K[0]:void 0;if(U!==void 0&&U.kind==="folder"){x(U);return}y(K)},[]),_=S.useCallback((K,U,X)=>{U.length!==0&&L.mutate({operation:K,items:U,...X!==void 0?{folderId:X}:{}})},[L]),I=S.useCallback(K=>{var U;k.current=K,(U=C.current)==null||U.click()},[]),R=S.useCallback((K,U)=>{switch(K){case"open":e(U);return;case"download":U.kind==="file"&&we.files.download(U.id);return;case"rename":u(U);return;case"move":b([U]);return;case"star":_("star",[U]);return;case"unstar":_("unstar",[U]);return;case"replace":I(U);return;case"details":t(U);return;case"trash":_("trash",[U]);return;case"restore":_("restore",[U]);return;case"delete":M([U]);return;default:return}},[e,t,b,I,M,_]),D=Kh(((G=E.data)==null?void 0:G.folders)??[]),B=m!==null?X0(m):"",W=p.jsxs(p.Fragment,{children:[p.jsx("input",{ref:C,type:"file",className:"hidden","aria-hidden":"true",tabIndex:-1,onChange:K=>{var me;const U=K.currentTarget,X=(me=U.files)==null?void 0:me[0],ge=k.current;U.value="",X!==void 0&&ge!==null&&s(X,ge.id),k.current=null}}),l!==null?p.jsx(dS,{title:l.kind==="file"?"Rename file":"Rename folder",label:"Name",confirmLabel:"Rename",initialValue:l.name,pending:P.isPending,onSubmit:K=>P.mutate({item:l,name:K}),onClose:()=>u(null)}):null,d!==null?p.jsx(wM,{targets:d,onClose:()=>h(null)}):null,v!==null&&v.folder!==null?p.jsx(xM,{folder:v.folder,tree:D,onClose:()=>x(null)}):null,m!==null?p.jsx(pS,{title:`Delete ${B}?`,message:`This will permanently delete ${B}. This action cannot be undone.`,confirmLabel:"Delete permanently",destructive:!0,busy:L.isPending,onConfirm:()=>_("delete",m),onClose:()=>y(null)}):null]});return{handleAction:R,openMove:b,requestDelete:M,runBatch:_,pendingBatch:L.isPending,dialogs:W}}function Qh(e,t,s){const[i,o]=S.useState(()=>{try{const u=localStorage.getItem(e);if(u!==null&&(s===void 0||s(u)))return u}catch{}return t});S.useEffect(()=>{try{localStorage.setItem(e,i)}catch{}},[e,i]);const l=S.useCallback(u=>o(u),[]);return[i,l]}function Gh(e,t=!0){const{registerPageShortcuts:s}=Xl();S.useEffect(()=>{if(!t){s(null);return}return s(e),()=>s(null)})}function kd(e){return`${e.kind}:${e.id}`}function Yh(){const[e,t]=S.useState(()=>new Set),s=S.useRef(null),i=S.useCallback(y=>e.has(y),[e]),o=S.useCallback(()=>{t(new Set),s.current=null},[]),l=S.useCallback(y=>{const v=kd(y);t(new Set([v])),s.current=v},[]),u=S.useCallback((y,v={})=>{const x=kd(y),{orderedKeys:C,range:k}=v;if(k===!0&&s.current!==null&&C!==void 0){const E=C.indexOf(s.current),T=C.indexOf(x);if(E!==-1&&T!==-1){const[P,L]=E<T?[E,T]:[T,E];t(b=>{const M=new Set(b);for(let _=P;_<=L;_+=1){const I=C[_];I!==void 0&&M.add(I)}return M});return}}t(E=>{const T=new Set(E);return T.has(x)?T.delete(x):T.add(x),T}),s.current=x},[]),d=S.useCallback(y=>{t(new Set(y)),s.current=y[0]??null},[]),h=S.useCallback(y=>{const v=new Set(y);t(x=>{let C=!1;const k=new Set;for(const E of x)v.has(E)?k.add(E):C=!0;return C?k:x})},[]),m=S.useCallback(y=>e.has(kd(y)),[e]);return S.useMemo(()=>({selected:e,count:e.size,isSelected:i,has:m,select:l,toggle:u,clear:o,selectAll:d,prune:h}),[e,i,m,l,u,o,d,h])}function SM({path:e,onNavigate:t}){return p.jsx("nav",{"aria-label":"Breadcrumb",className:"min-w-0",children:p.jsxs("ol",{className:"flex items-center gap-0.5 text-sm",children:[p.jsx("li",{className:"shrink-0",children:p.jsx("button",{type:"button",onClick:()=>t(null),"aria-current":e.length===0?"page":void 0,className:`rounded px-1.5 py-1 transition-colors ${e.length===0?"font-medium text-gold-text":"muted hover:text-gold-text"}`,children:"My Drive"})}),e.map((s,i)=>{const o=i===e.length-1;return p.jsxs("li",{className:"flex min-w-0 items-center gap-0.5",children:[p.jsx(fT,{className:"muted h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),p.jsx("button",{type:"button",onClick:()=>t(s.id),"aria-current":o?"page":void 0,title:s.name,className:`max-w-[14rem] truncate rounded px-1.5 py-1 transition-colors ${o?"font-medium text-gold-text":"muted hover:text-gold-text"}`,children:s.name})]},s.id)})]})})}function Xh({menu:e,onClose:t}){const s=mn(),i=S.useRef(null);S.useEffect(()=>{if(e===null)return;const d=m=>{var y;m.target instanceof Node&&((y=i.current)==null?void 0:y.contains(m.target))===!1&&t()},h=m=>{m.key==="Escape"&&t()};return document.addEventListener("pointerdown",d),document.addEventListener("keydown",h),window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{document.removeEventListener("pointerdown",d),document.removeEventListener("keydown",h),window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[e,t]);const o=s?0:-4,u=e===null?void 0:{left:Math.min(e.x,Math.max(0,window.innerWidth-224-8)),top:Math.min(e.y,Math.max(0,window.innerHeight-240))};return p.jsx(Lr,{children:e!==null?p.jsx(Qt.div,{ref:i,role:"menu","aria-label":e.label,initial:{opacity:0,y:o},animate:{opacity:1,y:0},exit:{opacity:0,y:o},transition:{duration:.13,ease:"easeOut"},style:u,className:"menu-panel fixed z-[120] w-56",children:e.items.map(d=>p.jsxs("button",{role:"menuitem",type:"button",disabled:d.disabled===!0,onClick:()=>{t(),d.onSelect()},className:`menu-item text-left ${d.danger===!0?"menu-item-danger":""}`,children:[d.icon,d.label]},d.label))}):null})}function gr({label:e,children:t}){return p.jsxs("div",{children:[p.jsx("dt",{className:"muted text-[11px] font-semibold tracking-wide uppercase",children:e}),p.jsx("dd",{className:"mt-1 text-[13.5px] break-words",children:t})]})}function kM({item:e}){if(e.kind==="folder")return p.jsx(wi,{className:"h-6 w-6 shrink-0 text-gold","aria-hidden":"true"});const{Icon:t,color:s}=Kn(e.mimeType);return p.jsx(t,{className:`h-6 w-6 shrink-0 ${s}`,"aria-hidden":"true"})}function Ho({item:e,onClose:t,onAction:s}){var o,l,u;const i=mn();return S.useEffect(()=>{if(e===null)return;const d=h=>{h.key==="Escape"&&t()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e,t]),e===null?null:p.jsxs("div",{className:"fixed inset-0 z-[100] flex items-end justify-end sm:items-stretch",children:[p.jsx("div",{className:"absolute inset-0 bg-black/40",onClick:t,"aria-hidden":"true"}),p.jsxs(Qt.aside,{role:"dialog","aria-modal":"true","aria-label":`Details for ${e.name}`,initial:i?{opacity:0}:{x:"100%"},animate:i?{opacity:1}:{x:0},transition:{duration:.22,ease:"easeOut"},className:"glass-strong relative flex max-h-[85dvh] w-full flex-col rounded-t-2xl border border-line sm:h-full sm:max-h-none sm:w-96 sm:rounded-none sm:border-r-0",children:[p.jsxs("header",{className:"flex items-start justify-between gap-3 border-b border-line/70 px-5 py-4",children:[p.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[p.jsx(kM,{item:e}),p.jsx("h2",{className:"min-w-0 text-[15px] font-semibold break-words",children:e.name})]}),p.jsx("button",{type:"button","aria-label":"Close details",onClick:t,className:"muted grid h-8 w-8 shrink-0 place-items-center rounded-lg transition-colors hover:bg-bg-soft hover:text-gold-text",children:p.jsx(cn,{className:"h-4 w-4","aria-hidden":"true"})})]}),p.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:[e.trashed?null:p.jsx("div",{className:"flex flex-wrap gap-2",children:e.kind==="file"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"btn-secondary",onClick:()=>s("download",e),children:[p.jsx(ih,{className:"h-4 w-4","aria-hidden":"true"}),"Download"]}),p.jsxs("button",{type:"button",className:"btn-secondary",onClick:()=>s("replace",e),children:[p.jsx(u1,{className:"h-4 w-4","aria-hidden":"true"}),"New version"]})]}):null}),p.jsxs("dl",{className:"mt-5 grid gap-4",children:[p.jsxs(gr,{label:"Type",children:[e.kind==="folder"?"Folder":Kn(e.mimeType).label,e.kind==="file"?p.jsxs("span",{className:"muted",children:[" · ",e.mimeType]}):null]}),e.kind==="file"?p.jsx(gr,{label:"Size",children:jt(e.size)}):null,e.kind==="file"?p.jsx(gr,{label:"SHA-256",children:p.jsx("code",{className:"font-mono text-[12px] break-all select-all",children:((o=e.file)==null?void 0:o.sha256)??""})}):null,p.jsx(gr,{label:"Folder",children:e.kind==="file"?((l=e.file)==null?void 0:l.folderId)??"My Drive":((u=e.folder)==null?void 0:u.parentId)??"My Drive"}),p.jsx(gr,{label:"Created",children:Ys(e.createdAt)}),p.jsx(gr,{label:"Modified",children:Ys(e.updatedAt)}),e.trashed&&e.deletedAt!==null?p.jsx(gr,{label:"Deleted",children:Ys(e.deletedAt)}):null,e.kind==="file"?p.jsx(gr,{label:"Versions",children:Nn(e.versionCount,"version")}):null]}),e.kind==="file"?p.jsx(CM,{fileId:e.id,versionCount:e.versionCount}):null]})]})]})}function CM({fileId:e,versionCount:t}){var i,o;const s=Dr({queryKey:["versions",e],queryFn:()=>we.files.versions(e)});return p.jsxs("section",{className:"mt-6",children:[p.jsx("h3",{className:"eyebrow",children:"Version history"}),s.isPending?p.jsx("p",{className:"muted mt-3 text-[13px]",children:"Loading versions..."}):s.error!==null?p.jsx("p",{className:"mt-3 text-[13px] text-bad",children:ze(s.error,"Could not load versions")}):(((i=s.data)==null?void 0:i.versions.length)??0)===0?p.jsx("p",{className:"muted mt-3 text-[13px]",children:t>1?"Version history is unavailable.":"No earlier versions."}):p.jsx("ul",{className:"mt-3 grid gap-2",children:(((o=s.data)==null?void 0:o.versions)??[]).map(l=>p.jsxs("li",{className:"flex items-center gap-3 rounded-xl border border-line bg-surface px-3 py-2",children:[p.jsxs("span",{className:"muted w-9 shrink-0 font-mono text-[12px]",children:["v",l.versionNumber]}),p.jsxs("span",{className:"min-w-0 flex-1",children:[p.jsx("span",{className:"block text-[12.5px]",children:jt(l.size)}),p.jsx("span",{className:"muted block text-[11px]",children:Ys(l.createdAt)})]}),l.isCurrent?p.jsx("span",{className:"shrink-0 rounded-full border border-gold/50 bg-gold-soft px-2 py-0.5 text-[11px] font-medium text-gold-text",children:"Current"}):null]},l.id))})]})}function Jl({icon:e,title:t,description:s,children:i}){return p.jsxs("div",{className:"mt-16 flex flex-col items-center px-4 text-center",children:[p.jsx("span",{className:"grid h-16 w-16 place-items-center rounded-full border border-gold/50 bg-gold-soft",children:p.jsx(e,{className:"h-7 w-7 text-gold","aria-hidden":"true"})}),p.jsx("h2",{className:"mt-4 text-base font-semibold",children:t}),s!==void 0?p.jsx("p",{className:"muted mt-1 max-w-sm text-sm",children:s}):null,i!==void 0?p.jsx("div",{className:"mt-5 flex flex-wrap justify-center gap-2.5",children:i}):null]})}function J0({label:e,items:t,trigger:s,triggerClassName:i,align:o="end"}){const[l,u]=S.useState(!1),d=mn(),h=S.useRef(null),m=S.useRef(null),y=S.useRef(null);S.useEffect(()=>{if(!l)return;const k=T=>{var P;T.target instanceof Node&&((P=h.current)==null?void 0:P.contains(T.target))===!1&&u(!1)},E=T=>{var P;T.key==="Escape"&&(u(!1),(P=m.current)==null||P.focus())};return document.addEventListener("pointerdown",k),document.addEventListener("keydown",E),()=>{document.removeEventListener("pointerdown",k),document.removeEventListener("keydown",E)}},[l]);const v=k=>{var T,P;const E=(T=y.current)==null?void 0:T.querySelectorAll("[role='menuitem']");(P=E==null?void 0:E[k])==null||P.focus()},x=(k,E)=>{var b,M;const T=Array.from(((b=y.current)==null?void 0:b.querySelectorAll("[role='menuitem']"))??[]);if(T.length===0)return;const L=(T.indexOf(k)+E+T.length)%T.length;(M=T[L])==null||M.focus()},C=d?0:-6;return p.jsxs("div",{ref:h,className:"relative",children:[p.jsx("button",{ref:m,type:"button","aria-label":e,"aria-haspopup":"menu","aria-expanded":l,onClick:()=>u(k=>!k),onKeyDown:k=>{k.key==="ArrowDown"&&(k.preventDefault(),l?v(0):(u(!0),window.requestAnimationFrame(()=>v(0))))},className:i??"muted grid h-8 w-8 place-items-center rounded-lg transition-colors hover:bg-bg-soft hover:text-gold-text",children:s??p.jsx(gT,{className:"h-4 w-4","aria-hidden":"true"})}),p.jsx(Lr,{children:l?p.jsx(Qt.div,{ref:y,role:"menu","aria-label":e,initial:{opacity:0,y:C},animate:{opacity:1,y:0},exit:{opacity:0,y:C},transition:{duration:.15,ease:"easeOut"},className:`menu-panel absolute top-full z-20 mt-1.5 w-48 ${o==="end"?"right-0":"left-0"}`,children:t.map(k=>p.jsxs("button",{role:"menuitem",type:"button",disabled:k.disabled===!0,onClick:()=>{u(!1),k.onSelect()},onKeyDown:E=>{E.key==="ArrowDown"?(E.preventDefault(),x(E.currentTarget,1)):E.key==="ArrowUp"&&(E.preventDefault(),x(E.currentTarget,-1))},className:`menu-item text-left ${k.danger===!0?"menu-item-danger":""}`,children:[k.icon,k.label]},k.label))},"item-menu"):null})]})}function Z0({checked:e,visible:t,label:s,onToggle:i}){return p.jsx("button",{type:"button",role:"checkbox","aria-checked":e,"aria-label":s,onClick:o=>{o.stopPropagation(),i({shiftKey:o.shiftKey,metaKey:o.metaKey,ctrlKey:o.ctrlKey})},onPointerDown:o=>o.stopPropagation(),className:`grid h-5 w-5 shrink-0 place-items-center rounded-md border transition-all ${e?"border-gold bg-gold text-gold-ink opacity-100":`border-line-strong bg-surface text-transparent hover:border-gold ${t?"opacity-100":"opacity-0 group-hover:opacity-100 focus-visible:opacity-100"}`}`,children:p.jsx(sh,{className:"h-3 w-3","aria-hidden":"true"})})}function Cd(e,t,s={}){const i=e.kind==="file",o=[];return e.trashed?(o.push({label:"Restore",icon:p.jsx(oh,{className:"h-4 w-4","aria-hidden":"true"}),onSelect:()=>t("restore",e)}),o.push({label:"Delete permanently",icon:p.jsx(br,{className:"h-4 w-4","aria-hidden":"true"}),danger:!0,onSelect:()=>t("delete",e)})):(o.push({label:i?"Download":"Open",icon:i?p.jsx(ih,{className:"h-4 w-4","aria-hidden":"true"}):p.jsx(hf,{className:"h-4 w-4","aria-hidden":"true"}),onSelect:()=>t(i?"download":"open",e)}),i&&o.push({label:"Details",icon:p.jsx(kT,{className:"h-4 w-4","aria-hidden":"true"}),onSelect:()=>t("details",e)}),o.push({label:"Rename",icon:p.jsx(RT,{className:"h-4 w-4","aria-hidden":"true"}),onSelect:()=>t("rename",e)}),o.push({label:"Move",icon:p.jsx(hf,{className:"h-4 w-4","aria-hidden":"true"}),onSelect:()=>t("move",e)}),o.push({label:e.starred?"Unstar":"Star",icon:e.starred?p.jsx(ah,{className:"h-4 w-4","aria-hidden":"true"}):p.jsx(ps,{className:"h-4 w-4","aria-hidden":"true"}),onSelect:()=>t(e.starred?"unstar":"star",e)}),i&&s.canReplace===!0&&o.push({label:"Upload new version",icon:p.jsx(u1,{className:"h-4 w-4","aria-hidden":"true"}),onSelect:()=>t("replace",e)}),o.push({label:"Move to trash",icon:p.jsx(br,{className:"h-4 w-4","aria-hidden":"true"}),danger:!0,onSelect:()=>t("trash",e)})),o}function EM({item:e}){if(e.kind==="folder")return p.jsx(wi,{className:"h-5 w-5 shrink-0 text-gold","aria-hidden":"true"});const{Icon:t,color:s}=Kn(e.mimeType);return p.jsx(t,{className:`h-5 w-5 shrink-0 ${s}`,"aria-hidden":"true"})}function TM({view:e}){const t=[0,1,2,3,4];return e==="grid"?p.jsx("div",{"aria-hidden":"true",className:"grid grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-4",children:t.map(s=>p.jsx("div",{className:"card h-40 animate-pulse bg-bg-soft"},s))}):p.jsx("div",{"aria-hidden":"true",className:"grid gap-2",children:t.map(s=>p.jsx("div",{className:"h-14 animate-pulse rounded-xl border border-line bg-bg-soft"},s))})}function PM({items:e,view:t,selection:s,onOpen:i,onAction:o,onContextMenu:l,menuContext:u={},loading:d=!1}){const h=e.map(ln),m=(v,x)=>{if(v.metaKey||v.ctrlKey){s.toggle(cl(x));return}if(v.shiftKey){s.toggle(cl(x),{orderedKeys:h,range:!0});return}i(x)},y=(v,x)=>{v.preventDefault(),l({x:v.clientX,y:v.clientY,label:`Actions for ${x.name}`,items:Cd(x,o,u)})};return d?p.jsx(TM,{view:t}):e.length===0?null:t==="grid"?p.jsx("ul",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-4",children:e.map(v=>{const x=s.isSelected(ln(v));return p.jsxs("li",{onClick:C=>m(C,v),onContextMenu:C=>y(C,v),className:`group relative flex cursor-pointer flex-col gap-3 rounded-2xl border bg-surface p-4 transition-colors ${x?"border-gold bg-gold-soft":"border-line hover:border-gold/40 hover:bg-bg-soft"} ${v.trashed?"opacity-70":""}`,children:[p.jsx("div",{className:"absolute top-3 left-3",onClick:C=>C.stopPropagation(),children:p.jsx(Z0,{checked:x,visible:x||s.count>0,label:`Select ${v.name}`,onToggle:C=>s.toggle(cl(v),{orderedKeys:h,range:C.shiftKey})})}),p.jsx("div",{className:"absolute top-3 right-3",onClick:C=>C.stopPropagation(),children:p.jsx(J0,{label:`Actions for ${v.name}`,items:Cd(v,o,u)})}),p.jsx("div",{className:"mt-6 flex flex-1 items-center justify-center",children:v.kind==="folder"?p.jsx(wi,{className:"h-10 w-10 text-gold","aria-hidden":"true"}):(()=>{const{Icon:C,color:k}=Kn(v.mimeType);return p.jsx(C,{className:`h-10 w-10 ${k}`,"aria-hidden":"true"})})()}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("p",{className:"line-clamp-2 text-[13px] leading-snug font-medium",title:v.name,children:v.name}),p.jsxs("p",{className:"muted mt-1 truncate text-[12px]",children:[v.starred?p.jsx(ps,{className:"mr-1 inline h-3 w-3 -translate-y-px text-gold","aria-hidden":"true"}):null,v.kind==="folder"?"Folder":`${jt(v.size)} · ${Kn(v.mimeType).label}`]}),v.deletedAt!==null?p.jsxs("p",{className:"muted mt-0.5 text-[11px]",children:["Deleted ",Of(v.deletedAt)]}):null]})]},ln(v))})}):p.jsx("ul",{className:"grid gap-1.5",children:e.map(v=>{const x=s.isSelected(ln(v));return p.jsxs("li",{onClick:C=>m(C,v),onContextMenu:C=>y(C,v),className:`group flex cursor-pointer items-center gap-3 rounded-xl border bg-surface px-3 py-2.5 transition-colors ${x?"border-gold bg-gold-soft":"border-line hover:border-gold/40 hover:bg-bg-soft"} ${v.trashed?"opacity-70":""}`,children:[p.jsx("div",{onClick:C=>C.stopPropagation(),children:p.jsx(Z0,{checked:x,visible:x||s.count>0,label:`Select ${v.name}`,onToggle:C=>s.toggle(cl(v),{orderedKeys:h,range:C.shiftKey})})}),p.jsx(EM,{item:v}),p.jsxs("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",title:v.name,children:[v.starred?p.jsx(ps,{className:"mr-1.5 inline h-3.5 w-3.5 -translate-y-px text-gold","aria-hidden":"true"}):null,v.name]}),v.deletedAt!==null?p.jsxs("span",{className:"muted hidden shrink-0 text-[12px] sm:block",children:["Deleted ",Of(v.deletedAt)]}):null,p.jsx("span",{className:"muted hidden w-40 shrink-0 truncate text-[12.5px] md:block",children:v.kind==="folder"?"Folder":Kn(v.mimeType).label}),p.jsx("span",{className:"muted hidden w-28 shrink-0 text-right text-[12.5px] lg:block",children:Qj(v.updatedAt)}),p.jsx("span",{className:"muted w-16 shrink-0 text-right text-[12.5px] tabular-nums",children:v.kind==="folder"?"—":jt(v.size)}),p.jsx("div",{onClick:C=>C.stopPropagation(),children:p.jsx(J0,{label:`Actions for ${v.name}`,items:Cd(v,o,u)})})]},ln(v))})})}function Jh({items:e,view:t,selection:s,onOpen:i,onAction:o,onContextMenu:l,menuContext:u,loading:d=!1,error:h=null,onRetry:m,emptyState:y,hasMore:v=!1,loadingMore:x=!1,onLoadMore:C}){return h!==null?p.jsxs("div",{className:"card mt-6 p-6 text-center",children:[p.jsx("p",{className:"text-sm font-medium",children:"Something went wrong."}),p.jsx("p",{className:"muted mt-1 text-sm",children:h}),m!==void 0?p.jsx("button",{type:"button",className:"btn-secondary mt-4",onClick:m,children:"Try again"}):null]}):e.length===0&&y!==void 0?p.jsx(p.Fragment,{children:y}):p.jsxs(p.Fragment,{children:[p.jsx(PM,{items:e,view:t,selection:s,onOpen:i,onAction:o,onContextMenu:l,...u!==void 0?{menuContext:u}:{},loading:d}),v&&C!==void 0?p.jsx("div",{className:"mt-6 flex justify-center",children:p.jsx("button",{type:"button",className:"btn-secondary",onClick:C,disabled:x,children:x?"Loading...":"Load more"})}):null]})}function hi({title:e,actions:t,children:s}){return p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsx("div",{className:"min-w-0",children:e}),t!==void 0?p.jsx("div",{className:"flex flex-wrap items-center gap-2.5",children:t}):null,s!==void 0?p.jsx("div",{className:"w-full",children:s}):null]})}function pi({children:e}){return p.jsx("h1",{className:"min-w-0 truncate text-lg font-semibold tracking-[-0.01em]",children:e})}function Zh({count:e,onClear:t,onSelectAll:s,children:i}){const o=mn(),l=e>0;return p.jsx(Lr,{children:l?p.jsxs(Qt.div,{role:"toolbar","aria-label":`${e} items selected`,initial:{opacity:0,y:o?0:20},animate:{opacity:1,y:0},exit:{opacity:0,y:o?0:20},transition:{duration:.18,ease:"easeOut"},className:"glass-strong fixed bottom-4 left-1/2 z-[90] flex max-w-[calc(100vw-2rem)] -translate-x-1/2 flex-wrap items-center gap-1.5 rounded-2xl border border-line px-3 py-2",children:[p.jsxs("span",{className:"px-2 text-[13px] font-medium tabular-nums",children:[e," selected"]}),p.jsx("span",{className:"text-line-strong","aria-hidden":"true",children:"·"}),s!==void 0?p.jsxs("button",{type:"button",className:"btn-secondary",onClick:s,children:[p.jsx(cT,{className:"h-4 w-4","aria-hidden":"true"}),"Select all"]}):null,i,p.jsxs("button",{type:"button",className:"btn-ghost",onClick:t,"aria-label":"Clear selection",children:[p.jsx(cn,{className:"h-4 w-4","aria-hidden":"true"}),"Clear"]})]},"selection-bar"):null})}const Ed={name:"Name",size:"Size",createdAt:"Date created",updatedAt:"Last modified",type:"Type"};function NM({sort:e,order:t,onChange:s}){const[i,o]=S.useState(!1),l=mn(),u=S.useRef(null);S.useEffect(()=>{if(!i)return;const m=v=>{var x;v.target instanceof Node&&((x=u.current)==null?void 0:x.contains(v.target))===!1&&o(!1)},y=v=>{v.key==="Escape"&&o(!1)};return document.addEventListener("pointerdown",m),document.addEventListener("keydown",y),()=>{document.removeEventListener("pointerdown",m),document.removeEventListener("keydown",y)}},[i]);const d=Object.keys(Ed),h=l?0:-6;return p.jsxs("div",{ref:u,className:"relative shrink-0",children:[p.jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":i,onClick:()=>o(m=>!m),className:"btn-secondary",children:[p.jsx(uT,{className:"h-4 w-4","aria-hidden":"true"}),p.jsx("span",{className:"hidden sm:inline",children:Ed[e]}),t==="asc"?p.jsx(Cy,{className:"h-3.5 w-3.5","aria-hidden":"true"}):p.jsx(ky,{className:"h-3.5 w-3.5","aria-hidden":"true"})]}),p.jsx(Lr,{children:i?p.jsx(Qt.div,{role:"menu","aria-label":"Sort by",initial:{opacity:0,y:h},animate:{opacity:1,y:0},exit:{opacity:0,y:h},transition:{duration:.15,ease:"easeOut"},className:"menu-panel absolute top-full right-0 z-30 mt-1.5 w-52",children:d.map(m=>p.jsxs("button",{role:"menuitemradio","aria-checked":e===m,type:"button",onClick:()=>{e===m?s(m,t==="asc"?"desc":"asc"):s(m,"asc")},className:"menu-item justify-between text-left",children:[Ed[m],e===m?t==="asc"?p.jsx(Cy,{className:"h-3.5 w-3.5","aria-hidden":"true"}):p.jsx(ky,{className:"h-3.5 w-3.5","aria-hidden":"true"}):null]},m))}):null})]})}function ep({view:e,onChange:t}){const s=[{mode:"list",label:"List view",Icon:TT},{mode:"grid",label:"Grid view",Icon:ET}];return p.jsx("div",{role:"group","aria-label":"View mode",className:"inline-flex shrink-0 rounded-lg border border-line-strong bg-surface p-0.5",children:s.map(({mode:i,label:o,Icon:l})=>{const u=e===i;return p.jsx("button",{type:"button","aria-label":o,"aria-pressed":u,onClick:()=>t(i),className:`grid h-7 w-8 place-items-center rounded-md transition-colors ${u?"bg-gold-soft text-gold-text":"muted hover:text-gold-text"}`,children:p.jsx(l,{className:"h-4 w-4","aria-hidden":"true"})},i)})})}const ev=100;function dl(e){return e.dataTransfer.types.includes("Files")}function bM(){const{uploads:e,setActiveFolderId:t,openCreateFolder:s,clearSearch:i}=Xl(),[o,l]=WE(),u=o.get("folder"),[d,h]=Qh("omnicloud-view","list",$h),[m,y]=S.useState("name"),[v,x]=S.useState("asc"),[C,k]=S.useState(null),[E,T]=S.useState(null),P=Yh(),[L,b]=S.useState(!1),M=S.useRef(0);S.useEffect(()=>{t(u)},[u,t]);const _=Dr({queryKey:Bh,queryFn:we.folders.tree}),I=S.useMemo(()=>{var F;return Kh(((F=_.data)==null?void 0:F.folders)??[])},[_.data]),R=S.useMemo(()=>yM(I,u),[I,u]),D=Mo({queryKey:["folders","children",u,m,v],queryFn:F=>we.folders.list({parentId:u,page:F,limit:ev,sort:m,order:v,status:"active"}).then(ne=>({items:ne.folders,pagination:ne.pagination}))}),B=Mo({queryKey:["files","folder",u,m,v],queryFn:F=>we.files.list({folderId:u,page:F,limit:ev,sort:m,order:v,status:"active"}).then(ne=>({items:ne.files,pagination:ne.pagination}))}),W=S.useMemo(()=>[...D.items.map(Uh),...B.items.map(Ci)],[D.items,B.items]),G=S.useMemo(()=>W.map(ln),[W]);S.useEffect(()=>{P.prune(G)},[G,P]);const K=S.useCallback(F=>{i(),P.clear(),T(null),l(F===null?{}:{folder:F},{replace:!1})},[i,P,l]),U=qh({onOpenItem:F=>{F.kind==="folder"?K(F.id):we.files.download(F.id)},onShowDetails:T,onReplaceFile:e.replace}),X=S.useMemo(()=>W.filter(F=>P.isSelected(ln(F))),[W,P]);S.useEffect(()=>{const F=pr(D.error,rn.NOT_FOUND,rn.FOLDER_NOT_FOUND)||pr(B.error,rn.NOT_FOUND,rn.FOLDER_NOT_FOUND);u!==null&&F&&l({},{replace:!0})},[u,D.error,B.error,l]),Gh({onDelete:()=>U.runBatch("trash",X),onEnter:()=>{const F=X[0];F!==void 0&&U.handleAction(F.kind==="folder"?"open":"download",F)},onSelectAll:()=>P.selectAll(G),onEscape:()=>T(null)});const ge=pr(D.error,rn.STORAGE_NOT_INITIALIZED)||pr(B.error,rn.STORAGE_NOT_INITIALIZED)||pr(D.error,rn.TELEGRAM_AUTH_REQUIRED)||pr(B.error,rn.TELEGRAM_AUTH_REQUIRED)||pr(D.error,rn.STORAGE_UNAVAILABLE)||pr(B.error,rn.STORAGE_UNAVAILABLE),me=D.error??B.error,Ee=D.isLoading||B.isLoading,ee=F=>{dl(F)&&(F.preventDefault(),M.current+=1,b(!0))},ue=F=>{dl(F)&&(M.current-=1,M.current<=0&&(M.current=0,b(!1)))},J=F=>{dl(F)&&F.preventDefault()},V=F=>{if(!dl(F))return;F.preventDefault(),M.current=0,b(!1);const ne=Array.from(F.dataTransfer.files);ne.length>0&&e.enqueue(ne,u)};return p.jsxs("div",{className:"relative min-h-full",onDragEnter:ee,onDragLeave:ue,onDragOver:J,onDrop:V,children:[p.jsxs("div",{className:"mx-auto max-w-6xl px-4 py-6 md:px-8",children:[p.jsx(hi,{title:u===null?p.jsx(pi,{children:"My Drive"}):p.jsx(SM,{path:R,onNavigate:K}),actions:p.jsxs(p.Fragment,{children:[p.jsx(ep,{view:d,onChange:h}),p.jsx(NM,{sort:m,order:v,onChange:(F,ne)=>{y(F),x(ne)}}),p.jsxs("button",{type:"button",className:"btn-secondary sm:hidden",onClick:()=>e.openPicker(u),children:[p.jsx(bl,{className:"h-4 w-4","aria-hidden":"true"}),"Upload"]})]})}),ge?p.jsx("p",{role:"alert",className:"notice notice-error",children:ze(me,"Your storage is unavailable right now.")}):null,p.jsx("div",{className:"mt-5",children:p.jsx(Jh,{items:W,view:d,selection:P,onOpen:F=>U.handleAction(F.kind==="folder"?"open":"download",F),onAction:U.handleAction,onContextMenu:k,loading:Ee,error:ge||me===null?null:ze(me,"Could not load this folder."),onRetry:()=>{D.refetch(),B.refetch()},hasMore:D.hasMore||B.hasMore,loadingMore:D.isLoadingMore||B.isLoadingMore,onLoadMore:()=>{D.hasMore&&D.loadMore(),B.hasMore&&B.loadMore()},emptyState:p.jsxs(Jl,{icon:mT,title:"Nothing here yet",description:"Upload your first file or create a folder to get started.",children:[p.jsxs("button",{type:"button",className:"btn-gold",onClick:()=>e.openPicker(u),children:[p.jsx(bl,{className:"h-4 w-4","aria-hidden":"true"}),"Upload files"]}),p.jsxs("button",{type:"button",className:"btn-secondary",onClick:s,children:[p.jsx(Gx,{className:"h-4 w-4","aria-hidden":"true"}),"New folder"]})]})})})]}),L?p.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 z-30 flex items-center justify-center bg-bg/70 p-6 backdrop-blur-sm",children:p.jsx("div",{className:"glass-strong rounded-2xl border-2 border-dashed border-gold/60 px-8 py-6 text-sm font-medium text-gold-text",children:"Drop files to upload"})}):null,p.jsxs(Zh,{count:P.count,onClear:P.clear,onSelectAll:()=>P.selectAll(G),children:[p.jsxs("button",{type:"button",className:"btn-secondary",onClick:()=>U.openMove(X),children:[p.jsx(hf,{className:"h-4 w-4","aria-hidden":"true"}),"Move"]}),p.jsxs("button",{type:"button",className:"btn-secondary",onClick:()=>U.runBatch("star",X),children:[p.jsx(ps,{className:"h-4 w-4","aria-hidden":"true"}),"Star"]}),p.jsxs("button",{type:"button",className:"btn-secondary",onClick:()=>U.runBatch("unstar",X),children:[p.jsx(ah,{className:"h-4 w-4","aria-hidden":"true"}),"Unstar"]}),p.jsxs("button",{type:"button",className:"btn-danger",onClick:()=>U.runBatch("trash",X),children:[p.jsx(br,{className:"h-4 w-4","aria-hidden":"true"}),"Trash"]})]}),p.jsx(Xh,{menu:C,onClose:()=>k(null)}),p.jsx(Ho,{item:E,onClose:()=>T(null),onAction:U.handleAction}),U.dialogs]})}var Hs={},Td,tv;function RM(){return tv||(tv=1,Td=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Td}var Pd={},yr={},nv;function ys(){if(nv)return yr;nv=1;let e;const t=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return yr.getSymbolSize=function(i){if(!i)throw new Error('"version" cannot be null or undefined');if(i<1||i>40)throw new Error('"version" should be in range from 1 to 40');return i*4+17},yr.getSymbolTotalCodewords=function(i){return t[i]},yr.getBCHDigit=function(s){let i=0;for(;s!==0;)i++,s>>>=1;return i},yr.setToSJISFunction=function(i){if(typeof i!="function")throw new Error('"toSJISFunc" is not a valid function.');e=i},yr.isKanjiModeEnabled=function(){return typeof e<"u"},yr.toSJIS=function(i){return e(i)},yr}var Nd={},rv;function tp(){return rv||(rv=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(s){if(typeof s!="string")throw new Error("Param is not a string");switch(s.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+s)}}e.isValid=function(i){return i&&typeof i.bit<"u"&&i.bit>=0&&i.bit<4},e.from=function(i,o){if(e.isValid(i))return i;try{return t(i)}catch{return o}}})(Nd)),Nd}var bd,sv;function jM(){if(sv)return bd;sv=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(t){const s=Math.floor(t/8);return(this.buffer[s]>>>7-t%8&1)===1},put:function(t,s){for(let i=0;i<s;i++)this.putBit((t>>>s-i-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const s=Math.floor(this.length/8);this.buffer.length<=s&&this.buffer.push(0),t&&(this.buffer[s]|=128>>>this.length%8),this.length++}},bd=e,bd}var Rd,iv;function MM(){if(iv)return Rd;iv=1;function e(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return e.prototype.set=function(t,s,i,o){const l=t*this.size+s;this.data[l]=i,o&&(this.reservedBit[l]=!0)},e.prototype.get=function(t,s){return this.data[t*this.size+s]},e.prototype.xor=function(t,s,i){this.data[t*this.size+s]^=i},e.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},Rd=e,Rd}var jd={},ov;function DM(){return ov||(ov=1,(function(e){const t=ys().getSymbolSize;e.getRowColCoords=function(i){if(i===1)return[];const o=Math.floor(i/7)+2,l=t(i),u=l===145?26:Math.ceil((l-13)/(2*o-2))*2,d=[l-7];for(let h=1;h<o-1;h++)d[h]=d[h-1]-u;return d.push(6),d.reverse()},e.getPositions=function(i){const o=[],l=e.getRowColCoords(i),u=l.length;for(let d=0;d<u;d++)for(let h=0;h<u;h++)d===0&&h===0||d===0&&h===u-1||d===u-1&&h===0||o.push([l[d],l[h]]);return o}})(jd)),jd}var Md={},av;function AM(){if(av)return Md;av=1;const e=ys().getSymbolSize,t=7;return Md.getPositions=function(i){const o=e(i);return[[0,0],[o-t,0],[0,o-t]]},Md}var Dd={},lv;function LM(){return lv||(lv=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(o){return o!=null&&o!==""&&!isNaN(o)&&o>=0&&o<=7},e.from=function(o){return e.isValid(o)?parseInt(o,10):void 0},e.getPenaltyN1=function(o){const l=o.size;let u=0,d=0,h=0,m=null,y=null;for(let v=0;v<l;v++){d=h=0,m=y=null;for(let x=0;x<l;x++){let C=o.get(v,x);C===m?d++:(d>=5&&(u+=t.N1+(d-5)),m=C,d=1),C=o.get(x,v),C===y?h++:(h>=5&&(u+=t.N1+(h-5)),y=C,h=1)}d>=5&&(u+=t.N1+(d-5)),h>=5&&(u+=t.N1+(h-5))}return u},e.getPenaltyN2=function(o){const l=o.size;let u=0;for(let d=0;d<l-1;d++)for(let h=0;h<l-1;h++){const m=o.get(d,h)+o.get(d,h+1)+o.get(d+1,h)+o.get(d+1,h+1);(m===4||m===0)&&u++}return u*t.N2},e.getPenaltyN3=function(o){const l=o.size;let u=0,d=0,h=0;for(let m=0;m<l;m++){d=h=0;for(let y=0;y<l;y++)d=d<<1&2047|o.get(m,y),y>=10&&(d===1488||d===93)&&u++,h=h<<1&2047|o.get(y,m),y>=10&&(h===1488||h===93)&&u++}return u*t.N3},e.getPenaltyN4=function(o){let l=0;const u=o.data.length;for(let h=0;h<u;h++)l+=o.data[h];return Math.abs(Math.ceil(l*100/u/5)-10)*t.N4};function s(i,o,l){switch(i){case e.Patterns.PATTERN000:return(o+l)%2===0;case e.Patterns.PATTERN001:return o%2===0;case e.Patterns.PATTERN010:return l%3===0;case e.Patterns.PATTERN011:return(o+l)%3===0;case e.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(l/3))%2===0;case e.Patterns.PATTERN101:return o*l%2+o*l%3===0;case e.Patterns.PATTERN110:return(o*l%2+o*l%3)%2===0;case e.Patterns.PATTERN111:return(o*l%3+(o+l)%2)%2===0;default:throw new Error("bad maskPattern:"+i)}}e.applyMask=function(o,l){const u=l.size;for(let d=0;d<u;d++)for(let h=0;h<u;h++)l.isReserved(h,d)||l.xor(h,d,s(o,h,d))},e.getBestMask=function(o,l){const u=Object.keys(e.Patterns).length;let d=0,h=1/0;for(let m=0;m<u;m++){l(m),e.applyMask(m,o);const y=e.getPenaltyN1(o)+e.getPenaltyN2(o)+e.getPenaltyN3(o)+e.getPenaltyN4(o);e.applyMask(m,o),y<h&&(h=y,d=m)}return d}})(Dd)),Dd}var fl={},uv;function gS(){if(uv)return fl;uv=1;const e=tp(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],s=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return fl.getBlocksCount=function(o,l){switch(l){case e.L:return t[(o-1)*4+0];case e.M:return t[(o-1)*4+1];case e.Q:return t[(o-1)*4+2];case e.H:return t[(o-1)*4+3];default:return}},fl.getTotalCodewordsCount=function(o,l){switch(l){case e.L:return s[(o-1)*4+0];case e.M:return s[(o-1)*4+1];case e.Q:return s[(o-1)*4+2];case e.H:return s[(o-1)*4+3];default:return}},fl}var Ad={},mo={},cv;function IM(){if(cv)return mo;cv=1;const e=new Uint8Array(512),t=new Uint8Array(256);return(function(){let i=1;for(let o=0;o<255;o++)e[o]=i,t[i]=o,i<<=1,i&256&&(i^=285);for(let o=255;o<512;o++)e[o]=e[o-255]})(),mo.log=function(i){if(i<1)throw new Error("log("+i+")");return t[i]},mo.exp=function(i){return e[i]},mo.mul=function(i,o){return i===0||o===0?0:e[t[i]+t[o]]},mo}var dv;function FM(){return dv||(dv=1,(function(e){const t=IM();e.mul=function(i,o){const l=new Uint8Array(i.length+o.length-1);for(let u=0;u<i.length;u++)for(let d=0;d<o.length;d++)l[u+d]^=t.mul(i[u],o[d]);return l},e.mod=function(i,o){let l=new Uint8Array(i);for(;l.length-o.length>=0;){const u=l[0];for(let h=0;h<o.length;h++)l[h]^=t.mul(o[h],u);let d=0;for(;d<l.length&&l[d]===0;)d++;l=l.slice(d)}return l},e.generateECPolynomial=function(i){let o=new Uint8Array([1]);for(let l=0;l<i;l++)o=e.mul(o,new Uint8Array([1,t.exp(l)]));return o}})(Ad)),Ad}var Ld,fv;function _M(){if(fv)return Ld;fv=1;const e=FM();function t(s){this.genPoly=void 0,this.degree=s,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(i){this.degree=i,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(i){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(i.length+this.degree);o.set(i);const l=e.mod(o,this.genPoly),u=this.degree-l.length;if(u>0){const d=new Uint8Array(this.degree);return d.set(l,u),d}return l},Ld=t,Ld}var Id={},Fd={},_d={},hv;function yS(){return hv||(hv=1,_d.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),_d}var Sn={},pv;function vS(){if(pv)return Sn;pv=1;const e="[0-9]+",t="[A-Z $%*+\\-./:]+";let s="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";s=s.replace(/u/g,"\\u");const i="(?:(?![A-Z0-9 $%*+\\-./:]|"+s+`)(?:.|[\r
|
|
339
|
+
`),()=>{var B;(B=d.current)==null||B.removeAttribute("data-motion-pop-id"),D.contains(R)&&D.removeChild(R)}},[t]),p.jsx(TR,{isPresent:t,childRef:d,sizeRef:h,pop:l,children:l===!1?e:S.cloneElement(e,{ref:v})})}const NR=({children:e,initial:t,isPresent:s,onExitComplete:i,custom:o,presenceAffectsLayout:l,mode:u,anchorX:d,anchorY:h,root:m})=>{const y=uh(bR),v=S.useId(),x=S.useRef(s),C=S.useRef(i);Co(()=>{x.current=s,C.current=i});let k=!0,E=S.useMemo(()=>(k=!1,{id:v,initial:t,isPresent:s,custom:o,onExitComplete:T=>{y.set(T,!0);for(const P of y.values())if(!P)return;i&&i()},register:T=>(y.set(T,!1),()=>{var P;y.delete(T),!x.current&&!y.size&&((P=C.current)==null||P.call(C))})}),[s,y,i]);return l&&k&&(E={...E}),S.useMemo(()=>{y.forEach((T,P)=>y.set(P,!1))},[s]),S.useEffect(()=>{!s&&!y.size&&i&&i()},[s]),e=p.jsx(PR,{pop:u==="popLayout",isPresent:s,anchorX:d,anchorY:h,root:m,children:e}),p.jsx(Hl.Provider,{value:E,children:e})};function bR(){return new Map}function Gw(e=!0){const t=S.useContext(Hl);if(t===null)return[!0,null];const{isPresent:s,onExitComplete:i,register:o}=t,l=S.useId();S.useEffect(()=>{if(e)return o(l)},[e]);const u=S.useCallback(()=>e&&i&&i(l),[l,i,e]);return!s&&i?[!1,u]:[!0]}const po=e=>e.key||"";function j0(e){const t=[];return S.Children.forEach(e,s=>{S.isValidElement(s)&&t.push(s)}),t}const Lr=({children:e,custom:t,initial:s=!0,onExitComplete:i,presenceAffectsLayout:o=!0,mode:l="sync",propagate:u=!1,anchorX:d="left",anchorY:h="top",root:m})=>{const[y,v]=Gw(u),x=S.useMemo(()=>j0(e),[e]),C=u&&!y?[]:x.map(po),k=S.useRef(!0),E=uh(()=>new Map),T=S.useRef(new Set),[P,L]=S.useState(x),[b,M]=S.useState(x);Co(()=>{u&&!y&&!b.length&&(v==null||v())},[y,u,b.length,v]),Co(()=>{k.current=!1;for(let R=0;R<b.length;R++){const D=po(b[R]);C.includes(D)?(E.delete(D),T.current.delete(D)):E.get(D)!==!0&&E.set(D,!1)}},[b,C.length,C.join("-")]);const _=[];if(x!==P){let R=[...x],D=0;for(const B of b){const W=C.indexOf(po(B));W===-1?(R.splice(D++,0,B),_.push(B)):D=W+_.length+1}return _.every(B=>E.get(po(B)))?R=x:l==="wait"&&(R=_),M(j0(R)),L(x),null}const{forceRender:I}=S.useContext(lh);return p.jsx(p.Fragment,{children:b.map(R=>{const D=po(R),B=u&&!y?!1:x===b||C.includes(D),W=()=>{if(T.current.has(D))return;if(E.has(D))T.current.add(D),E.set(D,!0);else return;let G=!0;E.forEach(K=>{K||(G=!1)}),G&&(I==null||I(),L([]),u&&(v==null||v()),i&&i())};return p.jsx(NR,{isPresent:B,initial:!k.current||s?void 0:!1,custom:t,presenceAffectsLayout:o,mode:l,root:m,onExitComplete:B?void 0:W,anchorX:d,anchorY:h,children:R},D)})})},Yw=S.createContext({strict:!1}),M0={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 D0=!1;function RR(){if(D0)return;const e={};for(const t in M0)e[t]={isEnabled:s=>M0[t].some(i=>!!s[i])};Dw(e),D0=!0}function Xw(){return RR(),Tb()}function jR(e){const t=Xw();for(const s in e)t[s]={...t[s],...e[s]};Dw(t)}const Gl=S.createContext({});function MR(e,t){if(Ql(e)){const{initial:s,animate:i}=e;return{initial:s===!1||bo(s)?s:void 0,animate:bo(i)?i:void 0}}return e.inherit!==!1?t:{}}function DR(e){const{initial:t,animate:s}=MR(e,S.useContext(Gl));return S.useMemo(()=>({initial:t,animate:s}),[A0(t),A0(s)])}function A0(e){return Array.isArray(e)?e.join(" "):e}const Oh=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Jw(e,t,s){for(const i in t)!ct(t[i])&&!Iw(i,s)&&(e[i]=t[i])}function AR({transformTemplate:e},t){return S.useMemo(()=>{const s=Oh();return Mh(s,t,e),Object.assign({},s.vars,s.style)},[t])}function LR(e,t){const s=e.style||{},i={};return Jw(i,s,e),Object.assign(i,AR(e,t)),i}function IR(e,t){const s={},i=LR(e,t);return e.drag&&e.dragListener!==!1&&(s.draggable=!1,i.userSelect=i.WebkitUserSelect=i.WebkitTouchCallout="none",i.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(s.tabIndex=0),s.style=i,s}const Zw=()=>({...Oh(),attrs:{}});function FR(e,t,s,i){const o=S.useMemo(()=>{const l=Zw();return Sw(l,t,_w(i),e.transformTemplate,e.style),{...l.attrs,style:{...l.style}}},[t]);if(e.style){const l={};Jw(l,e.style,e),o.style={...l,...o.style}}return o}const _R=new Set(["animate","exit","variants","initial","style","values","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function Vl(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||_R.has(e)}function OR(e,t){return e.startsWith("on")?!Vl(e):(t==null?void 0:t(e))??!Vl(e)}function VR(e,t,s,i){const o={};for(const l in e)l==="values"&&typeof e.values=="object"||ct(e[l])||(OR(l,i)||s===!0&&Vl(l)||!t&&!Vl(l)||e.draggable&&l.startsWith("onDrag"))&&(o[l]=e[l]);return o}const BR=["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 Vh(e){return typeof e!="string"||e.includes("-")?!1:!!(BR.indexOf(e)>-1||/[A-Z]/u.test(e))}function zR(e,t,s,{latestValues:i},o,l=!1,u,d){const m=(u??Vh(e)?FR:IR)(t,i,o,e),y=VR(t,typeof e=="string",l,d),v=e!==S.Fragment?{...y,...m,ref:s}:{},{children:x}=t,C=S.useMemo(()=>ct(x)?x.get():x,[x]);return S.createElement(e,{...v,children:C})}function UR({scrapeMotionValuesFromProps:e,createRenderState:t},s,i,o){return{latestValues:$R(s,i,o,e),renderState:t()}}function $R(e,t,s,i){const o={},l=i(e,{});for(const x in l)o[x]=Cl(l[x]);let{initial:u,animate:d}=e;const h=Ql(e),m=jw(e);t&&m&&!h&&e.inherit!==!1&&(u===void 0&&(u=t.initial),d===void 0&&(d=t.animate));let y=s?s.initial===!1:!1;y=y||u===!1;const v=y?d:u;if(v&&typeof v!="boolean"&&!ql(v)){const x=Array.isArray(v)?v:[v];for(let C=0;C<x.length;C++){const k=hw(e,x[C]);if(k){const{transitionEnd:E,transition:T,...P}=k;for(const L in P){let b=P[L];if(Array.isArray(b)){const M=y?b.length-1:0;b=b[M]}b!==null&&(o[L]=b)}for(const L in E)o[L]=E[L]}}}return o}const eS=e=>(t,s)=>{const i=S.useContext(Gl),o=S.useContext(Hl),l=()=>UR(e,t,i,o);return s?l():uh(l)},HR=eS({scrapeMotionValuesFromProps:Fh,createRenderState:Oh}),KR=eS({scrapeMotionValuesFromProps:Ow,createRenderState:Zw}),WR=Symbol.for("motionComponentSymbol");function qR(e,t,s){const i=S.useRef(s);S.useInsertionEffect(()=>{i.current=s});const o=S.useRef(null);return S.useCallback(l=>{var d;l&&((d=e.onMount)==null||d.call(e,l)),t&&(l?t.mount(l):t.unmount());const u=i.current;if(typeof u=="function")if(l){const h=u(l);typeof h=="function"&&(o.current=h)}else o.current?(o.current(),o.current=null):u(l);else u&&(u.current=l)},[t])}const tS=S.createContext({});function Ks(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function QR(e,t,s,i,o,l){var b,M;const{visualElement:u}=S.useContext(Gl),d=S.useContext(Yw),h=S.useContext(Hl),m=S.useContext(_h),y=m.reducedMotion,v=m.skipAnimations,x=S.useRef(null),C=S.useRef(!1);i=i||d.renderer,!x.current&&i&&(x.current=i(e,{visualState:t,parent:u,props:s,presenceContext:h,blockInitialAnimation:h?h.initial===!1:!1,reducedMotionConfig:y,skipAnimations:v,isSVG:l}),C.current&&x.current&&(x.current.manuallyAnimateOnMount=!0));const k=x.current,E=S.useContext(tS);k&&!k.projection&&o&&(k.type==="html"||k.type==="svg")&&GR(x.current,s,o,E);const T=S.useRef(!1);S.useInsertionEffect(()=>{k&&T.current&&k.update(s,h)});const P=s[gw],L=S.useRef(!!P&&typeof window<"u"&&!((b=window.MotionHandoffIsComplete)!=null&&b.call(window,P))&&((M=window.MotionHasOptimisedAnimation)==null?void 0:M.call(window,P)));return Co(()=>{var _;!C.current||!k||((_=k.animationState)==null||_.animateChanges(),k.enteringChildren=void 0)},[]),Co(()=>{C.current=!0,k&&(T.current=!0,window.MotionIsMounted=!0,k.updateFeatures(),k.scheduleRenderMicrotask(),L.current&&k.animationState&&k.animationState.animateChanges())}),S.useEffect(()=>{k&&(!L.current&&k.animationState&&k.animationState.animateChanges(),L.current&&(queueMicrotask(()=>{var _;(_=window.MotionHandoffMarkAsComplete)==null||_.call(window,P)}),L.current=!1),k.enteringChildren=void 0)}),k}function GR(e,t,s,i){const{layoutId:o,layout:l,drag:u,dragConstraints:d,layoutScroll:h,layoutRoot:m,layoutAnchor:y,layoutCrossfade:v}=t;e.projection=new s(e.latestValues,t["data-framer-portal-id"]?void 0:nS(e.parent)),e.projection.setOptions({layoutId:o,layout:l,alwaysMeasureLayout:!!u||d&&Ks(d),visualElement:e,animationType:typeof l=="string"?l:"both",initialPromotionConfig:i,crossfade:v,layoutScroll:h,layoutRoot:m,layoutAnchor:y})}function nS(e){if(e)return e.options.allowProjection!==!1?e.projection:nS(e.parent)}function yd(e,{forwardMotionProps:t=!1,type:s}={},i,o){i&&jR(i);const l=s?s==="svg":Vh(e),u=l?KR:HR;function d(m,y){let v;const x={...S.useContext(_h),...m,layoutId:YR(m)},{isStatic:C,isValidProp:k}=x,E=DR(m),T=u(m,C);if(!C&&typeof window<"u"){XR();const P=JR(x);v=P.MeasureLayout,E.visualElement=QR(e,T,x,o,P.ProjectionNode,l)}return p.jsxs(Gl.Provider,{value:E,children:[v&&E.visualElement?p.jsx(v,{visualElement:E.visualElement,...x}):null,zR(e,m,qR(T,E.visualElement,y),T,C,t,l,k)]})}d.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const h=S.forwardRef(d);return h[WR]=e,h}function YR({layoutId:e}){const t=S.useContext(lh).id;return t&&e!==void 0?t+"-"+e:e}function XR(e,t){S.useContext(Yw).strict}function JR(e){const t=Xw(),{drag:s,layout:i}=t;if(!s&&!i)return{};const o={...s,...i};return{MeasureLayout:s!=null&&s.isEnabled(e)||i!=null&&i.isEnabled(e)?o.MeasureLayout:void 0,ProjectionNode:o.ProjectionNode}}function ZR(e,t){if(typeof Proxy>"u")return yd;const s=new Map,i=(l,u)=>yd(l,u,e,t),o=(l,u)=>i(l,u);return new Proxy(o,{get:(l,u)=>u==="create"?i:(s.has(u)||s.set(u,yd(u,void 0,e,t)),s.get(u))})}const ej=(e,t)=>t.isSVG??Vh(e)?new jb(t):new bb(t,{allowProjection:e!==S.Fragment});class tj extends Ar{constructor(t){super(t),t.animationState||(t.animationState=Db(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();ql(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:s}=this.node.prevProps||{};t!==s&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)==null||t.call(this)}}let nj=0;class rj extends Ar{constructor(){super(...arguments),this.id=nj++}update(){var h;const{presenceContext:t,prevPresenceContext:s,animationState:i}=this.node;if(!t||!i)return;const{isPresent:o,onExitComplete:l}=t,u=s==null?void 0:s.isPresent;if(o===u)return;if(o&&u===!1){if(this.exit===!0){const{initial:m}=this.node.getProps();if(m&&!Array.isArray(m)){const{transition:y,transitionEnd:v,...x}=ds(this.node,m)||{};for(const C in x)(h=this.node.getValue(C))==null||h.jump(x[C])}this.node.blockInitialAnimation=!1,i.reset(),i.animateChanges()}else i.setActive("exit",!1);this.exit=void 0;return}const d=this.exit=i.setActive("exit",!o);l&&!o&&d.then(()=>{this.exit===d&&(this.exit=!0,l(this.id))})}mount(){const{register:t,onExitComplete:s}=this.node.presenceContext||{};s&&s(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const sj={animation:{Feature:tj},exit:{Feature:rj}};function Yl(e){return{point:{x:e.pageX,y:e.pageY}}}const ij=e=>t=>Ah(t)&&e(t,Yl(t));function So(e,t,s,i){return jo(e,t,ij(s),i)}const rS=({current:e})=>e?e.ownerDocument.defaultView:null,L0=(e,t)=>Math.abs(e-t);function oj(e,t){const s=L0(e.x,t.x),i=L0(e.y,t.y);return Math.sqrt(s**2+i**2)}const I0=new Set(["auto","scroll"]);class sS{constructor(t,s,{transformPagePoint:i,contextWindow:o=window,dragSnapToOrigin:l=!1,distanceThreshold:u=3,element:d}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=k=>{this.handleScroll(k.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.hasPendingMove=!1,this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=al(this.lastRawMoveEventInfo,this.transformPagePoint));const k=vd(this.lastMoveEventInfo,this.history),E=this.startEvent!==null,T=oj(k.offset,{x:0,y:0})>=this.distanceThreshold;if(!E&&!T)return;const{point:P}=k;this.history.push({...P,timestamp:ut.now()});const{onStart:L,onMove:b}=this.handlers;E||(L&&L(this.lastMoveEvent,k),this.startEvent=this.lastMoveEvent),b&&b(this.lastMoveEvent,k)},this.handlePointerMove=(k,E)=>{this.lastMoveEvent=k,this.lastRawMoveEventInfo=E,this.lastMoveEventInfo=al(E,this.transformPagePoint),this.hasPendingMove=!0,Le.update(this.updatePoint,!0)},this.handlePointerUp=(k,E)=>{this.hasPendingMove&&this.updatePoint(),this.end();const{onEnd:T,onSessionEnd:P,resumeAnimation:L}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&L&&L(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const b=vd(k.type==="pointercancel"?this.lastMoveEventInfo:al(E,this.transformPagePoint),this.history);this.startEvent&&T&&T(k,b),P&&P(k,b)},!Ah(t))return;this.dragSnapToOrigin=l,this.handlers=s,this.transformPagePoint=i,this.distanceThreshold=u,this.contextWindow=o||window;const h=Yl(t),m=al(h,this.transformPagePoint),{point:y}=m,{timestamp:v}=Ze;this.history=[{...y,timestamp:v}];const{onSessionStart:x}=s;x&&x(t,vd(m,this.history));const C={passive:!0,capture:!0};this.removeListeners=Vo(So(this.contextWindow,"pointermove",this.handlePointerMove,C),So(this.contextWindow,"pointerup",this.handlePointerUp,C),So(this.contextWindow,"pointercancel",this.handlePointerUp,C)),d&&this.startScrollTracking(d)}startScrollTracking(t){let s=t.parentElement;for(;s;){const i=getComputedStyle(s);(I0.has(i.overflowX)||I0.has(i.overflowY))&&this.scrollPositions.set(s,{x:s.scrollLeft,y:s.scrollTop}),s=s.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const s=this.scrollPositions.get(t);if(!s)return;const i=t===window,o=i?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},l={x:o.x-s.x,y:o.y-s.y};l.x===0&&l.y===0||(i?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=l.x,this.lastMoveEventInfo.point.y+=l.y):this.history.length>0&&(this.history[0].x-=l.x,this.history[0].y-=l.y),this.scrollPositions.set(t,o),Le.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Mr(this.updatePoint)}}function al(e,t){return t?{point:t(e.point)}:e}function F0(e,t){return{x:e.x-t.x,y:e.y-t.y}}function vd({point:e},t){return{point:e,delta:F0(e,iS(t)),offset:F0(e,aj(t)),velocity:lj(t,.1)}}function aj(e){return e[0]}function iS(e){return e[e.length-1]}function lj(e,t){if(e.length<2)return{x:0,y:0};let s=e.length-1,i=null;const o=iS(e);for(;s>=0&&(i=e[s],!(o.timestamp-i.timestamp>Wt(t)));)s--;if(!i)return{x:0,y:0};i===e[0]&&e.length>2&&o.timestamp-i.timestamp>Wt(t)*2&&(i=e[1]);const l=Ht(o.timestamp-i.timestamp);if(l===0)return{x:0,y:0};const u={x:(o.x-i.x)/l,y:(o.y-i.y)/l};return u.x===1/0&&(u.x=0),u.y===1/0&&(u.y=0),u}function uj(e,{min:t,max:s},i){return t!==void 0&&e<t?e=i?Ae(t,e,i.min):Math.max(e,t):s!==void 0&&e>s&&(e=i?Ae(s,e,i.max):Math.min(e,s)),e}function _0(e,t,s){return{min:t!==void 0?e.min+t:void 0,max:s!==void 0?e.max+s-(e.max-e.min):void 0}}function cj(e,{top:t,left:s,bottom:i,right:o}){return{x:_0(e.x,s,o),y:_0(e.y,t,i)}}function O0(e,t){let s=t.min-e.min,i=t.max-e.max;return t.max-t.min<e.max-e.min&&([s,i]=[i,s]),{min:s,max:i}}function dj(e,t){return{x:O0(e.x,t.x),y:O0(e.y,t.y)}}function fj(e,t){let s=.5;const i=Ct(e),o=Ct(t);return o>i?s=Eo(t.min,t.max-i,e.min):i>o&&(s=Eo(e.min,e.max-o,t.min)),Qn(0,1,s)}function hj(e,t){const s={};return t.min!==void 0&&(s.min=t.min-e.min),t.max!==void 0&&(s.max=t.max-e.min),s}const Ff=.35;function pj(e=Ff){return e===!1?e=0:e===!0&&(e=Ff),{x:V0(e,"left","right"),y:V0(e,"top","bottom")}}function V0(e,t,s){return{min:B0(e,t),max:B0(e,s)}}function B0(e,t){return typeof e=="number"?e:e[t]||0}const mj=new WeakMap;class gj{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=Je(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:s=!1,distanceThreshold:i}={}){const{presenceContext:o}=this.visualElement;if(o&&o.isPresent===!1)return;const l=v=>{s&&this.snapToCursor(v),this.stopAnimation()},u=(v,x)=>{const{drag:C,dragPropagation:k,onDragStart:E}=this.getProps();if(C&&!k&&(this.openDragLock&&this.openDragLock(),this.openDragLock=sb(C),!this.openDragLock))return;this.latestPointerEvent=v,this.latestPanInfo=x,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),kn(P=>{let L=this.getAxisMotionValue(P).get()||0;if(Rn.test(L)){const{projection:b}=this.visualElement;if(b&&b.layout){const M=b.layout.layoutBox[P];M&&(L=Ct(M)*(parseFloat(L)/100))}}this.originPoint[P]=L}),E&&Le.update(()=>E(v,x),!1,!0),jf(this.visualElement,"transform");const{animationState:T}=this.visualElement;T&&T.setActive("whileDrag",!0)},d=(v,x)=>{this.latestPointerEvent=v,this.latestPanInfo=x;const{dragPropagation:C,dragDirectionLock:k,onDirectionLock:E,onDrag:T}=this.getProps();if(!C&&!this.openDragLock)return;const{offset:P}=x;if(k&&this.currentDirection===null){this.currentDirection=vj(P),this.currentDirection!==null&&E&&E(this.currentDirection);return}this.updateAxis("x",x.point,P),this.updateAxis("y",x.point,P),this.visualElement.render(),T&&Le.update(()=>T(v,x),!1,!0)},h=(v,x)=>{this.latestPointerEvent=v,this.latestPanInfo=x,this.stop(v,x),this.latestPointerEvent=null,this.latestPanInfo=null},m=()=>{const{dragSnapToOrigin:v}=this.getProps();(v||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:y}=this.getProps();this.panSession=new sS(t,{onSessionStart:l,onStart:u,onMove:d,onSessionEnd:h,resumeAnimation:m},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:y,distanceThreshold:i,contextWindow:rS(this.visualElement),element:this.visualElement.current})}stop(t,s){const i=t||this.latestPointerEvent,o=s||this.latestPanInfo,l=this.isDragging;if(this.cancel(),!l||!o||!i)return;const{velocity:u}=o;this.startAnimation(u);const{onDragEnd:d}=this.getProps();d&&Le.postRender(()=>d(i,o))}cancel(){this.isDragging=!1;const{projection:t,animationState:s}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:i}=this.getProps();!i&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),s&&s.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,s,i){const{drag:o}=this.getProps();if(!i||!ll(t,o,this.currentDirection))return;const l=this.getAxisMotionValue(t);let u=this.originPoint[t]+i[t];this.constraints&&this.constraints[t]&&(u=uj(u,this.constraints[t],this.elastic[t])),l.set(u)}resolveConstraints(){var l;const{dragConstraints:t,dragElastic:s}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(l=this.visualElement.projection)==null?void 0:l.layout,o=this.constraints;t&&Ks(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&i?this.constraints=cj(i.layoutBox,t):this.constraints=!1,this.elastic=pj(s),o!==this.constraints&&!Ks(t)&&i&&this.constraints&&!this.hasMutatedConstraints&&kn(u=>{this.constraints!==!1&&this.getAxisMotionValue(u)&&(this.constraints[u]=hj(i.layoutBox[u],this.constraints[u]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:s}=this.getProps();if(!t||!Ks(t))return!1;const i=t.current,{projection:o}=this.visualElement;if(!o||!o.layout)return!1;o.root&&(o.root.scroll=void 0,o.root.updateScroll());const l=rb(i,o.root,this.visualElement.getTransformPagePoint());let u=dj(o.layout.layoutBox,l);if(s){const d=s(eb(u));this.hasMutatedConstraints=!!d,d&&(u=kw(d))}return u}startAnimation(t){const{drag:s,dragMomentum:i,dragElastic:o,dragTransition:l,dragSnapToOrigin:u,onDragTransitionEnd:d}=this.getProps(),h=this.constraints||{},m=kn(y=>{if(!ll(y,s,this.currentDirection))return;let v=h&&h[y]||{};(u===!0||u===y)&&(v={min:0,max:0});const x=o?200:1e6,C=o?40:1e7,k={type:"inertia",velocity:i?t[y]:0,bounceStiffness:x,bounceDamping:C,timeConstant:750,restDelta:1,restSpeed:10,...l,...v};return this.startAxisValueAnimation(y,k)});return Promise.all(m).then(d)}startAxisValueAnimation(t,s){const i=this.getAxisMotionValue(t);return jf(this.visualElement,t),i.start(Nh(t,i,0,s,this.visualElement,!1))}stopAnimation(){kn(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const s=`_drag${t.toUpperCase()}`,o=this.visualElement.getProps()[s];return o||this.visualElement.getValue(t,this.visualElement.latestValues[t]??0)}snapToCursor({clientX:t,clientY:s}){var d;const{drag:i}=this.getProps(),o={x:t,y:s},l=((d=this.visualElement.getTransformPagePoint())==null?void 0:d(o))||o,u=this.visualElement.measureViewportBox();kn(h=>{if(!ll(h,i,this.currentDirection))return;const m=this.getAxisMotionValue(h),{min:y,max:v}=u[h];m.set((m.get()||0)+l[h]-Ae(y,v,.5))})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:s}=this.getProps(),{projection:i}=this.visualElement;if(!Ks(s)||!i||!this.constraints)return;this.stopAnimation();const o=this.constraints,l={x:0,y:0};kn(d=>{const h=this.getAxisMotionValue(d).get();l[d]=fj({min:h,max:h},o[d])});const{transformTemplate:u}=this.visualElement.getProps();this.visualElement.current.style.transform=u?u({},""):"none",i.root&&i.root.updateScroll(),i.updateLayout(),this.constraints=!1,this.resolveConstraints(),kn(d=>{const h=this.getAxisMotionValue(d);if(!ll(d,t,null)||!h.get())return;const{min:m,max:y}=this.constraints[d];h.set(Ae(m,y,l[d]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;mj.set(this.visualElement,this);const t=this.visualElement.current,s=So(t,"pointerdown",m=>{const{drag:y,dragListener:v=!0}=this.getProps(),x=m.target,C=x!==t&&cb(x);y&&v&&!C&&this.start(m)});let i;const o=()=>{const{dragConstraints:m}=this.getProps();Ks(m)&&m.current&&(this.constraints=this.resolveRefConstraints(),i||(i=yj(t,m.current,()=>this.scalePositionWithinConstraints())))},{projection:l}=this.visualElement,u=l.addEventListener("measure",o);l&&!l.layout&&(l.root&&l.root.updateScroll(),l.updateLayout()),Le.read(o);const d=jo(window,"resize",()=>this.scalePositionWithinConstraints()),h=l.addEventListener("didUpdate",(({delta:m,hasLayoutChanged:y})=>{this.isDragging&&y&&(kn(v=>{const x=this.getAxisMotionValue(v);x&&(this.originPoint[v]+=m[v].translate,x.set(x.get()+m[v].translate))}),this.visualElement.render())}));return()=>{d(),s(),u(),h&&h(),i&&i()}}getProps(){const t=this.visualElement.getProps(),{drag:s=!1,dragDirectionLock:i=!1,dragPropagation:o=!1,dragConstraints:l=!1,dragElastic:u=Ff,dragMomentum:d=!0}=t;return{...t,drag:s,dragDirectionLock:i,dragPropagation:o,dragConstraints:l,dragElastic:u,dragMomentum:d}}}function z0(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function yj(e,t,s){const i=Zy(e,z0(s)),o=Zy(t,z0(s));return()=>{i(),o()}}function ll(e,t,s){return(t===!0||t===e)&&(s===null||s===e)}function vj(e,t=10){let s=null;return Math.abs(e.y)>t?s="y":Math.abs(e.x)>t&&(s="x"),s}class xj extends Ar{constructor(t){super(t),this.removeGroupControls=dn,this.removeListeners=dn,this.controls=new gj(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||dn}update(){const{dragControls:t}=this.node.getProps(),{dragControls:s}=this.node.prevProps||{};t!==s&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const xd=e=>(t,s)=>{e&&Le.update(()=>e(t,s),!1,!0)};class wj extends Ar{constructor(){super(...arguments),this.removePointerDownListener=dn}onPointerDown(t){this.session=new sS(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:rS(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:s,onPan:i,onPanEnd:o}=this.node.getProps();return{onSessionStart:xd(t),onStart:xd(s),onMove:xd(i),onEnd:(l,u)=>{delete this.session,o&&Le.postRender(()=>o(l,u))}}}mount(){this.removePointerDownListener=So(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 wd=!1;class Sj extends S.Component{componentDidMount(){const{visualElement:t,layoutGroup:s,switchLayoutGroup:i,layoutId:o}=this.props,{projection:l}=t;l&&(s.group&&s.group.add(l),i&&i.register&&o&&i.register(l),wd&&l.root.didUpdate(),l.addEventListener("animationComplete",()=>{this.safeToRemove()}),l.setOptions({...l.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),El.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:s,visualElement:i,drag:o,isPresent:l}=this.props,{projection:u}=i;return u&&(u.isPresent=l,t.layoutDependency!==s&&u.setOptions({...u.options,layoutDependency:s}),wd=!0,o||t.layoutDependency!==s||s===void 0||t.isPresent!==l?u.willUpdate():this.safeToRemove(),t.isPresent!==l&&(l?u.promote():u.relegate()||Le.postRender(()=>{const d=u.getStack();(!d||!d.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:s}=this.props,{projection:i}=t;i&&(i.options.layoutAnchor=s,i.root.didUpdate(),Dh.postRender(()=>{!i.currentAnimation&&i.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:s,switchLayoutGroup:i}=this.props,{projection:o}=t;wd=!0,o&&(o.scheduleCheckAfterUnmount(),s&&s.group&&s.group.remove(o),i&&i.deregister&&i.deregister(o))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function oS(e){const[t,s]=Gw(),i=S.useContext(lh);return p.jsx(Sj,{...e,layoutGroup:i,switchLayoutGroup:S.useContext(tS),isPresent:t,safeToRemove:s})}const kj={pan:{Feature:wj},drag:{Feature:xj,ProjectionNode:Qw,MeasureLayout:oS}};function U0(e,t,s){const{props:i}=e;e.animationState&&i.whileHover&&e.animationState.setActive("whileHover",s==="Start");const o="onHover"+s,l=i[o];l&&Le.postRender(()=>l(t,Yl(t)))}class Cj extends Ar{mount(){const{current:t}=this.node;t&&(this.unmount=ob(t,(s,i)=>(U0(this.node,i,"Start"),o=>U0(this.node,o,"End"))))}unmount(){}}class Ej extends Ar{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=Vo(jo(this.node.current,"focus",()=>this.onFocus()),jo(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function $0(e,t,s){const{props:i}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&i.whileTap&&e.animationState.setActive("whileTap",s==="Start");const o="onTap"+(s==="End"?"":s),l=i[o];l&&Le.postRender(()=>l(t,Yl(t)))}class Tj extends Ar{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:s,propagate:i}=this.node.props;this.unmount=fb(t,(o,l)=>($0(this.node,l,"Start"),(u,{success:d})=>$0(this.node,u,d?"End":"Cancel")),{useGlobalTarget:s,stopPropagation:(i==null?void 0:i.tap)===!1})}unmount(){}}const _f=new WeakMap,Sd=new WeakMap,Pj=e=>{const t=_f.get(e.target);t&&t(e)},Nj=e=>{e.forEach(Pj)};function bj({root:e,...t}){const s=e||document;Sd.has(s)||Sd.set(s,{});const i=Sd.get(s),o=JSON.stringify(t);return i[o]||(i[o]=new IntersectionObserver(Nj,{root:e,...t})),i[o]}function Rj(e,t,s){const i=bj(t);return _f.set(e,s),i.observe(e),()=>{_f.delete(e),i.unobserve(e)}}const jj={some:0,all:1};class Mj extends Ar{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var h;(h=this.stopObserver)==null||h.call(this);const{viewport:t={}}=this.node.getProps(),{root:s,margin:i,amount:o="some",once:l}=t,u={root:s?s.current:void 0,rootMargin:i,threshold:typeof o=="number"?o:jj[o]},d=m=>{const{isIntersecting:y}=m;if(this.isInView===y||(this.isInView=y,l&&!y&&this.hasEnteredView))return;y&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",y);const{onViewportEnter:v,onViewportLeave:x}=this.node.getProps(),C=y?v:x;C&&C(m)};this.stopObserver=Rj(this.node.current,u,d)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:s}=this.node;["amount","margin","root"].some(Dj(t,s))&&this.startObserver()}unmount(){var t;(t=this.stopObserver)==null||t.call(this),this.hasEnteredView=!1,this.isInView=!1}}function Dj({viewport:e={}},{viewport:t={}}={}){return s=>e[s]!==t[s]}const Aj={inView:{Feature:Mj},tap:{Feature:Tj},focus:{Feature:Ej},hover:{Feature:Cj}},Lj={layout:{ProjectionNode:Qw,MeasureLayout:oS}},Ij={...sj,...Aj,...kj,...Lj},Fj=ZR(Ij,ej);function mn(){!Ih.current&&Mw();const[e]=S.useState(Fl.current);return e}const Qt=Fj;function _j(e,t){const[s,i]=S.useState(e);return S.useEffect(()=>{const o=window.setTimeout(()=>i(e),t);return()=>window.clearTimeout(o)},[e,t]),s}const aS=S.createContext(null);function Xl(){const e=S.useContext(aS);if(e===null)throw new Error("useDriveShell must be used within the drive layout");return e}function Oj(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable}function Vj(e,t=!0){const s=S.useRef(e);s.current=e,S.useEffect(()=>{if(!t)return;const i=o=>{const l=o.ctrlKey||o.metaKey,u=Oj(o.target),d=s.current;if(l&&o.key.toLowerCase()==="k"){o.preventDefault(),d.onSearch();return}if(l&&o.key.toLowerCase()==="a"){if(u)return;o.preventDefault(),d.onSelectAll();return}if(o.key==="Escape"){d.onEscape();return}if(!u){if(o.key==="Delete"||o.key==="Backspace"){o.preventDefault(),d.onDelete();return}if(o.key==="Enter"){d.onEnter();return}o.key==="?"&&(o.preventDefault(),d.onHelp())}};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[t])}const Uo=["me"],Bh=["folders","tree"],Bj=["storage","stats"],lS={user:null,storage:null,health:null};function ms(e){e.invalidateQueries({queryKey:["files"]}),e.invalidateQueries({queryKey:["folders"]}),e.invalidateQueries({queryKey:["trash"]}),e.invalidateQueries({queryKey:["starred"]}),e.invalidateQueries({queryKey:["recent"]}),e.invalidateQueries({queryKey:["search"]}),e.invalidateQueries({queryKey:["activity"]}),e.invalidateQueries({queryKey:["subtree-files"]}),e.invalidateQueries({queryKey:["storage"]})}function zj(e,t){e.invalidateQueries({queryKey:["versions",t]})}function zh(){return Dr({queryKey:Uo,queryFn:we.auth.me})}function H0(e){return typeof e=="object"&&e!==null}function Uj(e,t){let s=null;try{s=JSON.parse(t)}catch{}if(H0(s)&&H0(s.file)){const i=s.file;if(typeof i.id=="string"&&typeof i.name=="string")return i}throw new Rr(e,"UNKNOWN","The server returned an unexpected response")}function uS(e,t,s,i){return new Promise((o,l)=>{const u=new XMLHttpRequest;u.open("POST",e);const d=new FormData;s!==null&&d.append("folderId",s),i.operationId&&d.append("operationId",i.operationId),d.append("file",t,t.name),u.upload.addEventListener("progress",m=>{var v;if(!m.lengthComputable)return;const y=Math.min(100,Math.round(m.loaded/m.total*100));(v=i.onProgress)==null||v.call(i,{loaded:m.loaded,total:m.total,percent:y})}),u.addEventListener("load",()=>{if(u.status>=200&&u.status<300){try{o(Uj(u.status,u.responseText))}catch(y){l(y)}return}const m=C1(u.status,u.responseText);u.status===401&&m.code!=="TELEGRAM_AUTH_REQUIRED"&&k1(),l(m)}),u.addEventListener("error",()=>{l(new Rr(0,"NETWORK_ERROR","Could not reach the server. Check your connection and try again."))}),u.addEventListener("abort",()=>{l(new Rr(0,"ABORTED","Upload cancelled"))});const h=i.signal;if(h!==void 0){if(h.aborted){l(new Rr(0,"ABORTED","Upload cancelled"));return}h.addEventListener("abort",()=>u.abort(),{once:!0})}u.send(d)})}function $j(e,t,s={}){return uS("/api/files",e,t,s)}function Hj(e,t,s={}){return uS(`/api/files/${encodeURIComponent(t)}/replace`,e,null,s)}const cS=S.createContext(null),Kj=4e3;function Wj({children:e}){const[t,s]=S.useState([]),i=mn(),o=S.useRef(new Set),l=S.useRef(0);S.useEffect(()=>{const y=o.current;return()=>{for(const v of y)window.clearTimeout(v)}},[]);const u=S.useCallback(y=>{s(v=>v.filter(x=>x.id!==y))},[]),d=S.useCallback((y,v)=>{const x=l.current;l.current+=1,s(k=>[...k,{id:x,kind:y,message:v}]);const C=window.setTimeout(()=>{o.current.delete(C),u(x)},Kj);o.current.add(C)},[u]),h=S.useMemo(()=>({success:y=>d("success",y),error:y=>d("error",y)}),[d]),m=i?0:16;return p.jsxs(cS.Provider,{value:h,children:[e,p.jsx("div",{"aria-live":"polite",className:"pointer-events-none fixed top-4 right-4 z-[200] flex w-80 max-w-[calc(100vw-2rem)] flex-col gap-2",children:p.jsx(Lr,{children:t.map(y=>p.jsxs(Qt.div,{role:y.kind==="error"?"alert":"status",initial:{opacity:0,x:m},animate:{opacity:1,x:0},exit:{opacity:0,x:m},transition:{duration:.18,ease:"easeOut"},className:"glass-strong pointer-events-auto flex items-start gap-2.5 rounded-xl border border-line px-4 py-3 text-[13px]",children:[y.kind==="error"?p.jsx(hT,{className:"mt-0.5 h-4 w-4 shrink-0 text-bad","aria-hidden":"true"}):p.jsx(sh,{className:"mt-0.5 h-4 w-4 shrink-0 text-gold-text","aria-hidden":"true"}),p.jsx("p",{className:"min-w-0 flex-1 break-words",children:y.message}),p.jsx("button",{type:"button","aria-label":"Dismiss notification",onClick:()=>u(y.id),className:"muted rounded p-0.5 transition-colors hover:bg-bg-soft hover:text-gold-text",children:p.jsx(cn,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]},y.id))})})]})}function gs(){const e=S.useContext(cS);if(e===null)throw new Error("useToast must be used within a ToastProvider");return e}let ul=0;function K0(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`op-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}function qj(){const e=fn(),t=gs(),[s,i]=S.useState([]),o=S.useRef(new Map),l=S.useRef(new Map),u=S.useRef(Promise.resolve()),d=S.useRef(new Set),h=S.useRef(!0),m=S.useRef(null),y=S.useRef(null);S.useEffect(()=>{const I=d.current,R=l.current;return()=>{h.current=!1;for(const D of I)window.clearTimeout(D);for(const D of R.values())D.abort()}},[]);const v=S.useCallback(I=>{const R=window.setTimeout(()=>{d.current.delete(R),i(D=>D.filter(B=>B.id!==I)),o.current.delete(I)},5e3);d.current.add(R)},[]),x=S.useCallback(async I=>{const R=new AbortController;l.current.set(I.id,R);try{const D={signal:R.signal,onProgress:({loaded:W,total:G,percent:K})=>{i(U=>U.map(X=>X.id===I.id?{...X,loaded:W,size:G||X.size,percent:K}:X))}},B=I.replaceId===null?await $j(I.file,I.folderId,{...D,operationId:I.operationId}):await Hj(I.file,I.replaceId,{...D,operationId:I.operationId});if(!h.current)return;i(W=>W.map(G=>G.id===I.id?{...G,status:"done",percent:100}:G)),ms(e),I.replaceId!==null&&zj(e,I.replaceId),t.success(I.replaceId===null?`Uploaded "${B.name}"`:`Replaced "${B.name}"`),v(I.id)}catch(D){if(!h.current)return;const B=ze(D,"Upload failed"),W=B==="Upload cancelled";i(G=>G.map(K=>K.id===I.id?{...K,status:W?"cancelled":"error",message:B}:K)),W||t.error(`Could not upload "${I.file.name}": ${B}`)}finally{l.current.delete(I.id)}},[e,v,t]),C=S.useCallback(I=>{o.current.set(I.id,I),i(R=>[...R,{id:I.id,name:I.file.name,size:I.file.size,loaded:0,percent:0,status:"uploading"}]),u.current=u.current.then(()=>x(I))},[x]),k=S.useCallback((I,R)=>{for(const D of I)ul+=1,C({id:ul,file:D,replaceId:null,folderId:R,operationId:K0()})},[C]),E=S.useCallback((I,R)=>{ul+=1,C({id:ul,file:I,replaceId:R,folderId:null,operationId:K0()})},[C]),T=S.useCallback(I=>{var R;(R=l.current.get(I))==null||R.abort()},[]),P=S.useCallback(I=>{const R=o.current.get(I);R!==void 0&&(i(D=>D.map(B=>B.id===I?{...B,status:"uploading",percent:0,loaded:0,message:void 0}:B)),u.current=u.current.then(()=>x(R)))},[x]),L=S.useCallback(I=>{var R;(R=l.current.get(I))==null||R.abort(),o.current.delete(I),i(D=>D.filter(B=>B.id!==I))},[]),b=S.useCallback(()=>{i(I=>{for(const R of I)R.status!=="uploading"&&o.current.delete(R.id);return I.filter(R=>R.status==="uploading")})},[]),M=S.useCallback(I=>{var R;y.current=I,(R=m.current)==null||R.click()},[]),_=S.useCallback(()=>{const I=m.current;if(I===null)return;const R=Array.from(I.files??[]);I.value="",R.length>0&&k(R,y.current)},[k]);return{uploads:s,enqueue:k,replace:E,cancel:T,retry:P,dismiss:L,clearFinished:b,openPicker:M,pickerInputRef:m,onPickerChange:_}}function $o({title:e,onClose:t,children:s}){const i=S.useRef(null),o=S.useId(),l=mn();return S.useEffect(()=>{const u=d=>{d.key==="Escape"&&t()};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[t]),S.useEffect(()=>{const u=i.current;u!==null&&(u.contains(document.activeElement)||u.focus())},[]),p.jsx("div",{className:"fixed inset-0 z-[150] flex items-center justify-center bg-black/50 p-4 backdrop-blur-sm",onMouseDown:u=>{u.target===u.currentTarget&&t()},children:p.jsxs(Qt.div,{ref:i,role:"dialog","aria-modal":"true","aria-labelledby":o,tabIndex:-1,initial:l?{opacity:0}:{opacity:0,y:-12,scale:.97},animate:{opacity:1,y:0,scale:1},transition:{duration:.18,ease:"easeOut"},className:"glass-strong w-full max-w-md rounded-2xl border border-line p-6 outline-none",children:[p.jsxs("div",{className:"mb-4 flex items-start justify-between gap-4",children:[p.jsx("h2",{id:o,className:"text-[15px] font-semibold",children:e}),p.jsx("button",{type:"button","aria-label":"Close dialog",onClick:t,className:"muted grid h-8 w-8 shrink-0 place-items-center rounded-lg transition-colors hover:bg-bg-soft hover:text-gold-text",children:p.jsx(cn,{className:"h-4 w-4","aria-hidden":"true"})})]}),s]})})}function dS({title:e,label:t,confirmLabel:s,initialValue:i,pending:o,onSubmit:l,onClose:u}){const[d,h]=S.useState(i),m=S.useId(),y=d.trim(),v=y===i.trim(),x=C=>{C.preventDefault(),!(o||y===""||v)&&l(y)};return p.jsx($o,{title:e,onClose:u,children:p.jsxs("form",{onSubmit:x,noValidate:!0,children:[p.jsxs("label",{htmlFor:m,className:"grid gap-1.5",children:[p.jsx("span",{className:"text-[13px] font-medium",children:t}),p.jsx("input",{id:m,type:"text",autoFocus:!0,value:d,maxLength:255,disabled:o,onFocus:C=>C.target.select(),onChange:C=>h(C.target.value),className:"input"})]}),p.jsxs("div",{className:"mt-5 flex justify-end gap-2.5",children:[p.jsx("button",{type:"button",className:"btn-ghost",onClick:u,disabled:o,children:"Cancel"}),p.jsxs("button",{type:"submit",className:"btn-gold",disabled:o||y===""||v,children:[o&&p.jsx(kt,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}),o?"Saving…":s]})]})]})})}const W0=["B","KB","MB","GB","TB","PB"];function jt(e){if(!Number.isFinite(e)||e<=0)return"0 B";let t=e,s=0;for(;t>=1024&&s<W0.length-1;)t/=1024,s+=1;const i=W0[s]??"B";return s===0?`${Math.round(t)} ${i}`:`${t.toFixed(1)} ${i}`}function Qj(e){const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function Ys(e){const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}const Gj=[{limit:60,divisor:1,unit:"second"},{limit:3600,divisor:60,unit:"minute"},{limit:86400,divisor:3600,unit:"hour"},{limit:604800,divisor:86400,unit:"day"},{limit:2629800,divisor:604800,unit:"week"},{limit:31557600,divisor:2629800,unit:"month"}];function Of(e,t=new Date){const s=new Date(e);if(Number.isNaN(s.getTime()))return"";const i=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"}),o=(s.getTime()-t.getTime())/1e3,l=Math.abs(o);for(const{limit:u,divisor:d,unit:h}of Gj)if(l<u)return i.format(Math.round(o/d),h);return i.format(Math.round(o/31557600),"year")}function Nn(e,t){return`${e} ${t}${e===1?"":"s"}`}function Yj(e,t=new Date){const s=new Date(e);if(Number.isNaN(s.getTime()))return"Unknown";const i=l=>new Date(l.getFullYear(),l.getMonth(),l.getDate()).getTime(),o=Math.round((i(t)-i(s))/864e5);return o<=0?"Today":o===1?"Yesterday":s.toLocaleDateString(void 0,{month:"long",day:"numeric",year:"numeric"})}const Xj={image:ST,video:xT,audio:bT,archive:yT,pdf:sd,text:sd,document:sd,other:vT},Jj={image:"Image",video:"Video",audio:"Audio",archive:"Archive",pdf:"PDF",text:"Text",document:"Document",other:"File"},Zj={image:"text-gold-text",video:"muted",audio:"muted",archive:"muted",pdf:"muted",text:"muted",document:"muted",other:"muted"};function Kn(e){const t=AT(e);return{Icon:Xj[t],label:Jj[t],color:Zj[t]}}function Ci(e){return{kind:"file",id:e.id,name:e.name,size:e.size,mimeType:e.mimeType,starred:e.starred,trashed:e.trashed,deletedAt:e.deletedAt,createdAt:e.createdAt,updatedAt:e.updatedAt,versionCount:e.versionCount,file:e,folder:null}}function Uh(e){return{kind:"folder",id:e.id,name:e.name,size:0,mimeType:"",starred:e.starred,trashed:e.trashed,deletedAt:e.deletedAt,createdAt:e.createdAt,updatedAt:e.updatedAt,versionCount:0,file:null,folder:e}}function cl(e){return{kind:e.kind,id:e.id}}function ln(e){return`${e.kind}:${e.id}`}function $h(e){return e==="list"||e==="grid"}function Hh({label:e="Loading"}){return p.jsx("div",{role:"status","aria-label":e,className:"mt-10 flex justify-center",children:p.jsx(kt,{className:"h-6 w-6 animate-spin text-gold","aria-hidden":"true"})})}const eM="Try type:pdf size:>100MB folder:Projects starred:true after:2026-01-01";function q0({icon:e,label:t,meta:s,onSelect:i}){return p.jsx("li",{children:p.jsxs("button",{type:"button",onClick:i,className:"flex w-full items-center gap-3 rounded-xl border border-transparent px-3 py-2.5 text-left transition-colors hover:border-gold/40 hover:bg-bg-soft",children:[e,p.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",title:t,children:t}),p.jsx("span",{className:"muted shrink-0 text-[12px]",children:s})]})})}function tM({query:e,onClose:t,onOpenFolder:s,onOpenFile:i}){var m,y;const o=mn(),l=Dr({queryKey:["search",e],queryFn:()=>we.search.query(e),enabled:e!=="",placeholderData:Mk});S.useEffect(()=>{const v=x=>{x.key==="Escape"&&t()};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[t]);const u=((m=l.data)==null?void 0:m.folders)??[],d=((y=l.data)==null?void 0:y.files)??[],h=u.length===0&&d.length===0;return p.jsx("div",{className:"fixed inset-0 z-[95] flex justify-center bg-black/40 p-4 pt-20",onMouseDown:v=>{v.target===v.currentTarget&&t()},children:p.jsxs(Qt.div,{role:"dialog","aria-modal":"true","aria-label":`Search results for ${e}`,initial:o?{opacity:0}:{opacity:0,y:-10},animate:{opacity:1,y:0},transition:{duration:.18,ease:"easeOut"},className:"glass-strong flex max-h-[70dvh] w-full max-w-2xl flex-col overflow-hidden rounded-2xl border border-line",children:[p.jsxs("header",{className:"flex items-center gap-3 border-b border-line/70 px-5 py-4",children:[p.jsx(h1,{className:"h-4 w-4 shrink-0 text-gold","aria-hidden":"true"}),p.jsxs("h2",{className:"min-w-0 flex-1 truncate text-[14px] font-semibold",children:["Results for “",e,"”"]}),p.jsx("button",{type:"button","aria-label":"Close search",onClick:t,className:"muted grid h-8 w-8 shrink-0 place-items-center rounded-lg transition-colors hover:bg-bg-soft hover:text-gold-text",children:p.jsx(cn,{className:"h-4 w-4","aria-hidden":"true"})})]}),p.jsx("p",{className:"muted border-b border-line/70 px-5 py-2 font-mono text-[11.5px]",children:eM}),p.jsx("div",{className:"flex-1 overflow-y-auto p-3",children:l.isPending?p.jsx(Hh,{label:"Searching"}):l.error!==null?p.jsx("p",{role:"alert",className:"notice notice-error",children:ze(l.error,"The search failed.")}):h?p.jsxs("div",{className:"flex flex-col items-center py-12 text-center",children:[p.jsx(jT,{className:"h-7 w-7 text-gold","aria-hidden":"true"}),p.jsxs("p",{className:"muted mt-3 text-sm",children:["No matches for “",e,"”."]})]}):p.jsxs(p.Fragment,{children:[u.length>0?p.jsxs("section",{className:"mb-3",children:[p.jsx("h3",{className:"eyebrow mb-2",children:"Folders"}),p.jsx("ul",{className:"grid gap-0.5",children:u.map(v=>p.jsx(q0,{icon:p.jsx(wi,{className:"h-4 w-4 shrink-0 text-gold","aria-hidden":"true"}),label:v.name,meta:"Folder",onSelect:()=>s(v)},v.id))})]}):null,d.length>0?p.jsxs("section",{children:[p.jsx("h3",{className:"eyebrow mb-2",children:"Files"}),p.jsx("ul",{className:"grid gap-0.5",children:d.map(v=>{const{Icon:x,color:C,label:k}=Kn(v.mimeType);return p.jsx(q0,{icon:p.jsx(x,{className:`h-4 w-4 shrink-0 ${C}`,"aria-hidden":"true"}),label:v.name,meta:`${jt(v.size)} · ${k}`,onSelect:()=>i(Ci(v))},v.id)})})]}):null]})})]})})}const nM=[{keys:"Ctrl/⌘ K",label:"Focus search"},{keys:"Enter",label:"Open the focused item"},{keys:"Delete",label:"Move selection to Trash"},{keys:"Ctrl/⌘ A",label:"Select all visible items"},{keys:"Esc",label:"Clear selection / close panels"},{keys:"Shift-click",label:"Select a range of items"},{keys:"Ctrl/⌘-click",label:"Add or remove one item"},{keys:"Click the ⋯",label:"Item actions menu"},{keys:"Right-click",label:"Context menu"},{keys:"?",label:"Show this help"}];function rM({onClose:e}){return p.jsx($o,{title:"Keyboard shortcuts",onClose:e,children:p.jsx("dl",{className:"grid gap-2",children:nM.map(t=>p.jsxs("div",{className:"flex items-center justify-between gap-4",children:[p.jsx("dt",{className:"muted text-[13px]",children:t.label}),p.jsx("dd",{children:p.jsx("kbd",{className:"rounded-md border border-line-strong bg-surface px-2 py-1 font-mono text-[12px]",children:t.keys})})]},t.keys))})})}const sM={DISCONNECTED:"Disconnected",CONNECTING:"Connecting",CONNECTED:"Connected",RECONNECTING:"Reconnecting",ERROR:"Connection error",AUTH_REQUIRED:"Reconnect required"};function iM(e){if(e===null)return{tone:"text-muted",label:"Unknown",usable:!1,hint:null};const t=sM[e.state];return e.state==="AUTH_REQUIRED"?{tone:"text-bad",label:t,usable:!1,hint:e.message??"Reconnect Telegram in Settings to keep syncing."}:e.state==="ERROR"||e.status==="unavailable"?{tone:"text-bad",label:t,usable:!1,hint:e.message??"The storage backend is unavailable right now."}:e.state==="CONNECTED"&&e.status==="healthy"?{tone:"text-ok",label:t,usable:!0,hint:null}:{tone:"text-gold-text",label:t,usable:e.state==="CONNECTED"||e.state==="CONNECTING"||e.state==="RECONNECTING",hint:e.message}}const oM=[{id:"drive",label:"My Drive",path:"/",icon:wT,regionLabel:"My Drive"},{id:"recent",label:"Recent",path:"/recent",icon:Ix,regionLabel:"Recent files"},{id:"starred",label:"Starred",path:"/starred",icon:ps,regionLabel:"Starred items"},{id:"trash",label:"Trash",path:"/trash",icon:br,regionLabel:"Trash"},{id:"storage",label:"Storage",path:"/storage",icon:ko,regionLabel:"Storage"}];function aM({tone:e,label:t}){return p.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[p.jsx("span",{className:`h-2 w-2 shrink-0 rounded-full bg-current ${e}`,"aria-hidden":"true"}),p.jsx("span",{className:`text-[11px] font-medium ${e}`,children:t})]})}function Q0({storage:e,health:t,username:s,onCreateFolder:i,onClose:o}){const l=iM(t);return p.jsxs("div",{className:"flex h-full flex-col bg-bg-soft",children:[p.jsxs("div",{className:"flex items-center justify-between px-4 pt-4 pb-2",children:[p.jsx("span",{className:"eyebrow",children:"Drive"}),o!==void 0?p.jsx("button",{type:"button","aria-label":"Close navigation",onClick:o,className:"muted grid h-8 w-8 place-items-center rounded-lg transition-colors hover:bg-surface hover:text-gold-text md:hidden",children:p.jsx(cn,{className:"h-4 w-4","aria-hidden":"true"})}):null]}),p.jsx("nav",{"aria-label":"Main",className:"px-3",children:p.jsx("ul",{className:"grid gap-0.5",children:oM.map(u=>{const d=u.icon;return p.jsx("li",{children:p.jsxs(kx,{to:u.path,end:u.path==="/",onClick:()=>o==null?void 0:o(),className:({isActive:h})=>`flex items-center gap-2.5 rounded-lg px-3 py-2 text-sm transition-colors ${h?"bg-surface font-medium text-gold-text":"muted hover:bg-surface hover:text-gold-text"}`,children:[p.jsx(d,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),u.label]})},u.id)})})}),p.jsx("div",{className:"px-3 pt-3",children:p.jsxs("button",{type:"button",className:"btn-secondary w-full justify-center",onClick:i,children:[p.jsx(Gx,{className:"h-4 w-4","aria-hidden":"true"}),"New folder"]})}),p.jsx("div",{className:"mt-auto p-3",children:p.jsxs("div",{className:"rounded-2xl border border-line bg-surface p-4",children:[p.jsxs("div",{className:"flex items-center gap-2.5",children:[p.jsx(Ox,{className:"h-5 w-5 shrink-0 text-gold","aria-hidden":"true"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",title:(e==null?void 0:e.title)??void 0,children:(e==null?void 0:e.title)??"No storage"})]}),p.jsx("div",{className:"mt-2",children:t!==null?p.jsx(aM,{tone:l.tone,label:l.label}):p.jsx("span",{className:"muted text-[11px]",children:"Status unknown"})}),l.hint!==null?p.jsx("p",{className:`mt-1.5 text-[11px] leading-snug ${l.tone}`,children:l.hint}):null,p.jsxs("p",{className:"muted mt-2 flex items-center gap-1.5 font-mono text-[11px] uppercase tracking-wide",children:[p.jsx(ko,{className:"h-3 w-3","aria-hidden":"true"}),(e==null?void 0:e.provider)??"—"]}),p.jsx("div",{className:"hairline mt-3"}),s!==null&&s!==""?p.jsxs("p",{className:"muted mt-2.5 truncate font-mono text-[11px] select-all",children:["@",s]}):null]})})]})}const G0="omnicloud:theme-changed";function lM(e){const t=s=>e(s.detail);return window.addEventListener(G0,t),()=>window.removeEventListener(G0,t)}const uM=450;function cM(){return document.documentElement.dataset.theme==="light"?"light":"dark"}function dM({size:e=16}){return p.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[p.jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"}),p.jsx("path",{d:"M20 2 21.1 3.9 23 5 21.1 6.1 20 8 18.9 6.1 17 5 18.9 3.9Z"})]})}function fM({size:e=16}){return p.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[p.jsx("circle",{cx:"12",cy:"12",r:"3.6"}),p.jsx("path",{d:"M12 1.6 13.6 4.6 12 7.6 10.4 4.6Z"}),p.jsx("path",{d:"M12 16.4 13.6 19.4 12 22.4 10.4 19.4Z"}),p.jsx("path",{d:"M1.6 12 4.6 10.4 7.6 12 4.6 13.6Z"}),p.jsx("path",{d:"M16.4 12 19.4 10.4 22.4 12 19.4 13.6Z"})]})}function fS({compact:e=!1}){const[t,s]=S.useState(cM),i=mn();S.useEffect(()=>lM(s),[]);const o=S.useRef(void 0);S.useEffect(()=>{document.documentElement.dataset.theme=t;try{localStorage.setItem("omnicloud-theme",t)}catch{}},[t]),S.useEffect(()=>()=>window.clearTimeout(o.current),[]);const l=t==="dark"?"light":"dark";function u(){if(!i){const m=document.documentElement;m.classList.add("theme-anim"),window.clearTimeout(o.current),o.current=window.setTimeout(()=>m.classList.remove("theme-anim"),uM)}s(l)}const d=e?15:16,h=t==="light"?p.jsx(dM,{size:d}):p.jsx(fM,{size:d});return p.jsx("button",{type:"button",onClick:u,"aria-label":`Switch to ${l} theme`,title:`Switch to ${l} theme`,className:`theme-toggle relative grid place-items-center rounded-full ${e?"h-7 w-7":"h-9 w-9"}`,children:i?h:p.jsx(Lr,{mode:"wait",initial:!1,children:p.jsx(Qt.span,{className:"grid place-items-center",initial:{opacity:0,scale:.4,rotate:-120},animate:{opacity:1,scale:1,rotate:0,transition:{duration:.3,ease:[.34,1.56,.64,1]}},exit:{opacity:0,scale:.4,rotate:120,transition:{duration:.15,ease:"easeIn"}},children:h},t)})})}function hM({storage:e,displayName:t,username:s,search:i,onUpload:o,onToggleSidebar:l,onOpenHelp:u,onSignOut:d,signingOut:h}){const[m,y]=S.useState(!1),v=mn(),x=t.charAt(0).toUpperCase()||"?",C=S.useCallback(()=>y(!1),[]);S.useEffect(()=>{if(!m)return;const T=L=>{var b,M;(M=(b=L.target).closest)!=null&&M.call(b,"[data-account-menu]")||y(!1)},P=L=>{L.key==="Escape"&&y(!1)};return document.addEventListener("pointerdown",T),document.addEventListener("keydown",P),()=>{document.removeEventListener("pointerdown",T),document.removeEventListener("keydown",P)}},[m]);const k=v?0:-6,E=S.useId();return p.jsxs("header",{className:"nav-blur sticky top-0 z-50 flex h-14 shrink-0 items-center gap-3 border-b border-line/70 px-4 md:px-6",children:[p.jsx("button",{type:"button","aria-label":"Open navigation",onClick:l,className:"muted grid h-9 w-9 shrink-0 place-items-center rounded-lg transition-colors hover:bg-surface hover:text-gold-text md:hidden",children:p.jsx(NT,{className:"h-5 w-5","aria-hidden":"true"})}),p.jsxs("a",{href:"/",className:"flex shrink-0 items-center gap-2.5 text-[15px] font-semibold tracking-tight",children:[p.jsx("span",{className:"text-lg leading-none text-gold",children:"◈"}),p.jsxs("span",{className:"hidden sm:inline",children:["Omni",p.jsx("span",{className:"muted font-normal",children:"Cloud"})]})]}),p.jsxs("div",{className:"relative ml-1 min-w-0 max-w-md flex-1",children:[p.jsx("label",{htmlFor:E,className:"sr-only",children:"Search files and folders"}),p.jsx(h1,{className:"muted pointer-events-none absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2","aria-hidden":"true"}),p.jsx("input",{id:E,ref:i.inputRef,type:"search",placeholder:"Search (Ctrl/⌘K)",value:i.value,onChange:T=>i.onChange(T.target.value),className:"input h-9 rounded-full py-0 pl-9"})]}),p.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2.5",children:[p.jsx("button",{type:"button",onClick:u,"aria-label":"Keyboard shortcuts",title:"Keyboard shortcuts (?)",className:"muted hidden h-9 w-9 place-items-center rounded-full border border-line-strong bg-surface transition-colors hover:border-gold hover:text-gold-text sm:grid",children:p.jsx(CT,{className:"h-4 w-4","aria-hidden":"true"})}),p.jsxs("button",{type:"button",className:"btn-gold hidden px-3.5 py-2 text-[13px] sm:inline-flex",onClick:o,children:[p.jsx(bl,{className:"h-4 w-4","aria-hidden":"true"}),"Upload"]}),p.jsx(fS,{}),p.jsxs("div",{className:"relative","data-account-menu":!0,children:[p.jsx("button",{type:"button","aria-label":"Account","aria-haspopup":"menu","aria-expanded":m,onClick:()=>y(T=>!T),className:"muted flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-line-strong bg-surface text-sm font-semibold transition-colors hover:border-gold hover:text-gold-text",children:x}),p.jsx(Lr,{children:m?p.jsxs(Qt.div,{initial:{opacity:0,y:k},animate:{opacity:1,y:0},exit:{opacity:0,y:k},transition:{duration:.15,ease:"easeOut"},className:"menu-panel absolute top-full right-0 z-50 mt-2 w-60",children:[p.jsxs("div",{className:"border-b border-line/70 px-3 py-2.5",children:[p.jsx("p",{className:"truncate text-[13px] font-semibold",children:t}),p.jsx("p",{className:"muted truncate text-[12px]",children:s!==null&&s!==""?`@${s}`:"Telegram account"})]}),p.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2",children:[p.jsx(ko,{className:"h-4 w-4 shrink-0 text-gold","aria-hidden":"true"}),p.jsxs("span",{className:"min-w-0 flex-1",children:[p.jsx("span",{className:"block truncate text-[13px] font-medium",title:(e==null?void 0:e.title)??void 0,children:(e==null?void 0:e.title)??"No storage"}),p.jsx("span",{className:"muted block truncate text-[11px] uppercase tracking-wide",children:(e==null?void 0:e.provider)??"—"})]})]}),p.jsxs("button",{type:"button",onClick:()=>{C(),d()},disabled:h,className:"menu-item menu-item-danger",children:[p.jsx(PT,{className:"h-4 w-4","aria-hidden":"true"}),h?"Signing out...":"Sign out"]})]},"account-menu"):null})]})]})]})}function pM(e){return e==="uploading"?p.jsx(kt,{className:"h-4 w-4 shrink-0 animate-spin text-gold-text","aria-hidden":"true"}):e==="done"?p.jsx(sh,{className:"h-4 w-4 shrink-0 text-ok","aria-hidden":"true"}):e==="cancelled"?p.jsx(cn,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):p.jsx(cn,{className:"h-4 w-4 shrink-0 text-bad","aria-hidden":"true"})}function mM({uploads:e,onCancel:t,onRetry:s,onDismiss:i,onClearFinished:o}){if(e.length===0)return null;const l=e.some(u=>u.status!=="uploading");return p.jsxs("section",{"aria-label":"Upload progress",className:"glass-strong fixed bottom-4 left-4 z-40 w-80 max-w-[calc(100vw-2rem)] overflow-hidden rounded-2xl border border-line",children:[p.jsxs("header",{className:"flex items-center justify-between border-b border-line/70 px-4 py-3",children:[p.jsxs("h2",{className:"flex items-center gap-2 text-[13px] font-semibold",children:[p.jsx(bl,{className:"h-4 w-4 text-gold","aria-hidden":"true"}),"Uploads"]}),l?p.jsx("button",{type:"button",onClick:o,className:"muted rounded px-1.5 py-0.5 text-xs transition-colors hover:bg-bg-soft hover:text-gold-text",children:"Clear finished"}):null]}),p.jsx("ul",{className:"max-h-72 divide-y divide-line/70 overflow-y-auto p-1.5",children:e.map(u=>p.jsxs("li",{className:"px-2.5 py-2.5",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[pM(u.status),p.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px]",title:u.name,children:u.name}),u.status==="uploading"?p.jsxs("span",{className:"muted shrink-0 text-[12px] tabular-nums",children:[jt(u.loaded)," / ",jt(u.size)]}):p.jsx("span",{className:"muted shrink-0 text-[12px] tabular-nums",children:jt(u.size)})]}),u.status==="uploading"?p.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[p.jsx("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-surface-2",children:p.jsx("div",{className:"progress-fill",style:{width:`${u.percent}%`}})}),p.jsxs("span",{className:"muted w-9 shrink-0 text-right text-[11px] tabular-nums",children:[u.percent,"%"]}),p.jsx("button",{type:"button","aria-label":`Cancel upload of ${u.name}`,onClick:()=>t(u.id),className:"muted rounded p-0.5 transition-colors hover:bg-bg-soft hover:text-bad",children:p.jsx(cn,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}):u.status==="error"||u.status==="cancelled"?p.jsxs("div",{className:"mt-1.5 flex items-center justify-between gap-2",children:[p.jsx("p",{className:`min-w-0 flex-1 text-xs ${u.status==="error"?"text-bad":"muted"}`,children:u.message??"Cancelled"}),p.jsxs("button",{type:"button",className:"muted inline-flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-xs transition-colors hover:bg-bg-soft hover:text-gold-text",onClick:()=>s(u.id),children:[p.jsx(oh,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Retry"]}),p.jsx("button",{type:"button","aria-label":`Dismiss upload of ${u.name}`,onClick:()=>i(u.id),className:"muted shrink-0 rounded p-0.5 transition-colors hover:bg-bg-soft hover:text-gold-text",children:p.jsx(cn,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}):p.jsx("div",{className:"mt-1.5 flex justify-end",children:p.jsx("button",{type:"button","aria-label":`Dismiss upload of ${u.name}`,onClick:()=>i(u.id),className:"muted rounded p-0.5 transition-colors hover:bg-bg-soft hover:text-gold-text",children:p.jsx(cn,{className:"h-3.5 w-3.5","aria-hidden":"true"})})})]},u.id))})]})}function gM(){var ue,J,V;const e=zh(),t=fn(),s=xi(),i=gs(),o=qj(),l=mn(),u=((ue=e.data)==null?void 0:ue.storage)??null,d=((J=e.data)==null?void 0:J.health)??null,h=S.useRef(null),[m,y]=S.useState(""),x=_j(m,300).trim(),[C,k]=S.useState(!1),[E,T]=S.useState(!1),[P,L]=S.useState(!1),[b,M]=S.useState(null),[_,I]=S.useState(null),R=S.useRef(null);R.current=_;const D=Kt({mutationFn:F=>we.folders.create(F,b),onSuccess:F=>{ms(t),L(!1),i.success(`Created "${F.folder.name}"`)},onError:F=>i.error(ze(F,"Could not create folder"))}),B=Kt({mutationFn:we.auth.logout,onSuccess:()=>{t.setQueryData(Uo,lS),t.removeQueries({predicate:F=>F.queryKey[0]!=="me"})},onError:F=>i.error(ze(F,"Could not sign out"))}),W=S.useCallback(()=>{var F,ne;(F=h.current)==null||F.focus(),(ne=h.current)==null||ne.select()},[]),G=S.useCallback(()=>y(""),[]);Vj({onSearch:W,onDelete:()=>{var F,ne;return(ne=(F=R.current)==null?void 0:F.onDelete)==null?void 0:ne.call(F)},onEnter:()=>{var F,ne;return(ne=(F=R.current)==null?void 0:F.onEnter)==null?void 0:ne.call(F)},onSelectAll:()=>{var F,ne;return(ne=(F=R.current)==null?void 0:F.onSelectAll)==null?void 0:ne.call(F)},onEscape:()=>{var F,ne;(ne=(F=R.current)==null?void 0:F.onEscape)==null||ne.call(F),E?T(!1):C?k(!1):x!==""&&y("")},onHelp:()=>T(F=>!F)},!0),S.useEffect(()=>{if(C)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[C]);const K=((V=e.data)==null?void 0:V.user)??null,U=K!==null?K.firstName??K.username??"Account":"Account",X=(K==null?void 0:K.username)??null,ge={uploads:o,activeFolderId:b,setActiveFolderId:M,openCreateFolder:()=>L(!0),clearSearch:G,openShortcuts:()=>T(!0),searchInputRef:h,registerPageShortcuts:I},me=F=>{y(""),s(`/?folder=${encodeURIComponent(F)}`)},Ee=F=>{F.file!==null&&we.files.download(F.file.id),G()},ee=l?0:-20;return p.jsx(aS.Provider,{value:ge,children:p.jsxs("div",{className:"flex h-dvh",children:[p.jsx("a",{href:"#main",className:"skip-link btn-gold",children:"Skip to content"}),p.jsx("aside",{className:"hidden w-60 shrink-0 border-r border-line md:block",children:p.jsx(Q0,{storage:u,health:d,username:X,onCreateFolder:()=>L(!0)})}),p.jsx(Lr,{children:C?p.jsxs("div",{className:"fixed inset-0 z-[80] md:hidden",children:[p.jsx(Qt.div,{className:"absolute inset-0 bg-black/50",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>k(!1),"aria-hidden":"true"}),p.jsx(Qt.div,{initial:{x:ee,opacity:0},animate:{x:0,opacity:1},exit:{x:ee,opacity:0},transition:{duration:.2,ease:"easeOut"},className:"absolute top-0 bottom-0 left-0 w-64 border-r border-line",children:p.jsx(Q0,{storage:u,health:d,username:X,onCreateFolder:()=>{k(!1),L(!0)},onClose:()=>k(!1)})})]}):null}),p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[p.jsx(hM,{storage:u,displayName:U,username:X,search:{value:m,onChange:y,inputRef:h},onUpload:()=>o.openPicker(b),onToggleSidebar:()=>k(!0),onOpenHelp:()=>T(!0),onSignOut:()=>B.mutate(),signingOut:B.isPending}),p.jsx("main",{id:"main",className:"relative flex-1 overflow-y-auto",children:p.jsx(mE,{})})]}),p.jsx("input",{ref:o.pickerInputRef,type:"file",multiple:!0,className:"hidden","aria-hidden":"true",tabIndex:-1,onChange:o.onPickerChange}),p.jsx(mM,{uploads:o.uploads,onCancel:o.cancel,onRetry:o.retry,onDismiss:o.dismiss,onClearFinished:o.clearFinished}),P?p.jsx(dS,{title:"Create folder",label:"Folder name",confirmLabel:"Create",initialValue:"",pending:D.isPending,onSubmit:F=>D.mutate(F),onClose:()=>L(!1)}):null,E?p.jsx(rM,{onClose:()=>T(!1)}):null,x!==""?p.jsx(tM,{query:x,onClose:G,onOpenFolder:F=>me(F.id),onOpenFile:Ee}):null]})})}function Kh(e){const t=new Map;for(const o of e)t.set(o.id,{folder:o,children:[]});const s=[];for(const o of t.values()){const l=o.folder.parentId===null?void 0:t.get(o.folder.parentId);l===void 0?s.push(o):l.children.push(o)}const i=o=>{o.sort((l,u)=>l.folder.name.localeCompare(u.folder.name));for(const l of o)i(l.children);return o};return i(s)}function hS(e,t){for(const s of e){if(s.folder.id===t)return s.folder;const i=hS(s.children,t);if(i!==null)return i}return null}function yM(e,t){if(t===null)return[];const s=[],i=new Set;let o=t;for(;o!==null&&!i.has(o);){i.add(o);const l=hS(e,o);if(l===null)break;s.unshift(l),o=l.parentId}return s}function Wh(e,t){const s=[],i=l=>{s.push(l.folder.id);for(const u of l.children)i(u)},o=l=>{for(const u of l){if(u.folder.id===t)return i(u),!0;if(o(u.children))return!0}return!1};return o(e),s}function Mo({queryKey:e,queryFn:t,enabled:s=!0}){var d;const i=lC({queryKey:e,enabled:s,initialPageParam:1,queryFn:({pageParam:h})=>t(h),getNextPageParam:h=>h.pagination.hasMore?h.pagination.page+1:void 0}),o=((d=i.data)==null?void 0:d.pages)??[],l=o.flatMap(h=>h.items),u=o[o.length-1];return{items:l,pagination:(u==null?void 0:u.pagination)??null,isLoading:i.isPending,isLoadingMore:i.isFetchingNextPage,isFetching:i.isFetching,isError:i.isError,error:i.error,hasMore:i.hasNextPage,loadMore:()=>{i.fetchNextPage()},refetch:()=>{i.refetch()}}}function pS({title:e,message:t,confirmLabel:s="Confirm",destructive:i=!1,busy:o=!1,onConfirm:l,onClose:u}){return p.jsxs($o,{title:e,onClose:u,children:[p.jsxs("div",{className:"flex items-start gap-3",children:[i?p.jsx(Nl,{className:"mt-0.5 h-5 w-5 shrink-0 text-bad","aria-hidden":"true"}):null,p.jsx("div",{className:"text-[13.5px] leading-relaxed",children:t})]}),p.jsxs("div",{className:"mt-6 flex justify-end gap-2.5",children:[p.jsx("button",{type:"button",className:"btn-ghost",onClick:u,disabled:o,children:"Cancel"}),p.jsx("button",{type:"button",autoFocus:!0,className:i?"btn-danger":"btn-gold",onClick:l,disabled:o,children:o?"Working…":s})]})]})}function vM(e,t){const s=Wh(t,e);return Promise.all(s.map(i=>we.files.list({folderId:i,limit:200}))).then(i=>i.reduce((o,l)=>o+l.files.length,0))}function xM({folder:e,tree:t,onClose:s}){const i=fn(),o=gs(),l=Dr({queryKey:["subtree-files",e.id],queryFn:()=>vM(e.id,t),staleTime:0}),u=Kt({mutationFn:()=>we.folders.delete(e.id),onSuccess:y=>{ms(i),o.success(`Deleted ${Nn(y.affectedFolders,"folder")} and ${Nn(y.affectedFiles,"file")}`),s()},onError:y=>o.error(ze(y,"Could not delete folder"))}),d=Wh(t,e.id).length-1,h=l.data;let m=`the folder "${e.name}"`;return d>0&&(m+=` and its ${Nn(d,"subfolder")}`),h!==void 0?m+=` and ${Nn(h,"file")}`:m+=" and all files inside it",p.jsxs($o,{title:`Delete "${e.name}"?`,onClose:s,children:[p.jsxs("section",{className:"rounded-2xl border border-bad/40 p-5",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Nl,{className:"h-4 w-4 shrink-0 text-bad","aria-hidden":"true"}),p.jsx("h3",{className:"text-[15px] font-semibold",children:"Danger zone"})]}),p.jsxs("p",{className:"muted mt-1.5 text-[13px] leading-relaxed",children:["This will permanently delete ",m,". This action cannot be undone."]})]}),p.jsxs("div",{className:"mt-5 flex justify-end gap-2.5",children:[p.jsx("button",{type:"button",className:"btn-ghost",onClick:s,disabled:u.isPending,children:"Cancel"}),p.jsxs("button",{type:"button",className:"btn-danger",onClick:()=>u.mutate(),disabled:u.isPending,children:[u.isPending&&p.jsx(kt,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}),"Delete"]})]})]})}function Y0(e){var t,s;return e.kind==="file"?((t=e.file)==null?void 0:t.folderId)??null:((s=e.folder)==null?void 0:s.parentId)??null}function mS({nodes:e,depth:t,groupName:s,selectedId:i,disabledIds:o,collapsedIds:l,onToggle:u,onSelect:d}){return p.jsx("ul",{className:"space-y-0.5",children:e.map(h=>{const m=h.folder.id,y=o.has(m),v=h.children.length>0,x=l.has(m);return p.jsxs("li",{children:[p.jsxs("div",{className:`flex items-center gap-1 rounded-lg pr-2 transition-colors ${y?"":"hover:bg-surface"}`,style:{paddingLeft:`${t*1.25+.375}rem`},children:[v?p.jsx("button",{type:"button","aria-label":x?`Expand ${h.folder.name}`:`Collapse ${h.folder.name}`,"aria-expanded":!x,onClick:()=>u(m),className:"muted shrink-0 rounded p-0.5 transition-colors hover:text-gold-text",children:p.jsx(dT,{className:`h-3.5 w-3.5 transition-transform ${x?"-rotate-90":""}`,"aria-hidden":"true"})}):p.jsx("span",{className:"w-[1.125rem] shrink-0","aria-hidden":"true"}),p.jsxs("label",{className:`flex min-w-0 flex-1 items-center gap-2.5 py-1.5 text-sm ${y?"cursor-not-allowed":"cursor-pointer"}`,children:[p.jsx("input",{type:"radio",name:s,value:m,checked:i===m,disabled:y,onChange:()=>d(m),className:"h-3.5 w-3.5",style:{accentColor:"var(--gold)"}}),p.jsx(wi,{className:`h-4 w-4 shrink-0 ${y?"muted":"text-gold"}`,"aria-hidden":"true"}),p.jsx("span",{className:`min-w-0 truncate ${y?"muted opacity-60":""}`,children:h.folder.name})]})]}),v&&!x?p.jsx(mS,{nodes:h.children,depth:t+1,groupName:s,selectedId:i,disabledIds:o,collapsedIds:l,onToggle:u,onSelect:d}):null]},m)})})}function wM({targets:e,onClose:t,onMoved:s}){const i=fn(),o=gs(),l=Dr({queryKey:Bh,queryFn:we.folders.tree}),u=S.useMemo(()=>{var P;return Kh(((P=l.data)==null?void 0:P.folders)??[])},[l.data]),d=e[0],[h,m]=S.useState(()=>d===void 0?null:Y0(d)),[y,v]=S.useState(new Set),x=e.length===1&&d!==void 0?`"${d.name}"`:`${e.length} items`,C=S.useMemo(()=>{var L;const P=new Set;for(const b of e)if(b.kind==="folder")for(const M of Wh(u,((L=b.folder)==null?void 0:L.id)??b.id))P.add(M);return P},[u,e]),k=Kt({mutationFn:async()=>{await Promise.all(e.map(P=>P.kind==="file"?we.files.move(P.id,h):we.folders.move(P.id,h)))},onSuccess:()=>{ms(i),o.success(`Moved ${x}`),s==null||s(),t()},onError:P=>o.error(ze(P,"Could not move item"))}),E=e.every(P=>Y0(P)===h),T=P=>{v(L=>{const b=new Set(L);return b.has(P)?b.delete(P):b.add(P),b})};return p.jsxs($o,{title:`Move ${x}`,onClose:t,children:[p.jsx("p",{className:"muted text-[13px]",children:"Choose a destination folder."}),p.jsxs("fieldset",{"aria-label":"Destination folder",className:"mt-3 max-h-72 overflow-y-auto rounded-xl border border-line bg-bg-soft p-2",children:[p.jsxs("label",{className:`flex items-center gap-2.5 rounded-lg px-2 py-1.5 text-sm transition-colors ${h===null?"bg-surface":"hover:bg-surface"}`,children:[p.jsx("input",{type:"radio",name:"move-target",checked:h===null,onChange:()=>m(null),className:"h-3.5 w-3.5",style:{accentColor:"var(--gold)"}}),p.jsx(wi,{className:"h-4 w-4 shrink-0 text-gold","aria-hidden":"true"}),p.jsx("span",{children:"My Drive (root)"})]}),p.jsx(mS,{nodes:u,depth:0,groupName:"move-target",selectedId:h,disabledIds:C,collapsedIds:y,onToggle:T,onSelect:m})]}),l.isPending?p.jsx("p",{className:"muted mt-2 text-[13px]",children:"Loading folders..."}):null,p.jsxs("div",{className:"mt-5 flex justify-end gap-2.5",children:[p.jsx("button",{type:"button",className:"btn-ghost",onClick:t,disabled:k.isPending,children:"Cancel"}),p.jsxs("button",{type:"button",className:"btn-gold",disabled:E||k.isPending,onClick:()=>k.mutate(),children:[k.isPending&&p.jsx(kt,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}),k.isPending?"Moving...":"Move"]})]})]})}function X0(e){const t=e[0];return e.length===1&&t!==void 0?`"${t.name}"`:`${e.length} items`}function qh({onOpenItem:e,onShowDetails:t,onReplaceFile:s}){var G;const i=fn(),o=gs(),[l,u]=S.useState(null),[d,h]=S.useState(null),[m,y]=S.useState(null),[v,x]=S.useState(null),C=S.useRef(null),k=S.useRef(null),E=Dr({queryKey:Bh,queryFn:we.folders.tree}),T=S.useCallback(K=>{ms(i),o.success(K)},[i,o]),P=Kt({mutationFn:async K=>{if(K.item.kind==="file"){const{file:X}=await we.files.update(K.item.id,{name:K.name});return{name:X.name}}const{folder:U}=await we.folders.update(K.item.id,{name:K.name});return{name:U.name}},onSuccess:(K,U)=>{u(null),T(`Renamed to "${U.name}"`)},onError:K=>o.error(ze(K,"Could not rename item"))}),L=Kt({mutationFn:async K=>{const U=[],X=[];for(const me of K.items)me.kind==="file"?U.push(me.id):X.push(me.id);const ge=[];return U.length>0&&ge.push(await we.files.batch({operation:K.operation,ids:U,...K.folderId!==void 0?{folderId:K.folderId}:{}})),X.length>0&&ge.push(await we.folders.batch({operation:K.operation,ids:X,...K.folderId!==void 0?{folderId:K.folderId}:{}})),ge.reduce((me,Ee)=>({requested:me.requested+Ee.requested,succeeded:me.succeeded+Ee.succeeded,failed:me.failed+Ee.failed}),{requested:0,succeeded:0,failed:0})},onSuccess:(K,U)=>{ms(i);const X=X0(U.items);K.failed>0?o.error(`${K.succeeded} of ${K.requested} succeeded — ${K.failed} failed`):o.success(`Updated ${X}`),y(null),h(null)},onError:K=>o.error(ze(K,"The operation failed"))}),b=S.useCallback(K=>{K.length>0&&h(K)},[]),M=S.useCallback(K=>{if(K.length===0)return;const U=K.length===1?K[0]:void 0;if(U!==void 0&&U.kind==="folder"){x(U);return}y(K)},[]),_=S.useCallback((K,U,X)=>{U.length!==0&&L.mutate({operation:K,items:U,...X!==void 0?{folderId:X}:{}})},[L]),I=S.useCallback(K=>{var U;k.current=K,(U=C.current)==null||U.click()},[]),R=S.useCallback((K,U)=>{switch(K){case"open":e(U);return;case"download":U.kind==="file"&&we.files.download(U.id);return;case"rename":u(U);return;case"move":b([U]);return;case"star":_("star",[U]);return;case"unstar":_("unstar",[U]);return;case"replace":I(U);return;case"details":t(U);return;case"trash":_("trash",[U]);return;case"restore":_("restore",[U]);return;case"delete":M([U]);return;default:return}},[e,t,b,I,M,_]),D=Kh(((G=E.data)==null?void 0:G.folders)??[]),B=m!==null?X0(m):"",W=p.jsxs(p.Fragment,{children:[p.jsx("input",{ref:C,type:"file",className:"hidden","aria-hidden":"true",tabIndex:-1,onChange:K=>{var me;const U=K.currentTarget,X=(me=U.files)==null?void 0:me[0],ge=k.current;U.value="",X!==void 0&&ge!==null&&s(X,ge.id),k.current=null}}),l!==null?p.jsx(dS,{title:l.kind==="file"?"Rename file":"Rename folder",label:"Name",confirmLabel:"Rename",initialValue:l.name,pending:P.isPending,onSubmit:K=>P.mutate({item:l,name:K}),onClose:()=>u(null)}):null,d!==null?p.jsx(wM,{targets:d,onClose:()=>h(null)}):null,v!==null&&v.folder!==null?p.jsx(xM,{folder:v.folder,tree:D,onClose:()=>x(null)}):null,m!==null?p.jsx(pS,{title:`Delete ${B}?`,message:`This will permanently delete ${B}. This action cannot be undone.`,confirmLabel:"Delete permanently",destructive:!0,busy:L.isPending,onConfirm:()=>_("delete",m),onClose:()=>y(null)}):null]});return{handleAction:R,openMove:b,requestDelete:M,runBatch:_,pendingBatch:L.isPending,dialogs:W}}function Qh(e,t,s){const[i,o]=S.useState(()=>{try{const u=localStorage.getItem(e);if(u!==null&&(s===void 0||s(u)))return u}catch{}return t});S.useEffect(()=>{try{localStorage.setItem(e,i)}catch{}},[e,i]);const l=S.useCallback(u=>o(u),[]);return[i,l]}function Gh(e,t=!0){const{registerPageShortcuts:s}=Xl();S.useEffect(()=>{if(!t){s(null);return}return s(e),()=>s(null)})}function kd(e){return`${e.kind}:${e.id}`}function Yh(){const[e,t]=S.useState(()=>new Set),s=S.useRef(null),i=S.useCallback(y=>e.has(y),[e]),o=S.useCallback(()=>{t(new Set),s.current=null},[]),l=S.useCallback(y=>{const v=kd(y);t(new Set([v])),s.current=v},[]),u=S.useCallback((y,v={})=>{const x=kd(y),{orderedKeys:C,range:k}=v;if(k===!0&&s.current!==null&&C!==void 0){const E=C.indexOf(s.current),T=C.indexOf(x);if(E!==-1&&T!==-1){const[P,L]=E<T?[E,T]:[T,E];t(b=>{const M=new Set(b);for(let _=P;_<=L;_+=1){const I=C[_];I!==void 0&&M.add(I)}return M});return}}t(E=>{const T=new Set(E);return T.has(x)?T.delete(x):T.add(x),T}),s.current=x},[]),d=S.useCallback(y=>{t(new Set(y)),s.current=y[0]??null},[]),h=S.useCallback(y=>{const v=new Set(y);t(x=>{let C=!1;const k=new Set;for(const E of x)v.has(E)?k.add(E):C=!0;return C?k:x})},[]),m=S.useCallback(y=>e.has(kd(y)),[e]);return S.useMemo(()=>({selected:e,count:e.size,isSelected:i,has:m,select:l,toggle:u,clear:o,selectAll:d,prune:h}),[e,i,m,l,u,o,d,h])}function SM({path:e,onNavigate:t}){return p.jsx("nav",{"aria-label":"Breadcrumb",className:"min-w-0",children:p.jsxs("ol",{className:"flex items-center gap-0.5 text-sm",children:[p.jsx("li",{className:"shrink-0",children:p.jsx("button",{type:"button",onClick:()=>t(null),"aria-current":e.length===0?"page":void 0,className:`rounded px-1.5 py-1 transition-colors ${e.length===0?"font-medium text-gold-text":"muted hover:text-gold-text"}`,children:"My Drive"})}),e.map((s,i)=>{const o=i===e.length-1;return p.jsxs("li",{className:"flex min-w-0 items-center gap-0.5",children:[p.jsx(fT,{className:"muted h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),p.jsx("button",{type:"button",onClick:()=>t(s.id),"aria-current":o?"page":void 0,title:s.name,className:`max-w-[14rem] truncate rounded px-1.5 py-1 transition-colors ${o?"font-medium text-gold-text":"muted hover:text-gold-text"}`,children:s.name})]},s.id)})]})})}function Xh({menu:e,onClose:t}){const s=mn(),i=S.useRef(null);S.useEffect(()=>{if(e===null)return;const d=m=>{var y;m.target instanceof Node&&((y=i.current)==null?void 0:y.contains(m.target))===!1&&t()},h=m=>{m.key==="Escape"&&t()};return document.addEventListener("pointerdown",d),document.addEventListener("keydown",h),window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{document.removeEventListener("pointerdown",d),document.removeEventListener("keydown",h),window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[e,t]);const o=s?0:-4,u=e===null?void 0:{left:Math.min(e.x,Math.max(0,window.innerWidth-224-8)),top:Math.min(e.y,Math.max(0,window.innerHeight-240))};return p.jsx(Lr,{children:e!==null?p.jsx(Qt.div,{ref:i,role:"menu","aria-label":e.label,initial:{opacity:0,y:o},animate:{opacity:1,y:0},exit:{opacity:0,y:o},transition:{duration:.13,ease:"easeOut"},style:u,className:"menu-panel fixed z-[120] w-56",children:e.items.map(d=>p.jsxs("button",{role:"menuitem",type:"button",disabled:d.disabled===!0,onClick:()=>{t(),d.onSelect()},className:`menu-item text-left ${d.danger===!0?"menu-item-danger":""}`,children:[d.icon,d.label]},d.label))}):null})}function gr({label:e,children:t}){return p.jsxs("div",{children:[p.jsx("dt",{className:"muted text-[11px] font-semibold tracking-wide uppercase",children:e}),p.jsx("dd",{className:"mt-1 text-[13.5px] break-words",children:t})]})}function kM({item:e}){if(e.kind==="folder")return p.jsx(wi,{className:"h-6 w-6 shrink-0 text-gold","aria-hidden":"true"});const{Icon:t,color:s}=Kn(e.mimeType);return p.jsx(t,{className:`h-6 w-6 shrink-0 ${s}`,"aria-hidden":"true"})}function Ho({item:e,onClose:t,onAction:s}){var o,l,u;const i=mn();return S.useEffect(()=>{if(e===null)return;const d=h=>{h.key==="Escape"&&t()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e,t]),e===null?null:p.jsxs("div",{className:"fixed inset-0 z-[100] flex items-end justify-end sm:items-stretch",children:[p.jsx("div",{className:"absolute inset-0 bg-black/40",onClick:t,"aria-hidden":"true"}),p.jsxs(Qt.aside,{role:"dialog","aria-modal":"true","aria-label":`Details for ${e.name}`,initial:i?{opacity:0}:{x:"100%"},animate:i?{opacity:1}:{x:0},transition:{duration:.22,ease:"easeOut"},className:"glass-strong relative flex max-h-[85dvh] w-full flex-col rounded-t-2xl border border-line sm:h-full sm:max-h-none sm:w-96 sm:rounded-none sm:border-r-0",children:[p.jsxs("header",{className:"flex items-start justify-between gap-3 border-b border-line/70 px-5 py-4",children:[p.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[p.jsx(kM,{item:e}),p.jsx("h2",{className:"min-w-0 text-[15px] font-semibold break-words",children:e.name})]}),p.jsx("button",{type:"button","aria-label":"Close details",onClick:t,className:"muted grid h-8 w-8 shrink-0 place-items-center rounded-lg transition-colors hover:bg-bg-soft hover:text-gold-text",children:p.jsx(cn,{className:"h-4 w-4","aria-hidden":"true"})})]}),p.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:[e.trashed?null:p.jsx("div",{className:"flex flex-wrap gap-2",children:e.kind==="file"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"btn-secondary",onClick:()=>s("download",e),children:[p.jsx(ih,{className:"h-4 w-4","aria-hidden":"true"}),"Download"]}),p.jsxs("button",{type:"button",className:"btn-secondary",onClick:()=>s("replace",e),children:[p.jsx(u1,{className:"h-4 w-4","aria-hidden":"true"}),"New version"]})]}):null}),p.jsxs("dl",{className:"mt-5 grid gap-4",children:[p.jsxs(gr,{label:"Type",children:[e.kind==="folder"?"Folder":Kn(e.mimeType).label,e.kind==="file"?p.jsxs("span",{className:"muted",children:[" · ",e.mimeType]}):null]}),e.kind==="file"?p.jsx(gr,{label:"Size",children:jt(e.size)}):null,e.kind==="file"?p.jsx(gr,{label:"SHA-256",children:p.jsx("code",{className:"font-mono text-[12px] break-all select-all",children:((o=e.file)==null?void 0:o.sha256)??""})}):null,p.jsx(gr,{label:"Folder",children:e.kind==="file"?((l=e.file)==null?void 0:l.folderId)??"My Drive":((u=e.folder)==null?void 0:u.parentId)??"My Drive"}),p.jsx(gr,{label:"Created",children:Ys(e.createdAt)}),p.jsx(gr,{label:"Modified",children:Ys(e.updatedAt)}),e.trashed&&e.deletedAt!==null?p.jsx(gr,{label:"Deleted",children:Ys(e.deletedAt)}):null,e.kind==="file"?p.jsx(gr,{label:"Versions",children:Nn(e.versionCount,"version")}):null]}),e.kind==="file"?p.jsx(CM,{fileId:e.id,versionCount:e.versionCount}):null]})]})]})}function CM({fileId:e,versionCount:t}){var i,o;const s=Dr({queryKey:["versions",e],queryFn:()=>we.files.versions(e)});return p.jsxs("section",{className:"mt-6",children:[p.jsx("h3",{className:"eyebrow",children:"Version history"}),s.isPending?p.jsx("p",{className:"muted mt-3 text-[13px]",children:"Loading versions..."}):s.error!==null?p.jsx("p",{className:"mt-3 text-[13px] text-bad",children:ze(s.error,"Could not load versions")}):(((i=s.data)==null?void 0:i.versions.length)??0)===0?p.jsx("p",{className:"muted mt-3 text-[13px]",children:t>1?"Version history is unavailable.":"No earlier versions."}):p.jsx("ul",{className:"mt-3 grid gap-2",children:(((o=s.data)==null?void 0:o.versions)??[]).map(l=>p.jsxs("li",{className:"flex items-center gap-3 rounded-xl border border-line bg-surface px-3 py-2",children:[p.jsxs("span",{className:"muted w-9 shrink-0 font-mono text-[12px]",children:["v",l.versionNumber]}),p.jsxs("span",{className:"min-w-0 flex-1",children:[p.jsx("span",{className:"block text-[12.5px]",children:jt(l.size)}),p.jsx("span",{className:"muted block text-[11px]",children:Ys(l.createdAt)})]}),l.isCurrent?p.jsx("span",{className:"shrink-0 rounded-full border border-gold/50 bg-gold-soft px-2 py-0.5 text-[11px] font-medium text-gold-text",children:"Current"}):null]},l.id))})]})}function Jl({icon:e,title:t,description:s,children:i}){return p.jsxs("div",{className:"mt-16 flex flex-col items-center px-4 text-center",children:[p.jsx("span",{className:"grid h-16 w-16 place-items-center rounded-full border border-gold/50 bg-gold-soft",children:p.jsx(e,{className:"h-7 w-7 text-gold","aria-hidden":"true"})}),p.jsx("h2",{className:"mt-4 text-base font-semibold",children:t}),s!==void 0?p.jsx("p",{className:"muted mt-1 max-w-sm text-sm",children:s}):null,i!==void 0?p.jsx("div",{className:"mt-5 flex flex-wrap justify-center gap-2.5",children:i}):null]})}function J0({label:e,items:t,trigger:s,triggerClassName:i,align:o="end"}){const[l,u]=S.useState(!1),d=mn(),h=S.useRef(null),m=S.useRef(null),y=S.useRef(null);S.useEffect(()=>{if(!l)return;const k=T=>{var P;T.target instanceof Node&&((P=h.current)==null?void 0:P.contains(T.target))===!1&&u(!1)},E=T=>{var P;T.key==="Escape"&&(u(!1),(P=m.current)==null||P.focus())};return document.addEventListener("pointerdown",k),document.addEventListener("keydown",E),()=>{document.removeEventListener("pointerdown",k),document.removeEventListener("keydown",E)}},[l]);const v=k=>{var T,P;const E=(T=y.current)==null?void 0:T.querySelectorAll("[role='menuitem']");(P=E==null?void 0:E[k])==null||P.focus()},x=(k,E)=>{var b,M;const T=Array.from(((b=y.current)==null?void 0:b.querySelectorAll("[role='menuitem']"))??[]);if(T.length===0)return;const L=(T.indexOf(k)+E+T.length)%T.length;(M=T[L])==null||M.focus()},C=d?0:-6;return p.jsxs("div",{ref:h,className:"relative",children:[p.jsx("button",{ref:m,type:"button","aria-label":e,"aria-haspopup":"menu","aria-expanded":l,onClick:()=>u(k=>!k),onKeyDown:k=>{k.key==="ArrowDown"&&(k.preventDefault(),l?v(0):(u(!0),window.requestAnimationFrame(()=>v(0))))},className:i??"muted grid h-8 w-8 place-items-center rounded-lg transition-colors hover:bg-bg-soft hover:text-gold-text",children:s??p.jsx(gT,{className:"h-4 w-4","aria-hidden":"true"})}),p.jsx(Lr,{children:l?p.jsx(Qt.div,{ref:y,role:"menu","aria-label":e,initial:{opacity:0,y:C},animate:{opacity:1,y:0},exit:{opacity:0,y:C},transition:{duration:.15,ease:"easeOut"},className:`menu-panel absolute top-full z-20 mt-1.5 w-48 ${o==="end"?"right-0":"left-0"}`,children:t.map(k=>p.jsxs("button",{role:"menuitem",type:"button",disabled:k.disabled===!0,onClick:()=>{u(!1),k.onSelect()},onKeyDown:E=>{E.key==="ArrowDown"?(E.preventDefault(),x(E.currentTarget,1)):E.key==="ArrowUp"&&(E.preventDefault(),x(E.currentTarget,-1))},className:`menu-item text-left ${k.danger===!0?"menu-item-danger":""}`,children:[k.icon,k.label]},k.label))},"item-menu"):null})]})}function Z0({checked:e,visible:t,label:s,onToggle:i}){return p.jsx("button",{type:"button",role:"checkbox","aria-checked":e,"aria-label":s,onClick:o=>{o.stopPropagation(),i({shiftKey:o.shiftKey,metaKey:o.metaKey,ctrlKey:o.ctrlKey})},onPointerDown:o=>o.stopPropagation(),className:`grid h-5 w-5 shrink-0 place-items-center rounded-md border transition-all ${e?"border-gold bg-gold text-gold-ink opacity-100":`border-line-strong bg-surface text-transparent hover:border-gold ${t?"opacity-100":"opacity-0 group-hover:opacity-100 focus-visible:opacity-100"}`}`,children:p.jsx(sh,{className:"h-3 w-3","aria-hidden":"true"})})}function Cd(e,t,s={}){const i=e.kind==="file",o=[];return e.trashed?(o.push({label:"Restore",icon:p.jsx(oh,{className:"h-4 w-4","aria-hidden":"true"}),onSelect:()=>t("restore",e)}),o.push({label:"Delete permanently",icon:p.jsx(br,{className:"h-4 w-4","aria-hidden":"true"}),danger:!0,onSelect:()=>t("delete",e)})):(o.push({label:i?"Download":"Open",icon:i?p.jsx(ih,{className:"h-4 w-4","aria-hidden":"true"}):p.jsx(hf,{className:"h-4 w-4","aria-hidden":"true"}),onSelect:()=>t(i?"download":"open",e)}),i&&o.push({label:"Details",icon:p.jsx(kT,{className:"h-4 w-4","aria-hidden":"true"}),onSelect:()=>t("details",e)}),o.push({label:"Rename",icon:p.jsx(RT,{className:"h-4 w-4","aria-hidden":"true"}),onSelect:()=>t("rename",e)}),o.push({label:"Move",icon:p.jsx(hf,{className:"h-4 w-4","aria-hidden":"true"}),onSelect:()=>t("move",e)}),o.push({label:e.starred?"Unstar":"Star",icon:e.starred?p.jsx(ah,{className:"h-4 w-4","aria-hidden":"true"}):p.jsx(ps,{className:"h-4 w-4","aria-hidden":"true"}),onSelect:()=>t(e.starred?"unstar":"star",e)}),i&&s.canReplace===!0&&o.push({label:"Upload new version",icon:p.jsx(u1,{className:"h-4 w-4","aria-hidden":"true"}),onSelect:()=>t("replace",e)}),o.push({label:"Move to trash",icon:p.jsx(br,{className:"h-4 w-4","aria-hidden":"true"}),danger:!0,onSelect:()=>t("trash",e)})),o}function EM({item:e}){if(e.kind==="folder")return p.jsx(wi,{className:"h-5 w-5 shrink-0 text-gold","aria-hidden":"true"});const{Icon:t,color:s}=Kn(e.mimeType);return p.jsx(t,{className:`h-5 w-5 shrink-0 ${s}`,"aria-hidden":"true"})}function TM({view:e}){const t=[0,1,2,3,4];return e==="grid"?p.jsx("div",{"aria-hidden":"true",className:"grid grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-4",children:t.map(s=>p.jsx("div",{className:"card h-40 animate-pulse bg-bg-soft"},s))}):p.jsx("div",{"aria-hidden":"true",className:"grid gap-2",children:t.map(s=>p.jsx("div",{className:"h-14 animate-pulse rounded-xl border border-line bg-bg-soft"},s))})}function PM({items:e,view:t,selection:s,onOpen:i,onAction:o,onContextMenu:l,menuContext:u={},loading:d=!1}){const h=e.map(ln),m=(v,x)=>{if(v.metaKey||v.ctrlKey){s.toggle(cl(x));return}if(v.shiftKey){s.toggle(cl(x),{orderedKeys:h,range:!0});return}i(x)},y=(v,x)=>{v.preventDefault(),l({x:v.clientX,y:v.clientY,label:`Actions for ${x.name}`,items:Cd(x,o,u)})};return d?p.jsx(TM,{view:t}):e.length===0?null:t==="grid"?p.jsx("ul",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-4",children:e.map(v=>{const x=s.isSelected(ln(v));return p.jsxs("li",{onClick:C=>m(C,v),onContextMenu:C=>y(C,v),className:`group relative flex cursor-pointer flex-col gap-3 rounded-2xl border bg-surface p-4 transition-colors ${x?"border-gold bg-gold-soft":"border-line hover:border-gold/40 hover:bg-bg-soft"} ${v.trashed?"opacity-70":""}`,children:[p.jsx("div",{className:"absolute top-3 left-3",onClick:C=>C.stopPropagation(),children:p.jsx(Z0,{checked:x,visible:x||s.count>0,label:`Select ${v.name}`,onToggle:C=>s.toggle(cl(v),{orderedKeys:h,range:C.shiftKey})})}),p.jsx("div",{className:"absolute top-3 right-3",onClick:C=>C.stopPropagation(),children:p.jsx(J0,{label:`Actions for ${v.name}`,items:Cd(v,o,u)})}),p.jsx("div",{className:"mt-6 flex flex-1 items-center justify-center",children:v.kind==="folder"?p.jsx(wi,{className:"h-10 w-10 text-gold","aria-hidden":"true"}):(()=>{const{Icon:C,color:k}=Kn(v.mimeType);return p.jsx(C,{className:`h-10 w-10 ${k}`,"aria-hidden":"true"})})()}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("p",{className:"line-clamp-2 text-[13px] leading-snug font-medium",title:v.name,children:v.name}),p.jsxs("p",{className:"muted mt-1 truncate text-[12px]",children:[v.starred?p.jsx(ps,{className:"mr-1 inline h-3 w-3 -translate-y-px text-gold","aria-hidden":"true"}):null,v.kind==="folder"?"Folder":`${jt(v.size)} · ${Kn(v.mimeType).label}`]}),v.deletedAt!==null?p.jsxs("p",{className:"muted mt-0.5 text-[11px]",children:["Deleted ",Of(v.deletedAt)]}):null]})]},ln(v))})}):p.jsx("ul",{className:"grid gap-1.5",children:e.map(v=>{const x=s.isSelected(ln(v));return p.jsxs("li",{onClick:C=>m(C,v),onContextMenu:C=>y(C,v),className:`group flex cursor-pointer items-center gap-3 rounded-xl border bg-surface px-3 py-2.5 transition-colors ${x?"border-gold bg-gold-soft":"border-line hover:border-gold/40 hover:bg-bg-soft"} ${v.trashed?"opacity-70":""}`,children:[p.jsx("div",{onClick:C=>C.stopPropagation(),children:p.jsx(Z0,{checked:x,visible:x||s.count>0,label:`Select ${v.name}`,onToggle:C=>s.toggle(cl(v),{orderedKeys:h,range:C.shiftKey})})}),p.jsx(EM,{item:v}),p.jsxs("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",title:v.name,children:[v.starred?p.jsx(ps,{className:"mr-1.5 inline h-3.5 w-3.5 -translate-y-px text-gold","aria-hidden":"true"}):null,v.name]}),v.deletedAt!==null?p.jsxs("span",{className:"muted hidden shrink-0 text-[12px] sm:block",children:["Deleted ",Of(v.deletedAt)]}):null,p.jsx("span",{className:"muted hidden w-40 shrink-0 truncate text-[12.5px] md:block",children:v.kind==="folder"?"Folder":Kn(v.mimeType).label}),p.jsx("span",{className:"muted hidden w-28 shrink-0 text-right text-[12.5px] lg:block",children:Qj(v.updatedAt)}),p.jsx("span",{className:"muted w-16 shrink-0 text-right text-[12.5px] tabular-nums",children:v.kind==="folder"?"—":jt(v.size)}),p.jsx("div",{onClick:C=>C.stopPropagation(),children:p.jsx(J0,{label:`Actions for ${v.name}`,items:Cd(v,o,u)})})]},ln(v))})})}function Jh({items:e,view:t,selection:s,onOpen:i,onAction:o,onContextMenu:l,menuContext:u,loading:d=!1,error:h=null,onRetry:m,emptyState:y,hasMore:v=!1,loadingMore:x=!1,onLoadMore:C}){return h!==null?p.jsxs("div",{className:"card mt-6 p-6 text-center",children:[p.jsx("p",{className:"text-sm font-medium",children:"Something went wrong."}),p.jsx("p",{className:"muted mt-1 text-sm",children:h}),m!==void 0?p.jsx("button",{type:"button",className:"btn-secondary mt-4",onClick:m,children:"Try again"}):null]}):e.length===0&&y!==void 0?p.jsx(p.Fragment,{children:y}):p.jsxs(p.Fragment,{children:[p.jsx(PM,{items:e,view:t,selection:s,onOpen:i,onAction:o,onContextMenu:l,...u!==void 0?{menuContext:u}:{},loading:d}),v&&C!==void 0?p.jsx("div",{className:"mt-6 flex justify-center",children:p.jsx("button",{type:"button",className:"btn-secondary",onClick:C,disabled:x,children:x?"Loading...":"Load more"})}):null]})}function hi({title:e,actions:t,children:s}){return p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsx("div",{className:"min-w-0",children:e}),t!==void 0?p.jsx("div",{className:"flex flex-wrap items-center gap-2.5",children:t}):null,s!==void 0?p.jsx("div",{className:"w-full",children:s}):null]})}function pi({children:e}){return p.jsx("h1",{className:"min-w-0 truncate text-lg font-semibold tracking-[-0.01em]",children:e})}function Zh({count:e,onClear:t,onSelectAll:s,children:i}){const o=mn(),l=e>0;return p.jsx(Lr,{children:l?p.jsxs(Qt.div,{role:"toolbar","aria-label":`${e} items selected`,initial:{opacity:0,y:o?0:20},animate:{opacity:1,y:0},exit:{opacity:0,y:o?0:20},transition:{duration:.18,ease:"easeOut"},className:"glass-strong fixed bottom-4 left-1/2 z-[90] flex max-w-[calc(100vw-2rem)] -translate-x-1/2 flex-wrap items-center gap-1.5 rounded-2xl border border-line px-3 py-2",children:[p.jsxs("span",{className:"px-2 text-[13px] font-medium tabular-nums",children:[e," selected"]}),p.jsx("span",{className:"text-line-strong","aria-hidden":"true",children:"·"}),s!==void 0?p.jsxs("button",{type:"button",className:"btn-secondary",onClick:s,children:[p.jsx(cT,{className:"h-4 w-4","aria-hidden":"true"}),"Select all"]}):null,i,p.jsxs("button",{type:"button",className:"btn-ghost",onClick:t,"aria-label":"Clear selection",children:[p.jsx(cn,{className:"h-4 w-4","aria-hidden":"true"}),"Clear"]})]},"selection-bar"):null})}const Ed={name:"Name",size:"Size",createdAt:"Date created",updatedAt:"Last modified",type:"Type"};function NM({sort:e,order:t,onChange:s}){const[i,o]=S.useState(!1),l=mn(),u=S.useRef(null);S.useEffect(()=>{if(!i)return;const m=v=>{var x;v.target instanceof Node&&((x=u.current)==null?void 0:x.contains(v.target))===!1&&o(!1)},y=v=>{v.key==="Escape"&&o(!1)};return document.addEventListener("pointerdown",m),document.addEventListener("keydown",y),()=>{document.removeEventListener("pointerdown",m),document.removeEventListener("keydown",y)}},[i]);const d=Object.keys(Ed),h=l?0:-6;return p.jsxs("div",{ref:u,className:"relative shrink-0",children:[p.jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":i,onClick:()=>o(m=>!m),className:"btn-secondary",children:[p.jsx(uT,{className:"h-4 w-4","aria-hidden":"true"}),p.jsx("span",{className:"hidden sm:inline",children:Ed[e]}),t==="asc"?p.jsx(Cy,{className:"h-3.5 w-3.5","aria-hidden":"true"}):p.jsx(ky,{className:"h-3.5 w-3.5","aria-hidden":"true"})]}),p.jsx(Lr,{children:i?p.jsx(Qt.div,{role:"menu","aria-label":"Sort by",initial:{opacity:0,y:h},animate:{opacity:1,y:0},exit:{opacity:0,y:h},transition:{duration:.15,ease:"easeOut"},className:"menu-panel absolute top-full right-0 z-30 mt-1.5 w-52",children:d.map(m=>p.jsxs("button",{role:"menuitemradio","aria-checked":e===m,type:"button",onClick:()=>{e===m?s(m,t==="asc"?"desc":"asc"):s(m,"asc")},className:"menu-item justify-between text-left",children:[Ed[m],e===m?t==="asc"?p.jsx(Cy,{className:"h-3.5 w-3.5","aria-hidden":"true"}):p.jsx(ky,{className:"h-3.5 w-3.5","aria-hidden":"true"}):null]},m))}):null})]})}function ep({view:e,onChange:t}){const s=[{mode:"list",label:"List view",Icon:TT},{mode:"grid",label:"Grid view",Icon:ET}];return p.jsx("div",{role:"group","aria-label":"View mode",className:"inline-flex shrink-0 rounded-lg border border-line-strong bg-surface p-0.5",children:s.map(({mode:i,label:o,Icon:l})=>{const u=e===i;return p.jsx("button",{type:"button","aria-label":o,"aria-pressed":u,onClick:()=>t(i),className:`grid h-7 w-8 place-items-center rounded-md transition-colors ${u?"bg-gold-soft text-gold-text":"muted hover:text-gold-text"}`,children:p.jsx(l,{className:"h-4 w-4","aria-hidden":"true"})},i)})})}const ev=100;function dl(e){return e.dataTransfer.types.includes("Files")}function bM(){const{uploads:e,setActiveFolderId:t,openCreateFolder:s,clearSearch:i}=Xl(),[o,l]=WE(),u=o.get("folder"),[d,h]=Qh("omnicloud-view","list",$h),[m,y]=S.useState("name"),[v,x]=S.useState("asc"),[C,k]=S.useState(null),[E,T]=S.useState(null),P=Yh(),[L,b]=S.useState(!1),M=S.useRef(0);S.useEffect(()=>{t(u)},[u,t]);const _=Dr({queryKey:Bh,queryFn:we.folders.tree}),I=S.useMemo(()=>{var F;return Kh(((F=_.data)==null?void 0:F.folders)??[])},[_.data]),R=S.useMemo(()=>yM(I,u),[I,u]),D=Mo({queryKey:["folders","children",u,m,v],queryFn:F=>we.folders.list({parentId:u,page:F,limit:ev,sort:m,order:v,status:"active"}).then(ne=>({items:ne.folders,pagination:ne.pagination}))}),B=Mo({queryKey:["files","folder",u,m,v],queryFn:F=>we.files.list({folderId:u,page:F,limit:ev,sort:m,order:v,status:"active"}).then(ne=>({items:ne.files,pagination:ne.pagination}))}),W=S.useMemo(()=>[...D.items.map(Uh),...B.items.map(Ci)],[D.items,B.items]),G=S.useMemo(()=>W.map(ln),[W]);S.useEffect(()=>{P.prune(G)},[G,P]);const K=S.useCallback(F=>{i(),P.clear(),T(null),l(F===null?{}:{folder:F},{replace:!1})},[i,P,l]),U=qh({onOpenItem:F=>{F.kind==="folder"?K(F.id):we.files.download(F.id)},onShowDetails:T,onReplaceFile:e.replace}),X=S.useMemo(()=>W.filter(F=>P.isSelected(ln(F))),[W,P]);S.useEffect(()=>{const F=pr(D.error,rn.NOT_FOUND,rn.FOLDER_NOT_FOUND)||pr(B.error,rn.NOT_FOUND,rn.FOLDER_NOT_FOUND);u!==null&&F&&l({},{replace:!0})},[u,D.error,B.error,l]),Gh({onDelete:()=>U.runBatch("trash",X),onEnter:()=>{const F=X[0];F!==void 0&&U.handleAction(F.kind==="folder"?"open":"download",F)},onSelectAll:()=>P.selectAll(G),onEscape:()=>T(null)});const ge=pr(D.error,rn.STORAGE_NOT_INITIALIZED)||pr(B.error,rn.STORAGE_NOT_INITIALIZED)||pr(D.error,rn.TELEGRAM_AUTH_REQUIRED)||pr(B.error,rn.TELEGRAM_AUTH_REQUIRED)||pr(D.error,rn.STORAGE_UNAVAILABLE)||pr(B.error,rn.STORAGE_UNAVAILABLE),me=D.error??B.error,Ee=D.isLoading||B.isLoading,ee=F=>{dl(F)&&(F.preventDefault(),M.current+=1,b(!0))},ue=F=>{dl(F)&&(M.current-=1,M.current<=0&&(M.current=0,b(!1)))},J=F=>{dl(F)&&F.preventDefault()},V=F=>{if(!dl(F))return;F.preventDefault(),M.current=0,b(!1);const ne=Array.from(F.dataTransfer.files);ne.length>0&&e.enqueue(ne,u)};return p.jsxs("div",{className:"relative min-h-full",onDragEnter:ee,onDragLeave:ue,onDragOver:J,onDrop:V,children:[p.jsxs("div",{className:"mx-auto max-w-6xl px-4 py-6 md:px-8",children:[p.jsx(hi,{title:u===null?p.jsx(pi,{children:"My Drive"}):p.jsx(SM,{path:R,onNavigate:K}),actions:p.jsxs(p.Fragment,{children:[p.jsx(ep,{view:d,onChange:h}),p.jsx(NM,{sort:m,order:v,onChange:(F,ne)=>{y(F),x(ne)}}),p.jsxs("button",{type:"button",className:"btn-secondary sm:hidden",onClick:()=>e.openPicker(u),children:[p.jsx(bl,{className:"h-4 w-4","aria-hidden":"true"}),"Upload"]})]})}),ge?p.jsx("p",{role:"alert",className:"notice notice-error",children:ze(me,"Your storage is unavailable right now.")}):null,p.jsx("div",{className:"mt-5",children:p.jsx(Jh,{items:W,view:d,selection:P,onOpen:F=>U.handleAction(F.kind==="folder"?"open":"download",F),onAction:U.handleAction,onContextMenu:k,loading:Ee,error:ge||me===null?null:ze(me,"Could not load this folder."),onRetry:()=>{D.refetch(),B.refetch()},hasMore:D.hasMore||B.hasMore,loadingMore:D.isLoadingMore||B.isLoadingMore,onLoadMore:()=>{D.hasMore&&D.loadMore(),B.hasMore&&B.loadMore()},emptyState:p.jsxs(Jl,{icon:mT,title:"Nothing here yet",description:"Upload your first file or create a folder to get started.",children:[p.jsxs("button",{type:"button",className:"btn-gold",onClick:()=>e.openPicker(u),children:[p.jsx(bl,{className:"h-4 w-4","aria-hidden":"true"}),"Upload files"]}),p.jsxs("button",{type:"button",className:"btn-secondary",onClick:s,children:[p.jsx(Gx,{className:"h-4 w-4","aria-hidden":"true"}),"New folder"]})]})})})]}),L?p.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 z-30 flex items-center justify-center bg-bg/70 p-6 backdrop-blur-sm",children:p.jsx("div",{className:"glass-strong rounded-2xl border-2 border-dashed border-gold/60 px-8 py-6 text-sm font-medium text-gold-text",children:"Drop files to upload"})}):null,p.jsxs(Zh,{count:P.count,onClear:P.clear,onSelectAll:()=>P.selectAll(G),children:[p.jsxs("button",{type:"button",className:"btn-secondary",onClick:()=>U.openMove(X),children:[p.jsx(hf,{className:"h-4 w-4","aria-hidden":"true"}),"Move"]}),p.jsxs("button",{type:"button",className:"btn-secondary",onClick:()=>U.runBatch("star",X),children:[p.jsx(ps,{className:"h-4 w-4","aria-hidden":"true"}),"Star"]}),p.jsxs("button",{type:"button",className:"btn-secondary",onClick:()=>U.runBatch("unstar",X),children:[p.jsx(ah,{className:"h-4 w-4","aria-hidden":"true"}),"Unstar"]}),p.jsxs("button",{type:"button",className:"btn-danger",onClick:()=>U.runBatch("trash",X),children:[p.jsx(br,{className:"h-4 w-4","aria-hidden":"true"}),"Trash"]})]}),p.jsx(Xh,{menu:C,onClose:()=>k(null)}),p.jsx(Ho,{item:E,onClose:()=>T(null),onAction:U.handleAction}),U.dialogs]})}var Hs={},Td,tv;function RM(){return tv||(tv=1,Td=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Td}var Pd={},yr={},nv;function ys(){if(nv)return yr;nv=1;let e;const t=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return yr.getSymbolSize=function(i){if(!i)throw new Error('"version" cannot be null or undefined');if(i<1||i>40)throw new Error('"version" should be in range from 1 to 40');return i*4+17},yr.getSymbolTotalCodewords=function(i){return t[i]},yr.getBCHDigit=function(s){let i=0;for(;s!==0;)i++,s>>>=1;return i},yr.setToSJISFunction=function(i){if(typeof i!="function")throw new Error('"toSJISFunc" is not a valid function.');e=i},yr.isKanjiModeEnabled=function(){return typeof e<"u"},yr.toSJIS=function(i){return e(i)},yr}var Nd={},rv;function tp(){return rv||(rv=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(s){if(typeof s!="string")throw new Error("Param is not a string");switch(s.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+s)}}e.isValid=function(i){return i&&typeof i.bit<"u"&&i.bit>=0&&i.bit<4},e.from=function(i,o){if(e.isValid(i))return i;try{return t(i)}catch{return o}}})(Nd)),Nd}var bd,sv;function jM(){if(sv)return bd;sv=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(t){const s=Math.floor(t/8);return(this.buffer[s]>>>7-t%8&1)===1},put:function(t,s){for(let i=0;i<s;i++)this.putBit((t>>>s-i-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const s=Math.floor(this.length/8);this.buffer.length<=s&&this.buffer.push(0),t&&(this.buffer[s]|=128>>>this.length%8),this.length++}},bd=e,bd}var Rd,iv;function MM(){if(iv)return Rd;iv=1;function e(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return e.prototype.set=function(t,s,i,o){const l=t*this.size+s;this.data[l]=i,o&&(this.reservedBit[l]=!0)},e.prototype.get=function(t,s){return this.data[t*this.size+s]},e.prototype.xor=function(t,s,i){this.data[t*this.size+s]^=i},e.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},Rd=e,Rd}var jd={},ov;function DM(){return ov||(ov=1,(function(e){const t=ys().getSymbolSize;e.getRowColCoords=function(i){if(i===1)return[];const o=Math.floor(i/7)+2,l=t(i),u=l===145?26:Math.ceil((l-13)/(2*o-2))*2,d=[l-7];for(let h=1;h<o-1;h++)d[h]=d[h-1]-u;return d.push(6),d.reverse()},e.getPositions=function(i){const o=[],l=e.getRowColCoords(i),u=l.length;for(let d=0;d<u;d++)for(let h=0;h<u;h++)d===0&&h===0||d===0&&h===u-1||d===u-1&&h===0||o.push([l[d],l[h]]);return o}})(jd)),jd}var Md={},av;function AM(){if(av)return Md;av=1;const e=ys().getSymbolSize,t=7;return Md.getPositions=function(i){const o=e(i);return[[0,0],[o-t,0],[0,o-t]]},Md}var Dd={},lv;function LM(){return lv||(lv=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(o){return o!=null&&o!==""&&!isNaN(o)&&o>=0&&o<=7},e.from=function(o){return e.isValid(o)?parseInt(o,10):void 0},e.getPenaltyN1=function(o){const l=o.size;let u=0,d=0,h=0,m=null,y=null;for(let v=0;v<l;v++){d=h=0,m=y=null;for(let x=0;x<l;x++){let C=o.get(v,x);C===m?d++:(d>=5&&(u+=t.N1+(d-5)),m=C,d=1),C=o.get(x,v),C===y?h++:(h>=5&&(u+=t.N1+(h-5)),y=C,h=1)}d>=5&&(u+=t.N1+(d-5)),h>=5&&(u+=t.N1+(h-5))}return u},e.getPenaltyN2=function(o){const l=o.size;let u=0;for(let d=0;d<l-1;d++)for(let h=0;h<l-1;h++){const m=o.get(d,h)+o.get(d,h+1)+o.get(d+1,h)+o.get(d+1,h+1);(m===4||m===0)&&u++}return u*t.N2},e.getPenaltyN3=function(o){const l=o.size;let u=0,d=0,h=0;for(let m=0;m<l;m++){d=h=0;for(let y=0;y<l;y++)d=d<<1&2047|o.get(m,y),y>=10&&(d===1488||d===93)&&u++,h=h<<1&2047|o.get(y,m),y>=10&&(h===1488||h===93)&&u++}return u*t.N3},e.getPenaltyN4=function(o){let l=0;const u=o.data.length;for(let h=0;h<u;h++)l+=o.data[h];return Math.abs(Math.ceil(l*100/u/5)-10)*t.N4};function s(i,o,l){switch(i){case e.Patterns.PATTERN000:return(o+l)%2===0;case e.Patterns.PATTERN001:return o%2===0;case e.Patterns.PATTERN010:return l%3===0;case e.Patterns.PATTERN011:return(o+l)%3===0;case e.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(l/3))%2===0;case e.Patterns.PATTERN101:return o*l%2+o*l%3===0;case e.Patterns.PATTERN110:return(o*l%2+o*l%3)%2===0;case e.Patterns.PATTERN111:return(o*l%3+(o+l)%2)%2===0;default:throw new Error("bad maskPattern:"+i)}}e.applyMask=function(o,l){const u=l.size;for(let d=0;d<u;d++)for(let h=0;h<u;h++)l.isReserved(h,d)||l.xor(h,d,s(o,h,d))},e.getBestMask=function(o,l){const u=Object.keys(e.Patterns).length;let d=0,h=1/0;for(let m=0;m<u;m++){l(m),e.applyMask(m,o);const y=e.getPenaltyN1(o)+e.getPenaltyN2(o)+e.getPenaltyN3(o)+e.getPenaltyN4(o);e.applyMask(m,o),y<h&&(h=y,d=m)}return d}})(Dd)),Dd}var fl={},uv;function gS(){if(uv)return fl;uv=1;const e=tp(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],s=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return fl.getBlocksCount=function(o,l){switch(l){case e.L:return t[(o-1)*4+0];case e.M:return t[(o-1)*4+1];case e.Q:return t[(o-1)*4+2];case e.H:return t[(o-1)*4+3];default:return}},fl.getTotalCodewordsCount=function(o,l){switch(l){case e.L:return s[(o-1)*4+0];case e.M:return s[(o-1)*4+1];case e.Q:return s[(o-1)*4+2];case e.H:return s[(o-1)*4+3];default:return}},fl}var Ad={},mo={},cv;function IM(){if(cv)return mo;cv=1;const e=new Uint8Array(512),t=new Uint8Array(256);return(function(){let i=1;for(let o=0;o<255;o++)e[o]=i,t[i]=o,i<<=1,i&256&&(i^=285);for(let o=255;o<512;o++)e[o]=e[o-255]})(),mo.log=function(i){if(i<1)throw new Error("log("+i+")");return t[i]},mo.exp=function(i){return e[i]},mo.mul=function(i,o){return i===0||o===0?0:e[t[i]+t[o]]},mo}var dv;function FM(){return dv||(dv=1,(function(e){const t=IM();e.mul=function(i,o){const l=new Uint8Array(i.length+o.length-1);for(let u=0;u<i.length;u++)for(let d=0;d<o.length;d++)l[u+d]^=t.mul(i[u],o[d]);return l},e.mod=function(i,o){let l=new Uint8Array(i);for(;l.length-o.length>=0;){const u=l[0];for(let h=0;h<o.length;h++)l[h]^=t.mul(o[h],u);let d=0;for(;d<l.length&&l[d]===0;)d++;l=l.slice(d)}return l},e.generateECPolynomial=function(i){let o=new Uint8Array([1]);for(let l=0;l<i;l++)o=e.mul(o,new Uint8Array([1,t.exp(l)]));return o}})(Ad)),Ad}var Ld,fv;function _M(){if(fv)return Ld;fv=1;const e=FM();function t(s){this.genPoly=void 0,this.degree=s,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(i){this.degree=i,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(i){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(i.length+this.degree);o.set(i);const l=e.mod(o,this.genPoly),u=this.degree-l.length;if(u>0){const d=new Uint8Array(this.degree);return d.set(l,u),d}return l},Ld=t,Ld}var Id={},Fd={},_d={},hv;function yS(){return hv||(hv=1,_d.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),_d}var Sn={},pv;function vS(){if(pv)return Sn;pv=1;const e="[0-9]+",t="[A-Z $%*+\\-./:]+";let s="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";s=s.replace(/u/g,"\\u");const i="(?:(?![A-Z0-9 $%*+\\-./:]|"+s+`)(?:.|[\r
|
|
340
340
|
]))+`;Sn.KANJI=new RegExp(s,"g"),Sn.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Sn.BYTE=new RegExp(i,"g"),Sn.NUMERIC=new RegExp(e,"g"),Sn.ALPHANUMERIC=new RegExp(t,"g");const o=new RegExp("^"+s+"$"),l=new RegExp("^"+e+"$"),u=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Sn.testKanji=function(h){return o.test(h)},Sn.testNumeric=function(h){return l.test(h)},Sn.testAlphanumeric=function(h){return u.test(h)},Sn}var mv;function vs(){return mv||(mv=1,(function(e){const t=yS(),s=vS();e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(l,u){if(!l.ccBits)throw new Error("Invalid mode: "+l);if(!t.isValid(u))throw new Error("Invalid version: "+u);return u>=1&&u<10?l.ccBits[0]:u<27?l.ccBits[1]:l.ccBits[2]},e.getBestModeForData=function(l){return s.testNumeric(l)?e.NUMERIC:s.testAlphanumeric(l)?e.ALPHANUMERIC:s.testKanji(l)?e.KANJI:e.BYTE},e.toString=function(l){if(l&&l.id)return l.id;throw new Error("Invalid mode")},e.isValid=function(l){return l&&l.bit&&l.ccBits};function i(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+o)}}e.from=function(l,u){if(e.isValid(l))return l;try{return i(l)}catch{return u}}})(Fd)),Fd}var gv;function OM(){return gv||(gv=1,(function(e){const t=ys(),s=gS(),i=tp(),o=vs(),l=yS(),u=7973,d=t.getBCHDigit(u);function h(x,C,k){for(let E=1;E<=40;E++)if(C<=e.getCapacity(E,k,x))return E}function m(x,C){return o.getCharCountIndicator(x,C)+4}function y(x,C){let k=0;return x.forEach(function(E){const T=m(E.mode,C);k+=T+E.getBitsLength()}),k}function v(x,C){for(let k=1;k<=40;k++)if(y(x,k)<=e.getCapacity(k,C,o.MIXED))return k}e.from=function(C,k){return l.isValid(C)?parseInt(C,10):k},e.getCapacity=function(C,k,E){if(!l.isValid(C))throw new Error("Invalid QR Code version");typeof E>"u"&&(E=o.BYTE);const T=t.getSymbolTotalCodewords(C),P=s.getTotalCodewordsCount(C,k),L=(T-P)*8;if(E===o.MIXED)return L;const b=L-m(E,C);switch(E){case o.NUMERIC:return Math.floor(b/10*3);case o.ALPHANUMERIC:return Math.floor(b/11*2);case o.KANJI:return Math.floor(b/13);case o.BYTE:default:return Math.floor(b/8)}},e.getBestVersionForData=function(C,k){let E;const T=i.from(k,i.M);if(Array.isArray(C)){if(C.length>1)return v(C,T);if(C.length===0)return 1;E=C[0]}else E=C;return h(E.mode,E.getLength(),T)},e.getEncodedBits=function(C){if(!l.isValid(C)||C<7)throw new Error("Invalid QR Code version");let k=C<<12;for(;t.getBCHDigit(k)-d>=0;)k^=u<<t.getBCHDigit(k)-d;return C<<12|k}})(Id)),Id}var Od={},yv;function VM(){if(yv)return Od;yv=1;const e=ys(),t=1335,s=21522,i=e.getBCHDigit(t);return Od.getEncodedBits=function(l,u){const d=l.bit<<3|u;let h=d<<10;for(;e.getBCHDigit(h)-i>=0;)h^=t<<e.getBCHDigit(h)-i;return(d<<10|h)^s},Od}var Vd={},Bd,vv;function BM(){if(vv)return Bd;vv=1;const e=vs();function t(s){this.mode=e.NUMERIC,this.data=s.toString()}return t.getBitsLength=function(i){return 10*Math.floor(i/3)+(i%3?i%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(i){let o,l,u;for(o=0;o+3<=this.data.length;o+=3)l=this.data.substr(o,3),u=parseInt(l,10),i.put(u,10);const d=this.data.length-o;d>0&&(l=this.data.substr(o),u=parseInt(l,10),i.put(u,d*3+1))},Bd=t,Bd}var zd,xv;function zM(){if(xv)return zd;xv=1;const e=vs(),t=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function s(i){this.mode=e.ALPHANUMERIC,this.data=i}return s.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(o){let l;for(l=0;l+2<=this.data.length;l+=2){let u=t.indexOf(this.data[l])*45;u+=t.indexOf(this.data[l+1]),o.put(u,11)}this.data.length%2&&o.put(t.indexOf(this.data[l]),6)},zd=s,zd}var Ud,wv;function UM(){if(wv)return Ud;wv=1;const e=vs();function t(s){this.mode=e.BYTE,typeof s=="string"?this.data=new TextEncoder().encode(s):this.data=new Uint8Array(s)}return t.getBitsLength=function(i){return i*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(s){for(let i=0,o=this.data.length;i<o;i++)s.put(this.data[i],8)},Ud=t,Ud}var $d,Sv;function $M(){if(Sv)return $d;Sv=1;const e=vs(),t=ys();function s(i){this.mode=e.KANJI,this.data=i}return s.getBitsLength=function(o){return o*13},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(i){let o;for(o=0;o<this.data.length;o++){let l=t.toSJIS(this.data[o]);if(l>=33088&&l<=40956)l-=33088;else if(l>=57408&&l<=60351)l-=49472;else throw new Error("Invalid SJIS character: "+this.data[o]+`
|
|
341
341
|
Make sure your charset is UTF-8`);l=(l>>>8&255)*192+(l&255),i.put(l,13)}},$d=s,$d}var Hd={exports:{}},kv;function HM(){return kv||(kv=1,(function(e){var t={single_source_shortest_paths:function(s,i,o){var l={},u={};u[i]=0;var d=t.PriorityQueue.make();d.push(i,0);for(var h,m,y,v,x,C,k,E,T;!d.empty();){h=d.pop(),m=h.value,v=h.cost,x=s[m]||{};for(y in x)x.hasOwnProperty(y)&&(C=x[y],k=v+C,E=u[y],T=typeof u[y]>"u",(T||E>k)&&(u[y]=k,d.push(y,k),l[y]=m))}if(typeof o<"u"&&typeof u[o]>"u"){var P=["Could not find a path from ",i," to ",o,"."].join("");throw new Error(P)}return l},extract_shortest_path_from_predecessor_list:function(s,i){for(var o=[],l=i;l;)o.push(l),s[l],l=s[l];return o.reverse(),o},find_path:function(s,i,o){var l=t.single_source_shortest_paths(s,i,o);return t.extract_shortest_path_from_predecessor_list(l,o)},PriorityQueue:{make:function(s){var i=t.PriorityQueue,o={},l;s=s||{};for(l in i)i.hasOwnProperty(l)&&(o[l]=i[l]);return o.queue=[],o.sorter=s.sorter||i.default_sorter,o},default_sorter:function(s,i){return s.cost-i.cost},push:function(s,i){var o={value:s,cost:i};this.queue.push(o),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(Hd)),Hd.exports}var Cv;function KM(){return Cv||(Cv=1,(function(e){const t=vs(),s=BM(),i=zM(),o=UM(),l=$M(),u=vS(),d=ys(),h=HM();function m(P){return unescape(encodeURIComponent(P)).length}function y(P,L,b){const M=[];let _;for(;(_=P.exec(b))!==null;)M.push({data:_[0],index:_.index,mode:L,length:_[0].length});return M}function v(P){const L=y(u.NUMERIC,t.NUMERIC,P),b=y(u.ALPHANUMERIC,t.ALPHANUMERIC,P);let M,_;return d.isKanjiModeEnabled()?(M=y(u.BYTE,t.BYTE,P),_=y(u.KANJI,t.KANJI,P)):(M=y(u.BYTE_KANJI,t.BYTE,P),_=[]),L.concat(b,M,_).sort(function(R,D){return R.index-D.index}).map(function(R){return{data:R.data,mode:R.mode,length:R.length}})}function x(P,L){switch(L){case t.NUMERIC:return s.getBitsLength(P);case t.ALPHANUMERIC:return i.getBitsLength(P);case t.KANJI:return l.getBitsLength(P);case t.BYTE:return o.getBitsLength(P)}}function C(P){return P.reduce(function(L,b){const M=L.length-1>=0?L[L.length-1]:null;return M&&M.mode===b.mode?(L[L.length-1].data+=b.data,L):(L.push(b),L)},[])}function k(P){const L=[];for(let b=0;b<P.length;b++){const M=P[b];switch(M.mode){case t.NUMERIC:L.push([M,{data:M.data,mode:t.ALPHANUMERIC,length:M.length},{data:M.data,mode:t.BYTE,length:M.length}]);break;case t.ALPHANUMERIC:L.push([M,{data:M.data,mode:t.BYTE,length:M.length}]);break;case t.KANJI:L.push([M,{data:M.data,mode:t.BYTE,length:m(M.data)}]);break;case t.BYTE:L.push([{data:M.data,mode:t.BYTE,length:m(M.data)}])}}return L}function E(P,L){const b={},M={start:{}};let _=["start"];for(let I=0;I<P.length;I++){const R=P[I],D=[];for(let B=0;B<R.length;B++){const W=R[B],G=""+I+B;D.push(G),b[G]={node:W,lastCount:0},M[G]={};for(let K=0;K<_.length;K++){const U=_[K];b[U]&&b[U].node.mode===W.mode?(M[U][G]=x(b[U].lastCount+W.length,W.mode)-x(b[U].lastCount,W.mode),b[U].lastCount+=W.length):(b[U]&&(b[U].lastCount=W.length),M[U][G]=x(W.length,W.mode)+4+t.getCharCountIndicator(W.mode,L))}}_=D}for(let I=0;I<_.length;I++)M[_[I]].end=0;return{map:M,table:b}}function T(P,L){let b;const M=t.getBestModeForData(P);if(b=t.from(L,M),b!==t.BYTE&&b.bit<M.bit)throw new Error('"'+P+'" cannot be encoded with mode '+t.toString(b)+`.
|
|
342
342
|
Suggested mode is: `+t.toString(M));switch(b===t.KANJI&&!d.isKanjiModeEnabled()&&(b=t.BYTE),b){case t.NUMERIC:return new s(P);case t.ALPHANUMERIC:return new i(P);case t.KANJI:return new l(P);case t.BYTE:return new o(P)}}e.fromArray=function(L){return L.reduce(function(b,M){return typeof M=="string"?b.push(T(M,null)):M.data&&b.push(T(M.data,M.mode)),b},[])},e.fromString=function(L,b){const M=v(L,d.isKanjiModeEnabled()),_=k(M),I=E(_,b),R=h.find_path(I.map,"start","end"),D=[];for(let B=1;B<R.length-1;B++)D.push(I.table[R[B]].node);return e.fromArray(C(D))},e.rawSplit=function(L){return e.fromArray(v(L,d.isKanjiModeEnabled()))}})(Vd)),Vd}var Ev;function WM(){if(Ev)return Pd;Ev=1;const e=ys(),t=tp(),s=jM(),i=MM(),o=DM(),l=AM(),u=LM(),d=gS(),h=_M(),m=OM(),y=VM(),v=vs(),x=KM();function C(I,R){const D=I.size,B=l.getPositions(R);for(let W=0;W<B.length;W++){const G=B[W][0],K=B[W][1];for(let U=-1;U<=7;U++)if(!(G+U<=-1||D<=G+U))for(let X=-1;X<=7;X++)K+X<=-1||D<=K+X||(U>=0&&U<=6&&(X===0||X===6)||X>=0&&X<=6&&(U===0||U===6)||U>=2&&U<=4&&X>=2&&X<=4?I.set(G+U,K+X,!0,!0):I.set(G+U,K+X,!1,!0))}}function k(I){const R=I.size;for(let D=8;D<R-8;D++){const B=D%2===0;I.set(D,6,B,!0),I.set(6,D,B,!0)}}function E(I,R){const D=o.getPositions(R);for(let B=0;B<D.length;B++){const W=D[B][0],G=D[B][1];for(let K=-2;K<=2;K++)for(let U=-2;U<=2;U++)K===-2||K===2||U===-2||U===2||K===0&&U===0?I.set(W+K,G+U,!0,!0):I.set(W+K,G+U,!1,!0)}}function T(I,R){const D=I.size,B=m.getEncodedBits(R);let W,G,K;for(let U=0;U<18;U++)W=Math.floor(U/3),G=U%3+D-8-3,K=(B>>U&1)===1,I.set(W,G,K,!0),I.set(G,W,K,!0)}function P(I,R,D){const B=I.size,W=y.getEncodedBits(R,D);let G,K;for(G=0;G<15;G++)K=(W>>G&1)===1,G<6?I.set(G,8,K,!0):G<8?I.set(G+1,8,K,!0):I.set(B-15+G,8,K,!0),G<8?I.set(8,B-G-1,K,!0):G<9?I.set(8,15-G-1+1,K,!0):I.set(8,15-G-1,K,!0);I.set(B-8,8,1,!0)}function L(I,R){const D=I.size;let B=-1,W=D-1,G=7,K=0;for(let U=D-1;U>0;U-=2)for(U===6&&U--;;){for(let X=0;X<2;X++)if(!I.isReserved(W,U-X)){let ge=!1;K<R.length&&(ge=(R[K]>>>G&1)===1),I.set(W,U-X,ge),G--,G===-1&&(K++,G=7)}if(W+=B,W<0||D<=W){W-=B,B=-B;break}}}function b(I,R,D){const B=new s;D.forEach(function(X){B.put(X.mode.bit,4),B.put(X.getLength(),v.getCharCountIndicator(X.mode,I)),X.write(B)});const W=e.getSymbolTotalCodewords(I),G=d.getTotalCodewordsCount(I,R),K=(W-G)*8;for(B.getLengthInBits()+4<=K&&B.put(0,4);B.getLengthInBits()%8!==0;)B.putBit(0);const U=(K-B.getLengthInBits())/8;for(let X=0;X<U;X++)B.put(X%2?17:236,8);return M(B,I,R)}function M(I,R,D){const B=e.getSymbolTotalCodewords(R),W=d.getTotalCodewordsCount(R,D),G=B-W,K=d.getBlocksCount(R,D),U=B%K,X=K-U,ge=Math.floor(B/K),me=Math.floor(G/K),Ee=me+1,ee=ge-me,ue=new h(ee);let J=0;const V=new Array(K),F=new Array(K);let ne=0;const ye=new Uint8Array(I.buffer);for(let je=0;je<K;je++){const it=je<X?me:Ee;V[je]=ye.slice(J,J+it),F[je]=ue.encode(V[je]),J+=it,ne=Math.max(ne,it)}const ke=new Uint8Array(B);let Te=0,Ce,xe;for(Ce=0;Ce<ne;Ce++)for(xe=0;xe<K;xe++)Ce<V[xe].length&&(ke[Te++]=V[xe][Ce]);for(Ce=0;Ce<ee;Ce++)for(xe=0;xe<K;xe++)ke[Te++]=F[xe][Ce];return ke}function _(I,R,D,B){let W;if(Array.isArray(I))W=x.fromArray(I);else if(typeof I=="string"){let ge=R;if(!ge){const me=x.rawSplit(I);ge=m.getBestVersionForData(me,D)}W=x.fromString(I,ge||40)}else throw new Error("Invalid data");const G=m.getBestVersionForData(W,D);if(!G)throw new Error("The amount of data is too big to be stored in a QR Code");if(!R)R=G;else if(R<G)throw new Error(`
|
package/server/web/index.html
CHANGED
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
</style>
|
|
138
|
-
<script type="module" crossorigin src="/assets/index-
|
|
138
|
+
<script type="module" crossorigin src="/assets/index-Cimv9hDI.js"></script>
|
|
139
139
|
<link rel="stylesheet" crossorigin href="/assets/index-DZrY56Sp.css">
|
|
140
140
|
</head>
|
|
141
141
|
<body>
|