hive-am 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -1
- package/package.json +1 -1
- package/server/dist/context.js +62 -0
- package/server/dist/db/migrations.js +7 -0
- package/server/dist/db.js +4 -4
- package/server/dist/history/claude.js +8 -2
- package/server/dist/http/routes/agents.js +1 -1
- package/server/dist/http/validate.js +2 -0
- package/server/dist/instructions.js +4 -0
- package/server/dist/models.js +2 -0
- package/server/dist/providers/claude.js +13 -1
- package/server/dist/providers/opencode-server.js +59 -0
- package/server/dist/providers/opencode.js +4 -1
- package/server/dist/stats.js +15 -3
- package/web/.next/BUILD_ID +1 -1
- package/web/.next/app-build-manifest.json +70 -70
- package/web/.next/app-path-routes-manifest.json +7 -7
- package/web/.next/build-manifest.json +2 -2
- package/web/.next/prerender-manifest.json +49 -49
- package/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/_not-found.html +1 -1
- package/web/.next/server/app/_not-found.rsc +3 -3
- package/web/.next/server/app/agents/[id]/page.js +3 -3
- package/web/.next/server/app/agents/[id]/page.js.nft.json +1 -1
- package/web/.next/server/app/agents/[id]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/agents/page.js +1 -1
- package/web/.next/server/app/agents/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/agents.html +1 -1
- package/web/.next/server/app/agents.rsc +4 -4
- package/web/.next/server/app/connections/page.js +1 -1
- package/web/.next/server/app/connections/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/connections.html +1 -1
- package/web/.next/server/app/connections.rsc +4 -4
- package/web/.next/server/app/index.html +1 -1
- package/web/.next/server/app/index.rsc +4 -4
- package/web/.next/server/app/page.js +1 -1
- package/web/.next/server/app/page.js.nft.json +1 -1
- package/web/.next/server/app/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/relations/page.js +1 -1
- package/web/.next/server/app/relations/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/relations.html +1 -1
- package/web/.next/server/app/relations.rsc +4 -4
- package/web/.next/server/app/resources/[id]/page.js +1 -1
- package/web/.next/server/app/resources/[id]/page.js.nft.json +1 -1
- package/web/.next/server/app/resources/[id]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/resources/page.js +1 -1
- package/web/.next/server/app/resources/page.js.nft.json +1 -1
- package/web/.next/server/app/resources/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/resources.html +1 -1
- package/web/.next/server/app/resources.rsc +4 -4
- package/web/.next/server/app/schedules/page.js +1 -1
- package/web/.next/server/app/schedules/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/schedules.html +1 -1
- package/web/.next/server/app/schedules.rsc +4 -4
- package/web/.next/server/app/sessions/page.js +1 -1
- package/web/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/sessions.html +1 -1
- package/web/.next/server/app/sessions.rsc +4 -4
- package/web/.next/server/app/skills/page.js +1 -1
- package/web/.next/server/app/skills/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/skills.html +1 -1
- package/web/.next/server/app/skills.rsc +4 -4
- package/web/.next/server/app/types/page.js +1 -1
- package/web/.next/server/app/types/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/types.html +1 -1
- package/web/.next/server/app/types.rsc +4 -4
- package/web/.next/server/app-paths-manifest.json +7 -7
- package/web/.next/server/chunks/143.js +1 -1
- package/web/.next/server/chunks/274.js +1 -1
- package/web/.next/server/chunks/306.js +1 -1
- package/web/.next/server/chunks/451.js +1 -0
- package/web/.next/server/chunks/505.js +1 -1
- package/web/.next/server/chunks/612.js +1 -1
- package/web/.next/server/chunks/716.js +2 -2
- package/web/.next/server/pages/404.html +1 -1
- package/web/.next/server/pages/500.html +1 -1
- package/web/.next/server/server-reference-manifest.json +1 -1
- package/web/.next/static/chunks/281-d8a0dcfaa6d064e4.js +1 -0
- package/web/.next/static/chunks/{291-efae53ea5f7ee92d.js → 291-23f314877fa39054.js} +1 -1
- package/web/.next/static/chunks/304-681348099f874a30.js +1 -0
- package/web/.next/static/chunks/350-0fe82e622e7a670f.js +1 -0
- package/web/.next/static/chunks/{491-6b4e6201f5110dff.js → 491-28f093772bd460ac.js} +1 -1
- package/web/.next/static/chunks/517-373a80c8ba432bdc.js +1 -0
- package/web/.next/static/chunks/654-92a63b3c4b412666.js +1 -0
- package/web/.next/static/chunks/705-780e48e55b0346bd.js +1 -0
- package/web/.next/static/chunks/{844-fe55292e0701f436.js → 844-519177e6198ca84f.js} +1 -1
- package/web/.next/static/chunks/app/agents/[id]/page-c005161cec5527d8.js +1 -0
- package/web/.next/static/chunks/app/agents/{page-f4c4c80f955f3967.js → page-9bb8cba69776c719.js} +1 -1
- package/web/.next/static/chunks/app/connections/{page-0936beaf02d863c6.js → page-eb11cfb1ffeab3ca.js} +1 -1
- package/web/.next/static/chunks/app/{layout-99620746d028dda8.js → layout-49b46c9b5aa512a8.js} +1 -1
- package/web/.next/static/chunks/app/{page-a7f292117b7d76bf.js → page-da042d146caeeab6.js} +1 -1
- package/web/.next/static/chunks/app/relations/{page-fba25393c8688714.js → page-a44fd515a3b0525e.js} +1 -1
- package/web/.next/static/chunks/app/resources/[id]/{page-d110d89bb8b5fca7.js → page-bf05836f97248ca7.js} +1 -1
- package/web/.next/static/chunks/app/resources/{page-bbd0b450d3f3131d.js → page-800f774e5cacf4c9.js} +1 -1
- package/web/.next/static/chunks/app/schedules/{page-a1124397fc760413.js → page-96976fff4ee23538.js} +1 -1
- package/web/.next/static/chunks/app/sessions/{page-0e322811b0cde724.js → page-a7534ebd90e982d6.js} +1 -1
- package/web/.next/static/chunks/app/skills/{page-22ea0ef89d9f7a13.js → page-bc1acd0663f36129.js} +1 -1
- package/web/.next/static/chunks/app/types/{page-18c4e1db2724d41d.js → page-ebd37e220f77c1f3.js} +1 -1
- package/web/.next/static/css/{b7a03c62468f4263.css → d42799b7e6a0e8a2.css} +1 -1
- package/web/.next/trace +29 -29
- package/web/.next/server/chunks/555.js +0 -1
- package/web/.next/static/chunks/176-aeaf907a6ea5627d.js +0 -1
- package/web/.next/static/chunks/350-56599dc3bf06066d.js +0 -1
- package/web/.next/static/chunks/486-13e08542f3a1cbac.js +0 -1
- package/web/.next/static/chunks/517-ccaf8cc5c733cbd8.js +0 -1
- package/web/.next/static/chunks/705-c7e75806f77b880c.js +0 -1
- package/web/.next/static/chunks/839-4aefe6e71be6e1ef.js +0 -1
- package/web/.next/static/chunks/app/agents/[id]/page-3faf40800981a736.js +0 -1
- /package/web/.next/static/{7BI__-ayGDTlOrSboD_bT → aSYzbHk1M5YeS_d3SQKTZ}/_buildManifest.js +0 -0
- /package/web/.next/static/{7BI__-ayGDTlOrSboD_bT → aSYzbHk1M5YeS_d3SQKTZ}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[491],{84491:(e,s,t)=>{t.d(s,{D:()=>s2});var n=t(94799),l=t(34023),a=t(83372),r=t(6673),c=t(82683),i=t(37104),o=t(8089),d=t(59959),h=t(73885),m=t(47405),u=t(3749),x=t(69654),j=t(48538),p=t(86606),b=t(61748),v=t(74988),g=t(31606),f=t(41463),w=t.n(f),N=t(33974),y=t(78330),k=t(92947),C=t(95587);function S(e){let{activeId:s,collapsed:t=!1,onToggle:a}=e,{t:r}=(0,x.s9)(),{objects:c,colonies:i}=(0,j.o0)(),[o,d]=(0,l.useState)(""),[h,m]=(0,l.useState)(!1),u=(0,l.useMemo)(()=>{let e=e=>!o||"".concat(e.name," ").concat(e.kind).toLowerCase().includes(o.toLowerCase()),s=i.map(s=>({key:s.id,name:s.name,color:s.color||"var(--honey)",items:c.filter(t=>t.colony_id===s.id&&e(t))}));return s.push({key:"free",name:r("obj.noColony"),color:null,items:c.filter(s=>(!s.colony_id||!i.some(e=>e.id===s.colony_id))&&e(s))}),s.filter(e=>e.items.length)},[c,i,o,r]),b=a&&(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:a,"aria-label":t?r("ow.expand"):r("ow.collapse"),title:t?r("ow.expand"):r("ow.collapse"),"aria-expanded":!t,children:t?(0,n.jsx)(N.A,{size:17}):(0,n.jsx)(y.A,{size:17})});return t?(0,n.jsxs)("aside",{className:"switcher mini","aria-label":r("nav.objects"),children:[(0,n.jsxs)("div",{className:"switcher-head",children:[b,(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>m(!0),"aria-label":r("obj.new"),title:r("obj.new"),children:(0,n.jsx)(k.A,{size:16})})]}),(0,n.jsx)("div",{className:"switcher-list",children:u.map(e=>(0,n.jsxs)("div",{className:"mini-group",children:[(0,n.jsx)("div",{className:"mini-sep",title:"".concat(e.name," \xb7 ").concat(e.items.length),style:e.color?{"--c":e.color}:void 0}),e.items.map(e=>{let{icon:t,color:l}=v.Nd[e.kind];return(0,n.jsx)(w(),{href:"/resources/".concat(e.id),className:"sw-item mini","aria-current":e.id===s?"page":void 0,"aria-label":e.name,title:"".concat(e.name,": ").concat(r("obj.status.".concat(e.state.status))),children:(0,n.jsxs)("span",{className:"sw-av",children:[(0,n.jsx)("span",{className:"obj-ico sm",style:{"--c":l},children:(0,n.jsx)(t,{size:17})}),(0,n.jsx)(g.md,{status:e.state.status,className:"sw-dot"})]})},e.id)})]},e.key))}),h&&(0,n.jsx)(C.X,{onClose:()=>m(!1)})]}):(0,n.jsxs)("aside",{className:"switcher","aria-label":r("nav.objects"),children:[(0,n.jsxs)("div",{className:"switcher-head",children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("b",{className:"grow sw-title",children:r("nav.objects")}),b,(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>m(!0),"aria-label":r("obj.new"),title:r("obj.new"),children:(0,n.jsx)(k.A,{size:16})})]}),(0,n.jsx)(p.DO,{value:o,onChange:d,placeholder:r("ow.find"),label:r("ow.find")})]}),(0,n.jsxs)("div",{className:"switcher-list",children:[0===u.length&&(0,n.jsx)("p",{className:"muted small sw-none",children:o?r("ow.noMatch",{query:o}):r("ow.empty.body")}),u.map(e=>(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"switcher-group",children:[e.color&&(0,n.jsx)("i",{className:"cdot",style:{background:e.color}}),e.name,(0,n.jsx)("span",{children:e.items.length})]}),e.items.map(e=>{let{icon:t,color:l}=v.Nd[e.kind];return(0,n.jsxs)(w(),{href:"/resources/".concat(e.id),className:"sw-item","aria-current":e.id===s?"page":void 0,children:[(0,n.jsx)("span",{className:"sw-av",children:(0,n.jsx)("span",{className:"obj-ico sm",style:{"--c":l},children:(0,n.jsx)(t,{size:17})})}),(0,n.jsxs)("span",{className:"sw-body",children:[(0,n.jsx)("span",{className:"sw-top",children:(0,n.jsx)("b",{children:e.name})}),(0,n.jsxs)("span",{className:"sw-sub",children:[(0,n.jsx)(g.md,{status:e.state.status})," ",r("obj.status.".concat(e.state.status)),e.state.detail?" \xb7 ".concat((0,v.HS)(r,e.state.detail)):""]}),(0,n.jsx)("span",{className:"sw-meta",children:r("obj.kind.".concat(e.kind))})]})]},e.id)})]},e.key))]}),h&&(0,n.jsx)(C.X,{onClose:()=>m(!1)})]})}var A=t(37064);let E=/\u001b\[[0-9;?]*[ -/]*[@-~]/g;function z(e){let{max:s=8e5,pollMs:t=1e3,paused:n=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},[a,r]=(0,l.useState)({text:null,dropped:0}),c=(0,l.useRef)(""),i=(0,l.useRef)(0);(0,l.useEffect)(()=>{r({text:null,dropped:0}),c.current="",i.current++},[e]),(0,l.useEffect)(()=>{if(n)return;let l=!1,a,o=i.current,d=async()=>{try{let t=c.current?"after=".concat(encodeURIComponent(c.current)):"tail=2000",n=await u.FH.get("/objects/".concat(e,"/logs?").concat(t));if(l||o!==i.current)return;c.current=n.cursor||c.current;let a=n.text.replace(E,"");r(e=>{var t;if(!a&&!n.reset)return e;let l=n.reset?"":null!=(t=e.text)?t:"",r=a?!l||l.endsWith("\n")||a.startsWith("\n")?l+a:"".concat(l,"\n").concat(a):l;if(r.length<=s)return{text:r,dropped:n.reset?0:e.dropped};let c=r.length-s,i=r.slice(0,c);return{text:r.slice(c),dropped:(n.reset?0:e.dropped)+i.split("\n").length-1}})}catch(e){}l||(a=setTimeout(d,t))};return d(),()=>{l=!0,clearTimeout(a)}},[e,n,s,t]);let o=(0,l.useCallback)(()=>r(e=>({text:"",dropped:e.dropped+(e.text?e.text.split("\n").length:0)})),[]);return{text:a.text,dropped:a.dropped,clear:o}}var F=t(47890),L=t(56072);function O(e){let{values:s,max:t,color:l="var(--honey)",height:a=36}=e,r=null!=t?t:Math.max(1,...s);if(s.length<2)return(0,n.jsx)("svg",{className:"spark",width:"100%",height:a,viewBox:"0 0 ".concat(160," ").concat(a),preserveAspectRatio:"none","aria-hidden":!0});let c=s.map((e,t)=>"".concat((t/(s.length-1)*160).toFixed(1),",").concat((a-2-Math.min(e,r)/r*(a-4)).toFixed(1)));return(0,n.jsxs)("svg",{className:"spark",width:"100%",height:a,viewBox:"0 0 ".concat(160," ").concat(a),preserveAspectRatio:"none","aria-hidden":!0,children:[(0,n.jsx)("polygon",{points:"0,".concat(a," ").concat(c.join(" ")," ").concat(160,",").concat(a),fill:l,opacity:".14"}),(0,n.jsx)("polyline",{points:c.join(" "),fill:"none",stroke:l,strokeWidth:"1.6",vectorEffect:"non-scaling-stroke"})]})}var q=t(75014),T=t(50703),R=t(12349),I=t(79141),H=t(91496),D=t(7991),M=t(70665),U=t(41435),B=t(43624),$=t(19431),W=t(70283),J=t(42162),P=t(58960),_=t(7168);let K=/pass|secret|token|api[_-]?key|auth|credential|private/i;function G(e){let{objectId:s,service:t,title:a,onClose:r}=e,{t:c}=(0,x.s9)(),i=(0,J.n)(),[o,d]=(0,l.useState)(null),[h,m]=(0,l.useState)(""),[j,b]=(0,l.useState)(!1);(0,l.useEffect)(()=>{u.FH.get("/objects/".concat(s,"/inspect").concat(t?"?service=".concat(encodeURIComponent(t)):"")).then(d).catch(e=>m(e instanceof Error?e.message:"error"))},[s,t]);let v=e=>e&&!e.startsWith("0001")?(0,L.v7)(Date.parse(e)):"—";return(0,n.jsx)(p.aF,{title:a,onClose:r,wide:!0,children:h?(0,n.jsx)("p",{className:"gx-note err res-m0",children:h}):o?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsxs)("span",{className:"muted small grow mono",children:[o.name," \xb7 ",o.id]}),"running"===o.status&&(0,n.jsxs)("button",{className:"btn sm",onClick:()=>{i.openTerminal({objectId:s,service:t}),r()},children:[(0,n.jsx)(W.A,{size:14}),c("svc.shell")]})]}),(0,n.jsxs)("section",{className:"sd-sec",children:[(0,n.jsx)("div",{className:"eyebrow",children:c("svc.d.general")}),(0,n.jsxs)("dl",{className:"sd-kv",children:[(0,n.jsx)("dt",{children:c("ow.d.image")}),(0,n.jsx)("dd",{className:"mono",children:o.image}),(0,n.jsx)("dt",{children:c("svc.col.status")}),(0,n.jsx)("dd",{children:o.status}),(0,n.jsx)("dt",{children:c("ow.d.created")}),(0,n.jsx)("dd",{children:v(o.created)}),(0,n.jsx)("dt",{children:c("svc.d.started")}),(0,n.jsx)("dd",{children:v(o.started)}),(0,n.jsx)("dt",{children:c("ow.d.restart")}),(0,n.jsxs)("dd",{children:[o.restartPolicy,o.restarts?" \xb7 ".concat(c("ow.d.restarts"),": ").concat(o.restarts):""]}),o.entrypoint&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("dt",{children:"Entrypoint"}),(0,n.jsx)("dd",{className:"mono",children:o.entrypoint})]}),o.command&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("dt",{children:c("ow.d.command")}),(0,n.jsx)("dd",{className:"mono",children:o.command})]}),o.workdir&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("dt",{children:c("svc.d.workdir")}),(0,n.jsx)("dd",{className:"mono",children:o.workdir})]}),o.user&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("dt",{children:c("svc.d.user")}),(0,n.jsx)("dd",{className:"mono",children:o.user})]})]})]}),o.health&&(0,n.jsxs)("section",{className:"sd-sec",children:[(0,n.jsxs)("div",{className:"eyebrow",children:[c("ow.d.health")," \xb7 ",o.health.status]}),0===o.health.log.length?(0,n.jsx)("p",{className:"muted small res-m0",children:"—"}):(0,n.jsx)("table",{className:"sd-table",children:(0,n.jsx)("tbody",{children:o.health.log.map((e,s)=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"mono",children:e.exit}),(0,n.jsx)("td",{className:"muted",children:v(e.at)}),(0,n.jsx)("td",{className:"mono",children:e.output.trim()})]},s))})})]}),(0,n.jsxs)("section",{className:"sd-sec",children:[(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsxs)("div",{className:"eyebrow grow",children:[c("of.env")," \xb7 ",o.env.length]}),(0,n.jsxs)("button",{className:"btn ghost sm",onClick:()=>b(e=>!e),children:[j?(0,n.jsx)(P.A,{size:14}):(0,n.jsx)(_.A,{size:14}),c("iv.reveal")]})]}),0===o.env.length?(0,n.jsx)("p",{className:"muted small res-m0",children:"—"}):(0,n.jsx)("table",{className:"sd-table",children:(0,n.jsx)("tbody",{children:o.env.map(e=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"mono",children:(0,n.jsx)("b",{children:e.name})}),(0,n.jsx)("td",{className:"mono",children:K.test(e.name)&&!j?"••••••••":e.value})]},e.name))})})]}),(0,n.jsxs)("section",{className:"sd-sec",children:[(0,n.jsx)("div",{className:"eyebrow",children:c("ow.d.ports")}),0===o.ports.length?(0,n.jsx)("p",{className:"muted small res-m0",children:"—"}):(0,n.jsx)("table",{className:"sd-table",children:(0,n.jsx)("tbody",{children:o.ports.map((e,s)=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"mono",children:e.container}),(0,n.jsx)("td",{className:"mono",children:e.host?(0,n.jsxs)("a",{href:"http://localhost:".concat(e.host),target:"_blank",rel:"noreferrer",children:["localhost:",e.host]}):(0,n.jsx)("span",{className:"muted",children:c("svc.d.unpublished")})})]},s))})})]}),(0,n.jsxs)("section",{className:"sd-sec",children:[(0,n.jsxs)("div",{className:"eyebrow",children:[c("svc.d.mounts")," \xb7 ",o.mounts.length]}),0===o.mounts.length?(0,n.jsx)("p",{className:"muted small res-m0",children:"—"}):(0,n.jsxs)("table",{className:"sd-table",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:c("svc.d.source")}),(0,n.jsx)("th",{children:c("svc.d.dest")}),(0,n.jsx)("th",{})]})}),(0,n.jsx)("tbody",{children:o.mounts.map((e,s)=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"mono",children:e.source}),(0,n.jsx)("td",{className:"mono",children:e.destination}),(0,n.jsxs)("td",{className:"muted",children:[e.type,e.rw?"":" \xb7 ro"]})]},s))})]})]}),(0,n.jsxs)("section",{className:"sd-sec",children:[(0,n.jsxs)("div",{className:"eyebrow",children:[c("ow.d.network")," \xb7 ",o.networks.length]}),0===o.networks.length?(0,n.jsx)("p",{className:"muted small res-m0",children:"—"}):(0,n.jsxs)("table",{className:"sd-table",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:c("obj.f.name")}),(0,n.jsx)("th",{children:"IP"}),(0,n.jsx)("th",{children:"Gateway"}),(0,n.jsx)("th",{children:"Aliases"})]})}),(0,n.jsx)("tbody",{children:o.networks.map(e=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"mono",children:e.name}),(0,n.jsx)("td",{className:"mono",children:e.ip}),(0,n.jsx)("td",{className:"mono",children:e.gateway}),(0,n.jsx)("td",{className:"mono",children:e.aliases.join(", ")})]},e.name))})]})]})]}):(0,n.jsx)("p",{className:"gx-note",children:c("git.loading")})})}function X(e){let{ports:s}=e,t=s.split(",").map(e=>e.trim()).filter(Boolean);return t.length?(0,n.jsx)("span",{className:"svc-ports",children:t.map(e=>{var s;let t=null==(s=/^(\d+)(?:->|→)/.exec(e))?void 0:s[1];return t?(0,n.jsx)("a",{className:"mono",href:"http://localhost:".concat(t),target:"_blank",rel:"noreferrer",title:"http://localhost:".concat(t),children:e},e):(0,n.jsx)("span",{className:"mono",children:e},e)})}):(0,n.jsx)("span",{className:"muted",children:"—"})}function V(e){let{objectId:s,services:t,onLogs:d,onChanged:h}=e,{t:j}=(0,x.s9)(),b=(0,p.dj)(),v=(0,J.n)(),[f,w]=(0,l.useState)(null),[N,y]=(0,l.useState)(null),k=async(e,t)=>{w("".concat(e,":").concat(t));try{await u.FH.post("/objects/".concat(s,"/service"),{service:e,action:t}),h()}catch(e){b("".concat(j("obj.act.failed",{action:j("obj.act.".concat(t))}),": ").concat(e instanceof Error?e.message:""),"err")}finally{w(null)}};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("table",{className:"cm-table svc",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:j("svc.col.name")}),(0,n.jsx)("th",{children:j("svc.col.image")}),(0,n.jsx)("th",{children:j("svc.col.status")}),(0,n.jsx)("th",{children:j("svc.col.ports")}),(0,n.jsx)("th",{className:"num",children:j("ow.cpu")}),(0,n.jsx)("th",{className:"num",children:j("ow.mem")}),(0,n.jsx)("th",{})]})}),(0,n.jsx)("tbody",{children:t.map(e=>{let t="running"===e.state||"restarting"===e.state;return(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{children:(0,n.jsxs)("span",{className:"row gap-s",children:[(0,n.jsx)(g.md,{status:"running"===e.state?/unhealthy/i.test(e.health)?"error":/starting/i.test(e.health)?"starting":"running":"exited"===e.state||"dead"===e.state?"error":"restarting"===e.state?"starting":"stopped"}),(0,n.jsxs)("span",{className:"svc-name",children:[(0,n.jsx)("b",{children:e.name}),(0,n.jsx)("small",{className:"mono muted",children:e.container})]})]})}),(0,n.jsx)("td",{className:"mono small svc-img",title:e.image,children:e.image||"—"}),(0,n.jsxs)("td",{children:[(0,n.jsxs)("span",{className:"small",children:[e.state,e.health?" \xb7 ".concat(e.health):""]}),(0,n.jsx)("div",{className:"muted small",children:e.status})]}),(0,n.jsx)("td",{children:(0,n.jsx)(X,{ports:e.ports})}),(0,n.jsx)("td",{className:"num mono small",children:null!==e.cpu?"".concat(e.cpu,"%"):"—"}),(0,n.jsx)("td",{className:"num mono small",children:null!==e.memBytes?(0,L.zi)(e.memBytes):"—"}),(0,n.jsxs)("td",{className:"cm-act",children:[t?(0,n.jsx)("button",{className:"btn ghost icon sm",disabled:!!f,onClick:()=>void k(e.name,"stop"),"aria-label":j("obj.act.stop"),title:j("obj.act.stop"),children:(0,n.jsx)(a.A,{size:14})}):(0,n.jsx)("button",{className:"btn ghost icon sm",disabled:!!f,onClick:()=>void k(e.name,"start"),"aria-label":j("obj.act.start"),title:j("obj.act.start"),children:(0,n.jsx)(m.A,{size:14})}),(0,n.jsx)("button",{className:"btn ghost icon sm",disabled:!!f,onClick:()=>void k(e.name,"restart"),"aria-label":j("obj.act.restart"),title:j("obj.act.restart"),children:(0,n.jsx)(r.A,{size:14})}),(0,n.jsx)(U.W1,{label:j("svc.more"),icon:(0,n.jsx)(H.A,{size:15}),iconOnly:!0,children:l=>(0,n.jsxs)(n.Fragment,{children:[d&&(0,n.jsx)(U.Dr,{icon:(0,n.jsx)($.A,{size:15}),onClick:()=>{l(),d(e.name)},children:j("svc.logs.short")}),(0,n.jsx)(U.Dr,{icon:(0,n.jsx)(W.A,{size:15}),disabled:!t,hint:t?void 0:j("svc.needsRunning"),onClick:()=>{l(),v.openTerminal({objectId:s,service:e.name})},children:j("svc.shell")}),(0,n.jsx)(U.Dr,{icon:(0,n.jsx)(c.A,{size:15}),onClick:()=>{l(),y(e.name)},children:j("svc.inspect")}),(0,n.jsx)(U.MU,{}),(0,n.jsx)(U.Dr,{icon:(0,n.jsx)(i.A,{size:15}),danger:!0,hint:j("svc.recreate.hint"),onClick:()=>{l(),k(e.name,"recreate")},children:j("svc.recreate")}),(0,n.jsx)(U.Dr,{icon:(0,n.jsx)(o.A,{size:15}),hint:j("svc.rebuild.hint"),onClick:()=>{l(),k(e.name,"rebuild")},children:j("svc.rebuild")})]})})]})]},e.name)})})]}),N&&(0,n.jsx)(G,{objectId:s,service:N,title:N,onClose:()=>y(null)})]})}function Z(e,s){var t,n,l,a,r,c;if("server"===e.kind)return e.config.start;let i=e.config;return"compose"===i.mode?"".concat((0,F._1)(null!=(t=i.file)?t:"")).concat((null==s?void 0:s.services)?" \xb7 ".concat(null!=(n=s.info.running)?n:0,"/").concat(null!=(l=s.info.services)?l:0):""):String(null!=(c=null!=(r=null!=(a=null==s?void 0:s.info.image)?a:i.image)?r:i.container)?c:"")}function Q(e){let{cluster:s}=e,{t}=(0,x.s9)(),{objects:c,refresh:i}=(0,j.o0)(),o=(0,p.dj)(),d=(0,B.useRouter)(),[h,b]=(0,l.useState)(null),[f,N]=(0,l.useState)(new Set),y=s.config.members,C=y.map(e=>c.find(s=>s.id===e)).filter(e=>!!e),{stats:S,reload:A}=function(e){let[s,t]=(0,l.useState)({}),[n,a]=(0,l.useState)(0),r=e.map(e=>"".concat(e.id,":").concat(e.state.status)).join(",");return(0,l.useEffect)(()=>{let s=!1,n,l=async()=>{let a=e.filter(e=>"cluster"!==e.kind&&"http"!==e.kind),r=await Promise.all(a.map(e=>u.FH.get("/objects/".concat(e.id,"/stats")).then(s=>[e.id,s]).catch(()=>null)));!s&&(t(Object.fromEntries(r.filter(e=>!!e))),e.some(e=>"running"===e.state.status||"starting"===e.state.status)&&(n=setTimeout(l,5e3)))};return l(),()=>{s=!0,clearTimeout(n)}},[r,n]),{stats:s,reload:()=>a(e=>e+1)}}(C),E=c.filter(e=>{var t,n;return("server"===e.kind||"docker"===e.kind)&&(null!=(t=e.colony_id)?t:null)===(null!=(n=s.colony_id)?n:null)&&!y.includes(e.id)}),z=async e=>{b("members");try{await u.FH.patch("/objects/".concat(s.id),{config:{members:e}}),await i(["objects"])}catch(e){o(e instanceof Error?e.message:t("edit.saveFailed"),"err")}finally{b(null)}},O=(e,s)=>{let t=[...y],n=e+s;n<0||n>=t.length||([t[e],t[n]]=[t[n],t[e]],z(t))},$=async(e,s)=>{b("".concat(e.id,":").concat(s));try{await u.FH.post("/objects/".concat(e.id,"/action"),{action:s})}catch(e){o("".concat(t("obj.act.failed",{action:t("obj.act.".concat(s))}),": ").concat(e instanceof Error?e.message:""),"err")}finally{b(null),A()}};return(0,n.jsxs)("div",{className:"cm",children:[0===C.length?(0,n.jsx)("p",{className:"muted",children:t("cl.none")}):(0,n.jsxs)("table",{className:"cm-table cm-tree",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:t("cl.order")}),(0,n.jsx)("th",{children:t("obj.f.name")}),(0,n.jsx)("th",{children:t("svc.col.runs")}),(0,n.jsx)("th",{children:t("ow.state")}),(0,n.jsx)("th",{className:"num",children:t("ow.cpu")}),(0,n.jsx)("th",{className:"num",children:t("ow.mem")}),(0,n.jsx)("th",{})]})}),(0,n.jsx)("tbody",{children:C.map((e,s)=>{let{icon:c,color:i}=v.Nd[e.kind],o="running"===e.state.status||"starting"===e.state.status,u=S[e.id],x=null==u?void 0:u.services,j=f.has(e.id);return(0,n.jsxs)(l.Fragment,{children:[(0,n.jsxs)("tr",{children:[(0,n.jsxs)("td",{className:"cm-ord",children:[(0,n.jsx)("span",{className:"ord",children:s+1}),(0,n.jsx)("button",{className:"btn ghost icon sm",disabled:0===s||!!h,onClick:()=>O(s,-1),"aria-label":t("cl.up"),title:t("cl.up"),children:(0,n.jsx)(q.A,{size:14})}),(0,n.jsx)("button",{className:"btn ghost icon sm",disabled:s===C.length-1||!!h,onClick:()=>O(s,1),"aria-label":t("cl.down"),title:t("cl.down"),children:(0,n.jsx)(T.A,{size:14})})]}),(0,n.jsx)("td",{children:(0,n.jsxs)("span",{className:"row gap-s",children:[x&&x.length>0?(0,n.jsx)("button",{className:"cm-chev",onClick:()=>{let s;return s=e.id,N(e=>{let t=new Set(e);return t.has(s)?t.delete(s):t.add(s),t})},"aria-expanded":j,"aria-label":j?t("svc.collapse"):t("svc.expand"),title:j?t("svc.collapse"):t("svc.expand"),children:j?(0,n.jsx)(R.A,{size:15}):(0,n.jsx)(I.A,{size:15})}):(0,n.jsx)("span",{style:{width:20}}),(0,n.jsxs)(w(),{href:"/resources/".concat(e.id),className:"cm-name",children:[(0,n.jsx)(c,{size:15,style:{color:i}}),(0,n.jsx)("b",{children:e.name})]})]})}),(0,n.jsx)("td",{className:"mono small svc-img",title:Z(e,u),children:Z(e,u)||"—"}),(0,n.jsxs)("td",{children:[(0,n.jsxs)("span",{className:"row gap-s small",children:[(0,n.jsx)(g.md,{status:e.state.status}),t("obj.status.".concat(e.state.status))]}),(0,n.jsx)("span",{className:"muted small",children:[(0,v.HS)(t,e.state.detail),e.state.since&&o?t("obj.since",{time:(0,F.KN)(e.state.since)}):""].filter(Boolean).join(" \xb7 ")})]}),(0,n.jsx)("td",{className:"num mono small",children:(null==u?void 0:u.cpu)!=null?"".concat(u.cpu,"%"):"—"}),(0,n.jsx)("td",{className:"num mono small",children:(null==u?void 0:u.memBytes)!=null?(0,L.zi)(u.memBytes):"—"}),(0,n.jsxs)("td",{className:"cm-act",children:[o?(0,n.jsx)("button",{className:"btn ghost icon sm",disabled:!!h,onClick:()=>void $(e,"stop"),"aria-label":t("obj.act.stop"),title:t("obj.act.stop"),children:(0,n.jsx)(a.A,{size:14})}):(0,n.jsx)("button",{className:"btn ghost icon sm",disabled:!!h,onClick:()=>void $(e,"start"),"aria-label":t("obj.act.start"),title:t("obj.act.start"),children:(0,n.jsx)(m.A,{size:14})}),(0,n.jsx)("button",{className:"btn ghost icon sm",disabled:!!h,onClick:()=>void $(e,"restart"),"aria-label":t("obj.act.restart"),title:t("obj.act.restart"),children:(0,n.jsx)(r.A,{size:14})}),(0,n.jsx)(U.W1,{label:t("svc.more"),icon:(0,n.jsx)(H.A,{size:15}),iconOnly:!0,children:s=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(U.Dr,{icon:(0,n.jsx)(D.A,{size:15}),onClick:()=>{s(),d.push("/resources/".concat(e.id))},children:t("cl.open")}),(0,n.jsx)(U.MU,{}),(0,n.jsx)(U.Dr,{icon:(0,n.jsx)(M.A,{size:15}),danger:!0,hint:t("cl.remove.hint"),disabled:!!h,onClick:()=>{s(),z(y.filter(s=>s!==e.id))},children:t("cl.remove")})]})})]})]}),j&&x&&(0,n.jsx)("tr",{className:"cm-sub",children:(0,n.jsx)("td",{colSpan:7,children:(0,n.jsx)(V,{objectId:e.id,services:x,onChanged:A})})})]},e.id)})})]}),(0,n.jsx)("p",{className:"muted small",style:{margin:"8px 0"},children:t("cl.startOrder")}),E.length>0&&(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)(k.A,{size:15,className:"muted"}),(0,n.jsxs)("select",{className:"select",style:{width:"auto"},value:"",onChange:e=>e.target.value&&void z([...y,e.target.value]),"aria-label":t("cl.add"),children:[(0,n.jsxs)("option",{value:"",children:[t("cl.add"),"…"]}),E.map(e=>(0,n.jsx)("option",{value:e.id,children:e.name},e.id))]})]})]})}let Y=e=>{let{k:s,v:t}=e;return(0,n.jsxs)("div",{className:"ov-row",children:[(0,n.jsx)("dt",{children:s}),(0,n.jsx)("dd",{children:t})]})};function ee(e){var s,t,a,r,c,i,o,h,m,j,p,b,f;let{object:w,onSeeLogs:N}=e,{t:y}=(0,x.s9)(),{stats:k,cpu:C,mem:S,live:E,reload:q}=function(e){let[s,t]=(0,l.useState)(null),[n,a]=(0,l.useState)([]),[r,c]=(0,l.useState)([]),i="running"===e.state.status||"starting"===e.state.status,[o,d]=(0,l.useState)(0);return(0,l.useEffect)(()=>{if("server"!==e.kind&&"docker"!==e.kind)return;0===o&&(t(null),a([]),c([]));let s=!1,n,l=async()=>{try{let n=await u.FH.get("/objects/".concat(e.id,"/stats"));if(s)return;t(n),null!==n.cpu&&a(e=>[...e,n.cpu].slice(-60)),null!==n.memBytes&&c(e=>[...e,n.memBytes].slice(-60))}catch(e){}!s&&i&&(n=setTimeout(l,3e3))};return l(),()=>{s=!0,clearTimeout(n)}},[e.id,e.kind,i,o]),{stats:s,cpu:n,mem:r,live:i,reload:()=>d(e=>e+1)}}(w),[,T]=(0,l.useState)(0);(0,A.n)(()=>T(e=>e+1),1e3,{enabled:E,immediate:!1});let{text:R}=z(w.id,{max:4e4,pollMs:2e3}),I=(0,l.useMemo)(()=>(null!=R?R:"").split("\n").filter(e=>e.trim()).slice(-14).join("\n"),[R]),H=null!=(t=null==k?void 0:k.info)?t:{},D=w.state,M=y("ow.d.none"),U=[];if("server"===w.kind){let e=w.config;U.push([y("ow.d.command"),(0,n.jsx)("code",{className:"mono",children:e.start},"c")],[y("ow.d.folder"),(0,n.jsx)("code",{className:"mono",title:e.cwd,children:(0,F._1)(e.cwd)},"f")]),e.port&&U.push([y("ow.d.port"),e.port]),e.stop&&U.push([y("ow.d.stop"),(0,n.jsx)("code",{className:"mono",children:e.stop},"s")]),U.push([y("ow.d.restart"),e.restart&&"no"!==e.restart?"".concat(y("always"===e.restart?"obj.sup.restart.always":"obj.sup.restart.fail")," (").concat(null!=(a=e.maxRestarts)?a:5,")"):y("obj.sup.restart.no")]),U.push([y("ow.d.health"),e.health?"".concat(e.health.kind.toUpperCase(),": ").concat(e.health.target):M]),D.pid&&U.push(["PID",D.pid])}else if("docker"===w.kind){let e=w.config;U.push([y("ow.d.mode"),y("obj.mode.".concat(e.mode))]),"compose"===e.mode?U.push([y("ow.d.compose"),(0,n.jsx)("code",{className:"mono",title:e.file,children:(0,F._1)(null!=(r=e.file)?r:"")},"f")],[y("ow.d.services"),"".concat(null!=(c=H.running)?c:0,"/").concat(null!=(i=H.services)?i:0)]):(U.push([y("ow.d.container"),(0,n.jsx)("code",{className:"mono",children:"existing"===e.mode?e.container:"hive-am-".concat(w.id.slice(0,8))},"n")]),(H.image||e.image)&&U.push([y("ow.d.image"),(0,n.jsx)("code",{className:"mono",children:String(null!=(m=H.image)?m:e.image)},"i")]),(H.ports||(null==(o=e.ports)?void 0:o.length))&&U.push([y("ow.d.ports"),String(null!=(j=H.ports)?j:null==(h=e.ports)?void 0:h.join(", "))]),(H.network||e.network)&&U.push([y("ow.d.network"),String(null!=(p=H.network)?p:e.network)]),H.restartPolicy&&U.push([y("ow.d.restart"),String(H.restartPolicy)]),void 0!==H.restarts&&null!==H.restarts&&U.push([y("ow.d.restarts"),String(H.restarts)]),H.memoryLimit&&U.push([y("ow.d.memLimit"),(0,L.zi)(Number(H.memoryLimit))]),H.cpuLimit&&U.push([y("ow.d.cpuLimit"),String(H.cpuLimit)]),H.created&&U.push([y("ow.d.created"),(0,F.KN)(Number(H.created))]))}return(0,n.jsxs)("div",{className:"ov",children:[(0,n.jsxs)("div",{className:"ov-grid",children:[(0,n.jsxs)("section",{className:"ov-card",children:[(0,n.jsx)("div",{className:"eyebrow",children:y("ow.state")}),(0,n.jsxs)("div",{className:"ov-big",children:[(0,n.jsx)(g.md,{status:D.status,className:"lg"}),y("obj.status.".concat(D.status))]}),D.detail&&(0,n.jsx)("p",{className:"muted small",style:{margin:0},children:(0,v.HS)(y,D.detail)}),D.since&&E&&(0,n.jsxs)("p",{className:"small",style:{margin:0},children:[y("ow.uptime")," ",(0,n.jsx)("b",{children:(e=>{let s=Math.max(0,Math.floor(e/1e3)),t=Math.floor(s/86400),n=Math.floor(s%86400/3600),l=Math.floor(s%3600/60);return t?"".concat(t,"d ").concat(n,"h"):n?"".concat(n,"h ").concat(l,"m"):l?"".concat(l,"m ").concat(s%60,"s"):"".concat(s,"s")})(Date.now()-D.since)})]})]}),("server"===w.kind||"docker"===w.kind)&&(0,n.jsxs)("section",{className:"ov-card",children:[(0,n.jsx)("div",{className:"eyebrow",children:y("ow.usage")}),E||(null==k?void 0:k.cpu)!==null?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"ov-meter",children:[(0,n.jsx)("span",{children:y("ow.cpu")}),(0,n.jsx)("b",{children:(null==k?void 0:k.cpu)!==null&&(null==k?void 0:k.cpu)!==void 0?"".concat(k.cpu,"%"):"—"})]}),(0,n.jsx)(O,{values:C,color:"var(--p-opencode)"}),(0,n.jsxs)("div",{className:"ov-meter",children:[(0,n.jsx)("span",{children:y("ow.mem")}),(0,n.jsx)("b",{children:(null==k?void 0:k.memBytes)!=null?"".concat((0,L.zi)(k.memBytes)).concat(k.memLimitBytes?" / ".concat((0,L.zi)(k.memLimitBytes)):""):"—"})]}),(0,n.jsx)(O,{values:S,color:"var(--ok)"}),(0,n.jsxs)("dl",{className:"ov-dl",children:[(null==k?void 0:k.pids)!=null&&(0,n.jsx)(Y,{k:y("ow.procs"),v:k.pids}),(null==k?void 0:k.net)&&(0,n.jsx)(Y,{k:y("ow.net"),v:k.net}),(null==k?void 0:k.block)&&(0,n.jsx)(Y,{k:y("ow.block"),v:k.block})]})]}):(0,n.jsx)("p",{className:"muted small",style:{margin:0},children:y("ow.noUsage")})]}),U.length>0&&(0,n.jsxs)("section",{className:"ov-card",children:[(0,n.jsx)("div",{className:"eyebrow",children:y("ow.info")}),(0,n.jsx)("dl",{className:"ov-dl",children:U.map((e,s)=>{let[t,l]=e;return(0,n.jsx)(Y,{k:t,v:l},s)})})]})]}),"docker"===w.kind&&"compose"===w.config.mode&&(0,n.jsxs)("section",{className:"ov-card wide",children:[(0,n.jsxs)("div",{className:"eyebrow",children:[y("ow.d.services"),(null==k||null==(s=k.services)?void 0:s.length)?" \xb7 ".concat(null!=(b=H.running)?b:0,"/").concat(null!=(f=H.services)?f:0):""]}),null===k?(0,n.jsxs)("p",{className:"muted small ov-empty",children:[(0,n.jsx)(d.A,{size:14,className:"spin"})," ",y("ow.svc.loading")]}):k.services&&k.services.length>0?(0,n.jsx)(V,{objectId:w.id,services:k.services,onLogs:e=>N("".concat(e,"-")),onChanged:q}):(0,n.jsx)("p",{className:"muted small ov-empty",children:y(E?"ow.svc.none":"ow.svc.stopped")})]}),"cluster"===w.kind&&(0,n.jsxs)("section",{className:"ov-card wide",children:[(0,n.jsx)("div",{className:"eyebrow",children:y("cl.members")}),(0,n.jsx)(Q,{cluster:w})]}),(0,n.jsxs)("section",{className:"ov-card wide grow",children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("div",{className:"eyebrow grow",children:y("ow.recent")}),(0,n.jsx)("button",{className:"btn ghost sm",onClick:()=>N(),children:y("ow.seeLogs")})]}),(0,n.jsx)("pre",{className:"ov-log mono",children:null===R?y("git.loading"):I||y("obj.logs.empty")})]})]})}var es=t(97356),et=t(52974),en=t(9217);function el(e){let{object:s}=e,{t}=(0,x.s9)(),{refresh:a}=(0,j.o0)(),r=(0,p.dj)(),c=(0,B.useRouter)(),i=(0,l.useMemo)(()=>(0,en.QJ)(s),[s.updated_at,s.id]),{d:o,set:d,setD:h}=(0,en.Te)(()=>i),[m,b]=(0,l.useState)(""),[v,g]=(0,l.useState)(!1),[f,w]=(0,l.useState)(!1),[N,y]=(0,l.useState)(null);(0,l.useEffect)(()=>{"http"===s.kind&&u.FH.get("/objects/".concat(s.id,"/http")).then(y).catch(()=>void 0)},[s.id,s.kind]);let k=JSON.stringify(o)!==JSON.stringify(i),C="running"===s.state.status||"starting"===s.state.status,S="server"===s.kind||"docker"===s.kind||"cluster"===s.kind,A=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!o.name.trim())return void b(t("obj.err.name"));g(!0),b("");try{await u.FH.patch("/objects/".concat(s.id),{name:o.name.trim(),colony_id:o.colony_id||null,config:(0,en.qP)(o)}),o.manager!==i.manager&&et.G.includes(s.kind)&&await u.FH.put("/objects/".concat(s.id,"/manager"),{agent_id:o.manager||null}),await a(["objects","agents"]),e&&await u.FH.post("/objects/".concat(s.id,"/action"),{action:"restart"}).catch(e=>r(e instanceof Error?e.message:"","err")),r(t("obj.saved"))}catch(e){b(e instanceof Error?e.message:t("edit.saveFailed"))}finally{g(!1)}},E=async()=>{await u.FH.del("/objects/".concat(s.id)),await a(["objects"]),r(t("obj.deleted")),c.push("/resources")};return(0,n.jsxs)("div",{className:"oc",children:[(0,n.jsx)("div",{className:"oc-body",children:(0,n.jsx)("div",{className:"oc-form",children:(0,n.jsx)(en.Bh,{objectId:s.id,d:o,set:d,setD:h,scan:N,error:m})})}),(0,n.jsxs)("div",{className:"savebar oc-bar",children:[(0,n.jsxs)("span",{className:"muted small grow",children:[k?t("ow.cfg.dirty"):t("ow.cfg.saved"),k&&S?" \xb7 ".concat(C?t("ow.cfg.appliesRunning"):t("ow.cfg.applies")):""]}),(0,n.jsxs)("button",{className:"btn danger",onClick:()=>w(!0),children:[(0,n.jsx)(es.A,{size:15}),t("common.delete")]}),(0,n.jsx)("button",{className:"btn ghost",disabled:!k||v,onClick:()=>{h(()=>i),b("")},children:t("ow.cfg.discard")}),S&&C&&(0,n.jsx)("button",{className:"btn",disabled:!k||v,onClick:()=>void A(!0),children:t("ow.cfg.saveRestart")}),(0,n.jsx)("button",{className:"btn primary",disabled:!k||v,onClick:()=>void A(),children:t("ow.cfg.save")})]}),f&&(0,n.jsx)(p.TM,{title:t("obj.delete.title",{name:s.name}),confirmLabel:t("obj.delete"),danger:!0,onConfirm:E,onClose:()=>w(!1),body:"server"===s.kind?t("obj.delete.server"):"docker"===s.kind?t("obj.delete.".concat(s.config.mode)):t("obj.delete.".concat(s.kind))})]})}var ea=t(58311),er=t(15145),ec=t(45385),ei=t(23132),eo=t(17395),ed=t(64883),eh=t(494),em=t(98759),eu=t(98392);let ex=/\b(error|fatal|exception|panic|fail(ed|ure)?|traceback)\b/i,ej=/\b(warn(ing)?|deprecated)\b/i;function ep(e){let{id:s,members:t,initialFilter:a}=e,{t:r}=(0,x.s9)(),[c,i]=(0,l.useState)(!1),{text:o,dropped:d,clear:h}=z(s,{paused:c}),[u,j]=(0,l.useState)(null!=a?a:""),p=(0,l.useDeferredValue)(u),[b,v]=(0,l.useState)(!!a),[g,f]=(0,l.useState)(!0),[w,N]=(0,l.useState)(!0),[y,k]=(0,l.useState)(12.5),[C,S]=(0,l.useState)(new Set),A=(0,l.useRef)(null);(0,l.useEffect)(()=>{try{let e=Number(localStorage.getItem("hive-am.logsize"));e>=10&&e<=20&&k(e)}catch(e){}},[]);let E=e=>k(s=>{let t=Math.max(10,Math.min(20,s+e));try{localStorage.setItem("hive-am.logsize",String(t))}catch(e){}return t}),L=(0,l.useMemo)(()=>o?o.split("\n"):[],[o]),O=(0,l.useMemo)(()=>{let e=p.trim().toLowerCase(),s=[];for(let n=0;n<L.length;n++){let l=L[n],a=t?/^\[([^\]]+)\] /.exec(l):null;!(a&&C.has(a[1]))&&(!b||!e||l.toLowerCase().includes(e))&&s.push({line:l,idx:d+n,member:null==a?void 0:a[1]})}return s},[L,p,b,C,t,d]),q=O.length>2e3?O.slice(O.length-2e3):O,T=(0,l.useMemo)(()=>{let e=new Map;for(let s of q){let t=Math.floor(s.idx/50),n=e.get(t);n?n.push(s):e.set(t,[s])}return[...e]},[q]),R=(0,l.useMemo)(()=>{let e=p.trim().toLowerCase();return e?O.filter(s=>s.line.toLowerCase().includes(e)).length:0},[O,p]);return(0,l.useEffect)(()=>{let e=A.current;e&&g&&(e.scrollTop=e.scrollHeight)},[q,g]),(0,n.jsxs)("div",{className:"lp",children:[(0,n.jsxs)("div",{className:"lp-bar",children:[(0,n.jsxs)("div",{className:"search lp-search",children:[(0,n.jsx)(ea.A,{size:14}),(0,n.jsx)("input",{className:"input",placeholder:r("lp.search"),value:u,onChange:e=>j(e.target.value),"aria-label":r("lp.search")}),R>0&&(0,n.jsx)("span",{className:"lp-hits",children:r("lp.matches",{count:R})})]}),(0,n.jsxs)("label",{className:"row gap-s small",children:[(0,n.jsx)("input",{type:"checkbox",checked:b,onChange:e=>v(e.target.checked)}),r("lp.only")]}),(0,n.jsx)("span",{className:"grow"}),(0,n.jsx)("button",{className:"btn ghost icon sm ".concat(w?"on":""),"aria-pressed":w,onClick:()=>N(e=>!e),"aria-label":r("lp.wrap"),title:r("lp.wrap"),children:(0,n.jsx)(er.A,{size:15})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>E(-1),"aria-label":r("lp.smaller"),title:r("lp.smaller"),children:(0,n.jsx)(ec.A,{size:15})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>E(1),"aria-label":r("lp.larger"),title:r("lp.larger"),children:(0,n.jsx)(ei.A,{size:15})}),(0,n.jsx)("button",{className:"btn ghost icon sm ".concat(c?"on":""),"aria-pressed":c,onClick:()=>i(e=>!e),"aria-label":r(c?"lp.resume":"lp.pause"),title:r(c?"lp.resume":"lp.pause"),children:c?(0,n.jsx)(m.A,{size:15}):(0,n.jsx)(eo.A,{size:15})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:h,"aria-label":r("lp.clear"),title:r("lp.clear"),children:(0,n.jsx)(ed.A,{size:15})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>{var e;null==(e=navigator.clipboard)||e.writeText(L.join("\n"))},"aria-label":r("lp.copy"),title:r("lp.copy"),children:(0,n.jsx)(eh.A,{size:15})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>{let e=document.createElement("a");e.href=URL.createObjectURL(new Blob([L.join("\n")],{type:"text/plain"})),e.download="".concat(s.slice(0,8),"-").concat(new Date().toISOString().slice(0,19).replace(/[:T]/g,"-"),".log"),e.click(),setTimeout(()=>URL.revokeObjectURL(e.href),4e3)},"aria-label":r("lp.download"),title:r("lp.download"),children:(0,n.jsx)(em.A,{size:15})})]}),t&&t.length>0&&(0,n.jsx)("div",{className:"lp-chips",children:t.map((e,s)=>(0,n.jsx)("button",{className:"lp-chip ".concat(C.has(e)?"off":""),style:{"--c":F.hg[s%F.hg.length]},"aria-pressed":!C.has(e),onClick:()=>S(s=>{let t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t}),children:e},e))}),(0,n.jsx)("div",{className:"lp-body mono ".concat(w?"wrap":""),ref:A,onScroll:()=>{let e=A.current;if(!e)return;let s=e.scrollHeight-e.scrollTop-e.clientHeight<40;!s&&g?f(!1):s&&!g&&f(!0)},tabIndex:0,style:{fontSize:y},children:null===o?(0,n.jsx)("p",{className:"muted",children:r("git.loading")}):0===q.length?(0,n.jsx)("p",{className:"muted",children:r("obj.logs.empty")}):T.map(e=>{let[s,l]=e;return(0,n.jsx)(ev,{rows:l,members:t,needle:p.trim()},s)})}),(0,n.jsxs)("div",{className:"lp-foot muted small",children:[(0,n.jsxs)("span",{children:[r("lp.lines",{count:O.length}),O.length>2e3?" \xb7 ".concat(r("lp.shown",{count:2e3})):"",c?" \xb7 ".concat(r("lp.paused")):""]}),!g&&(0,n.jsxs)("button",{className:"btn sm",onClick:()=>{f(!0);let e=A.current;e&&(e.scrollTop=e.scrollHeight)},children:[(0,n.jsx)(eu.A,{size:14}),r("lp.follow")]})]})]})}function eb(e){let{line:s,member:t,mi:a,needle:r}=e,c=ex.test(s)?"err":ej.test(s)?"warn":"",i=t&&a>=0?s.slice(t.length+3):s,o=!1,d=[];if(r){let e=i.toLowerCase(),s=r.toLowerCase(),t=0,l=0;for(let a=e.indexOf(s);a>=0;a=e.indexOf(s,t))o=!0,d.push(i.slice(t,a),(0,n.jsx)("mark",{children:i.slice(a,a+r.length)},l++)),t=a+r.length;d.push(i.slice(t))}let h=r?d.map((e,s)=>(0,n.jsx)(l.Fragment,{children:e},s)):i;return(0,n.jsx)("div",{className:"lp-row ".concat(c," ").concat(o?"hit":""),style:a>=0?{"--c":F.hg[a%F.hg.length]}:void 0,children:t&&a>=0?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("b",{className:"lp-src",children:["[",t,"]"]}),h]}):h})}let ev=(0,l.memo)(function(e){let{rows:s,members:t,needle:l}=e;return(0,n.jsx)(n.Fragment,{children:s.map(e=>{var s;return(0,n.jsx)(eb,{line:e.line,member:e.member,mi:e.member&&null!=(s=null==t?void 0:t.indexOf(e.member))?s:-1,needle:l},e.idx)})})},(e,s)=>e.needle===s.needle&&e.members===s.members&&e.rows.length===s.rows.length&&e.rows.every((e,t)=>e.idx===s.rows[t].idx&&e.line===s.rows[t].line));var eg=t(20422);function ef(e){let{list:s,children:t,gap:l=!1,listWidth:a}=e;return(0,n.jsxs)("div",{className:"msd ".concat(l?"msd-gap":""),style:a?{"--msd-list":a}:void 0,children:[s,t]})}let ew=(e,s)=>u.FH.get("/objects/".concat(e,"/http/file?file=").concat(encodeURIComponent(s))).then(e=>e.content),eN=(e,s,t)=>u.FH.put("/objects/".concat(e,"/http/file"),{file:s,content:t});async function ey(e,s,t){await eN(e,s,t(await ew(e,s)))}function ek(e){let s=["### ".concat(e.name.trim()||"".concat(e.method," request")),"".concat(e.method," ").concat(e.url.trim()),...e.headers.filter(e=>e.name.trim()).map(e=>"".concat(e.name.trim(),": ").concat(e.value))];return e.body.trim()&&s.push("",e.body.replace(/\s+$/,"")),s.join("\n")}function eC(e,s){let t=s;for(;t<e.length&&/^\s+[?&]/.test(e[t]);)t++;let n=t;for(;t<e.length&&e[t].trim()&&!/^#{3,}/.test(e[t].trim());)t++;return{first:n,end:t}}function eS(e,s,t,n){let l=e.split("\n"),{first:a,end:r}=eC(l,s),c=l.slice(a,r).findIndex(e=>e.split(":")[0].trim().toLowerCase()===t.toLowerCase());return c>=0?null===n?l.splice(a+c,1):l[a+c]="".concat(t,": ").concat(n):null!==n&&l.splice(r,0,"".concat(t,": ").concat(n)),l.join("\n")}function eA(e,s,t){let n=e.split("\n"),{first:l,end:a}=eC(n,s),r=n.slice(l,a).find(e=>e.split(":")[0].trim().toLowerCase()===t.toLowerCase());return void 0===r?void 0:r.slice(r.indexOf(":")+1).trim()}let eE={status:["=","!=","2xx","<",">"],time:["<",">"],header:["exists","=","contains"],body:["exists","=","!=","contains",">","<"],text:["contains"]},ez="// hive-am:asserts ",eF=e=>/^-?\d+(\.\d+)?$/.test(e.trim())||/^(true|false|null)$/.test(e.trim())?e.trim():JSON.stringify(e);function eL(e,s){let t=s;for(;t<e.length&&!/^#{3,}/.test(e[t].trim());)t++;return{start:s-1,end:t}}let eO=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],eq="\0new";function eT(e){var s,t;let{objectId:a,files:r,defaultFile:c,onClose:i,onCreated:o}=e,{t:d}=(0,x.s9)(),[h,m]=(0,l.useState)("form"),[j,b]=(0,l.useState)(c&&r.some(e=>e.relFile===c)?c:null!=(t=null==(s=r[0])?void 0:s.relFile)?t:eq),[v,g]=(0,l.useState)("requests.http"),[f,w]=(0,l.useState)({name:"",method:"GET",url:"{{host}}/",headers:[],body:""}),[N,y]=(0,l.useState)(""),[k,C]=(0,l.useState)(""),[S,A]=(0,l.useState)(""),[E,z]=(0,l.useState)(!1),F=async()=>{if(!f.url.trim())return void A(d("hw2.new.needUrl"));z(!0),A("");try{let e={...f,headers:N.split("\n").map(e=>{let s=e.indexOf(":");return s>0?{name:e.slice(0,s).trim(),value:e.slice(s+1).trim()}:{name:"",value:""}}).filter(e=>e.name)};if(j===eq){let s,t=v.trim();await (s="".concat(ek(e),"\n"),u.FH.post("/objects/".concat(a,"/http/file"),{file:t,content:s})),o(t)}else await ey(a,j,s=>(function(e,s){let t=e.replace(/\s+$/,"");return"".concat(t).concat(t?"\n\n":"").concat(ek(s),"\n")})(s,e)),o(j)}catch(e){A(e instanceof Error?e.message:"error")}finally{z(!1)}};return(0,n.jsx)(p.aF,{title:d("hw2.new.title"),onClose:i,children:(0,n.jsxs)("div",{className:"stack",children:[(0,n.jsx)(p.$q,{value:h,onChange:m,options:[{id:"form",label:d("hw2.new.form")},{id:"curl",label:d("hw2.new.curl")}]}),"curl"===h?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(p.D0,{label:d("hw2.new.curl"),hint:d("hw2.new.curlHint"),children:(0,n.jsx)("textarea",{className:"input mono",rows:7,value:k,onChange:e=>C(e.target.value),placeholder:"curl -X POST 'https://…' -H 'Content-Type: application/json' -d '{…}'",autoFocus:!0})}),(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)("span",{className:"grow"}),(0,n.jsx)("button",{className:"btn primary",disabled:!k.trim(),onClick:()=>{try{let e=function(e){let s=function(e){let s=[],t="",n=!1,l=e.replace(/\\\r?\n/g," ").replace(/\^\r?\n/g," ");for(let e=0;e<l.length;e++){let r=l[e];if("'"===r){n=!0;let s=l.indexOf("'",e+1),a=s<0?l.length:s;t+=l.slice(e+1,a),e=a;continue}if('"'===r){for(n=!0,e++;e<l.length&&'"'!==l[e];e++)"\\"===l[e]&&e+1<l.length&&/["\\$`]/.test(l[e+1])&&e++,t+=l[e];continue}if("$"===r&&"'"===l[e+1]){for(n=!0,e+=2;e<l.length&&"'"!==l[e];e++)if("\\"===l[e]&&e+1<l.length){var a;t+=null!=(a=({n:"\n",t:" ",r:"\r","'":"'","\\":"\\"})[l[++e]])?a:l[e]}else t+=l[e];continue}if("\\"===r&&e+1<l.length){n=!0,t+=l[++e];continue}if(/\s/.test(r)){n&&(s.push(t),t="",n=!1);continue}n=!0,t+=r}return n&&s.push(t),s}(e.trim());"curl"===s[0]&&s.shift();let t="",n="",l,a=[],r=[],c="",i=!1,o=!1;for(let e=0;e<s.length;e++){let l=s[e],d=()=>{var t;return null!=(t=s[++e])?t:""},h=RegExp("^(--[\\w-]+)=(.*)$","s").exec(l),m=h?h[1]:l,u=()=>h?h[2]:d();if("-X"===m||"--request"===m)t=u().toUpperCase();else if("-H"===m||"--header"===m){let e=u(),s=e.indexOf(":");s>0&&a.push({name:e.slice(0,s).trim(),value:e.slice(s+1).trim()})}else["-d","--data","--data-raw","--data-binary","--data-ascii","--data-urlencode"].includes(m)?r.push(u()):"-u"===m||"--user"===m?c=u():"-b"===m||"--cookie"===m?a.push({name:"Cookie",value:u()}):"-A"===m||"--user-agent"===m?a.push({name:"User-Agent",value:u()}):"-e"===m||"--referer"===m?a.push({name:"Referer",value:u()}):"--url"===m?n=u():"-F"===m||"--form"===m?(i=!0,r.push(u())):"-G"===m||"--get"===m?o=!0:"-I"===m||"--head"===m?t="HEAD":["-o","--output","-m","--max-time","--connect-timeout","-w","--write-out","--proxy","-x","--cacert","--cert","--key","-E"].includes(m)?h||d():l.startsWith("-")||n||(n=l)}if(!n)throw Error("No URL found in the command");if(r.length&&(l=r.join("&")),c&&a.push({name:"Authorization",value:"Basic ".concat(c.replace(":"," "))}),o&&l&&(n+=(n.includes("?")?"&":"?")+l,l=void 0),t||(t=void 0===l||i?"GET":"POST"),i)throw Error("multipart forms (-F) are not supported yet");let d="";try{let e=new URL(n);d="".concat(t," ").concat(e.pathname)}catch(e){d="".concat(t," request")}return void 0===l||a.some(e=>"content-type"===e.name.toLowerCase())||a.push({name:"Content-Type",value:/^\s*[[{]/.test(l)?"application/json":"application/x-www-form-urlencoded"}),{name:d,method:t,url:n,headers:a,body:null!=l?l:""}}(k);w(e),y(e.headers.map(e=>"".concat(e.name,": ").concat(e.value)).join("\n")),m("form"),A("")}catch(e){A(e instanceof Error?e.message:"error")}},children:d("hw2.new.parse")})]})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(p.D0,{label:d("hw2.new.file"),children:(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsxs)("select",{className:"select",value:j,onChange:e=>b(e.target.value),style:{flex:1},children:[r.map(e=>(0,n.jsx)("option",{value:e.relFile,children:e.relFile},e.relFile)),(0,n.jsx)("option",{value:eq,children:d("hw2.new.newFile")})]}),j===eq&&(0,n.jsx)("input",{className:"input mono",value:v,onChange:e=>g(e.target.value),"aria-label":d("hw2.new.file"),style:{flex:1}})]})}),(0,n.jsx)(p.D0,{label:d("obj.f.name"),children:(0,n.jsx)("input",{className:"input",value:f.name,onChange:e=>w({...f,name:e.target.value}),placeholder:"login",autoFocus:!0})}),(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)("select",{className:"select",style:{width:120},value:f.method,onChange:e=>w({...f,method:e.target.value}),"aria-label":"Method",children:eO.map(e=>(0,n.jsx)("option",{children:e},e))}),(0,n.jsx)("input",{className:"input mono",style:{flex:1},value:f.url,onChange:e=>w({...f,url:e.target.value}),placeholder:"{{host}}/path","aria-label":"URL"})]}),(0,n.jsx)(p.D0,{label:d("http.headers"),hint:d("hw2.new.headersHint"),children:(0,n.jsx)("textarea",{className:"input mono",rows:3,value:N,onChange:e=>y(e.target.value),placeholder:"Content-Type: application/json"})}),(0,n.jsx)(p.D0,{label:d("http.requestBody"),children:(0,n.jsx)("textarea",{className:"input mono",rows:4,value:f.body,onChange:e=>w({...f,body:e.target.value})})}),(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)("button",{className:"btn ghost",onClick:()=>m("curl"),children:d("hw2.new.curl")}),(0,n.jsx)("span",{className:"grow"}),(0,n.jsx)("button",{className:"btn",onClick:i,children:d("hw2.cancel")}),(0,n.jsx)("button",{className:"btn primary",disabled:E,onClick:()=>void F(),children:d("hw2.new.add")})]})]}),S&&(0,n.jsx)("p",{className:"gx-note err",style:{margin:0},children:S})]})})}var eR=t(37870),eI=t(42366);function eH(e){let{objectId:s,file:t,env:r,onClose:c,onDone:i}=e,{t:o}=(0,x.s9)(),[d,h]=(0,l.useState)(""),[j,b]=(0,l.useState)(!1),[v,g]=(0,l.useState)(""),[f,w]=(0,l.useState)([]),[N,y]=(0,l.useState)(!1),k=(0,l.useRef)(!1),C=null,S="";if(d.trim())try{(C=function(e){var s,t,n,l;let a=e.trim();if(!a)throw Error("No data");if(a.startsWith("[")||a.startsWith("{")){let e=JSON.parse(a),s=Array.isArray(e)?e:[e];if(!s.every(e=>e&&"object"==typeof e&&!Array.isArray(e)))throw Error("A JSON array of objects is expected");let t=[...new Set(s.flatMap(e=>Object.keys(e)))];return{columns:t,rows:s.map(e=>Object.fromEntries(t.map(s=>[s,void 0===e[s]||null===e[s]?"":"object"==typeof e[s]?JSON.stringify(e[s]):String(e[s])])))}}let r=a.split(/\r?\n/,1)[0],c=(null!=(n=null==(s=r.match(/;/g))?void 0:s.length)?n:0)>(null!=(l=null==(t=r.match(/,/g))?void 0:t.length)?l:0)?";":r.includes(" ")&&!r.includes(",")?" ":",",i=[],o=[],d="",h=!1;for(let e=0;e<a.length;e++){let s=a[e];if(h){'"'===s?'"'===a[e+1]?(d+='"',e++):h=!1:d+=s;continue}'"'===s?h=!0:s===c?(o.push(d),d=""):"\n"===s||"\r"===s?("\r"===s&&"\n"===a[e+1]&&e++,o.push(d),d="",o.some(e=>""!==e)&&i.push(o),o=[]):d+=s}o.push(d),o.some(e=>""!==e)&&i.push(o);let m=i[0].map(e=>e.trim());if(m.some(e=>!/^[A-Za-z_][\w.-]{0,80}$/.test(e)))throw Error("The first line must be the variable names (letters, numbers, _ . -)");return{columns:m,rows:i.slice(1).map(e=>Object.fromEntries(m.map((s,t)=>{var n;return[s,null!=(n=e[t])?n:""]})))}}(d)).rows.length>200&&(S=o("hw2.batch.tooMany",{max:200}),C=null)}catch(e){S=e instanceof Error?e.message:"error"}let A=async()=>{if(!C)return;g(""),w([]),y(!0),k.current=!1;let e=C.columns,n=[];try{for(let l of C.rows){if(k.current)break;for(let t of e)await u.FH.post("/objects/".concat(s,"/http/session"),{name:t,value:l[t]});let a=[],c=!1;for(let e of t.requests){if(k.current||c&&j){a.push({ok:!1,tests:"",error:o("hw2.batch.skipped")});continue}try{let n=await u.FH.post("/objects/".concat(s,"/http/run"),{file:t.relFile,index:e.index,env:r||void 0}),l=n.tests.filter(e=>!e.passed).length+ +!!n.scriptError,i=n.status<400&&0===l;i||(c=!0),a.push({status:n.status,ok:i,tests:n.tests.length?"".concat(n.tests.length-n.tests.filter(e=>!e.passed).length,"/").concat(n.tests.length):""})}catch(e){c=!0,a.push({ok:!1,tests:"",error:e instanceof Error?e.message:"error"})}}n.push(a),w([...n])}}catch(e){g(e instanceof Error?e.message:"error")}finally{for(let t of e)await u.FH.del("/objects/".concat(s,"/http/session?name=").concat(encodeURIComponent(t))).catch(()=>void 0);y(!1),i()}},E=f.filter(e=>e.every(e=>e.ok)).length;return(0,n.jsx)(p.aF,{title:o("hw2.batch.title",{file:t.relFile}),onClose:()=>{k.current=!0,c()},children:(0,n.jsxs)("div",{className:"stack",children:[(0,n.jsxs)("div",{className:"field",children:[(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)("label",{className:"label",htmlFor:"batch-data",children:o("hw2.batch.data")}),(0,n.jsx)(eI.B,{size:"sm",label:o("common.help"),title:o("hw2.help.how"),children:o("hw2.batch.hint")})]}),(0,n.jsx)("textarea",{id:"batch-data",className:"input mono",rows:6,value:d,onChange:e=>h(e.target.value),placeholder:"user,passwd\nana,s3cret\nluis,otra",spellCheck:!1,disabled:N}),(0,n.jsx)("span",{className:"muted small",children:o("hw2.batch.format")})]}),(0,n.jsxs)("div",{className:"row gap-s wrap",children:[(0,n.jsxs)("label",{className:"btn sm",children:[(0,n.jsx)(eR.A,{size:14}),o("hw2.batch.file"),(0,n.jsx)("input",{type:"file",accept:".csv,.json,.txt,text/csv,application/json",hidden:!0,onChange:e=>{var s,t;(t=null==(s=e.target.files)?void 0:s[0])&&t.text().then(h)}})]}),(0,n.jsx)(p.Tl,{checked:j,onChange:b,label:o("hw2.batch.stopRow")}),(0,n.jsx)("span",{className:"grow"}),C&&(0,n.jsx)("span",{className:"muted small",children:o("hw2.batch.rows",{rows:C.rows.length,cols:C.columns.join(", ")})}),N?(0,n.jsxs)("button",{className:"btn",onClick:()=>{k.current=!0},children:[(0,n.jsx)(a.A,{size:14}),o("hw2.batch.stop")]}):(0,n.jsxs)("button",{className:"btn primary",disabled:!C||!C.rows.length,onClick:()=>void A(),children:[(0,n.jsx)(m.A,{size:14}),o("hw2.batch.run")]})]}),S&&(0,n.jsx)("p",{className:"gx-note err",style:{margin:0},children:S}),v&&(0,n.jsx)("p",{className:"gx-note err",style:{margin:0},children:v}),f.length>0&&C&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("p",{className:"small",style:{margin:0},children:[(0,n.jsx)("b",{children:o("hw2.batch.summary",{ok:E,total:f.length})}),N?" …":""]}),(0,n.jsx)("div",{style:{overflow:"auto",maxHeight:280},children:(0,n.jsxs)("table",{className:"cm-table",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:"#"}),C.columns.slice(0,2).map(e=>(0,n.jsx)("th",{children:e},e)),t.requests.map(e=>(0,n.jsx)("th",{title:e.name,children:e.name.slice(0,18)},e.id))]})}),(0,n.jsx)("tbody",{children:f.map((e,s)=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{children:s+1}),C.columns.slice(0,2).map(e=>(0,n.jsx)("td",{className:"mono small",children:C.rows[s][e]},e)),e.map((e,s)=>{var t;return(0,n.jsx)("td",{title:null!=(t=e.error)?t:"",children:(0,n.jsxs)("span",{className:"hr-st ".concat(e.ok?"ok":"err"),children:[e.error?"—":e.status,e.tests?" \xb7 ".concat(e.tests):""]})},s)})]},s))})]})})]})]})})}let eD=e=>{try{return JSON.parse(e)}catch(e){return}},eM="default",eU=e=>"GET"===e?"get":"POST"===e?"post":"DELETE"===e?"del":"PUT"===e||"PATCH"===e?"put":"other",eB=e=>e>=200&&e<300?"ok":e>=300&&e<400?"warn":"err",e$=e=>e?e.run?(e=>!!(null==e?void 0:e.run)&&(e.run.tests.some(e=>!e.passed)||!!e.run.scriptError))(e)?"err":eB(e.run.status):"err":"";function eW(e){if(/json/i.test(e.contentType)||/^\s*[[{]/.test(e.body))try{return JSON.stringify(JSON.parse(e.body),null,2)}catch(e){}return e.body}var eJ=t(72705);function eP(e){let{value:s,refBase:t}=e;return(0,n.jsx)("div",{className:"jt mono",children:(0,n.jsx)(e_,{k:null,v:s,path:"$",refBase:t,depth:0})})}function e_(e){let{k:s,v:t,path:a,refBase:r,depth:c}=e,{t:i}=(0,x.s9)(),o=null!==t&&"object"==typeof t,[d,h]=(0,l.useState)(c<2),[m,u]=(0,l.useState)(!1),j=null===s?null:(0,n.jsxs)("span",{className:"jt-k",children:["number"==typeof s?s:JSON.stringify(s),(0,n.jsx)("i",{children:": "})]}),p=(0,n.jsx)("button",{type:"button",className:"jt-copy",onClick:()=>{var e;let s=r?"{{".concat(r,".").concat(a,"}}"):"string"==typeof t?t:JSON.stringify(t);null==(e=navigator.clipboard)||e.writeText(s),u(!0),setTimeout(()=>u(!1),1200)},title:i(r?"hw2.copyRef":"iv.copy"),"aria-label":i(r?"hw2.copyRef":"iv.copy"),children:m?i("hw2.copied"):(0,n.jsx)(eh.A,{size:11})});if(!o){let e="string"==typeof t?"jt-s":"number"==typeof t?"jt-n":"jt-b";return(0,n.jsxs)("div",{className:"jt-row",children:[j,(0,n.jsx)("span",{className:e,children:"string"==typeof t?JSON.stringify(t.length>160?"".concat(t.slice(0,160),"…"):t):String(t)}),p]})}let b=Array.isArray(t)?t.map((e,s)=>[s,e]):Object.entries(t),v=Array.isArray(t);return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"jt-row",children:[(0,n.jsx)("button",{type:"button",className:"jt-fold",onClick:()=>h(e=>!e),"aria-expanded":d,children:d?(0,n.jsx)(R.A,{size:12}):(0,n.jsx)(I.A,{size:12})}),j,(0,n.jsx)("span",{className:"jt-p",children:v?"[":"{"}),!d&&(0,n.jsxs)("span",{className:"muted",children:[" ",b.length," ","…"," "]}),!d&&(0,n.jsx)("span",{className:"jt-p",children:v?"]":"}"}),p]}),d&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"jt-kids",children:b.map(e=>{let[s,t]=e;return(0,n.jsx)(e_,{k:s,v:t,path:v?"".concat(a,"[").concat(s,"]"):/^[A-Za-z_]\w*$/.test(String(s))?"".concat(a,".").concat(s):"".concat(a,'["').concat(s,'"]'),refBase:r,depth:c+1},String(s))})}),(0,n.jsx)("div",{className:"jt-row",children:(0,n.jsx)("span",{className:"jt-p",children:v?"]":"}"})})]})]})}let eK=e=>{var s,t;let n=null!=(t=null==(s=e.run)?void 0:s.body)?t:"";try{return JSON.stringify(JSON.parse(n),null,2)}catch(e){return n}};function eG(e){var s,t,a,r;let{before:c,after:i}=e,{t:o}=(0,x.s9)(),d=(0,l.useMemo)(()=>(function(e,s){if(e.length*s.length>4e6)return[...e.map(e=>({t:"-",s:e})),...s.map(e=>({t:"+",s:e}))];let t=e.length,n=s.length,l=Array.from({length:t+1},()=>new Uint32Array(n+1));for(let a=t-1;a>=0;a--)for(let t=n-1;t>=0;t--)l[a][t]=e[a]===s[t]?l[a+1][t+1]+1:Math.max(l[a+1][t],l[a][t+1]);let a=[],r=0,c=0;for(;r<t&&c<n;)e[r]===s[c]?(a.push({t:" ",s:e[r]}),r++,c++):l[r+1][c]>=l[r][c+1]?a.push({t:"-",s:e[r++]}):a.push({t:"+",s:s[c++]});for(;r<t;)a.push({t:"-",s:e[r++]});for(;c<n;)a.push({t:"+",s:s[c++]});return a})(eK(c).split("\n"),eK(i).split("\n")),[c,i]),h=Object.fromEntries((null!=(a=null==(s=c.run)?void 0:s.headers)?a:[]).map(e=>[e.name.toLowerCase(),e.value])),m=Object.fromEntries((null!=(r=null==(t=i.run)?void 0:t.headers)?r:[]).map(e=>[e.name.toLowerCase(),e.value])),u=/^(date|age|etag|x-request-id|x-correlation-id|set-cookie|server-timing|content-length)$/,j=[...new Set([...Object.keys(h),...Object.keys(m)])].filter(e=>h[e]!==m[e]&&!u.test(e)),p=d.filter(e=>" "!==e.t).length,b=[],v=[],g=()=>{v.length>8?b.push(...v.slice(0,3),{fold:v.length-6},...v.slice(-3)):b.push(...v),v=[]};for(let e of d)" "===e.t?v.push(e):(g(),b.push(e));g();let f=e=>e.run?"".concat(e.run.status," \xb7 ").concat(e.run.durationMs," ms \xb7 ").concat((0,L.zi)(e.run.size)):o("hw2.diff.error");return(0,n.jsxs)("div",{className:"rd",children:[(0,n.jsxs)("div",{className:"rd-head",children:[(0,n.jsxs)("div",{children:[(0,n.jsxs)("span",{className:"muted small",children:[o("hw2.diff.before")," \xb7 ",(0,L.Xd)(c.at)]}),(0,n.jsx)("div",{className:"mono",children:f(c)})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("span",{className:"muted small",children:[o("hw2.diff.after")," \xb7 ",(0,L.Xd)(i.at)]}),(0,n.jsx)("div",{className:"mono",children:f(i)})]})]}),j.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"eyebrow",children:o("http.headers")}),(0,n.jsx)("div",{className:"rd-hdrs mono small",children:j.map(e=>(0,n.jsxs)("div",{children:[(0,n.jsx)("b",{children:e}),": ",void 0!==h[e]&&(0,n.jsx)("span",{className:"rd-del",children:h[e]})," ",void 0!==m[e]&&(0,n.jsx)("span",{className:"rd-add",children:m[e]})]},e))})]}),(0,n.jsxs)("div",{className:"eyebrow",style:{marginTop:10},children:[o("hw2.diff.body")," \xb7 ",0===p?o("hw2.diff.same"):o("hw2.diff.lines",{count:p})]}),(0,n.jsx)("div",{className:"rd-body mono",children:b.map((e,s)=>"fold"in e?(0,n.jsx)("div",{className:"rd-fold",children:o("hw2.diff.fold",{count:e.fold})},s):(0,n.jsxs)("div",{className:"rd-l ".concat("+"===e.t?"add":"-"===e.t?"del":""),children:[(0,n.jsx)("span",{children:e.t}),e.s||"\xa0"]},s))})]})}function eX(e){let{ws:s}=e,{t}=(0,x.s9)(),{kept:l,adding:a,setAdding:r,newName:c,setNewName:i,newValue:o,setNewValue:d,setValue:h,forget:m,setConfirm:u}=s;return(0,n.jsxs)("div",{className:"hw-session-body hw-session-pad",children:[(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)("b",{children:t("hw.session")}),(0,n.jsx)(eI.B,{size:"sm",label:t("common.help"),title:t("hw2.help.how"),children:t("hw.session.hint")})]}),0===l.length&&!a&&(0,n.jsx)("p",{className:"muted small res-m0",children:t("hw.session.empty")}),l.map(e=>{let[s,l]=e;return(0,n.jsxs)("div",{className:"hw-kv",children:[(0,n.jsx)("code",{className:"mono",title:s,children:s}),(0,n.jsx)("span",{className:"mono val",title:l,children:l}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>void m(s),"aria-label":t("hw.session.forget"),title:t("hw.session.forget"),children:(0,n.jsx)(M.A,{size:13})})]},s)}),a?(0,n.jsxs)("div",{className:"hw-kv-add",children:[(0,n.jsx)("input",{className:"input mono",placeholder:t("hw.session.name"),value:c,onChange:e=>i(e.target.value),"aria-label":t("hw.session.name")}),(0,n.jsx)("input",{className:"input mono",placeholder:t("hw.session.value"),value:o,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"===e.key&&h()},"aria-label":t("hw.session.value")}),(0,n.jsx)("button",{className:"btn primary icon sm",onClick:h,"aria-label":t("hw.session.add"),children:(0,n.jsx)(eJ.A,{size:14})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>r(!1),"aria-label":t("common.cancel"),children:(0,n.jsx)(M.A,{size:14})})]}):(0,n.jsxs)("div",{className:"row gap-s mt-s",children:[(0,n.jsxs)("button",{className:"btn sm",onClick:()=>r(!0),children:[(0,n.jsx)(k.A,{size:13}),t("hw.session.add")]}),l.length>0&&(0,n.jsxs)("button",{className:"btn ghost sm",onClick:()=>u("session"),children:[(0,n.jsx)(es.A,{size:13}),t("hw.session.clear")]})]})]})}function eV(e){let{ws:s}=e,{t}=(0,x.s9)(),{o:l,confirm:a,setConfirm:r,setHist:c,setHistSel:i,setSession:o}=s;return a&&(0,n.jsx)(p.TM,{title:t("history"===a?"hw2.history.clear":"hw.session.clear"),confirmLabel:t("history"===a?"hw2.history.clear":"hw.session.clear"),danger:!0,body:t("history"===a?"rs.confirm.history":"rs.confirm.session"),onClose:()=>r(null),onConfirm:()=>"history"===a?u.FH.del("/objects/".concat(l.id,"/http/history")).then(()=>{c([]),i(null)}):u.FH.del("/objects/".concat(l.id,"/http/session")).then(o)})}function eZ(e){var s,t,l,a;let{ws:r,scan:c,onGoRequests:i}=e,{t:o}=(0,x.s9)(),{hist:d,histSel:h,setHistSel:m,cmp:u,setCmp:j,setConfirm:p,setFile:b,setSel:v,setTab:g}=r,f=null!=(l=d.find(e=>e.n===h))?l:null,w=(null==f?void 0:f.run)?eD(f.run.body):void 0,N=e=>{var s;return null==(s=c.files.find(s=>s.relFile===e.file))?void 0:s.requests[e.index]},y=f?d.find(e=>e.n<f.n&&e.file===f.file&&e.index===f.index&&e.run):void 0,k="prev"===u?y:"number"==typeof u?d.find(e=>e.n===u):void 0;return(0,n.jsxs)(ef,{list:(0,n.jsxs)("aside",{className:"hw-list",children:[(0,n.jsxs)("div",{className:"hw-env",children:[(0,n.jsx)("b",{className:"grow",children:o("hw2.history")}),d.length>0&&(0,n.jsxs)("button",{className:"btn ghost sm",onClick:()=>p("history"),children:[(0,n.jsx)(es.A,{size:13}),o("hw2.history.clear")]})]}),(0,n.jsxs)("div",{className:"hr-reqs",children:[0===d.length&&(0,n.jsx)("p",{className:"gx-note",children:o("hw2.history.empty")}),d.map(e=>(0,n.jsxs)("button",{className:"hr-req ".concat(h===e.n?"sel":""),onClick:()=>{m(e.n),j(null)},children:[(0,n.jsx)("span",{className:"hr-m ".concat(eU(e.method||"GET")),children:e.method||"?"}),(0,n.jsx)("span",{className:"nm",children:e.name}),(0,n.jsx)("span",{className:"muted small",children:(0,L.v7)(e.at)}),(0,n.jsx)("i",{className:"hr-dot ".concat(e.run?e.run.tests.some(e=>!e.passed)||e.run.scriptError?"err":eB(e.run.status):"err"),title:e.run?String(e.run.status):e.error})]},e.n))]})]}),children:[(0,n.jsxs)("section",{className:"hr-detail hw-scroll",children:[f&&(0,n.jsxs)("div",{className:"hr-pre",children:[(0,n.jsxs)("div",{className:"row gap-s wrap res-mb",children:[(0,n.jsx)("span",{className:"hr-m ".concat(eU(f.method||"GET")),children:f.method}),(0,n.jsx)("code",{className:"mono grow hw-wrap",children:null!=(a=null==(s=f.run)?void 0:s.request.url)?a:f.name}),f.run&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("b",{className:"hr-st ".concat(eB(f.run.status)),children:[f.run.status," ",f.run.statusText]}),(0,n.jsxs)("span",{className:"muted small",children:[o("http.time",{ms:f.run.durationMs})," \xb7 ",(0,L.zi)(f.run.size)]})]}),N(f)&&(0,n.jsx)("button",{className:"btn sm",onClick:()=>{b(f.file),v(N(f)),g("body"),null==i||i()},children:o("hw2.history.open")})]}),(0,n.jsxs)("div",{className:"row gap-s wrap small res-mb",children:[(0,n.jsxs)("span",{className:"muted",children:[f.file,f.env?" \xb7 ".concat(f.env):""]}),(0,n.jsx)("span",{className:"grow"}),(0,n.jsxs)("select",{className:"select hw-cmp",value:String(null!=u?u:""),onChange:e=>j(""===e.target.value?null:"prev"===e.target.value?"prev":Number(e.target.value)),"aria-label":o("hw2.diff.with"),children:[(0,n.jsx)("option",{value:"",children:o("hw2.diff.with")}),(0,n.jsx)("option",{value:"prev",disabled:!y,children:o("hw2.diff.prev")}),d.filter(e=>e.n!==f.n&&e.run).map(e=>(0,n.jsxs)("option",{value:e.n,children:[e.name," \xb7 ",(0,L.Xd)(e.at)," \xb7 ",e.run.status]},e.n))]})]}),"prev"===u&&!y&&(0,n.jsx)("p",{className:"muted small",children:o("hw2.diff.noPrev")}),k&&f.run&&k.run?k.at<=f.at?(0,n.jsx)(eG,{before:k,after:f}):(0,n.jsx)(eG,{before:f,after:k}):(0,n.jsxs)(n.Fragment,{children:[f.error&&(0,n.jsx)("div",{className:"gx-banner err hw-pre",children:f.error}),f.run&&f.run.tests.map((e,s)=>(0,n.jsxs)("div",{className:"hw-test ".concat(e.passed?"ok":"err"),children:[e.passed?(0,n.jsx)(eJ.A,{size:14}):(0,n.jsx)(M.A,{size:14}),(0,n.jsx)("b",{children:e.name}),e.message&&(0,n.jsxs)("span",{className:"muted",children:[": ",e.message]})]},s)),f.run&&!f.run.binary&&f.run.body&&(void 0!==w?(0,n.jsx)(eP,{value:w,refBase:(null==(t=N(f))?void 0:t.named)?"".concat(N(f).named,".response.body"):void 0}):(0,n.jsx)("pre",{children:eW(f.run)}))]})]}),(0,n.jsx)(eX,{ws:r})]}),(0,n.jsx)(eV,{ws:r})]})}var eQ=t(89075),eY=t(25661),e0=t(55267),e1=t(75063);function e2(e){let{ws:s,scan:t,onOpenVars:l}=e,{t:a}=(0,x.s9)(),{env:r,setEnv:c,q:i,setQ:o,file:d,setFile:h,sel:m,setSel:u,open:j,setOpen:b,results:v,busy:g,setTab:f,setCreating:w,load:N,loadSession:y,files:C,summary:S,runFile:A}=s;return(0,n.jsxs)("aside",{className:"hw-list",children:[(0,n.jsxs)("div",{className:"hw-env",children:[(0,n.jsxs)("label",{className:"row gap-s small grow",children:[(0,n.jsx)("span",{className:"muted",children:a("http.env")}),(0,n.jsxs)("select",{className:"select hw-envsel",value:r,onChange:e=>c(e.target.value),children:[(0,n.jsx)("option",{value:"",children:a("http.noEnv")}),t.environments.map(e=>(0,n.jsx)("option",{value:e,children:e},e))]})]}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>w(!0),"aria-label":a("hw2.new.title"),title:a("hw2.new.title"),children:(0,n.jsx)(k.A,{size:15})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>{N(),y()},"aria-label":a("http.rescan"),title:a("http.rescan"),children:(0,n.jsx)(eQ.A,{size:15})})]}),0===t.envFiles.length&&0===t.environments.length&&(0,n.jsxs)("p",{className:"muted small hw-hint",children:[a("hw.noEnvFile")," ",(0,n.jsx)("button",{className:"btn sm",onClick:l,children:a("hw.editVars")})]}),(0,n.jsx)("div",{className:"gx-filter",children:(0,n.jsx)(p.DO,{value:i,onChange:o,placeholder:a("http.search"),label:a("http.search")})}),(0,n.jsxs)("div",{className:"hr-reqs",children:[0===C.length&&(0,n.jsx)("p",{className:"gx-note",children:t.files.length?a("ow.noMatch",{query:i}):a("http.empty")}),C.map(e=>{var s;let t=j.has(e.relFile)||!!i;return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"hw-file ".concat(d!==e.relFile||m?"":"sel"),children:[(0,n.jsxs)("button",{className:"hw-fbtn",onClick:()=>{h(e.relFile),u(null),b(s=>{let t=new Set(s);return t.has(e.relFile)?t.delete(e.relFile):t.add(e.relFile),t})},children:[t?(0,n.jsx)(R.A,{size:14}):(0,n.jsx)(I.A,{size:14}),(0,n.jsx)(eY.A,{size:14,className:"muted"}),(0,n.jsx)("span",{className:"mono nm",title:e.relFile,children:e.relFile}),(0,n.jsx)("span",{className:"muted small",children:null!=(s=S(e))?s:e.requests.length})]}),(0,n.jsx)("button",{className:"btn ghost icon sm",disabled:!!g,onClick:()=>void A(e),"aria-label":a("http.runFile"),title:a("http.runFile"),children:(0,n.jsx)(e0.A,{size:15})})]}),t&&e.requests.map(s=>{let t=v[s.id],l=e$(t);return(0,n.jsxs)("button",{className:"hr-req hr-req-sub ".concat((null==m?void 0:m.id)===s.id?"sel":""),onClick:()=>{h(e.relFile),u(s),f("body")},children:[(0,n.jsx)("span",{className:"hr-m ".concat(eU(s.method)),children:s.method}),(0,n.jsx)("span",{className:"nm",children:s.name}),s.script&&(0,n.jsx)(e1.A,{size:12,className:"muted","aria-label":a("hw.script")}),g===s.id?(0,n.jsx)("span",{className:"muted small",children:"…"}):l?(0,n.jsx)("i",{className:"hr-dot ".concat(l),title:(null==t?void 0:t.run)?"".concat(t.run.status).concat(t.run.tests.length?" \xb7 ".concat(a("hw.tests.count",{ok:t.run.tests.filter(e=>e.passed).length,total:t.run.tests.length})):""):null==t?void 0:t.error}):null]},s.id)})]},e.relFile)}),t.truncated&&(0,n.jsx)("p",{className:"gx-note",children:a("http.truncatedFiles")})]})]})}var e4=t(48180);let e3=[{key:"tools",formats:[["curl","cURL"],["wget","wget"],["httpie","HTTPie"],["powershell","PowerShell"]]},{key:"langs",formats:[["fetch","JavaScript (fetch)"],["axios","Node (axios)"],["python","Python (requests)"],["go","Go"],["php","PHP (cURL)"],["java","Java (HttpClient)"],["csharp","C# (HttpClient)"],["ruby","Ruby (net/http)"],["rust","Rust (reqwest)"]]},{key:"raw",formats:[["http","HTTP"]]}];function e9(e){let{objectId:s,file:t,index:a,env:r}=e,{t:c}=(0,x.s9)(),[i,o]=(0,l.useState)(!1),[d,h]=(0,l.useState)(null),[m,j]=(0,l.useState)(""),p=async e=>{j("");try{let n=await u.FH.get("/objects/".concat(s,"/http/export?file=").concat(encodeURIComponent(t),"&index=").concat(a,"&format=").concat(e).concat(r?"&env=".concat(encodeURIComponent(r)):"").concat(i?"&redact=1":""));await navigator.clipboard.writeText(n.text),h(e),setTimeout(()=>h(null),1500),n.unresolved.length&&j(c("hw2.copyAs.unresolved",{names:n.unresolved.map(e=>"{{".concat(e,"}}")).join(", ")}))}catch(e){j(e instanceof Error?e.message:"error")}};return(0,n.jsx)(U.W1,{label:c("hw2.copyAs"),icon:(0,n.jsx)(eh.A,{size:14}),children:()=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(U.iz,{checked:i,onChange:o,hint:c("hw2.copyAs.redact.hint"),children:c("hw2.copyAs.redact")}),(0,n.jsx)(U.MU,{}),e3.map(e=>(0,n.jsx)(U.rX,{label:c("hw2.copyAs.g.".concat(e.key)),children:e.formats.map(e=>{let[s,t]=e;return(0,n.jsx)(U.Dr,{icon:d===s?(0,n.jsx)(eJ.A,{size:15}):void 0,onClick:()=>void p(s),children:t},s)})},e.key)),m&&(0,n.jsx)("p",{className:"muted small menu-note",children:m})]})})}function e5(e){let{text:s}=e;return(0,n.jsx)(n.Fragment,{children:s.split(/(\{\{[^}]+\}\})/g).map((e,s)=>e.startsWith("{{")?(0,n.jsx)("span",{className:"hr-var",children:e},s):e)})}var e6=t(10969);let e7=e=>Array.isArray(e)?e:e&&"object"==typeof e?Object.values(e):[],e8=(e,s,t)=>"=="===s?e===t||String(e)===String(t):"!="===s?e!==t&&String(e)!==String(t):">"===s?Number(e)>Number(t):"<"===s?Number(e)<Number(t):">="===s?Number(e)>=Number(t):Number(e)<=Number(t);var se=t(66654);let ss={session:"sess",file:"file",envfile:"env",hive:"hive",response:"resp",dynamic:"dyn",missing:"miss"};function st(e,s,t){let n="$shared"===t?e("iv.shared"):t;return e("iv.source.".concat(s),{from:"envfile"===s||"hive"===s?n:t})}function sn(e){let{vars:s,onSet:t,onForget:a,onRun:r,compact:c=!1}=e,{t:i}=(0,x.s9)(),[o,d]=(0,l.useState)(""),[h,m]=(0,l.useState)(!1),[u,j]=(0,l.useState)({}),[p,b]=(0,l.useState)(null),[v,g]=(0,l.useState)(""),f=(0,l.useMemo)(()=>s.filter(e=>{var s;return(!h||"missing"===e.source)&&(!o||e.name.toLowerCase().includes(o.toLowerCase())||(null!=(s=e.value)?s:"").toLowerCase().includes(o.toLowerCase()))}),[s,o,h]),w=s.filter(e=>"missing"===e.source).length,N=()=>{p&&(null==t||t(p,v)),b(null)};return(0,n.jsxs)("div",{className:"ivt",children:[!c&&(0,n.jsxs)("div",{className:"ivt-bar",children:[(0,n.jsxs)("div",{className:"search",children:[(0,n.jsx)(ea.A,{size:14}),(0,n.jsx)("input",{className:"input",placeholder:i("iv.filter"),value:o,onChange:e=>d(e.target.value),"aria-label":i("iv.filter")})]}),w>0&&(0,n.jsxs)("label",{className:"row gap-s small",children:[(0,n.jsx)("input",{type:"checkbox",checked:h,onChange:e=>m(e.target.checked)}),i("iv.onlyMissing")," \xb7 ",w]})]}),0===f.length?(0,n.jsx)("p",{className:"muted small",style:{margin:8},children:i("iv.empty")}):(0,n.jsxs)("table",{className:"ivt-table",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:i("iv.col.name")}),(0,n.jsx)("th",{children:i("iv.col.value")}),(0,n.jsx)("th",{children:i("iv.col.source")}),!c&&(0,n.jsx)("th",{children:i("iv.col.used")}),(0,n.jsx)("th",{})]})}),(0,n.jsx)("tbody",{children:f.map(e=>{var s,l;let o=e.secret&&!u[e.name];return(0,n.jsxs)("tr",{className:"ivt-row ".concat("missing"===e.source?"miss":""),children:[(0,n.jsx)("td",{children:(0,n.jsx)("code",{className:"mono ivt-name",children:e.name.replace(/^\$/,"$")})}),(0,n.jsx)("td",{className:"ivt-val",children:p===e.name?(0,n.jsxs)("span",{className:"row gap-s",children:[(0,n.jsx)("input",{className:"input mono",autoFocus:!0,value:v,placeholder:i("hw.session.value"),onChange:e=>g(e.target.value),onKeyDown:e=>{"Enter"===e.key&&N(),"Escape"===e.key&&b(null)}}),(0,n.jsx)("button",{className:"btn primary icon sm",onClick:N,"aria-label":i("iv.save"),children:(0,n.jsx)(eJ.A,{size:14})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>b(null),"aria-label":i("hw2.cancel"),children:(0,n.jsx)(M.A,{size:14})})]}):"missing"===e.source?(0,n.jsx)("span",{className:"muted",children:"—"}):"dynamic"===e.source?(0,n.jsx)("span",{className:"muted small",children:i("iv.generated")}):e.hidden?(0,n.jsxs)("span",{className:"muted small",title:i("iv.hidden"),children:["•••••• ",(0,n.jsxs)("i",{children:["(",i("iv.hidden"),")"]})]}):(0,n.jsx)("span",{className:"mono ivt-text",title:o?void 0:null!=(l=e.value)?l:"",children:o?"••••••••":e.value})}),(0,n.jsxs)("td",{children:[(0,n.jsx)("span",{className:"ivt-src ".concat(ss[e.source]),children:st(i,e.source,e.from)}),e.overridden.length>0&&(0,n.jsx)("div",{className:"ivt-over",children:e.overridden.map((s,t)=>(0,n.jsxs)("div",{className:"small",children:[(0,n.jsx)("b",{children:st(i,s.source,s.from)})," ",i("iv.alsoDefines"),null!==s.value&&(0,n.jsxs)(n.Fragment,{children:[" ",(0,n.jsx)("code",{className:"mono",children:s.value})]})," — ",i("iv.winsOver",{who:st(i,e.source,e.from)})]},t))}),"missing"===e.source&&(null==(s=e.hint)?void 0:s.startsWith("run:"))&&r&&(0,n.jsx)("button",{className:"btn sm",style:{marginTop:4},onClick:()=>r(e.hint.slice(4)),children:i("iv.run",{name:e.hint.slice(4)})})]}),!c&&(0,n.jsx)("td",{className:"muted small",children:e.usedBy||""}),(0,n.jsxs)("td",{className:"ivt-act",children:[e.secret&&null!==e.value&&!e.hidden&&(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>j(s=>({...s,[e.name]:!s[e.name]})),"aria-label":i("iv.reveal"),title:i("iv.reveal"),children:u[e.name]?(0,n.jsx)(P.A,{size:14}):(0,n.jsx)(_.A,{size:14})}),t&&"dynamic"!==e.source&&"response"!==e.source&&!e.name.includes(".")&&p!==e.name&&(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>{var s;b(e.name),g("session"!==e.source&&e.secret?"":null!=(s=e.value)?s:"")},"aria-label":i("iv.override"),title:"".concat(i("iv.override"),". ").concat(i("iv.override.hint")),children:(0,n.jsx)(se.A,{size:14})}),a&&"session"===e.source&&(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>a(e.name),"aria-label":i("iv.forget"),title:i("iv.forget"),children:(0,n.jsx)(M.A,{size:14})})]})]},e.name)})})]})]})}var sl=t(55362);let sa=["status","time","header","body","text"],sr=new Set(["exists","2xx"]);function sc(e){let{objectId:s,file:t,line:a,onSaved:r}=e,{t:c}=(0,x.s9)(),i=(0,p.dj)(),[o,d]=(0,l.useState)([]),[h,m]=(0,l.useState)("[]"),[u,j]=(0,l.useState)(!1),[b,v]=(0,l.useState)("");(0,l.useEffect)(()=>{let e=!0;return ew(s,t).then(s=>{if(!e)return;let t=function(e,s){let t=e.split("\n"),{start:n,end:l}=eL(t,s),a=t.slice(n,l).findIndex(e=>e.startsWith(ez));if(a<0)return[];try{let e=JSON.parse(t[n+a].slice(ez.length));return Array.isArray(e)?e:[]}catch(e){return[]}}(s,a);d(t),m(JSON.stringify(t))}).catch(()=>void 0),()=>{e=!1}},[s,t,a]);let g=JSON.stringify(o)!==h,f=(e,s)=>d(t=>t.map((t,n)=>n===e?{...t,...s}:t)),w=async()=>{j(!0),v("");try{let e=o.filter(e=>{var s;return"status"===e.k||"time"===e.k||"header"!==e.k&&"body"!==e.k||!!(null==(s=e.name)?void 0:s.trim())});await ey(s,t,s=>(function(e,s,t){let n=e.split("\n"),{start:l,end:a}=eL(n,s),r=n.slice(l,a).findIndex(e=>e.startsWith(ez)),c=t.length?(function(e){let s=JSON.stringify(e).replace(/%\}/g,"%\\u007d"),t=e.map(e=>{let{label:s,cond:t}=function(e){var s,t,n,l;let a=null!=(s=e.v)?s:"";if("status"===e.k)return"2xx"===e.op?{label:"status is 2xx",cond:"response.status >= 200 && response.status < 300"}:{label:"status ".concat(e.op," ").concat(a),cond:"response.status ".concat("="===e.op?"==":e.op," ").concat(eF(a))};if("time"===e.k)return{label:"time ".concat(e.op," ").concat(a," ms"),cond:"response.time ".concat(e.op," ").concat(Number(a)||0)};if("header"===e.k){let s="response.headers.valueOf(".concat(JSON.stringify((null!=(t=e.name)?t:"").toLowerCase()),")");return"exists"===e.op?{label:"header ".concat(e.name," exists"),cond:"".concat(s," !== undefined")}:"contains"===e.op?{label:"header ".concat(e.name," contains ").concat(a),cond:"".concat(s," !== undefined && ").concat(s,".includes(").concat(JSON.stringify(a),")")}:{label:"header ".concat(e.name," = ").concat(a),cond:"".concat(s," == ").concat(eF(a))}}if("text"===e.k)return{label:"answer contains ".concat(a),cond:"response.text.includes(".concat(JSON.stringify(a),")")};let r=function(e){var s,t,n;let l=e.trim().replace(/^\$\.?/,""),a="response.body";for(let e of l.matchAll(/\[(\d+)\]|\["([^"]+)"\]|\.?([^.[\]]+)/g))a+=void 0!==e[1]?"[".concat(e[1],"]"):/^[A-Za-z_]\w*$/.test(null!=(s=e[2])?s:e[3])?".".concat(null!=(t=e[2])?t:e[3]):"[".concat(JSON.stringify(null!=(n=e[2])?n:e[3]),"]");return a}(null!=(n=e.name)?n:"$"),c=null!=(l=e.name)?l:"$";return"exists"===e.op?{label:"".concat(c," exists"),cond:"".concat(r," !== undefined && ").concat(r," !== null")}:"contains"===e.op?{label:"".concat(c," contains ").concat(a),cond:"String(".concat(r,").includes(").concat(JSON.stringify(a),")")}:{label:"".concat(c," ").concat(e.op," ").concat(a),cond:"".concat(r," ").concat("="===e.op?"==":e.op," ").concat(eF(a))}}(e);return"client.test(".concat(JSON.stringify(s),", function () { client.assert(").concat(t,", ").concat(JSON.stringify("expected ".concat(s)),"); });")});return["> {%","".concat(ez).concat(s),...t,"%}"].join("\n")})(t).split("\n"):[];if(r>=0){let e=l+r,s=e;for(;s<a&&!n[s].trim().endsWith("%}");)s++;return e>l&&"> {%"===n[e-1].trim()&&e--,!c.length&&e>l&&!n[e-1].trim()&&e--,n.splice(e,s-e+1,...c),n.join("\n")}if(!c.length)return e;let i=a;for(;i>l+1&&!n[i-1].trim();)i--;return n.splice(i,0,"",...c),n.join("\n")})(s,a,e)),d(e),m(JSON.stringify(e)),i(c("hw2.saved")),r()}catch(e){v(e instanceof Error?e.message:"error")}finally{j(!1)}};return(0,n.jsxs)("div",{className:"ae",children:[(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)("b",{children:c("hw2.assert.title")}),(0,n.jsx)(eI.B,{size:"sm",label:c("common.help"),title:c("hw2.help.how"),children:c("hw2.assert.hint")}),(0,n.jsx)("span",{className:"grow"}),(0,n.jsxs)("button",{className:"btn sm",onClick:()=>d(e=>[...e,{k:"status",op:"2xx"}]),children:[(0,n.jsx)(k.A,{size:13}),c("hw2.assert.add")]}),(0,n.jsxs)("button",{className:"btn primary sm",disabled:!g||u,onClick:()=>void w(),children:[(0,n.jsx)(sl.A,{size:13}),c("hw2.assert.save")]})]}),(0,n.jsx)("div",{style:{height:8}}),o.map((e,s)=>{var t,l;return(0,n.jsxs)("div",{className:"ae-row",children:[(0,n.jsx)("select",{className:"select",value:e.k,onChange:e=>{let t=e.target.value;f(s,{k:t,op:eE[t][0],name:void 0,v:""})},"aria-label":c("hw2.assert.kind"),children:sa.map(e=>(0,n.jsx)("option",{value:e,children:c("hw2.assert.k.".concat(e))},e))}),("header"===e.k||"body"===e.k)&&(0,n.jsx)("input",{className:"input mono",value:null!=(t=e.name)?t:"",placeholder:"header"===e.k?"Content-Type":"$.data.id",onChange:e=>f(s,{name:e.target.value}),"aria-label":c("obj.f.name")}),(0,n.jsx)("select",{className:"select",value:e.op,onChange:e=>f(s,{op:e.target.value}),"aria-label":c("hw2.assert.op"),children:eE[e.k].map(e=>(0,n.jsx)("option",{value:e,children:"exists"===e?c("hw2.assert.exists"):"2xx"===e?c("hw2.assert.ok"):"contains"===e?c("hw2.assert.contains"):e},e))}),!sr.has(e.op)&&(0,n.jsx)("input",{className:"input mono",value:null!=(l=e.v)?l:"",placeholder:"time"===e.k?"ms":c("hw.session.value"),onChange:e=>f(s,{v:e.target.value}),"aria-label":c("hw.session.value")}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>d(e=>e.filter((e,t)=>t!==s)),"aria-label":c("hw2.assert.remove"),children:(0,n.jsx)(M.A,{size:14})})]},s)}),b&&(0,n.jsx)("p",{className:"gx-note err",children:b})]})}let si=["X-Api-Key","Api-Key","X-Auth-Token"];function so(e){let{objectId:s,file:t,lines:a,onSaved:r}=e,{t:c}=(0,x.s9)(),i=(0,p.dj)(),o=a[0],[d,h]=(0,l.useState)("none"),[m,u]=(0,l.useState)(""),[j,b]=(0,l.useState)(""),[v,g]=(0,l.useState)(""),[f,w]=(0,l.useState)("X-Api-Key"),[N,y]=(0,l.useState)(""),[k,C]=(0,l.useState)(!1),[S,A]=(0,l.useState)(!1),[E,z]=(0,l.useState)("");(0,l.useEffect)(()=>{ew(s,t).then(e=>{var s,t,n;let l=eA(e,o,"Authorization"),a=si.find(s=>void 0!==eA(e,o,s));if(l&&/^Bearer\s/i.test(l))h("bearer"),u(l.replace(/^Bearer\s+/i,""));else if(l&&/^Basic\s/i.test(l)){let e=/^Basic\s+(\S+?)(?:\s+|:)(.+)$/i.exec(l);h("basic"),b(null!=(s=null==e?void 0:e[1])?s:""),g(null!=(t=null==e?void 0:e[2])?t:"")}else a?(h("apikey"),w(a),y(null!=(n=eA(e,o,a))?n:"")):h("none")}).catch(()=>void 0)},[s,t,o]);let F=async()=>{A(!0),z("");try{await ey(s,t,e=>{let s=e;for(let e of(k?[...a]:[o]).sort((e,s)=>s-e)){for(let t of["Authorization",...si])s=eS(s,e,t,null);"bearer"===d?s=eS(s,e,"Authorization","Bearer ".concat(m)):"basic"===d?s=eS(s,e,"Authorization","Basic ".concat(j," ").concat(v)):"apikey"===d&&(s=eS(s,e,f.trim()||"X-Api-Key",N))}return s}),i(c("hw2.saved")),r()}catch(e){z(e instanceof Error?e.message:"error")}finally{A(!1)}};return(0,n.jsxs)("div",{className:"hr-form",style:{maxWidth:600},children:[(0,n.jsxs)("div",{className:"row gap-s",style:{marginBottom:12},children:[(0,n.jsx)("b",{className:"grow",children:c("hw2.tab.auth")}),(0,n.jsx)(eI.B,{size:"sm",align:"end",label:c("common.help"),title:c("hw2.help.how"),children:c("hw2.auth.hint")})]}),(0,n.jsxs)("div",{className:"stack",children:[(0,n.jsxs)("select",{className:"select",value:d,onChange:e=>h(e.target.value),"aria-label":c("hw2.auth.type"),children:[(0,n.jsx)("option",{value:"none",children:c("hw2.auth.none")}),(0,n.jsx)("option",{value:"bearer",children:"Bearer token"}),(0,n.jsx)("option",{value:"basic",children:"Basic"}),(0,n.jsx)("option",{value:"apikey",children:"API key"})]}),"bearer"===d&&(0,n.jsx)("input",{className:"input mono",value:m,placeholder:"{{token}}",onChange:e=>u(e.target.value),"aria-label":"Token"}),"basic"===d&&(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)("input",{className:"input mono",style:{flex:1},value:j,placeholder:"{{user}}",onChange:e=>b(e.target.value),"aria-label":c("hw2.auth.user")}),(0,n.jsx)("input",{className:"input mono",style:{flex:1},value:v,placeholder:"{{passwd}}",onChange:e=>g(e.target.value),"aria-label":c("hw2.auth.pass")})]}),"apikey"===d&&(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)("input",{className:"input mono",style:{flex:1},value:f,onChange:e=>w(e.target.value),"aria-label":c("hw2.auth.header")}),(0,n.jsx)("input",{className:"input mono",style:{flex:2},value:N,placeholder:"{{apiKey}}",onChange:e=>y(e.target.value),"aria-label":c("hw.session.value")})]}),a.length>1&&(0,n.jsx)(p.Tl,{checked:k,onChange:C,label:c("hw2.auth.all",{count:a.length})}),(0,n.jsx)("div",{className:"row gap-s",children:(0,n.jsx)("button",{className:"btn primary",disabled:S,onClick:()=>void F(),children:c("hw2.auth.apply")})}),E&&(0,n.jsx)("p",{className:"gx-note err",style:{margin:0},children:E})]})]})}function sd(e){var s,t,l,a,r,c,i;let{ws:o,scan:d,sel:h}=e,{t:m}=(0,x.s9)(),{o:u,tab:j,insp:b,res:v,fileOf:g,load:f,forget:w,setVar:N,runNamed:y,testsOf:k,bodyView:C,setBodyView:S,bodyFilter:A,setBodyFilter:E}=o;return"auth"===j?(0,n.jsx)(so,{objectId:u.id,file:null!=(l=g.current.get(h.id))?l:"",lines:(null!=(a=null==(s=d.files.find(e=>e.relFile===g.current.get(h.id)))?void 0:s.requests)?a:[h]).map(e=>e.line).reduce((e,s)=>s===h.line?[s,...e]:[...e,s],[]),onSaved:f}):"vars"===j?(0,n.jsx)("div",{className:"hr-pre",children:b?(0,n.jsx)(sn,{vars:b.vars,onSet:N,onForget:e=>void w(e),onRun:y}):(0,n.jsx)("p",{className:"muted",children:m("git.loading")})}):"request"===j?(0,n.jsxs)("div",{className:"hr-pre",children:[!(null==v?void 0:v.run)&&(null==b?void 0:b.preview)?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"row gap-s small res-mb",children:[(0,n.jsx)("b",{children:m("hw2.resolved")}),b.preview.unresolved.length>0&&(0,n.jsx)("span",{className:"chip warn",children:m("hw2.unresolved",{count:b.preview.unresolved.length})})]}),(0,n.jsxs)("div",{className:"mono",children:[(0,n.jsx)("b",{children:b.preview.method})," ",(0,n.jsx)(e5,{text:b.preview.url})]}),b.preview.headers.map((e,s)=>(0,n.jsxs)("div",{children:[(0,n.jsx)("b",{children:e.name}),": ",(0,n.jsx)(e5,{text:e.value})]},s)),void 0!==b.preview.body&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"eyebrow hw-eb",children:m("http.requestBody")}),(0,n.jsx)("pre",{children:(0,n.jsx)(e5,{text:b.preview.body})})]})]}):null,(null==v?void 0:v.run)&&(0,n.jsx)("div",{className:"muted small res-mb",children:m("hw2.resolved")}),(null==v?void 0:v.run)&&(0,n.jsxs)("div",{className:"mono",children:[(0,n.jsx)("b",{children:v.run.request.method})," ",v.run.request.url]}),(null==v?void 0:v.run)&&v.run.request.headers.map((e,s)=>(0,n.jsxs)("div",{children:[(0,n.jsx)("b",{children:e.name}),": ",e.value]},s)),(null==v?void 0:v.run)?null:!(null==b?void 0:b.preview)&&h.headers.map((e,s)=>(0,n.jsxs)("div",{children:[(0,n.jsx)("b",{children:e.name}),": ",(null==v?void 0:v.run)?e.value:(0,n.jsx)(e5,{text:e.value})]},s)),(null==v?void 0:v.run)&&void 0!==v.run.request.body&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"eyebrow hw-eb",children:m("http.requestBody")}),(0,n.jsx)("pre",{children:(0,n.jsx)(e5,{text:null!=(c=null!=(r=null==v||null==(t=v.run)?void 0:t.request.body)?r:h.body)?c:""})})]}),h.script&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"eyebrow hw-eb",children:m("hw.script")}),(0,n.jsx)("p",{className:"muted small hw-hint2",children:m("hw.script.hint")}),(0,n.jsx)("pre",{children:h.script.trim()})]})]}):"tests"===j?(0,n.jsxs)("div",{className:"hr-form",children:[(0,n.jsx)(sc,{objectId:u.id,file:null!=(i=g.current.get(h.id))?i:"",line:h.line,onSaved:f}),(0,n.jsx)("div",{className:"eyebrow hw-eb2",children:m("hw.tests")}),(0,n.jsx)("div",{className:"hr-pre res-p0",children:(null==v?void 0:v.run)?0===k(v).length&&0===v.run.logs.length?(0,n.jsx)("p",{className:"muted",children:m("hw.tests.none")}):(0,n.jsxs)(n.Fragment,{children:[k(v).map((e,s)=>(0,n.jsxs)("div",{className:"hw-test ".concat(e.passed?"ok":"err"),children:[e.passed?(0,n.jsx)(eJ.A,{size:14}):(0,n.jsx)(M.A,{size:14}),(0,n.jsx)("b",{children:e.name}),e.message&&(0,n.jsxs)("span",{className:"muted",children:[": ",e.message]})]},s)),v.run.logs.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"eyebrow hw-eb",children:m("hw.console")}),(0,n.jsx)("pre",{children:v.run.logs.join("\n")})]})]}):(0,n.jsx)("p",{className:"muted",children:m("http.noResponse")})})]}):v?v.error?(0,n.jsx)("div",{className:"gx-banner err hw-pre hw-m16",children:v.error}):"headers"===j?(0,n.jsx)("div",{className:"hr-pre",children:v.run.headers.map((e,s)=>(0,n.jsxs)("div",{children:[(0,n.jsx)("b",{children:e.name}),": ",e.value]},s))}):(0,n.jsxs)("div",{className:"hr-pre",children:[v.run.truncated&&(0,n.jsx)("div",{className:"gx-banner",children:m("http.truncated")}),v.run.binary?(0,n.jsx)("p",{className:"muted",children:m("http.binary",{type:v.run.contentType||"?",size:(0,L.zi)(v.run.size)})}):v.run.body?(()=>{let e=eD(v.run.body),s=A.trim(),t=s.startsWith("$"),l=null,a="";if(t&&void 0!==e)try{l=function(e,s){let t=[e];for(let e of function(e){let s=e.trim();if(!s.startsWith("$"))throw Error("A path starts with $");let t=[],n=1;for(;n<s.length;){if(s.startsWith("..",n)){let e=/^\.\.([\w$-]+)/.exec(s.slice(n));if(!e)throw Error("Expected a name after ..");t.push({k:"deep",v:e[1]}),n+=e[0].length;continue}if("."===s[n]){var l;let e=/^\.(\*|[\w$-]+)/.exec(s.slice(n));if(!e)throw Error('Unexpected "'.concat(null!=(l=s[n+1])?l:"",'" after the dot'));t.push("*"===e[1]?{k:"all"}:{k:"key",v:e[1]}),n+=e[0].length;continue}if("["===s[n]){let e,l=s.indexOf("]",n);if(l<0)throw Error("A [ is not closed");let a=s.slice(n+1,l).trim();if("*"===a)t.push({k:"all"});else if(/^-?\d+$/.test(a))t.push({k:"idx",v:Number(a)});else if(e=/^(['"])(.*)\1$/.exec(a))t.push({k:"key",v:e[2]});else if(e=/^\?\(\s*@((?:\.[\w$-]+)*)\s*(==|!=|>=|<=|>|<)\s*(.+?)\s*\)$/.exec(a)){let s=e[3];try{s=JSON.parse(e[3].replace(/^'(.*)'$/,'"$1"'))}catch(e){}t.push({k:"filter",path:e[1],op:e[2],v:s})}else throw Error("Cannot read [".concat(a,"]"));n=l+1;continue}throw Error('Unexpected "'.concat(s[n],'"'))}return t}(s)){let s=[];for(let n of t)if("key"===e.k)n&&"object"==typeof n&&!Array.isArray(n)&&e.v in n&&s.push(n[e.v]);else if("idx"===e.k){if(Array.isArray(n)){let t=n[e.v<0?n.length+e.v:e.v];void 0!==t&&s.push(t)}}else if("all"===e.k)s.push(...e7(n));else if("deep"===e.k)!function e(s,t,n){for(let l of(s&&"object"==typeof s&&!Array.isArray(s)&&t in s&&n.push(s[t]),e7(s)))e(l,t,n)}(n,e.v,s);else for(let t of e7(n)){let n=t;for(let s of e.path.split(".").filter(Boolean))n=n&&"object"==typeof n?n[s]:void 0;void 0!==n&&e8(n,e.op,e.v)&&s.push(t)}t=s}return t}(e,s)}catch(e){a=e instanceof Error?e.message:"error"}let r=eW(v.run),c=s&&!t?r.split("\n").map((e,s)=>({l:e,n:s+1})).filter(e=>e.l.toLowerCase().includes(s.toLowerCase())):null;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)(p.DO,{className:"grow",value:A,onChange:E,placeholder:m("hw2.filter.placeholder"),label:m("hw2.filter")}),void 0!==e&&(0,n.jsx)(p.$q,{value:C,onChange:S,options:[{id:"tree",label:m("hw2.tree")},{id:"text",label:m("hw2.text")}]}),(0,n.jsx)(e6.WQ,{text:l?JSON.stringify(1===l.length?l[0]:l,null,2):v.run.body})]}),a&&(0,n.jsx)("p",{className:"gx-note err hw-my6",children:a}),t&&void 0===e&&(0,n.jsx)("p",{className:"muted small",children:m("hw2.noJson")}),l?0===l.length?(0,n.jsx)("p",{className:"muted small",children:m("hw2.filter.none")}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{className:"muted small hw-my6",children:m("hw2.filter.count",{count:l.length})}),"tree"===C?(0,n.jsx)(eP,{value:1===l.length?l[0]:l}):(0,n.jsx)("pre",{children:JSON.stringify(1===l.length?l[0]:l,null,2)})]}):c?0===c.length?(0,n.jsx)("p",{className:"muted small",children:m("hw2.filter.none")}):(0,n.jsx)("pre",{children:c.map(e=>"".concat(String(e.n).padStart(4)," ").concat(e.l)).join("\n")}):void 0!==e&&"tree"===C?(0,n.jsxs)(n.Fragment,{children:[!h.named&&(0,n.jsx)("p",{className:"muted small",children:m("hw2.copyRef.need")}),(0,n.jsx)(eP,{value:e,refBase:h.named?"".concat(h.named,".response.body"):void 0})]}):(0,n.jsx)("pre",{children:r})]})})():(0,n.jsx)("p",{className:"muted",children:m("http.emptyBody")})]}):(0,n.jsx)("p",{className:"gx-note",children:m("http.noResponse")})}function sh(e){var s,t,l;let{ws:a,scan:r,onOpenVars:c}=e,{t:i}=(0,x.s9)(),{o,env:d,sel:h,setSel:u,busy:j,missing:b,needsRun:v,tab:g,setTab:f,insp:w,note:N,fileOf:y,byName:k,run:C,res:S,testsOf:A}=a;return h?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"hr-reqhead",children:[(0,n.jsx)("span",{className:"hr-m ".concat(eU(h.method)),children:h.method}),(0,n.jsx)("code",{className:"hr-url grow",children:(0,n.jsx)(e5,{text:h.url})}),(0,n.jsx)(e9,{objectId:o.id,file:null!=(l=y.current.get(h.id))?l:"",index:h.index,env:d}),(0,n.jsxs)("button",{className:"btn primary sm",disabled:!!j||b.length>0,onClick:()=>void C(h),title:"Ctrl+Enter",children:[(0,n.jsx)(m.A,{size:14}),j===h.id?i("http.running"):i("http.run")]})]}),h.refs.length>0&&(0,n.jsx)("div",{className:"gx-banner",children:i("hw.uses",{names:h.refs.map(e=>"“".concat(e,"”")).join(", ")})}),b.length>0&&(0,n.jsxs)("div",{className:"gx-banner row gap-s wrap",children:[(0,n.jsx)(e4.A,{size:15}),(0,n.jsxs)("span",{className:"grow",children:[i("http.missing",{names:b.map(e=>"{{".concat(e,"}}")).join(", ")}),v.length?"":". ".concat(i("http.missing.hint"))]}),v.map(e=>k.current.get(e)&&(0,n.jsx)("button",{className:"btn sm",disabled:!!j,onClick:()=>{let s=k.current.get(e);u(s),C(s)},children:i("hw.needsRun",{name:e})},e)),!v.length&&(0,n.jsx)("button",{className:"btn sm",onClick:c,children:i("hw.editVars")})]}),N&&(0,n.jsx)("div",{className:"gx-banner",children:N}),(0,n.jsxs)("div",{className:"row gap-s hw-bar",children:[(0,n.jsx)(p.$q,{value:g,onChange:f,options:[{id:"body",label:i("http.body")},{id:"headers",label:"".concat(i("http.headers")).concat((null==S?void 0:S.run)?" \xb7 ".concat(S.run.headers.length):"")},{id:"tests",label:"".concat(i("hw.tests")).concat(A(S).length?" \xb7 ".concat(A(S).filter(e=>e.passed).length,"/").concat(A(S).length):"")},{id:"request",label:i("http.request")},{id:"vars",label:"".concat(i("hw2.tab.vars")).concat((null==w?void 0:w.vars.length)?" \xb7 ".concat(w.vars.length):"")},{id:"auth",label:i("hw2.tab.auth")}]}),(0,n.jsx)("span",{className:"grow"}),(null==S?void 0:S.run)&&(0,n.jsxs)("span",{className:"row gap-s small",children:[S.run.set.length>0&&(0,n.jsx)("span",{className:"chip",title:S.run.set.join(", "),children:i("hw.kept",{names:S.run.set.join(", ")})}),(0,n.jsxs)("b",{className:"hr-st ".concat(eB(S.run.status)),children:[S.run.status," ",S.run.statusText]}),(0,n.jsxs)("span",{className:"muted",children:[i("http.time",{ms:S.run.durationMs})," \xb7 ",(0,L.zi)(S.run.size)]})]})]}),(null==S||null==(s=S.run)?void 0:s.scriptError)&&(0,n.jsx)("div",{className:"gx-banner err",children:i("hw.script.error",{error:S.run.scriptError})}),(null==S||null==(t=S.run)?void 0:t.scriptFile)&&(0,n.jsx)("div",{className:"gx-banner",children:i("hw.script.file",{file:S.run.scriptFile})}),(0,n.jsx)("div",{className:"hr-out",children:(0,n.jsx)(sd,{ws:a,scan:r,sel:h})})]}):null}var sm=t(96213);let su=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],sx=["Accept","Accept-Language","Authorization","Cache-Control","Content-Type","Cookie","If-None-Match","Origin","Referer","User-Agent","X-Api-Key","X-Requested-With"],sj=["application/json","application/x-www-form-urlencoded","application/xml","text/plain","text/html","multipart/form-data"],sp=["$uuid","$timestamp","$isoTimestamp","$randomInt"];function sb(e,s){let t=getComputedStyle(e),n=document.createElement("div");for(let e of["fontFamily","fontSize","lineHeight","letterSpacing","tabSize","paddingTop","paddingLeft","paddingRight","paddingBottom","borderTopWidth","borderLeftWidth","borderRightWidth","boxSizing"])n.style[e]=t[e];n.style.cssText+=";position:absolute;visibility:hidden;white-space:pre;top:0;left:0;width:"+e.clientWidth+"px",n.textContent=e.value.slice(0,s);let l=document.createElement("span");l.textContent="",n.appendChild(l),document.body.appendChild(n);let a=l.offsetLeft,r=l.offsetTop;return document.body.removeChild(n),{x:a-e.scrollLeft,y:r-e.scrollTop}}function sv(e){var s,t,a,r;let{value:c,onChange:i,onSave:o,vars:d,named:h}=e,m=(0,l.useRef)(null),[u,x]=(0,l.useState)(null),[j,p]=(0,l.useState)(0),[b,v]=(0,l.useState)({x:0,y:0}),g=(0,l.useMemo)(()=>d,[d]),f=(e,s)=>{let t=function(e,s,t,n){let l=e.lastIndexOf("\n",s-1)+1,a=e.slice(l,s),r=e.slice(0,l).split("\n"),c=/\{\{([\w.$-]*)$/.exec(a);if(c){let e=c[1].toLowerCase(),l=s-c[1].length,a=[...t.filter(e=>!e.name.includes(".response.")&&!e.name.startsWith("$")).map(e=>{var s;return{label:e.name,insert:"".concat(e.name,"}}"),hint:"missing"===e.source?"—":e.secret||e.hidden?"••••":(null!=(s=e.value)?s:"").slice(0,30)}}),...n.map(e=>({label:"".concat(e,".response.body."),insert:"".concat(e,".response.body."),hint:"answer"})),...sp.map(e=>({label:e,insert:"".concat(e,"}}"),hint:"generated"}))].filter(s=>s.label.toLowerCase().includes(e)&&s.label.toLowerCase()!==e).slice(0,12);return a.length?{items:a,from:l,to:s}:null}let i=/^(content-type|accept)\s*:\s*([\w/+.-]*)$/i.exec(a);if(i){let e=i[2].toLowerCase(),t=sj.filter(s=>s.includes(e)&&s!==e).map(e=>({label:e,insert:e}));return t.length?{items:t,from:s-i[2].length,to:s}:null}let o=/^([A-Za-z-]+)$/.exec(a);if(o){var d;let e=(null!=(d=r[r.length-2])?d:"").trim(),t=!e||/^#{3,}/.test(e)||e.startsWith("#")||e.startsWith("//"),n=!!e&&!t&&!/^\{|^\[|^</.test(e)&&!e.endsWith("%}"),a=o[1].toLowerCase();if(t){let e=su.filter(e=>e.toLowerCase().startsWith(a)&&e.toLowerCase()!==a).map(e=>({label:e,insert:"".concat(e," ")}));return e.length?{items:e,from:l,to:s}:null}if(n){let e=sx.filter(e=>e.toLowerCase().startsWith(a)&&e.toLowerCase()!==a).map(e=>({label:e,insert:"".concat(e,": ")}));return e.length?{items:e,from:l,to:s}:null}}let h=/^#\s*@?(\w*)$/.exec(a);if(h&&h[0].length>1){let e=h[1].toLowerCase();if("name".startsWith(e)&&"name"!==e)return{items:[{label:"# @name",insert:"# @name ",hint:"name the request to use its answer"}],from:l,to:s}}return null}(e,s,g,h);if(x(t),p(0),t&&m.current){let e=sb(m.current,s);v({x:Math.min(e.x,Math.max(0,m.current.clientWidth-260)),y:e.y})}},w=e=>{if(!u||!m.current)return;i(c.slice(0,u.from)+e.insert+c.slice(u.to)),x(null);let s=u.from+e.insert.length;requestAnimationFrame(()=>{var e,t;null==(e=m.current)||e.focus(),null==(t=m.current)||t.setSelectionRange(s,s)})};return(0,n.jsxs)("div",{className:"se",children:[(0,n.jsx)(sm.B,{value:c,path:"requests.http",areaRef:m,onChange:e=>{i(e);let s=m.current;s&&requestAnimationFrame(()=>f(e,s.selectionStart))},onClick:()=>x(null),onBlur:()=>setTimeout(()=>x(null),120),onKeyDown:e=>{if((e.ctrlKey||e.metaKey)&&"s"===e.key){e.preventDefault(),o();return}if((e.ctrlKey||e.metaKey)&&" "===e.key){e.preventDefault(),f(c,e.currentTarget.selectionStart);return}u&&("ArrowDown"===e.key?(e.preventDefault(),p(e=>(e+1)%u.items.length)):"ArrowUp"===e.key?(e.preventDefault(),p(e=>(e-1+u.items.length)%u.items.length)):"Enter"===e.key||"Tab"===e.key?(e.preventDefault(),w(u.items[j])):"Escape"===e.key&&(e.preventDefault(),x(null)))}}),u&&(0,n.jsx)("ul",{className:"se-pop",role:"listbox",style:{left:b.x+16,...b.y>(null!=(a=null==(s=m.current)?void 0:s.clientHeight)?a:400)-30*u.items.length-50?{bottom:(null!=(r=null==(t=m.current)?void 0:t.clientHeight)?r:0)-b.y-8}:{top:b.y+34}},children:u.items.map((e,s)=>(0,n.jsxs)("li",{role:"option","aria-selected":s===j,className:s===j?"on":"",onMouseDown:s=>{s.preventDefault(),w(e)},children:[(0,n.jsx)("span",{className:"mono",children:e.label}),e.hint&&(0,n.jsx)("i",{children:e.hint})]},e.label))})]})}var sg=t(78060),sf=t(39696);function sw(e){let{objectId:s,file:t,vars:a,onRun:r,status:c,onSaved:i}=e,{t:o}=(0,x.s9)(),d=(0,p.dj)(),h=(0,sf.Wx)(),[u,j]=(0,l.useState)(null),[b,v]=(0,l.useState)(null),[g,f]=(0,l.useState)(""),[w,N]=(0,l.useState)(!1);(0,l.useEffect)(()=>{j(null),v(null),f(""),ew(s,t.relFile).then(j).catch(e=>f(e instanceof Error?e.message:""))},[s,t.relFile]);let y=(0,l.useMemo)(()=>new Map(a.map(e=>[e.name,e])),[a]),k=(0,l.useMemo)(()=>new Map(t.requests.map(e=>[e.line,e.index])),[t]),C=async()=>{if(null!==b){N(!0),f("");try{await eN(s,t.relFile,b),j(b),v(null),d(o("hw2.saved")),i()}catch(e){f(e instanceof Error?e.message:"")}finally{N(!1)}}},S=e=>{let s=e.split(/(\{\{[^}]+\}\})/g);return(0,n.jsx)(n.Fragment,{children:s.map((e,s)=>{if(!e.startsWith("{{"))return(0,n.jsx)(l.Fragment,{children:e},s);let t=e.slice(2,-2).trim(),a=y.get(t);return(0,n.jsx)("span",{className:"hs-var ".concat(a?ss[a.source]:"miss"),title:(e=>{var s;let t=y.get(e);if(!t)return"";let n=t.hidden?o("iv.hidden"):"missing"===t.source?"—":"dynamic"===t.source?o("iv.generated"):t.secret?"••••••••":null!=(s=t.value)?s:"";return"".concat(e," = ").concat(n,"\n").concat(st(o,t.source,t.from))})(t),children:e},s)})})};if(g&&null===u)return(0,n.jsx)("p",{className:"gx-note err",style:{padding:16},children:g});if(null===u)return(0,n.jsx)("p",{className:"gx-note",children:o("git.loading")});let A=(null!=b?b:u).split("\n");return(0,n.jsxs)("div",{className:"hs gx","data-gx-theme":h.theme,style:{"--g-tab":h.tabSize},children:[(0,n.jsxs)("div",{className:"hs-bar",children:[(0,n.jsx)("span",{className:"muted small",children:null!==b?o("hw2.dirty"):""}),(0,n.jsx)(eI.B,{size:"sm",label:o("common.help"),title:o("hw2.help.file"),children:o("hw2.fileHint")}),(0,n.jsx)("span",{className:"grow"}),(0,n.jsx)(sg.i,{compact:!0}),null===b?(0,n.jsxs)("button",{className:"btn sm",onClick:()=>v(u),children:[(0,n.jsx)(se.A,{size:14}),o("hw2.edit")]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("button",{className:"btn ghost sm",onClick:()=>{v(null),f("")},children:[(0,n.jsx)(M.A,{size:14}),o("hw2.cancel")]}),(0,n.jsxs)("button",{className:"btn primary sm",disabled:w||b===u,onClick:()=>void C(),children:[(0,n.jsx)(sl.A,{size:14}),o("hw2.save")]})]})]}),g&&(0,n.jsx)("div",{className:"gx-banner err",children:g}),null!==b?(0,n.jsx)(sv,{value:b,onChange:v,onSave:()=>void C(),vars:a,named:t.requests.map(e=>e.named).filter(e=>!!e)}):(0,n.jsx)("div",{className:"hs-view mono",children:A.map((e,s)=>{let t=k.get(s+1),l=void 0!==t?c[t]:void 0;return(0,n.jsxs)("div",{className:"hs-line ".concat(/^#{3,}/.test(e.trim())?"sep":""),children:[(0,n.jsx)("span",{className:"hs-gutter",children:void 0!==t?(0,n.jsx)("button",{className:"hs-run ".concat(null!=l?l:""),onClick:()=>r(t),"aria-label":o("hw2.runHere"),title:o("hw2.runHere"),children:(0,n.jsx)(m.A,{size:11})}):null}),(0,n.jsx)("span",{className:"hs-no",children:s+1}),(0,n.jsx)("span",{className:"hs-text",children:(e=>{if(/^#{3,}/.test(e.trim()))return(0,n.jsx)("span",{className:"hljs-section",children:e});if(/^\s*(#|\/\/)/.test(e))return(0,n.jsx)("span",{className:"hljs-comment",children:e});let s=/^(@[\w.-]+)(\s*=.*)$/.exec(e);if(s)return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"hljs-attr",children:s[1]}),S(s[2])]});let t=/^(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)(\s.*)$/.exec(e);if(t)return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"hljs-keyword",children:t[1]}),S(t[2])]});let l=/^([A-Za-z][\w-]*)(:.*)$/.exec(e);return l?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"hljs-attr",children:l[1]}),S(l[2])]}):S(e)})(e)||"\xa0"})]},s)})})]})}var sN=t(97318),sy=t(99381);function sk(e){let{objectId:s,file:t,onBatch:a,stopOnFail:r,onStopOnFail:c}=e,{t:i}=(0,x.s9)(),o=(0,p.dj)(),[d,h]=(0,l.useState)(!1),m=async(e,n)=>{try{let l=await u.FH.get("/objects/".concat(s,"/http/docs?format=").concat(e).concat(d?"":"&file=".concat(encodeURIComponent(t)))),a=URL.createObjectURL(new Blob([l.content],{type:l.mime})),r=document.createElement("a");r.href=a,r.download=l.filename,r.click(),setTimeout(()=>URL.revokeObjectURL(a),1e3),n(),o(i("hw2.export.done",{name:l.filename}))}catch(e){o(e instanceof Error?e.message:"error")}};return(0,n.jsx)(U.W1,{label:i("svc.more"),icon:(0,n.jsx)(H.A,{size:14}),children:e=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(U.Dr,{icon:(0,n.jsx)(sN.A,{size:15}),hint:i("hw2.batch.hint.short"),onClick:()=>{e(),a()},children:i("hw2.batch.open")}),(0,n.jsx)(U.iz,{checked:r,onChange:c,hint:i("hw2.stopOnFail.hint"),children:i("hw.stopOnFail")}),(0,n.jsx)(U.MU,{}),(0,n.jsxs)(U.rX,{label:i("hw2.export"),children:[(0,n.jsx)(U.Dr,{icon:(0,n.jsx)($.A,{size:15}),onClick:()=>void m("markdown",e),children:i("hw2.export.md")}),(0,n.jsx)(U.Dr,{icon:(0,n.jsx)(sy.A,{size:15}),onClick:()=>void m("postman",e),children:i("hw2.export.postman")}),(0,n.jsx)(U.iz,{checked:d,onChange:h,children:i("hw2.export.all")})]})]})})}function sC(e){var s;let{ws:t,picked:l}=e,{t:a}=(0,x.s9)(),{o:r,busy:c,runFile:i,setBatch:o,stopOnFail:d,setStopOnFail:h,fileInsp:m,fileTab:u,setFileTab:j,note:b,setVar:v,forget:g,runNamed:f,statusByIndex:w,load:N,refreshInsp:y,setSel:k,setTab:C,run:S,results:A,testsOf:E}=t;return(0,n.jsxs)("div",{className:"hw-file-view",children:[(0,n.jsxs)("div",{className:"hw-fhead",children:[(0,n.jsx)(eY.A,{size:20,className:"muted"}),(0,n.jsxs)("div",{className:"grow res-minw0",children:[(0,n.jsx)("h3",{className:"mono",title:l.relFile,children:l.relFile}),(0,n.jsxs)("p",{className:"muted small res-m0",children:[a("hw.fileInfo",{count:l.requests.length}),m?" \xb7 ".concat(a("hw2.vars.count",{count:m.vars.length})):""]})]}),(0,n.jsxs)("button",{className:"btn primary sm",disabled:!!c,onClick:()=>void i(l),children:[(0,n.jsx)(e0.A,{size:14}),a("http.runFile")]}),(0,n.jsx)(sk,{objectId:r.id,file:l.relFile,onBatch:()=>o(!0),stopOnFail:d,onStopOnFail:h})]}),(0,n.jsx)(p.$q,{value:u,onChange:j,options:[{id:"requests",label:"".concat(a("hw2.tab.requests")," \xb7 ").concat(l.requests.length)},{id:"vars",label:"".concat(a("hw2.tab.vars")).concat((null==m?void 0:m.vars.length)?" \xb7 ".concat(m.vars.length):"")},{id:"source",label:a("hw2.tab.source")}]}),b&&(0,n.jsx)("div",{className:"gx-banner",children:b}),"vars"===u?m?(0,n.jsx)(sn,{vars:m.vars,onSet:v,onForget:e=>void g(e),onRun:f}):(0,n.jsx)("p",{className:"muted",children:a("git.loading")}):"source"===u?(0,n.jsx)("div",{className:"hw-src",children:(0,n.jsx)(sw,{objectId:r.id,file:l,vars:null!=(s=null==m?void 0:m.vars)?s:[],status:w(l),onSaved:()=>{N(),y()},onRun:e=>{let s=l.requests.find(s=>s.index===e);s&&(k(s),C("body"),S(s))}})}):(0,n.jsxs)("table",{className:"cm-table",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{}),(0,n.jsx)("th",{children:a("obj.f.name")}),(0,n.jsx)("th",{children:a("hw.fileTests")}),(0,n.jsx)("th",{children:a("hw.lastRun")})]})}),(0,n.jsx)("tbody",{children:l.requests.map(e=>{let s=A[e.id],t=E(s);return(0,n.jsxs)("tr",{className:"hw-trow",onClick:()=>{k(e),C("body")},children:[(0,n.jsx)("td",{children:(0,n.jsx)("span",{className:"hr-m ".concat(eU(e.method)),children:e.method})}),(0,n.jsxs)("td",{children:[(0,n.jsx)("b",{children:e.name}),(0,n.jsx)("div",{className:"muted small mono hw-url",children:(0,n.jsx)(e5,{text:e.url})})]}),(0,n.jsx)("td",{children:t.length?(0,n.jsxs)("span",{className:"hr-st ".concat(t.every(e=>e.passed)?"ok":"err"),children:[t.filter(e=>e.passed).length,"/",t.length]}):(0,n.jsx)("span",{className:"muted small",children:"—"})}),(0,n.jsx)("td",{children:s?s.run?(0,n.jsxs)("span",{className:"hr-st ".concat(e$(s)),children:[(0,n.jsx)("b",{children:s.run.status})," ",(0,n.jsxs)("span",{className:"muted",children:[s.run.durationMs," ms"]})]}):(0,n.jsx)("span",{className:"hr-st err",title:s.error,children:"error"}):(0,n.jsx)("span",{className:"muted small",children:a("hw.notRun")})})]},e.id)})})]})]})}function sS(e){let{object:s,onOpenVars:t,pane:a="requests",onGoRequests:r}=e,{t:c}=(0,x.s9)(),i=function(e){var s,t;let{t:n}=(0,x.s9)(),{refresh:a}=(0,j.o0)(),[r,c]=(0,l.useState)(null),[i,o]=(0,l.useState)(""),[d,h]=(0,l.useState)(null!=(s=e.config.env)?s:""),[m,p]=(0,l.useState)(""),[b,v]=(0,l.useState)(null),[g,f]=(0,l.useState)(null),[w,N]=(0,l.useState)(new Set),[y,k]=(0,l.useState)({}),[C,S]=(0,l.useState)(null),[A,E]=(0,l.useState)([]),[z,F]=(0,l.useState)([]),[L,O]=(0,l.useState)("body"),[q,T]=(0,l.useState)("requests"),[R,I]=(0,l.useState)("tree"),[H,D]=(0,l.useState)(""),[M,U]=(0,l.useState)(null),[B,$]=(0,l.useState)(null),[W,J]=(0,l.useState)(null),[P,_]=(0,l.useState)(!1),[K,G]=(0,l.useState)(!1),[X,V]=(0,l.useState)([]),[Z,Q]=(0,l.useState)(null),[Y,ee]=(0,l.useState)(null),es=(0,l.useCallback)(()=>u.FH.get("/objects/".concat(e.id,"/http/history")).then(V).catch(()=>void 0),[e.id]);(0,l.useEffect)(()=>{es()},[es]);let[et,en]=(0,l.useState)({globals:{},responses:[]}),[el,ea]=(0,l.useState)(!1),[er,ec]=(0,l.useState)(""),[ei,eo]=(0,l.useState)(null),ed=(0,l.useRef)(new Map),eh=(0,l.useRef)(new Map),em=(0,l.useCallback)(()=>u.FH.get("/objects/".concat(e.id,"/http/session")).then(en).catch(()=>void 0),[e.id]),eu=(0,l.useCallback)(()=>{o(""),u.FH.get("/objects/".concat(e.id,"/http")).then(s=>{var t;c(s),ed.current=new Map(s.files.flatMap(e=>e.requests.map(s=>[s.id,e.relFile]))),eh.current=new Map(s.files.flatMap(e=>e.requests.filter(e=>e.named).map(e=>[e.named,e]))),v(e=>{var t,n;return e&&s.files.some(s=>s.relFile===e)?e:null!=(n=null==(t=s.files[0])?void 0:t.relFile)?n:null}),N(e=>e.size?e:new Set(s.files.slice(0,1).map(e=>e.relFile))),f(e=>{var t;return e&&ed.current.has(e.id)&&null!=(t=s.files.flatMap(e=>e.requests).find(s=>s.id===e.id))?t:null});let n=null!=(t=e.config.env)?t:"";h(e=>{var t;return e&&s.environments.includes(e)?e:n&&s.environments.includes(n)?n:null!=(t=s.environments[0])?t:""})}).catch(e=>o(e instanceof Error?e.message:n("git.loadError")))},[e.id,e.updated_at]);(0,l.useEffect)(()=>{eu(),em()},[eu,em]);let ex=(0,l.useCallback)(()=>{var s;if(!g){E([]),F([]);return}u.FH.get("/objects/".concat(e.id,"/http/describe?file=").concat(encodeURIComponent(null!=(s=ed.current.get(g.id))?s:""),"&index=").concat(g.index).concat(d?"&env=".concat(encodeURIComponent(d)):"")).then(e=>{var s;E(e.missing),F(null!=(s=e.needsRun)?s:[])}).catch(()=>{E([]),F([])})},[e.id,e.updated_at,null==g?void 0:g.id,d]);(0,l.useEffect)(()=>{ex()},[ex,et]);let ej=(0,l.useCallback)((s,t)=>u.FH.get("/objects/".concat(e.id,"/http/variables?").concat([s?"file=".concat(encodeURIComponent(s)):"",void 0!==t?"index=".concat(t):"",d?"env=".concat(encodeURIComponent(d)):""].filter(Boolean).join("&"))),[e.id,d]),ep=(0,l.useCallback)(()=>{g?ej(ed.current.get(g.id),g.index).then(U).catch(()=>U(null)):U(null),b&&ej(b).then($).catch(()=>$(null))},[ej,null==g?void 0:g.id,b]);(0,l.useEffect)(()=>{ep()},[ep,et,e.updated_at]);let eb=(0,l.useCallback)(async s=>{let t,n=ed.current.get(s.id);if(!n)return{error:"",at:Date.now()};S(s.id);try{t={run:await u.FH.post("/objects/".concat(e.id,"/http/run"),{file:n,index:s.index,env:d||void 0}),at:Date.now()}}catch(e){t={error:e instanceof Error?e.message:"error",at:Date.now()}}return k(e=>({...e,[s.id]:t})),S(null),es(),em(),t},[e.id,d,em,es]),ev=async e=>{for(let s of(ec(""),e.requests)){f(s);let e=await eb(s);if(el&&"err"===e$(e)){ec(n("hw.stopped",{name:s.name}));break}}};(0,l.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&g&&!C&&(e.preventDefault(),eb(g))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[g,C,eb]);let eg=(0,l.useMemo)(()=>{var e;return(null!=(e=null==r?void 0:r.files)?e:[]).map(e=>({...e,requests:e.requests.filter(s=>!m||"".concat(s.name," ").concat(s.url," ").concat(s.method).toLowerCase().includes(m.toLowerCase())||e.relFile.toLowerCase().includes(m.toLowerCase()))})).filter(e=>e.requests.length)},[r,m]),ef=null!=(t=null==r?void 0:r.files.find(e=>e.relFile===b))?t:null,ew=g?y[g.id]:void 0,[eN,ey]=(0,l.useState)(""),[ek,eC]=(0,l.useState)(""),[eS,eA]=(0,l.useState)(!1),eE=Object.entries(et.globals);return{o:e,scan:r,err:i,env:d,setEnv:h,q:m,setQ:p,file:b,setFile:v,sel:g,setSel:f,open:w,setOpen:N,results:y,busy:C,missing:A,needsRun:z,tab:L,setTab:O,fileTab:q,setFileTab:T,bodyView:R,setBodyView:I,bodyFilter:H,setBodyFilter:D,insp:M,fileInsp:B,creating:P,setCreating:_,batch:K,setBatch:G,hist:X,setHist:V,histSel:Z,setHistSel:Q,cmp:Y,setCmp:ee,loadHistory:es,loadSession:em,session:et,setSession:en,stopOnFail:el,setStopOnFail:ea,note:er,confirm:ei,setConfirm:eo,fileOf:ed,byName:eh,load:eu,run:eb,runFile:ev,refreshInsp:ep,files:eg,picked:ef,res:ew,summary:e=>{let s=e.requests.filter(e=>y[e.id]);return s.length?"".concat(s.filter(e=>"ok"===e$(y[e.id])).length,"/").concat(e.requests.length):null},testsOf:e=>{var s,t;return null!=(t=null==e||null==(s=e.run)?void 0:s.tests)?t:[]},forget:s=>u.FH.del("/objects/".concat(e.id,"/http/session").concat(s?"?name=".concat(encodeURIComponent(s)):"")).then(en).catch(()=>void 0),newName:eN,setNewName:ey,newValue:ek,setNewValue:eC,adding:eS,setAdding:eA,setValue:()=>{var s,t;let n=eN.trim();if(!n)return;let l=e.config,r={...null!=(s=l.variables)?s:{}};r[eM]={...null!=(t=r[eM])?t:{},[n]:{value:ek}},u.FH.patch("/objects/".concat(e.id),{config:{folder:l.folder,env:l.env,variables:r}}).then(()=>(ey(""),eC(""),eA(!1),h(eM),a(["objects"]))).catch(()=>void 0)},kept:eE,setVar:(s,t)=>u.FH.post("/objects/".concat(e.id,"/http/session"),{name:s,value:t}).then(en).catch(()=>void 0),runNamed:e=>{let s=eh.current.get(e);if(s){var t;v(null!=(t=ed.current.get(s.id))?t:b),f(s),O("body"),eb(s)}},statusByIndex:e=>Object.fromEntries(e.requests.map(e=>[e.index,e$(y[e.id])]))}}(s),{scan:o,err:d,env:h,file:m,setFile:p,sel:b,setSel:v,picked:g,batch:f,setBatch:w,creating:N,setCreating:y,setFileTab:k,setOpen:C,load:S,loadSession:A,loadHistory:E}=i;return d?(0,n.jsx)("p",{className:"gx-note err hw-pad",children:d}):o?"history"===a?(0,n.jsx)(eZ,{ws:i,scan:o,onGoRequests:r}):(0,n.jsxs)(ef,{list:(0,n.jsx)(e2,{ws:i,scan:o,onOpenVars:t}),children:[(0,n.jsx)("section",{className:"hr-detail",children:b?(0,n.jsx)(sh,{ws:i,scan:o,onOpenVars:t}):g?(0,n.jsx)(sC,{ws:i,picked:g}):(0,n.jsx)("div",{className:"gx-empty",children:(0,n.jsx)("p",{children:c("hw.pickFile")})})}),f&&g&&(0,n.jsx)(eH,{objectId:s.id,file:g,env:h,onClose:()=>w(!1),onDone:()=>{A(),E()}}),N&&(0,n.jsx)(eT,{objectId:s.id,files:o.files,defaultFile:m,onClose:()=>y(!1),onCreated:e=>{y(!1),p(e),v(null),k("source"),C(s=>new Set(s).add(e)),S()}}),(0,n.jsx)(eV,{ws:i})]}):(0,n.jsx)("p",{className:"gx-note",children:c("git.loading")})}var sA=t(13460);function sE(e){let{object:s}=e,{t}=(0,x.s9)(),{refresh:a}=(0,j.o0)(),r=(0,p.dj)(),c=s.config,i=(0,l.useMemo)(()=>{var e;return null!=(e=c.variables)?e:{}},[s.updated_at]),[o,d]=(0,l.useState)(i),[h,m]=(0,l.useState)(null),[b,v]=(0,l.useState)(!1),[g,f]=(0,l.useState)("");(0,l.useEffect)(()=>{u.FH.get("/objects/".concat(s.id,"/http")).then(m).catch(()=>void 0)},[s.id,s.updated_at]);let w=JSON.stringify(o)!==JSON.stringify(i),N=async()=>{v(!0),f("");try{await u.FH.patch("/objects/".concat(s.id),{config:{folder:c.folder,env:c.env,variables:Object.keys(o).length?o:void 0}}),await a(["objects"]),r(t("obj.saved"))}catch(e){f(e instanceof Error?e.message:t("edit.saveFailed"))}finally{v(!1)}};return(0,n.jsxs)("div",{className:"oc",children:[(0,n.jsxs)("div",{className:"oc-form",children:[(0,n.jsx)(sA.W,{value:o,onChange:d,fileEnvs:h?Object.keys(h.fileVars).filter(e=>"$shared"!==e):[],fileVars:null==h?void 0:h.fileVars,used:null==h?void 0:h.used,fileDefined:null==h?void 0:h.fileDefined,setBy:null==h?void 0:h.setBy}),g&&(0,n.jsx)("p",{className:"gx-note err",children:g})]}),(0,n.jsxs)("div",{className:"savebar oc-bar",children:[(0,n.jsx)("span",{className:"muted small grow",children:w?t("ow.cfg.dirty"):t("ow.cfg.saved")}),(0,n.jsx)("button",{className:"btn ghost",disabled:!w||b,onClick:()=>d(i),children:t("ow.cfg.discard")}),(0,n.jsx)("button",{className:"btn primary",disabled:!w||b,onClick:()=>void N(),children:t("ow.cfg.save")})]})]})}let sz=["SELECT","FROM","WHERE","AND","OR","NOT","IN","IS NULL","IS NOT NULL","LIKE","BETWEEN","EXISTS","JOIN","INNER JOIN","LEFT JOIN","RIGHT JOIN","FULL JOIN","CROSS JOIN","ON","USING","GROUP BY","ORDER BY","HAVING","LIMIT","OFFSET","DISTINCT","AS","ASC","DESC","UNION","UNION ALL","CASE","WHEN","THEN","ELSE","END","COUNT","SUM","AVG","MIN","MAX","COALESCE","CAST","INSERT INTO","VALUES","UPDATE","SET","DELETE FROM","CREATE TABLE","ALTER TABLE","DROP TABLE","NULL","TRUE","FALSE","WITH","TOP"],sF=new Set(["where","on","join","inner","left","right","full","cross","group","order","limit","set","values","using","union","having","offset","natural","outer","select","and","or"]),sL={mysql:"mysql",postgresql:"postgresql",sqlite:"sqlite",mssql:"transactsql"};async function sO(e,s){var n;let{format:l}=await t.e(701).then(t.bind(t,38701));return l(e,{language:null!=(n=sL[s])?n:"sql",keywordCase:"upper",tabWidth:2,linesBetweenQueries:1})}let sq=e=>e.replace(/^["`[]|["`\]]$/g,""),sT=/^[a-z_][a-z0-9_$]*$/,sR=(e,s)=>sT.test(s)?s:"mysql"===e?"`".concat(s,"`"):"mssql"===e?"[".concat(s,"]"):'"'.concat(s,'"'),sI=new Set(["public","dbo","main"]);function sH(e,s){let t=[],n=/\b(?:from|join|update|into)\s+((?:["`[]?[\w$]+["`\]]?\.)?["`[]?[\w$]+["`\]]?)(?:\s+(?:as\s+)?([A-Za-z_]\w*))?/gi;for(let l=n.exec(e);l;l=n.exec(e)){let e=l[1].split(".").map(sq),n=e[e.length-1].toLowerCase(),a=e.length>1?e[0].toLowerCase():"",r=s.find(e=>e.name.toLowerCase()===n&&(!a||e.schema.toLowerCase()===a));if(!r)continue;let c=l[2]&&!sF.has(l[2].toLowerCase())?l[2]:void 0;t.push({table:r,alias:c})}return t}let sD=(e,s)=>+!e.toLowerCase().startsWith(s),sM=(e,s)=>"mysql"===e?"`".concat(s.replace(/`/g,"``"),"`"):"mssql"===e?"[".concat(s.replace(/]/g,"]]"),"]"):'"'.concat(s.replace(/"/g,'""'),'"'),sU=e=>{let s=null==e?"":String(e);return/[",\n\r]/.test(s)?'"'.concat(s.replace(/"/g,'""'),'"'):s},sB=e=>[e.columns.map(e=>sU(e.name)).join(","),...e.rows.map(e=>e.map(sU).join(","))].join("\n");var s$=t(2432),sW=t(32335),sJ=t(46838),sP=t(17557);function s_(e){var s,t;let{value:a,onChange:r,areaRef:c,ctx:i,label:o,onKeyDown:d}=e,[h,m]=(0,l.useState)(null),[u,x]=(0,l.useState)(0),[j,p]=(0,l.useState)({x:0,y:0}),b=(0,l.useRef)(i);b.current=i;let v=function(e,s){let t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=function(e,s,t){var n,l,a,r,c;let i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=null!=(a=null==(n=t.schema)?void 0:n.engine)?a:"postgresql",d=null!=(r=null==(l=t.schema)?void 0:l.tables)?r:[],h=e.slice(0,s),m=/[\w$]*$/.exec(h)[0],u=s-m.length,x=h.slice(0,u),j=h.lastIndexOf("\n")+1;if(/--/.test(h.slice(j))||(h.split("'").length-1)%2==1||h.lastIndexOf("/*")>h.lastIndexOf("*/"))return null;let p=m.toLowerCase(),b=e.slice(Math.max(e.lastIndexOf(";",s-1)+1,0),(()=>{let t=e.indexOf(";",s);return t<0?e.length:t})()),v=/(["`[]?[\w$]+["`\]]?)\.$/.exec(x),g=e=>{let t=e.filter(e=>!p||e.label.toLowerCase().includes(p)&&e.label.toLowerCase()!==p).sort((e,s)=>sD(e.label,p)-sD(s.label,p)).slice(0,14);return t.length?{items:t,from:u,to:s}:null};if(v){let e=sq(v[1]).toLowerCase(),s=d.filter(s=>s.schema.toLowerCase()===e);if(s.length)return g(s.map(e=>({label:e.name,insert:sR(o,e.name),hint:"view"===e.type?"view":"table"})));let n=sH(b,d).find(s=>{var t;return(null!=(t=s.alias)?t:"").toLowerCase()===e||s.table.name.toLowerCase()===e});if(!n)return null;let l=t.cols(n.table);return l?g(l.map(e=>({label:e,insert:sR(o,e),hint:n.table.name}))):(t.need(n.table),null)}if(!m&&!i)return null;let f=/\b(from|join|update|into|table)\s+$/i.test(x),w=e=>({label:e.name,insert:"sqlite"===o||"mysql"===o||sI.has(e.schema)?sR(o,e.name):"".concat(sR(o,e.schema),".").concat(sR(o,e.name)),hint:"sqlite"===o||"mysql"===o||sI.has(e.schema)?"view"===e.type?"view":void 0:e.schema}),N=[...new Set(d.map(e=>e.schema))].filter(e=>"sqlite"!==o&&"mysql"!==o&&d.some(s=>s.schema===e)),y=[];if(!f)for(let e of sH(b,d)){let s=t.cols(e.table);if(!s){t.need(e.table);continue}for(let t of s)y.some(e=>e.label===t)||y.push({label:t,insert:sR(o,t),hint:null!=(c=e.alias)?c:e.table.name})}for(let e of d)y.push(w(e));for(let e of N)y.push({label:e,insert:sR(o,e),hint:"schema"});if(!f){let e=""!==m&&m===m.toLowerCase();for(let s of sz)y.push({label:e?s.toLowerCase():s,insert:"".concat(e?s.toLowerCase():s," "),hint:"SQL"})}return g(y)}(e,s,b.current,t);m(n),x(0);let l=c.current;if(n&&l){let e=sb(l,s);p({x:Math.min(e.x,Math.max(0,l.clientWidth-260)),y:e.y})}},g=e=>{let s=c.current;if(!h||!s)return;r(a.slice(0,h.from)+e.insert+a.slice(h.to)),m(null);let t=h.from+e.insert.length;requestAnimationFrame(()=>{s.focus(),s.setSelectionRange(t,t)})},f=null!=(t=null==(s=c.current)?void 0:s.clientHeight)?t:400;return(0,n.jsxs)("div",{className:"se",children:[(0,n.jsx)(sm.B,{value:a,path:"query.sql",areaRef:c,label:o,onChange:e=>{r(e);let s=c.current;s&&requestAnimationFrame(()=>v(e,s.selectionStart))},onClick:()=>m(null),onBlur:()=>setTimeout(()=>m(null),120),onKeyDown:e=>{if(d(e),!e.defaultPrevented){if((e.ctrlKey||e.metaKey)&&" "===e.key){e.preventDefault(),v(a,e.currentTarget.selectionStart,!0);return}h&&("ArrowDown"===e.key?(e.preventDefault(),x(e=>(e+1)%h.items.length)):"ArrowUp"===e.key?(e.preventDefault(),x(e=>(e-1+h.items.length)%h.items.length)):"Enter"===e.key||"Tab"===e.key?(e.preventDefault(),g(h.items[u])):"Escape"===e.key&&(e.preventDefault(),m(null)))}}}),h&&(0,n.jsx)("ul",{className:"se-pop",role:"listbox",style:{left:j.x+16,...j.y>f-30*h.items.length-50?{bottom:f-j.y-8}:{top:j.y+34}},children:h.items.map((e,s)=>(0,n.jsxs)("li",{role:"option","aria-selected":s===u,className:s===u?"on":"",onMouseDown:s=>{s.preventDefault(),g(e)},children:[(0,n.jsx)("span",{className:"mono",children:e.label}),e.hint&&(0,n.jsx)("i",{children:e.hint})]},"".concat(e.label,"-").concat(s)))})]})}function sK(e){var s;let{result:t}=e,{t:a}=(0,x.s9)(),r=(0,p.dj)(),[c,i]=(0,l.useState)(500);(0,l.useEffect)(()=>i(500),[t]);let o=e=>{var s;null==(s=navigator.clipboard)||s.writeText(e),r(a("db.copied"))},d=0===t.columns.length;return(0,n.jsxs)("div",{className:"dbr",children:[(0,n.jsxs)("div",{className:"dbr-bar small",children:[(0,n.jsx)("b",{children:d?a("db.result.affected",{count:null!=(s=t.affected)?s:0}):a("db.result.rows",{count:t.rows.length})}),(0,n.jsxs)("span",{className:"muted",children:["\xb7 ",t.ms," ms"]}),t.truncated&&(0,n.jsx)("span",{className:"db-trunc",children:a("db.result.truncated",{count:t.rows.length})}),(0,n.jsx)("span",{className:"grow"}),!d&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("button",{className:"btn ghost sm",onClick:()=>o(sB(t)),children:[(0,n.jsx)(eh.A,{size:13}),"CSV"]}),(0,n.jsxs)("button",{className:"btn ghost sm",onClick:()=>o(JSON.stringify(t.rows.map(e=>Object.fromEntries(t.columns.map((s,t)=>[s.name,e[t]]))),null,2)),children:[(0,n.jsx)(eh.A,{size:13}),"JSON"]}),(0,n.jsxs)("button",{className:"btn ghost sm",onClick:()=>{let e=document.createElement("a");e.href=URL.createObjectURL(new Blob([sB(t)],{type:"text/csv"})),e.download="query-".concat(new Date().toISOString().slice(0,19).replace(/[:T]/g,"-"),".csv"),e.click(),setTimeout(()=>URL.revokeObjectURL(e.href),2e3)},children:[(0,n.jsx)(em.A,{size:13}),a("db.download")]})]})]}),d?null:0===t.rows.length?(0,n.jsx)("p",{className:"muted small db-note",children:a("db.result.empty")}):(0,n.jsxs)("div",{className:"dbr-scroll",children:[(0,n.jsxs)("table",{className:"dbr-table",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{className:"n",children:"#"}),t.columns.map((e,s)=>{var l;return(0,n.jsx)("th",{className:"number"==typeof(null==(l=t.rows.find(e=>null!==e[s]))?void 0:l[s])?"num":"",children:e.name},s)})]})}),(0,n.jsx)("tbody",{children:t.rows.slice(0,c).map((e,s)=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"n",children:s+1}),e.map((e,s)=>(0,n.jsx)("td",{className:"number"==typeof e?"num":"",title:"string"==typeof e&&e.length>40?e:void 0,children:null===e?(0,n.jsx)("i",{className:"db-null",children:"NULL"}):String(e)},s))]},s))})]}),t.rows.length>c&&(0,n.jsx)("button",{className:"btn sm dbr-more",onClick:()=>i(e=>e+500),children:a("db.result.more",{count:Math.min(500,t.rows.length-c)})})]})]})}function sG(e){let{cfg:s}=e,{t}=(0,x.s9)();return!1!==s.readOnly?(0,n.jsxs)("span",{className:"db-badge ro",title:t("db.readonly.on"),children:[(0,n.jsx)(s$.A,{size:12}),t("db.readonly.badge")]}):(0,n.jsxs)("span",{className:"db-badge rw",title:t("db.readonly.off"),children:[(0,n.jsx)(sW.A,{size:12}),t("db.write.badge")]})}function sX(e){var s,t;let{o:l,sql:a,setSql:r,area:c,run:i,format:o,ctx:h,busy:u,result:j,error:p,schema:b,database:v,setDatabase:g,saved:f,onSave:w,onUse:N,onManage:y}=e,{t:k}=(0,x.s9)(),C=(0,sf.Wx)(),S=l.config,A=null!=(s=null==b?void 0:b.databases)?s:[];return(0,n.jsxs)("div",{className:"dbq",children:[(0,n.jsxs)("div",{className:"dbq-bar",children:[(0,n.jsxs)("button",{className:"btn primary sm",disabled:u||!a.trim(),onClick:i,title:"Ctrl/⌘ + Enter",children:[u?(0,n.jsx)(d.A,{size:14,className:"spin"}):(0,n.jsx)(m.A,{size:14}),u?k("db.running"):k("db.run")]}),(0,n.jsxs)("button",{className:"btn sm",disabled:!a.trim(),onClick:w,children:[(0,n.jsx)(sl.A,{size:14}),k("db.save")]}),(0,n.jsxs)("button",{className:"btn sm",disabled:!a.trim(),onClick:o,title:k("db.format.hint"),children:[(0,n.jsx)(sJ.A,{size:14}),k("db.format")]}),(0,n.jsx)(U.W1,{label:k("db.saved"),icon:(0,n.jsx)(sP.A,{size:14}),children:e=>(0,n.jsxs)(n.Fragment,{children:[0===f.length?(0,n.jsx)("p",{className:"muted small db-menu-none",children:k("db.saved.none")}):(0,n.jsx)(U.rX,{label:k("db.saved.title"),children:f.map(s=>(0,n.jsx)(U.Dr,{hint:s.sql.replace(/\s+/g," ").slice(0,70),onClick:()=>{e(),N(s.sql,s.database)},children:s.name},s.id))}),(0,n.jsx)(U.MU,{}),(0,n.jsx)(U.Dr,{icon:(0,n.jsx)(se.A,{size:14}),onClick:()=>{e(),y()},children:k("db.saved.manage")})]})}),A.length>1&&(0,n.jsx)("select",{className:"select db-pick",value:null!=(t=null!=v?v:null==b?void 0:b.database)?t:"",onChange:e=>g(e.target.value),"aria-label":k("db.database.pick"),title:k("db.database.pick"),children:A.map(e=>(0,n.jsx)("option",{value:e,children:e},e))}),(0,n.jsx)("span",{className:"grow"}),(0,n.jsx)(sG,{cfg:S}),(0,n.jsxs)(eI.B,{size:"sm",align:"end",label:k("common.help"),title:k("db.help.title"),children:[(0,n.jsx)("p",{children:k("db.help.1")}),(0,n.jsx)("p",{children:k("db.help.2")}),(0,n.jsx)("p",{children:k("db.help.3")}),(0,n.jsx)("p",{children:k("db.help.4")})]}),(0,n.jsx)(sg.i,{compact:!0})]}),(0,n.jsx)("div",{className:"db-ed gx","data-gx-theme":C.theme,style:{"--g-tab":C.tabSize},children:(0,n.jsx)(s_,{value:a,onChange:r,areaRef:c,ctx:h,label:k("db.editor"),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key?(e.preventDefault(),i()):e.altKey&&e.shiftKey&&"f"===e.key.toLowerCase()&&(e.preventDefault(),o())}})}),(0,n.jsx)("div",{className:"dbq-res",children:!u||j||p?p?(0,n.jsx)("div",{className:"gx-note err db-err",children:p}):j?(0,n.jsx)(sK,{result:j}):(0,n.jsx)("p",{className:"muted small db-note",children:k("db.result.none")}):(0,n.jsxs)("p",{className:"muted small db-note",children:[(0,n.jsx)(d.A,{size:14,className:"spin"})," ",k("db.running")]})})]})}var sV=t(12384),sZ=t(96914);function sQ(e){var s;let{o:t,schema:a,err:r,loading:c,onReload:i,database:o,setDatabase:h,onOpen:j}=e,{t:b}=(0,x.s9)(),v=(0,p.dj)(),[g,f]=(0,l.useState)(""),[w,N]=(0,l.useState)({}),[y,k]=(0,l.useState)(null),[C,S]=(0,l.useState)(null),[A,E]=(0,l.useState)(""),z=null!=(s=null==a?void 0:a.databases)?s:[],F=null!=o?o:null==a?void 0:a.database;(0,l.useEffect)(()=>{y&&(S(null),E(""),u.FH.get("/objects/".concat(t.id,"/db/columns?schema=").concat(encodeURIComponent(y.schema),"&table=").concat(encodeURIComponent(y.name)).concat(F&&a&&"sqlite"!==a.engine?"&database=".concat(encodeURIComponent(F)):"")).then(S).catch(e=>E(e instanceof Error?e.message:"")))},[y,t.id,F,a]);let O=(0,l.useMemo)(()=>{var e,s;let t=g.trim().toLowerCase(),n=new Map;for(let l of null!=(e=null==a?void 0:a.tables)?e:[])(!t||l.name.toLowerCase().includes(t))&&(null!=(s=n.get(l.schema))?s:n.set(l.schema,[]).get(l.schema)).push(l);return[...n]},[a,g]),q=1===O.length,T=(0,l.useMemo)(()=>{var e;return[...new Set((null!=(e=null==a?void 0:a.tables)?e:[]).map(e=>e.schema))]},[a]),H=T.every(e=>!1!==w[e]);return(0,n.jsx)(ef,{gap:!0,list:(0,n.jsxs)("aside",{className:"dbs-list",children:[(0,n.jsxs)("div",{className:"dbs-head",children:[z.length>1&&(0,n.jsx)("select",{className:"select",value:null!=F?F:"",onChange:e=>{k(null),h(e.target.value)},"aria-label":b("db.database.pick"),children:z.map(e=>(0,n.jsx)("option",{value:e,children:e},e))}),(0,n.jsxs)("div",{className:"dbs-tools",children:[(0,n.jsx)(p.DO,{className:"grow",value:g,onChange:f,placeholder:b("db.schema.filter"),label:b("db.schema.filter")}),T.length>1&&(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>{let e;return e=!H,N(Object.fromEntries(T.map(s=>[s,e])))},"aria-label":H?b("db.schema.collapseAll"):b("db.schema.expandAll"),title:H?b("db.schema.collapseAll"):b("db.schema.expandAll"),children:H?(0,n.jsx)(sV.A,{size:14}):(0,n.jsx)(sZ.A,{size:14})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:i,"aria-label":b("db.schema.refresh"),title:b("db.schema.refresh"),children:(0,n.jsx)(eQ.A,{size:14,className:c?"spin":""})})]})]}),(0,n.jsx)("div",{className:"dbs-tree",children:r?(0,n.jsx)("p",{className:"gx-note err",children:r}):!a&&c?(0,n.jsxs)("p",{className:"muted small db-note",children:[(0,n.jsx)(d.A,{size:14,className:"spin"})," ",b("db.schema.loading")]}):0===O.length?(0,n.jsx)("p",{className:"muted small db-note",children:b("db.schema.empty")}):O.map(e=>{let[s,t]=e;return(0,n.jsxs)("div",{children:[!q&&(0,n.jsxs)("button",{className:"dbs-group",onClick:()=>N(e=>({...e,[s]:!1===e[s]})),children:[!1===w[s]?(0,n.jsx)(I.A,{size:14}):(0,n.jsx)(R.A,{size:14}),s,(0,n.jsx)("span",{className:"muted",children:t.length})]}),(q||!1!==w[s])&&t.map(e=>(0,n.jsxs)("button",{className:"dbs-table ".concat((null==y?void 0:y.schema)===e.schema&&y.name===e.name?"on":""),onClick:()=>k(e),onDoubleClick:()=>j(e),children:["view"===e.type?(0,n.jsx)(_.A,{size:14}):(0,n.jsx)(sN.A,{size:14}),(0,n.jsx)("span",{className:"nm",children:e.name}),void 0!==e.rows&&(0,n.jsxs)("span",{className:"muted",children:["≈",(0,L._E)(e.rows)]})]},"".concat(e.schema,".").concat(e.name)))]},s)})})]}),children:(0,n.jsx)("section",{className:"dbs-detail",children:y?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"row gap-s wrap",children:[(0,n.jsxs)("h3",{className:"mono res-m0",children:["main"!==y.schema&&(null==a?void 0:a.engine)!=="mysql"?"".concat(y.schema,"."):"",y.name]}),(0,n.jsxs)("span",{className:"muted small",children:["view"===y.type?b("db.schema.view"):b("db.schema.table"),void 0!==y.rows?" \xb7 ".concat(b("db.rows.est",{count:(0,L._E)(y.rows)})):""]}),(0,n.jsx)("span",{className:"grow"}),(0,n.jsxs)("button",{className:"btn primary sm",onClick:()=>j(y),children:[(0,n.jsx)(m.A,{size:14}),b("db.select100")]}),(0,n.jsxs)("button",{className:"btn sm",onClick:()=>{var e;null==(e=navigator.clipboard)||e.writeText(y.name),v(b("db.copied"))},children:[(0,n.jsx)(eh.A,{size:14}),b("db.copyName")]})]}),A?(0,n.jsx)("p",{className:"gx-note err",children:A}):C?(0,n.jsxs)("table",{className:"dbr-table dbs-cols",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:b("db.col.name")}),(0,n.jsx)("th",{children:b("db.col.type")}),(0,n.jsx)("th",{children:b("db.col.null")}),(0,n.jsx)("th",{children:b("db.col.key")}),(0,n.jsx)("th",{children:b("db.col.default")})]})}),(0,n.jsx)("tbody",{children:C.map(e=>{var s;return(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"mono",children:e.name}),(0,n.jsx)("td",{className:"mono",children:e.type}),(0,n.jsx)("td",{children:e.nullable?b("db.yes"):(0,n.jsx)("b",{children:b("db.no")})}),(0,n.jsx)("td",{children:e.key?(0,n.jsx)("span",{className:"db-key",children:e.key}):""}),(0,n.jsx)("td",{className:"mono",children:null!=(s=e.default)?s:(0,n.jsx)("i",{className:"db-null",children:"NULL"})})]},e.name)})})]}):(0,n.jsxs)("p",{className:"muted small db-note",children:[(0,n.jsx)(d.A,{size:14,className:"spin"})," ",b("db.schema.loading")]})]}):(0,n.jsx)("p",{className:"muted db-note",children:b("db.schema.pick")})})})}function sY(e){let{onClose:s,onSave:t,title:a,initial:r=""}=e,{t:c}=(0,x.s9)(),[i,o]=(0,l.useState)(r);return(0,n.jsxs)(p.aF,{title:null!=a?a:c("db.save"),onClose:s,children:[(0,n.jsxs)("div",{className:"field",children:[(0,n.jsx)("label",{children:c("db.saved.name")}),(0,n.jsx)("input",{className:"input",autoFocus:!0,value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{"Enter"===e.key&&i.trim()&&t(i.trim())}})]}),(0,n.jsxs)("div",{className:"row res-end",children:[(0,n.jsx)("button",{className:"btn ghost",onClick:s,children:c("common.cancel")}),(0,n.jsx)("button",{className:"btn primary",disabled:!i.trim(),onClick:()=>t(i.trim()),children:c(a?"common.saveChanges":"db.save")})]})]})}function s0(e){let{o:s,hist:t,saved:a,sql:r,database:c,onUse:i,onChanged:o}=e,{t:d}=(0,x.s9)(),h=(0,p.dj)(),[m,j]=(0,l.useState)(null),[b,v]=(0,l.useState)(null),g=e=>h(e instanceof Error?e.message:"","err"),f=async()=>{try{await u.FH.del("/objects/".concat(s.id,"/db/history")),o()}catch(e){g(e)}},w=async e=>{await u.FH.del("/objects/".concat(s.id,"/db/saved/").concat(e)),o()},N=async(e,t,n)=>{try{await u.FH.patch("/objects/".concat(s.id,"/db/saved/").concat(e),t),n&&h(n),o()}catch(e){g(e)}};return(0,n.jsxs)("div",{className:"dbh",children:[(0,n.jsxs)("section",{children:[(0,n.jsx)("div",{className:"row gap-s",children:(0,n.jsx)("h3",{className:"grow",children:d("db.saved.title")})}),0===a.length?(0,n.jsx)("p",{className:"muted small",children:d("db.saved.none")}):a.map(e=>(0,n.jsxs)("div",{className:"dbh-row",children:[(0,n.jsxs)("button",{className:"dbh-main",onClick:()=>i(e.sql,e.database),title:d("db.saved.use"),children:[(0,n.jsx)("b",{children:e.name}),(0,n.jsx)("code",{className:"mono",title:e.sql,children:e.sql.trim().slice(0,600)})]}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>j(e),"aria-label":d("db.saved.rename"),title:d("db.saved.rename"),children:(0,n.jsx)(se.A,{size:14})}),(0,n.jsx)("button",{className:"btn ghost icon sm",disabled:!r.trim()||r===e.sql,onClick:()=>void N(e.id,{sql:r,database:null!=c?c:""},d("db.saved.updated")),"aria-label":d("db.saved.replace"),title:d("db.saved.replace"),children:(0,n.jsx)(sl.A,{size:14})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>v(e),"aria-label":d("db.delete"),title:d("db.delete"),children:(0,n.jsx)(es.A,{size:14})})]},e.id))]}),(0,n.jsxs)("section",{children:[(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)("h3",{className:"grow",children:d("db.hist.title")}),t&&t.length>0&&(0,n.jsxs)("button",{className:"btn ghost sm",onClick:()=>void f(),children:[(0,n.jsx)(es.A,{size:14}),d("db.hist.clear")]})]}),null===t?(0,n.jsx)("p",{className:"muted small",children:d("git.loading")}):0===t.length?(0,n.jsx)("p",{className:"muted small",children:d("db.hist.empty")}):t.map(e=>{var s;return(0,n.jsx)("div",{className:"dbh-row",children:(0,n.jsxs)("button",{className:"dbh-main",onClick:()=>i(e.sql,e.database),title:e.error,children:[(0,n.jsxs)("span",{className:"row gap-s small",children:[(0,n.jsx)("i",{className:"dot ".concat(e.ok?"ok":"err")}),(0,n.jsx)("span",{className:"muted",children:(0,F.KN)(e.at)}),e.ok?(0,n.jsxs)("span",{className:"muted",children:["\xb7 ",void 0!==e.rows?d("db.result.rows",{count:e.rows}):d("db.result.affected",{count:null!=(s=e.affected)?s:0})," \xb7 ",e.ms," ms"]}):(0,n.jsx)("span",{className:"db-bad",children:e.error})]}),(0,n.jsx)("code",{className:"mono",title:e.error?void 0:e.sql,children:e.sql.trim().slice(0,600)})]})},e.n)})]}),m&&(0,n.jsx)(sY,{title:d("db.saved.rename"),initial:m.name,onClose:()=>j(null),onSave:e=>{j(null),N(m.id,{name:e},d("db.saved.updated"))}}),b&&(0,n.jsx)(p.TM,{title:d("db.saved.delete.title",{name:b.name}),body:d("db.saved.delete.body"),confirmLabel:d("db.delete"),danger:!0,onConfirm:()=>w(b.id),onClose:()=>v(null)})]})}function s1(e){let{object:s,pane:t,onPane:a}=e,{t:r}=(0,x.s9)(),c=(0,p.dj)(),i=s.config,o="hive-am.dbq.".concat(s.id),[d,h]=(0,l.useState)(""),[m,j]=(0,l.useState)(void 0),[b,v]=(0,l.useState)(!1),[g,f]=(0,l.useState)(null),[w,N]=(0,l.useState)(""),[y,k]=(0,l.useState)(null),[C,S]=(0,l.useState)(""),[A,E]=(0,l.useState)(!1),[z,F]=(0,l.useState)([]),[L,O]=(0,l.useState)(null),[q,T]=(0,l.useState)(!1),R=(0,l.useRef)(null),I=(0,l.useRef)(new Map),[,H]=(0,l.useState)(0),D=e=>"".concat(null!=m?m:"","|").concat(e.schema,".").concat(e.name),M=(0,l.useMemo)(()=>({schema:y,cols:e=>{let s=I.current.get(D(e));return Array.isArray(s)?s:void 0},need:e=>{let t=D(e);if(I.current.has(t))return;I.current.set(t,"loading");let n=null!=m?m:null==y?void 0:y.database;u.FH.get("/objects/".concat(s.id,"/db/columns?schema=").concat(encodeURIComponent(e.schema),"&table=").concat(encodeURIComponent(e.name)).concat(n&&y&&"sqlite"!==y.engine?"&database=".concat(encodeURIComponent(n)):"")).then(e=>I.current.set(t,e.map(e=>e.name))).catch(()=>I.current.delete(t)).finally(()=>H(e=>e+1))}}),[y,m,s.id]);(0,l.useEffect)(()=>{I.current.clear()},[s.id,s.updated_at,m]);let U=(0,l.useRef)(null);(0,l.useEffect)(()=>{try{var e;h(null!=(e=localStorage.getItem(o))?e:"")}catch(e){}},[o]);let B=e=>{h(e);try{localStorage.setItem(o,e)}catch(e){}},$=(0,l.useCallback)(async e=>{E(!0),S("");try{let t=await u.FH.get("/objects/".concat(s.id,"/db/schema").concat(e?"?database=".concat(encodeURIComponent(e)):""));k(t)}catch(e){S(e instanceof Error?e.message:"")}finally{E(!1)}},[s.id]),W=(0,l.useCallback)(()=>{u.FH.get("/objects/".concat(s.id,"/db/history")).then(O).catch(()=>O([])),u.FH.get("/objects/".concat(s.id,"/db/saved")).then(F).catch(()=>void 0)},[s.id]);(0,l.useEffect)(()=>{$(m)},[$,m,s.updated_at]),(0,l.useEffect)(()=>{W()},[W]);let J=async e=>{let t=R.current,n=t&&t.selectionEnd>t.selectionStart?d.slice(t.selectionStart,t.selectionEnd):d,l=(null!=e?e:n).trim();if(l&&!b){v(!0),N("");try{let e=await u.FH.post("/objects/".concat(s.id,"/db/query"),{sql:l,database:m});f(e)}catch(e){f(null),N(e instanceof Error?e.message:"")}finally{v(!1),W()}}},P=(e,s)=>{let t=d.trimEnd(),n=t?"".concat(t,"\n\n"):"";B(n+e),U.current={from:n.length,to:n.length+e.length},void 0!==s&&j(s),a("query")};(0,l.useEffect)(()=>{let e=U.current,s=R.current;e&&s&&"query"===t&&(U.current=null,requestAnimationFrame(()=>{s.focus(),s.setSelectionRange(e.from,e.to),s.scrollTop=s.scrollHeight}))});let _=async()=>{let e=R.current,s=e&&e.selectionEnd>e.selectionStart;try{var t,n;if(s&&e){let s=await sO(d.slice(e.selectionStart,e.selectionEnd),null!=(n=null==y?void 0:y.engine)?n:i.engine);B(d.slice(0,e.selectionStart)+s+d.slice(e.selectionEnd))}else B(await sO(d,null!=(t=null==y?void 0:y.engine)?t:i.engine))}catch(e){c(r("db.format.fail",{error:e instanceof Error?e.message.split("\n")[0]:""}),"err")}},K=async e=>{try{await u.FH.post("/objects/".concat(s.id,"/db/saved"),{name:e,sql:d,database:m}),c(r("db.saved.done")),W()}catch(e){c(e instanceof Error?e.message:"","err")}};return(0,n.jsxs)("div",{className:"dbw",children:["query"===t&&(0,n.jsx)(sX,{o:s,sql:d,setSql:B,area:R,run:()=>void J(),format:()=>void _(),ctx:M,busy:b,result:g,error:w,schema:y,database:m,setDatabase:j,saved:z,onSave:()=>T(!0),onUse:P,onManage:()=>a("history")}),"schema"===t&&(0,n.jsx)(sQ,{o:s,schema:y,err:C,loading:A,onReload:()=>void $(m),database:m,setDatabase:j,onOpen:e=>{var s;let t=function(e,s){let t="sqlite"===e?sM(e,s.name):"".concat(sM(e,s.schema),".").concat(sM(e,s.name));return"mssql"===e?"SELECT TOP 100 * FROM ".concat(t):"SELECT * FROM ".concat(t," LIMIT 100")}(null!=(s=null==y?void 0:y.engine)?s:i.engine,e);B(t),a("query"),J(t)}}),"history"===t&&(0,n.jsx)(s0,{o:s,hist:L,saved:z,sql:d,database:m,onUse:P,onChanged:W}),q&&(0,n.jsx)(sY,{onClose:()=>T(!1),onSave:e=>{T(!1),K(e)}})]})}function s2(e){let{id:s}=e,{t}=(0,x.s9)(),{objects:a,ready:r,objects:c,error:i,retry:o}=(0,j.o0)(),d=s?a.find(e=>e.id===s):void 0,[h,m]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{try{m("1"===localStorage.getItem("hive-obj-switcher-collapsed"))}catch(e){}},[]),(0,n.jsxs)("div",{className:"ws ".concat(h?"sw-collapsed":""),children:[(0,n.jsx)(S,{activeId:s,collapsed:h,onToggle:()=>m(e=>{try{localStorage.setItem("hive-obj-switcher-collapsed",e?"0":"1")}catch(e){}return!e})}),!r&&i?(0,n.jsx)("section",{className:"ws-chat",children:(0,n.jsx)("div",{className:"ow-pad",children:(0,n.jsx)(p.lZ,{kind:"err",children:(0,n.jsxs)("div",{className:"row gap-s wrap",children:[(0,n.jsx)("span",{className:"grow",children:i}),(0,n.jsx)("button",{className:"btn sm",onClick:()=>void o(),children:t("rs.retry")})]})})})}):s||r?s?d?(0,n.jsx)(s4,{object:d},d.id):(0,n.jsx)("section",{className:"ws-chat",children:(0,n.jsx)("div",{className:"ow-pad",children:r?(0,n.jsx)(p.pp,{title:t("ow.gone")}):(0,n.jsx)(p.pp,{title:t("git.loading")})})}):(0,n.jsx)("section",{className:"ws-chat",children:(0,n.jsx)("div",{className:"ow-pad",children:(0,n.jsx)(p.pp,{title:t(c.length?"ow.pick":"ow.empty.title"),body:c.length?void 0:t("ow.empty.body")})})}):(0,n.jsx)("section",{className:"ws-chat"})]})}function s4(e){let{object:s}=e,{t}=(0,x.s9)(),f=(0,p.dj)(),w="http"===s.kind?["requests","history","vars","config"]:"database"===s.kind?["query","schema","history","config"]:["summary","logs","config"],[N,y]=(0,b.Z)("tab",w[0]),k=w.includes(N)?N:w[0],[C,S]=(0,l.useState)(""),[A,E]=(0,l.useState)(!1),[z,F]=(0,l.useState)(!1),[L,O]=(0,l.useState)(null),{icon:q,color:T}=v.Nd[s.kind],R=s.state.status,I="running"===R||"starting"===R,H=async e=>{O(e);try{await u.FH.post("/objects/".concat(s.id,"/action"),{action:e})}catch(s){f("".concat(t("obj.act.failed",{action:t("obj.act.".concat(e))}),": ").concat(s instanceof Error?s.message:""),"err")}finally{O(null)}},D=async()=>{O("test");try{let e=await u.FH.post("/object-db/test",{id:s.id,config:s.config});f("".concat(t("db.test.ok")," \xb7 ").concat(e.version," \xb7 ").concat(e.ms," ms"))}catch(e){f(e instanceof Error?e.message:"","err")}finally{O(null)}},M="cluster"===s.kind,U=M?s.config.members:[],{objects:B}=(0,j.o0)(),$=U.map(e=>{var s,t;return null!=(t=null==(s=B.find(s=>s.id===e))?void 0:s.name)?t:""}).filter(Boolean),W="server"===s.kind||"docker"===s.kind&&"compose"!==s.config.mode,J="docker"===s.kind?s.config:null,P=[];"http"!==s.kind&&"database"!==s.kind&&(P.push({id:"stop",label:t(M?"obj.act.stopAll":"obj.act.stop"),icon:(0,n.jsx)(a.A,{size:14}),disabled:!!L||!I&&"error"!==R,onClick:()=>void H("stop")}),P.push({id:"restart",label:t(M?"obj.act.restartAll":"obj.act.restart"),icon:(0,n.jsx)(r.A,{size:14}),disabled:!!L,onClick:()=>void H("restart")})),J&&"container"===J.mode&&P.push({id:"inspect",label:t("svc.inspect"),icon:(0,n.jsx)(c.A,{size:14}),onClick:()=>E(!0)}),J&&"existing"!==J.mode&&P.push({id:"recreate",label:t("obj.act.recreate"),icon:(0,n.jsx)(i.A,{size:14}),danger:!0,hint:t("svc.recreate.hint"),disabled:!!L,onClick:()=>F(!0)}),J&&"compose"===J.mode&&P.push({id:"rebuild",label:t("obj.act.rebuild"),icon:(0,n.jsx)(o.A,{size:14}),hint:t("svc.rebuild.hint"),disabled:!!L,onClick:()=>void H("rebuild")});let _=(0,n.jsxs)(n.Fragment,{children:["database"===s.kind&&(0,n.jsxs)("button",{className:"btn sm",disabled:!!L,onClick:()=>void D(),children:["test"===L?(0,n.jsx)(d.A,{size:14,className:"spin"}):(0,n.jsx)(h.A,{size:14}),t("db.test")]}),"http"!==s.kind&&"database"!==s.kind&&(0,n.jsxs)("button",{className:"btn primary sm",disabled:!!L||(M?"running"===R:I),onClick:()=>void H("start"),children:[(0,n.jsx)(m.A,{size:14}),t(M?"obj.act.startAll":"obj.act.start")]}),W&&(0,n.jsx)(eg.N,{spec:{objectId:s.id},title:"server"===s.kind?t("dock.here"):t("dock.shell")})]});return(0,n.jsxs)("section",{className:"ws-chat",children:[(0,n.jsx)(p.DS,{back:{href:"/",label:t("ow.back")},avatar:(0,n.jsx)("span",{className:"obj-ico",style:{"--c":T},children:(0,n.jsx)(q,{size:22})}),title:s.name,meta:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{className:"ostatus ".concat(v.Wy[R]),children:[(0,n.jsx)(g.md,{status:R}),t("obj.status.".concat(R))]}),(0,n.jsx)("span",{children:t("obj.kind.".concat(s.kind))}),s.state.detail&&(0,n.jsx)("span",{children:(0,v.HS)(t,s.state.detail)})]}),primary:_,actions:P}),(0,n.jsx)(p.tU,{idPrefix:"ow",label:t("rs.tabs"),value:k,onChange:e=>{"logs"===e&&S(""),y(e)},tabs:w.map(e=>({id:e,label:t("ow.tab.".concat(e))}))}),(0,n.jsx)("div",{className:"ow-body ".concat("logs"===k||"requests"===k||"history"===k||"query"===k||"schema"===k?"full":""),children:(0,n.jsxs)(p.Kp,{id:k,value:k,idPrefix:"ow",children:["summary"===k&&(0,n.jsx)(ee,{object:s,onSeeLogs:e=>{S(null!=e?e:""),y("logs")}}),"logs"===k&&(0,n.jsx)(ep,{id:s.id,members:M?$:void 0,initialFilter:C||void 0},C),"config"===k&&(0,n.jsx)(el,{object:s}),"database"===s.kind&&("query"===k||"schema"===k||"history"===k)&&(0,n.jsx)(s1,{object:s,pane:k,onPane:y}),"http"===s.kind&&("requests"===k||"history"===k)&&(0,n.jsx)(sS,{object:s,pane:k,onOpenVars:()=>y("vars"),onGoRequests:()=>y("requests")}),"vars"===k&&(0,n.jsx)(sE,{object:s})]})}),A&&(0,n.jsx)(G,{objectId:s.id,title:s.name,onClose:()=>E(!1)}),z&&(0,n.jsx)(p.TM,{title:t("rs.recreate.title",{name:s.name}),body:t("svc.recreate.hint"),confirmLabel:t("obj.act.recreate"),danger:!0,onConfirm:()=>H("recreate"),onClose:()=>F(!1)})]})}}}]);
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[491],{84491:(e,s,t)=>{t.d(s,{D:()=>s2});var n=t(94799),l=t(34023),a=t(83372),r=t(6673),c=t(82683),i=t(37104),o=t(8089),d=t(59959),h=t(73885),m=t(47405),u=t(3749),x=t(69654),j=t(48538),p=t(10804),b=t(61748),v=t(74988),g=t(31606),f=t(41463),w=t.n(f),N=t(33974),y=t(78330),k=t(92947),C=t(95587);function S(e){let{activeId:s,collapsed:t=!1,onToggle:a}=e,{t:r}=(0,x.s9)(),{objects:c,colonies:i}=(0,j.o0)(),[o,d]=(0,l.useState)(""),[h,m]=(0,l.useState)(!1),u=(0,l.useMemo)(()=>{let e=e=>!o||"".concat(e.name," ").concat(e.kind).toLowerCase().includes(o.toLowerCase()),s=i.map(s=>({key:s.id,name:s.name,color:s.color||"var(--honey)",items:c.filter(t=>t.colony_id===s.id&&e(t))}));return s.push({key:"free",name:r("obj.noColony"),color:null,items:c.filter(s=>(!s.colony_id||!i.some(e=>e.id===s.colony_id))&&e(s))}),s.filter(e=>e.items.length)},[c,i,o,r]),b=a&&(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:a,"aria-label":t?r("ow.expand"):r("ow.collapse"),title:t?r("ow.expand"):r("ow.collapse"),"aria-expanded":!t,children:t?(0,n.jsx)(N.A,{size:17}):(0,n.jsx)(y.A,{size:17})});return t?(0,n.jsxs)("aside",{className:"switcher mini","aria-label":r("nav.objects"),children:[(0,n.jsxs)("div",{className:"switcher-head",children:[b,(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>m(!0),"aria-label":r("obj.new"),title:r("obj.new"),children:(0,n.jsx)(k.A,{size:16})})]}),(0,n.jsx)("div",{className:"switcher-list",children:u.map(e=>(0,n.jsxs)("div",{className:"mini-group",children:[(0,n.jsx)("div",{className:"mini-sep",title:"".concat(e.name," \xb7 ").concat(e.items.length),style:e.color?{"--c":e.color}:void 0}),e.items.map(e=>{let{icon:t,color:l}=v.Nd[e.kind];return(0,n.jsx)(w(),{href:"/resources/".concat(e.id),className:"sw-item mini","aria-current":e.id===s?"page":void 0,"aria-label":e.name,title:"".concat(e.name,": ").concat(r("obj.status.".concat(e.state.status))),children:(0,n.jsxs)("span",{className:"sw-av",children:[(0,n.jsx)("span",{className:"obj-ico sm",style:{"--c":l},children:(0,n.jsx)(t,{size:17})}),(0,n.jsx)(g.md,{status:e.state.status,className:"sw-dot"})]})},e.id)})]},e.key))}),h&&(0,n.jsx)(C.X,{onClose:()=>m(!1)})]}):(0,n.jsxs)("aside",{className:"switcher","aria-label":r("nav.objects"),children:[(0,n.jsxs)("div",{className:"switcher-head",children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("b",{className:"grow sw-title",children:r("nav.objects")}),b,(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>m(!0),"aria-label":r("obj.new"),title:r("obj.new"),children:(0,n.jsx)(k.A,{size:16})})]}),(0,n.jsx)(p.DO,{value:o,onChange:d,placeholder:r("ow.find"),label:r("ow.find")})]}),(0,n.jsxs)("div",{className:"switcher-list",children:[0===u.length&&(0,n.jsx)("p",{className:"muted small sw-none",children:o?r("ow.noMatch",{query:o}):r("ow.empty.body")}),u.map(e=>(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"switcher-group",children:[e.color&&(0,n.jsx)("i",{className:"cdot",style:{background:e.color}}),e.name,(0,n.jsx)("span",{children:e.items.length})]}),e.items.map(e=>{let{icon:t,color:l}=v.Nd[e.kind];return(0,n.jsxs)(w(),{href:"/resources/".concat(e.id),className:"sw-item","aria-current":e.id===s?"page":void 0,children:[(0,n.jsx)("span",{className:"sw-av",children:(0,n.jsx)("span",{className:"obj-ico sm",style:{"--c":l},children:(0,n.jsx)(t,{size:17})})}),(0,n.jsxs)("span",{className:"sw-body",children:[(0,n.jsx)("span",{className:"sw-top",children:(0,n.jsx)("b",{children:e.name})}),(0,n.jsxs)("span",{className:"sw-sub",children:[(0,n.jsx)(g.md,{status:e.state.status})," ",r("obj.status.".concat(e.state.status)),e.state.detail?" \xb7 ".concat((0,v.HS)(r,e.state.detail)):""]}),(0,n.jsx)("span",{className:"sw-meta",children:r("obj.kind.".concat(e.kind))})]})]},e.id)})]},e.key))]}),h&&(0,n.jsx)(C.X,{onClose:()=>m(!1)})]})}var A=t(37064);let E=/\u001b\[[0-9;?]*[ -/]*[@-~]/g;function z(e){let{max:s=8e5,pollMs:t=1e3,paused:n=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},[a,r]=(0,l.useState)({text:null,dropped:0}),c=(0,l.useRef)(""),i=(0,l.useRef)(0);(0,l.useEffect)(()=>{r({text:null,dropped:0}),c.current="",i.current++},[e]),(0,l.useEffect)(()=>{if(n)return;let l=!1,a,o=i.current,d=async()=>{try{let t=c.current?"after=".concat(encodeURIComponent(c.current)):"tail=2000",n=await u.FH.get("/objects/".concat(e,"/logs?").concat(t));if(l||o!==i.current)return;c.current=n.cursor||c.current;let a=n.text.replace(E,"");r(e=>{var t;if(!a&&!n.reset)return e;let l=n.reset?"":null!=(t=e.text)?t:"",r=a?!l||l.endsWith("\n")||a.startsWith("\n")?l+a:"".concat(l,"\n").concat(a):l;if(r.length<=s)return{text:r,dropped:n.reset?0:e.dropped};let c=r.length-s,i=r.slice(0,c);return{text:r.slice(c),dropped:(n.reset?0:e.dropped)+i.split("\n").length-1}})}catch(e){}l||(a=setTimeout(d,t))};return d(),()=>{l=!0,clearTimeout(a)}},[e,n,s,t]);let o=(0,l.useCallback)(()=>r(e=>({text:"",dropped:e.dropped+(e.text?e.text.split("\n").length:0)})),[]);return{text:a.text,dropped:a.dropped,clear:o}}var F=t(47890),L=t(56072);function O(e){let{values:s,max:t,color:l="var(--honey)",height:a=36}=e,r=null!=t?t:Math.max(1,...s);if(s.length<2)return(0,n.jsx)("svg",{className:"spark",width:"100%",height:a,viewBox:"0 0 ".concat(160," ").concat(a),preserveAspectRatio:"none","aria-hidden":!0});let c=s.map((e,t)=>"".concat((t/(s.length-1)*160).toFixed(1),",").concat((a-2-Math.min(e,r)/r*(a-4)).toFixed(1)));return(0,n.jsxs)("svg",{className:"spark",width:"100%",height:a,viewBox:"0 0 ".concat(160," ").concat(a),preserveAspectRatio:"none","aria-hidden":!0,children:[(0,n.jsx)("polygon",{points:"0,".concat(a," ").concat(c.join(" ")," ").concat(160,",").concat(a),fill:l,opacity:".14"}),(0,n.jsx)("polyline",{points:c.join(" "),fill:"none",stroke:l,strokeWidth:"1.6",vectorEffect:"non-scaling-stroke"})]})}var q=t(75014),T=t(50703),R=t(12349),I=t(79141),H=t(91496),D=t(7991),M=t(70665),U=t(41435),B=t(43624),$=t(19431),W=t(70283),J=t(42162),P=t(58960),_=t(7168);let K=/pass|secret|token|api[_-]?key|auth|credential|private/i;function G(e){let{objectId:s,service:t,title:a,onClose:r}=e,{t:c}=(0,x.s9)(),i=(0,J.n)(),[o,d]=(0,l.useState)(null),[h,m]=(0,l.useState)(""),[j,b]=(0,l.useState)(!1);(0,l.useEffect)(()=>{u.FH.get("/objects/".concat(s,"/inspect").concat(t?"?service=".concat(encodeURIComponent(t)):"")).then(d).catch(e=>m(e instanceof Error?e.message:"error"))},[s,t]);let v=e=>e&&!e.startsWith("0001")?(0,L.v7)(Date.parse(e)):"—";return(0,n.jsx)(p.aF,{title:a,onClose:r,wide:!0,children:h?(0,n.jsx)("p",{className:"gx-note err res-m0",children:h}):o?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsxs)("span",{className:"muted small grow mono",children:[o.name," \xb7 ",o.id]}),"running"===o.status&&(0,n.jsxs)("button",{className:"btn sm",onClick:()=>{i.openTerminal({objectId:s,service:t}),r()},children:[(0,n.jsx)(W.A,{size:14}),c("svc.shell")]})]}),(0,n.jsxs)("section",{className:"sd-sec",children:[(0,n.jsx)("div",{className:"eyebrow",children:c("svc.d.general")}),(0,n.jsxs)("dl",{className:"sd-kv",children:[(0,n.jsx)("dt",{children:c("ow.d.image")}),(0,n.jsx)("dd",{className:"mono",children:o.image}),(0,n.jsx)("dt",{children:c("svc.col.status")}),(0,n.jsx)("dd",{children:o.status}),(0,n.jsx)("dt",{children:c("ow.d.created")}),(0,n.jsx)("dd",{children:v(o.created)}),(0,n.jsx)("dt",{children:c("svc.d.started")}),(0,n.jsx)("dd",{children:v(o.started)}),(0,n.jsx)("dt",{children:c("ow.d.restart")}),(0,n.jsxs)("dd",{children:[o.restartPolicy,o.restarts?" \xb7 ".concat(c("ow.d.restarts"),": ").concat(o.restarts):""]}),o.entrypoint&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("dt",{children:"Entrypoint"}),(0,n.jsx)("dd",{className:"mono",children:o.entrypoint})]}),o.command&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("dt",{children:c("ow.d.command")}),(0,n.jsx)("dd",{className:"mono",children:o.command})]}),o.workdir&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("dt",{children:c("svc.d.workdir")}),(0,n.jsx)("dd",{className:"mono",children:o.workdir})]}),o.user&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("dt",{children:c("svc.d.user")}),(0,n.jsx)("dd",{className:"mono",children:o.user})]})]})]}),o.health&&(0,n.jsxs)("section",{className:"sd-sec",children:[(0,n.jsxs)("div",{className:"eyebrow",children:[c("ow.d.health")," \xb7 ",o.health.status]}),0===o.health.log.length?(0,n.jsx)("p",{className:"muted small res-m0",children:"—"}):(0,n.jsx)("table",{className:"sd-table",children:(0,n.jsx)("tbody",{children:o.health.log.map((e,s)=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"mono",children:e.exit}),(0,n.jsx)("td",{className:"muted",children:v(e.at)}),(0,n.jsx)("td",{className:"mono",children:e.output.trim()})]},s))})})]}),(0,n.jsxs)("section",{className:"sd-sec",children:[(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsxs)("div",{className:"eyebrow grow",children:[c("of.env")," \xb7 ",o.env.length]}),(0,n.jsxs)("button",{className:"btn ghost sm",onClick:()=>b(e=>!e),children:[j?(0,n.jsx)(P.A,{size:14}):(0,n.jsx)(_.A,{size:14}),c("iv.reveal")]})]}),0===o.env.length?(0,n.jsx)("p",{className:"muted small res-m0",children:"—"}):(0,n.jsx)("table",{className:"sd-table",children:(0,n.jsx)("tbody",{children:o.env.map(e=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"mono",children:(0,n.jsx)("b",{children:e.name})}),(0,n.jsx)("td",{className:"mono",children:K.test(e.name)&&!j?"••••••••":e.value})]},e.name))})})]}),(0,n.jsxs)("section",{className:"sd-sec",children:[(0,n.jsx)("div",{className:"eyebrow",children:c("ow.d.ports")}),0===o.ports.length?(0,n.jsx)("p",{className:"muted small res-m0",children:"—"}):(0,n.jsx)("table",{className:"sd-table",children:(0,n.jsx)("tbody",{children:o.ports.map((e,s)=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"mono",children:e.container}),(0,n.jsx)("td",{className:"mono",children:e.host?(0,n.jsxs)("a",{href:"http://localhost:".concat(e.host),target:"_blank",rel:"noreferrer",children:["localhost:",e.host]}):(0,n.jsx)("span",{className:"muted",children:c("svc.d.unpublished")})})]},s))})})]}),(0,n.jsxs)("section",{className:"sd-sec",children:[(0,n.jsxs)("div",{className:"eyebrow",children:[c("svc.d.mounts")," \xb7 ",o.mounts.length]}),0===o.mounts.length?(0,n.jsx)("p",{className:"muted small res-m0",children:"—"}):(0,n.jsxs)("table",{className:"sd-table",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:c("svc.d.source")}),(0,n.jsx)("th",{children:c("svc.d.dest")}),(0,n.jsx)("th",{})]})}),(0,n.jsx)("tbody",{children:o.mounts.map((e,s)=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"mono",children:e.source}),(0,n.jsx)("td",{className:"mono",children:e.destination}),(0,n.jsxs)("td",{className:"muted",children:[e.type,e.rw?"":" \xb7 ro"]})]},s))})]})]}),(0,n.jsxs)("section",{className:"sd-sec",children:[(0,n.jsxs)("div",{className:"eyebrow",children:[c("ow.d.network")," \xb7 ",o.networks.length]}),0===o.networks.length?(0,n.jsx)("p",{className:"muted small res-m0",children:"—"}):(0,n.jsxs)("table",{className:"sd-table",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:c("obj.f.name")}),(0,n.jsx)("th",{children:"IP"}),(0,n.jsx)("th",{children:"Gateway"}),(0,n.jsx)("th",{children:"Aliases"})]})}),(0,n.jsx)("tbody",{children:o.networks.map(e=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"mono",children:e.name}),(0,n.jsx)("td",{className:"mono",children:e.ip}),(0,n.jsx)("td",{className:"mono",children:e.gateway}),(0,n.jsx)("td",{className:"mono",children:e.aliases.join(", ")})]},e.name))})]})]})]}):(0,n.jsx)("p",{className:"gx-note",children:c("git.loading")})})}function X(e){let{ports:s}=e,t=s.split(",").map(e=>e.trim()).filter(Boolean);return t.length?(0,n.jsx)("span",{className:"svc-ports",children:t.map(e=>{var s;let t=null==(s=/^(\d+)(?:->|→)/.exec(e))?void 0:s[1];return t?(0,n.jsx)("a",{className:"mono",href:"http://localhost:".concat(t),target:"_blank",rel:"noreferrer",title:"http://localhost:".concat(t),children:e},e):(0,n.jsx)("span",{className:"mono",children:e},e)})}):(0,n.jsx)("span",{className:"muted",children:"—"})}function V(e){let{objectId:s,services:t,onLogs:d,onChanged:h}=e,{t:j}=(0,x.s9)(),b=(0,p.dj)(),v=(0,J.n)(),[f,w]=(0,l.useState)(null),[N,y]=(0,l.useState)(null),k=async(e,t)=>{w("".concat(e,":").concat(t));try{await u.FH.post("/objects/".concat(s,"/service"),{service:e,action:t}),h()}catch(e){b("".concat(j("obj.act.failed",{action:j("obj.act.".concat(t))}),": ").concat(e instanceof Error?e.message:""),"err")}finally{w(null)}};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("table",{className:"cm-table svc",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:j("svc.col.name")}),(0,n.jsx)("th",{children:j("svc.col.image")}),(0,n.jsx)("th",{children:j("svc.col.status")}),(0,n.jsx)("th",{children:j("svc.col.ports")}),(0,n.jsx)("th",{className:"num",children:j("ow.cpu")}),(0,n.jsx)("th",{className:"num",children:j("ow.mem")}),(0,n.jsx)("th",{})]})}),(0,n.jsx)("tbody",{children:t.map(e=>{let t="running"===e.state||"restarting"===e.state;return(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{children:(0,n.jsxs)("span",{className:"row gap-s",children:[(0,n.jsx)(g.md,{status:"running"===e.state?/unhealthy/i.test(e.health)?"error":/starting/i.test(e.health)?"starting":"running":"exited"===e.state||"dead"===e.state?"error":"restarting"===e.state?"starting":"stopped"}),(0,n.jsxs)("span",{className:"svc-name",children:[(0,n.jsx)("b",{children:e.name}),(0,n.jsx)("small",{className:"mono muted",children:e.container})]})]})}),(0,n.jsx)("td",{className:"mono small svc-img",title:e.image,children:e.image||"—"}),(0,n.jsxs)("td",{children:[(0,n.jsxs)("span",{className:"small",children:[e.state,e.health?" \xb7 ".concat(e.health):""]}),(0,n.jsx)("div",{className:"muted small",children:e.status})]}),(0,n.jsx)("td",{children:(0,n.jsx)(X,{ports:e.ports})}),(0,n.jsx)("td",{className:"num mono small",children:null!==e.cpu?"".concat(e.cpu,"%"):"—"}),(0,n.jsx)("td",{className:"num mono small",children:null!==e.memBytes?(0,L.zi)(e.memBytes):"—"}),(0,n.jsxs)("td",{className:"cm-act",children:[t?(0,n.jsx)("button",{className:"btn ghost icon sm",disabled:!!f,onClick:()=>void k(e.name,"stop"),"aria-label":j("obj.act.stop"),title:j("obj.act.stop"),children:(0,n.jsx)(a.A,{size:14})}):(0,n.jsx)("button",{className:"btn ghost icon sm",disabled:!!f,onClick:()=>void k(e.name,"start"),"aria-label":j("obj.act.start"),title:j("obj.act.start"),children:(0,n.jsx)(m.A,{size:14})}),(0,n.jsx)("button",{className:"btn ghost icon sm",disabled:!!f,onClick:()=>void k(e.name,"restart"),"aria-label":j("obj.act.restart"),title:j("obj.act.restart"),children:(0,n.jsx)(r.A,{size:14})}),(0,n.jsx)(U.W1,{label:j("svc.more"),icon:(0,n.jsx)(H.A,{size:15}),iconOnly:!0,children:l=>(0,n.jsxs)(n.Fragment,{children:[d&&(0,n.jsx)(U.Dr,{icon:(0,n.jsx)($.A,{size:15}),onClick:()=>{l(),d(e.name)},children:j("svc.logs.short")}),(0,n.jsx)(U.Dr,{icon:(0,n.jsx)(W.A,{size:15}),disabled:!t,hint:t?void 0:j("svc.needsRunning"),onClick:()=>{l(),v.openTerminal({objectId:s,service:e.name})},children:j("svc.shell")}),(0,n.jsx)(U.Dr,{icon:(0,n.jsx)(c.A,{size:15}),onClick:()=>{l(),y(e.name)},children:j("svc.inspect")}),(0,n.jsx)(U.MU,{}),(0,n.jsx)(U.Dr,{icon:(0,n.jsx)(i.A,{size:15}),danger:!0,hint:j("svc.recreate.hint"),onClick:()=>{l(),k(e.name,"recreate")},children:j("svc.recreate")}),(0,n.jsx)(U.Dr,{icon:(0,n.jsx)(o.A,{size:15}),hint:j("svc.rebuild.hint"),onClick:()=>{l(),k(e.name,"rebuild")},children:j("svc.rebuild")})]})})]})]},e.name)})})]}),N&&(0,n.jsx)(G,{objectId:s,service:N,title:N,onClose:()=>y(null)})]})}function Z(e,s){var t,n,l,a,r,c;if("server"===e.kind)return e.config.start;let i=e.config;return"compose"===i.mode?"".concat((0,F._1)(null!=(t=i.file)?t:"")).concat((null==s?void 0:s.services)?" \xb7 ".concat(null!=(n=s.info.running)?n:0,"/").concat(null!=(l=s.info.services)?l:0):""):String(null!=(c=null!=(r=null!=(a=null==s?void 0:s.info.image)?a:i.image)?r:i.container)?c:"")}function Q(e){let{cluster:s}=e,{t}=(0,x.s9)(),{objects:c,refresh:i}=(0,j.o0)(),o=(0,p.dj)(),d=(0,B.useRouter)(),[h,b]=(0,l.useState)(null),[f,N]=(0,l.useState)(new Set),y=s.config.members,C=y.map(e=>c.find(s=>s.id===e)).filter(e=>!!e),{stats:S,reload:A}=function(e){let[s,t]=(0,l.useState)({}),[n,a]=(0,l.useState)(0),r=e.map(e=>"".concat(e.id,":").concat(e.state.status)).join(",");return(0,l.useEffect)(()=>{let s=!1,n,l=async()=>{let a=e.filter(e=>"cluster"!==e.kind&&"http"!==e.kind),r=await Promise.all(a.map(e=>u.FH.get("/objects/".concat(e.id,"/stats")).then(s=>[e.id,s]).catch(()=>null)));!s&&(t(Object.fromEntries(r.filter(e=>!!e))),e.some(e=>"running"===e.state.status||"starting"===e.state.status)&&(n=setTimeout(l,5e3)))};return l(),()=>{s=!0,clearTimeout(n)}},[r,n]),{stats:s,reload:()=>a(e=>e+1)}}(C),E=c.filter(e=>{var t,n;return("server"===e.kind||"docker"===e.kind)&&(null!=(t=e.colony_id)?t:null)===(null!=(n=s.colony_id)?n:null)&&!y.includes(e.id)}),z=async e=>{b("members");try{await u.FH.patch("/objects/".concat(s.id),{config:{members:e}}),await i(["objects"])}catch(e){o(e instanceof Error?e.message:t("edit.saveFailed"),"err")}finally{b(null)}},O=(e,s)=>{let t=[...y],n=e+s;n<0||n>=t.length||([t[e],t[n]]=[t[n],t[e]],z(t))},$=async(e,s)=>{b("".concat(e.id,":").concat(s));try{await u.FH.post("/objects/".concat(e.id,"/action"),{action:s})}catch(e){o("".concat(t("obj.act.failed",{action:t("obj.act.".concat(s))}),": ").concat(e instanceof Error?e.message:""),"err")}finally{b(null),A()}};return(0,n.jsxs)("div",{className:"cm",children:[0===C.length?(0,n.jsx)("p",{className:"muted",children:t("cl.none")}):(0,n.jsxs)("table",{className:"cm-table cm-tree",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:t("cl.order")}),(0,n.jsx)("th",{children:t("obj.f.name")}),(0,n.jsx)("th",{children:t("svc.col.runs")}),(0,n.jsx)("th",{children:t("ow.state")}),(0,n.jsx)("th",{className:"num",children:t("ow.cpu")}),(0,n.jsx)("th",{className:"num",children:t("ow.mem")}),(0,n.jsx)("th",{})]})}),(0,n.jsx)("tbody",{children:C.map((e,s)=>{let{icon:c,color:i}=v.Nd[e.kind],o="running"===e.state.status||"starting"===e.state.status,u=S[e.id],x=null==u?void 0:u.services,j=f.has(e.id);return(0,n.jsxs)(l.Fragment,{children:[(0,n.jsxs)("tr",{children:[(0,n.jsxs)("td",{className:"cm-ord",children:[(0,n.jsx)("span",{className:"ord",children:s+1}),(0,n.jsx)("button",{className:"btn ghost icon sm",disabled:0===s||!!h,onClick:()=>O(s,-1),"aria-label":t("cl.up"),title:t("cl.up"),children:(0,n.jsx)(q.A,{size:14})}),(0,n.jsx)("button",{className:"btn ghost icon sm",disabled:s===C.length-1||!!h,onClick:()=>O(s,1),"aria-label":t("cl.down"),title:t("cl.down"),children:(0,n.jsx)(T.A,{size:14})})]}),(0,n.jsx)("td",{children:(0,n.jsxs)("span",{className:"row gap-s",children:[x&&x.length>0?(0,n.jsx)("button",{className:"cm-chev",onClick:()=>{let s;return s=e.id,N(e=>{let t=new Set(e);return t.has(s)?t.delete(s):t.add(s),t})},"aria-expanded":j,"aria-label":j?t("svc.collapse"):t("svc.expand"),title:j?t("svc.collapse"):t("svc.expand"),children:j?(0,n.jsx)(R.A,{size:15}):(0,n.jsx)(I.A,{size:15})}):(0,n.jsx)("span",{style:{width:20}}),(0,n.jsxs)(w(),{href:"/resources/".concat(e.id),className:"cm-name",children:[(0,n.jsx)(c,{size:15,style:{color:i}}),(0,n.jsx)("b",{children:e.name})]})]})}),(0,n.jsx)("td",{className:"mono small svc-img",title:Z(e,u),children:Z(e,u)||"—"}),(0,n.jsxs)("td",{children:[(0,n.jsxs)("span",{className:"row gap-s small",children:[(0,n.jsx)(g.md,{status:e.state.status}),t("obj.status.".concat(e.state.status))]}),(0,n.jsx)("span",{className:"muted small",children:[(0,v.HS)(t,e.state.detail),e.state.since&&o?t("obj.since",{time:(0,F.KN)(e.state.since)}):""].filter(Boolean).join(" \xb7 ")})]}),(0,n.jsx)("td",{className:"num mono small",children:(null==u?void 0:u.cpu)!=null?"".concat(u.cpu,"%"):"—"}),(0,n.jsx)("td",{className:"num mono small",children:(null==u?void 0:u.memBytes)!=null?(0,L.zi)(u.memBytes):"—"}),(0,n.jsxs)("td",{className:"cm-act",children:[o?(0,n.jsx)("button",{className:"btn ghost icon sm",disabled:!!h,onClick:()=>void $(e,"stop"),"aria-label":t("obj.act.stop"),title:t("obj.act.stop"),children:(0,n.jsx)(a.A,{size:14})}):(0,n.jsx)("button",{className:"btn ghost icon sm",disabled:!!h,onClick:()=>void $(e,"start"),"aria-label":t("obj.act.start"),title:t("obj.act.start"),children:(0,n.jsx)(m.A,{size:14})}),(0,n.jsx)("button",{className:"btn ghost icon sm",disabled:!!h,onClick:()=>void $(e,"restart"),"aria-label":t("obj.act.restart"),title:t("obj.act.restart"),children:(0,n.jsx)(r.A,{size:14})}),(0,n.jsx)(U.W1,{label:t("svc.more"),icon:(0,n.jsx)(H.A,{size:15}),iconOnly:!0,children:s=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(U.Dr,{icon:(0,n.jsx)(D.A,{size:15}),onClick:()=>{s(),d.push("/resources/".concat(e.id))},children:t("cl.open")}),(0,n.jsx)(U.MU,{}),(0,n.jsx)(U.Dr,{icon:(0,n.jsx)(M.A,{size:15}),danger:!0,hint:t("cl.remove.hint"),disabled:!!h,onClick:()=>{s(),z(y.filter(s=>s!==e.id))},children:t("cl.remove")})]})})]})]}),j&&x&&(0,n.jsx)("tr",{className:"cm-sub",children:(0,n.jsx)("td",{colSpan:7,children:(0,n.jsx)(V,{objectId:e.id,services:x,onChanged:A})})})]},e.id)})})]}),(0,n.jsx)("p",{className:"muted small",style:{margin:"8px 0"},children:t("cl.startOrder")}),E.length>0&&(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)(k.A,{size:15,className:"muted"}),(0,n.jsxs)("select",{className:"select",style:{width:"auto"},value:"",onChange:e=>e.target.value&&void z([...y,e.target.value]),"aria-label":t("cl.add"),children:[(0,n.jsxs)("option",{value:"",children:[t("cl.add"),"…"]}),E.map(e=>(0,n.jsx)("option",{value:e.id,children:e.name},e.id))]})]})]})}let Y=e=>{let{k:s,v:t}=e;return(0,n.jsxs)("div",{className:"ov-row",children:[(0,n.jsx)("dt",{children:s}),(0,n.jsx)("dd",{children:t})]})};function ee(e){var s,t,a,r,c,i,o,h,m,j,p,b,f;let{object:w,onSeeLogs:N}=e,{t:y}=(0,x.s9)(),{stats:k,cpu:C,mem:S,live:E,reload:q}=function(e){let[s,t]=(0,l.useState)(null),[n,a]=(0,l.useState)([]),[r,c]=(0,l.useState)([]),i="running"===e.state.status||"starting"===e.state.status,[o,d]=(0,l.useState)(0);return(0,l.useEffect)(()=>{if("server"!==e.kind&&"docker"!==e.kind)return;0===o&&(t(null),a([]),c([]));let s=!1,n,l=async()=>{try{let n=await u.FH.get("/objects/".concat(e.id,"/stats"));if(s)return;t(n),null!==n.cpu&&a(e=>[...e,n.cpu].slice(-60)),null!==n.memBytes&&c(e=>[...e,n.memBytes].slice(-60))}catch(e){}!s&&i&&(n=setTimeout(l,3e3))};return l(),()=>{s=!0,clearTimeout(n)}},[e.id,e.kind,i,o]),{stats:s,cpu:n,mem:r,live:i,reload:()=>d(e=>e+1)}}(w),[,T]=(0,l.useState)(0);(0,A.n)(()=>T(e=>e+1),1e3,{enabled:E,immediate:!1});let{text:R}=z(w.id,{max:4e4,pollMs:2e3}),I=(0,l.useMemo)(()=>(null!=R?R:"").split("\n").filter(e=>e.trim()).slice(-14).join("\n"),[R]),H=null!=(t=null==k?void 0:k.info)?t:{},D=w.state,M=y("ow.d.none"),U=[];if("server"===w.kind){let e=w.config;U.push([y("ow.d.command"),(0,n.jsx)("code",{className:"mono",children:e.start},"c")],[y("ow.d.folder"),(0,n.jsx)("code",{className:"mono",title:e.cwd,children:(0,F._1)(e.cwd)},"f")]),e.port&&U.push([y("ow.d.port"),e.port]),e.stop&&U.push([y("ow.d.stop"),(0,n.jsx)("code",{className:"mono",children:e.stop},"s")]),U.push([y("ow.d.restart"),e.restart&&"no"!==e.restart?"".concat(y("always"===e.restart?"obj.sup.restart.always":"obj.sup.restart.fail")," (").concat(null!=(a=e.maxRestarts)?a:5,")"):y("obj.sup.restart.no")]),U.push([y("ow.d.health"),e.health?"".concat(e.health.kind.toUpperCase(),": ").concat(e.health.target):M]),D.pid&&U.push(["PID",D.pid])}else if("docker"===w.kind){let e=w.config;U.push([y("ow.d.mode"),y("obj.mode.".concat(e.mode))]),"compose"===e.mode?U.push([y("ow.d.compose"),(0,n.jsx)("code",{className:"mono",title:e.file,children:(0,F._1)(null!=(r=e.file)?r:"")},"f")],[y("ow.d.services"),"".concat(null!=(c=H.running)?c:0,"/").concat(null!=(i=H.services)?i:0)]):(U.push([y("ow.d.container"),(0,n.jsx)("code",{className:"mono",children:"existing"===e.mode?e.container:"hive-am-".concat(w.id.slice(0,8))},"n")]),(H.image||e.image)&&U.push([y("ow.d.image"),(0,n.jsx)("code",{className:"mono",children:String(null!=(m=H.image)?m:e.image)},"i")]),(H.ports||(null==(o=e.ports)?void 0:o.length))&&U.push([y("ow.d.ports"),String(null!=(j=H.ports)?j:null==(h=e.ports)?void 0:h.join(", "))]),(H.network||e.network)&&U.push([y("ow.d.network"),String(null!=(p=H.network)?p:e.network)]),H.restartPolicy&&U.push([y("ow.d.restart"),String(H.restartPolicy)]),void 0!==H.restarts&&null!==H.restarts&&U.push([y("ow.d.restarts"),String(H.restarts)]),H.memoryLimit&&U.push([y("ow.d.memLimit"),(0,L.zi)(Number(H.memoryLimit))]),H.cpuLimit&&U.push([y("ow.d.cpuLimit"),String(H.cpuLimit)]),H.created&&U.push([y("ow.d.created"),(0,F.KN)(Number(H.created))]))}return(0,n.jsxs)("div",{className:"ov",children:[(0,n.jsxs)("div",{className:"ov-grid",children:[(0,n.jsxs)("section",{className:"ov-card",children:[(0,n.jsx)("div",{className:"eyebrow",children:y("ow.state")}),(0,n.jsxs)("div",{className:"ov-big",children:[(0,n.jsx)(g.md,{status:D.status,className:"lg"}),y("obj.status.".concat(D.status))]}),D.detail&&(0,n.jsx)("p",{className:"muted small",style:{margin:0},children:(0,v.HS)(y,D.detail)}),D.since&&E&&(0,n.jsxs)("p",{className:"small",style:{margin:0},children:[y("ow.uptime")," ",(0,n.jsx)("b",{children:(e=>{let s=Math.max(0,Math.floor(e/1e3)),t=Math.floor(s/86400),n=Math.floor(s%86400/3600),l=Math.floor(s%3600/60);return t?"".concat(t,"d ").concat(n,"h"):n?"".concat(n,"h ").concat(l,"m"):l?"".concat(l,"m ").concat(s%60,"s"):"".concat(s,"s")})(Date.now()-D.since)})]})]}),("server"===w.kind||"docker"===w.kind)&&(0,n.jsxs)("section",{className:"ov-card",children:[(0,n.jsx)("div",{className:"eyebrow",children:y("ow.usage")}),E||(null==k?void 0:k.cpu)!==null?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"ov-meter",children:[(0,n.jsx)("span",{children:y("ow.cpu")}),(0,n.jsx)("b",{children:(null==k?void 0:k.cpu)!==null&&(null==k?void 0:k.cpu)!==void 0?"".concat(k.cpu,"%"):"—"})]}),(0,n.jsx)(O,{values:C,color:"var(--p-opencode)"}),(0,n.jsxs)("div",{className:"ov-meter",children:[(0,n.jsx)("span",{children:y("ow.mem")}),(0,n.jsx)("b",{children:(null==k?void 0:k.memBytes)!=null?"".concat((0,L.zi)(k.memBytes)).concat(k.memLimitBytes?" / ".concat((0,L.zi)(k.memLimitBytes)):""):"—"})]}),(0,n.jsx)(O,{values:S,color:"var(--ok)"}),(0,n.jsxs)("dl",{className:"ov-dl",children:[(null==k?void 0:k.pids)!=null&&(0,n.jsx)(Y,{k:y("ow.procs"),v:k.pids}),(null==k?void 0:k.net)&&(0,n.jsx)(Y,{k:y("ow.net"),v:k.net}),(null==k?void 0:k.block)&&(0,n.jsx)(Y,{k:y("ow.block"),v:k.block})]})]}):(0,n.jsx)("p",{className:"muted small",style:{margin:0},children:y("ow.noUsage")})]}),U.length>0&&(0,n.jsxs)("section",{className:"ov-card",children:[(0,n.jsx)("div",{className:"eyebrow",children:y("ow.info")}),(0,n.jsx)("dl",{className:"ov-dl",children:U.map((e,s)=>{let[t,l]=e;return(0,n.jsx)(Y,{k:t,v:l},s)})})]})]}),"docker"===w.kind&&"compose"===w.config.mode&&(0,n.jsxs)("section",{className:"ov-card wide",children:[(0,n.jsxs)("div",{className:"eyebrow",children:[y("ow.d.services"),(null==k||null==(s=k.services)?void 0:s.length)?" \xb7 ".concat(null!=(b=H.running)?b:0,"/").concat(null!=(f=H.services)?f:0):""]}),null===k?(0,n.jsxs)("p",{className:"muted small ov-empty",children:[(0,n.jsx)(d.A,{size:14,className:"spin"})," ",y("ow.svc.loading")]}):k.services&&k.services.length>0?(0,n.jsx)(V,{objectId:w.id,services:k.services,onLogs:e=>N("".concat(e,"-")),onChanged:q}):(0,n.jsx)("p",{className:"muted small ov-empty",children:y(E?"ow.svc.none":"ow.svc.stopped")})]}),"cluster"===w.kind&&(0,n.jsxs)("section",{className:"ov-card wide",children:[(0,n.jsx)("div",{className:"eyebrow",children:y("cl.members")}),(0,n.jsx)(Q,{cluster:w})]}),(0,n.jsxs)("section",{className:"ov-card wide grow",children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("div",{className:"eyebrow grow",children:y("ow.recent")}),(0,n.jsx)("button",{className:"btn ghost sm",onClick:()=>N(),children:y("ow.seeLogs")})]}),(0,n.jsx)("pre",{className:"ov-log mono",children:null===R?y("git.loading"):I||y("obj.logs.empty")})]})]})}var es=t(97356),et=t(52974),en=t(9217);function el(e){let{object:s}=e,{t}=(0,x.s9)(),{refresh:a}=(0,j.o0)(),r=(0,p.dj)(),c=(0,B.useRouter)(),i=(0,l.useMemo)(()=>(0,en.QJ)(s),[s.updated_at,s.id]),{d:o,set:d,setD:h}=(0,en.Te)(()=>i),[m,b]=(0,l.useState)(""),[v,g]=(0,l.useState)(!1),[f,w]=(0,l.useState)(!1),[N,y]=(0,l.useState)(null);(0,l.useEffect)(()=>{"http"===s.kind&&u.FH.get("/objects/".concat(s.id,"/http")).then(y).catch(()=>void 0)},[s.id,s.kind]);let k=JSON.stringify(o)!==JSON.stringify(i),C="running"===s.state.status||"starting"===s.state.status,S="server"===s.kind||"docker"===s.kind||"cluster"===s.kind,A=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!o.name.trim())return void b(t("obj.err.name"));g(!0),b("");try{await u.FH.patch("/objects/".concat(s.id),{name:o.name.trim(),colony_id:o.colony_id||null,config:(0,en.qP)(o)}),o.manager!==i.manager&&et.G.includes(s.kind)&&await u.FH.put("/objects/".concat(s.id,"/manager"),{agent_id:o.manager||null}),await a(["objects","agents"]),e&&await u.FH.post("/objects/".concat(s.id,"/action"),{action:"restart"}).catch(e=>r(e instanceof Error?e.message:"","err")),r(t("obj.saved"))}catch(e){b(e instanceof Error?e.message:t("edit.saveFailed"))}finally{g(!1)}},E=async()=>{await u.FH.del("/objects/".concat(s.id)),await a(["objects"]),r(t("obj.deleted")),c.push("/resources")};return(0,n.jsxs)("div",{className:"oc",children:[(0,n.jsx)("div",{className:"oc-body",children:(0,n.jsx)("div",{className:"oc-form",children:(0,n.jsx)(en.Bh,{objectId:s.id,d:o,set:d,setD:h,scan:N,error:m})})}),(0,n.jsxs)("div",{className:"savebar oc-bar",children:[(0,n.jsxs)("span",{className:"muted small grow",children:[k?t("ow.cfg.dirty"):t("ow.cfg.saved"),k&&S?" \xb7 ".concat(C?t("ow.cfg.appliesRunning"):t("ow.cfg.applies")):""]}),(0,n.jsxs)("button",{className:"btn danger",onClick:()=>w(!0),children:[(0,n.jsx)(es.A,{size:15}),t("common.delete")]}),(0,n.jsx)("button",{className:"btn ghost",disabled:!k||v,onClick:()=>{h(()=>i),b("")},children:t("ow.cfg.discard")}),S&&C&&(0,n.jsx)("button",{className:"btn",disabled:!k||v,onClick:()=>void A(!0),children:t("ow.cfg.saveRestart")}),(0,n.jsx)("button",{className:"btn primary",disabled:!k||v,onClick:()=>void A(),children:t("ow.cfg.save")})]}),f&&(0,n.jsx)(p.TM,{title:t("obj.delete.title",{name:s.name}),confirmLabel:t("obj.delete"),danger:!0,onConfirm:E,onClose:()=>w(!1),body:"server"===s.kind?t("obj.delete.server"):"docker"===s.kind?t("obj.delete.".concat(s.config.mode)):t("obj.delete.".concat(s.kind))})]})}var ea=t(58311),er=t(15145),ec=t(45385),ei=t(23132),eo=t(17395),ed=t(64883),eh=t(494),em=t(98759),eu=t(98392);let ex=/\b(error|fatal|exception|panic|fail(ed|ure)?|traceback)\b/i,ej=/\b(warn(ing)?|deprecated)\b/i;function ep(e){let{id:s,members:t,initialFilter:a}=e,{t:r}=(0,x.s9)(),[c,i]=(0,l.useState)(!1),{text:o,dropped:d,clear:h}=z(s,{paused:c}),[u,j]=(0,l.useState)(null!=a?a:""),p=(0,l.useDeferredValue)(u),[b,v]=(0,l.useState)(!!a),[g,f]=(0,l.useState)(!0),[w,N]=(0,l.useState)(!0),[y,k]=(0,l.useState)(12.5),[C,S]=(0,l.useState)(new Set),A=(0,l.useRef)(null);(0,l.useEffect)(()=>{try{let e=Number(localStorage.getItem("hive-am.logsize"));e>=10&&e<=20&&k(e)}catch(e){}},[]);let E=e=>k(s=>{let t=Math.max(10,Math.min(20,s+e));try{localStorage.setItem("hive-am.logsize",String(t))}catch(e){}return t}),L=(0,l.useMemo)(()=>o?o.split("\n"):[],[o]),O=(0,l.useMemo)(()=>{let e=p.trim().toLowerCase(),s=[];for(let n=0;n<L.length;n++){let l=L[n],a=t?/^\[([^\]]+)\] /.exec(l):null;!(a&&C.has(a[1]))&&(!b||!e||l.toLowerCase().includes(e))&&s.push({line:l,idx:d+n,member:null==a?void 0:a[1]})}return s},[L,p,b,C,t,d]),q=O.length>2e3?O.slice(O.length-2e3):O,T=(0,l.useMemo)(()=>{let e=new Map;for(let s of q){let t=Math.floor(s.idx/50),n=e.get(t);n?n.push(s):e.set(t,[s])}return[...e]},[q]),R=(0,l.useMemo)(()=>{let e=p.trim().toLowerCase();return e?O.filter(s=>s.line.toLowerCase().includes(e)).length:0},[O,p]);return(0,l.useEffect)(()=>{let e=A.current;e&&g&&(e.scrollTop=e.scrollHeight)},[q,g]),(0,n.jsxs)("div",{className:"lp",children:[(0,n.jsxs)("div",{className:"lp-bar",children:[(0,n.jsxs)("div",{className:"search lp-search",children:[(0,n.jsx)(ea.A,{size:14}),(0,n.jsx)("input",{className:"input",placeholder:r("lp.search"),value:u,onChange:e=>j(e.target.value),"aria-label":r("lp.search")}),R>0&&(0,n.jsx)("span",{className:"lp-hits",children:r("lp.matches",{count:R})})]}),(0,n.jsxs)("label",{className:"row gap-s small",children:[(0,n.jsx)("input",{type:"checkbox",checked:b,onChange:e=>v(e.target.checked)}),r("lp.only")]}),(0,n.jsx)("span",{className:"grow"}),(0,n.jsx)("button",{className:"btn ghost icon sm ".concat(w?"on":""),"aria-pressed":w,onClick:()=>N(e=>!e),"aria-label":r("lp.wrap"),title:r("lp.wrap"),children:(0,n.jsx)(er.A,{size:15})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>E(-1),"aria-label":r("lp.smaller"),title:r("lp.smaller"),children:(0,n.jsx)(ec.A,{size:15})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>E(1),"aria-label":r("lp.larger"),title:r("lp.larger"),children:(0,n.jsx)(ei.A,{size:15})}),(0,n.jsx)("button",{className:"btn ghost icon sm ".concat(c?"on":""),"aria-pressed":c,onClick:()=>i(e=>!e),"aria-label":r(c?"lp.resume":"lp.pause"),title:r(c?"lp.resume":"lp.pause"),children:c?(0,n.jsx)(m.A,{size:15}):(0,n.jsx)(eo.A,{size:15})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:h,"aria-label":r("lp.clear"),title:r("lp.clear"),children:(0,n.jsx)(ed.A,{size:15})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>{var e;null==(e=navigator.clipboard)||e.writeText(L.join("\n"))},"aria-label":r("lp.copy"),title:r("lp.copy"),children:(0,n.jsx)(eh.A,{size:15})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>{let e=document.createElement("a");e.href=URL.createObjectURL(new Blob([L.join("\n")],{type:"text/plain"})),e.download="".concat(s.slice(0,8),"-").concat(new Date().toISOString().slice(0,19).replace(/[:T]/g,"-"),".log"),e.click(),setTimeout(()=>URL.revokeObjectURL(e.href),4e3)},"aria-label":r("lp.download"),title:r("lp.download"),children:(0,n.jsx)(em.A,{size:15})})]}),t&&t.length>0&&(0,n.jsx)("div",{className:"lp-chips",children:t.map((e,s)=>(0,n.jsx)("button",{className:"lp-chip ".concat(C.has(e)?"off":""),style:{"--c":F.hg[s%F.hg.length]},"aria-pressed":!C.has(e),onClick:()=>S(s=>{let t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t}),children:e},e))}),(0,n.jsx)("div",{className:"lp-body mono ".concat(w?"wrap":""),ref:A,onScroll:()=>{let e=A.current;if(!e)return;let s=e.scrollHeight-e.scrollTop-e.clientHeight<40;!s&&g?f(!1):s&&!g&&f(!0)},tabIndex:0,style:{fontSize:y},children:null===o?(0,n.jsx)("p",{className:"muted",children:r("git.loading")}):0===q.length?(0,n.jsx)("p",{className:"muted",children:r("obj.logs.empty")}):T.map(e=>{let[s,l]=e;return(0,n.jsx)(ev,{rows:l,members:t,needle:p.trim()},s)})}),(0,n.jsxs)("div",{className:"lp-foot muted small",children:[(0,n.jsxs)("span",{children:[r("lp.lines",{count:O.length}),O.length>2e3?" \xb7 ".concat(r("lp.shown",{count:2e3})):"",c?" \xb7 ".concat(r("lp.paused")):""]}),!g&&(0,n.jsxs)("button",{className:"btn sm",onClick:()=>{f(!0);let e=A.current;e&&(e.scrollTop=e.scrollHeight)},children:[(0,n.jsx)(eu.A,{size:14}),r("lp.follow")]})]})]})}function eb(e){let{line:s,member:t,mi:a,needle:r}=e,c=ex.test(s)?"err":ej.test(s)?"warn":"",i=t&&a>=0?s.slice(t.length+3):s,o=!1,d=[];if(r){let e=i.toLowerCase(),s=r.toLowerCase(),t=0,l=0;for(let a=e.indexOf(s);a>=0;a=e.indexOf(s,t))o=!0,d.push(i.slice(t,a),(0,n.jsx)("mark",{children:i.slice(a,a+r.length)},l++)),t=a+r.length;d.push(i.slice(t))}let h=r?d.map((e,s)=>(0,n.jsx)(l.Fragment,{children:e},s)):i;return(0,n.jsx)("div",{className:"lp-row ".concat(c," ").concat(o?"hit":""),style:a>=0?{"--c":F.hg[a%F.hg.length]}:void 0,children:t&&a>=0?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("b",{className:"lp-src",children:["[",t,"]"]}),h]}):h})}let ev=(0,l.memo)(function(e){let{rows:s,members:t,needle:l}=e;return(0,n.jsx)(n.Fragment,{children:s.map(e=>{var s;return(0,n.jsx)(eb,{line:e.line,member:e.member,mi:e.member&&null!=(s=null==t?void 0:t.indexOf(e.member))?s:-1,needle:l},e.idx)})})},(e,s)=>e.needle===s.needle&&e.members===s.members&&e.rows.length===s.rows.length&&e.rows.every((e,t)=>e.idx===s.rows[t].idx&&e.line===s.rows[t].line));var eg=t(20422);function ef(e){let{list:s,children:t,gap:l=!1,listWidth:a}=e;return(0,n.jsxs)("div",{className:"msd ".concat(l?"msd-gap":""),style:a?{"--msd-list":a}:void 0,children:[s,t]})}let ew=(e,s)=>u.FH.get("/objects/".concat(e,"/http/file?file=").concat(encodeURIComponent(s))).then(e=>e.content),eN=(e,s,t)=>u.FH.put("/objects/".concat(e,"/http/file"),{file:s,content:t});async function ey(e,s,t){await eN(e,s,t(await ew(e,s)))}function ek(e){let s=["### ".concat(e.name.trim()||"".concat(e.method," request")),"".concat(e.method," ").concat(e.url.trim()),...e.headers.filter(e=>e.name.trim()).map(e=>"".concat(e.name.trim(),": ").concat(e.value))];return e.body.trim()&&s.push("",e.body.replace(/\s+$/,"")),s.join("\n")}function eC(e,s){let t=s;for(;t<e.length&&/^\s+[?&]/.test(e[t]);)t++;let n=t;for(;t<e.length&&e[t].trim()&&!/^#{3,}/.test(e[t].trim());)t++;return{first:n,end:t}}function eS(e,s,t,n){let l=e.split("\n"),{first:a,end:r}=eC(l,s),c=l.slice(a,r).findIndex(e=>e.split(":")[0].trim().toLowerCase()===t.toLowerCase());return c>=0?null===n?l.splice(a+c,1):l[a+c]="".concat(t,": ").concat(n):null!==n&&l.splice(r,0,"".concat(t,": ").concat(n)),l.join("\n")}function eA(e,s,t){let n=e.split("\n"),{first:l,end:a}=eC(n,s),r=n.slice(l,a).find(e=>e.split(":")[0].trim().toLowerCase()===t.toLowerCase());return void 0===r?void 0:r.slice(r.indexOf(":")+1).trim()}let eE={status:["=","!=","2xx","<",">"],time:["<",">"],header:["exists","=","contains"],body:["exists","=","!=","contains",">","<"],text:["contains"]},ez="// hive-am:asserts ",eF=e=>/^-?\d+(\.\d+)?$/.test(e.trim())||/^(true|false|null)$/.test(e.trim())?e.trim():JSON.stringify(e);function eL(e,s){let t=s;for(;t<e.length&&!/^#{3,}/.test(e[t].trim());)t++;return{start:s-1,end:t}}let eO=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],eq="\0new";function eT(e){var s,t;let{objectId:a,files:r,defaultFile:c,onClose:i,onCreated:o}=e,{t:d}=(0,x.s9)(),[h,m]=(0,l.useState)("form"),[j,b]=(0,l.useState)(c&&r.some(e=>e.relFile===c)?c:null!=(t=null==(s=r[0])?void 0:s.relFile)?t:eq),[v,g]=(0,l.useState)("requests.http"),[f,w]=(0,l.useState)({name:"",method:"GET",url:"{{host}}/",headers:[],body:""}),[N,y]=(0,l.useState)(""),[k,C]=(0,l.useState)(""),[S,A]=(0,l.useState)(""),[E,z]=(0,l.useState)(!1),F=async()=>{if(!f.url.trim())return void A(d("hw2.new.needUrl"));z(!0),A("");try{let e={...f,headers:N.split("\n").map(e=>{let s=e.indexOf(":");return s>0?{name:e.slice(0,s).trim(),value:e.slice(s+1).trim()}:{name:"",value:""}}).filter(e=>e.name)};if(j===eq){let s,t=v.trim();await (s="".concat(ek(e),"\n"),u.FH.post("/objects/".concat(a,"/http/file"),{file:t,content:s})),o(t)}else await ey(a,j,s=>(function(e,s){let t=e.replace(/\s+$/,"");return"".concat(t).concat(t?"\n\n":"").concat(ek(s),"\n")})(s,e)),o(j)}catch(e){A(e instanceof Error?e.message:"error")}finally{z(!1)}};return(0,n.jsx)(p.aF,{title:d("hw2.new.title"),onClose:i,children:(0,n.jsxs)("div",{className:"stack",children:[(0,n.jsx)(p.$q,{value:h,onChange:m,options:[{id:"form",label:d("hw2.new.form")},{id:"curl",label:d("hw2.new.curl")}]}),"curl"===h?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(p.D0,{label:d("hw2.new.curl"),hint:d("hw2.new.curlHint"),children:(0,n.jsx)("textarea",{className:"input mono",rows:7,value:k,onChange:e=>C(e.target.value),placeholder:"curl -X POST 'https://…' -H 'Content-Type: application/json' -d '{…}'",autoFocus:!0})}),(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)("span",{className:"grow"}),(0,n.jsx)("button",{className:"btn primary",disabled:!k.trim(),onClick:()=>{try{let e=function(e){let s=function(e){let s=[],t="",n=!1,l=e.replace(/\\\r?\n/g," ").replace(/\^\r?\n/g," ");for(let e=0;e<l.length;e++){let r=l[e];if("'"===r){n=!0;let s=l.indexOf("'",e+1),a=s<0?l.length:s;t+=l.slice(e+1,a),e=a;continue}if('"'===r){for(n=!0,e++;e<l.length&&'"'!==l[e];e++)"\\"===l[e]&&e+1<l.length&&/["\\$`]/.test(l[e+1])&&e++,t+=l[e];continue}if("$"===r&&"'"===l[e+1]){for(n=!0,e+=2;e<l.length&&"'"!==l[e];e++)if("\\"===l[e]&&e+1<l.length){var a;t+=null!=(a=({n:"\n",t:" ",r:"\r","'":"'","\\":"\\"})[l[++e]])?a:l[e]}else t+=l[e];continue}if("\\"===r&&e+1<l.length){n=!0,t+=l[++e];continue}if(/\s/.test(r)){n&&(s.push(t),t="",n=!1);continue}n=!0,t+=r}return n&&s.push(t),s}(e.trim());"curl"===s[0]&&s.shift();let t="",n="",l,a=[],r=[],c="",i=!1,o=!1;for(let e=0;e<s.length;e++){let l=s[e],d=()=>{var t;return null!=(t=s[++e])?t:""},h=RegExp("^(--[\\w-]+)=(.*)$","s").exec(l),m=h?h[1]:l,u=()=>h?h[2]:d();if("-X"===m||"--request"===m)t=u().toUpperCase();else if("-H"===m||"--header"===m){let e=u(),s=e.indexOf(":");s>0&&a.push({name:e.slice(0,s).trim(),value:e.slice(s+1).trim()})}else["-d","--data","--data-raw","--data-binary","--data-ascii","--data-urlencode"].includes(m)?r.push(u()):"-u"===m||"--user"===m?c=u():"-b"===m||"--cookie"===m?a.push({name:"Cookie",value:u()}):"-A"===m||"--user-agent"===m?a.push({name:"User-Agent",value:u()}):"-e"===m||"--referer"===m?a.push({name:"Referer",value:u()}):"--url"===m?n=u():"-F"===m||"--form"===m?(i=!0,r.push(u())):"-G"===m||"--get"===m?o=!0:"-I"===m||"--head"===m?t="HEAD":["-o","--output","-m","--max-time","--connect-timeout","-w","--write-out","--proxy","-x","--cacert","--cert","--key","-E"].includes(m)?h||d():l.startsWith("-")||n||(n=l)}if(!n)throw Error("No URL found in the command");if(r.length&&(l=r.join("&")),c&&a.push({name:"Authorization",value:"Basic ".concat(c.replace(":"," "))}),o&&l&&(n+=(n.includes("?")?"&":"?")+l,l=void 0),t||(t=void 0===l||i?"GET":"POST"),i)throw Error("multipart forms (-F) are not supported yet");let d="";try{let e=new URL(n);d="".concat(t," ").concat(e.pathname)}catch(e){d="".concat(t," request")}return void 0===l||a.some(e=>"content-type"===e.name.toLowerCase())||a.push({name:"Content-Type",value:/^\s*[[{]/.test(l)?"application/json":"application/x-www-form-urlencoded"}),{name:d,method:t,url:n,headers:a,body:null!=l?l:""}}(k);w(e),y(e.headers.map(e=>"".concat(e.name,": ").concat(e.value)).join("\n")),m("form"),A("")}catch(e){A(e instanceof Error?e.message:"error")}},children:d("hw2.new.parse")})]})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(p.D0,{label:d("hw2.new.file"),children:(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsxs)("select",{className:"select",value:j,onChange:e=>b(e.target.value),style:{flex:1},children:[r.map(e=>(0,n.jsx)("option",{value:e.relFile,children:e.relFile},e.relFile)),(0,n.jsx)("option",{value:eq,children:d("hw2.new.newFile")})]}),j===eq&&(0,n.jsx)("input",{className:"input mono",value:v,onChange:e=>g(e.target.value),"aria-label":d("hw2.new.file"),style:{flex:1}})]})}),(0,n.jsx)(p.D0,{label:d("obj.f.name"),children:(0,n.jsx)("input",{className:"input",value:f.name,onChange:e=>w({...f,name:e.target.value}),placeholder:"login",autoFocus:!0})}),(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)("select",{className:"select",style:{width:120},value:f.method,onChange:e=>w({...f,method:e.target.value}),"aria-label":"Method",children:eO.map(e=>(0,n.jsx)("option",{children:e},e))}),(0,n.jsx)("input",{className:"input mono",style:{flex:1},value:f.url,onChange:e=>w({...f,url:e.target.value}),placeholder:"{{host}}/path","aria-label":"URL"})]}),(0,n.jsx)(p.D0,{label:d("http.headers"),hint:d("hw2.new.headersHint"),children:(0,n.jsx)("textarea",{className:"input mono",rows:3,value:N,onChange:e=>y(e.target.value),placeholder:"Content-Type: application/json"})}),(0,n.jsx)(p.D0,{label:d("http.requestBody"),children:(0,n.jsx)("textarea",{className:"input mono",rows:4,value:f.body,onChange:e=>w({...f,body:e.target.value})})}),(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)("button",{className:"btn ghost",onClick:()=>m("curl"),children:d("hw2.new.curl")}),(0,n.jsx)("span",{className:"grow"}),(0,n.jsx)("button",{className:"btn",onClick:i,children:d("hw2.cancel")}),(0,n.jsx)("button",{className:"btn primary",disabled:E,onClick:()=>void F(),children:d("hw2.new.add")})]})]}),S&&(0,n.jsx)("p",{className:"gx-note err",style:{margin:0},children:S})]})})}var eR=t(37870),eI=t(42366);function eH(e){let{objectId:s,file:t,env:r,onClose:c,onDone:i}=e,{t:o}=(0,x.s9)(),[d,h]=(0,l.useState)(""),[j,b]=(0,l.useState)(!1),[v,g]=(0,l.useState)(""),[f,w]=(0,l.useState)([]),[N,y]=(0,l.useState)(!1),k=(0,l.useRef)(!1),C=null,S="";if(d.trim())try{(C=function(e){var s,t,n,l;let a=e.trim();if(!a)throw Error("No data");if(a.startsWith("[")||a.startsWith("{")){let e=JSON.parse(a),s=Array.isArray(e)?e:[e];if(!s.every(e=>e&&"object"==typeof e&&!Array.isArray(e)))throw Error("A JSON array of objects is expected");let t=[...new Set(s.flatMap(e=>Object.keys(e)))];return{columns:t,rows:s.map(e=>Object.fromEntries(t.map(s=>[s,void 0===e[s]||null===e[s]?"":"object"==typeof e[s]?JSON.stringify(e[s]):String(e[s])])))}}let r=a.split(/\r?\n/,1)[0],c=(null!=(n=null==(s=r.match(/;/g))?void 0:s.length)?n:0)>(null!=(l=null==(t=r.match(/,/g))?void 0:t.length)?l:0)?";":r.includes(" ")&&!r.includes(",")?" ":",",i=[],o=[],d="",h=!1;for(let e=0;e<a.length;e++){let s=a[e];if(h){'"'===s?'"'===a[e+1]?(d+='"',e++):h=!1:d+=s;continue}'"'===s?h=!0:s===c?(o.push(d),d=""):"\n"===s||"\r"===s?("\r"===s&&"\n"===a[e+1]&&e++,o.push(d),d="",o.some(e=>""!==e)&&i.push(o),o=[]):d+=s}o.push(d),o.some(e=>""!==e)&&i.push(o);let m=i[0].map(e=>e.trim());if(m.some(e=>!/^[A-Za-z_][\w.-]{0,80}$/.test(e)))throw Error("The first line must be the variable names (letters, numbers, _ . -)");return{columns:m,rows:i.slice(1).map(e=>Object.fromEntries(m.map((s,t)=>{var n;return[s,null!=(n=e[t])?n:""]})))}}(d)).rows.length>200&&(S=o("hw2.batch.tooMany",{max:200}),C=null)}catch(e){S=e instanceof Error?e.message:"error"}let A=async()=>{if(!C)return;g(""),w([]),y(!0),k.current=!1;let e=C.columns,n=[];try{for(let l of C.rows){if(k.current)break;for(let t of e)await u.FH.post("/objects/".concat(s,"/http/session"),{name:t,value:l[t]});let a=[],c=!1;for(let e of t.requests){if(k.current||c&&j){a.push({ok:!1,tests:"",error:o("hw2.batch.skipped")});continue}try{let n=await u.FH.post("/objects/".concat(s,"/http/run"),{file:t.relFile,index:e.index,env:r||void 0}),l=n.tests.filter(e=>!e.passed).length+ +!!n.scriptError,i=n.status<400&&0===l;i||(c=!0),a.push({status:n.status,ok:i,tests:n.tests.length?"".concat(n.tests.length-n.tests.filter(e=>!e.passed).length,"/").concat(n.tests.length):""})}catch(e){c=!0,a.push({ok:!1,tests:"",error:e instanceof Error?e.message:"error"})}}n.push(a),w([...n])}}catch(e){g(e instanceof Error?e.message:"error")}finally{for(let t of e)await u.FH.del("/objects/".concat(s,"/http/session?name=").concat(encodeURIComponent(t))).catch(()=>void 0);y(!1),i()}},E=f.filter(e=>e.every(e=>e.ok)).length;return(0,n.jsx)(p.aF,{title:o("hw2.batch.title",{file:t.relFile}),onClose:()=>{k.current=!0,c()},children:(0,n.jsxs)("div",{className:"stack",children:[(0,n.jsxs)("div",{className:"field",children:[(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)("label",{className:"label",htmlFor:"batch-data",children:o("hw2.batch.data")}),(0,n.jsx)(eI.B,{size:"sm",label:o("common.help"),title:o("hw2.help.how"),children:o("hw2.batch.hint")})]}),(0,n.jsx)("textarea",{id:"batch-data",className:"input mono",rows:6,value:d,onChange:e=>h(e.target.value),placeholder:"user,passwd\nana,s3cret\nluis,otra",spellCheck:!1,disabled:N}),(0,n.jsx)("span",{className:"muted small",children:o("hw2.batch.format")})]}),(0,n.jsxs)("div",{className:"row gap-s wrap",children:[(0,n.jsxs)("label",{className:"btn sm",children:[(0,n.jsx)(eR.A,{size:14}),o("hw2.batch.file"),(0,n.jsx)("input",{type:"file",accept:".csv,.json,.txt,text/csv,application/json",hidden:!0,onChange:e=>{var s,t;(t=null==(s=e.target.files)?void 0:s[0])&&t.text().then(h)}})]}),(0,n.jsx)(p.Tl,{checked:j,onChange:b,label:o("hw2.batch.stopRow")}),(0,n.jsx)("span",{className:"grow"}),C&&(0,n.jsx)("span",{className:"muted small",children:o("hw2.batch.rows",{rows:C.rows.length,cols:C.columns.join(", ")})}),N?(0,n.jsxs)("button",{className:"btn",onClick:()=>{k.current=!0},children:[(0,n.jsx)(a.A,{size:14}),o("hw2.batch.stop")]}):(0,n.jsxs)("button",{className:"btn primary",disabled:!C||!C.rows.length,onClick:()=>void A(),children:[(0,n.jsx)(m.A,{size:14}),o("hw2.batch.run")]})]}),S&&(0,n.jsx)("p",{className:"gx-note err",style:{margin:0},children:S}),v&&(0,n.jsx)("p",{className:"gx-note err",style:{margin:0},children:v}),f.length>0&&C&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("p",{className:"small",style:{margin:0},children:[(0,n.jsx)("b",{children:o("hw2.batch.summary",{ok:E,total:f.length})}),N?" …":""]}),(0,n.jsx)("div",{style:{overflow:"auto",maxHeight:280},children:(0,n.jsxs)("table",{className:"cm-table",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:"#"}),C.columns.slice(0,2).map(e=>(0,n.jsx)("th",{children:e},e)),t.requests.map(e=>(0,n.jsx)("th",{title:e.name,children:e.name.slice(0,18)},e.id))]})}),(0,n.jsx)("tbody",{children:f.map((e,s)=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{children:s+1}),C.columns.slice(0,2).map(e=>(0,n.jsx)("td",{className:"mono small",children:C.rows[s][e]},e)),e.map((e,s)=>{var t;return(0,n.jsx)("td",{title:null!=(t=e.error)?t:"",children:(0,n.jsxs)("span",{className:"hr-st ".concat(e.ok?"ok":"err"),children:[e.error?"—":e.status,e.tests?" \xb7 ".concat(e.tests):""]})},s)})]},s))})]})})]})]})})}let eD=e=>{try{return JSON.parse(e)}catch(e){return}},eM="default",eU=e=>"GET"===e?"get":"POST"===e?"post":"DELETE"===e?"del":"PUT"===e||"PATCH"===e?"put":"other",eB=e=>e>=200&&e<300?"ok":e>=300&&e<400?"warn":"err",e$=e=>e?e.run?(e=>!!(null==e?void 0:e.run)&&(e.run.tests.some(e=>!e.passed)||!!e.run.scriptError))(e)?"err":eB(e.run.status):"err":"";function eW(e){if(/json/i.test(e.contentType)||/^\s*[[{]/.test(e.body))try{return JSON.stringify(JSON.parse(e.body),null,2)}catch(e){}return e.body}var eJ=t(72705);function eP(e){let{value:s,refBase:t}=e;return(0,n.jsx)("div",{className:"jt mono",children:(0,n.jsx)(e_,{k:null,v:s,path:"$",refBase:t,depth:0})})}function e_(e){let{k:s,v:t,path:a,refBase:r,depth:c}=e,{t:i}=(0,x.s9)(),o=null!==t&&"object"==typeof t,[d,h]=(0,l.useState)(c<2),[m,u]=(0,l.useState)(!1),j=null===s?null:(0,n.jsxs)("span",{className:"jt-k",children:["number"==typeof s?s:JSON.stringify(s),(0,n.jsx)("i",{children:": "})]}),p=(0,n.jsx)("button",{type:"button",className:"jt-copy",onClick:()=>{var e;let s=r?"{{".concat(r,".").concat(a,"}}"):"string"==typeof t?t:JSON.stringify(t);null==(e=navigator.clipboard)||e.writeText(s),u(!0),setTimeout(()=>u(!1),1200)},title:i(r?"hw2.copyRef":"iv.copy"),"aria-label":i(r?"hw2.copyRef":"iv.copy"),children:m?i("hw2.copied"):(0,n.jsx)(eh.A,{size:11})});if(!o){let e="string"==typeof t?"jt-s":"number"==typeof t?"jt-n":"jt-b";return(0,n.jsxs)("div",{className:"jt-row",children:[j,(0,n.jsx)("span",{className:e,children:"string"==typeof t?JSON.stringify(t.length>160?"".concat(t.slice(0,160),"…"):t):String(t)}),p]})}let b=Array.isArray(t)?t.map((e,s)=>[s,e]):Object.entries(t),v=Array.isArray(t);return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"jt-row",children:[(0,n.jsx)("button",{type:"button",className:"jt-fold",onClick:()=>h(e=>!e),"aria-expanded":d,children:d?(0,n.jsx)(R.A,{size:12}):(0,n.jsx)(I.A,{size:12})}),j,(0,n.jsx)("span",{className:"jt-p",children:v?"[":"{"}),!d&&(0,n.jsxs)("span",{className:"muted",children:[" ",b.length," ","…"," "]}),!d&&(0,n.jsx)("span",{className:"jt-p",children:v?"]":"}"}),p]}),d&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"jt-kids",children:b.map(e=>{let[s,t]=e;return(0,n.jsx)(e_,{k:s,v:t,path:v?"".concat(a,"[").concat(s,"]"):/^[A-Za-z_]\w*$/.test(String(s))?"".concat(a,".").concat(s):"".concat(a,'["').concat(s,'"]'),refBase:r,depth:c+1},String(s))})}),(0,n.jsx)("div",{className:"jt-row",children:(0,n.jsx)("span",{className:"jt-p",children:v?"]":"}"})})]})]})}let eK=e=>{var s,t;let n=null!=(t=null==(s=e.run)?void 0:s.body)?t:"";try{return JSON.stringify(JSON.parse(n),null,2)}catch(e){return n}};function eG(e){var s,t,a,r;let{before:c,after:i}=e,{t:o}=(0,x.s9)(),d=(0,l.useMemo)(()=>(function(e,s){if(e.length*s.length>4e6)return[...e.map(e=>({t:"-",s:e})),...s.map(e=>({t:"+",s:e}))];let t=e.length,n=s.length,l=Array.from({length:t+1},()=>new Uint32Array(n+1));for(let a=t-1;a>=0;a--)for(let t=n-1;t>=0;t--)l[a][t]=e[a]===s[t]?l[a+1][t+1]+1:Math.max(l[a+1][t],l[a][t+1]);let a=[],r=0,c=0;for(;r<t&&c<n;)e[r]===s[c]?(a.push({t:" ",s:e[r]}),r++,c++):l[r+1][c]>=l[r][c+1]?a.push({t:"-",s:e[r++]}):a.push({t:"+",s:s[c++]});for(;r<t;)a.push({t:"-",s:e[r++]});for(;c<n;)a.push({t:"+",s:s[c++]});return a})(eK(c).split("\n"),eK(i).split("\n")),[c,i]),h=Object.fromEntries((null!=(a=null==(s=c.run)?void 0:s.headers)?a:[]).map(e=>[e.name.toLowerCase(),e.value])),m=Object.fromEntries((null!=(r=null==(t=i.run)?void 0:t.headers)?r:[]).map(e=>[e.name.toLowerCase(),e.value])),u=/^(date|age|etag|x-request-id|x-correlation-id|set-cookie|server-timing|content-length)$/,j=[...new Set([...Object.keys(h),...Object.keys(m)])].filter(e=>h[e]!==m[e]&&!u.test(e)),p=d.filter(e=>" "!==e.t).length,b=[],v=[],g=()=>{v.length>8?b.push(...v.slice(0,3),{fold:v.length-6},...v.slice(-3)):b.push(...v),v=[]};for(let e of d)" "===e.t?v.push(e):(g(),b.push(e));g();let f=e=>e.run?"".concat(e.run.status," \xb7 ").concat(e.run.durationMs," ms \xb7 ").concat((0,L.zi)(e.run.size)):o("hw2.diff.error");return(0,n.jsxs)("div",{className:"rd",children:[(0,n.jsxs)("div",{className:"rd-head",children:[(0,n.jsxs)("div",{children:[(0,n.jsxs)("span",{className:"muted small",children:[o("hw2.diff.before")," \xb7 ",(0,L.Xd)(c.at)]}),(0,n.jsx)("div",{className:"mono",children:f(c)})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("span",{className:"muted small",children:[o("hw2.diff.after")," \xb7 ",(0,L.Xd)(i.at)]}),(0,n.jsx)("div",{className:"mono",children:f(i)})]})]}),j.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"eyebrow",children:o("http.headers")}),(0,n.jsx)("div",{className:"rd-hdrs mono small",children:j.map(e=>(0,n.jsxs)("div",{children:[(0,n.jsx)("b",{children:e}),": ",void 0!==h[e]&&(0,n.jsx)("span",{className:"rd-del",children:h[e]})," ",void 0!==m[e]&&(0,n.jsx)("span",{className:"rd-add",children:m[e]})]},e))})]}),(0,n.jsxs)("div",{className:"eyebrow",style:{marginTop:10},children:[o("hw2.diff.body")," \xb7 ",0===p?o("hw2.diff.same"):o("hw2.diff.lines",{count:p})]}),(0,n.jsx)("div",{className:"rd-body mono",children:b.map((e,s)=>"fold"in e?(0,n.jsx)("div",{className:"rd-fold",children:o("hw2.diff.fold",{count:e.fold})},s):(0,n.jsxs)("div",{className:"rd-l ".concat("+"===e.t?"add":"-"===e.t?"del":""),children:[(0,n.jsx)("span",{children:e.t}),e.s||"\xa0"]},s))})]})}function eX(e){let{ws:s}=e,{t}=(0,x.s9)(),{kept:l,adding:a,setAdding:r,newName:c,setNewName:i,newValue:o,setNewValue:d,setValue:h,forget:m,setConfirm:u}=s;return(0,n.jsxs)("div",{className:"hw-session-body hw-session-pad",children:[(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)("b",{children:t("hw.session")}),(0,n.jsx)(eI.B,{size:"sm",label:t("common.help"),title:t("hw2.help.how"),children:t("hw.session.hint")})]}),0===l.length&&!a&&(0,n.jsx)("p",{className:"muted small res-m0",children:t("hw.session.empty")}),l.map(e=>{let[s,l]=e;return(0,n.jsxs)("div",{className:"hw-kv",children:[(0,n.jsx)("code",{className:"mono",title:s,children:s}),(0,n.jsx)("span",{className:"mono val",title:l,children:l}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>void m(s),"aria-label":t("hw.session.forget"),title:t("hw.session.forget"),children:(0,n.jsx)(M.A,{size:13})})]},s)}),a?(0,n.jsxs)("div",{className:"hw-kv-add",children:[(0,n.jsx)("input",{className:"input mono",placeholder:t("hw.session.name"),value:c,onChange:e=>i(e.target.value),"aria-label":t("hw.session.name")}),(0,n.jsx)("input",{className:"input mono",placeholder:t("hw.session.value"),value:o,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"===e.key&&h()},"aria-label":t("hw.session.value")}),(0,n.jsx)("button",{className:"btn primary icon sm",onClick:h,"aria-label":t("hw.session.add"),children:(0,n.jsx)(eJ.A,{size:14})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>r(!1),"aria-label":t("common.cancel"),children:(0,n.jsx)(M.A,{size:14})})]}):(0,n.jsxs)("div",{className:"row gap-s mt-s",children:[(0,n.jsxs)("button",{className:"btn sm",onClick:()=>r(!0),children:[(0,n.jsx)(k.A,{size:13}),t("hw.session.add")]}),l.length>0&&(0,n.jsxs)("button",{className:"btn ghost sm",onClick:()=>u("session"),children:[(0,n.jsx)(es.A,{size:13}),t("hw.session.clear")]})]})]})}function eV(e){let{ws:s}=e,{t}=(0,x.s9)(),{o:l,confirm:a,setConfirm:r,setHist:c,setHistSel:i,setSession:o}=s;return a&&(0,n.jsx)(p.TM,{title:t("history"===a?"hw2.history.clear":"hw.session.clear"),confirmLabel:t("history"===a?"hw2.history.clear":"hw.session.clear"),danger:!0,body:t("history"===a?"rs.confirm.history":"rs.confirm.session"),onClose:()=>r(null),onConfirm:()=>"history"===a?u.FH.del("/objects/".concat(l.id,"/http/history")).then(()=>{c([]),i(null)}):u.FH.del("/objects/".concat(l.id,"/http/session")).then(o)})}function eZ(e){var s,t,l,a;let{ws:r,scan:c,onGoRequests:i}=e,{t:o}=(0,x.s9)(),{hist:d,histSel:h,setHistSel:m,cmp:u,setCmp:j,setConfirm:p,setFile:b,setSel:v,setTab:g}=r,f=null!=(l=d.find(e=>e.n===h))?l:null,w=(null==f?void 0:f.run)?eD(f.run.body):void 0,N=e=>{var s;return null==(s=c.files.find(s=>s.relFile===e.file))?void 0:s.requests[e.index]},y=f?d.find(e=>e.n<f.n&&e.file===f.file&&e.index===f.index&&e.run):void 0,k="prev"===u?y:"number"==typeof u?d.find(e=>e.n===u):void 0;return(0,n.jsxs)(ef,{list:(0,n.jsxs)("aside",{className:"hw-list",children:[(0,n.jsxs)("div",{className:"hw-env",children:[(0,n.jsx)("b",{className:"grow",children:o("hw2.history")}),d.length>0&&(0,n.jsxs)("button",{className:"btn ghost sm",onClick:()=>p("history"),children:[(0,n.jsx)(es.A,{size:13}),o("hw2.history.clear")]})]}),(0,n.jsxs)("div",{className:"hr-reqs",children:[0===d.length&&(0,n.jsx)("p",{className:"gx-note",children:o("hw2.history.empty")}),d.map(e=>(0,n.jsxs)("button",{className:"hr-req ".concat(h===e.n?"sel":""),onClick:()=>{m(e.n),j(null)},children:[(0,n.jsx)("span",{className:"hr-m ".concat(eU(e.method||"GET")),children:e.method||"?"}),(0,n.jsx)("span",{className:"nm",children:e.name}),(0,n.jsx)("span",{className:"muted small",children:(0,L.v7)(e.at)}),(0,n.jsx)("i",{className:"hr-dot ".concat(e.run?e.run.tests.some(e=>!e.passed)||e.run.scriptError?"err":eB(e.run.status):"err"),title:e.run?String(e.run.status):e.error})]},e.n))]})]}),children:[(0,n.jsxs)("section",{className:"hr-detail hw-scroll",children:[f&&(0,n.jsxs)("div",{className:"hr-pre",children:[(0,n.jsxs)("div",{className:"row gap-s wrap res-mb",children:[(0,n.jsx)("span",{className:"hr-m ".concat(eU(f.method||"GET")),children:f.method}),(0,n.jsx)("code",{className:"mono grow hw-wrap",children:null!=(a=null==(s=f.run)?void 0:s.request.url)?a:f.name}),f.run&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("b",{className:"hr-st ".concat(eB(f.run.status)),children:[f.run.status," ",f.run.statusText]}),(0,n.jsxs)("span",{className:"muted small",children:[o("http.time",{ms:f.run.durationMs})," \xb7 ",(0,L.zi)(f.run.size)]})]}),N(f)&&(0,n.jsx)("button",{className:"btn sm",onClick:()=>{b(f.file),v(N(f)),g("body"),null==i||i()},children:o("hw2.history.open")})]}),(0,n.jsxs)("div",{className:"row gap-s wrap small res-mb",children:[(0,n.jsxs)("span",{className:"muted",children:[f.file,f.env?" \xb7 ".concat(f.env):""]}),(0,n.jsx)("span",{className:"grow"}),(0,n.jsxs)("select",{className:"select hw-cmp",value:String(null!=u?u:""),onChange:e=>j(""===e.target.value?null:"prev"===e.target.value?"prev":Number(e.target.value)),"aria-label":o("hw2.diff.with"),children:[(0,n.jsx)("option",{value:"",children:o("hw2.diff.with")}),(0,n.jsx)("option",{value:"prev",disabled:!y,children:o("hw2.diff.prev")}),d.filter(e=>e.n!==f.n&&e.run).map(e=>(0,n.jsxs)("option",{value:e.n,children:[e.name," \xb7 ",(0,L.Xd)(e.at)," \xb7 ",e.run.status]},e.n))]})]}),"prev"===u&&!y&&(0,n.jsx)("p",{className:"muted small",children:o("hw2.diff.noPrev")}),k&&f.run&&k.run?k.at<=f.at?(0,n.jsx)(eG,{before:k,after:f}):(0,n.jsx)(eG,{before:f,after:k}):(0,n.jsxs)(n.Fragment,{children:[f.error&&(0,n.jsx)("div",{className:"gx-banner err hw-pre",children:f.error}),f.run&&f.run.tests.map((e,s)=>(0,n.jsxs)("div",{className:"hw-test ".concat(e.passed?"ok":"err"),children:[e.passed?(0,n.jsx)(eJ.A,{size:14}):(0,n.jsx)(M.A,{size:14}),(0,n.jsx)("b",{children:e.name}),e.message&&(0,n.jsxs)("span",{className:"muted",children:[": ",e.message]})]},s)),f.run&&!f.run.binary&&f.run.body&&(void 0!==w?(0,n.jsx)(eP,{value:w,refBase:(null==(t=N(f))?void 0:t.named)?"".concat(N(f).named,".response.body"):void 0}):(0,n.jsx)("pre",{children:eW(f.run)}))]})]}),(0,n.jsx)(eX,{ws:r})]}),(0,n.jsx)(eV,{ws:r})]})}var eQ=t(89075),eY=t(25661),e0=t(55267),e1=t(75063);function e2(e){let{ws:s,scan:t,onOpenVars:l}=e,{t:a}=(0,x.s9)(),{env:r,setEnv:c,q:i,setQ:o,file:d,setFile:h,sel:m,setSel:u,open:j,setOpen:b,results:v,busy:g,setTab:f,setCreating:w,load:N,loadSession:y,files:C,summary:S,runFile:A}=s;return(0,n.jsxs)("aside",{className:"hw-list",children:[(0,n.jsxs)("div",{className:"hw-env",children:[(0,n.jsxs)("label",{className:"row gap-s small grow",children:[(0,n.jsx)("span",{className:"muted",children:a("http.env")}),(0,n.jsxs)("select",{className:"select hw-envsel",value:r,onChange:e=>c(e.target.value),children:[(0,n.jsx)("option",{value:"",children:a("http.noEnv")}),t.environments.map(e=>(0,n.jsx)("option",{value:e,children:e},e))]})]}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>w(!0),"aria-label":a("hw2.new.title"),title:a("hw2.new.title"),children:(0,n.jsx)(k.A,{size:15})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>{N(),y()},"aria-label":a("http.rescan"),title:a("http.rescan"),children:(0,n.jsx)(eQ.A,{size:15})})]}),0===t.envFiles.length&&0===t.environments.length&&(0,n.jsxs)("p",{className:"muted small hw-hint",children:[a("hw.noEnvFile")," ",(0,n.jsx)("button",{className:"btn sm",onClick:l,children:a("hw.editVars")})]}),(0,n.jsx)("div",{className:"gx-filter",children:(0,n.jsx)(p.DO,{value:i,onChange:o,placeholder:a("http.search"),label:a("http.search")})}),(0,n.jsxs)("div",{className:"hr-reqs",children:[0===C.length&&(0,n.jsx)("p",{className:"gx-note",children:t.files.length?a("ow.noMatch",{query:i}):a("http.empty")}),C.map(e=>{var s;let t=j.has(e.relFile)||!!i;return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"hw-file ".concat(d!==e.relFile||m?"":"sel"),children:[(0,n.jsxs)("button",{className:"hw-fbtn",onClick:()=>{h(e.relFile),u(null),b(s=>{let t=new Set(s);return t.has(e.relFile)?t.delete(e.relFile):t.add(e.relFile),t})},children:[t?(0,n.jsx)(R.A,{size:14}):(0,n.jsx)(I.A,{size:14}),(0,n.jsx)(eY.A,{size:14,className:"muted"}),(0,n.jsx)("span",{className:"mono nm",title:e.relFile,children:e.relFile}),(0,n.jsx)("span",{className:"muted small",children:null!=(s=S(e))?s:e.requests.length})]}),(0,n.jsx)("button",{className:"btn ghost icon sm",disabled:!!g,onClick:()=>void A(e),"aria-label":a("http.runFile"),title:a("http.runFile"),children:(0,n.jsx)(e0.A,{size:15})})]}),t&&e.requests.map(s=>{let t=v[s.id],l=e$(t);return(0,n.jsxs)("button",{className:"hr-req hr-req-sub ".concat((null==m?void 0:m.id)===s.id?"sel":""),onClick:()=>{h(e.relFile),u(s),f("body")},children:[(0,n.jsx)("span",{className:"hr-m ".concat(eU(s.method)),children:s.method}),(0,n.jsx)("span",{className:"nm",children:s.name}),s.script&&(0,n.jsx)(e1.A,{size:12,className:"muted","aria-label":a("hw.script")}),g===s.id?(0,n.jsx)("span",{className:"muted small",children:"…"}):l?(0,n.jsx)("i",{className:"hr-dot ".concat(l),title:(null==t?void 0:t.run)?"".concat(t.run.status).concat(t.run.tests.length?" \xb7 ".concat(a("hw.tests.count",{ok:t.run.tests.filter(e=>e.passed).length,total:t.run.tests.length})):""):null==t?void 0:t.error}):null]},s.id)})]},e.relFile)}),t.truncated&&(0,n.jsx)("p",{className:"gx-note",children:a("http.truncatedFiles")})]})]})}var e4=t(48180);let e3=[{key:"tools",formats:[["curl","cURL"],["wget","wget"],["httpie","HTTPie"],["powershell","PowerShell"]]},{key:"langs",formats:[["fetch","JavaScript (fetch)"],["axios","Node (axios)"],["python","Python (requests)"],["go","Go"],["php","PHP (cURL)"],["java","Java (HttpClient)"],["csharp","C# (HttpClient)"],["ruby","Ruby (net/http)"],["rust","Rust (reqwest)"]]},{key:"raw",formats:[["http","HTTP"]]}];function e9(e){let{objectId:s,file:t,index:a,env:r}=e,{t:c}=(0,x.s9)(),[i,o]=(0,l.useState)(!1),[d,h]=(0,l.useState)(null),[m,j]=(0,l.useState)(""),p=async e=>{j("");try{let n=await u.FH.get("/objects/".concat(s,"/http/export?file=").concat(encodeURIComponent(t),"&index=").concat(a,"&format=").concat(e).concat(r?"&env=".concat(encodeURIComponent(r)):"").concat(i?"&redact=1":""));await navigator.clipboard.writeText(n.text),h(e),setTimeout(()=>h(null),1500),n.unresolved.length&&j(c("hw2.copyAs.unresolved",{names:n.unresolved.map(e=>"{{".concat(e,"}}")).join(", ")}))}catch(e){j(e instanceof Error?e.message:"error")}};return(0,n.jsx)(U.W1,{label:c("hw2.copyAs"),icon:(0,n.jsx)(eh.A,{size:14}),children:()=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(U.iz,{checked:i,onChange:o,hint:c("hw2.copyAs.redact.hint"),children:c("hw2.copyAs.redact")}),(0,n.jsx)(U.MU,{}),e3.map(e=>(0,n.jsx)(U.rX,{label:c("hw2.copyAs.g.".concat(e.key)),children:e.formats.map(e=>{let[s,t]=e;return(0,n.jsx)(U.Dr,{icon:d===s?(0,n.jsx)(eJ.A,{size:15}):void 0,onClick:()=>void p(s),children:t},s)})},e.key)),m&&(0,n.jsx)("p",{className:"muted small menu-note",children:m})]})})}function e5(e){let{text:s}=e;return(0,n.jsx)(n.Fragment,{children:s.split(/(\{\{[^}]+\}\})/g).map((e,s)=>e.startsWith("{{")?(0,n.jsx)("span",{className:"hr-var",children:e},s):e)})}var e6=t(10969);let e7=e=>Array.isArray(e)?e:e&&"object"==typeof e?Object.values(e):[],e8=(e,s,t)=>"=="===s?e===t||String(e)===String(t):"!="===s?e!==t&&String(e)!==String(t):">"===s?Number(e)>Number(t):"<"===s?Number(e)<Number(t):">="===s?Number(e)>=Number(t):Number(e)<=Number(t);var se=t(66654);let ss={session:"sess",file:"file",envfile:"env",hive:"hive",response:"resp",dynamic:"dyn",missing:"miss"};function st(e,s,t){let n="$shared"===t?e("iv.shared"):t;return e("iv.source.".concat(s),{from:"envfile"===s||"hive"===s?n:t})}function sn(e){let{vars:s,onSet:t,onForget:a,onRun:r,compact:c=!1}=e,{t:i}=(0,x.s9)(),[o,d]=(0,l.useState)(""),[h,m]=(0,l.useState)(!1),[u,j]=(0,l.useState)({}),[p,b]=(0,l.useState)(null),[v,g]=(0,l.useState)(""),f=(0,l.useMemo)(()=>s.filter(e=>{var s;return(!h||"missing"===e.source)&&(!o||e.name.toLowerCase().includes(o.toLowerCase())||(null!=(s=e.value)?s:"").toLowerCase().includes(o.toLowerCase()))}),[s,o,h]),w=s.filter(e=>"missing"===e.source).length,N=()=>{p&&(null==t||t(p,v)),b(null)};return(0,n.jsxs)("div",{className:"ivt",children:[!c&&(0,n.jsxs)("div",{className:"ivt-bar",children:[(0,n.jsxs)("div",{className:"search",children:[(0,n.jsx)(ea.A,{size:14}),(0,n.jsx)("input",{className:"input",placeholder:i("iv.filter"),value:o,onChange:e=>d(e.target.value),"aria-label":i("iv.filter")})]}),w>0&&(0,n.jsxs)("label",{className:"row gap-s small",children:[(0,n.jsx)("input",{type:"checkbox",checked:h,onChange:e=>m(e.target.checked)}),i("iv.onlyMissing")," \xb7 ",w]})]}),0===f.length?(0,n.jsx)("p",{className:"muted small",style:{margin:8},children:i("iv.empty")}):(0,n.jsxs)("table",{className:"ivt-table",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:i("iv.col.name")}),(0,n.jsx)("th",{children:i("iv.col.value")}),(0,n.jsx)("th",{children:i("iv.col.source")}),!c&&(0,n.jsx)("th",{children:i("iv.col.used")}),(0,n.jsx)("th",{})]})}),(0,n.jsx)("tbody",{children:f.map(e=>{var s,l;let o=e.secret&&!u[e.name];return(0,n.jsxs)("tr",{className:"ivt-row ".concat("missing"===e.source?"miss":""),children:[(0,n.jsx)("td",{children:(0,n.jsx)("code",{className:"mono ivt-name",children:e.name.replace(/^\$/,"$")})}),(0,n.jsx)("td",{className:"ivt-val",children:p===e.name?(0,n.jsxs)("span",{className:"row gap-s",children:[(0,n.jsx)("input",{className:"input mono",autoFocus:!0,value:v,placeholder:i("hw.session.value"),onChange:e=>g(e.target.value),onKeyDown:e=>{"Enter"===e.key&&N(),"Escape"===e.key&&b(null)}}),(0,n.jsx)("button",{className:"btn primary icon sm",onClick:N,"aria-label":i("iv.save"),children:(0,n.jsx)(eJ.A,{size:14})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>b(null),"aria-label":i("hw2.cancel"),children:(0,n.jsx)(M.A,{size:14})})]}):"missing"===e.source?(0,n.jsx)("span",{className:"muted",children:"—"}):"dynamic"===e.source?(0,n.jsx)("span",{className:"muted small",children:i("iv.generated")}):e.hidden?(0,n.jsxs)("span",{className:"muted small",title:i("iv.hidden"),children:["•••••• ",(0,n.jsxs)("i",{children:["(",i("iv.hidden"),")"]})]}):(0,n.jsx)("span",{className:"mono ivt-text",title:o?void 0:null!=(l=e.value)?l:"",children:o?"••••••••":e.value})}),(0,n.jsxs)("td",{children:[(0,n.jsx)("span",{className:"ivt-src ".concat(ss[e.source]),children:st(i,e.source,e.from)}),e.overridden.length>0&&(0,n.jsx)("div",{className:"ivt-over",children:e.overridden.map((s,t)=>(0,n.jsxs)("div",{className:"small",children:[(0,n.jsx)("b",{children:st(i,s.source,s.from)})," ",i("iv.alsoDefines"),null!==s.value&&(0,n.jsxs)(n.Fragment,{children:[" ",(0,n.jsx)("code",{className:"mono",children:s.value})]})," — ",i("iv.winsOver",{who:st(i,e.source,e.from)})]},t))}),"missing"===e.source&&(null==(s=e.hint)?void 0:s.startsWith("run:"))&&r&&(0,n.jsx)("button",{className:"btn sm",style:{marginTop:4},onClick:()=>r(e.hint.slice(4)),children:i("iv.run",{name:e.hint.slice(4)})})]}),!c&&(0,n.jsx)("td",{className:"muted small",children:e.usedBy||""}),(0,n.jsxs)("td",{className:"ivt-act",children:[e.secret&&null!==e.value&&!e.hidden&&(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>j(s=>({...s,[e.name]:!s[e.name]})),"aria-label":i("iv.reveal"),title:i("iv.reveal"),children:u[e.name]?(0,n.jsx)(P.A,{size:14}):(0,n.jsx)(_.A,{size:14})}),t&&"dynamic"!==e.source&&"response"!==e.source&&!e.name.includes(".")&&p!==e.name&&(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>{var s;b(e.name),g("session"!==e.source&&e.secret?"":null!=(s=e.value)?s:"")},"aria-label":i("iv.override"),title:"".concat(i("iv.override"),". ").concat(i("iv.override.hint")),children:(0,n.jsx)(se.A,{size:14})}),a&&"session"===e.source&&(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>a(e.name),"aria-label":i("iv.forget"),title:i("iv.forget"),children:(0,n.jsx)(M.A,{size:14})})]})]},e.name)})})]})]})}var sl=t(55362);let sa=["status","time","header","body","text"],sr=new Set(["exists","2xx"]);function sc(e){let{objectId:s,file:t,line:a,onSaved:r}=e,{t:c}=(0,x.s9)(),i=(0,p.dj)(),[o,d]=(0,l.useState)([]),[h,m]=(0,l.useState)("[]"),[u,j]=(0,l.useState)(!1),[b,v]=(0,l.useState)("");(0,l.useEffect)(()=>{let e=!0;return ew(s,t).then(s=>{if(!e)return;let t=function(e,s){let t=e.split("\n"),{start:n,end:l}=eL(t,s),a=t.slice(n,l).findIndex(e=>e.startsWith(ez));if(a<0)return[];try{let e=JSON.parse(t[n+a].slice(ez.length));return Array.isArray(e)?e:[]}catch(e){return[]}}(s,a);d(t),m(JSON.stringify(t))}).catch(()=>void 0),()=>{e=!1}},[s,t,a]);let g=JSON.stringify(o)!==h,f=(e,s)=>d(t=>t.map((t,n)=>n===e?{...t,...s}:t)),w=async()=>{j(!0),v("");try{let e=o.filter(e=>{var s;return"status"===e.k||"time"===e.k||"header"!==e.k&&"body"!==e.k||!!(null==(s=e.name)?void 0:s.trim())});await ey(s,t,s=>(function(e,s,t){let n=e.split("\n"),{start:l,end:a}=eL(n,s),r=n.slice(l,a).findIndex(e=>e.startsWith(ez)),c=t.length?(function(e){let s=JSON.stringify(e).replace(/%\}/g,"%\\u007d"),t=e.map(e=>{let{label:s,cond:t}=function(e){var s,t,n,l;let a=null!=(s=e.v)?s:"";if("status"===e.k)return"2xx"===e.op?{label:"status is 2xx",cond:"response.status >= 200 && response.status < 300"}:{label:"status ".concat(e.op," ").concat(a),cond:"response.status ".concat("="===e.op?"==":e.op," ").concat(eF(a))};if("time"===e.k)return{label:"time ".concat(e.op," ").concat(a," ms"),cond:"response.time ".concat(e.op," ").concat(Number(a)||0)};if("header"===e.k){let s="response.headers.valueOf(".concat(JSON.stringify((null!=(t=e.name)?t:"").toLowerCase()),")");return"exists"===e.op?{label:"header ".concat(e.name," exists"),cond:"".concat(s," !== undefined")}:"contains"===e.op?{label:"header ".concat(e.name," contains ").concat(a),cond:"".concat(s," !== undefined && ").concat(s,".includes(").concat(JSON.stringify(a),")")}:{label:"header ".concat(e.name," = ").concat(a),cond:"".concat(s," == ").concat(eF(a))}}if("text"===e.k)return{label:"answer contains ".concat(a),cond:"response.text.includes(".concat(JSON.stringify(a),")")};let r=function(e){var s,t,n;let l=e.trim().replace(/^\$\.?/,""),a="response.body";for(let e of l.matchAll(/\[(\d+)\]|\["([^"]+)"\]|\.?([^.[\]]+)/g))a+=void 0!==e[1]?"[".concat(e[1],"]"):/^[A-Za-z_]\w*$/.test(null!=(s=e[2])?s:e[3])?".".concat(null!=(t=e[2])?t:e[3]):"[".concat(JSON.stringify(null!=(n=e[2])?n:e[3]),"]");return a}(null!=(n=e.name)?n:"$"),c=null!=(l=e.name)?l:"$";return"exists"===e.op?{label:"".concat(c," exists"),cond:"".concat(r," !== undefined && ").concat(r," !== null")}:"contains"===e.op?{label:"".concat(c," contains ").concat(a),cond:"String(".concat(r,").includes(").concat(JSON.stringify(a),")")}:{label:"".concat(c," ").concat(e.op," ").concat(a),cond:"".concat(r," ").concat("="===e.op?"==":e.op," ").concat(eF(a))}}(e);return"client.test(".concat(JSON.stringify(s),", function () { client.assert(").concat(t,", ").concat(JSON.stringify("expected ".concat(s)),"); });")});return["> {%","".concat(ez).concat(s),...t,"%}"].join("\n")})(t).split("\n"):[];if(r>=0){let e=l+r,s=e;for(;s<a&&!n[s].trim().endsWith("%}");)s++;return e>l&&"> {%"===n[e-1].trim()&&e--,!c.length&&e>l&&!n[e-1].trim()&&e--,n.splice(e,s-e+1,...c),n.join("\n")}if(!c.length)return e;let i=a;for(;i>l+1&&!n[i-1].trim();)i--;return n.splice(i,0,"",...c),n.join("\n")})(s,a,e)),d(e),m(JSON.stringify(e)),i(c("hw2.saved")),r()}catch(e){v(e instanceof Error?e.message:"error")}finally{j(!1)}};return(0,n.jsxs)("div",{className:"ae",children:[(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)("b",{children:c("hw2.assert.title")}),(0,n.jsx)(eI.B,{size:"sm",label:c("common.help"),title:c("hw2.help.how"),children:c("hw2.assert.hint")}),(0,n.jsx)("span",{className:"grow"}),(0,n.jsxs)("button",{className:"btn sm",onClick:()=>d(e=>[...e,{k:"status",op:"2xx"}]),children:[(0,n.jsx)(k.A,{size:13}),c("hw2.assert.add")]}),(0,n.jsxs)("button",{className:"btn primary sm",disabled:!g||u,onClick:()=>void w(),children:[(0,n.jsx)(sl.A,{size:13}),c("hw2.assert.save")]})]}),(0,n.jsx)("div",{style:{height:8}}),o.map((e,s)=>{var t,l;return(0,n.jsxs)("div",{className:"ae-row",children:[(0,n.jsx)("select",{className:"select",value:e.k,onChange:e=>{let t=e.target.value;f(s,{k:t,op:eE[t][0],name:void 0,v:""})},"aria-label":c("hw2.assert.kind"),children:sa.map(e=>(0,n.jsx)("option",{value:e,children:c("hw2.assert.k.".concat(e))},e))}),("header"===e.k||"body"===e.k)&&(0,n.jsx)("input",{className:"input mono",value:null!=(t=e.name)?t:"",placeholder:"header"===e.k?"Content-Type":"$.data.id",onChange:e=>f(s,{name:e.target.value}),"aria-label":c("obj.f.name")}),(0,n.jsx)("select",{className:"select",value:e.op,onChange:e=>f(s,{op:e.target.value}),"aria-label":c("hw2.assert.op"),children:eE[e.k].map(e=>(0,n.jsx)("option",{value:e,children:"exists"===e?c("hw2.assert.exists"):"2xx"===e?c("hw2.assert.ok"):"contains"===e?c("hw2.assert.contains"):e},e))}),!sr.has(e.op)&&(0,n.jsx)("input",{className:"input mono",value:null!=(l=e.v)?l:"",placeholder:"time"===e.k?"ms":c("hw.session.value"),onChange:e=>f(s,{v:e.target.value}),"aria-label":c("hw.session.value")}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>d(e=>e.filter((e,t)=>t!==s)),"aria-label":c("hw2.assert.remove"),children:(0,n.jsx)(M.A,{size:14})})]},s)}),b&&(0,n.jsx)("p",{className:"gx-note err",children:b})]})}let si=["X-Api-Key","Api-Key","X-Auth-Token"];function so(e){let{objectId:s,file:t,lines:a,onSaved:r}=e,{t:c}=(0,x.s9)(),i=(0,p.dj)(),o=a[0],[d,h]=(0,l.useState)("none"),[m,u]=(0,l.useState)(""),[j,b]=(0,l.useState)(""),[v,g]=(0,l.useState)(""),[f,w]=(0,l.useState)("X-Api-Key"),[N,y]=(0,l.useState)(""),[k,C]=(0,l.useState)(!1),[S,A]=(0,l.useState)(!1),[E,z]=(0,l.useState)("");(0,l.useEffect)(()=>{ew(s,t).then(e=>{var s,t,n;let l=eA(e,o,"Authorization"),a=si.find(s=>void 0!==eA(e,o,s));if(l&&/^Bearer\s/i.test(l))h("bearer"),u(l.replace(/^Bearer\s+/i,""));else if(l&&/^Basic\s/i.test(l)){let e=/^Basic\s+(\S+?)(?:\s+|:)(.+)$/i.exec(l);h("basic"),b(null!=(s=null==e?void 0:e[1])?s:""),g(null!=(t=null==e?void 0:e[2])?t:"")}else a?(h("apikey"),w(a),y(null!=(n=eA(e,o,a))?n:"")):h("none")}).catch(()=>void 0)},[s,t,o]);let F=async()=>{A(!0),z("");try{await ey(s,t,e=>{let s=e;for(let e of(k?[...a]:[o]).sort((e,s)=>s-e)){for(let t of["Authorization",...si])s=eS(s,e,t,null);"bearer"===d?s=eS(s,e,"Authorization","Bearer ".concat(m)):"basic"===d?s=eS(s,e,"Authorization","Basic ".concat(j," ").concat(v)):"apikey"===d&&(s=eS(s,e,f.trim()||"X-Api-Key",N))}return s}),i(c("hw2.saved")),r()}catch(e){z(e instanceof Error?e.message:"error")}finally{A(!1)}};return(0,n.jsxs)("div",{className:"hr-form",style:{maxWidth:600},children:[(0,n.jsxs)("div",{className:"row gap-s",style:{marginBottom:12},children:[(0,n.jsx)("b",{className:"grow",children:c("hw2.tab.auth")}),(0,n.jsx)(eI.B,{size:"sm",align:"end",label:c("common.help"),title:c("hw2.help.how"),children:c("hw2.auth.hint")})]}),(0,n.jsxs)("div",{className:"stack",children:[(0,n.jsxs)("select",{className:"select",value:d,onChange:e=>h(e.target.value),"aria-label":c("hw2.auth.type"),children:[(0,n.jsx)("option",{value:"none",children:c("hw2.auth.none")}),(0,n.jsx)("option",{value:"bearer",children:"Bearer token"}),(0,n.jsx)("option",{value:"basic",children:"Basic"}),(0,n.jsx)("option",{value:"apikey",children:"API key"})]}),"bearer"===d&&(0,n.jsx)("input",{className:"input mono",value:m,placeholder:"{{token}}",onChange:e=>u(e.target.value),"aria-label":"Token"}),"basic"===d&&(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)("input",{className:"input mono",style:{flex:1},value:j,placeholder:"{{user}}",onChange:e=>b(e.target.value),"aria-label":c("hw2.auth.user")}),(0,n.jsx)("input",{className:"input mono",style:{flex:1},value:v,placeholder:"{{passwd}}",onChange:e=>g(e.target.value),"aria-label":c("hw2.auth.pass")})]}),"apikey"===d&&(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)("input",{className:"input mono",style:{flex:1},value:f,onChange:e=>w(e.target.value),"aria-label":c("hw2.auth.header")}),(0,n.jsx)("input",{className:"input mono",style:{flex:2},value:N,placeholder:"{{apiKey}}",onChange:e=>y(e.target.value),"aria-label":c("hw.session.value")})]}),a.length>1&&(0,n.jsx)(p.Tl,{checked:k,onChange:C,label:c("hw2.auth.all",{count:a.length})}),(0,n.jsx)("div",{className:"row gap-s",children:(0,n.jsx)("button",{className:"btn primary",disabled:S,onClick:()=>void F(),children:c("hw2.auth.apply")})}),E&&(0,n.jsx)("p",{className:"gx-note err",style:{margin:0},children:E})]})]})}function sd(e){var s,t,l,a,r,c,i;let{ws:o,scan:d,sel:h}=e,{t:m}=(0,x.s9)(),{o:u,tab:j,insp:b,res:v,fileOf:g,load:f,forget:w,setVar:N,runNamed:y,testsOf:k,bodyView:C,setBodyView:S,bodyFilter:A,setBodyFilter:E}=o;return"auth"===j?(0,n.jsx)(so,{objectId:u.id,file:null!=(l=g.current.get(h.id))?l:"",lines:(null!=(a=null==(s=d.files.find(e=>e.relFile===g.current.get(h.id)))?void 0:s.requests)?a:[h]).map(e=>e.line).reduce((e,s)=>s===h.line?[s,...e]:[...e,s],[]),onSaved:f}):"vars"===j?(0,n.jsx)("div",{className:"hr-pre",children:b?(0,n.jsx)(sn,{vars:b.vars,onSet:N,onForget:e=>void w(e),onRun:y}):(0,n.jsx)("p",{className:"muted",children:m("git.loading")})}):"request"===j?(0,n.jsxs)("div",{className:"hr-pre",children:[!(null==v?void 0:v.run)&&(null==b?void 0:b.preview)?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"row gap-s small res-mb",children:[(0,n.jsx)("b",{children:m("hw2.resolved")}),b.preview.unresolved.length>0&&(0,n.jsx)("span",{className:"chip warn",children:m("hw2.unresolved",{count:b.preview.unresolved.length})})]}),(0,n.jsxs)("div",{className:"mono",children:[(0,n.jsx)("b",{children:b.preview.method})," ",(0,n.jsx)(e5,{text:b.preview.url})]}),b.preview.headers.map((e,s)=>(0,n.jsxs)("div",{children:[(0,n.jsx)("b",{children:e.name}),": ",(0,n.jsx)(e5,{text:e.value})]},s)),void 0!==b.preview.body&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"eyebrow hw-eb",children:m("http.requestBody")}),(0,n.jsx)("pre",{children:(0,n.jsx)(e5,{text:b.preview.body})})]})]}):null,(null==v?void 0:v.run)&&(0,n.jsx)("div",{className:"muted small res-mb",children:m("hw2.resolved")}),(null==v?void 0:v.run)&&(0,n.jsxs)("div",{className:"mono",children:[(0,n.jsx)("b",{children:v.run.request.method})," ",v.run.request.url]}),(null==v?void 0:v.run)&&v.run.request.headers.map((e,s)=>(0,n.jsxs)("div",{children:[(0,n.jsx)("b",{children:e.name}),": ",e.value]},s)),(null==v?void 0:v.run)?null:!(null==b?void 0:b.preview)&&h.headers.map((e,s)=>(0,n.jsxs)("div",{children:[(0,n.jsx)("b",{children:e.name}),": ",(null==v?void 0:v.run)?e.value:(0,n.jsx)(e5,{text:e.value})]},s)),(null==v?void 0:v.run)&&void 0!==v.run.request.body&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"eyebrow hw-eb",children:m("http.requestBody")}),(0,n.jsx)("pre",{children:(0,n.jsx)(e5,{text:null!=(c=null!=(r=null==v||null==(t=v.run)?void 0:t.request.body)?r:h.body)?c:""})})]}),h.script&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"eyebrow hw-eb",children:m("hw.script")}),(0,n.jsx)("p",{className:"muted small hw-hint2",children:m("hw.script.hint")}),(0,n.jsx)("pre",{children:h.script.trim()})]})]}):"tests"===j?(0,n.jsxs)("div",{className:"hr-form",children:[(0,n.jsx)(sc,{objectId:u.id,file:null!=(i=g.current.get(h.id))?i:"",line:h.line,onSaved:f}),(0,n.jsx)("div",{className:"eyebrow hw-eb2",children:m("hw.tests")}),(0,n.jsx)("div",{className:"hr-pre res-p0",children:(null==v?void 0:v.run)?0===k(v).length&&0===v.run.logs.length?(0,n.jsx)("p",{className:"muted",children:m("hw.tests.none")}):(0,n.jsxs)(n.Fragment,{children:[k(v).map((e,s)=>(0,n.jsxs)("div",{className:"hw-test ".concat(e.passed?"ok":"err"),children:[e.passed?(0,n.jsx)(eJ.A,{size:14}):(0,n.jsx)(M.A,{size:14}),(0,n.jsx)("b",{children:e.name}),e.message&&(0,n.jsxs)("span",{className:"muted",children:[": ",e.message]})]},s)),v.run.logs.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"eyebrow hw-eb",children:m("hw.console")}),(0,n.jsx)("pre",{children:v.run.logs.join("\n")})]})]}):(0,n.jsx)("p",{className:"muted",children:m("http.noResponse")})})]}):v?v.error?(0,n.jsx)("div",{className:"gx-banner err hw-pre hw-m16",children:v.error}):"headers"===j?(0,n.jsx)("div",{className:"hr-pre",children:v.run.headers.map((e,s)=>(0,n.jsxs)("div",{children:[(0,n.jsx)("b",{children:e.name}),": ",e.value]},s))}):(0,n.jsxs)("div",{className:"hr-pre",children:[v.run.truncated&&(0,n.jsx)("div",{className:"gx-banner",children:m("http.truncated")}),v.run.binary?(0,n.jsx)("p",{className:"muted",children:m("http.binary",{type:v.run.contentType||"?",size:(0,L.zi)(v.run.size)})}):v.run.body?(()=>{let e=eD(v.run.body),s=A.trim(),t=s.startsWith("$"),l=null,a="";if(t&&void 0!==e)try{l=function(e,s){let t=[e];for(let e of function(e){let s=e.trim();if(!s.startsWith("$"))throw Error("A path starts with $");let t=[],n=1;for(;n<s.length;){if(s.startsWith("..",n)){let e=/^\.\.([\w$-]+)/.exec(s.slice(n));if(!e)throw Error("Expected a name after ..");t.push({k:"deep",v:e[1]}),n+=e[0].length;continue}if("."===s[n]){var l;let e=/^\.(\*|[\w$-]+)/.exec(s.slice(n));if(!e)throw Error('Unexpected "'.concat(null!=(l=s[n+1])?l:"",'" after the dot'));t.push("*"===e[1]?{k:"all"}:{k:"key",v:e[1]}),n+=e[0].length;continue}if("["===s[n]){let e,l=s.indexOf("]",n);if(l<0)throw Error("A [ is not closed");let a=s.slice(n+1,l).trim();if("*"===a)t.push({k:"all"});else if(/^-?\d+$/.test(a))t.push({k:"idx",v:Number(a)});else if(e=/^(['"])(.*)\1$/.exec(a))t.push({k:"key",v:e[2]});else if(e=/^\?\(\s*@((?:\.[\w$-]+)*)\s*(==|!=|>=|<=|>|<)\s*(.+?)\s*\)$/.exec(a)){let s=e[3];try{s=JSON.parse(e[3].replace(/^'(.*)'$/,'"$1"'))}catch(e){}t.push({k:"filter",path:e[1],op:e[2],v:s})}else throw Error("Cannot read [".concat(a,"]"));n=l+1;continue}throw Error('Unexpected "'.concat(s[n],'"'))}return t}(s)){let s=[];for(let n of t)if("key"===e.k)n&&"object"==typeof n&&!Array.isArray(n)&&e.v in n&&s.push(n[e.v]);else if("idx"===e.k){if(Array.isArray(n)){let t=n[e.v<0?n.length+e.v:e.v];void 0!==t&&s.push(t)}}else if("all"===e.k)s.push(...e7(n));else if("deep"===e.k)!function e(s,t,n){for(let l of(s&&"object"==typeof s&&!Array.isArray(s)&&t in s&&n.push(s[t]),e7(s)))e(l,t,n)}(n,e.v,s);else for(let t of e7(n)){let n=t;for(let s of e.path.split(".").filter(Boolean))n=n&&"object"==typeof n?n[s]:void 0;void 0!==n&&e8(n,e.op,e.v)&&s.push(t)}t=s}return t}(e,s)}catch(e){a=e instanceof Error?e.message:"error"}let r=eW(v.run),c=s&&!t?r.split("\n").map((e,s)=>({l:e,n:s+1})).filter(e=>e.l.toLowerCase().includes(s.toLowerCase())):null;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)(p.DO,{className:"grow",value:A,onChange:E,placeholder:m("hw2.filter.placeholder"),label:m("hw2.filter")}),void 0!==e&&(0,n.jsx)(p.$q,{value:C,onChange:S,options:[{id:"tree",label:m("hw2.tree")},{id:"text",label:m("hw2.text")}]}),(0,n.jsx)(e6.WQ,{text:l?JSON.stringify(1===l.length?l[0]:l,null,2):v.run.body})]}),a&&(0,n.jsx)("p",{className:"gx-note err hw-my6",children:a}),t&&void 0===e&&(0,n.jsx)("p",{className:"muted small",children:m("hw2.noJson")}),l?0===l.length?(0,n.jsx)("p",{className:"muted small",children:m("hw2.filter.none")}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{className:"muted small hw-my6",children:m("hw2.filter.count",{count:l.length})}),"tree"===C?(0,n.jsx)(eP,{value:1===l.length?l[0]:l}):(0,n.jsx)("pre",{children:JSON.stringify(1===l.length?l[0]:l,null,2)})]}):c?0===c.length?(0,n.jsx)("p",{className:"muted small",children:m("hw2.filter.none")}):(0,n.jsx)("pre",{children:c.map(e=>"".concat(String(e.n).padStart(4)," ").concat(e.l)).join("\n")}):void 0!==e&&"tree"===C?(0,n.jsxs)(n.Fragment,{children:[!h.named&&(0,n.jsx)("p",{className:"muted small",children:m("hw2.copyRef.need")}),(0,n.jsx)(eP,{value:e,refBase:h.named?"".concat(h.named,".response.body"):void 0})]}):(0,n.jsx)("pre",{children:r})]})})():(0,n.jsx)("p",{className:"muted",children:m("http.emptyBody")})]}):(0,n.jsx)("p",{className:"gx-note",children:m("http.noResponse")})}function sh(e){var s,t,l;let{ws:a,scan:r,onOpenVars:c}=e,{t:i}=(0,x.s9)(),{o,env:d,sel:h,setSel:u,busy:j,missing:b,needsRun:v,tab:g,setTab:f,insp:w,note:N,fileOf:y,byName:k,run:C,res:S,testsOf:A}=a;return h?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"hr-reqhead",children:[(0,n.jsx)("span",{className:"hr-m ".concat(eU(h.method)),children:h.method}),(0,n.jsx)("code",{className:"hr-url grow",children:(0,n.jsx)(e5,{text:h.url})}),(0,n.jsx)(e9,{objectId:o.id,file:null!=(l=y.current.get(h.id))?l:"",index:h.index,env:d}),(0,n.jsxs)("button",{className:"btn primary sm",disabled:!!j||b.length>0,onClick:()=>void C(h),title:"Ctrl+Enter",children:[(0,n.jsx)(m.A,{size:14}),j===h.id?i("http.running"):i("http.run")]})]}),h.refs.length>0&&(0,n.jsx)("div",{className:"gx-banner",children:i("hw.uses",{names:h.refs.map(e=>"“".concat(e,"”")).join(", ")})}),b.length>0&&(0,n.jsxs)("div",{className:"gx-banner row gap-s wrap",children:[(0,n.jsx)(e4.A,{size:15}),(0,n.jsxs)("span",{className:"grow",children:[i("http.missing",{names:b.map(e=>"{{".concat(e,"}}")).join(", ")}),v.length?"":". ".concat(i("http.missing.hint"))]}),v.map(e=>k.current.get(e)&&(0,n.jsx)("button",{className:"btn sm",disabled:!!j,onClick:()=>{let s=k.current.get(e);u(s),C(s)},children:i("hw.needsRun",{name:e})},e)),!v.length&&(0,n.jsx)("button",{className:"btn sm",onClick:c,children:i("hw.editVars")})]}),N&&(0,n.jsx)("div",{className:"gx-banner",children:N}),(0,n.jsxs)("div",{className:"row gap-s hw-bar",children:[(0,n.jsx)(p.$q,{value:g,onChange:f,options:[{id:"body",label:i("http.body")},{id:"headers",label:"".concat(i("http.headers")).concat((null==S?void 0:S.run)?" \xb7 ".concat(S.run.headers.length):"")},{id:"tests",label:"".concat(i("hw.tests")).concat(A(S).length?" \xb7 ".concat(A(S).filter(e=>e.passed).length,"/").concat(A(S).length):"")},{id:"request",label:i("http.request")},{id:"vars",label:"".concat(i("hw2.tab.vars")).concat((null==w?void 0:w.vars.length)?" \xb7 ".concat(w.vars.length):"")},{id:"auth",label:i("hw2.tab.auth")}]}),(0,n.jsx)("span",{className:"grow"}),(null==S?void 0:S.run)&&(0,n.jsxs)("span",{className:"row gap-s small",children:[S.run.set.length>0&&(0,n.jsx)("span",{className:"chip",title:S.run.set.join(", "),children:i("hw.kept",{names:S.run.set.join(", ")})}),(0,n.jsxs)("b",{className:"hr-st ".concat(eB(S.run.status)),children:[S.run.status," ",S.run.statusText]}),(0,n.jsxs)("span",{className:"muted",children:[i("http.time",{ms:S.run.durationMs})," \xb7 ",(0,L.zi)(S.run.size)]})]})]}),(null==S||null==(s=S.run)?void 0:s.scriptError)&&(0,n.jsx)("div",{className:"gx-banner err",children:i("hw.script.error",{error:S.run.scriptError})}),(null==S||null==(t=S.run)?void 0:t.scriptFile)&&(0,n.jsx)("div",{className:"gx-banner",children:i("hw.script.file",{file:S.run.scriptFile})}),(0,n.jsx)("div",{className:"hr-out",children:(0,n.jsx)(sd,{ws:a,scan:r,sel:h})})]}):null}var sm=t(96213);let su=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],sx=["Accept","Accept-Language","Authorization","Cache-Control","Content-Type","Cookie","If-None-Match","Origin","Referer","User-Agent","X-Api-Key","X-Requested-With"],sj=["application/json","application/x-www-form-urlencoded","application/xml","text/plain","text/html","multipart/form-data"],sp=["$uuid","$timestamp","$isoTimestamp","$randomInt"];function sb(e,s){let t=getComputedStyle(e),n=document.createElement("div");for(let e of["fontFamily","fontSize","lineHeight","letterSpacing","tabSize","paddingTop","paddingLeft","paddingRight","paddingBottom","borderTopWidth","borderLeftWidth","borderRightWidth","boxSizing"])n.style[e]=t[e];n.style.cssText+=";position:absolute;visibility:hidden;white-space:pre;top:0;left:0;width:"+e.clientWidth+"px",n.textContent=e.value.slice(0,s);let l=document.createElement("span");l.textContent="",n.appendChild(l),document.body.appendChild(n);let a=l.offsetLeft,r=l.offsetTop;return document.body.removeChild(n),{x:a-e.scrollLeft,y:r-e.scrollTop}}function sv(e){var s,t,a,r;let{value:c,onChange:i,onSave:o,vars:d,named:h}=e,m=(0,l.useRef)(null),[u,x]=(0,l.useState)(null),[j,p]=(0,l.useState)(0),[b,v]=(0,l.useState)({x:0,y:0}),g=(0,l.useMemo)(()=>d,[d]),f=(e,s)=>{let t=function(e,s,t,n){let l=e.lastIndexOf("\n",s-1)+1,a=e.slice(l,s),r=e.slice(0,l).split("\n"),c=/\{\{([\w.$-]*)$/.exec(a);if(c){let e=c[1].toLowerCase(),l=s-c[1].length,a=[...t.filter(e=>!e.name.includes(".response.")&&!e.name.startsWith("$")).map(e=>{var s;return{label:e.name,insert:"".concat(e.name,"}}"),hint:"missing"===e.source?"—":e.secret||e.hidden?"••••":(null!=(s=e.value)?s:"").slice(0,30)}}),...n.map(e=>({label:"".concat(e,".response.body."),insert:"".concat(e,".response.body."),hint:"answer"})),...sp.map(e=>({label:e,insert:"".concat(e,"}}"),hint:"generated"}))].filter(s=>s.label.toLowerCase().includes(e)&&s.label.toLowerCase()!==e).slice(0,12);return a.length?{items:a,from:l,to:s}:null}let i=/^(content-type|accept)\s*:\s*([\w/+.-]*)$/i.exec(a);if(i){let e=i[2].toLowerCase(),t=sj.filter(s=>s.includes(e)&&s!==e).map(e=>({label:e,insert:e}));return t.length?{items:t,from:s-i[2].length,to:s}:null}let o=/^([A-Za-z-]+)$/.exec(a);if(o){var d;let e=(null!=(d=r[r.length-2])?d:"").trim(),t=!e||/^#{3,}/.test(e)||e.startsWith("#")||e.startsWith("//"),n=!!e&&!t&&!/^\{|^\[|^</.test(e)&&!e.endsWith("%}"),a=o[1].toLowerCase();if(t){let e=su.filter(e=>e.toLowerCase().startsWith(a)&&e.toLowerCase()!==a).map(e=>({label:e,insert:"".concat(e," ")}));return e.length?{items:e,from:l,to:s}:null}if(n){let e=sx.filter(e=>e.toLowerCase().startsWith(a)&&e.toLowerCase()!==a).map(e=>({label:e,insert:"".concat(e,": ")}));return e.length?{items:e,from:l,to:s}:null}}let h=/^#\s*@?(\w*)$/.exec(a);if(h&&h[0].length>1){let e=h[1].toLowerCase();if("name".startsWith(e)&&"name"!==e)return{items:[{label:"# @name",insert:"# @name ",hint:"name the request to use its answer"}],from:l,to:s}}return null}(e,s,g,h);if(x(t),p(0),t&&m.current){let e=sb(m.current,s);v({x:Math.min(e.x,Math.max(0,m.current.clientWidth-260)),y:e.y})}},w=e=>{if(!u||!m.current)return;i(c.slice(0,u.from)+e.insert+c.slice(u.to)),x(null);let s=u.from+e.insert.length;requestAnimationFrame(()=>{var e,t;null==(e=m.current)||e.focus(),null==(t=m.current)||t.setSelectionRange(s,s)})};return(0,n.jsxs)("div",{className:"se",children:[(0,n.jsx)(sm.B,{value:c,path:"requests.http",areaRef:m,onChange:e=>{i(e);let s=m.current;s&&requestAnimationFrame(()=>f(e,s.selectionStart))},onClick:()=>x(null),onBlur:()=>setTimeout(()=>x(null),120),onKeyDown:e=>{if((e.ctrlKey||e.metaKey)&&"s"===e.key){e.preventDefault(),o();return}if((e.ctrlKey||e.metaKey)&&" "===e.key){e.preventDefault(),f(c,e.currentTarget.selectionStart);return}u&&("ArrowDown"===e.key?(e.preventDefault(),p(e=>(e+1)%u.items.length)):"ArrowUp"===e.key?(e.preventDefault(),p(e=>(e-1+u.items.length)%u.items.length)):"Enter"===e.key||"Tab"===e.key?(e.preventDefault(),w(u.items[j])):"Escape"===e.key&&(e.preventDefault(),x(null)))}}),u&&(0,n.jsx)("ul",{className:"se-pop",role:"listbox",style:{left:b.x+16,...b.y>(null!=(a=null==(s=m.current)?void 0:s.clientHeight)?a:400)-30*u.items.length-50?{bottom:(null!=(r=null==(t=m.current)?void 0:t.clientHeight)?r:0)-b.y-8}:{top:b.y+34}},children:u.items.map((e,s)=>(0,n.jsxs)("li",{role:"option","aria-selected":s===j,className:s===j?"on":"",onMouseDown:s=>{s.preventDefault(),w(e)},children:[(0,n.jsx)("span",{className:"mono",children:e.label}),e.hint&&(0,n.jsx)("i",{children:e.hint})]},e.label))})]})}var sg=t(78060),sf=t(39696);function sw(e){let{objectId:s,file:t,vars:a,onRun:r,status:c,onSaved:i}=e,{t:o}=(0,x.s9)(),d=(0,p.dj)(),h=(0,sf.Wx)(),[u,j]=(0,l.useState)(null),[b,v]=(0,l.useState)(null),[g,f]=(0,l.useState)(""),[w,N]=(0,l.useState)(!1);(0,l.useEffect)(()=>{j(null),v(null),f(""),ew(s,t.relFile).then(j).catch(e=>f(e instanceof Error?e.message:""))},[s,t.relFile]);let y=(0,l.useMemo)(()=>new Map(a.map(e=>[e.name,e])),[a]),k=(0,l.useMemo)(()=>new Map(t.requests.map(e=>[e.line,e.index])),[t]),C=async()=>{if(null!==b){N(!0),f("");try{await eN(s,t.relFile,b),j(b),v(null),d(o("hw2.saved")),i()}catch(e){f(e instanceof Error?e.message:"")}finally{N(!1)}}},S=e=>{let s=e.split(/(\{\{[^}]+\}\})/g);return(0,n.jsx)(n.Fragment,{children:s.map((e,s)=>{if(!e.startsWith("{{"))return(0,n.jsx)(l.Fragment,{children:e},s);let t=e.slice(2,-2).trim(),a=y.get(t);return(0,n.jsx)("span",{className:"hs-var ".concat(a?ss[a.source]:"miss"),title:(e=>{var s;let t=y.get(e);if(!t)return"";let n=t.hidden?o("iv.hidden"):"missing"===t.source?"—":"dynamic"===t.source?o("iv.generated"):t.secret?"••••••••":null!=(s=t.value)?s:"";return"".concat(e," = ").concat(n,"\n").concat(st(o,t.source,t.from))})(t),children:e},s)})})};if(g&&null===u)return(0,n.jsx)("p",{className:"gx-note err",style:{padding:16},children:g});if(null===u)return(0,n.jsx)("p",{className:"gx-note",children:o("git.loading")});let A=(null!=b?b:u).split("\n");return(0,n.jsxs)("div",{className:"hs gx","data-gx-theme":h.theme,style:{"--g-tab":h.tabSize},children:[(0,n.jsxs)("div",{className:"hs-bar",children:[(0,n.jsx)("span",{className:"muted small",children:null!==b?o("hw2.dirty"):""}),(0,n.jsx)(eI.B,{size:"sm",label:o("common.help"),title:o("hw2.help.file"),children:o("hw2.fileHint")}),(0,n.jsx)("span",{className:"grow"}),(0,n.jsx)(sg.i,{compact:!0}),null===b?(0,n.jsxs)("button",{className:"btn sm",onClick:()=>v(u),children:[(0,n.jsx)(se.A,{size:14}),o("hw2.edit")]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("button",{className:"btn ghost sm",onClick:()=>{v(null),f("")},children:[(0,n.jsx)(M.A,{size:14}),o("hw2.cancel")]}),(0,n.jsxs)("button",{className:"btn primary sm",disabled:w||b===u,onClick:()=>void C(),children:[(0,n.jsx)(sl.A,{size:14}),o("hw2.save")]})]})]}),g&&(0,n.jsx)("div",{className:"gx-banner err",children:g}),null!==b?(0,n.jsx)(sv,{value:b,onChange:v,onSave:()=>void C(),vars:a,named:t.requests.map(e=>e.named).filter(e=>!!e)}):(0,n.jsx)("div",{className:"hs-view mono",children:A.map((e,s)=>{let t=k.get(s+1),l=void 0!==t?c[t]:void 0;return(0,n.jsxs)("div",{className:"hs-line ".concat(/^#{3,}/.test(e.trim())?"sep":""),children:[(0,n.jsx)("span",{className:"hs-gutter",children:void 0!==t?(0,n.jsx)("button",{className:"hs-run ".concat(null!=l?l:""),onClick:()=>r(t),"aria-label":o("hw2.runHere"),title:o("hw2.runHere"),children:(0,n.jsx)(m.A,{size:11})}):null}),(0,n.jsx)("span",{className:"hs-no",children:s+1}),(0,n.jsx)("span",{className:"hs-text",children:(e=>{if(/^#{3,}/.test(e.trim()))return(0,n.jsx)("span",{className:"hljs-section",children:e});if(/^\s*(#|\/\/)/.test(e))return(0,n.jsx)("span",{className:"hljs-comment",children:e});let s=/^(@[\w.-]+)(\s*=.*)$/.exec(e);if(s)return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"hljs-attr",children:s[1]}),S(s[2])]});let t=/^(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)(\s.*)$/.exec(e);if(t)return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"hljs-keyword",children:t[1]}),S(t[2])]});let l=/^([A-Za-z][\w-]*)(:.*)$/.exec(e);return l?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"hljs-attr",children:l[1]}),S(l[2])]}):S(e)})(e)||"\xa0"})]},s)})})]})}var sN=t(97318),sy=t(99381);function sk(e){let{objectId:s,file:t,onBatch:a,stopOnFail:r,onStopOnFail:c}=e,{t:i}=(0,x.s9)(),o=(0,p.dj)(),[d,h]=(0,l.useState)(!1),m=async(e,n)=>{try{let l=await u.FH.get("/objects/".concat(s,"/http/docs?format=").concat(e).concat(d?"":"&file=".concat(encodeURIComponent(t)))),a=URL.createObjectURL(new Blob([l.content],{type:l.mime})),r=document.createElement("a");r.href=a,r.download=l.filename,r.click(),setTimeout(()=>URL.revokeObjectURL(a),1e3),n(),o(i("hw2.export.done",{name:l.filename}))}catch(e){o(e instanceof Error?e.message:"error")}};return(0,n.jsx)(U.W1,{label:i("svc.more"),icon:(0,n.jsx)(H.A,{size:14}),children:e=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(U.Dr,{icon:(0,n.jsx)(sN.A,{size:15}),hint:i("hw2.batch.hint.short"),onClick:()=>{e(),a()},children:i("hw2.batch.open")}),(0,n.jsx)(U.iz,{checked:r,onChange:c,hint:i("hw2.stopOnFail.hint"),children:i("hw.stopOnFail")}),(0,n.jsx)(U.MU,{}),(0,n.jsxs)(U.rX,{label:i("hw2.export"),children:[(0,n.jsx)(U.Dr,{icon:(0,n.jsx)($.A,{size:15}),onClick:()=>void m("markdown",e),children:i("hw2.export.md")}),(0,n.jsx)(U.Dr,{icon:(0,n.jsx)(sy.A,{size:15}),onClick:()=>void m("postman",e),children:i("hw2.export.postman")}),(0,n.jsx)(U.iz,{checked:d,onChange:h,children:i("hw2.export.all")})]})]})})}function sC(e){var s;let{ws:t,picked:l}=e,{t:a}=(0,x.s9)(),{o:r,busy:c,runFile:i,setBatch:o,stopOnFail:d,setStopOnFail:h,fileInsp:m,fileTab:u,setFileTab:j,note:b,setVar:v,forget:g,runNamed:f,statusByIndex:w,load:N,refreshInsp:y,setSel:k,setTab:C,run:S,results:A,testsOf:E}=t;return(0,n.jsxs)("div",{className:"hw-file-view",children:[(0,n.jsxs)("div",{className:"hw-fhead",children:[(0,n.jsx)(eY.A,{size:20,className:"muted"}),(0,n.jsxs)("div",{className:"grow res-minw0",children:[(0,n.jsx)("h3",{className:"mono",title:l.relFile,children:l.relFile}),(0,n.jsxs)("p",{className:"muted small res-m0",children:[a("hw.fileInfo",{count:l.requests.length}),m?" \xb7 ".concat(a("hw2.vars.count",{count:m.vars.length})):""]})]}),(0,n.jsxs)("button",{className:"btn primary sm",disabled:!!c,onClick:()=>void i(l),children:[(0,n.jsx)(e0.A,{size:14}),a("http.runFile")]}),(0,n.jsx)(sk,{objectId:r.id,file:l.relFile,onBatch:()=>o(!0),stopOnFail:d,onStopOnFail:h})]}),(0,n.jsx)(p.$q,{value:u,onChange:j,options:[{id:"requests",label:"".concat(a("hw2.tab.requests")," \xb7 ").concat(l.requests.length)},{id:"vars",label:"".concat(a("hw2.tab.vars")).concat((null==m?void 0:m.vars.length)?" \xb7 ".concat(m.vars.length):"")},{id:"source",label:a("hw2.tab.source")}]}),b&&(0,n.jsx)("div",{className:"gx-banner",children:b}),"vars"===u?m?(0,n.jsx)(sn,{vars:m.vars,onSet:v,onForget:e=>void g(e),onRun:f}):(0,n.jsx)("p",{className:"muted",children:a("git.loading")}):"source"===u?(0,n.jsx)("div",{className:"hw-src",children:(0,n.jsx)(sw,{objectId:r.id,file:l,vars:null!=(s=null==m?void 0:m.vars)?s:[],status:w(l),onSaved:()=>{N(),y()},onRun:e=>{let s=l.requests.find(s=>s.index===e);s&&(k(s),C("body"),S(s))}})}):(0,n.jsxs)("table",{className:"cm-table",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{}),(0,n.jsx)("th",{children:a("obj.f.name")}),(0,n.jsx)("th",{children:a("hw.fileTests")}),(0,n.jsx)("th",{children:a("hw.lastRun")})]})}),(0,n.jsx)("tbody",{children:l.requests.map(e=>{let s=A[e.id],t=E(s);return(0,n.jsxs)("tr",{className:"hw-trow",onClick:()=>{k(e),C("body")},children:[(0,n.jsx)("td",{children:(0,n.jsx)("span",{className:"hr-m ".concat(eU(e.method)),children:e.method})}),(0,n.jsxs)("td",{children:[(0,n.jsx)("b",{children:e.name}),(0,n.jsx)("div",{className:"muted small mono hw-url",children:(0,n.jsx)(e5,{text:e.url})})]}),(0,n.jsx)("td",{children:t.length?(0,n.jsxs)("span",{className:"hr-st ".concat(t.every(e=>e.passed)?"ok":"err"),children:[t.filter(e=>e.passed).length,"/",t.length]}):(0,n.jsx)("span",{className:"muted small",children:"—"})}),(0,n.jsx)("td",{children:s?s.run?(0,n.jsxs)("span",{className:"hr-st ".concat(e$(s)),children:[(0,n.jsx)("b",{children:s.run.status})," ",(0,n.jsxs)("span",{className:"muted",children:[s.run.durationMs," ms"]})]}):(0,n.jsx)("span",{className:"hr-st err",title:s.error,children:"error"}):(0,n.jsx)("span",{className:"muted small",children:a("hw.notRun")})})]},e.id)})})]})]})}function sS(e){let{object:s,onOpenVars:t,pane:a="requests",onGoRequests:r}=e,{t:c}=(0,x.s9)(),i=function(e){var s,t;let{t:n}=(0,x.s9)(),{refresh:a}=(0,j.o0)(),[r,c]=(0,l.useState)(null),[i,o]=(0,l.useState)(""),[d,h]=(0,l.useState)(null!=(s=e.config.env)?s:""),[m,p]=(0,l.useState)(""),[b,v]=(0,l.useState)(null),[g,f]=(0,l.useState)(null),[w,N]=(0,l.useState)(new Set),[y,k]=(0,l.useState)({}),[C,S]=(0,l.useState)(null),[A,E]=(0,l.useState)([]),[z,F]=(0,l.useState)([]),[L,O]=(0,l.useState)("body"),[q,T]=(0,l.useState)("requests"),[R,I]=(0,l.useState)("tree"),[H,D]=(0,l.useState)(""),[M,U]=(0,l.useState)(null),[B,$]=(0,l.useState)(null),[W,J]=(0,l.useState)(null),[P,_]=(0,l.useState)(!1),[K,G]=(0,l.useState)(!1),[X,V]=(0,l.useState)([]),[Z,Q]=(0,l.useState)(null),[Y,ee]=(0,l.useState)(null),es=(0,l.useCallback)(()=>u.FH.get("/objects/".concat(e.id,"/http/history")).then(V).catch(()=>void 0),[e.id]);(0,l.useEffect)(()=>{es()},[es]);let[et,en]=(0,l.useState)({globals:{},responses:[]}),[el,ea]=(0,l.useState)(!1),[er,ec]=(0,l.useState)(""),[ei,eo]=(0,l.useState)(null),ed=(0,l.useRef)(new Map),eh=(0,l.useRef)(new Map),em=(0,l.useCallback)(()=>u.FH.get("/objects/".concat(e.id,"/http/session")).then(en).catch(()=>void 0),[e.id]),eu=(0,l.useCallback)(()=>{o(""),u.FH.get("/objects/".concat(e.id,"/http")).then(s=>{var t;c(s),ed.current=new Map(s.files.flatMap(e=>e.requests.map(s=>[s.id,e.relFile]))),eh.current=new Map(s.files.flatMap(e=>e.requests.filter(e=>e.named).map(e=>[e.named,e]))),v(e=>{var t,n;return e&&s.files.some(s=>s.relFile===e)?e:null!=(n=null==(t=s.files[0])?void 0:t.relFile)?n:null}),N(e=>e.size?e:new Set(s.files.slice(0,1).map(e=>e.relFile))),f(e=>{var t;return e&&ed.current.has(e.id)&&null!=(t=s.files.flatMap(e=>e.requests).find(s=>s.id===e.id))?t:null});let n=null!=(t=e.config.env)?t:"";h(e=>{var t;return e&&s.environments.includes(e)?e:n&&s.environments.includes(n)?n:null!=(t=s.environments[0])?t:""})}).catch(e=>o(e instanceof Error?e.message:n("git.loadError")))},[e.id,e.updated_at]);(0,l.useEffect)(()=>{eu(),em()},[eu,em]);let ex=(0,l.useCallback)(()=>{var s;if(!g){E([]),F([]);return}u.FH.get("/objects/".concat(e.id,"/http/describe?file=").concat(encodeURIComponent(null!=(s=ed.current.get(g.id))?s:""),"&index=").concat(g.index).concat(d?"&env=".concat(encodeURIComponent(d)):"")).then(e=>{var s;E(e.missing),F(null!=(s=e.needsRun)?s:[])}).catch(()=>{E([]),F([])})},[e.id,e.updated_at,null==g?void 0:g.id,d]);(0,l.useEffect)(()=>{ex()},[ex,et]);let ej=(0,l.useCallback)((s,t)=>u.FH.get("/objects/".concat(e.id,"/http/variables?").concat([s?"file=".concat(encodeURIComponent(s)):"",void 0!==t?"index=".concat(t):"",d?"env=".concat(encodeURIComponent(d)):""].filter(Boolean).join("&"))),[e.id,d]),ep=(0,l.useCallback)(()=>{g?ej(ed.current.get(g.id),g.index).then(U).catch(()=>U(null)):U(null),b&&ej(b).then($).catch(()=>$(null))},[ej,null==g?void 0:g.id,b]);(0,l.useEffect)(()=>{ep()},[ep,et,e.updated_at]);let eb=(0,l.useCallback)(async s=>{let t,n=ed.current.get(s.id);if(!n)return{error:"",at:Date.now()};S(s.id);try{t={run:await u.FH.post("/objects/".concat(e.id,"/http/run"),{file:n,index:s.index,env:d||void 0}),at:Date.now()}}catch(e){t={error:e instanceof Error?e.message:"error",at:Date.now()}}return k(e=>({...e,[s.id]:t})),S(null),es(),em(),t},[e.id,d,em,es]),ev=async e=>{for(let s of(ec(""),e.requests)){f(s);let e=await eb(s);if(el&&"err"===e$(e)){ec(n("hw.stopped",{name:s.name}));break}}};(0,l.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&g&&!C&&(e.preventDefault(),eb(g))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[g,C,eb]);let eg=(0,l.useMemo)(()=>{var e;return(null!=(e=null==r?void 0:r.files)?e:[]).map(e=>({...e,requests:e.requests.filter(s=>!m||"".concat(s.name," ").concat(s.url," ").concat(s.method).toLowerCase().includes(m.toLowerCase())||e.relFile.toLowerCase().includes(m.toLowerCase()))})).filter(e=>e.requests.length)},[r,m]),ef=null!=(t=null==r?void 0:r.files.find(e=>e.relFile===b))?t:null,ew=g?y[g.id]:void 0,[eN,ey]=(0,l.useState)(""),[ek,eC]=(0,l.useState)(""),[eS,eA]=(0,l.useState)(!1),eE=Object.entries(et.globals);return{o:e,scan:r,err:i,env:d,setEnv:h,q:m,setQ:p,file:b,setFile:v,sel:g,setSel:f,open:w,setOpen:N,results:y,busy:C,missing:A,needsRun:z,tab:L,setTab:O,fileTab:q,setFileTab:T,bodyView:R,setBodyView:I,bodyFilter:H,setBodyFilter:D,insp:M,fileInsp:B,creating:P,setCreating:_,batch:K,setBatch:G,hist:X,setHist:V,histSel:Z,setHistSel:Q,cmp:Y,setCmp:ee,loadHistory:es,loadSession:em,session:et,setSession:en,stopOnFail:el,setStopOnFail:ea,note:er,confirm:ei,setConfirm:eo,fileOf:ed,byName:eh,load:eu,run:eb,runFile:ev,refreshInsp:ep,files:eg,picked:ef,res:ew,summary:e=>{let s=e.requests.filter(e=>y[e.id]);return s.length?"".concat(s.filter(e=>"ok"===e$(y[e.id])).length,"/").concat(e.requests.length):null},testsOf:e=>{var s,t;return null!=(t=null==e||null==(s=e.run)?void 0:s.tests)?t:[]},forget:s=>u.FH.del("/objects/".concat(e.id,"/http/session").concat(s?"?name=".concat(encodeURIComponent(s)):"")).then(en).catch(()=>void 0),newName:eN,setNewName:ey,newValue:ek,setNewValue:eC,adding:eS,setAdding:eA,setValue:()=>{var s,t;let n=eN.trim();if(!n)return;let l=e.config,r={...null!=(s=l.variables)?s:{}};r[eM]={...null!=(t=r[eM])?t:{},[n]:{value:ek}},u.FH.patch("/objects/".concat(e.id),{config:{folder:l.folder,env:l.env,variables:r}}).then(()=>(ey(""),eC(""),eA(!1),h(eM),a(["objects"]))).catch(()=>void 0)},kept:eE,setVar:(s,t)=>u.FH.post("/objects/".concat(e.id,"/http/session"),{name:s,value:t}).then(en).catch(()=>void 0),runNamed:e=>{let s=eh.current.get(e);if(s){var t;v(null!=(t=ed.current.get(s.id))?t:b),f(s),O("body"),eb(s)}},statusByIndex:e=>Object.fromEntries(e.requests.map(e=>[e.index,e$(y[e.id])]))}}(s),{scan:o,err:d,env:h,file:m,setFile:p,sel:b,setSel:v,picked:g,batch:f,setBatch:w,creating:N,setCreating:y,setFileTab:k,setOpen:C,load:S,loadSession:A,loadHistory:E}=i;return d?(0,n.jsx)("p",{className:"gx-note err hw-pad",children:d}):o?"history"===a?(0,n.jsx)(eZ,{ws:i,scan:o,onGoRequests:r}):(0,n.jsxs)(ef,{list:(0,n.jsx)(e2,{ws:i,scan:o,onOpenVars:t}),children:[(0,n.jsx)("section",{className:"hr-detail",children:b?(0,n.jsx)(sh,{ws:i,scan:o,onOpenVars:t}):g?(0,n.jsx)(sC,{ws:i,picked:g}):(0,n.jsx)("div",{className:"gx-empty",children:(0,n.jsx)("p",{children:c("hw.pickFile")})})}),f&&g&&(0,n.jsx)(eH,{objectId:s.id,file:g,env:h,onClose:()=>w(!1),onDone:()=>{A(),E()}}),N&&(0,n.jsx)(eT,{objectId:s.id,files:o.files,defaultFile:m,onClose:()=>y(!1),onCreated:e=>{y(!1),p(e),v(null),k("source"),C(s=>new Set(s).add(e)),S()}}),(0,n.jsx)(eV,{ws:i})]}):(0,n.jsx)("p",{className:"gx-note",children:c("git.loading")})}var sA=t(13460);function sE(e){let{object:s}=e,{t}=(0,x.s9)(),{refresh:a}=(0,j.o0)(),r=(0,p.dj)(),c=s.config,i=(0,l.useMemo)(()=>{var e;return null!=(e=c.variables)?e:{}},[s.updated_at]),[o,d]=(0,l.useState)(i),[h,m]=(0,l.useState)(null),[b,v]=(0,l.useState)(!1),[g,f]=(0,l.useState)("");(0,l.useEffect)(()=>{u.FH.get("/objects/".concat(s.id,"/http")).then(m).catch(()=>void 0)},[s.id,s.updated_at]);let w=JSON.stringify(o)!==JSON.stringify(i),N=async()=>{v(!0),f("");try{await u.FH.patch("/objects/".concat(s.id),{config:{folder:c.folder,env:c.env,variables:Object.keys(o).length?o:void 0}}),await a(["objects"]),r(t("obj.saved"))}catch(e){f(e instanceof Error?e.message:t("edit.saveFailed"))}finally{v(!1)}};return(0,n.jsxs)("div",{className:"oc",children:[(0,n.jsxs)("div",{className:"oc-form",children:[(0,n.jsx)(sA.W,{value:o,onChange:d,fileEnvs:h?Object.keys(h.fileVars).filter(e=>"$shared"!==e):[],fileVars:null==h?void 0:h.fileVars,used:null==h?void 0:h.used,fileDefined:null==h?void 0:h.fileDefined,setBy:null==h?void 0:h.setBy}),g&&(0,n.jsx)("p",{className:"gx-note err",children:g})]}),(0,n.jsxs)("div",{className:"savebar oc-bar",children:[(0,n.jsx)("span",{className:"muted small grow",children:w?t("ow.cfg.dirty"):t("ow.cfg.saved")}),(0,n.jsx)("button",{className:"btn ghost",disabled:!w||b,onClick:()=>d(i),children:t("ow.cfg.discard")}),(0,n.jsx)("button",{className:"btn primary",disabled:!w||b,onClick:()=>void N(),children:t("ow.cfg.save")})]})]})}let sz=["SELECT","FROM","WHERE","AND","OR","NOT","IN","IS NULL","IS NOT NULL","LIKE","BETWEEN","EXISTS","JOIN","INNER JOIN","LEFT JOIN","RIGHT JOIN","FULL JOIN","CROSS JOIN","ON","USING","GROUP BY","ORDER BY","HAVING","LIMIT","OFFSET","DISTINCT","AS","ASC","DESC","UNION","UNION ALL","CASE","WHEN","THEN","ELSE","END","COUNT","SUM","AVG","MIN","MAX","COALESCE","CAST","INSERT INTO","VALUES","UPDATE","SET","DELETE FROM","CREATE TABLE","ALTER TABLE","DROP TABLE","NULL","TRUE","FALSE","WITH","TOP"],sF=new Set(["where","on","join","inner","left","right","full","cross","group","order","limit","set","values","using","union","having","offset","natural","outer","select","and","or"]),sL={mysql:"mysql",postgresql:"postgresql",sqlite:"sqlite",mssql:"transactsql"};async function sO(e,s){var n;let{format:l}=await t.e(701).then(t.bind(t,38701));return l(e,{language:null!=(n=sL[s])?n:"sql",keywordCase:"upper",tabWidth:2,linesBetweenQueries:1})}let sq=e=>e.replace(/^["`[]|["`\]]$/g,""),sT=/^[a-z_][a-z0-9_$]*$/,sR=(e,s)=>sT.test(s)?s:"mysql"===e?"`".concat(s,"`"):"mssql"===e?"[".concat(s,"]"):'"'.concat(s,'"'),sI=new Set(["public","dbo","main"]);function sH(e,s){let t=[],n=/\b(?:from|join|update|into)\s+((?:["`[]?[\w$]+["`\]]?\.)?["`[]?[\w$]+["`\]]?)(?:\s+(?:as\s+)?([A-Za-z_]\w*))?/gi;for(let l=n.exec(e);l;l=n.exec(e)){let e=l[1].split(".").map(sq),n=e[e.length-1].toLowerCase(),a=e.length>1?e[0].toLowerCase():"",r=s.find(e=>e.name.toLowerCase()===n&&(!a||e.schema.toLowerCase()===a));if(!r)continue;let c=l[2]&&!sF.has(l[2].toLowerCase())?l[2]:void 0;t.push({table:r,alias:c})}return t}let sD=(e,s)=>+!e.toLowerCase().startsWith(s),sM=(e,s)=>"mysql"===e?"`".concat(s.replace(/`/g,"``"),"`"):"mssql"===e?"[".concat(s.replace(/]/g,"]]"),"]"):'"'.concat(s.replace(/"/g,'""'),'"'),sU=e=>{let s=null==e?"":String(e);return/[",\n\r]/.test(s)?'"'.concat(s.replace(/"/g,'""'),'"'):s},sB=e=>[e.columns.map(e=>sU(e.name)).join(","),...e.rows.map(e=>e.map(sU).join(","))].join("\n");var s$=t(2432),sW=t(32335),sJ=t(46838),sP=t(17557);function s_(e){var s,t;let{value:a,onChange:r,areaRef:c,ctx:i,label:o,onKeyDown:d}=e,[h,m]=(0,l.useState)(null),[u,x]=(0,l.useState)(0),[j,p]=(0,l.useState)({x:0,y:0}),b=(0,l.useRef)(i);b.current=i;let v=function(e,s){let t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=function(e,s,t){var n,l,a,r,c;let i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=null!=(a=null==(n=t.schema)?void 0:n.engine)?a:"postgresql",d=null!=(r=null==(l=t.schema)?void 0:l.tables)?r:[],h=e.slice(0,s),m=/[\w$]*$/.exec(h)[0],u=s-m.length,x=h.slice(0,u),j=h.lastIndexOf("\n")+1;if(/--/.test(h.slice(j))||(h.split("'").length-1)%2==1||h.lastIndexOf("/*")>h.lastIndexOf("*/"))return null;let p=m.toLowerCase(),b=e.slice(Math.max(e.lastIndexOf(";",s-1)+1,0),(()=>{let t=e.indexOf(";",s);return t<0?e.length:t})()),v=/(["`[]?[\w$]+["`\]]?)\.$/.exec(x),g=e=>{let t=e.filter(e=>!p||e.label.toLowerCase().includes(p)&&e.label.toLowerCase()!==p).sort((e,s)=>sD(e.label,p)-sD(s.label,p)).slice(0,14);return t.length?{items:t,from:u,to:s}:null};if(v){let e=sq(v[1]).toLowerCase(),s=d.filter(s=>s.schema.toLowerCase()===e);if(s.length)return g(s.map(e=>({label:e.name,insert:sR(o,e.name),hint:"view"===e.type?"view":"table"})));let n=sH(b,d).find(s=>{var t;return(null!=(t=s.alias)?t:"").toLowerCase()===e||s.table.name.toLowerCase()===e});if(!n)return null;let l=t.cols(n.table);return l?g(l.map(e=>({label:e,insert:sR(o,e),hint:n.table.name}))):(t.need(n.table),null)}if(!m&&!i)return null;let f=/\b(from|join|update|into|table)\s+$/i.test(x),w=e=>({label:e.name,insert:"sqlite"===o||"mysql"===o||sI.has(e.schema)?sR(o,e.name):"".concat(sR(o,e.schema),".").concat(sR(o,e.name)),hint:"sqlite"===o||"mysql"===o||sI.has(e.schema)?"view"===e.type?"view":void 0:e.schema}),N=[...new Set(d.map(e=>e.schema))].filter(e=>"sqlite"!==o&&"mysql"!==o&&d.some(s=>s.schema===e)),y=[];if(!f)for(let e of sH(b,d)){let s=t.cols(e.table);if(!s){t.need(e.table);continue}for(let t of s)y.some(e=>e.label===t)||y.push({label:t,insert:sR(o,t),hint:null!=(c=e.alias)?c:e.table.name})}for(let e of d)y.push(w(e));for(let e of N)y.push({label:e,insert:sR(o,e),hint:"schema"});if(!f){let e=""!==m&&m===m.toLowerCase();for(let s of sz)y.push({label:e?s.toLowerCase():s,insert:"".concat(e?s.toLowerCase():s," "),hint:"SQL"})}return g(y)}(e,s,b.current,t);m(n),x(0);let l=c.current;if(n&&l){let e=sb(l,s);p({x:Math.min(e.x,Math.max(0,l.clientWidth-260)),y:e.y})}},g=e=>{let s=c.current;if(!h||!s)return;r(a.slice(0,h.from)+e.insert+a.slice(h.to)),m(null);let t=h.from+e.insert.length;requestAnimationFrame(()=>{s.focus(),s.setSelectionRange(t,t)})},f=null!=(t=null==(s=c.current)?void 0:s.clientHeight)?t:400;return(0,n.jsxs)("div",{className:"se",children:[(0,n.jsx)(sm.B,{value:a,path:"query.sql",areaRef:c,label:o,onChange:e=>{r(e);let s=c.current;s&&requestAnimationFrame(()=>v(e,s.selectionStart))},onClick:()=>m(null),onBlur:()=>setTimeout(()=>m(null),120),onKeyDown:e=>{if(d(e),!e.defaultPrevented){if((e.ctrlKey||e.metaKey)&&" "===e.key){e.preventDefault(),v(a,e.currentTarget.selectionStart,!0);return}h&&("ArrowDown"===e.key?(e.preventDefault(),x(e=>(e+1)%h.items.length)):"ArrowUp"===e.key?(e.preventDefault(),x(e=>(e-1+h.items.length)%h.items.length)):"Enter"===e.key||"Tab"===e.key?(e.preventDefault(),g(h.items[u])):"Escape"===e.key&&(e.preventDefault(),m(null)))}}}),h&&(0,n.jsx)("ul",{className:"se-pop",role:"listbox",style:{left:j.x+16,...j.y>f-30*h.items.length-50?{bottom:f-j.y-8}:{top:j.y+34}},children:h.items.map((e,s)=>(0,n.jsxs)("li",{role:"option","aria-selected":s===u,className:s===u?"on":"",onMouseDown:s=>{s.preventDefault(),g(e)},children:[(0,n.jsx)("span",{className:"mono",children:e.label}),e.hint&&(0,n.jsx)("i",{children:e.hint})]},"".concat(e.label,"-").concat(s)))})]})}function sK(e){var s;let{result:t}=e,{t:a}=(0,x.s9)(),r=(0,p.dj)(),[c,i]=(0,l.useState)(500);(0,l.useEffect)(()=>i(500),[t]);let o=e=>{var s;null==(s=navigator.clipboard)||s.writeText(e),r(a("db.copied"))},d=0===t.columns.length;return(0,n.jsxs)("div",{className:"dbr",children:[(0,n.jsxs)("div",{className:"dbr-bar small",children:[(0,n.jsx)("b",{children:d?a("db.result.affected",{count:null!=(s=t.affected)?s:0}):a("db.result.rows",{count:t.rows.length})}),(0,n.jsxs)("span",{className:"muted",children:["\xb7 ",t.ms," ms"]}),t.truncated&&(0,n.jsx)("span",{className:"db-trunc",children:a("db.result.truncated",{count:t.rows.length})}),(0,n.jsx)("span",{className:"grow"}),!d&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("button",{className:"btn ghost sm",onClick:()=>o(sB(t)),children:[(0,n.jsx)(eh.A,{size:13}),"CSV"]}),(0,n.jsxs)("button",{className:"btn ghost sm",onClick:()=>o(JSON.stringify(t.rows.map(e=>Object.fromEntries(t.columns.map((s,t)=>[s.name,e[t]]))),null,2)),children:[(0,n.jsx)(eh.A,{size:13}),"JSON"]}),(0,n.jsxs)("button",{className:"btn ghost sm",onClick:()=>{let e=document.createElement("a");e.href=URL.createObjectURL(new Blob([sB(t)],{type:"text/csv"})),e.download="query-".concat(new Date().toISOString().slice(0,19).replace(/[:T]/g,"-"),".csv"),e.click(),setTimeout(()=>URL.revokeObjectURL(e.href),2e3)},children:[(0,n.jsx)(em.A,{size:13}),a("db.download")]})]})]}),d?null:0===t.rows.length?(0,n.jsx)("p",{className:"muted small db-note",children:a("db.result.empty")}):(0,n.jsxs)("div",{className:"dbr-scroll",children:[(0,n.jsxs)("table",{className:"dbr-table",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{className:"n",children:"#"}),t.columns.map((e,s)=>{var l;return(0,n.jsx)("th",{className:"number"==typeof(null==(l=t.rows.find(e=>null!==e[s]))?void 0:l[s])?"num":"",children:e.name},s)})]})}),(0,n.jsx)("tbody",{children:t.rows.slice(0,c).map((e,s)=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"n",children:s+1}),e.map((e,s)=>(0,n.jsx)("td",{className:"number"==typeof e?"num":"",title:"string"==typeof e&&e.length>40?e:void 0,children:null===e?(0,n.jsx)("i",{className:"db-null",children:"NULL"}):String(e)},s))]},s))})]}),t.rows.length>c&&(0,n.jsx)("button",{className:"btn sm dbr-more",onClick:()=>i(e=>e+500),children:a("db.result.more",{count:Math.min(500,t.rows.length-c)})})]})]})}function sG(e){let{cfg:s}=e,{t}=(0,x.s9)();return!1!==s.readOnly?(0,n.jsxs)("span",{className:"db-badge ro",title:t("db.readonly.on"),children:[(0,n.jsx)(s$.A,{size:12}),t("db.readonly.badge")]}):(0,n.jsxs)("span",{className:"db-badge rw",title:t("db.readonly.off"),children:[(0,n.jsx)(sW.A,{size:12}),t("db.write.badge")]})}function sX(e){var s,t;let{o:l,sql:a,setSql:r,area:c,run:i,format:o,ctx:h,busy:u,result:j,error:p,schema:b,database:v,setDatabase:g,saved:f,onSave:w,onUse:N,onManage:y}=e,{t:k}=(0,x.s9)(),C=(0,sf.Wx)(),S=l.config,A=null!=(s=null==b?void 0:b.databases)?s:[];return(0,n.jsxs)("div",{className:"dbq",children:[(0,n.jsxs)("div",{className:"dbq-bar",children:[(0,n.jsxs)("button",{className:"btn primary sm",disabled:u||!a.trim(),onClick:i,title:"Ctrl/⌘ + Enter",children:[u?(0,n.jsx)(d.A,{size:14,className:"spin"}):(0,n.jsx)(m.A,{size:14}),u?k("db.running"):k("db.run")]}),(0,n.jsxs)("button",{className:"btn sm",disabled:!a.trim(),onClick:w,children:[(0,n.jsx)(sl.A,{size:14}),k("db.save")]}),(0,n.jsxs)("button",{className:"btn sm",disabled:!a.trim(),onClick:o,title:k("db.format.hint"),children:[(0,n.jsx)(sJ.A,{size:14}),k("db.format")]}),(0,n.jsx)(U.W1,{label:k("db.saved"),icon:(0,n.jsx)(sP.A,{size:14}),children:e=>(0,n.jsxs)(n.Fragment,{children:[0===f.length?(0,n.jsx)("p",{className:"muted small db-menu-none",children:k("db.saved.none")}):(0,n.jsx)(U.rX,{label:k("db.saved.title"),children:f.map(s=>(0,n.jsx)(U.Dr,{hint:s.sql.replace(/\s+/g," ").slice(0,70),onClick:()=>{e(),N(s.sql,s.database)},children:s.name},s.id))}),(0,n.jsx)(U.MU,{}),(0,n.jsx)(U.Dr,{icon:(0,n.jsx)(se.A,{size:14}),onClick:()=>{e(),y()},children:k("db.saved.manage")})]})}),A.length>1&&(0,n.jsx)("select",{className:"select db-pick",value:null!=(t=null!=v?v:null==b?void 0:b.database)?t:"",onChange:e=>g(e.target.value),"aria-label":k("db.database.pick"),title:k("db.database.pick"),children:A.map(e=>(0,n.jsx)("option",{value:e,children:e},e))}),(0,n.jsx)("span",{className:"grow"}),(0,n.jsx)(sG,{cfg:S}),(0,n.jsxs)(eI.B,{size:"sm",align:"end",label:k("common.help"),title:k("db.help.title"),children:[(0,n.jsx)("p",{children:k("db.help.1")}),(0,n.jsx)("p",{children:k("db.help.2")}),(0,n.jsx)("p",{children:k("db.help.3")}),(0,n.jsx)("p",{children:k("db.help.4")})]}),(0,n.jsx)(sg.i,{compact:!0})]}),(0,n.jsx)("div",{className:"db-ed gx","data-gx-theme":C.theme,style:{"--g-tab":C.tabSize},children:(0,n.jsx)(s_,{value:a,onChange:r,areaRef:c,ctx:h,label:k("db.editor"),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key?(e.preventDefault(),i()):e.altKey&&e.shiftKey&&"f"===e.key.toLowerCase()&&(e.preventDefault(),o())}})}),(0,n.jsx)("div",{className:"dbq-res",children:!u||j||p?p?(0,n.jsx)("div",{className:"gx-note err db-err",children:p}):j?(0,n.jsx)(sK,{result:j}):(0,n.jsx)("p",{className:"muted small db-note",children:k("db.result.none")}):(0,n.jsxs)("p",{className:"muted small db-note",children:[(0,n.jsx)(d.A,{size:14,className:"spin"})," ",k("db.running")]})})]})}var sV=t(12384),sZ=t(96914);function sQ(e){var s;let{o:t,schema:a,err:r,loading:c,onReload:i,database:o,setDatabase:h,onOpen:j}=e,{t:b}=(0,x.s9)(),v=(0,p.dj)(),[g,f]=(0,l.useState)(""),[w,N]=(0,l.useState)({}),[y,k]=(0,l.useState)(null),[C,S]=(0,l.useState)(null),[A,E]=(0,l.useState)(""),z=null!=(s=null==a?void 0:a.databases)?s:[],F=null!=o?o:null==a?void 0:a.database;(0,l.useEffect)(()=>{y&&(S(null),E(""),u.FH.get("/objects/".concat(t.id,"/db/columns?schema=").concat(encodeURIComponent(y.schema),"&table=").concat(encodeURIComponent(y.name)).concat(F&&a&&"sqlite"!==a.engine?"&database=".concat(encodeURIComponent(F)):"")).then(S).catch(e=>E(e instanceof Error?e.message:"")))},[y,t.id,F,a]);let O=(0,l.useMemo)(()=>{var e,s;let t=g.trim().toLowerCase(),n=new Map;for(let l of null!=(e=null==a?void 0:a.tables)?e:[])(!t||l.name.toLowerCase().includes(t))&&(null!=(s=n.get(l.schema))?s:n.set(l.schema,[]).get(l.schema)).push(l);return[...n]},[a,g]),q=1===O.length,T=(0,l.useMemo)(()=>{var e;return[...new Set((null!=(e=null==a?void 0:a.tables)?e:[]).map(e=>e.schema))]},[a]),H=T.every(e=>!1!==w[e]);return(0,n.jsx)(ef,{gap:!0,list:(0,n.jsxs)("aside",{className:"dbs-list",children:[(0,n.jsxs)("div",{className:"dbs-head",children:[z.length>1&&(0,n.jsx)("select",{className:"select",value:null!=F?F:"",onChange:e=>{k(null),h(e.target.value)},"aria-label":b("db.database.pick"),children:z.map(e=>(0,n.jsx)("option",{value:e,children:e},e))}),(0,n.jsxs)("div",{className:"dbs-tools",children:[(0,n.jsx)(p.DO,{className:"grow",value:g,onChange:f,placeholder:b("db.schema.filter"),label:b("db.schema.filter")}),T.length>1&&(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>{let e;return e=!H,N(Object.fromEntries(T.map(s=>[s,e])))},"aria-label":H?b("db.schema.collapseAll"):b("db.schema.expandAll"),title:H?b("db.schema.collapseAll"):b("db.schema.expandAll"),children:H?(0,n.jsx)(sV.A,{size:14}):(0,n.jsx)(sZ.A,{size:14})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:i,"aria-label":b("db.schema.refresh"),title:b("db.schema.refresh"),children:(0,n.jsx)(eQ.A,{size:14,className:c?"spin":""})})]})]}),(0,n.jsx)("div",{className:"dbs-tree",children:r?(0,n.jsx)("p",{className:"gx-note err",children:r}):!a&&c?(0,n.jsxs)("p",{className:"muted small db-note",children:[(0,n.jsx)(d.A,{size:14,className:"spin"})," ",b("db.schema.loading")]}):0===O.length?(0,n.jsx)("p",{className:"muted small db-note",children:b("db.schema.empty")}):O.map(e=>{let[s,t]=e;return(0,n.jsxs)("div",{children:[!q&&(0,n.jsxs)("button",{className:"dbs-group",onClick:()=>N(e=>({...e,[s]:!1===e[s]})),children:[!1===w[s]?(0,n.jsx)(I.A,{size:14}):(0,n.jsx)(R.A,{size:14}),s,(0,n.jsx)("span",{className:"muted",children:t.length})]}),(q||!1!==w[s])&&t.map(e=>(0,n.jsxs)("button",{className:"dbs-table ".concat((null==y?void 0:y.schema)===e.schema&&y.name===e.name?"on":""),onClick:()=>k(e),onDoubleClick:()=>j(e),children:["view"===e.type?(0,n.jsx)(_.A,{size:14}):(0,n.jsx)(sN.A,{size:14}),(0,n.jsx)("span",{className:"nm",children:e.name}),void 0!==e.rows&&(0,n.jsxs)("span",{className:"muted",children:["≈",(0,L._E)(e.rows)]})]},"".concat(e.schema,".").concat(e.name)))]},s)})})]}),children:(0,n.jsx)("section",{className:"dbs-detail",children:y?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"row gap-s wrap",children:[(0,n.jsxs)("h3",{className:"mono res-m0",children:["main"!==y.schema&&(null==a?void 0:a.engine)!=="mysql"?"".concat(y.schema,"."):"",y.name]}),(0,n.jsxs)("span",{className:"muted small",children:["view"===y.type?b("db.schema.view"):b("db.schema.table"),void 0!==y.rows?" \xb7 ".concat(b("db.rows.est",{count:(0,L._E)(y.rows)})):""]}),(0,n.jsx)("span",{className:"grow"}),(0,n.jsxs)("button",{className:"btn primary sm",onClick:()=>j(y),children:[(0,n.jsx)(m.A,{size:14}),b("db.select100")]}),(0,n.jsxs)("button",{className:"btn sm",onClick:()=>{var e;null==(e=navigator.clipboard)||e.writeText(y.name),v(b("db.copied"))},children:[(0,n.jsx)(eh.A,{size:14}),b("db.copyName")]})]}),A?(0,n.jsx)("p",{className:"gx-note err",children:A}):C?(0,n.jsxs)("table",{className:"dbr-table dbs-cols",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:b("db.col.name")}),(0,n.jsx)("th",{children:b("db.col.type")}),(0,n.jsx)("th",{children:b("db.col.null")}),(0,n.jsx)("th",{children:b("db.col.key")}),(0,n.jsx)("th",{children:b("db.col.default")})]})}),(0,n.jsx)("tbody",{children:C.map(e=>{var s;return(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"mono",children:e.name}),(0,n.jsx)("td",{className:"mono",children:e.type}),(0,n.jsx)("td",{children:e.nullable?b("db.yes"):(0,n.jsx)("b",{children:b("db.no")})}),(0,n.jsx)("td",{children:e.key?(0,n.jsx)("span",{className:"db-key",children:e.key}):""}),(0,n.jsx)("td",{className:"mono",children:null!=(s=e.default)?s:(0,n.jsx)("i",{className:"db-null",children:"NULL"})})]},e.name)})})]}):(0,n.jsxs)("p",{className:"muted small db-note",children:[(0,n.jsx)(d.A,{size:14,className:"spin"})," ",b("db.schema.loading")]})]}):(0,n.jsx)("p",{className:"muted db-note",children:b("db.schema.pick")})})})}function sY(e){let{onClose:s,onSave:t,title:a,initial:r=""}=e,{t:c}=(0,x.s9)(),[i,o]=(0,l.useState)(r);return(0,n.jsxs)(p.aF,{title:null!=a?a:c("db.save"),onClose:s,children:[(0,n.jsxs)("div",{className:"field",children:[(0,n.jsx)("label",{children:c("db.saved.name")}),(0,n.jsx)("input",{className:"input",autoFocus:!0,value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{"Enter"===e.key&&i.trim()&&t(i.trim())}})]}),(0,n.jsxs)("div",{className:"row res-end",children:[(0,n.jsx)("button",{className:"btn ghost",onClick:s,children:c("common.cancel")}),(0,n.jsx)("button",{className:"btn primary",disabled:!i.trim(),onClick:()=>t(i.trim()),children:c(a?"common.saveChanges":"db.save")})]})]})}function s0(e){let{o:s,hist:t,saved:a,sql:r,database:c,onUse:i,onChanged:o}=e,{t:d}=(0,x.s9)(),h=(0,p.dj)(),[m,j]=(0,l.useState)(null),[b,v]=(0,l.useState)(null),g=e=>h(e instanceof Error?e.message:"","err"),f=async()=>{try{await u.FH.del("/objects/".concat(s.id,"/db/history")),o()}catch(e){g(e)}},w=async e=>{await u.FH.del("/objects/".concat(s.id,"/db/saved/").concat(e)),o()},N=async(e,t,n)=>{try{await u.FH.patch("/objects/".concat(s.id,"/db/saved/").concat(e),t),n&&h(n),o()}catch(e){g(e)}};return(0,n.jsxs)("div",{className:"dbh",children:[(0,n.jsxs)("section",{children:[(0,n.jsx)("div",{className:"row gap-s",children:(0,n.jsx)("h3",{className:"grow",children:d("db.saved.title")})}),0===a.length?(0,n.jsx)("p",{className:"muted small",children:d("db.saved.none")}):a.map(e=>(0,n.jsxs)("div",{className:"dbh-row",children:[(0,n.jsxs)("button",{className:"dbh-main",onClick:()=>i(e.sql,e.database),title:d("db.saved.use"),children:[(0,n.jsx)("b",{children:e.name}),(0,n.jsx)("code",{className:"mono",title:e.sql,children:e.sql.trim().slice(0,600)})]}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>j(e),"aria-label":d("db.saved.rename"),title:d("db.saved.rename"),children:(0,n.jsx)(se.A,{size:14})}),(0,n.jsx)("button",{className:"btn ghost icon sm",disabled:!r.trim()||r===e.sql,onClick:()=>void N(e.id,{sql:r,database:null!=c?c:""},d("db.saved.updated")),"aria-label":d("db.saved.replace"),title:d("db.saved.replace"),children:(0,n.jsx)(sl.A,{size:14})}),(0,n.jsx)("button",{className:"btn ghost icon sm",onClick:()=>v(e),"aria-label":d("db.delete"),title:d("db.delete"),children:(0,n.jsx)(es.A,{size:14})})]},e.id))]}),(0,n.jsxs)("section",{children:[(0,n.jsxs)("div",{className:"row gap-s",children:[(0,n.jsx)("h3",{className:"grow",children:d("db.hist.title")}),t&&t.length>0&&(0,n.jsxs)("button",{className:"btn ghost sm",onClick:()=>void f(),children:[(0,n.jsx)(es.A,{size:14}),d("db.hist.clear")]})]}),null===t?(0,n.jsx)("p",{className:"muted small",children:d("git.loading")}):0===t.length?(0,n.jsx)("p",{className:"muted small",children:d("db.hist.empty")}):t.map(e=>{var s;return(0,n.jsx)("div",{className:"dbh-row",children:(0,n.jsxs)("button",{className:"dbh-main",onClick:()=>i(e.sql,e.database),title:e.error,children:[(0,n.jsxs)("span",{className:"row gap-s small",children:[(0,n.jsx)("i",{className:"dot ".concat(e.ok?"ok":"err")}),(0,n.jsx)("span",{className:"muted",children:(0,F.KN)(e.at)}),e.ok?(0,n.jsxs)("span",{className:"muted",children:["\xb7 ",void 0!==e.rows?d("db.result.rows",{count:e.rows}):d("db.result.affected",{count:null!=(s=e.affected)?s:0})," \xb7 ",e.ms," ms"]}):(0,n.jsx)("span",{className:"db-bad",children:e.error})]}),(0,n.jsx)("code",{className:"mono",title:e.error?void 0:e.sql,children:e.sql.trim().slice(0,600)})]})},e.n)})]}),m&&(0,n.jsx)(sY,{title:d("db.saved.rename"),initial:m.name,onClose:()=>j(null),onSave:e=>{j(null),N(m.id,{name:e},d("db.saved.updated"))}}),b&&(0,n.jsx)(p.TM,{title:d("db.saved.delete.title",{name:b.name}),body:d("db.saved.delete.body"),confirmLabel:d("db.delete"),danger:!0,onConfirm:()=>w(b.id),onClose:()=>v(null)})]})}function s1(e){let{object:s,pane:t,onPane:a}=e,{t:r}=(0,x.s9)(),c=(0,p.dj)(),i=s.config,o="hive-am.dbq.".concat(s.id),[d,h]=(0,l.useState)(""),[m,j]=(0,l.useState)(void 0),[b,v]=(0,l.useState)(!1),[g,f]=(0,l.useState)(null),[w,N]=(0,l.useState)(""),[y,k]=(0,l.useState)(null),[C,S]=(0,l.useState)(""),[A,E]=(0,l.useState)(!1),[z,F]=(0,l.useState)([]),[L,O]=(0,l.useState)(null),[q,T]=(0,l.useState)(!1),R=(0,l.useRef)(null),I=(0,l.useRef)(new Map),[,H]=(0,l.useState)(0),D=e=>"".concat(null!=m?m:"","|").concat(e.schema,".").concat(e.name),M=(0,l.useMemo)(()=>({schema:y,cols:e=>{let s=I.current.get(D(e));return Array.isArray(s)?s:void 0},need:e=>{let t=D(e);if(I.current.has(t))return;I.current.set(t,"loading");let n=null!=m?m:null==y?void 0:y.database;u.FH.get("/objects/".concat(s.id,"/db/columns?schema=").concat(encodeURIComponent(e.schema),"&table=").concat(encodeURIComponent(e.name)).concat(n&&y&&"sqlite"!==y.engine?"&database=".concat(encodeURIComponent(n)):"")).then(e=>I.current.set(t,e.map(e=>e.name))).catch(()=>I.current.delete(t)).finally(()=>H(e=>e+1))}}),[y,m,s.id]);(0,l.useEffect)(()=>{I.current.clear()},[s.id,s.updated_at,m]);let U=(0,l.useRef)(null);(0,l.useEffect)(()=>{try{var e;h(null!=(e=localStorage.getItem(o))?e:"")}catch(e){}},[o]);let B=e=>{h(e);try{localStorage.setItem(o,e)}catch(e){}},$=(0,l.useCallback)(async e=>{E(!0),S("");try{let t=await u.FH.get("/objects/".concat(s.id,"/db/schema").concat(e?"?database=".concat(encodeURIComponent(e)):""));k(t)}catch(e){S(e instanceof Error?e.message:"")}finally{E(!1)}},[s.id]),W=(0,l.useCallback)(()=>{u.FH.get("/objects/".concat(s.id,"/db/history")).then(O).catch(()=>O([])),u.FH.get("/objects/".concat(s.id,"/db/saved")).then(F).catch(()=>void 0)},[s.id]);(0,l.useEffect)(()=>{$(m)},[$,m,s.updated_at]),(0,l.useEffect)(()=>{W()},[W]);let J=async e=>{let t=R.current,n=t&&t.selectionEnd>t.selectionStart?d.slice(t.selectionStart,t.selectionEnd):d,l=(null!=e?e:n).trim();if(l&&!b){v(!0),N("");try{let e=await u.FH.post("/objects/".concat(s.id,"/db/query"),{sql:l,database:m});f(e)}catch(e){f(null),N(e instanceof Error?e.message:"")}finally{v(!1),W()}}},P=(e,s)=>{let t=d.trimEnd(),n=t?"".concat(t,"\n\n"):"";B(n+e),U.current={from:n.length,to:n.length+e.length},void 0!==s&&j(s),a("query")};(0,l.useEffect)(()=>{let e=U.current,s=R.current;e&&s&&"query"===t&&(U.current=null,requestAnimationFrame(()=>{s.focus(),s.setSelectionRange(e.from,e.to),s.scrollTop=s.scrollHeight}))});let _=async()=>{let e=R.current,s=e&&e.selectionEnd>e.selectionStart;try{var t,n;if(s&&e){let s=await sO(d.slice(e.selectionStart,e.selectionEnd),null!=(n=null==y?void 0:y.engine)?n:i.engine);B(d.slice(0,e.selectionStart)+s+d.slice(e.selectionEnd))}else B(await sO(d,null!=(t=null==y?void 0:y.engine)?t:i.engine))}catch(e){c(r("db.format.fail",{error:e instanceof Error?e.message.split("\n")[0]:""}),"err")}},K=async e=>{try{await u.FH.post("/objects/".concat(s.id,"/db/saved"),{name:e,sql:d,database:m}),c(r("db.saved.done")),W()}catch(e){c(e instanceof Error?e.message:"","err")}};return(0,n.jsxs)("div",{className:"dbw",children:["query"===t&&(0,n.jsx)(sX,{o:s,sql:d,setSql:B,area:R,run:()=>void J(),format:()=>void _(),ctx:M,busy:b,result:g,error:w,schema:y,database:m,setDatabase:j,saved:z,onSave:()=>T(!0),onUse:P,onManage:()=>a("history")}),"schema"===t&&(0,n.jsx)(sQ,{o:s,schema:y,err:C,loading:A,onReload:()=>void $(m),database:m,setDatabase:j,onOpen:e=>{var s;let t=function(e,s){let t="sqlite"===e?sM(e,s.name):"".concat(sM(e,s.schema),".").concat(sM(e,s.name));return"mssql"===e?"SELECT TOP 100 * FROM ".concat(t):"SELECT * FROM ".concat(t," LIMIT 100")}(null!=(s=null==y?void 0:y.engine)?s:i.engine,e);B(t),a("query"),J(t)}}),"history"===t&&(0,n.jsx)(s0,{o:s,hist:L,saved:z,sql:d,database:m,onUse:P,onChanged:W}),q&&(0,n.jsx)(sY,{onClose:()=>T(!1),onSave:e=>{T(!1),K(e)}})]})}function s2(e){let{id:s}=e,{t}=(0,x.s9)(),{objects:a,ready:r,objects:c,error:i,retry:o}=(0,j.o0)(),d=s?a.find(e=>e.id===s):void 0,[h,m]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{try{m("1"===localStorage.getItem("hive-obj-switcher-collapsed"))}catch(e){}},[]),(0,n.jsxs)("div",{className:"ws ".concat(h?"sw-collapsed":""),children:[(0,n.jsx)(S,{activeId:s,collapsed:h,onToggle:()=>m(e=>{try{localStorage.setItem("hive-obj-switcher-collapsed",e?"0":"1")}catch(e){}return!e})}),!r&&i?(0,n.jsx)("section",{className:"ws-chat",children:(0,n.jsx)("div",{className:"ow-pad",children:(0,n.jsx)(p.lZ,{kind:"err",children:(0,n.jsxs)("div",{className:"row gap-s wrap",children:[(0,n.jsx)("span",{className:"grow",children:i}),(0,n.jsx)("button",{className:"btn sm",onClick:()=>void o(),children:t("rs.retry")})]})})})}):s||r?s?d?(0,n.jsx)(s4,{object:d},d.id):(0,n.jsx)("section",{className:"ws-chat",children:(0,n.jsx)("div",{className:"ow-pad",children:r?(0,n.jsx)(p.pp,{title:t("ow.gone")}):(0,n.jsx)(p.pp,{title:t("git.loading")})})}):(0,n.jsx)("section",{className:"ws-chat",children:(0,n.jsx)("div",{className:"ow-pad",children:(0,n.jsx)(p.pp,{title:t(c.length?"ow.pick":"ow.empty.title"),body:c.length?void 0:t("ow.empty.body")})})}):(0,n.jsx)("section",{className:"ws-chat"})]})}function s4(e){let{object:s}=e,{t}=(0,x.s9)(),f=(0,p.dj)(),w="http"===s.kind?["requests","history","vars","config"]:"database"===s.kind?["query","schema","history","config"]:["summary","logs","config"],[N,y]=(0,b.Z)("tab",w[0]),k=w.includes(N)?N:w[0],[C,S]=(0,l.useState)(""),[A,E]=(0,l.useState)(!1),[z,F]=(0,l.useState)(!1),[L,O]=(0,l.useState)(null),{icon:q,color:T}=v.Nd[s.kind],R=s.state.status,I="running"===R||"starting"===R,H=async e=>{O(e);try{await u.FH.post("/objects/".concat(s.id,"/action"),{action:e})}catch(s){f("".concat(t("obj.act.failed",{action:t("obj.act.".concat(e))}),": ").concat(s instanceof Error?s.message:""),"err")}finally{O(null)}},D=async()=>{O("test");try{let e=await u.FH.post("/object-db/test",{id:s.id,config:s.config});f("".concat(t("db.test.ok")," \xb7 ").concat(e.version," \xb7 ").concat(e.ms," ms"))}catch(e){f(e instanceof Error?e.message:"","err")}finally{O(null)}},M="cluster"===s.kind,U=M?s.config.members:[],{objects:B}=(0,j.o0)(),$=U.map(e=>{var s,t;return null!=(t=null==(s=B.find(s=>s.id===e))?void 0:s.name)?t:""}).filter(Boolean),W="server"===s.kind||"docker"===s.kind&&"compose"!==s.config.mode,J="docker"===s.kind?s.config:null,P=[];"http"!==s.kind&&"database"!==s.kind&&(P.push({id:"stop",label:t(M?"obj.act.stopAll":"obj.act.stop"),icon:(0,n.jsx)(a.A,{size:14}),disabled:!!L||!I&&"error"!==R,onClick:()=>void H("stop")}),P.push({id:"restart",label:t(M?"obj.act.restartAll":"obj.act.restart"),icon:(0,n.jsx)(r.A,{size:14}),disabled:!!L,onClick:()=>void H("restart")})),J&&"container"===J.mode&&P.push({id:"inspect",label:t("svc.inspect"),icon:(0,n.jsx)(c.A,{size:14}),onClick:()=>E(!0)}),J&&"existing"!==J.mode&&P.push({id:"recreate",label:t("obj.act.recreate"),icon:(0,n.jsx)(i.A,{size:14}),danger:!0,hint:t("svc.recreate.hint"),disabled:!!L,onClick:()=>F(!0)}),J&&"compose"===J.mode&&P.push({id:"rebuild",label:t("obj.act.rebuild"),icon:(0,n.jsx)(o.A,{size:14}),hint:t("svc.rebuild.hint"),disabled:!!L,onClick:()=>void H("rebuild")});let _=(0,n.jsxs)(n.Fragment,{children:["database"===s.kind&&(0,n.jsxs)("button",{className:"btn sm",disabled:!!L,onClick:()=>void D(),children:["test"===L?(0,n.jsx)(d.A,{size:14,className:"spin"}):(0,n.jsx)(h.A,{size:14}),t("db.test")]}),"http"!==s.kind&&"database"!==s.kind&&(0,n.jsxs)("button",{className:"btn primary sm",disabled:!!L||(M?"running"===R:I),onClick:()=>void H("start"),children:[(0,n.jsx)(m.A,{size:14}),t(M?"obj.act.startAll":"obj.act.start")]}),W&&(0,n.jsx)(eg.N,{spec:{objectId:s.id},title:"server"===s.kind?t("dock.here"):t("dock.shell")})]});return(0,n.jsxs)("section",{className:"ws-chat",children:[(0,n.jsx)(p.DS,{back:{href:"/",label:t("ow.back")},avatar:(0,n.jsx)("span",{className:"obj-ico",style:{"--c":T},children:(0,n.jsx)(q,{size:22})}),title:s.name,meta:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{className:"ostatus ".concat(v.Wy[R]),children:[(0,n.jsx)(g.md,{status:R}),t("obj.status.".concat(R))]}),(0,n.jsx)("span",{children:t("obj.kind.".concat(s.kind))}),s.state.detail&&(0,n.jsx)("span",{children:(0,v.HS)(t,s.state.detail)})]}),primary:_,actions:P}),(0,n.jsx)(p.tU,{idPrefix:"ow",label:t("rs.tabs"),value:k,onChange:e=>{"logs"===e&&S(""),y(e)},tabs:w.map(e=>({id:e,label:t("ow.tab.".concat(e))}))}),(0,n.jsx)("div",{className:"ow-body ".concat("logs"===k||"requests"===k||"history"===k||"query"===k||"schema"===k?"full":""),children:(0,n.jsxs)(p.Kp,{id:k,value:k,idPrefix:"ow",children:["summary"===k&&(0,n.jsx)(ee,{object:s,onSeeLogs:e=>{S(null!=e?e:""),y("logs")}}),"logs"===k&&(0,n.jsx)(ep,{id:s.id,members:M?$:void 0,initialFilter:C||void 0},C),"config"===k&&(0,n.jsx)(el,{object:s}),"database"===s.kind&&("query"===k||"schema"===k||"history"===k)&&(0,n.jsx)(s1,{object:s,pane:k,onPane:y}),"http"===s.kind&&("requests"===k||"history"===k)&&(0,n.jsx)(sS,{object:s,pane:k,onOpenVars:()=>y("vars"),onGoRequests:()=>y("requests")}),"vars"===k&&(0,n.jsx)(sE,{object:s})]})}),A&&(0,n.jsx)(G,{objectId:s.id,title:s.name,onClose:()=>E(!1)}),z&&(0,n.jsx)(p.TM,{title:t("rs.recreate.title",{name:s.name}),body:t("svc.recreate.hint"),confirmLabel:t("obj.act.recreate"),danger:!0,onConfirm:()=>H("recreate"),onClose:()=>F(!1)})]})}}}]);
|