zidane-gui 9.3.1 → 9.4.0
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/out/main/chunks/{remote-hosts-B8_tzg_n.js → remote-hosts-CSiGJAfm.js} +1 -1
- package/out/main/chunks/{session-search-sql-2EUzjHAT.js → session-search-sql-D51BmAO2.js} +5 -5
- package/out/main/index.js +4397 -4086
- package/out/main/session-search-worker.js +1 -1
- package/out/preload/index.mjs +36 -2
- package/out/renderer/assets/{24BXRY42-eTlQfl4v.js → 24BXRY42-0UXaaWjY.js} +1 -1
- package/out/renderer/assets/{4FHPYW2L-BHx1bBmw.js → 4FHPYW2L-BWpHahlW.js} +1 -1
- package/out/renderer/assets/{4LWW3ZNH-D7lTurDT.js → 4LWW3ZNH-CPyJ9o9Y.js} +1 -1
- package/out/renderer/assets/{5XYWFMKW-e04QMbw9.js → 5XYWFMKW-ZZpHHfGa.js} +1 -1
- package/out/renderer/assets/{64PMEAB3-DTIFpDpU.js → 64PMEAB3-DOEnEuzl.js} +1 -1
- package/out/renderer/assets/{6BEWHPQE-BrYtHcZG.js → 6BEWHPQE-C2ZZckdj.js} +1 -1
- package/out/renderer/assets/{6PIGVMFT-CoAPPYTl.js → 6PIGVMFT-CRGq6eh3.js} +1 -1
- package/out/renderer/assets/{75JW6PN6-JbXPfJg4.js → 75JW6PN6-CYzAa9yx.js} +1 -1
- package/out/renderer/assets/{7XWI72E6-CFY3Kecs.js → 7XWI72E6-C_GZbyIF.js} +1 -1
- package/out/renderer/assets/{BGW36YJW-DhmSG9tb.js → BGW36YJW-BAwgTZ_z.js} +1 -1
- package/out/renderer/assets/{CGIZI67J-Cr9B0EmW.js → CGIZI67J-BxXITbQC.js} +1 -1
- package/out/renderer/assets/{CodeEditor-C6EJBlGG.js → CodeEditor-CLsAw7eu.js} +2 -2
- package/out/renderer/assets/{ComposerEditor-oFIdMkLB.js → ComposerEditor-BqnIn2NQ.js} +1 -1
- package/out/renderer/assets/{DNNCRC2E-CMqlK0W6.js → DNNCRC2E-kbsNJgPT.js} +1 -1
- package/out/renderer/assets/DiffsTab--BHt7StP.js +3 -0
- package/out/renderer/assets/{E67EBMDD-C_T2QnwF.js → E67EBMDD-BOeJkFNZ.js} +1 -1
- package/out/renderer/assets/{EFYWJBJK-Cbn-VZcb.js → EFYWJBJK-CFT5CQUG.js} +1 -1
- package/out/renderer/assets/{EXE5EH6O-SXdUe5We.js → EXE5EH6O-Cbj5xPKl.js} +1 -1
- package/out/renderer/assets/{EditorWorkers-bVeEZI8X.js → EditorWorkers-CXBU_HFf.js} +1 -1
- package/out/renderer/assets/{FilesTab-DtM2Q5R0.js → FilesTab-CZHD0eBx.js} +4 -4
- package/out/renderer/assets/{G6GPDDNC-XfFyRa0j.js → G6GPDDNC-Ax6dML4i.js} +1 -1
- package/out/renderer/assets/{G76NGGFM-Bj_m2WLJ.js → G76NGGFM-BxPXXNt_.js} +1 -1
- package/out/renderer/assets/{GH6G3TJC-wPRy41Zv.js → GH6G3TJC-CiCXY2r6.js} +1 -1
- package/out/renderer/assets/{HPNUA7RO-BhLNmX-t.js → HPNUA7RO-DiyW9VGu.js} +1 -1
- package/out/renderer/assets/{HQRGC5D7-dvTAT1Uv.js → HQRGC5D7-ArfvIYAC.js} +1 -1
- package/out/renderer/assets/{IX6Z2TVR-CzV_umYo.js → IX6Z2TVR-Df9chdw8.js} +1 -1
- package/out/renderer/assets/IconButtonTip-D0dQOfg6.js +1 -0
- package/out/renderer/assets/{J77NQRCJ-DTwwq3Ci.js → J77NQRCJ-DOWauTsf.js} +1 -1
- package/out/renderer/assets/{JAD36DTZ-DArKsMUT.js → JAD36DTZ-CJDdMCD5.js} +1 -1
- package/out/renderer/assets/{LF3NJQAX-DjYdE7YV.js → LF3NJQAX-B89ZqOpY.js} +1 -1
- package/out/renderer/assets/{LRZCOFJZ-C7m8fw-0.js → LRZCOFJZ-BBX_wZ5T.js} +1 -1
- package/out/renderer/assets/{N5NF2FGY-CqGhgjNF.js → N5NF2FGY-BoIFu-8L.js} +1 -1
- package/out/renderer/assets/{N7OWWQHY-BRk68LVa.js → N7OWWQHY-CloOgGu1.js} +1 -1
- package/out/renderer/assets/{NT5JY5WP-B1NtxJ-K.js → NT5JY5WP-BhjzefjG.js} +1 -1
- package/out/renderer/assets/{OT7W3RNY-CtDQ--Ld.js → OT7W3RNY-BRzBqtKB.js} +1 -1
- package/out/renderer/assets/{P67P66DB-LeAz_z3Z.js → P67P66DB-Dw-K1Ghu.js} +1 -1
- package/out/renderer/assets/{PFLLLM7K-CgODCVD8.js → PFLLLM7K-DfSPUrIT.js} +1 -1
- package/out/renderer/assets/{PUAMC4MJ-9REX_vGK.js → PUAMC4MJ-BnY1F2cF.js} +1 -1
- package/out/renderer/assets/{PVFCHRLY-CK5jTRjy.js → PVFCHRLY-BcyVPS3n.js} +1 -1
- package/out/renderer/assets/{PinnedSavedView-Dtdra7Gq.js → PinnedSavedView-ciRhY0cN.js} +1 -1
- package/out/renderer/assets/{QQW2P742-B2snHr_6.js → QQW2P742-D6aitZ24.js} +1 -1
- package/out/renderer/assets/{S63OEDPG-BeWWF1tc.js → S63OEDPG-Dlz1a9cD.js} +1 -1
- package/out/renderer/assets/{SG5TVYLW-ClCsbQ87.js → SG5TVYLW-Bu7LZZpx.js} +1 -1
- package/out/renderer/assets/{SavedViewArtifact-ATjDgAUF.js → SavedViewArtifact-CM9L4mc8.js} +1 -1
- package/out/renderer/assets/{SidebarPreviewPane-DHllX0GN.js → SidebarPreviewPane-DkOCt7Gb.js} +1 -1
- package/out/renderer/assets/{TranscriptViews-DD_JshFH.js → TranscriptViews-aYvP71ow.js} +1 -1
- package/out/renderer/assets/{UGRSUGA2-jP6nv8HL.js → UGRSUGA2-avwOtJG1.js} +1 -1
- package/out/renderer/assets/{V44WA6U7-Dr_tS3uH.js → V44WA6U7-DMF87Y7j.js} +1 -1
- package/out/renderer/assets/{V67O4WWV-BRn52u9c.js → V67O4WWV-BsDLuBDb.js} +1 -1
- package/out/renderer/assets/{VBUCM3YD-0sLtn_Zp.js → VBUCM3YD-C6FrRswP.js} +1 -1
- package/out/renderer/assets/{VINGRCPA-n98Gf7V0.js → VINGRCPA-Do3Pv3Tc.js} +1 -1
- package/out/renderer/assets/{ViewBlock-DdcTHRu3.js → ViewBlock-B-ppjb34.js} +3 -3
- package/out/renderer/assets/{ViewCharts-BAw6tExV.js → ViewCharts-jvS22ppO.js} +2 -2
- package/out/renderer/assets/{ViewCustom-BzwMbjqg.js → ViewCustom-yFkoy6a-.js} +1 -1
- package/out/renderer/assets/{ViewExtension-Ch5_33Ra.js → ViewExtension-DuHxho6W.js} +1 -1
- package/out/renderer/assets/{ViewInputs-BHooAs2f.js → ViewInputs-VAMDh56H.js} +1 -1
- package/out/renderer/assets/{ViewMcpApp-CJnOESMk.js → ViewMcpApp-CH_W9CZt.js} +1 -1
- package/out/renderer/assets/{ViewSessionAction-BHJv5QNb.js → ViewSessionAction-66veqRhO.js} +1 -1
- package/out/renderer/assets/{ViewTables-DBTupg46.js → ViewTables-CKKDcYKH.js} +1 -1
- package/out/renderer/assets/{WL6DNKX4-Csfp__Nw.js → WL6DNKX4-Cq-YK4Uf.js} +1 -1
- package/out/renderer/assets/{WQ63CJYP-oSbguA5n.js → WQ63CJYP-fjrhTSVs.js} +1 -1
- package/out/renderer/assets/{XOYAOB3S-DfDDKmX8.js → XOYAOB3S-CAQPI0he.js} +1 -1
- package/out/renderer/assets/{Y5LQLG3M-BnZ8APdi.js → Y5LQLG3M-DKntYAaW.js} +1 -1
- package/out/renderer/assets/{YIK6JTN6-Bunk5CDx.js → YIK6JTN6-CcjcC5JX.js} +1 -1
- package/out/renderer/assets/{core-BbPUgmX7.js → core-Cj89wpQh.js} +4 -4
- package/out/renderer/assets/{file-tabs-CFdJBYJ9.js → file-tabs-PoAgFa7v.js} +1 -1
- package/out/renderer/assets/{ghostty-web-Dn7o-dzQ.js → ghostty-web-DiMuvUtH.js} +1 -1
- package/out/renderer/assets/{highlights-eTGcn9lP.js → highlights-7WH0ppQl.js} +1 -1
- package/out/renderer/assets/{highlights-D4Jo_Sz0.js → highlights-DnSmFBdQ.js} +1 -1
- package/out/renderer/assets/index-CiuUSFeC.js +11 -0
- package/out/renderer/assets/kit-CD3F-f6F.js +147 -0
- package/out/renderer/assets/{langs-CXhlGiW6.js → langs-D5CRC9qz.js} +1 -1
- package/out/renderer/assets/{lazy-D3tN-GAO.js → lazy-CUmWiDAP.js} +3 -3
- package/out/renderer/assets/{loader-DGyfh0zB.js → loader-CPY9efuc.js} +1 -1
- package/out/renderer/assets/{pierre-theme-BZvsTYqQ.js → pierre-theme-BrzM0xZU.js} +3 -3
- package/out/renderer/assets/setting-demos-BW7cG2_G.css +1 -0
- package/out/renderer/assets/setting-demos-DEURBrvf.js +1 -0
- package/out/renderer/assets/{shiki-Wqv4XEGM.js → shiki-DFrbO9j3.js} +1 -1
- package/out/renderer/assets/{sidebar-layout-sK8ujsHX.js → sidebar-layout-fobokay5.js} +1 -1
- package/out/renderer/assets/{stream-tokenizer-C18hljKL.js → stream-tokenizer-CT1HAjvR.js} +1 -1
- package/out/renderer/assets/{themes-Dfx1_kFe.js → themes-Cj62ov9J.js} +1 -1
- package/out/renderer/assets/{useFind-BBxfQuQ2.js → useFind-Cdl0rVJO.js} +3 -3
- package/out/renderer/assets/{useFolderChanges-BcfSJoBT.js → useFolderChanges-C9L_NOgw.js} +2 -2
- package/out/renderer/assets/{view-preview-B2Rj--lZ.js → view-preview-BvCO9WZH.js} +1 -1
- package/out/renderer/assets/{zoom-reset-l-YVDJrI.js → zoom-reset-COqHFP45.js} +1 -1
- package/out/renderer/index.html +5 -5
- package/out/renderer/view-preview.html +6 -6
- package/package.json +2 -2
- package/out/renderer/assets/DiffsTab-D690H0Dy.js +0 -3
- package/out/renderer/assets/IconButtonTip-P9QUxPjA.js +0 -1
- package/out/renderer/assets/index-c95EBMdk.js +0 -8
- package/out/renderer/assets/kit-C9O_D5xC.js +0 -147
- package/out/renderer/assets/setting-demos-B0787McX.js +0 -1
- package/out/renderer/assets/setting-demos-vtrBsYTd.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as reactExports,j as jsxRuntimeExports}from"./vendor-react-CxJ4vs-5.js";import{
|
|
1
|
+
import{r as reactExports,j as jsxRuntimeExports}from"./vendor-react-CxJ4vs-5.js";import{fd as nodePathOf,f3 as viewRefKey,fe as CUSTOM_FRAME_DEFAULT_HEIGHT,ff as CUSTOM_PAGE_PROBLEMS_MAX,b as parseBindingSpecs,fg as CUSTOM_FRAME_MAX_HEIGHT}from"./core-Cj89wpQh.js";import{u as useViewsHost,e as useViewsLabels,X as LruMap,Y as useLinkRouter,Z as useLightbox,$ as useKeyCommandRegistry,a0 as useMergedKeybindings,a1 as customSlots,H as buttonClass,N as Notice,a2 as matchesBinding}from"./kit-CD3F-f6F.js";import{y as useViewportPresence,k as str,z as useViewRef,A as useViewExpanded,n as num,C as customShotOf,D as useFitPart,E as readThemeVars,F as watchTheme,G as CustomStatic}from"./ViewBlock-B-ppjb34.js";import"./vendor-owxl31sT.js";import"./vendor-motion-C2jPaSqL.js";import"./vendor-editor-gVJMCtGz.js";const CUSTOM_RUN_MARGIN="200px 0px",MIN_HEIGHT=40,CUSTOM_EXPANDED_MIN_HEIGHT=480;function fillFrame(element){Object.assign(element.style,{width:"100%",height:"100%",border:"0",display:element.tagName==="WEBVIEW"?"flex":"block"})}const snapshots=new LruMap(24);let liveFrames=0;function customFrameCounts(){return{frames:liveFrames,...customSlots.counts(),snapshots:snapshots.size}}const clamp=height=>Math.min(CUSTOM_FRAME_MAX_HEIGHT,Math.max(MIN_HEIGHT,Math.round(height)));function customShortcutEvent(key,registry,bindings){const actions=registry?.actions();if(!actions)return null;const event=new KeyboardEvent("keydown",{key:key.key,code:key.code,ctrlKey:key.ctrlKey,metaKey:key.metaKey,altKey:key.altKey,shiftKey:key.shiftKey,repeat:key.repeat,bubbles:!0,cancelable:!0});return actions.split(" ").some(action=>parseBindingSpecs(bindings[action]??"").some(spec=>spec!==null&&matchesBinding(event,spec)))?event:null}function problemLabel(labels,problem){return problem.kind==="overflow"?labels.viewCustomOverflow:problem.kind==="empty"?labels.viewCustomEmpty:labels.viewCustomConsoleError}const CustomFrameView=reactExports.memo(({node,scope})=>{const host=useViewsHost(),labels=useViewsLabels(),outer=reactExports.useRef(null),box=reactExports.useRef(null),near=useViewportPresence(outer,CUSTOM_RUN_MARGIN),p=node.props,title=str(p.title)??"",{tree,original}=scope,ref=useViewRef(scope.ref),sessionId=ref.kind==="session"?ref.sessionId:void 0,found=reactExports.useMemo(()=>nodePathOf(tree,node),[tree,node]),pathKey=found?found.join("."):"",path=reactExports.useMemo(()=>pathKey?pathKey.split(".").map(Number):void 0,[pathKey]),html=str(p.html)??"",data=p.data,expanded=useViewExpanded(),key=JSON.stringify([viewRefKey(ref),path,original]),[clicked,setClicked]=reactExports.useState(!1),[granted,setGranted]=reactExports.useState(!1),[live,setLive]=reactExports.useState(!1),[height,setHeight]=reactExports.useState(()=>clamp(num(p.height)??CUSTOM_FRAME_DEFAULT_HEIGHT)),[snapshot,setSnapshot]=reactExports.useState(()=>snapshots.peek(key)),stored=customShotOf(scope,node),parkedImage=snapshot??stored,ran=reactExports.useRef(!1),heightNow=reactExports.useRef(height),reported=reactExports.useRef(!1),fitted=reactExports.useRef(!1);reactExports.useLayoutEffect(()=>{heightNow.current=height}),useFitPart({height:()=>heightNow.current,known:()=>reported.current,set:next=>{fitted.current=!0,setHeight(clamp(next))}});const stateRef=reactExports.useRef(scope.state);reactExports.useEffect(()=>{stateRef.current=scope.state});const[problems,setProblems]=reactExports.useState([]),[error,setError]=reactExports.useState(null),[nearBefore,setNearBefore]=reactExports.useState(near);near!==nearBefore&&(setNearBefore(near),near||setClicked(!1));const start=host?.customFrame,report=host?.reportProblem,running=reactExports.useRef(null),links=useLinkRouter(),lightbox=useLightbox(),registry=useKeyCommandRegistry(),bindings=useMergedKeybindings(),openLightbox=lightbox.open,input=reactExports.useRef(null);reactExports.useEffect(()=>{input.current={links,registry,bindings,openImage:(src,name)=>openLightbox([{key:`${key}:image`,name:name||labels.viewCustomImage(title),src}],0,box.current)}}),reactExports.useEffect(()=>{if(!start||!path||error||!(near||clicked))return;const release=customSlots.request({grant:()=>setGranted(!0),revoke:()=>setGranted(!1)},{priority:clicked||expanded});return()=>{release(),setGranted(!1)}},[start,path,error,near,clicked,expanded]),reactExports.useEffect(()=>{if(!granted||!start||!path)return;let frame=null,stop=()=>{},stopTheme=()=>{},cancelled=!1;const theme=readThemeVars();let sentTheme=JSON.stringify(theme);const state=stateRef.current;return start({ref,path,original,theme,title,...state?{state}:{}}).then(result=>{if(cancelled){result.ok&&result.value.dispose();return}if(!result.ok){setError(result.error);return}frame=result.value,running.current=frame,liveFrames++;const element=frame.element;stop=frame.listen(event=>{if(event.kind==="height"){reported.current=!0,setHeight(clamp(event.height));return}if(event.kind==="open-link"){input.current?.links.open(event.url,{source:"transcript",...sessionId?{sessionId}:{}});return}if(event.kind==="image"){input.current?.openImage(event.src,event.name);return}if(event.kind==="key"){if(!input.current||document.activeElement!==element)return;const shortcut=customShortcutEvent(event,input.current.registry,input.current.bindings);shortcut&&(outer.current??element).dispatchEvent(shortcut);return}if(event.kind==="rpc")return;const problem=event.problem;setProblems(list=>list.length>=CUSTOM_PAGE_PROBLEMS_MAX||list.some(known=>known.kind===problem.kind&&known.message===problem.message)?list:[...list,problem]),report?.(ref,problem,path)});const live2=frame;if(live2.setTheme){const sync=()=>{const now=readThemeVars(),text=JSON.stringify(now);text!==sentTheme&&(sentTheme=text,live2.setTheme?.(now))};stopTheme=watchTheme(sync),sync()}fillFrame(frame.element),box.current?.appendChild(frame.element),ran.current=!0,setLive(!0)}),()=>{cancelled=!0,setLive(!1);const parked=frame;if(!parked)return;frame=null,running.current===parked&&(running.current=null),stop(),stopTheme(),liveFrames--;const done=()=>{parked.element.remove(),parked.dispose()};if(!parked.snapshot||!parked.element.isConnected){done();return}parked.snapshot().then(url=>{url&&(snapshots.set(key,url),setSnapshot(url))},()=>{}).finally(done)}},[granted,start,report,ref,sessionId,path,original,title,key,html]),reactExports.useEffect(()=>{live&&running.current?.setData?.(data)},[live,data]);const shown=expanded?Math.max(height,CUSTOM_EXPANDED_MIN_HEIGHT):height,fitStored=event=>{const img=event.currentTarget;if(ran.current||fitted.current||snapshot||!img.naturalWidth||!outer.current)return;const width=outer.current.getBoundingClientRect().width||img.naturalWidth;setHeight(clamp(img.naturalHeight*width/img.naturalWidth))};return jsxRuntimeExports.jsxs("div",{ref:outer,className:"flex flex-col gap-2 min-w-0","data-zg-view-custom":live?"live":"parked","data-zg-view-path":pathKey,children:[jsxRuntimeExports.jsxs("div",{className:"relative min-w-0 rounded-zg-md overflow-hidden",style:{height:shown},children:[jsxRuntimeExports.jsx("div",{ref:box,role:"group","aria-label":labels.viewCustomFrame(title),className:"absolute inset-0"}),live?null:jsxRuntimeExports.jsxs("div",{className:"absolute inset-0 flex flex-col gap-2",children:[parkedImage?jsxRuntimeExports.jsx("img",{onLoad:fitStored,src:parkedImage,alt:labels.viewCustomSnapshot(title),className:"block w-full h-full object-cover object-top",draggable:!1}):jsxRuntimeExports.jsx(CustomStatic,{p,note:!granted&&near?labels.viewCustomWaiting:void 0}),granted||error?null:jsxRuntimeExports.jsx("div",{className:"absolute bottom-2 right-2",children:jsxRuntimeExports.jsx("button",{type:"button",className:buttonClass({size:"xs"}),onClick:()=>setClicked(!0),children:labels.viewCustomRun})})]})]}),live?jsxRuntimeExports.jsx("p",{className:"sr-only",children:str(p.alt)}):null,problems.map((problem,i)=>jsxRuntimeExports.jsx(Notice,{tone:"warning",compact:!0,...problem.message?{detail:problem.message}:{},children:problemLabel(labels,problem)},i)),error?jsxRuntimeExports.jsx(Notice,{tone:"error",compact:!0,..."message"in error?{detail:error.message}:{},children:labels.viewCustomFailed}):null,lightbox.element]})});CustomFrameView.displayName="CustomFrameView";export{CUSTOM_EXPANDED_MIN_HEIGHT,CUSTOM_RUN_MARGIN,CustomFrameView,customFrameCounts,customShortcutEvent,fillFrame,readThemeVars};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as jsxRuntimeExports,r as reactExports}from"./vendor-react-CxJ4vs-5.js";import{
|
|
1
|
+
import{j as jsxRuntimeExports,r as reactExports}from"./vendor-react-CxJ4vs-5.js";import{fd as nodePathOf}from"./core-Cj89wpQh.js";import{e as useViewsLabels,a3 as useTranscriptRenderers,a4 as Raised,u as useViewsHost,a5 as useExtensionItems,a6 as ExtensionComponent}from"./kit-CD3F-f6F.js";import{g as ViewNodes,z as useViewRef}from"./ViewBlock-B-ppjb34.js";import"./vendor-owxl31sT.js";import"./vendor-motion-C2jPaSqL.js";import"./vendor-editor-gVJMCtGz.js";function ExtensionAlt({node}){const labels=useViewsLabels(),{Markdown}=useTranscriptRenderers();return jsxRuntimeExports.jsx(Raised,{radius:"md",className:"px-3 py-2 min-w-0","data-zg-view-extension":node.type,"data-state":"alt",children:node.alt?jsxRuntimeExports.jsx("div",{className:"text-zg-ui min-w-0",children:jsxRuntimeExports.jsx(Markdown,{children:node.alt})}):jsxRuntimeExports.jsx("span",{className:"text-zg-label text-[var(--zg-text-muted)]",children:labels.viewUnknown(node.type)})})}function useNodeData(host,scope,node,live){const[data,setData]=reactExports.useState(node.data),path=scope?nodePathOf(scope.tree,node):void 0,pathKey=path?path.join("."):"",resolve=host?.resolve,subscribeData=host?.subscribeData,ref=useViewRef(scope?.ref);return reactExports.useEffect(()=>{if(!live||!resolve||!scope||!ref||!path)return;let stopped=!1,timer;const ask=()=>{timer!==void 0&&clearTimeout(timer),timer=void 0,resolve(ref,{nodePath:path,...scope.original?{original:!0}:{}}).then(result=>{stopped||!result.ok||result.value&&(setData(result.value.data),timer=setTimeout(ask,Math.max(1e3,result.value.fetchedAt+result.value.ttlMs-Date.now())))})};ask();const off=subscribeData?.(components=>{components.includes(node.type)&&ask()});return()=>{stopped=!0,timer!==void 0&&clearTimeout(timer),off?.()}},[live,resolve,subscribeData,ref,scope?.original,pathKey,node.type]),data}function ExtensionViewNode({node,scope}){const host=useViewsHost(),entry=useExtensionItems("view-component").find(candidate=>candidate.item.name===node.type),data=useNodeData(host,scope,node,entry?.item.live===!0),alt=jsxRuntimeExports.jsx(ExtensionAlt,{node});return entry?.item.template!==void 0?node.children.length>0?jsxRuntimeExports.jsx("div",{className:"min-w-0","data-zg-view-extension":node.type,"data-state":"template",children:jsxRuntimeExports.jsx(ViewNodes,{nodes:node.children})}):alt:entry?.item.component?jsxRuntimeExports.jsx("div",{className:"min-w-0","data-zg-view-extension":node.type,children:jsxRuntimeExports.jsx(ExtensionComponent,{extension:entry.extension,component:{component:entry.item.component},props:{...node.props,...data!==void 0?{data}:{}},fallback:alt})}):alt}export{ExtensionAlt,ExtensionViewNode};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as reactExports,j as jsxRuntimeExports}from"./vendor-react-CxJ4vs-5.js";import{
|
|
1
|
+
import{r as reactExports,j as jsxRuntimeExports}from"./vendor-react-CxJ4vs-5.js";import{fd as nodePathOf}from"./core-Cj89wpQh.js";import{e as useViewsLabels,G as useViewsInputs,x as useViewsOrchestration,H as buttonClass,u as useViewsHost,J as useOptionalChatHost,L as useViewAnswer,M as viewAnswerKey,O as Checkbox,P as ChoiceCards,Q as FIELD_LABEL_CLASS,U as TEXTAREA_CLASS,W as INPUT_CLASS,N as Notice}from"./kit-CD3F-f6F.js";import{k as str,x as SessionActionPart,j as arr}from"./ViewBlock-B-ppjb34.js";import{V as ViewInputsPreviewContext,S as SavedViewInputsContext}from"./input-preview-CvBe1Cwt.js";import{i as isTrustedEvent}from"./trusted-C2plrfoK.js";import"./vendor-owxl31sT.js";import"./vendor-motion-C2jPaSqL.js";import"./vendor-editor-gVJMCtGz.js";function optionsOf(p){return arr(p.options).map(option=>{if(option&&typeof option=="object"&&!Array.isArray(option)){const label2=str(option.label)??"",description=str(option.description),category=str(option.category);return{label:label2,value:str(option.value)??label2,...description?{description}:{},...category?{category}:{}}}const label=str(option)??"";return{label,value:label}})}const FIELD_TYPES=["text","textarea","number","select","checkbox","date"],SECRET_FIELD=/password|passphrase|secret|api[\s_-]?key|token|credential/i;function fieldsOf(p){return arr(p.fields).flatMap(field=>{if(!field||typeof field!="object"||Array.isArray(field))return[];const name=str(field.name)??"",label=str(field.label)??name;if(!name||SECRET_FIELD.test(name)||SECRET_FIELD.test(label))return[];const type=FIELD_TYPES.find(t=>t===field.type)??"text",fallback=field.default,initial=type==="checkbox"?fallback===!0:typeof fallback=="string"||typeof fallback=="number"?String(fallback):"",placeholder=str(field.placeholder);return[{name,label,type,options:arr(field.options).flatMap(o=>typeof o=="string"?[o]:[]),...placeholder?{placeholder}:{},required:field.required===!0,initial}]})}function choiceColumns(count){return count<=3?Math.max(1,count):count===4?2:3}function choiceGrid(count){return{display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(min(100%, max(12rem, calc(100% / ${choiceColumns(count)} - 1rem))), 1fr))`}}function StaticInput({node,note}){const p=node.props,off=note===null?null:jsxRuntimeExports.jsx("div",{className:"text-zg-label text-[var(--zg-text-muted)]",children:note});if(node.type==="Action")return jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntimeExports.jsx("button",{type:"button",disabled:!0,className:buttonClass({size:"sm"}),children:str(p.label)}),off]});if(node.type==="Choice"){const options=optionsOf(p);return jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[str(p.prompt)?jsxRuntimeExports.jsx("div",{className:"text-zg-ui",children:str(p.prompt)}):null,jsxRuntimeExports.jsx("ul",{className:"m-0 p-0 list-none gap-2",style:choiceGrid(options.length),"data-zg-choice-grid":choiceColumns(options.length),children:options.map((option,i)=>jsxRuntimeExports.jsxs("li",{className:"zg-raised border rounded-zg-md px-2.5 py-1.5 text-zg-ui min-w-0",children:[option.label,option.description?jsxRuntimeExports.jsx("span",{className:"block text-zg-label text-[var(--zg-text-muted)]",children:option.description}):null]},i))}),off]})}const fields=arr(p.fields).flatMap(field=>field&&typeof field=="object"&&!Array.isArray(field)?[{label:str(field.label)??"",hint:str(field.placeholder)}]:[]);return jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[str(p.title)?jsxRuntimeExports.jsx("div",{className:"text-zg-ui font-medium",children:str(p.title)}):null,jsxRuntimeExports.jsx("dl",{className:"m-0 grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1 text-zg-ui",children:fields.map((field,i)=>jsxRuntimeExports.jsxs("div",{className:"contents",children:[jsxRuntimeExports.jsx("dt",{className:"text-[var(--zg-text-muted)]",children:field.label}),jsxRuntimeExports.jsx("dd",{className:"m-0 text-zg-label text-[var(--zg-text-muted)]",children:field.hint??""})]},i))}),off]})}function useInputAnswer(node,scope){const chat=useOptionalChatHost(),path=reactExports.useMemo(()=>scope?nodePathOf(scope.tree,node):void 0,[scope,node]),session=scope?.ref.kind==="session"?scope.ref:null,answer=useViewAnswer(session&&path?viewAnswerKey(session.id,path):null),[state,setState]=reactExports.useState("idle"),done=state==="sent"||answer!==void 0;return{scope,path,answer,state,setState,done,send:async(kind,text,value)=>{if(!session||!path||!chat?.send||done||state==="sending"||!text.trim())return;setState("sending");const view={sessionId:session.sessionId,viewId:session.id,nodePath:path,kind,value};try{await chat.send({sessionId:session.sessionId,prompt:text,origin:{kind:"user",source:"view",view},literal:!0,keepDraft:!0,delivery:"queue"}),setState("sent")}catch{setState("failed")}},canSend:!!(session&&path&&chat?.send)}}function Status({input,extra}){const labels=useViewsLabels();return input.done?jsxRuntimeExports.jsx("div",{className:"text-zg-label text-[var(--zg-text-muted)]",children:labels.viewInputsSent}):input.state==="failed"?jsxRuntimeExports.jsx(Notice,{tone:"error",compact:!0,children:labels.viewInputsFailed}):extra?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:extra}):null}function pickedValues(answer){const value=answer?.value;return typeof value=="string"?[value]:Array.isArray(value)?value.filter(v=>typeof v=="string"):[]}function ChoiceInput({node,input}){const labels=useViewsLabels(),p=node.props,options=reactExports.useMemo(()=>optionsOf(p),[p]),multiple=p.multiple===!0,[picked,setPicked]=reactExports.useState([]),answered=input.answer?pickedValues(input.answer):null,shown=answered?options.flatMap((option,i)=>answered.includes(option.value)?[i]:[]):picked,locked=input.done||input.state==="sending",prompt=str(p.prompt),onSend=event=>{if(!isTrustedEvent(event.nativeEvent)||picked.length===0)return;const chosen=picked.flatMap(i=>options[i]?[options[i]]:[]),text=chosen.map(option=>option.label).join(", ");input.send("choice",text,multiple?chosen.map(option=>option.value):chosen[0].value)};return jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2","data-zg-view-input":"choice",children:[prompt?jsxRuntimeExports.jsx("div",{className:"text-zg-ui",children:prompt}):null,input.done?jsxRuntimeExports.jsx("ul",{className:"m-0 p-0 list-none gap-2",style:choiceGrid(options.length),"data-zg-choice-grid":choiceColumns(options.length),"aria-label":prompt??labels.viewChoiceOptions,children:options.map((option,i)=>{const on=shown.includes(i);return jsxRuntimeExports.jsxs("li",{"data-picked":on?"":void 0,"aria-current":on?"true":void 0,className:`flex items-center gap-2 rounded-zg-md px-2 py-1 text-zg-ui border ${on?"zg-raised ring-1 ring-[color-mix(in_srgb,var(--zg-accent)_55%,transparent)] text-[var(--zg-text)]":"border-transparent text-[var(--zg-text-muted)]"}`,children:[option.label,on?jsxRuntimeExports.jsx("span",{"aria-hidden":!0,className:"i-ph-check-bold text-[var(--zg-accent)]"}):null]},i)})}):multiple?jsxRuntimeExports.jsx("div",{role:"group","aria-label":prompt??labels.viewChoiceOptions,className:"flex flex-col gap-1",children:options.map((option,i)=>{const on=shown.includes(i);return jsxRuntimeExports.jsxs("button",{type:"button",role:"checkbox","aria-checked":on,disabled:locked,onClick:()=>setPicked(now=>now.includes(i)?now.filter(n=>n!==i):[...now,i]),className:"zg-press-subtle flex items-start gap-2 text-left px-2 py-1.5 rounded-zg-md bg-transparent border-0 cursor-pointer text-[var(--zg-text)] hover:before:bg-[var(--zg-row-hover)] disabled:cursor-default disabled:opacity-zg-disabled zg-focus-ring",children:[jsxRuntimeExports.jsx(Checkbox,{checked:on}),jsxRuntimeExports.jsxs("span",{className:"flex flex-col min-w-0",children:[jsxRuntimeExports.jsx("span",{className:"text-zg-ui",children:option.label}),option.description?jsxRuntimeExports.jsx("span",{className:"text-zg-label text-[var(--zg-text-muted)]",children:option.description}):null]})]},i)})}):jsxRuntimeExports.jsx(ChoiceCards,{value:shown[0]!==void 0?String(shown[0]):void 0,onChange:value=>{locked||setPicked([Number(value)])},options:options.map((option,i)=>({value:String(i),title:option.label,...option.description?{description:option.description}:{},...option.category?{category:option.category}:{}})),strong:!0,inTray:!0,style:choiceGrid(options.length),ariaLabel:prompt??labels.viewChoiceOptions}),input.done?null:jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("button",{type:"button",disabled:picked.length===0||locked,onClick:onSend,className:buttonClass({variant:"primary",size:"sm"}),children:input.state==="sending"?labels.viewInputsSending:labels.viewInputsSend})}),jsxRuntimeExports.jsx(Status,{input})]})}function FormInput({node,input}){const labels=useViewsLabels(),p=node.props,fields=reactExports.useMemo(()=>fieldsOf(p),[p]),[values,setValues]=reactExports.useState(()=>Object.fromEntries(fields.map(field=>[field.name,field.initial]))),answered=input.answer?.value,shown=answered&&typeof answered=="object"&&!Array.isArray(answered)?Object.fromEntries(fields.map(field=>{const v=answered[field.name];return[field.name,field.type==="checkbox"?v===!0:v==null?"":String(v)]})):values,locked=input.done||input.state==="sending",title=str(p.title),set=(name,value)=>setValues(now=>({...now,[name]:value})),onSubmit=event=>{if(event.preventDefault(),!isTrustedEvent(event.nativeEvent)||locked)return;const value={},lines=title?[title]:[];for(const field of fields){const raw=values[field.name];if(field.type==="checkbox"){value[field.name]=raw===!0,lines.push(`${field.label}: ${raw===!0?labels.viewFormYes:labels.viewFormNo}`);continue}const text=typeof raw=="string"?raw.trim():"";if(!text)continue;const number=field.type==="number"?Number(text):Number.NaN;value[field.name]=field.type==="number"&&Number.isFinite(number)?number:text,lines.push(`${field.label}: ${text}`)}input.send("form",lines.join(`
|
|
2
2
|
`),value)};return jsxRuntimeExports.jsxs("form",{className:"flex flex-col gap-3",onSubmit,"data-zg-view-input":"form",children:[title?jsxRuntimeExports.jsx("div",{className:"text-zg-ui font-medium",children:title}):null,fields.map(field=>{const value=shown[field.name];if(field.type==="checkbox")return jsxRuntimeExports.jsxs("label",{className:"flex items-center gap-2 text-zg-ui cursor-pointer",children:[jsxRuntimeExports.jsx("input",{type:"checkbox",name:field.name,checked:value===!0,disabled:locked,onChange:e=>set(field.name,e.target.checked),className:"zg-focus-ring"}),field.label]},field.name);const common={name:field.name,value:typeof value=="string"?value:"",disabled:locked,required:field.required,...field.placeholder?{placeholder:field.placeholder}:{}};return jsxRuntimeExports.jsxs("label",{className:"block",children:[jsxRuntimeExports.jsx("span",{className:FIELD_LABEL_CLASS,children:field.label}),field.type==="textarea"?jsxRuntimeExports.jsx("textarea",{...common,rows:3,className:TEXTAREA_CLASS,onChange:e=>set(field.name,e.target.value)}):field.type==="select"?jsxRuntimeExports.jsxs("select",{...common,className:INPUT_CLASS,onChange:e=>set(field.name,e.target.value),children:[jsxRuntimeExports.jsx("option",{value:""}),field.options.map(option=>jsxRuntimeExports.jsx("option",{value:option,children:option},option))]}):jsxRuntimeExports.jsx("input",{...common,type:field.type,className:INPUT_CLASS,onChange:e=>set(field.name,e.target.value)})]},field.name)}),input.done?null:jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("button",{type:"submit",disabled:locked,className:buttonClass({variant:"primary",size:"sm"}),children:input.state==="sending"?labels.viewInputsSending:str(p.submitLabel)??labels.viewInputsSend})}),jsxRuntimeExports.jsx(Status,{input})]})}const TONE={primary:"primary",danger:"danger",default:"secondary"};function ActionInput({node,input}){const labels=useViewsLabels(),host=useViewsHost(),p=node.props,label=str(p.label)??"",tool=str(p.tool),message=str(p.message),text=message&&message!==label?message:label,[action,setAction]=reactExports.useState("idle"),runAction=host?.runAction,locked=input.done||input.state==="sending"||action==="waiting",onClick=async event=>{if(!isTrustedEvent(event.nativeEvent)||locked)return;if(!tool){input.send("action",text,{label});return}const{scope,path}=input;if(!scope||!path||!runAction)return;setAction("waiting");const result=await runAction(scope.ref,path,scope.original);!result.ok||result.value==="missing"?setAction("failed"):result.value==="denied"?setAction("denied"):result.value==="approved"&&(setAction("idle"),input.setState("sent"))};return jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-1","data-zg-view-input":"action",children:[jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[jsxRuntimeExports.jsx("button",{type:"button",disabled:locked,onClick:e=>{onClick(e)},className:buttonClass({variant:TONE[str(p.tone)??"default"]??"secondary",size:"sm"}),children:label}),tool?jsxRuntimeExports.jsx("span",{className:"text-zg-label text-[var(--zg-text-muted)]",children:labels.viewActionRuns(tool)}):text!==label?jsxRuntimeExports.jsx("span",{className:"text-zg-label text-[var(--zg-text-muted)]",children:labels.viewActionSends(text)}):null]}),jsxRuntimeExports.jsx(Status,{input,extra:action==="waiting"?jsxRuntimeExports.jsx("div",{className:"text-zg-label text-[var(--zg-text-muted)]",children:labels.viewActionWaiting}):action==="denied"?jsxRuntimeExports.jsx("div",{className:"text-zg-label text-[var(--zg-text-muted)]",children:labels.viewActionDenied}):action==="failed"?jsxRuntimeExports.jsx(Notice,{tone:"error",compact:!0,children:labels.viewActionFailed}):null})]})}function LiveInput({node,scope}){const labels=useViewsLabels(),host=useViewsHost(),input=useInputAnswer(node,scope);return reactExports.useContext(ViewInputsPreviewContext)?node.type==="Choice"?jsxRuntimeExports.jsx(ChoiceInput,{node,input}):node.type==="Form"?jsxRuntimeExports.jsx(FormInput,{node,input}):jsxRuntimeExports.jsx(ActionInput,{node,input}):!scope||!input.path?jsxRuntimeExports.jsx(StaticInput,{node,note:labels.viewInputsPending}):(node.type==="Action"&&typeof node.props.tool=="string"&&node.props.tool!==""?!host?.runAction:!input.canSend)?jsxRuntimeExports.jsx(StaticInput,{node,note:labels.viewInputsUnsupported}):node.type==="Choice"?jsxRuntimeExports.jsx(ChoiceInput,{node,input}):node.type==="Form"?jsxRuntimeExports.jsx(FormInput,{node,input}):jsxRuntimeExports.jsx(ActionInput,{node,input})}function SessionActionInput({node,scope,session}){const orchestration=useViewsOrchestration(),path=reactExports.useMemo(()=>scope?nodePathOf(scope.tree,node):null,[scope,node]),verb=str(session.do),key=str(session.key);if(orchestration==="read"||!scope||!path||!key||verb!=="start"&&verb!=="send"&&verb!=="schedule"&&verb!=="command")return null;const tone=str(node.props.tone);return jsxRuntimeExports.jsx("div",{className:"flex items-center min-w-0","data-zg-view-input":"session",children:jsxRuntimeExports.jsx(reactExports.Suspense,{fallback:jsxRuntimeExports.jsx("span",{"data-zg-view-pending":""}),children:jsxRuntimeExports.jsx(SessionActionPart,{target:{ref:scope.ref,path},label:str(node.props.label)??"",verb,linkKey:key,...tone?{tone}:{}})})})}const ViewInput=reactExports.memo(({node,scope=null})=>{const labels=useViewsLabels(),inputs=useViewsInputs(),preview=reactExports.useContext(ViewInputsPreviewContext),saved=reactExports.useContext(SavedViewInputsContext),orchestration=useViewsOrchestration(),session=node.type==="Action"?node.props.session:void 0;return orchestration!=="off"&&session&&typeof session=="object"&&!Array.isArray(session)&&!preview?jsxRuntimeExports.jsx(SessionActionInput,{node,scope,session}):saved?jsxRuntimeExports.jsx(StaticInput,{node,note:saved.openChat?jsxRuntimeExports.jsx("button",{type:"button",className:"bg-transparent border-0 p-0 text-zg-label text-[var(--zg-accent)] cursor-pointer hover:underline",onClick:saved.openChat,children:labels.viewOpenChat}):null}):!inputs&&!preview?jsxRuntimeExports.jsx(StaticInput,{node,note:labels.viewInputsOff}):jsxRuntimeExports.jsx(LiveInput,{node,scope})});ViewInput.displayName="ViewInput";export{ViewInput,choiceColumns};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as reactExports,j as jsxRuntimeExports}from"./vendor-react-CxJ4vs-5.js";import{
|
|
1
|
+
import{r as reactExports,j as jsxRuntimeExports}from"./vendor-react-CxJ4vs-5.js";import{fh as customLinkUrl,fi as MCP_APP_PROTOCOL_VERSION,f3 as viewRefKey,fj as MCP_APP_PERMISSIONS,fg as CUSTOM_FRAME_MAX_HEIGHT}from"./core-Cj89wpQh.js";import{u as useViewsHost,e as useViewsLabels,X as LruMap,Y as useLinkRouter,J as useOptionalChatHost,G as useViewsInputs,j as useOptionalConfirm,ah as useOptionalModal,ai as MCP_APP_ORIGIN_SOURCE,a1 as customSlots,H as buttonClass,N as Notice}from"./kit-CD3F-f6F.js";import{y as useViewportPresence,k as str,z as useViewRef,D as useFitPart,A as useViewExpanded,I as useExpandView,F as watchTheme,o as observeSize,G as CustomStatic,J as appIsLight}from"./ViewBlock-B-ppjb34.js";import{CUSTOM_RUN_MARGIN,fillFrame}from"./ViewCustom-yFkoy6a-.js";import"./vendor-owxl31sT.js";import"./vendor-motion-C2jPaSqL.js";import"./vendor-editor-gVJMCtGz.js";const MCP_APP_BRIDGE_PENDING_MAX=8,MCP_APP_BRIDGE_RATE_MAX=60,MCP_APP_BRIDGE_WINDOW_MS=1e4,MCP_APP_MESSAGE_MAX_CHARS=8e3,MCP_APP_CONTEXT_MAX_CHARS=2e3,MCP_APP_DOWNLOAD_MAX_BYTES=192*1024;class McpAppRefusal extends Error{}function isObject$1(value){return!!value&&typeof value=="object"&&!Array.isArray(value)}function isId(value){return typeof value=="string"||typeof value=="number"&&Number.isFinite(value)}const INVALID_PARAMS=-32602,METHOD_NOT_FOUND=-32601,REFUSED=-32e3;function contentText(content){return(Array.isArray(content)?content:content===void 0?[]:[content]).map(block=>isObject$1(block)&&block.type==="text"&&typeof block.text=="string"?block.text:"").filter(Boolean).join(`
|
|
2
2
|
`)}function base64Text(text){let binary="";for(const byte of new TextEncoder().encode(text))binary+=String.fromCharCode(byte);return btoa(binary)}function base64Bytes(data){const clean=data.replace(/\s+/g,"");return Math.floor(clean.length*3/4)-(clean.endsWith("==")?2:clean.endsWith("=")?1:0)}function fileNameOf(uri){const last=uri.split(/[?#]/)[0].split(/[/\\]/).filter(Boolean).at(-1)??"";let name=last;try{name=decodeURIComponent(last)}catch{}return name.replace(/[\u0000-\u001F<>:"/\\|?*]+/g,"_").replace(/^\.+/,"").slice(0,128).trim()||"download"}function downloadOf(params){const embedded=(Array.isArray(params.contents)?params.contents:[]).find(item=>isObject$1(item)&&item.type==="resource"&&isObject$1(item.resource));if(!embedded)return"ui/download-file needs an embedded resource.";const resource=embedded.resource,uri=typeof resource.uri=="string"?resource.uri:"",mimeType=typeof resource.mimeType=="string"&&/^[\w.+-]+\/[\w.+-]+$/.test(resource.mimeType)?resource.mimeType:"application/octet-stream";let data;if(typeof resource.blob=="string"){if(!/^[A-Z0-9+/\s]*={0,2}$/i.test(resource.blob))return"The file is not valid base64.";data=resource.blob.replace(/\s+/g,"")}else if(typeof resource.text=="string"){if(resource.text.length>MCP_APP_DOWNLOAD_MAX_BYTES)return"The file is larger than 192 KB.";data=base64Text(resource.text)}else return"The resource has no text or blob.";const size=base64Bytes(data);return size>MCP_APP_DOWNLOAD_MAX_BYTES?"The file is larger than 192 KB.":{name:fileNameOf(uri),mimeType,data,size}}function toolResult(value){const r=isObject$1(value)?value:{};return{content:Array.isArray(r.content)?r.content:[],...isObject$1(r.structuredContent)?{structuredContent:r.structuredContent}:{},...r.isError===!0?{isError:!0}:{},...isObject$1(r._meta)?{_meta:r._meta}:{}}}function createMcpAppBridge(options){const now=options.now??Date.now;let initialized=!1,stopped=!1,pending=0,sent;const times=[];let activeNow=!1;const post=message=>{stopped||options.post({jsonrpc:"2.0",...message})},respond=(id,result)=>post({id,result}),fail=(id,code,message)=>post({id,error:{code,message}}),notify=(method,params)=>post({method,params}),answer=(id,run)=>{if(pending>=MCP_APP_BRIDGE_PENDING_MAX){fail(id,REFUSED,"Too many requests in flight.");return}pending++,run().then(result=>{pending--,respond(id,result)},error=>{pending--,fail(id,REFUSED,error instanceof Error&&error.message?error.message:"Request failed.")})},sendToolCall=()=>{const input=options.toolCall.input;notify("ui/notifications/tool-input",{arguments:isObject$1(input)?input:{}}),options.toolCall.result!==null&¬ify("ui/notifications/tool-result",toolResult(options.toolCall.result))},request=(id,method,params)=>{switch(method){case"ui/initialize":{sent=options.hostContext(),respond(id,{protocolVersion:MCP_APP_PROTOCOL_VERSION,hostInfo:{name:"zidane",version:options.hostVersion??"0"},hostCapabilities:{openLinks:{},serverTools:{},serverResources:{},logging:{},...options.sendMessage?{message:{}}:{},...options.updateModelContext?{updateModelContext:{}}:{},...options.downloadFile?{downloadFile:{}}:{},sandbox:{...options.app.csp?{csp:options.app.csp}:{},permissions:Object.fromEntries(options.app.permissions.map(name=>[name,{}]))}},hostContext:sent});return}case"ping":respond(id,{});return;case"tools/call":{const name=params.name,args=params.arguments??{};if(typeof name!="string"||name.trim()===""||!isObject$1(args)){fail(id,INVALID_PARAMS,"tools/call needs a tool name and object arguments.");return}answer(id,async()=>toolResult(await options.request("tools/call",{name,arguments:args})));return}case"resources/read":{const uri=params.uri;if(typeof uri!="string"||uri.trim()===""){fail(id,INVALID_PARAMS,"resources/read needs a uri.");return}answer(id,()=>options.request("resources/read",{uri}));return}case"ui/open-link":{const url=customLinkUrl(params.url);if(!url){fail(id,INVALID_PARAMS,"Only http and https links open.");return}answer(id,()=>options.openLink(url,activeNow).then(()=>({})));return}case"ui/request-display-mode":{const mode=params.mode==="fullscreen"||params.mode==="inline"?params.mode:void 0,current=options.hostContext().displayMode;respond(id,{mode:mode&&options.requestDisplayMode?options.requestDisplayMode(mode,activeNow):current});return}case"ui/message":{const send=options.sendMessage,text=contentText(params.content).trim();if(!send){fail(id,METHOD_NOT_FOUND,"This host takes no messages from apps.");return}if(params.role!==void 0&¶ms.role!=="user"||!text||text.length>MCP_APP_MESSAGE_MAX_CHARS){fail(id,INVALID_PARAMS,`ui/message needs a user role and text content of at most ${MCP_APP_MESSAGE_MAX_CHARS} characters.`);return}const active=activeNow;answer(id,()=>send(text,active).then(()=>({})));return}case"ui/update-model-context":{const update=options.updateModelContext;if(!update){fail(id,METHOD_NOT_FOUND,"This host takes no model context from apps.");return}const structured=isObject$1(params.structuredContent)?JSON.stringify(params.structuredContent):"",text=[contentText(params.content),structured].filter(Boolean).join(`
|
|
3
3
|
`);if(text.length>MCP_APP_CONTEXT_MAX_CHARS){fail(id,INVALID_PARAMS,`The context is at most ${MCP_APP_CONTEXT_MAX_CHARS} characters.`);return}answer(id,()=>update(text).then(()=>({})));return}case"ui/download-file":{const download=options.downloadFile;if(!download){fail(id,METHOD_NOT_FOUND,"This host saves no files from apps.");return}const file=downloadOf(params);if(typeof file=="string"){fail(id,INVALID_PARAMS,file);return}answer(id,()=>download(file).then(()=>({})));return}default:fail(id,METHOD_NOT_FOUND,`Method not found: ${method}`)}},bridge={receive(message,meta){if(stopped)return;const at=now();for(;times.length>0&×[0]<=at-MCP_APP_BRIDGE_WINDOW_MS;)times.shift();const method=message.method;if(times.length>=MCP_APP_BRIDGE_RATE_MAX){isId(message.id)&&typeof method=="string"&&fail(message.id,REFUSED,"Too many messages.");return}if(times.push(at),typeof method!="string")return;const params=isObject$1(message.params)?message.params:{};activeNow=meta?.active===!0,isId(message.id)?request(message.id,method,params):notification(method,params)},updateHostContext(){if(!initialized||!sent||stopped)return;const next=options.hostContext(),changes={};for(const key of Object.keys(next))JSON.stringify(next[key])!==JSON.stringify(sent[key])&&(changes[key]=next[key]);sent=next,Object.keys(changes).length>0&¬ify("ui/notifications/host-context-changed",changes)},teardown(){stopped||(initialized&&post({id:"zidane-teardown",method:"ui/resource-teardown",params:{}}),stopped=!0)},pending:()=>pending};function notification(method,params){if(method==="ui/notifications/initialized"){if(initialized)return;initialized=!0,sendToolCall(),bridge.updateHostContext();return}if(method==="ui/notifications/size-changed"){const width=typeof params.width=="number"&&Number.isFinite(params.width)?params.width:void 0,height=typeof params.height=="number"&&Number.isFinite(params.height)?params.height:void 0;(width!==void 0||height!==void 0)&&options.onSizeChanged({...width===void 0?{}:{width},...height===void 0?{}:{height}})}}return bridge}const DEFAULT_HEIGHT=320,FULLSCREEN_MIN_HEIGHT=480,MIN_HEIGHT=80,granted=new LruMap(64);let liveApps=0;function mcpAppFrameCount(){return liveApps}const clamp=height=>Math.min(CUSTOM_FRAME_MAX_HEIGHT,Math.max(MIN_HEIGHT,Math.round(height))),STYLE_VARIABLES=[["--color-background-primary","background-color","var(--zg-bg)"],["--color-background-secondary","background-color","var(--zg-tray)"],["--color-background-tertiary","background-color","var(--zg-raised)"],["--color-background-inverse","background-color","var(--zg-text)"],["--color-background-info","background-color","var(--zg-info-soft)"],["--color-background-danger","background-color","var(--zg-danger-soft)"],["--color-background-success","background-color","var(--zg-success-soft)"],["--color-background-warning","background-color","var(--zg-warn-soft)"],["--color-text-primary","color","var(--zg-text)"],["--color-text-secondary","color","var(--zg-text-muted)"],["--color-text-tertiary","color","var(--zg-text-subtle)"],["--color-text-inverse","color","var(--zg-bg)"],["--color-text-info","color","var(--zg-info)"],["--color-text-danger","color","var(--zg-danger)"],["--color-text-success","color","var(--zg-success)"],["--color-text-warning","color","var(--zg-warn)"],["--color-border-primary","border-top-color","var(--zg-hairline)"],["--color-border-secondary","border-top-color","var(--zg-border)"],["--color-ring-primary","outline-color","var(--zg-ring)"],["--font-sans","font-family","var(--zg-font-ui)"],["--font-mono","font-family","var(--zg-font-mono)"],["--border-radius-sm","border-top-left-radius","var(--zg-radius-sm)"],["--border-radius-md","border-top-left-radius","var(--zg-radius-md)"],["--border-radius-lg","border-top-left-radius","var(--zg-radius-lg)"]];function mcpAppStyleVariables(within){const probe=document.createElement("span");probe.setAttribute("aria-hidden","true"),probe.style.cssText="position:absolute;visibility:hidden;pointer-events:none;border-top:1px solid;outline:1px solid",within.appendChild(probe);const out={};try{for(const[name,property,value]of STYLE_VARIABLES){probe.style.setProperty(property,value);const resolved=getComputedStyle(probe).getPropertyValue(property).replace(/\s+/g," ").trim();resolved&&(out[name]=resolved.slice(0,256)),probe.style.removeProperty(property)}}finally{probe.remove()}return out}function media(query){return typeof matchMedia=="function"&&matchMedia(query).matches}function sizeText(bytes){return bytes<1024?`${bytes} B`:bytes<1024*1024?`${Math.round(bytes/1024)} KB`:`${(bytes/1024/1024).toFixed(1)} MB`}function isObject(value){return!!value&&typeof value=="object"&&!Array.isArray(value)}const McpAppFrameView=reactExports.memo(({node,scope})=>{const host=useViewsHost(),labels=useViewsLabels(),outer=reactExports.useRef(null),box=reactExports.useRef(null),near=useViewportPresence(outer,CUSTOM_RUN_MARGIN),p=node.props,title=str(p.title)??"",server=str(p.server)??"",tool=str(p.tool)??"",ref=useViewRef(scope.ref),sessionId=ref.kind==="session"?ref.sessionId:void 0,viewId=ref.kind==="session"?ref.id:ref.key,viewKey=viewRefKey(ref),declared=MCP_APP_PERMISSIONS.filter(name=>Array.isArray(p.permissions)&&p.permissions.includes(name)),[allowed,setAllowed]=reactExports.useState(()=>granted.peek(viewKey)??[]),asked=declared.filter(name=>!allowed.includes(name)),[clicked,setClicked]=reactExports.useState(!1),[slot,setSlot]=reactExports.useState(!1),[live,setLive]=reactExports.useState(!1),[height,setHeight]=reactExports.useState(DEFAULT_HEIGHT),heightNow=reactExports.useRef(height),reported=reactExports.useRef(!1);reactExports.useLayoutEffect(()=>{heightNow.current=height}),useFitPart({height:()=>heightNow.current,known:()=>reported.current,set:next=>setHeight(clamp(next))});const[error,setError]=reactExports.useState(null),[refusal,setRefusal]=reactExports.useState(null),[nearBefore,setNearBefore]=reactExports.useState(near);near!==nearBefore&&(setNearBefore(near),near||setClicked(!1));const links=useLinkRouter(),chat=useOptionalChatHost(),inputsOn=useViewsInputs(),ask=useOptionalConfirm(),modal=useOptionalModal(),expanded=useViewExpanded(),expand=useExpandView(viewId),mode=expanded?"fullscreen":"inline",modes=expanded||expand?["inline","fullscreen"]:["inline"],input=reactExports.useRef(null);reactExports.useEffect(()=>{const send=chat?.send;input.current={links,host,send:send&&inputsOn&&sessionId?text=>send({sessionId,prompt:text,origin:{kind:"user",source:MCP_APP_ORIGIN_SOURCE,sender:{id:viewId,name:server}},literal:!0,keepDraft:!0,delivery:"queue"}):null,confirm:ask?file=>ask({title:labels.viewMcpAppDownloadTitle(file.name),message:labels.viewMcpAppDownloadBody(server,sizeText(file.size)),confirmLabel:labels.viewMcpAppDownloadSave}):null,displayMode:(next,active)=>next==="fullscreen"&&!expanded&&expand&&active?(expand({title:title||server,tree:scope.tree,custom:scope}),"fullscreen"):next==="inline"&&expanded&&modal?(modal.close(`view:${viewId}`),"inline"):mode}});const start=host?.customFrame;reactExports.useEffect(()=>{if(!start||error||!(near||clicked))return;const release=customSlots.request({grant:()=>setSlot(!0),revoke:()=>setSlot(!1)},{priority:clicked});return()=>{release(),setSlot(!1)}},[start,error,near,clicked]);const allowedKey=allowed.join(",");reactExports.useEffect(()=>{if(!slot||!start||!box.current)return;const container=box.current;let frame=null,bridge=null,stop=()=>{},stopTheme=()=>{},stopSize=()=>{},cancelled=!1,width=Math.round(container.getBoundingClientRect().width);const permissions=allowedKey?allowedKey.split(","):[];return start({ref,path:[0],original:!1,theme:{},title,permissions}).then(result=>{if(cancelled){result.ok&&result.value.dispose();return}if(!result.ok){setError(result.error);return}const started=result.value;if(started.kind!=="mcp-app"||!started.postRpc){started.dispose(),setError({code:"unsupported"});return}frame=started,liveApps++;const element=started.element,csp=isObject(p.csp)?p.csp:void 0,context=()=>({theme:appIsLight()?"light":"dark",styles:{variables:mcpAppStyleVariables(container)},displayMode:mode,availableDisplayModes:modes,containerDimensions:{width,maxHeight:CUSTOM_FRAME_MAX_HEIGHT},platform:element.tagName==="WEBVIEW"?"desktop":"web",locale:navigator.language,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,deviceCapabilities:{touch:media("(pointer: coarse)"),hover:media("(hover: hover)")},safeAreaInsets:{top:0,right:0,bottom:0,left:0},toolInfo:{tool:{name:tool,...title&&title!==tool?{title}:{},inputSchema:{type:"object"}}}}),data=isObject(node.data)?node.data:{},app=createMcpAppBridge({app:{server,tool,title,...csp?{csp}:{},permissions:started.permissions??[]},toolCall:{input:data.input??{},result:data.result??null},post:message=>started.postRpc?.(message),hostContext:context,request:async(method,params)=>{const appRequest=input.current?.host?.appRequest;if(!appRequest)throw new McpAppRefusal("This app cannot reach its server here.");const answer=await appRequest(ref,method,params);if(answer.ok)return answer.value;const message="message"in answer.error?answer.error.message:"This app cannot reach its server here.";throw setRefusal(message),new McpAppRefusal(message)},openLink:async(url,active)=>{if(!active||!input.current)throw new McpAppRefusal("Links open only from a click in the app.");await input.current.links.open(url,{source:"transcript",...sessionId?{sessionId}:{}})},onSizeChanged:size=>{size.height!==void 0&&(reported.current=!0,setHeight(clamp(size.height)))},requestDisplayMode:(next,active)=>input.current?.displayMode(next,active)??mode,...chat?.send?{sendMessage:async(text,active)=>{if(!active)throw new McpAppRefusal("Messages send only from a click in the app.");const send=input.current?.send;if(!send)throw new McpAppRefusal("This app cannot send messages here.");await send(text)}}:{},updateModelContext:async text=>{const appRequest=input.current?.host?.appRequest;if(!appRequest)throw new McpAppRefusal("This app cannot set context here.");const answer=await appRequest(ref,"ui/update-model-context",{text});if(!answer.ok)throw new McpAppRefusal("message"in answer.error?answer.error.message:"This app cannot set context here.")},...host?.downloadFile&&ask?{downloadFile:async file=>{const save=input.current?.host?.downloadFile,confirm=input.current?.confirm;if(!save||!confirm)throw new McpAppRefusal("This app cannot save files here.");if(!await confirm(file))throw new McpAppRefusal("The person did not save the file.");const saved=await save({name:file.name,mimeType:file.mimeType,data:file.data});if(!saved.ok)throw new McpAppRefusal("message"in saved.error?saved.error.message:"The file could not be saved.")}}:{}});bridge=app,stop=started.listen(event=>{event.kind==="rpc"&&app.receive(event.message,{...event.active!==void 0?{active:event.active}:{}})}),stopTheme=watchTheme(()=>app.updateHostContext()),stopSize=observeSize(container,next=>{const rounded=Math.round(next);rounded!==width&&(width=rounded,app.updateHostContext())}),fillFrame(element),container.appendChild(element),setLive(!0)}),()=>{cancelled=!0,setLive(!1),stop(),stopTheme(),stopSize(),bridge?.teardown(),frame&&(liveApps--,frame.element.remove(),frame.dispose(),frame=null)}},[slot,start,ref,allowedKey,mode]);const names=list=>list.map(name=>labels.viewMcpAppPermission(name)).join(", "),allow=()=>{const next=[...new Set([...allowed,...declared])];granted.set(viewKey,next),setAllowed(next)};return jsxRuntimeExports.jsxs("div",{ref:outer,className:"flex flex-col gap-2 min-w-0","data-zg-view-mcp-app":live?"live":"parked","data-zg-view-path":"0",children:[jsxRuntimeExports.jsxs("div",{className:"relative min-w-0 rounded-zg-md overflow-hidden",style:{height:expanded?Math.max(FULLSCREEN_MIN_HEIGHT,height):height},children:[jsxRuntimeExports.jsx("div",{ref:box,role:"group","aria-label":labels.viewMcpAppFrame(server,title),className:"absolute inset-0"}),live?null:jsxRuntimeExports.jsxs("div",{className:"absolute inset-0 flex flex-col gap-2",children:[jsxRuntimeExports.jsx(CustomStatic,{p,note:!slot&&near?labels.viewMcpAppWaiting:void 0}),slot||error?null:jsxRuntimeExports.jsx("div",{className:"absolute bottom-2 right-2",children:jsxRuntimeExports.jsx("button",{type:"button",className:buttonClass({size:"xs"}),onClick:()=>setClicked(!0),children:labels.viewMcpAppRun})})]})]}),jsxRuntimeExports.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[jsxRuntimeExports.jsx("span",{className:"text-zg-meta text-[var(--zg-text-muted)] truncate",children:labels.viewMcpAppFrom(server)}),allowed.length>0?jsxRuntimeExports.jsx("span",{className:"zg-meta",children:labels.viewMcpAppAllowed(names(allowed))}):null]}),asked.length>0?jsxRuntimeExports.jsx(Notice,{tone:"info",compact:!0,action:jsxRuntimeExports.jsx("button",{type:"button",className:buttonClass({size:"xs"}),onClick:allow,children:labels.viewMcpAppAllow}),children:labels.viewMcpAppAsks(names(asked))}):null,refusal?jsxRuntimeExports.jsx(Notice,{tone:"warning",compact:!0,detail:refusal,children:labels.viewMcpAppRefused}):null,error?jsxRuntimeExports.jsx(Notice,{tone:"error",compact:!0,..."message"in error?{detail:error.message}:{},children:labels.viewMcpAppFailed}):null]})});McpAppFrameView.displayName="McpAppFrameView";export{McpAppFrameView,mcpAppFrameCount,mcpAppStyleVariables};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as reactExports,j as jsxRuntimeExports}from"./vendor-react-CxJ4vs-5.js";import{fg as VIEW_SESSIONS_DATA,e$ as viewRefKey,fh as VIEW_SESSION_ACTION_LIMITS,fi as sessionActionAccess,fj as expandRowAction}from"./core-BbPUgmX7.js";import{e as useViewsLabels,u as useViewsHost,aj as useViewSessionNav,x as useViewsOrchestration,H as buttonClass,n as RowActionsMenu,T as Table,ak as useDismiss,al as FloatingSurface,am as KeyValue,an as toast,ao as returnFocus}from"./kit-C9O_D5xC.js";import{w as BADGE_TONE}from"./ViewBlock-DdcTHRu3.js";import{i as isTrustedEvent}from"./trusted-C2plrfoK.js";import"./vendor-owxl31sT.js";import"./vendor-motion-C2jPaSqL.js";import"./vendor-editor-gVJMCtGz.js";function createSessionLinks(host,ref){const entries=new Map;let queued=!1,again=!1,busy=!1;const scope=ref.kind==="saved"?ref.scope:void 0,set=(key,link)=>{const entry=entries.get(key);if(!entry)return;const was=entry.link;if(!(was===link||was&&link&&was.sessionId===link.sessionId&&was.status===link.status&&was.title===link.title)){entry.link=link;for(const listener of[...entry.listeners])listener()}},fetch=async()=>{if(busy){again=!0;return}const keys=[...entries.keys()];if(!(keys.length===0||!host.sessionLinks)){busy=!0;try{for(let at=0;at<keys.length;at+=VIEW_SESSION_ACTION_LIMITS.linkKeys){const chunk=keys.slice(at,at+VIEW_SESSION_ACTION_LIMITS.linkKeys),result=await host.sessionLinks(ref,chunk,scope);if(!result.ok)continue;const byKey=new Map(result.value.map(link=>[link.key,link]));for(const key of chunk)set(key,byKey.get(key)??null)}}finally{busy=!1,again&&(again=!1,fetch())}}},schedule=()=>{queued||(queued=!0,queueMicrotask(()=>{queued=!1,fetch()}))};return{get:key=>entries.get(key)?.link,watch(key,onChange){let entry=entries.get(key);return entry||(entry={link:void 0,listeners:new Set},entries.set(key,entry),schedule()),entry.listeners.add(onChange),()=>{entry.listeners.delete(onChange)}},refresh:schedule,watched:()=>[...entries.values()].some(entry=>entry.listeners.size>0)}}const byHost=new WeakMap;function sessionLinksOf(host,ref){let state=byHost.get(host);if(!state){const fresh={views:new Map};fresh.stop=host.subscribeData?.(components=>{if(components.includes(VIEW_SESSIONS_DATA))for(const links2 of fresh.views.values())links2.watched()&&links2.refresh()}),byHost.set(host,fresh),state=fresh}const key=viewRefKey(ref);let links=state.views.get(key);return links||(links=createSessionLinks(host,ref),state.views.set(key,links)),links}const TONE={primary:"primary",danger:"danger",default:"secondary"},STATUS_TONE={running:"info",blocked:"warning",done:"success",failed:"danger"},STATUSES=["running","blocked","done","failed"];function useSessionLink(ref,key){const host=useViewsHost(),links=host?.sessionLinks?sessionLinksOf(host,ref):null,subscribe=reactExports.useCallback(onChange=>links?links.watch(key,onChange):()=>{},[links,key]),read=()=>links?links.get(key):null;return reactExports.useSyncExternalStore(subscribe,read,read)}function statusWord(status,labels){return labels.viewSessionStatus(status)}function Stacked({words,shown}){return jsxRuntimeExports.jsx("span",{className:"inline-grid min-w-0",children:[...new Set([...words,shown])].map(word=>jsxRuntimeExports.jsx("span",{"aria-hidden":word===shown?void 0:!0,className:`[grid-area:1/1] min-w-0 truncate ${word===shown?"":"invisible"}`,children:word},word))})}const targetKey=target=>JSON.stringify([target.ref,target.path,target.rowIndex??null]),runners=new Map;function SessionActionControl({target,label,tone,verb,linkKey,compact=!1}){const labels=useViewsLabels(),host=useViewsHost(),nav=useViewSessionNav(),mode=useViewsOrchestration(),access=sessionActionAccess(mode,verb),link=useSessionLink(target.ref,linkKey),[state,setState]=reactExports.useState({kind:"idle"}),[menuOpen,setMenuOpen]=reactExports.useState(!1),buttonRef=reactExports.useRef(null),menuRef=reactExports.useRef(null),run=host?.sessionAction,drafts=(verb==="start"||verb==="send")&&nav.openDraft!==void 0,call=async options=>{if(!run)return;setState({kind:"busy"});const result=await run(target.ref,target.path,{...options,...target.rowIndex!==void 0?{rowIndex:target.rowIndex}:{}});if(!result.ok){setState({kind:"failed",message:"message"in result.error?result.error.message:labels.viewActionFailed,retry:options});return}settle(result.value,options)},links=host?.sessionLinks?sessionLinksOf(host,target.ref):null,open=sessionId=>nav.openSession?.(sessionId,target.ref);function settle(outcome,options){switch(outcome.status){case"needs-approval":setState({kind:"ask",approval:outcome.approval,options});return;case"draft":setState({kind:"idle"}),nav.openDraft?.({prompt:outcome.prompt,cwd:outcome.cwd,...outcome.title?{title:outcome.title}:{}},target.ref);return;case"started":case"sent":case"ran":case"exists":{setState({kind:"idle"}),links?.refresh();const{sessionId}=outcome;if(outcome.status==="exists"){open(sessionId);return}toast({type:outcome.status==="started"&&outcome.fallbackFrom?"info":"success",title:outcome.status==="started"?outcome.fallbackFrom?labels.viewSessionStartedDefault(outcome.title,outcome.fallbackFrom):labels.viewSessionStarted(outcome.title):outcome.status==="sent"?labels.viewSessionSent:labels.viewSessionRan,...nav.openSession?{actions:[{id:"open",label:labels.viewSessionOpenToast,onSelect:()=>open(sessionId)}]}:{}});return}case"scheduled":setState({kind:"idle"}),toast.success(labels.viewSessionScheduled);return;case"refused":if(outcome.reason==="off"||outcome.reason==="hidden"||outcome.reason==="declined"){setState({kind:"idle"});return}setState({kind:"failed",message:outcome.message,retry:options});return;case"failed":setState({kind:"failed",message:outcome.message,retry:options})}}const latest=reactExports.useRef(call);reactExports.useEffect(()=>{latest.current=call});const key=targetKey(target);if(reactExports.useEffect(()=>{const runner=options=>{latest.current(options)};return runners.set(key,runner),()=>{runners.get(key)===runner&&runners.delete(key)}},[key]),access==="hidden"||!run||access==="draft"&&!nav.openDraft)return null;const linked=link??null,opens=verb==="start"&&linked!==null,failed=state.kind==="failed",busy=state.kind==="busy",primary=event=>{if(!(!isTrustedEvent(event.nativeEvent)||busy)){if(failed){call(state.retry);return}if(opens&&linked){open(linked.sessionId);return}call({mode:access==="draft"?"draft":"run"})}},items=[...drafts?[{id:"draft",label:labels.viewSessionDraft,onSelect:()=>{call({mode:"draft"})}}]:[],...opens&&access!=="draft"?[{id:"another",label:labels.viewSessionAnother,onSelect:()=>{call({mode:"run",another:!0})}}]:[]],hasMenu=drafts||verb==="start",reveal=compact?" zg-reveal":"",size=compact?"xs":"sm",shown=failed?labels.viewSessionRetry:opens?labels.viewSessionOpen:label,statusWords=[...new Set([...STATUSES.map(s=>statusWord(s,labels)),labels.viewSessionFailed])],chipTone=failed?"danger":linked?STATUS_TONE[linked.status]:null,chipText=failed?labels.viewSessionFailed:linked?statusWord(linked.status,labels):"",chipFace=`inline-flex items-center justify-center rounded-full px-1.5 text-zg-meta font-medium ${chipTone?BADGE_TONE[chipTone]:""}`,chip=jsxRuntimeExports.jsxs("span",{className:"inline-grid shrink-0","data-zg-session-chip":failed?"failed":linked?.status??"",children:[statusWords.map(word=>jsxRuntimeExports.jsx("span",{"aria-hidden":!0,className:`[grid-area:1/1] invisible ${chipFace}`,children:word},word)),chipTone===null?null:linked&&!failed&&nav.openSession?jsxRuntimeExports.jsx("button",{type:"button",className:`[grid-area:1/1] zg-focus-ring border-0 cursor-pointer ${chipFace}`,"aria-label":labels.viewSessionChip(chipText,linked.title),title:linked.title,onClick:()=>open(linked.sessionId),children:chipText}):jsxRuntimeExports.jsx("span",{className:`[grid-area:1/1] ${chipFace}`,title:failed?state.message:linked?.title,role:"status",children:chipText})]});return jsxRuntimeExports.jsxs("span",{className:`inline-flex items-center gap-2 min-w-0 ${compact?"justify-end w-full":""}`,"data-zg-session-action":verb,children:[compact?chip:null,jsxRuntimeExports.jsxs("span",{className:"inline-flex items-center gap-px min-w-0 max-w-full",children:[jsxRuntimeExports.jsx("button",{ref:buttonRef,type:"button",disabled:busy,"aria-busy":busy||void 0,onClick:primary,...failed?{title:state.message}:{},...state.kind==="ask"?{"aria-expanded":!0}:{},className:`${buttonClass({variant:TONE[tone??"default"]??"secondary",size})} min-w-0 !shrink${hasMenu?" !rounded-r-none":""}${reveal}`,children:jsxRuntimeExports.jsx(Stacked,{words:[label,labels.viewSessionOpen,labels.viewSessionRetry],shown})}),hasMenu?jsxRuntimeExports.jsx("button",{ref:menuRef,type:"button","aria-label":labels.viewSessionMore,"aria-haspopup":"menu","aria-expanded":menuOpen,disabled:items.length===0,onClick:()=>setMenuOpen(was=>!was),className:`${buttonClass({variant:TONE[tone??"default"]??"secondary",size})} !rounded-l-none !px-1${reveal}`,children:jsxRuntimeExports.jsx("span",{"aria-hidden":"true",className:"i-ph-caret-down"})}):null]}),compact?null:chip,hasMenu?jsxRuntimeExports.jsx(RowActionsMenu,{open:menuOpen,anchorRef:menuRef,onClose:()=>setMenuOpen(!1),items}):null,state.kind==="ask"?jsxRuntimeExports.jsx(SessionApprove,{anchor:buttonRef,approval:state.approval,onCancel:()=>setState({kind:"idle"}),onApprove:as=>{call({...state.options,approve:as})}}):null]})}function useSessionActionMenuContext(){const labels=useViewsLabels(),host=useViewsHost(),nav=useViewSessionNav(),mode=useViewsOrchestration();return{labels,host,canDraft:nav.openDraft!==void 0,mode}}function sessionActionMenuItems(context,target,verb,linkKey){const{labels,host,canDraft,mode}=context,access=sessionActionAccess(mode,verb),runner=runners.get(targetKey(target));if(access==="hidden"||!host?.sessionAction||!runner)return[];const linked=host.sessionLinks?sessionLinksOf(host,target.ref).get(linkKey):null;return[...(verb==="start"||verb==="send")&&canDraft?[{id:"draft",label:labels.viewSessionDraft,onSelect:()=>runner({mode:"draft"})}]:[],...verb==="start"&&linked&&access!=="draft"?[{id:"another",label:labels.viewSessionAnother,onSelect:()=>runner({mode:"run",another:!0})}]:[]]}const ROW_END_WIDTH=200;function SessionRowsTable({table,rowAction,target}){const context=useSessionActionMenuContext(),stored=rowAction,{ref,path}=target,rowEnd=row=>{const action=expandRowAction(stored,row.index);return action?jsxRuntimeExports.jsx(SessionActionControl,{compact:!0,target:{ref,path,rowIndex:row.index},label:action.label,verb:action.session.do,linkKey:action.session.key,...action.tone?{tone:action.tone}:{}}):null},rowMenu=row=>{const action=expandRowAction(stored,row.index);return action?sessionActionMenuItems(context,{ref,path,rowIndex:row.index},action.session.do,action.session.key):[]};return sessionActionAccess(context.mode,stored.base?.session?.do??"start")!=="hidden"?jsxRuntimeExports.jsx(Table,{...table,rowEnd,rowEndWidth:ROW_END_WIDTH,rowMenu}):jsxRuntimeExports.jsx(Table,{...table})}function SessionApprove({anchor,approval,onCancel,onApprove}){const labels=useViewsLabels(),surface=reactExports.useRef(null),first=reactExports.useRef(null),cancel=()=>{onCancel(),returnFocus(anchor.current,surface.current)};useDismiss(!0,[anchor,surface],{onOutsidePress:onCancel,onEscape:cancel}),reactExports.useEffect(()=>{first.current?.focus({preventScroll:!0})},[]);const branch=approval.where?.worktree?.branch,schedule=approval.schedule,items=[...approval.prompt!==void 0?[{id:"prompt",label:labels.viewSessionPrompt,value:jsxRuntimeExports.jsx("span",{className:"whitespace-pre-wrap break-words",children:approval.prompt})}]:[],{id:"where",label:labels.viewSessionWhere,value:branch?labels.viewSessionWhereBranch(branch):labels.viewSessionWhereProject},{id:"agent",label:labels.viewSessionAgent,value:approval.agent??labels.viewSessionAgentDefault},...approval.artifacts?.length?[{id:"artifacts",label:labels.viewSessionArtifacts,value:approval.artifacts.map(artifact=>`${artifact.kind}: ${artifact.uri}`).join(`
|
|
1
|
+
import{r as reactExports,j as jsxRuntimeExports}from"./vendor-react-CxJ4vs-5.js";import{fk as VIEW_SESSIONS_DATA,f3 as viewRefKey,fl as VIEW_SESSION_ACTION_LIMITS,fm as sessionActionAccess,fn as expandRowAction}from"./core-Cj89wpQh.js";import{e as useViewsLabels,u as useViewsHost,aj as useViewSessionNav,x as useViewsOrchestration,H as buttonClass,n as RowActionsMenu,T as Table,ak as useDismiss,al as FloatingSurface,am as KeyValue,an as toast,ao as returnFocus}from"./kit-CD3F-f6F.js";import{w as BADGE_TONE}from"./ViewBlock-B-ppjb34.js";import{i as isTrustedEvent}from"./trusted-C2plrfoK.js";import"./vendor-owxl31sT.js";import"./vendor-motion-C2jPaSqL.js";import"./vendor-editor-gVJMCtGz.js";function createSessionLinks(host,ref){const entries=new Map;let queued=!1,again=!1,busy=!1;const scope=ref.kind==="saved"?ref.scope:void 0,set=(key,link)=>{const entry=entries.get(key);if(!entry)return;const was=entry.link;if(!(was===link||was&&link&&was.sessionId===link.sessionId&&was.status===link.status&&was.title===link.title)){entry.link=link;for(const listener of[...entry.listeners])listener()}},fetch=async()=>{if(busy){again=!0;return}const keys=[...entries.keys()];if(!(keys.length===0||!host.sessionLinks)){busy=!0;try{for(let at=0;at<keys.length;at+=VIEW_SESSION_ACTION_LIMITS.linkKeys){const chunk=keys.slice(at,at+VIEW_SESSION_ACTION_LIMITS.linkKeys),result=await host.sessionLinks(ref,chunk,scope);if(!result.ok)continue;const byKey=new Map(result.value.map(link=>[link.key,link]));for(const key of chunk)set(key,byKey.get(key)??null)}}finally{busy=!1,again&&(again=!1,fetch())}}},schedule=()=>{queued||(queued=!0,queueMicrotask(()=>{queued=!1,fetch()}))};return{get:key=>entries.get(key)?.link,watch(key,onChange){let entry=entries.get(key);return entry||(entry={link:void 0,listeners:new Set},entries.set(key,entry),schedule()),entry.listeners.add(onChange),()=>{entry.listeners.delete(onChange)}},refresh:schedule,watched:()=>[...entries.values()].some(entry=>entry.listeners.size>0)}}const byHost=new WeakMap;function sessionLinksOf(host,ref){let state=byHost.get(host);if(!state){const fresh={views:new Map};fresh.stop=host.subscribeData?.(components=>{if(components.includes(VIEW_SESSIONS_DATA))for(const links2 of fresh.views.values())links2.watched()&&links2.refresh()}),byHost.set(host,fresh),state=fresh}const key=viewRefKey(ref);let links=state.views.get(key);return links||(links=createSessionLinks(host,ref),state.views.set(key,links)),links}const TONE={primary:"primary",danger:"danger",default:"secondary"},STATUS_TONE={running:"info",blocked:"warning",done:"success",failed:"danger"},STATUSES=["running","blocked","done","failed"];function useSessionLink(ref,key){const host=useViewsHost(),links=host?.sessionLinks?sessionLinksOf(host,ref):null,subscribe=reactExports.useCallback(onChange=>links?links.watch(key,onChange):()=>{},[links,key]),read=()=>links?links.get(key):null;return reactExports.useSyncExternalStore(subscribe,read,read)}function statusWord(status,labels){return labels.viewSessionStatus(status)}function Stacked({words,shown}){return jsxRuntimeExports.jsx("span",{className:"inline-grid min-w-0",children:[...new Set([...words,shown])].map(word=>jsxRuntimeExports.jsx("span",{"aria-hidden":word===shown?void 0:!0,className:`[grid-area:1/1] min-w-0 truncate ${word===shown?"":"invisible"}`,children:word},word))})}const targetKey=target=>JSON.stringify([target.ref,target.path,target.rowIndex??null]),runners=new Map;function SessionActionControl({target,label,tone,verb,linkKey,compact=!1}){const labels=useViewsLabels(),host=useViewsHost(),nav=useViewSessionNav(),mode=useViewsOrchestration(),access=sessionActionAccess(mode,verb),link=useSessionLink(target.ref,linkKey),[state,setState]=reactExports.useState({kind:"idle"}),[menuOpen,setMenuOpen]=reactExports.useState(!1),buttonRef=reactExports.useRef(null),menuRef=reactExports.useRef(null),run=host?.sessionAction,drafts=(verb==="start"||verb==="send")&&nav.openDraft!==void 0,call=async options=>{if(!run)return;setState({kind:"busy"});const result=await run(target.ref,target.path,{...options,...target.rowIndex!==void 0?{rowIndex:target.rowIndex}:{}});if(!result.ok){setState({kind:"failed",message:"message"in result.error?result.error.message:labels.viewActionFailed,retry:options});return}settle(result.value,options)},links=host?.sessionLinks?sessionLinksOf(host,target.ref):null,open=sessionId=>nav.openSession?.(sessionId,target.ref);function settle(outcome,options){switch(outcome.status){case"needs-approval":setState({kind:"ask",approval:outcome.approval,options});return;case"draft":setState({kind:"idle"}),nav.openDraft?.({prompt:outcome.prompt,cwd:outcome.cwd,...outcome.title?{title:outcome.title}:{}},target.ref);return;case"started":case"sent":case"ran":case"exists":{setState({kind:"idle"}),links?.refresh();const{sessionId}=outcome;if(outcome.status==="exists"){open(sessionId);return}toast({type:outcome.status==="started"&&outcome.fallbackFrom?"info":"success",title:outcome.status==="started"?outcome.fallbackFrom?labels.viewSessionStartedDefault(outcome.title,outcome.fallbackFrom):labels.viewSessionStarted(outcome.title):outcome.status==="sent"?labels.viewSessionSent:labels.viewSessionRan,...nav.openSession?{actions:[{id:"open",label:labels.viewSessionOpenToast,onSelect:()=>open(sessionId)}]}:{}});return}case"scheduled":setState({kind:"idle"}),toast.success(labels.viewSessionScheduled);return;case"refused":if(outcome.reason==="off"||outcome.reason==="hidden"||outcome.reason==="declined"){setState({kind:"idle"});return}setState({kind:"failed",message:outcome.message,retry:options});return;case"failed":setState({kind:"failed",message:outcome.message,retry:options})}}const latest=reactExports.useRef(call);reactExports.useEffect(()=>{latest.current=call});const key=targetKey(target);if(reactExports.useEffect(()=>{const runner=options=>{latest.current(options)};return runners.set(key,runner),()=>{runners.get(key)===runner&&runners.delete(key)}},[key]),access==="hidden"||!run||access==="draft"&&!nav.openDraft)return null;const linked=link??null,opens=verb==="start"&&linked!==null,failed=state.kind==="failed",busy=state.kind==="busy",primary=event=>{if(!(!isTrustedEvent(event.nativeEvent)||busy)){if(failed){call(state.retry);return}if(opens&&linked){open(linked.sessionId);return}call({mode:access==="draft"?"draft":"run"})}},items=[...drafts?[{id:"draft",label:labels.viewSessionDraft,onSelect:()=>{call({mode:"draft"})}}]:[],...opens&&access!=="draft"?[{id:"another",label:labels.viewSessionAnother,onSelect:()=>{call({mode:"run",another:!0})}}]:[]],hasMenu=drafts||verb==="start",reveal=compact?" zg-reveal":"",size=compact?"xs":"sm",shown=failed?labels.viewSessionRetry:opens?labels.viewSessionOpen:label,statusWords=[...new Set([...STATUSES.map(s=>statusWord(s,labels)),labels.viewSessionFailed])],chipTone=failed?"danger":linked?STATUS_TONE[linked.status]:null,chipText=failed?labels.viewSessionFailed:linked?statusWord(linked.status,labels):"",chipFace=`inline-flex items-center justify-center rounded-full px-1.5 text-zg-meta font-medium ${chipTone?BADGE_TONE[chipTone]:""}`,chip=jsxRuntimeExports.jsxs("span",{className:"inline-grid shrink-0","data-zg-session-chip":failed?"failed":linked?.status??"",children:[statusWords.map(word=>jsxRuntimeExports.jsx("span",{"aria-hidden":!0,className:`[grid-area:1/1] invisible ${chipFace}`,children:word},word)),chipTone===null?null:linked&&!failed&&nav.openSession?jsxRuntimeExports.jsx("button",{type:"button",className:`[grid-area:1/1] zg-focus-ring border-0 cursor-pointer ${chipFace}`,"aria-label":labels.viewSessionChip(chipText,linked.title),title:linked.title,onClick:()=>open(linked.sessionId),children:chipText}):jsxRuntimeExports.jsx("span",{className:`[grid-area:1/1] ${chipFace}`,title:failed?state.message:linked?.title,role:"status",children:chipText})]});return jsxRuntimeExports.jsxs("span",{className:`inline-flex items-center gap-2 min-w-0 ${compact?"justify-end w-full":""}`,"data-zg-session-action":verb,children:[compact?chip:null,jsxRuntimeExports.jsxs("span",{className:"inline-flex items-center gap-px min-w-0 max-w-full",children:[jsxRuntimeExports.jsx("button",{ref:buttonRef,type:"button",disabled:busy,"aria-busy":busy||void 0,onClick:primary,...failed?{title:state.message}:{},...state.kind==="ask"?{"aria-expanded":!0}:{},className:`${buttonClass({variant:TONE[tone??"default"]??"secondary",size})} min-w-0 !shrink${hasMenu?" !rounded-r-none":""}${reveal}`,children:jsxRuntimeExports.jsx(Stacked,{words:[label,labels.viewSessionOpen,labels.viewSessionRetry],shown})}),hasMenu?jsxRuntimeExports.jsx("button",{ref:menuRef,type:"button","aria-label":labels.viewSessionMore,"aria-haspopup":"menu","aria-expanded":menuOpen,disabled:items.length===0,onClick:()=>setMenuOpen(was=>!was),className:`${buttonClass({variant:TONE[tone??"default"]??"secondary",size})} !rounded-l-none !px-1${reveal}`,children:jsxRuntimeExports.jsx("span",{"aria-hidden":"true",className:"i-ph-caret-down"})}):null]}),compact?null:chip,hasMenu?jsxRuntimeExports.jsx(RowActionsMenu,{open:menuOpen,anchorRef:menuRef,onClose:()=>setMenuOpen(!1),items}):null,state.kind==="ask"?jsxRuntimeExports.jsx(SessionApprove,{anchor:buttonRef,approval:state.approval,onCancel:()=>setState({kind:"idle"}),onApprove:as=>{call({...state.options,approve:as})}}):null]})}function useSessionActionMenuContext(){const labels=useViewsLabels(),host=useViewsHost(),nav=useViewSessionNav(),mode=useViewsOrchestration();return{labels,host,canDraft:nav.openDraft!==void 0,mode}}function sessionActionMenuItems(context,target,verb,linkKey){const{labels,host,canDraft,mode}=context,access=sessionActionAccess(mode,verb),runner=runners.get(targetKey(target));if(access==="hidden"||!host?.sessionAction||!runner)return[];const linked=host.sessionLinks?sessionLinksOf(host,target.ref).get(linkKey):null;return[...(verb==="start"||verb==="send")&&canDraft?[{id:"draft",label:labels.viewSessionDraft,onSelect:()=>runner({mode:"draft"})}]:[],...verb==="start"&&linked&&access!=="draft"?[{id:"another",label:labels.viewSessionAnother,onSelect:()=>runner({mode:"run",another:!0})}]:[]]}const ROW_END_WIDTH=200;function SessionRowsTable({table,rowAction,target}){const context=useSessionActionMenuContext(),stored=rowAction,{ref,path}=target,rowEnd=row=>{const action=expandRowAction(stored,row.index);return action?jsxRuntimeExports.jsx(SessionActionControl,{compact:!0,target:{ref,path,rowIndex:row.index},label:action.label,verb:action.session.do,linkKey:action.session.key,...action.tone?{tone:action.tone}:{}}):null},rowMenu=row=>{const action=expandRowAction(stored,row.index);return action?sessionActionMenuItems(context,{ref,path,rowIndex:row.index},action.session.do,action.session.key):[]};return sessionActionAccess(context.mode,stored.base?.session?.do??"start")!=="hidden"?jsxRuntimeExports.jsx(Table,{...table,rowEnd,rowEndWidth:ROW_END_WIDTH,rowMenu}):jsxRuntimeExports.jsx(Table,{...table})}function SessionApprove({anchor,approval,onCancel,onApprove}){const labels=useViewsLabels(),surface=reactExports.useRef(null),first=reactExports.useRef(null),cancel=()=>{onCancel(),returnFocus(anchor.current,surface.current)};useDismiss(!0,[anchor,surface],{onOutsidePress:onCancel,onEscape:cancel}),reactExports.useEffect(()=>{first.current?.focus({preventScroll:!0})},[]);const branch=approval.where?.worktree?.branch,schedule=approval.schedule,items=[...approval.prompt!==void 0?[{id:"prompt",label:labels.viewSessionPrompt,value:jsxRuntimeExports.jsx("span",{className:"whitespace-pre-wrap break-words",children:approval.prompt})}]:[],{id:"where",label:labels.viewSessionWhere,value:branch?labels.viewSessionWhereBranch(branch):labels.viewSessionWhereProject},{id:"agent",label:labels.viewSessionAgent,value:approval.agent??labels.viewSessionAgentDefault},...approval.artifacts?.length?[{id:"artifacts",label:labels.viewSessionArtifacts,value:approval.artifacts.map(artifact=>`${artifact.kind}: ${artifact.uri}`).join(`
|
|
2
2
|
`)}]:[],...schedule?[{id:"when",label:labels.viewSessionWhen,value:"cron"in schedule?schedule.cron:schedule.at}]:[],...approval.command?[{id:"command",label:labels.viewSessionCommand,value:[approval.command.id,approval.command.args].filter(Boolean).join(" ")}]:[]];return jsxRuntimeExports.jsx(FloatingSurface,{ref:surface,open:!0,anchor:{element:anchor.current},side:"bottom",align:"start",width:320,role:"dialog","aria-label":labels.viewSessionAsk(approval.do),children:jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-3 p-2 text-zg-label leading-4","data-zg-session-approve":"",children:[jsxRuntimeExports.jsx("div",{className:"text-[var(--zg-text)]",children:labels.viewSessionAsk(approval.do)}),jsxRuntimeExports.jsx(KeyValue,{meta:!0,items,className:"max-h-48 overflow-auto"}),jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-end gap-1",children:[jsxRuntimeExports.jsx("button",{type:"button",className:buttonClass({variant:"ghost",size:"xs"}),onClick:cancel,children:labels.viewSessionCancel}),jsxRuntimeExports.jsx("button",{ref:approval.each?first:void 0,type:"button",className:buttonClass({variant:approval.each?"primary":"secondary",size:"xs"}),onClick:()=>onApprove("once"),children:labels.viewSessionOnce(approval.do)}),approval.each?null:jsxRuntimeExports.jsx("button",{ref:first,type:"button",className:buttonClass({variant:"primary",size:"xs"}),onClick:()=>onApprove("view"),children:labels.viewSessionAlways})]})]})})}export{SessionActionControl,SessionRowsTable,sessionActionMenuItems,useSessionActionMenuContext};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as reactExports,j as jsxRuntimeExports}from"./vendor-react-CxJ4vs-5.js";import{
|
|
1
|
+
import{r as reactExports,j as jsxRuntimeExports}from"./vendor-react-CxJ4vs-5.js";import{fd as nodePathOf}from"./core-Cj89wpQh.js";import{t as useLabels,x as useViewsOrchestration,y as withUnit,z as viewLink,B as RoutedLink,T as Table,C as shareDecimals,E as setDecimals,F as isCompact}from"./kit-CD3F-f6F.js";import{h as useViewNumbers,f as ViewStateContext,i as useViewCustomScope,j as arr,k as str,n as num,l as oneOf,T as TONES,m as statusTones,B as BoolMark,q as TEXT_TONE,r as cellText,v as SessionRowsPart,w as BADGE_TONE}from"./ViewBlock-B-ppjb34.js";import"./vendor-owxl31sT.js";import"./vendor-motion-C2jPaSqL.js";import"./vendor-editor-gVJMCtGz.js";function objectOf(cell){return cell&&typeof cell=="object"&&!Array.isArray(cell)?cell:null}function rawCell(cell){const o=objectOf(cell);return o?o.badge!==void 0?str(o.badge)??null:o.bar!==void 0?num(o.bar)??null:str(o.text)??null:typeof cell=="number"||typeof cell=="string"?cell:null}function numberColumn(format,currency,decimals,nf){const fixed=decimals!==void 0?{minimumFractionDigits:decimals,maximumFractionDigits:decimals}:{};if(format==="currency"){const f2=new Intl.NumberFormat(nf.locale,{style:"currency",currency:currency??"USD",minimumFractionDigits:decimals??2,maximumFractionDigits:decimals??2});return value=>f2.format(value)}if(decimals===void 0)return;if(format==="percent"){const f2=new Intl.NumberFormat(nf.locale,{style:"percent",...fixed});return value=>f2.format(value)}const f=new Intl.NumberFormat(nf.locale,fixed);return format==="compact"?value=>{const step=[[1e12,"T"],[1e9,"B"],[1e6,"M"],[1e3,"k"]].find(([at])=>Math.abs(value)>=at);return step?`${f.format(value/step[0])}${step[1]}`:f.format(value)}:value=>f.format(value)}function carried(value){const text=String(Math.round(Math.abs(value)*100)/100),dot=text.indexOf(".");return dot<0?0:text.length-dot-1}function columnDecimals(values,format,unit){if(values.length===0||format==="compact")return;if(format==="percent")return Math.max(shareDecimals(values),setDecimals(values.map(v=>v*100),1));const digits=Math.max(setDecimals(values),...values.map(carried));return(format==="currency"||unit!==void 0&&withUnit("1",unit).startsWith(unit))&&digits===1?2:digits}function moneyColumn(header,unit){return/^(?:[$€£¥]|usd|eur|gbp|jpy|chf|cad|aud)$/i.test(unit??"")||/(?:\b|_)(?:usd|eur|gbp)\b|\([$€£]\)/i.test(header)}const BAR_TONE={neutral:"bg-[var(--zg-chart-baseline)]",info:"bg-zg-info",success:"bg-zg-success",warning:"bg-zg-warn",danger:"bg-zg-danger"},ISO_STAMP=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/;function stampColumn(values,locale){if(values.length===0)return;const dates=[];for(const value of values){if(typeof value!="string"||!ISO_STAMP.test(value))return;const date=new Date(value);if(Number.isNaN(date.getTime()))return;dates.push(date)}const years=new Set(dates.map(date=>date.getFullYear())),timed=dates.some(date=>date.getHours()!==0||date.getMinutes()!==0),f=new Intl.DateTimeFormat(locale,{month:"short",day:"numeric",...years.size>1?{year:"numeric"}:{},...timed?{hour:"2-digit",minute:"2-digit"}:{}});return value=>f.format(new Date(value))}function cellBadge(text,tone){return jsxRuntimeExports.jsx("span",{"data-tone":tone,className:`inline-flex items-center rounded-full px-1.5 text-zg-meta font-medium ${BADGE_TONE[tone]}`,children:text})}const ViewTable=reactExports.memo(({node,lead})=>{const p=node.props,nf=useViewNumbers(),labels=useLabels(),scope=reactExports.useContext(ViewStateContext),[ownFilter,setOwnFilter]=reactExports.useState(null),orchestration=useViewsOrchestration(),stored=useViewCustomScope(),rowAction=p.rowAction,acts=orchestration!=="off"&&orchestration!=="read"&&stored!==null&&rowAction!==null&&typeof rowAction=="object"&&!Array.isArray(rowAction),path=reactExports.useMemo(()=>acts&&stored?nodePathOf(stored.tree,node):null,[acts,stored,node]),cellRows=arr(p.rows).map(cells=>Array.isArray(cells)?cells:[]),many=cellRows.length>10,specs=arr(p.columns).map(column=>column&&typeof column=="object"&&!Array.isArray(column)?column:{label:column}),detailAt=specs.findIndex(spec=>spec.detail===!0),summed=new Map,keys=[],columns=specs.flatMap((spec,c)=>{if(c===detailAt)return[];const unit=str(spec.unit)?.trim()||void 0,prefix=unit!==void 0&&withUnit("1",unit).startsWith(unit),cellUnit=prefix?unit:void 0,base=str(spec.label)??"",header=unit&&!prefix&&!base.includes(`(${unit})`)?`${base} (${unit})`:base,format=spec.format,numbers=cellRows.flatMap(cells=>typeof cells[c]=="number"?[cells[c]]:[]),decimals=num(spec.decimals)??columnDecimals(numbers,format,unit),custom=numberColumn(format,str(spec.currency),decimals,nf),numberText=value=>custom?withUnit(custom(value),cellUnit,isCompact(custom(value))):cellText(value,format,cellUnit,nf),thresholds=arr(spec.thresholds).flatMap(t=>{const o=objectOf(t),above=o?num(o.above):void 0;return o&&above!==void 0?[{above,tone:oneOf(o.tone,TONES,"neutral")}]:[]}).sort((a,b)=>b.above-a.above);if(thresholds.length>0){const rules=[...thresholds].reverse().map(t=>labels.tableToneAbove(labels.tableToneColor(t.tone),numberText(t.above)));keys.push(labels.tableToneKey(header,rules.join(", ")))}const filled=cellRows.map(cells=>cells[c]).filter(cell=>cell!=null&&cell!==""),asShown=value=>decimals===void 0||format==="compact"?value:format==="percent"?Number((value*100).toFixed(decimals))/100:Number(value.toFixed(decimals)),barMax=spec.bar===!0?Math.max(0,...numbers.map(Math.abs)):0,totalKind=oneOf(spec.total,["sum","mean","none"],format==="percent"?"none":"sum");filled.length>0&&filled.every(cell=>typeof cell=="number")&&totalKind!=="none"&&summed.set(c,{text:numberText,mean:totalKind==="mean",money:format==="currency"||moneyColumn(header,unit)});const stamps=stampColumn(filled,nf.locale),texts=filled.map(cell=>objectOf(cell)?.badge!==void 0?str(objectOf(cell).badge):cell),distinct=new Set(texts),statuses=filled.every(cell=>typeof cell=="string")?statusTones(filled):void 0,filterable=many&&texts.length>0&&texts.every(cell=>typeof cell=="string")&&distinct.size>=2&&distinct.size<=8;return[{id:String(c),label:header,numeric:spec.align==="right"||format!==void 0||spec.decimals!==void 0||spec.align!=="left"&&filled.length>0&&filled.every(cell=>typeof cell=="number"),sortable:cellRows.length>=2,filterable,value:row=>rawCell(row.cells[c]),render:row=>{const cell=row.cells[c],o=objectOf(cell);if(o&&o.badge!==void 0)return cellBadge(str(o.badge)??"",oneOf(o.tone,TONES,"neutral"));if(o&&o.bar!==void 0){const share=Math.min(1,Math.max(0,num(o.bar)??0));return jsxRuntimeExports.jsxs("span",{className:"inline-flex items-center gap-2","data-bar":share,children:[jsxRuntimeExports.jsx("span",{"aria-hidden":!0,className:"inline-block w-16 h-1.5 rounded-full bg-[var(--zg-hairline)] overflow-hidden",children:jsxRuntimeExports.jsx("span",{className:"block h-full rounded-full bg-[var(--zg-chart-1)]",style:{width:`${share*100}%`}})}),jsxRuntimeExports.jsx("span",{children:str(o.text)??nf.percent(share)})]})}if(o){const url=viewLink(o.href),text=str(o.text)??"";return url?jsxRuntimeExports.jsx(RoutedLink,{href:url.href,source:"transcript",className:"text-[var(--zg-accent)] underline underline-offset-2",title:text.length>32?`${text}
|
|
2
2
|
${url.hostname}`:url.hostname,children:text}):text}if(typeof cell=="boolean")return jsxRuntimeExports.jsx(BoolMark,{value:cell});if(stamps&&typeof cell=="string")return jsxRuntimeExports.jsx("time",{dateTime:cell,title:cell,children:stamps(cell)});const status=typeof cell=="string"?statuses?.get(cell):void 0;if(status)return cellBadge(cell,status);if(typeof cell=="number"){const text=numberText(cell),hit=thresholds.find(t=>asShown(cell)>t.above),shown=hit?jsxRuntimeExports.jsx("span",{"data-tone":hit.tone,className:TEXT_TONE[hit.tone],children:text}):text;if(!barMax)return shown;const share=Math.min(1,Math.max(0,Math.abs(cell)/barMax));return jsxRuntimeExports.jsxs("span",{className:"inline-flex items-center gap-2","data-bar":share,children:[jsxRuntimeExports.jsx("span",{"aria-hidden":!0,className:"inline-block w-16 h-1.5 rounded-full bg-[var(--zg-hairline)] overflow-hidden",children:jsxRuntimeExports.jsx("span",{className:`block h-full rounded-full ${hit?BAR_TONE[hit.tone]:"bg-[var(--zg-chart-1)]"}`,style:{width:`${share*100}%`}})}),shown]})}return cellText(cell,format,cellUnit,nf)}}]}),rows=cellRows.map((cells,index)=>({index,cells})),caption=str(p.caption),highlight=typeof p.highlight=="number"?p.highlight:typeof p.highlight=="string"?cellRows.findIndex(cells=>{const first=rawCell(cells[0]);return first!==null&&String(first)===p.highlight}):void 0,note=keys.length>0?keys.join(" "):void 0,detail=detailAt>=0?row=>{const cell=row.cells[detailAt];return typeof cell=="number"?nf.number(cell):typeof cell=="string"&&cell!==""?cell:null}:void 0,filtered=p.filterColumn!==void 0&&p.filterColumn!==null,autoTotals=p.totals!==!0&&filtered&&[...summed.values()].some(s=>s.money),totals=p.totals===!0&&summed.size>0||autoTotals?shown=>{const out={};for(const[c,{text,mean,money}]of summed){if(autoTotals&&!money)continue;let sum=0,count=0;for(const row of shown){const cell=row.cells[c];typeof cell=="number"&&(sum+=cell,count++)}mean&&count===0||(out[String(c)]=text(mean?sum/count:sum))}return out}:void 0,filterAt=typeof p.filterColumn=="number"?p.filterColumn:typeof p.filterColumn=="string"?specs.findIndex(spec=>str(spec.label)===p.filterColumn):-1,bind=str(p.filterBind),bound=bind!==void 0&&scope!==null&&scope.live,boundValue=bound?scope.values[bind]:void 0,filterBar=filterAt>=0&&filterAt<specs.length&&filterAt!==detailAt?bound?{column:String(filterAt),value:(typeof boundValue=="string"||typeof boundValue=="number")&&String(boundValue)||null,onChange:value=>scope.set(bind,value??"")}:{column:String(filterAt),value:ownFilter,onChange:setOwnFilter}:void 0,table={...highlight!==void 0&&highlight>=0?{highlight:row=>row.index===highlight}:{},columns,rows,rowKey:row=>row.index,framed:!1,search:many,pageSize:50,...detail?{detail}:{},...totals?{totals}:{},...totals&&filterBar?{totalsAbove:!0}:{},...filterBar?{filterBar}:{},...caption?{caption,label:caption}:{},...note?{note}:{},...lead?{toolbarLead:lead}:{}};return acts&&stored&&path?jsxRuntimeExports.jsx(reactExports.Suspense,{fallback:jsxRuntimeExports.jsx("div",{className:"contents","data-zg-view-pending":"",children:jsxRuntimeExports.jsx(Table,{...table})}),children:jsxRuntimeExports.jsx(SessionRowsPart,{table,rowAction,target:{ref:stored.ref,path}})}):jsxRuntimeExports.jsx(Table,{...table})});ViewTable.displayName="ViewTable";export{ViewTable};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{p,h}from"./DKTLEL5E-CJTkVtjr.js";import{x,D,O,M,$,V,W,G,P,H,j,z,B,U,v}from"./EXE5EH6O-
|
|
1
|
+
import{p,h}from"./DKTLEL5E-CJTkVtjr.js";import{x,D,O,M,$,V,W,G,P,H,j,z,B,U,v}from"./EXE5EH6O-Cbj5xPKl.js";import{d as cn,c as ce,_ as _n}from"./EFYWJBJK-CFT5CQUG.js";import{I as It$1,g as gt,Y as Yt$2}from"./BGW36YJW-BAwgTZ_z.js";import{R,O as Ot,T as Tn,Y as Yt$1,m}from"./lazy-CUmWiDAP.js";import"./kit-CD3F-f6F.js";import"./vendor-react-CxJ4vs-5.js";import"./vendor-motion-C2jPaSqL.js";import"./vendor-owxl31sT.js";import"./core-Cj89wpQh.js";import"./vendor-editor-gVJMCtGz.js";function It(s){throw new R(s,"semantic",{type:"architecture"})}var Kt=class{type="architecture";title;accTitle;accDescr;nodes=new Map;groups=new Map;edges=[];layoutHints=[];registered=new Map;register(e,o,c){this.registered.has(o)&&It(`The ${e} id [${o}] is already in use by another ${this.registered.get(o)}`),c!==void 0&&(o===c&&It(`The ${e} [${o}] cannot be placed within itself`),this.registered.has(c)||It(`The ${e} [${o}]'s parent does not exist. Please make sure the parent is created before this ${e}`),this.registered.get(c)==="node"&&It(`The ${e} [${o}]'s parent is not a group`)),this.registered.set(o,e==="group"?"group":"node")}addService({id:e,icon:o,iconText:c,title:i,in:r}){this.register("service",e,r),this.nodes.set(e,{id:e,type:"service",icon:o,iconText:c,title:i,in:r})}addJunction({id:e,in:o}){this.register("junction",e,o),this.nodes.set(e,{id:e,type:"junction",in:o})}addGroup({id:e,icon:o,title:c,in:i}){this.register("group",e,i),this.groups.set(e,{id:e,icon:o,title:c,in:i})}addEdge({lhsId:e,rhsId:o,lhsDir:c,rhsDir:i,lhsInto:r,rhsInto:h2,lhsGroup:b,rhsGroup:l,title:M2}){let $2=[["left",e,b],["right",o,l]];for(let[p2,I]of $2)this.registered.has(I)||It(`The ${p2}-hand id [${I}] does not yet exist. Please create the service/group before declaring an edge to it.`);for(let[p2,I]of $2)this.nodes.has(I)||It(`The ${p2}-hand id [${I}] is a group. Add {group} to a service inside it instead.`);let x2=this.nodes.get(e).in;if(x2!==void 0&&x2===this.nodes.get(o).in)for(let[p2,I,T]of $2)T&&It(`The ${p2}-hand id [${I}] is modified to traverse the group boundary, but the edge does not pass through two groups.`);this.edges.push({lhsId:e,lhsDir:c,lhsInto:r,lhsGroup:b,rhsId:o,rhsDir:i,rhsInto:h2,rhsGroup:l,title:M2})}addLayoutHint(e){e.members.length<2&&It(`An align directive requires at least two members; got ${e.members.length}`);let o=new Set;for(let c of e.members)this.registered.get(c)!=="node"&&It(`align ${e.direction} references [${c}], which is not a service or junction`),o.has(c)&&It(`align ${e.direction} lists [${c}] more than once`),o.add(c);this.layoutHints.push(e)}};function Ee(s,e){s.accDescr&&(e.accDescr=s.accDescr.replace(/\n\s+/g,`
|
|
2
2
|
`)),s.accTitle&&(e.accTitle=s.accTitle.replace(/^\s+/g,"")),s.title&&(e.title=s.title);for(let o of s.groups)e.addGroup(o);for(let o of s.services)e.addService(o);for(let o of s.junctions)e.addJunction(o);for(let o of s.edges)e.addEdge(o);for(let o of s.alignments)e.addLayoutHint({direction:o.direction,members:[...o.members]})}var De={name:"ID",pattern:/[\w]([-\w]*\w)?/y};function Gt(s){return{name:s,pattern:s,longer:[De]}}var Le=[Gt("architecture-beta"),Gt("junction"),Gt("service"),Gt("column"),Gt("group"),Gt("align"),Gt("row"),{name:"--",pattern:"--",longer:[O]},Gt("in"),{name:":",pattern:":"},{name:"-",pattern:"-",longer:[O]},{name:"ARROW_DIRECTION",pattern:/L|R|T|B/y},{name:"ARROW_GROUP",pattern:/\{group\}/y},{name:"ARROW_INTO",pattern:/<|>/y},M,$,v(String.raw`[-\w]*\w`),V,De,W,G,O,P,H,{name:"ARCH_ICON",pattern:/\([\w-:]+\)/y},{name:"ARCH_TITLE",pattern:/\[(?:"([^"\\]|\\.)*"|'([^'\\]|\\.)*'|[^\[\]\r\n]+)\]/y}];function oe(s){let e=s.slice(1,-1).trim();return(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1).replace(/\\"/g,'"').replace(/\\'/g,"'")),e.trim()}function Ge(s){let e=new x(D(s,Le,"architecture"),Le,"architecture"),o={$type:"Architecture",groups:[],services:[],junctions:[],edges:[],alignments:[]},c=r=>e.kinds[e.i]===r,i=()=>{if(e.kind!==-1)for(e.kind!==19&&e.fail("a line break or the end of input");e.kind===19;)e.i++};for(;e.kind===19;)e.i++;for(e.expect(0);e.kind!==-1;){switch(e.kind){case 19:e.i++;continue;case 14:o.accDescr=U(e.take());break;case 15:o.accTitle=B(e.take());break;case 16:o.title=z(e.take());break;case 4:{e.i++;let r={$type:"Group",id:e.expect(18)};c(24)&&(r.icon=e.take().slice(1,-1)),c(25)&&(r.title=oe(e.take())),e.accept(8)&&(r.in=e.expect(18)),o.groups.push(r);break}case 2:{e.i++;let r={$type:"Service",id:e.expect(18)};c(17)?r.iconText=j(e.take()):c(24)&&(r.icon=e.take().slice(1,-1)),c(25)&&(r.title=oe(e.take())),e.accept(8)&&(r.in=e.expect(18)),o.services.push(r);break}case 1:{e.i++;let r={$type:"Junction",id:e.expect(18)};e.accept(8)&&(r.in=e.expect(18)),o.junctions.push(r);break}case 18:{let r=e.take(),h2=e.accept(12);e.expect(9);let b=e.expect(11),l=e.accept(13),M2;e.accept(7)||(c(10)||e.fail("'--' or '-'"),e.i++,M2=oe(e.expect(25)),e.expect(10));let $2=e.accept(13),x2=e.expect(11);e.expect(9);let p2=e.expect(18),I=e.accept(12);o.edges.push({$type:"Edge",lhsId:r,lhsGroup:h2,lhsDir:b,lhsInto:l,title:M2,rhsInto:$2,rhsDir:x2,rhsId:p2,rhsGroup:I});break}case 5:{e.i++,!c(6)&&!c(3)&&e.fail("'row' or 'column'");let r=e.take(),h2=[e.expect(18),e.expect(18)];for(;c(18);)h2.push(e.take());o.alignments.push({$type:"Alignment",direction:r,members:h2});break}default:e.fail("a group, a service, a junction, an edge, an alignment, a title, or a line break")}i()}return o}var We=new Map([["database","M4 6a8 3 0 1 0 16 0a8 3 0 1 0-16 0M4 6v12a8 3 0 0 0 16 0V6M4 12a8 3 0 0 0 16 0"],["server","M3 4h18v7H3zM3 13h18v7H3zM7 7.5h.01M7 16.5h.01M11 7.5h6M11 16.5h6"],["disk","M5 3h14v18H5zM12 6.5a4 4 0 1 0 0 8a4 4 0 1 0 0-8M12 10.5h.01M8 18h3"],["internet","M3 12a9 9 0 1 0 18 0a9 9 0 1 0-18 0M3 12h18M12 3a13 13 0 0 0 0 18M12 3a13 13 0 0 1 0 18"],["cloud","M7 18a4 4 0 0 1-.5-7.97A6 6 0 0 1 18 9.5a4.25 4.25 0 0 1-.5 8.5z"]]);function Ce(s){let e=We.get(s);return e===void 0?"":`<path d="${e}" stroke="var(--_fg)" stroke-width="1.5"/>`}var Yt=[-1,1,0,0],Qt=[0,0,-1,1];function Wt(s){return s==="L"?0:s==="R"?1:s==="T"?2:3}var je=64,Zt=2**25,He=2**26;function Oe(s,e,o,c){let i=s.length,r=e.length,h2=r,b=new Map,l=new Map,M2=new Int32Array(i+r).fill(h2),$2=new Int32Array(r+1),x2=[];for(let n=0;n<=r;n++)x2.push([]);e.forEach((n,a)=>{l.set(n.id,a);let u=n.in===void 0?void 0:l.get(n.in);u!==void 0&&u!==a?(M2[i+a]=u,$2[a]=$2[u]+1):$2[a]=1}),s.forEach((n,a)=>{b.set(n.id,a);let u=n.in===void 0?void 0:l.get(n.in);u!==void 0&&(M2[a]=u),x2[M2[a]].push(a)});for(let n=0;n<r;n++)x2[M2[i+n]].push(i+n);let p2=[],I=[],T=[],R2=[],E=[],C=[],J=new Array(i+r),ft=new Array(i+r),yt=(n,a,u,g,A)=>{if(n===a)return;let G2=n,H2=a,_=M2[n],v2=M2[a];for(;_!==v2;)$2[_]>=$2[v2]?(G2=i+_,_=M2[G2]):(H2=i+v2,v2=M2[H2]);let Q=p2.length;p2.push(n),I.push(a),T.push(u),R2.push(g),E.push(G2),C.push(H2),(A[G2]??=[]).push(Q),(A[H2]??=[]).push(Q)};for(let n of c){let a=n.direction==="row";for(let u=1;u<n.members.length;u++){let g=b.get(n.members[u-1]),A=b.get(n.members[u]);g!==void 0&&A!==void 0&&yt(g,A,a?1:3,a?0:2,J)}}for(let n of[!1,!0])for(let a of o){if(a.lhsDir===a.rhsDir!==n)continue;let u=b.get(a.lhsId),g=b.get(a.rhsId);u!==void 0&&g!==void 0&&yt(u,g,Wt(a.lhsDir),Wt(a.rhsDir),ft)}let z2=new Int32Array(i+r),O2=new Int32Array(i+r),B2=new Int32Array(i+r).fill(1),W2=new Int32Array(i+r).fill(1),bt=new Uint8Array(i+r),j2=[],pt=new Map,nt=[],xt=new Map,kt=0,gt2=0,wt=0,rt=(n,a)=>{gt2=0,wt=0;for(let u=n;u!==a;u=i+M2[u])gt2+=z2[u],wt+=O2[u]},ct=(n,a,u)=>{if(z2[n]=a,O2[n]=u,bt[n]=1,j2.push(n),B2[n]*W2[n]>je){nt.push(n);return}for(let g=u;g<u+W2[n];g++)for(let A=a;A<a+B2[n];A++)pt.set((A+Zt)*He+g+Zt,n)},Ct=(n,a,u,g,A)=>z2[n]<a+g&&a<z2[n]+B2[n]&&O2[n]<u+A&&u<O2[n]+W2[n],Jt=(n,a,u,g)=>{if(u*g>je){for(let A=kt;A<j2.length;A++)if(Ct(j2[A],n,a,u,g))return j2[A];return-1}for(let A=a;A<a+g;A++)for(let G2=n;G2<n+u;G2++){let H2=pt.get((G2+Zt)*He+A+Zt);if(H2!==void 0)return H2}for(let A of nt)if(Ct(A,n,a,u,g))return A;return-1},Tt=(n,a,u,g,A,G2)=>{let H2=`${n},${a},${u},${g},${A},${G2}`,_=xt.get(H2)??0;for(;;){let v2=Jt(n+_*A,a+_*G2,u,g);if(v2<0)break;_=A>0?z2[v2]+B2[v2]-n:A<0?n+u-z2[v2]:G2>0?O2[v2]+W2[v2]-a:a+g-O2[v2]}return xt.set(H2,_),_},_t=(n,a)=>{let u=E[a]===n,g=u?C[a]:E[a];if(bt[g])return;let A=u?T[a]:R2[a],G2=u?R2[a]:T[a];rt(u?p2[a]:I[a],n);let H2=gt2,_=wt;rt(u?I[a]:p2[a],g);let v2=Yt[A],Q=Qt[A],Dt=0,V2=0,st=Yt[A]+Yt[G2]===0&&Qt[A]+Qt[G2]===0;A===G2?(v2=Yt[A]===0?1:0,Q=1-v2):st||(Dt=-Yt[G2],V2=-Qt[G2]);let F,X;if(v2!==0?(F=v2>0?z2[n]+B2[n]:z2[n]-B2[g],X=O2[n]+_+V2-wt):(X=Q>0?O2[n]+W2[n]:O2[n]-W2[g],F=z2[n]+H2+Dt-gt2),st){let k=ft[g];if(k!==void 0&&k.length>1){let N=[];for(let Y of k){let tt=C[Y]===g,jt=tt?E[Y]:C[Y];if(!bt[jt]||(tt?T[Y]:R2[Y])!==A||(tt?R2[Y]:T[Y])!==G2)continue;rt(tt?p2[Y]:I[Y],jt);let Ft=v2!==0?O2[jt]+wt:z2[jt]+gt2;rt(tt?I[Y]:p2[Y],g),N.push(Ft-(v2!==0?wt:gt2))}N.length>1&&(N.sort((Y,tt)=>Y-tt),v2!==0?X=N[N.length-1>>1]:F=N[N.length-1>>1])}let P2=v2===0?1:0,q=1-P2,it=Tt(F,X,B2[g],W2[g],P2,q),Z=it===0?0:Tt(F,X,B2[g],W2[g],-P2,-q),at=it<=Z?it:-Z;F+=P2*at,X+=q*at}else{let k=Tt(F,X,B2[g],W2[g],v2,Q);F+=v2*k,X+=Q*k}ct(g,F,X)},At=n=>{let a=x2[n];if(a.length===0)return;j2.length=0;let u=[];for(let k of a){if(bt[k])continue;kt=j2.length,u.push(kt),pt.clear(),nt.length=0,xt.clear(),ct(k,0,0);let P2=kt,q=kt,it=0;for(;;){if(P2<j2.length){let at=j2[P2++],N=J[at];if(N!==void 0)for(let Y of N)_t(at,Y);continue}if(q>=j2.length)break;let Z=ft[j2[q]];if(Z===void 0||it>=Z.length){q++,it=0;continue}_t(j2[q],Z[it++])}}u.push(j2.length);let g=u.length-1,A=new Array(g),G2=new Array(g),H2=new Array(g),_=new Array(g),v2=0,Q=0;for(let k=0;k<g;k++){let P2=1/0,q=1/0,it=-1/0,Z=-1/0;for(let at=u[k];at<u[k+1];at++){let N=j2[at];P2=Math.min(P2,z2[N]),q=Math.min(q,O2[N]),it=Math.max(it,z2[N]+B2[N]),Z=Math.max(Z,O2[N]+W2[N])}A[k]=P2,G2[k]=q,H2[k]=it-P2,_[k]=Z-q,v2+=H2[k]*_[k],Q=Math.max(Q,H2[k])}let Dt=Math.max(Q,Math.ceil(Math.sqrt(v2*2))),V2=0,st=0,F=0,X=0;for(let k=0;k<g;k++){V2>0&&V2+H2[k]>Dt&&(st+=F,V2=0,F=0);for(let P2=u[k];P2<u[k+1];P2++)z2[j2[P2]]+=V2-A[k],O2[j2[P2]]+=st-G2[k];V2+=H2[k],F=Math.max(F,_[k]),X=Math.max(X,V2)}n<r&&(B2[i+n]=X,W2[i+n]=st+F)};for(let n=r-1;n>=0;n--)At(n);At(h2);let ot=new Int32Array(r),mt=new Int32Array(r),Mt=new Int32Array(r),Rt=new Uint8Array(r);for(let n=0;n<r;n++){let a=M2[i+n];Mt[n]=a===h2?-1:a,ot[n]=z2[i+n]+(a===h2?0:ot[a]),mt[n]=O2[i+n]+(a===h2?0:mt[a]),x2[n].length===0&&(Rt[n]=1)}let St=new Int32Array(i),Et=new Int32Array(i),Lt=new Int32Array(i);for(let n=0;n<i;n++){let a=M2[n];Lt[n]=a===h2?-1:a,St[n]=z2[n]+(a===h2?0:ot[a]),Et[n]=O2[n]+(a===h2?0:mt[a])}return{col:St,row:Et,groupCol:ot,groupRow:mt,groupCols:B2.slice(i),groupRows:W2.slice(i),groupParent:Mt,groupEmpty:Rt,nodeParent:Lt}}var et=12,Je=6,_e=4,Fe=3,Ve=[-1,1,0,0],Ue=[0,0,-1,1];function ie(s,e,o,c,i){let r=s.architecture,h2=r!==null&&typeof r=="object"&&!Array.isArray(r)?r[e]:void 0;return typeof h2=="number"&&Number.isFinite(h2)?Math.min(i,Math.max(c,h2)):o}function Ne(s){let e=new Map;for(let o of s.sort((c,i)=>c-i))e.has(o)||e.set(o,e.size);return e}function ze(s,e,o,c,i){return`<svg class="pele-icon" data-icon="${Tn(s)}" x="${m(e)}" y="${m(o)}" width="${m(c)}" height="${m(c)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i?.(s)??Ce(s)}</svg>`}function qe(s,e,o,c){let i=s.lines.length>o;if(!i&&s.width<=e)return s;let r=c.width("…",s.size,0),h2=[],b=[],l=0;for(let M2=0;M2<Math.min(o,s.lines.length);M2++){let $2=s.lines[M2].map(p2=>({...p2})),x2=s.widths[M2];if(x2>e||i&&M2===o-1)for(;;){let p2=$2[$2.length-1];if(p2===void 0){$2.push({text:"…",style:0,width:r}),x2=r;break}let I=x2-p2.width;if(p2.icon===void 0&&I+r<e){let T=0,R2=p2.text.length;for(;T<R2;){let C=T+R2+1>>1;I+c.width(p2.text.slice(0,C),s.size,p2.style)+r<=e?T=C:R2=C-1}let E=T>0?p2.text.charCodeAt(T-1):0;E>=55296&&E<=56319&&T--,p2.text=p2.text.slice(0,T).trimEnd()+"…",p2.width=c.width(p2.text,s.size,p2.style),x2=I+p2.width;break}$2.pop(),x2=I}h2.push($2),b.push(x2),l=Math.max(l,x2)}return{...s,lines:h2,widths:b,width:l,height:h2.length*s.lineHeight}}function Ke(s,e){let{x:o,y:c,dx:i,dy:r}=s,{x:h2,y:b,dx:l,dy:M2}=e,$2=o+i*et,x2=c+r*et,p2=h2+l*et,I=b+M2*et;if(i*l+r*M2===0){let C=i!==0?h2:o,J=i!==0?c:b;return(C-o)*i+(J-c)*r>0&&(C-h2)*l+(J-b)*M2>0?[o,c,C,J,h2,b]:i!==0?[o,c,$2,x2,$2,I,p2,I,h2,b]:[o,c,$2,x2,p2,x2,p2,I,h2,b]}let T=i!==0,R2=T?b-c:h2-o;if(i===-l&&r===-M2){if((h2-o)*i+(b-c)*r>0){if(Math.abs(R2)<.5)return[o,c,h2,b];if(T){let z2=i>0?s.x1:e.x1,O2=i>0?e.x0:s.x0,B2=z2<O2?(z2+O2)/2:(o+h2)/2;return[o,c,B2,c,B2,b,h2,b]}let J=r>0?s.y1:e.y1,ft=r>0?e.y0:s.y0,yt=J<ft?(J+ft)/2:(c+b)/2;return[o,c,o,yt,h2,yt,h2,b]}}else if(Math.abs(R2)>=1){if(T){let J=i>0?Math.max(o,h2)+et:Math.min(o,h2)-et;return[o,c,J,c,J,b,h2,b]}let C=r>0?Math.max(c,b)+et:Math.min(c,b)-et;return[o,c,o,C,h2,C,h2,b]}if(T){let C=s.y1+et<=e.y0?(s.y1+e.y0)/2:e.y1+et<=s.y0?(e.y1+s.y0)/2:Math.max(s.y1,e.y1)+et;return[o,c,$2,c,$2,C,p2,C,p2,b,h2,b]}let E=s.x1+et<=e.x0?(s.x1+e.x0)/2:e.x1+et<=s.x0?(e.x1+s.x0)/2:Math.max(s.x1,e.x1)+et;return[o,c,o,x2,E,x2,E,I,h2,I,h2,b]}function Qe(s){let e=[s[0],s[1]];for(let o=2;o<s.length;o+=2){let c=s[o],i=s[o+1],r=e.length,h2=Math.abs(c-e[r-2])<.01,b=Math.abs(i-e[r-1])<.01;h2&&b||(r>=4&&(h2&&Math.abs(e[r-4]-e[r-2])<.01||b&&Math.abs(e[r-3]-e[r-1])<.01)?(e[r-2]=c,e[r-1]=i):e.push(c,i))}return e}function Ze(s,e,o){let c=s.length/2,i=new Array(c),r=new Array(c);for(let l=0;l<c;l++)i[l]=s[l*2],r[l]=s[l*2+1];let h2=(l,M2,$2)=>{let x2=Math.hypot(i[M2]-i[l],r[M2]-r[l]),p2=Math.min($2,Math.max(0,x2-1));x2>0&&p2>0&&(i[l]+=(i[M2]-i[l])/x2*p2,r[l]+=(r[M2]-r[l])/x2*p2)};h2(0,1,e),h2(c-1,c-2,o);let b=`M${m(i[0])},${m(r[0])}`;for(let l=1;l<c-1;l++){let M2=Math.hypot(i[l]-i[l-1],r[l]-r[l-1]),$2=Math.hypot(i[l+1]-i[l],r[l+1]-r[l]),x2=Math.min(Je,M2/2,$2/2);if(x2<.5){b+=`L${m(i[l])},${m(r[l])}`;continue}let p2=i[l]-(i[l]-i[l-1])/M2*x2,I=r[l]-(r[l]-r[l-1])/M2*x2,T=i[l]+(i[l+1]-i[l])/$2*x2,R2=r[l]+(r[l+1]-r[l])/$2*x2;b+=`L${m(p2)},${m(I)}Q${m(i[l])},${m(r[l])} ${m(T)},${m(R2)}`}return b+`L${m(i[c-1])},${m(r[c-1])}`}function Pe(s,e,o){return p(o,c=>tn(s,e,o,c))}function tn(s,e,o,c){let i=ie(e,"iconSize",48,8,512),r=ie(e,"fontSize",o.fontSize??16,4,128),h$1=Math.min(ie(e,"padding",20,0,256),c?12:1/0),b=Math.round(r*.875),l=o.measurer??Ot(o.fontFamily,o.fontFamilyMono),M2=o.padding??8,$2=o.icons,x2=i/2,p2=[...s.nodes.values()],I=[...s.groups.values()],T=p2.length,R2=I.length,E=Oe(p2,I,s.edges,s.layoutHints),C=new Map;p2.forEach((t,f)=>C.set(t.id,f));let J=new Array(T),ft=new Float64Array(T),yt=new Float64Array(T),z2=c?Math.max(i,64):Math.max(i*2.25,96);for(let t=0;t<T;t++){let f=p2[t],y=It$1(f.type==="service"?f.title:void 0,!0,l,r,z2);J[t]=y,ft[t]=Math.max(i,2*Math.ceil(y.width/2)),yt[t]=i+(y.height>0?_e+y.height:0)}let O2=[],B2=[];for(let t=0;t<T;t++)O2.push(E.col[t]),B2.push(E.row[t]);for(let t=0;t<R2;t++)E.groupEmpty[t]&&(O2.push(E.groupCol[t]),B2.push(E.groupRow[t]));let W2=Ne(O2),bt=Ne(B2),j2=W2.size,pt=bt.size,nt=new Float64Array(j2),xt=new Float64Array(pt),kt=c?Math.max(24,2*et):Math.max(40,Math.round(i*.75)),gt$1=new Float64Array(j2).fill(kt),wt=new Float64Array(pt).fill(kt),rt=new Int32Array(T),ct=new Int32Array(T);for(let t=0;t<T;t++){let f=rt[t]=W2.get(E.col[t]),y=ct[t]=bt.get(E.row[t]);nt[f]=Math.max(nt[f],ft[t]),xt[y]=Math.max(xt[y],yt[t])}for(let t=0;t<R2;t++){if(!E.groupEmpty[t])continue;let f=W2.get(E.groupCol[t]),y=bt.get(E.groupRow[t]);nt[f]=Math.max(nt[f],i),xt[y]=Math.max(xt[y],x2)}let Ct=s.edges.length,Jt=new Array(Ct),Tt=new Int32Array(Ct*2);for(let t=0;t<Ct;t++){let f=s.edges[t],y=Tt[t*2]=C.get(f.lhsId)??-1,S=Tt[t*2+1]=C.get(f.rhsId)??-1,w=It$1(f.title,!0,l,b,160);if(Jt[t]=w,!(w.width===0||y<0||S<0)){if(rt[y]!==rt[S]){let m2=Math.min(rt[y],rt[S]);gt$1[m2]=Math.max(gt$1[m2],Math.ceil(w.width)+28)}else if(nt[rt[y]]=Math.max(nt[rt[y]],2*Math.ceil(w.width/2)+8),ct[y]!==ct[S]){let m2=Math.min(ct[y],ct[S]);wt[m2]=Math.max(wt[m2],Math.ceil(w.height)+24)}}}let _t=new Array(R2),At=new Int32Array(R2),ot=new Int32Array(R2),mt=new Int32Array(R2),Mt=new Int32Array(R2),Rt=new Float64Array(R2),St=new Float64Array(R2),Et=new Float64Array(R2),Lt=new Float64Array(R2),n=new Float64Array(R2),a=new Float64Array(R2),u=new Float64Array(j2),g=new Float64Array(j2),A=new Float64Array(pt),G2=new Float64Array(pt),H2=Math.round(r*1.25);for(let t=0;t<R2;t++){At[t]=W2.get(E.groupCol[t]),ot[t]=W2.get(E.groupCol[t]+E.groupCols[t]-1),mt[t]=bt.get(E.groupRow[t]),Mt[t]=bt.get(E.groupRow[t]+E.groupRows[t]-1);let f=It$1(I[t].title,!0,l,r,c?Math.max(80,h(o)/2):320);_t[t]=f;let y=I[t].icon?H2:0;n[t]=f.width+y+(f.width>0&&y>0?6:0),a[t]=Math.max(f.height,y)}for(let t=R2-1;t>=0;t--){let f=h$1+Rt[t],y=h$1+St[t],S=(a[t]>0?Math.max(h$1,a[t]+12):h$1)+Et[t],w=h$1+Lt[t];if(n[t]>0){let U2=f+y;for(let d=At[t];d<=ot[t];d++)U2+=nt[d]+(d<ot[t]?g[d]+gt$1[d]+u[d+1]:0);n[t]+20>U2&&(y+=Math.ceil(n[t]+20-U2))}Rt[t]=f,St[t]=y,Et[t]=S,Lt[t]=w,u[At[t]]=Math.max(u[At[t]],f),g[ot[t]]=Math.max(g[ot[t]],y),A[mt[t]]=Math.max(A[mt[t]],S),G2[Mt[t]]=Math.max(G2[Mt[t]],w);let m2=E.groupParent[t];m2<0||(At[m2]===At[t]&&(Rt[m2]=Math.max(Rt[m2],f)),ot[m2]===ot[t]&&(St[m2]=Math.max(St[m2],y)),mt[m2]===mt[t]&&(Et[m2]=Math.max(Et[m2],S)),Mt[m2]===Mt[t]&&(Lt[m2]=Math.max(Lt[m2],w)))}let _=new Float64Array(j2),v2=new Float64Array(pt),Q=0;for(let t=0;t<j2;t++)_[t]=Q+u[t],Q=_[t]+nt[t]+g[t]+(t<j2-1?gt$1[t]:0);let Dt=0;for(let t=0;t<pt;t++)v2[t]=Dt+A[t],Dt=v2[t]+xt[t]+G2[t]+(t<pt-1?wt[t]:0);let V2=0,st=0,F=Q,X=Dt,k=t=>_[At[t]]-Rt[t],P2=t=>_[ot[t]]+nt[ot[t]]+St[t],q=t=>v2[mt[t]]-Et[t],it=t=>v2[Mt[t]]+xt[Mt[t]]+Lt[t],Z=t=>_[rt[t]]+nt[rt[t]]/2,at=(t,f,y)=>{let S=Ve[f],w=Ue[f],m2=Z(t),U2=v2[ct[t]],d={x:m2,y:U2+x2,dx:S,dy:w,x0:m2-ft[t]/2,y0:U2,x1:m2+ft[t]/2,y1:U2+yt[t],gap:0,wire:!1};p2[t].type==="junction"?(d.x0=d.x1=m2,d.y0=d.y1=d.y,d.gap=Fe):S!==0?d.x=m2+S*x2:d.y=w<0?U2:U2+yt[t]+(J[t].height>0?2:0);let lt=y?E.nodeParent[t]:-1;return lt>=0&&(d.x0=k(lt),d.x1=P2(lt),d.y0=q(lt),d.y1=it(lt),d.gap=0,d.wire=p2[t].type==="junction",S!==0?d.x=S<0?d.x0:d.x1:d.y=w<0?d.y0:d.y1),d},N="",Y="",tt=[],jt=_n("arrow_point");for(let t=0;t<Ct;t++){let f=s.edges[t],y=Tt[t*2],S=Tt[t*2+1];if(y<0||S<0)continue;let w=at(y,Wt(f.lhsDir),f.lhsGroup),m2=at(S,Wt(f.rhsDir),f.rhsGroup);w.x===m2.x&&w.y===m2.y&&w.dx===m2.dx&&(w.x-=8*Math.abs(w.dy),w.y-=8*Math.abs(w.dx),m2.x+=8*Math.abs(w.dy),m2.y+=8*Math.abs(w.dx));let U2=Ke(w,m2);w.wire&&U2.unshift(Z(y),v2[ct[y]]+x2),m2.wire&&U2.push(Z(S),v2[ct[S]]+x2);let d=Qe(U2);if(d.length<4)continue;let lt=Tn(`${f.lhsId}-${f.rhsId}`);N+=`<g class="pele-edge" data-id="${lt}"><path d="${Ze(d,f.lhsInto&&!w.wire?jt+w.gap:0,f.rhsInto&&!m2.wire?jt+m2.gap:0)}"/>`+(f.lhsInto?cn("arrow_point",w.x+w.dx*w.gap,w.y+w.dy*w.gap,-w.dx,-w.dy,"var(--_l)"):"")+(f.rhsInto?cn("arrow_point",m2.x+m2.dx*m2.gap,m2.y+m2.dy*m2.gap,-m2.dx,-m2.dy,"var(--_l)"):"")+"</g>";let $t=-1,zt=-1,Pt=-1,K=-1,ut=Jt[t];for(let L=0;L<d.length;L+=2)V2=Math.min(V2,d[L]-4),F=Math.max(F,d[L]+4),st=Math.min(st,d[L+1]-4),X=Math.max(X,d[L+1]+4);for(let L=0;L+3<d.length;L+=2){let vt=Math.abs(d[L+1]-d[L+3])<.01,ht=Math.abs(d[L]-d[L+2])+Math.abs(d[L+1]-d[L+3]);vt||tt.push(d[L],Math.min(d[L+1],d[L+3]),Math.max(d[L+1],d[L+3])),ht>zt&&($t=L,zt=ht),vt&&ht>K&&(Pt=L,K=ht)}if(ut.width>0){let L=K>=ut.width+8?Pt:$t,vt=(d[L]+d[L+2])/2,ht=(d[L+1]+d[L+3])/2,Ht=ut.width+8,Ye=Math.abs(d[L]-d[L+2])<.01;for(let dt of[w,m2])vt+Ht/2<=dt.x0||vt-Ht/2>=dt.x1||ht+ut.height/2<=dt.y0||ht-ut.height/2>=dt.y1||(Ye?vt=vt>=(dt.x0+dt.x1)/2?dt.x1+Ht/2+4:dt.x0-Ht/2-4:ht=ht>=(dt.y0+dt.y1)/2?dt.y1+ut.height/2+4:dt.y0-ut.height/2-4);V2=Math.min(V2,vt-Ht/2),F=Math.max(F,vt+Ht/2),st=Math.min(st,ht-ut.height/2),X=Math.max(X,ht+ut.height/2),Y+=ce(`${f.lhsId}-${f.rhsId}`,ut,vt,ht,"",$2)}}let Ft="";for(let t=0;t<R2;t++){let f=I[t],y=k(t),S=q(t),w=P2(t)-y,m$1=_t[t],U2="";if(n[t]>0){let d=S+a[t]+12,lt=[];for(let K=0;K<tt.length;K+=3)tt[K+1]<d&&tt[K+2]>S&&tt[K]>y&&tt[K]<y+w&<.push(tt[K]);lt.sort((K,ut)=>K-ut),lt.push(y+w-4);let $t=y+10;for(let K of lt){if(K-6-$t>=n[t])break;$t=Math.max($t,K+6)}$t+n[t]>y+w-4&&($t=y+10);let zt=S+6+a[t]/2,Pt=$t;f.icon&&(U2+=ze(f.icon,$t,zt-H2/2,H2,$2),Pt+=H2+6),U2+=Yt$1(m$1,Pt+m$1.width/2,zt,' class="pele-cluster-label" fill="var(--_m)"',$2)}Ft+=`<g class="pele-cluster" data-id="${Tn(f.id)}"><rect x="${m(y)}" y="${m(S)}" width="${m(w)}" height="${m(it(t)-S)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${gt}/>`+U2+"</g>"}let Vt="",te=i*.5,se=Math.max(6,Math.round(r*.75));for(let t=0;t<T;t++){let f=p2[t],y=`data-id="${Tn(f.id)}" transform="translate(${m(Z(t))},${m(v2[ct[t]])})"`;if(f.type==="junction"){Vt+=`<g class="pele-node pele-junction" ${y}><circle cy="${m(x2)}" r="${Fe}" fill="var(--_l)"/></g>`;continue}let S="";if(f.icon)S=ze(f.icon,-te/2,(i-te)/2,te,$2);else if(f.iconText){let w=It$1(f.iconText,!1,l,se,i-8),m2=Math.max(1,Math.floor((i-4)/(w.lineHeight||1)));S=Yt$1(qe(w,i-8,m2,l),0,x2,` class="pele-icon-text" font-size="${se}"`,$2)}Vt+=`<g class="pele-node pele-service" ${y}><rect x="${m(-x2)}" width="${m(i)}" height="${m(i)}" fill="var(--_s)" stroke="var(--_b)"${gt}/>`+S+Yt$1(J[t],0,i+_e+J[t].height/2,' class="pele-label"',$2)+"</g>"}let Nt=It$1(s.title,!1,l,r,c?h(o):4e3,1),ce$1=Nt.height>0?Nt.height+12:0,Ut=Math.ceil(Math.max(F-V2,Nt.width)+2*M2),ae=Math.ceil(X-st+ce$1+2*M2),Be=Math.round((Ut-(F-V2))/2-V2),Xe=Math.round(M2+ce$1-st),le=(Ft?`<g class="pele-clusters">${Ft}</g>`:"")+(N?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round" stroke-linejoin="round">${N}</g>`:"")+(Y?`<g class="pele-edge-labels" font-size="${b}">${Y}</g>`:"")+(Vt?`<g class="pele-nodes">${Vt}</g>`:"");return{svg:Yt$2("architecture",Ut,ae,r,o,s,Yt$1(Nt,Ut/2,M2+Nt.height/2,' class="pele-title" font-weight="var(--_tw)"')+(le?`<g transform="translate(${Be},${Xe})">${le}</g>`:"")),width:Ut,height:ae,links:[]}}var $n={type:"architecture",parse(s,e,o){let c=new Kt;return o&&(c.title=o),Ee(Ge(s),c),c},render:Pe};export{$n as architecture};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{f,h}from"./DKTLEL5E-CJTkVtjr.js";import{K as Kt,I as It,Y as Yt,F as Ft}from"./BGW36YJW-
|
|
1
|
+
import{f,h}from"./DKTLEL5E-CJTkVtjr.js";import{K as Kt,I as It,Y as Yt,F as Ft}from"./BGW36YJW-BAwgTZ_z.js";import{b as me$1,t as tt$1,i as it,E as Et,n as fe,O as Ot,T as Tn,m,S,Y as Yt$1,R}from"./lazy-CUmWiDAP.js";import"./kit-CD3F-f6F.js";import"./vendor-react-CxJ4vs-5.js";import"./vendor-motion-C2jPaSqL.js";import"./vendor-owxl31sT.js";import"./core-Cj89wpQh.js";import"./vendor-editor-gVJMCtGz.js";var ge=class{type="sankey";nodes=[];links=[];title;accTitle;accDescr;lookup=new Map;findOrCreateNode(r){let o=this.lookup.get(r);return o===void 0&&(o={id:r,index:this.nodes.length},this.lookup.set(r,o),this.nodes.push(o)),o}addLink(r,o,n){this.links.push({source:r,target:o,value:n})}},de=["$end","STUCK","SANKEY","NEWLINE","COMMA","DQUOTE","NON_ESCAPED_TEXT","ESCAPED_TEXT","EOF"];function Fe(t){return t>=32&&t<=126&&t!==34&&t!==44||t>=160&&t<=55295||t>=57344&&t<=65533||t>=65536&&t<=1114111}function Ye(t){let r=t.length,o=[],n=[],u=[],h2=[],i=0,l=0,d=(y,S2,g)=>{o.push(y),n.push(t.slice(S2,g)),u.push(S2),l=g},p=y=>t.slice(l,l+y.length).toLowerCase()===y&&!Et(t.charCodeAt(l+y.length));for(;l<r;){let y=t.charCodeAt(l),S2=l,g=l;if(i===2){if(y===34&&t.charCodeAt(l+1)!==34){h2.length>0&&(i=h2.pop()),d(5,l,l+1);continue}for(;g<r;){let c=t.codePointAt(g);if(Fe(c)||c===44||c===13||c===10)g+=c>65535?2:1;else if(c===34&&t.charCodeAt(g+1)===34)g+=2;else break}d(7,l,g)}else{if(i===0&&(y|32)===115){let c=p("sankey-beta")?11:p("sankey")?6:0;if(c>0){h2.push(i),i=1,d(2,l,l+c);continue}}if(y===10||y===13&&t.charCodeAt(l+1)===10){d(3,l,y===10?l+1:l+2);continue}if(y===44){d(4,l,l+1);continue}if(y===34){h2.push(i),i=2,d(5,l,l+1);continue}for(;g<r;){let c=t.codePointAt(g);if(!Fe(c))break;g+=c>65535?2:1}d(6,l,g)}if(g===S2)return d(1,l,l),{types:o,texts:n,starts:u}}return d(i===2?7:8,r,r),d(0,r,r),{types:o,texts:n,starts:u}}var Ue=/[\n\r]+/g,Ze=/[\x00-\x08\x0b\x0c\x0e-\x1f\ud800-\udfff\ufffe\uffff]/u;function be(t){return t===10||t===13?!1:t<128?t===32||t===9||t===11||t===12:t===160||t===5760||t>=8192&&t<=8202||t===8232||t===8233||t===8239||t===8287||t===12288||t===65279}function Je(t,r){let o=t.length;for(;o>0&&be(t.charCodeAt(o-1));)o--;let n="",u=0,h2=!1;for(let i=0;i<o;){let l=t.charCodeAt(i);if(h2)l===34&&(t.charCodeAt(i+1)===34?i++:h2=!1),i++;else if(l===34)h2=!0,i++;else if(be(l)){let d=i+1;for(;be(t.charCodeAt(d));)d++;let p=t.charCodeAt(i-1),y=t.charCodeAt(d);(i===0||y===10||y===13||(p===10||p===13)&&y!==44)&&(n+=t.slice(u,i),r.push([i,d,0]),u=d),i=d}else i++}return o<t.length&&r.push([o,t.length,0]),n+t.slice(u,o)}function xe(t,r){let o=[],n=Je(t,o),u=n.replace(Ue,`
|
|
2
2
|
`),h2=u.trim();if(r!==void 0){let i=u.length-u.trimStart().length;r.push(o,fe(n,Ue,1),[[0,i,0],[i+h2.length,u.length,0]])}return h2}function Re(t,r,o=t){let{types:n,texts:u,starts:h2}=Ye(t),i=0,l=(g,c)=>{let w=[];o!==t&&xe(o,w);let N=g>0&&g>=t.length?tt$1(w,t.length-1)+1:tt$1(w,g);return it("sankey",o,N,c)},d=g=>{let c=n[i],w=c===1?de[n[i-1]]:de[c];throw l(h2[i],`Expecting ${g}, got '${w}'`)},p=(g,c="")=>{n[i]!==g&&d(`'${de[g]}'${c}`),i++},y=()=>{if(n[i]===6)return u[i++];n[i]!==5&&d("'DQUOTE', 'NON_ESCAPED_TEXT'"),i++,n[i]!==7&&d("'ESCAPED_TEXT'");let g=u[i++];return p(5),g},S2=()=>{let g=h2[i],c=y().trim().replaceAll('""','"');if(Ze.test(me$1(c)))throw l(g,"Invalid XML character in node name");return c};for(p(2),p(3);;){let g=S2();p(4,", 'NEWLINE', 'EOF'");let c=S2();p(4,", 'NEWLINE', 'EOF'");let w=h2[i],N=parseFloat(y());if(!Number.isFinite(N))throw l(w,"Expecting a number");let Z=r.findOrCreateNode(g),T=r.findOrCreateNode(c);if(r.addLink(Z,T,N),n[i]!==3)break;i++}n[i]===8&&i++,n[i]!==0&&d("'NEWLINE', 'EOF'")}var et=6;function Ee(t,r){if(t.length>8){t.sort(r);return}for(let o=1;o<t.length;o++){let n=t[o],u=o-1;for(;u>=0&&r(t[u],n)>0;)t[u+1]=t[u],u--;t[u+1]=n}}function Xe(t,r){let o=t.nodes.length,n=t.links.map(e=>({source:e.source.index,target:e.target.index,value:Number.isFinite(e.value)&&e.value>0?e.value:0,thickness:0,sourceY:0,targetY:0})),u=[],h2=[];for(let e=0;e<o;e++)u.push([]),h2.push([]);n.forEach((e,s)=>{u[e.source].push(s),h2[e.target].push(s)});let i=new Int32Array(o),l=new Int32Array(o),d=[];for(let e=0;e<o;e++)l[e]=h2[e].length,l[e]===0&&d.push(e);for(let e=0;e<d.length;e++){let s=d[e];for(let f2 of u[s]){let m2=n[f2].target;i[m2]<i[s]+1&&(i[m2]=i[s]+1),--l[m2]===0&&d.push(m2)}}if(d.length<o){let e=0;for(;l[e]===0;)e++;let s=new Uint8Array(o);for(;s[e]===0;){s[e]=1;for(let f2 of h2[e])if(l[n[f2].source]>0){e=n[f2].source;break}}throw new R(`Sankey diagrams cannot have circular links, and "${t.nodes[e].id}" is part of one.`,"semantic",{type:"sankey"})}let p=1;for(let e=0;e<o;e++)i[e]+1>p&&(p=i[e]+1);let y=new Int32Array(o);for(let e=o-1;e>=0;e--){let s=d[e];for(let f2 of u[s])y[s]<y[n[f2].target]+1&&(y[s]=y[n[f2].target]+1)}let S2=0;for(let e of n)e.value>S2&&(S2=e.value);let g=S2>0?1/S2:0,c=[],w=new Float64Array(o),N=[];for(let e=0;e<p;e++)N.push([]);let Z=p>1?(r.width-r.nodeWidth)/(p-1):0;for(let e=0;e<o;e++){let s;if(r.alignment==="left")s=i[e];else if(r.alignment==="right")s=p-1-y[e];else if(r.alignment==="center"){if(s=i[e],h2[e].length===0&&u[e].length>0){s=p;for(let L of u[e])i[n[L].target]-1<s&&(s=i[n[L].target]-1)}}else s=u[e].length>0?i[e]:p-1;let f2=0,m2=0,k=0,A=0;for(let L of h2[e])f2+=n[L].value*g,k+=n[L].value;for(let L of u[e])m2+=n[L].value*g,A+=n[L].value;w[e]=Math.max(f2,m2),c.push({layer:s,value:Math.max(k,A),x:s*Z,y:0,height:0}),N[s].push(e)}let T=1;for(let e of N)e.length>T&&(T=e.length);let Y=T>1?Math.min(r.nodePadding,r.height/(T-1)):r.nodePadding,C=1/0;for(let e of N){let s=0;for(let f2 of e)s+=w[f2];s>0&&(C=Math.min(C,(r.height-(e.length-1)*Y)/s))}(!Number.isFinite(C)||C<0)&&(C=0);let Q=Math.max(0,r.labelHeight-Y),z=e=>{for(let s of N){let f2=(s.length-1)*Y;for(let m2 of s)f2+=Math.max(w[m2]*e,Q);if(f2>r.height+1e-6)return!1}return!0};if(Q>0&&!z(C))if(z(0)){let e=0;for(let s=0;s<40;s++){let f2=(e+C)/2;z(f2)?e=f2:C=f2}C=e}else Q=0;let _=new Float64Array(o);for(let e of n)e.thickness=e.value*g*C;for(let e of N){let s=0;for(let m2 of e)c[m2].height=w[m2]*C,_[m2]=Math.max(0,Q-c[m2].height)/2,c[m2].y=s+_[m2],s+=c[m2].height+2*_[m2]+Y;let f2=(r.height-s+Y)/(e.length+1);e.forEach((m2,k)=>c[m2].y+=f2*(k+1))}let M=e=>c[e].y+c[e].height/2,G=new Float64Array(n.length),U=new Float64Array(n.length),le=(e,s)=>M(n[e].target)-M(n[s].target)||e-s,J=(e,s)=>M(n[e].source)-M(n[s].source)||e-s,ee=(e,s)=>M(e)-M(s)||e-s,te=e=>{let s=0;Ee(u[e],le);for(let f2 of u[e])G[f2]=s+n[f2].thickness/2,s+=n[f2].thickness},ne=e=>{let s=0;Ee(h2[e],J);for(let f2 of h2[e])U[f2]=s+n[f2].thickness/2,s+=n[f2].thickness},R$1=()=>{for(let e=0;e<o;e++)te(e),ne(e)},W=(e,s,f2)=>{for(let k of e){let A=f2?h2[k]:u[k];if(A.length===0)continue;f2?ne(k):te(k);let L=0,V=0,ce=0;for(let P of A){let H=f2?c[n[P].source].y+G[P]-U[P]:c[n[P].target].y+U[P]-G[P];L+=H*n[P].thickness,V+=n[P].thickness,ce+=M(f2?n[P].source:n[P].target)-c[k].height/2}let oe=V>0?L/V:ce/A.length;c[k].y+=(oe-c[k].y)*s}Ee(e,ee);let m2=0;for(let k of e)c[k].y-_[k]<m2&&(c[k].y=m2+_[k]),m2=c[k].y+c[k].height+_[k]+Y;m2=r.height;for(let k=e.length-1;k>=0;k--){let A=e[k];c[A].y+c[A].height+_[A]>m2&&(c[A].y=m2-c[A].height-_[A]),m2=c[A].y-_[A]-Y}};R$1();for(let e=0;e<et;e++){let s=Math.pow(.99,e);for(let f2=p-2;f2>=0;f2--)W(N[f2],s,!1);R$1();for(let f2=1;f2<p;f2++)W(N[f2],s,!0);R$1()}for(let e=0;e<n.length;e++)n[e].sourceY=c[n[e].source].y+G[e],n[e].targetY=c[n[e].target].y+U[e];return{nodes:c,links:n}}var K=6,tt=15,nt=1.8,je=300;function ot(t){let r=2166136261,o=5381;for(let n=0;n<t.length;n++){let u=t.charCodeAt(n);r=Math.imul(r^u,16777619),o=Math.imul(o,33)+u|0}return(r>>>0).toString(36)+(o>>>0).toString(36)}function ze(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function me(t,r,o,n,u){let h2=t[r];return typeof h2=="number"&&h2>=n?Math.min(h2,u):o}function Ke(t,r){let o=t[r];return typeof o=="string"||typeof o=="number"&&Number.isFinite(o)?String(o):""}function We(t){return Math.abs(t)<1e15?Math.round(t*100)/100:t}function Qe(t){return typeof t=="string"?Ft([`fill:${t}`]).shape:""}function He(t,r,o){let n=ze(r.sankey)?r.sankey:{},u=me(n,"width",600,1,1e4);return f(o,u,160,h2=>rt(t,n,o,h2,u))}function rt(t,r,o,n,u){let h$1=o.fontSize??16,i=Math.round(h$1*.625),l=Math.max(i,Math.round(h$1*.875*Math.min(1,n/u))),d=o.measurer??Ot(o.fontFamily,o.fontFamilyMono),p=o.padding??8,y=me(r,"height",400,1,1e4),S$1=Math.min(me(r,"nodeWidth",10,1,200),n),g=r.showValues!==!1,c=me$1(Ke(r,"prefix")),w=me$1(Ke(r,"suffix")),N=r.labelStyle==="outlined",Z=r.nodeAlignment==="left"||r.nodeAlignment==="right"||r.nodeAlignment==="center"?r.nodeAlignment:"justify",T=typeof r.linkColor=="string"?r.linkColor:"gradient",Y=a=>Xe(t,{width:n,height:y,nodeWidth:S$1,nodePadding:me(r,"nodePadding",12,0,200)+(g?tt:0),labelHeight:a*1.15,alignment:Z}),C=Y(l),Q=new Map,z=1;for(let a of C.nodes){let x=(Q.get(a.layer)??0)+1;Q.set(a.layer,x),x>z&&(z=x)}let _=Math.max(i,Math.round(y/z/nt));_<l&&(l=_,C=Y(l));let{nodes:M,links:G}=C,U=l*1.5,le=new Map;if(ze(r.nodeColors))for(let[a,x]of Object.entries(r.nodeColors)){let $=Qe(x);$&&le.set(a,$)}let J=a=>le.get(t.nodes[a].id)??"",ee=a=>/^ style="fill:(.*);"$/.exec(J(a))?.[1]??Kt(a),te=0,ne=0;M.forEach(a=>{a.value>ne&&(ne=a.value,te=a.layer)});let R2=0,W=n,e=0,s=y,f2=M.map((a,x)=>{let $=me$1(t.nodes[x].id),v=g?`${c}${We(a.value)}${w}`:"",D=d.width(v?`${$} ${v}`:$,l,0),E=N?a.layer>=te:a.x<n/2,O=E?a.x+S$1+K:a.x-K,F=a.y+a.height/2;return R2=Math.min(R2,E?O:O-D),W=Math.max(W,E?O+D:O),e=Math.min(e,F-l*.75),s=Math.max(s,F+l*.75),{value:v,width:D,after:E,left:E?O:O-D,y:F}}),m$1=new Map;if(M.length<=je)for(let a of f2){let x=Math.floor(a.y/U);for(let $ of[x-2,x-1,x,x+1,x+2]){let v=m$1.get($);v?v.push(a):m$1.set($,[a])}}let k="",A="";M.forEach((a,x)=>{let $=t.nodes[x].id,v=me$1($),D=Math.max(a.height,1);A+=`<rect class="pele-sankey-node" data-id="${Tn($)}" x="${m(a.x)}" y="${m(a.y)}" width="${m(S$1)}" height="${m(D)}" rx="${m(Math.min(2,D/2))}" fill="${Kt(x)}"${J(x)}/>`;let E=f2[x],O=(ue,ie)=>(m$1.get(Math.floor(ie/U))??[]).some(I=>I!==E&&Math.abs(I.y-ie)<U&&ue<I.left+I.width+K&&ue+E.width>I.left-K);if(M.length<=je&&O(E.left,E.y))e:for(let ue of[0,-U,U])for(let ie of[E.after,!E.after]){let I=ie?a.x+S$1+K:a.x-K-E.width,X=E.y+ue;if(O(I,X)||I<R2||I+E.width>W||X-l*.75<e||X+l*.75>s||M.some((j,pe)=>pe!==x&&I<j.x+S$1+K&&I+E.width>j.x-K&&X-l*.75<j.y+j.height&&X+l*.75>j.y))continue;let Ve=Math.max(0,a.y-X,X-a.y-a.height);if(!M.some((j,pe)=>pe!==x&&j.x===a.x&&Math.max(0,j.y-X,X-j.y-j.height)<=Ve)){E.left=I,E.y=X,E.after=ie;break e}}let{value:F,after:re,y:fe2}=E,se=re?a.x+S$1+K:a.x-K,Me=` x="${m(se)}" y="${m(fe2+l*.35)}" text-anchor="${re?"start":"end"}"`,Ge=S(v)+(F?` <tspan class="pele-sankey-value" fill="var(--_m)">${S(F)}</tspan>`:"");k+=`<g class="pele-label" data-id="${Tn($)}">`+(N?`<text${Me} fill="none" stroke="var(--_bg)" stroke-width="3" stroke-linejoin="round">${S(v)}${F?" "+S(F):""}</text>`:"")+`<text${Me}>${Ge}</text></g>`});let L=T==="gradient"||T==="source"||T==="target"?"":Qe(T),V=o.idPrefix??"",ce=T==="gradient"&&/^[\w-]+$/.test(V),oe=new Map,P="";for(let a of G){let x=T==="target"?a.target:a.source,$=Math.max(a.thickness,1)/2,v=M[a.source].x+S$1,D=M[a.target].x,E=`fill="${Kt(x)}"${L||J(x)}`;if(ce){let fe2=`x1="${m(v)}" x2="${m(D)}"><stop offset="0" stop-color="${ee(a.source)}"/><stop offset="1" stop-color="${ee(a.target)}"/>`,se=`${V}-sankey-${ot(fe2)}`;oe.set(se,`<linearGradient id="${se}" gradientUnits="userSpaceOnUse" ${fe2}</linearGradient>`),E=`fill="url(#${se}) ${ee(a.source)}"`}let O=m((v+D)/2),F=Tn(t.nodes[a.source].id),re=Tn(t.nodes[a.target].id);P+=`<path class="pele-sankey-link" data-id="${F}->${re}" d="M${m(v)},${m(a.sourceY-$)}C${O},${m(a.sourceY-$)} ${O},${m(a.targetY-$)} ${m(D)},${m(a.targetY-$)}L${m(D)},${m(a.targetY+$)}C${O},${m(a.targetY+$)} ${O},${m(a.sourceY+$)} ${m(v)},${m(a.sourceY+$)}Z" ${E}><title>${F} → ${re}: ${S(c)}${We(a.value)}${S(w)}</title></path>`}let H=It(t.title,!1,d,h$1,h(o),1),$e=H.height>0?H.height+12:0,Se=Math.max(W-R2,H.width),qe=p-R2+(Se-(W-R2))/2,Be=p+$e-e,ye=Math.ceil(Se+2*p),Ae=Math.ceil(s-e+$e+2*p);return{svg:Yt("sankey",ye,Ae,h$1,o,t,Yt$1(H,ye/2,p+H.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${m(qe)},${m(Be)})">`+(oe.size>0?`<defs>${[...oe.values()].join("")}</defs>`:"")+`<g class="pele-sankey-links" fill-opacity="0.4">${P}</g><g class="pele-sankey-nodes">${A}</g><g class="pele-labels" font-size="${l}">${k}</g></g>`),width:ye,height:Ae,links:[]}}var vt={type:"sankey",parse(t,r,o){let n=new ge;return o&&(n.title=o),Re(xe(t),n,t),n},render:He};export{vt as sankey};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as i$1,a}from"./FTXIJQGB-CtxUBUPE.js";import{h as h$1}from"./7WLXJQOR-DLi5wfxF.js";import{x,h}from"./4LWW3ZNH-
|
|
1
|
+
import{i as i$1,a}from"./FTXIJQGB-CtxUBUPE.js";import{h as h$1}from"./7WLXJQOR-DLi5wfxF.js";import{x,h}from"./4LWW3ZNH-CPyJ9o9Y.js";import{q as qe$1,z as ze$1,_ as _e,j as je$1,H as He$1}from"./VBUCM3YD-C6FrRswP.js";import{A,H,T,U}from"./QQW2P742-D6aitZ24.js";import{o,i,P,F,R as R$1,B}from"./6PIGVMFT-CRGq6eh3.js";import{m,c}from"./DKTLEL5E-CJTkVtjr.js";import{e as ee,_ as _n$1,i as ie,b as ae,o as oe,s as se,d as cn$1,c as ce}from"./EFYWJBJK-CFT5CQUG.js";import{F as Ft$1,I as It,D as Dt,N as Nt,K as Kt$1,Y as Yt$2,C as Ct}from"./BGW36YJW-BAwgTZ_z.js";import{k as we$1,R,V as Ve,O as Ot,T as Tn$1,P as Pt,m as m$1,Y as Yt$1,F as Ft$2,b as me,S,y as ye,t as tt$1,n as fe$1,i as it$1,E as Et}from"./lazy-CUmWiDAP.js";import"./kit-CD3F-f6F.js";import"./vendor-react-CxJ4vs-5.js";import"./vendor-motion-C2jPaSqL.js";import"./vendor-owxl31sT.js";import"./core-Cj89wpQh.js";import"./vendor-editor-gVJMCtGz.js";var nn=new Map([["task","roundedRect"],["tool","subroutine"],["input","lean-right"],["decision","diamond"],["refdoc","lin-doc"],["action","hexagon"],["round","rect"]]),sn=new Set(["doc","stadium","terminal","circle","trapezoid","inv_trapezoid","inv-trapezoid","doublecircle","double-circle","typeDeclaration","procs","lean_left","lean-left","in-out","cylinder","ellipse","odd","tag-rect","tagged-rectangle","delay","half-rounded-rectangle","lin-rect","lined-rectangle","win-pane","window-pane","curv-trap","curved-trapezoid"]),rn=new Set(["roundedRect","subroutine","subprocess","subproc","framed-rectangle","lean-right","diamond","lin-doc","lined-document","hexagon","hex","connector","collapsedGroup"]),Se="roundedRect";function Ee(n){return n&&(nn.get(n)??n)}function $t(n){return a(n)||n==="constructor"}function Kt(n,t){for(let i2 of n)i2.isGroup||((!i2.shape||i2.shape==="squareRect"||i2.shape==="rect")&&(i2.shape=Se),sn.has(i2.shape)?(t.emitError("SHAPE_REMOVED",`shape "${i2.shape}" was removed in v0.8.1, using "${Se}"`,{nodeId:i2.id}),i2.shape=Se):rn.has(i2.shape)||(t.emitWarning("SHAPE_UNSUPPORTED",`shape "${i2.shape}" is not supported, using "${Se}"`,{nodeId:i2.id}),i2.shape=Se))}var on=new Set(["shape","view","icon","img","form","pos","w","h","class","style","labelType"]),an=new Set(["subroutine","subprocess","subproc","framed-rectangle","tool"]);function ln(n){return an.has(n.type)}function He(n){return n==="markdown"||n==="string"||n==="text"?n:"markdown"}function Ft(n){return n.startsWith('"')&&n.endsWith('"')?n.substring(1,n.length-1):n}function Xe(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function dn(n){let t=s=>Array.isArray(s)?[]:Xe(s)?{}:s,i2=t(n),o2=[[n,i2]];for(;o2.length>0;){let[s,r]=o2.pop();if(Array.isArray(s))for(let d of s){let g=t(d);r.push(g),typeof d=="object"&&d!==null&&o2.push([d,g])}else if(Xe(s))for(let d of Object.keys(s)){if(d==="__proto__"||d==="constructor"||d==="prototype")continue;let g=s[d],e=t(g);r[d]=e,typeof g=="object"&&g!==null&&o2.push([g,e])}}return i2}function De(n,t){return Object.assign(n??{},t)}var cn=/:\s*[>|][\d+-]*\s*$/,fn=/,([\t ]*)$/;function un(n){let t=!1,i2=!1,o2=0,s,r=[];for(let d of n.split(`
|
|
2
2
|
`)){if(s!==void 0){let S2=d.length-d.trimStart().length;if(d.trim()===""||S2>s){r.push(d);continue}s=void 0}let g=-1;for(let S2=0;S2<d.length;S2++){let y=d[S2];if(i2)y==="\\"?S2++:y==='"'&&(i2=!1);else if(t)y==="'"&&(t=!1);else if(y==='"')i2=!0;else if(y==="'")t=!0;else if(y==="#"&&(S2===0||d[S2-1]===" "||d[S2-1]===" ")){g=S2;break}else y==="["||y==="{"?o2++:(y==="]"||y==="}")&&(o2=Math.max(0,o2-1))}if(t||i2||o2>0){r.push(d);continue}let e=g>=0?d.slice(0,g):d,_=g>=0?d.slice(g):"";if(cn.test(e)){s=d.length-d.trimStart().length,r.push(d);continue}r.push(e.replace(fn,"$1")+_)}return r.join(`
|
|
3
3
|
`)}function pn(n,t){if(n==="arrow_point"&&t==="normal")return"sequence";if(n==="arrow_cross"&&t==="normal")return"failure";if(n==="arrow_open"&&t==="dotted")return"reference"}function hn(n){let t=n.trim(),i2=t.slice(0,-1),o2="arrow_open";switch(t.slice(-1)){case"x":o2="arrow_cross";break;case">":o2="arrow_point";break;case"-":case".":i2=t;break}let s="normal",r=i2.length-1,d=0;for(let g=0;g<i2.length;g++)i2[g]==="."&&d++;return d>0&&(s="dotted",r=d),{type:o2,stroke:s,length:r}}function Vt(n){if(!n)return;let t={},i2=!1;for(let o2 of Object.keys(n))on.has(o2)||(t[o2]=n[o2],i2=!0);return i2?t:void 0}var we=class{type="agentflow";direction;nodes=new Map;edges=[];subgraphs=[];connectors=new Map;classes=new Map;tooltips=new Map;defaultEdgeStyle;defaultInterpolate;mappings=[];diagnostics=[];title;accTitle;accDescr;lineOffset;subgraphLookup=new Map;globalNodes=new Set;members=new Set;edgeById=new Map;pairCount=new Map;subCount=0;bareMappings=new Set;firstMapping=new Map;reported=new Map;options;constructor(t={}){this.options=t,this.lineOffset=t.lineOffset??0}metadata(t,i2,o2){let s=i2.includes(`
|
|
4
4
|
`),r;try{r=we$1(s?i2+`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{s}from"./5THPTBWS-BahUBl-u.js";import{A}from"./75JW6PN6-
|
|
1
|
+
import{s}from"./5THPTBWS-BahUBl-u.js";import{A}from"./75JW6PN6-CYzAa9yx.js";import{c,h}from"./DKTLEL5E-CJTkVtjr.js";import{x,D,O,M,$,L,V,W,G,P,H,j,z,B,U,Y}from"./EXE5EH6O-Cbj5xPKl.js";import{I as It,g as gt,Y as Yt$1}from"./BGW36YJW-BAwgTZ_z.js";import{R,O as Ot,b as me,m,Y as Yt,S}from"./lazy-CUmWiDAP.js";import"./kit-CD3F-f6F.js";import"./vendor-react-CxJ4vs-5.js";import"./vendor-motion-C2jPaSqL.js";import"./vendor-owxl31sT.js";import"./core-Cj89wpQh.js";import"./vendor-editor-gVJMCtGz.js";var Bt=1e4;function E(e,t,n,r,a){let h2=e.packet?.[t];return typeof h2=="number"&&h2>=r?Math.min(h2,a):n}function _(e){return new R(e,"semantic",{type:"packet"})}function wt(e,t,n){let r=Math.floor(E(t,"bitsPerRow",32,1,4096)),a=[],h2=-1,b=[],$2=1;for(let g of e.blocks){let{start:i,end:m2,bits:p}=g;if(i!==void 0&&m2!==void 0&&m2<i)throw _(`Packet block ${i} - ${m2} is invalid. End must be greater than start.`);if(i??=h2+1,i!==h2+1)throw _(`Packet block ${i} - ${m2??i} is not contiguous. It should start from ${h2+1}.`);if(p===0)throw _(`Packet block ${i} is invalid. Cannot have a zero bit field.`);for(m2??=i+(p??1)-1,p??=m2-i+1,h2=m2;b.length<=r+1&&a.length<Bt;){let x2=$2*r-1;if(m2<=x2){b.push({start:i,end:m2,bits:p,label:g.label}),m2===x2&&(a.push(b),b=[],$2++);break}b.push({start:i,end:x2,bits:x2-i,label:g.label}),a.push(b),b=[],$2++,i=x2+1,p=m2-i}}return b.length>0&&a.push(b),{type:"packet",title:e.title||n,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
|
|
2
2
|
`):void 0,bitsPerRow:r,rows:a}}var Pt=[{name:"packet-beta",pattern:"packet-beta"},Y("packet"),{name:"-",pattern:"-",longer:[O]},{name:"+",pattern:"+"},{name:":",pattern:":"},M,$,L,{name:"INT",pattern:/0|[1-9][0-9]*(?!\.)/y},V,W,G,O,P,H];function Mt(e){let t=new x(D(e,Pt,"packet"),Pt,"packet"),n={$type:"Packet",blocks:[]},r=()=>{if(t.kind!==-1)for(t.kind!==10&&t.fail("a line break or the end of input");t.kind===10;)t.i++};for(;t.kind===10;)t.i++;for(t.accept(0)||t.expect(1);t.kind!==-1;)switch(t.kind){case 10:t.i++;break;case 5:n.accDescr=U(t.take()),r();break;case 6:n.accTitle=B(t.take()),r();break;case 7:n.title=z(t.take()),r();break;case 8:case 3:{let a={$type:"PacketBlock",label:""};t.accept(3)?a.bits=Number(t.expect(8)):(a.start=Number(t.take()),t.accept(2)&&(a.end=Number(t.expect(8)))),t.expect(4),a.label=j(t.expect(9)),n.blocks.push(a),r();break}default:t.fail("a field, a title, or a line break")}return n}function xt(e,t,n){return c(n,r=>Ct(e,t,n,r))}function Ct(e,t,n,r){let a=n.fontSize??16,h$1=Math.round(a*.875),b=Math.round(a*.625),$2=n.measurer??Ot(n.fontFamily,n.fontFamilyMono),g=n.padding??8,i=t.packet??{},m$1=E(t,"rowHeight",32,1,400),p=E(t,"bitWidth",32,1,400),x2=E(t,"paddingX",5,0,400),L2=E(t,"paddingY",5,0,400),W2=i.showBits!==!1,D2=i.bitOrder==="descending",w=e.bitsPerRow,y=e.rows;if(r){let u=Math.max(1,Math.floor(((n.maxWidth??320)-2*g)/Math.min(p,18)));w=Math.min(w,Math.max(8,2**Math.floor(Math.log2(u))));let o=e.rows[e.rows.length-1],c2=o?.[o.length-1]?.end??0;Math.ceil((c2+1)/w)>1e4&&(w=e.bitsPerRow),p=Math.min(p,Math.max(18,((n.maxWidth??320)-2*g)/w));let P2=f=>f.bits===f.end-f.start,l=[];for(let f of e.rows)for(let d of f){let s2=l[l.length-1];s2&&P2(s2)&&P2(d)&&s2.label===d.label&&d.start===s2.end+1&&d.start%e.bitsPerRow===0?(s2.end=d.end,s2.bits=s2.end-s2.start):l.push({...d})}y=[];for(let f of l)for(let d=f.start;d<=f.end;){let s2=Math.min(f.end,(Math.floor(d/w)+1)*w-1),M2=Math.floor(d/w);(y[M2]??(y[M2]=[])).push({...f,start:d,end:s2}),d=s2+1}}let v=new Map;if(r)for(let u of y)for(let o of u){let c2=Math.max(1,(o.end-o.start+1)*p-Math.min(x2,p-1)-6),P2=A(me(o.label).trim(),$2,h$1,c2);v.set(o,P2)}let H2=W2?b+4:0,j2=y.map(u=>{let o=m$1;if(r)for(let c2 of u)o=Math.max(o,v.get(c2).height+10);return o}),F=[],B2=0;for(let u of j2)F.push(B2),B2+=H2+u+L2;y.length&&(B2-=L2);let V2=Math.min(x2,p-1),X=y.length>0?w*p-V2:0,T=It(e.title,!1,$2,a,r?h(n):4e3,1),yt=T.height>0?T.height+(B2>0?12:0):0,Y2=new Map,$t=(u,o)=>{let c2=Y2.get(u);return c2||Y2.set(u,c2=new Map),c2.has(o)||c2.set(o,s(me(u).trim(),o,h$1,Math.round(a*.5),$2)),c2.get(o)},Rt=g+Math.max(0,(T.width-X)/2),A$1="",C="";y.forEach((u,o)=>{let c2=g+F[o]+H2,P2=j2[o];for(let l of u){let f=l.end-l.start+1,d=l.start%w,s2=Rt+(D2?w-d-f:d)*p,M2=f*p-V2,R2=r?void 0:$t(l.label,M2-6);if(A$1+=`<g class="pele-node" data-id="${l.start}-${l.end}"><rect x="${m(s2)}" y="${m(c2)}" width="${m(M2)}" height="${m(P2)}" fill="var(--_s)" stroke="var(--_b)"${gt}/>`+(r?Yt(v.get(l),s2+M2/2,c2+P2/2,""):R2&&R2.size<=P2?`<text x="${m(s2+M2/2)}" y="${m(c2+P2/2+R2.size*.35)}"${R2.size===h$1?"":` font-size="${m(R2.size)}"`}>${S(R2.text)}</text>`:"")+"</g>",!W2)continue;let G2=D2?l.end:l.start,Et=D2?l.start:l.end;f===1?C+=`<text x="${m(s2+M2/2)}" y="${m(c2-4)}" text-anchor="middle">${G2}</text>`:C+=`<text x="${m(s2)}" y="${m(c2-4)}">${G2}</text><text x="${m(s2+M2)}" y="${m(c2-4)}" text-anchor="end">${Et}</text>`}});let z2=Math.ceil(Math.max(X,T.width)+2*g),N=Math.ceil(B2+yt+2*g),Tt=(A$1?`<g class="pele-packet-fields" font-size="${h$1}" text-anchor="middle">${A$1}</g>`:"")+(C?`<g class="pele-packet-bits" font-size="${b}" fill="var(--_m)">${C}</g>`:"")+Yt(T,z2/2,N-g-T.height/2,' class="pele-title" font-weight="var(--_tw)"');return{svg:Yt$1("packet",z2,N,a,n,e,Tt),width:z2,height:N,links:[]}}var Ut={type:"packet",parse:(e,t,n)=>wt(Mt(e),t,n),render:xt};export{Ut as packet};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{x,D,M,$,L,W,G,O,P,H,U,B,z as z$1,Y}from"./EXE5EH6O-
|
|
1
|
+
import{x,D,M,$,L,W,G,O,P,H,U,B,z as z$1,Y}from"./EXE5EH6O-Cbj5xPKl.js";import{I as It,Y as Yt$1}from"./BGW36YJW-BAwgTZ_z.js";import{O as Ot,Y as Yt}from"./lazy-CUmWiDAP.js";import"./kit-CD3F-f6F.js";import"./vendor-react-CxJ4vs-5.js";import"./vendor-motion-C2jPaSqL.js";import"./vendor-owxl31sT.js";import"./core-Cj89wpQh.js";import"./vendor-editor-gVJMCtGz.js";function A(i,e){return{type:"info",title:i.title||e,accTitle:i.accTitle?i.accTitle.replace(/^\s+/g,""):void 0,accDescr:i.accDescr?i.accDescr.replace(/\n\s+/g,`
|
|
2
2
|
`):void 0}}var C=[Y("showInfo"),Y("info"),M,$,L,W,G,O,P,H];function S(i){let e=new x(D(i,C,"info"),C,"info"),t={$type:"Info"};for(;e.kind===5;)e.i++;for(e.expect(1);e.kind===5;)e.i++;if(e.accept(0))for(;e.kind===5;)e.i++;for(;e.kind!==-1;){let s=e.kind;if(s===2?t.accDescr=U(e.take()):s===3?t.accTitle=B(e.take()):s===4?t.title=z$1(e.take()):e.fail("a title or the end of input"),e.kind===-1)break;for(e.kind!==5&&e.fail("a line break or the end of input");e.kind===5;)e.i++}return t}var _="1.13.0";function z(i,e,t){let s=t.fontSize??16,p=t.measurer??Ot(t.fontFamily,t.fontFamilyMono),r=t.padding??8,n=It(i.title,!1,p,s,4e3,1),f=n.height>0?n.height+8:0,o=It(`Pele v${_}`,!1,p,s,4e3),d=Math.ceil(Math.max(n.width,o.width)+2*r),m=Math.ceil(f+o.height+2*r),L2=Yt(n,d/2,r+n.height/2,' class="pele-title" font-weight="var(--_tw)"')+Yt(o,d/2,r+f+o.height/2,' class="pele-version" fill="var(--_m)"');return{svg:Yt$1("info",d,m,s,t,i,L2),width:d,height:m,links:[]}}var Q={type:"info",parse:(i,e,t)=>A(S(i),t),render:z};export{Q as info};
|