@dimina-kit/devtools 0.4.0-dev.20260728110120 → 0.4.0-dev.20260729062524

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.
@@ -1,4 +1,4 @@
1
- import{C as e,E as t,S as n,T as r,_ as i,a,d as o,g as s,h as c,l,n as u,o as d,p as f,r as p,s as m,t as h,u as g,v as _,w as v}from"./ipc-transport-B3EpmfNS.js";import{n as y,r as b,t as x}from"./input-xdmfv-eH.js";import{_ as S,a as C,b as w,d as T,f as E,g as D,h as ee,i as te,l as ne,m as re,n as ie,o as ae,p as oe,r as se,s as ce,t as le,u as ue,v as de,x as O,y as fe}from"./select-CD9CJyhI.js";import{n as pe}from"./constants-EAMiwL9_.js";import{u as me}from"./settings-api-pJKPuP1M.js";var he=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),ge=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),_e=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),ve=e=>{let t=_e(e);return t.charAt(0).toUpperCase()+t.slice(1)},ye={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},be=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},k=t(r()),xe=(0,k.createContext)({}),Se=()=>(0,k.useContext)(xe),Ce=(0,k.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f=`currentColor`,className:p=``}=Se()??{},m=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,k.createElement)(`svg`,{ref:c,...ye,width:t??l??ye.width,height:t??l??ye.height,stroke:e??f,strokeWidth:m,className:he(`lucide`,p,i),...!a&&!be(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,k.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),we=(e,t)=>{let n=(0,k.forwardRef)(({className:n,...r},i)=>(0,k.createElement)(Ce,{ref:i,iconNode:t,className:he(`lucide-${ge(ve(e))}`,`lucide-${e}`,n),...r}));return n.displayName=ve(e),n},Te=we(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Ee=we(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),De=t(e(),1),A=n();function Oe({project:e,onOpen:t,onRemove:n,thumbnail:r}){let[i,a]=(0,k.useState)(!1);return(0,A.jsxs)(`div`,{className:`relative bg-surface border border-border rounded-lg overflow-hidden cursor-pointer transition-all duration-150 hover:border-accent hover:-translate-y-0.5`,onClick:()=>t(e),onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[r?(0,A.jsx)(`img`,{src:r,className:`h-28 w-full object-cover object-top`,alt:``}):(0,A.jsx)(`div`,{className:`h-28 bg-surface-thumb`}),(0,A.jsxs)(`div`,{className:`p-3`,children:[(0,A.jsx)(`div`,{className:`text-sm font-medium text-text-white mb-1 truncate`,title:e.name,children:e.name}),(0,A.jsx)(`div`,{className:`text-[11px] text-text-secondary truncate`,title:e.path,children:e.path}),(0,A.jsx)(`div`,{className:`text-[11px] text-text-dim mt-1.5`,children:b(e.lastOpened)})]}),i&&(0,A.jsx)(O,{variant:`danger`,size:`icon-sm`,className:`absolute top-1.5 right-1.5 w-5 h-5 rounded-full bg-overlay text-text-secondary leading-none hover:text-status-error hover:bg-danger-bg`,onClick:t=>{t.stopPropagation(),n(e)},title:`移除`,children:`×`})]})}function ke(e){return(0,A.jsxs)(`button`,{type:`button`,onClick:e.onClick,"aria-label":`新建项目`,className:`relative bg-transparent border-2 border-dashed border-border rounded-lg overflow-hidden cursor-pointer transition-all duration-150 hover:border-accent hover:-translate-y-0.5 h-full min-h-[188px] flex flex-col items-center justify-center gap-2 text-text-secondary hover:text-accent focus:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,A.jsx)(`span`,{className:`text-3xl leading-none`,"aria-hidden":`true`,children:`+`}),(0,A.jsx)(`span`,{className:`text-sm font-medium`,children:`新建项目`})]})}function Ae({projects:e,onAdd:t,onCreate:n,onOpen:r,onRemove:i,thumbnails:a}){let[o,s]=(0,k.useState)(``),c=(0,k.useMemo)(()=>{if(!o.trim())return e;let t=o.trim().toLowerCase();return e.filter(e=>(e.name||``).toLowerCase().includes(t)||(e.path||``).toLowerCase().includes(t))},[e,o]),l=n??(()=>{}),u=e.length>0&&c.length===0;return(0,A.jsx)(`div`,{className:`flex flex-col h-screen bg-bg`,children:(0,A.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-6 gap-4`,children:[(0,A.jsx)(`div`,{className:`flex items-center flex-1 max-w-xs min-w-0`,children:(0,A.jsxs)(`div`,{className:`relative w-full`,children:[(0,A.jsx)(Te,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-text-secondary pointer-events-none`}),(0,A.jsx)(x,{placeholder:`搜索`,value:o,onChange:e=>s(e.target.value),className:`w-full h-8 pl-8 pr-3 rounded-md text-sm`})]})}),(0,A.jsx)(O,{variant:`ghost`,size:`sm`,onClick:t,className:`shrink-0 text-accent hover:text-accent-hover hover:bg-transparent`,children:`导入`})]}),u?(0,A.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-72 text-text-dim gap-3`,children:[(0,A.jsx)(`span`,{className:`text-5xl opacity-40`,children:`🔍`}),(0,A.jsx)(`span`,{className:`text-sm`,children:`未找到匹配的项目`})]}):(0,A.jsxs)(`div`,{className:`grid gap-4`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(220px, 1fr))`},children:[(0,A.jsx)(ke,{onClick:l}),c.map(e=>(0,A.jsx)(Oe,{project:e,onOpen:r,onRemove:i,thumbnail:a?.[e.path]},e.path))]})]})})}function je(e){return e.trim().replace(/[\\/:*?"<>|]+/g,`-`).replace(/\s+/g,`-`).replace(/-{2,}/g,`-`).replace(/^[-.]+|[-.]+$/g,``)}function Me(e,t){return t?e?e.endsWith(`/`)?`${e}${t}`:`${e}/${t}`:t:``}function Ne(e){let{open:t,templates:n,defaultBaseDir:r,onSubmit:i,onCancel:a,onBrowse:o}=e,[s,c]=(0,k.useState)(``),[l,u]=(0,k.useState)(``),[d,f]=(0,k.useState)(n[0]?.id??`blank`),p=(0,k.useRef)(!1);if((0,k.useEffect)(()=>{n.find(e=>e.id===d)||f(n[0]?.id??`blank`)},[n,d]),(0,k.useEffect)(()=>{t&&(c(``),u(``),p.current=!1)},[t]),!t)return null;let m=s.trim().length>0&&l.trim().length>0;function h(e){if(c(e),!p.current){let t=je(e);u(t?Me(r??``,t):``)}}function g(e){p.current=!0,u(e)}async function _(){let e=await o();e&&(p.current=!0,u(e))}function v(){m&&i({name:s.trim(),path:l.trim(),templateId:d})}return(0,A.jsx)(`div`,{role:`dialog`,"aria-label":`新建项目`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,children:(0,A.jsxs)(`div`,{className:`bg-surface rounded-lg shadow-lg w-[560px] max-w-[90vw] p-6`,children:[(0,A.jsx)(`h2`,{className:`text-base font-semibold text-text-white mb-4`,children:`新建项目`}),(0,A.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,A.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,A.jsx)(`span`,{className:`text-text-secondary`,children:`项目名`}),(0,A.jsx)(`input`,{"aria-label":`项目名`,type:`text`,value:s,onChange:e=>h(e.target.value),placeholder:`My App`,className:`h-8 px-2 rounded-md border border-border bg-bg text-sm text-text-white`})]}),(0,A.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,A.jsx)(`span`,{className:`text-text-secondary`,children:`目录`}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(`input`,{"aria-label":`目录`,type:`text`,value:l,onChange:e=>g(e.target.value),placeholder:`/absolute/path/to/dir`,className:`flex-1 h-8 px-2 rounded-md border border-border bg-bg text-sm text-text-white`}),(0,A.jsx)(`button`,{type:`button`,onClick:_,className:`px-3 h-8 rounded-md border border-border text-sm text-text-secondary hover:text-text-white`,children:`浏览`})]})]}),(0,A.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[(0,A.jsx)(`span`,{className:`text-text-secondary`,children:`模板`}),(0,A.jsx)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(160px, 1fr))`},children:n.map(e=>{let t=e.id===d;return(0,A.jsxs)(`button`,{type:`button`,onClick:()=>f(e.id),className:[`text-left p-3 rounded-md border`,t?`border-accent text-text-white bg-accent/10`:`border-border text-text-secondary hover:border-accent`].join(` `),"aria-pressed":t,children:[(0,A.jsx)(`div`,{className:`text-sm font-medium`,children:e.name}),e.description?(0,A.jsx)(`div`,{className:`text-[11px] mt-1 text-text-dim`,children:e.description}):null]},e.id)})})]})]}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-2 mt-6`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:a,className:`px-3 h-8 rounded-md border border-border text-sm text-text-secondary hover:text-text-white`,children:`取消`}),(0,A.jsx)(`button`,{type:`button`,onClick:v,disabled:!m,className:`px-3 h-8 rounded-md text-sm bg-accent text-white disabled:opacity-40 disabled:cursor-not-allowed`,children:`创建`})]})]})})}function Pe(){return h(a.GetBranding)}function Fe(){return u(g.List)}function Ie(){return h(d.OpenDirectory)}function Le(e){return u(g.Add,e)}function Re(e){return h(g.Remove,e)}function ze(e){return u(l.Open,e)}function Be(e){return u(l.GetPages,e)}function Ve(e){return u(l.GetCompileConfig,e)}function He(e,t){return u(l.SaveCompileConfig,e,t)}function Ue(e){return p(l.Status,t=>e(t))}function We(e){return p(l.CompileLog,t=>e(t))}function Ge(e){return p(o.RuntimeStatus,t=>e(t))}function Ke(e){return h(l.CaptureThumbnail,e)}function qe(e){return h(l.GetThumbnail,e)}function Je(){return u(g.ListTemplates)}function Ye(){return h(g.OpenCreateDialog)}function Xe(e){return u(g.Create,e)}function Ze(){return u(g.GetCreateDefaults)}function Qe(){return h(m.Open)}var $e={selected:`simulator`,simulatorVisible:!0};function et(e){return e+48}function tt(e,t){return Math.max(200,Math.min(t-200,e))}function nt(e){let{initialDevice:t}=e,[n,r]=(0,k.useState)(t),[i,a]=(0,k.useState)(85),[o,s]=(0,k.useState)(()=>et(t.width)),c=(0,k.useRef)(o),l=(0,k.useRef)(n);(0,k.useEffect)(()=>{c.current=o},[o]),(0,k.useEffect)(()=>{l.current=n},[n]);let u=(0,k.useCallback)(e=>{re({brand:`Apple`,model:e.name,system:e.system,platform:`ios`,pixelRatio:e.pixelRatio,screenWidth:e.width,screenHeight:e.height,statusBarHeight:e.statusBarHeight,notchType:e.notchType,safeAreaInsets:{...e.safeAreaInsets}})},[]);return{device:n,zoom:i,simPanelWidth:o,setSimPanelWidth:s,handleDeviceChange:(0,k.useCallback)(e=>{let t=fe.find(t=>t.name===e.target.value)??fe[1];r(t),u(t),s(et(t.width))},[u]),handleZoomChange:(0,k.useCallback)(e=>{a(e.target.value===`auto`?S:Number(e.target.value))},[]),handleSplitterDrag:(0,k.useCallback)((e,t=`trailing`)=>{e.preventDefault();let n=e.clientX,r=c.current,i=e=>{let i=e.clientX-n;s(tt(r+(t===`trailing`?i:-i),window.innerWidth))},a=()=>{window.removeEventListener(`mousemove`,i),window.removeEventListener(`mouseup`,a)};window.addEventListener(`mousemove`,i),window.addEventListener(`mouseup`,a)},[]),sendDeviceInfo:u,simPanelWidthRef:c,deviceRef:l}}var rt=200,it=300;function at(e){let{projectPath:t}=e,[n,r]=(0,k.useState)({status:`compiling`,message:`正在编译...`}),[i,a]=(0,k.useState)(null),[o,s]=(0,k.useState)([]),[c,l]=(0,k.useState)(0),[u,d]=(0,k.useState)({startPage:``,scene:pe,queryParams:[]});(0,k.useEffect)(()=>{let e=!1;async function n(){try{let n=await ze(t);if(e)return;if(!n.success){r({status:`error`,message:n.error});return}let[i,o]=await Promise.all([Be(t),Ve(t)]);if(e)return;a(n.appInfo),l(n.port),s(i.pages),d({startPage:o.startPage||i.entryPagePath||i.pages[0]||``,scene:o.scene??1001,queryParams:o.queryParams||[]}),r({status:`ready`,message:`编译完成`})}catch(t){if(e)return;r({status:`error`,message:t instanceof Error?t.message:String(t)})}}return n(),()=>{e=!0}},[t]);let[f,p]=(0,k.useState)(0),[m,h]=(0,k.useState)([]),[g,_]=(0,k.useState)([]),v=(0,k.useRef)(0),[y,b]=(0,k.useState)(null),[x,S]=(0,k.useState)(!1);(0,k.useEffect)(()=>{h([]),_([]),b(null),S(!1)},[t]),(0,k.useEffect)(()=>Ue(e=>{r(e),e.pages&&s(e.pages),e.watcher===`dead`&&S(!0);let t=++v.current;h(n=>{let r=e.hotReload===!0?{at:Date.now(),status:e.status,message:e.message,hotReload:!0,seq:t}:{at:Date.now(),status:e.status,message:e.message,seq:t},i=[...n,r];return i.length>rt?i.slice(i.length-rt):i}),e.hotReload===!0&&(b(null),p(e=>e+1))}),[]),(0,k.useEffect)(()=>Ge(e=>{i?.appId&&e.appId!==i.appId||b(e)}),[i]),(0,k.useEffect)(()=>We(e=>{let t=++v.current;_(n=>{let r=[...n,{...e,seq:t}];return r.length>it?r.slice(r.length-it):r})}),[]);let C=(0,k.useCallback)(()=>{h([]),_([])},[]),w=(0,k.useRef)(!1),[T,E]=(0,k.useState)(0);return{compileStatus:n,appInfo:i,port:c,pages:o,compileConfig:u,hotReloadToken:f,compileEvents:m,compileLogs:g,clearCompileEvents:C,relaunch:(0,k.useCallback)(async(e=u)=>{try{if(!i?.appId||w.current)return;w.current=!0,r({status:`ready`,message:`正在刷新...`});try{await He(t,e),d(e),E(e=>e+1),r({status:`ready`,message:`刷新完成`})}finally{w.current=!1}}catch(e){w.current=!1,r({status:`error`,message:e instanceof Error?e.message:`刷新失败`})}},[i,u,t]),relaunchNonce:T,runtimeStatus:y,watcherDead:x}}var ot=[`appId`,`entry`,`page`];function st(e){return encodeURIComponent(e).replace(/%2F/g,`/`).replace(/%2C/g,`,`)}function ct(e){let t=Object.keys(e.query);if(t.length===0)return e.pagePath;let n=t.map(t=>`${encodeURIComponent(t)}=${encodeURIComponent(e.query[t]??``)}`).join(`&`);return`${e.pagePath}?${n}`}function lt(e){let t=e.indexOf(`?`);if(t<0)return{pagePath:e,query:{}};let n=e.slice(0,t),r={};for(let n of e.slice(t+1).split(`&`)){if(!n)continue;let e=n.indexOf(`=`),t=e>=0?n.slice(0,e):n,i=e>=0?n.slice(e+1):``;t&&(r[decodeURIComponent(t)]=decodeURIComponent(i))}return{pagePath:n,query:r}}function ut(e,t,n={}){let r=ct(t),i=[`appId=${st(e)}`,`entry=${st(r)}`,`page=${st(r)}`];for(let[e,t]of Object.entries(n))ot.includes(e)||i.push(`${encodeURIComponent(e)}=${st(t)}`);return i.join(`&`)}function dt(e){let t=e.host??`localhost`,n=e.pathname??`/simulator.html`,r=ut(e.appId,e.page,e.extras??{});return`http://${t}:${e.port}${n}?${r}`}function ft(e,t,n,r){let i=t.startPage||`pages/index/index`,a={};for(let e of t.queryParams??[])e.key&&(a[e.key]=e.value);a.scene=String(t.scene??1001);let o={};return r?.length&&(o.apiNamespaces=r.join(`,`)),dt({appId:e,page:{pagePath:i,query:a},port:n,extras:o})}function pt(e){let t=new URLSearchParams(e.startsWith(`?`)?e.slice(1):e),n=t.get(`appId`),r=t.get(`entry`);if(!n||!r)return null;let i=lt(r),a=t.get(`page`);return{appId:n,entry:i,current:a&&a!==r?lt(a):i}}function mt(e){if(!e)return null;try{return pt(new URL(e).search)}catch{return null}}function ht(e){return mt(e)?.current.pagePath??``}function gt(e){let{compileStatus:t,sendDeviceInfo:n,simPanelWidthRef:r,deviceRef:i,appInfo:a,compileConfig:o,port:s,projectPath:c,hotReloadToken:l,relaunchNonce:u}=e,d=(0,k.useMemo)(()=>!a||!s?``:ft(a.appId,o,s),[a,o,s]),[f,p]=(0,k.useState)(()=>ht(d));(0,k.useEffect)(()=>{p(ht(d))},[d]),(0,k.useEffect)(()=>ue(e=>{e&&p(e)}),[]);let m=(0,k.useRef)({currentPage:f,compileConfig:o,appInfo:a,port:s});(0,k.useEffect)(()=>{m.current={currentPage:f,compileConfig:o,appInfo:a,port:s}});let h=(0,k.useRef)(l);return(0,k.useEffect)(()=>{if(t.status!==`ready`||!d)return;let e=l!==h.current;h.current=l;let a=d;if(e){let e=m.current;if(e.appInfo&&e.port){let t=e.currentPage||e.compileConfig.startPage;a=ft(e.appInfo.appId,t===e.compileConfig.startPage?e.compileConfig:{...e.compileConfig,startPage:t,queryParams:[]},e.port)}}n(i.current);let o=!1,s=null,u=()=>{o||(s=window.setTimeout(()=>{o||Ke(c).catch(()=>{})},3e3))},f=()=>{ie(a,r.current).then(u).catch(()=>{})};return e?D(a).then(e=>{if(!o){if(e===!0){u();return}f()}}).catch(()=>{o||f()}):f(),()=>{o=!0,s!==null&&window.clearTimeout(s)}},[t.status,d,l,u,r,i,n,c]),{simulatorUrl:d,currentPage:f}}function _t(){return{getSnapshot:async()=>await h(i.GetSnapshot)??null,subscribe:e=>p(i.Event,e),setActive:e=>{h(i.SetActive,e)},inspect:async e=>await h(c.Inspect,e)??null,clearInspection:async()=>{await h(c.Clear)}}}var vt={ok:!1,error:`ipc transport failed`};function yt(){return{getSnapshot:async()=>await h(s.GetSnapshot)??[],subscribe:e=>p(s.Event,e),setActive:()=>{},setItem:async(e,t)=>await h(s.Set,{key:e,value:t})??vt,removeItem:async e=>await h(s.Remove,{key:e})??vt,clear:async()=>await h(s.Clear)??vt,clearAll:async()=>await h(s.ClearAll)??vt,getPrefix:async()=>await h(s.GetActivePrefix)??``}}var bt={bridges:[],entries:{}};function xt(){return{getSnapshot:async()=>await h(f.GetSnapshot)??bt,subscribe:e=>p(f.Event,e),setActive:()=>{},setData:async(e,t)=>await h(f.SetData,{bridgeId:e,data:t})??!1}}function St(e){let{compileStatus:t}=e,n=t.status===`ready`;return{wxmlSource:(0,k.useMemo)(()=>_t(),[]),wxmlEnabled:n,storageSource:(0,k.useMemo)(()=>yt(),[]),storageEnabled:n,appDataSource:(0,k.useMemo)(()=>xt(),[]),appDataEnabled:n}}function Ct(e){let{initialRightPane:t}=e,[n,r]=(0,k.useState)(t);return{rightPane:n,selectRightPane:(0,k.useCallback)(e=>{r({selected:e,simulatorVisible:!0})},[]),toggleRightPaneVisible:(0,k.useCallback)(()=>{r(e=>({...e,simulatorVisible:!e.simulatorVisible}))},[])}}function wt(e){let{relaunch:t,compileConfig:n,pages:r,compileDropdownRef:i}=e,[a,o]=(0,k.useState)(!1),s=(0,k.useRef)(t);(0,k.useEffect)(()=>{s.current=t},[t]),(0,k.useEffect)(()=>{let e=ce(()=>o(!1)),t=ne(e=>{o(!1),s.current(e)});return()=>{e(),t()}},[]);let c=(0,k.useRef)(n),l=(0,k.useRef)(r);return(0,k.useEffect)(()=>{c.current=n},[n]),(0,k.useEffect)(()=>{l.current=r},[r]),{showCompilePanel:a,toggleCompilePanel:(0,k.useCallback)(()=>{o(e=>{if(e)return te(),!1;let t=i.current;if(!t)return e;let n=t.getBoundingClientRect();return ee({top:Math.round(n.bottom-40+6),left:Math.round(n.left),config:c.current,pages:l.current}),!0})},[i])}}function Tt(e){let{projectPath:t,initialDevice:n=fe[1],initialRightPane:r=$e}=e,i=(0,k.useRef)(null),a=(0,k.useRef)(null),o=nt({initialDevice:n}),s=at({projectPath:t});(0,k.useEffect)(()=>{s.compileStatus.status===`ready`&&o.setSimPanelWidth(o.device.width+48)},[o.device.width,s.compileStatus.status,o.setSimPanelWidth]);let c=gt({compileStatus:s.compileStatus,sendDeviceInfo:o.sendDeviceInfo,simPanelWidthRef:o.simPanelWidthRef,deviceRef:o.deviceRef,appInfo:s.appInfo,compileConfig:s.compileConfig,port:s.port,projectPath:t,hotReloadToken:s.hotReloadToken,relaunchNonce:s.relaunchNonce}),l=St({compileStatus:s.compileStatus,activePagePath:c.currentPage}),u=Ct({initialRightPane:r}),d=wt({relaunch:s.relaunch,compileConfig:s.compileConfig,pages:s.pages,compileDropdownRef:a});return{session:{compileStatus:s.compileStatus,appInfo:s.appInfo,port:s.port,pages:s.pages,compileConfig:s.compileConfig,compileEvents:s.compileEvents,compileLogs:s.compileLogs,clearCompileEvents:s.clearCompileEvents,relaunch:s.relaunch,runtimeStatus:s.runtimeStatus,watcherDead:s.watcherDead},device:{device:o.device,zoom:o.zoom,simPanelWidth:o.simPanelWidth,setSimPanelWidth:o.setSimPanelWidth,handleDeviceChange:o.handleDeviceChange,handleZoomChange:o.handleZoomChange,handleSplitterDrag:o.handleSplitterDrag,sendDeviceInfo:o.sendDeviceInfo},simulator:{simulatorRef:i,simulatorUrl:c.simulatorUrl,currentPage:c.currentPage},panelData:{wxmlSource:l.wxmlSource,wxmlEnabled:l.wxmlEnabled,storageSource:l.storageSource,storageEnabled:l.storageEnabled,appDataSource:l.appDataSource,appDataEnabled:l.appDataEnabled},rightPane:{rightPane:u.rightPane,selectRightPane:u.selectRightPane,toggleRightPaneVisible:u.toggleRightPaneVisible},popover:{compileDropdownRef:a,showCompilePanel:d.showCompilePanel,toggleCompilePanel:d.toggleCompilePanel}}}var Et={dockTree:null,simulatorAlignment:`left`,devtoolsPosition:`inEditor`},Dt=`dimina-devtools.layout.v1`;function Ot(){try{let e=window.localStorage.getItem(Dt);if(!e)return Et;let t=JSON.parse(e);return{dockTree:typeof t.dockTree==`string`?t.dockTree:null,simulatorAlignment:t.simulatorAlignment===`right`?`right`:`left`,devtoolsPosition:t.devtoolsPosition===`belowSimulator`||t.devtoolsPosition===`rightOfSimulator`?t.devtoolsPosition:`inEditor`}}catch{return Et}}function kt(e){try{window.localStorage.setItem(Dt,JSON.stringify(e))}catch{}}function At(){let[e,t]=(0,k.useState)(Ot);return(0,k.useEffect)(()=>{kt(e)},[e]),{state:e,setDockTree:(0,k.useCallback)(e=>{t(t=>t.dockTree===e?t:{...t,dockTree:e})},[]),setSimulatorAlignment:(0,k.useCallback)(e=>{t(t=>t.simulatorAlignment===e?t:{...t,simulatorAlignment:e})},[]),setDevtoolsPosition:(0,k.useCallback)(e=>{t(t=>t.devtoolsPosition===e?t:{...t,devtoolsPosition:e})},[])}}var jt={compiling:`bg-status-warn animate-[pulse_1s_infinite]`,ready:`bg-accent`,error:`bg-status-error`};function Mt({status:e}){return(0,A.jsx)(`span`,{className:y(`w-1.5 h-1.5 rounded-full shrink-0`,jt[e]??`bg-border`)})}function Nt(){let e=new Map;return{register(t){return e.set(t.id,t),{dispose(){e.get(t.id)===t&&e.delete(t.id)}}},get(t){return e.get(t)},list(){return[...e.values()]}}}var Pt=64;function Ft(e){return JSON.stringify(e)}function It(e,t,n,r){e===void 0?r.push(`node missing string id (kind=${String(t)})`):n.seenIds.has(e)?r.push(`duplicate node id: ${e}`):n.seenIds.add(e)}function Lt(e,t,n,r){if(typeof e!=`string`){r.push(`tabs ${t??`?`}: non-string panel id`);return}n.panelOwners.get(e)===void 0?n.panelOwners.set(e,t??`?`):r.push(`duplicate panel id across groups: ${e}`),n.knownPanelIds&&!n.knownPanelIds.has(e)&&r.push(`orphan panel not in known panel ids: ${e}`)}function Rt(e,t,n,r){let i=e,a=Array.isArray(i.panels)?i.panels:null;if(!a){r.push(`tabs ${t??`?`}: panels is not an array`);return}a.length===0&&r.push(`tabs ${t??`?`}: empty tabgroup`);for(let e of a)Lt(e,t,n,r);let o=i.active;(typeof o!=`string`||!a.includes(o))&&r.push(`tabs ${t??`?`}: active ${String(o)} not in panels`)}function zt(e,t,n){if(e===null)return!1;if(typeof e!=`object`)return n.push(`split ${t??`?`}: constraint is not null nor an object: ${String(e)}`),!1;let r=Object.keys(e),i=r.includes(`fixedPx`),a=r.includes(`minPx`);(r.length!==1||!(i||a))&&n.push(`split ${t??`?`}: constraint must have exactly one of 'fixedPx' or 'minPx', got [${r.join(`, `)}]`);let o=i?`fixedPx`:`minPx`,s=i?e.fixedPx:e.minPx;return(typeof s!=`number`||!Number.isFinite(s)||s<=0)&&n.push(`split ${t??`?`}: constraint ${o} must be a finite number > 0, got ${String(s)}`),!0}function Bt(e,t,n){let r=Array.isArray(e)?e:null;if(!r){n.push(`split ${t??`?`}: constraints is not an array`);return}let i=r.length>0;for(let e of r)zt(e,t,n)||(i=!1);i&&n.push(`split ${t??`?`}: all children are px-sized constraints; at least one must be weight-sized`)}function Vt(e,t,n,r){if(!e||e.length!==t.length){r.push(`split ${n??`?`}: sizes ${e?e.length:`missing`} != children ${t.length}`);return}for(let t of e)(typeof t!=`number`||!Number.isFinite(t))&&r.push(`split ${n??`?`}: non-finite size ${String(t)}`)}function Ht(e,t){let n=[],r={seenIds:new Set,seenObjects:new Set,panelOwners:new Map,knownPanelIds:t},i=(e,t,a)=>{if(t>Pt){n.push(`depth exceeds ${Pt}`);return}if(typeof e!=`object`||!e){n.push(`node is not an object: ${String(e)}`);return}let o=e;if(a.has(o)){n.push(`cycle detected: node reachable from itself`);return}if(r.seenObjects.has(o)){n.push(`shared node reference: same object appears twice`);return}r.seenObjects.add(o);let s=e,c=s.kind,l=typeof s.id==`string`?s.id:void 0;It(l,c,r,n),c===`tabs`?Rt(e,l,r,n):c===`split`?Ut(e,l,t,a,o,r,n,i):n.push(`unknown node kind: ${String(c)}`)};return i(e,0,new Set),n}function Ut(e,t,n,r,i,a,o,s){let c=e,l=Array.isArray(c.children)?c.children:null,u=Array.isArray(c.sizes)?c.sizes:null,d=c.orientation;if(d!==`row`&&d!==`column`&&o.push(`split ${t??`?`}: invalid orientation ${String(d)}`),c.constraints!==void 0&&Bt(c.constraints,t,o),!l){o.push(`split ${t??`?`}: children is not an array`);return}if(l.length<2&&o.push(`split ${t??`?`}: must have >= 2 children, has ${l.length}`),Vt(u,l,t,o),c.constraints!==void 0&&Array.isArray(c.constraints)){let e=c.constraints;e.length!==l.length&&o.push(`split ${t??`?`}: constraints ${e.length} != children ${l.length}`)}let f=new Set(r);f.add(i);for(let e of l)s(e,n+1,f)}function Wt(e,t){return typeof e!=`object`||!e?[`tree is not an object`]:e.version===1?Ht(e.root,t):[`unsupported version: ${String(e.version)}`]}function Gt(e){let t;try{t=JSON.parse(e)}catch{throw Error(`parseLayout: input is not valid JSON`)}if(typeof t!=`object`||!t)throw Error(`parseLayout: top-level value is not an object`);let n=t;if(n.version!==1)throw Error(`parseLayout: unsupported version ${String(n.version)}`);if(n.root===void 0||n.root===null)throw Error(`parseLayout: missing root`);let r=Ht(n.root,null);if(r.length>0)throw Error(`parseLayout: illegal layout — ${r.join(`; `)}`);return{version:1,root:n.root}}var Kt=1;function qt(e,t){return(e.constraints?.[t]??null)===null}function Jt(e){if(e.kind===`tabs`)return e;let t=e.children.map(Jt),n=t.some((t,n)=>t!==e.children[n]),r=e.sizes.map((t,r)=>!qt(e,r)||typeof t==`number`&&Number.isFinite(t)&&t>0?t:(n=!0,Kt));if(!n)return e;let i={kind:`split`,id:e.id,orientation:e.orientation,children:t,sizes:r};return e.constraints===void 0?i:{...i,constraints:e.constraints}}function Yt(e){let t=Jt(e.root);return t===e.root?e:{version:1,root:t}}function Xt(e,t){let n=null,r=e=>{n||(e.kind===`tabs`?e.id===t&&(n=e):e.children.forEach(r))};return r(e),n}function Zt(e,t){let n=null,r=e=>{n||(e.kind===`tabs`?e.panels.includes(t)&&(n=e):e.children.forEach(r))};return r(e),n}function Qt(e,t){return Zt(e,t)?.id}function $t(e){return e.kind===`tabs`?e.panels.length:e.children.reduce((e,t)=>e+$t(t),0)}function j(e,t,n){return{kind:`tabs`,id:e,panels:t,active:n}}function en(e,t,n){if(e.length===0)return``;if(e.includes(t))return t;let r=Math.min(n,e.length-1);return e[Math.max(0,r)]}function tn(e){if(e.kind===`tabs`)return e.panels.length===0?null:e;let t=[],n=[],r=[],i=e.constraints!==void 0;if(e.children.forEach((a,o)=>{let s=tn(a);s!==null&&(t.push(s),n.push(e.sizes[o]??1),i&&r.push(e.constraints[o]??null))}),t.length===0)return null;if(t.length===1)return t[0];let a={kind:`split`,id:e.id,orientation:e.orientation,children:t,sizes:n};return i?(r.length>0&&!r.some(e=>e===null)&&(r[r.length-1]=null),{...a,constraints:r}):a}function M(e){let t=tn(e);if(t===null)throw Error(`mutation would empty the entire layout`);return t}function nn(e){let t=new Set,n=e=>{if(e.kind===`tabs`)for(let n of e.panels)t.add(n);else e.children.forEach(n)};return n(e),t}function rn(e,t){return nn(e).has(t)}function an(e){let t=new Set,n=e=>{t.add(e.id),e.kind===`split`&&e.children.forEach(n)};return n(e),t}function N(e,t){let n=t,r=2;for(;e.has(n);)n=`${t}#${r}`,r+=1;return e.add(n),n}function on(e,t){let n=null,r=e=>{n||e.kind===`split`&&(e.id===t&&(n=e),e.children.forEach(r))};return r(e),n}function P(e,t,n){if(e.id===t)return n;if(e.kind===`tabs`)return j(e.id,[...e.panels],e.active);let r={kind:`split`,id:e.id,orientation:e.orientation,children:e.children.map(e=>P(e,t,n)),sizes:[...e.sizes]};return e.constraints===void 0?r:{...r,constraints:[...e.constraints]}}function sn(e){if(e.kind===`tabs`)return j(e.id,[...e.panels],e.active);let t={kind:`split`,id:e.id,orientation:e.orientation,children:e.children.map(sn),sizes:[...e.sizes]};return e.constraints===void 0?t:{...t,constraints:[...e.constraints]}}function F(e){return{version:1,root:e}}function cn(e,t,n){let r=on(e.root,t);if(!r)throw Error(`setSizes: split not found: ${t}`);if(n.length!==r.children.length)throw Error(`setSizes: sizes length ${n.length} != children length ${r.children.length}`);if(!n.every(e=>Number.isFinite(e)))throw Error(`setSizes: every size must be a finite number, got [${n.join(`, `)}]`);let i={kind:`split`,id:r.id,orientation:r.orientation,children:r.children.map(sn),sizes:[...n]},a=r.constraints===void 0?i:{...i,constraints:[...r.constraints]};return F(P(e.root,t,a))}function ln(e,t,n,r){let i=on(e.root,t);if(!i)throw Error(`setConstraint: split not found: ${t}`);if(!Number.isInteger(n))throw Error(`setConstraint: childIndex must be an integer, got ${n}`);if(n<0||n>=i.children.length)throw Error(`setConstraint: childIndex ${n} out of range [0, ${i.children.length})`);let a=i.constraints===void 0?i.children.map(()=>null):[...i.constraints];if(a[n]=r,a.length>0&&a.every(e=>e!==null))return e;let o={kind:`split`,id:i.id,orientation:i.orientation,children:i.children.map(sn),sizes:[...i.sizes],constraints:a};return F(P(e.root,t,o))}function un(e,t,n){let r=Xt(e.root,t);if(!r)throw Error(`setActive: group not found: ${t}`);if(!r.panels.includes(n))throw Error(`setActive: panel ${n} not in group ${t}`);let i=j(r.id,[...r.panels],n);return F(P(e.root,t,i))}function dn(e,t){let n=Zt(e,t);if(!n)throw Error(`panel not found: ${t}`);let r=n.panels.indexOf(t),i=n.panels.filter(e=>e!==t),a=j(n.id,i,en(i,n.active,r));return M(P(e,n.id,a))}function fn(e,t){let n=nn(e.root);return n.size===1&&n.has(t)?e:F(dn(e.root,t))}function pn(e,t){if(!Zt(e.root,t))throw Error(`extractPanel: panel not found: ${t}`);return{tree:F(dn(e.root,t)),extracted:t}}function mn(e,t,n){if(rn(e.root,t))throw Error(`insertPanel: panel already exists in the tree: ${t}`);let r=Xt(e.root,n.groupId);if(!r)throw Error(`insertPanel: dest group not found: ${n.groupId}`);let i=[...r.panels],a=hn(n.index,i.length);i.splice(a,0,t);let o=j(r.id,i,r.active);return F(M(P(e.root,r.id,o)))}function hn(e,t){return e===void 0?t:e<0?0:e>t?t:e}function gn(e,t,n){let r=Zt(e.root,t);if(!r)throw Error(`movePanel: panel not found: ${t}`);let i=Xt(e.root,n.groupId);if(!i)throw Error(`movePanel: dest group not found: ${n.groupId}`);if(r.id===i.id){let i=r.panels.filter(e=>e!==t),a=hn(n.index,i.length),o=[...i];o.splice(a,0,t);let s=j(r.id,o,r.active);return F(M(P(e.root,r.id,s)))}let a=r.panels.indexOf(t),o=r.panels.filter(e=>e!==t),s=j(r.id,o,en(o,r.active,a)),c=[...i.panels],l=hn(n.index,c.length);c.splice(l,0,t);let u=j(i.id,c,i.active),d=P(e.root,r.id,s);return d=P(d,i.id,u),F(M(d))}function _n(e,t,n,r){if(rn(e.root,t))throw Error(`wrapRoot: new panel already exists in the tree: ${t}`);let i=an(e.root),a=e.root.id,o=j(N(i,`${a}__new`),[t],t),s=sn(e.root),c=r===`after`?[s,o]:[o,s];return F({kind:`split`,id:N(i,`${a}__wrap`),orientation:n,children:c,sizes:[1,1]})}function vn(e,t,n,r,i){if(rn(e.root,r))throw Error(`splitGroup: new panel already exists in the tree: ${r}`);let a=Xt(e.root,t);if(!a)throw Error(`splitGroup: group not found: ${t}`);let o=an(e.root),s=j(N(o,`${t}__new`),[r],r),c=sn(a),l=i===`after`?[c,s]:[s,c],u={kind:`split`,id:N(o,`${t}__sp`),orientation:n,children:l,sizes:[1,1]};return F(M(P(e.root,t,u)))}function yn(e,t,n,r,i){if(rn(e.root,r))throw Error(`splitPanel: new panel already exists in the tree: ${r}`);let a=Zt(e.root,t);if(!a)throw Error(`splitPanel: panel not found: ${t}`);let o=an(e.root),s=a.id,c=j(N(o,`${s}__split`),[t],t),l=j(N(o,`${s}__new`),[r],r),u=i===`after`?[c,l]:[l,c],d={kind:`split`,id:N(o,`${s}__sp`),orientation:n,children:u,sizes:[1,1]};if(a.panels.length===1)return F(M(P(e.root,s,d)));let f=a.panels.indexOf(t),p=a.panels.filter(e=>e!==t),m=j(s,p,en(p,a.active,f)),h=i===`after`?[m,d]:[d,m],g={kind:`split`,id:N(o,`${s}__outer`),orientation:n,children:h,sizes:[1,1]};return F(M(P(e.root,s,g)))}function bn(e){let t=structuredClone(e),n=0,r=new Set,i=!1,a=[],o=e=>{let i=e(t);if(i===t)return;t=i,n+=1;let a={tree:t,revision:n};for(let e of[...r])try{e(a)}catch{}};return{get(){return t},apply(e){if(i){a.push(e);return}i=!0;try{for(o(e);a.length>0;){let e=a.shift();try{o(e)}catch{}}}finally{i=!1}},subscribe(e){return r.add(e),()=>{r.delete(e)}}}}function xn(e,t,n){return n.get(t)?.closable===!1?e:fn(e,t)}function Sn(){let e=Nt();return e.register({kind:`dom`,id:`simulator`,title:`Simulator`,draggable:!1,hideTab:!0}),e.register({kind:`dom`,id:`editor`,title:`Editor`,draggable:!1,hideTab:!0}),e.register({kind:`dom`,id:`wxml`,title:`WXML`,dropPolicy:`reorder-only`,closable:!1}),e.register({kind:`dom`,id:`appdata`,title:`AppData`,dropPolicy:`reorder-only`,closable:!1}),e.register({kind:`dom`,id:`storage`,title:`Storage`,dropPolicy:`reorder-only`,closable:!1}),e.register({kind:`native`,id:`console`,title:`Console`,nativeRef:{id:`console`},dropPolicy:`reorder-only`,closable:!1}),e.register({kind:`dom`,id:`compile`,title:`编译`,dropPolicy:`reorder-only`,closable:!1}),e}function Cn(e){return{version:1,root:{kind:`split`,id:`root`,orientation:`row`,sizes:[1,6],constraints:[{minPx:e},null],children:[{kind:`tabs`,id:`g-sim`,panels:[`simulator`],active:`simulator`},{kind:`split`,id:`col-main`,orientation:`column`,sizes:[70,30],children:[{kind:`tabs`,id:`g-editor`,panels:[`editor`],active:`editor`},{kind:`tabs`,id:`g-debug`,panels:[`wxml`,`appdata`,`storage`,`console`,`compile`],active:`wxml`}]}]}}}var wn={kind:`tabs`,id:`g-debug`,panels:[`wxml`,`appdata`,`storage`,`console`,`compile`],active:`wxml`},Tn=()=>({kind:`tabs`,id:`g-sim`,panels:[`simulator`],active:`simulator`}),En=()=>({kind:`tabs`,id:`g-editor`,panels:[`editor`],active:`editor`}),Dn=()=>({...wn,panels:[...wn.panels]});function On(e,t,n,r){return{version:1,root:{kind:`split`,id:`root`,orientation:`row`,sizes:e.map((e,t)=>r[t]??1),constraints:e.map((e,r)=>r===t?{minPx:n}:null),children:e}}}function kn(e,t,n){let r=t===`left`;if(n===`belowSimulator`){let t={kind:`split`,id:`col-sim`,orientation:`column`,sizes:[60,40],children:[Tn(),Dn()]};return r?On([t,En()],0,e,[1,6]):On([En(),t],1,e,[6,1])}if(n===`rightOfSimulator`)return r?On([Tn(),Dn(),En()],0,e,[1,4,5]):On([En(),Dn(),Tn()],2,e,[5,4,1]);let i={kind:`split`,id:`col-main`,orientation:`column`,sizes:[70,30],children:[En(),Dn()]};return r?On([Tn(),i],0,e,[1,6]):On([i,Tn()],1,e,[6,1])}function An(e,t,n){return bn(jn(e,t,n))}function jn(e,t,n){if(e===null)return Cn(t);try{let r=Gt(e);if(Wt(r,n).length===0)return Mn(Yt(r),t)}catch{}return Cn(t)}function Mn(e,t){let n=Fn(e);return Nn.some(e=>n.has(e))?Nn.reduce((e,r)=>n.has(r)?e:Bn(e,r,t),e):e}var Nn=[`wxml`,`appdata`,`storage`,`console`,`compile`];function Pn(e,t){if(e.kind===`tabs`){for(let n of e.panels)t.add(n);return}for(let n of e.children)Pn(n,t)}function Fn(e){let t=new Set;return Pn(e.root,t),t}function In(e,t){if(e.kind===`tabs`)return e.panels.includes(t)?e.id:void 0;for(let n of e.children){let e=In(n,t);if(e!==void 0)return e}}function Ln(e,t){return t.find(t=>e.has(t))}function Rn(e,t){if(e.kind===`tabs`)return null;for(let n=0;n<e.children.length;n++){if(e.children[n].id===t)return{splitId:e.id,childIndex:n};let r=Rn(e.children[n],t);if(r)return r}return null}function zn(e,t){let n=In(e.root,`simulator`);if(!n)return e;let r=Rn(e.root,n);return r?ln(e,r.splitId,r.childIndex,{minPx:t}):e}function Bn(e,t,n){let r=Fn(e);if(r.has(t))return e;if(Nn.includes(t)){let n=Nn.find(e=>e!==t&&r.has(e));return n?mn(e,t,{groupId:In(e.root,n)}):r.has(`editor`)?yn(e,`editor`,`column`,t,`after`):r.has(`simulator`)?yn(e,`simulator`,`row`,t,`after`):yn(e,[...r][0],`column`,t,`after`)}if(t===`editor`){let t=Ln(r,Nn);return t?vn(e,In(e.root,t),`column`,`editor`,`before`):r.has(`simulator`)?yn(e,`simulator`,`row`,`editor`,`after`):yn(e,[...r][0],`column`,`editor`,`before`)}return t===`simulator`?zn(_n(e,`simulator`,`row`,`before`),n):yn(e,[...r][0],`column`,t,`after`)}function Vn(e,t){let n=Fn(e);return t.list().map(e=>({id:e.id,title:e.title??e.id,open:n.has(e.id)}))}var Hn=Nn;function Un({model:e,registry:t,simPanelWidth:n}){let[,r]=(0,k.useState)(0);(0,k.useEffect)(()=>e.subscribe(()=>r(e=>e+1)),[e]);let i=new Set(Vn(e.get(),t).filter(e=>e.open).map(e=>e.id)),a=i.has(`simulator`),o=i.has(`editor`),s=Hn.some(e=>i.has(e)),c=[a,o,s].filter(Boolean).length;function l(r,i){e.apply(e=>i?xn(e,r,t):Bn(e,r,n))}function u(){if(s){let t=Hn.filter(e=>i.has(e));e.apply(e=>t.reduce((e,t)=>fn(e,t),e))}else{let t=Hn.filter(e=>!i.has(e));e.apply(e=>t.reduce((e,t)=>Bn(e,t,n),e))}}return(0,A.jsxs)(`div`,{className:`flex items-center gap-0.5`,role:`group`,"aria-label":`面板可见性`,children:[(0,A.jsx)(Kn,{active:a,disabled:a&&c===1,onClick:()=>l(`simulator`,a),title:a?`隐藏模拟器`:`显示模拟器`,testId:`layout-toolbar-toggle-simulator`,icon:(0,A.jsx)(qn,{filled:a})}),(0,A.jsx)(Kn,{active:o,disabled:o&&c===1,onClick:()=>l(`editor`,o),title:o?`隐藏编辑器`:`显示编辑器`,testId:`layout-toolbar-toggle-editor`,icon:(0,A.jsx)(Jn,{filled:o})}),(0,A.jsx)(Kn,{active:s,disabled:s&&c===1,onClick:u,title:s?`隐藏调试器`:`显示调试器`,testId:`layout-toolbar-toggle-debug`,icon:(0,A.jsx)(Yn,{filled:s})})]})}function Wn({model:e,layout:t,simPanelWidth:n}){let{simulatorAlignment:r,devtoolsPosition:i}=t.state,a=r===`left`;function o(){let r=a?`right`:`left`;t.setSimulatorAlignment(r),e.apply(()=>kn(n,r,i))}return(0,A.jsx)(O,{variant:`icon`,size:`icon`,onClick:o,title:a?`模拟器位置:左侧(点击切换到右侧)`:`模拟器位置:右侧(点击切换到左侧)`,"data-testid":`layout-toolbar-alignment-toggle`,"data-alignment":r,className:`text-text-muted hover:text-text hover:bg-surface-3`,children:(0,A.jsx)(Xn,{side:r})})}function Gn({model:e,layout:t,simPanelWidth:n}){let{simulatorAlignment:r,devtoolsPosition:i}=t.state;function a(i){t.setDevtoolsPosition(i),e.apply(()=>kn(n,r,i))}return(0,A.jsx)(`div`,{className:`flex items-center gap-0.5`,role:`group`,"aria-label":`调试器位置`,children:[{id:`inEditor`,title:`调试器位置:在编辑器面板中`},{id:`belowSimulator`,title:`调试器位置:在模拟器下方`},{id:`rightOfSimulator`,title:`调试器位置:在模拟器右侧`}].map(e=>(0,A.jsx)(Kn,{active:i===e.id,onClick:()=>a(e.id),title:e.title,testId:`layout-toolbar-devtools-${e.id}`,icon:(0,A.jsx)(Zn,{variant:e.id})},e.id))})}function Kn({active:e,disabled:t,onClick:n,title:r,testId:i,icon:a}){return(0,A.jsx)(O,{variant:`icon`,size:`icon`,onClick:n,disabled:t,title:r,"aria-pressed":e,"data-testid":i,"data-active":e?`true`:`false`,className:y(`text-text-muted/45 hover:text-text-muted hover:bg-surface-3`,e&&`bg-surface-active text-text ring-1 ring-accent/50 hover:bg-surface-active hover:text-text`),children:a})}function qn({filled:e}){return(0,A.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:e?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`rect`,{x:`4`,y:`1.5`,width:`8`,height:`13`,rx:`1.5`,fill:`currentColor`,stroke:`currentColor`}),(0,A.jsx)(`line`,{x1:`6.5`,y1:`12.5`,x2:`9.5`,y2:`12.5`,stroke:`var(--color-surface-2)`,strokeWidth:`1.2`})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`rect`,{x:`4`,y:`1.5`,width:`8`,height:`13`,rx:`1.5`}),(0,A.jsx)(`line`,{x1:`6.5`,y1:`12.5`,x2:`9.5`,y2:`12.5`})]})})}function Jn({filled:e}){return(0,A.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:e?2:1.6,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,A.jsx)(`polyline`,{points:`5,4 1.5,8 5,12`}),(0,A.jsx)(`polyline`,{points:`11,4 14.5,8 11,12`}),(0,A.jsx)(`line`,{x1:`9.5`,y1:`3`,x2:`6.5`,y2:`13`})]})}function Yn({filled:e}){return(0,A.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[e?(0,A.jsx)(`ellipse`,{cx:`8`,cy:`9`,rx:`3.5`,ry:`4.5`,fill:`currentColor`,stroke:`currentColor`}):(0,A.jsx)(`ellipse`,{cx:`8`,cy:`9`,rx:`3.5`,ry:`4.5`}),(0,A.jsx)(`line`,{x1:`6`,y1:`3.5`,x2:`5`,y2:`2`}),(0,A.jsx)(`line`,{x1:`10`,y1:`3.5`,x2:`11`,y2:`2`}),(0,A.jsx)(`line`,{x1:`4.5`,y1:`7.5`,x2:`2`,y2:`6.5`}),(0,A.jsx)(`line`,{x1:`4.5`,y1:`9.5`,x2:`2`,y2:`9.5`}),(0,A.jsx)(`line`,{x1:`4.5`,y1:`11.5`,x2:`2`,y2:`12.5`}),(0,A.jsx)(`line`,{x1:`11.5`,y1:`7.5`,x2:`14`,y2:`6.5`}),(0,A.jsx)(`line`,{x1:`11.5`,y1:`9.5`,x2:`14`,y2:`9.5`}),(0,A.jsx)(`line`,{x1:`11.5`,y1:`11.5`,x2:`14`,y2:`12.5`})]})}function Xn({side:e}){return(0,A.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,A.jsx)(`rect`,{x:`2`,y:`3`,width:`12`,height:`10`,rx:`1.5`}),e===`left`?(0,A.jsx)(`rect`,{x:`2.6`,y:`3.6`,width:`4.8`,height:`8.8`,rx:`0.8`,fill:`currentColor`,stroke:`none`}):(0,A.jsx)(`rect`,{x:`8.6`,y:`3.6`,width:`4.8`,height:`8.8`,rx:`0.8`,fill:`currentColor`,stroke:`none`})]})}function Zn({variant:e}){return e===`inEditor`?(0,A.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.2`,"aria-hidden":`true`,children:[(0,A.jsx)(`rect`,{x:`2`,y:`3`,width:`12`,height:`10`,rx:`1.5`}),(0,A.jsx)(`line`,{x1:`6.5`,y1:`3`,x2:`6.5`,y2:`13`}),(0,A.jsx)(`rect`,{x:`7.1`,y:`8.5`,width:`6.3`,height:`4`,rx:`0.6`,fill:`currentColor`,stroke:`none`})]}):e===`belowSimulator`?(0,A.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.2`,"aria-hidden":`true`,children:[(0,A.jsx)(`rect`,{x:`2`,y:`3`,width:`12`,height:`10`,rx:`1.5`}),(0,A.jsx)(`line`,{x1:`8`,y1:`3`,x2:`8`,y2:`13`}),(0,A.jsx)(`rect`,{x:`2.6`,y:`8.5`,width:`4.8`,height:`4`,rx:`0.6`,fill:`currentColor`,stroke:`none`})]}):(0,A.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.2`,"aria-hidden":`true`,children:[(0,A.jsx)(`rect`,{x:`2`,y:`3`,width:`12`,height:`10`,rx:`1.5`}),(0,A.jsx)(`line`,{x1:`6`,y1:`3`,x2:`6`,y2:`13`}),(0,A.jsx)(`line`,{x1:`9.5`,y1:`3`,x2:`9.5`,y2:`13`}),(0,A.jsx)(`rect`,{x:`6.3`,y:`3.6`,width:`3`,height:`8.8`,rx:`0.6`,fill:`currentColor`,stroke:`none`})]})}function Qn(){return(0,A.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`,"aria-hidden":`true`})}function $n({compileDropdownRef:e,showCompilePanel:t,onToggleCompilePanel:n,onRelaunch:r,compileStatus:i,dockModel:a,dockRegistry:o,layout:s,simPanelWidth:c}){return(0,A.jsx)(`div`,{className:`flex flex-col shrink-0`,children:(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 bg-surface-2 border-b border-border shrink-0`,style:{height:40},children:[(0,A.jsx)(`div`,{ref:e,children:(0,A.jsxs)(O,{variant:`outline`,size:`sm`,onClick:n,className:y(t&&`border-accent`),title:`编译模式`,children:[`普通编译 `,(0,A.jsx)(`span`,{className:`text-[10px] text-text-secondary`,children:`▾`})]})}),(0,A.jsx)(Qn,{}),(0,A.jsx)(O,{variant:`icon`,size:`icon`,onClick:()=>{r()},disabled:i.status===`compiling`,title:`重新编译`,children:`↺`}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 px-1.5 shrink-0`,children:[(0,A.jsx)(Mt,{status:i.status}),(0,A.jsx)(`span`,{className:`text-[11px] text-text-muted max-w-28 truncate`,children:i.message})]}),(0,A.jsx)(`div`,{className:`flex-1 min-w-2`}),(0,A.jsx)(Un,{model:a,registry:o,simPanelWidth:c}),(0,A.jsx)(Qn,{}),(0,A.jsx)(Wn,{model:a,layout:s,simPanelWidth:c}),(0,A.jsx)(Qn,{}),(0,A.jsx)(Gn,{model:a,layout:s,simPanelWidth:c}),(0,A.jsx)(Qn,{}),(0,A.jsx)(O,{variant:`icon`,size:`icon`,onClick:()=>{me(!0)},title:`设置`,children:`⚙`})]})})}var er={x:0,y:0,width:0,height:0},tr=e=>({x:Math.round(e.x),y:Math.round(e.y),width:Math.max(0,Math.round(e.width)),height:Math.max(0,Math.round(e.height))});function nr(e,t){let n=t.present,r=t.publish,i=null,a=null,o=!1,s=()=>{let t=e.getBoundingClientRect();return tr({x:t.left,y:t.top,width:t.width,height:t.height})},c=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,l=()=>{if(o||!n)return;let e=s();a&&c(a,e)||(a=e,r(e))},u=()=>{i||(i=new ResizeObserver(l),i.observe(e),window.addEventListener(`resize`,l))},d=()=>{i&&=(i.disconnect(),null),window.removeEventListener(`resize`,l)},f=()=>{a=null,n?(u(),a=s(),r(a)):(d(),r(er))};return f(),{update(e){o||(r=e.publish,n=e.present,f())},dispose(){o||(o=!0,d())}}}function rr(e){let t=e.getBoundingClientRect();return{visible:!0,bounds:tr({x:t.left,y:t.top,width:t.width,height:t.height})}}var ir=(e,t)=>e.visible===t.visible?e.visible&&t.visible?e.bounds.x===t.bounds.x&&e.bounds.y===t.bounds.y&&e.bounds.width===t.bounds.width&&e.bounds.height===t.bounds.height:!0:!1;function ar(e,t){let n=t.visible,r=t.publish,i=t.guardDisplayNone??!1,a=t.followScroll??!1,o=t.followGeometry??!1,s=null,c=null,l=null,u=!1,d=null,f=0,p=!1,m=null,h=()=>{let t=rr(e);return i&&t.visible&&(t.bounds.width===0||t.bounds.height===0)?{visible:!1}:t},g=()=>{if(u||!n)return;let e=h();l&&ir(l,e)||(l=e,r(e))},_=()=>l?.visible===!1?!0:f++>=30,v=()=>{if(d=null,u||!n){m=null;return}if(m!==null&&performance.now()>=m){m=null;return}let e=h();if(!e.visible){if(_()){m=null;return}d=requestAnimationFrame(v);return}if(l&&ir(l,e)){if(f++,f>=2&&!p){m=null;return}}else l=e,r(e),f=0;!u&&n?d=requestAnimationFrame(v):m=null},y=()=>{!o||u||(f=0,d===null&&(d=requestAnimationFrame(v)))},b=()=>{d!==null&&(cancelAnimationFrame(d),d=null),f=0,m=null,p=!1},x=()=>{o?y():g()},S=e=>{let t=e.target;t&&t.closest&&t.closest(`[role="separator"]`)&&(p=!0,y())},C=()=>{p&&(p=!1,y())},w=()=>{s||(s=new ResizeObserver(g),s.observe(e),window.addEventListener(`resize`,g),i&&typeof IntersectionObserver<`u`&&(c=new IntersectionObserver(g),c.observe(e)),a&&window.addEventListener(`scroll`,x,{capture:!0,passive:!0}),o&&(window.addEventListener(`pointerdown`,S,{capture:!0}),window.addEventListener(`pointerup`,C,{capture:!0})))},T=()=>{s&&=(s.disconnect(),null),c&&=(c.disconnect(),null),window.removeEventListener(`resize`,g),window.removeEventListener(`scroll`,x,{capture:!0}),window.removeEventListener(`pointerdown`,S,{capture:!0}),window.removeEventListener(`pointerup`,C,{capture:!0}),b()},E=()=>{if(l=null,n)w(),l=h(),r(l);else{T();let e={visible:!1};l=e,r(e)}};return E(),{update(e){u||(r=e.publish,n=e.visible,E())},dispose(){u||(u=!0,T())},pulse(e){if(!(u||!o)){if(e!==void 0&&e>0){let t=performance.now()+e;m=m===null?t:Math.max(m,t)}y()}}}}function or(e){let t=(0,k.useRef)(null),n=(0,k.useRef)(null),r=(0,k.useRef)(e);r.current=e;let i=(0,k.useRef)([e.present,e.publish,...e.deps??[]]),a=(0,k.useRef)(()=>{let e=t.current;e&&(e.update({present:!1,publish:r.current.publish}),e.dispose(),t.current=null)}),o=(0,k.useCallback)(e=>{e!==n.current&&(n.current=e,t.current&&(e?(t.current.dispose(),t.current=null):a.current()),e&&(t.current=nr(e,{present:r.current.present,publish:r.current.publish}),i.current=[r.current.present,r.current.publish,...r.current.deps??[]]))},[]);return(0,k.useEffect)(()=>{let n=[e.present,e.publish,...e.deps??[]],r=i.current;(n.length!==r.length||n.some((e,t)=>!Object.is(e,r[t])))&&(i.current=n,t.current?.update({present:e.present,publish:e.publish}))},[e.present,e.publish,...e.deps??[]]),(0,k.useEffect)(()=>{let e=a.current;return n.current&&!t.current&&(t.current=nr(n.current,{present:r.current.present,publish:r.current.publish})),()=>{n.current===null&&e()}},[]),o}var sr=(0,k.createContext)(null);function cr(){return(0,k.useContext)(sr)}var I={simulator:`simulator`,simulatorDevtools:`simulator-devtools`,workbench:`workbench`,hostToolbar:`host-toolbar`,settings:`settings`,popover:`popover`},lr={base:0,hostToolbar:5,settings:10,popover:20};function ur(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function dr(e,t){let n=getComputedStyle(e.ownerDocument.body);return t*parseFloat(n.fontSize)}function fr(e){return e/100*window.innerHeight}function pr(e){return e/100*window.innerWidth}function mr(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}function hr({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=mr(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=dr(t,i);break;case`em`:r=ur(t,i);break;case`vh`:r=fr(i);break;case`vw`:r=pr(i);break}return r}function L(e){return parseFloat(e.toFixed(3))}function gr({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>(e+=t===`horizontal`?n.element.offsetWidth:n.element.offsetHeight,e),0)}function _r(e){let{panels:t}=e,n=gr({group:e});return n===0?t.map(e=>({groupResizeBehavior:e.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:e.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let{element:t,panelConstraints:r}=e,i=0;r.collapsedSize!==void 0&&(i=L(hr({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=L(hr({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=L(hr({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=L(hr({groupSize:n,panelElement:t,styleProp:r.maxSize})/n*100)),{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsible:r.collapsible===!0,defaultSize:a,disabled:r.disabled,minSize:o,maxSize:s,panelId:e.id}})}function R(e,t=`Assertion error`){if(!e)throw Error(t)}function vr(e,t){return Array.from(t).sort(e===`horizontal`?yr:br)}function yr(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function br(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function xr(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function Sr(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function Cr({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=Sr(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return R(i,`No rect found`),i}var wr;function Tr(){return wr===void 0&&(wr=typeof matchMedia==`function`?!!matchMedia(`(pointer:coarse)`).matches:!1),wr}function Er(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=vr(n,Array.from(t.children).filter(xr).map(e=>({element:e}))).map(({element:e})=>e),o=[],s=!1,c=!1,l=-1,u=-1,d=0,f,p=[];{let e=-1;for(let t of a)t.hasAttribute(`data-panel`)&&(e++,t.hasAttribute(`data-disabled`)||(d++,l===-1&&(l=e),u=e))}if(d>1){let t=-1;for(let d of a)if(d.hasAttribute(`data-panel`)){t++;let i=r.find(e=>e.element===d);if(i){if(f){let r=f.element.getBoundingClientRect(),a=d.getBoundingClientRect(),m;if(c){let e=n===`horizontal`?new DOMRect(r.right,r.top,0,r.height):new DOMRect(r.left,r.bottom,r.width,0),t=n===`horizontal`?new DOMRect(a.left,a.top,0,a.height):new DOMRect(a.left,a.top,a.width,0);switch(p.length){case 0:m=[e,t];break;case 1:{let i=p[0];m=[i,Cr({orientation:n,rects:[r,a],targetRect:i.element.getBoundingClientRect()})===r?t:e];break}default:m=p;break}}else m=p.length?p:[n===`horizontal`?new DOMRect(r.right,a.top,a.left-r.right,a.height):new DOMRect(a.left,r.bottom,a.width,a.top-r.bottom)];for(let n of m){let r=`width`in n?n:n.element.getBoundingClientRect(),a=Tr()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<a){let e=a-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<a){let e=a-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}!s&&!(t<=l||t>u)&&o.push({group:e,groupSize:gr({group:e}),panels:[f,i],separator:`width`in n?void 0:n,rect:r}),s=!1}}c=!1,f=i,p=[]}}else if(d.hasAttribute(`data-separator`)){d.ariaDisabled!==null&&(s=!0);let e=i.find(e=>e.element===d);e?p.push(e):(f=void 0,p=[])}else c=!0}return o}var Dr=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0)if(n.length===1)n[0].call(null,t);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}},z=new Map,Or=new Dr;function kr(e){z=new Map(z),z.delete(e)}function Ar(e,t){for(let[t]of z)if(t.id===e)return t}function B(e,t){for(let[t,n]of z)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function V(){return z}function jr(e,t){return Or.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function H(e,t){let n=z.get(e);z=new Map(z),z.set(e,t),Or.emit(`groupChange`,{group:e,prev:n,next:t})}function Mr(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=Sr(n,a.rect);switch(e){case`horizontal`:t.x<=i.x&&(r=a,i=t);break;case`vertical`:t.y<=i.y&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function Nr(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Pr(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:Br(e),b:Br(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();R(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:zr(Rr(n.a)),b:zr(Rr(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var Fr=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Ir(e){let t=getComputedStyle(Vr(e)??e).display;return t===`flex`||t===`inline-flex`}function Lr(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||Ir(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||Fr.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function Rr(e){let t=e.length;for(;t--;){let n=e[t];if(R(n,`Missing node`),Lr(n))return n}return null}function zr(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Br(e){let t=[];for(;e;)t.push(e),e=Vr(e);return t}function Vr(e){let{parentNode:t}=e;return Nr(t)?t.host:t}function Hr(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Ur({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!xr(n)||n.contains(e)||e.contains(n))return!0;if(Pr(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(Hr(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Wr(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=Er(r),a=Mr(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&Ur({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function Gr(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function U(e,t,n=0){return Math.abs(L(e)-L(t))<=n}function W(e,t){return U(e,t)?0:e>t?1:-1}function Kr({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsible:a,disabled:o,maxSize:s=100,minSize:c=0}=t;if(o&&!e)return n;if(W(r,c)<0)if(a){let e=(i+c)/2;r=W(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=L(r),r}function qr({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(U(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;R(u!=null,`Invalid first pivot index`),R(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];R(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(R(n!=null,`Previous layout not found for panel index ${t}`),U(n,i)){let t=o-n;W(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];R(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(R(n!=null,`Previous layout not found for panel index ${t}`),U(n,o)){let t=n-i;W(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];R(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&W(i,c)<0)if(e>0){let t=c-o,n=t/2;W(i+e,c)<0&&(e=W(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;W(i-e,c)<0&&(e=W(100+e,n)>0?0:-t)}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];R(e!=null,`Previous layout not found for panel index ${r}`);let a=Kr({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];R(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=Kr({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!U(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(Gr(c,l))return i;{let t=e<0?d:u,r=s[t];R(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=Kr({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!U(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];R(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=Kr({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(U(i,s)||(t-=s-i,l[r]=s),U(t,0))break;e>0?r--:r++}}}if(!U(Object.values(l).reduce((e,t)=>t+e,0),100,.1))return i;let p=Object.keys(i);return l.reduce((e,t,n)=>(e[p[n]]=t,e),{})}function G(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||W(e[n],t[n])!==0)return!1;return!0}function K({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],i=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(`, `)}`);if(!U(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];R(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];R(i!=null,`No layout data found for index ${e}`);let o=r[e];R(o!=null,`No layout data found for index ${e}`);let s=Kr({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!U(a,0))for(let e=0;e<t.length;e++){let n=r[e];R(n!=null,`No layout data found for index ${e}`);let i=n+a,o=Kr({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,U(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function Jr({groupId:e,panelId:t}){let n=()=>{let t=V();for(let[n,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:a,groupSize:o,separatorToPanels:s}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:n,groupSize:o,layout:a,separatorToPanels:s};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().group.panels.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=e=>{let r=a();if(e===r)return;let{defaultLayoutDeferred:i,derivedPanelConstraints:o,group:s,groupSize:c,layout:l,separatorToPanels:u}=n(),d=s.panels.findIndex(e=>e.id===t),f=d===s.panels.length-1,p=K({layout:qr({delta:f?r-e:e-r,initialLayout:l,panelConstraints:o,pivotIndices:f?[d-1,d]:[d,d+1],prevLayout:l,trigger:`imperative-api`}),panelConstraints:o});G(l,p)||H(s,{defaultLayoutDeferred:i,derivedPanelConstraints:o,groupSize:c,layout:p,separatorToPanels:u})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),s=a();e&&s!==t&&(n.expandToSize=s,o(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:s}=i(),c=a();if(e&&c===t){let e=s.expandToSize??n;e===0&&(e=1),o(e)}},getSize:()=>{let{group:e}=n(),t=a(),{element:r}=i();return{asPercentage:t,inPixels:e.orientation===`horizontal`?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&U(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=gr({group:t});o(L(hr({groupSize:a,panelElement:r,styleProp:e})/a*100))}}}function Yr(e){e.defaultPrevented||Wr(e,V()).forEach(t=>{if(t.separator&&!t.separator.disableDoubleClick){let n=t.panels.find(e=>e.panelConstraints.defaultSize!==void 0);if(n){let r=n.panelConstraints.defaultSize,i=Jr({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function Xr(e){let t=V();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function Zr({groupId:e}){let t=()=>{let t=V();for(let[n,r]of t)if(n.id===e)return{group:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:i,groupSize:a,layout:o,separatorToPanels:s}=t(),c=K({layout:e,panelConstraints:r});return n?o:(G(o,c)||H(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function q(e,t){let n=Xr(e),r=B(n.id,!0),i=n.separators.find(t=>t.element===e);R(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);R(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=Zr({groupId:n.id}).getLayout(),c=K({layout:qr({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});G(s,c)||H(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels})}function Qr(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=Xr(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&q(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&q(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&q(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&q(t,-5);break;case`End`:e.preventDefault(),q(t,100);break;case`Enter`:{e.preventDefault();let n=Xr(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=B(n.id,!0),o=n.separators.find(e=>e.element===t);R(o,`Matching separator not found`);let s=a.get(o);R(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(R(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];q(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=Xr(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);R(r!==null,`Index not found`),n[e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0].focus({preventScroll:!0});break}case`Home`:e.preventDefault(),q(t,-100);break}}var $r={cursorFlags:0,state:`inactive`},ei=new Dr;function J(){return $r}function ti(e){return ei.addListener(`change`,e)}function ni(e){let t=$r,n={...$r};n.cursorFlags=e,$r=n,ei.emit(`change`,{prev:t,next:n})}function ri(e){let t=$r;$r=e,ei.emit(`change`,{prev:t,next:e})}function ii(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=V(),n=Wr(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus({preventScroll:!0})));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),ri({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}var ai=e=>e,oi=()=>{},si=1,ci=2,li=4,ui=8,di=3,fi=12,pi;function mi(){return pi===void 0&&(pi=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(pi=!0)),pi}function hi({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&mi()){let t=(e&si)!==0,n=(e&ci)!==0,r=(e&li)!==0,i=(e&ui)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return mi()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var gi=new WeakMap;function _i(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=gi.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(n));let r=J();switch(r.state){case`active`:case`hover`:{let e=hi({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(e=>e.group),state:r.state}),i=`*, *:hover {cursor: ${e} !important; }`;if(t===i)return;t=i,e?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}gi.set(e,{prevStyle:t,styleSheet:n})}function vi({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0;n.forEach(e=>{let{group:n,groupSize:o}=e,{orientation:c,panels:l}=n,{disableCursor:u}=n.mutableState,d=0;d=a?c===`horizontal`?(t.clientX-a.x)/o*100:(t.clientY-a.y)/o*100:c===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let f=r.get(n),p=i.get(n);if(!f||!p)return;let{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:_,separatorToPanels:v}=p;if(h&&_&&v){let t=qr({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(G(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?si:ci;break;case`vertical`:s|=d<0?li:ui;break}}else H(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&di:c|=s&di,t.movementY===0?c|=o&fi:c|=s&fi,ni(c),_i(e)}function yi(e){let t=V(),n=J();switch(n.state){case`active`:vi({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function bi(e){if(e.defaultPrevented)return;let t=J(),n=V();switch(t.state){case`active`:if(e.buttons===0){ri({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=B(e.group.id,!0);H(e.group,t)});return}for(let n of t.hitRegions)if(n.separator){let{element:t}=n.separator;t.hasPointerCapture?.(e.pointerId)||t.setPointerCapture?.(e.pointerId)}vi({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=Wr(e,n);r.length===0?t.state!==`inactive`&&ri({cursorFlags:0,state:`inactive`}):ri({cursorFlags:0,hitRegions:r,state:`hover`}),_i(e.currentTarget);break}}}function xi(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(J().state){case`hover`:ri({cursorFlags:0,state:`inactive`})}}function Si(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=J();switch(t.state){case`active`:ri({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(_i(e.currentTarget),t.hitRegions.forEach(e=>{let t=B(e.group.id,!0);H(e.group,t)}),e.preventDefault())}}function Ci(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=L(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=L((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function wi(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=gr({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:L(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function Ti(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Ei({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,a=0,o=!1,s=new Map,c=[];for(let l of e.panels){let e=r[l.id]??0;switch(l.panelConstraints.groupResizeBehavior){case`preserve-pixel-size`:{o=!0;let r=L(e/100*n/t*100);s.set(l.id,r),i+=r;break}default:c.push(l.id),a+=e;break}}if(!o||c.length===0)return r;let l=100-i,u={...r};if(s.forEach((e,t)=>{u[t]=e}),a>0)for(let e of c)u[e]=L((r[e]??0)/a*l);else{let e=L(l/c.length);for(let t of c)u[t]=e}return u}function Di(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}var Oi=new Map;function ki(e){let t=!0;R(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){let t=gr({group:e});if(t===0)return;let n=B(e.id);if(!n)return;let r=_r(e),i=n.defaultLayoutDeferred?Ci(r):n.layout,a=K({layout:Ei({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&G(n.layout,a)&&Ti(n.derivedPanelConstraints,r)&&n.groupSize===t)return;H(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else wi(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{R(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=gr({group:e}),s=_r(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(Di(e.panels,l)||(l=void 0));let u=K({layout:e.mutableState.layouts[c]??l??Ci(s),panelConstraints:s}),d=e.element.ownerDocument;Oi.set(d,(Oi.get(d)??0)+1);let f=new Map;return Er(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),H(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,groupSize:o,layout:u,separatorToPanels:f}),e.separators.forEach(e=>{R(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,Qr)}),Oi.get(d)===1&&(d.addEventListener(`dblclick`,Yr,!0),d.addEventListener(`pointerdown`,ii,!0),d.addEventListener(`pointerleave`,yi),d.addEventListener(`pointermove`,bi),d.addEventListener(`pointerout`,xi),d.addEventListener(`pointerup`,Si,!0)),function(){t=!1,Oi.set(d,Math.max(0,(Oi.get(d)??0)-1)),kr(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,Qr)}),Oi.get(d)||(d.removeEventListener(`dblclick`,Yr,!0),d.removeEventListener(`pointerdown`,ii,!0),d.removeEventListener(`pointerleave`,yi),d.removeEventListener(`pointermove`,bi),d.removeEventListener(`pointerout`,xi),d.removeEventListener(`pointerup`,Si,!0)),a.disconnect()}}function Ai(){let[e,t]=(0,k.useState)({});return[e,(0,k.useCallback)(()=>t({}),[])]}function ji(e){let t=(0,k.useId)();return`${e??t}`}var Mi=typeof window<`u`?k.useLayoutEffect:k.useEffect;function Ni(e){let t=(0,k.useRef)(e);return Mi(()=>{t.current=e},[e]),(0,k.useCallback)((...e)=>t.current?.(...e),[t])}function Pi(...e){return Ni(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function Fi(e){let t=(0,k.useRef)({...e});return Mi(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var Ii=(0,k.createContext)(null);function Li(e,t){let n=(0,k.useRef)({getLayout:()=>({}),setLayout:ai});(0,k.useImperativeHandle)(t,()=>n.current,[]),Mi(()=>{Object.assign(n.current,Zr({groupId:e}))})}function Ri({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){let m=(0,k.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=Ni(e=>{G(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=Ni(e=>{G(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e))}),_=ji(s),v=(0,k.useRef)(null),[y,b]=Ai(),x=(0,k.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=Pi(v,a);Li(_,o);let C=Ni((e,t)=>{let r=J(),i=Ar(e),a=B(e);if(a){let e=!1;switch(r.state){case`active`:e=r.hitRegions.some(e=>e.group===i);break}return{flexGrow:a.layout[t]??1,pointerEvents:e?`none`:void 0}}if(n?.[t])return{flexGrow:n?.[t]}}),w=Fi({defaultLayout:n,disableCursor:r}),T=(0,k.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=vr(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=vr(u,[...t.separators,e]),b(),()=>{t.separators=t.separators.filter(t=>t!==e),b()}},updatePanelProps:(e,{disabled:t})=>{let n=x.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let r=Ar(_),i=B(_);r&&i&&H(r,{...i,derivedPanelConstraints:_r(r)})},updateSeparatorProps:(e,{disabled:t,disableDoubleClick:n})=>{let r=x.current.separators.find(t=>t.id===e);r&&(r.disabled=t,r.disableDoubleClick=n)}}),[C,_,b,u,w]),E=(0,k.useRef)(null);return Mi(()=>{let e=v.current;if(e===null)return;let t=x.current,n;if(w.defaultLayout!==void 0&&Object.keys(w.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=w.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={disabled:!!i,element:e,id:_,mutableState:{defaultLayout:n,disableCursor:!!w.disableCursor,expandedPanelSizes:x.current.lastExpandedPanelSizes,layouts:x.current.layouts},orientation:u,panels:t.panels,resizeTargetMinimumSize:t.resizeTargetMinimumSize,separators:t.separators};E.current=r;let a=ki(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=B(r.id,!0);!o&&s.length>0&&(h(c),g(c));let l=jr(_,e=>{let{defaultLayoutDeferred:t,derivedPanelConstraints:n,layout:i}=e.next;if(t||n.length===0)return;let a=r.panels.map(({id:e})=>e).join(`,`);r.mutableState.layouts[a]=i,n.forEach(t=>{if(t.collapsible){let{layout:n}=e.prev??{};if(n){let e=U(t.collapsedSize,i[t.panelId]),a=U(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=J().state!==`active`;h(i),o&&g(i)});return()=>{E.current=null,a(),l()}},[i,_,g,h,u,y,w]),(0,k.useEffect)(()=>{let e=E.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,A.jsx)(Ii.Provider,{value:T,children:(0,A.jsx)(`div`,{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:S,style:{height:`100%`,width:`100%`,overflow:`hidden`,...f,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:e})})}Ri.displayName=`Group`;function zi(){let e=(0,k.useContext)(Ii);return R(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function Bi(e,t){let{id:n}=zi(),r=(0,k.useRef)({collapse:oi,expand:oi,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:oi});(0,k.useImperativeHandle)(t,()=>r.current,[]),Mi(()=>{Object.assign(r.current,Jr({groupId:n,panelId:e}))})}function Vi({children:e,className:t,collapsedSize:n=`0%`,collapsible:r=!1,defaultSize:i,disabled:a,elementRef:o,groupResizeBehavior:s=`preserve-relative-size`,id:c,maxSize:l=`100%`,minSize:u=`0%`,onResize:d,panelRef:f,style:p,...m}){let h=!!c,g=ji(c),_=Fi({disabled:a}),v=(0,k.useRef)(null),y=Pi(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,updatePanelProps:w}=zi(),T=d!==null,E=Ni((e,t,n)=>{d?.(e,c,n)});Mi(()=>{let e=v.current;if(e!==null)return C({element:e,id:g,idIsStable:h,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:T?E:void 0,panelConstraints:{groupResizeBehavior:s,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:l,minSize:u}})},[s,n,r,i,T,g,h,l,u,E,C,_]),(0,k.useEffect)(()=>{w(g,{disabled:a})},[a,g,w]),Bi(g,f);let D=()=>{let e=b(x,g);if(e)return JSON.stringify(e)},ee=(0,k.useSyncExternalStore)(e=>jr(x,e),D,D),te;return te=ee?JSON.parse(ee):i?{flexGrow:void 0,flexShrink:void 0,flexBasis:i}:{flexGrow:1},(0,A.jsx)(`div`,{...m,"data-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...Hi,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...te},children:(0,A.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:S===`horizontal`?`pan-y`:`pan-x`},children:e})})}Vi.displayName=`Panel`;var Hi={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function Ui({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a,o=e[n],s=t.find(e=>e.panelId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=K({layout:qr({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=K({layout:qr({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function Wi({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=ji(a),l=Fi({disabled:n,disableDoubleClick:r}),[u,d]=(0,k.useState)({}),[f,p]=(0,k.useState)(`inactive`),[m,h]=(0,k.useState)(!1),g=(0,k.useRef)(null),_=Pi(g,i),{disableCursor:v,id:y,orientation:b,registerSeparator:x,updateSeparatorProps:S}=zi(),C=b===`horizontal`?`vertical`:`horizontal`;Mi(()=>{let e=g.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=x(t),r=ti(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=jr(y,e=>{let{derivedPanelConstraints:n,layout:r,separatorToPanels:i}=e.next,a=i.get(t);if(a){let e=a[0],t=a.indexOf(e);d(Ui({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[y,c,x,l]),(0,k.useEffect)(()=>{S(c,{disabled:n,disableDoubleClick:r})},[n,r,c,S]);let w;n&&!v&&(w=`not-allowed`);let T;if(n)T=`disabled`;else switch(f){case`active`:T=`active`;break;default:T=m?`focus`:f}return(0,A.jsx)(`div`,{...s,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":C,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":T,"data-testid":c,id:c,onBlur:()=>h(!1),onFocus:()=>h(!0),ref:_,role:`separator`,style:{flexBasis:`auto`,cursor:w,...o,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}Wi.displayName=`Separator`;function Gi(e,t,n,r){return!(e>0)||!(t>0)||!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)}function Ki(e){return Number.isFinite(e)?Math.max(0,Math.min(.5,e)):.25}function qi(e,t,n,r){let i=n<0?n:n>e?n-e:0,a=r<0?r:r>t?r-t:0;if(i===0&&a===0)return;let o=Math.abs(i);return o>=Math.abs(a)&&o>0?i<0?`left`:`right`:a<0?`top`:`bottom`}function Ji(e,t,n,r,i){let a=i*Math.min(e,t),o=n<a,s=n>e-a,c=r<a,l=r>t-a;return{inLeft:o,inTop:c,activeHoriz:o||s,activeVert:c||l}}function Yi(e,t,n,r,i,a){return(i?n/e:(e-n)/e)<=(a?r/t:(t-r)/t)?i?`left`:`right`:a?`top`:`bottom`}function Xi(e,t,n,r,i){let{inLeft:a,inTop:o,activeHoriz:s,activeVert:c}=Ji(e,t,n,r,i);return!s&&!c?`center`:s&&!c?a?`left`:`right`:c&&!s?o?`top`:`bottom`:Yi(e,t,n,r,a,o)}function Zi(e,t,n=.25){let{width:r,height:i}=e,{x:a,y:o}=t;if(Gi(r,i,a,o))return`center`;let s=Ki(n),c=qi(r,i,a,o);return c===void 0?Xi(r,i,a,o,s):c}function Qi(e,t,n){if(e===`center`)return{kind:`move`,panelId:t,destGroupId:n.groupId};let r=e===`left`||e===`right`?`row`:`column`,i=e===`left`||e===`top`?`before`:`after`;return{kind:`split`,atPanelId:n.panelId,dir:r,side:i,newPanelId:t}}function $i(e,t,n,r){return e===n.panelId||r===`center`&&t!==void 0&&t===n.groupId}function ea(e,t){if(!Number.isFinite(t))return 0;let n=0;for(let r of e)if(t>=r.left+r.width/2)n+=1;else break;return n}function ta(e,t,n,r){let i=t.indexOf(n),a=i>=0&&r>i,o=t.filter(e=>e!==n),s=e.filter(e=>e!==n),c=a?r-1:r;if(c<0&&(c=0),c>o.length&&(c=o.length),c>=o.length)return s.length;let l=o[c],u=s.indexOf(l);return u>=0?u:s.length}var na=.5;function ra(e){let t=e.reduce((e,t)=>e+(t>0?t:0),0);if(t<=0){let t=e.length>0?100/e.length:100;return e.map(()=>t)}return e.map(e=>(e>0?e:0)/t*100)}function ia(e,t){let n=e.map((e,t)=>t).filter(e=>(t?.[e]??null)===null),r=ra(n.map(t=>e[t]??0)),i=new Map;return n.forEach((e,t)=>{i.set(e,r[t])}),i}function aa(e){return Math.min(1,Math.max(.5,Math.floor(90/Math.max(1,e))))}function oa(e,t){let n=e.filter((e,n)=>(t?.[n]??null)===null).length,r=aa(n);return e.map((e,n)=>(t?.[n]??null)===null?Number.isFinite(e)&&e>=r?e:r:e)}function sa(e,t,n,r=na){let i=new Set(n);for(let t of Object.keys(e))if(!i.has(t))return!1;for(let e of Object.keys(t))if(!i.has(e))return!1;for(let i of n){let n=e[i],a=t[i];if(!Number.isFinite(n)||!Number.isFinite(a)||Math.abs(n-a)>r)return!1}return!0}function ca(e,t,n,r,i){let a=e=>(n?.[e]??null)!==null,o=t=>{let a=n?.[t]??null;if(i&&i.containerPx>0&&a){if(a.fixedPx!=null)return a.fixedPx/i.containerPx*100;if(a.minPx!=null&&!i.trustLiveForMinPx)return a.minPx/i.containerPx*100}let o=r[e[t]];return typeof o==`number`?o:null},s=la(e,a,o);if(s===null)return null;let c=Math.max(0,100-s),l=0,u=0;for(let n=0;n<e.length;n++){if(a(n))continue;let e=t[n]??0;l+=e>0?e:0,u+=1}let d={};for(let n=0;n<e.length;n++){let r=e[n];d[r]=a(n)?o(n):ua(t[n]??0,c,l,u)}return d}function la(e,t,n){let r=0;for(let i=0;i<e.length;i++){if(!t(i))continue;let e=n(i);if(e===null)return null;r+=e}return r}function ua(e,t,n,r){return n<=0?r>0?t/r:t:t*(e>0?e:0)/n}function da(e,t,n){let r=[],i=[];for(let a=0;a<e.length;a++){if((t?.[a]??null)!==null)continue;let o=n[e[a]];if(typeof o!=`number`||!Number.isFinite(o))return null;r.push(a),i.push(o>0?o:0)}return r.length===0?null:{indices:r,ratios:ra(i)}}function fa(e){let{node:t,ctx:n}=e,r=t.orientation===`row`?`horizontal`:`vertical`,i=ia(t.sizes,t.constraints),a=t.children.filter((e,n)=>(t.constraints?.[n]??null)===null).length,o=String(aa(a)),s=(0,k.useRef)(null),c=(0,k.useRef)(null),l=(0,k.useRef)(t);l.current=t;let u=[];t.children.forEach((e,r)=>{r>0&&u.push((0,A.jsx)(Wi,{"data-deck-resize-handle":``},`handle-${r}`));let a=t.constraints?.[r]??null;if(a?.fixedPx!=null){let t=`${a.fixedPx}px`;u.push((0,A.jsx)(Vi,{id:e.id,defaultSize:t,minSize:t,maxSize:t,groupResizeBehavior:`preserve-pixel-size`,children:wa(e,n)},pa(e)))}else if(a?.minPx!=null){let t=`${a.minPx}px`;u.push((0,A.jsx)(Vi,{id:e.id,defaultSize:t,minSize:t,groupResizeBehavior:`preserve-pixel-size`,children:wa(e,n)},pa(e)))}else{let t=i.get(r);u.push((0,A.jsx)(Vi,{id:e.id,defaultSize:t==null?void 0:String(t),minSize:o,children:wa(e,n)},pa(e)))}});let d=e=>{let t=l.current,r=t.children.map(e=>e.id),i=e=>(t.constraints?.[e]??null)!==null,a=da(r,t.constraints,e);if(!a)return;let o=ia(t.sizes,t.constraints),s=a.indices.map(e=>o.get(e)??0);if(!a.ratios.some((e,t)=>Math.abs(e-s[t])>.1))return;let c=r.map((n,r)=>i(r)?t.sizes[r]??1:e[n]);n.onApplyLayout(t.id,oa(c,t.constraints))},f=e=>{c.current=e,e&&(e.__deckApplyLayout=e=>{let t=l.current,r=e=>(t.constraints?.[e]??null)!==null,i=e.map((e,n)=>r(n)?t.sizes[n]??1:e);n.onApplyLayout(t.id,oa(i,t.constraints))},Object.defineProperty(e,`__deckGroupApi`,{configurable:!0,get:()=>s.current??void 0}))},p=(0,k.useCallback)(e=>{let t=s.current;if(!t)return{pushed:!1,stuck:!1};let n=l.current,r=n.children.map(e=>e.id),i=t.getLayout(),a=c.current?.getBoundingClientRect(),o=a?n.orientation===`row`?a.width:a.height:0,u=o>0?{containerPx:o,trustLiveForMinPx:!e}:void 0,d=ca(r,n.sizes,n.constraints,i,u);return d?sa(i,d,r)?{pushed:!1,stuck:!0}:(t.setLayout(d),{pushed:!0,stuck:sa(t.getLayout(),d,r)}):{pushed:!1,stuck:!1}},[]),m=t.sizes.join(`,`),h=t.children.length,g=(0,k.useRef)(null);return(0,k.useEffect)(()=>{let e=g.current!==h;if(g.current=h,!e){p(!1);return}let t=!1,n=0,r=0,i=()=>{if(t)return;r+=1;let{stuck:e}=p(!0);!e&&r<8&&(n=requestAnimationFrame(i))};return n=requestAnimationFrame(i),()=>{t=!0,cancelAnimationFrame(n)}},[m,h,p]),(0,A.jsx)(`div`,{ref:f,"data-deck-split":t.id,"data-orientation":t.orientation,"data-deck-sizes":t.sizes.join(`,`),style:{width:`100%`,height:`100%`},children:(0,A.jsx)(Ri,{groupRef:s,orientation:r,onLayoutChanged:d,style:{width:`100%`,height:`100%`},children:u},t.children.length)})}function pa(e){return e.id}function ma(e,t){let n=e.active;return n?(0,A.jsxs)(k.Fragment,{children:[t.registry.get(n)?.kind===`native`?(0,A.jsx)(ha,{panelId:n,bindNativeSlot:t.bindNativeSlot},n):null,e.panels.filter(e=>t.registry.get(e)?.kind!==`native`).slice().sort((e,t)=>e<t?-1:+(e>t)).map(e=>{let r=e===n;return(0,A.jsx)(`div`,{"data-deck-panel-body":e,style:{display:r?`flex`:`none`,flexDirection:`column`,flex:1,minWidth:0,minHeight:0},children:t.renderDomPanel(e,{active:r})},`dom-${e}`)})]}):null}function ha(e){let{panelId:t,bindNativeSlot:n}=e,r=(0,k.useRef)(n);return r.current=n,(0,A.jsx)(`div`,{ref:(0,k.useCallback)(e=>{r.current(t,e)},[t]),"data-deck-native-slot":t,style:{flex:1,minWidth:0,minHeight:0,height:`100%`}})}var ga=`application/x-deck-panel`;function _a(e){let{node:t,ctx:n}=e,[r,i]=(0,k.useState)(null),a=(0,k.useRef)(t);a.current=t;let o=(0,k.useRef)(n.onRedock);o.current=n.onRedock;let s=e=>{e&&(e.__deckHandleDrop=(e,t)=>{let n=a.current;o.current(n.id,n.active,e,t)})},c=e=>{if(!e.dataTransfer?.types.includes(ga))return;e.preventDefault();let t=n.activeDragPanelId.current;if(n.suppressReorderOnlyDropIndicator&&t!==null&&n.registry.get(t)?.dropPolicy===`reorder-only`){i(null);return}let r=e.currentTarget.getBoundingClientRect();i(Zi({width:r.width,height:r.height},{x:e.clientX-r.left,y:e.clientY-r.top}))},l=()=>{i(null)},u=e=>{e.preventDefault();let r=e.currentTarget.getBoundingClientRect(),a=Zi({width:r.width,height:r.height},{x:e.clientX-r.left,y:e.clientY-r.top});i(null);let o=e.dataTransfer?.getData(ga);if(!o||n.registry.get(o)===void 0||!n.isPanelInTree(o))return;let s=ea(Array.from(e.currentTarget.querySelectorAll(`[data-deck-tab]`)).map(e=>{let t=e.getBoundingClientRect();return{left:t.left,width:t.width}}),e.clientX);n.onRedock(t.id,t.active,o,a,s)},d=e=>{e.dataTransfer?.types.includes(ga)&&(e.preventDefault(),e.stopPropagation(),i(null))},f=e=>{e.preventDefault(),e.stopPropagation(),i(null);let r=e.dataTransfer?.getData(ga);if(!r||n.registry.get(r)===void 0||!n.isPanelInTree(r))return;let a=ea(Array.from(e.currentTarget.querySelectorAll(`[data-deck-tab]`)).map(e=>{let t=e.getBoundingClientRect();return{left:t.left,width:t.width}}),e.clientX);n.onRedock(t.id,t.active,r,`center`,a)},p=t.panels.filter(e=>!n.registry.get(e)?.hideTab);return(0,A.jsxs)(`div`,{ref:s,"data-deck-group":t.id,onDragOver:c,onDragLeave:l,onDrop:u,style:{position:`relative`,display:`flex`,flexDirection:`column`,width:`100%`,height:`100%`,minWidth:0,minHeight:0},children:[p.length>0?(0,A.jsx)(`div`,{role:`tablist`,style:{flexShrink:0},onDragOver:d,onDrop:f,children:p.map(e=>{let r=e===t.active,i=n.registry.get(e),a=i?.title??e;return(0,A.jsxs)(`button`,{type:`button`,role:`tab`,draggable:i?.draggable===!1?void 0:`true`,"data-deck-tab":e,"data-active":r?`true`:`false`,onDragStart:t=>{if(t.target instanceof Element&&t.target.closest(`[data-deck-tab-close]`)!==null){t.preventDefault();return}t.dataTransfer.setData(ga,e),t.dataTransfer.setData(`text/plain`,e),t.dataTransfer.effectAllowed=`move`,n.activeDragPanelId.current=e},onDragEnd:()=>{n.activeDragPanelId.current=null},onClick:()=>{r?n.onActiveTabClick?.(e):n.onActivate(t.id,e)},children:[a,n.canClose&&i?.closable!==!1?(0,A.jsx)(`span`,{role:`button`,tabIndex:0,"data-deck-tab-close":e,"aria-label":`Close ${a}`,onPointerDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),t.preventDefault(),n.onClose(e)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.stopPropagation(),t.preventDefault(),n.onClose(e))},children:`×`}):null]},e)})}):null,ma(t,n),r?(0,A.jsx)(ya,{zone:r}):null]})}function va(e){let t={position:`absolute`,pointerEvents:`none`,background:`rgba(64, 128, 255, 0.25)`,outline:`2px solid rgba(64, 128, 255, 0.6)`};switch(e){case`left`:return{...t,left:`0`,top:`0`,width:`50%`,height:`100%`};case`right`:return{...t,right:`0`,top:`0`,width:`50%`,height:`100%`};case`top`:return{...t,left:`0`,top:`0`,width:`100%`,height:`50%`};case`bottom`:return{...t,left:`0`,bottom:`0`,width:`100%`,height:`50%`};default:return{...t,left:`0`,top:`0`,width:`100%`,height:`100%`}}}function ya(e){return(0,A.jsx)(`div`,{"data-deck-drop-zone":e.zone,style:va(e.zone)})}var ba=(0,k.createContext)(0);function xa(){return(0,k.useContext)(ba)}function Sa(e,t,n){let{groupId:r,activePanelId:i,draggedPanelId:a,draggedGroupId:o,zone:s,reorderIndex:c}=n;if(o===void 0||o!==r||s!==`center`)return;let l=Xt(e.get().root,r),u;if(c!==void 0&&l){let e=l.panels.filter(e=>t.get(e)?.hideTab!==!0);u=ta(l.panels,e,a,c)}else u=l?l.panels.indexOf(i):void 0;e.apply(e=>gn(e,a,{groupId:r,index:u}))}function Ca(e){let{model:t,registry:n,renderDomPanel:r,bindNativeSlot:i,suppressReorderOnlyDropIndicator:a,onActiveTabClick:o}=e,[s,c]=(0,k.useState)(()=>t.get()),[l,u]=(0,k.useState)(0),d=(0,k.useRef)(null);(0,k.useEffect)(()=>(c(t.get()),t.subscribe(e=>{c(e.tree),u(e.revision)})),[t]);let f=(0,k.useCallback)((e,n)=>{t.apply(t=>un(t,e,n))},[t]),p=(0,k.useCallback)(e=>{t.apply(t=>xn(t,e,n))},[t,n]),m=$t(s.root)>1,h=(0,k.useCallback)(e=>Qt(s.root,e)!==void 0,[s]),g=(0,k.useCallback)((e,n)=>{t.apply(t=>cn(t,e,n))},[t]),_=(0,k.useCallback)((e,r,i,a,o)=>{let s={groupId:e,panelId:r},c=Qt(t.get().root,i);if(n.get(i)?.draggable===!1||n.get(r)?.draggable===!1)return;if(n.get(i)?.dropPolicy===`reorder-only`){Sa(t,n,{groupId:e,activePanelId:r,draggedPanelId:i,draggedGroupId:c,zone:a,reorderIndex:o});return}if($i(i,c,s,a))return;let l=Qi(a,i,s);if(l.kind===`move`){t.apply(e=>gn(e,l.panelId,{groupId:l.destGroupId}));return}t.apply(e=>{let{tree:t}=pn(e,l.newPanelId);return Qt(t.root,l.atPanelId)===void 0?e:yn(t,l.atPanelId,l.dir,l.newPanelId,l.side)})},[t,n]);return(0,A.jsx)(ba.Provider,{value:l,children:wa(s.root,{registry:n,renderDomPanel:r,bindNativeSlot:i,onActivate:f,onActiveTabClick:o,onApplyLayout:g,onRedock:_,onClose:p,canClose:m,isPanelInTree:h,suppressReorderOnlyDropIndicator:a??!1,activeDragPanelId:d})})}function wa(e,t){return e.kind===`split`?Ta(e,t):Ea(e,t)}function Ta(e,t){return(0,A.jsx)(fa,{node:e,ctx:t},e.id)}function Ea(e,t){return(0,A.jsx)(_a,{node:e,ctx:t},e.id)}function Da({phase:e,code:t,reason:n,onRelaunch:r}){return(0,A.jsx)(`div`,{"data-testid":`sim-runtime-error`,className:`absolute inset-0 flex flex-col items-center justify-center bg-black/70 z-10`,children:(0,A.jsxs)(`div`,{className:`text-center p-4`,children:[(0,A.jsx)(`div`,{className:`text-status-error text-[14px] font-medium mb-2`,children:e===`crashed`?`小程序已崩溃`:`小程序启动失败`}),(0,A.jsx)(`div`,{className:`text-status-error text-[11px] max-w-[280px] break-words mb-3`,children:n??t??`未知原因`}),(0,A.jsx)(`button`,{type:`button`,onClick:r,className:`text-[11px] px-3 py-1 rounded border border-status-error text-status-error hover:bg-status-error/10`,children:`重新启动`})]})})}function Oa({requested:e,resolved:t,onDismiss:n}){return(0,A.jsxs)(`div`,{"data-testid":`sim-fallback-banner`,className:`flex items-center gap-2 px-2.5 py-1 bg-status-warn/15 border-b border-status-warn/40 text-[11px] text-status-warn shrink-0`,children:[(0,A.jsxs)(`span`,{className:`flex-1 min-w-0 truncate`,children:[`启动页 "`,e,`" 不存在,已回退到 "`,t,`"`]}),(0,A.jsx)(`button`,{type:`button`,onClick:n,className:`shrink-0 text-status-warn/80 hover:text-status-warn px-1`,title:`关闭`,children:`×`})]})}function ka(){return(0,A.jsx)(`div`,{"data-testid":`sim-watcher-dead-banner`,className:`flex items-center gap-2 px-2.5 py-1 bg-status-error/15 border-b border-status-error/40 text-[11px] text-status-error shrink-0`,children:`文件监听已停止,后续代码修改将不会自动重新编译`})}var Aa=50;function ja(e,t,n){if(e.width<=0||e.height<=0)return n;let r=Math.min(e.width/(t.width+Aa),e.height/(t.height+Aa));return Math.max(1,Math.min(100,Math.floor(r*100)))}function Ma({device:e,zoom:t,onDeviceChange:n,onZoomChange:r,compileStatus:i,currentPage:a,copied:o,onCopyPagePath:s,runtimeStatus:c=null,watcherDead:l=!1,onRelaunch:u=()=>{},onOpenInternalDevtools:d=()=>{}}){let f=(0,k.useRef)(typeof t==`number`?t:100),p=(0,k.useRef)(t),m=(0,k.useRef)(e),h=(0,k.useRef)(null),[g,_]=(0,k.useState)(!1);(0,k.useEffect)(()=>{i.status===`ready`&&_(!0)},[i.status]);let v=c?.phase===`launch-failed`||c?.phase===`crashed`,[b,x]=(0,k.useState)(!1);(0,k.useEffect)(()=>{c||x(!1)},[c]);let C=!!c?.pageFallback&&!v&&!b,T=i.status===`compiling`&&g,E=cr(),D=(0,k.useCallback)(e=>{if(e.visible){let t=p.current;f.current=t===`auto`?ja(e.bounds,m.current,f.current):t}E?.set({viewId:I.simulator,placement:e,layer:lr.base,extra:{zoom:f.current}})},[E]),ee=(0,k.useCallback)(e=>{let t=h.current;if(t){e?(t.dispose(),h.current=ar(e,{visible:!0,followGeometry:!0,guardDisplayNone:!0,publish:D})):(t.update({visible:!1,publish:D}),t.dispose(),h.current=null);return}e&&(h.current=ar(e,{visible:!0,followGeometry:!0,guardDisplayNone:!0,publish:D}))},[D]);return(0,k.useLayoutEffect)(()=>{p.current=t,m.current=e}),(0,k.useLayoutEffect)(()=>{h.current?.update({visible:!0,publish:D})},[t,e,D]),(0,k.useEffect)(()=>{h.current?.pulse(300)},[xa()]),(0,k.useEffect)(()=>()=>{h.current?.dispose(),h.current=null,E?.remove(I.simulator)},[E]),(0,A.jsxs)(`div`,{className:`bg-sim-bg flex flex-col overflow-hidden h-full w-full`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 px-5 py-2 shrink-0 border-b border-border-subtle`,children:[(0,A.jsx)(le,{value:e.name,onChange:n,children:fe.map(e=>(0,A.jsx)(`option`,{value:e.name,children:e.name},e.name))}),(0,A.jsxs)(le,{value:t,onChange:r,className:`w-[76px] shrink-0`,children:[w.map(e=>(0,A.jsxs)(`option`,{value:e,children:[e,`%`]},e)),(0,A.jsx)(`option`,{value:S,children:`自适应`})]})]}),l&&(0,A.jsx)(ka,{}),C&&c?.pageFallback&&(0,A.jsx)(Oa,{requested:c.pageFallback.requested,resolved:c.pageFallback.resolved,onDismiss:()=>x(!0)}),(0,A.jsxs)(`div`,{ref:ee,className:`flex-1 min-h-0 bg-sim-bg relative`,"data-area":`native-simulator`,children:[i.status===`compiling`&&!g&&(0,A.jsx)(`div`,{"data-testid":`sim-compiling-overlay`,className:`absolute inset-0 flex items-center justify-center bg-black/50 z-10`,children:(0,A.jsx)(`div`,{className:`text-text-dim text-[13px]`,children:`正在编译中...`})}),T&&(0,A.jsxs)(`div`,{"data-testid":`sim-recompiling-indicator`,className:`absolute top-2 right-2 z-10 flex items-center gap-1.5 rounded bg-black/60 px-2 py-0.5 pointer-events-none`,children:[(0,A.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-accent animate-pulse`}),(0,A.jsx)(`span`,{className:`text-text-dim text-[11px]`,children:`编译中…`})]}),i.status===`error`&&(0,A.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/70 z-10`,children:(0,A.jsxs)(`div`,{className:`text-center p-4`,children:[(0,A.jsx)(`div`,{className:`text-status-error text-[14px] font-medium mb-2`,children:`编译失败`}),(0,A.jsx)(`div`,{className:`text-status-error text-[11px] max-w-[280px] break-words`,children:i.message})]})}),i.status!==`error`&&c&&(c.phase===`launch-failed`||c.phase===`crashed`)&&(0,A.jsx)(Da,{phase:c.phase,code:c.code,reason:c.reason,onRelaunch:u})]}),(0,A.jsxs)(`div`,{className:`flex items-center px-2.5 bg-sim-bottom border-t border-border-subtle shrink-0 h-[30px] min-w-0`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0`,children:[(0,A.jsx)(`span`,{className:`text-[11px] text-text-dim truncate min-w-0`,children:a||`—`}),a&&(0,A.jsx)(`button`,{className:y(`shrink-0 flex items-center justify-center w-4 h-4 rounded transition-colors`,o?`text-accent`:`text-text-dim hover:text-text`),onClick:s,title:`复制路径`,children:o?(0,A.jsx)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 10 10`,fill:`none`,children:(0,A.jsx)(`polyline`,{points:`1.5,5 4,7.5 8.5,2.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})}):(0,A.jsxs)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 10 10`,fill:`none`,children:[(0,A.jsx)(`rect`,{x:`1`,y:`3`,width:`6`,height:`6.5`,rx:`1`,stroke:`currentColor`,strokeWidth:`1`}),(0,A.jsx)(`path`,{d:`M3 3V2a1 1 0 011-1h4a1 1 0 011 1v5a1 1 0 01-1 1H7`,stroke:`currentColor`,strokeWidth:`1`})]})})]}),(0,A.jsx)(`button`,{className:`ml-auto shrink-0 flex items-center justify-center w-4 h-4 rounded text-text-dim hover:text-text transition-colors`,onClick:d,title:`调试开发者工具`,"data-testid":`sim-open-internal-devtools`,children:(0,A.jsxs)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 11 11`,fill:`none`,children:[(0,A.jsx)(`rect`,{x:`3`,y:`3.5`,width:`5`,height:`5.5`,rx:`1.5`,stroke:`currentColor`,strokeWidth:`1`}),(0,A.jsx)(`path`,{d:`M4 3.5V3a1.5 1.5 0 013 0v.5M1.5 5.5H3M8 5.5h1.5M2 8.5l1.3-1M9 8.5l-1.3-1M2 3l1.3 1M9 3L7.7 4`,stroke:`currentColor`,strokeWidth:`1`,strokeLinecap:`round`})]})})]})]})}function Na(){let e=(0,k.useRef)(null),t=cr(),n=(0,k.useCallback)(e=>{t?.set({viewId:I.workbench,placement:e,layer:lr.base})},[t]),r=(0,k.useCallback)(t=>{let r=e.current;if(r){t?(r.dispose(),e.current=ar(t,{visible:!0,guardDisplayNone:!0,followScroll:!0,followGeometry:!0,publish:n})):(r.update({visible:!1,publish:n}),r.dispose(),e.current=null);return}t&&(e.current=ar(t,{visible:!0,guardDisplayNone:!0,followScroll:!0,followGeometry:!0,publish:n}))},[n]);return(0,k.useEffect)(()=>{e.current?.pulse(300)},[xa()]),(0,k.useEffect)(()=>()=>{e.current?.dispose(),e.current=null,t?.remove(I.workbench)},[t]),(0,A.jsx)(`div`,{ref:r,className:`h-full w-full`,"data-area":`editor`})}function Pa(e,t){return!!(t===0||e.tagName===`#shadow-root`||e.tagName.includes(`/`))}function Fa({entries:e}){return(0,A.jsx)(A.Fragment,{children:e.map(([e,t])=>(0,A.jsxs)(`span`,{children:[` `,(0,A.jsx)(`span`,{className:`text-code-blue`,children:e}),(0,A.jsx)(`span`,{className:`text-text-dim`,children:`=`}),(0,A.jsxs)(`span`,{className:`text-code-orange`,children:[`"`,t,`"`]})]},e))})}function Ia({node:e,depth:t}){return(0,A.jsxs)(`div`,{className:`py-px leading-[18px] hover:bg-surface-2`,style:{paddingLeft:t*16},children:[(0,A.jsx)(`span`,{className:`w-3 inline-block`}),(0,A.jsx)(`span`,{className:`text-text`,children:e.text})]})}function La({node:e,depth:t,inspectedSid:n,onInspect:r}){return(0,A.jsx)(A.Fragment,{children:(e.children??[]).map((e,i)=>(0,A.jsx)(Ha,{node:e,depth:t,inspectedSid:n,onInspect:r},i))})}function Ra({node:e,depth:t,inspectedSid:n,onInspect:r}){let[i,a]=(0,k.useState)(()=>Pa(e,t)),o=t*16,s=(e.children??[]).length>0;return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`div`,{className:`py-px leading-[18px] hover:bg-surface-2 cursor-pointer`,style:{paddingLeft:o},onClick:()=>s&&a(!i),children:[(0,A.jsx)(`span`,{className:`text-text-dim w-3 shrink-0 inline-block text-center select-none`,children:s?i?`▾`:`▸`:` `}),(0,A.jsx)(`span`,{className:`text-text-dim italic`,children:`#shadow-root`})]}),i&&e.children.map((e,i)=>(0,A.jsx)(Ha,{node:e,depth:t+1,inspectedSid:n,onInspect:r},i))]})}function za({node:e,indent:t,attrEntries:n,isInspected:r,onMouseEnter:i,inlineText:a}){return(0,A.jsxs)(`div`,{className:`py-px leading-[18px] hover:bg-surface-2${r?` bg-surface-2`:``}`,style:{paddingLeft:t},onMouseEnter:i,"data-wxml-sid":e.sid,children:[(0,A.jsx)(`span`,{className:`w-3 inline-block`}),(0,A.jsxs)(`span`,{className:`text-code-keyword`,children:[`<`,e.tagName]}),(0,A.jsx)(Fa,{entries:n}),(0,A.jsx)(`span`,{className:`text-code-keyword`,children:`>`}),(0,A.jsx)(`span`,{className:`text-text`,children:a}),(0,A.jsxs)(`span`,{className:`text-code-keyword`,children:[`</`,e.tagName,`>`]})]})}function Ba({node:e,depth:t,indent:n,attrEntries:r,hasChildren:i,expanded:a,isInspected:o,inspectedSid:s,onInspect:c,onToggle:l,onMouseEnter:u}){return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`div`,{className:`flex items-start hover:bg-surface-2 py-px leading-[18px]${i?` cursor-pointer`:``}${o?` bg-surface-2`:``}`,style:{paddingLeft:n},onMouseEnter:u,onClick:()=>{i&&l()},"data-wxml-sid":e.sid,children:[(0,A.jsx)(`span`,{className:`text-text-dim w-3 shrink-0 text-center select-none`,children:i?a?`▾`:`▸`:` `}),(0,A.jsxs)(`span`,{children:[(0,A.jsxs)(`span`,{className:`text-code-keyword`,children:[`<`,e.tagName]}),(0,A.jsx)(Fa,{entries:r}),(0,A.jsx)(`span`,{className:`text-code-keyword`,children:i?`>`:` />`})]})]}),a&&i&&(0,A.jsxs)(A.Fragment,{children:[e.children.map((e,n)=>(0,A.jsx)(Ha,{node:e,depth:t+1,inspectedSid:s,onInspect:c},n)),(0,A.jsxs)(`div`,{style:{paddingLeft:n},className:`py-px leading-[18px]`,children:[(0,A.jsx)(`span`,{className:`w-3 inline-block`}),(0,A.jsxs)(`span`,{className:`text-code-keyword`,children:[`</`,e.tagName,`>`]})]})]})]})}function Va({node:e,depth:t,inspectedSid:n,onInspect:r}){let[i,a]=(0,k.useState)(()=>Pa(e,t)),o=t*16,s=!!(e.sid&&e.sid===n),c=(e.children??[]).length>0,l=Object.entries(e.attrs),u=()=>{e.sid&&r?.(e)},d=c&&e.children.length===1&&e.children[0].tagName===`#text`?e.children[0].text:null;return d?(0,A.jsx)(za,{node:e,indent:o,attrEntries:l,isInspected:s,onMouseEnter:u,inlineText:d}):(0,A.jsx)(Ba,{node:e,depth:t,indent:o,attrEntries:l,hasChildren:c,expanded:i,isInspected:s,inspectedSid:n,onInspect:r,onToggle:()=>a(!i),onMouseEnter:u})}function Ha({node:e,depth:t,inspectedSid:n,onInspect:r}){return e.tagName===`#text`?(0,A.jsx)(Ia,{node:e,depth:t}):e.tagName===`#fragment`?(0,A.jsx)(La,{node:e,depth:t,inspectedSid:n,onInspect:r}):e.tagName===`#shadow-root`?(0,A.jsx)(Ra,{node:e,depth:t,inspectedSid:n,onInspect:r}):(0,A.jsx)(Va,{node:e,depth:t,inspectedSid:n,onInspect:r})}function Ua({inspection:e}){if(!e)return null;let{rect:t,style:n}=e,r=[n.display,n.position===`static`?null:n.position,n.boxSizing].filter(Boolean);return(0,A.jsxs)(`div`,{className:`border-t border-border-subtle bg-bg-panel px-2.5 py-1.5 font-mono text-[11px] text-text-dim shrink-0`,children:[(0,A.jsx)(`span`,{className:`text-text`,children:`box`}),` `,Math.round(t.width),` x `,Math.round(t.height),` @ `,Math.round(t.x),`, `,Math.round(t.y),(0,A.jsx)(`span`,{className:`mx-2 text-border-subtle`,children:`|`}),r.join(` / `),(0,A.jsx)(`span`,{className:`mx-2 text-border-subtle`,children:`|`}),`font `,n.fontSize]})}function Wa({tree:e,onInspectElement:t,onClearInspection:n,isRuntimeRunning:r=!0}){let[i,a]=(0,k.useState)(null),o=(0,k.useRef)(0),s=(0,k.useRef)(null);(0,k.useEffect)(()=>()=>{s.current!==null&&cancelAnimationFrame(s.current)},[]);let c=(0,k.useCallback)(e=>{if(!e.sid||!t)return;let n=e.sid;s.current!==null&&cancelAnimationFrame(s.current),s.current=requestAnimationFrame(()=>{s.current=null;let e=++o.current;t(n).then(t=>{e===o.current&&a(t)}).catch(()=>{e===o.current&&a(null)})})},[t]),l=(0,k.useCallback)(()=>{s.current!==null&&(cancelAnimationFrame(s.current),s.current=null),o.current++,a(null),n?.()},[n]);return e?(0,A.jsxs)(`div`,{className:`flex flex-col flex-1 overflow-hidden`,onMouseLeave:l,"data-testid":`wxml-panel`,children:[(0,A.jsx)(`div`,{className:`flex-1 overflow-y-auto p-2 font-mono text-[12px]`,children:(0,A.jsx)(Ha,{node:e,depth:0,inspectedSid:i?.sid??null,onInspect:c})}),(0,A.jsx)(Ua,{inspection:i})]}):(0,A.jsx)(`div`,{className:`flex flex-col flex-1 overflow-hidden`,"data-testid":`wxml-panel`,children:(0,A.jsx)(`div`,{className:`text-[12px] text-text-dim text-center px-4 py-6`,children:r?`等待小程序加载...`:`小程序未运行`})})}function Ga(e){let{source:t,enabled:n,active:r}=e,i=(0,k.useRef)({subscribe:e.subscribe,seed:e.seed});(0,k.useEffect)(()=>{i.current={subscribe:e.subscribe,seed:e.seed}}),(0,k.useEffect)(()=>{if(!n)return;let e=i.current.subscribe(t);return()=>{e(),t.setActive(!1)}},[t,n]),(0,k.useEffect)(()=>{n&&t.setActive(r)},[t,n,r]);let a=(0,k.useRef)({source:null,on:!1});(0,k.useEffect)(()=>{let e=n&&r,o=a.current,s=e&&(!o.on||o.source!==t);if(a.current={source:t,on:e},!s)return;let c=!1;return i.current.seed(t,()=>c),()=>{c=!0}},[t,n,r])}function Ka({source:e,active:t=!0,enabled:n=!0,isRuntimeRunning:r=!0}){let[i,a]=(0,k.useState)(null);return Ga({source:e,enabled:n,active:t,subscribe:e=>e.subscribe(a),seed:(e,t)=>{e.getSnapshot().then(e=>{t()||a(e)})}}),(0,A.jsx)(Wa,{tree:i,onInspectElement:t=>e.inspect(t),onClearInspection:async()=>{await e.clearInspection()},isRuntimeRunning:r})}var qa=`inline-flex items-center justify-center gap-1.5 font-medium transition-colors focus:outline-none disabled:opacity-35 disabled:cursor-not-allowed whitespace-nowrap shrink-0 border border-border text-text-muted hover:text-text rounded h-5 px-2 text-[11px]`;function Ja({items:e,onSet:t,onRemove:n,onClear:r,onClearAll:i,getPrefix:a,isRuntimeRunning:o=!0}){let[s,c]=(0,k.useState)(null),[l,u]=(0,k.useState)(null),[d,f]=(0,k.useState)(!1),[p,m]=(0,k.useState)(``),[h,g]=(0,k.useState)(``),[_,v]=(0,k.useState)(``);(0,k.useEffect)(()=>{let e=!1,t,n=()=>{a().then(r=>{if(!e){if(r){m(r);return}t=setTimeout(n,300)}})};return n(),()=>{e=!0,t&&clearTimeout(t)}},[a]);async function y(e){f(!0),u(null);try{let t=await e();return t.ok?t:(u(t.error),null)}finally{f(!1)}}function b(e){c({key:e.key,draft:e.value})}async function x(){if(!s)return;let{key:e,draft:n}=s;c(null),await y(()=>t(e,n))}async function S(e){await y(()=>n(e))}async function C(){e.length!==0&&await y(()=>r())}async function w(){i&&(typeof window<`u`&&!window.confirm(`清空所有 appId 的 Storage 数据?该操作不可撤销。`)||await y(()=>i()))}async function T(){let e=h.trim();if(!e){u(`key 不能为空`);return}let n=p+e;await y(()=>t(n,_))&&(g(``),v(``))}return(0,A.jsxs)(`div`,{className:`flex flex-col overflow-hidden flex-1`,"data-testid":`storage-panel`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 py-1.5 border-b border-border-subtle shrink-0 bg-bg-panel`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>void C(),disabled:d||e.length===0,className:`${qa} hover:border-status-error hover:text-status-error`,title:`仅清空当前 appId 的 Storage`,children:`清空`}),i&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>void w(),disabled:d,className:`${qa} hover:border-status-error hover:text-status-error`,title:`清空所有 appId 的 Storage`,children:`清空所有`}),l&&(0,A.jsx)(`span`,{className:`ml-2 text-[11px] text-status-error truncate`,title:l,children:l})]}),(0,A.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,A.jsxs)(`table`,{className:`w-full border-collapse text-[12px]`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{children:[(0,A.jsx)(`th`,{className:`text-left text-code-label font-normal px-2.5 py-1 border-b border-border-subtle text-[11px] sticky top-0 bg-bg-panel z-10 w-px pr-5`,children:`Key`}),(0,A.jsx)(`th`,{className:`text-left text-code-label font-normal px-2.5 py-1 border-b border-border-subtle text-[11px] sticky top-0 bg-bg-panel z-10`,children:`Value`}),(0,A.jsx)(`th`,{className:`w-px sticky top-0 bg-bg-panel z-10 border-b border-border-subtle`})]})}),(0,A.jsx)(`tbody`,{children:e.length===0?(0,A.jsx)(`tr`,{children:(0,A.jsx)(`td`,{colSpan:3,className:`text-[12px] text-text-dim text-center px-4 py-6`,children:o?`暂无 Storage 数据`:`小程序未运行`})}):e.map(e=>{let t=s?.key===e.key,n=p&&e.key.startsWith(p)?e.key.slice(p.length):e.key;return(0,A.jsxs)(`tr`,{className:`hover:[&>td]:bg-surface`,children:[(0,A.jsx)(`td`,{className:`px-2.5 py-0.5 border-b border-border-subtle w-px pr-5 align-top`,children:(0,A.jsx)(`div`,{className:`font-mono text-code-blue max-w-[240px] truncate`,title:e.key,children:n})}),(0,A.jsx)(`td`,{className:`px-2.5 py-0.5 border-b border-border-subtle font-mono text-code-orange break-all align-top cursor-text`,onClick:()=>{t||b(e)},children:t?(0,A.jsx)(`input`,{autoFocus:!0,type:`text`,value:s.draft,onChange:t=>c({key:e.key,draft:t.target.value}),onBlur:()=>void x(),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),x()):e.key===`Escape`&&(e.preventDefault(),c(null))},className:`w-full bg-transparent outline-none border border-accent/60 rounded px-1 py-0 font-mono text-code-orange`}):e.value}),(0,A.jsx)(`td`,{className:`px-1 py-0.5 border-b border-border-subtle align-top`,children:(0,A.jsx)(`button`,{type:`button`,onClick:()=>void S(e.key),disabled:d,title:`删除`,className:`text-text-dim hover:text-status-error px-1 leading-none`,children:`×`})})]},e.key)})})]})}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 py-1.5 border-t border-border-subtle shrink-0 bg-bg-panel`,children:[(0,A.jsx)(`input`,{type:`text`,placeholder:`key`,value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T())},className:`w-32 bg-transparent border border-border-subtle rounded px-1.5 py-0.5 text-[12px] font-mono outline-none focus:border-accent`}),(0,A.jsx)(`input`,{type:`text`,placeholder:`value`,value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T())},className:`flex-1 bg-transparent border border-border-subtle rounded px-1.5 py-0.5 text-[12px] font-mono outline-none focus:border-accent`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>void T(),disabled:d||!h.trim(),className:`${qa} hover:border-accent hover:text-accent`,children:`+ 新增`})]})]})}function Ya(e,t){switch(t.type){case`added`:case`updated`:{let n=e.findIndex(e=>e.key===t.key);if(n<0)return[...e,{key:t.key,value:t.newValue}];let r=[...e];return r[n]={key:t.key,value:t.newValue},r}case`removed`:return e.filter(e=>e.key!==t.key);case`cleared`:return[]}}function Xa({source:e,active:t=!0,enabled:n=!0,isRuntimeRunning:r=!0}){let[i,a]=(0,k.useState)([]);Ga({source:e,enabled:n,active:t,subscribe:e=>e.subscribe(e=>{a(t=>Ya(t,e))}),seed:(e,t)=>{e.getSnapshot().then(e=>{t()||a(e)})}});let o=e.clearAll?.bind(e);return(0,A.jsx)(Ja,{items:i,onSet:(t,n)=>e.setItem(t,n),onRemove:t=>e.removeItem(t),onClear:()=>e.clear(),onClearAll:o,getPrefix:()=>e.getPrefix(),isRuntimeRunning:r})}function Za(e,t){return typeof t==`number`?`${e}[${t}]`:e===``?t:`${e}.${t}`}function Qa(e){return typeof e==`object`&&!!e}function $a(e){return Array.isArray(e)?e.map((e,t)=>[t,e]):Object.keys(e).sort().map(t=>[t,e[t]])}function eo(e){return Array.isArray(e)?`[${e.length}]`:`{${Object.keys(e).length}}`}var to=``;function no(e,t){let n=e.overrides.get(t);return n===void 0?e.baseline===`expanded`?!0:e.baseline===`collapsed`?!1:t===to:n}function ro({path:e,value:t,editable:n,ctx:r}){if(typeof t==`boolean`)return(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-code-keyword`,children:[n&&(0,A.jsx)(`input`,{type:`checkbox`,checked:t,onChange:()=>r.onCommit?.(e,!t,t),className:`accent-accent`}),String(t)]});if(t==null)return(0,A.jsx)(`span`,{className:`text-code-keyword`,children:String(t)});if(r.state.editingPath===e){let n=()=>{let n=t;if(typeof n==`number`){let t=r.state.draft.trim(),i=Number(t);if(r.endEdit(),t===``||!Number.isFinite(i))return;r.onCommit?.(e,i,n);return}let i=r.state.draft;r.endEdit(),r.onCommit?.(e,i,n)};return(0,A.jsx)(`input`,{type:`text`,autoFocus:!0,value:r.state.draft,onChange:e=>r.setDraft(e.target.value),onKeyDown:e=>{e.key===`Enter`?n():e.key===`Escape`&&r.endEdit()},onBlur:n,className:`bg-surface-3 border border-accent rounded px-1 text-[12px] font-mono min-w-0 w-40`})}return(0,A.jsx)(`span`,{"data-testid":`appdata-value`,className:typeof t==`string`?`text-code-orange`:void 0,style:typeof t==`number`?{color:`var(--color-code-number)`}:void 0,onDoubleClick:n?()=>r.beginEdit(e,String(t)):void 0,children:String(t)})}function io(e){return typeof e==`string`&&(e===``||/[.[\]]/.test(e))}function ao({path:e,label:t,value:n,depth:r,unsafeSegments:i,ctx:a}){let o={paddingLeft:r*14};if(Qa(n)){let s=no(a.state,e);return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-px cursor-pointer hover:bg-surface-3 text-[12px] font-mono`,style:o,onClick:()=>a.toggle(e,n),children:[(0,A.jsx)(`span`,{className:`text-text-secondary w-3 shrink-0 text-center select-none`,children:s?`▾`:`▸`}),(0,A.jsx)(`span`,{className:`text-code-blue`,children:t}),(0,A.jsx)(`span`,{className:`text-text-secondary`,children:eo(n)})]}),s&&$a(n).map(([t,n])=>(0,A.jsx)(ao,{path:Za(e,t),label:String(t),value:n,depth:r+1,unsafeSegments:i||io(t),ctx:a},String(t)))]})}let s=typeof n==`string`||typeof n==`number`||typeof n==`boolean`,c=r>1&&i||t===`__proto__`,l=s&&a.onCommit!==void 0&&!c;return(0,A.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-px text-[12px] font-mono`,style:o,...l?{"data-path":e}:{},children:[(0,A.jsx)(`span`,{className:`w-3 shrink-0`}),(0,A.jsx)(`span`,{className:`text-code-blue`,children:t}),(0,A.jsx)(`span`,{className:`text-text-secondary`,children:`:`}),(0,A.jsx)(ro,{path:e,value:n,editable:l,ctx:a})]})}function oo({root:e,bridgeId:t,command:n,onCommit:r}){let[i,a]=(0,k.useState)(`default`),[o,s]=(0,k.useState)(new Map),[c,l]=(0,k.useState)(0),[u,d]=(0,k.useState)(null),[f,p]=(0,k.useState)(``);n&&n.bridgeId===t&&n.seq!==c&&(a(n.mode),s(new Map),l(n.seq));let m={baseline:i,overrides:o,editingPath:u,draft:f};return(0,A.jsx)(`div`,{"data-testid":`appdata-tree`,className:`py-1`,children:(0,A.jsx)(ao,{path:to,label:`object`,value:e,depth:0,unsafeSegments:!1,ctx:{state:m,toggle:(e,t)=>{let n=new Map(o),r=!no(m,e);n.set(e,r),r&&Array.isArray(t)&&t.forEach((t,r)=>{Qa(t)&&n.set(Za(e,r),!0)}),s(n)},beginEdit:(e,t)=>{d(e),p(t)},setDraft:p,endEdit:()=>d(null),onCommit:r}})})}function so(e){return e.pagePath??e.id}function co(e){return e!=null&&(typeof e==`object`||typeof e==`function`)&&typeof e.then==`function`}function lo(e){let t={};for(let n of Object.keys(e)){let r=e[n];if(!(!r||typeof r!=`object`))for(let e of Object.keys(r))Object.defineProperty(t,e,{value:r[e],enumerable:!0,writable:!0,configurable:!0})}return t}function uo({title:e,disabled:t,onClick:n,children:r}){return(0,A.jsx)(`button`,{title:e,disabled:t,onClick:n,className:`px-1.5 py-0.5 text-[12px] rounded text-text-secondary hover:bg-surface-3 hover:text-text-primary disabled:opacity-40 disabled:hover:bg-transparent`,children:r})}function fo({state:e,onSelectBridge:t,isRuntimeRunning:n=!0,onSetData:r}){let{bridges:i,activeBridgeId:a,entries:o}=e,[s,c]=(0,k.useState)(null),[l,u]=(0,k.useState)([]),[d,f]=(0,k.useState)([]),p=(0,k.useRef)(!1),[m,h]=(0,k.useState)(!1),g=n?`暂无页面数据(仅显示 Page 级 data)`:`小程序未运行`,_=e=>{a&&c({seq:(s?.seq??0)+1,mode:e,bridgeId:a})},v=(e,t,n)=>{let i;try{i=r?.(e,t)}catch{n(!1);return}if(co(i)){Promise.resolve(i).then(e=>e!==!1,()=>!1).then(n);return}n(i!==!1)},y=(e,t,n)=>{p.current||(p.current=!0,h(!0),v(e,t,e=>{p.current=!1,h(!1),n(e)}))},b=e=>(t,n,r)=>{y(e,{[t]:n},i=>{i&&(u(i=>[...i,{bridgeId:e,path:t,before:r,after:n}]),f([]))})},x=e=>i.some(t=>t.id===e),S=(e,t,n)=>{y(e.bridgeId,{[e.path]:t},t=>{t&&n(e)})};return i.length===0?(0,A.jsx)(`div`,{className:`flex flex-col overflow-hidden flex-1`,"data-testid":`appdata-panel`,children:(0,A.jsx)(`div`,{className:`text-[12px] text-text-dim text-center px-4 py-6`,children:g})}):(0,A.jsxs)(`div`,{className:`flex overflow-hidden flex-1`,"data-testid":`appdata-panel`,children:[(0,A.jsxs)(`div`,{"data-testid":`appdata-pages`,className:`w-40 shrink-0 border-r border-border-subtle bg-bg-panel flex flex-col overflow-hidden`,children:[(0,A.jsx)(`div`,{className:`px-2 py-1 text-[11px] text-text-secondary border-b border-border-subtle shrink-0`,children:`Pages`}),(0,A.jsx)(`div`,{className:`flex-1 overflow-y-auto`,role:`listbox`,children:i.map(e=>{let n=e.id===a;return(0,A.jsx)(`button`,{"data-testid":`appdata-page-item`,role:`option`,"aria-selected":n,title:e.id,onClick:()=>t(e.id),className:`block w-full text-left px-2 py-1 text-[11px] truncate `+(n?`bg-accent/20 text-accent`:`text-text-dim hover:bg-surface-3`),children:so(e)},e.id)})})]}),(0,A.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,A.jsxs)(`div`,{"data-testid":`appdata-toolbar`,className:`flex items-center gap-1 px-2 py-0.5 border-b border-border-subtle shrink-0 bg-bg-panel`,children:[(0,A.jsx)(uo,{title:`全部展开`,onClick:()=>_(`expanded`),children:`⊕`}),(0,A.jsx)(uo,{title:`全部收起`,onClick:()=>_(`collapsed`),children:`⊖`}),(0,A.jsx)(uo,{title:`撤销`,disabled:l.length===0||m,onClick:()=>{let e=l.at(-1);if(e){if(!x(e.bridgeId)){u(t=>t.filter(t=>t!==e));return}S(e,e.before,e=>{u(t=>t.filter(t=>t!==e)),f(t=>[...t,e])})}},children:`↶`}),(0,A.jsx)(uo,{title:`重做`,disabled:d.length===0||m,onClick:()=>{let e=d.at(-1);if(e){if(!x(e.bridgeId)){f(t=>t.filter(t=>t!==e));return}S(e,e.after,e=>{f(t=>t.filter(t=>t!==e)),u(t=>[...t,e])})}},children:`↷`})]}),(0,A.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:i.map(e=>{let t=e.id===a,n=o[e.id]??{},i=Object.keys(n).length>0;return(0,A.jsx)(`div`,{"data-bridge-id":e.id,className:`absolute inset-0 flex-col overflow-y-auto`,style:{display:t?`flex`:`none`},children:i?(0,A.jsx)(oo,{root:lo(n),bridgeId:e.id,command:s,onCommit:r?b(e.id):void 0}):(0,A.jsx)(`div`,{className:`text-[12px] text-text-dim text-center px-4 py-6`,children:g})},e.id)})})]})]})}function po(e){return(e??``).replace(/^\/+/,``)}function mo(e,t=``){let n=e.map(e=>e.id),r=n.join(`\0`),[i,a]=(0,k.useState)(null),[o,s]=(0,k.useState)(``),[c,l]=(0,k.useState)(t);if(r!==o){let e=o?o.split(`\0`):[];n.some(t=>!e.includes(t))&&a(null),s(r)}t!==c&&(a(null),l(t));let u=t?e.find(e=>po(e.pagePath)===po(t))?.id??null:null;return{activeBridgeId:i&&n.includes(i)?i:u??n.at(-1)??null,setActiveBridge:e=>{n.includes(e)&&a(e)}}}var ho={bridges:[],entries:{}};function go({source:e,active:t=!0,enabled:n=!0,isRuntimeRunning:r=!0,activePagePath:i=``}){let[a,o]=(0,k.useState)(ho);Ga({source:e,enabled:n,active:t,subscribe:e=>e.subscribe(e=>{o(e)}),seed:(e,t)=>{e.getSnapshot().then(e=>{t()||o(e)})}});let{activeBridgeId:s,setActiveBridge:c}=mo(a.bridges,i),l=e.setData?.bind(e),u=l?(e,t)=>l(e,t):void 0;return(0,A.jsx)(fo,{state:{bridges:a.bridges,activeBridgeId:s,entries:a.entries},onSelectBridge:c,isRuntimeRunning:r,onSetData:u})}function _o(...e){return e.filter(Boolean).join(` `)}function vo(e){let t=new Date(e);return[t.getHours(),t.getMinutes(),t.getSeconds()].map(e=>String(e).padStart(2,`0`)).join(`:`)}function yo(e){return e===`error`?`text-red-500`:e===`compiling`?`text-amber-500`:e===`ready`?`text-emerald-600`:`text-text-muted`}function bo(e){return e.kind===`event`?e.event.message:e.log.text}function xo({events:e,logs:t=[],onClear:n}){let r=e.length>0?e[e.length-1]:null,[i,a]=(0,k.useState)(``),o=(0,k.useRef)(null),s=(0,k.useRef)(null),c=(0,k.useRef)(!0);(0,k.useEffect)(()=>{let e=o.current;if(!e)return;let t=()=>{let{scrollTop:t,scrollHeight:n,clientHeight:r}=e;c.current=n-t-r<20};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[]),(0,k.useEffect)(()=>{c.current&&s.current?.scrollIntoView?.({behavior:`auto`})},[e.length+t.length]);let l=(0,k.useMemo)(()=>{let n=[];e.forEach((t,r)=>{let i=r>0?e[r-1]:null,a=t.status===`ready`&&i?.status===`compiling`?t.at-i.at:null;n.push({kind:`event`,at:t.at,seq:t.seq,event:t,durationMs:a})});for(let e of t)n.push({kind:`log`,at:e.at,seq:e.seq,log:e});return n.sort((e,t)=>e.at===t.at?e.seq!==void 0&&t.seq!==void 0?e.seq-t.seq:0:e.at-t.at)},[e,t]),u=(0,k.useMemo)(()=>{if(!i)return l;let e=i.toLowerCase();return l.filter(t=>bo(t).toLowerCase().includes(e))},[l,i]),d=e.length===0&&t.length===0;return(0,A.jsxs)(`div`,{className:`flex flex-col h-full w-full min-h-0 text-[12px]`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 px-2 h-8 shrink-0 border-b border-border-subtle`,children:[r?(0,A.jsx)(`span`,{"data-compile-current":!0,"data-status":r.status,className:_o(`truncate font-medium shrink-0`,yo(r.status)),children:r.message}):(0,A.jsx)(`span`,{className:`text-text-muted shrink-0`,children:`编译信息`}),(0,A.jsx)(`div`,{className:`flex-1 min-w-0`}),(0,A.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`过滤...`,className:`h-6 px-2 text-[12px] rounded-sm border border-border-subtle bg-surface
1
+ import{C as e,E as t,S as n,T as r,_ as i,a,d as o,g as s,h as c,l,n as u,o as d,p as f,r as p,s as m,t as h,u as g,v as _,w as v}from"./ipc-transport-B3EpmfNS.js";import{n as y,r as b,t as x}from"./input-xdmfv-eH.js";import{_ as S,a as C,b as w,d as T,f as E,g as D,h as ee,i as te,l as ne,m as re,n as ie,o as ae,p as oe,r as se,s as ce,t as le,u as ue,v as de,x as O,y as fe}from"./select-CD9CJyhI.js";import{n as pe}from"./constants-EAMiwL9_.js";import{u as me}from"./settings-api-pJKPuP1M.js";var he=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),ge=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),_e=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),ve=e=>{let t=_e(e);return t.charAt(0).toUpperCase()+t.slice(1)},ye={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},be=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},k=t(r()),xe=(0,k.createContext)({}),Se=()=>(0,k.useContext)(xe),Ce=(0,k.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f=`currentColor`,className:p=``}=Se()??{},m=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,k.createElement)(`svg`,{ref:c,...ye,width:t??l??ye.width,height:t??l??ye.height,stroke:e??f,strokeWidth:m,className:he(`lucide`,p,i),...!a&&!be(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,k.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),we=(e,t)=>{let n=(0,k.forwardRef)(({className:n,...r},i)=>(0,k.createElement)(Ce,{ref:i,iconNode:t,className:he(`lucide-${ge(ve(e))}`,`lucide-${e}`,n),...r}));return n.displayName=ve(e),n},Te=we(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Ee=we(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),De=t(e(),1),A=n();function Oe({project:e,onOpen:t,onRemove:n,thumbnail:r}){let[i,a]=(0,k.useState)(!1);return(0,A.jsxs)(`div`,{className:`relative bg-surface border border-border rounded-lg overflow-hidden cursor-pointer transition-all duration-150 hover:border-accent hover:-translate-y-0.5`,onClick:()=>t(e),onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[r?(0,A.jsx)(`img`,{src:r,className:`h-28 w-full object-cover object-top`,alt:``}):(0,A.jsx)(`div`,{className:`h-28 bg-surface-thumb`}),(0,A.jsxs)(`div`,{className:`p-3`,children:[(0,A.jsx)(`div`,{className:`text-sm font-medium text-text-white mb-1 truncate`,title:e.name,children:e.name}),(0,A.jsx)(`div`,{className:`text-[11px] text-text-secondary truncate`,title:e.path,children:e.path}),(0,A.jsx)(`div`,{className:`text-[11px] text-text-dim mt-1.5`,children:b(e.lastOpened)})]}),i&&(0,A.jsx)(O,{variant:`danger`,size:`icon-sm`,className:`absolute top-1.5 right-1.5 w-5 h-5 rounded-full bg-overlay text-text-secondary leading-none hover:text-status-error hover:bg-danger-bg`,onClick:t=>{t.stopPropagation(),n(e)},title:`移除`,children:`×`})]})}function ke(e){return(0,A.jsxs)(`button`,{type:`button`,onClick:e.onClick,"aria-label":`新建项目`,className:`relative bg-transparent border-2 border-dashed border-border rounded-lg overflow-hidden cursor-pointer transition-all duration-150 hover:border-accent hover:-translate-y-0.5 h-full min-h-[188px] flex flex-col items-center justify-center gap-2 text-text-secondary hover:text-accent focus:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,A.jsx)(`span`,{className:`text-3xl leading-none`,"aria-hidden":`true`,children:`+`}),(0,A.jsx)(`span`,{className:`text-sm font-medium`,children:`新建项目`})]})}function Ae({projects:e,onAdd:t,onCreate:n,onOpen:r,onRemove:i,thumbnails:a}){let[o,s]=(0,k.useState)(``),c=(0,k.useMemo)(()=>{if(!o.trim())return e;let t=o.trim().toLowerCase();return e.filter(e=>(e.name||``).toLowerCase().includes(t)||(e.path||``).toLowerCase().includes(t))},[e,o]),l=n??(()=>{}),u=e.length>0&&c.length===0;return(0,A.jsx)(`div`,{className:`flex flex-col h-screen bg-bg`,children:(0,A.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-6 gap-4`,children:[(0,A.jsx)(`div`,{className:`flex items-center flex-1 max-w-xs min-w-0`,children:(0,A.jsxs)(`div`,{className:`relative w-full`,children:[(0,A.jsx)(Te,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-text-secondary pointer-events-none`}),(0,A.jsx)(x,{placeholder:`搜索`,value:o,onChange:e=>s(e.target.value),className:`w-full h-8 pl-8 pr-3 rounded-md text-sm`})]})}),(0,A.jsx)(O,{variant:`ghost`,size:`sm`,onClick:t,className:`shrink-0 text-accent hover:text-accent-hover hover:bg-transparent`,children:`导入`})]}),u?(0,A.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-72 text-text-dim gap-3`,children:[(0,A.jsx)(`span`,{className:`text-5xl opacity-40`,children:`🔍`}),(0,A.jsx)(`span`,{className:`text-sm`,children:`未找到匹配的项目`})]}):(0,A.jsxs)(`div`,{className:`grid gap-4`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(220px, 1fr))`},children:[(0,A.jsx)(ke,{onClick:l}),c.map(e=>(0,A.jsx)(Oe,{project:e,onOpen:r,onRemove:i,thumbnail:a?.[e.path]},e.path))]})]})})}function je(e){return e.trim().replace(/[\\/:*?"<>|]+/g,`-`).replace(/\s+/g,`-`).replace(/-{2,}/g,`-`).replace(/^[-.]+|[-.]+$/g,``)}function Me(e,t){return t?e?e.endsWith(`/`)?`${e}${t}`:`${e}/${t}`:t:``}function Ne(e){let{open:t,templates:n,defaultBaseDir:r,onSubmit:i,onCancel:a,onBrowse:o}=e,[s,c]=(0,k.useState)(``),[l,u]=(0,k.useState)(``),[d,f]=(0,k.useState)(n[0]?.id??`blank`),p=(0,k.useRef)(!1);if((0,k.useEffect)(()=>{n.find(e=>e.id===d)||f(n[0]?.id??`blank`)},[n,d]),(0,k.useEffect)(()=>{t&&(c(``),u(``),p.current=!1)},[t]),!t)return null;let m=s.trim().length>0&&l.trim().length>0;function h(e){if(c(e),!p.current){let t=je(e);u(t?Me(r??``,t):``)}}function g(e){p.current=!0,u(e)}async function _(){let e=await o();e&&(p.current=!0,u(e))}function v(){m&&i({name:s.trim(),path:l.trim(),templateId:d})}return(0,A.jsx)(`div`,{role:`dialog`,"aria-label":`新建项目`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,children:(0,A.jsxs)(`div`,{className:`bg-surface rounded-lg shadow-lg w-[560px] max-w-[90vw] p-6`,children:[(0,A.jsx)(`h2`,{className:`text-base font-semibold text-text-white mb-4`,children:`新建项目`}),(0,A.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,A.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,A.jsx)(`span`,{className:`text-text-secondary`,children:`项目名`}),(0,A.jsx)(`input`,{"aria-label":`项目名`,type:`text`,value:s,onChange:e=>h(e.target.value),placeholder:`My App`,className:`h-8 px-2 rounded-md border border-border bg-bg text-sm text-text-white`})]}),(0,A.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,A.jsx)(`span`,{className:`text-text-secondary`,children:`目录`}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(`input`,{"aria-label":`目录`,type:`text`,value:l,onChange:e=>g(e.target.value),placeholder:`/absolute/path/to/dir`,className:`flex-1 h-8 px-2 rounded-md border border-border bg-bg text-sm text-text-white`}),(0,A.jsx)(`button`,{type:`button`,onClick:_,className:`px-3 h-8 rounded-md border border-border text-sm text-text-secondary hover:text-text-white`,children:`浏览`})]})]}),(0,A.jsxs)(`div`,{className:`flex flex-col gap-1 text-sm`,children:[(0,A.jsx)(`span`,{className:`text-text-secondary`,children:`模板`}),(0,A.jsx)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(160px, 1fr))`},children:n.map(e=>{let t=e.id===d;return(0,A.jsxs)(`button`,{type:`button`,onClick:()=>f(e.id),className:[`text-left p-3 rounded-md border`,t?`border-accent text-text-white bg-accent/10`:`border-border text-text-secondary hover:border-accent`].join(` `),"aria-pressed":t,children:[(0,A.jsx)(`div`,{className:`text-sm font-medium`,children:e.name}),e.description?(0,A.jsx)(`div`,{className:`text-[11px] mt-1 text-text-dim`,children:e.description}):null]},e.id)})})]})]}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-2 mt-6`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:a,className:`px-3 h-8 rounded-md border border-border text-sm text-text-secondary hover:text-text-white`,children:`取消`}),(0,A.jsx)(`button`,{type:`button`,onClick:v,disabled:!m,className:`px-3 h-8 rounded-md text-sm bg-accent text-white disabled:opacity-40 disabled:cursor-not-allowed`,children:`创建`})]})]})})}function Pe(){return h(a.GetBranding)}function Fe(){return u(g.List)}function Ie(){return h(d.OpenDirectory)}function Le(e){return u(g.Add,e)}function Re(e){return h(g.Remove,e)}function ze(e){return u(l.Open,e)}function Be(e){return u(l.GetPages,e)}function Ve(e){return u(l.GetCompileConfig,e)}function He(e,t){return u(l.SaveCompileConfig,e,t)}function Ue(e){return p(l.Status,t=>e(t))}function We(e){return p(l.CompileLog,t=>e(t))}function Ge(e){return p(o.RuntimeStatus,t=>e(t))}function Ke(e){return h(l.CaptureThumbnail,e)}function qe(e){return h(l.GetThumbnail,e)}function Je(){return u(g.ListTemplates)}function Ye(){return h(g.OpenCreateDialog)}function Xe(e){return u(g.Create,e)}function Ze(){return u(g.GetCreateDefaults)}function Qe(){return h(m.Open)}var $e={selected:`simulator`,simulatorVisible:!0};function et(e){return e+48}function tt(e,t){return Math.max(200,Math.min(t-200,e))}function nt(e){let{initialDevice:t}=e,[n,r]=(0,k.useState)(t),[i,a]=(0,k.useState)(85),[o,s]=(0,k.useState)(()=>et(t.width)),c=(0,k.useRef)(o),l=(0,k.useRef)(n);(0,k.useEffect)(()=>{c.current=o},[o]),(0,k.useEffect)(()=>{l.current=n},[n]);let u=(0,k.useCallback)(e=>{re({brand:`Apple`,model:e.name,system:e.system,platform:`ios`,pixelRatio:e.pixelRatio,screenWidth:e.width,screenHeight:e.height,statusBarHeight:e.statusBarHeight,notchType:e.notchType,safeAreaInsets:{...e.safeAreaInsets}})},[]);return{device:n,zoom:i,simPanelWidth:o,setSimPanelWidth:s,handleDeviceChange:(0,k.useCallback)(e=>{let t=fe.find(t=>t.name===e.target.value)??fe[1];r(t),u(t),s(et(t.width))},[u]),handleZoomChange:(0,k.useCallback)(e=>{a(e.target.value===`auto`?S:Number(e.target.value))},[]),handleSplitterDrag:(0,k.useCallback)((e,t=`trailing`)=>{e.preventDefault();let n=e.clientX,r=c.current,i=e=>{let i=e.clientX-n;s(tt(r+(t===`trailing`?i:-i),window.innerWidth))},a=()=>{window.removeEventListener(`mousemove`,i),window.removeEventListener(`mouseup`,a)};window.addEventListener(`mousemove`,i),window.addEventListener(`mouseup`,a)},[]),sendDeviceInfo:u,simPanelWidthRef:c,deviceRef:l}}var rt=200,it=300;function at(e){let{projectPath:t}=e,[n,r]=(0,k.useState)({status:`compiling`,message:`正在编译...`}),[i,a]=(0,k.useState)(null),[o,s]=(0,k.useState)([]),[c,l]=(0,k.useState)(0),[u,d]=(0,k.useState)({startPage:``,scene:pe,queryParams:[]});(0,k.useEffect)(()=>{let e=!1;async function n(){try{let n=await ze(t);if(e)return;if(!n.success){r({status:`error`,message:n.error});return}let[i,o]=await Promise.all([Be(t),Ve(t)]);if(e)return;a(n.appInfo),l(n.port),s(i.pages),d({startPage:o.startPage||i.entryPagePath||i.pages[0]||``,scene:o.scene??1001,queryParams:o.queryParams||[]}),r({status:`ready`,message:`编译完成`})}catch(t){if(e)return;r({status:`error`,message:t instanceof Error?t.message:String(t)})}}return n(),()=>{e=!0}},[t]);let[f,p]=(0,k.useState)(0),[m,h]=(0,k.useState)([]),[g,_]=(0,k.useState)([]),v=(0,k.useRef)(0),[y,b]=(0,k.useState)(null),[x,S]=(0,k.useState)(!1);(0,k.useEffect)(()=>{h([]),_([]),b(null),S(!1)},[t]),(0,k.useEffect)(()=>Ue(e=>{r(e),e.pages&&s(e.pages),e.watcher===`dead`&&S(!0);let t=++v.current;h(n=>{let r=e.hotReload===!0?{at:Date.now(),status:e.status,message:e.message,hotReload:!0,seq:t}:{at:Date.now(),status:e.status,message:e.message,seq:t},i=[...n,r];return i.length>rt?i.slice(i.length-rt):i}),e.hotReload===!0&&(b(null),p(e=>e+1))}),[]),(0,k.useEffect)(()=>Ge(e=>{i?.appId&&e.appId!==i.appId||b(e)}),[i]),(0,k.useEffect)(()=>We(e=>{let t=++v.current;_(n=>{let r=[...n,{...e,seq:t}];return r.length>it?r.slice(r.length-it):r})}),[]);let C=(0,k.useCallback)(()=>{h([]),_([])},[]),w=(0,k.useRef)(!1),[T,E]=(0,k.useState)(0);return{compileStatus:n,appInfo:i,port:c,pages:o,compileConfig:u,hotReloadToken:f,compileEvents:m,compileLogs:g,clearCompileEvents:C,relaunch:(0,k.useCallback)(async(e=u)=>{try{if(!i?.appId||w.current)return;w.current=!0,r({status:`ready`,message:`正在刷新...`});try{await He(t,e),d(e),E(e=>e+1),r({status:`ready`,message:`刷新完成`})}finally{w.current=!1}}catch(e){w.current=!1,r({status:`error`,message:e instanceof Error?e.message:`刷新失败`})}},[i,u,t]),relaunchNonce:T,runtimeStatus:y,watcherDead:x}}var ot=[`appId`,`entry`,`page`];function st(e){return encodeURIComponent(e).replace(/%2F/g,`/`).replace(/%2C/g,`,`)}function ct(e){let t=Object.keys(e.query);if(t.length===0)return e.pagePath;let n=t.map(t=>`${encodeURIComponent(t)}=${encodeURIComponent(e.query[t]??``)}`).join(`&`);return`${e.pagePath}?${n}`}function lt(e){let t=e.indexOf(`?`);if(t<0)return{pagePath:e,query:{}};let n=e.slice(0,t),r={};for(let n of e.slice(t+1).split(`&`)){if(!n)continue;let e=n.indexOf(`=`),t=e>=0?n.slice(0,e):n,i=e>=0?n.slice(e+1):``;t&&(r[decodeURIComponent(t)]=decodeURIComponent(i))}return{pagePath:n,query:r}}function ut(e,t,n={}){let r=ct(t),i=[`appId=${st(e)}`,`entry=${st(r)}`,`page=${st(r)}`];for(let[e,t]of Object.entries(n))ot.includes(e)||i.push(`${encodeURIComponent(e)}=${st(t)}`);return i.join(`&`)}function dt(e){let t=e.host??`localhost`,n=e.pathname??`/simulator.html`,r=ut(e.appId,e.page,e.extras??{});return`http://${t}:${e.port}${n}?${r}`}function ft(e,t,n,r){let i=t.startPage||`pages/index/index`,a={};for(let e of t.queryParams??[])e.key&&(a[e.key]=e.value);a.scene=String(t.scene??1001);let o={};return r?.length&&(o.apiNamespaces=r.join(`,`)),dt({appId:e,page:{pagePath:i,query:a},port:n,extras:o})}function pt(e){let t=new URLSearchParams(e.startsWith(`?`)?e.slice(1):e),n=t.get(`appId`),r=t.get(`entry`);if(!n||!r)return null;let i=lt(r),a=t.get(`page`);return{appId:n,entry:i,current:a&&a!==r?lt(a):i}}function mt(e){if(!e)return null;try{return pt(new URL(e).search)}catch{return null}}function ht(e){return mt(e)?.current.pagePath??``}function gt(e){let{compileStatus:t,sendDeviceInfo:n,simPanelWidthRef:r,deviceRef:i,appInfo:a,compileConfig:o,port:s,projectPath:c,hotReloadToken:l,relaunchNonce:u}=e,d=(0,k.useMemo)(()=>!a||!s?``:ft(a.appId,o,s),[a,o,s]),[f,p]=(0,k.useState)(()=>ht(d));(0,k.useEffect)(()=>{p(ht(d))},[d]),(0,k.useEffect)(()=>ue(e=>{e&&p(e)}),[]);let m=(0,k.useRef)({currentPage:f,compileConfig:o,appInfo:a,port:s});(0,k.useEffect)(()=>{m.current={currentPage:f,compileConfig:o,appInfo:a,port:s}});let h=(0,k.useRef)(l);return(0,k.useEffect)(()=>{if(t.status!==`ready`||!d)return;let e=l!==h.current;h.current=l;let a=d;if(e){let e=m.current;if(e.appInfo&&e.port){let t=e.currentPage||e.compileConfig.startPage;a=ft(e.appInfo.appId,t===e.compileConfig.startPage?e.compileConfig:{...e.compileConfig,startPage:t,queryParams:[]},e.port)}}n(i.current);let o=!1,s=null,u=()=>{o||(s=window.setTimeout(()=>{o||Ke(c).catch(()=>{})},3e3))},f=()=>{ie(a,r.current).then(u).catch(()=>{})};return e?D(a).then(e=>{if(!o){if(e===!0){u();return}f()}}).catch(()=>{o||f()}):f(),()=>{o=!0,s!==null&&window.clearTimeout(s)}},[t.status,d,l,u,r,i,n,c]),{simulatorUrl:d,currentPage:f}}function _t(){return{getSnapshot:async()=>await h(i.GetSnapshot)??null,subscribe:e=>p(i.Event,e),setActive:e=>{h(i.SetActive,e)},inspect:async e=>await h(c.Inspect,e)??null,clearInspection:async()=>{await h(c.Clear)}}}var vt={ok:!1,error:`ipc transport failed`};function yt(){return{getSnapshot:async()=>await h(s.GetSnapshot)??[],subscribe:e=>p(s.Event,e),setActive:()=>{},setItem:async(e,t)=>await h(s.Set,{key:e,value:t})??vt,removeItem:async e=>await h(s.Remove,{key:e})??vt,clear:async()=>await h(s.Clear)??vt,clearAll:async()=>await h(s.ClearAll)??vt,getPrefix:async()=>await h(s.GetActivePrefix)??``}}var bt={bridges:[],entries:{}};function xt(){return{getSnapshot:async()=>await h(f.GetSnapshot)??bt,subscribe:e=>p(f.Event,e),setActive:()=>{},setData:async(e,t)=>await h(f.SetData,{bridgeId:e,data:t})??!1}}function St(e){let{compileStatus:t}=e,n=t.status===`ready`;return{wxmlSource:(0,k.useMemo)(()=>_t(),[]),wxmlEnabled:n,storageSource:(0,k.useMemo)(()=>yt(),[]),storageEnabled:n,appDataSource:(0,k.useMemo)(()=>xt(),[]),appDataEnabled:n}}function Ct(e){let{initialRightPane:t}=e,[n,r]=(0,k.useState)(t);return{rightPane:n,selectRightPane:(0,k.useCallback)(e=>{r({selected:e,simulatorVisible:!0})},[]),toggleRightPaneVisible:(0,k.useCallback)(()=>{r(e=>({...e,simulatorVisible:!e.simulatorVisible}))},[])}}function wt(e){let{relaunch:t,compileConfig:n,pages:r,compileDropdownRef:i}=e,[a,o]=(0,k.useState)(!1),s=(0,k.useRef)(t);(0,k.useEffect)(()=>{s.current=t},[t]),(0,k.useEffect)(()=>{let e=ce(()=>o(!1)),t=ne(e=>{o(!1),s.current(e)});return()=>{e(),t()}},[]);let c=(0,k.useRef)(n),l=(0,k.useRef)(r);return(0,k.useEffect)(()=>{c.current=n},[n]),(0,k.useEffect)(()=>{l.current=r},[r]),{showCompilePanel:a,toggleCompilePanel:(0,k.useCallback)(()=>{o(e=>{if(e)return te(),!1;let t=i.current;if(!t)return e;let n=t.getBoundingClientRect();return ee({top:Math.round(n.bottom-40+6),left:Math.round(n.left),config:c.current,pages:l.current}),!0})},[i])}}function Tt(e){let{projectPath:t,initialDevice:n=fe[1],initialRightPane:r=$e}=e,i=(0,k.useRef)(null),a=(0,k.useRef)(null),o=nt({initialDevice:n}),s=at({projectPath:t});(0,k.useEffect)(()=>{s.compileStatus.status===`ready`&&o.setSimPanelWidth(o.device.width+48)},[o.device.width,s.compileStatus.status,o.setSimPanelWidth]);let c=gt({compileStatus:s.compileStatus,sendDeviceInfo:o.sendDeviceInfo,simPanelWidthRef:o.simPanelWidthRef,deviceRef:o.deviceRef,appInfo:s.appInfo,compileConfig:s.compileConfig,port:s.port,projectPath:t,hotReloadToken:s.hotReloadToken,relaunchNonce:s.relaunchNonce}),l=St({compileStatus:s.compileStatus,activePagePath:c.currentPage}),u=Ct({initialRightPane:r}),d=wt({relaunch:s.relaunch,compileConfig:s.compileConfig,pages:s.pages,compileDropdownRef:a});return{session:{compileStatus:s.compileStatus,appInfo:s.appInfo,port:s.port,pages:s.pages,compileConfig:s.compileConfig,compileEvents:s.compileEvents,compileLogs:s.compileLogs,clearCompileEvents:s.clearCompileEvents,relaunch:s.relaunch,runtimeStatus:s.runtimeStatus,watcherDead:s.watcherDead},device:{device:o.device,zoom:o.zoom,simPanelWidth:o.simPanelWidth,setSimPanelWidth:o.setSimPanelWidth,handleDeviceChange:o.handleDeviceChange,handleZoomChange:o.handleZoomChange,handleSplitterDrag:o.handleSplitterDrag,sendDeviceInfo:o.sendDeviceInfo},simulator:{simulatorRef:i,simulatorUrl:c.simulatorUrl,currentPage:c.currentPage},panelData:{wxmlSource:l.wxmlSource,wxmlEnabled:l.wxmlEnabled,storageSource:l.storageSource,storageEnabled:l.storageEnabled,appDataSource:l.appDataSource,appDataEnabled:l.appDataEnabled},rightPane:{rightPane:u.rightPane,selectRightPane:u.selectRightPane,toggleRightPaneVisible:u.toggleRightPaneVisible},popover:{compileDropdownRef:a,showCompilePanel:d.showCompilePanel,toggleCompilePanel:d.toggleCompilePanel}}}var Et={dockTree:null,simulatorAlignment:`left`,devtoolsPosition:`inEditor`},Dt=`dimina-devtools.layout.v1`;function Ot(){try{let e=window.localStorage.getItem(Dt);if(!e)return Et;let t=JSON.parse(e);return{dockTree:typeof t.dockTree==`string`?t.dockTree:null,simulatorAlignment:t.simulatorAlignment===`right`?`right`:`left`,devtoolsPosition:t.devtoolsPosition===`belowSimulator`||t.devtoolsPosition===`rightOfSimulator`?t.devtoolsPosition:`inEditor`}}catch{return Et}}function kt(e){try{window.localStorage.setItem(Dt,JSON.stringify(e))}catch{}}function At(){let[e,t]=(0,k.useState)(Ot);return(0,k.useEffect)(()=>{kt(e)},[e]),{state:e,setDockTree:(0,k.useCallback)(e=>{t(t=>t.dockTree===e?t:{...t,dockTree:e})},[]),setSimulatorAlignment:(0,k.useCallback)(e=>{t(t=>t.simulatorAlignment===e?t:{...t,simulatorAlignment:e})},[]),setDevtoolsPosition:(0,k.useCallback)(e=>{t(t=>t.devtoolsPosition===e?t:{...t,devtoolsPosition:e})},[])}}var jt={compiling:`bg-status-warn animate-[pulse_1s_infinite]`,ready:`bg-accent`,error:`bg-status-error`};function Mt({status:e}){return(0,A.jsx)(`span`,{className:y(`w-1.5 h-1.5 rounded-full shrink-0`,jt[e]??`bg-border`)})}function Nt(){let e=new Map;return{register(t){return e.set(t.id,t),{dispose(){e.get(t.id)===t&&e.delete(t.id)}}},get(t){return e.get(t)},list(){return[...e.values()]}}}var Pt=64;function Ft(e){return JSON.stringify(e)}function It(e,t,n,r){e===void 0?r.push(`node missing string id (kind=${String(t)})`):n.seenIds.has(e)?r.push(`duplicate node id: ${e}`):n.seenIds.add(e)}function Lt(e,t,n,r){if(typeof e!=`string`){r.push(`tabs ${t??`?`}: non-string panel id`);return}n.panelOwners.get(e)===void 0?n.panelOwners.set(e,t??`?`):r.push(`duplicate panel id across groups: ${e}`),n.knownPanelIds&&!n.knownPanelIds.has(e)&&r.push(`orphan panel not in known panel ids: ${e}`)}function Rt(e,t,n,r){let i=e,a=Array.isArray(i.panels)?i.panels:null;if(!a){r.push(`tabs ${t??`?`}: panels is not an array`);return}a.length===0&&r.push(`tabs ${t??`?`}: empty tabgroup`);for(let e of a)Lt(e,t,n,r);let o=i.active;(typeof o!=`string`||!a.includes(o))&&r.push(`tabs ${t??`?`}: active ${String(o)} not in panels`)}function zt(e,t,n){if(e===null)return!1;if(typeof e!=`object`)return n.push(`split ${t??`?`}: constraint is not null nor an object: ${String(e)}`),!1;let r=Object.keys(e),i=r.includes(`fixedPx`),a=r.includes(`minPx`);(r.length!==1||!(i||a))&&n.push(`split ${t??`?`}: constraint must have exactly one of 'fixedPx' or 'minPx', got [${r.join(`, `)}]`);let o=i?`fixedPx`:`minPx`,s=i?e.fixedPx:e.minPx;return(typeof s!=`number`||!Number.isFinite(s)||s<=0)&&n.push(`split ${t??`?`}: constraint ${o} must be a finite number > 0, got ${String(s)}`),!0}function Bt(e,t,n){let r=Array.isArray(e)?e:null;if(!r){n.push(`split ${t??`?`}: constraints is not an array`);return}let i=r.length>0;for(let e of r)zt(e,t,n)||(i=!1);i&&n.push(`split ${t??`?`}: all children are px-sized constraints; at least one must be weight-sized`)}function Vt(e,t,n,r){if(!e||e.length!==t.length){r.push(`split ${n??`?`}: sizes ${e?e.length:`missing`} != children ${t.length}`);return}for(let t of e)(typeof t!=`number`||!Number.isFinite(t))&&r.push(`split ${n??`?`}: non-finite size ${String(t)}`)}function Ht(e,t){let n=[],r={seenIds:new Set,seenObjects:new Set,panelOwners:new Map,knownPanelIds:t},i=(e,t,a)=>{if(t>Pt){n.push(`depth exceeds ${Pt}`);return}if(typeof e!=`object`||!e){n.push(`node is not an object: ${String(e)}`);return}let o=e;if(a.has(o)){n.push(`cycle detected: node reachable from itself`);return}if(r.seenObjects.has(o)){n.push(`shared node reference: same object appears twice`);return}r.seenObjects.add(o);let s=e,c=s.kind,l=typeof s.id==`string`?s.id:void 0;It(l,c,r,n),c===`tabs`?Rt(e,l,r,n):c===`split`?Ut(e,l,t,a,o,r,n,i):n.push(`unknown node kind: ${String(c)}`)};return i(e,0,new Set),n}function Ut(e,t,n,r,i,a,o,s){let c=e,l=Array.isArray(c.children)?c.children:null,u=Array.isArray(c.sizes)?c.sizes:null,d=c.orientation;if(d!==`row`&&d!==`column`&&o.push(`split ${t??`?`}: invalid orientation ${String(d)}`),c.constraints!==void 0&&Bt(c.constraints,t,o),!l){o.push(`split ${t??`?`}: children is not an array`);return}if(l.length<2&&o.push(`split ${t??`?`}: must have >= 2 children, has ${l.length}`),Vt(u,l,t,o),c.constraints!==void 0&&Array.isArray(c.constraints)){let e=c.constraints;e.length!==l.length&&o.push(`split ${t??`?`}: constraints ${e.length} != children ${l.length}`)}let f=new Set(r);f.add(i);for(let e of l)s(e,n+1,f)}function Wt(e,t){return typeof e!=`object`||!e?[`tree is not an object`]:e.version===1?Ht(e.root,t):[`unsupported version: ${String(e.version)}`]}function Gt(e){let t;try{t=JSON.parse(e)}catch{throw Error(`parseLayout: input is not valid JSON`)}if(typeof t!=`object`||!t)throw Error(`parseLayout: top-level value is not an object`);let n=t;if(n.version!==1)throw Error(`parseLayout: unsupported version ${String(n.version)}`);if(n.root===void 0||n.root===null)throw Error(`parseLayout: missing root`);let r=Ht(n.root,null);if(r.length>0)throw Error(`parseLayout: illegal layout — ${r.join(`; `)}`);return{version:1,root:n.root}}var Kt=1;function qt(e,t){return(e.constraints?.[t]??null)===null}function Jt(e){if(e.kind===`tabs`)return e;let t=e.children.map(Jt),n=t.some((t,n)=>t!==e.children[n]),r=e.sizes.map((t,r)=>!qt(e,r)||typeof t==`number`&&Number.isFinite(t)&&t>0?t:(n=!0,Kt));if(!n)return e;let i={kind:`split`,id:e.id,orientation:e.orientation,children:t,sizes:r};return e.constraints===void 0?i:{...i,constraints:e.constraints}}function Yt(e){let t=Jt(e.root);return t===e.root?e:{version:1,root:t}}function Xt(e,t){let n=null,r=e=>{n||(e.kind===`tabs`?e.id===t&&(n=e):e.children.forEach(r))};return r(e),n}function Zt(e,t){let n=null,r=e=>{n||(e.kind===`tabs`?e.panels.includes(t)&&(n=e):e.children.forEach(r))};return r(e),n}function Qt(e,t){return Zt(e,t)?.id}function $t(e){return e.kind===`tabs`?e.panels.length:e.children.reduce((e,t)=>e+$t(t),0)}function j(e,t,n){return{kind:`tabs`,id:e,panels:t,active:n}}function en(e,t,n){if(e.length===0)return``;if(e.includes(t))return t;let r=Math.min(n,e.length-1);return e[Math.max(0,r)]}function tn(e){if(e.kind===`tabs`)return e.panels.length===0?null:e;let t=[],n=[],r=[],i=e.constraints!==void 0;if(e.children.forEach((a,o)=>{let s=tn(a);s!==null&&(t.push(s),n.push(e.sizes[o]??1),i&&r.push(e.constraints[o]??null))}),t.length===0)return null;if(t.length===1)return t[0];let a={kind:`split`,id:e.id,orientation:e.orientation,children:t,sizes:n};return i?(r.length>0&&!r.some(e=>e===null)&&(r[r.length-1]=null),{...a,constraints:r}):a}function M(e){let t=tn(e);if(t===null)throw Error(`mutation would empty the entire layout`);return t}function nn(e){let t=new Set,n=e=>{if(e.kind===`tabs`)for(let n of e.panels)t.add(n);else e.children.forEach(n)};return n(e),t}function rn(e,t){return nn(e).has(t)}function an(e){let t=new Set,n=e=>{t.add(e.id),e.kind===`split`&&e.children.forEach(n)};return n(e),t}function N(e,t){let n=t,r=2;for(;e.has(n);)n=`${t}#${r}`,r+=1;return e.add(n),n}function on(e,t){let n=null,r=e=>{n||e.kind===`split`&&(e.id===t&&(n=e),e.children.forEach(r))};return r(e),n}function P(e,t,n){if(e.id===t)return n;if(e.kind===`tabs`)return j(e.id,[...e.panels],e.active);let r={kind:`split`,id:e.id,orientation:e.orientation,children:e.children.map(e=>P(e,t,n)),sizes:[...e.sizes]};return e.constraints===void 0?r:{...r,constraints:[...e.constraints]}}function sn(e){if(e.kind===`tabs`)return j(e.id,[...e.panels],e.active);let t={kind:`split`,id:e.id,orientation:e.orientation,children:e.children.map(sn),sizes:[...e.sizes]};return e.constraints===void 0?t:{...t,constraints:[...e.constraints]}}function F(e){return{version:1,root:e}}function cn(e,t,n){let r=on(e.root,t);if(!r)throw Error(`setSizes: split not found: ${t}`);if(n.length!==r.children.length)throw Error(`setSizes: sizes length ${n.length} != children length ${r.children.length}`);if(!n.every(e=>Number.isFinite(e)))throw Error(`setSizes: every size must be a finite number, got [${n.join(`, `)}]`);let i={kind:`split`,id:r.id,orientation:r.orientation,children:r.children.map(sn),sizes:[...n]},a=r.constraints===void 0?i:{...i,constraints:[...r.constraints]};return F(P(e.root,t,a))}function ln(e,t,n,r){let i=on(e.root,t);if(!i)throw Error(`setConstraint: split not found: ${t}`);if(!Number.isInteger(n))throw Error(`setConstraint: childIndex must be an integer, got ${n}`);if(n<0||n>=i.children.length)throw Error(`setConstraint: childIndex ${n} out of range [0, ${i.children.length})`);let a=i.constraints===void 0?i.children.map(()=>null):[...i.constraints];if(a[n]=r,a.length>0&&a.every(e=>e!==null))return e;let o={kind:`split`,id:i.id,orientation:i.orientation,children:i.children.map(sn),sizes:[...i.sizes],constraints:a};return F(P(e.root,t,o))}function un(e,t,n){let r=Xt(e.root,t);if(!r)throw Error(`setActive: group not found: ${t}`);if(!r.panels.includes(n))throw Error(`setActive: panel ${n} not in group ${t}`);let i=j(r.id,[...r.panels],n);return F(P(e.root,t,i))}function dn(e,t){let n=Zt(e,t);if(!n)throw Error(`panel not found: ${t}`);let r=n.panels.indexOf(t),i=n.panels.filter(e=>e!==t),a=j(n.id,i,en(i,n.active,r));return M(P(e,n.id,a))}function fn(e,t){let n=nn(e.root);return n.size===1&&n.has(t)?e:F(dn(e.root,t))}function pn(e,t){if(!Zt(e.root,t))throw Error(`extractPanel: panel not found: ${t}`);return{tree:F(dn(e.root,t)),extracted:t}}function mn(e,t,n){if(rn(e.root,t))throw Error(`insertPanel: panel already exists in the tree: ${t}`);let r=Xt(e.root,n.groupId);if(!r)throw Error(`insertPanel: dest group not found: ${n.groupId}`);let i=[...r.panels],a=hn(n.index,i.length);i.splice(a,0,t);let o=j(r.id,i,r.active);return F(M(P(e.root,r.id,o)))}function hn(e,t){return e===void 0?t:e<0?0:e>t?t:e}function gn(e,t,n){let r=Zt(e.root,t);if(!r)throw Error(`movePanel: panel not found: ${t}`);let i=Xt(e.root,n.groupId);if(!i)throw Error(`movePanel: dest group not found: ${n.groupId}`);if(r.id===i.id){let i=r.panels.filter(e=>e!==t),a=hn(n.index,i.length),o=[...i];o.splice(a,0,t);let s=j(r.id,o,r.active);return F(M(P(e.root,r.id,s)))}let a=r.panels.indexOf(t),o=r.panels.filter(e=>e!==t),s=j(r.id,o,en(o,r.active,a)),c=[...i.panels],l=hn(n.index,c.length);c.splice(l,0,t);let u=j(i.id,c,i.active),d=P(e.root,r.id,s);return d=P(d,i.id,u),F(M(d))}function _n(e,t,n,r){if(rn(e.root,t))throw Error(`wrapRoot: new panel already exists in the tree: ${t}`);let i=an(e.root),a=e.root.id,o=j(N(i,`${a}__new`),[t],t),s=sn(e.root),c=r===`after`?[s,o]:[o,s];return F({kind:`split`,id:N(i,`${a}__wrap`),orientation:n,children:c,sizes:[1,1]})}function vn(e,t,n,r,i){if(rn(e.root,r))throw Error(`splitGroup: new panel already exists in the tree: ${r}`);let a=Xt(e.root,t);if(!a)throw Error(`splitGroup: group not found: ${t}`);let o=an(e.root),s=j(N(o,`${t}__new`),[r],r),c=sn(a),l=i===`after`?[c,s]:[s,c],u={kind:`split`,id:N(o,`${t}__sp`),orientation:n,children:l,sizes:[1,1]};return F(M(P(e.root,t,u)))}function yn(e,t,n,r,i){if(rn(e.root,r))throw Error(`splitPanel: new panel already exists in the tree: ${r}`);let a=Zt(e.root,t);if(!a)throw Error(`splitPanel: panel not found: ${t}`);let o=an(e.root),s=a.id,c=j(N(o,`${s}__split`),[t],t),l=j(N(o,`${s}__new`),[r],r),u=i===`after`?[c,l]:[l,c],d={kind:`split`,id:N(o,`${s}__sp`),orientation:n,children:u,sizes:[1,1]};if(a.panels.length===1)return F(M(P(e.root,s,d)));let f=a.panels.indexOf(t),p=a.panels.filter(e=>e!==t),m=j(s,p,en(p,a.active,f)),h=i===`after`?[m,d]:[d,m],g={kind:`split`,id:N(o,`${s}__outer`),orientation:n,children:h,sizes:[1,1]};return F(M(P(e.root,s,g)))}function bn(e){let t=structuredClone(e),n=0,r=new Set,i=!1,a=[],o=e=>{let i=e(t);if(i===t)return;t=i,n+=1;let a={tree:t,revision:n};for(let e of[...r])try{e(a)}catch{}};return{get(){return t},apply(e){if(i){a.push(e);return}i=!0;try{for(o(e);a.length>0;){let e=a.shift();try{o(e)}catch{}}}finally{i=!1}},subscribe(e){return r.add(e),()=>{r.delete(e)}}}}function xn(e,t,n){return n.get(t)?.closable===!1?e:fn(e,t)}function Sn(){let e=Nt();return e.register({kind:`dom`,id:`simulator`,title:`Simulator`,draggable:!1,hideTab:!0}),e.register({kind:`dom`,id:`editor`,title:`Editor`,draggable:!1,hideTab:!0}),e.register({kind:`dom`,id:`wxml`,title:`WXML`,dropPolicy:`reorder-only`,closable:!1}),e.register({kind:`dom`,id:`appdata`,title:`AppData`,dropPolicy:`reorder-only`,closable:!1}),e.register({kind:`dom`,id:`storage`,title:`Storage`,dropPolicy:`reorder-only`,closable:!1}),e.register({kind:`native`,id:`console`,title:`Console`,nativeRef:{id:`console`},dropPolicy:`reorder-only`,closable:!1}),e.register({kind:`dom`,id:`compile`,title:`编译`,dropPolicy:`reorder-only`,closable:!1}),e}function Cn(e){return{version:1,root:{kind:`split`,id:`root`,orientation:`row`,sizes:[1,6],constraints:[{minPx:e},null],children:[{kind:`tabs`,id:`g-sim`,panels:[`simulator`],active:`simulator`},{kind:`split`,id:`col-main`,orientation:`column`,sizes:[70,30],children:[{kind:`tabs`,id:`g-editor`,panels:[`editor`],active:`editor`},{kind:`tabs`,id:`g-debug`,panels:[`wxml`,`appdata`,`storage`,`console`,`compile`],active:`wxml`}]}]}}}var wn={kind:`tabs`,id:`g-debug`,panels:[`wxml`,`appdata`,`storage`,`console`,`compile`],active:`wxml`},Tn=()=>({kind:`tabs`,id:`g-sim`,panels:[`simulator`],active:`simulator`}),En=()=>({kind:`tabs`,id:`g-editor`,panels:[`editor`],active:`editor`}),Dn=()=>({...wn,panels:[...wn.panels]});function On(e,t,n,r){return{version:1,root:{kind:`split`,id:`root`,orientation:`row`,sizes:e.map((e,t)=>r[t]??1),constraints:e.map((e,r)=>r===t?{minPx:n}:null),children:e}}}function kn(e,t,n){let r=t===`left`;if(n===`belowSimulator`){let t={kind:`split`,id:`col-sim`,orientation:`column`,sizes:[60,40],children:[Tn(),Dn()]};return r?On([t,En()],0,e,[1,6]):On([En(),t],1,e,[6,1])}if(n===`rightOfSimulator`)return r?On([Tn(),Dn(),En()],0,e,[1,4,5]):On([En(),Dn(),Tn()],2,e,[5,4,1]);let i={kind:`split`,id:`col-main`,orientation:`column`,sizes:[70,30],children:[En(),Dn()]};return r?On([Tn(),i],0,e,[1,6]):On([i,Tn()],1,e,[6,1])}function An(e,t,n){return bn(jn(e,t,n))}function jn(e,t,n){if(e===null)return Cn(t);try{let r=Gt(e);if(Wt(r,n).length===0)return Mn(Yt(r),t)}catch{}return Cn(t)}function Mn(e,t){let n=Fn(e);return Nn.some(e=>n.has(e))?Nn.reduce((e,r)=>n.has(r)?e:Bn(e,r,t),e):e}var Nn=[`wxml`,`appdata`,`storage`,`console`,`compile`];function Pn(e,t){if(e.kind===`tabs`){for(let n of e.panels)t.add(n);return}for(let n of e.children)Pn(n,t)}function Fn(e){let t=new Set;return Pn(e.root,t),t}function In(e,t){if(e.kind===`tabs`)return e.panels.includes(t)?e.id:void 0;for(let n of e.children){let e=In(n,t);if(e!==void 0)return e}}function Ln(e,t){return t.find(t=>e.has(t))}function Rn(e,t){if(e.kind===`tabs`)return null;for(let n=0;n<e.children.length;n++){if(e.children[n].id===t)return{splitId:e.id,childIndex:n};let r=Rn(e.children[n],t);if(r)return r}return null}function zn(e,t){let n=In(e.root,`simulator`);if(!n)return e;let r=Rn(e.root,n);return r?ln(e,r.splitId,r.childIndex,{minPx:t}):e}function Bn(e,t,n){let r=Fn(e);if(r.has(t))return e;if(Nn.includes(t)){let n=Nn.find(e=>e!==t&&r.has(e));return n?mn(e,t,{groupId:In(e.root,n)}):r.has(`editor`)?yn(e,`editor`,`column`,t,`after`):r.has(`simulator`)?yn(e,`simulator`,`row`,t,`after`):yn(e,[...r][0],`column`,t,`after`)}if(t===`editor`){let t=Ln(r,Nn);return t?vn(e,In(e.root,t),`column`,`editor`,`before`):r.has(`simulator`)?yn(e,`simulator`,`row`,`editor`,`after`):yn(e,[...r][0],`column`,`editor`,`before`)}return t===`simulator`?zn(_n(e,`simulator`,`row`,`before`),n):yn(e,[...r][0],`column`,t,`after`)}function Vn(e,t){let n=Fn(e);return t.list().map(e=>({id:e.id,title:e.title??e.id,open:n.has(e.id)}))}var Hn=Nn;function Un({model:e,registry:t,simPanelWidth:n}){let[,r]=(0,k.useState)(0);(0,k.useEffect)(()=>e.subscribe(()=>r(e=>e+1)),[e]);let i=new Set(Vn(e.get(),t).filter(e=>e.open).map(e=>e.id)),a=i.has(`simulator`),o=i.has(`editor`),s=Hn.some(e=>i.has(e)),c=[a,o,s].filter(Boolean).length;function l(r,i){e.apply(e=>i?xn(e,r,t):Bn(e,r,n))}function u(){if(s){let t=Hn.filter(e=>i.has(e));e.apply(e=>t.reduce((e,t)=>fn(e,t),e))}else{let t=Hn.filter(e=>!i.has(e));e.apply(e=>t.reduce((e,t)=>Bn(e,t,n),e))}}return(0,A.jsxs)(`div`,{className:`flex items-center gap-0.5`,role:`group`,"aria-label":`面板可见性`,children:[(0,A.jsx)(Kn,{active:a,disabled:a&&c===1,onClick:()=>l(`simulator`,a),title:a?`隐藏模拟器`:`显示模拟器`,testId:`layout-toolbar-toggle-simulator`,icon:(0,A.jsx)(qn,{filled:a})}),(0,A.jsx)(Kn,{active:o,disabled:o&&c===1,onClick:()=>l(`editor`,o),title:o?`隐藏编辑器`:`显示编辑器`,testId:`layout-toolbar-toggle-editor`,icon:(0,A.jsx)(Jn,{filled:o})}),(0,A.jsx)(Kn,{active:s,disabled:s&&c===1,onClick:u,title:s?`隐藏调试器`:`显示调试器`,testId:`layout-toolbar-toggle-debug`,icon:(0,A.jsx)(Yn,{filled:s})})]})}function Wn({model:e,layout:t,simPanelWidth:n}){let{simulatorAlignment:r,devtoolsPosition:i}=t.state,a=r===`left`;function o(){let r=a?`right`:`left`;t.setSimulatorAlignment(r),e.apply(()=>kn(n,r,i))}return(0,A.jsx)(O,{variant:`icon`,size:`icon`,onClick:o,title:a?`模拟器位置:左侧(点击切换到右侧)`:`模拟器位置:右侧(点击切换到左侧)`,"data-testid":`layout-toolbar-alignment-toggle`,"data-alignment":r,className:`text-text-muted hover:text-text hover:bg-surface-3`,children:(0,A.jsx)(Xn,{side:r})})}function Gn({model:e,layout:t,simPanelWidth:n}){let{simulatorAlignment:r,devtoolsPosition:i}=t.state;function a(i){t.setDevtoolsPosition(i),e.apply(()=>kn(n,r,i))}return(0,A.jsx)(`div`,{className:`flex items-center gap-0.5`,role:`group`,"aria-label":`调试器位置`,children:[{id:`inEditor`,title:`调试器位置:在编辑器面板中`},{id:`belowSimulator`,title:`调试器位置:在模拟器下方`},{id:`rightOfSimulator`,title:`调试器位置:在模拟器右侧`}].map(e=>(0,A.jsx)(Kn,{active:i===e.id,onClick:()=>a(e.id),title:e.title,testId:`layout-toolbar-devtools-${e.id}`,icon:(0,A.jsx)(Zn,{variant:e.id})},e.id))})}function Kn({active:e,disabled:t,onClick:n,title:r,testId:i,icon:a}){return(0,A.jsx)(O,{variant:`icon`,size:`icon`,onClick:n,disabled:t,title:r,"aria-pressed":e,"data-testid":i,"data-active":e?`true`:`false`,className:y(`text-text-muted/45 hover:text-text-muted hover:bg-surface-3`,e&&`bg-surface-active text-text ring-1 ring-accent/50 hover:bg-surface-active hover:text-text`),children:a})}function qn({filled:e}){return(0,A.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:e?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`rect`,{x:`4`,y:`1.5`,width:`8`,height:`13`,rx:`1.5`,fill:`currentColor`,stroke:`currentColor`}),(0,A.jsx)(`line`,{x1:`6.5`,y1:`12.5`,x2:`9.5`,y2:`12.5`,stroke:`var(--color-surface-2)`,strokeWidth:`1.2`})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`rect`,{x:`4`,y:`1.5`,width:`8`,height:`13`,rx:`1.5`}),(0,A.jsx)(`line`,{x1:`6.5`,y1:`12.5`,x2:`9.5`,y2:`12.5`})]})})}function Jn({filled:e}){return(0,A.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:e?2:1.6,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,A.jsx)(`polyline`,{points:`5,4 1.5,8 5,12`}),(0,A.jsx)(`polyline`,{points:`11,4 14.5,8 11,12`}),(0,A.jsx)(`line`,{x1:`9.5`,y1:`3`,x2:`6.5`,y2:`13`})]})}function Yn({filled:e}){return(0,A.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[e?(0,A.jsx)(`ellipse`,{cx:`8`,cy:`9`,rx:`3.5`,ry:`4.5`,fill:`currentColor`,stroke:`currentColor`}):(0,A.jsx)(`ellipse`,{cx:`8`,cy:`9`,rx:`3.5`,ry:`4.5`}),(0,A.jsx)(`line`,{x1:`6`,y1:`3.5`,x2:`5`,y2:`2`}),(0,A.jsx)(`line`,{x1:`10`,y1:`3.5`,x2:`11`,y2:`2`}),(0,A.jsx)(`line`,{x1:`4.5`,y1:`7.5`,x2:`2`,y2:`6.5`}),(0,A.jsx)(`line`,{x1:`4.5`,y1:`9.5`,x2:`2`,y2:`9.5`}),(0,A.jsx)(`line`,{x1:`4.5`,y1:`11.5`,x2:`2`,y2:`12.5`}),(0,A.jsx)(`line`,{x1:`11.5`,y1:`7.5`,x2:`14`,y2:`6.5`}),(0,A.jsx)(`line`,{x1:`11.5`,y1:`9.5`,x2:`14`,y2:`9.5`}),(0,A.jsx)(`line`,{x1:`11.5`,y1:`11.5`,x2:`14`,y2:`12.5`})]})}function Xn({side:e}){return(0,A.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,A.jsx)(`rect`,{x:`2`,y:`3`,width:`12`,height:`10`,rx:`1.5`}),e===`left`?(0,A.jsx)(`rect`,{x:`2.6`,y:`3.6`,width:`4.8`,height:`8.8`,rx:`0.8`,fill:`currentColor`,stroke:`none`}):(0,A.jsx)(`rect`,{x:`8.6`,y:`3.6`,width:`4.8`,height:`8.8`,rx:`0.8`,fill:`currentColor`,stroke:`none`})]})}function Zn({variant:e}){return e===`inEditor`?(0,A.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.2`,"aria-hidden":`true`,children:[(0,A.jsx)(`rect`,{x:`2`,y:`3`,width:`12`,height:`10`,rx:`1.5`}),(0,A.jsx)(`line`,{x1:`6.5`,y1:`3`,x2:`6.5`,y2:`13`}),(0,A.jsx)(`rect`,{x:`7.1`,y:`8.5`,width:`6.3`,height:`4`,rx:`0.6`,fill:`currentColor`,stroke:`none`})]}):e===`belowSimulator`?(0,A.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.2`,"aria-hidden":`true`,children:[(0,A.jsx)(`rect`,{x:`2`,y:`3`,width:`12`,height:`10`,rx:`1.5`}),(0,A.jsx)(`line`,{x1:`8`,y1:`3`,x2:`8`,y2:`13`}),(0,A.jsx)(`rect`,{x:`2.6`,y:`8.5`,width:`4.8`,height:`4`,rx:`0.6`,fill:`currentColor`,stroke:`none`})]}):(0,A.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.2`,"aria-hidden":`true`,children:[(0,A.jsx)(`rect`,{x:`2`,y:`3`,width:`12`,height:`10`,rx:`1.5`}),(0,A.jsx)(`line`,{x1:`6`,y1:`3`,x2:`6`,y2:`13`}),(0,A.jsx)(`line`,{x1:`9.5`,y1:`3`,x2:`9.5`,y2:`13`}),(0,A.jsx)(`rect`,{x:`6.3`,y:`3.6`,width:`3`,height:`8.8`,rx:`0.6`,fill:`currentColor`,stroke:`none`})]})}function Qn(){return(0,A.jsx)(`div`,{className:`w-px h-4 bg-border mx-1`,"aria-hidden":`true`})}function $n({compileDropdownRef:e,showCompilePanel:t,onToggleCompilePanel:n,onRelaunch:r,compileStatus:i,dockModel:a,dockRegistry:o,layout:s,simPanelWidth:c}){return(0,A.jsx)(`div`,{className:`flex flex-col shrink-0`,children:(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 bg-surface-2 border-b border-border shrink-0`,style:{height:40},children:[(0,A.jsx)(`div`,{ref:e,children:(0,A.jsxs)(O,{variant:`outline`,size:`sm`,onClick:n,className:y(t&&`border-accent`),title:`编译模式`,children:[`普通编译 `,(0,A.jsx)(`span`,{className:`text-[10px] text-text-secondary`,children:`▾`})]})}),(0,A.jsx)(Qn,{}),(0,A.jsx)(O,{variant:`icon`,size:`icon`,onClick:()=>{r()},disabled:i.status===`compiling`,title:`重新编译`,children:`↺`}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 px-1.5 shrink-0`,children:[(0,A.jsx)(Mt,{status:i.status}),(0,A.jsx)(`span`,{className:`text-[11px] text-text-muted max-w-28 truncate`,children:i.message})]}),(0,A.jsx)(`div`,{className:`flex-1 min-w-2`}),(0,A.jsx)(Un,{model:a,registry:o,simPanelWidth:c}),(0,A.jsx)(Qn,{}),(0,A.jsx)(Wn,{model:a,layout:s,simPanelWidth:c}),(0,A.jsx)(Qn,{}),(0,A.jsx)(Gn,{model:a,layout:s,simPanelWidth:c}),(0,A.jsx)(Qn,{}),(0,A.jsx)(O,{variant:`icon`,size:`icon`,onClick:()=>{me(!0)},title:`设置`,children:`⚙`})]})})}var er={x:0,y:0,width:0,height:0},tr=e=>({x:Math.round(e.x),y:Math.round(e.y),width:Math.max(0,Math.round(e.width)),height:Math.max(0,Math.round(e.height))});function nr(e,t){let n=t.present,r=t.publish,i=null,a=null,o=!1,s=()=>{let t=e.getBoundingClientRect();return tr({x:t.left,y:t.top,width:t.width,height:t.height})},c=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,l=()=>{if(o||!n)return;let e=s();a&&c(a,e)||(a=e,r(e))},u=()=>{i||(i=new ResizeObserver(l),i.observe(e),window.addEventListener(`resize`,l))},d=()=>{i&&=(i.disconnect(),null),window.removeEventListener(`resize`,l)},f=()=>{a=null,n?(u(),a=s(),r(a)):(d(),r(er))};return f(),{update(e){o||(r=e.publish,n=e.present,f())},dispose(){o||(o=!0,d())}}}function rr(e){let t=e.getBoundingClientRect();return{visible:!0,bounds:tr({x:t.left,y:t.top,width:t.width,height:t.height})}}var ir=(e,t)=>e.visible===t.visible?e.visible&&t.visible?e.bounds.x===t.bounds.x&&e.bounds.y===t.bounds.y&&e.bounds.width===t.bounds.width&&e.bounds.height===t.bounds.height:!0:!1;function ar(e,t){let n=t.visible,r=t.publish,i=t.guardDisplayNone??!1,a=t.followScroll??!1,o=t.followGeometry??!1,s=null,c=null,l=null,u=!1,d=null,f=0,p=!1,m=null,h=()=>{let t=rr(e);return i&&t.visible&&(t.bounds.width===0||t.bounds.height===0)?{visible:!1}:t},g=()=>{if(u||!n)return;let e=h();l&&ir(l,e)||(l=e,r(e))},_=()=>l?.visible===!1?!0:f++>=30,v=()=>{if(d=null,u||!n){m=null;return}if(m!==null&&performance.now()>=m){m=null;return}let e=h();if(!e.visible){if(_()){m=null;return}d=requestAnimationFrame(v);return}if(l&&ir(l,e)){if(f++,f>=2&&!p){m=null;return}}else l=e,r(e),f=0;!u&&n?d=requestAnimationFrame(v):m=null},y=()=>{!o||u||(f=0,d===null&&(d=requestAnimationFrame(v)))},b=()=>{d!==null&&(cancelAnimationFrame(d),d=null),f=0,m=null,p=!1},x=()=>{o?y():g()},S=e=>{let t=e.target;t&&t.closest&&t.closest(`[role="separator"]`)&&(p=!0,y())},C=()=>{p&&(p=!1,y())},w=()=>{s||(s=new ResizeObserver(g),s.observe(e),window.addEventListener(`resize`,g),i&&typeof IntersectionObserver<`u`&&(c=new IntersectionObserver(g),c.observe(e)),a&&window.addEventListener(`scroll`,x,{capture:!0,passive:!0}),o&&(window.addEventListener(`pointerdown`,S,{capture:!0}),window.addEventListener(`pointerup`,C,{capture:!0})))},T=()=>{s&&=(s.disconnect(),null),c&&=(c.disconnect(),null),window.removeEventListener(`resize`,g),window.removeEventListener(`scroll`,x,{capture:!0}),window.removeEventListener(`pointerdown`,S,{capture:!0}),window.removeEventListener(`pointerup`,C,{capture:!0}),b()},E=()=>{if(l=null,n)w(),l=h(),r(l);else{T();let e={visible:!1};l=e,r(e)}};return E(),{update(e){u||(r=e.publish,n=e.visible,E())},dispose(){u||(u=!0,T())},pulse(e){if(!(u||!o)){if(e!==void 0&&e>0){let t=performance.now()+e;m=m===null?t:Math.max(m,t)}y()}}}}function or(e){let t=(0,k.useRef)(null),n=(0,k.useRef)(null),r=(0,k.useRef)(e);r.current=e;let i=(0,k.useRef)([e.present,e.publish,...e.deps??[]]),a=(0,k.useRef)(()=>{let e=t.current;e&&(e.update({present:!1,publish:r.current.publish}),e.dispose(),t.current=null)}),o=(0,k.useCallback)(e=>{e!==n.current&&(n.current=e,t.current&&(e?(t.current.dispose(),t.current=null):a.current()),e&&(t.current=nr(e,{present:r.current.present,publish:r.current.publish}),i.current=[r.current.present,r.current.publish,...r.current.deps??[]]))},[]);return(0,k.useEffect)(()=>{let n=[e.present,e.publish,...e.deps??[]],r=i.current;(n.length!==r.length||n.some((e,t)=>!Object.is(e,r[t])))&&(i.current=n,t.current?.update({present:e.present,publish:e.publish}))},[e.present,e.publish,...e.deps??[]]),(0,k.useEffect)(()=>{let e=a.current;return n.current&&!t.current&&(t.current=nr(n.current,{present:r.current.present,publish:r.current.publish})),()=>{n.current===null&&e()}},[]),o}var sr=(0,k.createContext)(null);function cr(){return(0,k.useContext)(sr)}var I={simulator:`simulator`,simulatorDevtools:`simulator-devtools`,workbench:`workbench`,hostToolbar:`host-toolbar`,settings:`settings`,popover:`popover`},lr={base:0,hostToolbar:5,settings:10,popover:20};function ur(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function dr(e,t){let n=getComputedStyle(e.ownerDocument.body);return t*parseFloat(n.fontSize)}function fr(e){return e/100*window.innerHeight}function pr(e){return e/100*window.innerWidth}function mr(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}function hr({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=mr(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=dr(t,i);break;case`em`:r=ur(t,i);break;case`vh`:r=fr(i);break;case`vw`:r=pr(i);break}return r}function L(e){return parseFloat(e.toFixed(3))}function gr({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>(e+=t===`horizontal`?n.element.offsetWidth:n.element.offsetHeight,e),0)}function _r(e){let{panels:t}=e,n=gr({group:e});return n===0?t.map(e=>({groupResizeBehavior:e.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:e.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let{element:t,panelConstraints:r}=e,i=0;r.collapsedSize!==void 0&&(i=L(hr({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=L(hr({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=L(hr({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=L(hr({groupSize:n,panelElement:t,styleProp:r.maxSize})/n*100)),{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsible:r.collapsible===!0,defaultSize:a,disabled:r.disabled,minSize:o,maxSize:s,panelId:e.id}})}function R(e,t=`Assertion error`){if(!e)throw Error(t)}function vr(e,t){return Array.from(t).sort(e===`horizontal`?yr:br)}function yr(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function br(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function xr(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function Sr(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function Cr({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=Sr(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return R(i,`No rect found`),i}var wr;function Tr(){return wr===void 0&&(wr=typeof matchMedia==`function`?!!matchMedia(`(pointer:coarse)`).matches:!1),wr}function Er(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=vr(n,Array.from(t.children).filter(xr).map(e=>({element:e}))).map(({element:e})=>e),o=[],s=!1,c=!1,l=-1,u=-1,d=0,f,p=[];{let e=-1;for(let t of a)t.hasAttribute(`data-panel`)&&(e++,t.hasAttribute(`data-disabled`)||(d++,l===-1&&(l=e),u=e))}if(d>1){let t=-1;for(let d of a)if(d.hasAttribute(`data-panel`)){t++;let i=r.find(e=>e.element===d);if(i){if(f){let r=f.element.getBoundingClientRect(),a=d.getBoundingClientRect(),m;if(c){let e=n===`horizontal`?new DOMRect(r.right,r.top,0,r.height):new DOMRect(r.left,r.bottom,r.width,0),t=n===`horizontal`?new DOMRect(a.left,a.top,0,a.height):new DOMRect(a.left,a.top,a.width,0);switch(p.length){case 0:m=[e,t];break;case 1:{let i=p[0];m=[i,Cr({orientation:n,rects:[r,a],targetRect:i.element.getBoundingClientRect()})===r?t:e];break}default:m=p;break}}else m=p.length?p:[n===`horizontal`?new DOMRect(r.right,a.top,a.left-r.right,a.height):new DOMRect(a.left,r.bottom,a.width,a.top-r.bottom)];for(let n of m){let r=`width`in n?n:n.element.getBoundingClientRect(),a=Tr()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<a){let e=a-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<a){let e=a-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}!s&&!(t<=l||t>u)&&o.push({group:e,groupSize:gr({group:e}),panels:[f,i],separator:`width`in n?void 0:n,rect:r}),s=!1}}c=!1,f=i,p=[]}}else if(d.hasAttribute(`data-separator`)){d.ariaDisabled!==null&&(s=!0);let e=i.find(e=>e.element===d);e?p.push(e):(f=void 0,p=[])}else c=!0}return o}var Dr=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0)if(n.length===1)n[0].call(null,t);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}},z=new Map,Or=new Dr;function kr(e){z=new Map(z),z.delete(e)}function Ar(e,t){for(let[t]of z)if(t.id===e)return t}function B(e,t){for(let[t,n]of z)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function V(){return z}function jr(e,t){return Or.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function H(e,t){let n=z.get(e);z=new Map(z),z.set(e,t),Or.emit(`groupChange`,{group:e,prev:n,next:t})}function Mr(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=Sr(n,a.rect);switch(e){case`horizontal`:t.x<=i.x&&(r=a,i=t);break;case`vertical`:t.y<=i.y&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function Nr(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Pr(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:Br(e),b:Br(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();R(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:zr(Rr(n.a)),b:zr(Rr(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var Fr=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Ir(e){let t=getComputedStyle(Vr(e)??e).display;return t===`flex`||t===`inline-flex`}function Lr(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||Ir(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||Fr.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function Rr(e){let t=e.length;for(;t--;){let n=e[t];if(R(n,`Missing node`),Lr(n))return n}return null}function zr(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Br(e){let t=[];for(;e;)t.push(e),e=Vr(e);return t}function Vr(e){let{parentNode:t}=e;return Nr(t)?t.host:t}function Hr(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Ur({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!xr(n)||n.contains(e)||e.contains(n))return!0;if(Pr(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(Hr(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Wr(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=Er(r),a=Mr(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&Ur({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function Gr(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function U(e,t,n=0){return Math.abs(L(e)-L(t))<=n}function W(e,t){return U(e,t)?0:e>t?1:-1}function Kr({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsible:a,disabled:o,maxSize:s=100,minSize:c=0}=t;if(o&&!e)return n;if(W(r,c)<0)if(a){let e=(i+c)/2;r=W(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=L(r),r}function qr({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(U(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;R(u!=null,`Invalid first pivot index`),R(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];R(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(R(n!=null,`Previous layout not found for panel index ${t}`),U(n,i)){let t=o-n;W(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];R(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(R(n!=null,`Previous layout not found for panel index ${t}`),U(n,o)){let t=n-i;W(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];R(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&W(i,c)<0)if(e>0){let t=c-o,n=t/2;W(i+e,c)<0&&(e=W(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;W(i-e,c)<0&&(e=W(100+e,n)>0?0:-t)}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];R(e!=null,`Previous layout not found for panel index ${r}`);let a=Kr({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];R(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=Kr({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!U(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(Gr(c,l))return i;{let t=e<0?d:u,r=s[t];R(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=Kr({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!U(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];R(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=Kr({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(U(i,s)||(t-=s-i,l[r]=s),U(t,0))break;e>0?r--:r++}}}if(!U(Object.values(l).reduce((e,t)=>t+e,0),100,.1))return i;let p=Object.keys(i);return l.reduce((e,t,n)=>(e[p[n]]=t,e),{})}function G(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||W(e[n],t[n])!==0)return!1;return!0}function K({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],i=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(`, `)}`);if(!U(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];R(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];R(i!=null,`No layout data found for index ${e}`);let o=r[e];R(o!=null,`No layout data found for index ${e}`);let s=Kr({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!U(a,0))for(let e=0;e<t.length;e++){let n=r[e];R(n!=null,`No layout data found for index ${e}`);let i=n+a,o=Kr({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,U(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function Jr({groupId:e,panelId:t}){let n=()=>{let t=V();for(let[n,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:a,groupSize:o,separatorToPanels:s}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:n,groupSize:o,layout:a,separatorToPanels:s};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().group.panels.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=e=>{let r=a();if(e===r)return;let{defaultLayoutDeferred:i,derivedPanelConstraints:o,group:s,groupSize:c,layout:l,separatorToPanels:u}=n(),d=s.panels.findIndex(e=>e.id===t),f=d===s.panels.length-1,p=K({layout:qr({delta:f?r-e:e-r,initialLayout:l,panelConstraints:o,pivotIndices:f?[d-1,d]:[d,d+1],prevLayout:l,trigger:`imperative-api`}),panelConstraints:o});G(l,p)||H(s,{defaultLayoutDeferred:i,derivedPanelConstraints:o,groupSize:c,layout:p,separatorToPanels:u})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),s=a();e&&s!==t&&(n.expandToSize=s,o(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:s}=i(),c=a();if(e&&c===t){let e=s.expandToSize??n;e===0&&(e=1),o(e)}},getSize:()=>{let{group:e}=n(),t=a(),{element:r}=i();return{asPercentage:t,inPixels:e.orientation===`horizontal`?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&U(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=gr({group:t});o(L(hr({groupSize:a,panelElement:r,styleProp:e})/a*100))}}}function Yr(e){e.defaultPrevented||Wr(e,V()).forEach(t=>{if(t.separator&&!t.separator.disableDoubleClick){let n=t.panels.find(e=>e.panelConstraints.defaultSize!==void 0);if(n){let r=n.panelConstraints.defaultSize,i=Jr({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function Xr(e){let t=V();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function Zr({groupId:e}){let t=()=>{let t=V();for(let[n,r]of t)if(n.id===e)return{group:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:i,groupSize:a,layout:o,separatorToPanels:s}=t(),c=K({layout:e,panelConstraints:r});return n?o:(G(o,c)||H(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function q(e,t){let n=Xr(e),r=B(n.id,!0),i=n.separators.find(t=>t.element===e);R(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);R(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=Zr({groupId:n.id}).getLayout(),c=K({layout:qr({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});G(s,c)||H(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels})}function Qr(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=Xr(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&q(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&q(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&q(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&q(t,-5);break;case`End`:e.preventDefault(),q(t,100);break;case`Enter`:{e.preventDefault();let n=Xr(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=B(n.id,!0),o=n.separators.find(e=>e.element===t);R(o,`Matching separator not found`);let s=a.get(o);R(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(R(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];q(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=Xr(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);R(r!==null,`Index not found`),n[e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0].focus({preventScroll:!0});break}case`Home`:e.preventDefault(),q(t,-100);break}}var $r={cursorFlags:0,state:`inactive`},ei=new Dr;function J(){return $r}function ti(e){return ei.addListener(`change`,e)}function ni(e){let t=$r,n={...$r};n.cursorFlags=e,$r=n,ei.emit(`change`,{prev:t,next:n})}function ri(e){let t=$r;$r=e,ei.emit(`change`,{prev:t,next:e})}function ii(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=V(),n=Wr(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus({preventScroll:!0})));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),ri({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}var ai=e=>e,oi=()=>{},si=1,ci=2,li=4,ui=8,di=3,fi=12,pi;function mi(){return pi===void 0&&(pi=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(pi=!0)),pi}function hi({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&mi()){let t=(e&si)!==0,n=(e&ci)!==0,r=(e&li)!==0,i=(e&ui)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return mi()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var gi=new WeakMap;function _i(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=gi.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(n));let r=J();switch(r.state){case`active`:case`hover`:{let e=hi({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(e=>e.group),state:r.state}),i=`*, *:hover {cursor: ${e} !important; }`;if(t===i)return;t=i,e?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}gi.set(e,{prevStyle:t,styleSheet:n})}function vi({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0;n.forEach(e=>{let{group:n,groupSize:o}=e,{orientation:c,panels:l}=n,{disableCursor:u}=n.mutableState,d=0;d=a?c===`horizontal`?(t.clientX-a.x)/o*100:(t.clientY-a.y)/o*100:c===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let f=r.get(n),p=i.get(n);if(!f||!p)return;let{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:_,separatorToPanels:v}=p;if(h&&_&&v){let t=qr({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(G(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?si:ci;break;case`vertical`:s|=d<0?li:ui;break}}else H(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&di:c|=s&di,t.movementY===0?c|=o&fi:c|=s&fi,ni(c),_i(e)}function yi(e){let t=V(),n=J();switch(n.state){case`active`:vi({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function bi(e){if(e.defaultPrevented)return;let t=J(),n=V();switch(t.state){case`active`:if(e.buttons===0){ri({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=B(e.group.id,!0);H(e.group,t)});return}for(let n of t.hitRegions)if(n.separator){let{element:t}=n.separator;t.hasPointerCapture?.(e.pointerId)||t.setPointerCapture?.(e.pointerId)}vi({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=Wr(e,n);r.length===0?t.state!==`inactive`&&ri({cursorFlags:0,state:`inactive`}):ri({cursorFlags:0,hitRegions:r,state:`hover`}),_i(e.currentTarget);break}}}function xi(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(J().state){case`hover`:ri({cursorFlags:0,state:`inactive`})}}function Si(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=J();switch(t.state){case`active`:ri({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(_i(e.currentTarget),t.hitRegions.forEach(e=>{let t=B(e.group.id,!0);H(e.group,t)}),e.preventDefault())}}function Ci(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=L(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=L((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function wi(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=gr({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:L(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function Ti(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Ei({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,a=0,o=!1,s=new Map,c=[];for(let l of e.panels){let e=r[l.id]??0;switch(l.panelConstraints.groupResizeBehavior){case`preserve-pixel-size`:{o=!0;let r=L(e/100*n/t*100);s.set(l.id,r),i+=r;break}default:c.push(l.id),a+=e;break}}if(!o||c.length===0)return r;let l=100-i,u={...r};if(s.forEach((e,t)=>{u[t]=e}),a>0)for(let e of c)u[e]=L((r[e]??0)/a*l);else{let e=L(l/c.length);for(let t of c)u[t]=e}return u}function Di(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}var Oi=new Map;function ki(e){let t=!0;R(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){let t=gr({group:e});if(t===0)return;let n=B(e.id);if(!n)return;let r=_r(e),i=n.defaultLayoutDeferred?Ci(r):n.layout,a=K({layout:Ei({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&G(n.layout,a)&&Ti(n.derivedPanelConstraints,r)&&n.groupSize===t)return;H(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else wi(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{R(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=gr({group:e}),s=_r(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(Di(e.panels,l)||(l=void 0));let u=K({layout:e.mutableState.layouts[c]??l??Ci(s),panelConstraints:s}),d=e.element.ownerDocument;Oi.set(d,(Oi.get(d)??0)+1);let f=new Map;return Er(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),H(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,groupSize:o,layout:u,separatorToPanels:f}),e.separators.forEach(e=>{R(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,Qr)}),Oi.get(d)===1&&(d.addEventListener(`dblclick`,Yr,!0),d.addEventListener(`pointerdown`,ii,!0),d.addEventListener(`pointerleave`,yi),d.addEventListener(`pointermove`,bi),d.addEventListener(`pointerout`,xi),d.addEventListener(`pointerup`,Si,!0)),function(){t=!1,Oi.set(d,Math.max(0,(Oi.get(d)??0)-1)),kr(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,Qr)}),Oi.get(d)||(d.removeEventListener(`dblclick`,Yr,!0),d.removeEventListener(`pointerdown`,ii,!0),d.removeEventListener(`pointerleave`,yi),d.removeEventListener(`pointermove`,bi),d.removeEventListener(`pointerout`,xi),d.removeEventListener(`pointerup`,Si,!0)),a.disconnect()}}function Ai(){let[e,t]=(0,k.useState)({});return[e,(0,k.useCallback)(()=>t({}),[])]}function ji(e){let t=(0,k.useId)();return`${e??t}`}var Mi=typeof window<`u`?k.useLayoutEffect:k.useEffect;function Ni(e){let t=(0,k.useRef)(e);return Mi(()=>{t.current=e},[e]),(0,k.useCallback)((...e)=>t.current?.(...e),[t])}function Pi(...e){return Ni(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function Fi(e){let t=(0,k.useRef)({...e});return Mi(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var Ii=(0,k.createContext)(null);function Li(e,t){let n=(0,k.useRef)({getLayout:()=>({}),setLayout:ai});(0,k.useImperativeHandle)(t,()=>n.current,[]),Mi(()=>{Object.assign(n.current,Zr({groupId:e}))})}function Ri({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){let m=(0,k.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=Ni(e=>{G(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=Ni(e=>{G(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e))}),_=ji(s),v=(0,k.useRef)(null),[y,b]=Ai(),x=(0,k.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=Pi(v,a);Li(_,o);let C=Ni((e,t)=>{let r=J(),i=Ar(e),a=B(e);if(a){let e=!1;switch(r.state){case`active`:e=r.hitRegions.some(e=>e.group===i);break}return{flexGrow:a.layout[t]??1,pointerEvents:e?`none`:void 0}}if(n?.[t])return{flexGrow:n?.[t]}}),w=Fi({defaultLayout:n,disableCursor:r}),T=(0,k.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=vr(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=vr(u,[...t.separators,e]),b(),()=>{t.separators=t.separators.filter(t=>t!==e),b()}},updatePanelProps:(e,{disabled:t})=>{let n=x.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let r=Ar(_),i=B(_);r&&i&&H(r,{...i,derivedPanelConstraints:_r(r)})},updateSeparatorProps:(e,{disabled:t,disableDoubleClick:n})=>{let r=x.current.separators.find(t=>t.id===e);r&&(r.disabled=t,r.disableDoubleClick=n)}}),[C,_,b,u,w]),E=(0,k.useRef)(null);return Mi(()=>{let e=v.current;if(e===null)return;let t=x.current,n;if(w.defaultLayout!==void 0&&Object.keys(w.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=w.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={disabled:!!i,element:e,id:_,mutableState:{defaultLayout:n,disableCursor:!!w.disableCursor,expandedPanelSizes:x.current.lastExpandedPanelSizes,layouts:x.current.layouts},orientation:u,panels:t.panels,resizeTargetMinimumSize:t.resizeTargetMinimumSize,separators:t.separators};E.current=r;let a=ki(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=B(r.id,!0);!o&&s.length>0&&(h(c),g(c));let l=jr(_,e=>{let{defaultLayoutDeferred:t,derivedPanelConstraints:n,layout:i}=e.next;if(t||n.length===0)return;let a=r.panels.map(({id:e})=>e).join(`,`);r.mutableState.layouts[a]=i,n.forEach(t=>{if(t.collapsible){let{layout:n}=e.prev??{};if(n){let e=U(t.collapsedSize,i[t.panelId]),a=U(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=J().state!==`active`;h(i),o&&g(i)});return()=>{E.current=null,a(),l()}},[i,_,g,h,u,y,w]),(0,k.useEffect)(()=>{let e=E.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,A.jsx)(Ii.Provider,{value:T,children:(0,A.jsx)(`div`,{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:S,style:{height:`100%`,width:`100%`,overflow:`hidden`,...f,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:e})})}Ri.displayName=`Group`;function zi(){let e=(0,k.useContext)(Ii);return R(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function Bi(e,t){let{id:n}=zi(),r=(0,k.useRef)({collapse:oi,expand:oi,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:oi});(0,k.useImperativeHandle)(t,()=>r.current,[]),Mi(()=>{Object.assign(r.current,Jr({groupId:n,panelId:e}))})}function Vi({children:e,className:t,collapsedSize:n=`0%`,collapsible:r=!1,defaultSize:i,disabled:a,elementRef:o,groupResizeBehavior:s=`preserve-relative-size`,id:c,maxSize:l=`100%`,minSize:u=`0%`,onResize:d,panelRef:f,style:p,...m}){let h=!!c,g=ji(c),_=Fi({disabled:a}),v=(0,k.useRef)(null),y=Pi(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,updatePanelProps:w}=zi(),T=d!==null,E=Ni((e,t,n)=>{d?.(e,c,n)});Mi(()=>{let e=v.current;if(e!==null)return C({element:e,id:g,idIsStable:h,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:T?E:void 0,panelConstraints:{groupResizeBehavior:s,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:l,minSize:u}})},[s,n,r,i,T,g,h,l,u,E,C,_]),(0,k.useEffect)(()=>{w(g,{disabled:a})},[a,g,w]),Bi(g,f);let D=()=>{let e=b(x,g);if(e)return JSON.stringify(e)},ee=(0,k.useSyncExternalStore)(e=>jr(x,e),D,D),te;return te=ee?JSON.parse(ee):i?{flexGrow:void 0,flexShrink:void 0,flexBasis:i}:{flexGrow:1},(0,A.jsx)(`div`,{...m,"data-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...Hi,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...te},children:(0,A.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:S===`horizontal`?`pan-y`:`pan-x`},children:e})})}Vi.displayName=`Panel`;var Hi={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function Ui({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a,o=e[n],s=t.find(e=>e.panelId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=K({layout:qr({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=K({layout:qr({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function Wi({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=ji(a),l=Fi({disabled:n,disableDoubleClick:r}),[u,d]=(0,k.useState)({}),[f,p]=(0,k.useState)(`inactive`),[m,h]=(0,k.useState)(!1),g=(0,k.useRef)(null),_=Pi(g,i),{disableCursor:v,id:y,orientation:b,registerSeparator:x,updateSeparatorProps:S}=zi(),C=b===`horizontal`?`vertical`:`horizontal`;Mi(()=>{let e=g.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=x(t),r=ti(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=jr(y,e=>{let{derivedPanelConstraints:n,layout:r,separatorToPanels:i}=e.next,a=i.get(t);if(a){let e=a[0],t=a.indexOf(e);d(Ui({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[y,c,x,l]),(0,k.useEffect)(()=>{S(c,{disabled:n,disableDoubleClick:r})},[n,r,c,S]);let w;n&&!v&&(w=`not-allowed`);let T;if(n)T=`disabled`;else switch(f){case`active`:T=`active`;break;default:T=m?`focus`:f}return(0,A.jsx)(`div`,{...s,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":C,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":T,"data-testid":c,id:c,onBlur:()=>h(!1),onFocus:()=>h(!0),ref:_,role:`separator`,style:{flexBasis:`auto`,cursor:w,...o,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}Wi.displayName=`Separator`;function Gi(e,t,n,r){return!(e>0)||!(t>0)||!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)}function Ki(e){return Number.isFinite(e)?Math.max(0,Math.min(.5,e)):.25}function qi(e,t,n,r){let i=n<0?n:n>e?n-e:0,a=r<0?r:r>t?r-t:0;if(i===0&&a===0)return;let o=Math.abs(i);return o>=Math.abs(a)&&o>0?i<0?`left`:`right`:a<0?`top`:`bottom`}function Ji(e,t,n,r,i){let a=i*Math.min(e,t),o=n<a,s=n>e-a,c=r<a,l=r>t-a;return{inLeft:o,inTop:c,activeHoriz:o||s,activeVert:c||l}}function Yi(e,t,n,r,i,a){return(i?n/e:(e-n)/e)<=(a?r/t:(t-r)/t)?i?`left`:`right`:a?`top`:`bottom`}function Xi(e,t,n,r,i){let{inLeft:a,inTop:o,activeHoriz:s,activeVert:c}=Ji(e,t,n,r,i);return!s&&!c?`center`:s&&!c?a?`left`:`right`:c&&!s?o?`top`:`bottom`:Yi(e,t,n,r,a,o)}function Zi(e,t,n=.25){let{width:r,height:i}=e,{x:a,y:o}=t;if(Gi(r,i,a,o))return`center`;let s=Ki(n),c=qi(r,i,a,o);return c===void 0?Xi(r,i,a,o,s):c}function Qi(e,t,n){if(e===`center`)return{kind:`move`,panelId:t,destGroupId:n.groupId};let r=e===`left`||e===`right`?`row`:`column`,i=e===`left`||e===`top`?`before`:`after`;return{kind:`split`,atPanelId:n.panelId,dir:r,side:i,newPanelId:t}}function $i(e,t,n,r){return e===n.panelId||r===`center`&&t!==void 0&&t===n.groupId}function ea(e,t){if(!Number.isFinite(t))return 0;let n=0;for(let r of e)if(t>=r.left+r.width/2)n+=1;else break;return n}function ta(e,t,n,r){let i=t.indexOf(n),a=i>=0&&r>i,o=t.filter(e=>e!==n),s=e.filter(e=>e!==n),c=a?r-1:r;if(c<0&&(c=0),c>o.length&&(c=o.length),c>=o.length)return s.length;let l=o[c],u=s.indexOf(l);return u>=0?u:s.length}var na=.5;function ra(e){let t=e.reduce((e,t)=>e+(t>0?t:0),0);if(t<=0){let t=e.length>0?100/e.length:100;return e.map(()=>t)}return e.map(e=>(e>0?e:0)/t*100)}function ia(e,t){let n=e.map((e,t)=>t).filter(e=>(t?.[e]??null)===null),r=ra(n.map(t=>e[t]??0)),i=new Map;return n.forEach((e,t)=>{i.set(e,r[t])}),i}function aa(e){return Math.min(1,Math.max(.5,Math.floor(90/Math.max(1,e))))}function oa(e,t){let n=e.filter((e,n)=>(t?.[n]??null)===null).length,r=aa(n);return e.map((e,n)=>(t?.[n]??null)===null?Number.isFinite(e)&&e>=r?e:r:e)}function sa(e,t,n,r=na){let i=new Set(n);for(let t of Object.keys(e))if(!i.has(t))return!1;for(let e of Object.keys(t))if(!i.has(e))return!1;for(let i of n){let n=e[i],a=t[i];if(!Number.isFinite(n)||!Number.isFinite(a)||Math.abs(n-a)>r)return!1}return!0}function ca(e,t,n,r,i){let a=e=>(n?.[e]??null)!==null,o=t=>{let a=n?.[t]??null;if(i&&i.containerPx>0&&a){if(a.fixedPx!=null)return a.fixedPx/i.containerPx*100;if(a.minPx!=null&&!i.trustLiveForMinPx)return a.minPx/i.containerPx*100}let o=r[e[t]];return typeof o==`number`?o:null},s=la(e,a,o);if(s===null)return null;let c=Math.max(0,100-s),l=0,u=0;for(let n=0;n<e.length;n++){if(a(n))continue;let e=t[n]??0;l+=e>0?e:0,u+=1}let d={};for(let n=0;n<e.length;n++){let r=e[n];d[r]=a(n)?o(n):ua(t[n]??0,c,l,u)}return d}function la(e,t,n){let r=0;for(let i=0;i<e.length;i++){if(!t(i))continue;let e=n(i);if(e===null)return null;r+=e}return r}function ua(e,t,n,r){return n<=0?r>0?t/r:t:t*(e>0?e:0)/n}function da(e,t,n){let r=[],i=[];for(let a=0;a<e.length;a++){if((t?.[a]??null)!==null)continue;let o=n[e[a]];if(typeof o!=`number`||!Number.isFinite(o))return null;r.push(a),i.push(o>0?o:0)}return r.length===0?null:{indices:r,ratios:ra(i)}}function fa(e){let{node:t,ctx:n}=e,r=t.orientation===`row`?`horizontal`:`vertical`,i=ia(t.sizes,t.constraints),a=t.children.filter((e,n)=>(t.constraints?.[n]??null)===null).length,o=String(aa(a)),s=(0,k.useRef)(null),c=(0,k.useRef)(null),l=(0,k.useRef)(t);l.current=t;let u=[];t.children.forEach((e,r)=>{r>0&&u.push((0,A.jsx)(Wi,{"data-deck-resize-handle":``},`handle-${r}`));let a=t.constraints?.[r]??null;if(a?.fixedPx!=null){let t=`${a.fixedPx}px`;u.push((0,A.jsx)(Vi,{id:e.id,defaultSize:t,minSize:t,maxSize:t,groupResizeBehavior:`preserve-pixel-size`,children:wa(e,n)},pa(e)))}else if(a?.minPx!=null){let t=`${a.minPx}px`;u.push((0,A.jsx)(Vi,{id:e.id,defaultSize:t,minSize:t,groupResizeBehavior:`preserve-pixel-size`,children:wa(e,n)},pa(e)))}else{let t=i.get(r);u.push((0,A.jsx)(Vi,{id:e.id,defaultSize:t==null?void 0:String(t),minSize:o,children:wa(e,n)},pa(e)))}});let d=e=>{let t=l.current,r=t.children.map(e=>e.id),i=e=>(t.constraints?.[e]??null)!==null,a=da(r,t.constraints,e);if(!a)return;let o=ia(t.sizes,t.constraints),s=a.indices.map(e=>o.get(e)??0);if(!a.ratios.some((e,t)=>Math.abs(e-s[t])>.1))return;let c=r.map((n,r)=>i(r)?t.sizes[r]??1:e[n]);n.onApplyLayout(t.id,oa(c,t.constraints))},f=e=>{c.current=e,e&&(e.__deckApplyLayout=e=>{let t=l.current,r=e=>(t.constraints?.[e]??null)!==null,i=e.map((e,n)=>r(n)?t.sizes[n]??1:e);n.onApplyLayout(t.id,oa(i,t.constraints))},Object.defineProperty(e,`__deckGroupApi`,{configurable:!0,get:()=>s.current??void 0}))},p=(0,k.useCallback)(e=>{let t=s.current;if(!t)return{pushed:!1,stuck:!1};let n=l.current,r=n.children.map(e=>e.id),i=t.getLayout(),a=c.current?.getBoundingClientRect(),o=a?n.orientation===`row`?a.width:a.height:0,u=o>0?{containerPx:o,trustLiveForMinPx:!e}:void 0,d=ca(r,n.sizes,n.constraints,i,u);return d?sa(i,d,r)?{pushed:!1,stuck:!0}:(t.setLayout(d),{pushed:!0,stuck:sa(t.getLayout(),d,r)}):{pushed:!1,stuck:!1}},[]),m=t.sizes.join(`,`),h=t.children.length,g=(0,k.useRef)(null);return(0,k.useEffect)(()=>{let e=g.current!==h;if(g.current=h,!e){p(!1);return}let t=!1,n=0,r=0,i=()=>{if(t)return;r+=1;let{stuck:e}=p(!0);!e&&r<8&&(n=requestAnimationFrame(i))};return n=requestAnimationFrame(i),()=>{t=!0,cancelAnimationFrame(n)}},[m,h,p]),(0,A.jsx)(`div`,{ref:f,"data-deck-split":t.id,"data-orientation":t.orientation,"data-deck-sizes":t.sizes.join(`,`),style:{width:`100%`,height:`100%`},children:(0,A.jsx)(Ri,{groupRef:s,orientation:r,onLayoutChanged:d,style:{width:`100%`,height:`100%`},children:u},t.children.length)})}function pa(e){return e.id}function ma(e,t){let n=e.active;return n?(0,A.jsxs)(k.Fragment,{children:[t.registry.get(n)?.kind===`native`?(0,A.jsx)(ha,{panelId:n,bindNativeSlot:t.bindNativeSlot},n):null,e.panels.filter(e=>t.registry.get(e)?.kind!==`native`).slice().sort((e,t)=>e<t?-1:+(e>t)).map(e=>{let r=e===n;return(0,A.jsx)(`div`,{"data-deck-panel-body":e,style:{display:r?`flex`:`none`,flexDirection:`column`,flex:1,minWidth:0,minHeight:0},children:t.renderDomPanel(e,{active:r})},`dom-${e}`)})]}):null}function ha(e){let{panelId:t,bindNativeSlot:n}=e,r=(0,k.useRef)(n);return r.current=n,(0,A.jsx)(`div`,{ref:(0,k.useCallback)(e=>{r.current(t,e)},[t]),"data-deck-native-slot":t,style:{flex:1,minWidth:0,minHeight:0,height:`100%`}})}var ga=`application/x-deck-panel`;function _a(e){let{node:t,ctx:n}=e,[r,i]=(0,k.useState)(null),a=(0,k.useRef)(t);a.current=t;let o=(0,k.useRef)(n.onRedock);o.current=n.onRedock;let s=e=>{e&&(e.__deckHandleDrop=(e,t)=>{let n=a.current;o.current(n.id,n.active,e,t)})},c=e=>{if(!e.dataTransfer?.types.includes(ga))return;e.preventDefault();let t=n.activeDragPanelId.current;if(n.suppressReorderOnlyDropIndicator&&t!==null&&n.registry.get(t)?.dropPolicy===`reorder-only`){i(null);return}let r=e.currentTarget.getBoundingClientRect();i(Zi({width:r.width,height:r.height},{x:e.clientX-r.left,y:e.clientY-r.top}))},l=()=>{i(null)},u=e=>{e.preventDefault();let r=e.currentTarget.getBoundingClientRect(),a=Zi({width:r.width,height:r.height},{x:e.clientX-r.left,y:e.clientY-r.top});i(null);let o=e.dataTransfer?.getData(ga);if(!o||n.registry.get(o)===void 0||!n.isPanelInTree(o))return;let s=ea(Array.from(e.currentTarget.querySelectorAll(`[data-deck-tab]`)).map(e=>{let t=e.getBoundingClientRect();return{left:t.left,width:t.width}}),e.clientX);n.onRedock(t.id,t.active,o,a,s)},d=e=>{e.dataTransfer?.types.includes(ga)&&(e.preventDefault(),e.stopPropagation(),i(null))},f=e=>{e.preventDefault(),e.stopPropagation(),i(null);let r=e.dataTransfer?.getData(ga);if(!r||n.registry.get(r)===void 0||!n.isPanelInTree(r))return;let a=ea(Array.from(e.currentTarget.querySelectorAll(`[data-deck-tab]`)).map(e=>{let t=e.getBoundingClientRect();return{left:t.left,width:t.width}}),e.clientX);n.onRedock(t.id,t.active,r,`center`,a)},p=t.panels.filter(e=>!n.registry.get(e)?.hideTab);return(0,A.jsxs)(`div`,{ref:s,"data-deck-group":t.id,onDragOver:c,onDragLeave:l,onDrop:u,style:{position:`relative`,display:`flex`,flexDirection:`column`,width:`100%`,height:`100%`,minWidth:0,minHeight:0},children:[p.length>0?(0,A.jsx)(`div`,{role:`tablist`,style:{flexShrink:0},onDragOver:d,onDrop:f,children:p.map(e=>{let r=e===t.active,i=n.registry.get(e),a=i?.title??e;return(0,A.jsxs)(`button`,{type:`button`,role:`tab`,draggable:i?.draggable===!1?void 0:`true`,"data-deck-tab":e,"data-active":r?`true`:`false`,onDragStart:t=>{if(t.target instanceof Element&&t.target.closest(`[data-deck-tab-close]`)!==null){t.preventDefault();return}t.dataTransfer.setData(ga,e),t.dataTransfer.setData(`text/plain`,e),t.dataTransfer.effectAllowed=`move`,n.activeDragPanelId.current=e},onDragEnd:()=>{n.activeDragPanelId.current=null},onClick:()=>{r?n.onActiveTabClick?.(e):n.onActivate(t.id,e)},children:[a,n.canClose&&i?.closable!==!1?(0,A.jsx)(`span`,{role:`button`,tabIndex:0,"data-deck-tab-close":e,"aria-label":`Close ${a}`,onPointerDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),t.preventDefault(),n.onClose(e)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.stopPropagation(),t.preventDefault(),n.onClose(e))},children:`×`}):null]},e)})}):null,ma(t,n),r?(0,A.jsx)(ya,{zone:r}):null]})}function va(e){let t={position:`absolute`,pointerEvents:`none`,background:`rgba(64, 128, 255, 0.25)`,outline:`2px solid rgba(64, 128, 255, 0.6)`};switch(e){case`left`:return{...t,left:`0`,top:`0`,width:`50%`,height:`100%`};case`right`:return{...t,right:`0`,top:`0`,width:`50%`,height:`100%`};case`top`:return{...t,left:`0`,top:`0`,width:`100%`,height:`50%`};case`bottom`:return{...t,left:`0`,bottom:`0`,width:`100%`,height:`50%`};default:return{...t,left:`0`,top:`0`,width:`100%`,height:`100%`}}}function ya(e){return(0,A.jsx)(`div`,{"data-deck-drop-zone":e.zone,style:va(e.zone)})}var ba=(0,k.createContext)(0);function xa(){return(0,k.useContext)(ba)}function Sa(e,t,n){let{groupId:r,activePanelId:i,draggedPanelId:a,draggedGroupId:o,zone:s,reorderIndex:c}=n;if(o===void 0||o!==r||s!==`center`)return;let l=Xt(e.get().root,r),u;if(c!==void 0&&l){let e=l.panels.filter(e=>t.get(e)?.hideTab!==!0);u=ta(l.panels,e,a,c)}else u=l?l.panels.indexOf(i):void 0;e.apply(e=>gn(e,a,{groupId:r,index:u}))}function Ca(e){let{model:t,registry:n,renderDomPanel:r,bindNativeSlot:i,suppressReorderOnlyDropIndicator:a,onActiveTabClick:o}=e,[s,c]=(0,k.useState)(()=>t.get()),[l,u]=(0,k.useState)(0),d=(0,k.useRef)(null);(0,k.useEffect)(()=>(c(t.get()),t.subscribe(e=>{c(e.tree),u(e.revision)})),[t]);let f=(0,k.useCallback)((e,n)=>{t.apply(t=>un(t,e,n))},[t]),p=(0,k.useCallback)(e=>{t.apply(t=>xn(t,e,n))},[t,n]),m=$t(s.root)>1,h=(0,k.useCallback)(e=>Qt(s.root,e)!==void 0,[s]),g=(0,k.useCallback)((e,n)=>{t.apply(t=>cn(t,e,n))},[t]),_=(0,k.useCallback)((e,r,i,a,o)=>{let s={groupId:e,panelId:r},c=Qt(t.get().root,i);if(n.get(i)?.draggable===!1||n.get(r)?.draggable===!1)return;if(n.get(i)?.dropPolicy===`reorder-only`){Sa(t,n,{groupId:e,activePanelId:r,draggedPanelId:i,draggedGroupId:c,zone:a,reorderIndex:o});return}if($i(i,c,s,a))return;let l=Qi(a,i,s);if(l.kind===`move`){t.apply(e=>gn(e,l.panelId,{groupId:l.destGroupId}));return}t.apply(e=>{let{tree:t}=pn(e,l.newPanelId);return Qt(t.root,l.atPanelId)===void 0?e:yn(t,l.atPanelId,l.dir,l.newPanelId,l.side)})},[t,n]);return(0,A.jsx)(ba.Provider,{value:l,children:wa(s.root,{registry:n,renderDomPanel:r,bindNativeSlot:i,onActivate:f,onActiveTabClick:o,onApplyLayout:g,onRedock:_,onClose:p,canClose:m,isPanelInTree:h,suppressReorderOnlyDropIndicator:a??!1,activeDragPanelId:d})})}function wa(e,t){return e.kind===`split`?Ta(e,t):Ea(e,t)}function Ta(e,t){return(0,A.jsx)(fa,{node:e,ctx:t},e.id)}function Ea(e,t){return(0,A.jsx)(_a,{node:e,ctx:t},e.id)}function Da({phase:e,code:t,reason:n,onRelaunch:r}){return(0,A.jsx)(`div`,{"data-testid":`sim-runtime-error`,className:`absolute inset-0 flex flex-col items-center justify-center bg-black/70 z-10`,children:(0,A.jsxs)(`div`,{className:`text-center p-4`,children:[(0,A.jsx)(`div`,{className:`text-status-error text-[14px] font-medium mb-2`,children:e===`crashed`?`小程序已崩溃`:`小程序启动失败`}),(0,A.jsx)(`div`,{className:`text-status-error text-[11px] max-w-[280px] break-words mb-3`,children:n??t??`未知原因`}),(0,A.jsx)(`button`,{type:`button`,onClick:r,className:`text-[11px] px-3 py-1 rounded border border-status-error text-status-error hover:bg-status-error/10`,children:`重新启动`})]})})}function Oa({requested:e,resolved:t,onDismiss:n}){return(0,A.jsxs)(`div`,{"data-testid":`sim-fallback-banner`,className:`flex items-center gap-2 px-2.5 py-1 bg-status-warn/15 border-b border-status-warn/40 text-[11px] text-status-warn shrink-0`,children:[(0,A.jsxs)(`span`,{className:`flex-1 min-w-0 truncate`,children:[`启动页 "`,e,`" 不存在,已回退到 "`,t,`"`]}),(0,A.jsx)(`button`,{type:`button`,onClick:n,className:`shrink-0 text-status-warn/80 hover:text-status-warn px-1`,title:`关闭`,children:`×`})]})}function ka(){return(0,A.jsx)(`div`,{"data-testid":`sim-watcher-dead-banner`,className:`flex items-center gap-2 px-2.5 py-1 bg-status-error/15 border-b border-status-error/40 text-[11px] text-status-error shrink-0`,children:`文件监听已停止,后续代码修改将不会自动重新编译`})}var Aa=50;function ja(e,t,n){if(e.width<=0||e.height<=0)return n;let r=Math.min(e.width/(t.width+Aa),e.height/(t.height+Aa));return Math.max(1,Math.min(100,Math.floor(r*100)))}function Ma({device:e,zoom:t,onDeviceChange:n,onZoomChange:r,compileStatus:i,currentPage:a,copied:o,onCopyPagePath:s,runtimeStatus:c=null,watcherDead:l=!1,onRelaunch:u=()=>{},onOpenInternalDevtools:d=()=>{}}){let f=(0,k.useRef)(typeof t==`number`?t:100),p=(0,k.useRef)(t),m=(0,k.useRef)(e),h=(0,k.useRef)(null),[g,_]=(0,k.useState)(!1);(0,k.useEffect)(()=>{i.status===`ready`&&_(!0)},[i.status]);let v=c?.phase===`launch-failed`||c?.phase===`crashed`,[b,x]=(0,k.useState)(!1);(0,k.useEffect)(()=>{c||x(!1)},[c]);let C=!!c?.pageFallback&&!v&&!b,T=i.status===`compiling`&&g,E=cr(),D=(0,k.useCallback)(e=>{if(e.visible){let t=p.current;f.current=t===`auto`?ja(e.bounds,m.current,f.current):t}E?.set({viewId:I.simulator,placement:e,layer:lr.base,extra:{zoom:f.current}})},[E]),ee=(0,k.useCallback)(e=>{let t=h.current;if(t){e?(t.dispose(),h.current=ar(e,{visible:!0,followGeometry:!0,guardDisplayNone:!0,publish:D})):(t.update({visible:!1,publish:D}),t.dispose(),h.current=null);return}e&&(h.current=ar(e,{visible:!0,followGeometry:!0,guardDisplayNone:!0,publish:D}))},[D]);return(0,k.useLayoutEffect)(()=>{p.current=t,m.current=e}),(0,k.useLayoutEffect)(()=>{h.current?.update({visible:!0,publish:D})},[t,e,D]),(0,k.useEffect)(()=>{h.current?.pulse(300)},[xa()]),(0,k.useEffect)(()=>()=>{h.current?.dispose(),h.current=null,E?.remove(I.simulator)},[E]),(0,A.jsxs)(`div`,{className:`bg-sim-bg flex flex-col overflow-hidden h-full w-full`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 px-5 py-2 shrink-0 border-b border-border-subtle`,children:[(0,A.jsx)(le,{value:e.name,onChange:n,children:fe.map(e=>(0,A.jsx)(`option`,{value:e.name,children:e.name},e.name))}),(0,A.jsxs)(le,{value:t,onChange:r,className:`w-[76px] shrink-0`,children:[w.map(e=>(0,A.jsxs)(`option`,{value:e,children:[e,`%`]},e)),(0,A.jsx)(`option`,{value:S,children:`自适应`})]})]}),l&&(0,A.jsx)(ka,{}),C&&c?.pageFallback&&(0,A.jsx)(Oa,{requested:c.pageFallback.requested,resolved:c.pageFallback.resolved,onDismiss:()=>x(!0)}),(0,A.jsxs)(`div`,{ref:ee,className:`flex-1 min-h-0 bg-sim-bg relative`,"data-area":`native-simulator`,children:[i.status===`compiling`&&!g&&(0,A.jsx)(`div`,{"data-testid":`sim-compiling-overlay`,className:`absolute inset-0 flex items-center justify-center bg-black/50 z-10`,children:(0,A.jsx)(`div`,{className:`text-text-dim text-[13px]`,children:`正在编译中...`})}),T&&(0,A.jsxs)(`div`,{"data-testid":`sim-recompiling-indicator`,className:`absolute top-2 right-2 z-10 flex items-center gap-1.5 rounded bg-black/60 px-2 py-0.5 pointer-events-none`,children:[(0,A.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-accent animate-pulse`}),(0,A.jsx)(`span`,{className:`text-text-dim text-[11px]`,children:`编译中…`})]}),i.status===`error`&&(0,A.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/70 z-10`,children:(0,A.jsxs)(`div`,{className:`text-center p-4`,children:[(0,A.jsx)(`div`,{className:`text-status-error text-[14px] font-medium mb-2`,children:`编译失败`}),(0,A.jsx)(`div`,{className:`text-status-error text-[11px] max-w-[280px] break-words`,children:i.message})]})}),i.status!==`error`&&c&&(c.phase===`launch-failed`||c.phase===`crashed`)&&(0,A.jsx)(Da,{phase:c.phase,code:c.code,reason:c.reason,onRelaunch:u})]}),(0,A.jsxs)(`div`,{className:`flex items-center px-2.5 bg-sim-bottom border-t border-border-subtle shrink-0 h-[30px] min-w-0`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0`,children:[(0,A.jsx)(`span`,{className:`text-[11px] text-text-dim truncate min-w-0`,children:a||`—`}),a&&(0,A.jsx)(`button`,{className:y(`shrink-0 flex items-center justify-center w-4 h-4 rounded transition-colors`,o?`text-accent`:`text-text-dim hover:text-text`),onClick:s,title:`复制路径`,children:o?(0,A.jsx)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 10 10`,fill:`none`,children:(0,A.jsx)(`polyline`,{points:`1.5,5 4,7.5 8.5,2.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})}):(0,A.jsxs)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 10 10`,fill:`none`,children:[(0,A.jsx)(`rect`,{x:`1`,y:`3`,width:`6`,height:`6.5`,rx:`1`,stroke:`currentColor`,strokeWidth:`1`}),(0,A.jsx)(`path`,{d:`M3 3V2a1 1 0 011-1h4a1 1 0 011 1v5a1 1 0 01-1 1H7`,stroke:`currentColor`,strokeWidth:`1`})]})})]}),(0,A.jsx)(`button`,{className:`ml-auto shrink-0 flex items-center justify-center w-4 h-4 rounded text-text-dim hover:text-text transition-colors`,onClick:d,title:`调试开发者工具`,"data-testid":`sim-open-internal-devtools`,children:(0,A.jsxs)(`svg`,{width:`11`,height:`11`,viewBox:`0 0 11 11`,fill:`none`,children:[(0,A.jsx)(`rect`,{x:`3`,y:`3.5`,width:`5`,height:`5.5`,rx:`1.5`,stroke:`currentColor`,strokeWidth:`1`}),(0,A.jsx)(`path`,{d:`M4 3.5V3a1.5 1.5 0 013 0v.5M1.5 5.5H3M8 5.5h1.5M2 8.5l1.3-1M9 8.5l-1.3-1M2 3l1.3 1M9 3L7.7 4`,stroke:`currentColor`,strokeWidth:`1`,strokeLinecap:`round`})]})})]})]})}function Na(){let e=(0,k.useRef)(null),t=cr(),n=(0,k.useCallback)(e=>{t?.set({viewId:I.workbench,placement:e,layer:lr.base})},[t]),r=(0,k.useCallback)(t=>{let r=e.current;if(r){t?(r.dispose(),e.current=ar(t,{visible:!0,guardDisplayNone:!0,followScroll:!0,followGeometry:!0,publish:n})):(r.update({visible:!1,publish:n}),r.dispose(),e.current=null);return}t&&(e.current=ar(t,{visible:!0,guardDisplayNone:!0,followScroll:!0,followGeometry:!0,publish:n}))},[n]);return(0,k.useEffect)(()=>{e.current?.pulse(300)},[xa()]),(0,k.useEffect)(()=>()=>{e.current?.dispose(),e.current=null,t?.remove(I.workbench)},[t]),(0,A.jsx)(`div`,{ref:r,className:`h-full w-full`,"data-area":`editor`})}function Pa(e,t){return!!(t===0||e.tagName===`#shadow-root`||e.tagName.includes(`/`))}function Fa({entries:e}){return(0,A.jsx)(A.Fragment,{children:e.map(([e,t])=>(0,A.jsxs)(`span`,{children:[` `,(0,A.jsx)(`span`,{className:`text-code-blue`,children:e}),(0,A.jsx)(`span`,{className:`text-text-dim`,children:`=`}),(0,A.jsxs)(`span`,{className:`text-code-orange`,children:[`"`,t,`"`]})]},e))})}function Ia({node:e,depth:t}){return(0,A.jsxs)(`div`,{className:`py-px leading-[18px] hover:bg-surface-2`,style:{paddingLeft:t*16},children:[(0,A.jsx)(`span`,{className:`w-3 inline-block`}),(0,A.jsx)(`span`,{className:`text-text`,children:e.text})]})}function La({node:e,depth:t,inspectedSid:n,onInspect:r}){return(0,A.jsx)(A.Fragment,{children:(e.children??[]).map((e,i)=>(0,A.jsx)(Ha,{node:e,depth:t,inspectedSid:n,onInspect:r},i))})}function Ra({node:e,depth:t,inspectedSid:n,onInspect:r}){let[i,a]=(0,k.useState)(()=>Pa(e,t)),o=t*16,s=(e.children??[]).length>0;return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`div`,{className:`py-px leading-[18px] hover:bg-surface-2 cursor-pointer`,style:{paddingLeft:o},onClick:()=>s&&a(!i),children:[(0,A.jsx)(`span`,{className:`text-text-dim w-3 shrink-0 inline-block text-center select-none`,children:s?i?`▾`:`▸`:` `}),(0,A.jsx)(`span`,{className:`text-text-dim italic`,children:`#shadow-root`})]}),i&&e.children.map((e,i)=>(0,A.jsx)(Ha,{node:e,depth:t+1,inspectedSid:n,onInspect:r},i))]})}function za({node:e,indent:t,attrEntries:n,isInspected:r,onMouseEnter:i,inlineText:a}){return(0,A.jsxs)(`div`,{className:`py-px leading-[18px] hover:bg-surface-2${r?` bg-surface-2`:``}`,style:{paddingLeft:t},onMouseEnter:i,"data-wxml-sid":e.sid,children:[(0,A.jsx)(`span`,{className:`w-3 inline-block`}),(0,A.jsxs)(`span`,{className:`text-code-keyword`,children:[`<`,e.tagName]}),(0,A.jsx)(Fa,{entries:n}),(0,A.jsx)(`span`,{className:`text-code-keyword`,children:`>`}),(0,A.jsx)(`span`,{className:`text-text`,children:a}),(0,A.jsxs)(`span`,{className:`text-code-keyword`,children:[`</`,e.tagName,`>`]})]})}function Ba({node:e,depth:t,indent:n,attrEntries:r,hasChildren:i,expanded:a,isInspected:o,inspectedSid:s,onInspect:c,onToggle:l,onMouseEnter:u}){return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`div`,{className:`flex items-start hover:bg-surface-2 py-px leading-[18px]${i?` cursor-pointer`:``}${o?` bg-surface-2`:``}`,style:{paddingLeft:n},onMouseEnter:u,onClick:()=>{i&&l()},"data-wxml-sid":e.sid,children:[(0,A.jsx)(`span`,{className:`text-text-dim w-3 shrink-0 text-center select-none`,children:i?a?`▾`:`▸`:` `}),(0,A.jsxs)(`span`,{children:[(0,A.jsxs)(`span`,{className:`text-code-keyword`,children:[`<`,e.tagName]}),(0,A.jsx)(Fa,{entries:r}),(0,A.jsx)(`span`,{className:`text-code-keyword`,children:i?`>`:` />`})]})]}),a&&i&&(0,A.jsxs)(A.Fragment,{children:[e.children.map((e,n)=>(0,A.jsx)(Ha,{node:e,depth:t+1,inspectedSid:s,onInspect:c},n)),(0,A.jsxs)(`div`,{style:{paddingLeft:n},className:`py-px leading-[18px]`,children:[(0,A.jsx)(`span`,{className:`w-3 inline-block`}),(0,A.jsxs)(`span`,{className:`text-code-keyword`,children:[`</`,e.tagName,`>`]})]})]})]})}function Va({node:e,depth:t,inspectedSid:n,onInspect:r}){let[i,a]=(0,k.useState)(()=>Pa(e,t)),o=t*16,s=!!(e.sid&&e.sid===n),c=(e.children??[]).length>0,l=Object.entries(e.attrs),u=()=>{e.sid&&r?.(e)},d=c&&e.children.length===1&&e.children[0].tagName===`#text`?e.children[0].text:null;return d?(0,A.jsx)(za,{node:e,indent:o,attrEntries:l,isInspected:s,onMouseEnter:u,inlineText:d}):(0,A.jsx)(Ba,{node:e,depth:t,indent:o,attrEntries:l,hasChildren:c,expanded:i,isInspected:s,inspectedSid:n,onInspect:r,onToggle:()=>a(!i),onMouseEnter:u})}function Ha({node:e,depth:t,inspectedSid:n,onInspect:r}){return e.tagName===`#text`?(0,A.jsx)(Ia,{node:e,depth:t}):e.tagName===`#fragment`?(0,A.jsx)(La,{node:e,depth:t,inspectedSid:n,onInspect:r}):e.tagName===`#shadow-root`?(0,A.jsx)(Ra,{node:e,depth:t,inspectedSid:n,onInspect:r}):(0,A.jsx)(Va,{node:e,depth:t,inspectedSid:n,onInspect:r})}function Ua({inspection:e}){if(!e)return null;let{rect:t,style:n}=e,r=[n.display,n.position===`static`?null:n.position,n.boxSizing].filter(Boolean);return(0,A.jsxs)(`div`,{className:`border-t border-border-subtle bg-bg-panel px-2.5 py-1.5 font-mono text-[11px] text-text-dim shrink-0`,children:[(0,A.jsx)(`span`,{className:`text-text`,children:`box`}),` `,Math.round(t.width),` x `,Math.round(t.height),` @ `,Math.round(t.x),`, `,Math.round(t.y),(0,A.jsx)(`span`,{className:`mx-2 text-border-subtle`,children:`|`}),r.join(` / `),(0,A.jsx)(`span`,{className:`mx-2 text-border-subtle`,children:`|`}),`font `,n.fontSize]})}function Wa({tree:e,onInspectElement:t,onClearInspection:n,isRuntimeRunning:r=!0}){let[i,a]=(0,k.useState)(null),o=(0,k.useRef)(0),s=(0,k.useRef)(null);(0,k.useEffect)(()=>()=>{s.current!==null&&cancelAnimationFrame(s.current)},[]);let c=(0,k.useCallback)(e=>{if(!e.sid||!t)return;let n=e.sid;s.current!==null&&cancelAnimationFrame(s.current),s.current=requestAnimationFrame(()=>{s.current=null;let e=++o.current;t(n).then(t=>{e===o.current&&a(t)}).catch(()=>{e===o.current&&a(null)})})},[t]),l=(0,k.useCallback)(()=>{s.current!==null&&(cancelAnimationFrame(s.current),s.current=null),o.current++,a(null),n?.()},[n]);return e?(0,A.jsxs)(`div`,{className:`flex flex-col flex-1 overflow-hidden`,onMouseLeave:l,"data-testid":`wxml-panel`,children:[(0,A.jsx)(`div`,{className:`flex-1 overflow-y-auto p-2 font-mono text-[12px]`,children:(0,A.jsx)(Ha,{node:e,depth:0,inspectedSid:i?.sid??null,onInspect:c})}),(0,A.jsx)(Ua,{inspection:i})]}):(0,A.jsx)(`div`,{className:`flex flex-col flex-1 overflow-hidden`,"data-testid":`wxml-panel`,children:(0,A.jsx)(`div`,{className:`text-[12px] text-text-dim text-center px-4 py-6`,children:r?`等待小程序加载...`:`小程序未运行`})})}function Ga(e){let{source:t,enabled:n,active:r}=e,i=(0,k.useRef)({subscribe:e.subscribe,seed:e.seed});(0,k.useEffect)(()=>{i.current={subscribe:e.subscribe,seed:e.seed}}),(0,k.useEffect)(()=>{if(!n)return;let e=i.current.subscribe(t);return()=>{e(),t.setActive(!1)}},[t,n]),(0,k.useEffect)(()=>{n&&t.setActive(r)},[t,n,r]);let a=(0,k.useRef)({source:null,on:!1});(0,k.useEffect)(()=>{let e=n&&r,o=a.current,s=e&&(!o.on||o.source!==t);if(a.current={source:t,on:e},!s)return;let c=!1;return i.current.seed(t,()=>c),()=>{c=!0}},[t,n,r])}function Ka({source:e,active:t=!0,enabled:n=!0,isRuntimeRunning:r=!0}){let[i,a]=(0,k.useState)(null);return Ga({source:e,enabled:n,active:t,subscribe:e=>e.subscribe(a),seed:(e,t)=>{e.getSnapshot().then(e=>{t()||a(e)})}}),(0,A.jsx)(Wa,{tree:i,onInspectElement:t=>e.inspect(t),onClearInspection:async()=>{await e.clearInspection()},isRuntimeRunning:r})}var qa=`inline-flex items-center justify-center gap-1.5 font-medium transition-colors focus:outline-none disabled:opacity-35 disabled:cursor-not-allowed whitespace-nowrap shrink-0 border border-border text-text-muted hover:text-text rounded h-5 px-2 text-[11px]`;function Ja({items:e,onSet:t,onRemove:n,onClear:r,onClearAll:i,getPrefix:a,isRuntimeRunning:o=!0}){let[s,c]=(0,k.useState)(null),[l,u]=(0,k.useState)(null),[d,f]=(0,k.useState)(!1),[p,m]=(0,k.useState)(``),[h,g]=(0,k.useState)(``),[_,v]=(0,k.useState)(``);(0,k.useEffect)(()=>{let e=!1,t,n=()=>{a().then(r=>{if(!e){if(r){m(r);return}t=setTimeout(n,300)}})};return n(),()=>{e=!0,t&&clearTimeout(t)}},[a]);async function y(e){f(!0),u(null);try{let t=await e();return t.ok?t:(u(t.error),null)}finally{f(!1)}}function b(e){c({key:e.key,draft:e.value})}async function x(){if(!s)return;let{key:e,draft:n}=s;c(null),await y(()=>t(e,n))}async function S(e){await y(()=>n(e))}async function C(){e.length!==0&&await y(()=>r())}async function w(){i&&(typeof window<`u`&&!window.confirm(`清空所有 appId 的 Storage 数据?该操作不可撤销。`)||await y(()=>i()))}async function T(){let e=h.trim();if(!e){u(`key 不能为空`);return}let n=p+e;await y(()=>t(n,_))&&(g(``),v(``))}return(0,A.jsxs)(`div`,{className:`flex flex-col overflow-hidden flex-1`,"data-testid":`storage-panel`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 py-1.5 border-b border-border-subtle shrink-0 bg-bg-panel`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>void C(),disabled:d||e.length===0,className:`${qa} hover:border-status-error hover:text-status-error`,title:`仅清空当前 appId 的 Storage`,children:`清空`}),i&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>void w(),disabled:d,className:`${qa} hover:border-status-error hover:text-status-error`,title:`清空所有 appId 的 Storage`,children:`清空所有`}),l&&(0,A.jsx)(`span`,{className:`ml-2 text-[11px] text-status-error truncate`,title:l,children:l})]}),(0,A.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,A.jsxs)(`table`,{className:`w-full border-collapse text-[12px]`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{children:[(0,A.jsx)(`th`,{className:`text-left text-code-label font-normal px-2.5 py-1 border-b border-border-subtle text-[11px] sticky top-0 bg-bg-panel z-10 w-px pr-5`,children:`Key`}),(0,A.jsx)(`th`,{className:`text-left text-code-label font-normal px-2.5 py-1 border-b border-border-subtle text-[11px] sticky top-0 bg-bg-panel z-10`,children:`Value`}),(0,A.jsx)(`th`,{className:`w-px sticky top-0 bg-bg-panel z-10 border-b border-border-subtle`})]})}),(0,A.jsx)(`tbody`,{children:e.length===0?(0,A.jsx)(`tr`,{children:(0,A.jsx)(`td`,{colSpan:3,className:`text-[12px] text-text-dim text-center px-4 py-6`,children:o?`暂无 Storage 数据`:`小程序未运行`})}):e.map(e=>{let t=s?.key===e.key,n=p&&e.key.startsWith(p)?e.key.slice(p.length):e.key;return(0,A.jsxs)(`tr`,{className:`hover:[&>td]:bg-surface`,children:[(0,A.jsx)(`td`,{className:`px-2.5 py-0.5 border-b border-border-subtle w-px pr-5 align-top`,children:(0,A.jsx)(`div`,{className:`font-mono text-code-blue max-w-[240px] truncate`,title:e.key,children:n})}),(0,A.jsx)(`td`,{className:`px-2.5 py-0.5 border-b border-border-subtle font-mono text-code-orange break-all align-top cursor-text`,onClick:()=>{t||b(e)},children:t?(0,A.jsx)(`input`,{autoFocus:!0,type:`text`,value:s.draft,onChange:t=>c({key:e.key,draft:t.target.value}),onBlur:()=>void x(),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),x()):e.key===`Escape`&&(e.preventDefault(),c(null))},className:`w-full bg-transparent outline-none border border-accent/60 rounded px-1 py-0 font-mono text-code-orange`}):e.value}),(0,A.jsx)(`td`,{className:`px-1 py-0.5 border-b border-border-subtle align-top`,children:(0,A.jsx)(`button`,{type:`button`,onClick:()=>void S(e.key),disabled:d,title:`删除`,className:`text-text-dim hover:text-status-error px-1 leading-none`,children:`×`})})]},e.key)})})]})}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 py-1.5 border-t border-border-subtle shrink-0 bg-bg-panel`,children:[(0,A.jsx)(`input`,{type:`text`,placeholder:`key`,value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T())},className:`w-32 bg-transparent border border-border-subtle rounded px-1.5 py-0.5 text-[12px] font-mono outline-none focus:border-accent`}),(0,A.jsx)(`input`,{type:`text`,placeholder:`value`,value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T())},className:`flex-1 bg-transparent border border-border-subtle rounded px-1.5 py-0.5 text-[12px] font-mono outline-none focus:border-accent`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>void T(),disabled:d||!h.trim(),className:`${qa} hover:border-accent hover:text-accent`,children:`+ 新增`})]})]})}function Ya(e,t){switch(t.type){case`added`:case`updated`:{let n=e.findIndex(e=>e.key===t.key);if(n<0)return[...e,{key:t.key,value:t.newValue}];let r=[...e];return r[n]={key:t.key,value:t.newValue},r}case`removed`:return e.filter(e=>e.key!==t.key);case`cleared`:return[]}}function Xa({source:e,active:t=!0,enabled:n=!0,isRuntimeRunning:r=!0}){let[i,a]=(0,k.useState)([]);Ga({source:e,enabled:n,active:t,subscribe:e=>e.subscribe(e=>{a(t=>Ya(t,e))}),seed:(e,t)=>{e.getSnapshot().then(e=>{t()||a(e)})}});let o=e.clearAll?.bind(e);return(0,A.jsx)(Ja,{items:i,onSet:(t,n)=>e.setItem(t,n),onRemove:t=>e.removeItem(t),onClear:()=>e.clear(),onClearAll:o,getPrefix:()=>e.getPrefix(),isRuntimeRunning:r})}function Za(e,t){return typeof t==`number`?`${e}[${t}]`:e===``?t:`${e}.${t}`}function Qa(e){return typeof e==`object`&&!!e}function $a(e){return Array.isArray(e)?e.map((e,t)=>[t,e]):Object.keys(e).sort().map(t=>[t,e[t]])}function eo(e){return Array.isArray(e)?`[${e.length}]`:`{${Object.keys(e).length}}`}var to=``;function no(e,t){let n=e.overrides.get(t);return n===void 0?e.baseline===`expanded`?!0:e.baseline===`collapsed`?!1:t===to:n}function ro({path:e,value:t,editable:n,ctx:r}){if(typeof t==`boolean`)return(0,A.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-code-keyword`,children:[n&&(0,A.jsx)(`input`,{type:`checkbox`,checked:t,onChange:()=>r.onCommit?.(e,!t,t),className:`accent-accent`}),String(t)]});if(t==null)return(0,A.jsx)(`span`,{className:`text-code-keyword`,children:String(t)});if(r.state.editingPath===e){let n=()=>{let n=t;if(typeof n==`number`){let t=r.state.draft.trim(),i=Number(t);if(r.endEdit(),t===``||!Number.isFinite(i))return;r.onCommit?.(e,i,n);return}let i=r.state.draft;r.endEdit(),r.onCommit?.(e,i,n)};return(0,A.jsx)(`input`,{type:`text`,autoFocus:!0,value:r.state.draft,onChange:e=>r.setDraft(e.target.value),onKeyDown:e=>{e.key===`Enter`?n():e.key===`Escape`&&r.endEdit()},onBlur:n,className:`bg-surface-3 border border-accent rounded px-1 text-[12px] font-mono min-w-0 w-40`})}return(0,A.jsx)(`span`,{"data-testid":`appdata-value`,className:typeof t==`string`?`text-code-orange`:void 0,style:typeof t==`number`?{color:`var(--color-code-number)`}:void 0,onDoubleClick:n?()=>r.beginEdit(e,String(t)):void 0,children:String(t)})}function io(e){return typeof e==`string`&&(e===``||/[.[\]]/.test(e))}function ao({path:e,label:t,value:n,depth:r,unsafeSegments:i,ctx:a}){let o={paddingLeft:r*14};if(Qa(n)){let s=no(a.state,e);return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-px cursor-pointer hover:bg-surface-3 text-[12px] font-mono`,style:o,onClick:()=>a.toggle(e,n),children:[(0,A.jsx)(`span`,{className:`text-text-secondary w-3 shrink-0 text-center select-none`,children:s?`▾`:`▸`}),(0,A.jsx)(`span`,{className:`text-code-blue`,children:t}),(0,A.jsx)(`span`,{className:`text-text-secondary`,children:eo(n)})]}),s&&$a(n).map(([t,n])=>(0,A.jsx)(ao,{path:Za(e,t),label:String(t),value:n,depth:r+1,unsafeSegments:i||io(t),ctx:a},String(t)))]})}let s=typeof n==`string`||typeof n==`number`||typeof n==`boolean`,c=r>1&&i||t===`__proto__`,l=s&&a.onCommit!==void 0&&!c;return(0,A.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-px text-[12px] font-mono`,style:o,...l?{"data-path":e}:{},children:[(0,A.jsx)(`span`,{className:`w-3 shrink-0`}),(0,A.jsx)(`span`,{className:`text-code-blue`,children:t}),(0,A.jsx)(`span`,{className:`text-text-secondary`,children:`:`}),(0,A.jsx)(ro,{path:e,value:n,editable:l,ctx:a})]})}function oo({root:e,bridgeId:t,command:n,onCommit:r}){let[i,a]=(0,k.useState)(`default`),[o,s]=(0,k.useState)(new Map),[c,l]=(0,k.useState)(0),[u,d]=(0,k.useState)(null),[f,p]=(0,k.useState)(``);n&&n.bridgeId===t&&n.seq!==c&&(a(n.mode),s(new Map),l(n.seq));let m={baseline:i,overrides:o,editingPath:u,draft:f};return(0,A.jsx)(`div`,{"data-testid":`appdata-tree`,className:`py-1`,children:(0,A.jsx)(ao,{path:to,label:`object`,value:e,depth:0,unsafeSegments:!1,ctx:{state:m,toggle:(e,t)=>{let n=new Map(o),r=!no(m,e);n.set(e,r),r&&Array.isArray(t)&&t.forEach((t,r)=>{Qa(t)&&n.set(Za(e,r),!0)}),s(n)},beginEdit:(e,t)=>{d(e),p(t)},setDraft:p,endEdit:()=>d(null),onCommit:r}})})}function so(e){return e.pagePath??e.id}function co(e){return e!=null&&(typeof e==`object`||typeof e==`function`)&&typeof e.then==`function`}function lo(e){let t={};for(let n of Object.keys(e)){let r=e[n];if(!(!r||typeof r!=`object`))for(let e of Object.keys(r))Object.defineProperty(t,e,{value:r[e],enumerable:!0,writable:!0,configurable:!0})}return t}function uo({title:e,disabled:t,onClick:n,children:r}){return(0,A.jsx)(`button`,{title:e,disabled:t,onClick:n,className:`px-1.5 py-0.5 text-[12px] rounded text-text-secondary hover:bg-surface-3 hover:text-text-primary disabled:opacity-40 disabled:hover:bg-transparent`,children:r})}function fo({state:e,onSelectBridge:t,isRuntimeRunning:n=!0,onSetData:r}){let{bridges:i,activeBridgeId:a,entries:o}=e,[s,c]=(0,k.useState)(null),[l,u]=(0,k.useState)([]),[d,f]=(0,k.useState)([]),p=(0,k.useRef)(!1),[m,h]=(0,k.useState)(!1),g=n?`暂无页面数据(仅显示 Page 级 data)`:`小程序未运行`,_=e=>{a&&c({seq:(s?.seq??0)+1,mode:e,bridgeId:a})},v=(e,t,n)=>{let i;try{i=r?.(e,t)}catch{n(!1);return}if(co(i)){Promise.resolve(i).then(e=>e!==!1,()=>!1).then(n);return}n(i!==!1)},y=(e,t,n)=>{p.current||(p.current=!0,h(!0),v(e,t,e=>{p.current=!1,h(!1),n(e)}))},b=e=>(t,n,r)=>{y(e,{[t]:n},i=>{i&&(u(i=>[...i,{bridgeId:e,path:t,before:r,after:n}]),f([]))})},x=e=>i.some(t=>t.id===e),S=(e,t,n)=>{y(e.bridgeId,{[e.path]:t},t=>{t&&n(e)})};return i.length===0?(0,A.jsx)(`div`,{className:`flex flex-col overflow-hidden flex-1`,"data-testid":`appdata-panel`,children:(0,A.jsx)(`div`,{className:`text-[12px] text-text-dim text-center px-4 py-6`,children:g})}):(0,A.jsxs)(`div`,{className:`flex overflow-hidden flex-1`,"data-testid":`appdata-panel`,children:[(0,A.jsxs)(`div`,{"data-testid":`appdata-pages`,className:`w-40 shrink-0 border-r border-border-subtle bg-bg-panel flex flex-col overflow-hidden`,children:[(0,A.jsx)(`div`,{className:`px-2 py-1 text-[11px] text-text-secondary border-b border-border-subtle shrink-0`,children:`Pages`}),(0,A.jsx)(`div`,{className:`flex-1 overflow-y-auto`,role:`listbox`,children:i.map(e=>{let n=e.id===a;return(0,A.jsx)(`button`,{"data-testid":`appdata-page-item`,role:`option`,"aria-selected":n,title:e.id,onClick:()=>t(e.id),className:`block w-full text-left px-2 py-1 text-[11px] truncate `+(n?`bg-accent/20 text-accent`:`text-text-dim hover:bg-surface-3`),children:so(e)},e.id)})})]}),(0,A.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,A.jsxs)(`div`,{"data-testid":`appdata-toolbar`,className:`flex items-center gap-1 px-2 py-0.5 border-b border-border-subtle shrink-0 bg-bg-panel`,children:[(0,A.jsx)(uo,{title:`全部展开`,onClick:()=>_(`expanded`),children:`⊕`}),(0,A.jsx)(uo,{title:`全部收起`,onClick:()=>_(`collapsed`),children:`⊖`}),(0,A.jsx)(uo,{title:`撤销`,disabled:l.length===0||m,onClick:()=>{let e=l.at(-1);if(e){if(!x(e.bridgeId)){u(t=>t.filter(t=>t!==e));return}S(e,e.before,e=>{u(t=>t.filter(t=>t!==e)),f(t=>[...t,e])})}},children:`↶`}),(0,A.jsx)(uo,{title:`重做`,disabled:d.length===0||m,onClick:()=>{let e=d.at(-1);if(e){if(!x(e.bridgeId)){f(t=>t.filter(t=>t!==e));return}S(e,e.after,e=>{f(t=>t.filter(t=>t!==e)),u(t=>[...t,e])})}},children:`↷`})]}),(0,A.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:i.map(e=>{let t=e.id===a,n=o[e.id]??{},i=Object.keys(n).length>0;return(0,A.jsx)(`div`,{"data-bridge-id":e.id,className:`absolute inset-0 flex-col overflow-y-auto`,style:{display:t?`flex`:`none`},children:i?(0,A.jsx)(oo,{root:lo(n),bridgeId:e.id,command:s,onCommit:r?b(e.id):void 0}):(0,A.jsx)(`div`,{className:`text-[12px] text-text-dim text-center px-4 py-6`,children:g})},e.id)})})]})]})}function po(e){return(e??``).replace(/^\/+/,``)}function mo(e,t=``){let n=e.map(e=>e.id),r=n.join(`\0`),[i,a]=(0,k.useState)(null),[o,s]=(0,k.useState)(``),[c,l]=(0,k.useState)(t);if(r!==o){let e=o?o.split(`\0`):[];n.some(t=>!e.includes(t))&&a(null),s(r)}t!==c&&(a(null),l(t));let u=t?e.find(e=>po(e.pagePath)===po(t))?.id??null:null;return{activeBridgeId:i&&n.includes(i)?i:u??n.at(-1)??null,setActiveBridge:e=>{n.includes(e)&&a(e)}}}var ho={bridges:[],entries:{}};function go({source:e,active:t=!0,enabled:n=!0,isRuntimeRunning:r=!0,activePagePath:i=``}){let[a,o]=(0,k.useState)(ho);Ga({source:e,enabled:n,active:t,subscribe:e=>e.subscribe(e=>{o(e)}),seed:(e,t)=>{e.getSnapshot().then(e=>{t()||o(e)})}});let{activeBridgeId:s,setActiveBridge:c}=mo(a.bridges,i),l=e.setData?.bind(e),u=l?(e,t)=>l(e,t):void 0;return(0,A.jsx)(fo,{state:{bridges:a.bridges,activeBridgeId:s,entries:a.entries},onSelectBridge:c,isRuntimeRunning:r,onSetData:u})}function _o(...e){return e.filter(Boolean).join(` `)}function vo(e){let t=new Date(e);return[t.getHours(),t.getMinutes(),t.getSeconds()].map(e=>String(e).padStart(2,`0`)).join(`:`)}function yo(e){return e===`error`?`text-red-500`:e===`compiling`?`text-amber-500`:e===`ready`?`text-emerald-600`:`text-text-muted`}function bo(e){return e.kind===`event`?e.event.message:e.log.text}function xo({events:e,logs:t=[],onClear:n}){let r=e.length>0?e[e.length-1]:null,[i,a]=(0,k.useState)(``),o=(0,k.useRef)(null),s=(0,k.useRef)(null),c=(0,k.useRef)(!0);(0,k.useEffect)(()=>{let e=o.current;if(!e)return;let t=()=>{let{scrollTop:t,scrollHeight:n,clientHeight:r}=e;c.current=n-t-r<30};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[]),(0,k.useEffect)(()=>{c.current&&s.current?.scrollIntoView?.({behavior:`auto`})},[e.length+t.length]);let l=(0,k.useMemo)(()=>{let n=[];e.forEach((t,r)=>{let i=r>0?e[r-1]:null,a=t.status===`ready`&&i?.status===`compiling`?t.at-i.at:null;n.push({kind:`event`,at:t.at,seq:t.seq,event:t,durationMs:a})});for(let e of t)n.push({kind:`log`,at:e.at,seq:e.seq,log:e});return n.sort((e,t)=>e.at===t.at?e.seq!==void 0&&t.seq!==void 0?e.seq-t.seq:0:e.at-t.at)},[e,t]),u=(0,k.useMemo)(()=>{if(!i)return l;let e=i.toLowerCase();return l.filter(t=>bo(t).toLowerCase().includes(e))},[l,i]),d=e.length===0&&t.length===0;return(0,A.jsxs)(`div`,{className:`flex flex-col h-full w-full min-h-0 text-[12px]`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 px-2 h-8 shrink-0 border-b border-border-subtle`,children:[r?(0,A.jsx)(`span`,{"data-compile-current":!0,"data-status":r.status,className:_o(`truncate font-medium shrink-0`,yo(r.status)),children:r.message}):(0,A.jsx)(`span`,{className:`text-text-muted shrink-0`,children:`编译信息`}),(0,A.jsx)(`div`,{className:`flex-1 min-w-0`}),(0,A.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`过滤...`,className:`h-6 px-2 text-[12px] rounded-sm border border-border-subtle bg-surface
2
2
  text-text placeholder:text-text-dim
3
3
  focus:outline-none focus:border-text-muted
4
4
  w-40 shrink-0`}),i&&(0,A.jsxs)(`span`,{className:`text-[11px] text-text-muted tabular-nums shrink-0`,children:[u.length,`/`,l.length]}),(0,A.jsx)(`button`,{type:`button`,onClick:n,className:`px-2 h-6 rounded-sm text-text-muted hover:text-text hover:bg-surface-2 transition-colors shrink-0`,children:`清空`})]}),(0,A.jsx)(`div`,{ref:o,className:`flex-1 min-h-0 overflow-auto`,children:d?(0,A.jsx)(`div`,{className:`flex items-center justify-center h-full text-text-muted`,children:`暂无编译信息`}):u.length===0?(0,A.jsx)(`div`,{className:`flex items-center justify-center h-full text-text-muted`,children:`无匹配日志`}):(0,A.jsxs)(`ul`,{className:`px-2 py-1 space-y-0.5`,children:[u.map((e,t)=>e.kind===`event`?(0,A.jsxs)(`li`,{"data-compile-row":!0,"data-status":e.event.status,className:`flex items-baseline gap-2 leading-5`,children:[(0,A.jsx)(`span`,{className:`text-text-muted tabular-nums shrink-0`,children:vo(e.at)}),(0,A.jsx)(`span`,{className:_o(`break-all`,yo(e.event.status)),children:e.event.message}),e.event.hotReload===!0&&(0,A.jsx)(`span`,{className:`shrink-0 px-1 rounded-sm bg-surface-2 text-text-muted`,children:`已重启`}),e.durationMs!==null&&(0,A.jsxs)(`span`,{"data-compile-duration":!0,className:`shrink-0 text-text-muted tabular-nums`,children:[(e.durationMs/1e3).toFixed(1),`s`]})]},`e-${e.at}-${t}`):(0,A.jsxs)(`li`,{"data-compile-log":!0,"data-stream":e.log.stream,className:`flex items-baseline gap-2 leading-5`,children:[(0,A.jsx)(`span`,{className:`text-text-muted tabular-nums shrink-0`,children:vo(e.at)}),(0,A.jsx)(`span`,{className:_o(`break-all font-mono`,e.log.stream===`stderr`?`text-red-500`:`text-text`),children:e.log.text})]},`l-${e.at}-${t}`)),(0,A.jsx)(`div`,{ref:s})]})})]})}function So(e){let{tabId:t,wxmlSource:n,wxmlEnabled:r=!0,storageSource:i,storageEnabled:a=!0,appDataSource:o,appDataEnabled:s=!0,activePagePath:c,tabActive:l=!0,compileEvents:u=[],compileLogs:d=[],onClearCompileEvents:f,isRuntimeRunning:p=!0}=e;switch(t){case`wxml`:return(0,A.jsx)(Ka,{source:n,enabled:r,active:l,isRuntimeRunning:p});case`appdata`:return(0,A.jsx)(go,{source:o,enabled:s,active:l,isRuntimeRunning:p,activePagePath:c});case`storage`:return(0,A.jsx)(Xa,{source:i,enabled:a,active:l,isRuntimeRunning:p});case`compile`:return(0,A.jsx)(xo,{events:u,logs:d,onClear:f??(()=>{})})}}function Co(e){let t=e.requestFrame??(e=>requestAnimationFrame(e)),n=e.cancelFrame??(e=>cancelAnimationFrame(e)),r=typeof e.generation==`function`?e.generation:()=>e.generation,i=new Map,a=!1,o=null,s=0,c=!1;function l(){c||o!==null||(o=t(u))}function u(){o=null,!(c||!a)&&(a=!1,e.publish({generation:r(),epoch:s++,views:[...i.values()]}))}return{set(e){c||(i.set(e.viewId,e),a=!0,l())},remove(e){c||i.delete(e)&&(a=!0,l())},dispose(){c||(c=!0,o!==null&&(n(o),o=null),e.publish({generation:r(),epoch:s++,views:[]}))}}}var wo=0,To=new Set([`simulator`,`editor`,`wxml`,`appdata`,`storage`,`console`,`compile`]);function Eo({project:e}){let t=(0,k.useRef)(null),[n,r]=(0,k.useState)(!1),{session:i,device:a,simulator:o,panelData:s,rightPane:c,popover:l}=Tt({projectPath:e.path}),u=At(),{state:d}=u,[f]=(0,k.useState)(()=>An(d.dockTree??null,a.simPanelWidth,To)),p=(0,k.useMemo)(()=>Sn(),[]),[m]=(0,k.useState)(()=>++wo),h=(0,k.useMemo)(()=>Co({generation:m,publish:e=>{oe(e)}}),[m]);(0,k.useEffect)(()=>()=>h.dispose(),[h]);let[g,_]=(0,k.useState)(0);(0,k.useEffect)(()=>{let e=!1,t=ae(t=>{e=!0,_(t)});return se().then(t=>{e||typeof t==`number`&&_(t)}),t},[]);let v=or({present:g>0,publish:e=>{let t=g>0&&e.width>0&&e.height>0;h.set({viewId:I.hostToolbar,placement:t?{visible:!0,bounds:e}:{visible:!1},layer:lr.hostToolbar})},deps:[g,h]});(0,k.useEffect)(()=>{let t=`Dimina DevTools`;return document.title=`${e.name} - ${t}`,Pe().then(n=>{n?.appName&&(t=n.appName,document.title=`${e.name} - ${t}`)}).catch(()=>{}),()=>{document.title=t}},[e.name]),(0,k.useEffect)(()=>()=>{t.current!==null&&window.clearTimeout(t.current)},[]);async function y(){if(o.currentPage)try{await navigator.clipboard.writeText(o.currentPage),r(!0),t.current!==null&&window.clearTimeout(t.current),t.current=window.setTimeout(()=>r(!1),de)}catch{r(!1)}}let b={rightPane:c.rightPane,onSelectTab:c.selectRightPane,wxmlSource:s.wxmlSource,wxmlEnabled:s.wxmlEnabled,storageSource:s.storageSource,storageEnabled:s.storageEnabled,appDataSource:s.appDataSource,appDataEnabled:s.appDataEnabled,activePagePath:o.currentPage,compileEvents:i.compileEvents,compileLogs:i.compileLogs,onClearCompileEvents:i.clearCompileEvents,isRuntimeRunning:i.runtimeStatus?.phase===`running`};return(0,A.jsx)(sr.Provider,{value:h,children:(0,A.jsxs)(`div`,{className:`flex flex-col h-screen`,children:[(0,A.jsx)(`div`,{ref:v,style:{height:g},className:`shrink-0 w-full`,"data-area":`host-toolbar`}),(0,A.jsx)($n,{compileDropdownRef:l.compileDropdownRef,showCompilePanel:l.showCompilePanel,onToggleCompilePanel:l.toggleCompilePanel,onRelaunch:()=>i.relaunch(),compileStatus:i.compileStatus,dockModel:f,dockRegistry:p,layout:u,simPanelWidth:a.simPanelWidth}),(0,A.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:(0,A.jsx)(jo,{dockModel:f,dockRegistry:p,simPanelWidth:a.simPanelWidth,renderDomPanel:(e,t)=>e===`simulator`?(0,A.jsx)(Ma,{device:a.device,zoom:a.zoom,onDeviceChange:a.handleDeviceChange,onZoomChange:a.handleZoomChange,compileStatus:i.compileStatus,currentPage:o.currentPage,copied:n,onCopyPagePath:y,runtimeStatus:i.runtimeStatus,watcherDead:i.watcherDead,onRelaunch:()=>i.relaunch(),onOpenInternalDevtools:()=>{Qe()}}):e===`editor`?(0,A.jsx)(Na,{}):e===`wxml`||e===`appdata`||e===`storage`||e===`compile`?(0,A.jsx)(Ao,{tabId:e,active:t.active,panelProps:b}):null,onPersistTree:u.setDockTree,persistedTree:d.dockTree??null})})]})})}function Do(e){return e.kind===`tabs`?e.panels.includes(`simulator`):e.children.some(Do)}function Oo(e,t){function n(e){if(e.kind===`tabs`)return null;if(e.id===t.splitId)return(e.constraints?.[t.childIndex]??null)?.minPx??null;for(let t of e.children){let e=n(t);if(e!==null)return e}return null}return n(e)}function ko(e){if(e.kind===`tabs`)return null;for(let t=0;t<e.children.length;t++){let n=e.children[t];if((e.constraints?.[t]??null)!==null&&Do(n))return{splitId:e.id,childIndex:t};let r=ko(n);if(r)return r}return null}function Ao({tabId:e,active:t,panelProps:n}){return(0,A.jsx)(So,{tabId:e,...n,tabActive:t})}function jo(e){let{dockModel:t,dockRegistry:n,simPanelWidth:r,renderDomPanel:i,onPersistTree:a,persistedTree:o}=e,s=(0,k.useRef)(null),c=cr(),l=(0,k.useCallback)(e=>{c?.set({viewId:I.simulatorDevtools,placement:e,layer:lr.base})},[c]),u=(0,k.useCallback)((e,t,n)=>{if(e.current){t?(e.current.dispose(),e.current=ar(t,{visible:!0,guardDisplayNone:!0,followScroll:!0,followGeometry:!0,publish:n})):(e.current.update({visible:!1,publish:n}),e.current.dispose(),e.current=null);return}t&&(e.current=ar(t,{visible:!0,guardDisplayNone:!0,followScroll:!0,followGeometry:!0,publish:n}))},[]),d=(0,k.useCallback)((e,t)=>{e===`console`&&u(s,t,l)},[u,l]);return(0,k.useEffect)(()=>{let e=t.get().root,n=ko(e);n&&Oo(e,n)!==r&&t.apply(e=>{let t=ko(e.root);return!t||Oo(e.root,t)===r?e:ln(e,t.splitId,t.childIndex,{minPx:r})})},[t,r]),(0,k.useEffect)(()=>()=>{s.current?.dispose(),s.current=null,c?.remove(I.simulatorDevtools)},[c]),(0,k.useEffect)(()=>t.subscribe(e=>{a(Ft(e.tree))}),[t,a]),(0,k.useEffect)(()=>{let e=Ft(t.get());e!==o&&a(e)},[]),(0,A.jsx)(Ca,{model:t,registry:n,renderDomPanel:i,bindNativeSlot:d,onActiveTabClick:(0,k.useCallback)(e=>{e===`simulator`||e===`editor`||t.apply(t=>xn(t,e,n))},[t,n])})}typeof window<`u`&&window.document&&window.document.createElement;function Y(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function Mo(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function No(...e){return t=>{let n=!1,r=e.map(e=>{let r=Mo(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():Mo(e[t],null)}}}}function Po(...e){return k.useCallback(No(...e),e)}function Fo(e,t){let n=k.createContext(t),r=e=>{let{children:t,...r}=e,i=k.useMemo(()=>r,Object.values(r));return(0,A.jsx)(n.Provider,{value:i,children:t})};r.displayName=e+`Provider`;function i(r){let i=k.useContext(n);if(i)return i;if(t!==void 0)return t;throw Error(`\`${r}\` must be used within \`${e}\``)}return[r,i]}function Io(e,t=[]){let n=[];function r(t,r){let i=k.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=k.useMemo(()=>o,Object.values(o));return(0,A.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=k.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>k.createContext(e));return function(n){let r=n?.[e]||t;return k.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,Lo(i,...t)]}function Lo(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return k.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}var Ro=globalThis?.document?k.useLayoutEffect:()=>{},zo=k.useId||(()=>void 0),Bo=0;function Vo(e){let[t,n]=k.useState(zo());return Ro(()=>{e||n(e=>e??String(Bo++))},[e]),e||(t?`radix-${t}`:``)}var Ho=k.useInsertionEffect||Ro;function Uo({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=Wo({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=k.useRef(e!==void 0);k.useEffect(()=>{let e=t.current;e!==s&&console.warn(`${r} is changing from ${e?`controlled`:`uncontrolled`} to ${s?`controlled`:`uncontrolled`}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),t.current=s},[s,r])}return[c,k.useCallback(t=>{if(s){let n=Go(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function Wo({defaultProp:e,onChange:t}){let[n,r]=k.useState(e),i=k.useRef(n),a=k.useRef(t);return Ho(()=>{a.current=t},[t]),k.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function Go(e){return typeof e==`function`}var Ko=t(v(),1);function qo(e){let t=Jo(e),n=k.forwardRef((e,n)=>{let{children:r,...i}=e,a=k.Children.toArray(r),o=a.find(Xo);if(o){let e=o.props.children,r=a.map(t=>t===o?k.Children.count(e)>1?k.Children.only(null):k.isValidElement(e)?e.props.children:null:t);return(0,A.jsx)(t,{...i,ref:n,children:k.isValidElement(e)?k.cloneElement(e,void 0,r):null})}return(0,A.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function Jo(e){let t=k.forwardRef((e,t)=>{let{children:n,...r}=e;if(k.isValidElement(n)){let e=Qo(n),i=Zo(r,n.props);return n.type!==k.Fragment&&(i.ref=t?No(t,e):e),k.cloneElement(n,i)}return k.Children.count(n)>1?k.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Yo=Symbol(`radix.slottable`);function Xo(e){return k.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Yo}function Zo(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function Qo(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var X=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=qo(`Primitive.${t}`),r=k.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,A.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function $o(e,t){e&&Ko.flushSync(()=>e.dispatchEvent(t))}function es(e){let t=k.useRef(e);return k.useEffect(()=>{t.current=e}),k.useMemo(()=>(...e)=>t.current?.(...e),[])}function ts(e,t=globalThis?.document){let n=es(e);k.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var ns=`DismissableLayer`,rs=`dismissableLayer.update`,is=`dismissableLayer.pointerDownOutside`,as=`dismissableLayer.focusOutside`,os,ss=k.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),cs=k.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:s,...c}=e,l=k.useContext(ss),[u,d]=k.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=k.useState({}),m=Po(t,e=>d(e)),h=Array.from(l.layers),[g]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),_=h.indexOf(g),v=u?h.indexOf(u):-1,y=l.layersWithOutsidePointerEventsDisabled.size>0,b=v>=_,x=ds(e=>{let t=e.target,n=[...l.branches].some(e=>e.contains(t));!b||n||(i?.(e),o?.(e),e.defaultPrevented||s?.())},f),S=fs(e=>{let t=e.target;[...l.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||s?.())},f);return ts(e=>{v===l.layers.size-1&&(r?.(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},f),k.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(os=f.body.style.pointerEvents,f.body.style.pointerEvents=`none`),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),ps(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=os)}},[u,f,n,l]),k.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),ps())},[u,l]),k.useEffect(()=>{let e=()=>p({});return document.addEventListener(rs,e),()=>document.removeEventListener(rs,e)},[]),(0,A.jsx)(X.div,{...c,ref:m,style:{pointerEvents:y?b?`auto`:`none`:void 0,...e.style},onFocusCapture:Y(e.onFocusCapture,S.onFocusCapture),onBlurCapture:Y(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:Y(e.onPointerDownCapture,x.onPointerDownCapture)})});cs.displayName=ns;var ls=`DismissableLayerBranch`,us=k.forwardRef((e,t)=>{let n=k.useContext(ss),r=k.useRef(null),i=Po(t,r);return k.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,A.jsx)(X.div,{...e,ref:i})});us.displayName=ls;function ds(e,t=globalThis?.document){let n=es(e),r=k.useRef(!1),i=k.useRef(()=>{});return k.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){ms(is,n,a,{discrete:!0})},a={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,i.current),i.current=r,t.addEventListener(`click`,i.current,{once:!0})):r()}else t.removeEventListener(`click`,i.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(a),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function fs(e,t=globalThis?.document){let n=es(e),r=k.useRef(!1);return k.useEffect(()=>{let e=e=>{e.target&&!r.current&&ms(as,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function ps(){let e=new CustomEvent(rs);document.dispatchEvent(e)}function ms(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?$o(i,a):i.dispatchEvent(a)}var hs=`focusScope.autoFocusOnMount`,gs=`focusScope.autoFocusOnUnmount`,_s={bubbles:!1,cancelable:!0},vs=`FocusScope`,ys=k.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=k.useState(null),l=es(i),u=es(a),d=k.useRef(null),f=Po(t,e=>c(e)),p=k.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;k.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:Z(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||Z(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&Z(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),k.useEffect(()=>{if(s){Es.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(hs,_s);s.addEventListener(hs,l),s.dispatchEvent(t),t.defaultPrevented||(bs(ks(Ss(s)),{select:!0}),document.activeElement===e&&Z(s))}return()=>{s.removeEventListener(hs,l),setTimeout(()=>{let t=new CustomEvent(gs,_s);s.addEventListener(gs,u),s.dispatchEvent(t),t.defaultPrevented||Z(e??document.body,{select:!0}),s.removeEventListener(gs,u),Es.remove(p)},0)}}},[s,l,u,p]);let m=k.useCallback(e=>{if(!n&&!r||p.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=xs(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&Z(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&Z(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,A.jsx)(X.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});ys.displayName=vs;function bs(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(Z(r,{select:t}),document.activeElement!==n)return}function xs(e){let t=Ss(e);return[Cs(t,e),Cs(t.reverse(),e)]}function Ss(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Cs(e,t){for(let n of e)if(!ws(n,{upTo:t}))return n}function ws(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function Ts(e){return e instanceof HTMLInputElement&&`select`in e}function Z(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Ts(e)&&t&&e.select()}}var Es=Ds();function Ds(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Os(e,t),e.unshift(t)},remove(t){e=Os(e,t),e[0]?.resume()}}}function Os(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function ks(e){return e.filter(e=>e.tagName!==`A`)}var As=`Portal`,js=k.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=k.useState(!1);Ro(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?Ko.createPortal((0,A.jsx)(X.div,{...r,ref:t}),o):null});js.displayName=As;function Ms(e,t){return k.useReducer((e,n)=>t[e][n]??e,e)}var Ns=e=>{let{present:t,children:n}=e,r=Ps(t),i=typeof n==`function`?n({present:r.isPresent}):k.Children.only(n),a=Po(r.ref,Is(i));return typeof n==`function`||r.isPresent?k.cloneElement(i,{ref:a}):null};Ns.displayName=`Presence`;function Ps(e){let[t,n]=k.useState(),r=k.useRef(null),i=k.useRef(e),a=k.useRef(`none`),[o,s]=Ms(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return k.useEffect(()=>{let e=Fs(r.current);a.current=o===`mounted`?e:`none`},[o]),Ro(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=Fs(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),Ro(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=Fs(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=Fs(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:k.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function Fs(e){return e?.animationName||`none`}function Is(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Ls=0;function Rs(){k.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??zs()),document.body.insertAdjacentElement(`beforeend`,e[1]??zs()),Ls++,()=>{Ls===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),Ls--}},[])}function zs(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var Q=function(){return Q=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Q.apply(this,arguments)};function Bs(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Vs(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var Hs=`right-scroll-bar-position`,Us=`width-before-scroll-bar`,Ws=`with-scroll-bars-hidden`,Gs=`--removed-body-scroll-bar-size`;function Ks(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function qs(e,t){var n=(0,k.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var Js=typeof window<`u`?k.useLayoutEffect:k.useEffect,Ys=new WeakMap;function Xs(e,t){var n=qs(t||null,function(t){return e.forEach(function(e){return Ks(e,t)})});return Js(function(){var t=Ys.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||Ks(e,null)}),i.forEach(function(e){r.has(e)||Ks(e,a)})}Ys.set(n,e)},[e]),n}function Zs(e){return e}function Qs(e,t){t===void 0&&(t=Zs);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function $s(e){e===void 0&&(e={});var t=Qs(null);return t.options=Q({async:!0,ssr:!1},e),t}var ec=function(e){var t=e.sideCar,n=Bs(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return k.createElement(r,Q({},n))};ec.isSideCarExport=!0;function tc(e,t){return e.useMedium(t),ec}var nc=$s(),rc=function(){},ic=k.forwardRef(function(e,t){var n=k.useRef(null),r=k.useState({onScrollCapture:rc,onWheelCapture:rc,onTouchMoveCapture:rc}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=Bs(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=Xs([n,t]),C=Q(Q({},b),i);return k.createElement(k.Fragment,null,u&&k.createElement(x,{sideCar:nc,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?k.cloneElement(k.Children.only(s),Q(Q({},C),{ref:S})):k.createElement(v,Q({},C,{className:c,ref:S}),s))});ic.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ic.classNames={fullWidth:Us,zeroRight:Hs};var ac,oc=function(){if(ac)return ac;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function sc(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=oc();return t&&e.setAttribute(`nonce`,t),e}function cc(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function lc(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var uc=function(){var e=0,t=null;return{add:function(n){e==0&&(t=sc())&&(cc(t,n),lc(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},dc=function(){var e=uc();return function(t,n){k.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},fc=function(){var e=dc();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},pc={left:0,top:0,right:0,gap:0},mc=function(e){return parseInt(e||``,10)||0},hc=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[mc(n),mc(r),mc(i)]},gc=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return pc;var t=hc(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},_c=fc(),vc=`data-scroll-locked`,yc=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
@@ -46,4 +46,4 @@ import{C as e,E as t,S as n,T as r,_ as i,a,d as o,g as s,h as c,l,n as u,o as d
46
46
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
47
47
 
48
48
  For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return k.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Pl=`DialogDescriptionWarning`,Fl=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ml(Pl).contentName}}.`;return k.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},Il=sl,Ll=pl,Rl=hl,zl=yl,Bl=wl,Vl=El,Hl=Ol,Ul=Il,Wl=Ll,Gl=k.forwardRef(({className:e,...t},n)=>(0,A.jsx)(Rl,{ref:n,className:y(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t}));Gl.displayName=Rl.displayName;var Kl=k.forwardRef(({className:e,children:t,...n},r)=>(0,A.jsxs)(Wl,{children:[(0,A.jsx)(Gl,{}),(0,A.jsxs)(zl,{ref:r,className:y(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-border bg-surface text-text p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,e),...n,children:[t,(0,A.jsxs)(Hl,{className:`absolute right-4 top-4 rounded-sm opacity-70 ring-offset-bg transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-accent focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-surface-active data-[state=open]:text-text-muted`,children:[(0,A.jsx)(Ee,{className:`h-4 w-4`}),(0,A.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}));Kl.displayName=zl.displayName;var ql=({className:e,...t})=>(0,A.jsx)(`div`,{className:y(`flex flex-col space-y-1.5 text-center sm:text-left`,e),...t});ql.displayName=`DialogHeader`;var Jl=({className:e,...t})=>(0,A.jsx)(`div`,{className:y(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});Jl.displayName=`DialogFooter`;var Yl=k.forwardRef(({className:e,...t},n)=>(0,A.jsx)(Bl,{ref:n,className:y(`text-lg font-semibold leading-none tracking-tight`,e),...t}));Yl.displayName=Bl.displayName;var Xl=k.forwardRef(({className:e,...t},n)=>(0,A.jsx)(Vl,{ref:n,className:y(`text-sm text-text-muted`,e),...t}));Xl.displayName=Vl.displayName;function Zl(){let[e,t]=(0,k.useState)(!1),[n,r]=(0,k.useState)(null),[i,a]=(0,k.useState)(`prompt`),[o,s]=(0,k.useState)(0),[c,l]=(0,k.useState)(``),[d,f]=(0,k.useState)(`download`);(0,k.useEffect)(()=>p(_.Available,e=>{r(e),a(`prompt`),s(0),l(``),t(!0)}),[]),(0,k.useEffect)(()=>p(_.DownloadProgress,e=>{s(Math.round(e.percent))}),[]);let m=(0,k.useCallback)(async()=>{a(`downloading`),s(0);try{let e=await u(_.Download);e.success?a(`ready`):(l(e.error||`Download failed`),f(`download`),a(`error`))}catch(e){l(e instanceof Error?e.message:String(e)),f(`download`),a(`error`)}},[]),h=(0,k.useCallback)(async()=>{try{let e=await u(_.Install);e.success||(l(e.error||`Install failed`),f(`install`),a(`error`))}catch(e){l(e instanceof Error?e.message:String(e)),f(`install`),a(`error`)}},[]),g=(0,k.useCallback)(()=>{n?.mandatory&&i!==`ready`||t(!1)},[n,i]);return n?(0,A.jsx)(Ul,{open:e,onOpenChange:e=>{!e&&n?.mandatory&&i!==`ready`||t(e)},children:(0,A.jsxs)(Kl,{className:`max-w-md`,children:[(0,A.jsxs)(ql,{children:[(0,A.jsx)(Yl,{children:i===`ready`?`Ready to Install`:`Update Available`}),(0,A.jsxs)(Xl,{children:[i===`prompt`&&`New version ${n.version} is available.`,i===`downloading`&&`Downloading... ${o}%`,i===`ready`&&`Download complete. Click install to restart and apply the update.`,i===`error`&&`${d===`install`?`Install`:`Download`} failed: ${c}`]})]}),n.releaseNotes&&i===`prompt`&&(0,A.jsx)(`div`,{className:`max-h-40 overflow-y-auto rounded border border-border bg-surface-2 p-3 text-xs text-text-secondary whitespace-pre-wrap`,children:n.releaseNotes}),i===`downloading`&&(0,A.jsx)(`div`,{className:`h-2 w-full overflow-hidden rounded-full bg-surface-3`,children:(0,A.jsx)(`div`,{className:`h-full bg-accent transition-all duration-300`,style:{width:`${o}%`}})}),(0,A.jsxs)(Jl,{children:[i===`prompt`&&(0,A.jsxs)(A.Fragment,{children:[!n.mandatory&&(0,A.jsx)(O,{variant:`outline`,onClick:g,children:`Later`}),(0,A.jsx)(O,{onClick:m,children:`Download`})]}),i===`ready`&&(0,A.jsx)(O,{onClick:h,children:`Install & Restart`}),i===`error`&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(O,{variant:`outline`,onClick:g,children:`Close`}),(0,A.jsx)(O,{onClick:d===`install`?h:m,children:`Retry`})]})]})]})}):null}var Ql=`Dimina DevTools`;function $l(){let[e,t]=(0,k.useState)(`list`),[n,r]=(0,k.useState)(null),[i,a]=(0,k.useState)([]),[o,s]=(0,k.useState)({}),[c,l]=(0,k.useState)(Ql),[u,d]=(0,k.useState)(!1),[f,p]=(0,k.useState)([]),[m,h]=(0,k.useState)(``);async function g(){a(await Fe())}(0,k.useEffect)(()=>{g(),Pe().then(e=>{e?.appName&&(l(e.appName),document.title=e.appName)}).catch(()=>{})},[]),(0,k.useEffect)(()=>{i.length!==0&&Promise.all(i.map(e=>qe(e.path).then(t=>[e.path,t]))).then(e=>s(Object.fromEntries(e)))},[i]),(0,k.useEffect)(()=>{C(e===`project`?`project`:`list`)},[e]),(0,k.useEffect)(()=>T(()=>{document.title=c,t(`list`),r(null),Fe().then(a)}),[c]),(0,k.useEffect)(()=>E(e=>{r({name:e.name,path:e.path}),t(`project`)}),[]);async function _(){let e=await Ie();if(!e)return;let t;try{t=await Le(e)}catch{return}await g(),x(t)}async function v(){let e;try{e=await Ye()}catch{e=null}if(e&&`ready`in e){await g(),x(e.ready);return}if(e){let t;try{t=await Xe(e)}catch{return}await g(),x(t);return}let[t,n]=await Promise.allSettled([Je(),Ze()]);p(t.status===`fulfilled`?t.value:[]),h(n.status===`fulfilled`?n.value.baseDir:``),d(!0)}async function y(e){d(!1);let t;try{t=await Xe(e)}catch{return}await g(),x(t)}async function b(e){await Re(e.path),await g()}function x(e){r(e),t(`project`)}return e===`list`?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(Zl,{}),(0,A.jsx)(Ae,{projects:i,onAdd:_,onCreate:v,onOpen:x,onRemove:b,thumbnails:o}),(0,A.jsx)(Ne,{open:u,templates:f,defaultBaseDir:m,onSubmit:y,onCancel:()=>d(!1),onBrowse:Ie})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(Zl,{}),(0,A.jsx)(Eo,{project:n},n?.path)]})}De.createRoot(document.getElementById(`root`)).render((0,A.jsx)($l,{}));
49
- //# sourceMappingURL=index-BJlFbXHb.js.map
49
+ //# sourceMappingURL=index-BBg3YI5b.js.map