PageSourceSearch

https://qwarweww-newspace.hf.space/static/js/async/4057.960e2d891e.js

js qwarweww-newspace.hf.space collected 2026-10-03 17:15:36 UTC 134,123 bytes, 2 lines download raw bytes

1/*! LICENSE: 4057.960e2d891e.js.LICENSE.txt */
2"use strict";(self.rspackChunknewapi_web=self.rspackChunknewapi_web||[]).push([[4057],{13581(e,t,a){var s=a(53540),l=a(92778);function n(){return(0,s.I)({queryKey:["system-options"],queryFn:l.y,staleTime:3e5})}function r(e,t){if(!e)return t;let a={...t},s=[];return e.forEach(e=>{if(e.key in t){let l=function(e,t){if("boolean"==typeof t)return{success:!0,value:"true"===e||"1"===e};if("number"==typeof t){let a=e.trim();if(""===a)return{success:!1,error:"Empty string for number field",fallback:t};let s=Number(a);return Number.isNaN(s)?{success:!1,error:`Invalid number: "${e}"`,fallback:t}:{success:!0,value:s}}if(Array.isArray(t))try{let a=JSON.parse(e);if(!Array.isArray(a))return{success:!1,error:"Expected array but got non-array JSON",fallback:t};if(t.length>0){let e=typeof t[0],s=a.find(t=>typeof t!==e);if(void 0!==s)return{success:!1,error:`Array element type mismatch: expected ${e}, got ${typeof s}`,fallback:t}}return{success:!0,value:a}}catch(e){return{success:!1,error:`JSON parse failed: ${e instanceof Error?e.message:String(e)}`,fallback:t}}return{success:!0,value:e}}(e.value,t[e.key]);l.success?a[e.key]=l.value:(a[e.key]=l.fallback,s.push({key:e.key,error:l.error}))}}),s.length,a}a.d(t,{b:()=>n,n:()=>r})},27704(e,t,a){a.r(t),a.d(t,{component:()=>t2});var s=a(72361),l=a(96962),n=a(2718),r=a(82799),i=a(66002),o=a(68413),d=a(6702),c=a(47745),m=a(72868),u=a(56920),h=a(39987),x=a(55724),p=a(85949),g=a(92702),j=a(95227),f=a(52671),y=a(26197),v=a(9781);let b=(0,v.A)("wifi-off",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);
2var N=a(43284),_=a(56275);function w(e){let{label:t,status:a}=e;return(0,s.jsxs)("div",{className:"flex items-center gap-3",children:["loading"===a&&(0,s.jsx)(x.A,{className:"text-primary h-5 w-5 animate-spin"}),"done"===a&&(0,s.jsx)(p.A,{className:"h-5 w-5 text-green-500"}),"pending"===a&&(0,s.jsx)(g.A,{className:"text-muted-foreground/40 h-5 w-5"}),(0,s.jsx)("span",{className:(0,_.cn)("text-sm","loading"===a&&"text-foreground font-medium","done"===a&&"text-muted-foreground","pending"===a&&"text-muted-foreground/60"),children:t})]})}function C(e){let{children:t,loading:a,loadingPhase:l="settings",isEnabled:n,connectionLoading:i,connectionOk:o,connectionError:c,onRetry:u}=e,{t:h}=(0,d.Bd)(),p=(0,r.Z)(),g=()=>{p({to:"/system-settings/models/$section",params:{section:"model-deployment"}})};if(a||i){let e="connection"===l?"loading":"done"===l&&o?"done":"pending";return(0,s.jsx)("div",{className:"mx-auto mt-8 max-w-md",children:(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-12",children:[(0,s.jsx)(x.A,{className:"text-primary mb-6 h-10 w-10 animate-spin"}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)(w,{label:h("Loading configuration"),status:"settings"===l?"loading":"connection"===l||"done"===l?"done":"pending"}),(0,s.jsx)(w,{label:h("Checking connection"),status:e})]})]})})}return n?!1===o&&c?(0,s.jsxs)("div",{className:"mx-auto mt-8 max-w-md",children:[(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-2xl bg-red-100 dark:bg-red-900/20",children:(0,s.jsx)(b,{className:"h-8 w-8 text-red-600 dark:text-red-400"})}),(0,s.jsx)("h3",{className:"mb-6 text-xl font-semibold",children:h("Connection failed")})]}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)(N.Fc,{variant:"destructive",children:[(0,s.jsx)(f.A,{className:"h-4 w-4"}),(0,s.jsx)(N.XL,{children:h("Connection error")}),(0,s.jsx)(N.TN,{children:h(c)})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(m.$,{variant:"outline",onClick:u,className:"flex-1",children:h("Retry")}),(0,s.jsxs)(m.$,{onClick:g,className:"flex-1",children:[(0,s.jsx)(y.A,{className:"mr-2 h-4 w-4"}),h("Go to settings")]})]})]})]}):(0,s.jsx)(s.Fragment,{children:t}):(0,s.jsxs)("div",{className:"mx-auto mt-8 max-w-md",children:[(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-2xl bg-amber-100 dark:bg-amber-900/20",children:(0,s.jsx)(j.A,{className:"h-8 w-8 text-amber-600 dark:text-amber-400"})}),(0,s.jsx)("h3",{className:"mb-6 text-xl font-semibold",children:h("Model deployment service is disabled")})]}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)(N.Fc,{variant:"default",children:[(0,s.jsx)(f.A,{className:"h-4 w-4"}),(0,s.jsx)(N.XL,{children:h("Configuration required")}),(0,s.jsx)(N.TN,{children:h("Please enable io.net model deployment service and configure an API key in System Settings.")})]}),(0,s.jsxs)(m.$,{onClick:g,className:"w-full",children:[(0,s.jsx)(y.A,{className:"mr-2 h-4 w-4"}),h("Go to settings")]})]})]})}var S=a(53540),k=a(20598),R=a(55045),A=a(92379),M=a(7579),z=a(8803);let F={openai:{path:"/v1/chat/completions",method:"POST"},"openai-response":{path:"/v1/responses",method:"POST"},anthropic:{path:"/v1/messages",method:"POST"},gemini:{path:"/v1beta/models/{model}:generateContent",method:"POST"},"jina-rerank":{path:"/rerank",method:"POST"},"image-generation":{path:"/v1/images/generations",method:"POST"},embeddings:{path:"/v1/embeddings",method:"POST"}},I={all:["models"],lists:()=>[...I.all,"list"],list:e=>[...I.lists(),e],detail:e=>[...I.all,"detail",e],missing:()=>[...I.all,"missing"]},E={all:["vendors"],lists:()=>[...E.all,"list"],list:e=>[...E.lists(),e],detail:e=>[...E.all,"detail",e]},O={all:["prefill-groups"],lists:()=>[...O.all,"list"],list:e=>[...O.lists(),e]},$={all:["deployments"],lists:()=>[...$.all,"list"],list:e=>[...$.lists(),e],detail:e=>[...$.all,"detail",e]};var q=a(33271);function B(e){return e?e.split(",").map(e=>
2e.trim()).filter(Boolean):[]}var V=a(25732);V.Ik({id:V.ai().optional(),model_name:V.Yj().min(1,"Model name is required"),description:V.Yj().default(""),icon:V.Yj().default(""),tags:V.YO(V.Yj()).default([]),vendor_id:V.ai().optional(),endpoints:V.Yj().default(""),name_rule:V.ai().min(0).max(3).default(0),status:V.zM().default(!0),sync_official:V.zM().default(!0),enable_groups:V.YO(V.Yj()).default([]),quota_types:V.YO(V.ai()).default([])}),V.Ik({id:V.ai().optional(),name:V.Yj().min(1,"Vendor name is required"),description:V.Yj().default(""),icon:V.Yj().default(""),status:V.ai().default(1)});var D=a(19376);async function K(e,t,a){try{let s=await (0,h.vo)(e,1);s.success?(k.oR.success(D.Ay.t("Model enabled successfully")),t?.invalidateQueries({queryKey:I.lists()}),a?.()):k.oR.error(s.message||D.Ay.t("Failed to enable model"))}catch(e){k.oR.error(e?.message||D.Ay.t("Failed to enable model"))}}async function P(e,t,a){try{let s=await (0,h.vo)(e,0);s.success?(k.oR.success(D.Ay.t("Model disabled successfully")),t?.invalidateQueries({queryKey:I.lists()}),a?.()):k.oR.error(s.message||D.Ay.t("Failed to disable model"))}catch(e){k.oR.error(e?.message||D.Ay.t("Failed to disable model"))}}async function J(e,t,a,s){1===t?await P(e,a,s):await K(e,a,s)}async function T(e,t,a){try{let s=await (0,h.De)(e);s.success?(k.oR.success(D.Ay.t("Model deleted successfully")),t?.invalidateQueries({queryKey:I.lists()}),a?.()):k.oR.error(s.message||D.Ay.t("Failed to delete model"))}catch(e){k.oR.error(e?.message||D.Ay.t("Failed to delete model"))}}async function Y(e,t,a){if(0===e.length)return void k.oR.error(D.Ay.t("Please select at least one model"));try{let s=e.map(e=>(0,h.De)(e)),l=await Promise.all(s),n=0,r=0;l.forEach((t,a)=>{t.success?n++:(r++,console.error(`Failed to delete model ${e[a]}:`,t.message))}),n>0&&(k.oR.success(D.Ay.t("Successfully deleted {{count}} model(s)",{count:n})),t?.invalidateQueries({queryKey:I.lists()}),a?.(n)),r>0&&k.oR.error(D.Ay.t("Failed to delete {{count}} model(s)",{count:r}))}catch(e){k.oR.error(e?.message||D.Ay.t("Batch delete failed"))}}async function L(e,t,a){if(0===e.length)return void k.oR.error(D.Ay.t("Please select at least one model"));try{let s=e.map(e=>(0,h.vo)(e,1)),l=await Promise.all(s),n=0,r=0;l.forEach(e=>{e.success?n++:r++}),n>0&&(k.oR.success(D.Ay.t("Successfully enabled {{count}} model(s)",{count:n})),t?.invalidateQueries({queryKey:I.lists()}),a?.()),r>0&&k.oR.error(D.Ay.t("Failed to enable {{count}} model(s)",{count:r}))}catch(e){k.oR.error(e?.message||D.Ay.t("Batch enable failed"))}}async function U(e,t,a){if(0===e.length)return void k.oR.error(D.Ay.t("Please select at least one model"));try{let s=e.map(e=>(0,h.vo)(e,0)),l=await Promise.all(s),n=0,r=0;l.forEach(e=>{e.success?n++:r++}),n>0&&(k.oR.success(D.Ay.t("Successfully disabled {{count}} model(s)",{count:n})),t?.invalidateQueries({queryKey:I.lists()}),a?.()),r>0&&k.oR.error(D.Ay.t("Failed to disable {{count}} model(s)",{count:r}))}catch(e){k.oR.error(e?.message||D.Ay.t("Batch disable failed"))}}var W=a(92429),H=a(86094),G=a(76336),Q=a(60665),Z=a(65277),X=a(14653),ee=a(43494),et=a(42817),ea=a(28079),es=a(84368);function el(e){return"string"==typeof e?e.trim().toLowerCase():""}var en=a(60641),er=a(1738),ei=a(38939);function eo(e,t){let a="number"==typeof e?e:Number(e);return Number.isFinite(a)?Math.max(0,Math.round(a)):t}function ed(e){let{open:t,onOpenChange:a,deploymentId:n}=e,{t:r}=(0,d.Bd)(),i=(0,l.jE)(),[c,u]=(0,o.useState)(1),[p,g]=(0,o.useState)(!1);(0,o.useEffect)(()=>{t&&u(1)},[t]);let{data:j,isLoading:f}=(0,S.I)({queryKey:["deployment-details-for-extend",n],queryFn:()=>n?(0,h.i8)(n):null,enabled:t&&null!==n}),y=j?.data,v=(0,o.useMemo)(()=>{if(!y)return null;let e=eo(y.hardware_id,0),t=eo(y.gpus_per_container,0),a=eo(y.total_containers,0),s=(Array.isArray(y.locations)?y.locations:[]).map(e=>e&&"object"==typeof e?eo(e?.id,0):0).filter(e=>e>0);return e<=0||t<=0||a<=0||0===s.length?null:{hardware_id:e,gpus_per_container:t,replica_count:a,location_ids:s}},[y]),{data:b,isLoading:N,isFetching:_}=(0,S.I)({queryKey:["deployment-extend-price",n,c,v],queryFn:()=>v?(0,h.c9)({location_ids:v.location_ids,hardware_id:v.hardware_id,gpus_per_container:v.gpus_per_container,replica_count:v.replica_count,duration_hours:c,currency:"usdc"}):null,enabled:t&&!!v&&c>0}),w=(0,o.useMemo)(()=>{let e=b?.data;if(!e||"object"!=typeof e)return"";let t=e.price_breakdown,a=e.total_cost;t&&"object"==typeof t&&!Array.isArray(t)&&(a=t.total_cost??t.totalCost??t.TotalCost??a);let s=e.currency??"USDC";return null==a?"":`${String(a)} ${String(s).toUpperCase()}`.trim()},[b]),C=!!n&&c>0&&!p,R=async()=>
2{if(!n)return;let e=eo(c,1);if(e<=0)return void k.oR.error(r("Please enter a valid duration"));g(!0);try{let t=await (0,h.MG)(n,e);if(t.success){k.oR.success(r("Extended successfully")),i.invalidateQueries({queryKey:$.lists()}),i.invalidateQueries({queryKey:["deployment-details"]}),a(!1);return}k.oR.error(t.message||r("Extend failed"))}catch(e){k.oR.error(e instanceof Error?e.message:r("Extend failed"))}finally{g(!1)}};return(0,s.jsx)(en.l,{open:t,onOpenChange:a,title:r("Extend deployment"),contentClassName:"sm:max-w-lg",footerClassName:"mt-4",contentHeight:"auto",bodyClassName:"space-y-4",footer:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(m.$,{variant:"outline",onClick:()=>a(!1),children:r("Cancel")}),(0,s.jsxs)(m.$,{onClick:()=>void R(),disabled:!C,children:[p?(0,s.jsx)(x.A,{className:"mr-2 h-4 w-4 animate-spin"}):null,r("Extend")]})]}),children:f?(0,s.jsx)("div",{className:"flex items-center justify-center py-10",children:(0,s.jsx)(x.A,{className:"text-muted-foreground h-6 w-6 animate-spin"})}):(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"text-muted-foreground text-sm",children:[r("Deployment ID"),":"," ",(0,s.jsx)("span",{className:"font-mono",children:n})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("div",{className:"text-sm font-medium",children:r("Duration (hours)")}),(0,s.jsx)(er.p,{type:"number",min:1,value:c,onChange:e=>u(eo(e.target.value,1))}),(0,s.jsx)("div",{className:"text-muted-foreground text-xs",children:r("This will extend the deployment by the specified hours.")})]}),(0,s.jsx)(ei.w,{}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("div",{className:"text-sm font-medium",children:r("Estimated cost")}),(0,s.jsx)("div",{className:"text-muted-foreground text-sm",children:N||_?(0,s.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,s.jsx)(x.A,{className:"h-4 w-4 animate-spin"}),r("Calculating...")]}):v&&w||r("Not available")}),v?null:(0,s.jsx)("div",{className:"text-muted-foreground text-xs",children:r("Unable to estimate price for this deployment.")})]})]})})}function ec(e){let{open:t,onOpenChange:a,deploymentId:n,currentName:r}=e,{t:i}=(0,d.Bd)(),c=(0,l.jE)(),[u,p]=(0,o.useState)(r||""),[g,j]=(0,o.useState)(!1);(0,o.useEffect)(()=>{t&&p(r||"")},[t,r]);let f=u.trim(),{data:y,isFetching:v}=(0,S.I)({queryKey:["deployment-rename-check",f],queryFn:()=>f?(0,h.Z7)(f):null,enabled:t&&!!f,staleTime:1e4}),b=y?.success===!0?y?.data?.available:void 0,N=(0,o.useMemo)(()=>f?v?i("Checking name..."):!0===b?i("Name is available"):!1===b?i("Name is not available"):"":i("Enter a new name"),[b,v,i,f]),_=!!n&&!!f&&!1!==b&&!g,w=async()=>{if(n){if(!f)return void k.oR.error(i("Please enter a name"));if(!1===b)return void k.oR.error(i("Name is not available"));j(!0);try{let e=await (0,h.Ab)(n,f);if(e.success){k.oR.success(i("Renamed successfully")),c.invalidateQueries({queryKey:$.lists()}),c.invalidateQueries({queryKey:["deployment-details"]}),a(!1);return}k.oR.error(e.message||i("Rename failed"))}catch(e){k.oR.error(e instanceof Error?e.message:i("Rename failed"))}finally{j(!1)}}};return(0,s.jsx)(en.l,{open:t,onOpenChange:a,title:i("Rename deployment"),contentClassName:"sm:max-w-lg",footerClassName:"mt-4",contentHeight:"auto",bodyClassName:"space-y-4",footer:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(m.$,{variant:"outline",onClick:()=>a(!1),children:i("Cancel")}),(0,s.jsxs)(m.$,{onClick:()=>void w(),disabled:!_,children:[g?(0,s.jsx)(x.A,{className:"mr-2 h-4 w-4 animate-spin"}):null,i("Rename")]})]}),children:(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{className:"text-muted-foreground text-sm",children:[i("Deployment ID"),":"," ",(0,s.jsx)("span",{className:"font-mono",children:n})]}),(0,s.jsx)(er.p,{placeholder:i("Enter a new name"),value:u,onChange:e=>p(e.target.value),autoComplete:"off"}),(0,s.jsx)("div",{className:"text-muted-foreground text-xs",children:N})]})})}var em=a(48367),eu=a(86832),eh=a(63859),ex=a(91460),ep=a(6242),eg=a(36710);let ej=V.Ik({image_url:V.Yj().optional(),traffic_port:eh.ai().int().min(1).max(65535).optional(),entrypoint:V.Yj().optional(),args:V.Yj().optional(),command:V.Yj().optional(),registry_username:V.Yj().optional(),registry_secret:V.Yj().optional(),env_json:V.Yj().optional(),secret_env_json:V.Yj().optional()}),ef="update-config-form";function ey(e){if(!e||!e.trim())return;let t=JSON.parse(e);if(!t||"object"!=typeof t||Array.isArray(t))throw Error("JSON must be an object");return Object.fromEntries(Object.entries(t).map(e=>
2{let[t,a]=e;return[t,String(a)]}))}function ev(e){let{open:t,onOpenChange:a,deploymentId:n}=e,{t:r}=(0,d.Bd)(),i=(0,l.jE)(),c=(0,eu.mN)({resolver:(0,em.u)(ej),defaultValues:{image_url:"",traffic_port:void 0,entrypoint:"",args:"",command:"",registry_username:"",registry_secret:"",env_json:"",secret_env_json:""}}),{data:u,isLoading:p}=(0,S.I)({queryKey:["deployment-details-for-update",n],queryFn:()=>n?(0,h.i8)(n):null,enabled:t&&null!==n}),g=u?.data;(0,o.useEffect)(()=>{if(!t||!g)return;let e=g.container_config&&"object"==typeof g.container_config?g.container_config:{},a="string"==typeof e.image_url?e.image_url:"",s="number"==typeof e.traffic_port?e.traffic_port:void 0,l=Array.isArray(e.entrypoint)?e.entrypoint.map(e=>"string"==typeof e?e:"").filter(Boolean):[],n=e.env_variables&&"object"==typeof e.env_variables&&!Array.isArray(e.env_variables)?e.env_variables:{};c.reset({image_url:a,traffic_port:s,entrypoint:l.join(" "),args:"",command:"",registry_username:"",registry_secret:"",env_json:Object.keys(n).length?JSON.stringify(n,null,2):"",secret_env_json:""})},[t,g,c]);let j=(0,o.useMemo)(()=>n?`${r("Update configuration")} - ${n}`:r("Update configuration"),[n,r]),f=async e=>{if(n)try{let t=ey(e.env_json),s=ey(e.secret_env_json),l=e.entrypoint?e.entrypoint.split(" ").map(e=>e.trim()).filter(Boolean):void 0,o=e.args?e.args.split(" ").map(e=>e.trim()).filter(Boolean):void 0,d=await (0,h.VJ)(n,{image_url:e.image_url?.trim()||void 0,traffic_port:"number"==typeof e.traffic_port?e.traffic_port:void 0,registry_username:e.registry_username?.trim()||void 0,registry_secret:e.registry_secret?.trim()||void 0,command:e.command?.trim()||void 0,...l?.length?{entrypoint:l}:{},...o?.length?{args:o}:{},...t?{env_variables:t}:{},...s?{secret_env_variables:s}:{}});if(d.success){k.oR.success(r("Updated successfully")),i.invalidateQueries({queryKey:$.lists()}),i.invalidateQueries({queryKey:["deployment-details"]}),a(!1);return}k.oR.error(d.message||r("Update failed"))}catch(t){let e=t instanceof Error?t.message:r("Update failed");k.oR.error(e)}};return(0,s.jsx)(en.l,{open:t,onOpenChange:a,title:j,contentClassName:"max-h-[calc(100dvh-2rem)] overflow-hidden max-sm:w-screen max-sm:max-w-none max-sm:rounded-none max-sm:p-4 sm:max-w-3xl",contentHeight:"auto",bodyClassName:"space-y-4",footer:p?null:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(m.$,{type:"button",variant:"outline",onClick:()=>a(!1),children:r("Cancel")}),(0,s.jsxs)(m.$,{type:"submit",form:ef,disabled:c.formState.isSubmitting,children:[c.formState.isSubmitting?(0,s.jsx)(x.A,{className:"mr-2 h-4 w-4 animate-spin"}):null,r("Update")]})]}),children:p?(0,s.jsx)("div",{className:"flex items-center justify-center py-10",children:(0,s.jsx)(x.A,{className:"text-muted-foreground h-6 w-6 animate-spin"})}):(0,s.jsx)("div",{className:"max-h-[calc(100dvh-8.5rem)] overflow-y-auto py-2 pr-1 sm:max-h-[72vh]",children:(0,s.jsx)(eg.lV,{...c,children:(0,s.jsxs)("form",{id:ef,onSubmit:c.handleSubmit(f),autoComplete:"off",className:"space-y-4",children:[(0,s.jsxs)("div",{className:"grid gap-3 md:grid-cols-2 md:gap-4",children:[(0,s.jsx)(eg.zB,{control:c.control,name:"image_url",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Image")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{placeholder:"ollama/ollama:latest",...t})}),(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsx)(eg.zB,{control:c.control,name:"traffic_port",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Port")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{type:"number",min:1,max:65535,value:"number"==typeof t.value||"string"==typeof t.value?t.value:"",onChange:e=>{let a=e.target.value;t.onChange(""===a?void 0:Number(a))},onBlur:t.onBlur,name:t.name,ref:t.ref})}),(0,s.jsx)(eg.C5,{})]})}})]}),(0,s.jsxs)("div",{className:"grid gap-3 md:grid-cols-2 md:gap-4",children:[(0,s.jsx)(eg.zB,{control:c.control,name:"entrypoint",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Entrypoint (space separated)")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{placeholder:"bash -lc",...t})}),(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsx)(eg.zB,{control:c.control,name:"args",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Args (space separated)")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{placeholder:"--foo bar",...t})}),(0,s.jsx)(eg.C5,{})]})}})]}),(0,s.jsx)(eg.zB,{control:c.control,name:"command",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Command")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{placeholder:"Optional",...t})}),(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsxs)(ep.Nt,{className:"rounded-md border p-3",children:[(0,s.jsx)(ep.R6,{className:"cursor-pointer text-sm",children:r("Registry (optional)")}),(0,s.jsx)(ep.Ke,{children:(0,s.jsxs)("div",{className:"mt-3 grid gap-3 md:grid-cols-2 md:gap-4",children:[(0,s.jsx)(eg.zB,{control:c.control,name:"registry_username",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Registry username")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{autoComplete:"off",...t})}),(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsx)(eg.zB,{control:c.control,name:"registry_secret",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Registry secret")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{type:"password",autoComplete:"off",...t})}),(0,s.jsx)(eg.C5,{})]})}})]})})]}),(0,s.jsxs)(ep.Nt,{className:"rounded-md border p-3",children:[(0,s.jsx)(ep.R6,{className:"cursor-pointer text-sm",children:r("Environment variables")}
2),(0,s.jsx)(ep.Ke,{children:(0,s.jsxs)("div",{className:"mt-3 grid gap-3 md:grid-cols-2 md:gap-4",children:[(0,s.jsx)(eg.zB,{control:c.control,name:"env_json",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Env (JSON object)")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(ex.B,{value:t.value||"",onChange:t.onChange,name:t.name,onBlur:t.onBlur,textareaRef:t.ref,placeholder:'{"KEY":"VALUE"}',heightClassName:"h-40 min-h-40 max-h-40"})}),(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsx)(eg.zB,{control:c.control,name:"secret_env_json",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Secret env (JSON object)")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(ex.B,{value:t.value||"",onChange:t.onChange,name:t.name,onBlur:t.onBlur,textareaRef:t.ref,placeholder:'{"SECRET":"VALUE"}',heightClassName:"h-40 min-h-40 max-h-40"})}),(0,s.jsx)(eg.C5,{})]})}})]})})]})]})})})})}var eb=a(99893),eN=a(88693),e_=a(66552);function ew(e){let{open:t,onOpenChange:a,deploymentId:l}=e,{t:n}=(0,d.Bd)(),{data:r,isLoading:i,refetch:c,isFetching:u}=(0,S.I)({queryKey:["deployment-details",l],queryFn:()=>l?(0,h.i8)(l):null,enabled:t&&null!==l}),{data:p,isLoading:g,refetch:j,isFetching:f}=(0,S.I)({queryKey:["deployment-details-containers",l],queryFn:()=>l?(0,h.sC)(l):null,enabled:t&&null!==l}),y=r?.data,v=(0,o.useMemo)(()=>{let e=p?.data?.containers;return Array.isArray(e)?e:[]},[p?.data?.containers]),b=(0,o.useMemo)(()=>{let e=y?.locations;return Array.isArray(e)?e.map(e=>{if(!e||"object"!=typeof e)return null;let t=e?.name,a=e?.iso2,s=e?.id;return`${String(t??s??"")}${a?` (${a})`:""}`.trim()}).filter(Boolean):[]},[y]),N=async()=>{if(null!=l)try{await navigator.clipboard.writeText(String(l)),k.oR.success(n("Copied"))}catch{k.oR.error(n("Copy failed"))}},_=(0,o.useMemo)(()=>{if(!y)return"";try{return JSON.stringify(y,null,2)}catch{return""}},[y]),w=i||g,C=!w&&!r?.success,R=!w&&r?.success;return(0,s.jsx)(en.l,{open:t,onOpenChange:a,title:n("Deployment details"),contentClassName:"max-h-[calc(100dvh-2rem)] overflow-hidden max-sm:w-screen max-sm:max-w-none max-sm:rounded-none max-sm:p-4 sm:max-w-3xl",contentHeight:"auto",bodyClassName:"space-y-4",footer:(0,s.jsx)(m.$,{variant:"outline",onClick:()=>a(!1),className:"w-full sm:w-auto",children:n("Close")}),children:(0,s.jsxs)("div",{className:"max-h-[calc(100dvh-8.5rem)] space-y-3 overflow-y-auto py-2 pr-1 sm:max-h-[72vh] sm:space-y-4",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsxs)("div",{className:"text-muted-foreground text-sm",children:[n("Deployment ID"),":"," ",(0,s.jsx)("span",{className:"font-mono",children:l})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2 sm:flex sm:items-center",children:[(0,s.jsxs)(m.$,{variant:"outline",size:"sm",onClick:N,children:[(0,s.jsx)(eb.A,{className:"mr-2 h-4 w-4"}),n("Copy")]}),(0,s.jsxs)(m.$,{variant:"outline",size:"sm",onClick:()=>{c(),j()},disabled:u||f,children:[u||f?(0,s.jsx)(x.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(eN.A,{className:"mr-2 h-4 w-4"}),n("Refresh")]})]})]}),(0,s.jsx)(ei.w,{}),w?(0,s.jsx)("div",{className:"flex items-center justify-center py-10",children:(0,s.jsx)(x.A,{className:"text-muted-foreground h-6 w-6 animate-spin"})}):null,C?(0,s.jsx)("div",{className:"text-muted-foreground py-10 text-center text-sm",children:r?.message||n("Failed to fetch deployment details")}):null,R?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,s.jsxs)("div",{className:"rounded-lg border p-3",children:[(0,s.jsx)("div",{className:"text-muted-foreground text-xs",children:n("Status")}),(0,s.jsx)("div",{className:"mt-1 font-medium",children:String(y?.status??"-")})]}),(0,s.jsxs)("div",{className:"rounded-lg border p-3",children:[(0,s.jsx)("div",{className:"text-muted-foreground text-xs",children:n("Hardware")}),(0,s.jsxs)("div",{className:"mt-1 font-medium",children:[String(y?.brand_name??"")," ",String(y?.hardware_name??"")]})]}),(0,s.jsxs)("div",{className:"rounded-lg border p-3",children:[(0,s.jsx)("div",{className:"text-muted-foreground text-xs",children:n("Total GPUs")}),(0,s.jsx)("div",{className:"mt-1 font-medium",children:String(y?.total_gpus??y?.hardware_qty??"-")})]}),(0,s.jsxs)("div",{className:"rounded-lg border p-3",children:[(0,s.jsx)("div",{className:"text-muted-foreground text-xs",children:n("Containers")}),(0,s.jsx)("div",{className:"mt-1 font-medium",children:v.length})]})]}),b.length?(0,s.jsxs)("div",{className:"rounded-lg border p-3",children:[(0,s.jsx)("div",{className:"text-muted-foreground text-xs",children:n("Locations")}),(0,s.jsx)("div",{className:"mt-1 flex flex-wrap gap-2 text-sm",children:b.map(e=>(0,s.jsx)("span",{className:"bg-muted rounded-md px-2 py-1",children:e},e))})]}):null,v.length?(0,s.jsxs)("div",{className:"rounded-lg border p-3",children:[(0,s.jsx)("div",{className:"text-muted-foreground mb-2 text-xs",children:n("Containers")}),(0,s.jsx)("div",{className:"space-y-2",children:v.map(e=>{let t=e?.container_id;if("string"!=typeof t||!t)return null;let a="string"==typeof e?.status?e.status:void 0,l="string"==typeof e?.public_url?e.public_url:"";return(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("div",{className:"truncate font-mono text-sm",children:t}),(0,s.jsx)("div",{className:"text-muted-foreground text-xs",children:a?`${n("Status")}: ${a}`:""})]}),l?(0,s.jsxs)(m.$,{variant:"outline",size:"sm",onClick:()=>window.open(l,"_blank"),children:[(0,s.jsx)(e_.A,{className:"mr-2 h-4 w-4"}),n("Open")]}):null]},t)})})]}):null,(0,s.jsxs)(ep.Nt,{className:"rounded-lg border p-3",children:[(0,s.jsx)(ep.R6,{className:"cursor-pointer text-sm font-medium",children:n("Raw JSON")}),(0,s.jsx)(ep.Ke,{children:(0,s.jsx)("pre",{className:"bg-muted text-foreground mt-3 max-h-[360px] overflow-auto rounded-md p-3 text-xs",children:_||"-"})})]})]}):null]})})}let eC=(0,v.A)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);var eS=a(33834),ek=a(39649),eR=a(88288),eA=a(87212);function eM(e){let t,{open:a,onOpenChange:l,deploymentId:n}=e,{t:r}=(0,d.Bd)(),i=(0,o.useRef)(null),[c,u]=(0,o.useState)(!0),[p,g]=(0,o.useState)(!1),[j,f]=(0,o.useState)("stdout"),[y,v]=(0,o.useState)(""),{data:b,isLoading:N,refetch:_,isFetching:w}=(0,S.I)({queryKey:["deployment-containers",n],queryFn:()=>n?(0,h.sC)(n):null,enabled:a&&null!==n}),C=(0,o.useMemo)(()=>{let e=b?.data?.containers;return Array.isArray(e)?e:[]},[b?.data?.containers]);(0,o.useEffect)(()=>
2{if(!a){v(""),f("stdout"),u(!0),g(!1);return}if(a&&C.length>0&&!y){let e=C[0]?.container_id;"string"==typeof e&&e&&v(e)}},[a,C,y]);let{data:k,isLoading:R,refetch:A,isFetching:M}=(0,S.I)({queryKey:["deployment-logs",n,y,j],queryFn:()=>n&&y?(0,h.B1)(n,{container_id:y,stream:j,limit:500}):null,enabled:a&&null!==n&&!!y,refetchInterval:!!a&&!!p&&5e3}),z=(0,o.useMemo)(()=>{let e=k?.data;return"string"==typeof e?e:""},[k?.data]),F=(0,o.useMemo)(()=>{let e=z.replaceAll(/\r\n?/g,"\n");return e?e.split("\n"):[]},[z]),I=(0,o.useMemo)(()=>{let e=new Map;return F.map(t=>{let a=e.get(t)??0;return e.set(t,a+1),{key:`${t}-${a}`,line:t}})},[F]);(0,o.useEffect)(()=>{c&&i.current&&(i.current.scrollTop=i.current.scrollHeight)},[F,c]);let E=r("Select");return N?E=r("Loading..."):0===C.length&&(E=r("No containers")),t=N||R?(0,s.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,s.jsx)(x.A,{className:"h-6 w-6 animate-spin text-gray-400"})}):0===C.length?(0,s.jsx)("div",{className:"py-8 text-center text-gray-400",children:r("No containers")}):y?z.trim()?(0,s.jsx)("div",{className:"font-mono text-sm",children:I.map(e=>{let{key:t,line:a}=e;return(0,s.jsx)("div",{className:"whitespace-pre-wrap text-gray-200",children:a},t)})}):(0,s.jsx)("div",{className:"py-8 text-center text-gray-400",children:r("No logs")}):(0,s.jsx)("div",{className:"py-8 text-center text-gray-400",children:r("Please select a container")}),(0,s.jsxs)(en.l,{open:a,onOpenChange:l,title:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ek.f,{tone:"chart-3",size:"sm",children:(0,s.jsx)(eC,{})}),r("Deployment logs")]}),contentClassName:"flex h-[calc(100dvh-2rem)] flex-col max-sm:w-screen max-sm:max-w-none max-sm:rounded-none max-sm:p-4 sm:h-[80vh] sm:max-w-4xl",titleClassName:"flex items-center gap-2",contentHeight:"min(72vh, 720px)",bodyClassName:"space-y-4",children:[(0,s.jsxs)("div",{className:"mb-3 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-3",children:[(0,s.jsxs)("div",{className:"text-muted-foreground text-sm",children:[r("Deployment ID"),": ",n]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2 sm:flex sm:flex-wrap sm:items-center",children:[(0,s.jsxs)(m.$,{variant:"outline",size:"sm",onClick:()=>{_(),A()},disabled:M||w,children:[M||w?(0,s.jsx)(x.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(eN.A,{className:"mr-2 h-4 w-4"}),r("Refresh")]}),(0,s.jsxs)(m.$,{variant:"outline",size:"sm",onClick:()=>{if(!z.trim())return;let e=new Blob([z],{type:"text/plain"}),t=URL.createObjectURL(e),a=document.createElement("a");a.href=t,a.download=`deployment-${n}-${y||"logs"}.txt`,a.click(),URL.revokeObjectURL(t)},disabled:!z.trim(),children:[(0,s.jsx)(eS.A,{className:"mr-2 h-4 w-4"}),r("Download")]}),(0,s.jsxs)("div",{className:"col-span-2 flex items-center justify-between gap-2 rounded-md border px-3 py-1.5 sm:col-span-1",children:[(0,s.jsx)("span",{className:"text-xs",children:r("Auto refresh")}),(0,s.jsx)(eA.d,{checked:p,onCheckedChange:g})]})]})]}),(0,s.jsxs)("div",{className:"mb-3 grid gap-2 sm:grid-cols-2 sm:gap-3",children:[(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("div",{className:"text-muted-foreground text-xs",children:r("Container")}),(0,s.jsxs)(eR.l6,{items:C.flatMap(e=>{let t=e?.container_id;if("string"!=typeof t||!t)return[];let a="string"==typeof e?.status&&e.status?` (${e.status})`:"";return[{value:t,label:(0,s.jsxs)(s.Fragment,{children:[t,a]})}]}),value:y,onValueChange:e=>null!==e&&v(e),disabled:N||0===C.length,children:[(0,s.jsx)(eR.bq,{children:(0,s.jsx)(eR.yv,{placeholder:E})}),(0,s.jsx)(eR.gC,{alignItemWithTrigger:!1,children:(0,s.jsx)(eR.s3,{children:C.map(e=>{let t=e?.container_id;if("string"!=typeof t||!t)return null;let a="string"==typeof e?.status&&e.status?` (${e.status})`:"";return(0,s.jsxs)(eR.eb,{value:t,children:[t,a]},t)})})})]})]}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("div",{className:"text-muted-foreground text-xs",children:r("Stream")}),(0,s.jsxs)(eR.l6,{items:[{value:"stdout",label:"stdout"},{value:"stderr",label:"stderr"},{value:"all",label:"all"}],value:j,onValueChange:e=>{"stderr"===e||"all"===e||"stdout"===e?f(e):f("stdout")},children:[(0,s.jsx)(eR.bq,{children:(0,s.jsx)(eR.yv,{placeholder:r("Select")})}),(0,s.jsx)(eR.gC,{alignItemWithTrigger:!1,children:(0,s.jsxs)(eR.s3,{children:[(0,s.jsx)(eR.eb,{value:"stdout",children:"stdout"}),(0,s.jsx)(eR.eb,{value:"stderr",children:"stderr"}),(0,s.jsx)(eR.eb,{value:"all",children:"all"})]})})]})]})]}),(0,s.jsx)("div",{ref:i,className:"bg-muted flex-1 overflow-auto rounded-md border p-3 sm:p-4",onScroll:e=>{let t=e.target;u(t.scrollHeight-t.scrollTop-t.clientHeight<50)},children:t})]})}let ez=(0,n.GY)("/_authenticated/models/$section");function eF(){let{t:e}=(0,d.Bd)(),t=(0,l.jE)(),a=(0,M.Ub)("(max-width: 640px)"),{globalFilter:n,onGlobalFilterChange:r,columnFilters:i,onColumnFiltersChange:c,pagination:u,onPaginationChange:x,ensurePageInRange:p}=(0,z.c)({search:ez.useSearch(),navigate:ez.useNavigate(),pagination:{pageKey:"dPage",pageSizeKey:"dPageSize",defaultPage:1,defaultPageSize:a?8:10},globalFilter:{enabled:!0,key:"dFilter"},columnFilters:[{columnId:"status",searchKey:"dStatus",type:"array"}]}),g=n??"",j=i.find(e=>"status"===e.id)?.value||[],f=j.length>0&&!j.includes("all")?j[0]:void 0,[y,v]=(0,o.useState)(!1),[b,N]=(0,o.useState)(null),[_,w]=(0,o.useState)(!1),[C,F]=(0,o.useState)(null),[I,E]=(0,o.useState)(!1),[O,B]=(0,o.useState)(null),[V,D]=(0,o.useState)(!1),[K,P]=(0,o.useState)(null),[J,T]=(0,o.useState)(!1),[Y,L]=(0,o.useState)(null),[U,en]=(0,o.useState)(""),[er,ei]=(0,o.useState)(!1),[eo,em]=(0,o.useState)(null),[eu,eh]=(0,o.useState)(!1),{data:ex,isLoading:ep,isFetching:eg}=(0,S.I)({queryKey:$.list({keyword:g,status:f,p:u.pageIndex+1,page_size:u.pageSize}),queryFn:async()=>g.trim()?(0,h.r8)({keyword:g,status:f,p:u.pageIndex+1,page_size:u.pageSize}):(0,h.Jn)({status:f,p:u.pageIndex+1,page_size:u.pageSize}),placeholderData:e=>e}),ej=ex?.data?.items||[],ef=ex?.data?.total||0,ey=async()=>
2{if(eo){eh(!0);try{let a=await (0,h.rd)(eo.id);a?.success?(k.oR.success(e("Deleted successfully")),t.invalidateQueries({queryKey:$.lists()})):k.oR.error(a?.message||e("Delete failed"))}catch(t){k.oR.error(t instanceof Error?t.message:e("Delete failed"))}finally{eh(!1),ei(!1),em(null)}}},eb=function(e){let{t}=(0,d.Bd)(),a={running:{label:t("Running"),variant:"success"},completed:{label:t("Completed"),variant:"success"},failed:{label:t("Failed"),variant:"danger"},error:{label:t("Failed"),variant:"danger"},destroyed:{label:t("Destroyed"),variant:"danger"},"deployment requested":{label:t("Deployment requested"),variant:"warning"},"termination requested":{label:t("Termination requested"),variant:"warning"}};return[{accessorKey:"id",header:t("ID"),meta:{mobileHidden:!0},cell:e=>{let{row:t}=e,a=t.original.id;return(0,s.jsx)(ea.C,{value:a})},size:120},{id:"name",accessorFn:e=>e.container_name||e.deployment_name||e.name||"",header:t("Name"),meta:{mobileTitle:!0},cell:e=>{let{getValue:t}=e,a=String(t()||"-")||"-";return(0,s.jsx)(et.Wh,{label:a,variant:"neutral",copyText:a,size:"sm",className:"-ml-1.5 font-mono"})},minSize:220},{accessorKey:"status",header:t("Status"),meta:{mobileBadge:!0},cell:e=>{let{row:l}=e,n=l.original.status,r=a[el(n)]||{label:"string"==typeof n&&n.trim()?n.trim():t("Unknown"),variant:"neutral"};return(0,s.jsx)(et.Wh,{label:r.label,variant:r.variant,size:"sm",copyable:!1,className:"-ml-1.5"})},filterFn:(e,t,a)=>{if(!Array.isArray(a)||0===a.length||a.includes("all"))return!0;let s=el(e.getValue(t));return a.includes(s)},size:160,enableSorting:!1},{accessorKey:"provider",header:t("Provider"),cell:e=>{let{row:t}=e,a=t.original.provider;return a?(0,s.jsx)(et.Wh,{label:String(a),autoColor:String(a),size:"sm",copyable:!1,className:"-ml-1.5"}):(0,s.jsx)("span",{className:"text-muted-foreground text-xs",children:"-"})},size:140,enableSorting:!1},{accessorKey:"time_remaining",header:t("Time remaining"),cell:e=>{let{row:a}=e,l=el(a.original.status),n="string"==typeof a.original.time_remaining&&a.original.time_remaining.trim()?a.original.time_remaining.trim():"-",r=function(e){let t="string"==typeof e?Number(e):"number"==typeof e?e:NaN;if(!Number.isFinite(t))return null;let a=Math.max(0,Math.round(t)),s=Math.floor(a/1440),l=Math.floor(a%1440/60),n=a%60,r=[];return s>0&&r.push(`${s}d`),l>0&&r.push(`${l}h`),(0===r.length||n>0)&&r.push(`${n}m`),r.join(" ")}(a.original.compute_minutes_remaining),i="number"==typeof a.original.completed_percent&&Number.isFinite(a.original.completed_percent)?Math.max(0,Math.min(100,Math.round(a.original.completed_percent))):null,o=null===i?null:Math.max(0,Math.min(100,100-i));return(0,s.jsxs)("div",{className:"flex flex-col gap-1 text-sm",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"font-medium",children:n}),"running"===l&&null!==o?(0,s.jsx)(et.Wh,{label:`${o}%`,variant:"info",size:"sm",copyable:!1}):null]}),r?(0,s.jsxs)("div",{className:"text-muted-foreground text-xs",children:[t("Approx.")," ",r]}):null]})},minSize:220,enableSorting:!1},{id:"hardware",header:t("Hardware"),meta:{mobileHidden:!0},accessorFn:e=>e.hardware_info||e.hardware_name||e.brand_name||"",cell:e=>{let{row:t}=e,a=t.original.hardware_name||("string"==typeof t.original.hardware_info?t.original.hardware_info:""),l="number"==typeof t.original.hardware_quantity?t.original.hardware_quantity:null;return a?(0,s.jsxs)("div",{className:"flex max-w-full min-w-0 flex-nowrap items-center gap-2 overflow-hidden",children:[(0,s.jsx)(et.Wh,{label:String(a),variant:"neutral",copyText:String(a),size:"sm"}),null!==l?(0,s.jsxs)("span",{className:"text-muted-foreground text-xs",children:["×",l]}):null]}):(0,s.jsx)("span",{className:"text-muted-foreground text-xs",children:"-"})},minSize:220,enableSorting:!1},{accessorKey:"created_at",header:t("Created"),meta:{mobileHidden:!0},cell:e=>{let t,{row:a}=e;return"number"==typeof a.original.created_at?t=a.original.created_at:"string"==typeof a.original.created_at&&(t=Number(a.original.created_at)),(0,s.jsx)("div",{className:"min-w-[140px] font-mono text-sm",children:(0,q.fk)(t)})},size:180},{id:"actions",header:()=>t("Actions"),enableHiding:!1,enableSorting:!1,cell:a=>{let{row:l}=a,n=l.original.id,r=l.original.container_name||l.original.deployment_name||l.original.n
2ame||"";return(0,s.jsxs)("div",{className:"-ml-2.5 flex items-center gap-1",children:[(0,s.jsx)(m.$,{variant:"ghost",size:"icon-sm",onClick:()=>e.onViewLogs(n),"aria-label":t("View logs"),children:(0,s.jsx)(W.A,{})}),(0,s.jsxs)(ee.C,{ariaLabel:t("Open menu"),children:[(0,s.jsxs)(es._2,{onClick:()=>e.onViewDetails(n),children:[t("View details"),(0,s.jsx)(es.V0,{children:(0,s.jsx)(H.A,{size:16})})]}),(0,s.jsxs)(es._2,{onClick:()=>e.onUpdateConfig(n),children:[t("Update configuration"),(0,s.jsx)(es.V0,{children:(0,s.jsx)(G.A,{size:16})})]}),(0,s.jsxs)(es._2,{onClick:()=>e.onExtend(n),children:[t("Extend deployment"),(0,s.jsx)(es.V0,{children:(0,s.jsx)(Q.A,{size:16})})]}),(0,s.jsxs)(es._2,{onClick:()=>e.onRename(n,r),children:[t("Rename deployment"),(0,s.jsx)(es.V0,{children:(0,s.jsx)(Z.A,{size:16})})]}),(0,s.jsx)(es.mB,{}),(0,s.jsxs)(es._2,{onClick:()=>e.onDelete(l.original),className:"text-destructive focus:text-destructive",children:[t("Delete"),(0,s.jsx)(es.V0,{children:(0,s.jsx)(X.A,{size:16})})]})]})]})},meta:{pinned:"right"}}]}({onViewLogs:e=>{N(e),v(!0)},onViewDetails:e=>{F(e),w(!0)},onUpdateConfig:e=>{B(e),E(!0)},onExtend:e=>{P(e),D(!0)},onRename:(e,t)=>{en(t),L(e),T(!0)},onDelete:e=>{em(e),ei(!0)}}),{table:eN}=(0,R.uI)({data:ej,columns:eb,totalCount:ef,columnFilters:i,pagination:u,globalFilter:n,onColumnFiltersChange:c,onPaginationChange:x,onGlobalFilterChange:r,manualPagination:!0,manualFiltering:!0,withSortedRowModel:!1,ensurePageInRange:p}),e_=(0,o.useMemo)(()=>[{label:e("All Status"),value:"all"},{label:e("Running"),value:"running"},{label:e("Completed"),value:"completed"},{label:e("Failed"),value:"failed"},{label:e("Deployment requested"),value:"deployment requested"},{label:e("Termination requested"),value:"termination requested"},{label:e("Destroyed"),value:"destroyed"}].map(e=>({label:e.label,value:e.value})),[e]);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(R.cx,{table:eN,columns:eb,isLoading:ep,isFetching:eg,emptyTitle:e("No Deployments Found"),emptyDescription:e("No deployments available. Create one to get started."),skeletonKeyPrefix:"deployment-skeleton",applyHeaderSize:!0,toolbarProps:{searchPlaceholder:e("Search deployments..."),filters:[{columnId:"status",title:e("Status"),options:e_,singleSelect:!0}]}}),(0,s.jsx)(eM,{open:y,onOpenChange:e=>{v(e),e||N(null)},deploymentId:b}),(0,s.jsx)(ew,{open:_,onOpenChange:e=>{w(e),e||F(null)},deploymentId:C}),(0,s.jsx)(ev,{open:I,onOpenChange:e=>{E(e),e||B(null)},deploymentId:O}),(0,s.jsx)(ed,{open:V,onOpenChange:e=>{D(e),e||P(null)},deploymentId:K}),(0,s.jsx)(ec,{open:J,onOpenChange:e=>{T(e),e||L(null)},deploymentId:Y,currentName:U}),(0,s.jsx)(A.Lt,{open:er,onOpenChange:ei,children:(0,s.jsxs)(A.EO,{children:[(0,s.jsxs)(A.wd,{children:[(0,s.jsx)(A.r7,{children:e("Confirm delete")}),(0,s.jsx)(A.$v,{children:e('Are you sure you want to delete deployment "{{name}}"? This action cannot be undone.',{name:eo?.container_name||eo?.deployment_name||eo?.id})})]}),(0,s.jsxs)(A.ck,{children:[(0,s.jsx)(A.Zr,{disabled:eu,children:e("Cancel")}),(0,s.jsx)(A.Rx,{onClick:ey,disabled:eu,variant:"destructive",children:eu?e("Deleting..."):e("Delete")})]})]})})]})}var eI=a(55667),eE=a(47029),eO=a(18353),e$=a(74559);let eq="ollama/ollama:latest",eB=V.Ik({resource_private_name:V.Yj().min(1),image_url:V.Yj().min(1),traffic_port:eh.ai().int().min(1).max(65535),hardware_id:V.Yj().min(1),gpus_per_container:eh.ai().int().min(1),location_ids:V.YO(V.Yj()).min(1),replica_count:eh.ai().int().min(1),duration_hours:eh.ai().int().min(1),env_json:V.Yj().optional(),secret_env_json:V.Yj().optional(),entrypoint:V.Yj().optional(),args:V.Yj().optional(),registry_username:V.Yj().optional(),registry_secret:V.Yj().optional(),currency:V.Yj().optional()});function eV(e,t){let a="number"==typeof e?e:Number(e);return Number.isFinite(a)?a:t}function eD(e){let{open:t,onOpenChange:a}=e,{t:n}=(0,d.Bd)(),r=(0,l.jE)(),i=(0,eu.mN)({resolver:(0,em.u)(eB),defaultValues:{resource_private_name:"",image_url:eq,traffic_port:11434,hardware_id:"",gpus_per_container:1,location_ids:[],replica_count:1,duration_hours:1,env_json:"",secret_env_json:"",entrypoint:"",args:"",registry_username:"",registry_secret:"",currency:"usdc"}}),c=i.watch("hardware_id"),u=eV(i.watch("gpus_per_container"),1),x=i.watch("location_ids"),p=eV(i.watch("duration_hours"),1),g=eV(i.watch("replica_count"),1),j=eV(i.watch("traffic_port"),11434),f=i.watch("currency"),y=i.watch("resource_private_name"),{data:v,isLoading:b}=(0,S.I)({queryKey:["deployment-hardware-types"],queryFn:h.cN,enabled:t}),N=(0,o.useMemo)(()=>{let e=v?.data?.hardware_types||[];return Array.isArray(e)?e.map(e=>({label:(e?.brand_name?`${e.brand_name} `:"")+String(e?.name??e?.id),value:String(e?.id),max_gpus:Number(e?.max_gpus||1)}
2)):[]},[v]);(0,o.useEffect)(()=>{if(!c)return;let e=N.find(e=>e.value===c);if(!e)return;let t=Number.isFinite(e.max_gpus)&&e.max_gpus>0?e.max_gpus:1;u>t&&i.setValue("gpus_per_container",t)},[c,N,u,i]);let{data:_,isLoading:w}=(0,S.I)({queryKey:["deployment-available-replicas",c,u],queryFn:()=>(0,h.Jd)({hardware_id:c,gpu_count:u}),enabled:t&&!!c&&u>0}),C=(0,o.useMemo)(()=>{let e=_?.data?.replicas||[];if(!Array.isArray(e))return[];let t=new Map;return e.forEach(e=>{let a=e?.location_id??e?.location?.id;if(null==a)return;let s=e?.location_name??e?.location?.name??e?.name??String(a),l=String(a);t.has(l)||t.set(l,{label:String(s),value:l})}),Array.from(t.values())},[_]),{data:R,isLoading:A}=(0,S.I)({queryKey:["deployment-price",c,u,p,g,x,f],queryFn:()=>(0,h.c9)({location_ids:x,hardware_id:c,gpus_per_container:u,duration_hours:p,replica_count:g,currency:f||"usdc"}),enabled:t&&!!c&&u>0&&p>0&&g>0&&x.length>0}),{data:M,isFetching:z}=(0,S.I)({queryKey:["deployment-name-check",y],queryFn:async()=>{let e=(y||"").trim();return e?await (0,h.Z7)(e):null},enabled:t&&!!(y&&y.trim().length>0),staleTime:1e4}),F=M?.success===!0?M?.data?.available:void 0,I=(0,eI.n)({mutationFn:async e=>{let t=e.env_json&&e.env_json.trim()?JSON.parse(e.env_json):void 0,a=e.secret_env_json&&e.secret_env_json.trim()?JSON.parse(e.secret_env_json):void 0,s=t&&"object"==typeof t&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).map(e=>{let[t,a]=e;return[t,String(a)]})):void 0,l=a&&"object"==typeof a&&!Array.isArray(a)?Object.fromEntries(Object.entries(a).map(e=>{let[t,a]=e;return[t,String(a)]})):void 0,n=Number(e.gpus_per_container),r=Number(e.duration_hours),i=Number(e.replica_count),o=e.entrypoint?e.entrypoint.split(" ").map(e=>e.trim()).filter(Boolean):void 0,d=e.args?e.args.split(" ").map(e=>e.trim()).filter(Boolean):void 0,c=(e.location_ids||[]).map(e=>Number(e)).filter(e=>Number.isInteger(e)&&e>0),m={resource_private_name:e.resource_private_name.trim(),duration_hours:Number.isFinite(r)?r:1,gpus_per_container:Number.isFinite(n)?n:1,hardware_id:Number(e.hardware_id),location_ids:c,container_config:{replica_count:Number.isFinite(i)?i:1,traffic_port:Number.isFinite(j)?j:11434,...o?.length?{entrypoint:o}:{},...d?.length?{args:d}:{},...s?{env_variables:s}:{},...l?{secret_env_variables:l}:{}},registry_config:{image_url:e.image_url,...e.registry_username?.trim()?{registry_username:e.registry_username.trim()}:{},...e.registry_secret?.trim()?{registry_secret:e.registry_secret.trim()}:{}}};return await (0,h.Yy)(m)},onSuccess:e=>{if(e?.success){k.oR.success(n("Deployment created successfully")),r.invalidateQueries({queryKey:$.lists()}),a(!1);return}k.oR.error(e?.message||n("Failed to create deployment"))},onError:e=>{k.oR.error(e.message||n("Failed to create deployment"))}});return(0,o.useEffect)(()=>{t&&i.reset({resource_private_name:"",image_url:eq,traffic_port:11434,hardware_id:"",gpus_per_container:1,location_ids:[],replica_count:1,duration_hours:1,env_json:"",secret_env_json:"",entrypoint:"",args:"",registry_username:"",registry_secret:"",currency:"usdc"})},[t,i]),(0,o.useMemo)(()=>{let e=R?.data;if(!e||"object"!=typeof e)return"";let t=e?.total_cost??e?.total??"",a=e?.currency??"";return""===t&&""===a?"":`${t} ${a}`.trim()},[R]),(0,s.jsx)(e$.cj,{open:t,onOpenChange:e=>{a(e),e||i.reset()},children:(0,s.jsxs)(e$.h,{className:(0,eE.jW)("sm:max-w-[600px]"),children:[(0,s.jsxs)(e$.Fm,{className:(0,eE.Dt)(),children:[(0,s.jsx)(e$.qp,{children:n("Create deployment")}),(0,s.jsx)(e$.Qs,{children:n("Configure and deploy a new container instance.")})]}),(0,s.jsx)(eg.lV,{...i,children:(0,s.jsxs)("form",{id:"deployment-form",onSubmit:i.handleSubmit(e=>I.mutate(e)),className:(0,eE.e)(),children:[(0,s.jsxs)(eE.y5,{children:[(0,s.jsx)("h3",{className:"text-sm font-medium",children:n("Basic Configuration")}),(0,s.jsx)(eg.zB,{control:i.control,name:"resource_private_name",render:e=>{let{field:a}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:n("Container name")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{placeholder:n("Enter a name"),...a})}),t&&a.value?.trim()?(0,s.jsx)("div",{className:"text-muted-foreground text-xs",children:z?n("Checking name..."):!0===F?n("Name is available"):!1===F?n("Name is not available"):""}):null,(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsx)(eg.zB,{control:i.control,name:"image_url",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:n("Image")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{...t})}),(0,s.jsx)(eg.C5,{})]})}})]}),(0,s.jsxs)(eE.y5,{children:[(0,s.jsx)("h3",{className:"text-sm font-medium",children:n("Resource Configuration")}),(0,s.jsx)("div",{className:"grid gap-4 sm:grid-cols-2",children:(0,s.jsx)(eg.zB,{control:i.control,name:"hardware_id",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:n("Hardware type")}),(0,s.jsxs)(eR.l6,{items:[...N.map(e=>({value:e.value,label:e.label}))],value:t.value,onValueChange:e=>t.onChange(e),disabled:b,children:[(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(eR.bq,{className:"w-full",children:(0,s.jsx)(eR.yv,{placeholder:n("Select")})})}),(0,s.jsx)(eR.gC,{alignItemWithTrigger:!1,children:(0,s.jsx)(eR.s3,{children:N.map(e=>(0,s.jsx)(eR.eb,{value:e.value,children:e.label},e.value))})})]}),(0,s.jsx)(eg.C5,{})]})}})}),(0,s.jsx)(eg.zB,{control:i.control,name:"location_ids",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:n("Deployment location")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(eO.K,{options:C,selected:t.value||[],onChange:e=>{!w&&c&&t.onChange(e)},placeholder:w?n("Loading..."):n("Select locations"),className:w||!c?"pointer-events-none opacity-60":""})}),(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,s.jsx)(eg.zB,{control:i.control,name:"gpus_per_container",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:n("GPU count")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{type:"number",value:eV(t.value,u),onChange:e=>t.onChange(""===e.target.value?0:Number(e.target.value))})}),(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsx)(eg.zB,{control:i.control,name:"replica_count",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:n("Replica count")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{type:"number",value:eV(t.value,g),onChange:e=>t.onChange(""===e.target.value?0:Number(e.target.value))})}),(0,s.jsx)(eg.C5,{})]})}})]}),(0,s.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,s.jsx)(eg.zB,{control:i.control,name:"duration_hours",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:n("Duration (hours)")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{type:"number",value:eV(t.value,p),onChange:e=>t.onChange(""===e.target.value?0:Number(e.target.value))})}),(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsx)(eg.zB,{control:i.control,name:"traffic_port",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:n("Port")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{type:"number",value:eV(t.value,j),onChange:e=>t.onChange(""===e.target.value?0:Number(e.target.value))})}),(0,s.jsx)(eg.C5,{})]})}})]})]}),(0,s.jsxs)(eE.y5,{children:[(0,s.jsx)("h3",{className:"text-sm font-medium",children:n("Price estimation")}),(0,s.jsx)("p",{className:"text-muted-foreground text-xs",children:n("Price estimation description")}),(0,s.jsx)(eg.zB,{control:i.control,name:"currency",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:n("Billing currency")}),(0,s.jsxs)(eR.l6,{items:[{value:"usdc",label:"USDC"},{value:"iocoin",label:"IOCOIN"}],value:t.value||"usdc",onValueChange:e=>t.onChange(e),children:[(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(eR.bq,{className:"w-full",children:(0,s.jsx)(eR.yv,{placeholder:n("Select")})})}),(0,s.jsx)(eR.gC,{alignItemWithTrigger:!1,children:(0,s.jsxs)(eR.s3,{children:[(0,s.jsx)(eR.eb,{value:"usdc",children:"USDC"}),(0,s.jsx)(eR.eb,{value:"iocoin",children:"IOCOIN"})]})})]})]})}})]}),(0,s.jsxs)(eE.y5,{children:[(0,s.jsx)("h3",{className:"text-sm font-medium",children:n("Advanced Configuration")}),(0,s.jsx)("p",{className:"text-muted-foreground text-xs",children:n("Optional settings for advanced container configuration.")}),(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,s.jsx)(eg.zB,{control:i.control,name:"entrypoint",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:n("Entrypoint (space separated)")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{placeholder:"bash -lc",...t})}),(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsx)(eg.zB,{control:i.control,name:"args",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:n("Args (space separated)")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{placeholder:"--foo bar",...t})}),(0,s.jsx)(eg.C5,{})]})}})]}),(0,s.jsx)(eg.zB,{control:i.control,name:"env_json",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:n("Environment variables (JSON)")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(ex.B,{value:t.value||"",onChange:t.onChange,name:t.name,onBlur:t.onBlur,textareaRef:t.ref,placeholder:'{"KEY":"VALUE"}',heightClassName:"h-40 min-h-40 max-h-40"})}),(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsx)(eg.zB,{control:i.control,name:"secret_env_json",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:n("Secret environment variables (JSON)")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(ex.B,{value:t.value||"",onChange:t.onChange,name:t.name,onBlur:t.onBlur,textareaRef:t.ref,placeholder:'{"SECRET":"VALUE"}',heightClassName:"h-40 min-h-40 max-h-40"})}),(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,s.jsx)(eg.zB,{control:i.control,name:"registry_username",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:n("Registry username")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{autoComplete:"off",...t})}),(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsx)(eg.zB,{control:i.control,name:"registry_secret",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:n("Registry secret")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{type:"password",autoComplete:"off",...t})}),(0,s.jsx)(eg.C5,{})]})}})]})]})]})]})}),(0,s.jsxs)(e$.XW,{className:(0,eE.Jx)(),children:[(0,s.jsx)(e$.kN,{render:(0,s.jsx)(m.$,{variant:"outline"}),children:n("Cancel")}),(0,s.jsx)(m.$,{form:"deployment-form",type:"submit",disabled:I.isPending,children:I.isPending?n("Submitting..."):n("Create")})]})]})})}
2var eK=a(15161);function eP(e){let{open:t,onOpenChange:a,modelName:l,description:n}=e,{t:r}=(0,d.Bd)();return(0,s.jsx)(en.l,{open:t,onOpenChange:a,title:l,description:r("Model Description"),contentClassName:"max-w-2xl",contentHeight:"auto",bodyClassName:"space-y-4",children:(0,s.jsx)(eK.F,{className:"max-h-96",children:(0,s.jsx)("div",{className:"space-y-2 pr-4",children:(0,s.jsx)("p",{className:"text-foreground text-sm leading-relaxed break-words whitespace-pre-wrap",children:n})})})})}var eJ=a(38766),eT=a(24623),eY=a(63162),eL=a(12393),eU=a(38009);let eW=(0,o.createContext)(void 0);function eH(e){let{children:t}=e,[a,l]=(0,o.useState)(null),[n,r]=(0,o.useState)(null),[i,d]=(0,o.useState)(null),[c,m]=(0,o.useState)(null),[u,h]=(0,o.useState)(null),[x,p]=(0,o.useState)([]),[g,j]=(0,o.useState)({locale:"zh",source:"official"}),[f,y]=(0,o.useState)("metadata");return(0,s.jsx)(eW.Provider,{value:{open:a,setOpen:l,currentRow:n,setCurrentRow:r,currentVendor:i,setCurrentVendor:d,selectedVendor:c,setSelectedVendor:m,descriptionData:u,setDescriptionData:h,upstreamConflicts:x,setUpstreamConflicts:p,syncWizardOptions:g,setSyncWizardOptions:j,tabCategory:f,setTabCategory:y},children:t})}function eG(){let e=(0,o.useContext)(eW);if(!e)throw Error("useModels must be used within ModelsProvider");return e}function eQ(e){let{open:t,onOpenChange:a}=e,{t:l}=(0,d.Bd)(),{setOpen:n,setCurrentRow:r}=eG(),c=(0,eU.a)(),[u,p]=(0,o.useState)(""),[g,j]=(0,o.useState)(1),{data:f,isLoading:y}=(0,S.I)({queryKey:I.missing(),queryFn:h.ng,enabled:t}),v=(0,o.useMemo)(()=>f?.data||[],[f?.data]);(0,o.useEffect)(()=>{t&&(p(""),j(1))},[t]);let b=(0,o.useMemo)(()=>{if(!u.trim())return v;let e=u.toLowerCase().trim();return v.filter(t=>t.toLowerCase().includes(e))},[v,u]),N=b.length,_=0===N?1:Math.ceil(N/20);(0,o.useEffect)(()=>{g>_&&j(Math.max(1,_))},[g,_]);let w=(0,o.useMemo)(()=>{let e=(g-1)*20;return b.slice(e,e+20)},[b,g,20]),C=0===N?0:(g-1)*20+1,k=0===N?0:Math.min(20*g,N),R=N>20;return(0,s.jsx)(en.l,{open:t,onOpenChange:a,title:l("Missing Models"),description:l("Models that are being used but not configured in the system"),contentClassName:"flex max-h-[85vh] max-w-2xl flex-col gap-3 p-4",headerClassName:"flex-shrink-0 text-start",contentHeight:"min(74vh, 760px)",bodyClassName:"space-y-4",initialFocus:!c,children:y?(0,s.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,s.jsx)(x.A,{className:"h-8 w-8 animate-spin"})}):0===v.length?(0,s.jsxs)("div",{className:"text-muted-foreground py-12 text-center",children:[(0,s.jsx)("p",{children:l("No missing models found.")}),(0,s.jsx)("p",{className:"text-sm",children:l("All models in use are properly configured.")})]}):(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto",children:[(0,s.jsxs)("div",{className:"flex flex-shrink-0 items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"text-muted-foreground text-sm whitespace-nowrap",children:[l("Showing")," ",C,"-",k," ",l("of")," ",N]}),(0,s.jsxs)("div",{className:"relative w-48",children:[(0,s.jsx)(eJ.A,{className:"text-muted-foreground pointer-events-none absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2"}),(0,s.jsx)(er.p,{value:u,onChange:e=>{p(e.target.value),j(1)},placeholder:l("Search models..."),className:"pl-9","aria-label":l("Search missing models")})]})]}),0===b.length?(0,s.jsx)(eL.Sv,{className:"border",children:(0,s.jsxs)(eL.FT,{children:[(0,s.jsx)(eL.Kr,{variant:"icon",children:(0,s.jsx)(eJ.A,{className:"h-5 w-5"})}),(0,s.jsx)(eL.cz,{children:l("No matches found")}),(0,s.jsx)(eL.Ou,{children:l("Try adjusting your search to locate a missing model.")})]})}):(0,s.jsxs)("div",{className:"flex-shrink-0 rounded-lg border",children:[(0,s.jsx)("div",{className:"divide-y",children:w.map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3 p-3",children:[(0,s.jsx)("div",{className:"min-w-0 flex-1",children:(0,s.jsx)(et.Wh,{label:e,variant:"neutral",copyText:e})}),(0,s.jsxs)(m.$,{size:"sm",className:"flex-shrink-0 gap-1",onClick:()=>{r({model_name:e}),n("create-model")},children:[(0,s.jsx)(i.A,{className:"h-4 w-4"}),"Configure"]})]},e))}),(0,s.jsxs)("div",{className:"bg-muted/40 flex items-center justify-between border-t px-3 py-2 text-sm",children:[(0,s.jsx)("div",{className:"text-muted-foreground text-sm",children:l("Page {{current}} of {{total}}",{current:g,total:_})}),R&&(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(m.$,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>j(e=>Math.max(1,e-1)),disabled:1===g,"aria-label":l("Previous page"),children:(0,s.jsx)(eT.A,{className:"h-4 w-4"})}),(0,s.jsx)(m.$,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>j(e=>Math.min(_,e+1)),disabled:g===_,"aria-label":l("Next page"),children:(0,s.jsx)(eY.A,{className:"h-4 w-4"})})]})]})]})]})})}var eZ=a(24877),eX=a(15762),e0=a(90879);function e1(e){let{value:t=[],onChange:a,placeholder:l,className:n,disabled:r=!1}=e,{t:i}=(0,d.Bd)(),c=l??i("Add tags..."),[u,h]=(0,o.useState)(""),x=(0,o.useRef)(null),p=e=>{let s=e.trim();s&&!t.includes(s)&&(a([...t,s]),h(""))},g=e=>{a(t.filter(t=>t!==e))};return(0,s.jsxs)("div",{className:(0,_.cn)("border-input focus-within:border-ring focus-within:ring-ring/50 flex min-h-9 w-full flex-wrap items-center gap-2 rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-within:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n),onClick:()=>x.current?.focus(),children:[t.map(e=>(0,s.jsxs)(e0.E,{variant:"secondary",className:"gap-1 pr-1",children:[e,!r&&(0,s.jsx)(m.$,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Remove tag",onClick:t=>{t.stopPropagation(),g(e)}
2,className:"hover:bg-secondary-foreground/20 size-auto rounded-sm p-0",children:(0,s.jsx)(eX.A,{className:"h-3 w-3","aria-hidden":"true"})})]},e)),(0,s.jsx)("input",{ref:x,type:"text",value:u,onChange:e=>h(e.target.value),onKeyDown:e=>{"Enter"===e.key||","===e.key?(e.preventDefault(),p(u)):"Backspace"===e.key&&!u&&t.length>0&&g(t[t.length-1])},onBlur:()=>{u.trim()&&p(u)},placeholder:0===t.length?c:"",disabled:r,className:"placeholder:text-muted-foreground min-w-[120px] flex-1 border-0 bg-transparent shadow-none outline-none focus-visible:ring-0"})]})}var e2=a(70954);V.Ik({id:V.ai().optional(),model_name:V.Yj().min(1,"Model name is required"),description:V.Yj().default(""),icon:V.Yj().default(""),tags:V.YO(V.Yj()).default([]),vendor_id:V.ai().optional(),endpoints:V.Yj().default(""),name_rule:V.ai().min(0).max(3).default(0),status:V.zM().default(!0),sync_official:V.zM().default(!0)});let e4=V.Ik({id:V.ai().optional(),name:V.Yj().min(1,"Vendor name is required"),description:V.Yj().default(""),icon:V.Yj().default(""),status:V.ai().default(1)}),e5=V.Ik({id:V.ai().optional(),name:V.Yj().min(1,"Group name is required"),description:V.Yj().optional(),type:V.k5(["model","tag","endpoint"]),items:V.KC([V.Yj(),V.YO(V.Yj())])}),e3=[{value:"model",label:"Model Group",description:"Reusable sets of models you can attach to channels.",badge:"blue"},{value:"tag",label:"Tag Group",description:"Collections of metadata tags for bulk operations.",badge:"purple"},{value:"endpoint",label:"Endpoint Group",description:"HTTP endpoint mappings shared across providers.",badge:"cyan"}],e6=e3.reduce((e,t)=>(e[t.value]={label:t.label,badge:t.badge},e),{}),e8={name:"",description:"",type:"model",items:[]};function e7(e){if(!e)return[];if(Array.isArray(e))return e.map(e=>"string"==typeof e?e.trim():"").filter(Boolean);if("string"==typeof e)try{let t=JSON.parse(e);if(Array.isArray(t))return t.map(e=>"string"==typeof e?e.trim():"").filter(Boolean)}catch{return e.split(/[\n,]/).map(e=>e.trim()).filter(Boolean)}return[]}function e9(e){let{open:t,onClose:a,currentGroup:n}=e,{t:r}=(0,d.Bd)(),i=(0,l.jE)(),c=!!n?.id,[u,p]=(0,o.useState)(!1),g=(0,eu.mN)({resolver:(0,em.u)(e5),defaultValues:e8}),j=g.watch("type");(0,o.useEffect)(()=>{t&&(c&&n?g.reset({id:n.id,name:n.name,description:n.description||"",type:n.type,items:"endpoint"===n.type?function(e){if(!e)return"";if("string"==typeof e)return e;try{return JSON.stringify(e,null,2)}catch{return""}}(n.items):e7(n.items)}):g.reset(e8))},[t,c,n,g]),(0,o.useEffect)(()=>{let e=g.getValues("items");"endpoint"===j&&Array.isArray(e)?g.setValue("items","",{shouldValidate:!1}):"endpoint"!==j&&"string"==typeof e&&g.setValue("items",[],{shouldValidate:!1})},[j,g]);let f=async e=>{p(!0);let t={name:e.name.trim(),type:e.type,description:e.description?.trim()||"",items:"endpoint"===e.type?"string"==typeof e.items?e.items:"":Array.isArray(e.items)?e.items:[]};try{let e=c?await (0,h.Lw)({id:n.id,...t}):await (0,h.Kx)(t);e.success?(k.oR.success(c?"Prefill group updated":"Prefill group created"),i.invalidateQueries({queryKey:O.lists()}),a()):k.oR.error(e.message||"Operation failed")}catch(e){k.oR.error(e?.message||"Operation failed")}finally{p(!1)}},y=e6[j]||e6.model;return(0,s.jsx)(e$.cj,{open:t,onOpenChange:e=>{e||a()},children:(0,s.jsxs)(e$.h,{className:(0,eE.jW)("sm:max-w-2xl"),children:[(0,s.jsxs)(e$.Fm,{className:(0,eE.Dt)(),children:[(0,s.jsx)(e$.qp,{children:c?r("Edit Prefill Group"):r("Create Prefill Group")}),(0,s.jsx)(e$.Qs,{children:c?r("Update the reusable bundle below."):r("Capture a reusable bundle of models, tags, or endpoints.")})]}),(0,s.jsx)(eg.lV,{...g,children:(0,s.jsxs)("form",{id:"prefill-group-form",onSubmit:g.handleSubmit(f),className:(0,eE.e)(),children:[(0,s.jsxs)(eE.y5,{children:[(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold",children:r("Group details")}),(0,s.jsx)("p",{className:"text-muted-foreground text-sm",children:r("Give the group a recognizable name and optional description.")})]}),(0,s.jsx)(eg.zB,{control:g.control,name:"name",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Group Name")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{placeholder:r("Premium chat models"),...t})}),(0,s.jsx)(eg.Rr,{children:r("Give this group a recognizable name.")}),(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsx)(eg.zB,{control:g.control,name:"description",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Description")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(e2.T,{placeholder:r("Optional notes about when to use this group"),rows:3,...t})}),(0,s.jsx)(eg.Rr,{children:r("Make it easier for teammates to pick the right group.")}),(0,s.jsx)(eg.C5,{})]})}})]}),(0,s.jsxs)(eE.y5,{children:[(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold",children:r("Configuration")}),(0,s.jsx)("p",{className:"text-muted-foreground text-sm",children:r("Choose the bundle type and define the items inside it.")})]}),(0,s.jsx)(eg.zB,{control:g.control,name:"type",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:"Group Type"}),(0,s.jsxs)(eR.l6,{items:[...e3.map(e=>({value:e.value,label:(0,s.jsxs)("div",{className:"flex flex-col text-left",children:[(0,s.jsx)("span",{className:"font-medium",children:e.label}),(0,s.jsx)("span",{"data-prefill-description":!0,className:"text-muted-foreground text-xs",children:e.description})]})}))],value:t.value,onValueChange:e=>null!==e&&t.onChange(e),children:[(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(eR.bq,{className:"[&_[data-slot=select-value]_[data-prefill-description]]:hidden",children:(0,s.jsx)(eR.yv,{placeholder:r("Select a group type")})})}),(0,s.jsx)(eR.gC,{alignItemWithTrigger:!1,children:(0,s.jsx)(eR.s3,{children:e3.map(e=>(0,s.jsx)(eR.eb,{value:e.value,children:(0,s.jsxs)("div",{className:"flex flex-col text-left",children:[(0,s.jsx)("span",{className:"font-medium",children:e.label}),(0,s.jsx)("span",{"data-prefill-description":!0,className:"text-muted-foreground text-xs",children:e.description})]})},e.value))})})]}),(0,s.jsx)(eg.Rr,{children:r("Determines how this group is applied elsewhere.")}),(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsxs)("div",{className:"border-border/60 flex flex-col gap-3 border-y py-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("h4",{className:"text-sm font-medium",children:r("Project")}),(0,s.jsx)(et.Wh,{label:y.label,variant:y.badge,size:"sm",copyable:!1})]}),(0,s.jsx)(eg.zB,{control:g.control,name:"items",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{className:"sr-only",children:r("Items")}),(0,s.jsx)(eg.MJ,{children:"endpoint"===j?(0,s.jsx)(eZ.i,{value:t.value||"",onChange:t.onChange,keyPlaceholder:"provider",valuePlaceholder:'{"path": "/v1/...","method": "POST"}',keyLabel:r("Provider"),valueLabel:r("Endpoint config"),valueType:"any",template:F,emptyMessage:r("Define endpoint mappings for each provider.")}):(0,s.jsx)(e1,{value:Array.isArray(t.value)?t.value:[],onChange:t.onChange,placeholder:r("Enter a value and press Enter")})}),(0,s.jsx)(eg.Rr,{children:"endpoint"===j?r("Provide a JSON object where each key maps to an endpoint definition."):r("Add each model or tag you want to include.")}),(0,s.jsx)(eg.C5,{})]})}})]})]})]})}),(0,s.jsxs)(e$.XW,{className:(0,eE.Jx)(),children:[(0,s.jsx)(e$.kN,{render:(0,s.jsx)(m.$,{type:"button",variant:"outline",disabled:u}),children:r("Cancel")}),(0,s.jsxs)(m.$,{type:"submit",form:"prefill-group-form",disabled:u,children:[u&&(0,s.jsx)(x.A,{className:"mr-2 h-4 w-4 animate-spin"}),u?r("Saving..."):c?r("Save changes"):r("Create")]})]})]})})}var te=a(20468),tt=a(73280),ta=a(32348),ts=a(21505),tl=a(68974);function tn(e){let t,{open:a,onOpenChange:n,onCreateGroup:r,onEditGroup:c}=e,{t:u}=(0,d.Bd)(),p=(0,l.jE)(),g=(0,eU.a)(),[j,f]=(0,o.useState)({open:!1,group:null}),[y,v]=(0,o.useState)(!1),{data:b,isLoading:w,isFetching:C,error:R,refetch:A}=(0,S.I)({queryKey:O.list(),queryFn:()=>(0,h.xI)(),enabled:a}),M=(0,o.useMemo)(()=>b?.data??[],[b?.data]),z=(0,o.useMemo)(()=>[...M].sort((e,t)=>
2e.type===t.type?e.name.localeCompare(t.name):e.type.localeCompare(t.type)),[M]),F=(0,o.useMemo)(()=>z.map(e=>{let t=e6[e.type]||{label:e.type,badge:"neutral"},a="endpoint"===e.type?function(e){if(!e)return[];try{let t="string"==typeof e?JSON.parse(e||"{}"):e;if(Array.isArray(t))return t.map(e=>"string"==typeof e?e:"string"==typeof e?.name?e.name:"").filter(Boolean);if(t&&"object"==typeof t)return Object.keys(t)}catch{}return[]}(e.items):e7(e.items);return{group:e,meta:t,parsedItems:a}}),[z]);(0,o.useEffect)(()=>{a||(f({open:!1,group:null}),v(!1))},[a]);let I=e=>{f({open:!0,group:e})},E=async()=>{if(j.group){v(!0);try{let e=await (0,h.Vq)(j.group.id);e.success?(k.oR.success(u('Deleted "{{name}}"',{name:j.group.name})),p.invalidateQueries({queryKey:O.lists()}),f({open:!1,group:null})):k.oR.error(e.message||u("Failed to delete group"))}catch(e){k.oR.error(e?.message||u("Failed to delete group"))}finally{v(!1)}}};return t=w?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center gap-2 py-12 text-center",children:[(0,s.jsx)(x.A,{className:"text-muted-foreground h-6 w-6 animate-spin"}),(0,s.jsx)("p",{className:"text-muted-foreground text-sm",children:u("Fetching prefill groups...")})]}):0===F.length?(0,s.jsxs)(eL.Sv,{className:"border border-dashed py-10",children:[(0,s.jsx)(eL.Kr,{variant:"icon",children:(0,s.jsx)(te.A,{className:"h-6 w-6"})}),(0,s.jsxs)(eL.FT,{children:[(0,s.jsx)(eL.cz,{children:u("No prefill groups yet")}),(0,s.jsx)(eL.Ou,{children:u("Create your first group to reuse model, tag, or endpoint selections anywhere in the dashboard.")})]}),(0,s.jsx)(eL.Ou,{children:u("Prefill groups help you keep complex configurations in sync.")})]}):g?(0,s.jsx)("div",{className:"space-y-3",children:F.map(e=>{let{group:t,meta:a,parsedItems:l}=e;return(0,s.jsxs)(tl.Zp,{className:"border-border/60",children:[(0,s.jsxs)(tl.aR,{className:"flex flex-row items-start justify-between gap-4",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)(tl.ZB,{className:"flex flex-wrap items-center gap-2",children:[t.name,(0,s.jsxs)(et.Wh,{variant:a.badge,size:"sm",copyable:!1,children:[a.label,(0,s.jsx)("span",{className:"text-muted-foreground/30",children:"·"}),(0,s.jsxs)("span",{className:"text-muted-foreground font-mono",children:["#",t.id]})]})]}),t.description?(0,s.jsx)(tl.BT,{className:"line-clamp-2",children:t.description}):(0,s.jsx)(tl.BT,{className:"text-muted-foreground italic",children:"No description provided"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)(m.$,{size:"icon",variant:"outline",onClick:()=>c(t),children:[(0,s.jsx)(Z.A,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"sr-only",children:u("Edit group")})]}),(0,s.jsxs)(m.$,{size:"icon",variant:"ghost",className:"text-destructive hover:text-destructive",onClick:()=>I(t),children:[(0,s.jsx)(X.A,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"sr-only",children:u("Delete group")})]})]})]}),(0,s.jsxs)(tl.Wu,{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"text-muted-foreground flex flex-wrap items-center gap-2 text-xs font-medium tracking-wide uppercase",children:[(0,s.jsx)("span",{children:"Items"}),(0,s.jsx)(et.Wh,{label:`${l.length} item${1===l.length?"":"s"}`,variant:"neutral",size:"sm",copyable:!1})]}),l.length>0?(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[l.slice(0,6).map(e=>(0,s.jsx)(et.Wh,{label:e,autoColor:e,size:"sm"},e)),l.length>6&&(0,s.jsx)(et.Wh,{label:`+${l.length-6} more`,variant:"neutral",size:"sm",copyable:!1})]}):(0,s.jsx)("p",{className:"text-muted-foreground text-sm",children:"endpoint"===t.type?"No endpoint mappings configured.":"No items configured yet."})]})]},t.id)})}):(0,s.jsx)(ta.h,{tableClassName:"min-w-[680px]",data:F,getRowKey:e=>{let{group:t}=e;return t.id},columns:[{id:"group",header:u("Group"),cellClassName:"align-top whitespace-normal",cell:e=>{let{group:t}=e;return(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"font-medium",children:t.name}),(0,s.jsx)(ea.C,{value:t.id})]}),t.description?(0,s.jsx)("p",{className:"text-muted-foreground text-xs",children:t.description}):(0,s.jsx)("p",{className:"text-muted-foreground text-xs italic",children:"No description provided"})]})}},{id:"type",header:u("Type"),cellClassName:"align-top",cell:e=>{let{meta:t}=e;return(0,s.jsx)(et.Wh,{label:t.label,variant:t.badge,size:"sm",copyable:!1})}},{id:"items",header:u("Items"),className:"min-w-[240px]",cellClassName:"align-top whitespace-normal",cell:e=>{let{group:t,parsedItems:a}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:a.length>0?(0,s.jsxs)(s.Fragment,{children:[a.slice(0,6).map(e=>(0,s.jsx)(et.Wh,{label:e,autoColor:e,size:"sm"},e)),a.length>6&&(0,s.jsx)(et.Wh,{label:`+${a.length-6} more`,variant:"neutral",size:"sm",copyable:!1})]}):(0,s.jsx)("p",{className:"text-muted-foreground text-sm",children:"endpoint"===t.type?"No endpoint mappings configured.":"No items configured yet."})}),(0,s.jsxs)("div",{className:"text-muted-foreground mt-2 text-xs font-medium tracking-wide uppercase",children:[a.length," item",1===a.length?"":"s"]})]})}},{id:"actions",header:u("Actions"),className:"text-right",cellClassName:"align-top",cell:e=>{let{group:t}=e;return(0,s.jsx)(ts._,{editLabel:u("Edit group"),deleteLabel:u("Delete group"),menuLabel:u("Open menu"),onEdit:()=>c(t),onDelete:()=>I(t)})}}]}),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(en.l,{open:a,onOpenChange:n,title:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(te.A,{className:"text-foreground
2/80 h-5 w-5"}),u("Prefill Group Management")]}),description:u("Create reusable bundles of models, tags, endpoints, and user groups to speed up configuration elsewhere in the console."),contentClassName:(0,_.cn)("w-[calc(100vw-2rem)] sm:max-w-[52rem]",g&&"max-w-none rounded-none"),titleClassName:"flex flex-wrap items-center gap-2 text-lg",descriptionClassName:"text-sm leading-relaxed",contentHeight:"auto",bodyClassName:(0,_.cn)("space-y-3",g&&"pb-[calc(env(safe-area-inset-bottom,0px)+1rem)]"),children:[(0,s.jsxs)("div",{className:"bg-muted/30 flex flex-wrap items-center justify-between gap-3 rounded-md border p-2 text-sm",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsxs)(m.$,{size:"sm",onClick:r,children:[(0,s.jsx)(i.A,{className:"mr-2 h-4 w-4"}),u("New Group")]}),(0,s.jsxs)(m.$,{size:"sm",variant:"ghost",onClick:()=>A(),disabled:C,children:[C?(0,s.jsx)(x.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(eN.A,{className:"mr-2 h-4 w-4"}),u("Refresh")]})]}),(0,s.jsx)(et.Wh,{label:`${M.length} group${1===M.length?"":"s"}`,variant:"neutral",copyable:!1})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[R&&(0,s.jsxs)(N.Fc,{variant:"destructive",children:[(0,s.jsx)(N.XL,{children:u("Unable to load groups")}),(0,s.jsx)(N.TN,{children:R.message||"Please retry or refresh the page."})]}),t]})]}),(0,s.jsx)(tt.T,{open:j.open,onOpenChange:e=>f({open:e,group:null}),title:u("Delete group"),desc:(0,s.jsx)("p",{children:u('Are you sure you want to delete group "{{name}}"? This action cannot be undone.',{name:j.group?.name??""})}),destructive:!0,confirmText:y?u("Deleting..."):u("Delete"),isLoading:y,handleConfirm:E})]})}function tr(e){let{open:t,onOpenChange:a}=e,[l,n]=(0,o.useState)("dialog"),[r,i]=(0,o.useState)(null);(0,o.useEffect)(()=>{t||(n("dialog"),i(null))},[t]);let d=e=>{i(e),n("drawer")};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tn,{open:t&&"dialog"===l,onOpenChange:e=>{e||(n("dialog"),i(null),a(!1))},onCreateGroup:()=>d(null),onEditGroup:e=>d(e)}),(0,s.jsx)(e9,{open:t&&"drawer"===l,onClose:()=>{n("dialog"),i(null)},currentGroup:r})]})}var ti=a(54622),to=a(11728),td=a(67085);function tc(e){let{open:t,onOpenChange:a}=e,{t:n}=(0,d.Bd)(),r=(0,l.jE)(),{setOpen:i,setUpstreamConflicts:c,setSyncWizardOptions:u,syncWizardOptions:p}=eG(),g=(0,eU.a)(),[j,f]=(0,o.useState)("zh"),[y,v]=(0,o.useState)("official"),[b,N]=(0,o.useState)(!1),w=[{label:n("Official Repository"),value:"official",description:n("Sync from the public upstream metadata repository."),disabled:!1},{label:n("Configuration File"),value:"config",description:n("Upload or reference a local configuration file."),disabled:!0}],C=[{label:n("Chinese"),value:"zh"},{label:n("English"),value:"en"},{label:n("Japanese"),value:"ja"}];(0,o.useEffect)(()=>{if(t){f(p.locale||"zh");let e=w.find(e=>e.value===p.source);v(e&&!e.disabled?e.value:"official")}},[t,p,w]);let S=async()=>{N(!0);try{u({locale:j,source:y});let e=await (0,h.$v)({locale:j,source:y});if(!e.success)throw Error(e.message||"Failed to preview upstream diff");let t=e.data?.conflicts||[];if(t.length>0){k.oR.warning(`Found ${t.length} conflict${t.length>1?"s":""}. Please resolve them first.`),c(t),i("upstream-conflict");return}let s=await (0,h.ZZ)({locale:j,source:y});if(s.success){let{created_models:e,created_vendors:t,updated_models:l}=s.data||{};k.oR.success(`Sync completed! Created ${e||0} models, updated ${l||0}, and added ${t||0} vendors.`),r.invalidateQueries({queryKey:I.lists()}),r.invalidateQueries({queryKey:E.lists()}),a(!1)}else k.oR.error(s.message||"Sync failed")}catch(e){k.oR.error(e?.message||"Sync failed")}finally{N(!1)}};return(0,s.jsxs)(en.l,{open:t,onOpenChange:a,title:n("Sync Upstream Models"),description:n("Synchronize models and vendors from an upstream source"),initialFocus:!g,contentHeight:"auto",bodyClassName:"flex flex-col gap-6",footer:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(m.$,{variant:"outline",onClick:()=>a(!1),disabled:b,children:n("Cancel")}),(0,s.jsxs)(m.$,{onClick:S,disabled:b,children:[b&&(0,s.jsx)(x.A,{className:"mr-2 h-4 w-4 animate-spin"}),(0,s.jsx)(ti.A,{className:"mr-2 h-4 w-4"}),n(b?"Syncing...":"Sync Now")]})]}),children:[(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(to.J,{className:"text-base",children:n("Select Sync Source")}),(0,s.jsx)("p",{className:"text-muted-foreground text-sm",children:n("Choose where to fetch upstream metadata.")})]}),(0,s.jsx)(td.z,{value:y,onValueChange:e=>{let t=w.find(t=>t.value===e);t&&!t.disabled&&v(t.value)},className:"grid gap-3 md:grid-cols-2",children:w.map(e=>{let t=y===e.value,a=e.disabled;return(0,s.jsx)(to.J,{htmlFor:`sync-source-${e.value}`,className:(0,_.cn)("flex-col items-start gap-0 rounded-lg border p-4 font-normal transition-all",t&&"border-primary ring-primary ring-1",a?"cursor-not-allowed opacity-60":"hover:border-primary/60 cursor-pointer"),children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)(td.C,{value:e.value,id:`sync-source-${e.value}`,disabled:a}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"font-medium",children:e.label}),"official"===e.value&&(0,s.jsx)(et.Wh,{label:"Default",variant:"neutral",copyable:!1})]}),(0,s.jsx)("p",{className:"text-muted-foreground text-sm",children:e.description})]})]})},e.value)})})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(to.J,{className:"text-base",children:n("Select Language")}),(0,s.jsx)(td.z,{value:j,onValueChange:e=>f(e),className:"grid gap-3 sm:grid-cols-3",children:C.map(e=>(0,s.jsxs)("div",{className:"flex items-center space-x-2 rounded-lg border p-3",children:[(0,s.jsx)(td.C,{value:e.value,id:`locale-${e.value}`}),(0,s.jsx)(to.J,{htmlFor:`locale-${e.value}`,className:"cursor-pointer font-normal",children:e.label})]},e.value))})]}),(0,s.jsx)("div",{className:"bg-muted/50 rounded-lg border p-4",children:(0,s.jsx)("p",{className:"text-muted-foreground text-sm",children:n("The sync will fetch missing models and vendors from the selected source. Existing records are updated only when you approve conflicts.")})})]})}let tm=(0,v.A)("mouse-pointer-click",[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.
2074z",key:"s0h3yz"}]]);var tu=a(82655),th=a(74501);let tx={description:"Description",icon:"Icon",tags:"Tags",vendor:"Vendor",name_rule:"Name Rule",status:"Status",endpoints:"Endpoints",quota_types:"Quota Types",enable_groups:"Enable Groups"},tp=[5,10,20,50],tg=e=>{if(null==e)return"—";if("string"==typeof e)return e||"—";if("number"==typeof e||"boolean"==typeof e)return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}};function tj(e){let{value:t}=e;return(0,s.jsx)("pre",{className:"bg-muted/70 text-muted-foreground max-h-32 overflow-auto rounded-md border px-2 py-1.5 font-mono text-xs break-words whitespace-pre-wrap",children:tg(t)})}function tf(e){let{open:t,onOpenChange:a}=e,{t:n}=(0,d.Bd)(),r=(0,l.jE)(),{upstreamConflicts:i=[],setUpstreamConflicts:c,syncWizardOptions:u}=eG(),x=(0,eU.a)(),[p,g]=(0,o.useState)(""),[j,f]=(0,o.useState)(!1),[y,v]=(0,o.useState)({}),[b,N]=(0,o.useState)(10),[_,w]=(0,o.useState)(0);(0,o.useEffect)(()=>{t&&(v({}),g(""),w(0))},[t,i]);let C=(0,o.useMemo)(()=>i.flatMap(e=>e.fields?.length?e.fields.map(t=>({id:`${e.model_name}-${t.field}`,modelName:e.model_name,fieldKey:t.field,fieldLabel:tx[t.field]||t.field,localValue:t.local,upstreamValue:t.upstream})):[]),[i]),S=i.length,A=C.length,M=p.trim().toLowerCase(),{matchingModelNames:z,visibleRowIds:F}=(0,o.useMemo)(()=>{if(!M)return{matchingModelNames:null,visibleRowIds:null};let e=new Set;i.forEach(t=>{t.model_name?.toLowerCase().includes(M)?e.add(t.model_name):t.fields?.some(e=>(tx[e.field]||e.field).toLowerCase().includes(M)||e.field.toLowerCase().includes(M))&&e.add(t.model_name)});let t=new Set;
2return C.forEach(a=>{(e.has(a.modelName)||a.fieldLabel.toLowerCase().includes(M)||a.fieldKey.toLowerCase().includes(M))&&t.add(a.id)}),{matchingModelNames:e,visibleRowIds:t}},[M,i,C]),O=(0,o.useMemo)(()=>{let e={accessorKey:"modelName",header:"Model",cell:e=>{let{row:t}=e;return(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[x?(0,s.jsx)(tu.S,{checked:t.getIsSelected(),onCheckedChange:e=>t.toggleSelected(!!e),"aria-label":"Select row"}):null,(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("p",{className:"leading-none font-medium",children:t.original.modelName}),(0,s.jsx)("span",{className:"text-muted-foreground font-mono text-xs",children:t.original.fieldKey}),x?(0,s.jsx)(et.Wh,{label:t.original.fieldLabel,variant:"neutral",size:"sm",copyable:!1}):null]})]})},size:220};return x?[e,{id:"actions",header:"Diff",enableSorting:!1,enableHiding:!1,cell:e=>{let{row:t}=e;return(0,s.jsxs)(th.AM,{children:[(0,s.jsxs)(th.Wv,{render:(0,s.jsx)(m.$,{variant:"ghost",size:"sm",className:x?"h-7 w-7 p-0":"h-7 gap-2 px-2 text-xs"}),children:[(0,s.jsx)(tm,{className:"h-3.5 w-3.5"}),!x&&"View diff"]}),(0,s.jsxs)(th.hl,{className:"w-[min(90vw,24rem)] space-y-4 text-sm",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(et.Wh,{label:"Local",variant:"neutral",size:"sm",copyable:!1,className:"mb-1"}),(0,s.jsx)("pre",{className:"bg-muted rounded-md p-2 text-xs",children:tg(t.original.localValue)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(et.Wh,{label:"Upstream",variant:"info",size:"sm",copyable:!1,className:"mb-1"}),(0,s.jsx)("pre",{className:"bg-muted rounded-md p-2 text-xs",children:tg(t.original.upstreamValue)})]})]})]})},size:x?50:140}]:[{id:"select",header:e=>{let{table:t}=e;return(0,s.jsx)(tu.S,{checked:t.getIsAllPageRowsSelected(),indeterminate:t.getIsSomePageRowsSelected(),onCheckedChange:e=>t.toggleAllPageRowsSelected(!!e),"aria-label":"Select all"})},cell:e=>{let{row:t}=e;return(0,s.jsx)(tu.S,{checked:t.getIsSelected(),onCheckedChange:e=>t.toggleSelected(!!e),"aria-label":"Select row"})},enableSorting:!1,enableHiding:!1,size:40},e,{accessorKey:"fieldLabel",header:"Field",cell:e=>{let{row:t}=e;return(0,s.jsx)(et.Wh,{label:t.original.fieldLabel,variant:"neutral",size:"sm",copyable:!1})},enableSorting:!1,size:160},{accessorKey:"localValue",header:"Local Value",cell:e=>{let{row:t}=e;return(0,s.jsx)(tj,{value:t.original.localValue})}},{accessorKey:"upstreamValue",header:"Upstream Value",cell:e=>{let{row:t}=e;return(0,s.jsx)(tj,{value:t.original.upstreamValue})}}]},[x]),{table:$}=(0,R.uI)({data:C,columns:O,rowSelection:y,enableRowSelection:!0,onRowSelectionChange:v,getRowId:e=>e.id,withFilteredRowModel:!1,withPaginationRowModel:!1,withSortedRowModel:!1,withFacetedRowModel:!1}),q=$.getSelectedRowModel().rows.length,B=q>0,V=$.getRowModel().rows,D=F?V.filter(e=>F.has(e.id)):V,K=D.length,P=0===K?1:Math.ceil(K/b);(0,o.useEffect)(()=>{w(e=>Math.min(e,Math.max(0,P-1)))},[P]);let J=_*b,T=D.slice(J,J+b),Y=0===K?0:J+1,L=0===K?0:Math.min(J+b,K),U=0===K?0:_+1,W=0===K?0:P,G=z?.size??S,Q=A>0,Z=Q&&0===K,X=(0,o.useCallback)(()=>{v({})},[]),ee=async()=>{let e=Object.entries($.getSelectedRowModel().rows.reduce((e,t)=>{let a=t.original.modelName;return e[a]||(e[a]=new Set),e[a].add(t.original.fieldKey),e},{})).map(e=>{let[t,a]=e;return{model_name:t,fields:Array.from(a)}}).filter(e=>e.fields.length>0);if(0===e.length)return void k.oR.warning(n("Select at least one field to overwrite."));f(!0);try{let t=await (0,h.RT)({overwrite:e,locale:u.locale,source:u.source});t.success?(k.oR.success(n("Selected conflicts were overwritten successfully.")),r.invalidateQueries({queryKey:I.lists()}),r.invalidateQueries({queryKey:E.lists()}),c([]),a(!1)):k.oR.error(t.message||n("Failed to apply overwrite."))}catch(e){k.oR.error(e?.message||n("Failed to apply overwrite."))}finally{f(!1)}};return(0,s.jsx)(en.l,{open:t,onOpenChange:e=>{e||c([]),a(e)},title:n("Resolve Conflicts"),description:n("Select the fields you want to overwrite with upstream data. Unselected fields keep their local values."),contentClassName:"w-full sm:max-w-5xl",contentHeight:"min(72vh, 720px)",bodyClassName:"flex flex-col gap-4",initialFocus:!x,footerClassName:"sm:justify-between",footer
2:(0,s.jsxs)("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{className:"text-muted-foreground flex flex-1 items-start gap-2 text-xs",children:[(0,s.jsx)(H.A,{className:"h-4 w-4 flex-shrink-0"}),(0,s.jsx)("span",{children:n("Only selected fields will be overwritten. You can re-run the sync wizard if new conflicts appear.")})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:justify-end",children:[(0,s.jsx)(m.$,{variant:"outline",onClick:()=>{c([]),a(!1)},children:n("Cancel")}),(0,s.jsx)(m.$,{onClick:ee,disabled:j||!B,children:j?n("Applying..."):n("Apply Overwrite")})]})]}),children:(0,s.jsx)("div",{className:"flex min-h-0 flex-1 flex-col gap-4",children:Q?(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsxs)("div",{className:"text-sm font-medium",children:[G," ",n("model"),1===G?"":"s"," ",n("with conflicts")]}),(0,s.jsxs)("div",{className:"text-muted-foreground text-xs",children:[K," ",n("field"),1===K?"":"s"," ",n("showing •")," ",q," ",n("selected")]})]}),(0,s.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row",children:[(0,s.jsxs)("div",{className:"relative flex-1",children:[(0,s.jsx)(eJ.A,{className:"text-muted-foreground pointer-events-none absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2"}),(0,s.jsx)(er.p,{value:p,onChange:e=>{g(e.target.value),w(0)},placeholder:n("Search models or fields..."),className:"pl-9","aria-label":n("Search conflicting models or fields")})]}),(0,s.jsx)(m.$,{variant:"ghost",size:"sm",onClick:X,disabled:!B,children:n("Clear selection")})]})]}),Z?(0,s.jsx)("div",{className:"text-muted-foreground flex flex-1 items-center justify-center rounded-md border border-dashed p-8 text-center text-sm",children:n("No conflicts match your search.")}):(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-md border",children:[(0,s.jsx)("div",{className:"flex-1 overflow-auto",children:(0,s.jsx)(R.Oz,{table:$,rows:T,containerClassName:"border-0",tableContainerClassName:x?"min-w-full":"min-w-[720px]"})}),(0,s.jsxs)("div",{className:"bg-muted/40 flex flex-col gap-2 border-t px-2 py-1.5 text-sm sm:flex-row sm:items-center sm:justify-between sm:gap-3 sm:px-3 sm:py-2",children:[(0,s.jsxs)("div",{className:"text-muted-foreground text-xs",children:[n("Showing")," ",Y,"-",L," ",n("of")," ",K," ",n("field"),1===K?"":"s"]}),(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2 sm:flex-wrap sm:gap-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-xs sm:gap-2",children:[(0,s.jsx)("span",{className:"hidden sm:inline",children:n("Rows per page")}),(0,s.jsxs)(eR.l6,{items:tp.map(e=>({value:String(e),label:e})),value:String(b),onValueChange:e=>{N(Number(e)),w(0)},children:[(0,s.jsx)(eR.bq,{className:"h-8 w-[70px] text-xs sm:h-8 sm:w-[72px]",children:(0,s.jsx)(eR.yv,{})}),(0,s.jsx)(eR.gC,{alignItemWithTrigger:!1,children:(0,s.jsx)(eR.s3,{children:tp.map(e=>(0,s.jsx)(eR.eb,{value:String(e),children:e},e))})})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)(m.$,{variant:"outline",size:"icon",className:"h-7 w-7 sm:h-8 sm:w-8",onClick:()=>w(e=>Math.max(0,e-1)),disabled:0===_,"aria-label":n("Previous page"),children:(0,s.jsx)(eT.A,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"})}),(0,s.jsx)("span",{className:"text-xs font-medium",children:n("Page {{current}} of {{total}}",{current:U,total:W})}),(0,s.jsx)(m.$,{variant:"outline",size:"icon",className:"h-7 w-7 sm:h-8 sm:w-8",onClick:()=>w(e=>Math.min(P-1,e+1)),disabled:_>=P-1||0===K,"aria-label":n("Next page"),children:(0,s.jsx)(eY.A,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"})})]})]})]})]})]}):(0,s.jsx)("div",{className:"text-muted-foreground flex flex-1 items-center justify-center rounded-md border border-dashed p-8 text-center text-sm",children:n("No conflict entries available.")})})})}
2let ty="vendor-mutate-form";function tv(e){let{open:t,onOpenChange:a,currentVendor:n}=e,{t:r}=(0,d.Bd)(),i=(0,l.jE)(),c=!!n?.id,[u,p]=(0,o.useState)(!1),g=(0,eu.mN)({resolver:(0,em.u)(e4),defaultValues:{name:"",description:"",icon:"",status:1}});(0,o.useEffect)(()=>{t&&c&&n?g.reset({id:n.id,name:n.name,description:n.description||"",icon:n.icon||"",status:n.status||1}):t&&!c&&g.reset({name:"",description:"",icon:"",status:1})},[t,c,n,g]);let j=async e=>{p(!0);try{let t=c?await (0,h._d)({...e,id:n.id}):await (0,h.zC)(e);t.success?(k.oR.success(c?"Vendor updated successfully":"Vendor created successfully"),i.invalidateQueries({queryKey:E.lists()}),i.invalidateQueries({queryKey:I.lists()}),a(!1)):k.oR.error(t.message||"Operation failed")}catch(e){k.oR.error(e?.message||"Operation failed")}finally{p(!1)}};return(0,s.jsx)(en.l,{open:t,onOpenChange:a,title:c?r("Edit Vendor"):r("Create Vendor"),description:c?r("Update vendor information for {{name}}",{name:n?.name}):r("Add a new vendor to the system"),contentHeight:"auto",bodyClassName:"space-y-4",footer:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(m.$,{type:"button",variant:"outline",onClick:()=>a(!1),disabled:u,children:r("Cancel")}),(0,s.jsxs)(m.$,{type:"submit",form:ty,disabled:u,children:[u?(0,s.jsx)(x.A,{className:"mr-2 h-4 w-4 animate-spin"}):null,u?r("Saving..."):c?r("Update"):r("Create")]})]}),children:(0,s.jsx)(eg.lV,{...g,children:(0,s.jsxs)("form",{id:ty,onSubmit:g.handleSubmit(j),className:"space-y-4",children:[(0,s.jsx)(eg.zB,{control:g.control,name:"name",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Vendor Name *")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{placeholder:r("OpenAI, Anthropic, etc."),...t})}),(0,s.jsx)(eg.Rr,{children:r("The unique name for this vendor")}),(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsx)(eg.zB,{control:g.control,name:"description",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Description")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(e2.T,{placeholder:r("Describe this vendor..."),rows:3,...t})}),(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsx)(eg.zB,{control:g.control,name:"icon",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Icon")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{placeholder:r("OpenAI, Anthropic, Google, etc."),...t})}),(0,s.jsx)(eg.Rr,{children:r("@lobehub/icons key name")}),(0,s.jsx)(eg.C5,{})]})}})]})})})}var tb=a(37116),tN=a(13581),t_=a(47182),tw=a(31852),tC=a(24518);let tS=V.Ik({id:V.ai().optional(),model_name:V.Yj().min(1,"Model name is required"),description:V.Yj(),icon:V.Yj(),tags:V.YO(V.Yj()),vendor_id:V.ai().optional(),endpoints:V.Yj(),name_rule:V.ai(),status:V.zM(),sync_official:V.zM(),price:V.Yj().optional(),ratio:V.Yj().optional(),cacheRatio:V.Yj().optional(),completionRatio:V.Yj().optional(),imageRatio:V.Yj().optional(),audioRatio:V.Yj().optional(),audioCompletionRatio:V.Yj().optional()}),tk={price:"",ratio:"",cacheRatio:"",completionRatio:"",imageRatio:"",audioRatio:"",audioCompletionRatio:""},tR={mode:"per-token",fields:tk,promptPrice:"",completionPrice:"",advancedOpen:!1};function tA(e,t){return(0,tC.jD)(e,{fallback:{},silent:!0})[t]}function tM(e,t){if(!e||!t)return tR;let a=tA(e.ModelPrice,t),s=tA(e.ModelRatio,t),l=tA(e.CacheRatio,t),n=tA(e.CompletionRatio,t),r=tA(e.ImageRatio,t),i=tA(e.AudioRatio,t),o=tA(e.AudioCompletionRatio,t);if(null!=a)return{...tR,mode:"per-request",fields:{...tk,price:a.toString()}};let d="",c="";if(null!=s){let e=2*s;d=e.toString(),null!=n&&(c=(e*n).toString())}return{mode:"per-token",fields:{price:"",ratio:s?.toString()||"",cacheRatio:l?.toString()||"",completionRatio:n?.toString()||"",imageRatio:r?.toString()||"",audioRatio:i?.toString()||"",audioCompletionRatio:o?.toString()||""},promptPrice:d,completionPrice:c,advancedOpen:[l,r,i,o].some(e=>null!=e)}}function tz(e){let{open:t,onOpenChange:a,currentRow:n}=e,{t:r}=(0,d.Bd)(),i=(0,l.jE)(),c=n?.id,u=!!c,[p,g]=(0,o.useState)(!1),[j,f]=(0,o.useState)("per-token"),[y,v]=(0,o.useState)("ratio"),[b,N]=(0,o.useState)(!1),[_,w]=(0,o.useState)(""),[C,R]=(0,o.useState)(""),[A,M]=(0,o.useState)(""),[z,O]=(0,o.useState)(""),$=(0,o.useRef)(null),{data:q}=(0,S.I)({queryKey:E.list(),queryFn:()=>(0,h.YQ)({page_size:1e3}),enabled:t}),V=q?.data?.items||[],{data:D}=(0,S.I)({queryKey:I.detail(c||0),queryFn:()=>
2{if(!c)throw Error("Model ID is required");return(0,h.E1)(c)},enabled:t&&u}),{data:K}=(0,tN.b)(),P=(0,t_.M)(),J=(0,o.useMemo)(()=>K?.data?(0,tN.n)(K.data,{"global.pass_through_request_enabled":!1,"global.thinking_model_blacklist":"[]","global.chat_completions_to_responses_policy":"{}","general_setting.ping_interval_enabled":!1,"general_setting.ping_interval_seconds":60,"gemini.safety_settings":"","gemini.version_settings":"","gemini.supported_imagine_models":"","gemini.thinking_adapter_enabled":!1,"gemini.thinking_adapter_budget_tokens_percentage":.6,"gemini.function_call_thought_signature_enabled":!1,"gemini.remove_function_response_id_enabled":!0,"claude.model_headers_settings":"","claude.default_max_tokens":"","claude.thinking_adapter_enabled":!0,"claude.thinking_adapter_budget_tokens_percentage":.8,ModelPrice:"",ModelRatio:"",CacheRatio:"",CompletionRatio:"",ImageRatio:"",AudioRatio:"",AudioCompletionRatio:"",ExposeRatioEnabled:!1,"billing_setting.billing_mode":"{}","billing_setting.billing_expr":"{}","tool_price_setting.prices":"{}",TopupGroupRatio:"",GroupRatio:"",UserUsableGroups:"",GroupGroupRatio:"",AutoGroups:"",MaxTokenAutoGroups:5,DefaultUseAutoGroup:!1,CreateCacheRatio:"","group_ratio_setting.group_special_usable_group":"{}","grok.violation_deduction_enabled":!1,"grok.violation_deduction_amount":0,RetryTimes:0,ChannelDisableThreshold:"",AutomaticDisableChannelEnabled:!1,AutomaticEnableChannelEnabled:!1,AutomaticDisableKeywords:"",AutomaticDisableStatusCodes:"401",AutomaticRetryStatusCodes:"100-199,300-399,401-407,409-499,500-503,505-523,525-599","monitor_setting.auto_test_channel_enabled":!1,"monitor_setting.auto_test_channel_minutes":10,"monitor_setting.channel_test_mode":"scheduled_all","channel_affinity_setting.enabled":!1,"channel_affinity_setting.switch_on_success":!0,"channel_affinity_setting.keep_on_channel_disabled":!1,"channel_affinity_setting.max_entries":1e5,"channel_affinity_setting.default_ttl_seconds":3600,"channel_affinity_setting.rules":"[]","model_deployment.ionet.api_key":"","model_deployment.ionet.enabled":!1}):null,[K]),T=null!==J;(0,o.useEffect)(()=>{$.current=J});let Y=(0,eu.mN)({resolver:(0,em.u)(tS),defaultValues:{model_name:"",description:"",icon:"",tags:[],vendor_id:void 0,endpoints:"",name_rule:0,status:!0,sync_official:!0,price:"",ratio:"",cacheRatio:"",completionRatio:"",imageRatio:"",audioRatio:"",audioCompletionRatio:""}}),L=e=>""===e||!Number.isNaN(Number.parseFloat(e));(0,o.useEffect)(()=>{if(t&&u&&D?.data){let e=D.data;M(e.model_name);let t=tM($.current,e.model_name);O(e.model_name),f(t.mode),w(t.promptPrice),R(t.completionPrice),N(t.advancedOpen),Y.reset({id:e.id,model_name:e.model_name,description:e.description||"",icon:e.icon||"",tags:B(e.tags),vendor_id:e.vendor_id,endpoints:e.endpoints||"",name_rule:e.name_rule||0,status:1===e.status,sync_official:1===e.sync_official,...t.fields})}else if(t&&!u){let e=n?.model_name||"",t=tM($.current,e);M(""),O(e),v("ratio"),f(t.mode),w(t.promptPrice),R(t.completionPrice),N(t.advancedOpen),Y.reset({model_name:e,description:"",icon:"",tags:[],vendor_id:void 0,endpoints:"",name_rule:0,status:!0,sync_official:!0,...t.fields})}},[t,u,D,n,Y,T]);let U=(0,o.useCallback)(async e=>{g(!0);try{let{price:t,ratio:s,cacheRatio:l,completionRatio:n,imageRatio:r,audioRatio:o,audioCompletionRatio:d,...m}={...e,id:u?c:void 0,tags:Array.isArray(e.tags)?e.tags.join(","):"",status:+!!e.status,sync_official:+!!e.sync_official},x=u&&c?await (0,h.Q5)({...m,id:c}):await (0,h.kQ)(m);if(x.success){let t=e.model_name,s="per-request"===j&&e.price&&""!==e.price||"per-token"===j&&(e.ratio||e.cacheRatio||e.completionRatio||e.imageRatio||e.audioRatio||e.audioCompletionRatio);if(J){let a=(0,tC.jD)(J.ModelPrice,{fallback:{},silent:!0}),l=(0,tC.jD)(J.ModelRatio,{fallback:{},silent:!0}),n=(0,tC.jD)(J.CacheRatio,{fallback:{},silent:!0}),r=(0,tC.jD)(J.CompletionRatio,{fallback:{},silent:!0}),i=(0,tC.jD)(J.ImageRatio,{fallback:{},silent:!0}),o=(0,tC.jD)(J.AudioRatio,{fallback:{},silent:!0}),d=(0,tC.jD)(J.AudioCompletionRatio,{fallback:{},silent:!0});u&&A&&A!==t&&(delete a[A],delete l[A],delete n[A],delete r[A],delete i[A],delete o[A],delete d[A]),(s||t===z)&&(
2delete a[t],delete l[t],delete n[t],delete r[t],delete i[t],delete o[t],delete d[t]),s&&("per-request"===j&&e.price&&""!==e.price?a[t]=Number.parseFloat(e.price):"per-token"===j&&(e.ratio&&""!==e.ratio&&(l[t]=Number.parseFloat(e.ratio)),e.cacheRatio&&""!==e.cacheRatio&&(n[t]=Number.parseFloat(e.cacheRatio)),e.completionRatio&&""!==e.completionRatio&&(r[t]=Number.parseFloat(e.completionRatio)),e.imageRatio&&""!==e.imageRatio&&(i[t]=Number.parseFloat(e.imageRatio)),e.audioRatio&&""!==e.audioRatio&&(o[t]=Number.parseFloat(e.audioRatio)),e.audioCompletionRatio&&""!==e.audioCompletionRatio&&(d[t]=Number.parseFloat(e.audioCompletionRatio))));let c=[],m=(0,tw.Nr)(JSON.stringify(a));m!==(0,tw.Nr)(J.ModelPrice)&&c.push({key:"ModelPrice",value:m});let h=(0,tw.Nr)(JSON.stringify(l));h!==(0,tw.Nr)(J.ModelRatio)&&c.push({key:"ModelRatio",value:h});let x=(0,tw.Nr)(JSON.stringify(n));x!==(0,tw.Nr)(J.CacheRatio)&&c.push({key:"CacheRatio",value:x});let p=(0,tw.Nr)(JSON.stringify(r));p!==(0,tw.Nr)(J.CompletionRatio)&&c.push({key:"CompletionRatio",value:p});let g=(0,tw.Nr)(JSON.stringify(i));g!==(0,tw.Nr)(J.ImageRatio)&&c.push({key:"ImageRatio",value:g});let f=(0,tw.Nr)(JSON.stringify(o));f!==(0,tw.Nr)(J.AudioRatio)&&c.push({key:"AudioRatio",value:f});let y=(0,tw.Nr)(JSON.stringify(d));for(let e of(y!==(0,tw.Nr)(J.AudioCompletionRatio)&&c.push({key:"AudioCompletionRatio",value:y}),c))await P.mutateAsync(e)}k.oR.success(u?"Model updated successfully":"Model created successfully"),i.invalidateQueries({queryKey:I.lists()}),i.invalidateQueries({queryKey:["system-options"]}),a(!1)}else k.oR.error(x.message||"Operation failed")}catch(e){k.oR.error(e?.message||"Operation failed")}finally{g(!1)}},[u,c,i,a,j,A,z,J,P]);return(0,s.jsx)(e$.cj,{open:t,onOpenChange:a,children:(0,s.jsxs)(e$.h,{className:(0,eE.jW)("sm:max-w-2xl"),children:[(0,s.jsxs)(e$.Fm,{className:(0,eE.Dt)(),children:[(0,s.jsx)(e$.qp,{children:u?r("Edit Model"):r("Create Model")}),(0,s.jsx)(e$.Qs,{children:u?r("Update model configuration and click save when you're done."):r("Add a new model to the system by providing the necessary information.")})]}),(0,s.jsx)(eg.lV,{...Y,children:(0,s.jsxs)("form",{id:"model-form",onSubmit:Y.handleSubmit(U),className:(0,eE.e)(),children:[(0,s.jsxs)(eE.y5,{children:[(0,s.jsx)("h3",{className:"text-sm font-semibold",children:r("Basic Information")}),(0,s.jsx)(eg.zB,{control:Y.control,name:"model_name",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Model Name *")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{placeholder:r("gpt-4, claude-3-opus, etc."),...t})}),(0,s.jsx)(eg.Rr,{children:r("The unique identifier for this model")}),(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsx)(eg.zB,{control:Y.control,name:"description",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Description")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(e2.T,{placeholder:r("Describe this model..."),rows:3,...t})}),(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsx)(eg.zB,{control:Y.control,name:"icon",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Icon")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{placeholder:r("OpenAI, Anthropic, etc."),...t})}),(0,s.jsx)(eg.Rr,{className:"text-xs",children:r("@lobehub/icons key")}),(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsx)(eg.zB,{control:Y.control,name:"vendor_id",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Vendor")}),(0,s.jsxs)(eR.l6,{items:V.map(e=>({value:String(e.id),label:e.name})),onValueChange:e=>t.onChange(e?Number.parseInt(e):void 0),value:t.value?String(t.value):void 0,children:[(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(eR.bq,{children:(0,s.jsx)(eR.yv,{placeholder:r("Select vendor")})})}),(0,s.jsx)(eR.gC,{alignItemWithTrigger:!1,children:(0,s.jsx)(eR.s3,{children:V.map(e=>(0,s.jsx)(eR.eb,{value:String(e.id),children:e.name},e.id))})})]}),(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsx)(eg.zB,{control:Y.control,name:"tags",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Tags")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(e1,{value:t.value||[],onChange:t.onChange,placeholder:r("Add tags...")})}),(0,s.jsx)(eg.Rr,{children:r("Press Enter or comma to add tags")}),(0,s.jsx)(eg.C5,{})]})}})]}),(0,s.jsxs)(eE.y5,{children:[(0,s.jsx)("h3",{className:"text-sm font-semibold",children:r("Matching Rules")}),(0,s.jsx)(eg.zB,{control:Y.control,name:"name_rule",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Name Rule")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(td.z,{onValueChange:e=>t.onChange(Number.parseInt(e)),value:String(t.value),className:"grid grid-cols-2 gap-4",children:[{label:r("Exact Match"),value:0},{label:r("Prefix Match"),value:1},{label:r("Contains Match"),value:2},{label:r("Suffix Match"),value:3}].map(e=>(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)(td.C,{value:String(e.value),id:`rule-${e.value}`}),(0,s.jsx)(to.J,{htmlFor:`rule-${e.value}`,className:"cursor-pointer font-normal",children:e.label})]},e.value))})}),(0,s.jsx)(eg.Rr,{children:r("How this model name should match requests")}),(0,s.jsx)(eg.C5,{})]})}})]}),(0,s.jsxs)(eE.y5,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold",children:r("Endpoints")}),(0,s.jsxs)(eR.l6,{items:Object.keys(F).map(e=>({value:e,label:e})),onValueChange:e=>null!==e&&(e=>{let t=F[e];if(t){let a=JSON.stringify({[e]:t},null,2);Y.setValue("endpoints",a)}})(e),children:[(0,s.jsx)(eR.bq,{size:"sm",className:"w-[200px]",children:(0,s.jsx)(eR.yv,{placeholder:r("Load template...")})}),(0,s.jsx)(eR.gC,{alignItemWithTrigger:!1,children:(0,s.jsx)(eR.s3,{children:Object.keys(F).map(e=>(0,s.jsx)(eR.eb,{value:e,children:e},e))})})]})]}),(0,s.jsx)(eg.zB,{control:Y.control,name:"endpoints",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Endpoint Configuration")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(eZ.i,{value:t.value||"",onChange:t.onChange,keyPlaceholder:"endpoint_type",valuePlaceholder:'{"path": "/v1/...", "method": "POST"}',keyLabel:"Endpoint Type",valueLabel:"Configuration",valueType:"any",emptyMessage:r("No endpoints configured. Switch to JSON mode or add rows to define endpoints.")})}),(0,s.jsx)(eg.Rr,{children:r("Define API endpoints for this model (JSON format)")}),(0,s.jsx)(eg.C5,{})]})}})]}),(0,s.jsxs)(eE.y5,{children:[(0,s.jsx)("h3",{className:"text-sm font-semibold",children:r("Pricing Configuration")}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)(to.J,{children:r("Pricing mode")}),(0,s.jsxs)(td.z,{value:j,onValueChange:e=>f(e),children:[(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)(td.C,{value:"per-token",id:"per-token"}),(0,s.jsx)(to.J,{htmlFor:"per-token",className:"font-normal",children:r("Per-token (ratio based)")})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)(td.C,{value:"per-request",id:"per-request"}),(0,s.jsx)(to.J,{htmlFor:"per-request",className:"font-normal",children:r("Per-request (fixed price)")})]})]})]}),"per-request"===j?(0,s.jsx)(eg.zB,{control:Y.control,name:"price",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Fixed price (USD)")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{type:"text",placeholder:"0.01",...t,onChange:e=>{let a=e.target.value;L(a)&&t.onChange(a)}})}),(0,s.jsx)(eg.Rr,{children:r("Cost in USD per request, regardless of tokens used.")}),(0,s.jsx)(eg.C5,{})]})}}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)(to.J,{children:r("Input mode")}),(0,s.jsxs)(td.z,{value:y,onValueChange:e=>v(e),children:[(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)(td.C,{value:"ratio",id:"ratio"}),(0,s.jsx)(to.J,{htmlFor:"ratio",className:"font-normal",children:r("Ratio mode")})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)(td.C,{value:"price",id:"price"}),(0,s.jsx)(to.J,{htmlFor:"price",className:"font-normal",children:r("Price mode (USD per 1M tokens)")})]})]})]}),"ratio"===y?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eg.zB,{control:Y.control,name:"ratio",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Model ratio")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{type:"text",placeholder:"1.0",...t,onChange:e=>{let a=e.target.value;L(a)&&(t.onChange(a),a?w((2*Number.parseFloat(a)).toString()):w(""))}})}),(0,s.jsx)(eg.Rr,{children:t.value&&!Number.isNaN(Number.parseFloat(t.value))?`Calculated price: $${(2*Number.parseFloat(t.value)).toFixed(4)} per 1M tokens`:r("Multiplier for prompt tokens.")}),(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsx)(eg.zB,{control:Y.control,name:"completionRatio",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Completion ratio")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{type:"text",placeholder:"1.0",...t,onChange:e=>{let a=e.target.value;
2if(L(a)){t.onChange(a);let e=Y.getValues("ratio");a&&e?R((2*Number.parseFloat(e)*Number.parseFloat(a)).toString()):R("")}}})}),(0,s.jsx)(eg.Rr,{children:t.value&&!Number.isNaN(Number.parseFloat(t.value))&&_&&!Number.isNaN(Number.parseFloat(_))?`Calculated price: $${(Number.parseFloat(_)*Number.parseFloat(t.value)).toFixed(4)} per 1M tokens`:r("Multiplier for completion tokens.")}),(0,s.jsx)(eg.C5,{})]})}})]}):(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(to.J,{children:r("Prompt price ($/1M tokens)")}),(0,s.jsx)(er.p,{type:"text",placeholder:"2.0",value:_,onChange:e=>(e=>{if(w(e),e&&!Number.isNaN(Number.parseFloat(e))){let t=Number.parseFloat(e)/2;Y.setValue("ratio",t.toString())}else Y.setValue("ratio","")})(e.target.value)}),(0,s.jsx)("p",{className:"text-muted-foreground text-sm",children:_&&!Number.isNaN(Number.parseFloat(_))?`Calculated ratio: ${(Number.parseFloat(_)/2).toFixed(4)}`:r("Enter Input price to calculate ratio")})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(to.J,{children:r("Completion price ($/1M tokens)")}),(0,s.jsx)(er.p,{type:"text",placeholder:"4.0",value:C,onChange:e=>(e=>{if(R(e),e&&!Number.isNaN(Number.parseFloat(e))&&_&&!Number.isNaN(Number.parseFloat(_))&&Number.parseFloat(_)>0){let t=Number.parseFloat(e)/Number.parseFloat(_);Y.setValue("completionRatio",t.toString())}else Y.setValue("completionRatio","")})(e.target.value)}),(0,s.jsx)("p",{className:"text-muted-foreground text-sm",children:C&&!Number.isNaN(Number.parseFloat(C))&&_&&!Number.isNaN(Number.parseFloat(_))&&Number.parseFloat(_)>0?`Calculated ratio: ${(Number.parseFloat(C)/Number.parseFloat(_)).toFixed(4)}`:r("Enter Completion price to calculate ratio")})]})]}),(0,s.jsxs)(ep.Nt,{open:b,onOpenChange:N,children:[(0,s.jsxs)(ep.R6,{render:(0,s.jsx)(m.$,{type:"button",variant:"outline",className:"flex w-full items-center justify-between"}),children:[r("Advanced options"),(0,s.jsx)(tb.A,{className:`h-4 w-4 transition-transform duration-200 ${b?"rotate-180":""}`})]}),(0,s.jsxs)(ep.Ke,{className:"flex flex-col gap-4 pt-4",children:[(0,s.jsx)(eg.zB,{control:Y.control,name:"cacheRatio",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Cache ratio")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{type:"text",placeholder:"0.1",...t,onChange:e=>{let a=e.target.value;L(a)&&t.onChange(a)}})}),(0,s.jsx)(eg.Rr,{children:r("Discount ratio for cache hits.")}),(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsx)(eg.zB,{control:Y.control,name:"imageRatio",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Image ratio")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{type:"text",placeholder:"1.0",...t,onChange:e=>{let a=e.target.value;L(a)&&t.onChange(a)}})}),(0,s.jsx)(eg.Rr,{children:r("Multiplier for image processing.")}),(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsx)(eg.zB,{control:Y.control,name:"audioRatio",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Audio ratio")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{type:"text",placeholder:"1.0",...t,onChange:e=>{let a=e.target.value;L(a)&&t.onChange(a)}})}),(0,s.jsx)(eg.Rr,{children:r("Multiplier for audio inputs.")}),(0,s.jsx)(eg.C5,{})]})}}),(0,s.jsx)(eg.zB,{control:Y.control,name:"audioCompletionRatio",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{children:[(0,s.jsx)(eg.lR,{children:r("Audio completion ratio")}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(er.p,{type:"text",placeholder:"1.0",...t,onChange:e=>{let a=e.target.value;L(a)&&t.onChange(a)}})}),(0,s.jsx)(eg.Rr,{children:r("Multiplier for audio outputs.")}),(0,s.jsx)(eg.C5,{})]})}})]})]})]})]}),(0,s.jsxs)(eE.y5,{children:[(0,s.jsx)("h3",{className:"text-sm font-semibold",children:r("Status & Sync")}),(0,s.jsx)(eg.zB,{control:Y.control,name:"status",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{className:(0,eE.fE)(),children:[(0,s.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,s.jsx)(eg.lR,{className:"text-base",children:r("Enabled")}),(0,s.jsx)(eg.Rr,{children:r("Enable or disable this model")})]}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(eA.d,{checked:t.value,onCheckedChange:t.onChange})})]})}}),(0,s.jsx)(eg.zB,{control:Y.control,name:"sync_official",render:e=>{let{field:t}=e;return(0,s.jsxs)(eg.eI,{className:(0,eE.fE)(),children:[(0,s.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,s.jsx)(eg.lR,{className:"text-base",children:r("Official Sync")}),(0,s.jsx)(eg.Rr,{children:r("Sync this model with official upstream")})]}),(0,s.jsx)(eg.MJ,{children:(0,s.jsx)(eA.d,{checked:t.value,onCheckedChange:t.onChange})})]})}})]})]})}),(0,s.jsxs)(e$.XW,{className:(0,eE.Jx)(),children:[(0,s.jsx)(e$.kN,{render:(0,s.jsx)(m.$,{variant:"outline",disabled:p}),children:r("Cancel")}),(0,s.jsxs)(m.$,{form:"model-form",type:"submit",disabled:p,children:[p&&(0,s.jsx)(x.A,{className:"mr-2 h-4 w-4 animate-spin"}),u?r("Update Model"):r("Save changes")]})]})]})})}function tF(){let{open:e,setOpen:t,currentRow:a,currentVendor:l,descriptionData:n,setDescriptionData:r}=eG();return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tz,{open:"create-model"===e||"update-model"===e,onOpenChange:e=>!e&&t(null),currentRow:a}),(0,s.jsx)(tv,{open:"create-vendor"===e||"update-vendor"===e,onOpenChange:e=>!e&&t(null),currentVendor:"update-vendor"===e?l:null}),(0,s.jsx)(eQ,{open:"missing-models"===e,onOpenChange:e=>!e&&t(null)}),(0,s.jsx)(tc,{open:"sync-wizard"===e,onOpenChange:e=>!e&&t(null)}),(0,s.jsx)(tf,{open:"upstream-conflict"===e,onOpenChange:e=>!e&&t(null)}),(0,s.jsx)(tr,{open:"prefill-groups"===e,onOpenChange:e=>!e&&t(null)}),(0,s.jsx)(eP,{open:"description"===e,onOpenChange:e=>{e||(t(null),r(null))},modelName:n?.modelName||"",description:n?.description||""})]})}var tI=a(50947);let tE=(0,v.A)("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]);var tO=a(18727);function t$(){let{t:e}=(0,d.Bd)(),{setOpen:t,setCurrentRow:a}=eG();return(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)(m.$,{onClick:()=>{a(null),t("create-model")},size:"sm",children:[(0,s.jsx)(i.A,{className:"h-4 w-4"}),e("Add Model")]}),(0,s.jsxs)(es.rI,{children:[(0,s.jsx)(es.ty,{render:(0,s.jsx)(m.$,{variant:"outline",size:"sm"}),children:(0,s.jsx)(tI.A,{className:"h-4 w-4"})}),(0,s.jsxs)(es.SQ,{align:"end",className:"w-56",children:[(0,s.jsxs)(es._2,{onClick:()=>{t("missing-models")},children:[e("Missing Models"),(0,s.jsx)(es.V0,{children:(0,s.jsx)(f.A,{className:"h-4 w-4"})})]}),(0,s.jsxs)(es._2,{onClick:()=>{t("sync-wizard")},children:[e("Sync Upstream"),(0,s.jsx)(es.V0,{children:(0,s.jsx)(ti.A,{className:"h-4 w-4"})})]}),(0,s.jsx)(es.mB,{}),(0,s.jsxs)(es._2,{onClick:()=>{t("prefill-groups")},children:[e("Prefill Groups"),(0,s.jsx)(es.V0,{children:(0,s.jsx)(tE,{className:"h-4 w-4"})})]}),(0,s.jsxs)(es._2,{onClick:()=>{t("create-vendor")},children:[e("Manage Vendors"),(0,s.jsx)(es.V0,{children:(0,s.jsx)(tO.A,{className:"h-4 w-4"})})]})]})]})]})}var tq=a(36001),tB=a(6201),tV=a(47303),tD=a(11768);function tK(e){let{table:t}=e,{t:a}=(0,d.Bd)(),n=(0,l.jE)(),[r,i]=(0,o.useState)(!1),c=t.getFilteredSelectedRowModel().rows,u=c.reduce((e,t)=>
2{let a=t.original.id;return"number"==typeof a&&e.push(a),e},[]),h=c.map(e=>e.original),x=()=>{t.resetRowSelection()},p=async()=>{let e=h.map(e=>e.model_name).join(",");await (0,tD.l)(e)?k.oR.success(a("Model names copied to clipboard")):k.oR.error(a("Failed to copy model names"))};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(R.Of,{table:t,entityName:"model",children:[(0,s.jsxs)(tV.m_,{children:[(0,s.jsxs)(tV.k$,{render:(0,s.jsx)(m.$,{variant:"outline",size:"icon",onClick:()=>{L(u,n,x)},className:"size-8","aria-label":a("Enable selected models"),title:a("Enable selected models")}),children:[(0,s.jsx)(tq.A,{}),(0,s.jsx)("span",{className:"sr-only",children:a("Enable selected models")})]}),(0,s.jsx)(tV.ZI,{children:(0,s.jsx)("p",{children:a("Enable selected models")})})]}),(0,s.jsxs)(tV.m_,{children:[(0,s.jsxs)(tV.k$,{render:(0,s.jsx)(m.$,{variant:"outline",size:"icon",onClick:()=>{U(u,n,x)},className:"size-8","aria-label":a("Disable selected models"),title:a("Disable selected models")}),children:[(0,s.jsx)(tB.A,{}),(0,s.jsx)("span",{className:"sr-only",children:a("Disable selected models")})]}),(0,s.jsx)(tV.ZI,{children:(0,s.jsx)("p",{children:a("Disable selected models")})})]}),(0,s.jsxs)(tV.m_,{children:[(0,s.jsxs)(tV.k$,{render:(0,s.jsx)(m.$,{variant:"outline",size:"icon",onClick:p,className:"size-8","aria-label":a("Copy model names"),title:a("Copy model names")}),children:[(0,s.jsx)(eb.A,{}),(0,s.jsx)("span",{className:"sr-only",children:a("Copy model names")})]}),(0,s.jsx)(tV.ZI,{children:(0,s.jsx)("p",{children:a("Copy model names")})})]}),(0,s.jsxs)(tV.m_,{children:[(0,s.jsxs)(tV.k$,{render:(0,s.jsx)(m.$,{variant:"destructive",size:"icon",onClick:()=>i(!0),className:"size-8","aria-label":a("Delete selected models"),title:a("Delete selected models")}),children:[(0,s.jsx)(X.A,{}),(0,s.jsx)("span",{className:"sr-only",children:a("Delete selected models")})]}),(0,s.jsx)(tV.ZI,{children:(0,s.jsx)("p",{children:a("Delete selected models")})})]})]}),(0,s.jsx)(en.l,{open:r,onOpenChange:i,title:a("Delete Models?"),description:a("Are you sure you want to delete {{count}} model(s)? This action cannot be undone.",{count:u.length}),contentHeight:"auto",footer:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(m.$,{variant:"outline",onClick:()=>i(!1),children:a("Cancel")}),(0,s.jsx)(m.$,{variant:"destructive",onClick:()=>{Y(u,n,()=>{i(!1),x()})},children:a("Delete")})]}),children:" "})]})}var tP=a(98622),tJ=a(74764),tT=a(95327);function tY(e){let{row:t}=e,{t:a}=(0,d.Bd)(),n=t.original,{setOpen:r,setCurrentRow:i}=eG(),c=(0,l.jE)(),[u,h]=(0,o.useState)(!1),x=1===n.status,p=a(x?"Disable":"Enable");return(0,s.jsxs)("div",{className:"-ml-1.5 flex items-center gap-1",children:[(0,s.jsxs)(tV.m_,{children:[(0,s.jsx)(tV.k$,{render:(0,s.jsx)(m.$,{variant:"ghost",size:"icon-sm",onClick:()=>{i(n),r("update-model")},"aria-label":a("Edit")}),children:(0,s.jsx)(Z.A,{})}),(0,s.jsx)(tV.ZI,{children:a("Edit")})]}),(0,s.jsxs)(tV.m_,{children:[(0,s.jsx)(tV.k$,{render:(0,s.jsx)(m.$,{variant:"ghost",size:"icon-sm",onClick:()=>{J(n.id,n.status,c)},"aria-label":p,className:x?"text-destructive hover:text-destructive":"text-success hover:text-success"}),children:x?(0,s.jsx)(tB.A,{}):(0,s.jsx)(tq.A,{})}),(0,s.jsx)(tV.ZI,{children:p})]}),(0,s.jsx)(ee.C,{ariaLabel:a("Open menu"),children:(0,s.jsxs)(es._2,{onSelect:e=>{e.preventDefault(),h(!0)},className:"text-destructive focus:text-destructive",children:[a("Delete"),(0,s.jsx)(es.V0,{children:(0,s.jsx)(X.A,{size:16})})]})}),(0,s.jsx)(tt.T,{open:u,onOpenChange:h,title:a("Delete Model"),desc:a('Are you sure you want to delete model "{{name}}"? This action cannot be undone.',{name:n.model_name}),confirmText:a("Delete"),destructive:!0,handleConfirm:()=>{T(n.id,c),h(!1)}})]})}function tL(e){let{modelName:t,description:a}=e,{setOpen:l,setDescriptionData:n}=eG();return a?(0,s.jsx)("div",{className:"max-w-[150px]",children:(0,s.jsx)(m.$,{variant:"link",onClick:()=>{n({modelName:t,description:a}),l("description")},className:"text-muted-foreground hover:text-foreground block h-auto w-full cursor-pointer overflow-hidden p-0 text-left text-sm text-ellipsis whitespace-nowrap no-underline",children:a})}):(0,s.jsx)("span",{className:"text-muted-foreground text-xs",children:"-"})}let tU=(0,n.GY)("/_authenticated/models/$section");function tW(){let{t:e}=(0,d.Bd)(),{selectedVendor:t}=eG(),a=(0,M.Ub)("(max-width: 640px)"),{globalFilter:l,onGlobalFilterChange:n,columnFilters:r,onColumnFiltersChange:i,pagination:c,onPaginationChange:m,ensurePageInRange:u}
2=(0,z.c)({search:tU.useSearch(),navigate:tU.useNavigate(),pagination:{defaultPage:1,defaultPageSize:a?10:20},globalFilter:{enabled:!0,key:"filter"},columnFilters:[{columnId:"status",searchKey:"status",type:"array"},{columnId:"vendor_id",searchKey:"vendor",type:"array"},{columnId:"sync_official",searchKey:"sync",type:"array"}]}),x=r.find(e=>"status"===e.id)?.value||[],p=r.find(e=>"vendor_id"===e.id)?.value||[],g=r.find(e=>"sync_official"===e.id)?.value||[],{data:j}=(0,S.I)({queryKey:E.list(),queryFn:()=>(0,h.YQ)({page_size:1e3})}),f=(0,o.useMemo)(()=>j?.data?.items||[],[j?.data?.items]),y=(0,o.useMemo)(()=>f.map(e=>({label:e.name,value:String(e.id)})),[f]),v=t||(p.length>0&&!p.includes("all")?p[0]:void 0),b=x.length>0&&!x.includes("all")?x[0]:void 0,N=g.length>0&&!g.includes("all")?g[0]:void 0,_=!!(l?.trim()||v||b||N),{data:w,isLoading:C,isFetching:k}=(0,S.I)({queryKey:I.list({keyword:l,vendor:v,status:b,sync_official:N,p:c.pageIndex+1,page_size:c.pageSize}),queryFn:async()=>_?(0,h.j6)({keyword:l,vendor:v,status:b,sync_official:N,p:c.pageIndex+1,page_size:c.pageSize}):(0,h.zr)({p:c.pageIndex+1,page_size:c.pageSize})}),A=w?.data?.items||[],F=w?.data?.total||0,O=w?.data?.vendor_counts,$=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],{t}=(0,d.Bd)(),a={0:{label:t("Exact"),color:"green",description:t("Match model name exactly")},1:{label:t("Prefix"),color:"blue",description:t("Match models starting with this name")},2:{label:t("Contains"),color:"orange",description:t("Match models containing this name")},3:{label:t("Suffix"),color:"purple",description:t("Match models ending with this name")}},l={1:{label:t("Enabled"),variant:"success"},0:{label:t("Disabled"),variant:"neutral"}},n={0:{label:t("Usage-based"),color:"violet"},1:{label:t("Per-call"),color:"teal"}},r={};return e.forEach(e=>{r[e.id]=e}),[{id:"select",header:e=>{let{table:t}=e;return(0,s.jsx)(tu.S,{checked:t.getIsAllPageRowsSelected(),indeterminate:t.getIsSomePageRowsSelected(),onCheckedChange:e=>t.toggleAllPageRowsSelected(!!e),"aria-label":"Select all"})},cell:e=>{let{row:t}=e;return(0,s.jsx)(tu.S,{checked:t.getIsSelected(),onCheckedChange:e=>t.toggleSelected(!!e),"aria-label":"Select row"})},enableSorting:!1,enableHiding:!1,size:40},{accessorKey:"id",header:t("ID"),meta:{mobileHidden:!0},cell:e=>{let{row:t}=e,a=t.getValue("id");return(0,s.jsx)(ea.C,{value:a})},size:64},{accessorKey:"model_name",header:t("Model Name"),meta:{mobileTitle:!0},cell:e=>{let t,{row:a}=e,l=a.original,n=a.getValue("model_name"),i=(t=(l.icon||r[l.vendor_id||0]?.icon||l.model_name?.[0]||"N").split(".")[0],(0,tT.Y)(`${t}.Avatar.type={'platform'}`,20));return(0,s.jsxs)("div",{className:"flex max-w-full min-w-0 items-center gap-2",children:[(0,s.jsx)("div",{className:"flex size-5 shrink-0 items-center justify-center overflow-hidden",children:i}),(0,s.jsx)(et.Wh,{label:n,variant:"neutral",copyText:n,size:"sm",className:"-ml-1.5 font-mono"})]})},size:260,minSize:200},{accessorKey:"name_rule",header:t("Match Type"),cell:e=>{let{row:t}=e,l=t.getValue("name_rule"),n=t.original,r=a[l],i=r.label;0!==l&&n.matched_count&&(i=`${r.label} (${n.matched_count})`);let o=(0,s.jsx)(et.Wh,{variant:"error"===r.color?"danger":r.color,size:"sm",className:"-ml-1.5 max-w-none shrink-0",children:i});if(0!==l&&n.matched_models&&n.matched_models.length>0){let e=n.matched_models.map(e=>(0,s.jsx)(et.Wh,{label:e,autoColor:e,size:"sm"},e));return(0,s.jsx)(tV.Bc,{children:(0,s.jsxs)(tV.m_,{children:[(0,s.jsx)(tV.k$,{render:(0,s.jsx)("div",{className:"inline-flex max-w-full min-w-0"}),children:o}),(0,s.jsx)(tV.ZI,{side:"top",className:"border-border bg-popover max-h-48 max-w-[320px] overflow-y-auto p-2",children:(0,s.jsx)("div",{className:"flex flex-wrap gap-1",children:e})})]})})}return o},size:100,enableSorting:!1},{accessorKey:"status",header:t("Status"),meta:{mobileBadge:!0},cell:e=>{let{row:t}=e,a=l[t.getValue("status")]||l[0];return(0,s.jsx)(et.Wh,{variant:a.variant,size:"sm",copyable:!1,className:"-ml-1.5 max-w-none shrink-0",children:a.label})},filterFn:(e,t,a)=>{if(!a||0===a.length||a.includes("all"))return!0;let s=e.getValue(t);return a.includes("enabled")?1===s:!!a.includes("disabled")&&1!==s},size:110,minSize:110,enableSorting:!1},{accessorKey:"vendor_id",header:t("Vendor"),cell:e=>{let{row:t}=e,a=r[t.getValue("vendor_id")];return a?(0,s.jsx)(R.ak,{children:(0,s.jsx)(tJ.d,{iconKey:a.icon,label:a.name})}):(0,s.jsx)("span",{className:"text-muted-foreground text-xs",children:"-"})},filterFn:(e,t,a)=>!!(!a||0===a.length||a.includes("all"))||a.includes(String(e.getValue(t))),size:130,enableSorting:!1},{accessorKey:"description",header:t("Description"),meta:{mobileHidden:!0},cell:e=>{let{row:t}=e,a=t.getValue("description"),l=t.getValue("model_name");return(0,s.jsx)(tL,{modelName:l,description:a})},size:150,enableSorting:!1},{accessorKey:"tags",header:t("Tags"),meta:{mobileHidden:!0},cell:e=>{let{row:t}=e,a=B(t.getValue("tags"));return(0,s.jsx)(R.Yt,{items:a.map(e=>(0,s.jsx)(et.Wh,{label:e,autoColor:e,size:"sm"},e))})},size:100,enableSorting:!1},{accessorKey:"endpoints",header:t("Endpoints"),meta:{mobileHidden:!0},cell:e=>{let t,{row:a}=e,l=(t=function(e){if(!e||""===e.trim())return null;try{return JSON.parse(e)}catch{return null}}(a.getValue("endpoints")))?"object"!=typeof t||Array.isArray(t)?Array.isArray(t)?t.map(String):[]:Object.keys(t):[];return(0,s.jsx)(R.Yt,{max:3,items:l.map(e=>(0,s.jsx)(et.Wh,{label:e,autoColor:e,size:"sm"},e))})},size:200,enableSorting:!1},{accessorKey:"bound_channels",header:t("Bound Channels"),meta:{mobileHidden:!0},cell:e=>{let{row:t}=e,a=t.getValue("bound_channels");return(0,s.jsx)(R.Yt,{items:(a??[]).map(e=>(0,s.jsx)(et.Wh,{label:`${e.name} (${e.type})`,autoColor:e.name,size:"sm"},e.id))})},size:150,enableSorting:!1},{accessorKey:"enable_groups",header:t("Enable Groups"),meta:{mobileHidden:!0},cell:e=>{let{row:t}=e,a=t.getValue("enable_groups");return(0,s.jsx)(R.Yt,{max:3,items:(a??[]).map(e=>(0,s.jsx)(tP.d,{group:e,size:"sm"},e))})},size:200,enableSorting:!1},{accessorKey:"quota_types",header:t("Quota Types"),meta:{mobileHidden:!0},cell:e=>{let{row:t}=e,a=t.getValue("quota_types");return(0,s.jsx)(R.Yt,{items:(a??[]).map(e=>{let t=n[e];return(0,s.jsx)(et.Wh,{label:t?.label||String(e),variant:t?.color==="error"?"danger":t?.color,size:"sm"},e)})})},size:150,enableSorting:!1},{accessorKey:"sync_official",header:t("Official Sync"),meta:{mobileHidden:!0},cell:e=>{let{row:a}=e,l=a.getValue("sync_official");return(0,s.jsx)(et.Wh,{variant:1===l?"success":"warning",size:"sm",copyable:!1,className:"-ml-1.5 max-w-none shrink-0",children:1===l?t("Official Sync"):t("No Sync")})},filterFn:(e,t,a)=>{if(!a||0===a.length||a.includes("all"))return!0;let s=e.getValue(t);return a.includes("yes")?1===s:!!a.includes("no")&&1!==s},size:100,enableSorting:!1},{accessorKey:"created_time",header:t("Created"),meta:{mobileHidden:!0},cell:e=>{let{row:t}=e,a=t.getValue("created_time");return(0,s.jsx)("div",{className:"font-mono text-sm whitespace-nowrap",children:(0,q.fk)(a)})},size:140},{accessorKey:"updated_time",header:t("Updated"),meta:{mobileHidden:!0},cell:e=>{let{row:t}=e,a=t.getValue("updated_time");return(0,s.jsx)("div",{className:"font-mono text-sm whitespace-nowrap",children:(0,q.fk)(a)})},size:140},{id:"actions",header:()=>t("Actions"),cell:e=>{let{row:t}=e;return(0,s.jsx)(tY,{row:t})},enableSorting:!1,enableHiding:!1,meta:{pinned:"right"}}]}(f),{table:V}=(0,R.uI)({data:A,columns:$,totalCount:F,initialColumnVisibility:{description:!1,bound_channels:!1,quota_types:!1},columnFilters:r,pagination:c,globalFilter:l,enableRowSelection:!0,onColumnFiltersChange:i,onPaginationChange:m,onGlobalFilterChange:n,manualPagination:!0,manualFiltering:!0,ensurePageInRange:u}),D=[{label:`${e("All Vendors")}${O?.all?` (${O.all})`:""}`,value:"all"},...y.map(e=>({label:`${e.label}${O?.[e.value]?` (${O[e.value]})`:""}`,value:e.value}))];return(0,s.jsx)(R.cx,{table:V,columns:$,isLoading:C,isFetching:k,emptyTitle:e("No Models Found"),empty
2Description:e("No models available. Create your first model to get started."),skeletonKeyPrefix:"model-skeleton",applyHeaderSize:!0,toolbarProps:{searchPlaceholder:e("Filter by model name..."),filters:[{columnId:"status",title:e("Status"),options:[{label:e("All Status"),value:"all"},{label:e("Enabled"),value:"enabled"},{label:e("Disabled"),value:"disabled"}],singleSelect:!0},{columnId:"vendor_id",title:e("Vendor"),options:D,singleSelect:!0},{columnId:"sync_official",title:e("Official Sync"),options:[{label:e("All Sync Status"),value:"all"},{label:e("Official Sync"),value:"yes"},{label:e("No Sync"),value:"no"}],singleSelect:!0}]},bulkActions:(0,s.jsx)(tK,{table:V})})}let tH=null;function tG(e){tH={ok:e,timestamp:Date.now()}}var tQ=a(87558);let tZ=(0,n.GY)("/_authenticated/models/$section"),tX={metadata:{titleKey:"Metadata"},deployments:{titleKey:"Deployments"}};function t0(){let{t:e}=(0,d.Bd)(),t=(0,r.Z)(),{tabCategory:a,setTabCategory:l}=eG(),n=tZ.useParams().section??tQ.Fi,[h,x]=(0,o.useState)(!1);(0,o.useEffect)(()=>{a!==n&&l(n)},[n,l,a]);let p=(0,o.useCallback)(e=>{t({to:"/models/$section",params:{section:e}})},[t]),g=tX[n]??tX.metadata;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(c.Ni,{fixedContent:!0,children:[(0,s.jsx)(c.Ni.Title,{children:e(g.titleKey)}),(0,s.jsx)(c.Ni.Actions,{children:"metadata"===n?(0,s.jsx)(t$,{}):(0,s.jsxs)(m.$,{onClick:()=>x(!0),size:"sm",children:[(0,s.jsx)(i.A,{className:"h-4 w-4"}),e("Create deployment")]})}),(0,s.jsx)(c.Ni.Content,{children:(0,s.jsxs)("div",{className:"flex h-full min-h-0 flex-col gap-4",children:[(0,s.jsx)(u.tU,{value:n,onValueChange:p,children:(0,s.jsx)(u.j7,{className:"max-w-full flex-wrap justify-start group-data-horizontal/tabs:h-auto",children:tQ.ev.map(t=>(0,s.jsx)(u.Xi,{value:t,children:e(tX[t].titleKey)},t))})}),(0,s.jsx)("div",{className:"min-h-0 flex-1",children:"metadata"===n?(0,s.jsx)(tW,{}):(0,s.jsx)(t1,{})})]})})]}),(0,s.jsx)(tF,{}),(0,s.jsx)(eD,{open:h,onOpenChange:x})]})}function t1(){let e=(0,l.jE)(),{loading:t,loadingPhase:a,isIoNetEnabled:n,connectionLoading:r,connectionOk:i,connectionError:d,testConnection:c}=function(){let[e,t]=(0,o.useState)(!0),[a,s]=(0,o.useState)("settings"),[l,n]=(0,o.useState)({"model_deployment.ionet.enabled":!1}),[r,i]=(0,o.useState)({loading:!1,ok:null,error:null}),d=(0,o.useRef)(!0),c=(0,o.useCallback)(async function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];t(!0),s("settings");try{let a=await (0,h.BY)(),l=a?.success&&a?.data?.enabled===!0;if(n({"model_deployment.ionet.enabled":l}),!l){i({loading:!1,ok:null,error:null}),s("done"),t(!1);return}if(e){let e=tH?Date.now()-tH.timestamp>3e5?(tH=null,null):tH.ok:null;if(null!==e){i({loading:!1,ok:e,error:null}),s("done"),t(!1);return}}s("connection"),i({loading:!0,ok:null,error:null});try{let e=await (0,h.ck)();if(e?.success)tG(!0),i({loading:!1,ok:!0,error:null});else{let t=e?.message||"Connection failed";tG(!1),i({loading:!1,ok:!1,error:t})}}catch(t){let e=t instanceof Error?t.message:"Connection failed";tG(!1),i({loading:!1,ok:!1,error:e})}}catch{i({loading:!1,ok:null,error:null})}finally{s("done"),t(!1)}},[]);(0,o.useEffect)(()=>{d.current&&(d.current=!1,c(!0))},[c]);let m=!!l["model_deployment.ionet.enabled"],u=(0,o.useCallback)(async()=>{tH=null,i({loading:!0,ok:null,error:null}),s("connection");try{let e=await (0,h.ck)();if(e?.success){tG(!0),i({loading:!1,ok:!0,error:null});return}let t=e?.message||"Connection failed";tG(!1),i({loading:!1,ok:!1,error:t})}catch(t){let e=t instanceof Error?t.message:"Connection failed";tG(!1),i({loading:!1,ok:!1,error:e})}finally{s("done")}},[]),x=(0,o.useCallback)(()=>(tH=null,c(!1)),[c]);return(0,o.useEffect)(()=>{let e=()=>{c(!0)};return window.addEventListener("focus",e),()=>window.removeEventListener("focus",e)},[c]),{loading:e,loadingPhase:a,settings:l,isIoNetEnabled:m,refresh:x,connectionLoading:r.loading,connectionOk:r.ok,connectionError:r.error,testConnection:u}}();return(0,o.useEffect)(()=>{if(n&&"connection"===a){let t={p:1,page_size:10};e.prefetchQuery({queryKey:$.list(t),queryFn:()=>(0,h.Jn)(t),staleTime:3e4})}},[n,a,e]),(0,s.jsx)(C,{loading:t,loadingPhase:a,isEnabled:n,connectionLoading:r,connectionOk:i,connectionError:d,onRetry:c,children:(0,s.jsx)(eF,{})})}let t2=function(){return(0,s.jsx)(eH,{children:(0,s.jsx)(t0,{})})}},25104(e,t,a){a.d(t,{},{A:[["path",{d:"M12.001 5.00003V19.002",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",key:"0"}],["path",{d:"M19.002 12.002L4.99998 12.002",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",key:"1"}]]})},18727(e,t,a){let s=(0,a(9781).A)("building-2",[["path",{d:"M10 12h4",key:"a56b0p"}],["path",{d:"M10 8h4",key:"1sr2af"}
2],["path",{d:"M14 21v-3a2 2 0 0 0-4 0v3",key:"1rgiei"}],["path",{d:"M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2",key:"secmi2"}],["path",{d:"M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16",key:"16ra0t"}]]);a.d(t,{},{A:s})},92702(e,t,a){let s=(0,a(9781).A)("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);a.d(t,{},{A:s})},3501(e,t,a){let s=(0,a(9781).A)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]);a.d(t,{},{A:s})},33834(e,t,a){let s=(0,a(9781).A)("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);a.d(t,{},{A:s})},20468(e,t,a){let s=(0,a(9781).A)("layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]);a.d(t,{},{A:s})},6201(e,t,a){let s=(0,a(9781).A)("power-off",[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);a.d(t,{},{A:s})},36001(e,t,a){let s=(0,a(9781).A)("power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]);a.d(t,{},{A:s})},95227(e,t,a){let s=(0,a(9781).A)("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);a.d(t,{},{A:s})},76336(e,t,a){let s=(0,a(9781).A)("settings-2",[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);a.d(t,{},{A:s})},12798(e,t,a){let s=(0,a(9781).A)("table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]);a.d(t,{},{A:s})},60665(e,t,a){let s=(0,a(9781).A)("timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);a.d(t,{},{A:s})}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.