@deepseekcode/cli 1.0.25 → 1.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1170 -1124
- package/package.json +4 -1
- package/web/dist/assets/AutomationView-CPCd-Qhd.js +1 -0
- package/web/dist/assets/ChannelConfigView-D6JtjZyf.js +8 -0
- package/web/dist/assets/ConnectorsView-BPPr7T9p.js +1 -0
- package/web/dist/assets/FileTreeView-CO8knuwu.js +11 -0
- package/web/dist/assets/HookConfigView-CYuzwf8u.js +1 -0
- package/web/dist/assets/ModelsView-Cji4mbXE.js +1 -0
- package/web/dist/assets/PluginsView-CKKnYKMP.js +1 -0
- package/web/dist/assets/SessionGrid-BOpVWUEK.js +37 -0
- package/web/dist/assets/SettingsPanel-R1fOoB25.js +4 -0
- package/web/dist/assets/{SkillsView-BrQY_vgT.js → SkillsView-DmQGY9v0.js} +1 -1
- package/web/dist/assets/TemplatesTab-_vSIuTZP.js +1 -0
- package/web/dist/assets/TerminalView-CTU0aA8o.js +3 -0
- package/web/dist/assets/ToolsView-DUEqePPo.js +1 -0
- package/web/dist/assets/{icons-B9mi2ie6.js → icons-qcawb7PZ.js} +1 -1
- package/web/dist/assets/index-DL2ULWxM.css +1 -0
- package/web/dist/assets/index-DUpwXfa-.js +70 -0
- package/web/dist/assets/{markdown-BrFQfawv.js → markdown-yjmXQjrx.js} +1 -1
- package/web/dist/assets/{panels-BX-TtLOU.js → panels-CX_dYEv0.js} +1 -1
- package/web/dist/assets/{react-vendor-CiRFOYk_.js → react-vendor-CSlQceOk.js} +1 -1
- package/web/dist/assets/{state-BcoCffxz.js → state-DOzZasIm.js} +1 -1
- package/web/dist/favicon.svg +32 -12
- package/web/dist/index.html +7 -7
- package/web/dist/logo.svg +32 -12
- package/web/dist/assets/AutomationView-MOGwMs0s.js +0 -1
- package/web/dist/assets/ChannelConfigView-CHWC4ETy.js +0 -8
- package/web/dist/assets/ConnectorsView-DaP_wB0W.js +0 -1
- package/web/dist/assets/FileTreeView-N64-Dser.js +0 -11
- package/web/dist/assets/HookConfigView-DsZDeVFi.js +0 -2
- package/web/dist/assets/ModelsView-C1cE2wMN.js +0 -2
- package/web/dist/assets/PluginsView-CsSjjfrn.js +0 -1
- package/web/dist/assets/SessionGrid-Bg-UTI2P.js +0 -37
- package/web/dist/assets/SettingsPanel-pZbjabYJ.js +0 -4
- package/web/dist/assets/TemplatesTab-DSfCryw2.js +0 -1
- package/web/dist/assets/TerminalView-Drr72DaP.js +0 -3
- package/web/dist/assets/ToolsView-ByqbKwqW.js +0 -1
- package/web/dist/assets/index-DCj9TkXV.css +0 -1
- package/web/dist/assets/index-PcXINYWS.js +0 -68
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as f,R as hn}from"./icons-B9mi2ie6.js";const we=f.createContext(null);we.displayName="PanelGroupContext";const k={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},$e=10,ne=f.useLayoutEffect,Fe=hn.useId,zn=typeof Fe=="function"?Fe:()=>null;let yn=0;function Ne(e=null){const n=zn(),t=f.useRef(e||n||null);return t.current===null&&(t.current=""+yn++),e??t.current}function Je({children:e,className:n="",collapsedSize:t,collapsible:r,defaultSize:i,forwardedRef:o,id:l,maxSize:s,minSize:a,onCollapse:h,onExpand:w,onResize:p,order:u,style:v,tagName:z="div",...C}){const E=f.useContext(we);if(E===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:b,expandPanel:L,getPanelSize:M,getPanelStyle:$,groupId:O,isPanelCollapsed:R,reevaluatePanelConstraints:P,registerPanel:K,resizePanel:J,unregisterPanel:F}=E,G=Ne(l),D=f.useRef({callbacks:{onCollapse:h,onExpand:w,onResize:p},constraints:{collapsedSize:t,collapsible:r,defaultSize:i,maxSize:s,minSize:a},id:G,idIsFromProps:l!==void 0,order:u});f.useRef({didLogMissingDefaultSizeWarning:!1}),ne(()=>{const{callbacks:_,constraints:N}=D.current,B={...N};D.current.id=G,D.current.idIsFromProps=l!==void 0,D.current.order=u,_.onCollapse=h,_.onExpand=w,_.onResize=p,N.collapsedSize=t,N.collapsible=r,N.defaultSize=i,N.maxSize=s,N.minSize=a,(B.collapsedSize!==N.collapsedSize||B.collapsible!==N.collapsible||B.maxSize!==N.maxSize||B.minSize!==N.minSize)&&P(D.current,B)}),ne(()=>{const _=D.current;return K(_),()=>{F(_)}},[u,G,K,F]),f.useImperativeHandle(o,()=>({collapse:()=>{b(D.current)},expand:_=>{L(D.current,_)},getId(){return G},getSize(){return M(D.current)},isCollapsed(){return R(D.current)},isExpanded(){return!R(D.current)},resize:_=>{J(D.current,_)}}),[b,L,M,R,G,J]);const Z=$(D.current,i);return f.createElement(z,{...C,children:e,className:n,id:G,style:{...Z,...v},[k.groupId]:O,[k.panel]:"",[k.panelCollapsible]:r||void 0,[k.panelId]:G,[k.panelSize]:parseFloat(""+Z.flexGrow).toFixed(1)})}const xn=f.forwardRef((e,n)=>f.createElement(Je,{...e,forwardedRef:n}));Je.displayName="Panel";xn.displayName="forwardRef(Panel)";let He=null,Se=-1,Y=null;function vn(e,n){if(n){const t=(n&en)!==0,r=(n&nn)!==0,i=(n&tn)!==0,o=(n&rn)!==0;if(t)return i?"se-resize":o?"ne-resize":"e-resize";if(r)return i?"sw-resize":o?"nw-resize":"w-resize";if(i)return"s-resize";if(o)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function Sn(){Y!==null&&(document.head.removeChild(Y),He=null,Y=null,Se=-1)}function Le(e,n){var t,r;const i=vn(e,n);if(He!==i){if(He=i,Y===null&&(Y=document.createElement("style"),document.head.appendChild(Y)),Se>=0){var o;(o=Y.sheet)===null||o===void 0||o.removeRule(Se)}Se=(t=(r=Y.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${i} !important;}`))!==null&&t!==void 0?t:-1}}function je(e){return e.type==="keydown"}function Ye(e){return e.type.startsWith("pointer")}function Ze(e){return e.type.startsWith("mouse")}function Ee(e){if(Ye(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Ze(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function bn(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Pn(e,n,t){return e.x<n.x+n.width&&e.x+e.width>n.x&&e.y<n.y+n.height&&e.y+e.height>n.y}function wn(e,n){if(e===n)throw new Error("Cannot compare node with itself");const t={a:Ue(e),b:Ue(n)};let r;for(;t.a.at(-1)===t.b.at(-1);)e=t.a.pop(),n=t.b.pop(),r=e;x(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:Ke(We(t.a)),b:Ke(We(t.b))};if(i.a===i.b){const o=r.childNodes,l={a:t.a.at(-1),b:t.b.at(-1)};let s=o.length;for(;s--;){const a=o[s];if(a===l.a)return 1;if(a===l.b)return-1}}return Math.sign(i.a-i.b)}const En=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Cn(e){var n;const t=getComputedStyle((n=Qe(e))!==null&&n!==void 0?n:e).display;return t==="flex"||t==="inline-flex"}function In(e){const n=getComputedStyle(e);return!!(n.position==="fixed"||n.zIndex!=="auto"&&(n.position!=="static"||Cn(e))||+n.opacity<1||"transform"in n&&n.transform!=="none"||"webkitTransform"in n&&n.webkitTransform!=="none"||"mixBlendMode"in n&&n.mixBlendMode!=="normal"||"filter"in n&&n.filter!=="none"||"webkitFilter"in n&&n.webkitFilter!=="none"||"isolation"in n&&n.isolation==="isolate"||En.test(n.willChange)||n.webkitOverflowScrolling==="touch")}function We(e){let n=e.length;for(;n--;){const t=e[n];if(x(t,"Missing node"),In(t))return t}return null}function Ke(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Ue(e){const n=[];for(;e;)n.push(e),e=Qe(e);return n}function Qe(e){const{parentNode:n}=e;return n&&n instanceof ShadowRoot?n.host:n}const en=1,nn=2,tn=4,rn=8,Rn=bn()==="coarse";let V=[],se=!1,ee=new Map,Ce=new Map;const he=new Set;function Ln(e,n,t,r,i){var o;const{ownerDocument:l}=n,s={direction:t,element:n,hitAreaMargins:r,setResizeHandlerState:i},a=(o=ee.get(l))!==null&&o!==void 0?o:0;return ee.set(l,a+1),he.add(s),be(),function(){var w;Ce.delete(e),he.delete(s);const p=(w=ee.get(l))!==null&&w!==void 0?w:1;if(ee.set(l,p-1),be(),p===1&&ee.delete(l),V.includes(s)){const u=V.indexOf(s);u>=0&&V.splice(u,1),Ge(),i("up",!0,null)}}}function An(e){const{target:n}=e,{x:t,y:r}=Ee(e);se=!0,_e({target:n,x:t,y:r}),be(),V.length>0&&(Pe("down",e),e.preventDefault(),on(n)||e.stopImmediatePropagation())}function Ae(e){const{x:n,y:t}=Ee(e);if(se&&e.buttons===0&&(se=!1,Pe("up",e)),!se){const{target:r}=e;_e({target:r,x:n,y:t})}Pe("move",e),Ge(),V.length>0&&e.preventDefault()}function ke(e){const{target:n}=e,{x:t,y:r}=Ee(e);Ce.clear(),se=!1,V.length>0&&(e.preventDefault(),on(n)||e.stopImmediatePropagation()),Pe("up",e),_e({target:n,x:t,y:r}),Ge(),be()}function on(e){let n=e;for(;n;){if(n.hasAttribute(k.resizeHandle))return!0;n=n.parentElement}return!1}function _e({target:e,x:n,y:t}){V.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),he.forEach(i=>{const{element:o,hitAreaMargins:l}=i,s=o.getBoundingClientRect(),{bottom:a,left:h,right:w,top:p}=s,u=Rn?l.coarse:l.fine;if(n>=h-u&&n<=w+u&&t>=p-u&&t<=a+u){if(r!==null&&document.contains(r)&&o!==r&&!o.contains(r)&&!r.contains(o)&&wn(r,o)>0){let z=r,C=!1;for(;z&&!z.contains(o);){if(Pn(z.getBoundingClientRect(),s)){C=!0;break}z=z.parentElement}if(C)return}V.push(i)}})}function De(e,n){Ce.set(e,n)}function Ge(){let e=!1,n=!1;V.forEach(r=>{const{direction:i}=r;i==="horizontal"?e=!0:n=!0});let t=0;Ce.forEach(r=>{t|=r}),e&&n?Le("intersection",t):e?Le("horizontal",t):n?Le("vertical",t):Sn()}let Me=new AbortController;function be(){Me.abort(),Me=new AbortController;const e={capture:!0,signal:Me.signal};he.size&&(se?(V.length>0&&ee.forEach((n,t)=>{const{body:r}=t;n>0&&(r.addEventListener("contextmenu",ke,e),r.addEventListener("pointerleave",Ae,e),r.addEventListener("pointermove",Ae,e))}),window.addEventListener("pointerup",ke,e),window.addEventListener("pointercancel",ke,e)):ee.forEach((n,t)=>{const{body:r}=t;n>0&&(r.addEventListener("pointerdown",An,e),r.addEventListener("pointermove",Ae,e))}))}function Pe(e,n){he.forEach(t=>{const{setResizeHandlerState:r}=t,i=V.includes(t);r(e,i,n)})}function kn(){const[e,n]=f.useState(0);return f.useCallback(()=>n(t=>t+1),[])}function x(e,n){if(!e)throw console.error(n),Error(n)}function te(e,n,t=$e){return e.toFixed(t)===n.toFixed(t)?0:e>n?1:-1}function j(e,n,t=$e){return te(e,n,t)===0}function W(e,n,t){return te(e,n,t)===0}function Dn(e,n,t){if(e.length!==n.length)return!1;for(let r=0;r<e.length;r++){const i=e[r],o=n[r];if(!W(i,o,t))return!1}return!0}function le({panelConstraints:e,panelIndex:n,size:t}){const r=e[n];x(r!=null,`Panel constraints not found for index ${n}`);let{collapsedSize:i=0,collapsible:o,maxSize:l=100,minSize:s=0}=r;if(te(t,s)<0)if(o){const a=(i+s)/2;te(t,a)<0?t=i:t=s}else t=s;return t=Math.min(l,t),t=parseFloat(t.toFixed($e)),t}function ge({delta:e,initialLayout:n,panelConstraints:t,pivotIndices:r,prevLayout:i,trigger:o}){if(W(e,0))return n;const l=[...n],[s,a]=r;x(s!=null,"Invalid first pivot index"),x(a!=null,"Invalid second pivot index");let h=0;if(o==="keyboard"){{const p=e<0?a:s,u=t[p];x(u,`Panel constraints not found for index ${p}`);const{collapsedSize:v=0,collapsible:z,minSize:C=0}=u;if(z){const E=n[p];if(x(E!=null,`Previous layout not found for panel index ${p}`),W(E,v)){const b=C-E;te(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}{const p=e<0?s:a,u=t[p];x(u,`No panel constraints found for index ${p}`);const{collapsedSize:v=0,collapsible:z,minSize:C=0}=u;if(z){const E=n[p];if(x(E!=null,`Previous layout not found for panel index ${p}`),W(E,C)){const b=E-v;te(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}}{const p=e<0?1:-1;let u=e<0?a:s,v=0;for(;;){const C=n[u];x(C!=null,`Previous layout not found for panel index ${u}`);const b=le({panelConstraints:t,panelIndex:u,size:100})-C;if(v+=b,u+=p,u<0||u>=t.length)break}const z=Math.min(Math.abs(e),Math.abs(v));e=e<0?0-z:z}{let u=e<0?s:a;for(;u>=0&&u<t.length;){const v=Math.abs(e)-Math.abs(h),z=n[u];x(z!=null,`Previous layout not found for panel index ${u}`);const C=z-v,E=le({panelConstraints:t,panelIndex:u,size:C});if(!W(z,E)&&(h+=z-E,l[u]=E,h.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?u--:u++}}if(Dn(i,l))return i;{const p=e<0?a:s,u=n[p];x(u!=null,`Previous layout not found for panel index ${p}`);const v=u+h,z=le({panelConstraints:t,panelIndex:p,size:v});if(l[p]=z,!W(z,v)){let C=v-z,b=e<0?a:s;for(;b>=0&&b<t.length;){const L=l[b];x(L!=null,`Previous layout not found for panel index ${b}`);const M=L+C,$=le({panelConstraints:t,panelIndex:b,size:M});if(W(L,$)||(C-=$-L,l[b]=$),W(C,0))break;e>0?b--:b++}}}const w=l.reduce((p,u)=>u+p,0);return W(w,100)?l:i}function Mn({layout:e,panelsArray:n,pivotIndices:t}){let r=0,i=100,o=0,l=0;const s=t[0];x(s!=null,"No pivot index found"),n.forEach((p,u)=>{const{constraints:v}=p,{maxSize:z=100,minSize:C=0}=v;u===s?(r=C,i=z):(o+=C,l+=z)});const a=Math.min(i,100-o),h=Math.max(r,100-l),w=e[s];return{valueMax:a,valueMin:h,valueNow:w}}function ze(e,n=document){return Array.from(n.querySelectorAll(`[${k.resizeHandleId}][data-panel-group-id="${e}"]`))}function ln(e,n,t=document){const i=ze(e,t).findIndex(o=>o.getAttribute(k.resizeHandleId)===n);return i??null}function sn(e,n,t){const r=ln(e,n,t);return r!=null?[r,r+1]:[-1,-1]}function an(e,n=document){var t;if(n instanceof HTMLElement&&(n==null||(t=n.dataset)===null||t===void 0?void 0:t.panelGroupId)==e)return n;const r=n.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return r||null}function Ie(e,n=document){const t=n.querySelector(`[${k.resizeHandleId}="${e}"]`);return t||null}function Hn(e,n,t,r=document){var i,o,l,s;const a=Ie(n,r),h=ze(e,r),w=a?h.indexOf(a):-1,p=(i=(o=t[w])===null||o===void 0?void 0:o.id)!==null&&i!==void 0?i:null,u=(l=(s=t[w+1])===null||s===void 0?void 0:s.id)!==null&&l!==void 0?l:null;return[p,u]}function $n({committedValuesRef:e,eagerValuesRef:n,groupId:t,layout:r,panelDataArray:i,panelGroupElement:o,setLayout:l}){f.useRef({didWarnAboutMissingResizeHandle:!1}),ne(()=>{if(!o)return;const s=ze(t,o);for(let a=0;a<i.length-1;a++){const{valueMax:h,valueMin:w,valueNow:p}=Mn({layout:r,panelsArray:i,pivotIndices:[a,a+1]}),u=s[a];if(u!=null){const v=i[a];x(v,`No panel data found for index "${a}"`),u.setAttribute("aria-controls",v.id),u.setAttribute("aria-valuemax",""+Math.round(h)),u.setAttribute("aria-valuemin",""+Math.round(w)),u.setAttribute("aria-valuenow",p!=null?""+Math.round(p):"")}}return()=>{s.forEach((a,h)=>{a.removeAttribute("aria-controls"),a.removeAttribute("aria-valuemax"),a.removeAttribute("aria-valuemin"),a.removeAttribute("aria-valuenow")})}},[t,r,i,o]),f.useEffect(()=>{if(!o)return;const s=n.current;x(s,"Eager values not found");const{panelDataArray:a}=s,h=an(t,o);x(h!=null,`No group found for id "${t}"`);const w=ze(t,o);x(w,`No resize handles found for group id "${t}"`);const p=w.map(u=>{const v=u.getAttribute(k.resizeHandleId);x(v,"Resize handle element has no handle id attribute");const[z,C]=Hn(t,v,a,o);if(z==null||C==null)return()=>{};const E=b=>{if(!b.defaultPrevented)switch(b.key){case"Enter":{b.preventDefault();const L=a.findIndex(M=>M.id===z);if(L>=0){const M=a[L];x(M,`No panel data found for index ${L}`);const $=r[L],{collapsedSize:O=0,collapsible:R,minSize:P=0}=M.constraints;if($!=null&&R){const K=ge({delta:W($,O)?P-O:O-$,initialLayout:r,panelConstraints:a.map(J=>J.constraints),pivotIndices:sn(t,v,o),prevLayout:r,trigger:"keyboard"});r!==K&&l(K)}}break}}};return u.addEventListener("keydown",E),()=>{u.removeEventListener("keydown",E)}});return()=>{p.forEach(u=>u())}},[o,e,n,t,r,i,l])}function Ve(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function un(e,n){const t=e==="horizontal",{x:r,y:i}=Ee(n);return t?r:i}function Nn(e,n,t,r,i){const o=t==="horizontal",l=Ie(n,i);x(l,`No resize handle element found for id "${n}"`);const s=l.getAttribute(k.groupId);x(s,"Resize handle element has no group id attribute");let{initialCursorPosition:a}=r;const h=un(t,e),w=an(s,i);x(w,`No group element found for id "${s}"`);const p=w.getBoundingClientRect(),u=o?p.width:p.height;return(h-a)/u*100}function _n(e,n,t,r,i,o){if(je(e)){const l=t==="horizontal";let s=0;e.shiftKey?s=100:i!=null?s=i:s=10;let a=0;switch(e.key){case"ArrowDown":a=l?0:s;break;case"ArrowLeft":a=l?-s:0;break;case"ArrowRight":a=l?s:0;break;case"ArrowUp":a=l?0:-s;break;case"End":a=100;break;case"Home":a=-100;break}return a}else return r==null?0:Nn(e,n,t,r,o)}function Gn({panelDataArray:e}){const n=Array(e.length),t=e.map(o=>o.constraints);let r=0,i=100;for(let o=0;o<e.length;o++){const l=t[o];x(l,`Panel constraints not found for index ${o}`);const{defaultSize:s}=l;s!=null&&(r++,n[o]=s,i-=s)}for(let o=0;o<e.length;o++){const l=t[o];x(l,`Panel constraints not found for index ${o}`);const{defaultSize:s}=l;if(s!=null)continue;const a=e.length-r,h=i/a;r++,n[o]=h,i-=h}return n}function oe(e,n,t){n.forEach((r,i)=>{const o=e[i];x(o,`Panel data not found for index ${i}`);const{callbacks:l,constraints:s,id:a}=o,{collapsedSize:h=0,collapsible:w}=s,p=t[a];if(p==null||r!==p){t[a]=r;const{onCollapse:u,onExpand:v,onResize:z}=l;z&&z(r,p),w&&(u||v)&&(v&&(p==null||j(p,h))&&!j(r,h)&&v(),u&&(p==null||!j(p,h))&&j(r,h)&&u())}})}function ve(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!=n[t])return!1;return!0}function Bn({defaultSize:e,dragState:n,layout:t,panelData:r,panelIndex:i,precision:o=3}){const l=t[i];let s;return l==null?s=e!=null?e.toPrecision(o):"1":r.length===1?s="1":s=l.toPrecision(o),{flexBasis:0,flexGrow:s,flexShrink:1,overflow:"hidden",pointerEvents:n!==null?"none":void 0}}function Tn(e,n=10){let t=null;return(...i)=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{e(...i)},n)}}function Oe(e){try{if(typeof localStorage<"u")e.getItem=n=>localStorage.getItem(n),e.setItem=(n,t)=>{localStorage.setItem(n,t)};else throw new Error("localStorage not supported in this environment")}catch(n){console.error(n),e.getItem=()=>null,e.setItem=()=>{}}}function cn(e){return`react-resizable-panels:${e}`}function fn(e){return e.map(n=>{const{constraints:t,id:r,idIsFromProps:i,order:o}=n;return i?r:o?`${o}:${JSON.stringify(t)}`:JSON.stringify(t)}).sort((n,t)=>n.localeCompare(t)).join(",")}function dn(e,n){try{const t=cn(e),r=n.getItem(t);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function Fn(e,n,t){var r,i;const o=(r=dn(e,t))!==null&&r!==void 0?r:{},l=fn(n);return(i=o[l])!==null&&i!==void 0?i:null}function Wn(e,n,t,r,i){var o;const l=cn(e),s=fn(n),a=(o=dn(e,i))!==null&&o!==void 0?o:{};a[s]={expandToSizes:Object.fromEntries(t.entries()),layout:r};try{i.setItem(l,JSON.stringify(a))}catch(h){console.error(h)}}function qe({layout:e,panelConstraints:n}){const t=[...e],r=t.reduce((o,l)=>o+l,0);if(t.length!==n.length)throw Error(`Invalid ${n.length} panel layout: ${t.map(o=>`${o}%`).join(", ")}`);if(!W(r,100)&&t.length>0)for(let o=0;o<n.length;o++){const l=t[o];x(l!=null,`No layout data found for index ${o}`);const s=100/r*l;t[o]=s}let i=0;for(let o=0;o<n.length;o++){const l=t[o];x(l!=null,`No layout data found for index ${o}`);const s=le({panelConstraints:n,panelIndex:o,size:l});l!=s&&(i+=l-s,t[o]=s)}if(!W(i,0))for(let o=0;o<n.length;o++){const l=t[o];x(l!=null,`No layout data found for index ${o}`);const s=l+i,a=le({panelConstraints:n,panelIndex:o,size:s});if(l!==a&&(i-=a-l,t[o]=a,W(i,0)))break}return t}const Kn=100,me={getItem:e=>(Oe(me),me.getItem(e)),setItem:(e,n)=>{Oe(me),me.setItem(e,n)}},Xe={};function pn({autoSaveId:e=null,children:n,className:t="",direction:r,forwardedRef:i,id:o=null,onLayout:l=null,keyboardResizeBy:s=null,storage:a=me,style:h,tagName:w="div",...p}){const u=Ne(o),v=f.useRef(null),[z,C]=f.useState(null),[E,b]=f.useState([]),L=kn(),M=f.useRef({}),$=f.useRef(new Map),O=f.useRef(0),R=f.useRef({autoSaveId:e,direction:r,dragState:z,id:u,keyboardResizeBy:s,onLayout:l,storage:a}),P=f.useRef({layout:E,panelDataArray:[],panelDataArrayChanged:!1});f.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),f.useImperativeHandle(i,()=>({getId:()=>R.current.id,getLayout:()=>{const{layout:c}=P.current;return c},setLayout:c=>{const{onLayout:m}=R.current,{layout:S,panelDataArray:g}=P.current,d=qe({layout:c,panelConstraints:g.map(y=>y.constraints)});Ve(S,d)||(b(d),P.current.layout=d,m&&m(d),oe(g,d,M.current))}}),[]),ne(()=>{R.current.autoSaveId=e,R.current.direction=r,R.current.dragState=z,R.current.id=u,R.current.onLayout=l,R.current.storage=a}),$n({committedValuesRef:R,eagerValuesRef:P,groupId:u,layout:E,panelDataArray:P.current.panelDataArray,setLayout:b,panelGroupElement:v.current}),f.useEffect(()=>{const{panelDataArray:c}=P.current;if(e){if(E.length===0||E.length!==c.length)return;let m=Xe[e];m==null&&(m=Tn(Wn,Kn),Xe[e]=m);const S=[...c],g=new Map($.current);m(e,S,g,E,a)}},[e,E,a]),f.useEffect(()=>{});const K=f.useCallback(c=>{const{onLayout:m}=R.current,{layout:S,panelDataArray:g}=P.current;if(c.constraints.collapsible){const d=g.map(q=>q.constraints),{collapsedSize:y=0,panelSize:I,pivotIndices:H}=Q(g,c,S);if(x(I!=null,`Panel size not found for panel "${c.id}"`),!j(I,y)){$.current.set(c.id,I);const X=ie(g,c)===g.length-1?I-y:y-I,A=ge({delta:X,initialLayout:S,panelConstraints:d,pivotIndices:H,prevLayout:S,trigger:"imperative-api"});ve(S,A)||(b(A),P.current.layout=A,m&&m(A),oe(g,A,M.current))}}},[]),J=f.useCallback((c,m)=>{const{onLayout:S}=R.current,{layout:g,panelDataArray:d}=P.current;if(c.constraints.collapsible){const y=d.map(U=>U.constraints),{collapsedSize:I=0,panelSize:H=0,minSize:q=0,pivotIndices:X}=Q(d,c,g),A=m??q;if(j(H,I)){const U=$.current.get(c.id),de=U!=null&&U>=A?U:A,Re=ie(d,c)===d.length-1?H-de:de-H,T=ge({delta:Re,initialLayout:g,panelConstraints:y,pivotIndices:X,prevLayout:g,trigger:"imperative-api"});ve(g,T)||(b(T),P.current.layout=T,S&&S(T),oe(d,T,M.current))}}},[]),F=f.useCallback(c=>{const{layout:m,panelDataArray:S}=P.current,{panelSize:g}=Q(S,c,m);return x(g!=null,`Panel size not found for panel "${c.id}"`),g},[]),G=f.useCallback((c,m)=>{const{panelDataArray:S}=P.current,g=ie(S,c);return Bn({defaultSize:m,dragState:z,layout:E,panelData:S,panelIndex:g})},[z,E]),D=f.useCallback(c=>{const{layout:m,panelDataArray:S}=P.current,{collapsedSize:g=0,collapsible:d,panelSize:y}=Q(S,c,m);return x(y!=null,`Panel size not found for panel "${c.id}"`),d===!0&&j(y,g)},[]),Z=f.useCallback(c=>{const{layout:m,panelDataArray:S}=P.current,{collapsedSize:g=0,collapsible:d,panelSize:y}=Q(S,c,m);return x(y!=null,`Panel size not found for panel "${c.id}"`),!d||te(y,g)>0},[]),_=f.useCallback(c=>{const{panelDataArray:m}=P.current;m.push(c),m.sort((S,g)=>{const d=S.order,y=g.order;return d==null&&y==null?0:d==null?-1:y==null?1:d-y}),P.current.panelDataArrayChanged=!0,L()},[L]);ne(()=>{if(P.current.panelDataArrayChanged){P.current.panelDataArrayChanged=!1;const{autoSaveId:c,onLayout:m,storage:S}=R.current,{layout:g,panelDataArray:d}=P.current;let y=null;if(c){const H=Fn(c,d,S);H&&($.current=new Map(Object.entries(H.expandToSizes)),y=H.layout)}y==null&&(y=Gn({panelDataArray:d}));const I=qe({layout:y,panelConstraints:d.map(H=>H.constraints)});Ve(g,I)||(b(I),P.current.layout=I,m&&m(I),oe(d,I,M.current))}}),ne(()=>{const c=P.current;return()=>{c.layout=[]}},[]);const N=f.useCallback(c=>{let m=!1;const S=v.current;return S&&window.getComputedStyle(S,null).getPropertyValue("direction")==="rtl"&&(m=!0),function(d){d.preventDefault();const y=v.current;if(!y)return()=>null;const{direction:I,dragState:H,id:q,keyboardResizeBy:X,onLayout:A}=R.current,{layout:U,panelDataArray:de}=P.current,{initialLayout:xe}=H??{},Re=sn(q,c,y);let T=_n(d,c,I,H,X,y);const Be=I==="horizontal";Be&&m&&(T=-T);const gn=de.map(mn=>mn.constraints),pe=ge({delta:T,initialLayout:xe??U,panelConstraints:gn,pivotIndices:Re,prevLayout:U,trigger:je(d)?"keyboard":"mouse-or-touch"}),Te=!ve(U,pe);(Ye(d)||Ze(d))&&O.current!=T&&(O.current=T,!Te&&T!==0?Be?De(c,T<0?en:nn):De(c,T<0?tn:rn):De(c,0)),Te&&(b(pe),P.current.layout=pe,A&&A(pe),oe(de,pe,M.current))}},[]),B=f.useCallback((c,m)=>{const{onLayout:S}=R.current,{layout:g,panelDataArray:d}=P.current,y=d.map(U=>U.constraints),{panelSize:I,pivotIndices:H}=Q(d,c,g);x(I!=null,`Panel size not found for panel "${c.id}"`);const X=ie(d,c)===d.length-1?I-m:m-I,A=ge({delta:X,initialLayout:g,panelConstraints:y,pivotIndices:H,prevLayout:g,trigger:"imperative-api"});ve(g,A)||(b(A),P.current.layout=A,S&&S(A),oe(d,A,M.current))},[]),ae=f.useCallback((c,m)=>{const{layout:S,panelDataArray:g}=P.current,{collapsedSize:d=0,collapsible:y}=m,{collapsedSize:I=0,collapsible:H,maxSize:q=100,minSize:X=0}=c.constraints,{panelSize:A}=Q(g,c,S);A!=null&&(y&&H&&j(A,d)?j(d,I)||B(c,I):A<X?B(c,X):A>q&&B(c,q))},[B]),ue=f.useCallback((c,m)=>{const{direction:S}=R.current,{layout:g}=P.current;if(!v.current)return;const d=Ie(c,v.current);x(d,`Drag handle element not found for id "${c}"`);const y=un(S,m);C({dragHandleId:c,dragHandleRect:d.getBoundingClientRect(),initialCursorPosition:y,initialLayout:g})},[]),ce=f.useCallback(()=>{C(null)},[]),ye=f.useCallback(c=>{const{panelDataArray:m}=P.current,S=ie(m,c);S>=0&&(m.splice(S,1),delete M.current[c.id],P.current.panelDataArrayChanged=!0,L())},[L]),re=f.useMemo(()=>({collapsePanel:K,direction:r,dragState:z,expandPanel:J,getPanelSize:F,getPanelStyle:G,groupId:u,isPanelCollapsed:D,isPanelExpanded:Z,reevaluatePanelConstraints:ae,registerPanel:_,registerResizeHandle:N,resizePanel:B,startDragging:ue,stopDragging:ce,unregisterPanel:ye,panelGroupElement:v.current}),[K,z,r,J,F,G,u,D,Z,ae,_,N,B,ue,ce,ye]),fe={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return f.createElement(we.Provider,{value:re},f.createElement(w,{...p,children:n,className:t,id:o,ref:v,style:{...fe,...h},[k.group]:"",[k.groupDirection]:r,[k.groupId]:u}))}const Un=f.forwardRef((e,n)=>f.createElement(pn,{...e,forwardedRef:n}));pn.displayName="PanelGroup";Un.displayName="forwardRef(PanelGroup)";function ie(e,n){return e.findIndex(t=>t===n||t.id===n.id)}function Q(e,n,t){const r=ie(e,n),o=r===e.length-1?[r-1,r]:[r,r+1],l=t[r];return{...n.constraints,panelSize:l,pivotIndices:o}}function Vn({disabled:e,handleId:n,resizeHandler:t,panelGroupElement:r}){f.useEffect(()=>{if(e||t==null||r==null)return;const i=Ie(n,r);if(i==null)return;const o=l=>{if(!l.defaultPrevented)switch(l.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{l.preventDefault(),t(l);break}case"F6":{l.preventDefault();const s=i.getAttribute(k.groupId);x(s,`No group element found for id "${s}"`);const a=ze(s,r),h=ln(s,n,r);x(h!==null,`No resize element found for id "${n}"`);const w=l.shiftKey?h>0?h-1:a.length-1:h+1<a.length?h+1:0;a[w].focus();break}}};return i.addEventListener("keydown",o),()=>{i.removeEventListener("keydown",o)}},[r,e,n,t])}function On({children:e=null,className:n="",disabled:t=!1,hitAreaMargins:r,id:i,onBlur:o,onClick:l,onDragging:s,onFocus:a,onPointerDown:h,onPointerUp:w,style:p={},tabIndex:u=0,tagName:v="div",...z}){var C,E;const b=f.useRef(null),L=f.useRef({onClick:l,onDragging:s,onPointerDown:h,onPointerUp:w});f.useEffect(()=>{L.current.onClick=l,L.current.onDragging=s,L.current.onPointerDown=h,L.current.onPointerUp=w});const M=f.useContext(we);if(M===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:$,groupId:O,registerResizeHandle:R,startDragging:P,stopDragging:K,panelGroupElement:J}=M,F=Ne(i),[G,D]=f.useState("inactive"),[Z,_]=f.useState(!1),[N,B]=f.useState(null),ae=f.useRef({state:G});ne(()=>{ae.current.state=G}),f.useEffect(()=>{if(t)B(null);else{const re=R(F);B(()=>re)}},[t,F,R]);const ue=(C=r==null?void 0:r.coarse)!==null&&C!==void 0?C:15,ce=(E=r==null?void 0:r.fine)!==null&&E!==void 0?E:5;f.useEffect(()=>{if(t||N==null)return;const re=b.current;x(re,"Element ref not attached");let fe=!1;return Ln(F,re,$,{coarse:ue,fine:ce},(m,S,g)=>{if(!S){D("inactive");return}switch(m){case"down":{D("drag"),fe=!1,x(g,'Expected event to be defined for "down" action'),P(F,g);const{onDragging:d,onPointerDown:y}=L.current;d==null||d(!0),y==null||y();break}case"move":{const{state:d}=ae.current;fe=!0,d!=="drag"&&D("hover"),x(g,'Expected event to be defined for "move" action'),N(g);break}case"up":{D("hover"),K();const{onClick:d,onDragging:y,onPointerUp:I}=L.current;y==null||y(!1),I==null||I(),fe||d==null||d();break}}})},[ue,$,t,ce,R,F,N,P,K]),Vn({disabled:t,handleId:F,resizeHandler:N,panelGroupElement:J});const ye={touchAction:"none",userSelect:"none"};return f.createElement(v,{...z,children:e,className:n,id:i,onBlur:()=>{_(!1),o==null||o()},onFocus:()=>{_(!0),a==null||a()},ref:b,role:"separator",style:{...ye,...p},tabIndex:u,[k.groupDirection]:$,[k.groupId]:O,[k.resizeHandle]:"",[k.resizeHandleActive]:G==="drag"?"pointer":Z?"keyboard":void 0,[k.resizeHandleEnabled]:!t,[k.resizeHandleId]:F,[k.resizeHandleState]:G})}On.displayName="PanelResizeHandle";export{Un as P,xn as a,On as b};
|
|
1
|
+
import{a as f,R as hn}from"./icons-qcawb7PZ.js";const we=f.createContext(null);we.displayName="PanelGroupContext";const k={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},$e=10,ne=f.useLayoutEffect,Fe=hn.useId,zn=typeof Fe=="function"?Fe:()=>null;let yn=0;function Ne(e=null){const n=zn(),t=f.useRef(e||n||null);return t.current===null&&(t.current=""+yn++),e??t.current}function Je({children:e,className:n="",collapsedSize:t,collapsible:r,defaultSize:i,forwardedRef:o,id:l,maxSize:s,minSize:a,onCollapse:h,onExpand:w,onResize:p,order:u,style:v,tagName:z="div",...C}){const E=f.useContext(we);if(E===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:b,expandPanel:L,getPanelSize:M,getPanelStyle:$,groupId:O,isPanelCollapsed:R,reevaluatePanelConstraints:P,registerPanel:K,resizePanel:J,unregisterPanel:F}=E,G=Ne(l),D=f.useRef({callbacks:{onCollapse:h,onExpand:w,onResize:p},constraints:{collapsedSize:t,collapsible:r,defaultSize:i,maxSize:s,minSize:a},id:G,idIsFromProps:l!==void 0,order:u});f.useRef({didLogMissingDefaultSizeWarning:!1}),ne(()=>{const{callbacks:_,constraints:N}=D.current,B={...N};D.current.id=G,D.current.idIsFromProps=l!==void 0,D.current.order=u,_.onCollapse=h,_.onExpand=w,_.onResize=p,N.collapsedSize=t,N.collapsible=r,N.defaultSize=i,N.maxSize=s,N.minSize=a,(B.collapsedSize!==N.collapsedSize||B.collapsible!==N.collapsible||B.maxSize!==N.maxSize||B.minSize!==N.minSize)&&P(D.current,B)}),ne(()=>{const _=D.current;return K(_),()=>{F(_)}},[u,G,K,F]),f.useImperativeHandle(o,()=>({collapse:()=>{b(D.current)},expand:_=>{L(D.current,_)},getId(){return G},getSize(){return M(D.current)},isCollapsed(){return R(D.current)},isExpanded(){return!R(D.current)},resize:_=>{J(D.current,_)}}),[b,L,M,R,G,J]);const Z=$(D.current,i);return f.createElement(z,{...C,children:e,className:n,id:G,style:{...Z,...v},[k.groupId]:O,[k.panel]:"",[k.panelCollapsible]:r||void 0,[k.panelId]:G,[k.panelSize]:parseFloat(""+Z.flexGrow).toFixed(1)})}const xn=f.forwardRef((e,n)=>f.createElement(Je,{...e,forwardedRef:n}));Je.displayName="Panel";xn.displayName="forwardRef(Panel)";let He=null,Se=-1,Y=null;function vn(e,n){if(n){const t=(n&en)!==0,r=(n&nn)!==0,i=(n&tn)!==0,o=(n&rn)!==0;if(t)return i?"se-resize":o?"ne-resize":"e-resize";if(r)return i?"sw-resize":o?"nw-resize":"w-resize";if(i)return"s-resize";if(o)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function Sn(){Y!==null&&(document.head.removeChild(Y),He=null,Y=null,Se=-1)}function Le(e,n){var t,r;const i=vn(e,n);if(He!==i){if(He=i,Y===null&&(Y=document.createElement("style"),document.head.appendChild(Y)),Se>=0){var o;(o=Y.sheet)===null||o===void 0||o.removeRule(Se)}Se=(t=(r=Y.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${i} !important;}`))!==null&&t!==void 0?t:-1}}function je(e){return e.type==="keydown"}function Ye(e){return e.type.startsWith("pointer")}function Ze(e){return e.type.startsWith("mouse")}function Ee(e){if(Ye(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Ze(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function bn(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Pn(e,n,t){return e.x<n.x+n.width&&e.x+e.width>n.x&&e.y<n.y+n.height&&e.y+e.height>n.y}function wn(e,n){if(e===n)throw new Error("Cannot compare node with itself");const t={a:Ue(e),b:Ue(n)};let r;for(;t.a.at(-1)===t.b.at(-1);)e=t.a.pop(),n=t.b.pop(),r=e;x(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:Ke(We(t.a)),b:Ke(We(t.b))};if(i.a===i.b){const o=r.childNodes,l={a:t.a.at(-1),b:t.b.at(-1)};let s=o.length;for(;s--;){const a=o[s];if(a===l.a)return 1;if(a===l.b)return-1}}return Math.sign(i.a-i.b)}const En=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Cn(e){var n;const t=getComputedStyle((n=Qe(e))!==null&&n!==void 0?n:e).display;return t==="flex"||t==="inline-flex"}function In(e){const n=getComputedStyle(e);return!!(n.position==="fixed"||n.zIndex!=="auto"&&(n.position!=="static"||Cn(e))||+n.opacity<1||"transform"in n&&n.transform!=="none"||"webkitTransform"in n&&n.webkitTransform!=="none"||"mixBlendMode"in n&&n.mixBlendMode!=="normal"||"filter"in n&&n.filter!=="none"||"webkitFilter"in n&&n.webkitFilter!=="none"||"isolation"in n&&n.isolation==="isolate"||En.test(n.willChange)||n.webkitOverflowScrolling==="touch")}function We(e){let n=e.length;for(;n--;){const t=e[n];if(x(t,"Missing node"),In(t))return t}return null}function Ke(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Ue(e){const n=[];for(;e;)n.push(e),e=Qe(e);return n}function Qe(e){const{parentNode:n}=e;return n&&n instanceof ShadowRoot?n.host:n}const en=1,nn=2,tn=4,rn=8,Rn=bn()==="coarse";let V=[],se=!1,ee=new Map,Ce=new Map;const he=new Set;function Ln(e,n,t,r,i){var o;const{ownerDocument:l}=n,s={direction:t,element:n,hitAreaMargins:r,setResizeHandlerState:i},a=(o=ee.get(l))!==null&&o!==void 0?o:0;return ee.set(l,a+1),he.add(s),be(),function(){var w;Ce.delete(e),he.delete(s);const p=(w=ee.get(l))!==null&&w!==void 0?w:1;if(ee.set(l,p-1),be(),p===1&&ee.delete(l),V.includes(s)){const u=V.indexOf(s);u>=0&&V.splice(u,1),Ge(),i("up",!0,null)}}}function An(e){const{target:n}=e,{x:t,y:r}=Ee(e);se=!0,_e({target:n,x:t,y:r}),be(),V.length>0&&(Pe("down",e),e.preventDefault(),on(n)||e.stopImmediatePropagation())}function Ae(e){const{x:n,y:t}=Ee(e);if(se&&e.buttons===0&&(se=!1,Pe("up",e)),!se){const{target:r}=e;_e({target:r,x:n,y:t})}Pe("move",e),Ge(),V.length>0&&e.preventDefault()}function ke(e){const{target:n}=e,{x:t,y:r}=Ee(e);Ce.clear(),se=!1,V.length>0&&(e.preventDefault(),on(n)||e.stopImmediatePropagation()),Pe("up",e),_e({target:n,x:t,y:r}),Ge(),be()}function on(e){let n=e;for(;n;){if(n.hasAttribute(k.resizeHandle))return!0;n=n.parentElement}return!1}function _e({target:e,x:n,y:t}){V.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),he.forEach(i=>{const{element:o,hitAreaMargins:l}=i,s=o.getBoundingClientRect(),{bottom:a,left:h,right:w,top:p}=s,u=Rn?l.coarse:l.fine;if(n>=h-u&&n<=w+u&&t>=p-u&&t<=a+u){if(r!==null&&document.contains(r)&&o!==r&&!o.contains(r)&&!r.contains(o)&&wn(r,o)>0){let z=r,C=!1;for(;z&&!z.contains(o);){if(Pn(z.getBoundingClientRect(),s)){C=!0;break}z=z.parentElement}if(C)return}V.push(i)}})}function De(e,n){Ce.set(e,n)}function Ge(){let e=!1,n=!1;V.forEach(r=>{const{direction:i}=r;i==="horizontal"?e=!0:n=!0});let t=0;Ce.forEach(r=>{t|=r}),e&&n?Le("intersection",t):e?Le("horizontal",t):n?Le("vertical",t):Sn()}let Me=new AbortController;function be(){Me.abort(),Me=new AbortController;const e={capture:!0,signal:Me.signal};he.size&&(se?(V.length>0&&ee.forEach((n,t)=>{const{body:r}=t;n>0&&(r.addEventListener("contextmenu",ke,e),r.addEventListener("pointerleave",Ae,e),r.addEventListener("pointermove",Ae,e))}),window.addEventListener("pointerup",ke,e),window.addEventListener("pointercancel",ke,e)):ee.forEach((n,t)=>{const{body:r}=t;n>0&&(r.addEventListener("pointerdown",An,e),r.addEventListener("pointermove",Ae,e))}))}function Pe(e,n){he.forEach(t=>{const{setResizeHandlerState:r}=t,i=V.includes(t);r(e,i,n)})}function kn(){const[e,n]=f.useState(0);return f.useCallback(()=>n(t=>t+1),[])}function x(e,n){if(!e)throw console.error(n),Error(n)}function te(e,n,t=$e){return e.toFixed(t)===n.toFixed(t)?0:e>n?1:-1}function j(e,n,t=$e){return te(e,n,t)===0}function W(e,n,t){return te(e,n,t)===0}function Dn(e,n,t){if(e.length!==n.length)return!1;for(let r=0;r<e.length;r++){const i=e[r],o=n[r];if(!W(i,o,t))return!1}return!0}function le({panelConstraints:e,panelIndex:n,size:t}){const r=e[n];x(r!=null,`Panel constraints not found for index ${n}`);let{collapsedSize:i=0,collapsible:o,maxSize:l=100,minSize:s=0}=r;if(te(t,s)<0)if(o){const a=(i+s)/2;te(t,a)<0?t=i:t=s}else t=s;return t=Math.min(l,t),t=parseFloat(t.toFixed($e)),t}function ge({delta:e,initialLayout:n,panelConstraints:t,pivotIndices:r,prevLayout:i,trigger:o}){if(W(e,0))return n;const l=[...n],[s,a]=r;x(s!=null,"Invalid first pivot index"),x(a!=null,"Invalid second pivot index");let h=0;if(o==="keyboard"){{const p=e<0?a:s,u=t[p];x(u,`Panel constraints not found for index ${p}`);const{collapsedSize:v=0,collapsible:z,minSize:C=0}=u;if(z){const E=n[p];if(x(E!=null,`Previous layout not found for panel index ${p}`),W(E,v)){const b=C-E;te(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}{const p=e<0?s:a,u=t[p];x(u,`No panel constraints found for index ${p}`);const{collapsedSize:v=0,collapsible:z,minSize:C=0}=u;if(z){const E=n[p];if(x(E!=null,`Previous layout not found for panel index ${p}`),W(E,C)){const b=E-v;te(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}}{const p=e<0?1:-1;let u=e<0?a:s,v=0;for(;;){const C=n[u];x(C!=null,`Previous layout not found for panel index ${u}`);const b=le({panelConstraints:t,panelIndex:u,size:100})-C;if(v+=b,u+=p,u<0||u>=t.length)break}const z=Math.min(Math.abs(e),Math.abs(v));e=e<0?0-z:z}{let u=e<0?s:a;for(;u>=0&&u<t.length;){const v=Math.abs(e)-Math.abs(h),z=n[u];x(z!=null,`Previous layout not found for panel index ${u}`);const C=z-v,E=le({panelConstraints:t,panelIndex:u,size:C});if(!W(z,E)&&(h+=z-E,l[u]=E,h.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?u--:u++}}if(Dn(i,l))return i;{const p=e<0?a:s,u=n[p];x(u!=null,`Previous layout not found for panel index ${p}`);const v=u+h,z=le({panelConstraints:t,panelIndex:p,size:v});if(l[p]=z,!W(z,v)){let C=v-z,b=e<0?a:s;for(;b>=0&&b<t.length;){const L=l[b];x(L!=null,`Previous layout not found for panel index ${b}`);const M=L+C,$=le({panelConstraints:t,panelIndex:b,size:M});if(W(L,$)||(C-=$-L,l[b]=$),W(C,0))break;e>0?b--:b++}}}const w=l.reduce((p,u)=>u+p,0);return W(w,100)?l:i}function Mn({layout:e,panelsArray:n,pivotIndices:t}){let r=0,i=100,o=0,l=0;const s=t[0];x(s!=null,"No pivot index found"),n.forEach((p,u)=>{const{constraints:v}=p,{maxSize:z=100,minSize:C=0}=v;u===s?(r=C,i=z):(o+=C,l+=z)});const a=Math.min(i,100-o),h=Math.max(r,100-l),w=e[s];return{valueMax:a,valueMin:h,valueNow:w}}function ze(e,n=document){return Array.from(n.querySelectorAll(`[${k.resizeHandleId}][data-panel-group-id="${e}"]`))}function ln(e,n,t=document){const i=ze(e,t).findIndex(o=>o.getAttribute(k.resizeHandleId)===n);return i??null}function sn(e,n,t){const r=ln(e,n,t);return r!=null?[r,r+1]:[-1,-1]}function an(e,n=document){var t;if(n instanceof HTMLElement&&(n==null||(t=n.dataset)===null||t===void 0?void 0:t.panelGroupId)==e)return n;const r=n.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return r||null}function Ie(e,n=document){const t=n.querySelector(`[${k.resizeHandleId}="${e}"]`);return t||null}function Hn(e,n,t,r=document){var i,o,l,s;const a=Ie(n,r),h=ze(e,r),w=a?h.indexOf(a):-1,p=(i=(o=t[w])===null||o===void 0?void 0:o.id)!==null&&i!==void 0?i:null,u=(l=(s=t[w+1])===null||s===void 0?void 0:s.id)!==null&&l!==void 0?l:null;return[p,u]}function $n({committedValuesRef:e,eagerValuesRef:n,groupId:t,layout:r,panelDataArray:i,panelGroupElement:o,setLayout:l}){f.useRef({didWarnAboutMissingResizeHandle:!1}),ne(()=>{if(!o)return;const s=ze(t,o);for(let a=0;a<i.length-1;a++){const{valueMax:h,valueMin:w,valueNow:p}=Mn({layout:r,panelsArray:i,pivotIndices:[a,a+1]}),u=s[a];if(u!=null){const v=i[a];x(v,`No panel data found for index "${a}"`),u.setAttribute("aria-controls",v.id),u.setAttribute("aria-valuemax",""+Math.round(h)),u.setAttribute("aria-valuemin",""+Math.round(w)),u.setAttribute("aria-valuenow",p!=null?""+Math.round(p):"")}}return()=>{s.forEach((a,h)=>{a.removeAttribute("aria-controls"),a.removeAttribute("aria-valuemax"),a.removeAttribute("aria-valuemin"),a.removeAttribute("aria-valuenow")})}},[t,r,i,o]),f.useEffect(()=>{if(!o)return;const s=n.current;x(s,"Eager values not found");const{panelDataArray:a}=s,h=an(t,o);x(h!=null,`No group found for id "${t}"`);const w=ze(t,o);x(w,`No resize handles found for group id "${t}"`);const p=w.map(u=>{const v=u.getAttribute(k.resizeHandleId);x(v,"Resize handle element has no handle id attribute");const[z,C]=Hn(t,v,a,o);if(z==null||C==null)return()=>{};const E=b=>{if(!b.defaultPrevented)switch(b.key){case"Enter":{b.preventDefault();const L=a.findIndex(M=>M.id===z);if(L>=0){const M=a[L];x(M,`No panel data found for index ${L}`);const $=r[L],{collapsedSize:O=0,collapsible:R,minSize:P=0}=M.constraints;if($!=null&&R){const K=ge({delta:W($,O)?P-O:O-$,initialLayout:r,panelConstraints:a.map(J=>J.constraints),pivotIndices:sn(t,v,o),prevLayout:r,trigger:"keyboard"});r!==K&&l(K)}}break}}};return u.addEventListener("keydown",E),()=>{u.removeEventListener("keydown",E)}});return()=>{p.forEach(u=>u())}},[o,e,n,t,r,i,l])}function Ve(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function un(e,n){const t=e==="horizontal",{x:r,y:i}=Ee(n);return t?r:i}function Nn(e,n,t,r,i){const o=t==="horizontal",l=Ie(n,i);x(l,`No resize handle element found for id "${n}"`);const s=l.getAttribute(k.groupId);x(s,"Resize handle element has no group id attribute");let{initialCursorPosition:a}=r;const h=un(t,e),w=an(s,i);x(w,`No group element found for id "${s}"`);const p=w.getBoundingClientRect(),u=o?p.width:p.height;return(h-a)/u*100}function _n(e,n,t,r,i,o){if(je(e)){const l=t==="horizontal";let s=0;e.shiftKey?s=100:i!=null?s=i:s=10;let a=0;switch(e.key){case"ArrowDown":a=l?0:s;break;case"ArrowLeft":a=l?-s:0;break;case"ArrowRight":a=l?s:0;break;case"ArrowUp":a=l?0:-s;break;case"End":a=100;break;case"Home":a=-100;break}return a}else return r==null?0:Nn(e,n,t,r,o)}function Gn({panelDataArray:e}){const n=Array(e.length),t=e.map(o=>o.constraints);let r=0,i=100;for(let o=0;o<e.length;o++){const l=t[o];x(l,`Panel constraints not found for index ${o}`);const{defaultSize:s}=l;s!=null&&(r++,n[o]=s,i-=s)}for(let o=0;o<e.length;o++){const l=t[o];x(l,`Panel constraints not found for index ${o}`);const{defaultSize:s}=l;if(s!=null)continue;const a=e.length-r,h=i/a;r++,n[o]=h,i-=h}return n}function oe(e,n,t){n.forEach((r,i)=>{const o=e[i];x(o,`Panel data not found for index ${i}`);const{callbacks:l,constraints:s,id:a}=o,{collapsedSize:h=0,collapsible:w}=s,p=t[a];if(p==null||r!==p){t[a]=r;const{onCollapse:u,onExpand:v,onResize:z}=l;z&&z(r,p),w&&(u||v)&&(v&&(p==null||j(p,h))&&!j(r,h)&&v(),u&&(p==null||!j(p,h))&&j(r,h)&&u())}})}function ve(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!=n[t])return!1;return!0}function Bn({defaultSize:e,dragState:n,layout:t,panelData:r,panelIndex:i,precision:o=3}){const l=t[i];let s;return l==null?s=e!=null?e.toPrecision(o):"1":r.length===1?s="1":s=l.toPrecision(o),{flexBasis:0,flexGrow:s,flexShrink:1,overflow:"hidden",pointerEvents:n!==null?"none":void 0}}function Tn(e,n=10){let t=null;return(...i)=>{t!==null&&clearTimeout(t),t=setTimeout(()=>{e(...i)},n)}}function Oe(e){try{if(typeof localStorage<"u")e.getItem=n=>localStorage.getItem(n),e.setItem=(n,t)=>{localStorage.setItem(n,t)};else throw new Error("localStorage not supported in this environment")}catch(n){console.error(n),e.getItem=()=>null,e.setItem=()=>{}}}function cn(e){return`react-resizable-panels:${e}`}function fn(e){return e.map(n=>{const{constraints:t,id:r,idIsFromProps:i,order:o}=n;return i?r:o?`${o}:${JSON.stringify(t)}`:JSON.stringify(t)}).sort((n,t)=>n.localeCompare(t)).join(",")}function dn(e,n){try{const t=cn(e),r=n.getItem(t);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function Fn(e,n,t){var r,i;const o=(r=dn(e,t))!==null&&r!==void 0?r:{},l=fn(n);return(i=o[l])!==null&&i!==void 0?i:null}function Wn(e,n,t,r,i){var o;const l=cn(e),s=fn(n),a=(o=dn(e,i))!==null&&o!==void 0?o:{};a[s]={expandToSizes:Object.fromEntries(t.entries()),layout:r};try{i.setItem(l,JSON.stringify(a))}catch(h){console.error(h)}}function qe({layout:e,panelConstraints:n}){const t=[...e],r=t.reduce((o,l)=>o+l,0);if(t.length!==n.length)throw Error(`Invalid ${n.length} panel layout: ${t.map(o=>`${o}%`).join(", ")}`);if(!W(r,100)&&t.length>0)for(let o=0;o<n.length;o++){const l=t[o];x(l!=null,`No layout data found for index ${o}`);const s=100/r*l;t[o]=s}let i=0;for(let o=0;o<n.length;o++){const l=t[o];x(l!=null,`No layout data found for index ${o}`);const s=le({panelConstraints:n,panelIndex:o,size:l});l!=s&&(i+=l-s,t[o]=s)}if(!W(i,0))for(let o=0;o<n.length;o++){const l=t[o];x(l!=null,`No layout data found for index ${o}`);const s=l+i,a=le({panelConstraints:n,panelIndex:o,size:s});if(l!==a&&(i-=a-l,t[o]=a,W(i,0)))break}return t}const Kn=100,me={getItem:e=>(Oe(me),me.getItem(e)),setItem:(e,n)=>{Oe(me),me.setItem(e,n)}},Xe={};function pn({autoSaveId:e=null,children:n,className:t="",direction:r,forwardedRef:i,id:o=null,onLayout:l=null,keyboardResizeBy:s=null,storage:a=me,style:h,tagName:w="div",...p}){const u=Ne(o),v=f.useRef(null),[z,C]=f.useState(null),[E,b]=f.useState([]),L=kn(),M=f.useRef({}),$=f.useRef(new Map),O=f.useRef(0),R=f.useRef({autoSaveId:e,direction:r,dragState:z,id:u,keyboardResizeBy:s,onLayout:l,storage:a}),P=f.useRef({layout:E,panelDataArray:[],panelDataArrayChanged:!1});f.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),f.useImperativeHandle(i,()=>({getId:()=>R.current.id,getLayout:()=>{const{layout:c}=P.current;return c},setLayout:c=>{const{onLayout:m}=R.current,{layout:S,panelDataArray:g}=P.current,d=qe({layout:c,panelConstraints:g.map(y=>y.constraints)});Ve(S,d)||(b(d),P.current.layout=d,m&&m(d),oe(g,d,M.current))}}),[]),ne(()=>{R.current.autoSaveId=e,R.current.direction=r,R.current.dragState=z,R.current.id=u,R.current.onLayout=l,R.current.storage=a}),$n({committedValuesRef:R,eagerValuesRef:P,groupId:u,layout:E,panelDataArray:P.current.panelDataArray,setLayout:b,panelGroupElement:v.current}),f.useEffect(()=>{const{panelDataArray:c}=P.current;if(e){if(E.length===0||E.length!==c.length)return;let m=Xe[e];m==null&&(m=Tn(Wn,Kn),Xe[e]=m);const S=[...c],g=new Map($.current);m(e,S,g,E,a)}},[e,E,a]),f.useEffect(()=>{});const K=f.useCallback(c=>{const{onLayout:m}=R.current,{layout:S,panelDataArray:g}=P.current;if(c.constraints.collapsible){const d=g.map(q=>q.constraints),{collapsedSize:y=0,panelSize:I,pivotIndices:H}=Q(g,c,S);if(x(I!=null,`Panel size not found for panel "${c.id}"`),!j(I,y)){$.current.set(c.id,I);const X=ie(g,c)===g.length-1?I-y:y-I,A=ge({delta:X,initialLayout:S,panelConstraints:d,pivotIndices:H,prevLayout:S,trigger:"imperative-api"});ve(S,A)||(b(A),P.current.layout=A,m&&m(A),oe(g,A,M.current))}}},[]),J=f.useCallback((c,m)=>{const{onLayout:S}=R.current,{layout:g,panelDataArray:d}=P.current;if(c.constraints.collapsible){const y=d.map(U=>U.constraints),{collapsedSize:I=0,panelSize:H=0,minSize:q=0,pivotIndices:X}=Q(d,c,g),A=m??q;if(j(H,I)){const U=$.current.get(c.id),de=U!=null&&U>=A?U:A,Re=ie(d,c)===d.length-1?H-de:de-H,T=ge({delta:Re,initialLayout:g,panelConstraints:y,pivotIndices:X,prevLayout:g,trigger:"imperative-api"});ve(g,T)||(b(T),P.current.layout=T,S&&S(T),oe(d,T,M.current))}}},[]),F=f.useCallback(c=>{const{layout:m,panelDataArray:S}=P.current,{panelSize:g}=Q(S,c,m);return x(g!=null,`Panel size not found for panel "${c.id}"`),g},[]),G=f.useCallback((c,m)=>{const{panelDataArray:S}=P.current,g=ie(S,c);return Bn({defaultSize:m,dragState:z,layout:E,panelData:S,panelIndex:g})},[z,E]),D=f.useCallback(c=>{const{layout:m,panelDataArray:S}=P.current,{collapsedSize:g=0,collapsible:d,panelSize:y}=Q(S,c,m);return x(y!=null,`Panel size not found for panel "${c.id}"`),d===!0&&j(y,g)},[]),Z=f.useCallback(c=>{const{layout:m,panelDataArray:S}=P.current,{collapsedSize:g=0,collapsible:d,panelSize:y}=Q(S,c,m);return x(y!=null,`Panel size not found for panel "${c.id}"`),!d||te(y,g)>0},[]),_=f.useCallback(c=>{const{panelDataArray:m}=P.current;m.push(c),m.sort((S,g)=>{const d=S.order,y=g.order;return d==null&&y==null?0:d==null?-1:y==null?1:d-y}),P.current.panelDataArrayChanged=!0,L()},[L]);ne(()=>{if(P.current.panelDataArrayChanged){P.current.panelDataArrayChanged=!1;const{autoSaveId:c,onLayout:m,storage:S}=R.current,{layout:g,panelDataArray:d}=P.current;let y=null;if(c){const H=Fn(c,d,S);H&&($.current=new Map(Object.entries(H.expandToSizes)),y=H.layout)}y==null&&(y=Gn({panelDataArray:d}));const I=qe({layout:y,panelConstraints:d.map(H=>H.constraints)});Ve(g,I)||(b(I),P.current.layout=I,m&&m(I),oe(d,I,M.current))}}),ne(()=>{const c=P.current;return()=>{c.layout=[]}},[]);const N=f.useCallback(c=>{let m=!1;const S=v.current;return S&&window.getComputedStyle(S,null).getPropertyValue("direction")==="rtl"&&(m=!0),function(d){d.preventDefault();const y=v.current;if(!y)return()=>null;const{direction:I,dragState:H,id:q,keyboardResizeBy:X,onLayout:A}=R.current,{layout:U,panelDataArray:de}=P.current,{initialLayout:xe}=H??{},Re=sn(q,c,y);let T=_n(d,c,I,H,X,y);const Be=I==="horizontal";Be&&m&&(T=-T);const gn=de.map(mn=>mn.constraints),pe=ge({delta:T,initialLayout:xe??U,panelConstraints:gn,pivotIndices:Re,prevLayout:U,trigger:je(d)?"keyboard":"mouse-or-touch"}),Te=!ve(U,pe);(Ye(d)||Ze(d))&&O.current!=T&&(O.current=T,!Te&&T!==0?Be?De(c,T<0?en:nn):De(c,T<0?tn:rn):De(c,0)),Te&&(b(pe),P.current.layout=pe,A&&A(pe),oe(de,pe,M.current))}},[]),B=f.useCallback((c,m)=>{const{onLayout:S}=R.current,{layout:g,panelDataArray:d}=P.current,y=d.map(U=>U.constraints),{panelSize:I,pivotIndices:H}=Q(d,c,g);x(I!=null,`Panel size not found for panel "${c.id}"`);const X=ie(d,c)===d.length-1?I-m:m-I,A=ge({delta:X,initialLayout:g,panelConstraints:y,pivotIndices:H,prevLayout:g,trigger:"imperative-api"});ve(g,A)||(b(A),P.current.layout=A,S&&S(A),oe(d,A,M.current))},[]),ae=f.useCallback((c,m)=>{const{layout:S,panelDataArray:g}=P.current,{collapsedSize:d=0,collapsible:y}=m,{collapsedSize:I=0,collapsible:H,maxSize:q=100,minSize:X=0}=c.constraints,{panelSize:A}=Q(g,c,S);A!=null&&(y&&H&&j(A,d)?j(d,I)||B(c,I):A<X?B(c,X):A>q&&B(c,q))},[B]),ue=f.useCallback((c,m)=>{const{direction:S}=R.current,{layout:g}=P.current;if(!v.current)return;const d=Ie(c,v.current);x(d,`Drag handle element not found for id "${c}"`);const y=un(S,m);C({dragHandleId:c,dragHandleRect:d.getBoundingClientRect(),initialCursorPosition:y,initialLayout:g})},[]),ce=f.useCallback(()=>{C(null)},[]),ye=f.useCallback(c=>{const{panelDataArray:m}=P.current,S=ie(m,c);S>=0&&(m.splice(S,1),delete M.current[c.id],P.current.panelDataArrayChanged=!0,L())},[L]),re=f.useMemo(()=>({collapsePanel:K,direction:r,dragState:z,expandPanel:J,getPanelSize:F,getPanelStyle:G,groupId:u,isPanelCollapsed:D,isPanelExpanded:Z,reevaluatePanelConstraints:ae,registerPanel:_,registerResizeHandle:N,resizePanel:B,startDragging:ue,stopDragging:ce,unregisterPanel:ye,panelGroupElement:v.current}),[K,z,r,J,F,G,u,D,Z,ae,_,N,B,ue,ce,ye]),fe={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return f.createElement(we.Provider,{value:re},f.createElement(w,{...p,children:n,className:t,id:o,ref:v,style:{...fe,...h},[k.group]:"",[k.groupDirection]:r,[k.groupId]:u}))}const Un=f.forwardRef((e,n)=>f.createElement(pn,{...e,forwardedRef:n}));pn.displayName="PanelGroup";Un.displayName="forwardRef(PanelGroup)";function ie(e,n){return e.findIndex(t=>t===n||t.id===n.id)}function Q(e,n,t){const r=ie(e,n),o=r===e.length-1?[r-1,r]:[r,r+1],l=t[r];return{...n.constraints,panelSize:l,pivotIndices:o}}function Vn({disabled:e,handleId:n,resizeHandler:t,panelGroupElement:r}){f.useEffect(()=>{if(e||t==null||r==null)return;const i=Ie(n,r);if(i==null)return;const o=l=>{if(!l.defaultPrevented)switch(l.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{l.preventDefault(),t(l);break}case"F6":{l.preventDefault();const s=i.getAttribute(k.groupId);x(s,`No group element found for id "${s}"`);const a=ze(s,r),h=ln(s,n,r);x(h!==null,`No resize element found for id "${n}"`);const w=l.shiftKey?h>0?h-1:a.length-1:h+1<a.length?h+1:0;a[w].focus();break}}};return i.addEventListener("keydown",o),()=>{i.removeEventListener("keydown",o)}},[r,e,n,t])}function On({children:e=null,className:n="",disabled:t=!1,hitAreaMargins:r,id:i,onBlur:o,onClick:l,onDragging:s,onFocus:a,onPointerDown:h,onPointerUp:w,style:p={},tabIndex:u=0,tagName:v="div",...z}){var C,E;const b=f.useRef(null),L=f.useRef({onClick:l,onDragging:s,onPointerDown:h,onPointerUp:w});f.useEffect(()=>{L.current.onClick=l,L.current.onDragging=s,L.current.onPointerDown=h,L.current.onPointerUp=w});const M=f.useContext(we);if(M===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:$,groupId:O,registerResizeHandle:R,startDragging:P,stopDragging:K,panelGroupElement:J}=M,F=Ne(i),[G,D]=f.useState("inactive"),[Z,_]=f.useState(!1),[N,B]=f.useState(null),ae=f.useRef({state:G});ne(()=>{ae.current.state=G}),f.useEffect(()=>{if(t)B(null);else{const re=R(F);B(()=>re)}},[t,F,R]);const ue=(C=r==null?void 0:r.coarse)!==null&&C!==void 0?C:15,ce=(E=r==null?void 0:r.fine)!==null&&E!==void 0?E:5;f.useEffect(()=>{if(t||N==null)return;const re=b.current;x(re,"Element ref not attached");let fe=!1;return Ln(F,re,$,{coarse:ue,fine:ce},(m,S,g)=>{if(!S){D("inactive");return}switch(m){case"down":{D("drag"),fe=!1,x(g,'Expected event to be defined for "down" action'),P(F,g);const{onDragging:d,onPointerDown:y}=L.current;d==null||d(!0),y==null||y();break}case"move":{const{state:d}=ae.current;fe=!0,d!=="drag"&&D("hover"),x(g,'Expected event to be defined for "move" action'),N(g);break}case"up":{D("hover"),K();const{onClick:d,onDragging:y,onPointerUp:I}=L.current;y==null||y(!1),I==null||I(),fe||d==null||d();break}}})},[ue,$,t,ce,R,F,N,P,K]),Vn({disabled:t,handleId:F,resizeHandler:N,panelGroupElement:J});const ye={touchAction:"none",userSelect:"none"};return f.createElement(v,{...z,children:e,className:n,id:i,onBlur:()=>{_(!1),o==null||o()},onFocus:()=>{_(!0),a==null||a()},ref:b,role:"separator",style:{...ye,...p},tabIndex:u,[k.groupDirection]:$,[k.groupId]:O,[k.resizeHandle]:"",[k.resizeHandleActive]:G==="drag"?"pointer":Z?"keyboard":void 0,[k.resizeHandleEnabled]:!t,[k.resizeHandleId]:F,[k.resizeHandleState]:G})}On.displayName="PanelResizeHandle";export{Un as P,xn as a,On as b};
|
package/web/dist/favicon.svg
CHANGED
|
@@ -1,12 +1,32 @@
|
|
|
1
|
-
<svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<defs>
|
|
3
|
-
<linearGradient id="fav-bg" x1="0" y1="0" x2="64" y2="64" gradientUnits="userSpaceOnUse">
|
|
4
|
-
<stop stop-color="#
|
|
5
|
-
<stop offset="
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
</
|
|
1
|
+
<svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="fav-bg" x1="0" y1="0" x2="64" y2="64" gradientUnits="userSpaceOnUse">
|
|
4
|
+
<stop stop-color="#38BDF8"/>
|
|
5
|
+
<stop offset="0.52" stop-color="#6366F1"/>
|
|
6
|
+
<stop offset="1" stop-color="#A855F7"/>
|
|
7
|
+
</linearGradient>
|
|
8
|
+
<radialGradient id="fav-sheen" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(14.4 10.6) scale(47.5)">
|
|
9
|
+
<stop stop-color="#FFFFFF" stop-opacity="0.20"/>
|
|
10
|
+
<stop offset="0.55" stop-color="#FFFFFF" stop-opacity="0.04"/>
|
|
11
|
+
<stop offset="1" stop-color="#FFFFFF" stop-opacity="0"/>
|
|
12
|
+
</radialGradient>
|
|
13
|
+
<radialGradient id="fav-glow" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(30.4 33.75) scale(26.25)">
|
|
14
|
+
<stop stop-color="#FFFFFF" stop-opacity="0.30"/>
|
|
15
|
+
<stop offset="1" stop-color="#FFFFFF" stop-opacity="0"/>
|
|
16
|
+
</radialGradient>
|
|
17
|
+
<linearGradient id="fav-spark" x1="29.69" y1="15.31" x2="29.69" y2="52.81" gradientUnits="userSpaceOnUse">
|
|
18
|
+
<stop stop-color="#FFFFFF"/>
|
|
19
|
+
<stop offset="1" stop-color="#D7E6FF"/>
|
|
20
|
+
</linearGradient>
|
|
21
|
+
<clipPath id="fav-round">
|
|
22
|
+
<rect width="64" height="64" rx="14.5"/>
|
|
23
|
+
</clipPath>
|
|
24
|
+
</defs>
|
|
25
|
+
<g clip-path="url(#fav-round)">
|
|
26
|
+
<rect width="64" height="64" fill="url(#fav-bg)"/>
|
|
27
|
+
<rect width="64" height="64" fill="url(#fav-sheen)"/>
|
|
28
|
+
<circle cx="30.4" cy="33.75" r="26.25" fill="url(#fav-glow)"/>
|
|
29
|
+
<path d="M29.69 15.31 Q32.19 31.56 48.44 34.06 Q32.19 36.56 29.69 52.81 Q27.19 36.56 10.94 34.06 Q27.19 31.56 29.69 15.31 Z" fill="url(#fav-spark)"/>
|
|
30
|
+
<path d="M50 8.13 Q50.88 13.81 56.56 14.69 Q50.88 15.56 50 21.25 Q49.13 15.56 43.44 14.69 Q49.13 13.81 50 8.13 Z" fill="#FFFFFF" fill-opacity="0.92"/>
|
|
31
|
+
</g>
|
|
32
|
+
</svg>
|
package/web/dist/index.html
CHANGED
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
<meta name="theme-color" content="#0d1117" />
|
|
13
13
|
<meta name="color-scheme" content="dark light" />
|
|
14
14
|
<title>DeepSeekCode Web</title>
|
|
15
|
-
<script type="module" crossorigin src="/assets/index-
|
|
16
|
-
<link rel="modulepreload" crossorigin href="/assets/icons-
|
|
17
|
-
<link rel="modulepreload" crossorigin href="/assets/markdown-
|
|
18
|
-
<link rel="modulepreload" crossorigin href="/assets/react-vendor-
|
|
19
|
-
<link rel="modulepreload" crossorigin href="/assets/state-
|
|
20
|
-
<link rel="modulepreload" crossorigin href="/assets/panels-
|
|
21
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
15
|
+
<script type="module" crossorigin src="/assets/index-DUpwXfa-.js"></script>
|
|
16
|
+
<link rel="modulepreload" crossorigin href="/assets/icons-qcawb7PZ.js">
|
|
17
|
+
<link rel="modulepreload" crossorigin href="/assets/markdown-yjmXQjrx.js">
|
|
18
|
+
<link rel="modulepreload" crossorigin href="/assets/react-vendor-CSlQceOk.js">
|
|
19
|
+
<link rel="modulepreload" crossorigin href="/assets/state-DOzZasIm.js">
|
|
20
|
+
<link rel="modulepreload" crossorigin href="/assets/panels-CX_dYEv0.js">
|
|
21
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DL2ULWxM.css">
|
|
22
22
|
</head>
|
|
23
23
|
<body>
|
|
24
24
|
<div id="root"></div>
|
package/web/dist/logo.svg
CHANGED
|
@@ -1,12 +1,32 @@
|
|
|
1
|
-
<svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="DeepSeekCode">
|
|
2
|
-
<defs>
|
|
3
|
-
<linearGradient id="
|
|
4
|
-
<stop stop-color="#
|
|
5
|
-
<stop offset="
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
</
|
|
1
|
+
<svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="DeepSeekCode">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="dc-bg" x1="0" y1="0" x2="64" y2="64" gradientUnits="userSpaceOnUse">
|
|
4
|
+
<stop stop-color="#38BDF8"/>
|
|
5
|
+
<stop offset="0.52" stop-color="#6366F1"/>
|
|
6
|
+
<stop offset="1" stop-color="#A855F7"/>
|
|
7
|
+
</linearGradient>
|
|
8
|
+
<radialGradient id="dc-sheen" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(14.4 10.6) scale(47.5)">
|
|
9
|
+
<stop stop-color="#FFFFFF" stop-opacity="0.20"/>
|
|
10
|
+
<stop offset="0.55" stop-color="#FFFFFF" stop-opacity="0.04"/>
|
|
11
|
+
<stop offset="1" stop-color="#FFFFFF" stop-opacity="0"/>
|
|
12
|
+
</radialGradient>
|
|
13
|
+
<radialGradient id="dc-glow" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(30.4 33.75) scale(26.25)">
|
|
14
|
+
<stop stop-color="#FFFFFF" stop-opacity="0.30"/>
|
|
15
|
+
<stop offset="1" stop-color="#FFFFFF" stop-opacity="0"/>
|
|
16
|
+
</radialGradient>
|
|
17
|
+
<linearGradient id="dc-spark" x1="29.69" y1="15.31" x2="29.69" y2="52.81" gradientUnits="userSpaceOnUse">
|
|
18
|
+
<stop stop-color="#FFFFFF"/>
|
|
19
|
+
<stop offset="1" stop-color="#D7E6FF"/>
|
|
20
|
+
</linearGradient>
|
|
21
|
+
<clipPath id="dc-round">
|
|
22
|
+
<rect width="64" height="64" rx="14.5"/>
|
|
23
|
+
</clipPath>
|
|
24
|
+
</defs>
|
|
25
|
+
<g clip-path="url(#dc-round)">
|
|
26
|
+
<rect width="64" height="64" fill="url(#dc-bg)"/>
|
|
27
|
+
<rect width="64" height="64" fill="url(#dc-sheen)"/>
|
|
28
|
+
<circle cx="30.4" cy="33.75" r="26.25" fill="url(#dc-glow)"/>
|
|
29
|
+
<path d="M29.69 15.31 Q32.19 31.56 48.44 34.06 Q32.19 36.56 29.69 52.81 Q27.19 36.56 10.94 34.06 Q27.19 31.56 29.69 15.31 Z" fill="url(#dc-spark)"/>
|
|
30
|
+
<path d="M50 8.13 Q50.88 13.81 56.56 14.69 Q50.88 15.56 50 21.25 Q49.13 15.56 43.44 14.69 Q49.13 13.81 50 8.13 Z" fill="#FFFFFF" fill-opacity="0.92"/>
|
|
31
|
+
</g>
|
|
32
|
+
</svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./markdown-BrFQfawv.js";import{a,ak as k,h as $,z as T,_ as O,ba as D,f as I,aq as L,aO as U,X as J}from"./icons-B9mi2ie6.js";import{U as _}from"./index-PcXINYWS.js";import"./react-vendor-CiRFOYk_.js";import"./state-BcoCffxz.js";import"./panels-BX-TtLOU.js";function K(){const{automations:r,runsByAutomation:c,fetchAutomations:n,createAutomation:v,deleteAutomation:N,toggleAutomation:y,runAutomation:w,fetchRuns:C,error:l}=_(),[A,i]=a.useState(!1),[x,S]=a.useState(null),[m,u]=a.useState(""),[p,h]=a.useState(""),[o,b]=a.useState("0 9 * * *"),[g,f]=a.useState("");a.useEffect(()=>{n()},[n]);const z=async t=>{const s=g.trim();if(!s)return;const[d,...R]=s.split(/\s+/),j=R.join(" ");d&&j&&(await fetch(`/api/automations/${encodeURIComponent(t)}/permissions`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tool:d,target:j})})).ok&&(f(""),await n())},E=async(t,s)=>{(await fetch(`/api/automations/${encodeURIComponent(t)}/permissions`,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({entry:s})})).ok&&await n()},P=async t=>{const s=x===t?null:t;S(s),s&&await C(t)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(k,{size:20,className:"text-accent-blue"}),"定时自动化",e.jsxs("span",{className:"text-xs text-dark-muted font-normal",children:["(",r.length,")"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>void n(),className:"p-2 rounded-lg hover:bg-dark-hover text-dark-muted",title:"刷新",children:e.jsx($,{size:16})}),e.jsxs("button",{onClick:()=>i(t=>!t),className:"flex items-center gap-1 px-3 py-1.5 rounded-lg bg-accent-blue/20 text-accent-blue hover:bg-accent-blue/30 text-sm font-medium",children:[e.jsx(T,{size:16})," 新建"]})]})]}),l&&e.jsxs("div",{className:"mb-3 p-3 rounded-lg bg-accent-red/10 text-accent-red text-sm flex items-center gap-2",children:[e.jsx(O,{size:16})," ",l]}),A&&e.jsxs("div",{className:"mb-4 rounded-lg border border-dark-border bg-dark-surface p-4 space-y-3",children:[e.jsx("input",{value:m,onChange:t=>u(t.target.value),placeholder:"名称(如:每早 9 点汇总 Git 状态)",className:"w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue"}),e.jsx("textarea",{value:p,onChange:t=>h(t.target.value),placeholder:"指令(agent 每次触发时执行的内容)",rows:3,className:"w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue resize-none"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:o,onChange:t=>b(t.target.value),placeholder:"cron(5 段,如 0 9 * * *)",className:"flex-1 px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue"}),e.jsx("button",{onClick:async()=>{await v({name:m,instructions:p,schedule:{kind:"cron",cron:o}})&&(u(""),h(""),i(!1))},className:"px-4 py-2 rounded-lg bg-accent-blue text-white text-sm font-medium hover:bg-accent-blue/80",children:"创建"})]}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:[["0 9 * * *","每天 9:00"],["0 9 * * 1-5","工作日 9:00"],["*/30 * * * *","每 30 分钟"]].map(([t,s])=>e.jsxs("button",{onClick:()=>b(t),className:`px-2 py-1 rounded text-xs ${o===t?"bg-accent-blue/20 text-accent-blue":"bg-dark-hover text-dark-muted hover:text-dark-text"}`,children:[s," (",t,")"]},t))})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2",children:[r.length===0&&e.jsx("p",{className:"text-dark-muted text-center py-8",children:"还没有定时自动化。新建一个,让 agent 无人值守干活。"}),r.map(t=>e.jsxs("div",{className:"rounded-lg border border-dark-border bg-dark-surface",children:[e.jsxs("div",{className:"flex items-center justify-between p-3",children:[e.jsxs("button",{onClick:()=>void P(t.id),className:"flex items-center gap-2 min-w-0 text-left",children:[e.jsx(k,{size:16,className:"text-accent-blue shrink-0"}),e.jsx("span",{className:"font-medium text-sm truncate",children:t.name}),e.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded shrink-0 ${t.status==="enabled"?"bg-accent-green/20 text-accent-green":"bg-dark-hover text-dark-muted"}`,children:t.status})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsxs("span",{className:"text-xs text-dark-muted hidden lg:inline mr-1",children:[t.schedule.kind==="cron"?t.schedule.cron:t.schedule.fireAt,t.nextRunAt?` · ${new Date(t.nextRunAt).toLocaleString()}`:""]}),e.jsx("button",{onClick:()=>void y(t.id,t.status!=="enabled"),className:"p-1.5 rounded-lg hover:bg-dark-hover text-dark-muted",title:t.status==="enabled"?"停用":"启用",children:e.jsx(D,{size:15})}),e.jsx("button",{onClick:()=>void w(t.id),className:"p-1.5 rounded-lg hover:bg-dark-hover text-accent-green",title:"手动触发",children:e.jsx(I,{size:15})}),e.jsx("button",{onClick:()=>void N(t.id),className:"p-1.5 rounded-lg hover:bg-dark-hover text-accent-red",title:"删除",children:e.jsx(L,{size:15})})]})]}),x===t.id&&e.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t border-dark-border pt-3",children:[e.jsx("p",{className:"text-xs text-dark-muted whitespace-pre-wrap",children:t.instructions}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-semibold text-dark-muted mb-1 flex items-center gap-1",children:[e.jsx(U,{size:12})," 运行历史"]}),(c[t.id]||[]).length===0&&e.jsx("p",{className:"text-xs text-dark-muted",children:"暂无运行记录"}),(c[t.id]||[]).slice(0,10).map(s=>e.jsxs("div",{className:"flex items-center gap-2 text-xs py-1",children:[e.jsx("span",{className:`px-1.5 py-0.5 rounded ${s.status==="ok"?"bg-accent-green/20 text-accent-green":s.status==="error"?"bg-accent-red/20 text-accent-red":"bg-accent-yellow/20 text-accent-yellow"}`,children:s.status}),e.jsx("span",{className:"text-dark-muted",children:new Date(s.startedAt).toLocaleString()}),e.jsxs("span",{className:"text-dark-muted truncate flex-1",children:["#",s.id.slice(0,8)," · ",s.trigger]})]},s.id))]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-semibold text-dark-muted mb-1",children:"作用域放行(tool target)"}),t.permissions.length===0&&e.jsx("p",{className:"text-xs text-dark-muted",children:"无。未放行的写操作需人工批准,超时后自动拒绝。"}),e.jsx("div",{className:"flex flex-wrap gap-1 mb-1",children:t.permissions.map(s=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded bg-accent-blue/10 text-accent-blue text-xs",children:[s,e.jsx("button",{onClick:()=>void E(t.id,s),className:"hover:text-accent-red",children:e.jsx(J,{size:12})})]},s))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:g,onChange:s=>f(s.target.value),placeholder:"如:write_file docs/report.md",className:"flex-1 px-2 py-1.5 rounded-lg bg-dark-bg border border-dark-border text-xs focus:outline-none focus:border-accent-blue"}),e.jsx("button",{onClick:()=>void z(t.id),className:"px-3 py-1.5 rounded-lg bg-dark-hover text-dark-muted hover:text-dark-text text-xs",children:"添加"})]})]})]})]},t.id))]})]})}export{K as AutomationView};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{j as i}from"./markdown-BrFQfawv.js";import{a as M,bb as ft,_ as ht,aw as gt,av as mt,aj as kt,z as ne,bc as Be,aq as xt,a7 as Et,g as vt,h as St}from"./icons-B9mi2ie6.js";import{S as Te,M as Bt,a as Pe,t as re}from"./index-PcXINYWS.js";import"./react-vendor-CiRFOYk_.js";import"./state-BcoCffxz.js";import"./panels-BX-TtLOU.js";const Tt={wechat:"微信",feishu:"飞书",dingtalk:"钉钉",telegram:"Telegram",discord:"Discord",slack:"Slack",signal:"Signal",whatsapp:"WhatsApp",line:"LINE",qqbot:"QQ Bot",matrix:"Matrix",mattermost:"Mattermost",msteams:"Teams",googlechat:"Google Chat",irc:"IRC",imessage:"iMessage",sms:"SMS","nextcloud-talk":"Nextcloud Talk",nostr:"Nostr","synology-chat":"Synology Chat",tlon:"Tlon",twitch:"Twitch",zalo:"Zalo",zalouser:"ZaloUser",clickclack:"ClickClack",raft:"Raft","qa-channel":"QA"},At={wechat:"💬",feishu:"📘",dingtalk:"🔔",telegram:"✈️",discord:"🎮",slack:"💼",signal:"🔒",whatsapp:"📱",line:"🟢",qqbot:"🐧",matrix:"🧩",mattermost:"🏢",msteams:"📋",googlechat:"📧",irc:"💻",imessage:"✉️",sms:"📨"},Rt=new Set(["mattermost","msteams","googlechat","irc","imessage","sms","nextcloud-talk","nostr","synology-chat","tlon","twitch","zalo","zalouser","clickclack","raft","qa-channel"]);function V(n){return Tt[n]??n}function $(n){return At[n]??"📡"}function J(n){return Rt.has(n)}const G=[{label:"即时通讯",types:["wechat","feishu","dingtalk"]},{label:"国际主流",types:["telegram","discord","slack","signal","whatsapp"]},{label:"东亚",types:["line","qqbot"]},{label:"协作平台",types:["matrix","mattermost","msteams","googlechat"]},{label:"经典协议",types:["irc","imessage","sms"]},{label:"其他",types:["nextcloud-talk","nostr","synology-chat","tlon","twitch","zalo","zalouser"]},{label:"内置",types:["clickclack","raft","qa-channel"]}];function Mt(){const{channels:n,availableTypes:r,selectedType:o,selectType:t,loadTypes:e}=Te();M.useEffect(()=>{e()},[e]);const s=M.useMemo(()=>{if(r.length>0){const u=new Set(r);return G.map(d=>({...d,types:d.types.filter(m=>u.has(m))})).filter(d=>d.types.length>0).concat(r.filter(d=>!G.flatMap(m=>m.types).includes(d)).length>0?[{label:"插件扩展",types:r.filter(d=>!G.flatMap(m=>m.types).includes(d))}]:[])}return G},[r]),a=M.useMemo(()=>{const u=new Map;for(const d of n){const m=u.get(d.type)??{count:0,connected:0};u.set(d.type,{count:m.count+1,connected:m.connected+(d.connected?1:0)})}return u},[n]),c=r.length>0,l=M.useMemo(()=>c?[...a.keys()].filter(u=>!r.includes(u)):[],[c,a,r]);return i.jsxs("div",{className:"flex flex-col h-full min-h-0 border-r border-dark-border bg-dark-surface",children:[i.jsxs("div",{className:"shrink-0 px-4 py-3 border-b border-dark-border",children:[i.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-dark-muted",children:"频道列表"}),i.jsx("p",{className:"text-[11px] text-dark-muted mt-0.5",children:n.length>0?`${n.length} 个已配置`:"点击下方频道开始配置"})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:[s.map(u=>{const d=u.types.filter(m=>a.has(m));return d.length===0?null:i.jsxs("div",{children:[i.jsx("div",{className:"sticky top-0 bg-dark-surface/95 backdrop-blur px-4 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-dark-muted/60",children:u.label}),d.map(m=>{const g=a.get(m);return i.jsx(se,{label:V(m),icon:$(m),isSelected:o===m,experimental:J(m),info:g,pluginMissing:c&&!r.includes(m),onClick:()=>t(m)},m)})]},u.label)}),l.length>0&&i.jsxs("div",{children:[i.jsx("div",{className:"sticky top-0 bg-dark-surface/95 backdrop-blur px-4 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-amber-500/80",children:"已配置 · 插件未安装"}),l.map(u=>{const d=a.get(u);return i.jsx(se,{label:V(u),icon:$(u),isSelected:o===u,experimental:J(u),info:d,pluginMissing:!0,onClick:()=>t(u)},u)})]}),(()=>{const u=s.flatMap(d=>d.types).filter(d=>!a.has(d));return u.length===0?null:i.jsxs("div",{children:[i.jsx("div",{className:"sticky top-0 bg-dark-surface/95 backdrop-blur px-4 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-dark-muted/60",children:"未配置"}),u.map(d=>i.jsx(se,{label:V(d),icon:$(d),isSelected:o===d,experimental:J(d),onClick:()=>t(d)},d))]})})()]})]})}function se({label:n,icon:r,isSelected:o,experimental:t,info:e,pluginMissing:s,onClick:a}){return i.jsxs("button",{onClick:a,className:`w-full flex items-center gap-2.5 px-4 py-2.5 text-left transition-colors hover:bg-dark-hover ${o?"bg-accent-blue/10 border-l-2 border-accent-blue":"border-l-2 border-transparent"}`,children:[i.jsx("span",{className:"text-lg shrink-0 w-7 h-7 flex items-center justify-center rounded-md bg-dark-bg",children:r}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:"text-sm font-medium text-dark-text truncate",children:n}),t&&i.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[9px] text-yellow-500 bg-yellow-500/10 px-1 py-0.5 rounded shrink-0",title:"实验性实现,功能不完整",children:[i.jsx(ft,{className:"w-2.5 h-2.5"})," 实验"]}),s&&i.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[9px] text-amber-500 bg-amber-500/10 border border-amber-500/30 px-1 py-0.5 rounded shrink-0",title:"该频道类型的插件未安装或未激活,无法启动实例",children:[i.jsx(ht,{className:"w-2.5 h-2.5"})," 插件未安装"]}),e&&i.jsx("span",{className:"text-[10px] text-dark-muted bg-dark-hover px-1.5 py-0.5 rounded shrink-0",children:e.count})]}),i.jsx("div",{className:"flex items-center gap-1 mt-0.5",children:e?e.connected>0?i.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-green-400",children:[i.jsx(gt,{className:"w-3 h-3"}),e.connected===e.count?"已连接":`${e.connected}/${e.count} 已连接`]}):i.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-dark-muted",children:[i.jsx(mt,{className:"w-3 h-3"}),s?"等待安装插件":"未连接"]}):i.jsx("span",{className:"text-[11px] text-dark-muted",children:"未配置"})})]})]})}const z={name:"",type:"wechat",appId:"",appSecret:"",token:"",encodingAESKey:"",enabled:!0};function It(){const{channels:n,selectedType:r,availableTypes:o,create:t,update:e,remove:s,toggle:a,error:c,clearError:l,openQr:u,load:d}=Te(),m=M.useMemo(()=>o.length>0&&!!r&&!o.includes(r),[o,r]),g=M.useMemo(()=>r?n.filter(h=>h.type===r):[],[n,r]),[x,j]=M.useState(""),[S,R]=M.useState(z),[v,B]=M.useState(!1),C=x==="__new__",f=M.useMemo(()=>C?null:g.find(h=>h.id===x)??null,[g,x,C]);M.useEffect(()=>{j(""),R(z),B(!1),l()},[r]),M.useEffect(()=>{r==="wechat"&&g.length===0&&!m&&u(null)},[r,g.length,m,u]),M.useEffect(()=>{f?R({name:f.name,type:f.type,appId:f.appId||"",appSecret:"",token:"",encodingAESKey:f.encodingAESKey||"",enabled:f.enabled}):C&&R(h=>({...h,type:r}))},[x]);const A=(h,w)=>{l(),R(T=>({...T,[h]:w}))},p=h=>{j(h),l()},y=()=>{j("__new__"),R({...z,type:r}),l()},k=()=>{j(""),R(z),l()},b=async()=>{if(!S.name.trim())return;B(!0);const h=f?await e(f.id,S):await t(S);B(!1),h&&(j(""),R(z))},E=async h=>{if(!confirm("确认删除该频道?"))return;await s(h)&&x===h&&(j(""),R(z))},N=(h,w)=>{a(h,w)};return r?i.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[i.jsx("div",{className:"shrink-0 px-6 py-4 border-b border-dark-border",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("span",{className:"text-2xl",children:$(r)}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("h2",{className:"font-semibold text-base text-dark-text",children:V(r)}),J(r)&&i.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[10px] text-yellow-500 bg-yellow-500/10 px-1.5 py-0.5 rounded",title:"实验性实现,功能不完整",children:[i.jsx(ft,{className:"w-3 h-3"})," 实验性"]})]}),i.jsx("p",{className:"text-xs text-dark-muted mt-0.5",children:g.length>0?`${g.length} 个配置实例`:"尚未配置"}),J(r)&&i.jsx("p",{className:"text-[10px] text-yellow-600/70 mt-1",children:"此频道为基础适配器封装,支持基础消息收发,部分高级功能可能不完整"})]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:()=>d(),className:"text-xs px-3 py-1.5 rounded-lg border border-dark-border text-dark-muted hover:text-dark-text hover:bg-dark-hover transition-colors",children:"刷新"}),i.jsxs("button",{onClick:y,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg bg-accent-blue hover:bg-accent-blue/90 text-white transition-colors",children:[i.jsx(ne,{className:"w-3.5 h-3.5"})," 新建实例"]})]})]})}),c&&i.jsxs("div",{className:"shrink-0 mx-6 mt-3 bg-red-500/10 border border-red-500/40 text-red-400 px-3 py-2 rounded-lg text-sm flex justify-between items-center",children:[i.jsx("span",{children:c}),i.jsx("button",{onClick:l,className:"text-red-400 hover:text-red-300",children:i.jsx("span",{className:"w-4 h-4 inline-flex items-center justify-center",children:"×"})})]}),m&&i.jsxs("div",{className:"shrink-0 mx-6 mt-3 flex items-start gap-2 bg-amber-500/10 border border-amber-500/40 text-amber-400 px-3 py-2 rounded-lg text-xs",children:[i.jsx(ht,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),i.jsxs("span",{children:["该频道类型的插件未安装或未激活,实例无法启动。请到「插件」页安装并激活",r==="wechat"?" WeChat Channel":` ${V(r)}`," 插件后重试。"]})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto custom-scrollbar p-6",children:[g.length>1&&!C&&i.jsxs("div",{className:"mb-4",children:[i.jsx("label",{className:"block text-xs text-dark-muted mb-1.5",children:"选择实例"}),i.jsxs("div",{className:"flex flex-wrap gap-2",children:[g.map(h=>i.jsxs("button",{onClick:()=>p(h.id),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs border transition-colors ${x===h.id?"bg-accent-blue/10 border-accent-blue/40 text-accent-blue":"border-dark-border text-dark-muted hover:text-dark-text hover:bg-dark-hover"}`,children:[i.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${h.connected?"bg-green-500":"bg-gray-500"}`}),h.name]},h.id)),i.jsxs("button",{onClick:y,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs border border-dashed border-dark-border text-dark-muted hover:text-dark-text hover:bg-dark-hover transition-colors",children:[i.jsx(ne,{className:"w-3 h-3"})," 新建"]})]})]}),g.length===0&&x===""&&i.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[i.jsx("div",{className:"text-4xl mb-3",children:$(r)}),i.jsxs("p",{className:"text-dark-text font-medium",children:["还没有配置 ",V(r)]}),i.jsx("p",{className:"text-sm text-dark-muted mt-1 mb-4",children:r==="wechat"?"点击下方按钮,用微信扫码即可自动完成绑定":"点击上方「新建实例」开始配置"}),r==="wechat"&&i.jsxs("button",{onClick:()=>u(null),className:"flex items-center gap-1.5 text-sm px-4 py-2 rounded-lg bg-green-600/15 hover:bg-green-600/25 text-green-400 border border-green-600/40 transition-colors mb-3",children:[i.jsx(Be,{className:"w-4 h-4"})," 扫码绑定"]}),i.jsxs("button",{onClick:y,className:"flex items-center gap-1.5 text-sm px-4 py-2 rounded-lg bg-accent-blue hover:bg-accent-blue/90 text-white transition-colors",children:[i.jsx(ne,{className:"w-4 h-4"})," 新建实例"]})]}),g.length===1&&x===""&&g[0]&&i.jsx(Le,{channel:g[0],onEdit:()=>p(g[0].id),onDelete:()=>E(g[0].id),onToggle:h=>N(g[0].id,h),onQr:()=>u(g[0])}),g.length>1&&x===""&&i.jsx("div",{className:"space-y-3",children:g.map(h=>i.jsx(Le,{channel:h,onEdit:()=>p(h.id),onDelete:()=>E(h.id),onToggle:w=>N(h.id,w),onQr:()=>u(h)},h.id))}),x!==""&&(C||f)&&i.jsx(Pt,{form:S,upd:A,saving:v,editing:!!f,channel:f??void 0,onSave:b,onCancel:k,onDelete:f?()=>E(f.id):void 0,onQr:f?()=>u(f):void 0})]})]}):i.jsx("div",{className:"flex-1 flex items-center justify-center",children:i.jsxs("div",{className:"text-center",children:[i.jsx(kt,{className:"w-12 h-12 mx-auto mb-3 text-dark-muted/40"}),i.jsx("p",{className:"text-dark-muted text-sm",children:"请从左侧选择一个频道类型"})]})})}function Le({channel:n,onEdit:r,onDelete:o,onToggle:t,onQr:e}){return i.jsxs("div",{className:"border border-dark-border rounded-lg bg-dark-surface overflow-hidden",children:[i.jsx("div",{className:"p-5",children:i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"font-medium text-dark-text",children:n.name}),i.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[i.jsx("span",{className:`flex items-center gap-1 text-xs ${n.connected?"text-green-400":"text-dark-muted"}`,children:n.connected?i.jsxs(i.Fragment,{children:[i.jsx(gt,{className:"w-3 h-3"})," 已连接"]}):i.jsxs(i.Fragment,{children:[i.jsx(mt,{className:"w-3 h-3"})," 未连接"]})}),i.jsxs("span",{className:"text-xs text-dark-muted",children:["AppID: ",n.appId||"—"]})]})]}),i.jsx("button",{onClick:()=>t(!n.enabled),className:`w-9 h-5 rounded-full relative transition-colors shrink-0 ${n.enabled?"bg-green-600":"bg-gray-600"}`,children:i.jsx("span",{className:`absolute top-0.5 w-4 h-4 bg-white rounded-full transition-all ${n.enabled?"left-[18px]":"left-0.5"}`})})]})}),i.jsxs("div",{className:"flex items-center gap-1 px-5 py-2.5 bg-dark-bg/50 border-t border-dark-border",children:[n.type==="wechat"&&i.jsxs("button",{onClick:e,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md text-green-400 hover:bg-green-500/10 transition-colors",children:[i.jsx(Be,{className:"w-3.5 h-3.5"})," 扫码登录"]}),i.jsxs("button",{onClick:r,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md text-accent-blue hover:bg-accent-blue/10 transition-colors",children:[i.jsx("span",{className:"w-3.5 h-3.5 inline-flex items-center justify-center",children:"✎"})," 编辑"]}),i.jsxs("button",{onClick:o,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md text-red-400 hover:bg-red-500/10 transition-colors ml-auto",children:[i.jsx(xt,{className:"w-3.5 h-3.5"})," 删除"]})]})]})}function Pt({form:n,upd:r,saving:o,editing:t,channel:e,onSave:s,onCancel:a,onDelete:c,onQr:l}){return i.jsxs("div",{className:"border border-dark-border rounded-lg bg-dark-surface overflow-hidden",children:[i.jsx("div",{className:"px-5 py-4 border-b border-dark-border",children:i.jsx("h3",{className:"font-medium text-dark-text",children:t?"编辑配置":"新建配置"})}),i.jsxs("div",{className:"p-5 space-y-4",children:[i.jsx(qe,{label:"频道名称",required:!0,children:i.jsx("input",{value:n.name,onChange:u=>r("name",u.target.value),placeholder:"例如:研发群机器人",className:O})}),i.jsxs(qe,{label:"接入凭证",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-[10px] text-dark-muted mb-1",children:"AppID / 企业ID"}),i.jsx("input",{value:n.appId,onChange:u=>r("appId",u.target.value),placeholder:"AppID",className:O})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-[10px] text-dark-muted mb-1",children:"AppSecret"}),i.jsx("input",{type:"password",value:n.appSecret,onChange:u=>r("appSecret",u.target.value),placeholder:t?"留空不修改":"应用密钥",className:O})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-[10px] text-dark-muted mb-1",children:"Token"}),i.jsx("input",{value:n.token,onChange:u=>r("token",u.target.value),placeholder:t?"留空不修改":"回调校验 Token",className:O})]}),n.type==="wechat"&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-[10px] text-dark-muted mb-1",children:"EncodingAESKey"}),i.jsx("input",{value:n.encodingAESKey,onChange:u=>r("encodingAESKey",u.target.value),placeholder:"选填",className:O})]})]}),n.type==="wechat"&&i.jsx("p",{className:"text-xs text-dark-muted mt-2",children:"微信 iLink 机器人通过扫码授权,凭证可留空,保存后扫码登录即可。"})]}),i.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-dark-border px-3 py-2.5",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-dark-text",children:"启用频道"}),i.jsx("p",{className:"text-xs text-dark-muted",children:"关闭后停止收发消息"})]}),i.jsx("button",{onClick:()=>r("enabled",!n.enabled),className:`w-9 h-5 rounded-full relative transition-colors shrink-0 ${n.enabled?"bg-green-600":"bg-gray-600"}`,children:i.jsx("span",{className:`absolute top-0.5 w-4 h-4 bg-white rounded-full transition-all ${n.enabled?"left-[18px]":"left-0.5"}`})})]}),t&&(e==null?void 0:e.type)==="wechat"&&l&&i.jsxs("button",{onClick:l,className:"w-full flex items-center justify-center gap-2 text-sm bg-green-600/15 hover:bg-green-600/25 text-green-400 border border-green-600/40 px-3 py-2.5 rounded-lg transition-colors",children:[i.jsx(Be,{className:"w-4 h-4"})," 扫码登录 / 重新授权"]})]}),i.jsxs("div",{className:"flex items-center justify-between px-5 py-3 bg-dark-bg/50 border-t border-dark-border",children:[i.jsx("div",{children:t&&c&&i.jsxs("button",{onClick:c,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-md text-red-400 hover:bg-red-500/10 transition-colors",children:[i.jsx(xt,{className:"w-3.5 h-3.5"})," 删除"]})}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:a,className:"px-4 py-2 text-sm text-dark-muted hover:text-dark-text transition-colors",children:"取消"}),i.jsxs("button",{onClick:s,disabled:o||!n.name.trim(),className:"flex items-center gap-1.5 px-4 py-2 text-sm bg-accent-blue hover:bg-accent-blue/90 text-white rounded-lg disabled:opacity-50 transition-colors",children:[i.jsx(Et,{className:"w-3.5 h-3.5"}),o?"保存中...":"保存"]})]})]})]})}function qe({label:n,required:r,children:o}){return i.jsxs("div",{children:[i.jsxs("label",{className:"block text-xs text-dark-muted mb-1.5",children:[n,r&&i.jsx("span",{className:"text-red-400 ml-0.5",children:"*"})]}),o]})}const O="w-full bg-dark-bg border border-dark-border rounded-lg px-3 py-2 text-sm text-dark-text placeholder-dark-muted/60 focus:outline-none focus:border-accent-blue transition-colors";var K={},ie,_e;function Lt(){return _e||(_e=1,ie=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),ie}var oe={},_={},De;function D(){if(De)return _;De=1;let n;const r=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return _.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17},_.getSymbolTotalCodewords=function(t){return r[t]},_.getBCHDigit=function(o){let t=0;for(;o!==0;)t++,o>>>=1;return t},_.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');n=t},_.isKanjiModeEnabled=function(){return typeof n<"u"},_.toSJIS=function(t){return n(t)},_}var ae={},Ue;function Ae(){return Ue||(Ue=1,(function(n){n.L={bit:1},n.M={bit:0},n.Q={bit:3},n.H={bit:2};function r(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"l":case"low":return n.L;case"m":case"medium":return n.M;case"q":case"quartile":return n.Q;case"h":case"high":return n.H;default:throw new Error("Unknown EC Level: "+o)}}n.isValid=function(t){return t&&typeof t.bit<"u"&&t.bit>=0&&t.bit<4},n.from=function(t,e){if(n.isValid(t))return t;try{return r(t)}catch{return e}}})(ae)),ae}var le,Fe;function qt(){if(Fe)return le;Fe=1;function n(){this.buffer=[],this.length=0}return n.prototype={get:function(r){const o=Math.floor(r/8);return(this.buffer[o]>>>7-r%8&1)===1},put:function(r,o){for(let t=0;t<o;t++)this.putBit((r>>>o-t-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(r){const o=Math.floor(this.length/8);this.buffer.length<=o&&this.buffer.push(0),r&&(this.buffer[o]|=128>>>this.length%8),this.length++}},le=n,le}var ce,ze;function _t(){if(ze)return ce;ze=1;function n(r){if(!r||r<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=r,this.data=new Uint8Array(r*r),this.reservedBit=new Uint8Array(r*r)}return n.prototype.set=function(r,o,t,e){const s=r*this.size+o;this.data[s]=t,e&&(this.reservedBit[s]=!0)},n.prototype.get=function(r,o){return this.data[r*this.size+o]},n.prototype.xor=function(r,o,t){this.data[r*this.size+o]^=t},n.prototype.isReserved=function(r,o){return this.reservedBit[r*this.size+o]},ce=n,ce}var ue={},Ke;function Dt(){return Ke||(Ke=1,(function(n){const r=D().getSymbolSize;n.getRowColCoords=function(t){if(t===1)return[];const e=Math.floor(t/7)+2,s=r(t),a=s===145?26:Math.ceil((s-13)/(2*e-2))*2,c=[s-7];for(let l=1;l<e-1;l++)c[l]=c[l-1]-a;return c.push(6),c.reverse()},n.getPositions=function(t){const e=[],s=n.getRowColCoords(t),a=s.length;for(let c=0;c<a;c++)for(let l=0;l<a;l++)c===0&&l===0||c===0&&l===a-1||c===a-1&&l===0||e.push([s[c],s[l]]);return e}})(ue)),ue}var de={},Ve;function Ut(){if(Ve)return de;Ve=1;const n=D().getSymbolSize,r=7;return de.getPositions=function(t){const e=n(t);return[[0,0],[e-r,0],[0,e-r]]},de}var fe={},He;function Ft(){return He||(He=1,(function(n){n.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const r={N1:3,N2:3,N3:40,N4:10};n.isValid=function(e){return e!=null&&e!==""&&!isNaN(e)&&e>=0&&e<=7},n.from=function(e){return n.isValid(e)?parseInt(e,10):void 0},n.getPenaltyN1=function(e){const s=e.size;let a=0,c=0,l=0,u=null,d=null;for(let m=0;m<s;m++){c=l=0,u=d=null;for(let g=0;g<s;g++){let x=e.get(m,g);x===u?c++:(c>=5&&(a+=r.N1+(c-5)),u=x,c=1),x=e.get(g,m),x===d?l++:(l>=5&&(a+=r.N1+(l-5)),d=x,l=1)}c>=5&&(a+=r.N1+(c-5)),l>=5&&(a+=r.N1+(l-5))}return a},n.getPenaltyN2=function(e){const s=e.size;let a=0;for(let c=0;c<s-1;c++)for(let l=0;l<s-1;l++){const u=e.get(c,l)+e.get(c,l+1)+e.get(c+1,l)+e.get(c+1,l+1);(u===4||u===0)&&a++}return a*r.N2},n.getPenaltyN3=function(e){const s=e.size;let a=0,c=0,l=0;for(let u=0;u<s;u++){c=l=0;for(let d=0;d<s;d++)c=c<<1&2047|e.get(u,d),d>=10&&(c===1488||c===93)&&a++,l=l<<1&2047|e.get(d,u),d>=10&&(l===1488||l===93)&&a++}return a*r.N3},n.getPenaltyN4=function(e){let s=0;const a=e.data.length;for(let l=0;l<a;l++)s+=e.data[l];return Math.abs(Math.ceil(s*100/a/5)-10)*r.N4};function o(t,e,s){switch(t){case n.Patterns.PATTERN000:return(e+s)%2===0;case n.Patterns.PATTERN001:return e%2===0;case n.Patterns.PATTERN010:return s%3===0;case n.Patterns.PATTERN011:return(e+s)%3===0;case n.Patterns.PATTERN100:return(Math.floor(e/2)+Math.floor(s/3))%2===0;case n.Patterns.PATTERN101:return e*s%2+e*s%3===0;case n.Patterns.PATTERN110:return(e*s%2+e*s%3)%2===0;case n.Patterns.PATTERN111:return(e*s%3+(e+s)%2)%2===0;default:throw new Error("bad maskPattern:"+t)}}n.applyMask=function(e,s){const a=s.size;for(let c=0;c<a;c++)for(let l=0;l<a;l++)s.isReserved(l,c)||s.xor(l,c,o(e,l,c))},n.getBestMask=function(e,s){const a=Object.keys(n.Patterns).length;let c=0,l=1/0;for(let u=0;u<a;u++){s(u),n.applyMask(u,e);const d=n.getPenaltyN1(e)+n.getPenaltyN2(e)+n.getPenaltyN3(e)+n.getPenaltyN4(e);n.applyMask(u,e),d<l&&(l=d,c=u)}return c}})(fe)),fe}var W={},Oe;function pt(){if(Oe)return W;Oe=1;const n=Ae(),r=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],o=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return W.getBlocksCount=function(e,s){switch(s){case n.L:return r[(e-1)*4+0];case n.M:return r[(e-1)*4+1];case n.Q:return r[(e-1)*4+2];case n.H:return r[(e-1)*4+3];default:return}},W.getTotalCodewordsCount=function(e,s){switch(s){case n.L:return o[(e-1)*4+0];case n.M:return o[(e-1)*4+1];case n.Q:return o[(e-1)*4+2];case n.H:return o[(e-1)*4+3];default:return}},W}var he={},Q={},Qe;function zt(){if(Qe)return Q;Qe=1;const n=new Uint8Array(512),r=new Uint8Array(256);return(function(){let t=1;for(let e=0;e<255;e++)n[e]=t,r[t]=e,t<<=1,t&256&&(t^=285);for(let e=255;e<512;e++)n[e]=n[e-255]})(),Q.log=function(t){if(t<1)throw new Error("log("+t+")");return r[t]},Q.exp=function(t){return n[t]},Q.mul=function(t,e){return t===0||e===0?0:n[r[t]+r[e]]},Q}var $e;function Kt(){return $e||($e=1,(function(n){const r=zt();n.mul=function(t,e){const s=new Uint8Array(t.length+e.length-1);for(let a=0;a<t.length;a++)for(let c=0;c<e.length;c++)s[a+c]^=r.mul(t[a],e[c]);return s},n.mod=function(t,e){let s=new Uint8Array(t);for(;s.length-e.length>=0;){const a=s[0];for(let l=0;l<e.length;l++)s[l]^=r.mul(e[l],a);let c=0;for(;c<s.length&&s[c]===0;)c++;s=s.slice(c)}return s},n.generateECPolynomial=function(t){let e=new Uint8Array([1]);for(let s=0;s<t;s++)e=n.mul(e,new Uint8Array([1,r.exp(s)]));return e}})(he)),he}var ge,Je;function Vt(){if(Je)return ge;Je=1;const n=Kt();function r(o){this.genPoly=void 0,this.degree=o,this.degree&&this.initialize(this.degree)}return r.prototype.initialize=function(t){this.degree=t,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const e=new Uint8Array(t.length+this.degree);e.set(t);const s=n.mod(e,this.genPoly),a=this.degree-s.length;if(a>0){const c=new Uint8Array(this.degree);return c.set(s,a),c}return s},ge=r,ge}var me={},xe={},pe={},Ye;function bt(){return Ye||(Ye=1,pe.isValid=function(r){return!isNaN(r)&&r>=1&&r<=40}),pe}var I={},Ge;function wt(){if(Ge)return I;Ge=1;const n="[0-9]+",r="[A-Z $%*+\\-./:]+";let o="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";o=o.replace(/u/g,"\\u");const t="(?:(?![A-Z0-9 $%*+\\-./:]|"+o+`)(?:.|[\r
|
|
2
|
-
]))+`;I.KANJI=new RegExp(o,"g"),I.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),I.BYTE=new RegExp(t,"g"),I.NUMERIC=new RegExp(n,"g"),I.ALPHANUMERIC=new RegExp(r,"g");const e=new RegExp("^"+o+"$"),s=new RegExp("^"+n+"$"),a=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return I.testKanji=function(l){return e.test(l)},I.testNumeric=function(l){return s.test(l)},I.testAlphanumeric=function(l){return a.test(l)},I}var We;function U(){return We||(We=1,(function(n){const r=bt(),o=wt();n.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},n.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},n.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},n.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},n.MIXED={bit:-1},n.getCharCountIndicator=function(s,a){if(!s.ccBits)throw new Error("Invalid mode: "+s);if(!r.isValid(a))throw new Error("Invalid version: "+a);return a>=1&&a<10?s.ccBits[0]:a<27?s.ccBits[1]:s.ccBits[2]},n.getBestModeForData=function(s){return o.testNumeric(s)?n.NUMERIC:o.testAlphanumeric(s)?n.ALPHANUMERIC:o.testKanji(s)?n.KANJI:n.BYTE},n.toString=function(s){if(s&&s.id)return s.id;throw new Error("Invalid mode")},n.isValid=function(s){return s&&s.bit&&s.ccBits};function t(e){if(typeof e!="string")throw new Error("Param is not a string");switch(e.toLowerCase()){case"numeric":return n.NUMERIC;case"alphanumeric":return n.ALPHANUMERIC;case"kanji":return n.KANJI;case"byte":return n.BYTE;default:throw new Error("Unknown mode: "+e)}}n.from=function(s,a){if(n.isValid(s))return s;try{return t(s)}catch{return a}}})(xe)),xe}var Ze;function Ht(){return Ze||(Ze=1,(function(n){const r=D(),o=pt(),t=Ae(),e=U(),s=bt(),a=7973,c=r.getBCHDigit(a);function l(g,x,j){for(let S=1;S<=40;S++)if(x<=n.getCapacity(S,j,g))return S}function u(g,x){return e.getCharCountIndicator(g,x)+4}function d(g,x){let j=0;return g.forEach(function(S){const R=u(S.mode,x);j+=R+S.getBitsLength()}),j}function m(g,x){for(let j=1;j<=40;j++)if(d(g,j)<=n.getCapacity(j,x,e.MIXED))return j}n.from=function(x,j){return s.isValid(x)?parseInt(x,10):j},n.getCapacity=function(x,j,S){if(!s.isValid(x))throw new Error("Invalid QR Code version");typeof S>"u"&&(S=e.BYTE);const R=r.getSymbolTotalCodewords(x),v=o.getTotalCodewordsCount(x,j),B=(R-v)*8;if(S===e.MIXED)return B;const C=B-u(S,x);switch(S){case e.NUMERIC:return Math.floor(C/10*3);case e.ALPHANUMERIC:return Math.floor(C/11*2);case e.KANJI:return Math.floor(C/13);case e.BYTE:default:return Math.floor(C/8)}},n.getBestVersionForData=function(x,j){let S;const R=t.from(j,t.M);if(Array.isArray(x)){if(x.length>1)return m(x,R);if(x.length===0)return 1;S=x[0]}else S=x;return l(S.mode,S.getLength(),R)},n.getEncodedBits=function(x){if(!s.isValid(x)||x<7)throw new Error("Invalid QR Code version");let j=x<<12;for(;r.getBCHDigit(j)-c>=0;)j^=a<<r.getBCHDigit(j)-c;return x<<12|j}})(me)),me}var be={},Xe;function Ot(){if(Xe)return be;Xe=1;const n=D(),r=1335,o=21522,t=n.getBCHDigit(r);return be.getEncodedBits=function(s,a){const c=s.bit<<3|a;let l=c<<10;for(;n.getBCHDigit(l)-t>=0;)l^=r<<n.getBCHDigit(l)-t;return(c<<10|l)^o},be}var we={},ye,et;function Qt(){if(et)return ye;et=1;const n=U();function r(o){this.mode=n.NUMERIC,this.data=o.toString()}return r.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(t){let e,s,a;for(e=0;e+3<=this.data.length;e+=3)s=this.data.substr(e,3),a=parseInt(s,10),t.put(a,10);const c=this.data.length-e;c>0&&(s=this.data.substr(e),a=parseInt(s,10),t.put(a,c*3+1))},ye=r,ye}var Ne,tt;function $t(){if(tt)return Ne;tt=1;const n=U(),r=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function o(t){this.mode=n.ALPHANUMERIC,this.data=t}return o.getBitsLength=function(e){return 11*Math.floor(e/2)+6*(e%2)},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(e){let s;for(s=0;s+2<=this.data.length;s+=2){let a=r.indexOf(this.data[s])*45;a+=r.indexOf(this.data[s+1]),e.put(a,11)}this.data.length%2&&e.put(r.indexOf(this.data[s]),6)},Ne=o,Ne}var Ce,nt;function Jt(){if(nt)return Ce;nt=1;const n=U();function r(o){this.mode=n.BYTE,typeof o=="string"?this.data=new TextEncoder().encode(o):this.data=new Uint8Array(o)}return r.getBitsLength=function(t){return t*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(o){for(let t=0,e=this.data.length;t<e;t++)o.put(this.data[t],8)},Ce=r,Ce}var je,rt;function Yt(){if(rt)return je;rt=1;const n=U(),r=D();function o(t){this.mode=n.KANJI,this.data=t}return o.getBitsLength=function(e){return e*13},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(t){let e;for(e=0;e<this.data.length;e++){let s=r.toSJIS(this.data[e]);if(s>=33088&&s<=40956)s-=33088;else if(s>=57408&&s<=60351)s-=49472;else throw new Error("Invalid SJIS character: "+this.data[e]+`
|
|
3
|
-
Make sure your charset is UTF-8`);s=(s>>>8&255)*192+(s&255),t.put(s,13)}},je=o,je}var ke={exports:{}},st;function Gt(){return st||(st=1,(function(n){var r={single_source_shortest_paths:function(o,t,e){var s={},a={};a[t]=0;var c=r.PriorityQueue.make();c.push(t,0);for(var l,u,d,m,g,x,j,S,R;!c.empty();){l=c.pop(),u=l.value,m=l.cost,g=o[u]||{};for(d in g)g.hasOwnProperty(d)&&(x=g[d],j=m+x,S=a[d],R=typeof a[d]>"u",(R||S>j)&&(a[d]=j,c.push(d,j),s[d]=u))}if(typeof e<"u"&&typeof a[e]>"u"){var v=["Could not find a path from ",t," to ",e,"."].join("");throw new Error(v)}return s},extract_shortest_path_from_predecessor_list:function(o,t){for(var e=[],s=t;s;)e.push(s),o[s],s=o[s];return e.reverse(),e},find_path:function(o,t,e){var s=r.single_source_shortest_paths(o,t,e);return r.extract_shortest_path_from_predecessor_list(s,e)},PriorityQueue:{make:function(o){var t=r.PriorityQueue,e={},s;o=o||{};for(s in t)t.hasOwnProperty(s)&&(e[s]=t[s]);return e.queue=[],e.sorter=o.sorter||t.default_sorter,e},default_sorter:function(o,t){return o.cost-t.cost},push:function(o,t){var e={value:o,cost:t};this.queue.push(e),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};n.exports=r})(ke)),ke.exports}var it;function Wt(){return it||(it=1,(function(n){const r=U(),o=Qt(),t=$t(),e=Jt(),s=Yt(),a=wt(),c=D(),l=Gt();function u(v){return unescape(encodeURIComponent(v)).length}function d(v,B,C){const f=[];let A;for(;(A=v.exec(C))!==null;)f.push({data:A[0],index:A.index,mode:B,length:A[0].length});return f}function m(v){const B=d(a.NUMERIC,r.NUMERIC,v),C=d(a.ALPHANUMERIC,r.ALPHANUMERIC,v);let f,A;return c.isKanjiModeEnabled()?(f=d(a.BYTE,r.BYTE,v),A=d(a.KANJI,r.KANJI,v)):(f=d(a.BYTE_KANJI,r.BYTE,v),A=[]),B.concat(C,f,A).sort(function(y,k){return y.index-k.index}).map(function(y){return{data:y.data,mode:y.mode,length:y.length}})}function g(v,B){switch(B){case r.NUMERIC:return o.getBitsLength(v);case r.ALPHANUMERIC:return t.getBitsLength(v);case r.KANJI:return s.getBitsLength(v);case r.BYTE:return e.getBitsLength(v)}}function x(v){return v.reduce(function(B,C){const f=B.length-1>=0?B[B.length-1]:null;return f&&f.mode===C.mode?(B[B.length-1].data+=C.data,B):(B.push(C),B)},[])}function j(v){const B=[];for(let C=0;C<v.length;C++){const f=v[C];switch(f.mode){case r.NUMERIC:B.push([f,{data:f.data,mode:r.ALPHANUMERIC,length:f.length},{data:f.data,mode:r.BYTE,length:f.length}]);break;case r.ALPHANUMERIC:B.push([f,{data:f.data,mode:r.BYTE,length:f.length}]);break;case r.KANJI:B.push([f,{data:f.data,mode:r.BYTE,length:u(f.data)}]);break;case r.BYTE:B.push([{data:f.data,mode:r.BYTE,length:u(f.data)}])}}return B}function S(v,B){const C={},f={start:{}};let A=["start"];for(let p=0;p<v.length;p++){const y=v[p],k=[];for(let b=0;b<y.length;b++){const E=y[b],N=""+p+b;k.push(N),C[N]={node:E,lastCount:0},f[N]={};for(let h=0;h<A.length;h++){const w=A[h];C[w]&&C[w].node.mode===E.mode?(f[w][N]=g(C[w].lastCount+E.length,E.mode)-g(C[w].lastCount,E.mode),C[w].lastCount+=E.length):(C[w]&&(C[w].lastCount=E.length),f[w][N]=g(E.length,E.mode)+4+r.getCharCountIndicator(E.mode,B))}}A=k}for(let p=0;p<A.length;p++)f[A[p]].end=0;return{map:f,table:C}}function R(v,B){let C;const f=r.getBestModeForData(v);if(C=r.from(B,f),C!==r.BYTE&&C.bit<f.bit)throw new Error('"'+v+'" cannot be encoded with mode '+r.toString(C)+`.
|
|
4
|
-
Suggested mode is: `+r.toString(f));switch(C===r.KANJI&&!c.isKanjiModeEnabled()&&(C=r.BYTE),C){case r.NUMERIC:return new o(v);case r.ALPHANUMERIC:return new t(v);case r.KANJI:return new s(v);case r.BYTE:return new e(v)}}n.fromArray=function(B){return B.reduce(function(C,f){return typeof f=="string"?C.push(R(f,null)):f.data&&C.push(R(f.data,f.mode)),C},[])},n.fromString=function(B,C){const f=m(B,c.isKanjiModeEnabled()),A=j(f),p=S(A,C),y=l.find_path(p.map,"start","end"),k=[];for(let b=1;b<y.length-1;b++)k.push(p.table[y[b]].node);return n.fromArray(x(k))},n.rawSplit=function(B){return n.fromArray(m(B,c.isKanjiModeEnabled()))}})(we)),we}var ot;function Zt(){if(ot)return oe;ot=1;const n=D(),r=Ae(),o=qt(),t=_t(),e=Dt(),s=Ut(),a=Ft(),c=pt(),l=Vt(),u=Ht(),d=Ot(),m=U(),g=Wt();function x(p,y){const k=p.size,b=s.getPositions(y);for(let E=0;E<b.length;E++){const N=b[E][0],h=b[E][1];for(let w=-1;w<=7;w++)if(!(N+w<=-1||k<=N+w))for(let T=-1;T<=7;T++)h+T<=-1||k<=h+T||(w>=0&&w<=6&&(T===0||T===6)||T>=0&&T<=6&&(w===0||w===6)||w>=2&&w<=4&&T>=2&&T<=4?p.set(N+w,h+T,!0,!0):p.set(N+w,h+T,!1,!0))}}function j(p){const y=p.size;for(let k=8;k<y-8;k++){const b=k%2===0;p.set(k,6,b,!0),p.set(6,k,b,!0)}}function S(p,y){const k=e.getPositions(y);for(let b=0;b<k.length;b++){const E=k[b][0],N=k[b][1];for(let h=-2;h<=2;h++)for(let w=-2;w<=2;w++)h===-2||h===2||w===-2||w===2||h===0&&w===0?p.set(E+h,N+w,!0,!0):p.set(E+h,N+w,!1,!0)}}function R(p,y){const k=p.size,b=u.getEncodedBits(y);let E,N,h;for(let w=0;w<18;w++)E=Math.floor(w/3),N=w%3+k-8-3,h=(b>>w&1)===1,p.set(E,N,h,!0),p.set(N,E,h,!0)}function v(p,y,k){const b=p.size,E=d.getEncodedBits(y,k);let N,h;for(N=0;N<15;N++)h=(E>>N&1)===1,N<6?p.set(N,8,h,!0):N<8?p.set(N+1,8,h,!0):p.set(b-15+N,8,h,!0),N<8?p.set(8,b-N-1,h,!0):N<9?p.set(8,15-N-1+1,h,!0):p.set(8,15-N-1,h,!0);p.set(b-8,8,1,!0)}function B(p,y){const k=p.size;let b=-1,E=k-1,N=7,h=0;for(let w=k-1;w>0;w-=2)for(w===6&&w--;;){for(let T=0;T<2;T++)if(!p.isReserved(E,w-T)){let q=!1;h<y.length&&(q=(y[h]>>>N&1)===1),p.set(E,w-T,q),N--,N===-1&&(h++,N=7)}if(E+=b,E<0||k<=E){E-=b,b=-b;break}}}function C(p,y,k){const b=new o;k.forEach(function(T){b.put(T.mode.bit,4),b.put(T.getLength(),m.getCharCountIndicator(T.mode,p)),T.write(b)});const E=n.getSymbolTotalCodewords(p),N=c.getTotalCodewordsCount(p,y),h=(E-N)*8;for(b.getLengthInBits()+4<=h&&b.put(0,4);b.getLengthInBits()%8!==0;)b.putBit(0);const w=(h-b.getLengthInBits())/8;for(let T=0;T<w;T++)b.put(T%2?17:236,8);return f(b,p,y)}function f(p,y,k){const b=n.getSymbolTotalCodewords(y),E=c.getTotalCodewordsCount(y,k),N=b-E,h=c.getBlocksCount(y,k),w=b%h,T=h-w,q=Math.floor(b/h),H=Math.floor(N/h),Nt=H+1,Re=q-H,Ct=new l(Re);let Z=0;const Y=new Array(h),Me=new Array(h);let X=0;const jt=new Uint8Array(p.buffer);for(let F=0;F<h;F++){const te=F<T?H:Nt;Y[F]=jt.slice(Z,Z+te),Me[F]=Ct.encode(Y[F]),Z+=te,X=Math.max(X,te)}const ee=new Uint8Array(b);let Ie=0,P,L;for(P=0;P<X;P++)for(L=0;L<h;L++)P<Y[L].length&&(ee[Ie++]=Y[L][P]);for(P=0;P<Re;P++)for(L=0;L<h;L++)ee[Ie++]=Me[L][P];return ee}function A(p,y,k,b){let E;if(Array.isArray(p))E=g.fromArray(p);else if(typeof p=="string"){let q=y;if(!q){const H=g.rawSplit(p);q=u.getBestVersionForData(H,k)}E=g.fromString(p,q||40)}else throw new Error("Invalid data");const N=u.getBestVersionForData(E,k);if(!N)throw new Error("The amount of data is too big to be stored in a QR Code");if(!y)y=N;else if(y<N)throw new Error(`
|
|
5
|
-
The chosen QR Code version cannot contain this amount of data.
|
|
6
|
-
Minimum version required to store current data is: `+N+`.
|
|
7
|
-
`);const h=C(y,k,E),w=n.getSymbolSize(y),T=new t(w);return x(T,y),j(T),S(T,y),v(T,k,0),y>=7&&R(T,y),B(T,h),isNaN(b)&&(b=a.getBestMask(T,v.bind(null,T,k))),a.applyMask(b,T),v(T,k,b),{modules:T,version:y,errorCorrectionLevel:k,maskPattern:b,segments:E}}return oe.create=function(y,k){if(typeof y>"u"||y==="")throw new Error("No input text");let b=r.M,E,N;return typeof k<"u"&&(b=r.from(k.errorCorrectionLevel,r.M),E=u.from(k.version),N=a.from(k.maskPattern),k.toSJISFunc&&n.setToSJISFunction(k.toSJISFunc)),A(y,E,b,N)},oe}var Ee={},ve={},at;function yt(){return at||(at=1,(function(n){function r(o){if(typeof o=="number"&&(o=o.toString()),typeof o!="string")throw new Error("Color should be defined as hex string");let t=o.slice().replace("#","").split("");if(t.length<3||t.length===5||t.length>8)throw new Error("Invalid hex color: "+o);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(s){return[s,s]}))),t.length===6&&t.push("F","F");const e=parseInt(t.join(""),16);return{r:e>>24&255,g:e>>16&255,b:e>>8&255,a:e&255,hex:"#"+t.slice(0,6).join("")}}n.getOptions=function(t){t||(t={}),t.color||(t.color={});const e=typeof t.margin>"u"||t.margin===null||t.margin<0?4:t.margin,s=t.width&&t.width>=21?t.width:void 0,a=t.scale||4;return{width:s,scale:s?4:a,margin:e,color:{dark:r(t.color.dark||"#000000ff"),light:r(t.color.light||"#ffffffff")},type:t.type,rendererOpts:t.rendererOpts||{}}},n.getScale=function(t,e){return e.width&&e.width>=t+e.margin*2?e.width/(t+e.margin*2):e.scale},n.getImageWidth=function(t,e){const s=n.getScale(t,e);return Math.floor((t+e.margin*2)*s)},n.qrToImageData=function(t,e,s){const a=e.modules.size,c=e.modules.data,l=n.getScale(a,s),u=Math.floor((a+s.margin*2)*l),d=s.margin*l,m=[s.color.light,s.color.dark];for(let g=0;g<u;g++)for(let x=0;x<u;x++){let j=(g*u+x)*4,S=s.color.light;if(g>=d&&x>=d&&g<u-d&&x<u-d){const R=Math.floor((g-d)/l),v=Math.floor((x-d)/l);S=m[c[R*a+v]?1:0]}t[j++]=S.r,t[j++]=S.g,t[j++]=S.b,t[j]=S.a}}})(ve)),ve}var lt;function Xt(){return lt||(lt=1,(function(n){const r=yt();function o(e,s,a){e.clearRect(0,0,s.width,s.height),s.style||(s.style={}),s.height=a,s.width=a,s.style.height=a+"px",s.style.width=a+"px"}function t(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}n.render=function(s,a,c){let l=c,u=a;typeof l>"u"&&(!a||!a.getContext)&&(l=a,a=void 0),a||(u=t()),l=r.getOptions(l);const d=r.getImageWidth(s.modules.size,l),m=u.getContext("2d"),g=m.createImageData(d,d);return r.qrToImageData(g.data,s,l),o(m,u,d),m.putImageData(g,0,0),u},n.renderToDataURL=function(s,a,c){let l=c;typeof l>"u"&&(!a||!a.getContext)&&(l=a,a=void 0),l||(l={});const u=n.render(s,a,l),d=l.type||"image/png",m=l.rendererOpts||{};return u.toDataURL(d,m.quality)}})(Ee)),Ee}var Se={},ct;function en(){if(ct)return Se;ct=1;const n=yt();function r(e,s){const a=e.a/255,c=s+'="'+e.hex+'"';return a<1?c+" "+s+'-opacity="'+a.toFixed(2).slice(1)+'"':c}function o(e,s,a){let c=e+s;return typeof a<"u"&&(c+=" "+a),c}function t(e,s,a){let c="",l=0,u=!1,d=0;for(let m=0;m<e.length;m++){const g=Math.floor(m%s),x=Math.floor(m/s);!g&&!u&&(u=!0),e[m]?(d++,m>0&&g>0&&e[m-1]||(c+=u?o("M",g+a,.5+x+a):o("m",l,0),l=0,u=!1),g+1<s&&e[m+1]||(c+=o("h",d),d=0)):l++}return c}return Se.render=function(s,a,c){const l=n.getOptions(a),u=s.modules.size,d=s.modules.data,m=u+l.margin*2,g=l.color.light.a?"<path "+r(l.color.light,"fill")+' d="M0 0h'+m+"v"+m+'H0z"/>':"",x="<path "+r(l.color.dark,"stroke")+' d="'+t(d,u,l.margin)+'"/>',j='viewBox="0 0 '+m+" "+m+'"',R='<svg xmlns="http://www.w3.org/2000/svg" '+(l.width?'width="'+l.width+'" height="'+l.width+'" ':"")+j+' shape-rendering="crispEdges">'+g+x+`</svg>
|
|
8
|
-
`;return typeof c=="function"&&c(null,R),R},Se}var ut;function tn(){if(ut)return K;ut=1;const n=Lt(),r=Zt(),o=Xt(),t=en();function e(s,a,c,l,u){const d=[].slice.call(arguments,1),m=d.length,g=typeof d[m-1]=="function";if(!g&&!n())throw new Error("Callback required as last argument");if(g){if(m<2)throw new Error("Too few arguments provided");m===2?(u=c,c=a,a=l=void 0):m===3&&(a.getContext&&typeof u>"u"?(u=l,l=void 0):(u=l,l=c,c=a,a=void 0))}else{if(m<1)throw new Error("Too few arguments provided");return m===1?(c=a,a=l=void 0):m===2&&!a.getContext&&(l=c,c=a,a=void 0),new Promise(function(x,j){try{const S=r.create(c,l);x(s(S,a,l))}catch(S){j(S)}})}try{const x=r.create(c,l);u(null,s(x,a,l))}catch(x){u(x)}}return K.create=r.create,K.toCanvas=e.bind(null,o.render),K.toDataURL=e.bind(null,o.renderToDataURL),K.toString=e.bind(null,function(s,a,c){return t.render(s,c)}),K}var nn=tn();const rn=vt(nn),sn=2e3,dt=5;function on({channel:n,onClose:r}){const[o,t]=M.useState("loading"),[e,s]=M.useState(null),[a,c]=M.useState(null),[l,u]=M.useState(""),d=M.useRef(null),m=M.useRef(0),g=M.useRef(null),x=M.useRef(!1),j=()=>{g.current&&(clearTimeout(g.current),g.current=null),x.current=!0},S=async f=>{if(d.current)try{await rn.toCanvas(d.current,f,{width:240,margin:2,color:{dark:"#000000ff",light:"#ffffffff"}})}catch(A){console.warn("[WechatQr] Canvas QR generation failed, falling back to URL:",A)}},R=async()=>{if(!(x.current||!a))try{const f=await Pe.channels.weixin.bindStatus(a),A=(f==null?void 0:f.data)??f,p=(A==null?void 0:A.status)??"";if(m.current=0,p==="confirmed"){t("confirmed"),re.success(n?`微信「${n.name}」重新授权成功,频道已连接`:"微信绑定成功,频道已自动创建并连接"),setTimeout(r,2400);return}if(p==="scaned")t("scanned");else if(p==="expired"){t("expired");return}x.current||(g.current=setTimeout(R,sn))}catch(f){if(m.current++,console.warn("[WechatQr] poll error ("+m.current+"/"+dt+")",f),m.current>=dt)t("error"),u("轮询状态失败次数过多,请刷新二维码重试"),re.error("微信绑定状态轮询失败,请刷新二维码重试");else if(!x.current){const A=Math.min(1e3*Math.pow(2,m.current),1e4);g.current=setTimeout(R,A)}}},v=()=>{j(),x.current=!1,m.current=0,g.current=setTimeout(R,1e3)},B=async()=>{t("loading"),s(null),c(null),u(""),m.current=0;try{const f=await Pe.channels.weixin.bind(),A=(f==null?void 0:f.data)??f,p=(A==null?void 0:A.qrcode_img_content)??"",y=(A==null?void 0:A.qrcode)??"";if(!p||!y){t("error"),u(`二维码数据缺失: ${JSON.stringify(A)}`);return}s(p),c(y),await S(p),t("waiting")}catch(f){t("error");const A=String((f==null?void 0:f.message)??f);u(A),re.error(`获取微信二维码失败:${A}`)}},C=()=>{B()};return M.useEffect(()=>(B(),j),[]),M.useEffect(()=>(a&&v(),j),[a]),i.jsx(Bt,{isOpen:!0,onClose:r,title:`扫码绑定 · ${(n==null?void 0:n.name)??"微信"}`,size:"sm",children:i.jsxs("div",{className:"flex flex-col items-center gap-4 py-2",children:[i.jsxs("div",{className:"relative w-60 h-60 rounded-lg bg-white flex items-center justify-center overflow-hidden",children:[o==="loading"&&i.jsx("span",{className:"text-gray-400 text-sm",children:"二维码生成中..."}),o!=="error"&&o!=="expired"&&i.jsx("canvas",{ref:d,width:240,height:240,className:`w-full h-full object-contain ${o==="waiting"?"":"opacity-30"}`}),o==="scanned"&&i.jsxs("div",{className:"absolute inset-0 bg-black/70 flex flex-col items-center justify-center text-white gap-1",children:[i.jsx("span",{className:"text-2xl",children:"✓"}),i.jsx("span",{className:"text-sm",children:"已扫描,请在手机上确认"})]}),o==="confirmed"&&i.jsxs("div",{className:"absolute inset-0 bg-green-600/90 flex flex-col items-center justify-center text-white gap-2 px-4 text-center",children:[i.jsx("span",{className:"text-2xl",children:"🎉"}),i.jsx("span",{className:"text-sm font-medium",children:"绑定成功"}),i.jsx("span",{className:"text-xs opacity-90",children:n?`「${n.name}」已连接,可开始使用`:"微信频道已创建并连接,可开始使用"}),i.jsx("button",{onClick:r,className:"mt-1 text-xs bg-white/20 hover:bg-white/30 px-3 py-1.5 rounded-md transition-colors",children:"开始使用"})]}),o==="expired"&&i.jsxs("div",{className:"absolute inset-0 bg-black/80 flex flex-col items-center justify-center text-white gap-2",children:[i.jsx("span",{className:"text-sm",children:"二维码已失效"}),i.jsx("button",{onClick:C,className:"text-xs bg-green-600 hover:bg-green-500 px-3 py-1 rounded",children:"点击刷新"})]}),o==="error"&&i.jsxs("div",{className:"absolute inset-0 bg-black/80 flex flex-col items-center justify-center text-red-300 gap-2 px-4 text-center",children:[i.jsx("span",{className:"text-xs",children:l||"未知错误"}),i.jsx("button",{onClick:C,className:"text-xs bg-blue-600 hover:bg-blue-500 px-3 py-1 rounded text-white",children:"重试"})]})]}),i.jsxs("p",{className:"text-sm text-dark-muted text-center",children:[o==="waiting"&&"请使用微信扫描二维码授权机器人",o==="scanned"&&"已扫描,请在手机上确认...",o==="confirmed"&&"机器人已授权并启动,即将自动关闭",o==="loading"&&"正在连接 iLink 服务...",(o==="expired"||o==="error")&&(o==="expired"?"二维码已失效":"")]}),e&&o==="waiting"&&i.jsxs("button",{onClick:()=>window.open(e,"_blank","width=480,height=600,noopener"),className:"w-full flex items-center justify-center gap-2 text-sm bg-green-600/15 hover:bg-green-600/25 text-green-400 border border-green-600/40 px-3 py-2.5 rounded-lg transition-colors",children:[i.jsx("span",{children:"🔔"})," 在新标签页打开(备用)"]})]})})}function hn(){const{load:n,loading:r,qrOpen:o,qrChannel:t,closeQr:e}=Te();return M.useEffect(()=>{n()},[]),i.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-dark-bg text-dark-text",children:[i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-dark-border shrink-0",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"font-semibold text-base",children:"频道管理"}),i.jsx("p",{className:"text-xs text-dark-muted mt-0.5",children:"接入微信、飞书、钉钉,用户可通过频道发送任务并实时接收进度与结果"})]}),i.jsx("div",{className:"flex items-center gap-2",children:i.jsx("button",{onClick:()=>n(),title:"刷新",className:"p-2 rounded-lg text-dark-muted hover:text-dark-text hover:bg-dark-hover transition-colors",children:i.jsx(St,{className:`w-4 h-4 ${r?"animate-spin":""}`})})})]}),i.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[i.jsx("div",{className:"w-[260px] shrink-0",children:i.jsx(Mt,{})}),i.jsx("div",{className:"flex-1 min-w-0",children:i.jsx(It,{})})]}),o&&i.jsx(on,{channel:t,onClose:e})]})}export{hn as ChannelConfigView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as s}from"./markdown-BrFQfawv.js";import{a as d,L as w,_ as A,aj as F,z as ae,h as ne,af as le,aa as R,b6 as q,b9 as K,a0 as oe,aU as V,E as de,aq as ce,D,l as ie}from"./icons-B9mi2ie6.js";import{c as me,a as f}from"./index-PcXINYWS.js";import"./react-vendor-CiRFOYk_.js";import"./state-BcoCffxz.js";import"./panels-BX-TtLOU.js";const ue={"code-intelligence":"🧠 代码智能",filesystem:"📂 文件系统",databases:"🗄️ 数据库","browser-automation":"🌐 浏览器自动化","knowledge-memory":"🧠 知识/记忆","search-web":"🔎 搜索/网页","cloud-platforms":"☁️ 云平台",communication:"💬 通讯","developer-tools":"🛠️ 开发者工具",security:"🔒 安全","test-demo":"🧪 测试/Demo",other:"📦 其他"};function je(){const{t:r}=me(),[u,x]=d.useState([]),[H,C]=d.useState(!0),[E,S]=d.useState(null),[j,p]=d.useState({}),[z,m]=d.useState(null),[v,O]=d.useState(""),[b,$]=d.useState(null),[k,U]=d.useState("all"),[Y,g]=d.useState(null),[G,L]=d.useState({}),[M,N]=d.useState(!1),[l,i]=d.useState({name:"",command:"",args:"",env:"",transport:"stdio",url:"",headers:""}),Q=()=>i({name:"",command:"",args:"",env:"",transport:"stdio",url:"",headers:""}),T=e=>Object.fromEntries(e.split(",").map(t=>t.trim()).filter(Boolean).map(t=>{const n=t.indexOf("=");return n>0?[t.slice(0,n).trim(),t.slice(n+1).trim()]:[t,""]})),I=async()=>{const e=l.transport!=="stdio";if(!l.name.trim()||!e&&!l.command.trim()||e&&!l.url.trim()){m(r("connectors.customFormRequired"));return}p(t=>({...t,__add:!0})),m(null);try{const t=await f.connectors.addCustom({name:l.name.trim(),command:e?void 0:l.command.trim(),args:e?void 0:l.args.split(/\s+/).filter(Boolean),env:T(l.env),url:e?l.url.trim():void 0,transport:e?l.transport:void 0,headers:e?T(l.headers):void 0});t.success&&t.data?(x(n=>[...n,t.data]),N(!1),Q()):m(t.error||"添加失败")}catch(t){m(t instanceof Error?t.message:String(t))}finally{p(t=>({...t,__add:!1}))}},W=async e=>{p(t=>({...t,[e.id]:!0}));try{const t=await f.connectors.removeCustom(e.id);t.success?x(n=>n.filter(a=>a.id!==e.id)):m(t.error||"删除失败")}finally{p(t=>({...t,[e.id]:!1}))}},y=async()=>{var t;C(!0),S(null);const e=await f.connectors.list();e.success&&Array.isArray((t=e.data)==null?void 0:t.connectors)?x(e.data.connectors):S(e.error||"加载连接器失败"),C(!1)};d.useEffect(()=>{y()},[]);const B=(e,t,n,a)=>{m(n||null),x(o=>o.map(c=>c.id===e?{...c,enabled:!!a,status:"error"}:c))},_=async(e,t,n)=>{m(null),p(a=>({...a,[e.id]:!0})),x(a=>a.map(o=>o.id===e.id?{...o,enabled:t,status:t?"connecting":"installed"}:o));try{const a=await f.connectors.toggle(e.id,t,n);a.success&&a.data?x(o=>o.map(c=>c.id===e.id?a.data:c)):B(e.id,void 0,a.error||`切换 ${e.name} 失败`,!t)}catch(a){B(e.id,void 0,a instanceof Error?a.message:String(a),!t)}finally{p(a=>({...a,[e.id]:!1}))}},Z=e=>{var t,n;if(!e.enabled&&((t=e.requiresEnv)!=null&&t.length)&&((n=e.missingEnv)!=null&&n.length)){g(e.id);return}g(null),_(e,!e.enabled)},J=(e,t)=>{g(null),L(n=>({...n,[e.id]:{}})),_(e,!0,t)},X=e=>{const t="inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium";if(!e.installed)return s.jsxs("span",{className:`${t} bg-dark-hover text-dark-muted`,children:[s.jsx(D,{size:12}),r("connectors.notInstalled")]});switch(e.status){case"ready":return s.jsxs("span",{className:`${t} bg-accent-green/15 text-accent-green`,children:[s.jsx(ie,{size:12}),r("connectors.ready")]});case"connecting":return s.jsxs("span",{className:`${t} bg-accent-blue/15 text-accent-blue`,children:[s.jsx(w,{size:12,className:"animate-spin"}),r("connectors.connecting")]});case"error":return s.jsxs("span",{className:`${t} bg-accent-red/15 text-accent-red`,children:[s.jsx(A,{size:12}),r("connectors.error")]});case"disabled":return s.jsx("span",{className:`${t} bg-dark-hover text-dark-muted`,children:r("connectors.disabled")});default:return s.jsx("span",{className:`${t} bg-dark-hover text-dark-muted`,children:r("connectors.installed")})}},h=u.filter(e=>k==="all"||e.kind===k),P=h.filter(e=>{if(v){const t=v.toLowerCase();if(![e.name,e.id,e.description,e.category??"",e.kind,...e.languages??[]].join(" ").toLowerCase().includes(t))return!1}return!(b&&e.category!==b)}).sort((e,t)=>e.enabled!==t.enabled?e.enabled?-1:1:e.name.localeCompare(t.name)),ee=[...new Set(h.map(e=>e.category).filter(Boolean))];if(H)return s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsxs("div",{className:"text-center",children:[s.jsx(w,{size:32,className:"animate-spin mx-auto mb-2 text-accent-blue"}),s.jsx("p",{className:"text-dark-muted",children:r("common.loading")})]})});if(E)return s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsxs("div",{className:"text-center",children:[s.jsx(A,{size:32,className:"mx-auto mb-2 text-accent-red"}),s.jsx("p",{className:"text-accent-red mb-4",children:E}),s.jsx("button",{onClick:()=>void y(),className:"px-4 py-2 bg-accent-blue text-white rounded-lg",children:r("common.retry")})]})});const se=e=>{const t=G[e.id]??{},n=(a,o)=>L(c=>({...c,[e.id]:{...c[e.id]??{},[a]:o}}));return s.jsxs("div",{className:"mt-3 pt-3 border-t border-dark-border",children:[s.jsxs("div",{className:"text-xs text-dark-muted mb-2 flex items-center gap-1",children:[s.jsx(V,{size:12}),r("connectors.needCredentials")]}),s.jsx("div",{className:"space-y-2",children:(e.requiresEnv??[]).map(a=>s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] text-dark-muted mb-1",children:a.label}),s.jsx("input",{type:a.secret?"password":"text",value:t[a.key]??"",onChange:o=>n(a.key,o.target.value),placeholder:a.key,className:"w-full px-3 py-1.5 bg-dark-bg border border-dark-border rounded-lg text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]},a.key))}),s.jsxs("div",{className:"flex gap-2 mt-2",children:[s.jsx("button",{onClick:()=>void J(e,t),className:"px-3 py-1.5 bg-accent-blue text-white rounded-lg text-sm",children:r("connectors.connect")}),s.jsx("button",{onClick:()=>g(null),className:"px-3 py-1.5 bg-dark-surface border border-dark-border rounded-lg text-sm",children:r("common.cancel")})]})]})},te=e=>{var a,o,c;const t=!!j[e.id],n=Y===e.id;return s.jsxs("div",{className:`bg-dark-surface border border-dark-border rounded-lg p-4 transition-opacity ${e.enabled?"":"opacity-80"}`,children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[s.jsx("span",{className:`mt-0.5 shrink-0 px-2 py-1 rounded-md text-[11px] font-semibold uppercase ${e.kind==="lsp"?"bg-accent-purple/15 text-accent-purple":"bg-accent-green/15 text-accent-green"}`,children:e.kind==="lsp"?"LSP":"MCP"}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"font-medium text-sm truncate",children:e.name}),e.custom?s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-purple/15 text-accent-purple",children:r("connectors.custom")}):null,e.official?s.jsxs("span",{title:"Official",className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-yellow/15 text-accent-yellow",children:["🎖️ ",r("connectors.official")]}):null,e.scope==="cloud"?s.jsxs("span",{title:"Cloud",className:"inline-flex items-center gap-0.5 text-[10px] px-1.5 py-0.5 rounded bg-accent-blue/15 text-accent-blue",children:[s.jsx(q,{size:9}),r("connectors.cloud")]}):s.jsxs("span",{title:"Local",className:"inline-flex items-center gap-0.5 text-[10px] px-1.5 py-0.5 rounded bg-dark-hover text-dark-muted",children:[s.jsx(K,{size:9}),r("connectors.local")]}),e.language?s.jsx("span",{className:"text-[10px]",children:e.language}):null,X(e)]}),s.jsx("p",{className:"text-xs text-dark-muted mt-1 line-clamp-2",children:e.description}),s.jsxs("div",{className:"flex items-center gap-3 mt-2 text-[11px] text-dark-muted flex-wrap",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(K,{size:11}),s.jsx("code",{className:"text-[10px]",children:e.installHint})]}),e.transport&&e.transport!=="stdio"?s.jsxs("span",{className:"inline-flex items-center gap-1 text-accent-blue",children:[s.jsx(q,{size:11}),e.transport==="sse"?"SSE":"Streamable HTTP"]}):null,(a=e.languages)!=null&&a.length?s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(oe,{size:11}),e.languages.join(", ")]}):null,e.kind==="mcp"&&e.toolCount!==void 0?s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(F,{size:11}),r("connectors.toolCount",{count:e.toolCount})]}):null,(o=e.requiresEnv)!=null&&o.length?s.jsxs("span",{className:"inline-flex items-center gap-1 text-accent-yellow",children:[s.jsx(V,{size:11}),(c=e.missingEnv)!=null&&c.length?`${e.missingEnv.join(", ")} ${r("connectors.missing")}`:r("connectors.envConfigured")]}):null,e.docsUrl?s.jsxs("a",{href:e.docsUrl,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 hover:text-accent-blue",onClick:re=>re.stopPropagation(),children:[s.jsx(de,{size:11}),r("connectors.docs")]}):null]}),e.error?s.jsx("p",{className:"text-[11px] text-accent-red mt-1",children:e.error}):null]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.custom?s.jsx("button",{onClick:()=>void W(e),disabled:t,title:r("connectors.removeCustom"),className:"p-1.5 rounded-lg text-dark-muted hover:text-accent-red hover:bg-accent-red/10 transition-colors disabled:opacity-40",children:s.jsx(ce,{size:14})}):null,!e.installed&&e.enabled?s.jsxs("span",{className:"text-[11px] text-accent-blue flex items-center gap-1",children:[s.jsx(D,{size:11,className:"animate-pulse"}),r("connectors.installing")]}):null,s.jsx("button",{role:"switch","aria-checked":e.enabled,disabled:t,onClick:()=>Z(e),className:`relative w-12 h-6 rounded-full transition-colors disabled:opacity-50 ${e.enabled?"bg-accent-green":"bg-dark-border"}`,children:s.jsx("span",{className:`absolute top-1 w-4 h-4 bg-white rounded-full transition-transform ${e.enabled?"left-7":"left-1"}`})})]})]}),n?se(e):null]},e.id)};return s.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[s.jsx(F,{size:20}),r("nav.connectors"),s.jsxs("span",{className:"text-sm font-normal text-dark-muted",children:["· ",u.filter(e=>e.enabled).length,"/",u.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>N(e=>!e),className:"flex items-center gap-2 px-3 py-1.5 bg-accent-blue text-white rounded hover:bg-accent-blue/90 transition-colors",children:[s.jsx(ae,{size:14}),r("connectors.addCustom")]}),s.jsxs("button",{onClick:()=>void y(),className:"flex items-center gap-2 px-3 py-1.5 bg-dark-surface border border-dark-border rounded hover:bg-dark-hover transition-colors",children:[s.jsx(ne,{size:14}),r("common.refresh")]})]})]}),M?s.jsxs("div",{className:"mb-4 p-4 bg-dark-surface border border-dark-border rounded-lg",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[s.jsx(le,{size:15,className:"text-accent-purple"}),r("connectors.customTitle")]}),s.jsx("div",{className:"flex gap-1",children:[["stdio","🖥️ "+r("connectors.customLocal")],["http","🌐 HTTP"],["sse","📡 SSE"]].map(([e,t])=>s.jsx("button",{onClick:()=>i(n=>({...n,transport:e})),className:`px-3 py-1.5 rounded-lg text-xs transition-colors ${l.transport===e?"bg-accent-blue text-white":"bg-dark-bg border border-dark-border hover:bg-dark-hover"}`,children:t},e))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] text-dark-muted mb-1",children:r("connectors.customName")}),s.jsx("input",{value:l.name,onChange:e=>i(t=>({...t,name:e.target.value})),placeholder:"my-server",className:"w-full px-3 py-1.5 bg-dark-bg border border-dark-border rounded-lg text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]}),l.transport==="stdio"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] text-dark-muted mb-1",children:r("connectors.customCommand")}),s.jsx("input",{value:l.command,onChange:e=>i(t=>({...t,command:e.target.value})),placeholder:"npx -y @some/mcp-server",className:"w-full px-3 py-1.5 bg-dark-bg border border-dark-border rounded-lg text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] text-dark-muted mb-1",children:r("connectors.customArgs")}),s.jsx("input",{value:l.args,onChange:e=>i(t=>({...t,args:e.target.value})),placeholder:"--arg value",className:"w-full px-3 py-1.5 bg-dark-bg border border-dark-border rounded-lg text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]})]}):s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] text-dark-muted mb-1",children:r("connectors.customUrl")}),s.jsx("input",{value:l.url,onChange:e=>i(t=>({...t,url:e.target.value})),placeholder:"https://mcp.example.com/mcp",className:"w-full px-3 py-1.5 bg-dark-bg border border-dark-border rounded-lg text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]}),l.transport==="stdio"?s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] text-dark-muted mb-1",children:r("connectors.customEnv")}),s.jsx("input",{value:l.env,onChange:e=>i(t=>({...t,env:e.target.value})),placeholder:"KEY=value, KEY2=value2",className:"w-full px-3 py-1.5 bg-dark-bg border border-dark-border rounded-lg text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]}):s.jsxs("div",{children:[s.jsx("label",{className:"block text-[11px] text-dark-muted mb-1",children:r("connectors.customHeaders")}),s.jsx("input",{value:l.headers,onChange:e=>i(t=>({...t,headers:e.target.value})),placeholder:"Authorization=Bearer xxx",className:"w-full px-3 py-1.5 bg-dark-bg border border-dark-border rounded-lg text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]})]}),s.jsxs("div",{className:"flex gap-2 mt-3",children:[s.jsx("button",{onClick:()=>void I(),disabled:!!j.__add,className:"px-3 py-1.5 bg-accent-blue text-white rounded-lg text-sm disabled:opacity-50",children:j.__add?s.jsx(w,{size:14,className:"animate-spin"}):r("connectors.add")}),s.jsx("button",{onClick:()=>N(!1),className:"px-3 py-1.5 bg-dark-surface border border-dark-border rounded-lg text-sm",children:r("common.cancel")})]})]}):null,s.jsx("div",{className:"flex gap-1 mb-3",children:[["all",`${r("connectors.all")} (${u.length})`],["lsp",`LSP (${u.filter(e=>e.kind==="lsp").length})`],["mcp",`MCP (${u.filter(e=>e.kind==="mcp").length})`]].map(([e,t])=>s.jsx("button",{onClick:()=>U(e),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${k===e?"bg-accent-blue text-white":"bg-dark-surface border border-dark-border hover:bg-dark-hover"}`,children:t},e))}),s.jsx("div",{className:"flex gap-3 mb-3",children:s.jsxs("div",{className:"flex-1 relative",children:[s.jsx(R,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-dark-muted"}),s.jsx("input",{type:"text",value:v,onChange:e=>O(e.target.value),placeholder:r("connectors.searchPlaceholder"),className:"w-full pl-10 pr-4 py-2 bg-dark-surface border border-dark-border rounded-lg text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]})}),s.jsxs("div",{className:"flex gap-1 mb-4 flex-wrap",children:[s.jsxs("button",{onClick:()=>$(null),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${b?"bg-dark-surface border border-dark-border hover:bg-dark-hover":"bg-accent-blue text-white"}`,children:[r("connectors.all")," ",s.jsxs("span",{className:"opacity-70 text-xs",children:["(",h.length,")"]})]}),ee.map(e=>{const t=h.filter(n=>n.category===e).length;return s.jsxs("button",{onClick:()=>$(b===e?null:e),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${b===e?"bg-accent-blue text-white":"bg-dark-surface border border-dark-border hover:bg-dark-hover"}`,children:[ue[e]??e," ",s.jsxs("span",{className:"opacity-70 text-xs",children:["(",t,")"]})]},e)})]}),z?s.jsx("div",{className:"mb-4 px-3 py-2 bg-accent-red/10 border border-accent-red/30 rounded-lg text-accent-red text-sm",children:z}):null,s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar",children:P.length===0?s.jsxs("div",{className:"text-center text-dark-muted text-sm py-10",children:[s.jsx(R,{size:24,className:"mx-auto mb-2 opacity-50"}),r("connectors.noResults")]}):s.jsx("div",{className:"space-y-2",children:P.map(te)})})]})}export{je as ConnectorsView};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{j as l}from"./markdown-BrFQfawv.js";import{a as c,W as J,ad as Se,aE as Ce,h as Me,aM as Ne,aa as ke,u as ce,a7 as Ee,D as le,X as Pe,d as Re,K as Le,aN as $e}from"./icons-B9mi2ie6.js";import{a as Q,t as $}from"./index-PcXINYWS.js";import"./react-vendor-CiRFOYk_.js";import"./state-BcoCffxz.js";import"./panels-BX-TtLOU.js";function ue(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function ze(e){if(Array.isArray(e))return e}function Ae(e,t,r){return(t=qe(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function De(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,o,u,h,g=[],b=!0,x=!1;try{if(u=(r=r.call(e)).next,t!==0)for(;!(b=(n=u.call(r)).done)&&(g.push(n.value),g.length!==t);b=!0);}catch(M){x=!0,o=M}finally{try{if(!b&&r.return!=null&&(h=r.return(),Object(h)!==h))return}finally{if(x)throw o}}return g}}function Fe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function de(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function fe(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?de(Object(r),!0).forEach(function(n){Ae(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):de(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Te(e,t){if(e==null)return{};var r,n,o=Ie(e,t);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(n=0;n<u.length;n++)r=u[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function Ie(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function Ve(e,t){return ze(e)||De(e,t)||We(e,t)||Fe()}function Ue(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function qe(e){var t=Ue(e,"string");return typeof t=="symbol"?t:t+""}function We(e,t){if(e){if(typeof e=="string")return ue(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ue(e,t):void 0}}function He(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function pe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function he(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?pe(Object(r),!0).forEach(function(n){He(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):pe(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Be(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(n){return t.reduceRight(function(o,u){return u(o)},n)}}function X(e){return function t(){for(var r=this,n=arguments.length,o=new Array(n),u=0;u<n;u++)o[u]=arguments[u];return o.length>=e.length?e.apply(this,o):function(){for(var h=arguments.length,g=new Array(h),b=0;b<h;b++)g[b]=arguments[b];return t.apply(r,[].concat(o,g))}}}function ne(e){return{}.toString.call(e).includes("Object")}function Ke(e){return!Object.keys(e).length}function _(e){return typeof e=="function"}function Qe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ge(e,t){return ne(t)||A("changeType"),Object.keys(t).some(function(r){return!Qe(e,r)})&&A("changeField"),t}function Je(e){_(e)||A("selectorType")}function Xe(e){_(e)||ne(e)||A("handlerType"),ne(e)&&Object.values(e).some(function(t){return!_(t)})&&A("handlersType")}function Ye(e){e||A("initialIsRequired"),ne(e)||A("initialType"),Ke(e)&&A("initialContent")}function _e(e,t){throw new Error(e[t]||e.default)}var Ze={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},A=X(_e)(Ze),te={changes:Ge,selector:Je,handler:Xe,initial:Ye};function et(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};te.initial(e),te.handler(t);var r={current:e},n=X(nt)(r,t),o=X(rt)(r),u=X(te.changes)(e),h=X(tt)(r);function g(){var x=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(M){return M};return te.selector(x),x(r.current)}function b(x){Be(n,o,u,h)(x)}return[g,b]}function tt(e,t){return _(t)?t(e.current):t}function rt(e,t){return e.current=he(he({},e.current),t),t}function nt(e,t,r){return _(t)?t(e.current):Object.keys(r).forEach(function(n){var o;return(o=t[n])===null||o===void 0?void 0:o.call(t,e.current[n])}),r}var at={create:et},it={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function ot(e){return function t(){for(var r=this,n=arguments.length,o=new Array(n),u=0;u<n;u++)o[u]=arguments[u];return o.length>=e.length?e.apply(this,o):function(){for(var h=arguments.length,g=new Array(h),b=0;b<h;b++)g[b]=arguments[b];return t.apply(r,[].concat(o,g))}}}function st(e){return{}.toString.call(e).includes("Object")}function ct(e){return e||me("configIsRequired"),st(e)||me("configType"),e.urls?(lt(),{paths:{vs:e.urls.monacoBase}}):e}function lt(){console.warn(ge.deprecation)}function ut(e,t){throw new Error(e[t]||e.default)}var ge={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
3
|
-
You are using deprecated way of configuration.
|
|
4
|
-
|
|
5
|
-
Instead of using
|
|
6
|
-
monaco.config({ urls: { monacoBase: '...' } })
|
|
7
|
-
use
|
|
8
|
-
monaco.config({ paths: { vs: '...' } })
|
|
9
|
-
|
|
10
|
-
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
11
|
-
`},me=ot(ut)(ge),dt={config:ct},ft=function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return function(o){return r.reduceRight(function(u,h){return h(u)},o)}};function ve(e,t){return Object.keys(t).forEach(function(r){t[r]instanceof Object&&e[r]&&Object.assign(t[r],ve(e[r],t[r]))}),fe(fe({},e),t)}var pt={type:"cancelation",msg:"operation is manually canceled"};function ie(e){var t=!1,r=new Promise(function(n,o){e.then(function(u){return t?o(pt):n(u)}),e.catch(o)});return r.cancel=function(){return t=!0},r}var ht=["monaco"],mt=at.create({config:it,isInitialized:!1,resolve:null,reject:null,monaco:null}),be=Ve(mt,2),Z=be[0],ae=be[1];function gt(e){var t=dt.config(e),r=t.monaco,n=Te(t,ht);ae(function(o){return{config:ve(o.config,n),monaco:r}})}function vt(){var e=Z(function(t){var r=t.monaco,n=t.isInitialized,o=t.resolve;return{monaco:r,isInitialized:n,resolve:o}});if(!e.isInitialized){if(ae({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),ie(oe);if(window.monaco&&window.monaco.editor)return ye(window.monaco),e.resolve(window.monaco),ie(oe);ft(bt,xt)(jt)}return ie(oe)}function bt(e){return document.body.appendChild(e)}function yt(e){var t=document.createElement("script");return e&&(t.src=e),t}function xt(e){var t=Z(function(n){var o=n.config,u=n.reject;return{config:o,reject:u}}),r=yt("".concat(t.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=t.reject,r}function jt(){var e=Z(function(r){var n=r.config,o=r.resolve,u=r.reject;return{config:n,resolve:o,reject:u}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(r){var n=r.m||r;ye(n),e.resolve(n)},function(r){e.reject(r)})}function ye(e){Z().monaco||ae({monaco:e})}function wt(){return Z(function(e){var t=e.monaco;return t})}var oe=new Promise(function(e,t){return ae({resolve:e,reject:t})}),xe={config:gt,init:vt,__getMonacoInstance:wt},Ot={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},se=Ot,St={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Ct=St;function Mt({children:e}){return J.createElement("div",{style:Ct.container},e)}var Nt=Mt,kt=Nt;function Et({width:e,height:t,isEditorReady:r,loading:n,_ref:o,className:u,wrapperProps:h}){return J.createElement("section",{style:{...se.wrapper,width:e,height:t},...h},!r&&J.createElement(kt,null,n),J.createElement("div",{ref:o,style:{...se.fullWidth,...!r&&se.hide},className:u}))}var Pt=Et,je=c.memo(Pt);function Rt(e){c.useEffect(e,[])}var we=Rt;function Lt(e,t,r=!0){let n=c.useRef(!0);c.useEffect(n.current||!r?()=>{n.current=!1}:e,t)}var C=Lt;function Y(){}function G(e,t,r,n){return $t(e,n)||zt(e,t,r,n)}function $t(e,t){return e.editor.getModel(Oe(e,t))}function zt(e,t,r,n){return e.editor.createModel(t,r,n?Oe(e,n):void 0)}function Oe(e,t){return e.Uri.parse(t)}function At({original:e,modified:t,language:r,originalLanguage:n,modifiedLanguage:o,originalModelPath:u,modifiedModelPath:h,keepCurrentOriginalModel:g=!1,keepCurrentModifiedModel:b=!1,theme:x="light",loading:M="Loading...",options:N={},height:I="100%",width:V="100%",className:U,wrapperProps:q={},beforeMount:W=Y,onMount:H=Y}){let[j,D]=c.useState(!1),[P,y]=c.useState(!0),w=c.useRef(null),v=c.useRef(null),F=c.useRef(null),O=c.useRef(H),p=c.useRef(W),R=c.useRef(!1);we(()=>{let d=xe.init();return d.then(m=>(v.current=m)&&y(!1)).catch(m=>(m==null?void 0:m.type)!=="cancelation"&&console.error("Monaco initialization: error:",m)),()=>w.current?z():d.cancel()}),C(()=>{if(w.current&&v.current){let d=w.current.getOriginalEditor(),m=G(v.current,e||"",n||r||"text",u||"");m!==d.getModel()&&d.setModel(m)}},[u],j),C(()=>{if(w.current&&v.current){let d=w.current.getModifiedEditor(),m=G(v.current,t||"",o||r||"text",h||"");m!==d.getModel()&&d.setModel(m)}},[h],j),C(()=>{let d=w.current.getModifiedEditor();d.getOption(v.current.editor.EditorOption.readOnly)?d.setValue(t||""):t!==d.getValue()&&(d.executeEdits("",[{range:d.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),d.pushUndoStop())},[t],j),C(()=>{var d,m;(m=(d=w.current)==null?void 0:d.getModel())==null||m.original.setValue(e||"")},[e],j),C(()=>{let{original:d,modified:m}=w.current.getModel();v.current.editor.setModelLanguage(d,n||r||"text"),v.current.editor.setModelLanguage(m,o||r||"text")},[r,n,o],j),C(()=>{var d;(d=v.current)==null||d.editor.setTheme(x)},[x],j),C(()=>{var d;(d=w.current)==null||d.updateOptions(N)},[N],j);let B=c.useCallback(()=>{var k;if(!v.current)return;p.current(v.current);let d=G(v.current,e||"",n||r||"text",u||""),m=G(v.current,t||"",o||r||"text",h||"");(k=w.current)==null||k.setModel({original:d,modified:m})},[r,t,o,e,n,u,h]),K=c.useCallback(()=>{var d;!R.current&&F.current&&(w.current=v.current.editor.createDiffEditor(F.current,{automaticLayout:!0,...N}),B(),(d=v.current)==null||d.editor.setTheme(x),D(!0),R.current=!0)},[N,x,B]);c.useEffect(()=>{j&&O.current(w.current,v.current)},[j]),c.useEffect(()=>{!P&&!j&&K()},[P,j,K]);function z(){var m,k,L,T;let d=(m=w.current)==null?void 0:m.getModel();g||((k=d==null?void 0:d.original)==null||k.dispose()),b||((L=d==null?void 0:d.modified)==null||L.dispose()),(T=w.current)==null||T.dispose()}return J.createElement(je,{width:V,height:I,isEditorReady:j,loading:M,_ref:F,className:U,wrapperProps:q})}var Dt=At;c.memo(Dt);function Ft(e){let t=c.useRef();return c.useEffect(()=>{t.current=e},[e]),t.current}var Tt=Ft,re=new Map;function It({defaultValue:e,defaultLanguage:t,defaultPath:r,value:n,language:o,path:u,theme:h="light",line:g,loading:b="Loading...",options:x={},overrideServices:M={},saveViewState:N=!0,keepCurrentModel:I=!1,width:V="100%",height:U="100%",className:q,wrapperProps:W={},beforeMount:H=Y,onMount:j=Y,onChange:D,onValidate:P=Y}){let[y,w]=c.useState(!1),[v,F]=c.useState(!0),O=c.useRef(null),p=c.useRef(null),R=c.useRef(null),B=c.useRef(j),K=c.useRef(H),z=c.useRef(),d=c.useRef(n),m=Tt(u),k=c.useRef(!1),L=c.useRef(!1);we(()=>{let a=xe.init();return a.then(s=>(O.current=s)&&F(!1)).catch(s=>(s==null?void 0:s.type)!=="cancelation"&&console.error("Monaco initialization: error:",s)),()=>p.current?i():a.cancel()}),C(()=>{var s,f,S,E;let a=G(O.current,e||n||"",t||o||"",u||r||"");a!==((s=p.current)==null?void 0:s.getModel())&&(N&&re.set(m,(f=p.current)==null?void 0:f.saveViewState()),(S=p.current)==null||S.setModel(a),N&&((E=p.current)==null||E.restoreViewState(re.get(u))))},[u],y),C(()=>{var a;(a=p.current)==null||a.updateOptions(x)},[x],y),C(()=>{!p.current||n===void 0||(p.current.getOption(O.current.editor.EditorOption.readOnly)?p.current.setValue(n):n!==p.current.getValue()&&(L.current=!0,p.current.executeEdits("",[{range:p.current.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),p.current.pushUndoStop(),L.current=!1))},[n],y),C(()=>{var s,f;let a=(s=p.current)==null?void 0:s.getModel();a&&o&&((f=O.current)==null||f.editor.setModelLanguage(a,o))},[o],y),C(()=>{var a;g!==void 0&&((a=p.current)==null||a.revealLine(g))},[g],y),C(()=>{var a;(a=O.current)==null||a.editor.setTheme(h)},[h],y);let T=c.useCallback(()=>{var a;if(!(!R.current||!O.current)&&!k.current){K.current(O.current);let s=u||r,f=G(O.current,n||e||"",t||o||"",s||"");p.current=(a=O.current)==null?void 0:a.editor.create(R.current,{model:f,automaticLayout:!0,...x},M),N&&p.current.restoreViewState(re.get(s)),O.current.editor.setTheme(h),g!==void 0&&p.current.revealLine(g),w(!0),k.current=!0}},[e,t,r,n,o,u,x,M,N,h,g]);c.useEffect(()=>{y&&B.current(p.current,O.current)},[y]),c.useEffect(()=>{!v&&!y&&T()},[v,y,T]),d.current=n,c.useEffect(()=>{var a,s;y&&D&&((a=z.current)==null||a.dispose(),z.current=(s=p.current)==null?void 0:s.onDidChangeModelContent(f=>{L.current||D(p.current.getValue(),f)}))},[y,D]),c.useEffect(()=>{if(y){let a=O.current.editor.onDidChangeMarkers(s=>{var S;let f=(S=p.current.getModel())==null?void 0:S.uri;if(f&&s.find(E=>E.path===f.path)){let E=O.current.editor.getModelMarkers({resource:f});P==null||P(E)}});return()=>{a==null||a.dispose()}}return()=>{}},[y,P]);function i(){var a,s;(a=z.current)==null||a.dispose(),I?N&&re.set(u,p.current.saveViewState()):(s=p.current.getModel())==null||s.dispose(),p.current.dispose()}return J.createElement(je,{width:V,height:U,isEditorReady:y,loading:b,_ref:R,className:q,wrapperProps:W})}var Vt=It,Ut=c.memo(Vt),qt=Ut;function Wt(e){var n;const t=(n=e.split(".").pop())==null?void 0:n.toLowerCase();return{ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",py:"python",rs:"rust",go:"go",rb:"ruby",json:"json",xml:"xml",html:"html",css:"css",scss:"scss",md:"markdown",yaml:"yaml",yml:"yaml",toml:"toml",sql:"sql",sh:"shell",bat:"bat",ps1:"powershell",dockerfile:"dockerfile",properties:"properties",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",vue:"html",svelte:"html",svg:"xml"}[t||""]||"plaintext"}function Xt(){const[e,t]=c.useState([]),[r,n]=c.useState(null),[o,u]=c.useState(""),[h,g]=c.useState(""),[b,x]=c.useState(!1),[M,N]=c.useState(""),[I,V]=c.useState(!1),[U,q]=c.useState(!1),[W,H]=c.useState(!1),[j,D]=c.useState(""),P=c.useRef(null);c.useEffect(()=>{if(!r){u(""),g("");return}x(!0),Q.files.read(r).then(i=>{if(i.success&&i.data){const a=typeof i.data=="string"?i.data:JSON.stringify(i.data);u(a),g(a)}else $.error(i.error||"读取文件失败")}).catch(()=>$.error("读取文件失败")).finally(()=>x(!1))},[r]);const y=async i=>{V(!0);try{const a=await Q.files.list(i);a.success&&Array.isArray(a.data)&&t(a.data.map(s=>({...s,expanded:!1})))}finally{V(!1)}},w=async i=>{if(i.type==="directory")try{const a=await Q.files.list(i.path);if(a.success&&Array.isArray(a.data)){const s=a.data.map(f=>({...f,expanded:!1}));t(f=>v(f,i.id,s))}}catch{}},v=(i,a,s)=>i.map(f=>f.id===a?{...f,children:s,expanded:!0}:f.children?{...f,children:v(f.children,a,s)}:f);c.useEffect(()=>{y()},[]);const F=i=>{const a=p(e,i);if(a&&a.type==="directory"&&!a.children){w(a);return}t(s=>O(s,i))},O=(i,a)=>i.map(s=>s.id===a&&s.type==="directory"?{...s,expanded:!s.expanded}:s.children?{...s,children:O(s.children,a)}:s),p=(i,a)=>{for(const s of i){if(s.id===a)return s;if(s.children){const f=p(s.children,a);if(f)return f}}return null},R=(i,a)=>a?i.reduce((s,f)=>{if(f.name.toLowerCase().includes(a.toLowerCase()))s.push(f);else if(f.children){const S=R(f.children,a);S.length>0&&s.push({...f,children:S,expanded:!0})}return s},[]):i,B=c.useCallback(async()=>{if(r){q(!0);try{const i=await Q.files.update(r,o);i.success?(g(o),$.success("文件已保存")):$.error(i.error||"保存失败")}catch{$.error("保存失败")}finally{q(!1)}}},[r,o]),K=()=>{n(null),u(""),g("")},z=c.useCallback(async i=>{const a=await Q.files.download(i);a.success?$.success("已开始下载"):$.error(a.error||"下载失败")},[]),d=()=>{var i;return(i=P.current)==null?void 0:i.click()},m=c.useCallback(async i=>{if(!i||i.length===0)return;const a=j||(r?r.replace(/[\\/][^\\/]+$/,""):"");H(!0);let s=0,f=0;for(const S of Array.from(i)){const E=a?`${a}/${S.name}`:S.name;(await Q.files.upload(S,E)).success?s++:f++}H(!1),s>0&&$.success(`已上传 ${s} 个文件`),f>0&&$.error(`${f} 个文件上传失败`),await y()},[j,r]),k=o!==h,L=(i,a=0)=>{var E;const s=i.type==="directory",f=r===i.path,S=j===i.path;return l.jsxs("div",{children:[l.jsxs("div",{className:`group flex items-center gap-1 px-2 py-0.5 cursor-pointer rounded text-xs transition-colors ${f?"bg-accent-blue/20 text-accent-blue":S?"bg-accent-blue/10":"hover:bg-dark-hover"}`,style:{paddingLeft:`${a*14+6}px`},onClick:()=>s?(D(i.path),F(i.id)):n(i.path),title:s?"点击设为上传目录并展开":i.path,children:[s&&l.jsx("span",{className:"text-dark-muted shrink-0",children:i.expanded?l.jsx(Re,{size:12}):l.jsx(Le,{size:12})}),s?l.jsx($e,{size:12,className:"text-accent-yellow shrink-0"}):l.jsx("span",{className:"w-3"}),l.jsx("span",{className:"truncate flex-1",children:i.name}),!s&&l.jsx("button",{onClick:ee=>{ee.stopPropagation(),z(i.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 rounded hover:bg-dark-border text-dark-muted hover:text-dark-text shrink-0",title:"下载",children:l.jsx(le,{size:11})})]}),s&&i.expanded&&((E=i.children)==null?void 0:E.map(ee=>L(ee,a+1)))]},i.id)},T=M?R(e,M):e;return l.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[l.jsxs("div",{className:"w-64 shrink-0 flex flex-col overflow-hidden border-r border-dark-border",children:[l.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-dark-border",children:[l.jsxs("h2",{className:"text-xs font-semibold flex items-center gap-1.5",children:[l.jsx(Se,{size:14}),"文件浏览器"]}),l.jsxs("div",{className:"flex items-center gap-0.5",children:[l.jsx("button",{onClick:d,disabled:W,className:"p-1 rounded hover:bg-dark-hover disabled:opacity-50",title:j?`上传到 ${j}`:"上传到工作区根目录",children:l.jsx(Ce,{size:12,className:W?"animate-pulse":""})}),l.jsx("button",{onClick:()=>y(),disabled:I,className:"p-1 rounded hover:bg-dark-hover",title:"刷新",children:l.jsx(Me,{size:12,className:I?"animate-spin":""})}),l.jsx("button",{onClick:()=>{t(e.map(i=>({...i,expanded:!1}))),n(null)},className:"p-1 rounded hover:bg-dark-hover",title:"折叠",children:l.jsx(Ne,{size:12})})]})]}),l.jsx("div",{className:"p-1.5 border-b border-dark-border",children:l.jsxs("div",{className:"relative",children:[l.jsx(ke,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-dark-muted"}),l.jsx("input",{type:"text",value:M,onChange:i=>N(i.target.value),placeholder:"搜索...",className:"w-full pl-6 pr-2 py-1 text-xs bg-dark-bg border border-dark-border rounded focus:border-accent-blue focus:outline-none"})]})}),l.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar py-1",children:T.map(i=>L(i))}),l.jsx("input",{ref:P,type:"file",multiple:!0,className:"hidden",onChange:i=>{m(i.target.files),i.currentTarget.value=""}})]}),l.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-dark-bg",children:r?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-dark-border bg-dark-surface",children:[l.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[l.jsx(ce,{size:12,className:"text-dark-muted shrink-0"}),l.jsx("span",{className:"truncate",children:r}),k&&l.jsx("span",{className:"text-accent-yellow text-[10px] shrink-0",children:"● 已修改"})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsxs("button",{onClick:B,disabled:!k||U,className:`px-2 py-0.5 text-[10px] rounded flex items-center gap-1 transition-colors ${k?"bg-accent-green text-white hover:opacity-90":"bg-dark-border text-dark-muted cursor-not-allowed"}`,children:[l.jsx(Ee,{size:10}),U?"保存中...":"保存"]}),l.jsx("button",{onClick:()=>void z(r),className:"p-1 rounded hover:bg-dark-hover",title:"下载",children:l.jsx(le,{size:12})}),l.jsx("button",{onClick:K,className:"p-1 rounded hover:bg-dark-hover",title:"关闭",children:l.jsx(Pe,{size:12})})]})]}),l.jsx("div",{className:"flex-1 min-h-0",children:b?l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsx("div",{className:"w-4 h-4 border-2 border-accent-blue border-t-transparent rounded-full animate-spin"})}):l.jsx(qt,{language:Wt(r),value:o,onChange:i=>u(i||""),theme:"vs-dark",options:{fontSize:13,fontFamily:'"Cascadia Code", "Fira Code", Consolas, monospace',minimap:{enabled:!1},lineNumbers:"on",scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0,tabSize:2}})})]}):l.jsx("div",{className:"flex-1 flex items-center justify-center",children:l.jsxs("div",{className:"text-center",children:[l.jsx(ce,{size:32,className:"text-dark-muted mx-auto mb-2"}),l.jsx("p",{className:"text-sm text-dark-muted",children:"选择文件以预览或编辑"})]})})})]})}export{Xt as FileTreeView,Xt as default};
|