most-box 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -16
- package/out/about/index.html +2 -2
- package/out/admin/index.html +0 -0
- package/out/app/index.html +0 -0
- package/out/assets/AccountMenu-D_rcXDZr.js +1 -0
- package/out/assets/AppShell-CKP_dglR.js +1 -0
- package/out/assets/{AppTop-BE5kKBYH.js → AppTop-C03PsDr_.js} +1 -1
- package/out/assets/ChatRestoringIndicator-CLV78gNW.js +1 -0
- package/out/assets/{CopyButton-DnFqfCN9.js → CopyButton-ClwBN6Iy.js} +1 -1
- package/out/assets/{MarketingHeader-8gNzHawY.js → MarketingHeader-ChTIIzXG.js} +1 -1
- package/out/assets/{MarketingLayout-BPdjpEfc.js → MarketingLayout-hkPAtieL.js} +1 -1
- package/out/assets/{MilkdownEditor-C388llV6.js → MilkdownEditor-X9MUH_0q.js} +1 -1
- package/out/assets/{OpenSidebarButton-OP8zl7ad.js → OpenSidebarButton-CXBAjjCE.js} +1 -1
- package/out/assets/{chatJoinInvite-CeC6H6t8.js → chatJoinInvite-7tuD-STm.js} +1 -1
- package/out/assets/i18n-DKsg67mH.js +1 -0
- package/out/assets/{index-D1mozno-.js → index-DJzLHA0V.js} +3 -3
- package/out/assets/index-FEwag7ej.css +1 -0
- package/out/assets/index.lazy-B8ud1tpC.js +1 -0
- package/out/assets/{index.lazy-CX2l1_Gi.js → index.lazy-BEDWJZPP.js} +1 -1
- package/out/assets/{index.lazy-CsTaY5WS.js → index.lazy-BQ_Dyw5C.js} +1 -1
- package/out/assets/{index.lazy-D7E1pb1S.js → index.lazy-C0L9TDqK.js} +1 -1
- package/out/assets/{index.lazy-ClrSkRx5.js → index.lazy-C8luNCxY.js} +1 -1
- package/out/assets/{index.lazy-B1iJsXQ8.js → index.lazy-CT5TGyGl.js} +1 -1
- package/out/assets/{index.lazy-59kmyNMW.js → index.lazy-CTLlLPjy.js} +1 -1
- package/out/assets/{index.lazy-m9XAzMt1.js → index.lazy-Cgrv1NmQ.js} +1 -1
- package/out/assets/{index.lazy-Bz77Jlzu.js → index.lazy-CnpeKB4C.js} +1 -1
- package/out/assets/{index.lazy-DzaN9qwA.js → index.lazy-CwAN1t6l.js} +2 -2
- package/out/assets/{index.lazy-FvXAYdEO.js → index.lazy-Cy249kq1.js} +1 -1
- package/out/assets/index.lazy-DA98XQ0Q.js +1 -0
- package/out/assets/index.lazy-DYhpVW5B.js +3 -0
- package/out/assets/{index.lazy-CVFcovqX.js → index.lazy-b811JgFg.js} +1 -1
- package/out/assets/{index.lazy-CflWbocP.js → index.lazy-psYKmxdW.js} +1 -1
- package/out/assets/{saveLocalFile-2CNt4X0T.js → saveLocalFile-DTgdBgO9.js} +1 -1
- package/out/assets/useChannelMessages-BrqZa2SG.js +4 -0
- package/out/assets/{useGameRoom-asr2gyY6.js → useGameRoom-B3wvUICl.js} +1 -1
- package/out/chat/index.html +0 -0
- package/out/chat/join/demo/index.html +0 -0
- package/out/chat/join/index.html +0 -0
- package/out/download/index.html +2 -2
- package/out/game/gandengyan/index.html +0 -0
- package/out/game/index.html +0 -0
- package/out/game/zhajinhua/index.html +0 -0
- package/out/index.html +2 -2
- package/out/note/index.html +0 -0
- package/out/ping/index.html +2 -2
- package/out/profile/index.html +0 -0
- package/out/web3/index.html +0 -0
- package/package.json +1 -1
- package/server/src/index.js +212 -77
- package/out/assets/AccountMenu-D-wa5tux.js +0 -1
- package/out/assets/AppShell-BdRKZIZ9.js +0 -1
- package/out/assets/i18n-C6yaqRst.js +0 -1
- package/out/assets/index-C6IjeTBh.css +0 -1
- package/out/assets/index.lazy-C_J9afOY.js +0 -1
- package/out/assets/index.lazy-CazlK1-Y.js +0 -3
- package/out/assets/index.lazy-JwrS2vDI.js +0 -1
- package/out/assets/useChannelMessages-DDBqKBXU.js +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,E as i,H as a,_ as o,g as s,t as c}from"./useAppStore-DNhyhD20.js";import{a as l}from"./i18n-C6yaqRst.js";import{t as ee}from"./copy-OwXDsstV.js";import{t as te}from"./AppShell-BdRKZIZ9.js";import{t as ne}from"./play-DSHtNcOe.js";import{t as re}from"./send-Bie9hgHI.js";import{i as ie,n as ae,r as oe,t as se}from"./useGameRoom-asr2gyY6.js";import{g as u}from"./index-D1mozno-.js";var ce=r(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),d=t(e(),1),f=[`S`,`H`,`C`,`D`],p=[`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`J`,`Q`,`K`,`A`,`2`],m=p.filter(e=>e!==`2`),h=new Map(p.map((e,t)=>[e,t+3])),g=5,_=20,v=1e3;function le({roomCode:e,ownerAddress:t,ownerName:n,players:r=[],random:i=Math.random}){let a=E(r);return a.some(e=>e.address===s(t))||a.unshift({address:s(t),name:K(n),avatar:``}),y({id:String(e||``).toUpperCase(),ownerAddress:s(t),status:`lobby`,seq:1,players:a.slice(0,6).map((e,t)=>({address:e.address,name:K(e.name),avatar:o(e.avatar),seat:t,hand:[],handCount:0,score:v,playedCards:0})),deck:[],discard:[],table:null,currentSeat:0,lastWinnerSeat:null,previousWinnerSeat:null,passSeats:[],baseScore:1,bombCount:0,diceRolls:[],roundResult:null,log:[`房间已创建`],winnerSeat:null,random:i})}function ue(e,t=[]){let n=b(e);if(!n||n.status!==`lobby`)return n;let r=new Map(n.players.map(e=>[e.address,e.score]));return n.players=E(t).slice(0,6).map((e,t)=>({address:e.address,name:K(e.name),avatar:o(e.avatar),seat:t,hand:[],handCount:0,score:r.get(e.address)??v,playedCards:0})),n.seq+=1,y(n)}function de(e,t=Math.random){let n=b(e);if(!n||n.players.length<2)throw Error(`至少需要 2 名玩家`);n.deck=N(M(),t),n.discard=[],n.table=null,n.passSeats=[],n.winnerSeat=null,n.roundResult=null,n.baseScore=1,n.bombCount=0,n.status=`playing`;for(let e of R(n))e.hand=P(n,g),e.handCount=e.hand.length,e.playedCards=0,F(e.hand);let r=k(n,t);return n.currentSeat=r.seat,n.lastWinnerSeat=null,n.log=[`新一局开始,${r.name} 先出牌`],n.diceRolls.length>0&&n.log.unshift(`骰子结果:${n.diceRolls.map(e=>`${e.name} ${e.value}`).join(`,`)}`),n.seq+=1,y(n)}function fe(e,t,n){let r=b(e),i=I(r),a=s(t);if(!i||i.address!==a)return{ok:!1,error:`还没轮到你`,state:y(r)};let o=n.map(e=>i.hand.find(t=>t.id===e));if(o.length===0||o.some(e=>!e))return{ok:!1,error:`手牌不存在`,state:y(r)};let c=he(o);return c?T(c,r.table?.combo)?(o.sort(V),i.hand=i.hand.filter(e=>!n.includes(e.id)),i.handCount=i.hand.length,i.playedCards+=o.length,r.discard.push(...o),r.table={seat:i.seat,playerName:i.name,cards:o,combo:c},r.passSeats=[],r.lastWinnerSeat=i.seat,c.type===`bomb`&&(r.bombCount+=1,r.baseScore*=2),r.log.unshift(`${i.name} 出 ${c.label} ${o.map(G).join(` `)}${c.type===`bomb`?`,底分 ${r.baseScore}`:``}`),i.hand.length===0?A(r,i):z(r),r.seq+=1,{ok:!0,state:y(r)}):{ok:!1,error:`出的牌压不过上一手`,state:y(r)}:{ok:!1,error:`这个牌型不合法`,state:y(r)}}function pe(e,t){let n=b(e),r=I(n),i=s(t);return!r||r.address!==i?{ok:!1,error:`还没轮到你`,state:y(n)}:n.table?(n.passSeats.includes(r.seat)||n.passSeats.push(r.seat),n.log.unshift(`${r.name} 不要`),L(n).map(e=>e.seat).filter(e=>e!==n.lastWinnerSeat).every(e=>n.passSeats.includes(e))?(j(n),n.currentSeat=n.lastWinnerSeat,n.table=null,n.passSeats=[],n.log.unshift(`本轮结束,所有玩家各补 1 张,重新领出`)):z(n),n.seq+=1,{ok:!0,state:y(n)}):{ok:!1,error:`领出时不能不要`,state:y(n)}}function me(e,t){let n=b(e);if(!n)return null;let r=s(t),i=n.players.findIndex(e=>e.address===r);if(i===-1)return y(n);let a=n.players[i],o=n.currentSeat===a.seat,c=n.lastWinnerSeat===a.seat;n.players.splice(i,1),n.passSeats=n.passSeats.filter(e=>e!==a.seat),n.log.unshift(`${a.name} 已退出房间`);let l=R(n);if(n.status===`playing`)if(l.length<=1)l.length===1?A(n,l[0]):(n.status=`finished`,n.log.unshift(`玩家不足,本局结束`));else{if(o){let e=L(n);if(e.length>0){let t=e.findIndex(e=>e.seat>a.seat);n.currentSeat=e[t>=0?t:0].seat}}c&&n.table&&(n.table=null,n.passSeats=[])}return n.seq+=1,y(n)}function y(e){return e?{id:e.id,ownerAddress:e.ownerAddress,status:e.status,seq:Number(e.seq||1),deck:Array.isArray(e.deck)?e.deck.map(W):[],deckCount:e.deck?.length||Number(e.deckCount||0),discard:Array.isArray(e.discard)?e.discard.map(W):[],discardCount:e.discard?.length||Number(e.discardCount||0),currentSeat:Number(e.currentSeat||0),lastWinnerSeat:e.lastWinnerSeat===null||e.lastWinnerSeat===void 0?null:Number(e.lastWinnerSeat),previousWinnerSeat:e.previousWinnerSeat===null||e.previousWinnerSeat===void 0?null:Number(e.previousWinnerSeat),baseScore:Number(e.baseScore||1),bombCount:Number(e.bombCount||0),diceRolls:Array.isArray(e.diceRolls)?e.diceRolls:[],roundResult:e.roundResult||null,table:e.table?{...e.table,cards:e.table.cards.map(W)}:null,passSeats:Array.isArray(e.passSeats)?e.passSeats:[],winnerSeat:e.winnerSeat===null||e.winnerSeat===void 0?null:Number(e.winnerSeat),log:Array.isArray(e.log)?e.log.slice(0,18):[],players:R(e).map(e=>({address:e.address,name:e.name,avatar:o(e.avatar),seat:e.seat,handCount:e.hand?.length??e.handCount??0,score:Number(e.score??v),playedCards:Number(e.playedCards||0),hand:Array.isArray(e.hand)?e.hand.map(W):[]}))}:null}function b(e){return!e||typeof e!=`object`?null:{id:String(e.id||``).toUpperCase(),ownerAddress:s(e.ownerAddress),status:e.status===`playing`||e.status===`finished`?e.status:`lobby`,seq:Number(e.seq||1),players:Array.isArray(e.players)?e.players.map(D).filter(Boolean):[],deck:Array.isArray(e.deck)?e.deck.map(ve).filter(Boolean):[],discard:Array.isArray(e.discard)?e.discard.map(O).filter(Boolean):[],table:e.table&&typeof e.table==`object`?{...e.table,cards:Array.isArray(e.table.cards)?e.table.cards.map(O).filter(Boolean):[]}:null,currentSeat:Number(e.currentSeat||0),lastWinnerSeat:e.lastWinnerSeat===null||e.lastWinnerSeat===void 0?null:Number(e.lastWinnerSeat),previousWinnerSeat:e.previousWinnerSeat===null||e.previousWinnerSeat===void 0?null:Number(e.previousWinnerSeat),passSeats:Array.isArray(e.passSeats)?e.passSeats.map(Number):[],baseScore:Number(e.baseScore||1),bombCount:Number(e.bombCount||0),diceRolls:Array.isArray(e.diceRolls)?e.diceRolls:[],roundResult:e.roundResult||null,log:Array.isArray(e.log)?e.log.map(String):[],winnerSeat:e.winnerSeat===null||e.winnerSeat===void 0?null:Number(e.winnerSeat)}}function he(e){if(!e?.length)return null;e=[...e].sort(V);let t=e.filter(U).length,n=e.filter(e=>!U(e));if(n.length===0)return null;let r=x(e,n,t);if(r)return r;if(e.length===1&&t===0)return w(`single`,H(e[0]),1,[H(e[0])]);if(e.length===2&&B(n,t)){let e=ge(n);return w(`pair`,e,2,[e,e])}return S(e)||C(e)}function x(e,t,n){if(e.length<3||!B(t,n))return null;let r=ge(t);return w(`bomb`,r,e.length,Array(e.length).fill(r),n===0)}function S(e){if(e.length<3)return null;let t=e.filter(U).length,n=e.filter(e=>!U(e));for(let r=0;r<=m.length-e.length;r+=1){let i=m.slice(r,r+e.length).map(e=>h.get(e)),a=[...i],o=0;for(let e of n){let t=a.indexOf(H(e));t!==-1&&(a.splice(t,1),o+=1)}if(o+t===e.length&&a.length===t)return w(`straight`,i.at(-1),e.length,i)}return null}function C(e){if(e.length<4||e.length%2!=0)return null;let t=e.length/2,n=e.filter(U).length,r=e.filter(e=>!U(e));for(let i=0;i<=m.length-t;i+=1){let a=m.slice(i,i+t).map(e=>h.get(e)),o=a.flatMap(e=>[e,e]),s=0;for(let e of r){let t=o.indexOf(H(e));t!==-1&&(o.splice(t,1),s+=1)}if(s+n===e.length&&o.length===n){let t=a.flatMap(e=>[e,e]);return w(`pairStraight`,a.at(-1),e.length,t)}}return null}function w(e,t,n,r,i=!0){return{type:e,value:t,length:n,resolvedValues:r,pure:i,label:xe({type:e,value:t,length:n,resolvedValues:r,pure:i})}}function T(e,t){return e?!t||e.type===`bomb`&&t.type!==`bomb`?!0:e.type===t.type?e.type===`bomb`?e.length===t.length?e.value===t.value?e.pure&&!t.pure:e.value>t.value:e.length>t.length:e.length===t.length?e.type===`single`||e.type===`pair`?e.value===Ce(t.value)||e.value===h.get(`2`)&&t.value!==h.get(`2`):e.value===Ce(t.value):!1:!1:!1}function E(e){let t=new Set;return e.map(e=>({address:s(e.address),name:K(e.name),avatar:o(e.avatar),publicKey:String(e.publicKey||``)})).filter(e=>!e.address||t.has(e.address)?!1:(t.add(e.address),!0))}function D(e){let t=s(e.address);return t?{address:t,name:K(e.name),avatar:o(e.avatar),seat:Number(e.seat||0),hand:Array.isArray(e.hand)?e.hand.map(O).filter(Boolean):[],handCount:Number(e.handCount||0),score:Number(e.score??v),playedCards:Number(e.playedCards||0)}:null}function O(e){if(!e||typeof e!=`object`)return null;let t=String(e.rank||``),n=String(e.suit||``);return!h.has(t)&&t!==`SJ`&&t!==`BJ`||!f.includes(n)&&n!==`Joker`?null:{id:String(e.id||`${n}-${t}`),suit:n,rank:t,label:e.label||G({suit:n,rank:t}),color:e.color||be({suit:n,rank:t})}}function k(e,t){if(e.previousWinnerSeat!==null)return e.diceRolls=[],R(e).find(t=>t.seat===e.previousWinnerSeat)||R(e)[0];let n=R(e),r=[];for(;n.length>1;){r=n.map(e=>({seat:e.seat,name:e.name,value:we(t)}));let i=Math.max(...r.map(e=>e.value)),a=r.filter(e=>e.value===i);if(a.length===1)return e.diceRolls=r,n.find(e=>e.seat===a[0].seat);n=n.filter(e=>a.some(t=>t.seat===e.seat))}return e.diceRolls=r,n[0]}function A(e,t){e.status=`finished`,e.winnerSeat=t.seat,e.previousWinnerSeat=t.seat;let n=[],r=0;for(let i of R(e)){if(i.seat===t.seat)continue;let a=i.playedCards===0,o=a?_:i.hand.length*e.baseScore*.5;i.score-=o,r+=o,n.push({seat:i.seat,name:i.name,loss:o,sealed:a,cardsLeft:i.hand.length})}t.score+=r,e.roundResult={winnerSeat:t.seat,winnerName:t.name,winnerGain:r,baseScore:e.baseScore,bombCount:e.bombCount,losers:n},e.log.unshift(`${t.name} 获胜,赢 ${r} 分`)}function j(e){for(let t of L(e)){if(e.deck.length===0)break;t.hand.push(...P(e,1)),t.handCount=t.hand.length,F(t.hand)}}function M(){let e=[];for(let t of f)for(let n of p)e.push({id:`${t}-${n}`,suit:t,rank:n});return e.push({id:`SJ`,suit:`Joker`,rank:`SJ`}),e.push({id:`BJ`,suit:`Joker`,rank:`BJ`}),e.map(W)}function N(e,t){let n=[...e];for(let e=n.length-1;e>0;--e){let r=Math.floor(t()*(e+1));[n[e],n[r]]=[n[r],n[e]]}return n}function P(e,t){return e.deck.splice(0,t)}function F(e){e.sort(V)}function I(e){return e.players.find(t=>t.seat===e.currentSeat)}function L(e){return R(e).filter(e=>e.hand.length>0)}function R(e){return[...e?.players||[]].sort((e,t)=>e.seat-t.seat)}function z(e){let t=L(e).map(e=>e.seat);e.currentSeat=t[(t.indexOf(e.currentSeat)+1)%t.length]}function B(e,t=0){if(e.length===0)return!1;let n=e[0].rank;return e.every(e=>e.rank===n)&&e.length+t>=2}function ge(e){return H(e[0])}function V(e,t){return H(e)-H(t)||_e(e.suit)-_e(t.suit)}function H(e){return h.get(e.rank)||99}function U(e){return e.rank===`SJ`||e.rank===`BJ`}function _e(e){return{D:0,C:1,H:2,S:3,Joker:4}[e]||0}function ve(e){if(typeof e==`string`){let[t,n]=e.split(`-`);return O({id:e,suit:t,rank:n})}return O(e)}function W(e){return{id:e.id,suit:e.suit,rank:e.rank,label:G(e),color:be(e)}}function G(e){return e.rank===`SJ`?`小王`:e.rank===`BJ`?`大王`:`${ye(e.suit)}${e.rank}`}function ye(e){return{S:`♠`,H:`♥`,C:`♣`,D:`♦`}[e]||``}function be(e){return e.suit===`H`||e.suit===`D`||e.rank===`BJ`?`red`:`black`}function xe(e){let t=e.resolvedValues?.length?`(${e.resolvedValues.map(Se).join(` `)})`:``;return`${{single:`单张`,pair:`对子`,straight:`顺子`,pairStraight:`连对`,bomb:e.pure?`纯炸弹`:`带王炸弹`}[e.type]}${t}`}function Se(e){return p.find(t=>h.get(t)===e)||String(e)}function Ce(e){let t=p.findIndex(t=>h.get(t)===e);return t===-1||t>=p.length-1?null:h.get(p[t+1])}function we(e){return Math.floor(e()*6)+1}function K(e){return String(e||`玩家`).trim().slice(0,16)||`玩家`}var q={page:`_page_1c8jk_1`,headerActions:`_headerActions_1c8jk_7`,entry:`_entry_1c8jk_13`,entryBrand:`_entryBrand_1c8jk_23`,cardMark:`_cardMark_1c8jk_29`,entryPanel:`_entryPanel_1c8jk_59`,panel:`_panel_1c8jk_60`,handPanel:`_handPanel_1c8jk_61`,accountLine:`_accountLine_1c8jk_74`,scoreMeta:`_scoreMeta_1c8jk_75`,roomBar:`_roomBar_1c8jk_76`,badges:`_badges_1c8jk_77`,actions:`_actions_1c8jk_78`,joinForm:`_joinForm_1c8jk_98`,status:`_status_1c8jk_119`,gameGrid:`_gameGrid_1c8jk_125`,tablePanel:`_tablePanel_1c8jk_136`,seats:`_seats_1c8jk_170`,player:`_player_1c8jk_176`,active:`_active_1c8jk_193`,winner:`_winner_1c8jk_197`,avatar:`_avatar_1c8jk_201`,avatarOffline:`_avatarOffline_1c8jk_222`,onlineDot:`_onlineDot_1c8jk_227`,centerTable:`_centerTable_1c8jk_253`,deckBox:`_deckBox_1c8jk_260`,playedBox:`_playedBox_1c8jk_261`,playedCards:`_playedCards_1c8jk_289`,notice:`_notice_1c8jk_297`,resultDetail:`_resultDetail_1c8jk_305`,sidePanel:`_sidePanel_1c8jk_316`,scoreRow:`_scoreRow_1c8jk_341`,logPanel:`_logPanel_1c8jk_349`,hand:`_hand_1c8jk_61`,cardButton:`_cardButton_1c8jk_376`,picked:`_picked_1c8jk_386`,card:`_card_1c8jk_29`,red:`_red_1c8jk_417`,black:`_black_1c8jk_421`,small:`_small_1c8jk_425`,preview:`_preview_1c8jk_443`,valid:`_valid_1c8jk_466`},J=n(),Y=`gandengyan`;function X(...e){return e.filter(Boolean).join(` `)}function Te(e,t){return String(e||``).toLowerCase()===String(t||``).toLowerCase()}function Ee(e,t){if(typeof window>`u`||!(`speechSynthesis`in window)||!e)return;window.speechSynthesis.cancel();let n=new SpeechSynthesisUtterance(e);n.lang=t,n.rate=1.1,window.speechSynthesis.speak(n)}function De(){let{t:e,locale:t}=l(),n=c(e=>e.addToast),r=i(e=>e.initializeUser),[a,o]=(0,d.useState)(``),[s,u]=(0,d.useState)([]),[f,p]=(0,d.useState)(!1),m=(0,d.useRef)(``),h=(0,d.useRef)(!1),g=se({gameId:Y,onError:e=>n(e,`error`)});(0,d.useEffect)(()=>{r()},[r]),(0,d.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`room`)?.toUpperCase();e&&(o(e),m.current=e)},[]),(0,d.useEffect)(()=>{let t=m.current;!t||h.current||!g.isBackendReady||!g.userIdentity||(h.current=!0,m.current=``,g.joinRoom(t).then(t=>{t&&n(e(`game.toast.joinedRoom`),`success`)}))},[g.isBackendReady,g.userIdentity,g.joinRoom,n,e]),(0,d.useEffect)(()=>{if(!g.roomCode)return;let e=`/game/gandengyan?room=${g.roomCode}`;`${window.location.pathname}${window.location.search}`!==e&&window.history.replaceState(null,``,e)},[g.roomCode]);let _=(0,d.useMemo)(()=>ae(g.messages,g.roomCode?{gameId:Y,roomCode:g.roomCode}:{gameId:Y}),[g.messages,g.roomCode]),v=(0,d.useMemo)(()=>oe(g.messages,{gameId:Y,roomCode:g.roomCode}),[g.messages,g.roomCode]),y=v?.payload?.state,b=y?.players.find(e=>Te(e.address,g.userIdentity?.address)),x=Te(y?.ownerAddress||_.hostAddress,g.userIdentity?.address),S=y?.status===`playing`&&y.currentSeat===b?.seat,C=(0,d.useMemo)(()=>s.map(e=>b?.hand.find(t=>t.id===e)).filter(Boolean),[s,b]),w=(0,d.useMemo)(()=>he(C),[C]),T=g.roomCode&&typeof window<`u`?`${window.location.origin}/game/gandengyan?room=${g.roomCode}`:``,E=(0,d.useRef)(-1),D=(0,d.useRef)(!1);(0,d.useEffect)(()=>{u([])},[y?.seq]),(0,d.useEffect)(()=>{if(!y)return;let n=y.seq;if(E.current<0){E.current=n;return}if(n!==E.current&&(E.current=n,y.status!==`finished`&&(D.current=!1),y.status===`finished`&&y.winnerSeat!==null)){D.current||(D.current=!0,Ee(e(`game.gandengyan.speech.gameOver`),t));return}},[t,y?.seq,e]),(0,d.useEffect)(()=>{if(!x||!g.roomCode||!g.userIdentity||v||_.players.length===0)return;let e=le({roomCode:g.roomCode,ownerAddress:g.userIdentity.address,ownerName:g.userIdentity.displayName||g.userIdentity.username,players:_.players});g.sendRoomEvent(`room:state`,{state:e,seq:e.seq})},[g,x,v,_.players]),(0,d.useEffect)(()=>{if(!y||!x||y.status!==`lobby`)return;let e=ue(y,_.players);e&&ke(y.players,e.players)&&g.sendRoomEvent(`room:state`,{state:e,seq:e.seq})},[g,x,_.players,y]);let O=(0,d.useRef)(0),k=(0,d.useMemo)(()=>g.roomEvents.filter(e=>e.event?.event===`player:leave`),[g.roomEvents]);(0,d.useEffect)(()=>{if(k.length<=O.current)return;let t=k.slice(O.current);O.current=k.length;for(let r of t)n(e(`game.toast.playerLeft`,{player:r.event?.payload?.player?.name||e(`game.player`)}),`info`)},[k,n,e]),(0,d.useEffect)(()=>{if(!y||!x||y.status!==`playing`)return;let e=new Set(_.players.map(e=>e.address.toLowerCase())),t=y.players.find(t=>!e.has(t.address.toLowerCase()));if(!t)return;let n=me(y,t.address);n&&N(n)},[g,x,_.players,y]);async function A(){await g.createRoom()&&n(e(`game.toast.roomCreated`),`success`)}async function j(t){t.preventDefault(),await g.joinRoom(a)&&n(e(`game.toast.joinedRoom`),`success`)}async function M(){T&&(await navigator.clipboard.writeText(T),p(!0),setTimeout(()=>p(!1),1400))}async function N(e){await g.sendRoomEvent(`room:state`,{state:e,seq:e.seq})}async function P(){if(!(!y||!x))try{await N(de(y))}catch(t){n(t instanceof Error?t.message:e(`game.zhajinhua.error.startFailed`),`error`)}}async function F(){await P()}async function I(){if(!y||!g.userIdentity)return;let t=fe(y,g.userIdentity.address,s);if(!t.ok){n(t.error||e(`game.gandengyan.error.playFailed`),`error`);return}await N(t.state)}async function L(){if(!y||!g.userIdentity)return;let t=pe(y,g.userIdentity.address);if(!t.ok){n(t.error||e(`game.gandengyan.error.actionFailed`),`error`);return}await N(t.state)}function R(e){u(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}return(0,J.jsx)(te,{sidebar:({closeSidebar:e})=>(0,J.jsx)(ie,{activeGame:`gandengyan`,closeSidebar:e}),headerTitle:(0,J.jsx)(`h2`,{className:`header-title`,children:e(`game.gandengyan.title`)}),headerRight:(0,J.jsx)(`div`,{className:q.headerActions,children:y&&(0,J.jsxs)(`button`,{className:`btn btn-sm`,onClick:M,children:[(0,J.jsx)(ee,{size:14}),e(f?`common.copied`:`game.action.shareRoom`)]})}),children:(0,J.jsx)(`main`,{className:q.page,children:y?(0,J.jsxs)(`section`,{className:q.gameGrid,children:[(0,J.jsxs)(`div`,{className:q.tablePanel,children:[(0,J.jsxs)(`div`,{className:q.roomBar,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{translate:`no`,children:e(`game.roomLabel`,{room:y.id})}),(0,J.jsx)(`span`,{children:y.status===`lobby`?e(`game.status.waitingStart`):y.status===`finished`?e(`game.status.finished`):e(`game.status.playing`)})]}),(0,J.jsx)(`div`,{className:q.badges,children:(0,J.jsx)(`span`,{children:g.connected?e(`game.status.online`):e(`game.status.offline`)})})]}),(0,J.jsx)(`div`,{className:q.seats,children:y.players.map(t=>(0,J.jsx)(Oe,{player:t,active:y.currentSeat===t.seat,winner:y.winnerSeat===t.seat,relation:Me(b,t,y.players.length,e),presenceByAddress:g.presenceByAddress,onlineAddresses:g.onlineAddresses},t.seat))}),(0,J.jsxs)(`div`,{className:q.centerTable,children:[(0,J.jsxs)(`div`,{className:q.deckBox,children:[(0,J.jsx)(`span`,{children:e(`game.gandengyan.deck`)}),(0,J.jsx)(`strong`,{children:y.deckCount})]}),(0,J.jsx)(`div`,{className:q.playedBox,children:y.table?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`strong`,{children:e(`game.gandengyan.tablePlay`,{player:Q(y.players.find(e=>e.seat===y.table?.seat),g.presenceByAddress)||y.table.playerName,combo:y.table.combo?.label||e(`game.card`)})}),(0,J.jsx)(`div`,{className:q.playedCards,children:y.table.cards.map(e=>(0,J.jsx)($,{card:e,small:!0},e.id))})]}):(0,J.jsx)(`span`,{children:e(`game.gandengyan.waitingLead`)})}),(0,J.jsxs)(`div`,{className:q.deckBox,children:[(0,J.jsx)(`span`,{children:e(`game.gandengyan.baseScore`)}),(0,J.jsx)(`strong`,{children:y.baseScore})]})]}),(0,J.jsx)(`div`,{className:q.notice,children:y.status===`finished`?y.roundResult?(0,J.jsxs)(`div`,{className:q.resultDetail,children:[(0,J.jsxs)(`p`,{children:[e(`game.gandengyan.result.winnerGain`,{player:y.roundResult.winnerName,score:y.roundResult.winnerGain}),y.roundResult.bombCount>0&&e(`game.gandengyan.result.bombCount`,{count:y.roundResult.bombCount})]}),y.roundResult.losers.map(t=>(0,J.jsx)(`p`,{children:t.sealed?e(`game.gandengyan.result.sealedLoss`,{player:t.name,loss:20}):e(`game.gandengyan.result.cardsLeftLoss`,{player:t.name,cards:t.cardsLeft,loss:t.loss})},t.seat))]}):e(`game.gandengyan.result.winner`,{player:Q(y.players.find(e=>e.seat===y.winnerSeat),g.presenceByAddress)||e(`game.player`)}):S?e(`game.gandengyan.status.yourTurn`):e(`game.zhajinhua.status.waitingPlayer`,{player:Q(y.players.find(e=>e.seat===y.currentSeat),g.presenceByAddress)||e(`game.player`)})})]}),(0,J.jsxs)(`aside`,{className:q.sidePanel,children:[(0,J.jsxs)(`section`,{className:q.panel,children:[(0,J.jsx)(`h3`,{children:e(`game.gandengyan.roundPanel`)}),x&&y.status===`lobby`&&(0,J.jsxs)(`button`,{className:`btn btn-primary`,disabled:y.players.length<2,onClick:P,children:[(0,J.jsx)(ne,{size:16}),e(`game.action.startRound`)]}),x&&y.status===`finished`&&(0,J.jsxs)(`button`,{className:`btn btn-primary`,onClick:F,children:[(0,J.jsx)(ce,{size:16}),e(`game.action.nextRound`)]}),!x&&(0,J.jsx)(`p`,{className:q.status,children:e(`game.waitingHost`)})]}),(0,J.jsxs)(`section`,{className:q.panel,children:[(0,J.jsx)(`h3`,{children:e(`game.gandengyan.score`)}),(0,J.jsxs)(`div`,{className:q.scoreMeta,children:[(0,J.jsx)(`span`,{children:e(`game.gandengyan.bombCount`,{count:y.bombCount})}),(0,J.jsx)(`span`,{children:e(`game.gandengyan.discardCount`,{count:y.discardCount})})]}),y.players.map(e=>(0,J.jsxs)(`div`,{className:q.scoreRow,children:[(0,J.jsx)(`span`,{translate:`no`,children:Q(e,g.presenceByAddress)}),(0,J.jsx)(`strong`,{children:e.score})]},e.seat))]}),(0,J.jsxs)(`section`,{className:X(q.panel,q.logPanel),children:[(0,J.jsx)(`h3`,{children:e(`game.gandengyan.log`)}),y.log.map((e,t)=>(0,J.jsx)(`p`,{translate:`no`,children:e},`${e}-${t}`))]})]}),(0,J.jsxs)(`div`,{className:q.handPanel,children:[(0,J.jsx)(Oe,{player:b,active:S,winner:y.winnerSeat===b?.seat,presenceByAddress:g.presenceByAddress,onlineAddresses:g.onlineAddresses}),(0,J.jsx)(`div`,{className:q.hand,children:b?.hand.map(e=>(0,J.jsx)(`button`,{className:X(q.cardButton,s.includes(e.id)&&q.picked),onClick:()=>R(e.id),children:(0,J.jsx)($,{card:e})},e.id))}),(0,J.jsxs)(`div`,{className:q.actions,children:[(0,J.jsxs)(`div`,{className:X(q.preview,w&&q.valid),children:[(0,J.jsx)(`strong`,{children:w?w.label:s.length?e(`game.gandengyan.invalidCombo`):e(`game.gandengyan.selectCards`)}),(0,J.jsx)(`span`,{children:C.map(e=>e.label).join(` `)||e(`game.gandengyan.jokerOrderHint`)})]}),(0,J.jsxs)(`button`,{className:`btn btn-primary`,disabled:!S||s.length===0||!w,onClick:I,children:[(0,J.jsx)(re,{size:16}),e(`game.gandengyan.action.play`)]}),(0,J.jsx)(`button`,{className:`btn`,disabled:!S||!y.table,onClick:L,children:e(`game.gandengyan.action.pass`)})]})]})]}):(0,J.jsxs)(`section`,{className:q.entry,children:[(0,J.jsxs)(`div`,{className:q.entryBrand,children:[(0,J.jsx)(`div`,{className:q.cardMark,children:e(`game.gandengyan.mark`)}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h1`,{children:e(`game.gandengyan.hero.title`)}),(0,J.jsx)(`p`,{children:e(`game.hero.desc`)})]})]}),(0,J.jsxs)(`div`,{className:q.entryPanel,children:[(0,J.jsxs)(`div`,{className:q.accountLine,children:[(0,J.jsx)(`span`,{children:e(`game.currentAccount`)}),(0,J.jsx)(`strong`,{translate:`no`,children:g.userIdentity?.displayName||e(`web3.notSignedIn`)})]}),(0,J.jsxs)(`button`,{className:`btn btn-primary`,disabled:g.joining,onClick:A,children:[(0,J.jsx)(ne,{size:16}),e(`game.action.createRoom`)]}),(0,J.jsxs)(`form`,{onSubmit:j,className:q.joinForm,children:[(0,J.jsxs)(`label`,{children:[e(`game.roomCode`),(0,J.jsx)(`input`,{value:a,maxLength:8,onChange:e=>o(e.target.value.toUpperCase()),placeholder:e(`game.roomCode.placeholder`)})]}),(0,J.jsx)(`button`,{className:`btn`,disabled:g.joining||!a,children:e(`game.action.joinRoom`)})]}),(0,J.jsx)(`p`,{className:q.status,children:g.isBackendReady?e(`game.status.nodeConnected`):e(`game.status.nodeConnecting`)})]})]})})})}function Oe({player:e,active:t,winner:n,relation:r=``,presenceByAddress:i,onlineAddresses:a}){let{t:o}=l();if(!e)return null;let s=je(e,i,a);return(0,J.jsxs)(`div`,{className:X(q.player,t&&q.active,n&&q.winner),children:[(0,J.jsxs)(`div`,{className:X(q.avatar,!s.online&&q.avatarOffline),translate:`no`,children:[(0,J.jsx)(`img`,{src:u(e.address,s.avatar),alt:``}),s.online&&(0,J.jsx)(`span`,{className:q.onlineDot})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{translate:`no`,children:s.name}),(0,J.jsxs)(`span`,{children:[r,r?` · `:``,o(`game.gandengyan.handCount`,{count:e.handCount})]})]})]})}function ke(e,t){return e.length===t.length?t.some((t,n)=>{let r=e[n];return Z(r?.address)!==Z(t.address)||r?.name!==t.name||(r?.avatar||``)!==(t.avatar||``)}):!0}function Z(e=``){return String(e||``).trim().toLowerCase()}function Ae(e=``){return e?`${e.slice(0,6)}...${e.slice(-4)}`:``}function Q(e,t){if(!e)return``;let n=Z(e.address),r=t.get(n)?.displayName||e.name;return String(r||Ae(e.address)).trim()}function je(e,t,n){let r=Z(e.address),i=t.get(r);return{name:Q(e,t),avatar:i?.avatar||e.avatar||``,online:r?n.has(r):!1}}function $({card:e,small:t=!1}){return(0,J.jsxs)(`div`,{className:X(q.card,q[e.color],t&&q.small),children:[(0,J.jsx)(`span`,{children:e.label}),(0,J.jsx)(`i`,{children:e.suit===`Joker`?`*`:e.label.slice(0,1)})]})}function Me(e,t,n,r){if(!e)return r(`game.gandengyan.position.seat`,{seat:t.seat+1});let i=(t.seat-e.seat+n)%n;return i===0?r(`game.gandengyan.position.me`):n===2?r(`game.gandengyan.position.opponent`):n===3?r(i===1?`game.gandengyan.position.nextOpponent`:`game.gandengyan.position.prevOpponent`):n===4?r(i===1?`game.gandengyan.position.nextOpponent`:i===2?`game.gandengyan.position.partner`:`game.gandengyan.position.prevOpponent`):i%2==0?r(`game.gandengyan.position.seatPartner`,{seat:t.seat+1}):r(`game.gandengyan.position.seatOpponent`,{seat:t.seat+1})}var Ne=a(`/game/gandengyan/`)({component:De});export{Ne as Route};
|
|
1
|
+
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,E as i,H as a,_ as o,g as s,t as c}from"./useAppStore-DNhyhD20.js";import{a as l}from"./i18n-DKsg67mH.js";import{t as ee}from"./copy-OwXDsstV.js";import{t as te}from"./AppShell-CKP_dglR.js";import{t as ne}from"./play-DSHtNcOe.js";import{t as re}from"./send-Bie9hgHI.js";import{i as ie,n as ae,r as oe,t as se}from"./useGameRoom-B3wvUICl.js";import{g as u}from"./index-DJzLHA0V.js";var ce=r(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),d=t(e(),1),f=[`S`,`H`,`C`,`D`],p=[`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`J`,`Q`,`K`,`A`,`2`],m=p.filter(e=>e!==`2`),h=new Map(p.map((e,t)=>[e,t+3])),g=5,_=20,v=1e3;function le({roomCode:e,ownerAddress:t,ownerName:n,players:r=[],random:i=Math.random}){let a=E(r);return a.some(e=>e.address===s(t))||a.unshift({address:s(t),name:K(n),avatar:``}),y({id:String(e||``).toUpperCase(),ownerAddress:s(t),status:`lobby`,seq:1,players:a.slice(0,6).map((e,t)=>({address:e.address,name:K(e.name),avatar:o(e.avatar),seat:t,hand:[],handCount:0,score:v,playedCards:0})),deck:[],discard:[],table:null,currentSeat:0,lastWinnerSeat:null,previousWinnerSeat:null,passSeats:[],baseScore:1,bombCount:0,diceRolls:[],roundResult:null,log:[`房间已创建`],winnerSeat:null,random:i})}function ue(e,t=[]){let n=b(e);if(!n||n.status!==`lobby`)return n;let r=new Map(n.players.map(e=>[e.address,e.score]));return n.players=E(t).slice(0,6).map((e,t)=>({address:e.address,name:K(e.name),avatar:o(e.avatar),seat:t,hand:[],handCount:0,score:r.get(e.address)??v,playedCards:0})),n.seq+=1,y(n)}function de(e,t=Math.random){let n=b(e);if(!n||n.players.length<2)throw Error(`至少需要 2 名玩家`);n.deck=N(M(),t),n.discard=[],n.table=null,n.passSeats=[],n.winnerSeat=null,n.roundResult=null,n.baseScore=1,n.bombCount=0,n.status=`playing`;for(let e of R(n))e.hand=P(n,g),e.handCount=e.hand.length,e.playedCards=0,F(e.hand);let r=k(n,t);return n.currentSeat=r.seat,n.lastWinnerSeat=null,n.log=[`新一局开始,${r.name} 先出牌`],n.diceRolls.length>0&&n.log.unshift(`骰子结果:${n.diceRolls.map(e=>`${e.name} ${e.value}`).join(`,`)}`),n.seq+=1,y(n)}function fe(e,t,n){let r=b(e),i=I(r),a=s(t);if(!i||i.address!==a)return{ok:!1,error:`还没轮到你`,state:y(r)};let o=n.map(e=>i.hand.find(t=>t.id===e));if(o.length===0||o.some(e=>!e))return{ok:!1,error:`手牌不存在`,state:y(r)};let c=he(o);return c?T(c,r.table?.combo)?(o.sort(V),i.hand=i.hand.filter(e=>!n.includes(e.id)),i.handCount=i.hand.length,i.playedCards+=o.length,r.discard.push(...o),r.table={seat:i.seat,playerName:i.name,cards:o,combo:c},r.passSeats=[],r.lastWinnerSeat=i.seat,c.type===`bomb`&&(r.bombCount+=1,r.baseScore*=2),r.log.unshift(`${i.name} 出 ${c.label} ${o.map(G).join(` `)}${c.type===`bomb`?`,底分 ${r.baseScore}`:``}`),i.hand.length===0?A(r,i):z(r),r.seq+=1,{ok:!0,state:y(r)}):{ok:!1,error:`出的牌压不过上一手`,state:y(r)}:{ok:!1,error:`这个牌型不合法`,state:y(r)}}function pe(e,t){let n=b(e),r=I(n),i=s(t);return!r||r.address!==i?{ok:!1,error:`还没轮到你`,state:y(n)}:n.table?(n.passSeats.includes(r.seat)||n.passSeats.push(r.seat),n.log.unshift(`${r.name} 不要`),L(n).map(e=>e.seat).filter(e=>e!==n.lastWinnerSeat).every(e=>n.passSeats.includes(e))?(j(n),n.currentSeat=n.lastWinnerSeat,n.table=null,n.passSeats=[],n.log.unshift(`本轮结束,所有玩家各补 1 张,重新领出`)):z(n),n.seq+=1,{ok:!0,state:y(n)}):{ok:!1,error:`领出时不能不要`,state:y(n)}}function me(e,t){let n=b(e);if(!n)return null;let r=s(t),i=n.players.findIndex(e=>e.address===r);if(i===-1)return y(n);let a=n.players[i],o=n.currentSeat===a.seat,c=n.lastWinnerSeat===a.seat;n.players.splice(i,1),n.passSeats=n.passSeats.filter(e=>e!==a.seat),n.log.unshift(`${a.name} 已退出房间`);let l=R(n);if(n.status===`playing`)if(l.length<=1)l.length===1?A(n,l[0]):(n.status=`finished`,n.log.unshift(`玩家不足,本局结束`));else{if(o){let e=L(n);if(e.length>0){let t=e.findIndex(e=>e.seat>a.seat);n.currentSeat=e[t>=0?t:0].seat}}c&&n.table&&(n.table=null,n.passSeats=[])}return n.seq+=1,y(n)}function y(e){return e?{id:e.id,ownerAddress:e.ownerAddress,status:e.status,seq:Number(e.seq||1),deck:Array.isArray(e.deck)?e.deck.map(W):[],deckCount:e.deck?.length||Number(e.deckCount||0),discard:Array.isArray(e.discard)?e.discard.map(W):[],discardCount:e.discard?.length||Number(e.discardCount||0),currentSeat:Number(e.currentSeat||0),lastWinnerSeat:e.lastWinnerSeat===null||e.lastWinnerSeat===void 0?null:Number(e.lastWinnerSeat),previousWinnerSeat:e.previousWinnerSeat===null||e.previousWinnerSeat===void 0?null:Number(e.previousWinnerSeat),baseScore:Number(e.baseScore||1),bombCount:Number(e.bombCount||0),diceRolls:Array.isArray(e.diceRolls)?e.diceRolls:[],roundResult:e.roundResult||null,table:e.table?{...e.table,cards:e.table.cards.map(W)}:null,passSeats:Array.isArray(e.passSeats)?e.passSeats:[],winnerSeat:e.winnerSeat===null||e.winnerSeat===void 0?null:Number(e.winnerSeat),log:Array.isArray(e.log)?e.log.slice(0,18):[],players:R(e).map(e=>({address:e.address,name:e.name,avatar:o(e.avatar),seat:e.seat,handCount:e.hand?.length??e.handCount??0,score:Number(e.score??v),playedCards:Number(e.playedCards||0),hand:Array.isArray(e.hand)?e.hand.map(W):[]}))}:null}function b(e){return!e||typeof e!=`object`?null:{id:String(e.id||``).toUpperCase(),ownerAddress:s(e.ownerAddress),status:e.status===`playing`||e.status===`finished`?e.status:`lobby`,seq:Number(e.seq||1),players:Array.isArray(e.players)?e.players.map(D).filter(Boolean):[],deck:Array.isArray(e.deck)?e.deck.map(ve).filter(Boolean):[],discard:Array.isArray(e.discard)?e.discard.map(O).filter(Boolean):[],table:e.table&&typeof e.table==`object`?{...e.table,cards:Array.isArray(e.table.cards)?e.table.cards.map(O).filter(Boolean):[]}:null,currentSeat:Number(e.currentSeat||0),lastWinnerSeat:e.lastWinnerSeat===null||e.lastWinnerSeat===void 0?null:Number(e.lastWinnerSeat),previousWinnerSeat:e.previousWinnerSeat===null||e.previousWinnerSeat===void 0?null:Number(e.previousWinnerSeat),passSeats:Array.isArray(e.passSeats)?e.passSeats.map(Number):[],baseScore:Number(e.baseScore||1),bombCount:Number(e.bombCount||0),diceRolls:Array.isArray(e.diceRolls)?e.diceRolls:[],roundResult:e.roundResult||null,log:Array.isArray(e.log)?e.log.map(String):[],winnerSeat:e.winnerSeat===null||e.winnerSeat===void 0?null:Number(e.winnerSeat)}}function he(e){if(!e?.length)return null;e=[...e].sort(V);let t=e.filter(U).length,n=e.filter(e=>!U(e));if(n.length===0)return null;let r=x(e,n,t);if(r)return r;if(e.length===1&&t===0)return w(`single`,H(e[0]),1,[H(e[0])]);if(e.length===2&&B(n,t)){let e=ge(n);return w(`pair`,e,2,[e,e])}return S(e)||C(e)}function x(e,t,n){if(e.length<3||!B(t,n))return null;let r=ge(t);return w(`bomb`,r,e.length,Array(e.length).fill(r),n===0)}function S(e){if(e.length<3)return null;let t=e.filter(U).length,n=e.filter(e=>!U(e));for(let r=0;r<=m.length-e.length;r+=1){let i=m.slice(r,r+e.length).map(e=>h.get(e)),a=[...i],o=0;for(let e of n){let t=a.indexOf(H(e));t!==-1&&(a.splice(t,1),o+=1)}if(o+t===e.length&&a.length===t)return w(`straight`,i.at(-1),e.length,i)}return null}function C(e){if(e.length<4||e.length%2!=0)return null;let t=e.length/2,n=e.filter(U).length,r=e.filter(e=>!U(e));for(let i=0;i<=m.length-t;i+=1){let a=m.slice(i,i+t).map(e=>h.get(e)),o=a.flatMap(e=>[e,e]),s=0;for(let e of r){let t=o.indexOf(H(e));t!==-1&&(o.splice(t,1),s+=1)}if(s+n===e.length&&o.length===n){let t=a.flatMap(e=>[e,e]);return w(`pairStraight`,a.at(-1),e.length,t)}}return null}function w(e,t,n,r,i=!0){return{type:e,value:t,length:n,resolvedValues:r,pure:i,label:xe({type:e,value:t,length:n,resolvedValues:r,pure:i})}}function T(e,t){return e?!t||e.type===`bomb`&&t.type!==`bomb`?!0:e.type===t.type?e.type===`bomb`?e.length===t.length?e.value===t.value?e.pure&&!t.pure:e.value>t.value:e.length>t.length:e.length===t.length?e.type===`single`||e.type===`pair`?e.value===Ce(t.value)||e.value===h.get(`2`)&&t.value!==h.get(`2`):e.value===Ce(t.value):!1:!1:!1}function E(e){let t=new Set;return e.map(e=>({address:s(e.address),name:K(e.name),avatar:o(e.avatar),publicKey:String(e.publicKey||``)})).filter(e=>!e.address||t.has(e.address)?!1:(t.add(e.address),!0))}function D(e){let t=s(e.address);return t?{address:t,name:K(e.name),avatar:o(e.avatar),seat:Number(e.seat||0),hand:Array.isArray(e.hand)?e.hand.map(O).filter(Boolean):[],handCount:Number(e.handCount||0),score:Number(e.score??v),playedCards:Number(e.playedCards||0)}:null}function O(e){if(!e||typeof e!=`object`)return null;let t=String(e.rank||``),n=String(e.suit||``);return!h.has(t)&&t!==`SJ`&&t!==`BJ`||!f.includes(n)&&n!==`Joker`?null:{id:String(e.id||`${n}-${t}`),suit:n,rank:t,label:e.label||G({suit:n,rank:t}),color:e.color||be({suit:n,rank:t})}}function k(e,t){if(e.previousWinnerSeat!==null)return e.diceRolls=[],R(e).find(t=>t.seat===e.previousWinnerSeat)||R(e)[0];let n=R(e),r=[];for(;n.length>1;){r=n.map(e=>({seat:e.seat,name:e.name,value:we(t)}));let i=Math.max(...r.map(e=>e.value)),a=r.filter(e=>e.value===i);if(a.length===1)return e.diceRolls=r,n.find(e=>e.seat===a[0].seat);n=n.filter(e=>a.some(t=>t.seat===e.seat))}return e.diceRolls=r,n[0]}function A(e,t){e.status=`finished`,e.winnerSeat=t.seat,e.previousWinnerSeat=t.seat;let n=[],r=0;for(let i of R(e)){if(i.seat===t.seat)continue;let a=i.playedCards===0,o=a?_:i.hand.length*e.baseScore*.5;i.score-=o,r+=o,n.push({seat:i.seat,name:i.name,loss:o,sealed:a,cardsLeft:i.hand.length})}t.score+=r,e.roundResult={winnerSeat:t.seat,winnerName:t.name,winnerGain:r,baseScore:e.baseScore,bombCount:e.bombCount,losers:n},e.log.unshift(`${t.name} 获胜,赢 ${r} 分`)}function j(e){for(let t of L(e)){if(e.deck.length===0)break;t.hand.push(...P(e,1)),t.handCount=t.hand.length,F(t.hand)}}function M(){let e=[];for(let t of f)for(let n of p)e.push({id:`${t}-${n}`,suit:t,rank:n});return e.push({id:`SJ`,suit:`Joker`,rank:`SJ`}),e.push({id:`BJ`,suit:`Joker`,rank:`BJ`}),e.map(W)}function N(e,t){let n=[...e];for(let e=n.length-1;e>0;--e){let r=Math.floor(t()*(e+1));[n[e],n[r]]=[n[r],n[e]]}return n}function P(e,t){return e.deck.splice(0,t)}function F(e){e.sort(V)}function I(e){return e.players.find(t=>t.seat===e.currentSeat)}function L(e){return R(e).filter(e=>e.hand.length>0)}function R(e){return[...e?.players||[]].sort((e,t)=>e.seat-t.seat)}function z(e){let t=L(e).map(e=>e.seat);e.currentSeat=t[(t.indexOf(e.currentSeat)+1)%t.length]}function B(e,t=0){if(e.length===0)return!1;let n=e[0].rank;return e.every(e=>e.rank===n)&&e.length+t>=2}function ge(e){return H(e[0])}function V(e,t){return H(e)-H(t)||_e(e.suit)-_e(t.suit)}function H(e){return h.get(e.rank)||99}function U(e){return e.rank===`SJ`||e.rank===`BJ`}function _e(e){return{D:0,C:1,H:2,S:3,Joker:4}[e]||0}function ve(e){if(typeof e==`string`){let[t,n]=e.split(`-`);return O({id:e,suit:t,rank:n})}return O(e)}function W(e){return{id:e.id,suit:e.suit,rank:e.rank,label:G(e),color:be(e)}}function G(e){return e.rank===`SJ`?`小王`:e.rank===`BJ`?`大王`:`${ye(e.suit)}${e.rank}`}function ye(e){return{S:`♠`,H:`♥`,C:`♣`,D:`♦`}[e]||``}function be(e){return e.suit===`H`||e.suit===`D`||e.rank===`BJ`?`red`:`black`}function xe(e){let t=e.resolvedValues?.length?`(${e.resolvedValues.map(Se).join(` `)})`:``;return`${{single:`单张`,pair:`对子`,straight:`顺子`,pairStraight:`连对`,bomb:e.pure?`纯炸弹`:`带王炸弹`}[e.type]}${t}`}function Se(e){return p.find(t=>h.get(t)===e)||String(e)}function Ce(e){let t=p.findIndex(t=>h.get(t)===e);return t===-1||t>=p.length-1?null:h.get(p[t+1])}function we(e){return Math.floor(e()*6)+1}function K(e){return String(e||`玩家`).trim().slice(0,16)||`玩家`}var q={page:`_page_1c8jk_1`,headerActions:`_headerActions_1c8jk_7`,entry:`_entry_1c8jk_13`,entryBrand:`_entryBrand_1c8jk_23`,cardMark:`_cardMark_1c8jk_29`,entryPanel:`_entryPanel_1c8jk_59`,panel:`_panel_1c8jk_60`,handPanel:`_handPanel_1c8jk_61`,accountLine:`_accountLine_1c8jk_74`,scoreMeta:`_scoreMeta_1c8jk_75`,roomBar:`_roomBar_1c8jk_76`,badges:`_badges_1c8jk_77`,actions:`_actions_1c8jk_78`,joinForm:`_joinForm_1c8jk_98`,status:`_status_1c8jk_119`,gameGrid:`_gameGrid_1c8jk_125`,tablePanel:`_tablePanel_1c8jk_136`,seats:`_seats_1c8jk_170`,player:`_player_1c8jk_176`,active:`_active_1c8jk_193`,winner:`_winner_1c8jk_197`,avatar:`_avatar_1c8jk_201`,avatarOffline:`_avatarOffline_1c8jk_222`,onlineDot:`_onlineDot_1c8jk_227`,centerTable:`_centerTable_1c8jk_253`,deckBox:`_deckBox_1c8jk_260`,playedBox:`_playedBox_1c8jk_261`,playedCards:`_playedCards_1c8jk_289`,notice:`_notice_1c8jk_297`,resultDetail:`_resultDetail_1c8jk_305`,sidePanel:`_sidePanel_1c8jk_316`,scoreRow:`_scoreRow_1c8jk_341`,logPanel:`_logPanel_1c8jk_349`,hand:`_hand_1c8jk_61`,cardButton:`_cardButton_1c8jk_376`,picked:`_picked_1c8jk_386`,card:`_card_1c8jk_29`,red:`_red_1c8jk_417`,black:`_black_1c8jk_421`,small:`_small_1c8jk_425`,preview:`_preview_1c8jk_443`,valid:`_valid_1c8jk_466`},J=n(),Y=`gandengyan`;function X(...e){return e.filter(Boolean).join(` `)}function Te(e,t){return String(e||``).toLowerCase()===String(t||``).toLowerCase()}function Ee(e,t){if(typeof window>`u`||!(`speechSynthesis`in window)||!e)return;window.speechSynthesis.cancel();let n=new SpeechSynthesisUtterance(e);n.lang=t,n.rate=1.1,window.speechSynthesis.speak(n)}function De(){let{t:e,locale:t}=l(),n=c(e=>e.addToast),r=i(e=>e.initializeUser),[a,o]=(0,d.useState)(``),[s,u]=(0,d.useState)([]),[f,p]=(0,d.useState)(!1),m=(0,d.useRef)(``),h=(0,d.useRef)(!1),g=se({gameId:Y,onError:e=>n(e,`error`)});(0,d.useEffect)(()=>{r()},[r]),(0,d.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`room`)?.toUpperCase();e&&(o(e),m.current=e)},[]),(0,d.useEffect)(()=>{let t=m.current;!t||h.current||!g.isBackendReady||!g.userIdentity||(h.current=!0,m.current=``,g.joinRoom(t).then(t=>{t&&n(e(`game.toast.joinedRoom`),`success`)}))},[g.isBackendReady,g.userIdentity,g.joinRoom,n,e]),(0,d.useEffect)(()=>{if(!g.roomCode)return;let e=`/game/gandengyan?room=${g.roomCode}`;`${window.location.pathname}${window.location.search}`!==e&&window.history.replaceState(null,``,e)},[g.roomCode]);let _=(0,d.useMemo)(()=>ae(g.messages,g.roomCode?{gameId:Y,roomCode:g.roomCode}:{gameId:Y}),[g.messages,g.roomCode]),v=(0,d.useMemo)(()=>oe(g.messages,{gameId:Y,roomCode:g.roomCode}),[g.messages,g.roomCode]),y=v?.payload?.state,b=y?.players.find(e=>Te(e.address,g.userIdentity?.address)),x=Te(y?.ownerAddress||_.hostAddress,g.userIdentity?.address),S=y?.status===`playing`&&y.currentSeat===b?.seat,C=(0,d.useMemo)(()=>s.map(e=>b?.hand.find(t=>t.id===e)).filter(Boolean),[s,b]),w=(0,d.useMemo)(()=>he(C),[C]),T=g.roomCode&&typeof window<`u`?`${window.location.origin}/game/gandengyan?room=${g.roomCode}`:``,E=(0,d.useRef)(-1),D=(0,d.useRef)(!1);(0,d.useEffect)(()=>{u([])},[y?.seq]),(0,d.useEffect)(()=>{if(!y)return;let n=y.seq;if(E.current<0){E.current=n;return}if(n!==E.current&&(E.current=n,y.status!==`finished`&&(D.current=!1),y.status===`finished`&&y.winnerSeat!==null)){D.current||(D.current=!0,Ee(e(`game.gandengyan.speech.gameOver`),t));return}},[t,y?.seq,e]),(0,d.useEffect)(()=>{if(!x||!g.roomCode||!g.userIdentity||v||_.players.length===0)return;let e=le({roomCode:g.roomCode,ownerAddress:g.userIdentity.address,ownerName:g.userIdentity.displayName||g.userIdentity.username,players:_.players});g.sendRoomEvent(`room:state`,{state:e,seq:e.seq})},[g,x,v,_.players]),(0,d.useEffect)(()=>{if(!y||!x||y.status!==`lobby`)return;let e=ue(y,_.players);e&&ke(y.players,e.players)&&g.sendRoomEvent(`room:state`,{state:e,seq:e.seq})},[g,x,_.players,y]);let O=(0,d.useRef)(0),k=(0,d.useMemo)(()=>g.roomEvents.filter(e=>e.event?.event===`player:leave`),[g.roomEvents]);(0,d.useEffect)(()=>{if(k.length<=O.current)return;let t=k.slice(O.current);O.current=k.length;for(let r of t)n(e(`game.toast.playerLeft`,{player:r.event?.payload?.player?.name||e(`game.player`)}),`info`)},[k,n,e]),(0,d.useEffect)(()=>{if(!y||!x||y.status!==`playing`)return;let e=new Set(_.players.map(e=>e.address.toLowerCase())),t=y.players.find(t=>!e.has(t.address.toLowerCase()));if(!t)return;let n=me(y,t.address);n&&N(n)},[g,x,_.players,y]);async function A(){await g.createRoom()&&n(e(`game.toast.roomCreated`),`success`)}async function j(t){t.preventDefault(),await g.joinRoom(a)&&n(e(`game.toast.joinedRoom`),`success`)}async function M(){T&&(await navigator.clipboard.writeText(T),p(!0),setTimeout(()=>p(!1),1400))}async function N(e){await g.sendRoomEvent(`room:state`,{state:e,seq:e.seq})}async function P(){if(!(!y||!x))try{await N(de(y))}catch(t){n(t instanceof Error?t.message:e(`game.zhajinhua.error.startFailed`),`error`)}}async function F(){await P()}async function I(){if(!y||!g.userIdentity)return;let t=fe(y,g.userIdentity.address,s);if(!t.ok){n(t.error||e(`game.gandengyan.error.playFailed`),`error`);return}await N(t.state)}async function L(){if(!y||!g.userIdentity)return;let t=pe(y,g.userIdentity.address);if(!t.ok){n(t.error||e(`game.gandengyan.error.actionFailed`),`error`);return}await N(t.state)}function R(e){u(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}return(0,J.jsx)(te,{sidebar:({closeSidebar:e})=>(0,J.jsx)(ie,{activeGame:`gandengyan`,closeSidebar:e}),headerTitle:(0,J.jsx)(`h2`,{className:`header-title`,children:e(`game.gandengyan.title`)}),headerRight:(0,J.jsx)(`div`,{className:q.headerActions,children:y&&(0,J.jsxs)(`button`,{className:`btn btn-sm`,onClick:M,children:[(0,J.jsx)(ee,{size:14}),e(f?`common.copied`:`game.action.shareRoom`)]})}),children:(0,J.jsx)(`main`,{className:q.page,children:y?(0,J.jsxs)(`section`,{className:q.gameGrid,children:[(0,J.jsxs)(`div`,{className:q.tablePanel,children:[(0,J.jsxs)(`div`,{className:q.roomBar,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{translate:`no`,children:e(`game.roomLabel`,{room:y.id})}),(0,J.jsx)(`span`,{children:y.status===`lobby`?e(`game.status.waitingStart`):y.status===`finished`?e(`game.status.finished`):e(`game.status.playing`)})]}),(0,J.jsx)(`div`,{className:q.badges,children:(0,J.jsx)(`span`,{children:g.connected?e(`game.status.online`):e(`game.status.offline`)})})]}),(0,J.jsx)(`div`,{className:q.seats,children:y.players.map(t=>(0,J.jsx)(Oe,{player:t,active:y.currentSeat===t.seat,winner:y.winnerSeat===t.seat,relation:Me(b,t,y.players.length,e),presenceByAddress:g.presenceByAddress,onlineAddresses:g.onlineAddresses},t.seat))}),(0,J.jsxs)(`div`,{className:q.centerTable,children:[(0,J.jsxs)(`div`,{className:q.deckBox,children:[(0,J.jsx)(`span`,{children:e(`game.gandengyan.deck`)}),(0,J.jsx)(`strong`,{children:y.deckCount})]}),(0,J.jsx)(`div`,{className:q.playedBox,children:y.table?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`strong`,{children:e(`game.gandengyan.tablePlay`,{player:Q(y.players.find(e=>e.seat===y.table?.seat),g.presenceByAddress)||y.table.playerName,combo:y.table.combo?.label||e(`game.card`)})}),(0,J.jsx)(`div`,{className:q.playedCards,children:y.table.cards.map(e=>(0,J.jsx)($,{card:e,small:!0},e.id))})]}):(0,J.jsx)(`span`,{children:e(`game.gandengyan.waitingLead`)})}),(0,J.jsxs)(`div`,{className:q.deckBox,children:[(0,J.jsx)(`span`,{children:e(`game.gandengyan.baseScore`)}),(0,J.jsx)(`strong`,{children:y.baseScore})]})]}),(0,J.jsx)(`div`,{className:q.notice,children:y.status===`finished`?y.roundResult?(0,J.jsxs)(`div`,{className:q.resultDetail,children:[(0,J.jsxs)(`p`,{children:[e(`game.gandengyan.result.winnerGain`,{player:y.roundResult.winnerName,score:y.roundResult.winnerGain}),y.roundResult.bombCount>0&&e(`game.gandengyan.result.bombCount`,{count:y.roundResult.bombCount})]}),y.roundResult.losers.map(t=>(0,J.jsx)(`p`,{children:t.sealed?e(`game.gandengyan.result.sealedLoss`,{player:t.name,loss:20}):e(`game.gandengyan.result.cardsLeftLoss`,{player:t.name,cards:t.cardsLeft,loss:t.loss})},t.seat))]}):e(`game.gandengyan.result.winner`,{player:Q(y.players.find(e=>e.seat===y.winnerSeat),g.presenceByAddress)||e(`game.player`)}):S?e(`game.gandengyan.status.yourTurn`):e(`game.zhajinhua.status.waitingPlayer`,{player:Q(y.players.find(e=>e.seat===y.currentSeat),g.presenceByAddress)||e(`game.player`)})})]}),(0,J.jsxs)(`aside`,{className:q.sidePanel,children:[(0,J.jsxs)(`section`,{className:q.panel,children:[(0,J.jsx)(`h3`,{children:e(`game.gandengyan.roundPanel`)}),x&&y.status===`lobby`&&(0,J.jsxs)(`button`,{className:`btn btn-primary`,disabled:y.players.length<2,onClick:P,children:[(0,J.jsx)(ne,{size:16}),e(`game.action.startRound`)]}),x&&y.status===`finished`&&(0,J.jsxs)(`button`,{className:`btn btn-primary`,onClick:F,children:[(0,J.jsx)(ce,{size:16}),e(`game.action.nextRound`)]}),!x&&(0,J.jsx)(`p`,{className:q.status,children:e(`game.waitingHost`)})]}),(0,J.jsxs)(`section`,{className:q.panel,children:[(0,J.jsx)(`h3`,{children:e(`game.gandengyan.score`)}),(0,J.jsxs)(`div`,{className:q.scoreMeta,children:[(0,J.jsx)(`span`,{children:e(`game.gandengyan.bombCount`,{count:y.bombCount})}),(0,J.jsx)(`span`,{children:e(`game.gandengyan.discardCount`,{count:y.discardCount})})]}),y.players.map(e=>(0,J.jsxs)(`div`,{className:q.scoreRow,children:[(0,J.jsx)(`span`,{translate:`no`,children:Q(e,g.presenceByAddress)}),(0,J.jsx)(`strong`,{children:e.score})]},e.seat))]}),(0,J.jsxs)(`section`,{className:X(q.panel,q.logPanel),children:[(0,J.jsx)(`h3`,{children:e(`game.gandengyan.log`)}),y.log.map((e,t)=>(0,J.jsx)(`p`,{translate:`no`,children:e},`${e}-${t}`))]})]}),(0,J.jsxs)(`div`,{className:q.handPanel,children:[(0,J.jsx)(Oe,{player:b,active:S,winner:y.winnerSeat===b?.seat,presenceByAddress:g.presenceByAddress,onlineAddresses:g.onlineAddresses}),(0,J.jsx)(`div`,{className:q.hand,children:b?.hand.map(e=>(0,J.jsx)(`button`,{className:X(q.cardButton,s.includes(e.id)&&q.picked),onClick:()=>R(e.id),children:(0,J.jsx)($,{card:e})},e.id))}),(0,J.jsxs)(`div`,{className:q.actions,children:[(0,J.jsxs)(`div`,{className:X(q.preview,w&&q.valid),children:[(0,J.jsx)(`strong`,{children:w?w.label:s.length?e(`game.gandengyan.invalidCombo`):e(`game.gandengyan.selectCards`)}),(0,J.jsx)(`span`,{children:C.map(e=>e.label).join(` `)||e(`game.gandengyan.jokerOrderHint`)})]}),(0,J.jsxs)(`button`,{className:`btn btn-primary`,disabled:!S||s.length===0||!w,onClick:I,children:[(0,J.jsx)(re,{size:16}),e(`game.gandengyan.action.play`)]}),(0,J.jsx)(`button`,{className:`btn`,disabled:!S||!y.table,onClick:L,children:e(`game.gandengyan.action.pass`)})]})]})]}):(0,J.jsxs)(`section`,{className:q.entry,children:[(0,J.jsxs)(`div`,{className:q.entryBrand,children:[(0,J.jsx)(`div`,{className:q.cardMark,children:e(`game.gandengyan.mark`)}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h1`,{children:e(`game.gandengyan.hero.title`)}),(0,J.jsx)(`p`,{children:e(`game.hero.desc`)})]})]}),(0,J.jsxs)(`div`,{className:q.entryPanel,children:[(0,J.jsxs)(`div`,{className:q.accountLine,children:[(0,J.jsx)(`span`,{children:e(`game.currentAccount`)}),(0,J.jsx)(`strong`,{translate:`no`,children:g.userIdentity?.displayName||e(`web3.notSignedIn`)})]}),(0,J.jsxs)(`button`,{className:`btn btn-primary`,disabled:g.joining,onClick:A,children:[(0,J.jsx)(ne,{size:16}),e(`game.action.createRoom`)]}),(0,J.jsxs)(`form`,{onSubmit:j,className:q.joinForm,children:[(0,J.jsxs)(`label`,{children:[e(`game.roomCode`),(0,J.jsx)(`input`,{value:a,maxLength:8,onChange:e=>o(e.target.value.toUpperCase()),placeholder:e(`game.roomCode.placeholder`)})]}),(0,J.jsx)(`button`,{className:`btn`,disabled:g.joining||!a,children:e(`game.action.joinRoom`)})]}),(0,J.jsx)(`p`,{className:q.status,children:g.isBackendReady?e(`game.status.nodeConnected`):e(`game.status.nodeConnecting`)})]})]})})})}function Oe({player:e,active:t,winner:n,relation:r=``,presenceByAddress:i,onlineAddresses:a}){let{t:o}=l();if(!e)return null;let s=je(e,i,a);return(0,J.jsxs)(`div`,{className:X(q.player,t&&q.active,n&&q.winner),children:[(0,J.jsxs)(`div`,{className:X(q.avatar,!s.online&&q.avatarOffline),translate:`no`,children:[(0,J.jsx)(`img`,{src:u(e.address,s.avatar),alt:``}),s.online&&(0,J.jsx)(`span`,{className:q.onlineDot})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{translate:`no`,children:s.name}),(0,J.jsxs)(`span`,{children:[r,r?` · `:``,o(`game.gandengyan.handCount`,{count:e.handCount})]})]})]})}function ke(e,t){return e.length===t.length?t.some((t,n)=>{let r=e[n];return Z(r?.address)!==Z(t.address)||r?.name!==t.name||(r?.avatar||``)!==(t.avatar||``)}):!0}function Z(e=``){return String(e||``).trim().toLowerCase()}function Ae(e=``){return e?`${e.slice(0,6)}...${e.slice(-4)}`:``}function Q(e,t){if(!e)return``;let n=Z(e.address),r=t.get(n)?.displayName||e.name;return String(r||Ae(e.address)).trim()}function je(e,t,n){let r=Z(e.address),i=t.get(r);return{name:Q(e,t),avatar:i?.avatar||e.avatar||``,online:r?n.has(r):!1}}function $({card:e,small:t=!1}){return(0,J.jsxs)(`div`,{className:X(q.card,q[e.color],t&&q.small),children:[(0,J.jsx)(`span`,{children:e.label}),(0,J.jsx)(`i`,{children:e.suit===`Joker`?`*`:e.label.slice(0,1)})]})}function Me(e,t,n,r){if(!e)return r(`game.gandengyan.position.seat`,{seat:t.seat+1});let i=(t.seat-e.seat+n)%n;return i===0?r(`game.gandengyan.position.me`):n===2?r(`game.gandengyan.position.opponent`):n===3?r(i===1?`game.gandengyan.position.nextOpponent`:`game.gandengyan.position.prevOpponent`):n===4?r(i===1?`game.gandengyan.position.nextOpponent`:i===2?`game.gandengyan.position.partner`:`game.gandengyan.position.prevOpponent`):i%2==0?r(`game.gandengyan.position.seatPartner`,{seat:t.seat+1}):r(`game.gandengyan.position.seatOpponent`,{seat:t.seat+1})}var Ne=a(`/game/gandengyan/`)({component:De});export{Ne as Route};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,E as i,G as a,H as o,W as s,o as ee,t as c,u as te}from"./useAppStore-DNhyhD20.js";import{a as l}from"./i18n-C6yaqRst.js";import{t as u}from"./triangle-alert-BhNtjKm2.js";import{t as d}from"./download-Cy2BlfKM.js";import{t as ne}from"./external-link-D_AQSgxW.js";import{t as re}from"./file-text-zvTER2mN.js";import{t as f}from"./hard-drive-DL1KJHmG.js";import{t as p}from"./refresh-cw-CfkUlTK9.js";import{I as m,L as h}from"./index-D1mozno-.js";import{t as ie}from"./MarketingHeader-8gNzHawY.js";import{t as g}from"./format-CAKfypjK.js";import{n as _,r as ae,s as oe,t as v}from"./downloadValidation-Dd43i9_9.js";var se=r(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),y=r(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),b=r(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),x=r(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),S=t(e(),1),C=n(),ce=1800;function w(e,t){return`most://${e}${t||``}`}function le(e,t){let n=e.trim().replace(/[\\/]+$/,``);return n?`${n}${n.includes(`\\`)?`\\`:`/`}downloads`:t}function T(e,t){let n=e[t];return typeof n==`string`?n:void 0}function E(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function D(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=`object`)return null;let n=t,r=T(n,`event`),i=n.data;if(!r||!i||typeof i!=`object`)return null;let a=i;return{event:r,payload:{taskId:T(a,`taskId`),percent:E(a,`percent`),loaded:E(a,`loaded`),total:E(a,`total`),file:T(a,`file`),fileName:T(a,`fileName`),error:T(a,`error`)}}}function O(){let{t:e}=l(),{cid:t}=a({from:`/cid/$cid/`}),n=h({select:e=>e.searchStr}),r=c(e=>e.hasBackend),o=c(e=>e.addToast),m=c(e=>e.openConnectModal),T=i(e=>e.identity),E=i(e=>e.openLoginModal),O=(0,S.useMemo)(()=>w(t,n),[t,n]),k=(0,S.useMemo)(()=>oe(O),[O]),A=(0,S.useMemo)(()=>v(O,e),[O,e]),fe=k.fileName||t,[j,M]=(0,S.useState)({status:`idle`,message:``}),[N,P]=(0,S.useState)(null),[F,I]=(0,S.useState)({status:`idle`,message:``}),[L,R]=(0,S.useState)(``),[z,B]=(0,S.useState)(0),[V,H]=(0,S.useState)(null),[U,W]=(0,S.useState)(null),[pe,G]=(0,S.useState)(``),[me,K]=(0,S.useState)(!1),q=(0,S.useRef)(0),J=(0,S.useRef)(null),Y=N?.fileName||fe,X=N?.size??U,Z=j.status===`available`||j.status===`already-local`,Q=F.status===`starting`||F.status===`downloading`,he=le(pe,e(`cid.saveToFallback`)),$=(0,S.useCallback)(async()=>{let t=q.current+1;if(q.current=t,R(``),B(0),H(null),W(null),I({status:`idle`,message:``}),A){P(null),M({status:`error`,message:A});return}if(r===null){P(null),M({status:`waiting-backend`,message:e(`cid.status.waitingBackend`)});return}if(r!==!0){P(null),M({status:`backend-missing`,message:e(`cid.status.backendMissing`)});return}if(!T){P(null),M({status:`login-required`,message:e(`cid.status.loginRequired`)});return}M({status:`checking`,message:e(`cid.status.checking`)}),P(null);try{let n=await _.checkDownload(O);if(q.current!==t)return;P(n),M({status:n.alreadyExists?`already-local`:`available`,message:n.alreadyExists?e(`cid.status.alreadyLocal`,{fileName:n.fileName}):e(`cid.status.available`,{fileName:n.fileName})})}catch(e){if(q.current!==t)return;M({status:`error`,message:await ae(e)}),P(null)}},[r,O,e,T,A]);(0,S.useEffect)(()=>{document.title=e(`cid.meta.title`)},[e]),(0,S.useEffect)(()=>{let e=()=>{J.current!==null&&(window.clearTimeout(J.current),J.current=null)},t=()=>{document.visibilityState===`hidden`&&(e(),K(!1))};return document.addEventListener(`visibilitychange`,t),window.addEventListener(`pagehide`,t),()=>{e(),document.removeEventListener(`visibilitychange`,t),window.removeEventListener(`pagehide`,t)}},[]),(0,S.useEffect)(()=>{$()},[$]),(0,S.useEffect)(()=>{if(r!==!0)return;let e=!1;return _.getDataPath().then(t=>{e||G(t.dataPath)}).catch(()=>{e||G(``)}),()=>{e=!0}},[r]),(0,S.useEffect)(()=>{if(!L||!T)return;let t=null,n=!1;return(async()=>{if(t=new WebSocket(await te(`/ws`)),n){t.close();return}t.onmessage=t=>{let n=D(t.data);!n||n.payload.taskId!==L||(n.event===`download:progress`&&(B(n.payload.percent||0),H(n.payload.loaded??null),W(n.payload.total??null)),n.event===`download:status`&&I({status:`downloading`,message:n.payload.file?e(`cid.status.downloadingFile`,{fileName:n.payload.file}):e(`cid.status.downloading`)}),n.event===`download:success`&&(B(100),I({status:`completed`,message:e(`cid.status.downloadComplete`,{fileName:n.payload.fileName||Y})}),o(e(`cid.toast.downloadComplete`),`success`)),n.event===`download:error`&&(I({status:`error`,message:n.payload.error||e(`cid.status.downloadFailed`,{error:``})}),o(e(`cid.toast.downloadFailed`,{error:n.payload.error||e(`cid.errorFallback`)}),`error`)),n.event===`download:cancelled`&&(I({status:`cancelled`,message:e(`cid.status.cancelled`)}),o(e(`cid.toast.cancelled`),`warning`)))}})(),()=>{n=!0,t?.close()}},[o,Y,e,L,T]);let ge=async()=>{if(!T){E();return}if(r!==!0){m();return}if(!(!Z||Q)){I({status:`starting`,message:e(`cid.status.startingDownload`)}),B(0);try{let t=await _.downloadFile(O);if(t.alreadyExists){I({status:`completed`,message:e(`cid.status.alreadyLocal`,{fileName:t.fileName||Y})}),o(e(`cid.toast.alreadyLocal`),`warning`);return}t.taskId&&(R(t.taskId),I({status:`downloading`,message:e(`cid.status.downloading`)}),o(e(`cid.toast.downloadStarted`),`info`))}catch(t){let n=await ee(t,e(`cid.status.downloadFailed`,{error:e(`cid.errorFallback`)}));I({status:`error`,message:n}),o(n,`error`)}}},_e=()=>{K(!1),J.current!==null&&window.clearTimeout(J.current),J.current=window.setTimeout(()=>{J.current=null,document.visibilityState!==`hidden`&&K(!0)},ce)},ve=async()=>{L&&await _.cancelDownload(L).catch(()=>{})},ye=ue(j.status,F.status);return(0,C.jsxs)(`div`,{className:`cid-layout`,children:[(0,C.jsx)(ie,{}),(0,C.jsx)(`main`,{className:`cid-page`,children:(0,C.jsxs)(`section`,{className:`cid-shell`,children:[(0,C.jsxs)(`div`,{className:`cid-heading`,children:[(0,C.jsx)(`span`,{className:`cid-kicker`,children:e(`cid.kicker`)}),(0,C.jsx)(`h1`,{children:e(`cid.title`)}),(0,C.jsx)(`p`,{children:e(`cid.subtitle`)})]}),(0,C.jsxs)(`div`,{className:`cid-panel`,children:[(0,C.jsxs)(`div`,{className:`cid-handoff`,"aria-label":e(`cid.handoff.title`),children:[(0,C.jsxs)(`div`,{className:`cid-handoff-copy`,children:[(0,C.jsx)(`p`,{className:`cid-handoff-title`,children:e(`cid.handoff.title`)}),(0,C.jsx)(`p`,{children:e(`cid.handoff.desc`)})]}),(0,C.jsxs)(`a`,{className:`btn btn-primary`,href:O,onClick:_e,children:[(0,C.jsx)(ne,{size:16}),e(`cid.handoff.action`)]})]}),me&&(0,C.jsxs)(`div`,{className:`cid-handoff-fallback`,role:`status`,children:[(0,C.jsx)(u,{size:18}),(0,C.jsx)(`p`,{children:e(`cid.handoff.fallback`)}),(0,C.jsxs)(s,{to:`/download/`,className:`btn btn-secondary`,children:[(0,C.jsx)(d,{size:16}),e(`cid.handoff.downloadAction`)]})]}),(0,C.jsxs)(`div`,{className:`cid-status`,children:[(0,C.jsx)(`span`,{className:`cid-status-icon ${j.status}`,children:ye}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`p`,{className:`cid-status-label`,children:de(j.status,e)}),(0,C.jsx)(`p`,{className:`cid-status-message`,children:j.message})]})]}),(0,C.jsxs)(`dl`,{className:`cid-details`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`dt`,{children:[(0,C.jsx)(re,{size:16}),e(`cid.fileNameLabel`)]}),(0,C.jsx)(`dd`,{children:Y})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`dt`,{children:e(`cid.cidLabel`)}),(0,C.jsx)(`dd`,{className:`cid-mono`,children:t})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`dt`,{children:e(`cid.sizeLabel`)}),(0,C.jsx)(`dd`,{children:X?g(X):e(`cid.unknownSize`)})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`dt`,{children:[(0,C.jsx)(f,{size:16}),e(`cid.saveToLabel`)]}),(0,C.jsx)(`dd`,{children:he})]})]}),F.status!==`idle`&&(0,C.jsxs)(`div`,{className:`cid-download-state ${F.status}`,children:[(0,C.jsx)(`p`,{children:F.message}),(F.status===`starting`||F.status===`downloading`)&&(0,C.jsxs)(`div`,{className:`cid-progress`,children:[(0,C.jsx)(`progress`,{className:`cid-progress-bar`,value:z,max:100}),(0,C.jsx)(`span`,{children:V!==null&&U!==null?`${g(V)} / ${g(U)}`:`${z}%`})]})]}),(0,C.jsxs)(`div`,{className:`cid-actions`,children:[j.status===`login-required`&&(0,C.jsxs)(`button`,{className:`btn btn-primary`,onClick:E,children:[(0,C.jsx)(b,{size:16}),e(`cid.loginAction`)]}),j.status===`backend-missing`&&(0,C.jsxs)(`button`,{className:`btn btn-primary`,onClick:m,children:[(0,C.jsx)(x,{size:16}),e(`cid.connectAction`)]}),(0,C.jsxs)(`button`,{className:`btn btn-primary`,disabled:!Z||Q,onClick:ge,children:[Q?(0,C.jsx)(y,{className:`cid-spin-icon`,size:16}):(0,C.jsx)(d,{size:16}),e(Q?`cid.downloadingAction`:`cid.startAction`)]}),L&&F.status===`downloading`&&(0,C.jsxs)(`button`,{className:`btn btn-secondary`,onClick:ve,children:[(0,C.jsx)(se,{size:16}),e(`cid.cancelAction`)]}),(0,C.jsxs)(`button`,{className:`btn btn-secondary`,disabled:j.status===`checking`,onClick:$,children:[(0,C.jsx)(p,{size:16}),e(`cid.retryAction`)]}),(0,C.jsx)(s,{to:`/app/`,className:`btn btn-secondary`,children:e(`cid.openAppAction`)})]})]})]})})]})}function ue(e,t){return t===`completed`?(0,C.jsx)(m,{size:28}):t===`error`||e===`error`?(0,C.jsx)(u,{size:28}):e===`checking`||e===`waiting-backend`||t===`starting`||t===`downloading`?(0,C.jsx)(y,{size:28}):e===`backend-missing`?(0,C.jsx)(x,{size:28}):e===`login-required`?(0,C.jsx)(b,{size:28}):(0,C.jsx)(m,{size:28})}function de(e,t){switch(e){case`checking`:return t(`cid.label.checking`);case`available`:return t(`cid.label.available`);case`already-local`:return t(`cid.label.alreadyLocal`);case`login-required`:return t(`cid.label.loginRequired`);case`backend-missing`:return t(`cid.label.backendMissing`);case`waiting-backend`:return t(`cid.label.waitingBackend`);case`error`:return t(`cid.label.error`);default:return t(`cid.label.idle`)}}var k=o(`/cid/$cid/`)({component:O});export{k as Route};
|
|
1
|
+
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,E as i,G as a,H as o,W as s,o as ee,t as c,u as te}from"./useAppStore-DNhyhD20.js";import{a as l}from"./i18n-DKsg67mH.js";import{t as u}from"./triangle-alert-BhNtjKm2.js";import{t as d}from"./download-Cy2BlfKM.js";import{t as ne}from"./external-link-D_AQSgxW.js";import{t as re}from"./file-text-zvTER2mN.js";import{t as f}from"./hard-drive-DL1KJHmG.js";import{t as p}from"./refresh-cw-CfkUlTK9.js";import{I as m,L as h}from"./index-DJzLHA0V.js";import{t as ie}from"./MarketingHeader-ChTIIzXG.js";import{t as g}from"./format-CAKfypjK.js";import{n as _,r as ae,s as oe,t as v}from"./downloadValidation-Dd43i9_9.js";var se=r(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),y=r(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),b=r(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),x=r(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),S=t(e(),1),C=n(),ce=1800;function w(e,t){return`most://${e}${t||``}`}function le(e,t){let n=e.trim().replace(/[\\/]+$/,``);return n?`${n}${n.includes(`\\`)?`\\`:`/`}downloads`:t}function T(e,t){let n=e[t];return typeof n==`string`?n:void 0}function E(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function D(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=`object`)return null;let n=t,r=T(n,`event`),i=n.data;if(!r||!i||typeof i!=`object`)return null;let a=i;return{event:r,payload:{taskId:T(a,`taskId`),percent:E(a,`percent`),loaded:E(a,`loaded`),total:E(a,`total`),file:T(a,`file`),fileName:T(a,`fileName`),error:T(a,`error`)}}}function O(){let{t:e}=l(),{cid:t}=a({from:`/cid/$cid/`}),n=h({select:e=>e.searchStr}),r=c(e=>e.hasBackend),o=c(e=>e.addToast),m=c(e=>e.openConnectModal),T=i(e=>e.identity),E=i(e=>e.openLoginModal),O=(0,S.useMemo)(()=>w(t,n),[t,n]),k=(0,S.useMemo)(()=>oe(O),[O]),A=(0,S.useMemo)(()=>v(O,e),[O,e]),fe=k.fileName||t,[j,M]=(0,S.useState)({status:`idle`,message:``}),[N,P]=(0,S.useState)(null),[F,I]=(0,S.useState)({status:`idle`,message:``}),[L,R]=(0,S.useState)(``),[z,B]=(0,S.useState)(0),[V,H]=(0,S.useState)(null),[U,W]=(0,S.useState)(null),[pe,G]=(0,S.useState)(``),[me,K]=(0,S.useState)(!1),q=(0,S.useRef)(0),J=(0,S.useRef)(null),Y=N?.fileName||fe,X=N?.size??U,Z=j.status===`available`||j.status===`already-local`,Q=F.status===`starting`||F.status===`downloading`,he=le(pe,e(`cid.saveToFallback`)),$=(0,S.useCallback)(async()=>{let t=q.current+1;if(q.current=t,R(``),B(0),H(null),W(null),I({status:`idle`,message:``}),A){P(null),M({status:`error`,message:A});return}if(r===null){P(null),M({status:`waiting-backend`,message:e(`cid.status.waitingBackend`)});return}if(r!==!0){P(null),M({status:`backend-missing`,message:e(`cid.status.backendMissing`)});return}if(!T){P(null),M({status:`login-required`,message:e(`cid.status.loginRequired`)});return}M({status:`checking`,message:e(`cid.status.checking`)}),P(null);try{let n=await _.checkDownload(O);if(q.current!==t)return;P(n),M({status:n.alreadyExists?`already-local`:`available`,message:n.alreadyExists?e(`cid.status.alreadyLocal`,{fileName:n.fileName}):e(`cid.status.available`,{fileName:n.fileName})})}catch(e){if(q.current!==t)return;M({status:`error`,message:await ae(e)}),P(null)}},[r,O,e,T,A]);(0,S.useEffect)(()=>{document.title=e(`cid.meta.title`)},[e]),(0,S.useEffect)(()=>{let e=()=>{J.current!==null&&(window.clearTimeout(J.current),J.current=null)},t=()=>{document.visibilityState===`hidden`&&(e(),K(!1))};return document.addEventListener(`visibilitychange`,t),window.addEventListener(`pagehide`,t),()=>{e(),document.removeEventListener(`visibilitychange`,t),window.removeEventListener(`pagehide`,t)}},[]),(0,S.useEffect)(()=>{$()},[$]),(0,S.useEffect)(()=>{if(r!==!0)return;let e=!1;return _.getDataPath().then(t=>{e||G(t.dataPath)}).catch(()=>{e||G(``)}),()=>{e=!0}},[r]),(0,S.useEffect)(()=>{if(!L||!T)return;let t=null,n=!1;return(async()=>{if(t=new WebSocket(await te(`/ws`)),n){t.close();return}t.onmessage=t=>{let n=D(t.data);!n||n.payload.taskId!==L||(n.event===`download:progress`&&(B(n.payload.percent||0),H(n.payload.loaded??null),W(n.payload.total??null)),n.event===`download:status`&&I({status:`downloading`,message:n.payload.file?e(`cid.status.downloadingFile`,{fileName:n.payload.file}):e(`cid.status.downloading`)}),n.event===`download:success`&&(B(100),I({status:`completed`,message:e(`cid.status.downloadComplete`,{fileName:n.payload.fileName||Y})}),o(e(`cid.toast.downloadComplete`),`success`)),n.event===`download:error`&&(I({status:`error`,message:n.payload.error||e(`cid.status.downloadFailed`,{error:``})}),o(e(`cid.toast.downloadFailed`,{error:n.payload.error||e(`cid.errorFallback`)}),`error`)),n.event===`download:cancelled`&&(I({status:`cancelled`,message:e(`cid.status.cancelled`)}),o(e(`cid.toast.cancelled`),`warning`)))}})(),()=>{n=!0,t?.close()}},[o,Y,e,L,T]);let ge=async()=>{if(!T){E();return}if(r!==!0){m();return}if(!(!Z||Q)){I({status:`starting`,message:e(`cid.status.startingDownload`)}),B(0);try{let t=await _.downloadFile(O);if(t.alreadyExists){I({status:`completed`,message:e(`cid.status.alreadyLocal`,{fileName:t.fileName||Y})}),o(e(`cid.toast.alreadyLocal`),`warning`);return}t.taskId&&(R(t.taskId),I({status:`downloading`,message:e(`cid.status.downloading`)}),o(e(`cid.toast.downloadStarted`),`info`))}catch(t){let n=await ee(t,e(`cid.status.downloadFailed`,{error:e(`cid.errorFallback`)}));I({status:`error`,message:n}),o(n,`error`)}}},_e=()=>{K(!1),J.current!==null&&window.clearTimeout(J.current),J.current=window.setTimeout(()=>{J.current=null,document.visibilityState!==`hidden`&&K(!0)},ce)},ve=async()=>{L&&await _.cancelDownload(L).catch(()=>{})},ye=ue(j.status,F.status);return(0,C.jsxs)(`div`,{className:`cid-layout`,children:[(0,C.jsx)(ie,{}),(0,C.jsx)(`main`,{className:`cid-page`,children:(0,C.jsxs)(`section`,{className:`cid-shell`,children:[(0,C.jsxs)(`div`,{className:`cid-heading`,children:[(0,C.jsx)(`span`,{className:`cid-kicker`,children:e(`cid.kicker`)}),(0,C.jsx)(`h1`,{children:e(`cid.title`)}),(0,C.jsx)(`p`,{children:e(`cid.subtitle`)})]}),(0,C.jsxs)(`div`,{className:`cid-panel`,children:[(0,C.jsxs)(`div`,{className:`cid-handoff`,"aria-label":e(`cid.handoff.title`),children:[(0,C.jsxs)(`div`,{className:`cid-handoff-copy`,children:[(0,C.jsx)(`p`,{className:`cid-handoff-title`,children:e(`cid.handoff.title`)}),(0,C.jsx)(`p`,{children:e(`cid.handoff.desc`)})]}),(0,C.jsxs)(`a`,{className:`btn btn-primary`,href:O,onClick:_e,children:[(0,C.jsx)(ne,{size:16}),e(`cid.handoff.action`)]})]}),me&&(0,C.jsxs)(`div`,{className:`cid-handoff-fallback`,role:`status`,children:[(0,C.jsx)(u,{size:18}),(0,C.jsx)(`p`,{children:e(`cid.handoff.fallback`)}),(0,C.jsxs)(s,{to:`/download/`,className:`btn btn-secondary`,children:[(0,C.jsx)(d,{size:16}),e(`cid.handoff.downloadAction`)]})]}),(0,C.jsxs)(`div`,{className:`cid-status`,children:[(0,C.jsx)(`span`,{className:`cid-status-icon ${j.status}`,children:ye}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`p`,{className:`cid-status-label`,children:de(j.status,e)}),(0,C.jsx)(`p`,{className:`cid-status-message`,children:j.message})]})]}),(0,C.jsxs)(`dl`,{className:`cid-details`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`dt`,{children:[(0,C.jsx)(re,{size:16}),e(`cid.fileNameLabel`)]}),(0,C.jsx)(`dd`,{children:Y})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`dt`,{children:e(`cid.cidLabel`)}),(0,C.jsx)(`dd`,{className:`cid-mono`,children:t})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`dt`,{children:e(`cid.sizeLabel`)}),(0,C.jsx)(`dd`,{children:X?g(X):e(`cid.unknownSize`)})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`dt`,{children:[(0,C.jsx)(f,{size:16}),e(`cid.saveToLabel`)]}),(0,C.jsx)(`dd`,{children:he})]})]}),F.status!==`idle`&&(0,C.jsxs)(`div`,{className:`cid-download-state ${F.status}`,children:[(0,C.jsx)(`p`,{children:F.message}),(F.status===`starting`||F.status===`downloading`)&&(0,C.jsxs)(`div`,{className:`cid-progress`,children:[(0,C.jsx)(`progress`,{className:`cid-progress-bar`,value:z,max:100}),(0,C.jsx)(`span`,{children:V!==null&&U!==null?`${g(V)} / ${g(U)}`:`${z}%`})]})]}),(0,C.jsxs)(`div`,{className:`cid-actions`,children:[j.status===`login-required`&&(0,C.jsxs)(`button`,{className:`btn btn-primary`,onClick:E,children:[(0,C.jsx)(b,{size:16}),e(`cid.loginAction`)]}),j.status===`backend-missing`&&(0,C.jsxs)(`button`,{className:`btn btn-primary`,onClick:m,children:[(0,C.jsx)(x,{size:16}),e(`cid.connectAction`)]}),(0,C.jsxs)(`button`,{className:`btn btn-primary`,disabled:!Z||Q,onClick:ge,children:[Q?(0,C.jsx)(y,{className:`cid-spin-icon`,size:16}):(0,C.jsx)(d,{size:16}),e(Q?`cid.downloadingAction`:`cid.startAction`)]}),L&&F.status===`downloading`&&(0,C.jsxs)(`button`,{className:`btn btn-secondary`,onClick:ve,children:[(0,C.jsx)(se,{size:16}),e(`cid.cancelAction`)]}),(0,C.jsxs)(`button`,{className:`btn btn-secondary`,disabled:j.status===`checking`,onClick:$,children:[(0,C.jsx)(p,{size:16}),e(`cid.retryAction`)]}),(0,C.jsx)(s,{to:`/app/`,className:`btn btn-secondary`,children:e(`cid.openAppAction`)})]})]})]})})]})}function ue(e,t){return t===`completed`?(0,C.jsx)(m,{size:28}):t===`error`||e===`error`?(0,C.jsx)(u,{size:28}):e===`checking`||e===`waiting-backend`||t===`starting`||t===`downloading`?(0,C.jsx)(y,{size:28}):e===`backend-missing`?(0,C.jsx)(x,{size:28}):e===`login-required`?(0,C.jsx)(b,{size:28}):(0,C.jsx)(m,{size:28})}function de(e,t){switch(e){case`checking`:return t(`cid.label.checking`);case`available`:return t(`cid.label.available`);case`already-local`:return t(`cid.label.alreadyLocal`);case`login-required`:return t(`cid.label.loginRequired`);case`backend-missing`:return t(`cid.label.backendMissing`);case`waiting-backend`:return t(`cid.label.waitingBackend`);case`error`:return t(`cid.label.error`);default:return t(`cid.label.idle`)}}var k=o(`/cid/$cid/`)({component:O});export{k as Route};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,H as i,W as a,t as o}from"./useAppStore-DNhyhD20.js";import{a as s}from"./i18n-
|
|
1
|
+
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,H as i,W as a,t as o}from"./useAppStore-DNhyhD20.js";import{a as s}from"./i18n-DKsg67mH.js";import{a as c}from"./AccountMenu-D_rcXDZr.js";import{t as l}from"./arrow-right-BsHzC0ZL.js";import{t as u}from"./download-Cy2BlfKM.js";import{t as d}from"./external-link-D_AQSgxW.js";import{t as f}from"./folder-open-DOJ4bB58.js";import{t as p}from"./gamepad-2-BYqNgCQr.js";import{t as m}from"./hard-drive-DL1KJHmG.js";import{t as h}from"./message-square-CfApq8Ou.js";import{t as g}from"./notebook-pen-Bcd3MrtD.js";import{t as _}from"./wallet-D6HZocla.js";import{E as v,k as y}from"./index-DJzLHA0V.js";import{t as b}from"./MarketingLayout-hkPAtieL.js";var x=r(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),S=t(e(),1),C=n(),w=[{id:`app`,titleKey:`portal.feature.app.title`,subtitleKey:`portal.feature.app.subtitle`,icon:(0,C.jsx)(f,{size:28}),path:`/app/`,requiresBackend:!0,heroKey:`portal.feature.app.hero`,descKey:`portal.feature.app.desc`,featureKeys:[`portal.feature.app.bullet.localIdentity`,`portal.feature.app.bullet.hyperswarm`,`portal.feature.app.bullet.largeFiles`,`portal.feature.app.bullet.cid`,`portal.feature.app.bullet.seedAfterDownload`,`portal.feature.app.bullet.noCloud`,`portal.feature.app.bullet.desktop`,`portal.feature.app.bullet.openSource`],steps:[{num:`1`,titleKey:`portal.feature.app.step.download.title`,descKey:`portal.feature.app.step.download.desc`,link:`/download/`,linkTextKey:`portal.feature.app.step.download.link`,hideInDesktopClient:!0},{num:`2`,titleKey:`portal.feature.app.step.install.title`,descKey:`portal.feature.app.step.install.desc`,hideInDesktopClient:!0},{num:`3`,titleKey:`portal.feature.app.step.share.title`,descKey:`portal.feature.app.step.share.desc`}]},{id:`chat`,titleKey:`portal.feature.chat.title`,subtitleKey:`portal.feature.chat.subtitle`,icon:(0,C.jsx)(h,{size:28}),path:`/chat/`,requiresBackend:!0,heroKey:`portal.feature.chat.hero`,descKey:`portal.feature.chat.desc`,featureKeys:[`portal.feature.chat.bullet.encrypted`,`portal.feature.chat.bullet.identity`,`portal.feature.chat.bullet.sync`,`portal.feature.chat.bullet.offline`,`portal.feature.chat.bullet.noAccount`],steps:[{num:`1`,titleKey:`portal.feature.chat.step.download.title`,descKey:`portal.feature.chat.step.download.desc`,link:`/download/`,linkTextKey:`portal.feature.chat.step.download.link`,hideInDesktopClient:!0},{num:`2`,titleKey:`portal.feature.chat.step.create.title`,descKey:`portal.feature.chat.step.create.desc`},{num:`3`,titleKey:`portal.feature.chat.step.send.title`,descKey:`portal.feature.chat.step.send.desc`}]},{id:`note`,titleKey:`portal.feature.note.title`,subtitleKey:`portal.feature.note.subtitle`,icon:(0,C.jsx)(g,{size:28}),path:`/note/`,requiresBackend:!1,heroKey:`portal.feature.note.hero`,descKey:`portal.feature.note.desc`,featureKeys:[`portal.feature.note.bullet.markdown`,`portal.feature.note.bullet.privacy`,`portal.feature.note.bullet.folders`,`portal.feature.note.bullet.web3`,`portal.feature.note.bullet.backup`,`portal.feature.note.bullet.independent`],steps:[{num:`1`,titleKey:`portal.feature.note.step.account.title`,descKey:`portal.feature.note.step.account.desc`},{num:`2`,titleKey:`portal.feature.note.step.create.title`,descKey:`portal.feature.note.step.create.desc`},{num:`3`,titleKey:`portal.feature.note.step.backup.title`,descKey:`portal.feature.note.step.backup.desc`}]},{id:`gandengyan`,titleKey:`portal.feature.game.title`,subtitleKey:`portal.feature.game.subtitle`,icon:(0,C.jsx)(p,{size:28}),path:`/game/gandengyan/`,requiresBackend:!0,heroKey:`portal.feature.game.hero`,descKey:`portal.feature.game.desc`,featureKeys:[`portal.feature.game.bullet.account`,`portal.feature.game.bullet.channel`,`portal.feature.game.bullet.link`,`portal.feature.game.bullet.rules`,`portal.feature.game.bullet.maintain`],steps:[{num:`1`,titleKey:`portal.feature.game.step.login.title`,descKey:`portal.feature.game.step.login.desc`},{num:`2`,titleKey:`portal.feature.game.step.create.title`,descKey:`portal.feature.game.step.create.desc`},{num:`3`,titleKey:`portal.feature.game.step.test.title`,descKey:`portal.feature.game.step.test.desc`}]},{id:`web3`,titleKey:`portal.feature.web3.title`,subtitleKey:`portal.feature.web3.subtitle`,icon:(0,C.jsx)(_,{size:28}),path:`/web3/`,requiresBackend:!1,heroKey:`portal.feature.web3.hero`,descKey:`portal.feature.web3.desc`,featureKeys:[`portal.feature.web3.bullet.frontend`,`portal.feature.web3.bullet.keys`,`portal.feature.web3.bullet.mnemonic`,`portal.feature.web3.bullet.eth`,`portal.feature.web3.bullet.pem`,`portal.feature.web3.bullet.qr`],steps:[{num:`1`,titleKey:`portal.feature.web3.step.username.title`,descKey:`portal.feature.web3.step.username.desc`},{num:`2`,titleKey:`portal.feature.web3.step.keys.title`,descKey:`portal.feature.web3.step.keys.desc`},{num:`3`,titleKey:`portal.feature.web3.step.export.title`,descKey:`portal.feature.web3.step.export.desc`}]}],T=[`chat`,`app`,`note`,`gandengyan`,`web3`];function E(){let e=o(e=>e.hasBackend),t=o(e=>e.openConnectModal),[n,r]=(0,S.useState)(`chat`),{t:i}=s(),f=v(),p=T.map(e=>w.find(t=>t.id===e)).filter(e=>!!e),h=p.find(e=>e.id===n)||p[0],g=i(h.titleKey),_=h.steps.filter(e=>!(f&&e.hideInDesktopClient));return(0,C.jsxs)(`div`,{className:`portal-page`,children:[(0,C.jsx)(`section`,{className:`portal-hero`,children:(0,C.jsxs)(`div`,{className:`mkt-container`,children:[(0,C.jsx)(`h1`,{className:`portal-hero-title`,children:i(`common.brand`)}),(0,C.jsx)(`p`,{className:`portal-hero-subtitle`,children:i(`portal.hero.subtitle`)})]})}),(0,C.jsx)(`section`,{className:`portal-cards-section`,children:(0,C.jsxs)(`div`,{className:`mkt-container`,children:[(0,C.jsx)(`div`,{className:`portal-cards`,children:p.map(t=>{let o=n===t.id,s=t.requiresBackend,c=s?e===!0?`connected`:e===!1?`disconnected`:`checking`:`none`,l=i(t.titleKey);return(0,C.jsxs)(`button`,{className:`portal-card ${o?`active`:``}`,onClick:()=>r(t.id),children:[(0,C.jsx)(a,{to:t.path,className:`btn btn-icon portal-card-open-btn`,onClick:e=>e.stopPropagation(),title:i(`portal.openFeature`,{title:l}),children:(0,C.jsx)(x,{size:16})}),(0,C.jsx)(`div`,{className:`portal-card-icon`,children:t.icon}),(0,C.jsx)(`div`,{className:`portal-card-title`,children:l}),(0,C.jsx)(`div`,{className:`portal-card-subtitle`,children:i(t.subtitleKey)}),s?(0,C.jsxs)(`div`,{className:`ui-badge portal-card-status ${c}`,children:[c===`checking`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`span`,{className:`status-dot checking`}),i(`common.status.checking`)]}),c===`connected`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`span`,{className:`status-dot connected`}),i(`common.status.connected`)]}),c===`disconnected`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`span`,{className:`status-dot disconnected`}),i(`common.status.needsConnection`)]})]}):(0,C.jsxs)(`div`,{className:`ui-badge portal-card-status ready`,children:[(0,C.jsx)(`span`,{className:`status-dot ready`}),i(`common.status.ready`)]})]},t.id)})}),(0,C.jsxs)(`div`,{className:`portal-node-actions`,"aria-label":i(`portal.nodeEntry`),children:[(0,C.jsxs)(`button`,{onClick:t,className:`btn btn-secondary`,children:[(0,C.jsx)(y,{size:16}),i(`portal.webConnectNode`)]}),(0,C.jsxs)(a,{to:`/admin/`,className:`btn btn-secondary`,children:[(0,C.jsx)(m,{size:16}),i(`portal.nodeAdmin`)]})]})]})}),(0,C.jsx)(`section`,{className:`portal-marketing`,children:(0,C.jsx)(`div`,{className:`mkt-container`,children:(0,C.jsxs)(`div`,{className:`portal-marketing-inner`,children:[(0,C.jsxs)(`div`,{className:`portal-marketing-header`,children:[(0,C.jsx)(`h2`,{children:i(h.heroKey)}),(0,C.jsx)(`p`,{children:i(h.descKey)})]}),(0,C.jsx)(`div`,{className:`portal-marketing-features`,children:h.featureKeys.map(e=>(0,C.jsxs)(`div`,{className:`portal-feature-item`,children:[(0,C.jsx)(`span`,{className:`portal-feature-icon`,children:(0,C.jsx)(c,{size:14,strokeWidth:3})}),(0,C.jsx)(`span`,{children:i(e)})]},e))}),(0,C.jsx)(`div`,{className:`portal-marketing-steps`,children:_.map((e,t)=>(0,C.jsxs)(`div`,{className:`portal-step`,children:[(0,C.jsx)(`span`,{className:`portal-step-num`,children:t+1}),(0,C.jsxs)(`div`,{className:`portal-step-content`,children:[(0,C.jsx)(`strong`,{children:i(e.titleKey)}),(0,C.jsx)(`p`,{children:i(e.descKey)}),e.code&&(0,C.jsx)(`code`,{className:`portal-step-code`,translate:`no`,children:e.code}),e.link&&e.linkTextKey&&(0,C.jsx)(`p`,{className:`portal-step-link`,children:(0,C.jsxs)(a,{to:e.link,children:[i(e.linkTextKey),` `,(0,C.jsx)(d,{size:12})]})})]})]},e.num))}),(0,C.jsxs)(`div`,{className:`portal-actions`,children:[(0,C.jsxs)(a,{to:h.path,className:`btn btn-primary`,children:[i(`portal.enterFeature`,{title:g}),(0,C.jsx)(l,{size:16})]}),h.requiresBackend&&e===!1&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`button`,{onClick:t,className:`btn btn-secondary`,children:[(0,C.jsx)(y,{size:16}),i(`portal.webConnectNode`)]}),!f&&(0,C.jsxs)(a,{to:`/download/`,className:`btn btn-secondary`,children:[(0,C.jsx)(u,{size:16}),i(`nav.downloadClient`)]})]})]})]})})})]})}function D(){return(0,C.jsx)(b,{children:(0,C.jsx)(E,{})})}var O=i(`/`)({component:D});export{O as Route};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MilkdownEditor-
|
|
2
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,C as i,E as a,H as o,M as s,d as c,j as l,o as u,t as d,w as f}from"./useAppStore-DNhyhD20.js";import{n as ee}from"./useNavigate-DWlBD_-b.js";import{a as te}from"./i18n-C6yaqRst.js";import{a as ne,i as re,n as ie,o as p}from"./chatNoteDraft-DTy6In5R.js";import{t as ae}from"./OpenSidebarButton-OP8zl7ad.js";import{n as m,t as oe}from"./trash-2-B9gno5q6.js";import{t as h}from"./folder-open-DOJ4bB58.js";import{t as g}from"./folder-6pYYnS2-.js";import{t as _}from"./lock-yG7M7GkB.js";import{t as se}from"./AppShell-BdRKZIZ9.js";import{t as v}from"./notebook-pen-Bcd3MrtD.js";import{t as ce}from"./save-CfYzXcxH.js";import{t as le}from"./search-DLBOUfny.js";import{C as ue,E as y,L as de,M as b,O as fe,P as x,S as pe,T as me,c as S,d as C,f as w,l as he,m as T,p as ge,s as _e,t as E,u as ve,w as ye}from"./index-D1mozno-.js";import{t as D}from"./AppTop-BE5kKBYH.js";var be=r(`move`,[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`m15 19-3 3-3-3`,key:`11eu04`}],[`path`,{d:`m19 9 3 3-3 3`,key:`1mg7y2`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}],[`path`,{d:`m5 9-3 3 3 3`,key:`j64kie`}],[`path`,{d:`m9 5 3-3 3 3`,key:`l8vdw6`}]]),xe=r(`pencil-ruler`,[[`path`,{d:`M13 7 8.7 2.7a2.41 2.41 0 0 0-3.4 0L2.7 5.3a2.41 2.41 0 0 0 0 3.4L7 13`,key:`orapub`}],[`path`,{d:`m8 6 2-2`,key:`115y1s`}],[`path`,{d:`m18 16 2-2`,key:`ee94s4`}],[`path`,{d:`m17 11 4.3 4.3c.94.94.94 2.46 0 3.4l-2.6 2.6c-.94.94-2.46.94-3.4 0L11 17`,key:`cfq27r`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),O=t(e(),1),k=n();function A(e){return e.type===`directory`?f(e.path?`${e.path}/${e.name}`:e.name):i(e)}function Se({target:e,targetLabel:t,directories:n,onMove:r,onClose:i}){let{t:a}=te(),o=f(e.path||``),s=A(e),c=n.filter(t=>e.type===`directory`?t.path!==s&&!t.path.startsWith(`${s}/`):!0),[l,u]=(0,O.useState)(o),[d,ee]=(0,O.useState)(``),[ne,re]=(0,O.useState)(new Set),ie=f(d),p=d.trim()?ie:l,ae=f(p)===o,oe=a(`note.move.rootDirectory`),h=new Map;for(let e of c){let t=h.get(e.parentPath)||[];t.push(e),h.set(e.parentPath,t)}let _=c.filter(e=>{if(!e.parentPath)return!0;let t=e.parentPath.split(`/`).filter(Boolean);return t.every((e,n)=>ne.has(t.slice(0,n+1).join(`/`)))}),se=[{label:oe,path:``},...l.split(`/`).filter(Boolean).map((e,t,n)=>({label:e,path:n.slice(0,t+1).join(`/`)}))];function v(e){u(f(e)),ee(``)}function ce(e){v(e),h.has(e)&&re(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function le(){ae||r(p)}return(0,k.jsx)(me,{onClose:i,children:(0,k.jsxs)(`div`,{className:`note-move-modal`,onClick:e=>e.stopPropagation(),children:[(0,k.jsxs)(`div`,{className:`modal-header`,children:[(0,k.jsx)(`h3`,{children:a(`note.move.title`)}),(0,k.jsx)(`button`,{className:`btn btn-icon`,onClick:i,children:(0,k.jsx)(fe,{size:18})})]}),(0,k.jsxs)(`div`,{className:`note-move-target`,children:[(0,k.jsx)(`span`,{children:a(`note.move.moving`)}),(0,k.jsx)(`strong`,{translate:`no`,children:t||e.name})]}),(0,k.jsx)(`div`,{className:`note-move-path`,children:se.map((e,t)=>(0,k.jsxs)(O.Fragment,{children:[t>0&&(0,k.jsx)(`span`,{children:`/`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>v(e.path),children:(0,k.jsx)(`span`,{translate:e.path?`no`:`yes`,children:e.label})})]},e.path||`root`))}),(0,k.jsxs)(`div`,{className:`note-move-folder-list`,children:[(0,k.jsxs)(`button`,{type:`button`,className:`note-move-folder-item ${l===``?`selected`:``}`,onClick:()=>v(``),children:[(0,k.jsx)(`span`,{className:`note-move-folder-spacer`}),(0,k.jsx)(g,{className:`note-move-folder-icon`,size:16}),(0,k.jsx)(`span`,{children:oe})]}),c.length===0?(0,k.jsx)(`p`,{className:`note-move-empty`,children:a(`note.move.noFolders`)}):_.map(e=>{let t=h.has(e.path),n=ne.has(e.path);return(0,k.jsxs)(`button`,{type:`button`,className:`note-move-folder-item note-move-depth-${Math.min(e.depth,4)} ${l===e.path?`selected`:``}`,onClick:()=>ce(e.path),children:[t?n?(0,k.jsx)(x,{className:`note-move-expander`,size:14}):(0,k.jsx)(m,{className:`note-move-expander`,size:14}):(0,k.jsx)(`span`,{className:`note-move-folder-spacer`}),(0,k.jsx)(g,{className:`note-move-folder-icon`,size:16}),(0,k.jsx)(`span`,{translate:`no`,children:e.name}),e.parentPath&&(0,k.jsx)(`small`,{translate:`no`,children:e.parentPath})]},e.path)})]}),(0,k.jsx)(`input`,{className:`input input-compact`,value:d,onChange:e=>ee(e.target.value),placeholder:a(`note.move.pathPlaceholder`),translate:`no`}),(0,k.jsxs)(`div`,{className:`note-move-destination`,children:[(0,k.jsx)(`span`,{children:a(`note.move.destinationLabel`)}),(0,k.jsx)(`span`,{translate:p?`no`:`yes`,children:p||oe})]}),(0,k.jsxs)(`div`,{className:`modal-actions`,children:[(0,k.jsx)(`button`,{className:`btn btn-secondary`,onClick:i,children:a(`common.cancel`)}),(0,k.jsx)(`button`,{className:`btn btn-primary`,onClick:le,disabled:ae,children:a(`note.action.move`)})]})]})})}function Ce({children:e}){return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(D,{}),e]})}var we=(0,O.lazy)(async()=>({default:(await E(()=>import(`./MilkdownEditor-C388llV6.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8]))).MilkdownEditor})),j=/\[\[([^\]\n]+?)\]\]/g,M=/(```[\s\S]*?```)/g;function Te(e){let t=new URLSearchParams(e),n=t.get(`mode`);return{cid:t.get(`cid`)||void 0,file:t.get(`file`)||void 0,path:t.get(`path`)||void 0,chatDraft:t.get(`chatDraft`)||void 0,mode:n===`edit`?`edit`:void 0}}function N(e={}){let t=new URLSearchParams;e.cid&&t.set(`cid`,e.cid),e.file&&t.set(`file`,e.file),e.path&&t.set(`path`,e.path),e.chatDraft&&t.set(`chatDraft`,e.chatDraft),e.mode&&t.set(`mode`,e.mode);let n=t.toString();return n?`/note/?${n}`:`/note/`}function Ee(e){let t=e.indexOf(`?`),n=t>=0?e.slice(t):``;if(typeof window>`u`)return Te(n);try{return Te(new URL(e,window.location.origin).search)}catch{return Te(n)}}var P={"note.error.nameRequired":`note.error.nameRequired`,"note.error.nameNoSlash":`note.error.nameNoSlash`,"note.error.nameNoBackslash":`note.error.nameNoBackslash`,"note.error.nameInvalid":`note.error.nameInvalid`,"note.error.nameConflict":`note.error.nameConflict`,"note.error.moveIntoSelf":`note.error.moveIntoSelf`};function De(e,t,n){let r=e instanceof Error?e.message:``,i=P[r];return i?n(i):r||t}function Oe(e){return e.type===`directory`?f(e.path?`${e.path}/${e.name}`:e.name):i(e)}function F(e=``){return String(e).trim().replace(/\.md$/i,``)}function I(e){let t=F(e);return t?`${t}.md`:``}function ke(e,t,n){let r=F(e)||t;for(let e=0;e<1e3;e+=1){let t=I(e===0?r:`${r} ${e+1}`);if(t&&!n(t))return t}return I(`${r} ${Date.now()}`)}function Ae(e=``){let t=f(e).split(`/`).filter(Boolean);if(t.length===0)return``;let n=t.length-1;return t[n]=I(t[n]),t.join(`/`)}function je(e=``){let t=f(e).split(`/`).filter(Boolean);if(t.length===0)return``;let n=t.length-1;return t[n]=F(t[n]),t.join(`/`)}function Me(e){return je(i(e))}function L(e){let t=e.trim().replace(/^\/+/,``),n=t.search(/[#^]/);return je(n>=0?t.slice(0,n):t)}function Ne(e,t){let n=t?.trim();if(n)return n;let r=e.split(`/`).filter(Boolean);return r[r.length-1]||e}function R(e){return e.replace(/\\/g,`\\\\`).replace(/\[/g,`\\[`).replace(/\]/g,`\\]`)}function Pe(e,t){return`[${R(e)}](<${t.replace(/>/g,`%3E`)}>)`}function Fe(e,t,n=``){let r=L(t);if(!r)return null;let i=r.toLowerCase(),a=e=>Me(e).toLowerCase();if(r.includes(`/`))return e.find(e=>a(e)===i)||null;let o=f(n);if(o){let t=f(`${o}/${r}`).toLowerCase(),n=e.find(e=>a(e)===t);if(n)return n}return e.find(e=>F(e.name).toLowerCase()===i)||null}function Ie(e,t,n,r=``,i){let a=e.indexOf(`|`),o=a>=0?e.slice(0,a):e,s=a>=0?e.slice(a+1):void 0,c=L(o);if(!c)return null;let l=Fe(t,o,r),u=l?n(l):i?.(c);return u?{label:Ne(c,s),href:u}:null}function Le(e,t,n,r=``,i){return e.includes(`[[`)?e.split(M).map(e=>e.startsWith("```")?e:e.replace(j,(e,a)=>{let o=Ie(a,t,n,r,i);return o?Pe(o.label,o.href):e})).join(``):e}function z(e){return e.type===`file`?F(e.name):e.name}function B(e){return e.type===`file`?je(e.fullPath):e.fullPath}function Re(e){return e.type===`file`?F(e.name):e.name}function ze(e=``){let t=f(e).split(`/`).filter(Boolean);return t.map((e,n)=>t.slice(0,n+1).join(`/`))}function Be(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function Ve(e,t){if(t.length===0)return e;let n=!1,r=new Set(e);for(let e of t)r.has(e)||(r.add(e),n=!0);return n?r:e}function He(e){return{name:e.name,cid:`__dir__${e.fullPath}`,path:e.path,type:`directory`,size:0,created_at:e.updatedAt,updated_at:e.updatedAt}}function Ue(e,t){let n=[],r=new Map;function a(e){return e&&r.get(e)?.children||n}function o(e,t,n){let i=f(t?`${t}/${e}`:e),o=r.get(i);if(o)return o.updatedAt=Math.max(o.updatedAt,n),o;let s={id:`directory:${i}`,type:`directory`,name:e,path:t,fullPath:i,updatedAt:n,children:[]};return r.set(i,s),a(t).push(s),s}for(let t of e){let e=f(t.path||``),n=e.split(`/`).filter(Boolean),r=t.updated_at||t.created_at||0,s=``;for(let e of n)s=o(e,s,r).fullPath;a(s).push({id:`file:${t.cid}:${i(t)}`,type:`file`,name:t.name,path:e,fullPath:i(t),updatedAt:r,note:t,children:[]})}function s(e){e.sort((e,n)=>{if(e.type!==n.type)return e.type===`directory`?-1:1;let r=t(z(e),z(n));return r===0?t(B(e),B(n)):r});for(let t of e)t.type===`directory`&&s(t.children)}return s(n),n}function We(e,t){let n=t.trim().toLowerCase();return n?e.flatMap(e=>{let t=z(e).toLowerCase(),r=B(e).toLowerCase(),i=t.includes(n)||r.includes(n);if(e.type===`file`)return i?[e]:[];let a=i?e.children:We(e.children,n);return!i&&a.length===0?[]:[{...e,children:a}]}):e}function Ge({nodes:e,searchQuery:t,expandedPaths:n,activeFileId:r,activeFolderPath:i,onToggleDirectory:a,onOpenFile:o,renderActions:s}){let c=t.trim().length>0;return(0,k.jsx)(`div`,{className:`note-tree`,role:`tree`,children:e.map(e=>(0,k.jsx)(V,{node:e,forceExpanded:c,expandedPaths:n,activeFileId:r,activeFolderPath:i,onToggleDirectory:a,onOpenFile:o,renderActions:s},e.id))})}function V({node:e,forceExpanded:t,expandedPaths:n,activeFileId:r,activeFolderPath:i,onToggleDirectory:a,onOpenFile:o,renderActions:s}){let c=e.type===`directory`,l=c&&(t||n.has(e.fullPath)),u=e.type===`file`&&e.note?.cid===r,d=c&&f(i)===e.fullPath,ee=c?He(e):e.note||null,te=ee&&s?s(ee):null;return(0,k.jsxs)(`div`,{className:`note-tree-node`,role:`none`,children:[(0,k.jsxs)(`div`,{className:`note-tree-row ${c?`is-directory`:`is-file`} ${u?`is-active`:``} ${d?`is-folder-active`:``} ${te?`has-actions`:``}`,children:[(0,k.jsxs)(`button`,{type:`button`,className:`note-tree-item`,role:`treeitem`,"aria-expanded":c?l:void 0,onClick:()=>{if(c){a(e);return}e.note&&o(e.note)},children:[(0,k.jsx)(`span`,{className:`note-tree-toggle`,"aria-hidden":`true`,children:c?l?(0,k.jsx)(x,{size:16}):(0,k.jsx)(m,{size:16}):(0,k.jsx)(`span`,{className:`note-tree-toggle-placeholder`})}),(0,k.jsx)(`span`,{className:`note-tree-label`,translate:`no`,children:z(e)}),e.note?.isSecret&&(0,k.jsx)(_,{className:`note-tree-lock`,size:14,"aria-hidden":`true`})]}),te]}),c&&l&&e.children.length>0&&(0,k.jsx)(`div`,{className:`note-tree-children`,role:`group`,children:e.children.map(e=>(0,k.jsx)(V,{node:e,forceExpanded:t,expandedPaths:n,activeFileId:r,activeFolderPath:i,onToggleDirectory:a,onOpenFile:o,renderActions:s},e.id))})]})}function Ke(e,t){let n=new Set;for(let t of e){let e=f(t.path).split(`/`).filter(Boolean);for(let t=0;t<e.length;t+=1)n.add(e.slice(0,t+1).join(`/`))}return Array.from(n).sort(t).map(e=>{let t=e.split(`/`);return{path:e,name:t[t.length-1]||e,parentPath:t.slice(0,-1).join(`/`),depth:Math.max(t.length-1,0)}})}function H(e){return e.map(e=>({name:e.name,cid:e.path,path:f(e.directory),content:``,size:e.size,type:`file`,created_at:Number(e.mtimeMs)||Date.now(),updated_at:Number(e.mtimeMs)||Date.now(),isSecret:!1}))}function U(e,t){let n=I(t);return f(e?`${e}/${n}`:n)}function qe(e){let t=e||typeof window<`u`&&window.location.origin||``;if(!t)return!1;try{let e=new URL(t).hostname.toLowerCase();return e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}catch{return!1}}function W(e,t=``){let[n,r]=(0,O.useState)(!1);return(0,O.useEffect)(()=>{let n=!1;return!e||!t?(r(!1),()=>{n=!0}):(ve().then(e=>{n||r(e.configured===!0)}).catch(()=>{n||r(!1)}),()=>{n=!0})},[e,t]),n}function G(){let{t:e,formatDate:t,compareStrings:n}=te(),r=ee(),i=de({select:e=>e.searchStr}),o=(0,O.useMemo)(()=>Te(i),[i]),c=(0,O.useRef)(null),u=d(e=>e.addToast),p=a(e=>e.wallet),m=a(e=>e.openLoginModal),h=d(e=>e.notes),g=d(e=>e.notesPath),y=d(e=>e.setNotesPath),x=d(e=>e.saveNote),pe=d(e=>e.deleteNote),me=d(e=>e.renameNote),S=d(e=>e.localDataReady),C=o.cid||``,w=h.find(e=>e.cid===C),he=!!C,T=he&&o.mode===`edit`,[ge,_e]=(0,O.useState)(``),[E,ve]=(0,O.useState)(null),[D,A]=(0,O.useState)(null),[j,M]=(0,O.useState)(null),P=(0,O.useRef)(``),je=(0,O.useRef)(``),[Me,L]=(0,O.useState)(``),[Ne,R]=(0,O.useState)(``),[Pe,z]=(0,O.useState)(``),[B,He]=(0,O.useState)(``),[V,H]=(0,O.useState)(``),[U,qe]=(0,O.useState)(!1),[W,G]=(0,O.useState)(``),[K,q]=(0,O.useState)(!1),[Je,Ye]=(0,O.useState)(()=>new Set(ze(g)));(0,O.useEffect)(()=>{if(!C){L(``),R(``);return}if(!w){L(``),R(S?e(`note.error.notFound`):``);return}if(w.content.startsWith(`mp://1`)){if(!p){L(``),R(e(`note.error.loginToDecrypt`));return}let t=l(w.content,p.danger);if(!t){L(``),R(e(`note.error.decryptFailed`));return}L(t),R(``);return}L(w.content||``),R(``)},[C,S,w,e,p]),(0,O.useEffect)(()=>{if(!T){q(!1);return}if(!C||!w){z(``),He(``),H(``),qe(!1),G(S?e(`note.error.notFound`):``);return}if(z(F(w.name)),He(w.path||``),qe(w.isSecret===!0||w.content.startsWith(`mp://1`)),w.content.startsWith(`mp://1`)){if(!p){H(``),G(e(`note.error.loginToDecrypt`));return}let t=l(w.content,p.danger);if(!t){H(``),G(e(`note.error.decryptFailed`));return}H(t),G(``);return}H(w.content||``),G(``)},[C,T,S,w,e,p]);let Xe=(0,O.useMemo)(()=>Ue(h,n),[n,h]),Ze=(0,O.useMemo)(()=>We(Xe,ge),[Xe,ge]),Qe=w?.isSecret===!0||w?.content.startsWith(`mp://1`)===!0,J=e(T?U?`note.privacy.secret`:`note.privacy.public`:Qe?`note.privacy.secret`:`note.privacy.public`),$e=(0,O.useMemo)(()=>Ke(h,n),[n,h]),et=(0,O.useMemo)(()=>Le(Me,h,e=>N({cid:e.cid}),w?.path||``,e=>N({path:Ae(e)})),[h,Me,w?.path]),tt=(0,O.useCallback)(e=>Ie(e,h,e=>N({cid:e.cid}),w?.path||``,e=>N({path:Ae(e)})),[h,w?.path]);(0,O.useEffect)(()=>{w?.path&&Ye(e=>Ve(e,ze(w.path)))},[w?.path]),(0,O.useEffect)(()=>{if(!o.path||C||h.length===0)return;let e=Fe(h,o.path);e&&(y(f(e.path||``)),r({href:N({cid:e.cid}),replace:!0}))},[C,r,h,o.path,y]),(0,O.useEffect)(()=>{let t=o.chatDraft||``;if(!t||P.current===t||!S)return;if(!p){let e=`${t}:auth`;je.current!==e&&(je.current=e,m());return}let n=re(t);if(!n){P.current=t,u(e(`note.chatDraft.missing`),`warning`),Y({},!0);return}P.current=t,at(n)},[u,S,o.chatDraft,e,p]);function Y(e={},t=!1){r({href:N(e),replace:t})}function nt(e){Y(Ee(e))}function rt(e){y(f(e.path||``)),Y({cid:e.cid})}function it(e){y(e.fullPath),Ye(t=>Be(t,e.fullPath))}function X(e){Y({cid:e.cid,mode:`edit`})}function Z(){return p?!0:(m(),!1)}async function at(t){if(p)try{let n=await x({name:ke(t.title,e(`note.chatDraft.defaultTitle`),e=>h.some(t=>f(t.path||``)===f(g)&&t.name===e)),path:g,content:t.content,isSecret:!1});ie(t.id),u(e(`note.chatDraft.created`),`success`),Y({cid:n,mode:`edit`},!0)}catch(t){P.current=``,u(De(t,e(`note.toast.createFailed`),e),`error`)}}function ot(){Y(w?{cid:w.cid}:{})}async function st(){if(!Z())return;if(!w){u(e(`note.toast.notFound`),`error`);return}let t=I(Pe);if(!t){u(e(`note.toast.nameRequired`),`warning`);return}q(!0);try{let n=c.current?.getMarkdown()??V,r=U?s(n,p.danger):n,i=await x({cid:w.cid,name:t,path:B,content:r,isSecret:U});H(n),Y({cid:i},!0),u(e(`note.toast.saved`),`success`)}catch(t){u(De(t,e(`note.toast.saveFailed`),e),`error`)}finally{q(!1)}}function ct(){Z()&&ve({title:e(`note.create.title`),placeholder:e(`note.namePlaceholder`),confirmText:e(`note.create.action`),onConfirm:async t=>{if(Z())try{let n=await x({name:I(t),path:g,content:``,isSecret:!1});ve(null),u(e(`note.toast.created`),`success`),Y({cid:n,mode:`edit`})}catch(t){u(De(t,e(`note.toast.createFailed`),e),`error`)}}})}function lt(e){Z()&&M(e)}async function Q(t){if(j)try{me(Oe(j),t,j.name),M(null),u(e(`note.toast.moved`),`success`)}catch(t){u(De(t,e(`note.toast.moveFailed`),e),`error`)}}function $(t){if(!Z())return;let n=t.type===`directory`;A({title:e(n?`note.delete.folderTitle`:`note.delete.noteTitle`),message:e(`note.delete.message`,{name:Re(t)}),confirmText:e(`note.action.delete`),onConfirm:async()=>{pe(n?void 0:t.cid,t.path,t.name),A(null),u(e(`note.toast.deleted`),`success`),t.type===`file`&&t.cid===C&&Y()}})}let ut=(0,k.jsxs)(`div`,{className:`note-header-title`,children:[(0,k.jsx)(`h2`,{className:`header-title`,children:e(`note.title`)}),(0,k.jsx)(`span`,{children:e(`note.count`,{count:h.length})})]}),dt=(0,k.jsx)(`div`,{className:`note-theme-wrap`}),ft=(0,k.jsxs)(`section`,{className:`note-list-panel note-sidebar-list`,"aria-label":e(`note.listLabel`),children:[(0,k.jsxs)(`div`,{className:`note-search`,children:[(0,k.jsx)(le,{size:16}),(0,k.jsx)(`input`,{className:`input input-flex`,value:ge,onChange:e=>_e(e.target.value),placeholder:e(`note.search.placeholder`)})]}),Ze.length===0?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,k.jsx)(v,{size:32}),(0,k.jsx)(`p`,{children:e(ge?`note.empty.noMatches`:`note.empty.noNotes`)})]}):(0,k.jsx)(Ge,{nodes:Ze,searchQuery:ge,expandedPaths:Je,activeFileId:C,activeFolderPath:C?``:g,onToggleDirectory:it,onOpenFile:rt}),(0,k.jsx)(`div`,{className:`note-create-btn`,children:(0,k.jsxs)(`button`,{className:`btn`,onClick:ct,children:[(0,k.jsx)(ne,{size:16}),e(`note.newNote`)]})})]});return(0,k.jsxs)(se,{sidebar:()=>(0,k.jsx)(Ce,{children:ft}),headerTitle:ut,headerRight:dt,children:[(0,k.jsx)(`main`,{className:`note-page note-browser-page ${he?`has-editor`:``}`,children:(0,k.jsx)(`section`,{className:`note-workspace`,children:(0,k.jsx)(`section`,{className:`note-editor-panel`,"aria-label":e(T?`note.editorLabel.edit`:`note.editorLabel.read`),children:he?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`note-editor-panel-header`,children:[(0,k.jsxs)(`div`,{className:`note-editor-title-area`,children:[T?(0,k.jsx)(`input`,{className:`note-title-input`,value:Pe,onChange:e=>z(e.target.value),placeholder:e(`note.namePlaceholder`),translate:`no`,disabled:!w}):w?(0,k.jsx)(`h3`,{translate:`no`,children:F(w.name)}):(0,k.jsx)(`h3`,{children:e(`note.untitled`)}),w&&(0,k.jsxs)(`div`,{className:`note-editor-info`,children:[(0,k.jsx)(`span`,{children:e(T?`note.mode.edit`:`note.mode.read`)}),(0,k.jsx)(`span`,{children:J}),(0,k.jsx)(`span`,{children:t(w.updated_at)})]})]}),(0,k.jsxs)(`div`,{className:`note-editor-actions`,children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:T?ot:()=>Y(),title:e(T?`common.cancel`:`common.close`),"aria-label":e(T?`common.cancel`:`common.close`),children:(0,k.jsx)(fe,{size:16})}),T?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`button`,{className:`btn btn-sm ${U?`btn-warning`:`btn-secondary`}`,onClick:()=>qe(!U),disabled:!w,children:[U?(0,k.jsx)(_,{size:16}):(0,k.jsx)(b,{size:16}),e(U?`note.privacy.secret`:`note.privacy.public`)]}),(0,k.jsxs)(`button`,{className:`btn btn-sm btn-primary`,onClick:st,disabled:K||!!W||!w,children:[(0,k.jsx)(ce,{size:16}),e(K?`note.action.saving`:`note.action.save`)]})]}):w&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>lt(w),title:e(`note.action.move`),"aria-label":e(`note.action.move`),children:(0,k.jsx)(be,{size:16})}),(0,k.jsx)(`button`,{type:`button`,className:`btn btn-icon note-editor-action-danger`,onClick:()=>$(w),title:e(`note.action.delete`),"aria-label":e(`note.action.delete`),children:(0,k.jsx)(oe,{size:16})}),(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,onClick:()=>X(w),disabled:!!Ne,title:e(`note.action.edit`),"aria-label":e(`note.action.edit`),children:[(0,k.jsx)(xe,{size:16}),e(`note.action.edit`)]})]})]})]}),T?W?(0,k.jsxs)(`div`,{className:`note-empty-state editor-error`,children:[(0,k.jsx)(_,{size:36}),(0,k.jsx)(`p`,{children:W})]}):w?(0,k.jsx)(`div`,{className:`note-editor-frame editing`,children:(0,k.jsx)(we,{ref:c,content:V,onChange:H,className:`milkdown-editor`})}):(0,k.jsxs)(`div`,{className:`note-empty-state editor-error`,children:[(0,k.jsx)(v,{size:36}),(0,k.jsx)(`p`,{children:e(S?`note.error.notFound`:`note.loading`)})]}):Ne?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,k.jsx)(_,{size:36}),(0,k.jsx)(`p`,{children:Ne})]}):w?(0,k.jsx)(`div`,{className:`note-editor-frame reading`,children:(0,k.jsx)(we,{content:et,readOnly:!0,onInternalNoteLinkOpen:nt,resolveWikiNoteLink:tt,className:`milkdown-editor`})}):(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,k.jsx)(v,{size:36}),(0,k.jsx)(`p`,{children:e(S?`note.error.notFound`:`note.loading`)})]})]}):(0,k.jsxs)(`div`,{className:`ui-empty-state note-editor-empty`,children:[(0,k.jsx)(`div`,{className:`ui-empty-icon note-editor-empty-icon`,children:(0,k.jsx)(v,{size:32})}),(0,k.jsx)(`h3`,{className:`ui-empty-title`,children:e(`note.noOpen.title`)}),(0,k.jsx)(`p`,{className:`ui-empty-desc`,children:h.length>0?e(`note.noOpen.select`):e(`note.noOpen.createFirst`)}),(0,k.jsx)(ae,{label:e(`note.openList`),variant:`default`})]})})})}),E&&(0,k.jsx)(ue,{title:E.title,placeholder:E.placeholder,defaultValue:E.defaultValue,confirmText:E.confirmText,onConfirm:E.onConfirm,onClose:()=>ve(null)}),D&&(0,k.jsx)(ye,{title:D.title,message:D.message,confirmText:D.confirmText,danger:!0,onConfirm:D.onConfirm,onClose:()=>A(null)}),j&&(0,k.jsx)(Se,{target:j,targetLabel:Re(j),directories:$e,onMove:Q,onClose:()=>M(null)})]})}function K(){let{t:e,formatDate:t,compareStrings:n}=te(),r=ee(),i=de({select:e=>e.searchStr}),o=(0,O.useMemo)(()=>Te(i),[i]),s=(0,O.useRef)(null),c=d(e=>e.addToast),l=a(e=>e.wallet),m=a(e=>e.openLoginModal),g=o.file||``,y=!!g,b=y&&o.mode===`edit`,[x,me]=(0,O.useState)(null),[E,D]=(0,O.useState)([]),[A,j]=(0,O.useState)(``),[M,P]=(0,O.useState)(!0),[De,Me]=(0,O.useState)(``),[L,Ne]=(0,O.useState)(``),[R,Pe]=(0,O.useState)(!1),[z,B]=(0,O.useState)(null),[He,V]=(0,O.useState)(``),[qe,W]=(0,O.useState)(``),[G,K]=(0,O.useState)(!1),[q,Je]=(0,O.useState)(``),[Ye,Xe]=(0,O.useState)(!1),[Ze,Qe]=(0,O.useState)(()=>new Set(ze(A))),[J,$e]=(0,O.useState)(null),[et,tt]=(0,O.useState)(null),[Y,nt]=(0,O.useState)(null),rt=(0,O.useRef)(``),it=(0,O.useRef)(``),X=(0,O.useMemo)(()=>H(E),[E]),Z=X.find(e=>e.cid===g),at=(0,O.useMemo)(()=>Ke(X,n),[n,X]),ot=(0,O.useMemo)(()=>Ue(X,n),[n,X]),st=(0,O.useMemo)(()=>We(ot,L),[ot,L]),ct=(0,O.useMemo)(()=>Le(z?.content||``,X,e=>N({file:e.cid}),Z?.path||z?.directory||``,e=>N({path:Ae(e)})),[z?.content,z?.directory,Z?.path,X]),lt=(0,O.useCallback)(e=>Ie(e,X,e=>N({file:e.cid}),Z?.path||z?.directory||``,e=>N({path:Ae(e)})),[z?.directory,Z?.path,X]);(0,O.useEffect)(()=>{Z?.path&&Qe(e=>Ve(e,ze(Z.path)))},[Z?.path]),(0,O.useEffect)(()=>{if(!o.path||g||X.length===0)return;let e=Fe(X,o.path);e&&(j(f(e.path||``)),r({href:N({file:e.cid}),replace:!0}))},[g,r,o.path,X]),(0,O.useEffect)(()=>{let t=o.chatDraft||``;if(!t||rt.current===t||M)return;if(!l){let e=`${t}:auth`;it.current!==e&&(it.current=e,m());return}if(x?.configured!==!0){let n=`${t}:vault`;it.current!==n&&(it.current=n,c(e(`note.chatDraft.openVaultFirst`),`warning`));return}let n=re(t);if(!n){rt.current=t,c(e(`note.chatDraft.missing`),`warning`),$({},!0);return}rt.current=t,_t(n)},[c,o.chatDraft,e,M,x?.configured,l]);let Q=(0,O.useCallback)(async()=>{if(!l){me(null),D([]),Me(e(`note.vault.loginRequired`)),P(!1);return}P(!0),Me(``);try{let e=await ve();me(e),e.configured?D(await C()):D([])}catch(t){me(null),D([]),Me(await u(t,e(`note.vault.loadFailed`)))}finally{P(!1)}},[e,l]);(0,O.useEffect)(()=>{Q()},[Q]),(0,O.useEffect)(()=>{V(F(z?.name||Z?.name||``))},[z?.name,Z?.name]),(0,O.useEffect)(()=>{let t=!1;async function n(){if(!g){B(null),W(``),Je(``),K(!1);return}if(!l){B(null),W(``),Je(e(`note.vault.loginRequired`)),K(!1);return}if(x?.configured!==!0){B(null),W(``),Je(``),K(!1);return}K(!0),Je(``);try{let e=await ge(g);if(t)return;B(e),W(e.content)}catch(n){if(t)return;B(null),W(``),Je(await u(n,e(`note.error.notFound`)))}finally{t||K(!1)}}return n(),()=>{t=!0}},[g,e,x?.configured,l]);function $(e={},t=!1){r({href:N(e),replace:t})}function ut(e){$(Ee(e))}function dt(e){j(f(e.path||``)),$({file:e.cid})}function ft(e){j(e.fullPath),Qe(t=>Be(t,e.fullPath))}function pt(){g&&$({file:g,mode:`edit`})}function mt(){V(F(z?.name||Z?.name||``)),$(g?{file:g}:{})}async function ht(){if(!l){m();return}let t=window.electronAPI?.selectNoteVaultDirectory;if(!t){c(e(`note.vault.selectFailed`),`error`);return}Pe(!0);try{let n=await t();if(!n)return;await _e(n),await Q(),$({},!0),c(e(`note.vault.opened`),`success`)}catch(t){c(await u(t,e(`note.vault.selectFailed`)),`error`)}finally{Pe(!1)}}function gt(){return l?x?.configured===!0?!0:(c(e(`note.vault.emptyPrompt`),`warning`),!1):(m(),!1)}async function _t(t){if(gt())try{let n=ke(t.title,e(`note.chatDraft.defaultTitle`),e=>E.some(t=>f(t.directory)===f(A)&&t.name===e)),r=await S(f(A?`${A}/${n}`:n),t.content);ie(t.id),await Q(),c(e(`note.chatDraft.created`),`success`),$({file:r.path,mode:`edit`},!0)}catch(t){rt.current=``,c(await u(t,e(`note.toast.createFailed`)),`error`)}}function vt(){gt()&&$e({title:e(`note.create.title`),placeholder:e(`note.namePlaceholder`),confirmText:e(`note.create.action`),onConfirm:async t=>{if(!gt())return;let n=U(A,t);if(!n){c(e(`note.toast.nameRequired`),`warning`);return}try{let t=await S(n,``);$e(null),await Q(),$({file:t.path,mode:`edit`}),c(e(`note.toast.created`),`success`)}catch(t){c(await u(t,e(`note.toast.createFailed`)),`error`)}}})}function yt(e){gt()&&nt(e)}async function bt(t){if(!(!Y||!gt()))try{let n=g;if(Y.type===`directory`){let e=Oe(Y),r=f(t?`${t}/${Y.name}`:Y.name),i=E.filter(t=>t.path.startsWith(`${e}/`));for(let t of i){let i=f(`${r}/${t.path.slice(e.length+1)}`);await w(t.path,i),g===t.path&&(n=i)}}else{let e=f(t?`${t}/${Y.name}`:Y.name),r=await w(Y.cid,e);g===Y.cid&&(n=r.path)}nt(null),await Q(),$(n?{file:n}:{},!0),c(e(`note.toast.moved`),`success`)}catch(t){c(await u(t,e(`note.toast.moveFailed`)),`error`)}}function xt(t){gt()&&tt({title:t.type===`directory`?e(`note.delete.folderTitle`):e(`note.delete.noteTitle`),message:e(`note.delete.message`,{name:Re(t)}),confirmText:e(`note.action.delete`),onConfirm:async()=>{try{if(t.type===`directory`){let e=Oe(t),n=E.filter(t=>t.path.startsWith(`${e}/`));for(let e of n)await he(e.path);g.startsWith(`${e}/`)&&$({},!0)}else await he(t.cid),g===t.cid&&$({},!0);tt(null),await Q(),c(e(`note.toast.deleted`),`success`)}catch(t){c(await u(t,e(`note.toast.deleteFailed`)),`error`)}}})}async function St(){if(!l){m();return}if(!g||!z){c(e(`note.toast.notFound`),`error`);return}let t=I(He);if(!t){c(e(`note.toast.nameRequired`),`warning`);return}Xe(!0);try{let n=s.current?.getMarkdown()??qe,r=z.path;if(t!==z.name){r=f(z.directory?`${z.directory}/${t}`:t);let e=await w(z.path,r);B(e),V(F(e.name)),r=e.path}let i=await T(r,n);B(i),V(F(i.name)),W(i.content),await Q(),$({file:i.path},!0),c(e(`note.toast.saved`),`success`)}catch(t){c(await u(t,e(`note.toast.saveFailed`)),`error`)}finally{Xe(!1)}}let Ct=(0,k.jsxs)(`div`,{className:`note-header-title`,children:[(0,k.jsx)(`h2`,{className:`header-title`,children:e(`note.title`)}),(0,k.jsx)(`span`,{children:e(`note.count`,{count:E.length})})]}),wt=(0,k.jsx)(`div`,{className:`note-theme-wrap`,children:(0,k.jsxs)(`button`,{className:`btn btn-sm`,onClick:ht,disabled:R,title:e(`note.vault.open`),"aria-label":e(`note.vault.open`),children:[(0,k.jsx)(h,{size:16}),e(R?`note.vault.opening`:`note.vault.open`)]})}),Tt=(0,k.jsxs)(`section`,{className:`note-list-panel note-sidebar-list`,"aria-label":e(`note.listLabel`),children:[(0,k.jsxs)(`div`,{className:`note-search`,children:[(0,k.jsx)(le,{size:16}),(0,k.jsx)(`input`,{className:`input input-flex`,value:L,onChange:e=>Ne(e.target.value),placeholder:e(`note.search.placeholder`)})]}),M?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,k.jsx)(v,{size:32}),(0,k.jsx)(`p`,{children:e(`note.loading`)})]}):De?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,k.jsx)(_,{size:32}),(0,k.jsx)(`p`,{children:De})]}):x?.configured===!0?st.length===0?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,k.jsx)(v,{size:32}),(0,k.jsx)(`p`,{children:e(L?`note.empty.noMatches`:`note.vault.noFiles`)})]}):(0,k.jsx)(Ge,{nodes:st,searchQuery:L,expandedPaths:Ze,activeFileId:g,activeFolderPath:g?``:A,onToggleDirectory:ft,onOpenFile:dt,renderActions:t=>(0,k.jsx)(pe,{ariaLabel:e(`common.moreActions`),className:`note-list-actions-anchor`,placement:`bottom-end`,items:[{key:`move`,label:e(`note.action.move`),icon:(0,k.jsx)(be,{size:16}),onSelect:()=>yt(t)},{key:`delete`,label:e(`note.action.delete`),icon:(0,k.jsx)(oe,{size:16}),danger:!0,onSelect:()=>xt(t)}],renderTrigger:t=>(0,k.jsx)(`button`,{...t,className:`note-list-actions-trigger`,title:e(`common.moreActions`),"aria-label":e(`common.moreActions`),children:(0,k.jsx)(p,{size:16})})})}):(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,k.jsx)(h,{size:32}),(0,k.jsxs)(`button`,{className:`btn btn-primary`,onClick:ht,disabled:R,children:[(0,k.jsx)(h,{size:16}),e(R?`note.vault.opening`:`note.vault.open`)]})]}),x?.configured===!0&&(0,k.jsx)(`div`,{className:`note-create-btn`,children:(0,k.jsxs)(`button`,{className:`btn`,onClick:vt,children:[(0,k.jsx)(ne,{size:16}),e(`note.newNote`)]})})]}),Et=z?.mtimeMs||Z?.updated_at||Date.now(),Dt=F(z?.name||Z?.name||``)||e(`note.untitled`);return(0,k.jsxs)(se,{sidebar:()=>(0,k.jsx)(Ce,{children:Tt}),headerTitle:Ct,headerRight:wt,children:[(0,k.jsx)(`main`,{className:`note-page note-browser-page ${y?`has-editor`:``}`,children:(0,k.jsx)(`section`,{className:`note-workspace`,children:(0,k.jsx)(`section`,{className:`note-editor-panel`,"aria-label":e(b?`note.editorLabel.edit`:`note.editorLabel.read`),children:y?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`note-editor-panel-header`,children:[(0,k.jsxs)(`div`,{className:`note-editor-title-area`,children:[b&&z?(0,k.jsx)(`input`,{className:`note-title-input`,value:He,onChange:e=>V(e.target.value),onKeyDown:e=>{if(e.key===`Enter`){e.currentTarget.blur();return}e.key===`Escape`&&(V(F(z.name)),e.currentTarget.blur())},placeholder:e(`note.namePlaceholder`),translate:`no`}):(0,k.jsx)(`h3`,{translate:`no`,children:Dt}),(0,k.jsxs)(`div`,{className:`note-editor-info`,children:[(0,k.jsx)(`span`,{children:e(b?`note.mode.edit`:`note.mode.read`)}),(0,k.jsx)(`span`,{translate:`no`,children:je(g)}),(0,k.jsx)(`span`,{children:t(Et)})]})]}),(0,k.jsxs)(`div`,{className:`note-editor-actions`,children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:b?mt:()=>$(),title:e(b?`common.cancel`:`common.close`),"aria-label":e(b?`common.cancel`:`common.close`),children:(0,k.jsx)(fe,{size:16})}),b?(0,k.jsxs)(`button`,{className:`btn btn-sm btn-primary`,onClick:St,disabled:Ye||!!q||!z,children:[(0,k.jsx)(ce,{size:16}),e(Ye?`note.action.saving`:`note.action.save`)]}):Z&&(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,onClick:pt,disabled:!!q||!z,title:e(`note.action.edit`),"aria-label":e(`note.action.edit`),children:[(0,k.jsx)(xe,{size:16}),e(`note.action.edit`)]})]})]}),G?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,k.jsx)(v,{size:36}),(0,k.jsx)(`p`,{children:e(`note.loading`)})]}):q?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,k.jsx)(_,{size:36}),(0,k.jsx)(`p`,{children:q})]}):b?(0,k.jsx)(`div`,{className:`note-editor-frame editing`,children:(0,k.jsx)(we,{ref:s,content:qe,onChange:W,className:`milkdown-editor`})}):z?(0,k.jsx)(`div`,{className:`note-editor-frame reading`,children:(0,k.jsx)(we,{content:ct,readOnly:!0,onInternalNoteLinkOpen:ut,resolveWikiNoteLink:lt,className:`milkdown-editor`})}):(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,k.jsx)(v,{size:36}),(0,k.jsx)(`p`,{children:e(`note.error.notFound`)})]})]}):(0,k.jsxs)(`div`,{className:`ui-empty-state note-editor-empty`,children:[(0,k.jsx)(`div`,{className:`ui-empty-icon note-editor-empty-icon`,children:(0,k.jsx)(v,{size:32})}),(0,k.jsx)(`h3`,{className:`ui-empty-title`,children:x?.configured?e(`note.noOpen.title`):e(`note.vault.open`)}),(0,k.jsx)(`p`,{className:`ui-empty-desc`,children:x?.configured?e(`note.noOpen.select`):e(`note.vault.emptyPrompt`)}),x?.configured?(0,k.jsx)(ae,{label:e(`note.openList`),variant:`default`}):(0,k.jsxs)(`button`,{className:`btn btn-primary`,onClick:ht,disabled:R,children:[(0,k.jsx)(h,{size:16}),e(R?`note.vault.opening`:`note.vault.open`)]})]})})})}),J&&(0,k.jsx)(ue,{title:J.title,placeholder:J.placeholder,defaultValue:J.defaultValue,confirmText:J.confirmText,onConfirm:J.onConfirm,onClose:()=>$e(null)}),et&&(0,k.jsx)(ye,{title:et.title,message:et.message,confirmText:et.confirmText,danger:!0,onConfirm:et.onConfirm,onClose:()=>tt(null)}),Y&&(0,k.jsx)(Se,{target:Y,targetLabel:Re(Y),directories:at,onMove:bt,onClose:()=>nt(null)})]})}function q(){let{t:e}=te(),t=d(e=>e.hasBackend),n=a(e=>e.wallet),r=y(),i=t===!0&&qe(c()),o=W(i,n?.address||``),s=i&&(r||o);return(0,k.jsx)(O.Suspense,{fallback:(0,k.jsx)(`div`,{className:`note-editor-loading`,children:e(`note.loading`)}),children:s?(0,k.jsx)(K,{}):(0,k.jsx)(G,{})})}var Je=o(`/note/`)({component:q});export{Je as Route};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MilkdownEditor-X9MUH_0q.js","assets/jsx-runtime-Bt-cYkS5.js","assets/i18n-DKsg67mH.js","assets/index-DJzLHA0V.js","assets/useAppStore-DNhyhD20.js","assets/useNavigate-DWlBD_-b.js","assets/index-FEwag7ej.css","assets/dist-CSyRxrry.js","assets/dist-RU_cpjXQ.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,C as i,E as a,H as o,M as s,d as c,j as l,o as u,t as d,w as f}from"./useAppStore-DNhyhD20.js";import{n as ee}from"./useNavigate-DWlBD_-b.js";import{a as te}from"./i18n-DKsg67mH.js";import{a as ne,i as re,n as ie,o as p}from"./chatNoteDraft-DTy6In5R.js";import{t as ae}from"./OpenSidebarButton-CXBAjjCE.js";import{n as m,t as oe}from"./trash-2-B9gno5q6.js";import{t as h}from"./folder-open-DOJ4bB58.js";import{t as g}from"./folder-6pYYnS2-.js";import{t as _}from"./lock-yG7M7GkB.js";import{t as se}from"./AppShell-CKP_dglR.js";import{t as v}from"./notebook-pen-Bcd3MrtD.js";import{t as ce}from"./save-CfYzXcxH.js";import{t as le}from"./search-DLBOUfny.js";import{C as ue,E as y,L as de,M as b,O as fe,P as x,S as pe,T as me,c as S,d as C,f as w,l as he,m as T,p as ge,s as _e,t as E,u as ve,w as ye}from"./index-DJzLHA0V.js";import{t as D}from"./AppTop-C03PsDr_.js";var be=r(`move`,[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`m15 19-3 3-3-3`,key:`11eu04`}],[`path`,{d:`m19 9 3 3-3 3`,key:`1mg7y2`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}],[`path`,{d:`m5 9-3 3 3 3`,key:`j64kie`}],[`path`,{d:`m9 5 3-3 3 3`,key:`l8vdw6`}]]),xe=r(`pencil-ruler`,[[`path`,{d:`M13 7 8.7 2.7a2.41 2.41 0 0 0-3.4 0L2.7 5.3a2.41 2.41 0 0 0 0 3.4L7 13`,key:`orapub`}],[`path`,{d:`m8 6 2-2`,key:`115y1s`}],[`path`,{d:`m18 16 2-2`,key:`ee94s4`}],[`path`,{d:`m17 11 4.3 4.3c.94.94.94 2.46 0 3.4l-2.6 2.6c-.94.94-2.46.94-3.4 0L11 17`,key:`cfq27r`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),O=t(e(),1),k=n();function A(e){return e.type===`directory`?f(e.path?`${e.path}/${e.name}`:e.name):i(e)}function Se({target:e,targetLabel:t,directories:n,onMove:r,onClose:i}){let{t:a}=te(),o=f(e.path||``),s=A(e),c=n.filter(t=>e.type===`directory`?t.path!==s&&!t.path.startsWith(`${s}/`):!0),[l,u]=(0,O.useState)(o),[d,ee]=(0,O.useState)(``),[ne,re]=(0,O.useState)(new Set),ie=f(d),p=d.trim()?ie:l,ae=f(p)===o,oe=a(`note.move.rootDirectory`),h=new Map;for(let e of c){let t=h.get(e.parentPath)||[];t.push(e),h.set(e.parentPath,t)}let _=c.filter(e=>{if(!e.parentPath)return!0;let t=e.parentPath.split(`/`).filter(Boolean);return t.every((e,n)=>ne.has(t.slice(0,n+1).join(`/`)))}),se=[{label:oe,path:``},...l.split(`/`).filter(Boolean).map((e,t,n)=>({label:e,path:n.slice(0,t+1).join(`/`)}))];function v(e){u(f(e)),ee(``)}function ce(e){v(e),h.has(e)&&re(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function le(){ae||r(p)}return(0,k.jsx)(me,{onClose:i,children:(0,k.jsxs)(`div`,{className:`note-move-modal`,onClick:e=>e.stopPropagation(),children:[(0,k.jsxs)(`div`,{className:`modal-header`,children:[(0,k.jsx)(`h3`,{children:a(`note.move.title`)}),(0,k.jsx)(`button`,{className:`btn btn-icon`,onClick:i,children:(0,k.jsx)(fe,{size:18})})]}),(0,k.jsxs)(`div`,{className:`note-move-target`,children:[(0,k.jsx)(`span`,{children:a(`note.move.moving`)}),(0,k.jsx)(`strong`,{translate:`no`,children:t||e.name})]}),(0,k.jsx)(`div`,{className:`note-move-path`,children:se.map((e,t)=>(0,k.jsxs)(O.Fragment,{children:[t>0&&(0,k.jsx)(`span`,{children:`/`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>v(e.path),children:(0,k.jsx)(`span`,{translate:e.path?`no`:`yes`,children:e.label})})]},e.path||`root`))}),(0,k.jsxs)(`div`,{className:`note-move-folder-list`,children:[(0,k.jsxs)(`button`,{type:`button`,className:`note-move-folder-item ${l===``?`selected`:``}`,onClick:()=>v(``),children:[(0,k.jsx)(`span`,{className:`note-move-folder-spacer`}),(0,k.jsx)(g,{className:`note-move-folder-icon`,size:16}),(0,k.jsx)(`span`,{children:oe})]}),c.length===0?(0,k.jsx)(`p`,{className:`note-move-empty`,children:a(`note.move.noFolders`)}):_.map(e=>{let t=h.has(e.path),n=ne.has(e.path);return(0,k.jsxs)(`button`,{type:`button`,className:`note-move-folder-item note-move-depth-${Math.min(e.depth,4)} ${l===e.path?`selected`:``}`,onClick:()=>ce(e.path),children:[t?n?(0,k.jsx)(x,{className:`note-move-expander`,size:14}):(0,k.jsx)(m,{className:`note-move-expander`,size:14}):(0,k.jsx)(`span`,{className:`note-move-folder-spacer`}),(0,k.jsx)(g,{className:`note-move-folder-icon`,size:16}),(0,k.jsx)(`span`,{translate:`no`,children:e.name}),e.parentPath&&(0,k.jsx)(`small`,{translate:`no`,children:e.parentPath})]},e.path)})]}),(0,k.jsx)(`input`,{className:`input input-compact`,value:d,onChange:e=>ee(e.target.value),placeholder:a(`note.move.pathPlaceholder`),translate:`no`}),(0,k.jsxs)(`div`,{className:`note-move-destination`,children:[(0,k.jsx)(`span`,{children:a(`note.move.destinationLabel`)}),(0,k.jsx)(`span`,{translate:p?`no`:`yes`,children:p||oe})]}),(0,k.jsxs)(`div`,{className:`modal-actions`,children:[(0,k.jsx)(`button`,{className:`btn btn-secondary`,onClick:i,children:a(`common.cancel`)}),(0,k.jsx)(`button`,{className:`btn btn-primary`,onClick:le,disabled:ae,children:a(`note.action.move`)})]})]})})}function Ce({children:e}){return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(D,{}),e]})}var we=(0,O.lazy)(async()=>({default:(await E(()=>import(`./MilkdownEditor-X9MUH_0q.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8]))).MilkdownEditor})),j=/\[\[([^\]\n]+?)\]\]/g,M=/(```[\s\S]*?```)/g;function Te(e){let t=new URLSearchParams(e),n=t.get(`mode`);return{cid:t.get(`cid`)||void 0,file:t.get(`file`)||void 0,path:t.get(`path`)||void 0,chatDraft:t.get(`chatDraft`)||void 0,mode:n===`edit`?`edit`:void 0}}function N(e={}){let t=new URLSearchParams;e.cid&&t.set(`cid`,e.cid),e.file&&t.set(`file`,e.file),e.path&&t.set(`path`,e.path),e.chatDraft&&t.set(`chatDraft`,e.chatDraft),e.mode&&t.set(`mode`,e.mode);let n=t.toString();return n?`/note/?${n}`:`/note/`}function Ee(e){let t=e.indexOf(`?`),n=t>=0?e.slice(t):``;if(typeof window>`u`)return Te(n);try{return Te(new URL(e,window.location.origin).search)}catch{return Te(n)}}var P={"note.error.nameRequired":`note.error.nameRequired`,"note.error.nameNoSlash":`note.error.nameNoSlash`,"note.error.nameNoBackslash":`note.error.nameNoBackslash`,"note.error.nameInvalid":`note.error.nameInvalid`,"note.error.nameConflict":`note.error.nameConflict`,"note.error.moveIntoSelf":`note.error.moveIntoSelf`};function De(e,t,n){let r=e instanceof Error?e.message:``,i=P[r];return i?n(i):r||t}function Oe(e){return e.type===`directory`?f(e.path?`${e.path}/${e.name}`:e.name):i(e)}function F(e=``){return String(e).trim().replace(/\.md$/i,``)}function I(e){let t=F(e);return t?`${t}.md`:``}function ke(e,t,n){let r=F(e)||t;for(let e=0;e<1e3;e+=1){let t=I(e===0?r:`${r} ${e+1}`);if(t&&!n(t))return t}return I(`${r} ${Date.now()}`)}function Ae(e=``){let t=f(e).split(`/`).filter(Boolean);if(t.length===0)return``;let n=t.length-1;return t[n]=I(t[n]),t.join(`/`)}function je(e=``){let t=f(e).split(`/`).filter(Boolean);if(t.length===0)return``;let n=t.length-1;return t[n]=F(t[n]),t.join(`/`)}function Me(e){return je(i(e))}function L(e){let t=e.trim().replace(/^\/+/,``),n=t.search(/[#^]/);return je(n>=0?t.slice(0,n):t)}function Ne(e,t){let n=t?.trim();if(n)return n;let r=e.split(`/`).filter(Boolean);return r[r.length-1]||e}function R(e){return e.replace(/\\/g,`\\\\`).replace(/\[/g,`\\[`).replace(/\]/g,`\\]`)}function Pe(e,t){return`[${R(e)}](<${t.replace(/>/g,`%3E`)}>)`}function Fe(e,t,n=``){let r=L(t);if(!r)return null;let i=r.toLowerCase(),a=e=>Me(e).toLowerCase();if(r.includes(`/`))return e.find(e=>a(e)===i)||null;let o=f(n);if(o){let t=f(`${o}/${r}`).toLowerCase(),n=e.find(e=>a(e)===t);if(n)return n}return e.find(e=>F(e.name).toLowerCase()===i)||null}function Ie(e,t,n,r=``,i){let a=e.indexOf(`|`),o=a>=0?e.slice(0,a):e,s=a>=0?e.slice(a+1):void 0,c=L(o);if(!c)return null;let l=Fe(t,o,r),u=l?n(l):i?.(c);return u?{label:Ne(c,s),href:u}:null}function Le(e,t,n,r=``,i){return e.includes(`[[`)?e.split(M).map(e=>e.startsWith("```")?e:e.replace(j,(e,a)=>{let o=Ie(a,t,n,r,i);return o?Pe(o.label,o.href):e})).join(``):e}function z(e){return e.type===`file`?F(e.name):e.name}function B(e){return e.type===`file`?je(e.fullPath):e.fullPath}function Re(e){return e.type===`file`?F(e.name):e.name}function ze(e=``){let t=f(e).split(`/`).filter(Boolean);return t.map((e,n)=>t.slice(0,n+1).join(`/`))}function Be(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function Ve(e,t){if(t.length===0)return e;let n=!1,r=new Set(e);for(let e of t)r.has(e)||(r.add(e),n=!0);return n?r:e}function He(e){return{name:e.name,cid:`__dir__${e.fullPath}`,path:e.path,type:`directory`,size:0,created_at:e.updatedAt,updated_at:e.updatedAt}}function Ue(e,t){let n=[],r=new Map;function a(e){return e&&r.get(e)?.children||n}function o(e,t,n){let i=f(t?`${t}/${e}`:e),o=r.get(i);if(o)return o.updatedAt=Math.max(o.updatedAt,n),o;let s={id:`directory:${i}`,type:`directory`,name:e,path:t,fullPath:i,updatedAt:n,children:[]};return r.set(i,s),a(t).push(s),s}for(let t of e){let e=f(t.path||``),n=e.split(`/`).filter(Boolean),r=t.updated_at||t.created_at||0,s=``;for(let e of n)s=o(e,s,r).fullPath;a(s).push({id:`file:${t.cid}:${i(t)}`,type:`file`,name:t.name,path:e,fullPath:i(t),updatedAt:r,note:t,children:[]})}function s(e){e.sort((e,n)=>{if(e.type!==n.type)return e.type===`directory`?-1:1;let r=t(z(e),z(n));return r===0?t(B(e),B(n)):r});for(let t of e)t.type===`directory`&&s(t.children)}return s(n),n}function We(e,t){let n=t.trim().toLowerCase();return n?e.flatMap(e=>{let t=z(e).toLowerCase(),r=B(e).toLowerCase(),i=t.includes(n)||r.includes(n);if(e.type===`file`)return i?[e]:[];let a=i?e.children:We(e.children,n);return!i&&a.length===0?[]:[{...e,children:a}]}):e}function Ge({nodes:e,searchQuery:t,expandedPaths:n,activeFileId:r,activeFolderPath:i,onToggleDirectory:a,onOpenFile:o,renderActions:s}){let c=t.trim().length>0;return(0,k.jsx)(`div`,{className:`note-tree`,role:`tree`,children:e.map(e=>(0,k.jsx)(V,{node:e,forceExpanded:c,expandedPaths:n,activeFileId:r,activeFolderPath:i,onToggleDirectory:a,onOpenFile:o,renderActions:s},e.id))})}function V({node:e,forceExpanded:t,expandedPaths:n,activeFileId:r,activeFolderPath:i,onToggleDirectory:a,onOpenFile:o,renderActions:s}){let c=e.type===`directory`,l=c&&(t||n.has(e.fullPath)),u=e.type===`file`&&e.note?.cid===r,d=c&&f(i)===e.fullPath,ee=c?He(e):e.note||null,te=ee&&s?s(ee):null;return(0,k.jsxs)(`div`,{className:`note-tree-node`,role:`none`,children:[(0,k.jsxs)(`div`,{className:`note-tree-row ${c?`is-directory`:`is-file`} ${u?`is-active`:``} ${d?`is-folder-active`:``} ${te?`has-actions`:``}`,children:[(0,k.jsxs)(`button`,{type:`button`,className:`note-tree-item`,role:`treeitem`,"aria-expanded":c?l:void 0,onClick:()=>{if(c){a(e);return}e.note&&o(e.note)},children:[(0,k.jsx)(`span`,{className:`note-tree-toggle`,"aria-hidden":`true`,children:c?l?(0,k.jsx)(x,{size:16}):(0,k.jsx)(m,{size:16}):(0,k.jsx)(`span`,{className:`note-tree-toggle-placeholder`})}),(0,k.jsx)(`span`,{className:`note-tree-label`,translate:`no`,children:z(e)}),e.note?.isSecret&&(0,k.jsx)(_,{className:`note-tree-lock`,size:14,"aria-hidden":`true`})]}),te]}),c&&l&&e.children.length>0&&(0,k.jsx)(`div`,{className:`note-tree-children`,role:`group`,children:e.children.map(e=>(0,k.jsx)(V,{node:e,forceExpanded:t,expandedPaths:n,activeFileId:r,activeFolderPath:i,onToggleDirectory:a,onOpenFile:o,renderActions:s},e.id))})]})}function Ke(e,t){let n=new Set;for(let t of e){let e=f(t.path).split(`/`).filter(Boolean);for(let t=0;t<e.length;t+=1)n.add(e.slice(0,t+1).join(`/`))}return Array.from(n).sort(t).map(e=>{let t=e.split(`/`);return{path:e,name:t[t.length-1]||e,parentPath:t.slice(0,-1).join(`/`),depth:Math.max(t.length-1,0)}})}function H(e){return e.map(e=>({name:e.name,cid:e.path,path:f(e.directory),content:``,size:e.size,type:`file`,created_at:Number(e.mtimeMs)||Date.now(),updated_at:Number(e.mtimeMs)||Date.now(),isSecret:!1}))}function U(e,t){let n=I(t);return f(e?`${e}/${n}`:n)}function qe(e){let t=e||typeof window<`u`&&window.location.origin||``;if(!t)return!1;try{let e=new URL(t).hostname.toLowerCase();return e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}catch{return!1}}function W(e,t=``){let[n,r]=(0,O.useState)(!1);return(0,O.useEffect)(()=>{let n=!1;return!e||!t?(r(!1),()=>{n=!0}):(ve().then(e=>{n||r(e.configured===!0)}).catch(()=>{n||r(!1)}),()=>{n=!0})},[e,t]),n}function G(){let{t:e,formatDate:t,compareStrings:n}=te(),r=ee(),i=de({select:e=>e.searchStr}),o=(0,O.useMemo)(()=>Te(i),[i]),c=(0,O.useRef)(null),u=d(e=>e.addToast),p=a(e=>e.wallet),m=a(e=>e.openLoginModal),h=d(e=>e.notes),g=d(e=>e.notesPath),y=d(e=>e.setNotesPath),x=d(e=>e.saveNote),pe=d(e=>e.deleteNote),me=d(e=>e.renameNote),S=d(e=>e.localDataReady),C=o.cid||``,w=h.find(e=>e.cid===C),he=!!C,T=he&&o.mode===`edit`,[ge,_e]=(0,O.useState)(``),[E,ve]=(0,O.useState)(null),[D,A]=(0,O.useState)(null),[j,M]=(0,O.useState)(null),P=(0,O.useRef)(``),je=(0,O.useRef)(``),[Me,L]=(0,O.useState)(``),[Ne,R]=(0,O.useState)(``),[Pe,z]=(0,O.useState)(``),[B,He]=(0,O.useState)(``),[V,H]=(0,O.useState)(``),[U,qe]=(0,O.useState)(!1),[W,G]=(0,O.useState)(``),[K,q]=(0,O.useState)(!1),[Je,Ye]=(0,O.useState)(()=>new Set(ze(g)));(0,O.useEffect)(()=>{if(!C){L(``),R(``);return}if(!w){L(``),R(S?e(`note.error.notFound`):``);return}if(w.content.startsWith(`mp://1`)){if(!p){L(``),R(e(`note.error.loginToDecrypt`));return}let t=l(w.content,p.danger);if(!t){L(``),R(e(`note.error.decryptFailed`));return}L(t),R(``);return}L(w.content||``),R(``)},[C,S,w,e,p]),(0,O.useEffect)(()=>{if(!T){q(!1);return}if(!C||!w){z(``),He(``),H(``),qe(!1),G(S?e(`note.error.notFound`):``);return}if(z(F(w.name)),He(w.path||``),qe(w.isSecret===!0||w.content.startsWith(`mp://1`)),w.content.startsWith(`mp://1`)){if(!p){H(``),G(e(`note.error.loginToDecrypt`));return}let t=l(w.content,p.danger);if(!t){H(``),G(e(`note.error.decryptFailed`));return}H(t),G(``);return}H(w.content||``),G(``)},[C,T,S,w,e,p]);let Xe=(0,O.useMemo)(()=>Ue(h,n),[n,h]),Ze=(0,O.useMemo)(()=>We(Xe,ge),[Xe,ge]),Qe=w?.isSecret===!0||w?.content.startsWith(`mp://1`)===!0,J=e(T?U?`note.privacy.secret`:`note.privacy.public`:Qe?`note.privacy.secret`:`note.privacy.public`),$e=(0,O.useMemo)(()=>Ke(h,n),[n,h]),et=(0,O.useMemo)(()=>Le(Me,h,e=>N({cid:e.cid}),w?.path||``,e=>N({path:Ae(e)})),[h,Me,w?.path]),tt=(0,O.useCallback)(e=>Ie(e,h,e=>N({cid:e.cid}),w?.path||``,e=>N({path:Ae(e)})),[h,w?.path]);(0,O.useEffect)(()=>{w?.path&&Ye(e=>Ve(e,ze(w.path)))},[w?.path]),(0,O.useEffect)(()=>{if(!o.path||C||h.length===0)return;let e=Fe(h,o.path);e&&(y(f(e.path||``)),r({href:N({cid:e.cid}),replace:!0}))},[C,r,h,o.path,y]),(0,O.useEffect)(()=>{let t=o.chatDraft||``;if(!t||P.current===t||!S)return;if(!p){let e=`${t}:auth`;je.current!==e&&(je.current=e,m());return}let n=re(t);if(!n){P.current=t,u(e(`note.chatDraft.missing`),`warning`),Y({},!0);return}P.current=t,at(n)},[u,S,o.chatDraft,e,p]);function Y(e={},t=!1){r({href:N(e),replace:t})}function nt(e){Y(Ee(e))}function rt(e){y(f(e.path||``)),Y({cid:e.cid})}function it(e){y(e.fullPath),Ye(t=>Be(t,e.fullPath))}function X(e){Y({cid:e.cid,mode:`edit`})}function Z(){return p?!0:(m(),!1)}async function at(t){if(p)try{let n=await x({name:ke(t.title,e(`note.chatDraft.defaultTitle`),e=>h.some(t=>f(t.path||``)===f(g)&&t.name===e)),path:g,content:t.content,isSecret:!1});ie(t.id),u(e(`note.chatDraft.created`),`success`),Y({cid:n,mode:`edit`},!0)}catch(t){P.current=``,u(De(t,e(`note.toast.createFailed`),e),`error`)}}function ot(){Y(w?{cid:w.cid}:{})}async function st(){if(!Z())return;if(!w){u(e(`note.toast.notFound`),`error`);return}let t=I(Pe);if(!t){u(e(`note.toast.nameRequired`),`warning`);return}q(!0);try{let n=c.current?.getMarkdown()??V,r=U?s(n,p.danger):n,i=await x({cid:w.cid,name:t,path:B,content:r,isSecret:U});H(n),Y({cid:i},!0),u(e(`note.toast.saved`),`success`)}catch(t){u(De(t,e(`note.toast.saveFailed`),e),`error`)}finally{q(!1)}}function ct(){Z()&&ve({title:e(`note.create.title`),placeholder:e(`note.namePlaceholder`),confirmText:e(`note.create.action`),onConfirm:async t=>{if(Z())try{let n=await x({name:I(t),path:g,content:``,isSecret:!1});ve(null),u(e(`note.toast.created`),`success`),Y({cid:n,mode:`edit`})}catch(t){u(De(t,e(`note.toast.createFailed`),e),`error`)}}})}function lt(e){Z()&&M(e)}async function Q(t){if(j)try{me(Oe(j),t,j.name),M(null),u(e(`note.toast.moved`),`success`)}catch(t){u(De(t,e(`note.toast.moveFailed`),e),`error`)}}function $(t){if(!Z())return;let n=t.type===`directory`;A({title:e(n?`note.delete.folderTitle`:`note.delete.noteTitle`),message:e(`note.delete.message`,{name:Re(t)}),confirmText:e(`note.action.delete`),onConfirm:async()=>{pe(n?void 0:t.cid,t.path,t.name),A(null),u(e(`note.toast.deleted`),`success`),t.type===`file`&&t.cid===C&&Y()}})}let ut=(0,k.jsxs)(`div`,{className:`note-header-title`,children:[(0,k.jsx)(`h2`,{className:`header-title`,children:e(`note.title`)}),(0,k.jsx)(`span`,{children:e(`note.count`,{count:h.length})})]}),dt=(0,k.jsx)(`div`,{className:`note-theme-wrap`}),ft=(0,k.jsxs)(`section`,{className:`note-list-panel note-sidebar-list`,"aria-label":e(`note.listLabel`),children:[(0,k.jsxs)(`div`,{className:`note-search`,children:[(0,k.jsx)(le,{size:16}),(0,k.jsx)(`input`,{className:`input input-flex`,value:ge,onChange:e=>_e(e.target.value),placeholder:e(`note.search.placeholder`)})]}),Ze.length===0?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,k.jsx)(v,{size:32}),(0,k.jsx)(`p`,{children:e(ge?`note.empty.noMatches`:`note.empty.noNotes`)})]}):(0,k.jsx)(Ge,{nodes:Ze,searchQuery:ge,expandedPaths:Je,activeFileId:C,activeFolderPath:C?``:g,onToggleDirectory:it,onOpenFile:rt}),(0,k.jsx)(`div`,{className:`note-create-btn`,children:(0,k.jsxs)(`button`,{className:`btn`,onClick:ct,children:[(0,k.jsx)(ne,{size:16}),e(`note.newNote`)]})})]});return(0,k.jsxs)(se,{sidebar:()=>(0,k.jsx)(Ce,{children:ft}),headerTitle:ut,headerRight:dt,children:[(0,k.jsx)(`main`,{className:`note-page note-browser-page ${he?`has-editor`:``}`,children:(0,k.jsx)(`section`,{className:`note-workspace`,children:(0,k.jsx)(`section`,{className:`note-editor-panel`,"aria-label":e(T?`note.editorLabel.edit`:`note.editorLabel.read`),children:he?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`note-editor-panel-header`,children:[(0,k.jsxs)(`div`,{className:`note-editor-title-area`,children:[T?(0,k.jsx)(`input`,{className:`note-title-input`,value:Pe,onChange:e=>z(e.target.value),placeholder:e(`note.namePlaceholder`),translate:`no`,disabled:!w}):w?(0,k.jsx)(`h3`,{translate:`no`,children:F(w.name)}):(0,k.jsx)(`h3`,{children:e(`note.untitled`)}),w&&(0,k.jsxs)(`div`,{className:`note-editor-info`,children:[(0,k.jsx)(`span`,{children:e(T?`note.mode.edit`:`note.mode.read`)}),(0,k.jsx)(`span`,{children:J}),(0,k.jsx)(`span`,{children:t(w.updated_at)})]})]}),(0,k.jsxs)(`div`,{className:`note-editor-actions`,children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:T?ot:()=>Y(),title:e(T?`common.cancel`:`common.close`),"aria-label":e(T?`common.cancel`:`common.close`),children:(0,k.jsx)(fe,{size:16})}),T?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`button`,{className:`btn btn-sm ${U?`btn-warning`:`btn-secondary`}`,onClick:()=>qe(!U),disabled:!w,children:[U?(0,k.jsx)(_,{size:16}):(0,k.jsx)(b,{size:16}),e(U?`note.privacy.secret`:`note.privacy.public`)]}),(0,k.jsxs)(`button`,{className:`btn btn-sm btn-primary`,onClick:st,disabled:K||!!W||!w,children:[(0,k.jsx)(ce,{size:16}),e(K?`note.action.saving`:`note.action.save`)]})]}):w&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>lt(w),title:e(`note.action.move`),"aria-label":e(`note.action.move`),children:(0,k.jsx)(be,{size:16})}),(0,k.jsx)(`button`,{type:`button`,className:`btn btn-icon note-editor-action-danger`,onClick:()=>$(w),title:e(`note.action.delete`),"aria-label":e(`note.action.delete`),children:(0,k.jsx)(oe,{size:16})}),(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,onClick:()=>X(w),disabled:!!Ne,title:e(`note.action.edit`),"aria-label":e(`note.action.edit`),children:[(0,k.jsx)(xe,{size:16}),e(`note.action.edit`)]})]})]})]}),T?W?(0,k.jsxs)(`div`,{className:`note-empty-state editor-error`,children:[(0,k.jsx)(_,{size:36}),(0,k.jsx)(`p`,{children:W})]}):w?(0,k.jsx)(`div`,{className:`note-editor-frame editing`,children:(0,k.jsx)(we,{ref:c,content:V,onChange:H,className:`milkdown-editor`})}):(0,k.jsxs)(`div`,{className:`note-empty-state editor-error`,children:[(0,k.jsx)(v,{size:36}),(0,k.jsx)(`p`,{children:e(S?`note.error.notFound`:`note.loading`)})]}):Ne?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,k.jsx)(_,{size:36}),(0,k.jsx)(`p`,{children:Ne})]}):w?(0,k.jsx)(`div`,{className:`note-editor-frame reading`,children:(0,k.jsx)(we,{content:et,readOnly:!0,onInternalNoteLinkOpen:nt,resolveWikiNoteLink:tt,className:`milkdown-editor`})}):(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,k.jsx)(v,{size:36}),(0,k.jsx)(`p`,{children:e(S?`note.error.notFound`:`note.loading`)})]})]}):(0,k.jsxs)(`div`,{className:`ui-empty-state note-editor-empty`,children:[(0,k.jsx)(`div`,{className:`ui-empty-icon note-editor-empty-icon`,children:(0,k.jsx)(v,{size:32})}),(0,k.jsx)(`h3`,{className:`ui-empty-title`,children:e(`note.noOpen.title`)}),(0,k.jsx)(`p`,{className:`ui-empty-desc`,children:h.length>0?e(`note.noOpen.select`):e(`note.noOpen.createFirst`)}),(0,k.jsx)(ae,{label:e(`note.openList`),variant:`default`})]})})})}),E&&(0,k.jsx)(ue,{title:E.title,placeholder:E.placeholder,defaultValue:E.defaultValue,confirmText:E.confirmText,onConfirm:E.onConfirm,onClose:()=>ve(null)}),D&&(0,k.jsx)(ye,{title:D.title,message:D.message,confirmText:D.confirmText,danger:!0,onConfirm:D.onConfirm,onClose:()=>A(null)}),j&&(0,k.jsx)(Se,{target:j,targetLabel:Re(j),directories:$e,onMove:Q,onClose:()=>M(null)})]})}function K(){let{t:e,formatDate:t,compareStrings:n}=te(),r=ee(),i=de({select:e=>e.searchStr}),o=(0,O.useMemo)(()=>Te(i),[i]),s=(0,O.useRef)(null),c=d(e=>e.addToast),l=a(e=>e.wallet),m=a(e=>e.openLoginModal),g=o.file||``,y=!!g,b=y&&o.mode===`edit`,[x,me]=(0,O.useState)(null),[E,D]=(0,O.useState)([]),[A,j]=(0,O.useState)(``),[M,P]=(0,O.useState)(!0),[De,Me]=(0,O.useState)(``),[L,Ne]=(0,O.useState)(``),[R,Pe]=(0,O.useState)(!1),[z,B]=(0,O.useState)(null),[He,V]=(0,O.useState)(``),[qe,W]=(0,O.useState)(``),[G,K]=(0,O.useState)(!1),[q,Je]=(0,O.useState)(``),[Ye,Xe]=(0,O.useState)(!1),[Ze,Qe]=(0,O.useState)(()=>new Set(ze(A))),[J,$e]=(0,O.useState)(null),[et,tt]=(0,O.useState)(null),[Y,nt]=(0,O.useState)(null),rt=(0,O.useRef)(``),it=(0,O.useRef)(``),X=(0,O.useMemo)(()=>H(E),[E]),Z=X.find(e=>e.cid===g),at=(0,O.useMemo)(()=>Ke(X,n),[n,X]),ot=(0,O.useMemo)(()=>Ue(X,n),[n,X]),st=(0,O.useMemo)(()=>We(ot,L),[ot,L]),ct=(0,O.useMemo)(()=>Le(z?.content||``,X,e=>N({file:e.cid}),Z?.path||z?.directory||``,e=>N({path:Ae(e)})),[z?.content,z?.directory,Z?.path,X]),lt=(0,O.useCallback)(e=>Ie(e,X,e=>N({file:e.cid}),Z?.path||z?.directory||``,e=>N({path:Ae(e)})),[z?.directory,Z?.path,X]);(0,O.useEffect)(()=>{Z?.path&&Qe(e=>Ve(e,ze(Z.path)))},[Z?.path]),(0,O.useEffect)(()=>{if(!o.path||g||X.length===0)return;let e=Fe(X,o.path);e&&(j(f(e.path||``)),r({href:N({file:e.cid}),replace:!0}))},[g,r,o.path,X]),(0,O.useEffect)(()=>{let t=o.chatDraft||``;if(!t||rt.current===t||M)return;if(!l){let e=`${t}:auth`;it.current!==e&&(it.current=e,m());return}if(x?.configured!==!0){let n=`${t}:vault`;it.current!==n&&(it.current=n,c(e(`note.chatDraft.openVaultFirst`),`warning`));return}let n=re(t);if(!n){rt.current=t,c(e(`note.chatDraft.missing`),`warning`),$({},!0);return}rt.current=t,_t(n)},[c,o.chatDraft,e,M,x?.configured,l]);let Q=(0,O.useCallback)(async()=>{if(!l){me(null),D([]),Me(e(`note.vault.loginRequired`)),P(!1);return}P(!0),Me(``);try{let e=await ve();me(e),e.configured?D(await C()):D([])}catch(t){me(null),D([]),Me(await u(t,e(`note.vault.loadFailed`)))}finally{P(!1)}},[e,l]);(0,O.useEffect)(()=>{Q()},[Q]),(0,O.useEffect)(()=>{V(F(z?.name||Z?.name||``))},[z?.name,Z?.name]),(0,O.useEffect)(()=>{let t=!1;async function n(){if(!g){B(null),W(``),Je(``),K(!1);return}if(!l){B(null),W(``),Je(e(`note.vault.loginRequired`)),K(!1);return}if(x?.configured!==!0){B(null),W(``),Je(``),K(!1);return}K(!0),Je(``);try{let e=await ge(g);if(t)return;B(e),W(e.content)}catch(n){if(t)return;B(null),W(``),Je(await u(n,e(`note.error.notFound`)))}finally{t||K(!1)}}return n(),()=>{t=!0}},[g,e,x?.configured,l]);function $(e={},t=!1){r({href:N(e),replace:t})}function ut(e){$(Ee(e))}function dt(e){j(f(e.path||``)),$({file:e.cid})}function ft(e){j(e.fullPath),Qe(t=>Be(t,e.fullPath))}function pt(){g&&$({file:g,mode:`edit`})}function mt(){V(F(z?.name||Z?.name||``)),$(g?{file:g}:{})}async function ht(){if(!l){m();return}let t=window.electronAPI?.selectNoteVaultDirectory;if(!t){c(e(`note.vault.selectFailed`),`error`);return}Pe(!0);try{let n=await t();if(!n)return;await _e(n),await Q(),$({},!0),c(e(`note.vault.opened`),`success`)}catch(t){c(await u(t,e(`note.vault.selectFailed`)),`error`)}finally{Pe(!1)}}function gt(){return l?x?.configured===!0?!0:(c(e(`note.vault.emptyPrompt`),`warning`),!1):(m(),!1)}async function _t(t){if(gt())try{let n=ke(t.title,e(`note.chatDraft.defaultTitle`),e=>E.some(t=>f(t.directory)===f(A)&&t.name===e)),r=await S(f(A?`${A}/${n}`:n),t.content);ie(t.id),await Q(),c(e(`note.chatDraft.created`),`success`),$({file:r.path,mode:`edit`},!0)}catch(t){rt.current=``,c(await u(t,e(`note.toast.createFailed`)),`error`)}}function vt(){gt()&&$e({title:e(`note.create.title`),placeholder:e(`note.namePlaceholder`),confirmText:e(`note.create.action`),onConfirm:async t=>{if(!gt())return;let n=U(A,t);if(!n){c(e(`note.toast.nameRequired`),`warning`);return}try{let t=await S(n,``);$e(null),await Q(),$({file:t.path,mode:`edit`}),c(e(`note.toast.created`),`success`)}catch(t){c(await u(t,e(`note.toast.createFailed`)),`error`)}}})}function yt(e){gt()&&nt(e)}async function bt(t){if(!(!Y||!gt()))try{let n=g;if(Y.type===`directory`){let e=Oe(Y),r=f(t?`${t}/${Y.name}`:Y.name),i=E.filter(t=>t.path.startsWith(`${e}/`));for(let t of i){let i=f(`${r}/${t.path.slice(e.length+1)}`);await w(t.path,i),g===t.path&&(n=i)}}else{let e=f(t?`${t}/${Y.name}`:Y.name),r=await w(Y.cid,e);g===Y.cid&&(n=r.path)}nt(null),await Q(),$(n?{file:n}:{},!0),c(e(`note.toast.moved`),`success`)}catch(t){c(await u(t,e(`note.toast.moveFailed`)),`error`)}}function xt(t){gt()&&tt({title:t.type===`directory`?e(`note.delete.folderTitle`):e(`note.delete.noteTitle`),message:e(`note.delete.message`,{name:Re(t)}),confirmText:e(`note.action.delete`),onConfirm:async()=>{try{if(t.type===`directory`){let e=Oe(t),n=E.filter(t=>t.path.startsWith(`${e}/`));for(let e of n)await he(e.path);g.startsWith(`${e}/`)&&$({},!0)}else await he(t.cid),g===t.cid&&$({},!0);tt(null),await Q(),c(e(`note.toast.deleted`),`success`)}catch(t){c(await u(t,e(`note.toast.deleteFailed`)),`error`)}}})}async function St(){if(!l){m();return}if(!g||!z){c(e(`note.toast.notFound`),`error`);return}let t=I(He);if(!t){c(e(`note.toast.nameRequired`),`warning`);return}Xe(!0);try{let n=s.current?.getMarkdown()??qe,r=z.path;if(t!==z.name){r=f(z.directory?`${z.directory}/${t}`:t);let e=await w(z.path,r);B(e),V(F(e.name)),r=e.path}let i=await T(r,n);B(i),V(F(i.name)),W(i.content),await Q(),$({file:i.path},!0),c(e(`note.toast.saved`),`success`)}catch(t){c(await u(t,e(`note.toast.saveFailed`)),`error`)}finally{Xe(!1)}}let Ct=(0,k.jsxs)(`div`,{className:`note-header-title`,children:[(0,k.jsx)(`h2`,{className:`header-title`,children:e(`note.title`)}),(0,k.jsx)(`span`,{children:e(`note.count`,{count:E.length})})]}),wt=(0,k.jsx)(`div`,{className:`note-theme-wrap`,children:(0,k.jsxs)(`button`,{className:`btn btn-sm`,onClick:ht,disabled:R,title:e(`note.vault.open`),"aria-label":e(`note.vault.open`),children:[(0,k.jsx)(h,{size:16}),e(R?`note.vault.opening`:`note.vault.open`)]})}),Tt=(0,k.jsxs)(`section`,{className:`note-list-panel note-sidebar-list`,"aria-label":e(`note.listLabel`),children:[(0,k.jsxs)(`div`,{className:`note-search`,children:[(0,k.jsx)(le,{size:16}),(0,k.jsx)(`input`,{className:`input input-flex`,value:L,onChange:e=>Ne(e.target.value),placeholder:e(`note.search.placeholder`)})]}),M?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,k.jsx)(v,{size:32}),(0,k.jsx)(`p`,{children:e(`note.loading`)})]}):De?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,k.jsx)(_,{size:32}),(0,k.jsx)(`p`,{children:De})]}):x?.configured===!0?st.length===0?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,k.jsx)(v,{size:32}),(0,k.jsx)(`p`,{children:e(L?`note.empty.noMatches`:`note.vault.noFiles`)})]}):(0,k.jsx)(Ge,{nodes:st,searchQuery:L,expandedPaths:Ze,activeFileId:g,activeFolderPath:g?``:A,onToggleDirectory:ft,onOpenFile:dt,renderActions:t=>(0,k.jsx)(pe,{ariaLabel:e(`common.moreActions`),className:`note-list-actions-anchor`,placement:`bottom-end`,items:[{key:`move`,label:e(`note.action.move`),icon:(0,k.jsx)(be,{size:16}),onSelect:()=>yt(t)},{key:`delete`,label:e(`note.action.delete`),icon:(0,k.jsx)(oe,{size:16}),danger:!0,onSelect:()=>xt(t)}],renderTrigger:t=>(0,k.jsx)(`button`,{...t,className:`note-list-actions-trigger`,title:e(`common.moreActions`),"aria-label":e(`common.moreActions`),children:(0,k.jsx)(p,{size:16})})})}):(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,k.jsx)(h,{size:32}),(0,k.jsxs)(`button`,{className:`btn btn-primary`,onClick:ht,disabled:R,children:[(0,k.jsx)(h,{size:16}),e(R?`note.vault.opening`:`note.vault.open`)]})]}),x?.configured===!0&&(0,k.jsx)(`div`,{className:`note-create-btn`,children:(0,k.jsxs)(`button`,{className:`btn`,onClick:vt,children:[(0,k.jsx)(ne,{size:16}),e(`note.newNote`)]})})]}),Et=z?.mtimeMs||Z?.updated_at||Date.now(),Dt=F(z?.name||Z?.name||``)||e(`note.untitled`);return(0,k.jsxs)(se,{sidebar:()=>(0,k.jsx)(Ce,{children:Tt}),headerTitle:Ct,headerRight:wt,children:[(0,k.jsx)(`main`,{className:`note-page note-browser-page ${y?`has-editor`:``}`,children:(0,k.jsx)(`section`,{className:`note-workspace`,children:(0,k.jsx)(`section`,{className:`note-editor-panel`,"aria-label":e(b?`note.editorLabel.edit`:`note.editorLabel.read`),children:y?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`note-editor-panel-header`,children:[(0,k.jsxs)(`div`,{className:`note-editor-title-area`,children:[b&&z?(0,k.jsx)(`input`,{className:`note-title-input`,value:He,onChange:e=>V(e.target.value),onKeyDown:e=>{if(e.key===`Enter`){e.currentTarget.blur();return}e.key===`Escape`&&(V(F(z.name)),e.currentTarget.blur())},placeholder:e(`note.namePlaceholder`),translate:`no`}):(0,k.jsx)(`h3`,{translate:`no`,children:Dt}),(0,k.jsxs)(`div`,{className:`note-editor-info`,children:[(0,k.jsx)(`span`,{children:e(b?`note.mode.edit`:`note.mode.read`)}),(0,k.jsx)(`span`,{translate:`no`,children:je(g)}),(0,k.jsx)(`span`,{children:t(Et)})]})]}),(0,k.jsxs)(`div`,{className:`note-editor-actions`,children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:b?mt:()=>$(),title:e(b?`common.cancel`:`common.close`),"aria-label":e(b?`common.cancel`:`common.close`),children:(0,k.jsx)(fe,{size:16})}),b?(0,k.jsxs)(`button`,{className:`btn btn-sm btn-primary`,onClick:St,disabled:Ye||!!q||!z,children:[(0,k.jsx)(ce,{size:16}),e(Ye?`note.action.saving`:`note.action.save`)]}):Z&&(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,onClick:pt,disabled:!!q||!z,title:e(`note.action.edit`),"aria-label":e(`note.action.edit`),children:[(0,k.jsx)(xe,{size:16}),e(`note.action.edit`)]})]})]}),G?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,k.jsx)(v,{size:36}),(0,k.jsx)(`p`,{children:e(`note.loading`)})]}):q?(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,k.jsx)(_,{size:36}),(0,k.jsx)(`p`,{children:q})]}):b?(0,k.jsx)(`div`,{className:`note-editor-frame editing`,children:(0,k.jsx)(we,{ref:s,content:qe,onChange:W,className:`milkdown-editor`})}):z?(0,k.jsx)(`div`,{className:`note-editor-frame reading`,children:(0,k.jsx)(we,{content:ct,readOnly:!0,onInternalNoteLinkOpen:ut,resolveWikiNoteLink:lt,className:`milkdown-editor`})}):(0,k.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,k.jsx)(v,{size:36}),(0,k.jsx)(`p`,{children:e(`note.error.notFound`)})]})]}):(0,k.jsxs)(`div`,{className:`ui-empty-state note-editor-empty`,children:[(0,k.jsx)(`div`,{className:`ui-empty-icon note-editor-empty-icon`,children:(0,k.jsx)(v,{size:32})}),(0,k.jsx)(`h3`,{className:`ui-empty-title`,children:x?.configured?e(`note.noOpen.title`):e(`note.vault.open`)}),(0,k.jsx)(`p`,{className:`ui-empty-desc`,children:x?.configured?e(`note.noOpen.select`):e(`note.vault.emptyPrompt`)}),x?.configured?(0,k.jsx)(ae,{label:e(`note.openList`),variant:`default`}):(0,k.jsxs)(`button`,{className:`btn btn-primary`,onClick:ht,disabled:R,children:[(0,k.jsx)(h,{size:16}),e(R?`note.vault.opening`:`note.vault.open`)]})]})})})}),J&&(0,k.jsx)(ue,{title:J.title,placeholder:J.placeholder,defaultValue:J.defaultValue,confirmText:J.confirmText,onConfirm:J.onConfirm,onClose:()=>$e(null)}),et&&(0,k.jsx)(ye,{title:et.title,message:et.message,confirmText:et.confirmText,danger:!0,onConfirm:et.onConfirm,onClose:()=>tt(null)}),Y&&(0,k.jsx)(Se,{target:Y,targetLabel:Re(Y),directories:at,onMove:bt,onClose:()=>nt(null)})]})}function q(){let{t:e}=te(),t=d(e=>e.hasBackend),n=a(e=>e.wallet),r=y(),i=t===!0&&qe(c()),o=W(i,n?.address||``),s=i&&(r||o);return(0,k.jsx)(O.Suspense,{fallback:(0,k.jsx)(`div`,{className:`note-editor-loading`,children:e(`note.loading`)}),children:s?(0,k.jsx)(K,{}):(0,k.jsx)(G,{})})}var Je=o(`/note/`)({component:q});export{Je as Route};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,E as i,H as a,O as ee,W as o,n as te,o as ne,t as s}from"./useAppStore-DNhyhD20.js";import{a as c}from"./i18n-C6yaqRst.js";import{t as l}from"./fingerprint-pattern-BT73ASEB.js";import{t as u}from"./circle-alert-DXVkx8p8.js";import{a as d,i as f}from"./AccountMenu-D-wa5tux.js";import{t as re}from"./download-Cy2BlfKM.js";import{t as ie}from"./external-link-D_AQSgxW.js";import{n as ae,t as p}from"./CopyButton-DnFqfCN9.js";import{t as m}from"./loader-C4pED_QP.js";import{t as h}from"./save-CfYzXcxH.js";import{t as g}from"./shield-check-2-h_eEXp.js";import{t as _}from"./upload-BmufnMFu.js";import{I as v,O as y,T as b,_ as x,g as S,h as C,o as oe,v as w,w as se,y as T}from"./index-D1mozno-.js";import{t as E}from"./MarketingLayout-BPdjpEfc.js";import{t as ce}from"./MarketingHeader-8gNzHawY.js";import{n as le}from"./mp-cEQteKUC.js";var ue=r(`cloud-download`,[[`path`,{d:`M12 13v8l-4-4`,key:`1f5nwf`}],[`path`,{d:`m12 21 4-4`,key:`1lfcce`}],[`path`,{d:`M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284`,key:`ui1hmy`}]]),de=r(`cloud-upload`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]]),fe=r(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),pe=r(`wallet-cards`,[[`path`,{d:`M3 11h3.75a2 2 0 0 1 1.6.8l.45.6a4 4 0 0 0 6.4 0l.45-.6a2 2 0 0 1 1.6-.8H21`,key:`1vwh6y`}],[`path`,{d:`M3 7h18`,key:`1uiuf2`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]),D=t(e(),1),O=n(),k=[{value:``,labelKey:`profile.avatar.address`},...C.map(e=>({value:x(e),labelKey:`profile.avatar.${e}`}))];function A(e){if(w(e))return!0;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function j(e){return e===`disabled`?`is-disabled`:e===`working`?`is-working`:e===`synced`?`is-synced`:e===`error`?`is-error`:`is-idle`}function M({status:e,busy:t}){return t||e===`working`?(0,O.jsx)(m,{size:16,className:`ui-spinner`}):e===`synced`?(0,O.jsx)(v,{size:16}):e===`error`?(0,O.jsx)(u,{size:16}):(0,O.jsx)(g,{size:16})}function N(){let{formatNumber:e,t}=c(),n=s(e=>e.addToast),r=s(e=>e.hasBackend),a=i(e=>e.identity),u=i(e=>e.openLoginModal),v=i(e=>e.setUserIdentity),x=i(e=>e.logoutUser),C=oe(),[w,N]=(0,D.useState)(``),[I,L]=(0,D.useState)(``),[R,z]=(0,D.useState)(``),[B,V]=(0,D.useState)(!1),[H,U]=(0,D.useState)(null),W=(0,O.jsx)(ce,{});(0,D.useEffect)(()=>{if(!a){N(``),L(``),z(``);return}N(a.displayName||a.username),L(T(a.avatar)||a.avatar||``),z(``)},[a]),(0,D.useEffect)(()=>{a&&C.refreshBackupSummary()},[C.refreshBackupSummary,r,a]);let G=(0,D.useMemo)(()=>a?ee(a.danger):null,[a]),me=(0,D.useMemo)(()=>G?le(G.private_key,G.ed_public_key):``,[G]);if(!a)return(0,O.jsx)(E,{header:W,children:(0,O.jsx)(`section`,{className:`profile-page`,children:(0,O.jsx)(`div`,{className:`profile-container narrow`,children:(0,O.jsxs)(`div`,{className:`profile-empty glass`,children:[(0,O.jsx)(`div`,{className:`profile-empty-icon`,children:(0,O.jsx)(f,{size:34})}),(0,O.jsx)(`h1`,{children:t(`profile.signedOut.title`)}),(0,O.jsx)(`p`,{children:t(`profile.signedOut.desc`)}),(0,O.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:u,children:[(0,O.jsx)(f,{size:16}),t(`account.signIn`)]})]})})})});let he=T(a.avatar)||a.avatar||``,ge=S(a.address,a.avatar),K=a.address.toLowerCase(),_e=I.trim().length>0,ve=j(C.status),q=C.action===`backup`,J=C.action===`restore`,Y=C.action===`export`,X=C.action===`import`,ye=[{key:`notes`,label:t(`profile.backup.summary.notes`),value:C.notesCount},{key:`files`,label:t(`profile.backup.summary.files`),value:C.backupSummary.filesCount},{key:`trash`,label:t(`profile.backup.summary.trash`),value:C.backupSummary.trashFilesCount},{key:`channels`,label:t(`profile.backup.summary.channels`),value:C.backupSummary.channelsCount}];function be(){U({title:t(`profile.backup.confirm.backupTitle`),message:t(`profile.backup.confirm.backupMessage`),confirmText:t(`profile.backup.action.cloudBackup`),onConfirm:async()=>{U(null),await C.backupToCloud()}})}function xe(){U({title:t(`profile.backup.confirm.restoreTitle`),message:t(`profile.backup.confirm.restoreMessage`),confirmText:t(`profile.backup.action.cloudRestore`),onConfirm:async()=>{U(null),await C.restoreFromCloud({confirm:!1})}})}function Se(){return new Promise(e=>{let n=t=>{U(null),e(t)};U({title:t(`profile.backup.confirm.importTitle`),message:t(`profile.backup.confirm.restore`),confirmText:t(`profile.backup.action.importLocal`),onConfirm:()=>n(!0),onClose:()=>n(!1)})})}function Z(){C.importLocalBackup({requestConfirm:Se})}let Ce=[{key:`cloud-backup`,tone:`cloud-backup`,label:t(q?`profile.backup.status.backingUp`:`profile.backup.action.cloudBackup`),icon:q?(0,O.jsx)(m,{size:16,className:`ui-spinner`}):(0,O.jsx)(de,{size:16}),onClick:be},{key:`cloud-restore`,tone:`cloud-restore`,label:t(J?`profile.backup.status.restoring`:`profile.backup.action.cloudRestore`),icon:J?(0,O.jsx)(m,{size:16,className:`ui-spinner`}):(0,O.jsx)(ue,{size:16}),onClick:xe},{key:`export-local`,tone:`export-local`,label:t(Y?`profile.backup.status.exporting`:`profile.backup.action.exportLocal`),icon:Y?(0,O.jsx)(m,{size:16,className:`ui-spinner`}):(0,O.jsx)(re,{size:16}),onClick:C.exportLocalBackup},{key:`import-local`,tone:`import-local`,label:t(X?`profile.backup.status.importing`:`profile.backup.action.importLocal`),icon:X?(0,O.jsx)(m,{size:16,className:`ui-spinner`}):(0,O.jsx)(_,{size:16}),onClick:Z}];async function Q(e){if(r===!0)try{await te.put(`/api/user/profile`,{json:{displayName:e.displayName||e.username,avatar:e.avatar||``,updatedAt:e.profileUpdatedAt||Date.now()}}).json()}catch(e){n(await ne(e,t(`profile.backup.error.profileSaveFailed`)),`error`)}}function $(e){if(!a)return;let r={...a,avatar:e||void 0,profileUpdatedAt:Date.now()};v(r),Q(r),z(``),n(t(`profile.toast.avatarUpdated`),`success`)}function we(){if(!a)return;let e=w.trim()||a.username,r={...a,displayName:e,profileUpdatedAt:Date.now()};v(r),Q(r),N(e),n(t(`profile.toast.saved`),`success`)}function Te(){let e=I.trim();if(!e){$(void 0);return}if(!A(e)){z(t(`nav.avatarUrlInvalid`));return}$(e)}function Ee(){x(),V(!1)}return(0,O.jsxs)(E,{header:W,children:[(0,O.jsx)(`section`,{className:`profile-page`,children:(0,O.jsxs)(`div`,{className:`profile-container`,children:[(0,O.jsxs)(`section`,{className:`profile-panel profile-backup-card`,children:[(0,O.jsxs)(`div`,{className:`profile-panel-header profile-backup-header`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{children:t(`profile.section.backup`)}),(0,O.jsx)(`p`,{children:t(`profile.section.backup.desc`)})]}),(0,O.jsxs)(`span`,{className:`profile-backup-status ${ve}`,children:[(0,O.jsx)(M,{status:C.status,busy:C.busy}),C.statusLabel]})]}),(0,O.jsx)(`div`,{className:`profile-backup-summary`,"aria-label":t(`profile.backup.summary.label`),children:ye.map(t=>(0,O.jsxs)(`div`,{className:`profile-backup-stat`,children:[(0,O.jsx)(`span`,{className:`profile-backup-stat-value`,children:t.value===null?C.backupSummary.loading?`...`:`-`:e(t.value)}),(0,O.jsx)(`span`,{className:`profile-backup-stat-label`,children:t.label})]},t.key))}),(0,O.jsx)(`div`,{className:`profile-backup-actions`,children:Ce.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:[`btn`,`profile-backup-action`,`is-${e.tone}`].join(` `),disabled:C.busy,onClick:e.onClick,children:[e.icon,e.label]},e.key))})]}),(0,O.jsxs)(`header`,{className:`profile-header`,children:[(0,O.jsx)(`img`,{className:`profile-avatar-large`,src:ge,alt:``}),(0,O.jsxs)(`div`,{className:`profile-heading`,children:[(0,O.jsx)(`p`,{className:`profile-kicker`,children:t(`profile.kicker`)}),(0,O.jsx)(`h1`,{children:a.displayName||a.username}),(0,O.jsxs)(`div`,{className:`profile-address-line`,children:[(0,O.jsx)(`code`,{translate:`no`,children:K}),(0,O.jsx)(p,{text:K}),(0,O.jsxs)(`a`,{href:`https://debank.com/profile/${a.address}`,target:`_blank`,rel:`noopener noreferrer`,className:`btn btn-secondary btn-sm`,children:[(0,O.jsx)(ie,{size:14}),t(`web3.action.view`)]})]})]}),(0,O.jsxs)(`button`,{type:`button`,className:`btn btn-secondary profile-logout-btn`,onClick:()=>V(!0),children:[(0,O.jsx)(fe,{size:16}),t(`account.logout`)]})]}),(0,O.jsxs)(`div`,{className:`profile-grid`,children:[(0,O.jsxs)(`section`,{className:`profile-panel`,children:[(0,O.jsx)(`div`,{className:`profile-panel-header`,children:(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{children:t(`profile.section.account`)}),(0,O.jsx)(`p`,{children:t(`profile.section.account.desc`)})]})}),(0,O.jsxs)(`label`,{className:`profile-field`,children:[(0,O.jsx)(`span`,{children:t(`profile.label.displayName`)}),(0,O.jsxs)(`div`,{className:`profile-field-row`,children:[(0,O.jsx)(`input`,{className:`input`,value:w,onChange:e=>N(e.target.value),placeholder:t(`nav.displayNamePlaceholder`)}),(0,O.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:we,children:[(0,O.jsx)(h,{size:16}),t(`profile.action.save`)]})]})]}),(0,O.jsx)(`div`,{className:`profile-facts`,children:(0,O.jsx)(P,{label:t(`profile.label.username`),value:a.username})})]}),(0,O.jsxs)(`section`,{className:`profile-panel`,children:[(0,O.jsx)(`div`,{className:`profile-panel-header`,children:(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{children:t(`profile.section.avatar`)}),(0,O.jsx)(`p`,{children:t(`profile.section.avatar.desc`)})]})}),(0,O.jsx)(`div`,{className:`profile-avatar-grid`,role:`list`,children:k.map(e=>{let n=he===e.value;return(0,O.jsxs)(`button`,{type:`button`,className:[`profile-avatar-option`,n?`selected`:``].filter(Boolean).join(` `),onClick:()=>$(e.value),"aria-pressed":n,title:t(e.labelKey),children:[(0,O.jsx)(`img`,{src:S(a.address,e.value),alt:``,"aria-hidden":`true`}),(0,O.jsx)(`span`,{children:t(e.labelKey)}),n&&(0,O.jsx)(`span`,{className:`profile-avatar-check`,children:(0,O.jsx)(d,{size:14})})]},e.value||`address`)})}),(0,O.jsxs)(`div`,{className:`profile-avatar-url`,children:[(0,O.jsxs)(`label`,{className:`profile-field`,htmlFor:`profile-avatar-url`,children:[(0,O.jsx)(`span`,{children:t(`profile.label.customAvatar`)}),(0,O.jsxs)(`div`,{className:`profile-field-row`,children:[(0,O.jsx)(`input`,{id:`profile-avatar-url`,className:`input`,value:I,onChange:e=>{L(e.target.value),z(``)},placeholder:t(`nav.avatarUrlPlaceholder`)}),(0,O.jsxs)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:Te,disabled:!_e,children:[(0,O.jsx)(h,{size:16}),t(`profile.action.save`)]})]})]}),R&&(0,O.jsx)(`p`,{className:`profile-error`,children:R})]})]})]}),(0,O.jsxs)(`section`,{className:`profile-panel profile-identity-panel`,children:[(0,O.jsxs)(`div`,{className:`profile-panel-header`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{children:t(`profile.section.identity`)}),(0,O.jsx)(`p`,{children:t(`profile.section.identity.desc`)})]}),(0,O.jsxs)(o,{to:`/web3/`,hash:`wallet`,className:`btn btn-secondary`,children:[(0,O.jsx)(pe,{size:16}),t(`profile.action.openWallet`)]})]}),(0,O.jsxs)(`div`,{className:`profile-key-grid`,children:[G&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(F,{title:t(`web3.label.ed25519Public`),icon:(0,O.jsx)(l,{size:18}),value:G.ed_public_key}),(0,O.jsx)(F,{title:t(`web3.label.x25519Public`),icon:(0,O.jsx)(ae,{size:18}),value:G.public_key})]}),(0,O.jsx)(F,{title:`IPNS ID`,icon:(0,O.jsx)(g,{size:18}),value:me||`-`})]})]})]})}),H&&(0,O.jsx)(se,{title:H.title,message:H.message,confirmText:H.confirmText,danger:H.danger,onConfirm:H.onConfirm,onClose:H.onClose||(()=>U(null))}),B&&(0,O.jsx)(b,{className:`profile-logout-overlay`,onClose:()=>V(!1),children:(0,O.jsxs)(`div`,{className:`confirm-modal profile-logout-modal`,onClick:e=>e.stopPropagation(),children:[(0,O.jsxs)(`div`,{className:`modal-header`,children:[(0,O.jsx)(`h3`,{children:t(`account.logoutTitle`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>V(!1),"aria-label":t(`common.close`),children:(0,O.jsx)(y,{size:18})})]}),(0,O.jsx)(`p`,{className:`profile-logout-reminder`,children:t(`profile.logout.backupReminder`)}),(0,O.jsxs)(`div`,{className:`profile-logout-backup-actions`,children:[(0,O.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,disabled:C.busy,onClick:()=>void C.backupToCloud(),children:t(`profile.backup.action.cloudBackup`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,disabled:C.busy,onClick:()=>void C.exportLocalBackup(),children:t(`profile.backup.action.exportLocal`)})]}),(0,O.jsxs)(`div`,{className:`modal-actions`,children:[(0,O.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:()=>V(!1),children:t(`common.cancel`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn btn-danger`,onClick:Ee,children:t(`account.logout`)})]})]})})]})}function P({label:e,value:t,copy:n=!1}){return(0,O.jsxs)(`div`,{className:`profile-fact`,children:[(0,O.jsx)(`span`,{children:e}),(0,O.jsxs)(`div`,{className:`profile-fact-value`,children:[(0,O.jsx)(`code`,{translate:`no`,children:t}),n&&(0,O.jsx)(p,{text:t})]})]})}function F({title:e,icon:t,value:n}){return(0,O.jsxs)(`div`,{className:`profile-key-card`,children:[(0,O.jsxs)(`div`,{className:`profile-key-card-header`,children:[(0,O.jsx)(`span`,{className:`profile-key-card-icon`,children:t}),(0,O.jsx)(`span`,{children:e})]}),(0,O.jsxs)(`div`,{className:`mono-row`,children:[(0,O.jsx)(`code`,{className:`mono`,translate:`no`,children:n}),(0,O.jsx)(p,{text:n})]})]})}var I=a(`/profile/`)({component:N});export{I as Route};
|
|
1
|
+
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,E as i,H as a,O as ee,W as o,n as te,o as ne,t as s}from"./useAppStore-DNhyhD20.js";import{a as c}from"./i18n-DKsg67mH.js";import{t as l}from"./fingerprint-pattern-BT73ASEB.js";import{t as u}from"./circle-alert-DXVkx8p8.js";import{a as d,i as f}from"./AccountMenu-D_rcXDZr.js";import{t as re}from"./download-Cy2BlfKM.js";import{t as ie}from"./external-link-D_AQSgxW.js";import{n as ae,t as p}from"./CopyButton-ClwBN6Iy.js";import{t as m}from"./loader-C4pED_QP.js";import{t as h}from"./save-CfYzXcxH.js";import{t as g}from"./shield-check-2-h_eEXp.js";import{t as _}from"./upload-BmufnMFu.js";import{I as v,O as y,T as b,_ as x,g as S,h as C,o as oe,v as w,w as se,y as T}from"./index-DJzLHA0V.js";import{t as E}from"./MarketingLayout-hkPAtieL.js";import{t as ce}from"./MarketingHeader-ChTIIzXG.js";import{n as le}from"./mp-cEQteKUC.js";var ue=r(`cloud-download`,[[`path`,{d:`M12 13v8l-4-4`,key:`1f5nwf`}],[`path`,{d:`m12 21 4-4`,key:`1lfcce`}],[`path`,{d:`M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284`,key:`ui1hmy`}]]),de=r(`cloud-upload`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]]),fe=r(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),pe=r(`wallet-cards`,[[`path`,{d:`M3 11h3.75a2 2 0 0 1 1.6.8l.45.6a4 4 0 0 0 6.4 0l.45-.6a2 2 0 0 1 1.6-.8H21`,key:`1vwh6y`}],[`path`,{d:`M3 7h18`,key:`1uiuf2`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]),D=t(e(),1),O=n(),k=[{value:``,labelKey:`profile.avatar.address`},...C.map(e=>({value:x(e),labelKey:`profile.avatar.${e}`}))];function A(e){if(w(e))return!0;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function j(e){return e===`disabled`?`is-disabled`:e===`working`?`is-working`:e===`synced`?`is-synced`:e===`error`?`is-error`:`is-idle`}function M({status:e,busy:t}){return t||e===`working`?(0,O.jsx)(m,{size:16,className:`ui-spinner`}):e===`synced`?(0,O.jsx)(v,{size:16}):e===`error`?(0,O.jsx)(u,{size:16}):(0,O.jsx)(g,{size:16})}function N(){let{formatNumber:e,t}=c(),n=s(e=>e.addToast),r=s(e=>e.hasBackend),a=i(e=>e.identity),u=i(e=>e.openLoginModal),v=i(e=>e.setUserIdentity),x=i(e=>e.logoutUser),C=oe(),[w,N]=(0,D.useState)(``),[I,L]=(0,D.useState)(``),[R,z]=(0,D.useState)(``),[B,V]=(0,D.useState)(!1),[H,U]=(0,D.useState)(null),W=(0,O.jsx)(ce,{});(0,D.useEffect)(()=>{if(!a){N(``),L(``),z(``);return}N(a.displayName||a.username),L(T(a.avatar)||a.avatar||``),z(``)},[a]),(0,D.useEffect)(()=>{a&&C.refreshBackupSummary()},[C.refreshBackupSummary,r,a]);let G=(0,D.useMemo)(()=>a?ee(a.danger):null,[a]),me=(0,D.useMemo)(()=>G?le(G.private_key,G.ed_public_key):``,[G]);if(!a)return(0,O.jsx)(E,{header:W,children:(0,O.jsx)(`section`,{className:`profile-page`,children:(0,O.jsx)(`div`,{className:`profile-container narrow`,children:(0,O.jsxs)(`div`,{className:`profile-empty glass`,children:[(0,O.jsx)(`div`,{className:`profile-empty-icon`,children:(0,O.jsx)(f,{size:34})}),(0,O.jsx)(`h1`,{children:t(`profile.signedOut.title`)}),(0,O.jsx)(`p`,{children:t(`profile.signedOut.desc`)}),(0,O.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:u,children:[(0,O.jsx)(f,{size:16}),t(`account.signIn`)]})]})})})});let he=T(a.avatar)||a.avatar||``,ge=S(a.address,a.avatar),K=a.address.toLowerCase(),_e=I.trim().length>0,ve=j(C.status),q=C.action===`backup`,J=C.action===`restore`,Y=C.action===`export`,X=C.action===`import`,ye=[{key:`notes`,label:t(`profile.backup.summary.notes`),value:C.notesCount},{key:`files`,label:t(`profile.backup.summary.files`),value:C.backupSummary.filesCount},{key:`trash`,label:t(`profile.backup.summary.trash`),value:C.backupSummary.trashFilesCount},{key:`channels`,label:t(`profile.backup.summary.channels`),value:C.backupSummary.channelsCount}];function be(){U({title:t(`profile.backup.confirm.backupTitle`),message:t(`profile.backup.confirm.backupMessage`),confirmText:t(`profile.backup.action.cloudBackup`),onConfirm:async()=>{U(null),await C.backupToCloud()}})}function xe(){U({title:t(`profile.backup.confirm.restoreTitle`),message:t(`profile.backup.confirm.restoreMessage`),confirmText:t(`profile.backup.action.cloudRestore`),onConfirm:async()=>{U(null),await C.restoreFromCloud({confirm:!1})}})}function Se(){return new Promise(e=>{let n=t=>{U(null),e(t)};U({title:t(`profile.backup.confirm.importTitle`),message:t(`profile.backup.confirm.restore`),confirmText:t(`profile.backup.action.importLocal`),onConfirm:()=>n(!0),onClose:()=>n(!1)})})}function Z(){C.importLocalBackup({requestConfirm:Se})}let Ce=[{key:`cloud-backup`,tone:`cloud-backup`,label:t(q?`profile.backup.status.backingUp`:`profile.backup.action.cloudBackup`),icon:q?(0,O.jsx)(m,{size:16,className:`ui-spinner`}):(0,O.jsx)(de,{size:16}),onClick:be},{key:`cloud-restore`,tone:`cloud-restore`,label:t(J?`profile.backup.status.restoring`:`profile.backup.action.cloudRestore`),icon:J?(0,O.jsx)(m,{size:16,className:`ui-spinner`}):(0,O.jsx)(ue,{size:16}),onClick:xe},{key:`export-local`,tone:`export-local`,label:t(Y?`profile.backup.status.exporting`:`profile.backup.action.exportLocal`),icon:Y?(0,O.jsx)(m,{size:16,className:`ui-spinner`}):(0,O.jsx)(re,{size:16}),onClick:C.exportLocalBackup},{key:`import-local`,tone:`import-local`,label:t(X?`profile.backup.status.importing`:`profile.backup.action.importLocal`),icon:X?(0,O.jsx)(m,{size:16,className:`ui-spinner`}):(0,O.jsx)(_,{size:16}),onClick:Z}];async function Q(e){if(r===!0)try{await te.put(`/api/user/profile`,{json:{displayName:e.displayName||e.username,avatar:e.avatar||``,updatedAt:e.profileUpdatedAt||Date.now()}}).json()}catch(e){n(await ne(e,t(`profile.backup.error.profileSaveFailed`)),`error`)}}function $(e){if(!a)return;let r={...a,avatar:e||void 0,profileUpdatedAt:Date.now()};v(r),Q(r),z(``),n(t(`profile.toast.avatarUpdated`),`success`)}function we(){if(!a)return;let e=w.trim()||a.username,r={...a,displayName:e,profileUpdatedAt:Date.now()};v(r),Q(r),N(e),n(t(`profile.toast.saved`),`success`)}function Te(){let e=I.trim();if(!e){$(void 0);return}if(!A(e)){z(t(`nav.avatarUrlInvalid`));return}$(e)}function Ee(){x(),V(!1)}return(0,O.jsxs)(E,{header:W,children:[(0,O.jsx)(`section`,{className:`profile-page`,children:(0,O.jsxs)(`div`,{className:`profile-container`,children:[(0,O.jsxs)(`section`,{className:`profile-panel profile-backup-card`,children:[(0,O.jsxs)(`div`,{className:`profile-panel-header profile-backup-header`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{children:t(`profile.section.backup`)}),(0,O.jsx)(`p`,{children:t(`profile.section.backup.desc`)})]}),(0,O.jsxs)(`span`,{className:`profile-backup-status ${ve}`,children:[(0,O.jsx)(M,{status:C.status,busy:C.busy}),C.statusLabel]})]}),(0,O.jsx)(`div`,{className:`profile-backup-summary`,"aria-label":t(`profile.backup.summary.label`),children:ye.map(t=>(0,O.jsxs)(`div`,{className:`profile-backup-stat`,children:[(0,O.jsx)(`span`,{className:`profile-backup-stat-value`,children:t.value===null?C.backupSummary.loading?`...`:`-`:e(t.value)}),(0,O.jsx)(`span`,{className:`profile-backup-stat-label`,children:t.label})]},t.key))}),(0,O.jsx)(`div`,{className:`profile-backup-actions`,children:Ce.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:[`btn`,`profile-backup-action`,`is-${e.tone}`].join(` `),disabled:C.busy,onClick:e.onClick,children:[e.icon,e.label]},e.key))})]}),(0,O.jsxs)(`header`,{className:`profile-header`,children:[(0,O.jsx)(`img`,{className:`profile-avatar-large`,src:ge,alt:``}),(0,O.jsxs)(`div`,{className:`profile-heading`,children:[(0,O.jsx)(`p`,{className:`profile-kicker`,children:t(`profile.kicker`)}),(0,O.jsx)(`h1`,{children:a.displayName||a.username}),(0,O.jsxs)(`div`,{className:`profile-address-line`,children:[(0,O.jsx)(`code`,{translate:`no`,children:K}),(0,O.jsx)(p,{text:K}),(0,O.jsxs)(`a`,{href:`https://debank.com/profile/${a.address}`,target:`_blank`,rel:`noopener noreferrer`,className:`btn btn-secondary btn-sm`,children:[(0,O.jsx)(ie,{size:14}),t(`web3.action.view`)]})]})]}),(0,O.jsxs)(`button`,{type:`button`,className:`btn btn-secondary profile-logout-btn`,onClick:()=>V(!0),children:[(0,O.jsx)(fe,{size:16}),t(`account.logout`)]})]}),(0,O.jsxs)(`div`,{className:`profile-grid`,children:[(0,O.jsxs)(`section`,{className:`profile-panel`,children:[(0,O.jsx)(`div`,{className:`profile-panel-header`,children:(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{children:t(`profile.section.account`)}),(0,O.jsx)(`p`,{children:t(`profile.section.account.desc`)})]})}),(0,O.jsxs)(`label`,{className:`profile-field`,children:[(0,O.jsx)(`span`,{children:t(`profile.label.displayName`)}),(0,O.jsxs)(`div`,{className:`profile-field-row`,children:[(0,O.jsx)(`input`,{className:`input`,value:w,onChange:e=>N(e.target.value),placeholder:t(`nav.displayNamePlaceholder`)}),(0,O.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:we,children:[(0,O.jsx)(h,{size:16}),t(`profile.action.save`)]})]})]}),(0,O.jsx)(`div`,{className:`profile-facts`,children:(0,O.jsx)(P,{label:t(`profile.label.username`),value:a.username})})]}),(0,O.jsxs)(`section`,{className:`profile-panel`,children:[(0,O.jsx)(`div`,{className:`profile-panel-header`,children:(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{children:t(`profile.section.avatar`)}),(0,O.jsx)(`p`,{children:t(`profile.section.avatar.desc`)})]})}),(0,O.jsx)(`div`,{className:`profile-avatar-grid`,role:`list`,children:k.map(e=>{let n=he===e.value;return(0,O.jsxs)(`button`,{type:`button`,className:[`profile-avatar-option`,n?`selected`:``].filter(Boolean).join(` `),onClick:()=>$(e.value),"aria-pressed":n,title:t(e.labelKey),children:[(0,O.jsx)(`img`,{src:S(a.address,e.value),alt:``,"aria-hidden":`true`}),(0,O.jsx)(`span`,{children:t(e.labelKey)}),n&&(0,O.jsx)(`span`,{className:`profile-avatar-check`,children:(0,O.jsx)(d,{size:14})})]},e.value||`address`)})}),(0,O.jsxs)(`div`,{className:`profile-avatar-url`,children:[(0,O.jsxs)(`label`,{className:`profile-field`,htmlFor:`profile-avatar-url`,children:[(0,O.jsx)(`span`,{children:t(`profile.label.customAvatar`)}),(0,O.jsxs)(`div`,{className:`profile-field-row`,children:[(0,O.jsx)(`input`,{id:`profile-avatar-url`,className:`input`,value:I,onChange:e=>{L(e.target.value),z(``)},placeholder:t(`nav.avatarUrlPlaceholder`)}),(0,O.jsxs)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:Te,disabled:!_e,children:[(0,O.jsx)(h,{size:16}),t(`profile.action.save`)]})]})]}),R&&(0,O.jsx)(`p`,{className:`profile-error`,children:R})]})]})]}),(0,O.jsxs)(`section`,{className:`profile-panel profile-identity-panel`,children:[(0,O.jsxs)(`div`,{className:`profile-panel-header`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{children:t(`profile.section.identity`)}),(0,O.jsx)(`p`,{children:t(`profile.section.identity.desc`)})]}),(0,O.jsxs)(o,{to:`/web3/`,hash:`wallet`,className:`btn btn-secondary`,children:[(0,O.jsx)(pe,{size:16}),t(`profile.action.openWallet`)]})]}),(0,O.jsxs)(`div`,{className:`profile-key-grid`,children:[G&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(F,{title:t(`web3.label.ed25519Public`),icon:(0,O.jsx)(l,{size:18}),value:G.ed_public_key}),(0,O.jsx)(F,{title:t(`web3.label.x25519Public`),icon:(0,O.jsx)(ae,{size:18}),value:G.public_key})]}),(0,O.jsx)(F,{title:`IPNS ID`,icon:(0,O.jsx)(g,{size:18}),value:me||`-`})]})]})]})}),H&&(0,O.jsx)(se,{title:H.title,message:H.message,confirmText:H.confirmText,danger:H.danger,onConfirm:H.onConfirm,onClose:H.onClose||(()=>U(null))}),B&&(0,O.jsx)(b,{className:`profile-logout-overlay`,onClose:()=>V(!1),children:(0,O.jsxs)(`div`,{className:`confirm-modal profile-logout-modal`,onClick:e=>e.stopPropagation(),children:[(0,O.jsxs)(`div`,{className:`modal-header`,children:[(0,O.jsx)(`h3`,{children:t(`account.logoutTitle`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>V(!1),"aria-label":t(`common.close`),children:(0,O.jsx)(y,{size:18})})]}),(0,O.jsx)(`p`,{className:`profile-logout-reminder`,children:t(`profile.logout.backupReminder`)}),(0,O.jsxs)(`div`,{className:`profile-logout-backup-actions`,children:[(0,O.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,disabled:C.busy,onClick:()=>void C.backupToCloud(),children:t(`profile.backup.action.cloudBackup`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,disabled:C.busy,onClick:()=>void C.exportLocalBackup(),children:t(`profile.backup.action.exportLocal`)})]}),(0,O.jsxs)(`div`,{className:`modal-actions`,children:[(0,O.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:()=>V(!1),children:t(`common.cancel`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn btn-danger`,onClick:Ee,children:t(`account.logout`)})]})]})})]})}function P({label:e,value:t,copy:n=!1}){return(0,O.jsxs)(`div`,{className:`profile-fact`,children:[(0,O.jsx)(`span`,{children:e}),(0,O.jsxs)(`div`,{className:`profile-fact-value`,children:[(0,O.jsx)(`code`,{translate:`no`,children:t}),n&&(0,O.jsx)(p,{text:t})]})]})}function F({title:e,icon:t,value:n}){return(0,O.jsxs)(`div`,{className:`profile-key-card`,children:[(0,O.jsxs)(`div`,{className:`profile-key-card-header`,children:[(0,O.jsx)(`span`,{className:`profile-key-card-icon`,children:t}),(0,O.jsx)(`span`,{children:e})]}),(0,O.jsxs)(`div`,{className:`mono-row`,children:[(0,O.jsx)(`code`,{className:`mono`,translate:`no`,children:n}),(0,O.jsx)(p,{text:n})]})]})}var I=a(`/profile/`)({component:N});export{I as Route};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,E as i,H as a,c as o,o as s,t as c,u as l}from"./useAppStore-DNhyhD20.js";import{a as ee}from"./i18n-DKsg67mH.js";import{a as u}from"./AccountMenu-D_rcXDZr.js";import{t as te}from"./OpenSidebarButton-CXBAjjCE.js";import{a as d,i as f,n as ne,o as re,r as p,t as ie}from"./saveLocalFile-DTgdBgO9.js";import{t as ae}from"./arrow-up-down-DvLSz6Ma.js";import{n as oe,t as se}from"./trash-2-B9gno5q6.js";import{t as ce}from"./copy-OwXDsstV.js";import{t as le}from"./download-Cy2BlfKM.js";import{t as ue}from"./file-text-zvTER2mN.js";import{t as m}from"./folder-6pYYnS2-.js";import{t as de}from"./loader-C4pED_QP.js";import{r as fe,t as pe}from"./AppShell-CKP_dglR.js";import{t as h}from"./music-Br2x8TKX.js";import{t as me}from"./search-DLBOUfny.js";import{t as he}from"./upload-BmufnMFu.js";import{C as ge,O as g,T as _,w as _e}from"./index-DJzLHA0V.js";import{t as ve}from"./AppTop-C03PsDr_.js";import{t as ye}from"./format-CAKfypjK.js";import{a as be,i as xe,n as v,r as Se,t as Ce}from"./downloadValidation-Dd43i9_9.js";var we=r(`files`,[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]),Te=r(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),Ee=r(`star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),y=t(e(),1);function De(e={}){let t=e.timeout??2e3,[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(!1),o=(0,y.useRef)(null);(0,y.useEffect)(()=>()=>{window.clearTimeout(o.current)},[]);let s=e=>{window.clearTimeout(o.current),o.current=window.setTimeout(()=>a(!1),t),a(e)};return{copy:e=>{`clipboard`in navigator?navigator.clipboard.writeText(e).then(()=>{r(null),s(!0)}).catch(e=>r(e)):r(Error(`useClipboard: navigator.clipboard is not supported`))},reset:()=>{a(!1),r(null),window.clearTimeout(o.current)},error:n,copied:i}}var b=n();function Oe(e){let t=e.lastIndexOf(`/`);return t===-1?{folder:``,name:e}:{folder:e.substring(0,t),name:e.substring(t+1)}}function ke({file:e,isSelected:t,onSelect:n,onPreview:r}){let i=p(e.fileName),a=(0,b.jsx)(ue,{size:24,color:`#fff`});return i===`image`?a=(0,b.jsx)(f,{size:24,color:`#fff`}):i===`video`?a=(0,b.jsx)(d,{size:24,color:`#fff`}):i===`audio`&&(a=(0,b.jsx)(h,{size:24,color:`#fff`})),(0,b.jsxs)(`div`,{"data-id":e.cid,onClick:()=>n(e.cid),onDoubleClick:()=>r(e),className:`card ${t?`selected`:``}`,children:[(0,b.jsx)(`div`,{className:`card-icon ${e.starred?`starred`:`file`}`,children:a}),(0,b.jsx)(`p`,{className:`card-name`,translate:`no`,children:Oe(e.fileName).name})]})}function Ae({folder:e,onClick:t}){return(0,b.jsxs)(`div`,{onClick:t,className:`card`,children:[(0,b.jsx)(`div`,{className:`card-icon folder`,children:(0,b.jsx)(m,{size:28,color:`#fff`})}),(0,b.jsx)(`p`,{className:`card-name`,translate:`no`,children:e.name})]})}function x(e,t){return e?[{path:``,name:t},...e.split(`/`).filter(Boolean).map((e,t,n)=>({path:n.slice(0,t+1).join(`/`),name:e}))]:[]}function je({items:e,allFolders:t,currentPath:n,onMove:r,onClose:i}){let[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(n),{t:l}=ee(),u=x(a,l(`move.root`));function te(){r(a||s.trim())}let d=t.filter(e=>{if(a===``)return!e.path.includes(`/`);let t=a+`/`;return e.path.startsWith(t)?!e.path.substring(t.length).includes(`/`):!1});return(0,b.jsx)(_,{onClose:i,children:(0,b.jsxs)(`div`,{className:`move-modal`,onClick:e=>e.stopPropagation(),children:[(0,b.jsxs)(`div`,{className:`modal-header`,children:[(0,b.jsx)(`h3`,{children:l(`move.title`)}),(0,b.jsx)(`button`,{type:`button`,onClick:i,className:`btn btn-icon`,children:(0,b.jsx)(g,{size:18})})]}),(0,b.jsx)(`p`,{className:`move-modal-desc`,children:l(`move.selectedCount`,{count:e.length})}),(0,b.jsx)(`div`,{className:`move-new-folder`,children:(0,b.jsx)(`input`,{type:`text`,className:`input`,value:s,onChange:e=>c(e.target.value),placeholder:l(`move.pathPlaceholder`),translate:`no`})}),(0,b.jsx)(`p`,{className:`move-modal-hint`,children:l(`move.pathExample`)}),(0,b.jsx)(`div`,{className:`move-breadcrumb`,children:u.map((e,t)=>(0,b.jsxs)(y.Fragment,{children:[t>0&&(0,b.jsx)(`span`,{className:`breadcrumb-separator`,children:`/`}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>{o(e.path),c(e.path)},className:`move-breadcrumb-btn ${a===e.path&&!s?`active`:``}`,children:(0,b.jsx)(`span`,{translate:e.path?`no`:`yes`,children:e.name})})]},e.path))}),(0,b.jsxs)(`div`,{className:`move-folder-list`,children:[d.length===0&&(0,b.jsx)(`p`,{className:`move-modal-empty`,children:l(`move.noSubfolders`)}),d.map(e=>(0,b.jsxs)(`button`,{type:`button`,onClick:()=>o(e.path),className:`move-folder-item ${a===e.path&&!s?`selected`:``}`,children:[(0,b.jsx)(m,{size:16}),(0,b.jsx)(`span`,{translate:`no`,children:e.name})]},e.path))]}),(0,b.jsxs)(`div`,{className:`modal-actions`,children:[(0,b.jsx)(`button`,{type:`button`,onClick:i,className:`btn btn-secondary`,children:l(`common.cancel`)}),(0,b.jsx)(`button`,{type:`button`,onClick:te,className:`btn btn-primary`,children:l(`move.action`)})]})]})})}var S=`https://most.box`;function C(e){return String(e||``).trim()}function Me(e,t){let n=C(t);return n?`most://${e}?filename=${encodeURIComponent(n)}`:`most://${e}`}function Ne(e,t){let n=C(t),r=`${S}/cid/${encodeURIComponent(e)}`;return n?`${r}?filename=${encodeURIComponent(n)}`:r}function w(e){return Oe(e)}function Pe(e){let t=new Set;return e.forEach(e=>{let{folder:n}=w(e.fileName),r=n.split(`/`).filter(Boolean),i=``;for(let e of r)i+=(i?`/`:``)+e,t.add(i)}),[...t].sort()}function Fe(e,t){let n=t?t+`/`:``;return e.filter(e=>{let t=e.toLowerCase().startsWith(n.toLowerCase()),r=e.substring(n.length);return t&&!r.includes(`/`)}).map(e=>({name:e.substring(n.length),path:e}))}function Ie(e,t,n){return{folders:Fe(t,n),files:e.filter(e=>w(e.fileName).folder===n)}}function Le(e,t){return e?[{path:``,name:t},...e.split(`/`).filter(Boolean).map((e,t,n)=>({path:n.slice(0,t+1).join(`/`),name:e}))]:[]}function T(){let e=c(e=>e.addToast),t=c(e=>e.hasBackend),n=c(e=>e.openConnectModal),r=i(e=>e.identity),a=i(e=>e.openLoginModal),[d,f]=(0,y.useState)([]),[m,h]=(0,y.useState)([]),[Oe,x]=(0,y.useState)(null),[S,C]=(0,y.useState)(`all`),[Fe,T]=(0,y.useState)(!1),[E,D]=(0,y.useState)([]),[Re,O]=(0,y.useState)(null),[k,A]=(0,y.useState)(null),[ze,Be]=fe(!1),[Ve,j]=(0,y.useState)(``),[M,N]=(0,y.useState)(null),[P,He]=(0,y.useState)(!1),[Ue,F]=(0,y.useState)([]),[We,I]=fe(!1),[L,R]=(0,y.useState)(``),{copy:Ge,copied:Ke}=De({timeout:2e3}),{copy:qe,copied:Je}=De({timeout:2e3}),[Ye,Xe]=fe(!1),[z,B]=(0,y.useState)(null),[V,Ze]=(0,y.useState)(null),[Qe,$e]=(0,y.useState)(!1),{t:H,formatDate:et}=ee(),U=t===!0,tt=e=>e?et(e):``,W=Oe||``,nt=Pe(d),{folders:rt,files:it}=Ie(d,nt,W);function G(){return U?!0:(n(),!1)}function K(){return r?!0:(a(),!1)}let at=L?d.filter(e=>w(e.fileName).name.toLowerCase().includes(L.toLowerCase())):it,q=async()=>{if(!U||!r){f([]);return}try{f(await v.listPublishedFiles()||[])}catch{f([])}},J=async()=>{if(!U||!r){h([]);return}try{h(await v.listTrashFiles()||[])}catch{h([])}},ot=e=>{D(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},st=async t=>{if(K()&&G())try{await v.restoreTrashFile(t),e(H(`app.toast.restored`),`success`),q(),J()}catch(t){e(await s(t,H(`app.toast.restoreFailed`)),`error`)}},ct=async()=>{K()&&G()&&B({title:H(`app.clearTrash.title`),message:H(`app.clearTrash.message`),confirmText:H(`app.clear`),danger:!0,onConfirm:async()=>{B(null);try{await v.emptyTrash(),e(H(`app.toast.trashEmptied`),`success`),J()}catch(t){e(await s(t,H(`app.toast.emptyFailed`)),`error`)}}})},lt=async t=>{if(K()&&G())try{let n=await v.toggleStar(t);f(e=>e.map(e=>e.cid===t?{...e,starred:n.starred}:e)),e(n.starred?H(`app.toast.favorited`):H(`app.toast.unfavorited`),`success`)}catch(t){e(await s(t,H(`app.toast.actionFailed`)),`error`)}},ut=async()=>{if(!K()||!G())return;let t=S===`trash`;B({title:H(t?`app.permanentDelete`:`app.batchDelete`),message:H(t?`app.deleteSelectedPermanent`:`app.deleteSelected`,{count:E.length}),confirmText:H(t?`app.permanentDelete`:`app.delete`),danger:!0,onConfirm:async()=>{B(null);try{for(let e of E)t?await v.permanentDeleteTrashFile(e):e.startsWith(`__`)||await v.deletePublishedFile(e);D([]),e(H(t?`app.toast.deletedPermanently`:`app.toast.deleted`),`success`),q(),J()}catch(t){e(await s(t,H(`app.toast.deleteFailed`)),`error`)}}})},dt=async t=>{if(K()&&G())try{for(let e of E){let n=d.find(t=>t.cid===e);if(!n)continue;let{name:r}=w(n.fileName),i=t?`${t}/${r}`:r;n.fileName!==i&&await v.moveFile(e,i)}D([]),Xe.close(),e(H(`app.toast.moved`),`success`),q()}catch(t){e(await s(t,H(`app.toast.moveFailed`)),`error`)}},ft=t=>{let n=!!t.path,r=n?t.name:w(t.fileName).name;Ze({title:H(n?`app.renameFolder`:`app.renameFile`),placeholder:H(`app.enterNewName`),defaultValue:r,confirmText:H(`app.rename`),onConfirm:async i=>{if(i!==r&&K()&&G()){$e(!0);try{if(n){let n=t.path.lastIndexOf(`/`),r=n===-1?``:t.path.substring(0,n),a=r?`${r}/${i}`:i;await v.renameFolder(t.path,a),e(H(`app.toast.renamed`),`success`),q(),Q(a)}else{let{folder:n}=w(t.fileName),r=n?`${n}/${i}`:i;await v.moveFile(t.cid,r),e(H(`app.toast.renamed`),`success`),q()}Ze(null)}catch(t){e(await s(t,H(`app.toast.renameFailed`)),`error`)}finally{$e(!1)}}}})},pt=async t=>{if(!r){a(),e(H(`app.toast.signInBeforePublish`),`warning`);return}if(!G())return;let n=W?W+`/`:``,i=[],o=await v.getNodePolicy().catch(()=>null),s=Array.from(t);for(let t of s){let r=n+t.name,a=be(t,o,H);if(a){e(a,`error`);continue}if(d.some(e=>e.fileName===r)){e(H(`app.fileAlreadyExists`,{fileName:t.name}),`warning`);continue}let s=`upload_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,c={id:s,fileName:t.name,progress:0,type:`upload`,status:`uploading`};i.push(c),F(e=>[...e,c]),i.length>0&&I.open();try{(await v.publishFile(t,r)).alreadyExists?(F(e=>e.map(e=>e.id===s?{...e,status:`completed`}:e)),e(H(`app.fileAlreadyExists`,{fileName:t.name}),`warning`)):F(e=>e.map(e=>e.id===s?{...e,progress:100,status:`completed`}:e))}catch(n){F(e=>e.map(e=>e.id===s?{...e,status:`error`}:e)),e(await xe(n,H(`app.publishFailedWithFile`,{fileName:t.name}),H,t.name),`error`)}}setTimeout(()=>{F(e=>e.filter(e=>e.status!==`completed`&&e.status!==`error`&&e.status!==`cancelled`))},3e3),q()},mt=k?Me(k.cid,k.fileName):``,ht=k?Ne(k.cid,k.fileName):``,gt=()=>{mt&&Ge(mt)},_t=()=>{ht&&qe(ht)},[Y,vt]=(0,y.useState)(!1),X=Ve.trim(),Z=M?.status===`success`&&M.link===X,yt=()=>{Be.close(),N(null)},bt=e=>{j(e.target.value),N(null)},xt=async()=>{let t=Ce(X,H);if(t){N({status:`error`,link:X,message:t}),e(t,`warning`);return}if(!(P||Y)&&K()&&G()){He(!0),N(null);try{let t=await v.checkDownload(X);N({status:`success`,link:X,message:t.alreadyExists?H(`app.fileAlreadyLocal`,{fileName:t.fileName}):H(`app.fileAvailable`,{fileName:t.fileName})}),e(t.alreadyExists?H(`app.fileAlreadyExists`,{fileName:t.fileName}):H(`app.toast.checkPassed`),t.alreadyExists?`warning`:`success`)}catch(t){let n=await Se(t);N({status:`error`,link:X,message:n}),e(n,`error`)}finally{He(!1)}}},St=async()=>{if(!r){a(),e(H(`app.toast.signInBeforeDownload`),`warning`);return}if(!G())return;let t=Ce(X,H);if(t){e(t,`warning`);return}if(!Z){e(H(`app.toast.checkLinkFirst`),`warning`);return}if(!Y){vt(!0);try{let t=await v.downloadFile(X);if(j(``),N(null),yt(),t.alreadyExists)e(H(`app.fileAlreadyExists`,{fileName:t.fileName}),`warning`);else if(t.localAvailable)q();else{let n={id:t.taskId,fileName:H(`app.downloadFallbackName`),progress:0,type:`download`,status:`downloading`};F(e=>[...e,n]),I.open(),e(H(`app.toast.downloadStarted`),`info`)}}catch(t){e(await s(t,H(`app.toast.downloadFailed`)),`error`)}finally{vt(!1)}}},Ct=async t=>{if(K()&&G()&&t.type===`download`&&t.status===`downloading`){F(e=>e.map(e=>e.id===t.id?{...e,status:`cancelling`}:e));try{await v.cancelDownload(t.id)}catch(n){F(e=>e.map(e=>e.id===t.id?{...e,status:`downloading`}:e)),e(await s(n,H(`app.toast.cancelFailed`)),`error`)}}},wt=async t=>{if(K()&&G()){if(t.localAvailable===!1){e(H(`app.toast.fileNotLocal`),`warning`);return}try{(await ie({cid:t.cid,fileName:t.fileName,getFileDownloadUrl:v.getFileDownloadUrl,getRequestHeaders:o,loadFailedMessage:H(`app.toast.getFileFailed`)})).method===`picker`?e(H(`app.toast.fileSaved`),`success`):e(H(`app.toast.fileDownloaded`),`success`)}catch(t){t.name!==`AbortError`&&e(H(`app.saveFailedWithError`,{error:t.message}),`error`)}}},Tt=async t=>{if(K()&&G())try{e(H(`app.toast.startPullLocal`),`info`),await v.cacheFile(t.cid),e(H(`app.toast.pulledAndSeeding`),`success`),q()}catch(t){e(await s(t,H(`app.toast.pullFailed`)),`error`)}},Q=e=>{x(e||null),D([])};(0,y.useEffect)(()=>{if(t!==!0)return;let n=null,r=!1;return(async()=>{if(n=new WebSocket(await l(`/ws`)),r){n.close();return}n.onmessage=t=>{try{let{event:n,data:r}=JSON.parse(t.data);if(n===`publish:success`||n===`download:success`){q();let t=r.taskId||r.fileName;F(e=>e.map(e=>e.id===t||e.fileName===r.fileName?{...e,progress:100,status:`completed`}:e)),n===`download:success`&&(r.alreadyExists?e(H(`app.fileAlreadyExists`,{fileName:r.fileName}),`warning`):e(H(`app.fileDownloadCompleted`,{fileName:r.fileName}),`success`),setTimeout(()=>{F(e=>e.filter(e=>!(e.id===t&&e.status===`completed`)))},3e3))}n===`publish:progress`&&F(e=>e.map(e=>{if(r.file&&e.fileName===r.file&&e.type===`upload`){let t=50;return r.stage===`calculating-cid`?t=25:r.stage===`uploading`?t=75:r.stage===`complete`&&(t=100),{...e,progress:t}}return e})),n===`download:progress`&&F(e=>e.map(e=>e.id===r.taskId?{...e,progress:r.percent||0,loaded:r.loaded,total:r.total}:e)),n===`download:error`&&(F(e=>e.map(e=>e.id===r.taskId?{...e,status:`error`}:e)),e(H(`app.downloadFailedWithError`,{error:r.error}),`error`)),n===`download:status`&&F(e=>e.map(e=>e.id===r.taskId?{...e,fileName:r.file||e.fileName}:e)),n===`download:cancelled`&&(F(e=>e.map(e=>e.id===r.taskId?{...e,status:`cancelled`}:e)),e(H(`app.toast.downloadCancelled`),`warning`)),n===`user:metadata:updated`&&(q(),J())}catch(e){console.warn(`[App WS] Failed to parse message:`,e.message)}}})(),()=>{r=!0,n?.close()}},[t,r?.address]),(0,y.useEffect)(()=>{if(t===!0&&r){q(),J();return}t===!1&&(f([]),h([]))},[t,r?.address]),(0,y.useEffect)(()=>{r||(D([]),O(null),A(null),j(``),N(null),F([]),R(``),x(null),C(`all`))},[r?.address]);let Et=H(S===`all`?`app.nav.local`:S===`starred`?`app.nav.favorites`:`app.nav.trash`),$=S===`all`?at:S===`starred`?d.filter(e=>e.starred&&w(e.fileName).name.toLowerCase().includes(L.toLowerCase())):m.filter(e=>w(e.fileName).name.toLowerCase().includes(L.toLowerCase())),Dt=S===`starred`?[]:rt.filter(e=>e.name.toLowerCase().includes(L.toLowerCase())),Ot=Le(W,H(`app.allContent`));return(0,b.jsxs)(pe,{sidebar:({closeSidebar:e})=>(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(ve,{onNavigate:e}),(0,b.jsx)(`nav`,{className:`sidebar-nav`,children:[{id:`all`,icon:(0,b.jsx)(we,{size:18}),label:H(`app.nav.local`)},{id:`starred`,icon:(0,b.jsx)(Ee,{size:18}),label:H(`app.nav.favorites`)},{id:`trash`,icon:(0,b.jsx)(se,{size:18}),label:H(`app.nav.trash`)}].map(t=>(0,b.jsxs)(`button`,{onClick:()=>{C(t.id),x(null),D([]),R(``),e()},className:`sidebar-nav-btn ${S===t.id?`active`:``}`,children:[t.icon,(0,b.jsx)(`span`,{children:t.label})]},t.id))})]}),headerTitle:(0,b.jsx)(`h2`,{className:`header-title`,children:Et}),headerRight:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`search-box`,children:[(0,b.jsx)(me,{size:14}),(0,b.jsx)(`input`,{type:`text`,value:L,onChange:e=>R(e.target.value),placeholder:H(`app.search.placeholder`)}),L&&(0,b.jsx)(`button`,{onClick:()=>R(``),children:(0,b.jsx)(g,{size:12})})]}),S===`trash`&&m.length>0&&(0,b.jsx)(`button`,{onClick:ct,className:`btn btn-sm btn-empty-trash`,children:H(`app.emptyTrash`)}),(0,b.jsx)(`button`,{onClick:()=>I.open(),className:`btn btn-icon`,children:(0,b.jsx)(ae,{size:16})})]}),children:[S===`all`&&(0,b.jsxs)(`div`,{className:`action-grid`,children:[(0,b.jsxs)(`div`,{className:`action-card upload ${Fe?`drag-over`:``}`,onDragOver:e=>{e.preventDefault(),T(!0)},onDragLeave:()=>T(!1),onDrop:e=>{e.preventDefault(),T(!1),!(!K()||!G())&&pt(e.dataTransfer.files)},children:[(0,b.jsx)(`input`,{type:`file`,multiple:!0,onClick:e=>{(!K()||!G())&&e.preventDefault()},onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,pt(t)},className:`action-card-input`}),(0,b.jsx)(he,{size:20,className:`action-grid-icon`}),(0,b.jsx)(`p`,{children:H(`app.publishFile`)})]}),(0,b.jsxs)(`div`,{className:`action-card action-card-download`,onClick:()=>{!K()||!G()||Be.open()},children:[(0,b.jsx)(le,{size:20,className:`action-grid-icon`}),(0,b.jsx)(`p`,{children:H(`app.downloadFile`)})]})]}),S===`all`&&(0,b.jsx)(`div`,{className:`breadcrumb`,children:W?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`button`,{onClick:()=>Q(``),children:H(`app.allContent`)}),Ot.slice(1).map((e,t)=>(0,b.jsxs)(y.Fragment,{children:[(0,b.jsx)(oe,{size:12}),(0,b.jsx)(`button`,{onClick:()=>Q(e.path),className:t===Ot.length-2?`current`:``,children:(0,b.jsx)(`span`,{translate:`no`,children:e.name})}),t===Ot.length-2&&(0,b.jsx)(`button`,{onClick:()=>ft(e),className:`breadcrumb-edit-btn`,children:(0,b.jsx)(re,{size:12})})]},e.path))]}):null}),(0,b.jsxs)(`div`,{className:`content-grid`,children:[S===`trash`&&($.length===0?(0,b.jsxs)(`div`,{className:`empty-state app-empty-state`,children:[(0,b.jsx)(`p`,{children:H(L?`app.noMatches`:`app.trashEmpty`)}),(0,b.jsx)(te,{label:H(`app.openFileNavigation`)})]}):(0,b.jsx)(`div`,{className:`file-grid`,children:$.map(e=>(0,b.jsxs)(`div`,{onClick:()=>D(t=>t.includes(e.cid)?t.filter(t=>t!==e.cid):[...t,e.cid]),onDoubleClick:()=>st(e.cid),className:`card ${E.includes(e.cid)?`selected`:``}`,children:[(0,b.jsx)(`div`,{className:`card-icon trash`,children:(0,b.jsx)(ue,{size:24,color:`#fff`})}),(0,b.jsx)(`p`,{className:`card-name`,translate:`no`,children:w(e.fileName).name}),(0,b.jsx)(`p`,{className:`card-date`,children:H(`app.deletedOn`,{date:tt(e.deletedAt)})})]},e.cid))})),S!==`trash`&&($.length===0&&Dt.length===0?(0,b.jsxs)(`div`,{className:`empty-state app-empty-state`,children:[(0,b.jsx)(`p`,{children:H(L?`app.noMatches`:S===`starred`?`app.noFavorites`:`app.noLocalFiles`)}),(0,b.jsx)(te,{label:H(`app.openFileNavigation`)})]}):(0,b.jsxs)(`div`,{className:`file-grid`,children:[Dt.map(e=>(0,b.jsx)(Ae,{folder:e,onClick:()=>Q(e.path)},e.path)),$.map(t=>(0,b.jsx)(ke,{file:t,isSelected:E.includes(t.cid),onSelect:ot,onPreview:t=>{if(t.localAvailable===!1){e(H(`app.toast.fileNotLocal`),`warning`);return}O({...t,subtype:p(t.fileName)})}},t.cid))]}))]}),z&&(0,b.jsx)(_e,{title:z.title,message:z.message,confirmText:z.confirmText,danger:z.danger,onConfirm:z.onConfirm,onClose:()=>B(null)}),V&&(0,b.jsx)(ge,{title:V.title,placeholder:V.placeholder,defaultValue:V.defaultValue,confirmText:V.confirmText,isLoading:Qe,onConfirm:V.onConfirm,onClose:()=>Ze(null)}),Ye&&(0,b.jsx)(je,{items:E.map(e=>d.find(t=>t.cid===e)).filter(Boolean),allFolders:nt.map(e=>({path:e,name:e.split(`/`).pop()})),currentPath:W,onMove:dt,onClose:()=>Xe.close()}),k&&(0,b.jsx)(_,{onClose:()=>A(null),children:(0,b.jsxs)(`div`,{className:`share-modal`,onClick:e=>e.stopPropagation(),children:[(0,b.jsxs)(`div`,{className:`modal-header`,children:[(0,b.jsx)(`h3`,{children:H(`app.shareLink`)}),(0,b.jsx)(`button`,{onClick:()=>A(null),className:`btn btn-icon`,children:(0,b.jsx)(g,{size:18})})]}),(0,b.jsxs)(`div`,{className:`share-link-list`,children:[(0,b.jsxs)(`div`,{className:`share-link-box`,children:[(0,b.jsxs)(`div`,{className:`share-link-content`,children:[(0,b.jsx)(`span`,{className:`share-link-label`,children:H(`app.shareMostLink`)}),(0,b.jsx)(`div`,{className:`share-link-text`,translate:`no`,children:mt})]}),(0,b.jsx)(`button`,{type:`button`,"aria-label":H(`app.copyMostShareLink`),onClick:gt,className:`btn btn-circle btn-primary ${Ke?`copied`:``}`,children:Ke?(0,b.jsx)(u,{size:18}):(0,b.jsx)(ce,{size:18})})]}),(0,b.jsxs)(`div`,{className:`share-link-box`,children:[(0,b.jsxs)(`div`,{className:`share-link-content`,children:[(0,b.jsx)(`span`,{className:`share-link-label`,children:H(`app.shareWebLink`)}),(0,b.jsx)(`div`,{className:`share-link-text`,translate:`no`,children:ht})]}),(0,b.jsx)(`button`,{type:`button`,"aria-label":H(`app.copyWebShareLink`),onClick:_t,className:`btn btn-circle btn-primary ${Je?`copied`:``}`,children:Je?(0,b.jsx)(u,{size:18}):(0,b.jsx)(ce,{size:18})})]})]}),(0,b.jsx)(`div`,{className:`share-storage-note`,children:(0,b.jsx)(`span`,{children:H(`app.shareSeedNote`)})})]})}),ze&&(0,b.jsx)(_,{onClose:yt,children:(0,b.jsxs)(`div`,{className:`download-modal`,onClick:e=>e.stopPropagation(),children:[(0,b.jsxs)(`div`,{className:`modal-header`,children:[(0,b.jsx)(`h3`,{children:H(`app.downloadFile`)}),(0,b.jsx)(`button`,{onClick:yt,className:`btn btn-icon`,children:(0,b.jsx)(g,{size:18})})]}),(0,b.jsxs)(`div`,{className:`download-link-row`,children:[(0,b.jsx)(`input`,{type:`text`,className:`input`,value:Ve,onChange:bt,placeholder:H(`app.downloadLink.placeholder`)}),(0,b.jsxs)(`button`,{type:`button`,onClick:xt,disabled:!X||P||Y,className:`btn btn-secondary download-check-btn`,children:[P?(0,b.jsx)(de,{size:14,className:`spin`}):Z?(0,b.jsx)(u,{size:14}):(0,b.jsx)(me,{size:14}),H(P?`app.checking`:Z?`app.passed`:`app.check`)]})]}),M&&(0,b.jsxs)(`div`,{className:`download-check-status ${M.status}`,children:[M.status===`success`?(0,b.jsx)(u,{size:14}):(0,b.jsx)(Te,{size:14}),(0,b.jsx)(`span`,{children:M.message})]}),(0,b.jsxs)(`button`,{onClick:St,disabled:!Z||Y||P,className:`btn btn-info btn-full`,children:[Y?(0,b.jsx)(de,{size:14,className:`spin`}):(0,b.jsx)(le,{size:14}),H(Y?`app.downloading`:`app.startDownload`)]})]})}),Re&&(0,b.jsx)(ne,{item:Re,isBackendReady:U,getFileDownloadUrl:v.getFileDownloadUrl,onSaveAs:wt,onClose:()=>O(null)}),E.length>0&&(0,b.jsxs)(`div`,{className:`batch-bar`,children:[(0,b.jsx)(`span`,{className:`batch-info`,children:H(`app.selectedItems`,{count:E.length})}),(0,b.jsx)(`button`,{onClick:()=>D([]),className:`batch-dismiss`,children:(0,b.jsx)(g,{size:16})}),(0,b.jsx)(`div`,{className:`batch-divider`}),S===`trash`?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`button`,{onClick:async()=>{K()&&G()&&(await Promise.all(E.map(e=>v.restoreTrashFile(e))),D([]),e(H(`app.toast.restored`),`success`),q(),J())},className:`btn btn-sm`,children:H(`app.restore`)}),(0,b.jsx)(`button`,{onClick:ut,className:`btn btn-sm btn-danger`,children:H(`app.permanentDelete`)})]}):(0,b.jsxs)(b.Fragment,{children:[E.length===1&&(()=>{let e=d.find(e=>e.cid===E[0]);return e&&p(e.fileName)!==`file`})()&&(0,b.jsx)(`button`,{onClick:()=>{let t=d.find(e=>e.cid===E[0]);if(t){if(t.localAvailable===!1){e(H(`app.toast.fileNotLocal`),`warning`);return}let n=p(t.fileName);O({...t,subtype:n})}},className:`btn btn-sm`,children:H(`app.preview`)}),(0,b.jsx)(`button`,{onClick:()=>{let e=E.some(e=>{let t=d.find(t=>t.cid===e);return t&&!t.starred});E.forEach(t=>{let n=d.find(e=>e.cid===t);n&&(e?!n.starred:n.starred)&<(t)})},className:`btn btn-sm btn-star`,children:H(`app.favorite`)}),E.length===1&&(0,b.jsx)(`button`,{onClick:()=>{let e=d.find(e=>e.cid===E[0]);e&&ft(e)},className:`btn btn-sm`,children:H(`app.rename`)}),(0,b.jsx)(`button`,{onClick:()=>Xe.open(),className:`btn btn-sm btn-move`,children:H(`app.move`)}),(0,b.jsx)(`button`,{onClick:ut,className:`btn btn-sm btn-danger`,children:H(`app.delete`)}),E.length===1&&(()=>{let e=d.find(e=>e.cid===E[0]);return e&&e.localAvailable===!1})()&&(0,b.jsx)(`button`,{onClick:()=>{let e=d.find(e=>e.cid===E[0]);e&&Tt(e)},className:`btn btn-sm`,children:H(`app.pullToLocal`)}),E.length===1&&(0,b.jsx)(`button`,{onClick:()=>A(d.find(e=>e.cid===E[0])),className:`btn btn-sm`,children:H(`app.share`)}),E.length===1&&(0,b.jsx)(`button`,{onClick:()=>{let e=d.find(e=>e.cid===E[0]);e&&wt(e)},className:`btn btn-sm`,children:H(`app.saveAs`)})]})]}),We&&(0,b.jsx)(_,{onClose:()=>I.close(),children:(0,b.jsxs)(`div`,{className:`transfer-modal`,onClick:e=>e.stopPropagation(),children:[(0,b.jsxs)(`div`,{className:`modal-header`,children:[(0,b.jsx)(`h3`,{children:H(`app.transfers`)}),(0,b.jsx)(`button`,{onClick:()=>I.close(),className:`btn btn-icon`,children:(0,b.jsx)(g,{size:18})})]}),Ue.length===0?(0,b.jsx)(`div`,{className:`empty-transfer`,children:H(`app.noTransfers`)}):Ue.map(e=>(0,b.jsxs)(`div`,{className:`transfer-item`,children:[(0,b.jsxs)(`div`,{className:`transfer-item-header`,children:[e.type===`upload`?(0,b.jsx)(he,{size:14}):(0,b.jsx)(le,{size:14}),(0,b.jsx)(`span`,{className:`transfer-item-name`,translate:`no`,children:e.fileName}),e.status===`downloading`&&e.type===`download`&&(0,b.jsx)(`button`,{onClick:()=>Ct(e),className:`transfer-item-cancel`,children:(0,b.jsx)(g,{size:14})})]}),(0,b.jsxs)(`div`,{className:`transfer-progress-row`,children:[(0,b.jsx)(`progress`,{className:`transfer-progress-meter ${e.type===`download`?`download`:``} ${e.status===`error`?`error`:``} ${e.status===`cancelled`?`cancelled`:``}`,value:Math.max(0,Math.min(100,e.progress)),max:100,"aria-label":H(`app.transferProgress`,{fileName:e.fileName})}),(0,b.jsx)(`span`,{className:`transfer-progress-text`,children:e.status===`completed`?H(`app.completed`):e.status===`error`?H(`app.failed`):e.status===`cancelled`?H(`app.cancelled`):e.status===`cancelling`?H(`app.cancelling`):e.loaded&&e.total?`${ye(e.loaded)}/${ye(e.total)}`:`${e.progress}%`})]})]},e.id))]})})]})}var E=a(`/app/`)({component:T});export{E as Route};
|