@forsion/unit 2.13.5 → 2.13.6
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 +2 -2
- package/main.mjs +20 -4
- package/package.json +1 -1
- package/release.json +6 -5
- package/web/assets/{ArtificialView-BD1yHz1N.js → ArtificialView-DHqb9CTL.js} +1 -1
- package/web/assets/{AutomationBuilder-B09c-5Bi.js → AutomationBuilder-CzBKmOiw.js} +1 -1
- package/web/assets/{CalendarConfigView-Bd-ZDGPO.js → CalendarConfigView-Blw47NCs.js} +1 -1
- package/web/assets/CalendarSide-CFSzme3H.js +1 -0
- package/web/assets/CalendarView-B8sQfgZt.js +3 -0
- package/web/assets/{CapabilityMenu-DyHTEYLr.js → CapabilityMenu-Dzn6RbB1.js} +1 -1
- package/web/assets/{Chrome-C7F6fdDp.js → Chrome-owLewFu4.js} +1 -1
- package/web/assets/{CodeView-BGOnrGhB.js → CodeView-E18NDilX.js} +3 -3
- package/web/assets/{CtxMenuButtons-BYjrbUKS.js → CtxMenuButtons-CAiwQkOK.js} +1 -1
- package/web/assets/DashboardGridView-CBbYKcCo.js +25 -0
- package/web/assets/EventCard-D9uQe7g4.js +1 -0
- package/web/assets/{ExcalidrawCanvas-lwJCN6uB.js → ExcalidrawCanvas-BSOERegJ.js} +1 -1
- package/web/assets/{FloatingToc-DO7SH8Ku.js → FloatingToc-iK08Qpjc.js} +1 -1
- package/web/assets/GitCloneDialog-DfY0kqhP.js +1 -0
- package/web/assets/{HomepageView-CHJEhf9c.js → HomepageView-BCqFe1Ym.js} +3 -3
- package/web/assets/{ImageStudioPanels-CgVf0wiq.js → ImageStudioPanels-DdwihAkT.js} +2 -2
- package/web/assets/ImageStudioView-gJSYrmu1.js +1 -0
- package/web/assets/{InlineAiPanel-CdIPINsA.js → InlineAiPanel-CjYOW0_0.js} +1 -1
- package/web/assets/InlineFiles-3g2jMUeA.js +1 -0
- package/web/assets/{MarkdownBlock-DSItkLhu.js → MarkdownBlock-DjsGkPZ_.js} +24 -24
- package/web/assets/{ModelPill--CU3XTIQ.js → ModelPill-DgyXBsL9.js} +2 -2
- package/web/assets/MuseLibraryView-D_HBijmU.js +2 -0
- package/web/assets/{MuseView-CvsO62Fo.js → MuseView-BVDlmM6i.js} +3 -3
- package/web/assets/{PageHistoryPanel-CDh7nm78.js → PageHistoryPanel-B1EAPZeX.js} +2 -2
- package/web/assets/{PdfAnnotator-DafvjP3U.js → PdfAnnotator-bdB9evsY.js} +1 -1
- package/web/assets/{PenRow-CEy-s6SF.js → PenRow-DCOIGlfY.js} +1 -1
- package/web/assets/PluginToolCard-BXE5vA1h.js +2 -0
- package/web/assets/{ProductView-AUqnTwmQ.js → ProductView-l5Q7uBy6.js} +1 -1
- package/web/assets/{SettingsPage-B9mmkWaM.js → SettingsPage-fjxfS_Mt.js} +2 -2
- package/web/assets/{StudioGuestSurface-OOhRA8nt.js → StudioGuestSurface-360CWUwf.js} +1 -1
- package/web/assets/TodoListView-BsPt2GUU.js +1 -0
- package/web/assets/{Tooltip-DOYi44eY.js → Tooltip-CuXpWtdJ.js} +1 -1
- package/web/assets/UnifiedPage-6xbFLtXT.js +712 -0
- package/web/assets/{ViewSelectionBar-WmSWMFsR.js → ViewSelectionBar-C5FDh7fO.js} +2 -2
- package/web/assets/{appStore-DDOkzWDA.js → appStore-BskcSDl6.js} +114 -115
- package/web/assets/{arrow-up-right-BptN64d-.js → arrow-up-right-DEykpgsH.js} +1 -1
- package/web/assets/{astryxBridge-BL56QfEv.js → astryxBridge-B2IZdPvo.js} +1 -1
- package/web/assets/automationListSource-Cm09JKkK.js +1 -0
- package/web/assets/{boardSurface-CP4HNmcm.js → boardSurface-Dv-aVaUJ.js} +1 -1
- package/web/assets/{calendarNavStore-DCi7VBmM.js → calendarNavStore-FKStA7Hh.js} +1 -1
- package/web/assets/{canvasPrefs-ArsX3NFO.js → canvasPrefs-CMulOS0k.js} +1 -1
- package/web/assets/{chatBoxSurface-DRsDr-MT.js → chatBoxSurface-BR_G6cxG.js} +1 -1
- package/web/assets/{chevron-up-ChXNh14u.js → chevron-up-C_EDOZzI.js} +1 -1
- package/web/assets/{client-fKy9CWk0.js → client-DD5czSuF.js} +1 -1
- package/web/assets/{code-xml-DCCD9eCS.js → code-xml-vTB4LtTf.js} +1 -1
- package/web/assets/{codeStudioStore-BgLfCDK2.js → codeStudioStore-OswE1_s0.js} +1 -1
- package/web/assets/{contextMenuSurface-BF593l2M.js → contextMenuSurface-DqdYEGuH.js} +1 -1
- package/web/assets/{copy-plus-ClKrSgM7.js → copy-plus-CVHqDNny.js} +1 -1
- package/web/assets/create-DZWy4zBR.js +14 -0
- package/web/assets/{dashboardSurface-C6cbR3oG.js → dashboardSurface-Co4byEQm.js} +1 -1
- package/web/assets/dbStore-Bc2lC8ZI.js +2 -0
- package/web/assets/deskCapture-BfTzH2aO.js +1 -0
- package/web/assets/{diff2html-Di8qIz6O.js → diff2html-0MkNy2ws.js} +1 -1
- package/web/assets/{docx-preview-B-URZXdP.js → docx-preview-CwNWZegI.js} +1 -1
- package/web/assets/{draft-CBSW5tHx.js → draft-DTzuTatQ.js} +2 -2
- package/web/assets/{drawingStore-CGvTqqYW.js → drawingStore-BD5m2eqn.js} +1 -1
- package/web/assets/{file-down-Z913cCyQ.js → file-down-Cjo_T6By.js} +1 -1
- package/web/assets/{floatingTocSurface-DGwTiqvU.js → floatingTocSurface-D3IIVNnq.js} +1 -1
- package/web/assets/{foldActions-DGIPTmE1.js → foldActions-utwZpRrA.js} +1 -1
- package/web/assets/{folder-1OJQeDI1.js → folder-DiaFWdCg.js} +1 -1
- package/web/assets/{folder-minus-D_j1SwHu.js → folder-minus-DUEOcs12.js} +1 -1
- package/web/assets/{folder-plus-DP9sFr26.js → folder-plus-Cmhq0GcR.js} +1 -1
- package/web/assets/{gestures-ZhFAENNZ.js → gestures-Bx9M0le5.js} +1 -1
- package/web/assets/{git-branch-BMajF2cu.js → git-branch-DzGWffyD.js} +1 -1
- package/web/assets/{homeCardStatus-5R7XkxFL.js → homeCardStatus-NAk4A77P.js} +1 -1
- package/web/assets/{i18n.generated-DW_l6CkR.js → i18n.generated-D4-Wu9Wh.js} +1 -1
- package/web/assets/imageStudio-D67oElIb.js +4 -0
- package/web/assets/{index-COzdD7mZ.js → index-3VWZ1rsL.js} +1 -1
- package/web/assets/{index-bF04pF8q.js → index-58wBjkHy.js} +1 -1
- package/web/assets/{index-Cg1FWM_p.js → index-B9_zH7f5.js} +1 -1
- package/web/assets/index-BQrMYjou.js +1 -0
- package/web/assets/{index-D-ClOPbg.js → index-BWrWMYua.js} +1 -1
- package/web/assets/{index-C--E96Ul.js → index-BdLJBf4-.js} +1 -1
- package/web/assets/{index-CI2esW1X.js → index-Bf3W92Hb.js} +1 -1
- package/web/assets/{index-B8A3nKeL.js → index-BjmPaLFA.js} +1 -1
- package/web/assets/{index-BeW45J9J.js → index-Bv-vJTzF.js} +1 -1
- package/web/assets/{index-BnJguNqI.js → index-C7yb62gg.js} +1 -1
- package/web/assets/{index-CtRdzpNh.js → index-C9gBBMYv.js} +1 -1
- package/web/assets/index-CiQ59Kib.js +1 -0
- package/web/assets/{index-DfhEDV2T.js → index-CzTUjEMt.js} +1 -1
- package/web/assets/{index-BYKR7EVg.js → index-D4Qx6o3E.js} +1 -1
- package/web/assets/{index-jzlU5luC.js → index-DDBcn3UD.js} +1 -1
- package/web/assets/{index-CtCYv9bF.js → index-DEADY94l.js} +1 -1
- package/web/assets/{index-CWXpOSI2.js → index-DGTKsPAQ.js} +1 -1
- package/web/assets/{index-SpegRFQV.js → index-DRwDqvjf.js} +1 -1
- package/web/assets/{index-BDZIQnEx.js → index-DexVkoxH.js} +1 -1
- package/web/assets/{index-uhvJ8AiJ.js → index-IMOhRWY8.js} +1 -1
- package/web/assets/{index-Dr6YmrrT.js → index-XjvpYHIo.js} +1 -1
- package/web/assets/{index-fDB1l4d-.js → index-YuejkHoJ.js} +51 -37
- package/web/assets/{index-CVLDDD5Z.js → index-pH0266gX.js} +1 -1
- package/web/assets/{index-BniT-A2n.js → index-sQl_bGM_.js} +1 -1
- package/web/assets/{index-CPfmhZ3Z.js → index-vbNFy5lS.js} +1 -1
- package/web/assets/{invitePage-iOT1zBvp.js → invitePage-BT_rFfab.js} +1 -1
- package/web/assets/{ipc-SAPDwyQ4.js → ipc-8cxXGSZK.js} +1 -1
- package/web/assets/{jszip.min-B3n1FGCb.js → jszip.min-By4OI3XR.js} +1 -1
- package/web/assets/launchpad-BX4jQyF4.js +2 -0
- package/web/assets/{layout-grid-oIyIGbc5.js → layout-grid-CzxXbCDa.js} +1 -1
- package/web/assets/{linkFollow-uke1Xtit.js → linkFollow-J2c0wSgB.js} +4 -4
- package/web/assets/{listFold-BeNv2v6M.js → listFold-B_2Xqxn_.js} +1 -1
- package/web/assets/{lock-open-D2nMg0ga.js → lock-open-DVWCLSZm.js} +1 -1
- package/web/assets/{log-out-D70NCXC4.js → log-out-CdKTS7HC.js} +1 -1
- package/web/assets/{magnet-Cqmm97W8.js → magnet-BmVcZ9U4.js} +1 -1
- package/web/assets/main-CForzSFD.js +15 -0
- package/web/assets/{markdownEditorSurface-zUzFity2.js → markdownEditorSurface-Bs8FJNHu.js} +1 -1
- package/web/assets/{mediaPlayer-DB4KUvua.js → mediaPlayer-O9pVRl_k.js} +1 -1
- package/web/assets/{message-square-plus-BvUfAAZm.js → message-square-plus-CspBv9iG.js} +1 -1
- package/web/assets/{messages-GQUjmbwW.js → messages-CG7ywZ-K.js} +1 -1
- package/web/assets/{minimize-2-CMhzL6ZW.js → minimize-2-Bq4vUin-.js} +1 -1
- package/web/assets/mobileEntry-CptXQ4Ov.js +13 -0
- package/web/assets/modelPickerSurface-C0SkjaPL.js +1 -0
- package/web/assets/{nativeDownload-DsGyUSJ5.js → nativeDownload-DlnT8U-y.js} +1 -1
- package/web/assets/{nativeSheetMenu--iihXNVd.js → nativeSheetMenu-CVC51DzC.js} +1 -1
- package/web/assets/{pageStore-ys8L4rjF.css → pageStore-BC6Z18n7.css} +1 -1
- package/web/assets/{pageStore-CyvNZEYX.js → pageStore-D_fKLv-o.js} +7 -7
- package/web/assets/{pageTree-Ci2qzrs1.js → pageTree-DtDKozTg.js} +3 -3
- package/web/assets/{pen-line-DC3lbEY1.js → pen-line-ho1GgAe2.js} +1 -1
- package/web/assets/{pen-tool-DD5_N4lZ.js → pen-tool-CV-FKFEZ.js} +1 -1
- package/web/assets/{pencil--sWwxHdP.js → pencil-BgF4Kiqp.js} +1 -1
- package/web/assets/{phoneList-DKRMxQHf.js → phoneList-BLVdQcXY.js} +1 -1
- package/web/assets/pluginChat-C6t6DWhY.js +2 -0
- package/web/assets/{react-b7FrqRQR.js → react-DOzedx9n.js} +1 -1
- package/web/assets/recordSurface-C9SRNjy4.js +1 -0
- package/web/assets/{redo-2-CqlqhWrI.js → redo-2-DWZTaEz-.js} +1 -1
- package/web/assets/{rotate-ccw-D8kni6Ni.js → rotate-ccw-CyZpL7MX.js} +1 -1
- package/web/assets/{selectionActions-DIq0xDm8.js → selectionActions-C2a8ImJm.js} +1 -1
- package/web/assets/selectionBarSurface-DaXlyy1s.js +1 -0
- package/web/assets/{sessionTitle-Ctp4iNKu.js → sessionTitle-BtZ1BteL.js} +1 -1
- package/web/assets/settingsPageSurface-Cg8FNZq3.js +1 -0
- package/web/assets/{sharePage-CY04XCAf.js → sharePage-vnghra3Q.js} +2 -2
- package/web/assets/{shareViewer-DweNF8Ch.js → shareViewer-CWJQHiV-.js} +1 -1
- package/web/assets/{star-B0sZEmbj.js → star-ZEpUQwnX.js} +1 -1
- package/web/assets/tableSurface-DfEdzVDn.js +1 -0
- package/web/assets/{tanguProbe-B8Qv2vcm.js → tanguProbe-BboOas-a.js} +6 -6
- package/web/assets/{terminalView-BLGdmdl7.js → terminalView-xp8ARBLi.js} +1 -1
- package/web/assets/{type-Dt7RNB9g.js → type-CMyP4cKt.js} +1 -1
- package/web/assets/{undo-2-QimgpLBn.js → undo-2-C4ZCsMsx.js} +1 -1
- package/web/assets/{unitAccount-DL3jfd84.js → unitAccount-DNxfGo3c.js} +1 -1
- package/web/assets/{unitBridge-BSsCy1zP.js → unitBridge-Bq0n1ZM6.js} +1 -1
- package/web/assets/{unitCloudTransport-CI_6H0TU.js → unitCloudTransport-CErylgEO.js} +1 -1
- package/web/assets/{unitOwnerAccess-CiQ7nD7E.js → unitOwnerAccess-7s-3dfNM.js} +1 -1
- package/web/assets/{unitShim-Dl2ksNp-.js → unitShim-BfheyIG8.js} +3 -3
- package/web/assets/{upload-Dy7svciS.js → upload-VtCrluEO.js} +1 -1
- package/web/assets/userSpaces-BpeYjLni.js +1 -0
- package/web/assets/viewportLock-cVUalJAI.js +738 -0
- package/web/assets/{zoom-in-DDEtY_Go.js → zoom-in-C7R8s9x-.js} +1 -1
- package/web/index.html +2 -2
- package/web/assets/CalendarSide-B0RVbOsg.js +0 -1
- package/web/assets/CalendarView-BHio-n_r.js +0 -3
- package/web/assets/DashboardGridView-CR-R_qV8.js +0 -25
- package/web/assets/EventCard-QyYorE1_.js +0 -1
- package/web/assets/GitCloneDialog-CbW-RJak.js +0 -1
- package/web/assets/ImageStudioView-4WcX0_V4.js +0 -1
- package/web/assets/InlineFiles-CAIyTk1n.js +0 -1
- package/web/assets/MuseLibraryView-PlS7HAlV.js +0 -2
- package/web/assets/PluginToolCard-DCzLhsCA.js +0 -2
- package/web/assets/TodoListView-BkgMe44I.js +0 -1
- package/web/assets/UnifiedPage-s7-tDSwG.js +0 -712
- package/web/assets/automationListSource-B1jz6q0t.js +0 -1
- package/web/assets/create-DYmVT68X.js +0 -14
- package/web/assets/dbStore-BIG5Mfh2.js +0 -1
- package/web/assets/deskCapture-q-jRDIcc.js +0 -1
- package/web/assets/imageStudio-DC_syDtx.js +0 -4
- package/web/assets/index-CIKPZc3Q.js +0 -1
- package/web/assets/index-CmsN2Zm2.js +0 -1
- package/web/assets/launchpad-CcmSwlJl.js +0 -2
- package/web/assets/main-B9aT0WXG.js +0 -15
- package/web/assets/mobileEntry-BnHzrdoC.js +0 -13
- package/web/assets/modelPickerSurface-Dtz40Ae2.js +0 -1
- package/web/assets/pluginChat-82zZt47Y.js +0 -2
- package/web/assets/recordSurface-vUX25Z8R.js +0 -1
- package/web/assets/selectionBarSurface-B94e5JW_.js +0 -1
- package/web/assets/settingsPageSurface-C9TA3mJg.js +0 -1
- package/web/assets/tableSurface-CSBYBw5P.js +0 -1
- package/web/assets/userSpaces-oMHIWgYe.js +0 -1
- package/web/assets/viewportLock-BZq5PTeN.js +0 -738
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as I,t as k,r as w,j as u,u as F}from"./index-YuejkHoJ.js";import{X as B,u as y,kc as H,kd as j,bu as X,aC as Y,ke as Z,kf as O,g5 as ee,kg as te,kh as ne,h1 as oe,bV as b,g9 as U,dy as ae,a3 as se,L as re,ki as ie,kj as le,c7 as ce}from"./appStore-BskcSDl6.js";import{t as T,k as de,h as ue}from"./dbStore-Bc2lC8ZI.js";import{c as L}from"./react-DOzedx9n.js";import{l as he,bF as ge,ad as pe}from"./pageStore-D_fKLv-o.js";import"./client-DD5czSuF.js";I({"btw.title":{zh:"顺便问",en:"By the way"},"btw.windowTitle":{zh:"顺便问 · {title}",en:"By the way · {title}"},"btw.context":{zh:"当前对话",en:"Conversation"},"btw.hint":{zh:"带着本会话上下文提问,不会加入对话,也不打断正在跑的任务",en:"Uses this conversation as context. Not added to it, and never interrupts a running task."},"btw.sideEmpty":{zh:"打开一个对话后,可以在这里顺便问",en:"Open a conversation to ask side questions here"},"btw.empty":{zh:"问点与当前对话有关的事:概念、代码、刚才那步为什么这么做……",en:"Ask about anything in this conversation: a concept, some code, why a step was taken…"},"btw.placeholder":{zh:"顺便问点什么…",en:"Ask a side question…"},"btw.defaultQuestion":{zh:"解释一下这段",en:"Explain this"},"btw.send":{zh:"发送",en:"Send"},"btw.stop":{zh:"停止",en:"Stop"},"btw.clear":{zh:"清空旁聊",en:"Clear side chat"},"btw.copy":{zh:"复制",en:"Copy"},"btw.copied":{zh:"已复制",en:"Copied"},"btw.quoteToChat":{zh:"带回这里",en:"Bring back"},"btw.quoted":{zh:"已带回输入框",en:"Brought back to the chat box"},"btw.removeQuote":{zh:"移除引用",en:"Remove quote"},"btw.thinking":{zh:"思考中…",en:"Thinking…"},"btw.stopped":{zh:"已停止",en:"Stopped"},"btw.noTools":{zh:"旁聊不能用工具,上面提到的操作都没有执行。",en:"Side chats have no tools. Nothing mentioned above was run."},"btw.errCut":{zh:"连接中断,回答不完整",en:"The connection dropped before the answer finished"},"btw.errUnsupported":{zh:"当前引擎还不支持旁聊,请更新 Forsion",en:"This engine does not support side questions yet. Update Forsion."},"btw.close":{zh:"关闭",en:"Close"},"btw.selectionAction":{zh:"顺便问",en:"Ask aside"},"btw.cmd":{zh:"顺便问(旁聊)",en:"Ask a side question"}});const m=new Map,v=new Set,N=new Set,x=new Map;let fe=0;function $e(e){return N.has(e.nonce)?!1:(N.add(e.nonce),!0)}function Ie(e,n){return!!e&&(!e.scope||e.scope===n)}function Fe(e){const n=a=>typeof e?.[a]=="string"&&e[a]?e[a]:void 0,t=n("sessionId"),o=n("nonce");return t&&o?{sessionId:t,nonce:o,scope:n("scope"),title:n("title"),quote:n("quote"),question:n("question"),modelId:n("modelId"),messageId:n("messageId"),asideId:n("asideId")}:null}const me=L((e,n)=>({threads:{},webOpen:null,compose:{},anchors:{},saved:{},setCompose:(t,o)=>e(a=>({compose:{...a.compose,[t]:{...a.compose[t]??{draft:""},...o}}})),loadSaved:(t,o)=>{!o&&(v.has(t)||n().saved[t])||(v.add(t),j(T(t),t).then(a=>e(r=>({saved:{...r.saved,[t]:a}}))).catch(()=>{}).finally(()=>v.delete(t)))},applySeed:(t,o)=>{const a=t.sessionId;if(m.has(a)){x.set(a,t);return}const r=n().anchors[a]||{};if(t.asideId){if(r.asideId===t.asideId)return;const d=n().saved[a]?.find(i=>i.id===t.asideId);if(!d){o||j(T(a),a).then(i=>{e(l=>({saved:{...l.saved,[a]:i}})),n().applySeed(t,!0)}).catch(()=>{});return}const g=d.turns.map((i,l)=>({id:`${d.id}-${l}`,question:i.question,quote:i.quote,answer:i.answer,status:"done"}));e(i=>({threads:{...i.threads,[a]:g},anchors:{...i.anchors,[a]:{asideId:d.id,messageId:d.message_id||void 0}}}));return}t.messageId&&t.messageId!==r.messageId&&e(d=>({threads:{...d.threads,[a]:[]},anchors:{...d.anchors,[a]:{messageId:t.messageId}}}))},ask:async(t,o,a,r)=>{if(!o.trim()||m.has(t))return;const d=n().threads[t]||[],g=`btw-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`,i=s=>e(c=>({threads:{...c.threads,[t]:(c.threads[t]||[]).map(f=>f.id===g?{...f,...s(f)}:f)}}));e(s=>({threads:{...s.threads,[t]:[...d,{id:g,question:o,quote:a,answer:"",status:"streaming"}]}}));const l=new AbortController;m.set(t,l);const p=d.filter(s=>s.status==="done"&&s.answer).slice(-20).map(s=>({question:s.question,quote:s.quote,answer:s.answer})),h=n().anchors[t]||{};try{await we(t,{question:o,quote:a,thread:p,model_id:r||void 0,message_id:h.messageId,aside_id:h.asideId},s=>{s.type==="delta"?i(c=>({answer:c.answer+String(s.text??"")})):s.type==="done"?(i(c=>({answer:String(s.content||c.answer),status:"done",toolCallText:!!s.toolCallText})),s.asideId&&(e(c=>({anchors:{...c.anchors,[t]:{messageId:s.asideMessageId||c.anchors[t]?.messageId,asideId:s.asideId}}})),n().loadSaved(t,!0))):s.type==="error"&&i(()=>({status:"error",error:P(String(s.error||""))}))},l.signal),i(s=>s.status==="streaming"?{status:"error",error:k("btw.errCut")}:{})}catch(s){i(c=>c.status!=="streaming"?{}:l.signal.aborted?{status:"stopped"}:{status:"error",error:P(String(s?.message||s))})}finally{m.get(t)===l&&m.delete(t);const s=x.get(t);s&&!m.has(t)&&(x.delete(t),n().applySeed(s))}},stop:t=>m.get(t)?.abort(),clear:t=>{m.get(t)?.abort(),m.delete(t);const{asideId:o,messageId:a}=n().anchors[t]||{};e(r=>({threads:{...r.threads,[t]:[]},anchors:{...r.anchors,[t]:{messageId:a}}})),o&&(e(r=>({saved:{...r.saved,[t]:(r.saved[t]||[]).filter(d=>d.id!==o)}})),H(T(t),t,o).catch(()=>{}))},closeWeb:()=>e({webOpen:null})})),P=e=>/token_quota_exceeded/i.test(e)?k("chat.err.quota"):e;async function we(e,n,t,o){const a=T(e);let r;try{r=await de(a,`/agent/sessions/${encodeURIComponent(e)}/aside`,{method:"POST",signal:o,body:JSON.stringify({...n,app_id:Y,client:X()})})}catch(l){if(a.via==="unit"&&!o.aborted){const p=Z(l);throw new Error(O(a,p,l?.code)||String(l?.message||l))}throw l}if(!r.ok||!r.body){const l=await r.text().catch(()=>"");let p="",h,s=null;try{s=JSON.parse(l),p=String(s?.detail||"");const c=s?.code;h=typeof c=="string"?c:void 0}catch{}if(a.via==="unit"){const c=ee(r.status,{code:h});te(a.key,c,ne(s));const f=O(a,c,h,s);if(f&&c!=="fatal")throw new Error(f)}throw new Error(p||(r.status===404?k("btw.errUnsupported"):`HTTP ${r.status}`))}const d=r.body.getReader(),g=new TextDecoder;let i="";for(;;){const{done:l,value:p}=await d.read();if(l)break;i+=g.decode(p,{stream:!0});const h=i.split(`
|
|
2
|
+
`);i=h.pop()||"";for(const s of h)if(s.startsWith("data:"))try{t(JSON.parse(s.slice(5)))}catch{}}}function Be(e){const n=B()==="main"?y.getState().activeId:null,t={...e,title:e.title||void 0,scope:n,nonce:`${Date.now().toString(36)}-${++fe}`};if(n&&!window.tangu?.mobile){oe.getState().open(n,{id:`aside:${e.sessionId}`,title:k("btw.title"),aside:t});return}const o=window.tangu;if(o?.openFloatingPanel){o.openFloatingPanel({id:`btw:${e.sessionId}`,title:k("btw.windowTitle",{title:e.title||k("btw.title")}),builtin:"btw",params:{...t},...n?{sessionId:n}:{}});return}me.setState({webOpen:t})}function be(e){const n=e.trim().slice(0,2e4);if(!n)return;if(B()!=="main"&&window.tangu?.requestMainAction){window.tangu.requestMainAction("chat-quote",n);return}const t=he.getState(),o=t.rightVisible&&t.rightTabs.some(a=>a.type==="chat-panel"&&a.active);y.getState().setPendingChatQuote(o?"chat-panel":"chat",n),o||t.openView("chat",{followActive:!0,reuseKey:"primary"},"main")}function ye(e,n,t,o){return e.find(a=>a.item.tool===o&&(n.find(r=>r.id===a.pluginId)?.bundle?.enginePlugins??[]).some(r=>t[r]?.includes(o)))}const ke=e=>e.done&&!e.isError&&!e.parked&&e.result!==void 0,R=L(()=>({byEngine:{}}));let C=null,E=!1;function S(){return C?(E=!0,C):(C=(async()=>{let e={};try{if(await U()?.waitBackend?.(15e3)){const t=await ae(ue());e=Object.fromEntries(t.filter(o=>o.enabled&&o.active!==!1&&o.tools?.length).map(o=>[o.id,o.tools]))}}catch(n){console.warn("[amadeus] 拉引擎插件名下工具失败",n)}finally{R.setState({byEngine:e}),C=null,E&&(E=!1,S())}})(),C)}const Se=1e4;let A=0,_=!1;function Ce(){if(_)return;_=!0;let e;b.subscribe((n,t)=>{n.toolResultRenderers===t.toolResultRenderers||!n.toolResultRenderers.length||(clearTimeout(e),e=setTimeout(()=>{S()},300))}),U()?.subscribeReady?.(()=>{b.getState().toolResultRenderers.length&&S()}),b.getState().toolResultRenderers.length&&S()}function V(e,n,t,o){if(!ke(o))return;const a=ye(e,n,t,o.name);return!a&&e.some(r=>r.item.tool===o.name)&&Date.now()-A>Se&&(A=Date.now(),S()),a}function Te(){const e=b(o=>o.toolResultRenderers),n=b(o=>o.plugins),t=R(o=>o.byEngine);return w.useEffect(Ce,[]),w.useMemo(()=>e.length?o=>V(e,n,t,o):()=>{},[e,n,t])}function M(e){const n=b.getState();return n.toolResultRenderers.length?V(n.toolResultRenderers,n.plugins,R.getState().byEngine,e):void 0}const $=new Map;function ze(e){return{get:()=>$.get(e),set:n=>{$.set(e,n)}}}function ve(e){if(!e)return{};try{return JSON.parse(e)}catch{return e}}function J(e){try{const n=typeof e.title=="function"?e.title():e.title;return typeof n=="string"&&n.trim()||e.tool}catch{return e.tool}}I({"toolCard.openInDesk":{zh:"在 Desk 打开",en:"Open in Desk"},"toolCard.backToChat":{zh:"收回到对话",en:"Back to chat"},"toolCard.putBack":{zh:"放回对话",en:"Move back to chat"},"toolCard.showingInDesk":{zh:"正在 Desk 中显示",en:"Showing in Desk"},"toolCard.notLoaded":{zh:"这次调用的记录还没加载",en:"This call isn’t loaded yet"},"toolCard.noRenderer":{zh:"插件没在运行,先显示原始结果",en:"The plugin isn’t running. Showing the raw result."}});const W=w.createContext(null);function xe(e){return e.sessionId&&e.takesFiles&&!e.canvas&&e.width>=760&&!(e.childOpen&&e.deskOpen)?e.sessionId:null}const Ee=2e4,q=e=>y.getState().deskBySession[e]?.items??[];function D(e,n,t){const o=y.getState(),a=o.deskBySession[e],r={key:`tool:${n}`,path:"",name:t,at:Date.now(),tool:{callId:n}},d=le(q(e).filter(g=>g.tool?.callId!==n),r);o.patchDesk(e,{items:d,mode:"open",...a?.userResized?{}:{size:"half"}})}function K(e,n){const t=q(e).filter(o=>o.tool?.callId!==n);y.getState().patchDesk(e,{items:t,...t.length?{}:{mode:void 0}})}const z=new Set;async function Re(e,n){if(z.has(n)||pe==="mobile"||!ie(!!y.getState().desktopConfig?.agentDeskEnabled))return;const t=Q(e,n);if(!t)return;let o=M(t);if(!o&&b.getState().toolResultRenderers.some(a=>a.item.tool===t.name&&a.item.surface==="desk")){if(await S(),z.has(n))return;o=M(t)}!o||o.item.surface!=="desk"||(z.add(n),D(e,n,J(o.item)))}const qe=()=>z.clear();function Q(e,n){for(const t of y.getState().messagesBySession[e]||[]){const o=t.toolEvents?.find(a=>a.id===n);if(o)return o}}function De(e){const{locale:n}=F(),t=b(o=>o.plugins.find(a=>a.id===e));return t?ce(t,n):e}function G({event:e,claim:n,surface:t,onQuote:o,fallback:a}){const r=w.useRef(null),[d,g]=w.useState(null),i=w.useRef(o);i.current=o;const{item:l}=n,p=d===l;return w.useEffect(()=>{const h=r.current;if(!h)return;h.textContent="";let s;try{s=l.mount(h,{id:e.id,tool:e.name,args:ve(e.arguments),result:e.result??"",surface:t,state:ze(e.id),quote:c=>{const f=String(c??"").trim().slice(0,Ee);f&&(i.current?i.current(f):be(f))}})}catch(c){console.error(`[plugin:${n.pluginId}] 工具结果卡片挂载失败(${e.name})`,c),g(l)}return()=>{try{s?.()}catch(c){console.warn(`[plugin:${n.pluginId}] 工具结果卡片清理失败`,c)}h.textContent=""}},[l,p,e.id,e.name,e.arguments,e.result,t]),p?u.jsx(u.Fragment,{children:a}):u.jsx("div",{ref:r,className:`plugin-tool-card-body ${t}`,"data-plugin-tool-card-body":t})}function je({event:e,claim:n,onQuote:t,fallback:o}){const{t:a}=F(),r=w.useContext(W),d=y(l=>!!r&&!!l.deskBySession[r]?.items.some(p=>p.tool?.callId===e.id)),g=De(n.pluginId),i=J(n.item);return r&&d?u.jsxs("div",{className:"sketch-card plugin-tool-card is-stub","data-plugin-tool-stub":e.name,children:[u.jsx(se,{size:14,className:"plugin-tool-stub-ic"}),u.jsxs("span",{className:"plugin-tool-stub-copy",children:[u.jsx("span",{className:"plugin-tool-stub-name",children:i}),u.jsxs("span",{className:"plugin-tool-stub-meta",children:[g," · ",a("toolCard.showingInDesk")]})]}),u.jsxs("button",{type:"button",className:"plugin-tool-stub-back","data-act":"tool-card-back",onClick:()=>K(r,e.id),children:[u.jsx(re,{size:13}),a("toolCard.backToChat")]})]}):u.jsxs("div",{className:"sketch-card plugin-tool-card","data-plugin-tool-card":e.name,children:[u.jsxs("div",{className:"sketch-card-head",children:[u.jsxs("span",{className:"sketch-card-title",children:[i,u.jsxs("span",{className:"plugin-tool-card-by",children:[" · ",g]})]}),r&&u.jsx("button",{type:"button",className:"t2-iconbtn","data-act":"tool-card-desk",title:a("toolCard.openInDesk"),"aria-label":a("toolCard.openInDesk"),onClick:()=>D(r,e.id,i),children:u.jsx(ge,{size:14})})]}),u.jsx(G,{event:e,claim:n,surface:"inline",onQuote:t,fallback:o})]})}const Ue=Object.freeze(Object.defineProperty({__proto__:null,CardMount:G,PluginToolCard:je,ToolCardDeskContext:W,__resetToolCardPlacement:qe,deskItemsOf:q,findToolEvent:Q,placeLiveToolCard:Re,returnToolCardToChat:K,showToolCardInDesk:D,toolCardDeskFor:xe,useToolCardOf:Te},Symbol.toStringTag,{value:"Module"}));export{G as C,je as P,W as T,Fe as a,Ie as b,$e as c,Te as d,Ue as e,Be as o,be as q,K as r,xe as t,me as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as C,r as e,j as t}from"./index-
|
|
1
|
+
import{u as C,r as e,j as t}from"./index-YuejkHoJ.js";import{f as k,A as y,l as E,s as R}from"./pageStore-D_fKLv-o.js";import"./client-DD5czSuF.js";import{S as q}from"./StudioGuestSurface-360CWUwf.js";import{qZ as P,q_ as A,jb as I,K as z,N as F,gp as L,gq as O}from"./appStore-BskcSDl6.js";import{u as T}from"./codeStudioStore-OswE1_s0.js";/* empty css */import{C as W}from"./code-xml-vTB4LtTf.js";import"./react-DOzedx9n.js";import"./dbStore-Bc2lC8ZI.js";import"./ipc-8cxXGSZK.js";import"./nativeDownload-DlnT8U-y.js";import"./drawingStore-BD5m2eqn.js";function Y({leaf:d,params:N}){const{t:a}=C(),r=P(N),[i,u]=e.useState("loading"),[p,S]=e.useState(""),[o,f]=e.useState(null),x=e.useRef(null),v=e.useRef(null),l=e.useRef(0),b=k(s=>s.spaces.some(c=>c.id==="coding"))&&!!y("code-studio"),j=e.useCallback(async s=>{const c=window.tangu?.productsGet;if(!(!r||!c))try{const n=await c(r);s===l.current&&n&&f(n)}catch{}},[r]),m=e.useCallback(async()=>{const s=window.tangu?.productsServe;if(!r||!s){u("gone");return}const c=++l.current;u("loading");try{const n=await s(r);if(c!==l.current)return;S(n.url),f(n.product),u("ready")}catch(n){if(c!==l.current)return;const g=A(n);u(g),g==="unservable"&&j(c)}},[r,j]);e.useEffect(()=>(m(),()=>{l.current++}),[m]),e.useEffect(()=>{o&&d.setTitle(o.name)},[d,o]);const w=e.useCallback(()=>E.getState().activateLeaf(d.id),[d.id]),h=e.useCallback(s=>{R("coding"),requestAnimationFrame(()=>{T.getState().openProject(s.root,s.name)})},[]);return t.jsxs("div",{className:"art-product","data-product-view":!0,"data-product-id":r??"","data-status":i,children:[t.jsxs("div",{className:"art-bar",children:[t.jsx("span",{className:"art-bar-name",children:o?.name??a("view.product")}),t.jsx("button",{className:"btn ghost sm","data-action":"reload",title:a("artificial.product.reload"),"aria-label":a("artificial.product.reload"),disabled:i==="unservable",onClick:()=>i==="ready"?v.current?.reload():void m(),children:t.jsx(I,{size:14})}),t.jsx("button",{className:"btn ghost sm","data-action":"external",title:a("artificial.product.openExternal"),"aria-label":a("artificial.product.openExternal"),disabled:!p,onClick:()=>{window.tangu?.openExternal?.(p)},children:t.jsx(z,{size:14})}),b&&o&&t.jsx("button",{className:"btn ghost sm","data-action":"edit",title:a("artificial.action.edit"),"aria-label":a("artificial.action.edit"),onClick:()=>h(o),children:t.jsx(W,{size:14})})]}),i==="loading"&&t.jsxs("div",{className:"art-state",role:"status","data-state":"loading",children:[t.jsx(F,{size:16,className:"spin"})," ",a("artificial.product.loading")]}),i==="gone"&&t.jsx("div",{className:"art-state",role:"alert","data-state":"gone",children:t.jsx("div",{className:"art-state-title",children:a("artificial.product.gone")})}),i==="unservable"&&t.jsxs("div",{className:"art-state",role:"alert","data-state":"unservable",children:[t.jsx("div",{className:"art-state-title",children:a("artificial.product.unservable")}),t.jsx("p",{children:a("artificial.product.unservableBody")}),b&&o&&t.jsx("button",{className:"btn sm","data-action":"edit-instead",onClick:()=>h(o),children:a("artificial.action.edit")})]}),i==="error"&&t.jsxs("div",{className:"art-state",role:"alert","data-state":"error",children:[t.jsx("div",{className:"art-state-title",children:a("artificial.product.failed")}),t.jsx("button",{className:"btn sm","data-action":"retry",onClick:()=>{m()},children:a("common.retry")})]}),i==="ready"&&t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:x,className:"art-anchor"}),t.jsx(q,{anchorRef:x,onActivate:w,children:t.jsx("div",{className:"art-guest",children:t.jsx(L,{ref:s=>{v.current=s},className:"art-frame","data-product-id":r??"",src:p,partition:O,allowpopups:"true"})})})]})]})}export{Y as ProductView};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as i,a as T,j as t,u as N}from"./index-
|
|
1
|
+
import{r as i,a as T,j as t,u as N}from"./index-YuejkHoJ.js";import{ad as z,bQ as R,aj as O,a6 as D,T as $}from"./pageStore-D_fKLv-o.js";import{r as F}from"./nativeSheetMenu-CVC51DzC.js";import"./client-DD5czSuF.js";import{N as G,aW as A,I as B,bk as U,aJ as _,kl as w,aK as K,b4 as V,gZ as J,aS as Q}from"./appStore-BskcSDl6.js";T({"settingsparts.decrease":{zh:"减少",en:"Decrease"},"settingsparts.increase":{zh:"增加",en:"Increase"},"settingsparts.cancel":{zh:"取消",en:"Cancel"}});function S(){if(window.tangu?.mobile||z==="mobile")return!0;try{return window.matchMedia("(pointer: coarse) and (max-width: 820px)").matches}catch{return!1}}const f=i.createContext({alive:()=>!0,rev:0}),fe=f.Provider,h=e=>Array.isArray(e)?e.filter(s=>s!=null&&typeof s=="object"):[];function P(){const e=i.useRef(null);return i.useEffect(()=>{const s=new AbortController;return e.current=s,()=>s.abort()},[]),i.useCallback(()=>e.current?.signal,[])}function E(){const e=i.useRef(0);return[()=>++e.current,s=>s===e.current]}class C extends i.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(s){console.error("[settings] 这一项画不出来,已跳过",s)}render(){return this.state.failed?null:this.props.children}}function x(e,s){if(e())try{const a=s();return a&&typeof a.then=="function"?Promise.resolve(a).then(()=>!0,n=>(console.error("[settings] 回调失败",n),!1)):void 0}catch(a){return console.error("[settings] 回调抛错",a),Promise.resolve(!1)}}function m(e,s){const{rev:a}=i.useContext(f),[n,r]=i.useState(()=>({v:e??s,value:e,rev:a})),o=i.useCallback(l=>r(c=>({...c,v:l})),[]);if(n.rev!==a||!Object.is(n.value,e)){const l={v:e===void 0?n.v:e,value:e,rev:a};return r(l),[l.v,o]}return[n.v,o]}function y(e,s){if(typeof e!="string"||!Object.prototype.hasOwnProperty.call(w,e))return null;const a=w[e];return t.jsx(a,{width:s,height:s})}async function W(e,s,a){const n=await R({title:e.title,...e.message?{message:e.message}:{},confirm:e.confirmLabel,cancel:s,danger:e.danger??!0},a);return a?.aborted?!1:n.handled?n.value!=null:window.confirm(e.message?`${e.title}
|
|
2
2
|
|
|
3
|
-
${e.message}`:e.title)}function g({b:e,value:s,disabled:a}){const{alive:n}=i.useContext(f),{t:r}=N(),[o,l]=i.useState(!1),c=P(),d=e.kind==="primary"||e.kind==="danger"?e.kind:"ghost",p=async()=>{const
|
|
3
|
+
${e.message}`:e.title)}function g({b:e,value:s,disabled:a}){const{alive:n}=i.useContext(f),{t:r}=N(),[o,l]=i.useState(!1),c=P(),d=e.kind==="primary"||e.kind==="danger"?e.kind:"ghost",p=async()=>{const v=c();if(e.confirm&&!await W(e.confirm,r("settingsparts.cancel"),v)||v?.aborted)return;const u=x(n,()=>e.onClick(s));u&&(l(!0),u.then(()=>l(!1)))};return t.jsxs("button",{type:"button",className:`btn ${d} sm`,disabled:a||e.disabled||o,"aria-busy":o||void 0,onClick:()=>{p()},children:[y(e.icon,13),e.label]})}function Y({item:e}){const{alive:s}=i.useContext(f),[a,n]=m(e.value,!1),[r,o]=E(),l=i.useRef(e.value);return l.current=e.value,t.jsx(Q,{checked:!!a,label:e.title,disabled:e.disabled,onChange:c=>{n(c);const d=r();x(s,()=>e.onChange(c))?.then(p=>{!p&&o(d)&&n(l.current)})}})}function I(e){const{alive:s}=i.useContext(f),[a,n]=m(e.value,""),[r,o]=E(),l=i.useRef(e.value);return l.current=e.value,[a,c=>{if(c===a)return;n(c);const d=r();x(s,()=>e.onChange(c))?.then(p=>{!p&&o(d)&&n(l.current)})}]}function Z({item:e}){const[s,a]=I(e);return t.jsx("div",{className:"seg",role:"radiogroup","aria-label":e.title,children:h(e.options).map(n=>t.jsx("button",{type:"button",role:"radio","aria-checked":s===n.value,className:s===n.value?"active":void 0,disabled:e.disabled,onClick:()=>a(n.value),children:n.label},n.value))})}function q({item:e}){const[s,a]=I(e);return t.jsx("select",{value:s,"aria-label":e.title,disabled:e.disabled,onChange:n=>a(n.target.value),children:h(e.options).map(n=>t.jsx("option",{value:n.value,children:n.label},n.value))})}const H=new Set(["text","email","url","password","search"]);function X({item:e}){const{alive:s}=i.useContext(f),[a,n]=m(e.value,"");return t.jsxs("span",{className:"settings-parts-inline",children:[t.jsx("input",{type:H.has(e.inputType??"")?e.inputType:"text",value:a,placeholder:e.placeholder,"aria-label":e.title,disabled:e.disabled,onChange:r=>{const o=r.target.value;n(o),x(s,()=>e.onChange?.(o))}}),e.button&&t.jsx(g,{b:e.button,value:a,disabled:e.disabled})]})}const j=(e,s)=>typeof e=="number"&&Number.isFinite(e)?e:s;function ee({item:e}){const{alive:s}=i.useContext(f),{t:a}=N(),n=j(e.min,-1/0),r=j(e.max,1/0),o=j(e.step,1)>0?j(e.step,1):1,[l,c]=m(e.value,Number.isFinite(n)?n:0),d=p=>{const v=Math.min(r,Math.max(n,p));v!==l&&(c(v),x(s,()=>e.onChange?.(v)))};return t.jsxs("span",{className:"settings-parts-inline",children:[t.jsxs("span",{className:"settings-stepper",role:"group","aria-label":e.title,children:[t.jsx("button",{type:"button","aria-label":a("settingsparts.decrease"),disabled:e.disabled||l<=n,onClick:()=>d(l-o),children:t.jsx(J,{size:14})}),t.jsx("output",{"aria-live":"polite",children:l}),t.jsx("button",{type:"button","aria-label":a("settingsparts.increase"),disabled:e.disabled||l>=r,onClick:()=>d(l+o),children:t.jsx(D,{size:14})})]}),e.button&&t.jsx(g,{b:e.button,value:l,disabled:e.disabled})]})}function te({item:e}){const{alive:s}=i.useContext(f),[a,n]=i.useState(!1);i.useEffect(()=>{if(!a)return;const o=setTimeout(()=>n(!1),1500);return()=>clearTimeout(o)},[a]);const r=()=>{Promise.resolve().then(()=>navigator.clipboard.writeText(e.value)).then(()=>{n(!0),x(s,()=>e.onCopy?.())},o=>console.error("[settings] 复制失败",o))};return t.jsxs("span",{className:"settings-inline-actions",children:[t.jsx("code",{className:"settings-code-chip",children:e.value}),t.jsxs("button",{type:"button",className:"btn ghost sm",disabled:e.disabled,onClick:r,children:[a?t.jsx(O,{size:13}):t.jsx(V,{size:13}),e.copyLabel]})]})}function se({title:e,options:s,onPick:a,onClose:n}){return i.useEffect(()=>{const r=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[n]),t.jsx("div",{className:"mb-sheet-scrim settings-parts-sheet",onClick:n,children:t.jsxs("div",{className:"mb-sheet",role:"dialog","aria-modal":"true","aria-label":e,onClick:r=>r.stopPropagation(),style:{paddingBottom:"env(safe-area-inset-bottom)"},children:[t.jsx("div",{className:"mb-sheet-grip"}),t.jsx("div",{className:"mb-sheet-head",children:e}),s.map(r=>t.jsxs("button",{type:"button",className:"mb-sheet-row",onClick:()=>a(r.value),children:[t.jsx("span",{children:r.label}),r.detail&&t.jsx("small",{children:r.detail})]},r.value))]})})}function ne({item:e,phone:s}){const{alive:a}=i.useContext(f),[n,r]=i.useState(!1),o=i.useCallback(()=>r(!1),[]),l=P(),c=h(e.options);if(!s)return t.jsx("span",{className:"settings-inline-actions",children:c.map(u=>t.jsx(g,{b:{label:u.label,onClick:()=>e.onPick(u.value)},value:void 0,disabled:e.disabled},u.value))});const d=e.sheetTitle??e.title,p=u=>{r(!1),x(a,()=>e.onPick(u))},v=()=>{const u=l();F({title:d,sections:[{items:c.map(b=>({id:b.value,label:b.label,...b.detail?{detail:b.detail}:{},run:()=>{u?.aborted||p(b.value)}}))}]},{signal:u}).then(b=>{!b&&!u?.aborted&&r(!0)})};return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"btn ghost sm",disabled:e.disabled,"aria-haspopup":"dialog",onClick:v,children:e.button}),n&&$.createPortal(t.jsx(se,{title:d,options:c,onPick:p,onClose:o}),document.body)]})}function ae(e,s){switch(e.type){case"input":case"select":case"stepper":return"wrap";case"button":return h(e.buttons).length>1?"wrap":"inline";case"choice":return s||h(e.options).length<=1?"inline":"wrap";default:return"inline"}}function re({item:e,phone:s}){switch(e.type){case"switch":return t.jsx(Y,{item:e});case"value":return t.jsx("span",{className:"settings-value",children:e.value});case"button":return t.jsx("span",{className:"settings-inline-actions",children:h(e.buttons).map((a,n)=>t.jsx(g,{b:a,value:void 0,disabled:e.disabled},n))});case"input":return t.jsx(X,{item:e});case"segmented":return t.jsx(Z,{item:e});case"select":return t.jsx(q,{item:e});case"choice":return t.jsx(ne,{item:e,phone:s});case"stepper":return t.jsx(ee,{item:e});case"code":return t.jsx(te,{item:e});default:return null}}function ie({meters:e}){return t.jsx("div",{className:"settings-meters",children:e.map((s,a)=>{const n=Math.round(Math.min(1,Math.max(0,j(s.value,0)))*100);return t.jsxs("div",{className:"settings-meter",children:[t.jsxs("div",{className:"settings-meter-head",children:[t.jsx("span",{children:s.label}),t.jsx("strong",{children:s.valueLabel??`${n}%`})]}),t.jsx("div",{className:"settings-meter-track",role:"meter","aria-label":s.label,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n,children:t.jsx("div",{className:"settings-meter-fill",style:{width:`${n}%`}})}),s.caption&&t.jsx("small",{children:s.caption})]},a)})})}function M({state:e}){const s=e.kind==="loading",a=s?t.jsx(G,{size:20}):y(e.icon,20)??(e.kind==="error"?t.jsx(A,{size:20}):t.jsx(B,{size:20}));return t.jsx(U,{icon:a,title:e.title,description:e.desc,busy:s,actions:e.action&&t.jsx(g,{b:e.action,value:void 0})})}function oe({mount:e}){const{alive:s}=i.useContext(f),a=i.useRef(null),n=i.useRef({mount:e,alive:s});return i.useEffect(()=>{const{mount:r,alive:o}=n.current;if(!o()||typeof r!="function")return;let l;try{l=r(a.current)}catch(c){console.error("[settings] 自定义块挂载失败",c)}return()=>{if(typeof l=="function")try{l()}catch(c){console.error("[settings] 自定义块收尾失败",c)}}},[]),t.jsx("div",{ref:a,className:"settings-parts-custom"})}function L({item:e,phone:s}){switch(e?.type){case"meters":return t.jsx(ie,{meters:h(e.meters)});case"state":return e.state?t.jsx(M,{state:e.state}):null;case"custom":return t.jsx(oe,{mount:e.mount});case"switch":case"value":case"button":case"input":case"segmented":case"select":case"choice":case"stepper":case"code":return t.jsx(K,{label:e.title,description:e.desc,className:e.disabled?"is-disabled":void 0,fit:ae(e,s),control:t.jsx(re,{item:e,phone:s})});default:return null}}const k=(e,s)=>typeof e?.id=="string"&&e.id?e.id:`#${s}`;function le({group:e,phone:s}){const a=h(e.items),n=h(e.actions);return t.jsx(_,{className:"settings-panel--parts",icon:y(e.icon,16),title:e.title,description:e.desc,actions:n.length?n.map((r,o)=>t.jsx(g,{b:r,value:void 0},o)):void 0,children:a.length>0&&t.jsx("div",{className:"settings-control-list settings-parts-list",children:a.map((r,o)=>t.jsx(C,{children:t.jsx(L,{item:r,phone:s})},k(r,o)))})})}function ve({schema:e}){const[s]=i.useState(S);return e?.state?t.jsx(M,{state:e.state}):t.jsx(t.Fragment,{children:h(e?.groups).map((a,n)=>t.jsx(C,{children:t.jsx(le,{group:a,phone:s})},k(a,n)))})}function be({item:e}){const[s]=i.useState(S);return t.jsx(C,{children:t.jsx(L,{item:e,phone:s})},k(e,0))}export{ve as S,fe as a,be as b,S as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as v}from"./index-
|
|
1
|
+
import{r as v}from"./index-YuejkHoJ.js";import{U as J,T as ne,R as re}from"./pageStore-D_fKLv-o.js";const K=/^(auto|scroll|hidden|clip)$/,M=(l,p=1)=>Number.isFinite(l)&&l>0?l:p,m=l=>`${Math.round(l*1e3)/1e3}px`;function ce({anchorRef:l,enabled:p=!0,onActivate:Y,children:Q}){const[t]=v.useState(()=>{const u=document.createElement("div");return u.className="csu-guest-surface",u.setAttribute("aria-hidden","true"),u.inert=!0,Object.assign(u.style,{position:"absolute",display:"flex",flexDirection:"column",minWidth:"0",minHeight:"0",overflow:"hidden",boxSizing:"border-box",visibility:"hidden",pointerEvents:"none",zIndex:"1"}),u}),E=v.useRef(p);E.current=p;const q=v.useRef(Y);q.current=Y;const T=v.useRef(0),$=v.useRef(null);return v.useLayoutEffect(()=>{T.current++;let u=!1,b=0,r=t.parentElement,x=null,I=!1,R=!1;const n=t.ownerDocument,c=n.defaultView,o=(i,e)=>{t.style[i]!==e&&(t.style[i]=e)},f=()=>{o("visibility","hidden"),o("pointerEvents","none"),t.inert||(t.inert=!0),t.getAttribute("aria-hidden")!=="true"&&t.setAttribute("aria-hidden","true")},D=()=>{const i=t.style.visibility==="visible"&&E.current&&!I&&!n.documentElement.hasAttribute("data-dv-dragging");o("pointerEvents",i?"auto":"none"),t.inert===i&&(t.inert=!i);const e=i?"false":"true";t.getAttribute("aria-hidden")!==e&&t.setAttribute("aria-hidden",e)},y=()=>{u||!E.current||n.hidden||t.inert||t.style.visibility!=="visible"||!l.current?.isConnected||l.current.closest('[hidden], [inert], [aria-hidden="true"]')||n.documentElement.hasAttribute("data-dv-dragging")||(R=t.contains(n.activeElement),q.current?.())},G=()=>{t.contains(n.activeElement)||(R=!1)},ee=()=>{const i=l.current;if(!i?.isConnected||(r||(r=i.closest(".shell-work")??i.closest(".shell-host")??n.body,(r===n.body||c.getComputedStyle(r).position==="static")&&o("position","fixed"),r.appendChild(t),A?.observe(r)),x!==i&&(x&&A?.unobserve(x),A?.observe(i),x=i),!E.current||n.hidden||!r.isConnected))return f(),!1;const e=i.getBoundingClientRect();if(e.width<=0||e.height<=0)return f(),!1;let g=Math.max(0,e.left),C=Math.max(0,e.top),z=Math.min(c.innerWidth,e.right),O=Math.min(c.innerHeight,e.bottom),W=1,k="";I=!1;for(let s=i;s;s=s.parentElement){const d=c.getComputedStyle(s);if(s.hidden||d.display==="none"||d.visibility==="hidden"||d.visibility==="collapse")return f(),!1;(s.inert||s.getAttribute("aria-hidden")==="true")&&(I=!0),s!==r&&!s.contains(r)&&(W*=Number.parseFloat(d.opacity||"1"));const U=/\b(paint|strict|content)\b/.test(d.contain),B=U||K.test(d.overflowX||d.overflow),X=U||K.test(d.overflowY||d.overflow);if(!B&&!X)continue;const h=s.getBoundingClientRect(),V=M(h.width/s.offsetWidth),Z=M(h.height/s.offsetHeight),_=h.left+s.clientLeft*V,j=h.top+s.clientTop*Z,te=_+s.clientWidth*V,ie=j+s.clientHeight*Z;B&&(g=Math.max(g,_),z=Math.min(z,te)),X&&(C=Math.max(C,j),O=Math.min(O,ie)),!k&&B&&X&&Math.abs(h.left-e.left)<1&&Math.abs(h.top-e.top)<1&&Math.abs(h.right-e.right)<1&&Math.abs(h.bottom-e.bottom)<1&&(k=d.borderRadius)}if(z<=g||O<=C)return f(),!1;if(W<=0)return f(),!0;const S=r.getBoundingClientRect(),F=M(re(t)),H=t.style.position==="absolute",L=H?M(S.width/r.offsetWidth,F):F,w=H?M(S.height/r.offsetHeight,F):F;return o("left",m(H?(e.left-S.left)/L-r.clientLeft+r.scrollLeft:e.left/L)),o("top",m(H?(e.top-S.top)/w-r.clientTop+r.scrollTop:e.top/w)),o("width",m(e.width/L)),o("height",m(e.height/w)),o("clipPath",`inset(${m((C-e.top)/w)} ${m((e.right-z)/L)} ${m((e.bottom-O)/w)} ${m((g-e.left)/L)})`),o("borderRadius",k),o("opacity",String(W)),o("visibility","visible"),D(),!0},N=()=>{if(b=0,u)return;const i=ee(),e=t.contains(n.activeElement),g=e&&!R;R=e,g&&y(),i&&(b=c.requestAnimationFrame(N))},a=()=>{!u&&!b&&(b=c.requestAnimationFrame(N))},A=typeof ResizeObserver>"u"?null:new ResizeObserver(a),P=new MutationObserver(i=>{i.some(e=>e.target===n.documentElement&&e.attributeName==="data-dv-dragging")&&D(),i.some(e=>!t.contains(e.target))&&a()});return P.observe(n.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["style","class","hidden","inert","aria-hidden","data-dv-dragging"]}),c.addEventListener("resize",a),n.addEventListener("scroll",a,!0),n.addEventListener("visibilitychange",a),c.addEventListener(J,a),t.addEventListener("focus",y,!0),t.addEventListener("pointerdown",y,!0),n.addEventListener("focus",G,!0),$.current=()=>{E.current||f(),a()},N(),()=>{u=!0,b&&c.cancelAnimationFrame(b),A?.disconnect(),P.disconnect(),c.removeEventListener("resize",a),n.removeEventListener("scroll",a,!0),n.removeEventListener("visibilitychange",a),c.removeEventListener(J,a),t.removeEventListener("focus",y,!0),t.removeEventListener("pointerdown",y,!0),n.removeEventListener("focus",G,!0),$.current=null,f();const i=++T.current;queueMicrotask(()=>{T.current===i&&t.remove()})}},[l,t]),v.useLayoutEffect(()=>{$.current?.()},[p]),ne.createPortal(Q,t)}export{ce as S};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as t,r as l,u as xt,a as mt}from"./index-YuejkHoJ.js";import{p as K,A as ht}from"./astryxBridge-B2IZdPvo.js";import{pY as Ye,pZ as J,qa as Je,pF as kt,qi as pt,qj as ft,pG as bt,pJ as fe,qk as Pe,ql as Re,pH as gt,qm as be,qn as ie,qo as Se,mL as wt,C as Ve,qp as ge,qq as Fe,qr as He,pV as yt,K as jt,eH as vt,qs as zt,pi as Nt,qt as $t,pr as St,qu as Ct}from"./appStore-BskcSDl6.js";import{as as Ke,u as Tt,aE as Dt,aj as re,F as we,a6 as qt,aA as Mt,R as It}from"./pageStore-D_fKLv-o.js";import{r as Et,I as At,m as le,t as ce,u as Lt,c as Wt,S as Ot,a as se,D as ye,T as je}from"./draft-DTzuTatQ.js";import{E as Pt}from"./EventCard-D9uQe7g4.js";import"./client-DD5czSuF.js";import{Tooltip as Rt}from"./Tooltip-CuXpWtdJ.js";import"./dbStore-Bc2lC8ZI.js";import"./react-DOzedx9n.js";import"./ipc-8cxXGSZK.js";import"./nativeDownload-DlnT8U-y.js";import"./drawingStore-BD5m2eqn.js";import"./chevron-up-C_EDOZzI.js";function Qe({label:r,inputID:x,labelID:d,isGroupLabel:n=!1,isLabelHidden:a=!1,isDisabled:g=!1,isOptional:p=!1,isRequired:h=!1,labelIcon:f,labelTooltip:N,description:m,descriptionID:M,ref:D}){const o=p?"Optional":h?"Required":null,k=n?"span":"label",b=t.jsxs(t.Fragment,{children:[f&&Et(f,{size:"sm",color:"inherit"}),r,o&&t.jsxs("span",{className:"x1sodnla x141an7d x1ltkj2j xv1l7n4",children:[t.jsx("span",{"aria-hidden":"true",children:" ∙ "}),o]}),N&&t.jsx(Rt,{content:N,placement:"above",children:t.jsx(At,{icon:"info",size:"sm",color:"inherit"})})]});return t.jsxs(t.Fragment,{children:[t.jsx(k,{ref:D,id:d,htmlFor:n?void 0:x,...le(ce("field-label"),{0:{className:"x78zum5 x6s0dn4 xzye2dw x9ynric xcr08ib x1kq96og x1e4wzip xv1l7n4 x1ypdohk"},2:{className:"x78zum5 x6s0dn4 xzye2dw x9ynric xcr08ib x1kq96og x1e4wzip xnbbluu x1h6gzvc"},1:{className:"x78zum5 x6s0dn4 xzye2dw x9ynric xcr08ib x1kq96og x1e4wzip xv1l7n4 x1ypdohk xng3xce xzpqnlu xjm9jq1 xu96u03 xkdpibf xb3r6kr x1717udv x47corl x10l6tqk x13vifvy x87ps6o xuxw1ft x1i1rx1s"},3:{className:"x78zum5 x6s0dn4 xzye2dw x9ynric xcr08ib x1kq96og x1e4wzip xnbbluu x1h6gzvc xng3xce xzpqnlu xjm9jq1 xu96u03 xkdpibf xb3r6kr x1717udv x47corl x10l6tqk x13vifvy x87ps6o xuxw1ft x1i1rx1s"}}[!!g<<1|!!a<<0]),children:b}),m&&t.jsx("span",{id:M,...{0:{className:"x9ynric x141an7d x1ltkj2j x1sodnla xv1l7n4"},1:{className:"x9ynric x141an7d x1ltkj2j x1sodnla xv1l7n4 xng3xce xzpqnlu xjm9jq1 xu96u03 xkdpibf xb3r6kr x1717udv x47corl x10l6tqk x13vifvy x87ps6o xuxw1ft x1i1rx1s"}}[!!a<<0],children:m})]})}Qe.displayName="FieldLabel";let et=!1;typeof window<"u"&&requestAnimationFrame(()=>{et=!0});const Vt={slideDown:{kKVMdj:"x1srr2gu x1aquc0h",k44tkh:"x9uej1z",kyAemX:"x128ha8g",kWV6AL:"xskzprw",$$css:!0},slideUp:{kKVMdj:"x1dvww92 x1aquc0h",k44tkh:"x9uej1z",kyAemX:"x128ha8g",kWV6AL:"xskzprw",$$css:!0},fadeIn:{kKVMdj:"xqcmdr3 x1aquc0h",k44tkh:"x9uej1z",kyAemX:"x128ha8g",kWV6AL:"xskzprw",$$css:!0},scaleIn:{kKVMdj:"x97zbip x1aquc0h",k44tkh:"x9uej1z",kyAemX:"x128ha8g",kWV6AL:"xskzprw",$$css:!0}};function Ft(r="slideDown"){const[x]=l.useState(()=>et);return x?Vt[r]:null}const ve={base:{kMv6JI:"x9ynric",kGuDYH:"x141an7d",kLWn49:"x1ltkj2j",$$css:!0},attached:{keoZOQ:"x1c40v9y",kLKAdn:"x1ak3mig",kGO01o:"x1wesfrj",kg3NbH:"xf314gf",kqGeR4:"x14lggfu",kYm2EN:"xtufxuj",$$css:!0},detached:{keoZOQ:"xcsaf9d",k8WAf4:"xce4md1",kg3NbH:"xf314gf",kaIpWk:"xh6dtrn",$$css:!0}},Ht={warning:{kWkggS:"x24i8r5",kMwMTN:"xdhq94a",$$css:!0},error:{kWkggS:"x1pritpl",kMwMTN:"x1joocv1",$$css:!0},success:{kWkggS:"xu13z74",kMwMTN:"xltfdvo",$$css:!0}};function tt({ref:r,type:x,message:d,id:n,variant:a="attached",xstyle:g,className:p,style:h,...f}){const N=Ft("slideDown");return t.jsx("div",{ref:r,id:n,role:x==="error"?"alert":"status","aria-live":x==="error"?"assertive":"polite",...f,...le(ce("field-status",{type:x,variant:a}),K(ve.base,N,a==="attached"?ve.attached:ve.detached,Ht[x],g),p,h),children:d})}tt.displayName="FieldStatus";const Kt={x1tspnpo:"x1tspnpo",$$css:!0},st=l.createContext(null);st.displayName="CheckboxListContext";const v={container:{k1xSpc:"x78zum5",kGNEyG:"x6s0dn4",kOIVth:"x1txdalj",$$css:!0},containerLabelHidden:{kOIVth:"xxhr3t",$$css:!0},checkboxWrapper:{kVAEAm:"x1n2onr6",k1xSpc:"x78zum5",kGNEyG:"x6s0dn4",kjj79g:"xl56j7k",kmuXW:"x2lah0s",kHBbk8:"xc8icb0",$$css:!0},input:{kVAEAm:"x10l6tqk",kogj98:"x1ghz6dp",kmVPX3:"x1717udv",kSiTet:"xg01cxk",kkrTdU:"x1ypdohk",kY2c9j:"x1vjfegm",$$css:!0},inputDisabled:{kkrTdU:"x1h6gzvc",$$css:!0},checkbox:{k1xSpc:"x78zum5",kGNEyG:"x6s0dn4",kjj79g:"xl56j7k",kMzoRj:"x1litavf",ksu8eU:"x1y0btm7",kaIpWk:"xx3sua9",k1ekBW:"xts7igz",kIyJzY:"xuedmi6 x12w9bfk",kAMwcw:"xlr8y92",$$css:!0},checkboxFocus:{kI3sdo:"x1a2a7pz xkri23q",kInvED:"x81n7kt",$$css:!0},checkboxUnchecked:{kMwMTN:"xqwr325",kVAM5u:"xvy26l8 x1jtjlen",kWkggS:"x10xzikg xrsv7h",$$css:!0},checkboxChecked:{kMwMTN:"x17wrial",kVAM5u:"xad5do x1od6ugu",kWkggS:"x1ewilqj x6aeo4j",$$css:!0},checkboxDisabled:{kSiTet:"xbyyjgo",kVAM5u:"x14i3s5s xmt8yqp",$$css:!0},checkboxDisabledUnchecked:{kWkggS:"xwmxj5m x1cjfj8k",$$css:!0},checkmark:{k1xSpc:"x1s85apg",kMwMTN:"x17wrial",$$css:!0},checkmarkVisible:{k1xSpc:"x1lliihq",$$css:!0},indeterminateMark:{k1xSpc:"x1s85apg",kWkggS:"x1azo05",kaIpWk:"x1nj7uno",$$css:!0},indeterminateMarkVisible:{k1xSpc:"x1lliihq",$$css:!0}},Xe={sm:{kzqmXN:"xw4jnvo",kZKoxP:"x1qx5ct2",$$css:!0},md:{kzqmXN:"xvy4d1p",kZKoxP:"xxk0z11",$$css:!0}},Xt={sm:{kzqmXN:"x1xp8n7a",kZKoxP:"xmix8c7",$$css:!0},md:{kzqmXN:"x17z2i9w",kZKoxP:"x17rw0jw",$$css:!0}},Bt={sm:{kzqmXN:"xsmyaan",kZKoxP:"x1kpxq89",$$css:!0},md:{kzqmXN:"x6jxa94",kZKoxP:"x1v9usgg",$$css:!0}},Ut={sm:{kzqmXN:"x1fsd2vl",kZKoxP:"x36qwtl",$$css:!0},md:{kzqmXN:"xsmyaan",kZKoxP:"x36qwtl",$$css:!0}},_t={width:r=>[{kzqmXN:r!=null?"x5lhr3w":r,$$css:!0},{"--x-width":(x=>typeof x=="number"?x+"px":x??void 0)(r)}]};function Ce({label:r,isLabelHidden:x=!1,description:d,onChange:n,changeAction:a,isLoading:g=!1,value:p,isDisabled:h=!1,htmlName:f,disabledMessage:N,isReadOnly:m=!1,isOptional:M=!1,isRequired:D=!1,size:o="md",onFocus:k,onBlur:b,labelIcon:S,status:W,width:q,xstyle:Q,className:oe,style:ee,ref:ne}){const O=l.useId(),I=l.useId(),_=l.useId(),[,G]=l.useTransition(),[P,ae]=l.useOptimistic(p),X=g||P!==p,C=h&&!!N,E=l.use(st),T=h&&(C||(E?.hasDisabledMessage??!1)),z=Lt({placement:"above",focusTrigger:"always",isEnabled:C}),R=P==="indeterminate",V=P===!0,A=V||R,F=l.useCallback(w=>{w&&(w.indeterminate=R)},[R]),B=[];d&&!x&&B.push(I),W?.message&&B.push(_),C&&B.push(z.describedBy);const te=B.length>0?B.join(" "):void 0;return t.jsxs("div",{...le(ce("checkbox-input",{size:o}),K(q!=null&&_t.width(q),Q),oe,ee),children:[t.jsxs("div",{ref:w=>{z.interactionRef(w)},...K(v.container,x&&v.containerLabelHidden,!h&&Kt),children:[t.jsxs("div",{...K(v.checkboxWrapper,Xe[o]),children:[t.jsx("input",{ref:Wt(ne,F,z.positionRef),id:O,type:"checkbox",name:h?void 0:f,checked:V,disabled:h&&!T,"aria-disabled":T?"true":void 0,readOnly:m,required:D,onChange:w=>{if(h||X||m)return;const Z=w.target.checked;n?.(Z,w),a&&!w.defaultPrevented&&G(async()=>{ae(Z),await a(Z,w)})},onFocus:k,onBlur:b,"aria-readonly":m||void 0,"aria-describedby":te,"aria-invalid":W?.type==="error"?!0:void 0,"aria-busy":X||void 0,...K(v.input,Xe[o],h&&v.inputDisabled)}),t.jsx("div",{"aria-hidden":"true",...le(ce("checkbox",{size:o,checked:V?"checked":R?"indeterminate":null,disabled:h?"disabled":null}),K(v.checkbox,Xt[o],!h&&v.checkboxFocus,A?v.checkboxChecked:v.checkboxUnchecked,h&&v.checkboxDisabled,h&&!A&&v.checkboxDisabledUnchecked)),children:X?t.jsx(Ot,{size:"sm",shade:"inherit"}):t.jsxs(t.Fragment,{children:[t.jsx("svg",{viewBox:"0 0 10 10",...K(v.checkmark,Bt[o],V&&v.checkmarkVisible),children:t.jsx("path",{d:"M8.5 2.5L4 7.5L1.5 5",stroke:"currentColor",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}),t.jsx("div",{...K(v.indeterminateMark,Ut[o],R&&v.indeterminateMarkVisible)})]})})]}),t.jsx("div",{className:"x78zum5 xdt5ytf x1lsbc85",children:t.jsx(Qe,{label:r,inputID:O,isLabelHidden:x,isDisabled:h,isOptional:M,isRequired:D,labelIcon:S,description:d,descriptionID:I})})]}),W?.message&&t.jsx(tt,{type:W.type,message:W.message,id:_,variant:"detached"}),C&&z.renderTooltip(N)]})}Ce.displayName="CheckboxInput";const Be={日:0,天:0,一:1,二:2,三:3,四:4,五:5,六:6},Ue={sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6},_e="sunday|monday|tuesday|wednesday|thursday|friday|saturday|sun|mon|tues|tue|wed|thurs|thur|thu|fri|sat",ze={一:1,二:2,两:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10};function Gt(r){return/^\d+$/.test(r)?Number(r):r.startsWith("十")?10+(ze[r.slice(1)]??0):r.endsWith("十")?(ze[r[0]]??0)*10:ze[r]??NaN}function Ne(r,x,d=!1){const n=(x-r.getDay()+7)%7;return J(r,n===0&&d?7:n)}function Zt(r,x){const d=J(r,-((r.getDay()+6)%7));return J(d,7+(x+6)%7)}function Yt(r,x=new Date){const d=Ye(x);let n=` ${r} `,a=null,g=null;const p=(o,k)=>{const b=n.match(o);!b||b.index===void 0||!k(b)||(n=`${n.slice(0,b.index)} ${n.slice(b.index+b[0].length)}`)},h=(o,k,b)=>{const S=new Date(o,k-1,b);return S.getMonth()!==k-1||S.getDate()!==b?!1:(a=S,!0)},f=(o,k)=>h(d.getFullYear(),o,k)?(a<d&&h(d.getFullYear()+1,o,k),!0):!1;p(/(\d{4})-(\d{1,2})-(\d{1,2})/,o=>h(+o[1],+o[2],+o[3])),a||p(/(\d{1,2})月(\d{1,2})[日号]?/,o=>f(+o[1],+o[2])),a||p(new RegExp("(?<![\\d/:])(\\d{1,2})\\/(\\d{1,2})(?![\\d/:])"),o=>f(+o[1],+o[2])),a||p(/大后天/,()=>!!(a=J(d,3))),a||p(/后天/,()=>!!(a=J(d,2))),a||p(/明天|明日|\btomorrow\b/i,()=>!!(a=J(d,1))),a||p(/今天|今日|\btoday\b/i,()=>!!(a=d)),a||p(/下(?:个)?(?:周|星期|礼拜)([一二三四五六日天])/,o=>!!(a=Zt(d,Be[o[1]]))),a||p(/(?:周|星期|礼拜)([一二三四五六日天])/,o=>!!(a=Ne(d,Be[o[1]]))),a||p(new RegExp(`\\bnext\\s+(${_e})\\b`,"i"),o=>!!(a=Ne(d,Ue[o[1].slice(0,3).toLowerCase()],!0))),a||p(new RegExp(`\\b(?:on\\s+)?(${_e})\\b`,"i"),o=>!!(a=Ne(d,Ue[o[1].slice(0,3).toLowerCase()])));const N=(o,k)=>o&&/下午|晚上|傍晚|今晚/.test(o)&&k<12||o==="中午"&&k<11?k+12:k;if(p(/(上午|早上|早晨|中午|下午|傍晚|晚上|今晚)?\s*(\d{1,2}|[一二两三四五六七八九十]{1,3})[点點](半|(\d{1,2})分?)?/,o=>{const k=N(o[1],Gt(o[2])),b=o[3]==="半"?30:o[4]?+o[4]:0;return k>=0&&k<24&&b<60?(g=k*60+b,o[1]==="今晚"&&!a&&(a=d),!0):!1}),g===null&&p(/\b(?:at\s+)?(\d{1,2})(?::(\d{2}))?\s*(am|pm)\b/i,o=>{let k=+o[1]%12;o[3].toLowerCase()==="pm"&&(k+=12);const b=o[2]?+o[2]:0;return+o[1]>12||b>=60?!1:(g=k*60+b,!0)}),g===null&&p(new RegExp("(上午|下午|晚上)?\\s*(?:\\bat\\s+)?(?<![\\d:])(\\d{1,2}):(\\d{2})(?![\\d:])"),o=>{const k=N(o[1],+o[2]);return k>=24||+o[3]>=60?!1:(g=k*60+ +o[3],!0)}),!a&&g===null)return{title:r.trim(),value:null};const m=n.replace(/\s+/g," ").trim().replace(/^(?:at|on|by)\s+|\s+(?:at|on|by)$/i,"").trim(),M=Je(a??d,!0);if(g===null)return{title:m,value:M};const D=g;return{title:m,value:`${M}T${String(Math.floor(D/60)).padStart(2,"0")}:${String(D%60).padStart(2,"0")}`}}mt({"todolist.title":{zh:"待办",en:"To-dos"},"todolist.untitled":{zh:"未命名",en:"Untitled"},"todolist.done":{zh:"已完成",en:"Completed"},"todolist.openInNote":{zh:"在笔记中打开",en:"Open in note"},"todolist.clickToEdit":{zh:"点击编辑",en:"Click to edit"},"todolist.addPlaceholder":{zh:"新建待办,如「明天下午3点」",en:'New to-do, e.g. "tomorrow 3pm"'},"todolist.addPlaceholderShort":{zh:"新建待办",en:"New to-do"},"todolist.addTo":{zh:"加到「{name}」",en:'Adds to "{name}"'},"todolist.addTarget":{zh:"加到哪张表",en:"Add to"},"todolist.dragHint":{zh:"拖进日历排时段",en:"Drag into the calendar to schedule"},"todolist.dragHintGroups":{zh:"拖到「今天」「明天」或「未排期」上改日期",en:"Drag onto Today, Tomorrow or Unscheduled to change the date"},"todolist.allDone":{zh:"全部完成了。",en:"All done."},"todolist.emptyTitle":{zh:"还没有待办。",en:"No to-dos yet."},"todolist.emptyHintA":{zh:"在笔记里写 ",en:"Write "},"todolist.emptyExample":{zh:"- [ ] 事项 @2026-09-01",en:"- [ ] Task @2026-09-01"},"todolist.emptyHintB":{zh:"(打 ",en:" in a note (type "},"todolist.emptyHintC":{zh:" 有候选),或在上面直接加一条。",en:" for suggestions), or add one above."},"todolist.emptyHintCNoAdd":{zh:" 有候选)。",en:" for suggestions)."},"todolist.view.today":{zh:"今天",en:"Today"},"todolist.view.plan":{zh:"计划",en:"Scheduled"},"todolist.view.all":{zh:"全部",en:"All"},"todolist.viewsLabel":{zh:"筛选",en:"Filter"},"todolist.allLists":{zh:"所有清单",en:"All lists"},"todolist.noteTasks":{zh:"笔记里的任务",en:"Tasks in notes"},"todolist.filterLabel":{zh:"{view} · {list}",en:"{view} · {list}"},"todolist.mdAddHint":{zh:"笔记里的任务在笔记里写:",en:"Write tasks in a note: "},"todolist.todayDone":{zh:"今天的都做完了。",en:"Nothing left for today."},"todolist.planEmpty":{zh:"没有排了日期的待办。",en:"No scheduled to-dos."},"todolist.listEmpty":{zh:"这张清单里没有待办。",en:"No to-dos in this list."},"todolist.restItem":{zh:"{label} {n} 条",en:"{label} {n}"},"todolist.restSep":{zh:"、",en:" · "},"todolist.showAll":{zh:"看全部",en:"Show all"}});const Ge="done",Ze=480,$e="application/x-forsion-todo-md";function Jt(r){const x=a=>typeof a=="string"?a:typeof a=="number"?String(a):"",d=x(r?.src),n=x(r?.view);return{db:x(r?.db)||void 0,src:d==="db"||d==="md"?d:"all",side:r?.side===!0||r?.side==="true",view:Se.includes(n)?n:"all"}}function Qt(r){const[x,d]=l.useState(!1);return l.useLayoutEffect(()=>{const n=r.current;if(!n||typeof ResizeObserver>"u")return;d(n.offsetWidth>=Ze);const a=new ResizeObserver(([g])=>d(g.contentRect.width>=Ze));return a.observe(n),()=>a.disconnect()},[r]),x}function hs({params:r,leaf:x}={}){const d=Jt(r),{t:n}=xt(),a=kt(),g=pt(),p=l.useRef(null),h=Qt(p);l.useEffect(()=>{x?.loc==="main"&&!r?.miniSurface&&Ke("todo.open")},[]);const[f,N]=l.useState(d.view),[m,M]=l.useState({db:d.db,src:d.src}),D=e=>{N(e),x?.setParams({view:e})};l.useEffect(()=>{N(d.view)},[d.view]),l.useEffect(()=>{M(e=>e.db===d.db&&e.src===d.src?e:{db:d.db,src:d.src}),ee(null)},[d.db,d.src]);const o=e=>{M(e),ee(null),x?.setParams({db:e.db??"",src:e.src})},[k,b]=l.useState(new Set([...ft,Ge])),[S,W]=l.useState(null),[q,Q]=l.useState(""),[oe,ee]=l.useState(null),[ne,O]=l.useState(null),I=l.useRef(null),[_,G]=l.useState(null);l.useEffect(()=>{if(!_)return;const e=()=>{window.setTimeout(()=>{I.current=null,G(null),O(null)},0)};return window.addEventListener("drop",e,!0),window.addEventListener("dragend",e,!0),()=>{window.removeEventListener("drop",e,!0),window.removeEventListener("dragend",e,!0)}},[_]);const[P,ae]=l.useState(new Set),X=l.useRef(null),C=Tt(e=>e.vaultRoot)??"",E=bt(e=>e.byVault),T=l.useMemo(()=>Ye(new Date),[]),z=l.useMemo(()=>a.filter(e=>e.checkboxCol),[a]),R=l.useMemo(()=>z.filter(e=>!m.db||e.db.path===m.db),[z,m.db]),V=e=>fe(C,E,e.db.path,a.indexOf(e)),A=l.useMemo(()=>{const e=[];for(const s of z){const u=s.checkboxCol,c=fe(C,E,s.db.path,a.indexOf(s));for(const i of s.db.rows){const y=typeof i.cells[s.dateCol]=="string"?i.cells[s.dateCol]:"";e.push({key:`db:${s.db.path}:${i.rowId}`,name:i.name||n("todolist.untitled"),checked:i.cells[u]===!0,raw:y,source:s.db.name,short:s.db.name,color:c,db:s,rowId:i.rowId})}}for(const s of g.filter(u=>u.isTask))e.push({key:`md:${s.path}:${s.line}`,name:s.text,checked:s.checked,raw:s.due,source:s.heading?`${s.title} › ${s.heading}`:s.title,short:s.title,note:{path:s.path,heading:s.heading},mark:s});return e},[z,a,g,C,E,n]),F=l.useMemo(()=>A.filter(e=>e.db?m.src!=="md"&&(!m.db||e.db.db.path===m.db):m.src!=="db"&&!m.db),[A,m]),B=e=>e.checked&&!P.has(e.key),te=l.useMemo(()=>F.filter(e=>e.checked&&!P.has(e.key)),[F,P]),w=l.useMemo(()=>{const e=new Map;for(const s of F){if(B(s))continue;const u=Pe(s.raw,T),c=e.get(u);c?c.push(s):e.set(u,[s])}for(const s of e.values())s.sort((u,c)=>{const i=Re(u.raw),y=Re(c.raw);return(i===y?0:i<y?-1:1)||u.source.localeCompare(c.source,"zh")||u.name.localeCompare(c.name,"zh")});return e},[F,T,P]),Z=(e,s,u)=>{u(),s&&(Ke("todo.done"),ae(c=>new Set(c).add(e.key)),setTimeout(()=>ae(c=>{const i=new Set(c);return i.delete(e.key),i}),1e3))},ue=e=>be.reduce((s,u)=>s+(ie(e,u)?w.get(u)?.length??0:0),0),xe=ue(f),Te=e=>A.filter(s=>!s.checked&&e(s)).length,De=A.some(e=>e.mark),ot=new Set(F.map(e=>e.db?.db.path??"md")).size>1,nt=e=>b(s=>{const u=new Set(s);return u.has(e)?u.delete(e):u.add(e),u}),qe=l.useMemo(()=>{if(!S)return null;const e=z.find(c=>c.db.path===S.dbPath),s=e?.db.rows.find(c=>c.rowId===S.rowId);if(!e||!s)return null;const u=typeof s.cells[e.dateCol]=="string"?s.cells[e.dateCol]:"";return{db:e.db,row:s,colId:e.dateCol,title:s.name,raw:u,color:fe(C,E,e.db.path,a.indexOf(e))}},[S,z,a,C,E]),U=l.useMemo(()=>R.filter(e=>!e.db.readonly&&!e.db.isNoteView),[R]),L=l.useMemo(()=>{const e=gt(C,E);return U.find(s=>s.db.path===oe)??U.find(s=>s.db.path===m.db)??U.find(s=>s.db.path===e)??U[0]},[U,oe,m.db,C,E]),H=l.useMemo(()=>q.trim()?Yt(q):null,[q]),at=()=>{if(!H||!L)return;const e=H.title||q.trim();yt(L.db,L.dateCol,H.value??Je(T,!0),e),Q("")};l.useEffect(()=>{const e=s=>{if(s.key!=="n"&&s.key!=="N"||s.metaKey||s.ctrlKey||s.altKey||s.defaultPrevented||s.target?.closest("input, textarea, select, [contenteditable]"))return;const c=X.current,i=p.current;if(!c||!i||!c.getClientRects().length)return;const y=document.activeElement;(!y||y===document.body||i.contains(y)||d.side&&y.closest(".amx-cal")||!d.side&&!y.closest(".dv-react-part"))&&(s.preventDefault(),c.focus())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[d.side]);const dt=(e,s)=>{if(e.note){vt(e.note.path,e.note.heading);return}if(!e.db||!e.rowId)return;const c=(s.currentTarget.querySelector(".amx-todo-name")??s.currentTarget).getBoundingClientRect();W({dbPath:e.db.db.path,rowId:e.rowId,at:{left:c.left,top:c.top,right:c.right,bottom:c.bottom,zoom:It(s.currentTarget)||1}})},it=e=>{if(e.key==="ArrowDown"||e.key==="ArrowUp"){const s=[...p.current?.querySelectorAll(".amx-todo-reveal.is-open .amx-todo-main")??[]],u=s.indexOf(e.currentTarget),c=s[u+(e.key==="ArrowDown"?1:-1)];c&&(e.preventDefault(),c.focus())}else e.key===" "&&(e.preventDefault(),e.currentTarget.closest("li")?.querySelector('input[type="checkbox"]')?.click())},me=!!Dt?.patchMark,rt=(e,s)=>{const u=He(s,T);if(u===void 0)return;const c=zt(e.raw,u);if(e.db&&e.rowId){const i=e.db.db.rows.find(y=>y.rowId===e.rowId);i&&Nt(e.db.db,i,e.db.dateCol,e.raw,c,e.name)}else e.mark&&me&&$t(e.mark,e.raw,c,e.name)},Y=(e,s)=>!e||He(s,T)===void 0||Pe(e.raw,T)===s?!1:e.mark?me&&s!=="undated":!!(e.db&&e.rowId&&!e.db.db.readonly),Me=e=>ot?h?t.jsxs("span",{className:"amx-todo-srctag",title:e.source,children:[e.mark?t.jsx(we,{size:12}):t.jsx("i",{className:"amx-todo-dot",style:{background:e.color}}),t.jsx("span",{className:"amx-todo-srcname",children:e.short})]}):e.mark?t.jsx(we,{className:"amx-todo-srcic",size:11,"aria-label":e.source}):t.jsx("i",{className:"amx-todo-dot",style:{background:e.color},title:e.source}):null,Ie=e=>{const s=ge(e.raw,T),u=!!(d.side&&e.db&&e.rowId&&!e.db.db.readonly),c=!e.checked&&(u||Y(e,"today")||Y(e,"tomorrow")||Y(e,"undated"));return t.jsxs("li",{className:"amx-todo-item",draggable:c||void 0,title:c?n(u?"todolist.dragHint":"todolist.dragHintGroups"):void 0,onDragStart:c?i=>{I.current=e,requestAnimationFrame(()=>G(e)),e.db&&e.rowId?i.dataTransfer.setData(je,JSON.stringify({dbPath:e.db.db.path,rowId:e.rowId})):i.dataTransfer.setData($e,e.key),i.dataTransfer.effectAllowed="move",i.currentTarget.classList.add("dragging")}:void 0,onDragEnd:c?i=>{i.currentTarget.classList.remove("dragging"),I.current=null,G(null),O(null)}:void 0,onClick:i=>{i.target.closest(".amx-todo-main, .astryx-checkbox-input, .amx-todo-box")||i.currentTarget.querySelector(".amx-todo-main")?.click()},children:[e.db&&e.rowId?t.jsx(Ce,{label:e.name,isLabelHidden:!0,size:"sm",value:e.checked,onChange:i=>Z(e,i,()=>St(e.db.db,e.rowId,e.db.checkboxCol,i?!0:void 0))}):e.mark&&me?t.jsx(Ce,{label:e.name,isLabelHidden:!0,size:"sm",value:e.checked,onChange:i=>Z(e,i,()=>Ct(e.mark,{checked:i}))}):t.jsx("span",{className:`amx-todo-box${e.checked?" on":""}`,"aria-hidden":"true"}),t.jsxs("button",{className:"amx-todo-main",title:e.note?n("todolist.openInNote"):n("todolist.clickToEdit"),onClick:i=>dt(e,i),onKeyDown:it,children:[t.jsx("span",{className:`amx-todo-name${e.checked?" done":""}`,children:e.name}),e.note?t.jsx(jt,{className:"amx-todo-jump",size:12}):null]}),h&&Me(e),t.jsxs("span",{className:"amx-todo-duecell",children:[!h&&Me(e),e.raw?t.jsxs("span",{className:`amx-todo-due ${s.tone}`,children:[e.raw.includes("T")&&t.jsx(Ve,{size:11}),s.label]}):null]})]},e.key)},Ee=(e,s,u,c,i)=>{const y=!k.has(e),pe=j=>{const $=j.dataTransfer.types;return $.includes(je)||$.includes($e)},ct=(j,$)=>{if(!($.db&&$.rowId))return j.dataTransfer.getData($e)===$.key;try{const Oe=JSON.parse(j.dataTransfer.getData(je)||"{}");return Oe.dbPath===$.db?.db.path&&Oe.rowId===$.rowId}catch{return!1}},ut=i?{onDragOver:j=>{pe(j)&&Y(I.current,i)&&(j.preventDefault(),j.dataTransfer.dropEffect="move",ne!==i&&O(i))},onDragLeave:()=>O(j=>j===i?null:j),onDrop:j=>{j.preventDefault();const $=I.current;I.current=null,G(null),O(null),$&&pe(j)&&ct(j,$)&&Y($,i)&&rt($,i)}}:{};return t.jsxs("section",{className:"amx-todo-group",children:[t.jsxs("button",{className:`amx-todo-ghead${y?" is-open":""}${ne===i&&i?" is-drop":""}`,onClick:()=>nt(e),"aria-expanded":y,...ut,children:[t.jsx(Mt,{className:"amx-todo-caret",size:12}),t.jsx("span",{className:"amx-todo-gname",children:s}),t.jsx("span",{className:"amx-todo-gcount",children:u.length})]}),t.jsx("div",{className:`amx-todo-reveal${y?" is-open":""}`,children:t.jsx("div",{className:"amx-todo-reveal-in",children:c})})]},e)},de=e=>n(`todolist.view.${e}`),he=m.src==="md"?n("todolist.noteTasks"):m.db?z.find(e=>e.db.path===m.db)?.db.name??m.db:"",Ae=e=>e?t.jsx(re,{size:14}):t.jsx("span",{style:{display:"inline-block",width:14}}),Le=t.jsxs(t.Fragment,{children:[t.jsx(se,{icon:Ae(!m.db&&m.src==="all"),label:n("todolist.allLists"),onClick:()=>o({src:"all"})}),z.map(e=>t.jsx(se,{icon:m.db===e.db.path?t.jsx(re,{size:14}):t.jsx("i",{className:"amx-todo-dot amx-todo-menudot",style:{background:V(e)}}),label:e.db.name,endContent:t.jsx("span",{className:"amx-todo-menun",children:Te(s=>s.db===e)}),onClick:()=>o({db:e.db.path,src:"all"})},e.db.path)),De&&t.jsx(se,{icon:m.src==="md"?t.jsx(re,{size:14}):t.jsx(we,{size:14}),label:n("todolist.noteTasks"),endContent:t.jsx("span",{className:"amx-todo-menun",children:Te(e=>!!e.mark)}),onClick:()=>o({src:"md"})})]}),ke=z.length+(De?1:0)>1,lt=be.filter(e=>ie(f,e)&&w.get(e)?.length||Y(_,e)),We=f==="today"?be.filter(e=>!ie("today",e)&&w.get(e)?.length):[];return t.jsx(ht,{children:t.jsxs("div",{className:`amx-todo${h?" is-wide":""}`,ref:p,children:[t.jsxs("div",{className:"amx-todo-col",children:[t.jsxs("div",{className:"amx-todo-bar",children:[t.jsx("span",{className:"amx-todo-title",children:n("todolist.title")}),xe>0&&t.jsx("span",{className:"amx-todo-total",children:xe}),t.jsx("span",{className:"amx-todo-grow"}),h?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"seg seg-sm amx-todo-seg",role:"group","aria-label":n("todolist.viewsLabel"),children:Se.map(e=>t.jsxs("button",{className:f===e?"active":"","aria-pressed":f===e,onClick:()=>D(e),children:[de(e),t.jsx("em",{children:ue(e)})]},e))}),ke&&t.jsx(ye,{button:{label:he||n("todolist.allLists"),variant:"ghost",size:"sm",icon:t.jsx(wt,{size:13})},menuWidth:220,children:Le})]}):t.jsxs(ye,{button:{label:he?n("todolist.filterLabel",{view:de(f),list:he}):de(f),variant:"ghost",size:"sm"},menuWidth:220,children:[Se.map(e=>t.jsx(se,{icon:Ae(f===e),label:de(e),endContent:t.jsx("span",{className:"amx-todo-menun",children:ue(e)}),onClick:()=>D(e)},e)),ke&&t.jsx("div",{className:"amx-cal-menusep",role:"separator"}),ke&&Le]})]}),m.src==="md"?t.jsxs("div",{className:"amx-todo-addhint",children:[n("todolist.mdAddHint"),t.jsx("code",{children:n("todolist.emptyExample")})]}):L&&t.jsxs("div",{className:`amx-todo-add${q?" typing":""}`,children:[t.jsx(qt,{className:"amx-todo-addicon",size:13}),t.jsx("input",{ref:X,className:"amx-todo-addinput",placeholder:n(h?"todolist.addPlaceholder":"todolist.addPlaceholderShort"),value:q,onChange:e=>Q(e.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||(e.key==="Enter"&&(e.preventDefault(),at()),e.key==="Escape"&&(Q(""),e.currentTarget.blur()))}}),U.length>1&&t.jsx("span",{className:"amx-todo-target",children:t.jsx(ye,{button:{label:h?L.db.name:n("todolist.addTarget"),isIconOnly:!h,variant:"ghost",size:"sm",icon:t.jsx("i",{className:"amx-todo-dot",style:{background:V(L)}})},menuWidth:200,children:U.map(e=>t.jsx(se,{icon:t.jsx("i",{className:"amx-todo-dot amx-todo-menudot",style:{background:V(e)}}),label:e.db.name,endContent:e===L?t.jsx(re,{size:14}):void 0,onClick:()=>{ee(e.db.path),X.current?.focus()}},e.db.path))})}),!q&&t.jsx("kbd",{className:"amx-cal-panel-kbd",children:"N"}),H&&t.jsxs("div",{className:"amx-todo-addprev",children:[H.value&&t.jsxs("span",{className:`amx-todo-due ${ge(H.value,T).tone}`,children:[H.value.includes("T")&&t.jsx(Ve,{size:11}),ge(H.value,T).label]}),t.jsx("span",{children:n("todolist.addTo",{name:L.db.name})})]})]}),A.length===0&&t.jsxs("div",{className:"amx-todo-empty",children:[n("todolist.emptyTitle"),!r?.miniSurface&&t.jsxs(t.Fragment,{children:[t.jsx("br",{}),n("todolist.emptyHintA"),t.jsx("code",{children:n("todolist.emptyExample")}),n("todolist.emptyHintB"),t.jsx("code",{children:"@"}),n(L?"todolist.emptyHintC":"todolist.emptyHintCNoAdd")]})]}),A.length>0&&xe===0&&t.jsx("div",{className:"amx-todo-empty",children:f==="today"?n("todolist.todayDone"):f==="plan"?n("todolist.planEmpty"):F.length===0?n("todolist.listEmpty"):n("todolist.allDone")}),lt.map(e=>Ee(e,Fe[e],w.get(e)??[],t.jsx("ul",{className:"amx-todo-list",children:ie(f,e)?(w.get(e)??[]).map(Ie):null}),e)),We.length>0&&t.jsxs("div",{className:"amx-todo-rest",children:[We.map(e=>n("todolist.restItem",{label:Fe[e],n:w.get(e).length})).join(n("todolist.restSep"))," · ",t.jsx("button",{className:"amx-todo-link",onClick:()=>D("all"),children:n("todolist.showAll")})]}),f==="all"&&te.length>0&&Ee(Ge,n("todolist.done"),te,t.jsx("ul",{className:"amx-todo-list",children:te.map(Ie)}))]}),qe&&S&&t.jsx(Pt,{ev:qe,at:S.at,onClose:()=>W(null)})]})})}export{hs as TodoListView,Jt as readTodoParams};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as l,j as o}from"./index-
|
|
1
|
+
import{r as l,j as o}from"./index-YuejkHoJ.js";import{a as f}from"./astryxBridge-B2IZdPvo.js";import{u as E}from"./draft-DTzuTatQ.js";import"./appStore-BskcSDl6.js";import"./dbStore-Bc2lC8ZI.js";import"./pageStore-D_fKLv-o.js";import"./react-DOzedx9n.js";import"./client-DD5czSuF.js";import"./ipc-8cxXGSZK.js";import"./nativeDownload-DlnT8U-y.js";import"./drawingStore-BD5m2eqn.js";function N(r){return typeof r=="string"||typeof r=="number"}function p(...r){const i=r.filter(Boolean);return i.length>0?i.join(" "):void 0}function F({children:r,anchorRef:i,content:n,placement:m="above",alignment:y="center",delay:x=200,hideDelay:j=0,focusTrigger:g="auto",isEnabled:A=!0,onOpenChange:u,hasHoverIndication:b="auto",isOpen:B,isDefaultOpen:T}){const c=l.useRef(null),d=r!=null?N(r):!1,v=b===!0||b==="auto"&&d,w=l.useCallback(()=>{u?.(!0)},[u]),k=l.useCallback(()=>{u?.(!1)},[u]),e=E({placement:m,alignment:y,delay:x,hideDelay:j,focusTrigger:g,isEnabled:A,isOpen:B,isDefaultOpen:T,onShow:w,onHide:k});return f(()=>{if(!i)return;const s=i.current;if(!s)return;e.ref(s);const t=s.getAttribute("aria-describedby");return s.setAttribute("aria-describedby",p(t,e.describedBy)??""),()=>{e.ref(null),t?s.setAttribute("aria-describedby",t):s.removeAttribute("aria-describedby")}},[i,e.ref,e.describedBy]),f(()=>{if(i||d)return;const s=c.current;if(!s)return;const t=s.firstElementChild;if(!t)return;e.ref(t);const a=t.getAttribute("aria-describedby");return t.setAttribute("aria-describedby",p(a,e.describedBy)??""),()=>{e.ref(null),a?t.setAttribute("aria-describedby",a):t.removeAttribute("aria-describedby")}},[i,d,e.ref,e.describedBy]),i&&r==null?o.jsx(o.Fragment,{children:e.renderTooltip(n)}):d?o.jsxs(o.Fragment,{children:[o.jsx("span",{ref:e.ref,tabIndex:0,"aria-describedby":e.describedBy,...{0:{className:"xt0psk2"},1:{className:"xt0psk2 xujl8zx xev0dqp xycaml9 xrys4gj"}}[!!v<<0],children:r}),e.renderTooltip(n)]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{ref:c,className:"xjp7ctv",children:r}),e.renderTooltip(n)]})}F.displayName="Tooltip";export{F as Tooltip};
|